Re: handling of HTML Comments in HTML style element

fantasai wrote:
> The grammar defines the tokens
> 
>   CDO  <!--
>   CDC  -->
> 
> then it defines a style sheet as
> 
>   stylesheet  : [ CDO | CDC | S | statement ]*;

I seem to recall that this has come up in the past on this list and it was 
concluded that the grammar, as written, is wrong.  The idea of allowing these at 
all is to allow CDO at the beginning of inline stylesheets (_not_ all 
stylesheets) and allow CDC at the end of inline stylesheets (again not all 
stylesheets).  Has that decision been changed?  Or am I recalling incorrectly?

That all said, section 4.1.9 just says that CDO and CDC are allowed in a 
stylesheet production by the grammar (which is true).  The grammar itself points 
to Appending G, which defines CSS 2.1.  Note that this is slightly more 
restrictive, and in particular that according to this grammar the string

   body { color: red }
   <!-- comment -->
   body { color: blue }

Does not actually match the stylesheet production.  Indeed, for it to match the 
string "comment" would need to match one of the productions "ruleset", "media", 
and "page", and it doesn't match any of those.

I'm not certain that it's ever been clearly concluded what to do with strings 
that do not match the stylesheet production.

> This means '<!--' and '-->' are allowed anywhere between style rules
> and @rules, so your style sheet should result in the following style
> rules:
> 
>   1. body { color: red }
>   2. comment

Sorry, but no.  That doesn't follow from the only thing we can actually conclude 
about our string, which is that it doesn't match the "stylesheet" production of 
CSS2.1.

> I think this would make a very good test for the test suite, btw.

Once we figure out what the heck the right behavior is, absolutely.  ;)

-Boris

Received on Sunday, 2 September 2007 07:01:41 UTC