/posthtml-remove-attributes

PostHTML plugin to remove attributes unconditionally or with content match

Primary LanguageJavaScript

posthtml-remove-attributes

PostHTML plugin to remove attributes unconditionally or with content match

Dependency Status Greenkeeper badge Current version Travis Build Status

Installation

Install the posthtml-remove-attributes:

$ npm install posthtml-remove-attributes --save

Usage

var posthtml = require('posthtml');
var removeAttributes = require('posthtml-remove-attributes');

var html = '<div style="display: inline;" class="wow">OMG</div>';

posthtml([ 
  removeAttributes([  // The only non-array argument is also possible
    'class', // match name
    {name: 'style', value: /inline/} // match name and value
  ])
])
    .process(html)
    .then(function(result) {
        console.log(result);
    });

// Yields:
// <div>OMG</div>

Contribution guidelines

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using npm test.