htmlparser2-es6
A minimalist ES6-compatible HTML/XML parser. A callback interface is provided.
Installation
npm install htmlparser2-es6
A live demo of the original htmlparser2 is available here.
Usage
var htmlparser = ;var parser = { ifname === "script" && attribstype === "text/javascript" console; } { console; } { iftagname === "script" console; } decodeEntities: true;parser;parser;
Output (simplified):
--> Xyz
JS! Hooray!
--> var foo = '<<bar>>';
That's it?!
Documentation
Read more about the original htmlparser2 module and its options in the htmlparser2 wiki. Note that this module only provides the Parser
interface.
Performance
After having some artificial benchmarks for some time, @AndreasMadsen published his htmlparser-benchmark
, which benchmarks HTML parses based on real-world websites.
At the time of writing, the latest versions of all supported parsers show the following performance characteristics on Travis CI (please note that Travis doesn't guarantee equal conditions for all tests):
gumbo-parser : 34.9208 ms/file ± 21.4238
html-parser : 24.8224 ms/file ± 15.8703
html5 : 419.597 ms/file ± 264.265
htmlparser : 60.0722 ms/file ± 384.844
htmlparser2-dom: 12.0749 ms/file ± 6.49474
htmlparser2 : 7.49130 ms/file ± 5.74368
hubbub : 30.4980 ms/file ± 16.4682
libxmljs : 14.1338 ms/file ± 18.6541
parse5 : 22.0439 ms/file ± 15.3743
sax : 49.6513 ms/file ± 26.6032