For anyone interested, things are close, they just need to be glued:
In guile, (htmlprag) addresses the import[1]. It handles "weird html". The SXML modules[2] can handle encoding and rendering. CDATA is the only thing (that seems to be) missing. I'll have to look into that.
Someone also made a module to render html[3].
[1]http://www.nongnu.org/guile-lib/doc/ref/htmlprag/
[2]https://www.gnu.org/software/guile/manual/guile.html#SXML
[3]https://dthompson.us/rendering-html-with-sxml-and-gnu-guile....
> Not rocket science of course
And it depends on whether you're parsing or rendering. Rendering is much easier than parsing. But even parsing is nonetheless a solved problem :-)
Last time I looked <textarea> and <pre> also worked kind of like <script>.
- Standalone, non-closed tags <!doctype>, <hr>, <br>, <link>, <meta>, <img> etc.
- Proper encoding or quoting of [< > " ' &] in html attributes
- <script> tags and CDATA
Probably lots more as well. Not rocket science of course, but you would want a tool where you have some confidence they've covered all of these things.