Re: CSS parser recovery

On 12/13/02 11:58 AM, "L. David Baron" <dbaron@fas.harvard.edu> wrote:

> 
> On Friday 2002-12-13 19:00 +0000, Ian Hickson wrote:
>> On Fri, 13 Dec 2002, REFSTRUP,JACOB (HP-Vancouver,ex1) wrote:
>>> 
>>> p {color: green; /* missing "}" */
>>> q {color: blue;}
>>> samp {color:red;}
>> 
>> That should parse as something like (froom memory):
> 
> It doesn't parse, since there's no ending brace to match the beginning
> brace on the first line.

It is a misconception that you must match random braces everywhere when
parsing CSS.  See CSS1 section 7.1 for precise specifics on when "blocks"
(as defined in 7.1, {...} ) may appear.

 http://www.w3.org/TR/REC-CSS1#forward-compatible-parsing

In particular, nowhere does it say that that a brace is permitted as part of
a declaration, except as part of the value of declaration.

Thus the above style sheet should be parsed as (white space adjusted to
demonstrate parsing):

 p { color : green ; q{color : blue ; }
 samp { color : red ; }

The second declaration in the p rule is ill-formed, thus ignored, resulting
in the following equivalent style sheet:

 p { color : green }
 samp { color : red }

Which is precisely what IE5/Mac and IE6/Windows do.

Tantek

Received on Friday, 13 December 2002 18:27:36 UTC