Package Exports
- striptags
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (striptags) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
striptags
An implementation of PHP's strip_tags in Node.js.
striptags(html, allowedTags);Installing
npm install striptagsUsage
var striptags = require('striptags');
var html = '<html><a href="#meow" class="default">hello world</a><button disabled> I am the walrus</button></html>';
striptags(html);
striptags(html, '<a><button>');Output:
'hello world I am the walrus'<a href="meow" class="default">hello world</a><button disabled=""> I am the walrus</button>Differences between PHP strip_tags and striptags
striptags.js uses a full-bodied HTML parser (htmlparser2) to determine and remove tags from a string, whereas strip_tags uses "the same tag stripping state machine as the fgetss() function."
Because striptags.js uses an actual parser, this should avoid the pitfalls of using a Regular Expression against HTML (see here).