strip-attributes

0.2.0 • Public • Published

strip-attributes NPM version NPM monthly downloads NPM total downloads Linux Build Status

Strip attributes from HTML tags.

Install

Install with npm:

$ npm install --save strip-attributes

Usage

Pass a string of HTML to stripAttr():

var stripAttr = require('strip-attributes');
var str = '<h1 id="a" class="b">Foo</h1>';
 
// By default, all attributes are omitted
stripAttr(str);
//=> '<h1>Foo</h1>'

Omit specific attributes

Pass an array of specific attributes to omit to options.omit:

stripAttr(str, {omit: ['class']});
//=> '<h1 id="a" >Foo</h1>'

Keep specific attributes

Pass an array of specific attributes to keep to options.keep:

stripAttr(str, {keep: ['class']});
//=> '<h1 class="b">Foo</h1>'

About

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Building docs

(This document was generated by verb-generate-readme (a verb generator), please don't edit the readme directly. Any changes to the readme must be made in .verb.md.)

To generate the readme and API documentation with verb:

$ npm install -g verb verb-generate-readme && verb

Running tests

Install dev dependencies:

$ npm install -d && npm test

Author

Jon Schlinkert

License

Copyright © 2017, Jon Schlinkert. Released under the MIT license.


This file was generated by verb-generate-readme, v0.2.3, on January 04, 2017.

Package Sidebar

Install

npm i strip-attributes

Weekly Downloads

111

Version

0.2.0

License

MIT

Last publish

Collaborators

  • doowb
  • jonschlinkert