3 ms·
Browser from Scratch: HTML Parsing
- tannhaeuser 3y agoWHATWG's procedural HTML parsing spec sucks big time indeed. Ian Hickson, as the original author, once derived it from how SGML parses HTML, with empty elements and inferring omitted end-tags when encountering block-level markup within span-level markup and all, modulo the commenting oddities introduced to stop browsers rendering CSS and JS as content, and also handling attribute short forms. Once precisely capturing SGML, the spec wasn't updated consistently as new elements were introduced, precisely because of its presentation as explicit redundant enumeration of elements forcing certain others to close or open seemingly at random. I have absolutely no idea how one can be motivated to implement HTML parsing from WHATWG's description, or how one can seriously see it as an improvement over SGML.
- ttfkam 3y ago> I have absolutely no idea how one can be motivated to implement HTML parsing from WHATWG's description To be compatible with every other browser and HTML parser on the planet? Yes, it's quirky. That's what happens when you have a Wild West of HTML for over a decade between Netscape and Internet Explorer. HTML5 is the embodiment of "perfect is the enemy of good". Parsing as you think it should be done would put you at odds with the reality of how HTML is used.