html5-purifier

0.8.3 • Public • Published

node-html5-purifier

Code Climate

Purify dirty HTML and CSS into standards compliant and namespaced code.

Cleans up any input into standards compliant DOM safe code, both CSS and HTML5.

Can pass in prefix and postfix values for namespacing all elements, id's and classes within the html.

purifier.purify(html, options, cb);

Examples

Sanitize unsafe HTML

    var purifier = require('html5-purifier');
    var html = '<b onmouseover=alert('boo!')>click me!</b>';
    var options = {};
    purifier.purify(html, options, cb);

Returns:

<b>click me!</b>

Prefix and Postfix css classes

    var purifier = require('html5-purifier');
    var html = 'hello<span>world</a>';
    var options = { prefix: 'abc-', postfix: 'abc' };
    purifier.purify(html, options, cb);

Returns:

hello<span class="abc">world</span>

Package Sidebar

Install

npm i html5-purifier

Weekly Downloads

20

Version

0.8.3

License

MIT

Last publish

Collaborators

  • ahammel
  • deepwell
  • inssein
  • saem
  • stage3
  • tajinder_lamba