diff --git a/ebnf-scheme/CSS3.ebnf b/ebnf-scheme/CSS3.ebnf index 0c96d46..e9c74ca 100644 --- a/ebnf-scheme/CSS3.ebnf +++ b/ebnf-scheme/CSS3.ebnf @@ -1,71 +1,58 @@ -css ::= ( ( rule | simple_atrule | mediaquery ) )* -simple_atrule ::= ('@charset'|'@import'|'@namespace') (STRING|IDENT) ';' -rule ::= selectors_group '{' ( declaration ( ';' declaration)* ';'? )* '}' -mediaquery ::= mediarule '{' query_declaration ( query_declaration)* '}' +css ::= S* ( ( rule | simple_atrule | mediaquery | COMMENT) S* )* +simple_atrule ::= ('@charset'|'@import'|'@namespace') S+ STRING S* ';' +rule ::= selectors_group S? '{' S? (COMMENT? declaration ( S? ';' S? declaration)* ';'? S?)* COMMENT* '}' +mediaquery ::= mediarule S? '{' S? COMMENT* query_declaration ( S? COMMENT* query_declaration)* S? '}' query_declaration ::= rule -declaration ::= property ':' (property ':')* values +declaration ::= property S? ':' (property ':')* S? values selectors_group - ::= selector ( COMMA selector )* -selector ::= simple_selector_sequence ( combinator? simple_selector_sequence)* + ::= selector ( COMMENT? COMMA S* selector )* +selector ::= simple_selector_sequence ( combinator simple_selector_sequence )* mediaquery_selector::= '(' declaration ')' combinator - ::= PLUS - | GREATER - | TILDE - /* ws: explicit */ + ::= PLUS S* + | GREATER S* + | TILDE S* + | S+ simple_selector_sequence - ::= type_selector ( HASH | class | attrib | pseudo | negation | atrule | mediaquery_selector )* + ::= ( type_selector | universal ) ( HASH | class | attrib | pseudo | negation | atrule | mediaquery_selector )* | ( HASH | class | attrib | pseudo | negation | atrule| mediaquery_selector )+ - /* ws: explicit */ type_selector - ::= namespace_prefix? ( element_name | '*' ) - /* ws: explicit */ + ::= namespace_prefix? element_name namespace_prefix ::= ( IDENT | '*' )? '|' - /* ws: explicit */ element_name ::= IDENT - /* ws: explicit */ +universal + ::= namespace_prefix? '*' class ::= '.' IDENT - /* ws: explicit */ -mediarule ::= '@media' conditions ( conditions| mediaquery_selector )* +mediarule ::= '@media' S conditions ( S? conditions| S? mediaquery_selector )* atrule ::= '@' IDENT - /* ws: explicit */ conditions ::= ('and'|'screen'|'or'|'only'|'not'|'amzn-mobi'|'amzn-kf8'|',') -attrib ::= '[' namespace_prefix? IDENT ( ( PREFIXMATCH | SUFFIXMATCH | SUBSTRINGMATCH | '=' | INCLUDES | DASHMATCH ) ( IDENT | STRING ) )? ']' - /* ws: explicit */ +attrib ::= '[' S* namespace_prefix? IDENT S* ( ( PREFIXMATCH | SUFFIXMATCH | SUBSTRINGMATCH | '=' | INCLUDES | DASHMATCH ) S* ( IDENT | STRING ) S* )? ']' pseudo ::= ':' ':'? ( IDENT | functional_pseudo ) - /* ws: explicit */ functional_pseudo - ::= FUNCTION expression ')' - /* ws: explicit */ + ::= FUNCTION S* expression ')' property ::= ( STRING | IDENT ) -values ::= value ( value | '/' value )* important? -value ::= ( URL | PLUS | HEX | PERCENTAGE | '-' | DIMENSION | NUMBER | STRING | IDENT | COMMA | functional_pseudo) /*(COMMA IDENT)?*/ - /* ws: explicit */ -expression ::= ( ( PLUS | PERCENTAGE | URL | HEX | '-' | DIMENSION | NUMBER | STRING | IDENT | COMMA) )+ -negation ::= NOT negation_arg ')' - /* ws: explicit */ +values ::= value (S value | '/' value )* ( S* COMMA S* value (S value | '/' value )* )* important? +value ::= ( URL | PLUS | HEX | PERCENTAGE | '-' | DIMENSION | NUMBER | STRING | IDENT | functional_pseudo) +expression ::= ( ( PLUS | PERCENTAGE | URL | HEX | '-' | DIMENSION | NUMBER | STRING | IDENT | COMMA) S* )+ +negation ::= NOT S* negation_arg S* ')' negation_arg ::= type_selector + | universal | HASH | class | attrib | pseudo - /* ws: explicit */ - -Ignore ::= S^WS | COMMENT - /* ws: definition */ -COMMENT ::= '/*' CommentContents '*/' + +STRING ::= '"' STRING_CONTENT1 '"' | "'" STRING_CONTENT2 "'" EOF ::= $ URL ::= 'url(' ("'"|#x0027|nmchar|'/'|'.')+ ')' - /* ws: explicit */ -important ::= '!important' +important ::= S '!important' ident ::= [-]? nmstart nmchar* - /* ws: explicit */ name ::= nmchar+ nmstart ::= [_a-zA-Z] | nonascii @@ -79,14 +66,13 @@ nmchar ::= [_a-zA-Z0-9#x2D] | escape num ::= [0-9]+ | [0-9]* '.' [0-9]+ -string ::= string1 - | string2 -string1 ::= '"' ( [^#x000A#x000D#x000C\"] | '\' nl | nonascii | escape )* '"' -string2 ::= "'" ( [^#x000A#x000D#x000C\'] | '\' nl | nonascii | escape )* "'" nl ::= #x000A | #x000D #x000A | #x000D | #x000C +STRING_CONTENT1 ::= ( [^#x000A#x000D#x000C\"] | '\' nl | nonascii | escape )* +STRING_CONTENT2 ::= ( [^#x000A#x000D#x000C\'] | '\' nl | nonascii | escape )* +w ::= [ #x0009#x000D#x000A#x000C]* N ::= 'n' | '\' zero-to-four-zeroes ( '4e' | '6e' ) ( #x000D #x000A | [ #x0009#x000D#x000A#x000C] )? | '\n' @@ -96,8 +82,7 @@ O ::= 'o' T ::= 't' | '\' zero-to-four-zeroes ( '54' | '74' ) ( #x000D #x000A | [ #x0009#x000D#x000A#x000C] )? | '\t' -S ::= ( #x0020 | #x0009 | #x000D | #x000A )+ -SPACE ::= #x0020 +S ::= [ #x0009#x000D#x000A#x000C]+ INCLUDES ::= '~=' DASHMATCH ::= '|=' @@ -108,28 +93,18 @@ SUFFIXMATCH SUBSTRINGMATCH ::= '*=' IDENT ::= ident -STRING ::= string FUNCTION ::= ident '(' NUMBER ::= '-'?num HASH ::= '#' name HEX ::= '#' one-to-six-hex-digits PERCENTAGE ::= num '%' -PLUS ::= '+' -GREATER ::= '>' -COMMA ::= ',' -TILDE ::= '~' +PLUS ::= w '+' +GREATER ::= w '>' +COMMA ::= w ',' +TILDE ::= w '~' NOT ::= ':' N O T '(' -DIMENSION ::= '-'?num ('em' | 'px' | 'fr' | 'cm' | 'mm' | 'in' | 'pt' | 'pc'|'vh') -Char ::= #x0009 - | #x000A - | #x000D - | [#x0020-#xD7FF] - | [#xE000-#xFFFD] - | [#x10000-#x10FFFF] -CommentContents - ::=( ( Char+ - ( Char* ( '/*' | '*/' ) Char* ) ) - ( Char* '/' ) ) &'*' - | ( Char+ - ( Char* ( '/*' | '*/' ) Char* ) ) &'*/' - +DIMENSION ::= '-'?num S? ('em' | 'px' | 'fr' | 'cm' | 'mm' | 'in' | 'pt' | 'pc'|'vh') +COMMENT ::= S* '/*' S? (nmchar|':'|';'|','|S|'='|'('|')'|'#'|"'"|'"'|'/'|'.'|'!'|'?')+ S? '*/' S? one-to-six-hex-digits ::= [0-9a-fA-F] | [0-9a-fA-F] [0-9a-fA-F] diff --git a/xpl/css.xpl b/xpl/css.xpl index 7e8188a..94b69b3 100644 --- a/xpl/css.xpl +++ b/xpl/css.xpl @@ -12,50 +12,123 @@ - + + - + + In order to invoke this step directly with Calabash, you need to specify -l css-tools/xpl/css.xpl and + -s {http://www.w3.org/1996/css}parse + an XHTML document - a stylesheet that can be overriden, e.g. if CSS2.1 features are wanted only or if you want to use the + a stylesheet that can be overridden, e.g. if CSS2.1 features are wanted only or if you want to use the oldschool regex-based parser XML representation of the CSS. See css:expand - + + + + - - - - Calculate base-uri - - - - - - - - - - + + + + Calculate base-uri + + + + + + + First try parsing with comments, then try parsing without comments. Parsing with comments + will fail if comments are located in selectors or properties. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Reverting to CSS parsing with all comments removed. You can try to + help the parser by moving comments from selectors and properties outside the rules. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - + + + - + @@ -68,9 +141,9 @@ an XHTML document + - a stylesheet that can be overriden, e.g. if CSS2.1 features are wanted only or if you want to use the - oldschool regex-based parser + a stylesheet that can be overriden, e.g. if CSS2.1 features are wanted only an XHTML document with CSSa attributes (in addition to its style elements/attributes/linked CSS @@ -113,7 +186,7 @@ - + @@ -132,7 +205,7 @@ - + diff --git a/xsl/CSS3.xsl b/xsl/CSS3.xsl index 1ceb668..5588b02 100644 --- a/xsl/CSS3.xsl +++ b/xsl/CSS3.xsl @@ -1,6 +1,6 @@ - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + @@ -675,20 +643,59 @@ - + + + + + + + + + + + + - + + + + + + + + + + + + - - + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + - - - + + + - + - + - - + @@ -783,257 +796,515 @@ - + - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + - - + + + + + + + + + + + + + + + - - + + - - + + + - - + + - - - + + - + - + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + - - + + + - - + + + - + - + - + + + + - - - - - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + @@ -1041,13 +1312,14 @@ if ($state[$p:error]) then $state else - p:try-functional_pseudo($input, $state) + p:parse-STRING($input, $state) "/> - + + - - + + @@ -1085,12 +1354,18 @@ - + @@ -1099,11 +1374,8 @@ - - - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -1148,16 +1483,13 @@ - - - + + @@ -1166,12 +1498,18 @@ - + @@ -1180,99 +1518,115 @@ - - - + + + - + - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - - - - + - + + + + + + - - - - + + + - + + + - + + - + @@ -1280,7 +1634,8 @@ - + + - - + + - + @@ -1326,17 +1687,23 @@ + - - + + - + @@ -1361,15 +1728,43 @@ - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1377,64 +1772,48 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + - + - + @@ -1442,11 +1821,11 @@ if ($state[$p:error]) then $state else - p:try-property($input, $state) + p:parse-property($input, $state) "/> - - - + + + @@ -1472,10 +1851,38 @@ else p:parse-property($input, $state) "/> - - + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + - - - - - - - - - - - - - - - + + - - + + - - - - - - - - - - - - - - - + + + - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + - + - + - + @@ -1670,125 +2046,103 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - + - - - - - - - - + + + + + + + + + + + + + + + + + - + - + + + + - - - + + + + - + @@ -1797,148 +2151,102 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + - + + - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + - - - + + + + + + + + + + + + + - + - - + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - + + - - + + @@ -2049,14 +2353,14 @@ - + - - + + @@ -2075,49 +2379,75 @@ - + - - + + - - + + + + + + + + + + + - + + + + + + + + + - - + + + + + + - + + + + + @@ -2126,24 +2456,149 @@ - + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + @@ -2157,9 +2612,9 @@ - + - - + + + - + - - + + - - + + - - + + - - + + - - + + - + - + - - + + - + + @@ -2237,30 +2697,49 @@ - - + + + + + + + + + + + + + + + - + - - + + - - + + @@ -2273,14 +2752,14 @@ - + @@ -2289,110 +2768,10 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - - - - - + + + - - - - - - - - - + - - + + - + @@ -2469,44 +2834,51 @@ - - + + - + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - + + @@ -2514,261 +2886,333 @@ - - - + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + - + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - + @@ -2777,183 +3221,11 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + @@ -2961,179 +3233,27 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + @@ -3141,14 +3261,38 @@ + + + + + + + + + + + + + - + @@ -3157,418 +3301,106 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - + + - + - + @@ -3577,9 +3409,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -3588,16 +3452,25 @@ - - - + + + + + + + + + + + + + + + + + + + @@ -3605,55 +3478,121 @@ - - - + - - - - + + + + - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -3662,22 +3601,14 @@ + - + - - - - - + + @@ -3685,13 +3616,13 @@ - + @@ -3701,22 +3632,87 @@ if ($state[$p:error]) then $state else - p:parse-selector($input, $state) + p:parse-selectors_group($input, $state) "/> - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -3725,34 +3721,15 @@ - - - - - - - - - - - - + - + - - - - - + + @@ -3760,14 +3737,14 @@ - + @@ -3776,137 +3753,59 @@ - - + - - - - - + + + + + + + + + + + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + @@ -75,36 +74,79 @@ or wrong encoding. Supported encodings: UTF-8, CP1252 (the latter should work fo - - - - - - - - - - - + + + + - - + + - + - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -171,31 +213,51 @@ or wrong encoding. Supported encodings: UTF-8, CP1252 (the latter should work fo - - - - - , - - - , - - - , - - + + + + + + + + + + + + + - + - - + + + + + + + + + + + + + + + + + + + + + @@ -205,17 +267,22 @@ or wrong encoding. Supported encodings: UTF-8, CP1252 (the latter should work fo + + + - - - + + + + - + + @@ -224,7 +291,7 @@ or wrong encoding. Supported encodings: UTF-8, CP1252 (the latter should work fo - + @@ -233,23 +300,31 @@ or wrong encoding. Supported encodings: UTF-8, CP1252 (the latter should work fo - - - - - - - - - + + + + - - - - - ] - + + + + + + + + + + + + + + + + + *: + + @@ -258,113 +333,128 @@ or wrong encoding. Supported encodings: UTF-8, CP1252 (the latter should work fo ] - - - @id=' - - '] - - - - - - matches(@class - ,'(^|\s) - - (\s|$)') - ] - - - + * - - - - / - - - [ancestor:: - - - /preceding::*[1]/self:: - - - [preceding-sibling:: - - - | - - - - - - + + + [ + ] - + - - - - - - - - - + + + + + + + + + + - - | + + + + + + + + * + + + + [. + + ] + + - - - + + + + + intersect + + key('class', ' + + ') - - - - - - - - - - - + + + + - + + + + intersect + + key('id', ' + + ') + - - - - + + + - - + + [ + + + + + parent:: + + + ancestor:: + + + preceding-sibling::*[1]/self:: + + + preceding-sibling:: + + + + ] - - - - - + + + - + @@ -568,4 +658,33 @@ or wrong encoding. Supported encodings: UTF-8, CP1252 (the latter should work fo + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/xsl/css-parser.xsl b/xsl/css-parser.xsl index d061326..2f42534 100644 --- a/xsl/css-parser.xsl +++ b/xsl/css-parser.xsl @@ -577,18 +577,14 @@ or wrong encoding. Supported encodings: UTF-8, CP1252 (the latter should work fo - + - + - - - - diff --git a/xsl/css-util.xsl b/xsl/css-util.xsl index deb3349..6192a6a 100644 --- a/xsl/css-util.xsl +++ b/xsl/css-util.xsl @@ -19,23 +19,23 @@ - + - - + + - + - + @@ -300,5 +300,6 @@ - + + \ No newline at end of file diff --git a/xsl/css2-1-parser.xsl b/xsl/css2-1-parser.xsl index e12a441..5bd5eb4 100644 --- a/xsl/css2-1-parser.xsl +++ b/xsl/css2-1-parser.xsl @@ -11,7 +11,7 @@ For example text-decoration should become a short hand property --> - + diff --git a/xsl/css2xsl.xsl b/xsl/css2xsl.xsl index 12ffa04..d42c05e 100644 --- a/xsl/css2xsl.xsl +++ b/xsl/css2xsl.xsl @@ -34,15 +34,10 @@ - - + - 0 - - @@ -75,12 +70,10 @@ - - - + - +