fast-html is a sax-style HTML parser focused on performance. It only copes with sane HTML - see the Things that break section.
npm install --save fast-htmlTest-documentation generated with mocha's "doc" reporter.
varfastHtml=require('fast-html')({parseAttributes: true});// Receive start tagsfastHtml.on('start',function(tagName,attributes){});// Receive text nodesfastHtml.on('data',function(text){});// Receive end tagsfastHtml.on('end',function(tagName)){});// Release the houndsfastHtml.parse('<ul id="list"><li>Hello World</li></ul>')FastHTML is designed for maximum performance, therefore it will not
- Try to fix broken markup
- Try to fix slightly broken markup
- Try to do automagic closing stuff
- Be graceful about unescaped HTML strings in inline
script,styleand HTML attributes
</script>strings in inlinescript- Use<![CDATA[...]]>.- HTML strings in attributes - Escape them.