Let'S do it by example:
.ident_a, .ident_b {
& + & + & { color: red; }
}
We have to generate all permutations of the parent identifier list and
the amount of ampersand child identifiers. In the above case, the
exploded identifier list has ident_count**ampersand_count entries (8).
As a bonus, we get the same identifier sort order as lessc does.
Conflicts:
lesscpy/plib/identifier.py
Including double-nested queries which are used (not only) by bootstrap3.
Triple-nested (or more) media queries are currently not supported. Added
several tests.
See http://www.lesscss.org/#-nested-media-queries
The lexer now identifies media queries in @media ... {} and
@import ... ; statements. For that, two new states "mediaquery" and
import" where added. The parser uses those to implement the CSS3 media
query BNF (www.w3.org/TR/css3-mediaqueries). Overall test coverage
increased.
The alpha value can either be a number in the range 0-1 or a percentage
(0-100%). Alpha values greater than 1 are simply dropped. Compare with
the rgba() function definition at http://lesscss.org/#reference.
The operator list includes "=<", but not "<>", "!=" or "<=". Properly
adjust test cases and drop occurences of invalid operators. Raise a
syntax error if an unknown operator is used. See
http://lesscss.org/#-pattern-matching-and-guard-expressions
'rect' is a DOM element and occurs as a function. Currently, the parser
doesn't have a list of valid function names but uses css_dom elements
(and some others) to identify function calls.
Therefore the lexer got additional state tracking a while ago. This
turned out to wrongly work on constructs such as "button::-moz-$FOO,
input::-moz-$BAR", where 'input' was marked as 'css_ident' rather than
'css_dom'. This is fixed by resetting the 'in_property_decl' state
variable after a comma.
Quote from lesscss.org: "prior to LESS 1.3.1 a (~"@{name}") type of
selector was supported. Support for this will be removed in 1.4.0.".
Meanwhile, interpolated selectors look like .@{name}.
For this, the lexer needed another state. Promote literals '{}' to
tokens to be able to drop the 'istring' state when '.foo{' occurs
(rather than '.foo {').
To be used inside general_sibling_selector (e.g. 'a ~ b { ... }')
instead of the literal '~'. Necessary since we had to remove the literal
from the lexer in order to tokenize ~"..." and ~'...'.
Ordinary CSS strings may contain @{...}-style variables. Here are some
examples:
content: "@{breadcrumb-separator}\00a0";
background-image: url("@{file-2x}");
.col(@index + 1, ~"@{list}, @{item}");
The lexer catches Microsoft-specific function calls such "progid:..."
and "DX.Transform..." in the css_ms_filter token class. It should be
used only as the function for "fcall" constructs in the parser.
The following constructs are escapes: ~"..." and ~'...'. Inside, only
@{...} is a LESS variable, @foo is not! To express that, the lexer needs
to additional states ('lessstringquotes' and 'lessstringapostrophe') and
some parsing rules special to those states. The literal '~' had to be
promoted to token too. Now, instead as marking the complete LESS string
as 'less_string' token, the lexer properly tokenizes it's content which
in turn the parser can properly evaluate.
Includes a minor bug fix, t_less_variable() wasn't ever used because
t_css_ident already captured them. This part was removed from
t_css_ident becaus it's much easier to overwrite t_less_variable in lexer
states.
And revert "Temprarily remove the "rect" SVG DOM element."
This reverts commit fcea9f0bd65807be14c0cbf56b3d21659a81856f.
The lexer now uses a variable to distinguish of being inside a CSS
property declaration or outside. If inside, don't mark token as css_dom
(e.g. 'rect'). This circumvents the ambiguity between the "rect" SVG DOM
element and the "clip()" CSS function. CSS functions only occur within
property declarations.
For that, ';' had to be promoted from a literal to an ordinar token.
This solution is somewhat hacky, the @media element really deserves a
Node subclass and it's own parsing rules. What's still missing is LESS
variables in grouped media queries like:
@singleQuery: ~"(max-width: 500px)";
@media screen, @singleQuery {
set { padding: 3 3 3 3; }
}
Fixes #18
Mimics Python3's changed rounding behavior: "The round() function
rounding strategy and return type have changed. Exact halfway cases are
now rounded to the nearest even result instead of away from zero. (For
example, round(2.5) now returns 2 rather than 3.) round(x[, n]) now
delegates to x.__round__([n]) instead of always returning a float. It
generally returns an integer when called with a single argument and a
value of the same type as x when called with two arguments."
The SVG standard defines several DOM elements in camel-case (namely
textPath, altGlyph, altGlyphDef, altGlyphItem and glyphRef). Even though
most browser also accept lower-case, the lexer should take this into
account.