parse5-based library for converting JsonML to HTML.
npm install html-to-jsonmlA simple parse5-based library for converting HTML text to
JsonML. Developed for Webstrates, but can be
used for anything JsonML-related.
This replaces the htmlparser2-basedjsonml-parse module we previously used, because of
its issues parsing tags with <. For instance, htmlparser2 would turn
``html`
Into
`json`
["script","var x, y, z = x ","< y;"]
Whereas this library gives you
`json`
["script",{},"var x, y, z = x < y;"]
With more complicated script code, this gets even worse with jsonml-parse, resulting in odd and
complicated objects, rather than plain text as it should be.
To be fair to jsonml-parse, this is not an issue with the module itself, but with the thehtmlparser2
underlying .
Additionally, it's worth noting that html-to-jsonml (at the time of writing) takes up 459 KB: 29jsonml-parse
KB of which is this library itself, and 430 KB on parse5. In comparison, uses a
total 2.6 MB.
Very brief and initial testing shows that jsonmlParse appears to be slightly faster thanhtml-to-jsonml`, though.