html5-purifier
v0.8.3
Published
Purify unsafe HTML and CSS into standards compliant and namespaced code.
Downloads
34
Readme
node-html5-purifier
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>