lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]





On Tue, May 27, 2014 at 1:33 PM, Tom N Harris <telliamed@whoopdedo.org> wrote:
On Tuesday, May 27, 2014 12:20:49 PM Sean Conner wrote:
> is legal (and before you say no sane person would actually write the above,
> there's some saying I can't quite find that states that if it's possible, it
> will exist in some codebase somewhere).

Worse than that, CSS requires that a parser must accept *illegal* syntax
without failing. It must pass over the nonsense, while balancing braces,
parenthesis, and quotes, then ignore what it doesn't understand.

    @media screen {
     p { font-family: monospace }
     @foo @bar;
     p { color: red;  color{;color:maroon}; color: green }
     ) ( {} ) p {color: red }
     p {
       font-family: 'Times New Roman
       font-style: italic;

A conforming CSS processor must be accept this and reduce it to

    @media screen {
      p { font-family:monospace; color:green; font-style:italic; }
    }

Now, if you don't mind being non-conforming, I don't think anyone will be too
upset if you refuse to accept that unholy mess.

--
tom <telliamed@whoopdedo.org>


If the OP has a specialized sand-box that is more restrictive than the rest of the world, then fine.

However, skipping bad input is used almost all of the time. This is especially true for dealing with browser incompatibilities (IE5.5), etc.

And then you have selectors that modify "all paragraphs not inside of class Foo", etc. 

A generic CSS parser / resource selector would be an extremely powerful tool, but it might be about as large as your average utf8 library. :)

-Andrew