Anybody else think that if your markup language requires a 10k line parser, somebody took a wrong turn at the complexity vs simplicity fork in the road?
Anybody else think that if your markup language requires a 10k line parser, somebody took a wrong turn at the complexity vs simplicity fork in the road?
All browsers that implement the HTML5 parsing algorithm
should parse HTML the same way, which means your web page
should parse the same way in Firefox 4 and the WebKit
nightly, even if it contains invalid markup.
Parsing perfect HTML5 would be easy, but one of the features of HTML5 spec is that it does that no spec did before: it defines how parsing should work exactly, even in the case of invalid markup. Also, the parser hast to deal with deprecated elements no longer in the spec (such as infamous <font>). I assums most work went into this "how to parse tag soup" part.It would have been very easy to drop all the back compat bs by saying "An HTML5 document is one that begins with the 6 bytes '<html5' and if the document is invalid, reject it. Anything else, parse however you want." Browsers that support HTML5 add text/html5 to the Accept header.
You'd still need to support HTML4 somewhere. Supporting HTML5 separately just means duplicating the common parts of the parser. The simplicity boat has already sailed.
HTML4 + HTML5 < HTML4 * HTML5Browsers are going to have a complex, ugly, recovery-enabled parser in them either way, and the effort to add HTML5 to the recovery-enabled parser isn't very big, comparatively speaking.
If you allow people to leave comments on your page or if you are serving ads, you lose a bit of control in what gets put on a particular page of yours.
In case of comments you could try and sanitize them, but with ads that's hardly possible.
The basic idea may be simple, but by the time you have covered a reasonable fraction of real-world use cases and error conditions for a sizeable population, the resulting code is anything but.
And 10k lines still counts as "moderately simple" - 10k lines is well within scope for one developer working alone.
Just imagine how large "quirks mode" must be.
I spent a few hours looking into Ragel over the weekend, and, honestly, I can't envisage how a html5 parser mostly written in Ragel would look. But I'm going to give it a crack.
When I consider what I can accomplish using C vs what I can accomplish using HTML, that doesn't appear to be the expected result.
It's fairly easy to get a simpler implementation by shifting complexity from the parser to the user. But from a "total society productivity" standpoint, having a handful of developers spend a few months to implement a resilient parser is a cheap price to pay to have umpteen million people save hours of debugging for every page they create.
It would have been better for everyone if HTML had used a bog-simple Lisp-like format from day one, but without a time machine we’re stuck with these kludges of history.
HTML5 does, and most of the spec (and probably the parser) is about dealing with error cases.
Plus it's not like XML parsers are small. And HTML parsing is far more complex an affair (due to not just blowing up on error)
http://dig.csail.mit.edu/breadcrumbs/node/166
Now HTML5 has to deal with two parsers.