Re: [css3-mediaqueries] Request for feedback on syntax

Anne van Kesteren wrote:
> 
> Most implementations follow the HTML4 rules for media. From the few 
> content surveys I've seen so far it does not seem that content relies on 
> the error handling rules. Content uses conforming media queries (mostly 
> 'screen'). This suggests that we can probably completely override what 
> HTML4 said by media queries. (This is what HTML5 currently suggests.) 
> The implication of this would be that "{},all" would not apply in either 
> HTML or CSS because it is a syntax error in both.
> 
> Now there is an open question on whether or not we want to use the CSS 
> parser for media queries used in other languages. This is relevant for 
> whether or not "all and (min-width:1p\x)" should work in HTML, or 
> "x,/**/all".
> 
> The advantage of simply using the CSS parser is that HTML 
> implementations that also support CSS can easily reuse code. Another 
> advantage is that authors can simply copy and paste their media query 
> and that the way media queries are treated is predictable.
> 
> The disadvantage is that for non-CSS HTML implementations it would be 
> slightly more complicated to support <link rel=alternate media=print 
> href=print> for instance.
> 
> Any feedback on this?

I'm leaning towards making Media Queries define its own set of parsing
rules that are compatible with CSS but are more amenable to being
embedded in other applications. For the issues listed in
   http://lists.w3.org/Archives/Public/www-style/2007Dec/0057.html
I'd like to say

   - The set of white space characters is defined by the host language.
     This set must include the space character. If the host language
     doesn't define a set of white space characters, the CSS set is used.

   - CSS comments: I don't mind either way. If they're allowed, they
     become "Media Queries comment syntax": i.e. they're part of the
     syntax defined for Media Queries.

   - CSS backslash escapes are not allowed. The host language's escapes
     can of course be used. Consider that if you embed Media Queries or
     Selectors in a language that uses backslashes for its escapes. If
     we imported CSS backslash escapes the situation would be very
     confusing there. Also I don't see a use case.

   - Media Queries should match parentheses and quotes when parsing
     invalid queries, just like in CSS, to ensure forwards-compatibility.

   - EOF closes any open brackets or quotes, just like in CSS, thereby
     handling the same error case (incomplete file) the same way.

   - Opening brace is an invalid token in a media query. In CSS, if
     it's not embedded in a string or a set of brackets it signals the
     end of the media query and the start of the @media block.
     Elsewhere it's just an invalid token. In languages that don't
     terminate the media query with an opening brace it should just be
     an invalid token everywhere.

     Consider, for example, a syntax that terminates a media query with
     a colon:
        MEDIA screen, print:
     In that language
        MEDIA screen: , print
     would recognize 'screen' but not 'print'. You're not going to get
     identical behavior across languages wrt the terminating character,
     so let's just treat the abstract idea of a terminating character
     consistently instead of trying to treat the character itself
     identically.

~fantasai

Received on Wednesday, 12 December 2007 21:04:58 UTC