posthtml-remove-tags
Version:
A posthtml plugin for removing tags
83 lines (59 loc) • 3.69 kB
Markdown
# <a href="https://github.com/posthtml/posthtml"><img valign="text-bottom" height="49" title="PostHTML logo" src="http://posthtml.github.io/posthtml/logo.svg"></a> remove tags
> A [posthtml](https://github.com/posthtml) A posthtml plugin for removing tags
[](https://travis-ci.org/GitScrum/posthtml-remove-tags)[](https://ci.appveyor.com/project/GitScrum/posthtml-remove-tags)[]()[](https://www.npmjs.com/package/posthtml-remove-tags)[](https://david-dm.org/gitscrum/posthtml-remove-tags)[](https://github.com/sindresorhus/xo)[](https://coveralls.io/r/GitScrum/posthtml-remove-tags)
[](https://www.npmjs.com/package/posthtml-remove-tags)[](https://www.npmjs.com/package/posthtml-remove-tags)[](http://packagequality.com/#?package=posthtml-remove-tags)
## Why?
Essential for removing unwanted or tags do not pass validation
## Install
```bash
npm i -S posthtml posthtml-remove-tags
```
> **Note:** This project is compatible with node v4+
## Usage
```js
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
```html
<!DOCTYPE html>
<head><style></style></head>
```
#### output.html
```html
<!DOCTYPE html>
<head></head>
```
## Options
#### `tags`
Type: `Array`
Default: `[]`
Description: *The list of tags to be deleted*
## LICENSE
> MIT License (MIT)
> Copyright (c) Ivan Demidov <scrum@list.ru>
> Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
> The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.