[whatwg] Comment Syntax and Parsing
ian at hixie.ch
Sun Jan 22 19:23:26 PST 2006
On Sun, 22 Jan 2006, Lachlan Hunt wrote:
> Firstly, Ian, could you please clarify what exactly made you change your
> mind about this issue, after seven years of pushing (mostly) proper SGML
> comment handling and which eventually resulted in 5 implementations
> (Mozilla, Safari, Opera, Konqueror and Prince)?
What made me change my mind was a realisation that I was being stupid. The
person who originally implemented this feature in Mozilla, the current
maintainer of the HTML Parser in Mozilla, the person who implemented it in
Safari, the person who implemented it in Opera, the people who tested it
in Opera, the CTO of Opera Software, the president of Prince's YesLogic,
and one of YesLogic's board members, all came to me and told me that I was
being stupid, and it was only when a good portion of them all said it
within about two days of each other that I realised that they were right.
> I assume, of course, this now means that all of those browsers will
> soon, if not already, be removing such support?
That is what they assured me before I changed the spec.
> Secondly, what will now be defined as a conforming comment syntax for
> use in a document?
Probably the same as XML. Or maybe just "<!--" followed by zero or more
characters other than U+0000, followed by "-->".
> Ignoring parsing requirements, is it safe to assume that HTML will
> borrow from the stricter XML comment syntax, which start with '<!--' and
> end with '-->' and does not contain '--' anywhere in between?
> In other words:
> <!-- valid comment -->
> <!-- invalid -- comment -->
> <!-- invalid -- -- comment --> (though, valid in HTML4)
> That seems like the most backwards compatible method, it remains
> compatible with the HTML4 syntax and is actually the way most good
> tutorials teach authors to write comments.
Yeah. The question is do we really want to confuse people by telling them
that their comment is invalid when they write:
> What about the empty comment declaration: <!> ? I've never seen anyone
> use it (except in test cases), and I tested it with your new live DOM
> viewer tool and these were the results:
> Firefox 184.108.40.206: Treated as comment
> IE 6: Rendered the document properly, though the DOM view
> showed nothing but: #comment: CTYPE ht
> Opera 9/Win: CRASHED!
> Opera 9/Mac: CRASHED!
> Opera 8.5/Mac: Ignored (not shown in DOM view)
> Safari 2.0.3: Ignored (not shown in DOM view)
> As a result, and because nothing is gained by using it, it too should be
> considered non-conformant, but should be parsed as a comment, like
> Firefox does.
It's treated as an errorneous comment in the current HTML5 spec ("<!"
switches to the bogus comment state, ">" emits a comment token).
Ian Hickson U+1047E )\._.,--....,'``. fL
http://ln.hixie.ch/ U+263A /, _.. \ _\ ;`._ ,.
Things that are impossible just take longer. `._.-(,_..'--(,_..'`-.;.'
(Disclaimer: the aforementioned CTO and the aforementioned board member
are actually the same person.)
More information about the whatwg