A posthtml A posthtml plugin for removing tags
Why?
Essential for removing unwanted or tags do not pass validation
Install
npm i -S posthtml posthtml-remove-tags
Note: This project is compatible with node v4+
Usage
import {readFileSync, writeFileSync} from 'fs'; import posthtml from 'posthtml'; import removeTags from 'posthtml-remove-tags'; const html = readFileSync('input.html', 'utf8'); posthtml() .use(removeTags({tags: ['style', 'script']})) .process(html) .then(result => { writeFileSync('output.html', result.html); });
Returns the html without the tags listed in option
Example
input.html
<!DOCTYPE html> <head><style></style></head>
output.html
<!DOCTYPE html> <head></head>
Options
tags
Type: Array
Default: []
Description: The list of tags to be deleted