-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Parser ignores strings at an unknown at-rule prelude (thus failing at {
and ;
there)
#3147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
You can insert literal content using a string that is 'unquoted' via the @-moz-document regexp(~'"(\d{0,15})"') {
a {
color : red;
}
} If that still messes with the parser, you may consider moving the expression contents into a variable first: @regexp : ~'"(\d{0,15})"';
@-moz-document regexp(@regexp) {
a {
color : red;
}
} |
Apparently the problem is in P.S. Recalling how custom at-rules are parsed, I guess the problem here is that the parser does not even triy to parse anything between For the same reason ("unknown grammar") the workaround with @-moz-document regexp("(\d {
0,15})") {
a {
color: red;
}
} And the only workarounds I can invent at quick glance in this case would be either a separate file injected with @mzd: ~'-{} @-moz-document regexp("(\d{0,15})")';
@keyframes @mzd {
a {
color: red;
}
} or sort of. |
@seven-phases-max In that case, I wonder if Less can do any better in the look-ahead code to match the opening brace of the at-rule's block. E.g. make some assumptions on sanity of the structure of the value(s) that follow the at-directive, and performing some rudimentary open/close-matching for brace/bracket/quote characters on them. |
I think it can try to parse that |
{
and ;
)
{
and ;
){
and ;
there)
@seven-phases-max (or anyone) |
It sounds to me like the rules for at-rules and custom property syntax may be similar. That is, you can include almost anything for an unknown at-rule, but there are some pair-matching rules? It might make sense to see what the overlap is and normalize the parsing between them. |
Yes; that's the conclusion I arrived at as well. ^_^ |
The Stylus extension (not to be confused with the Stylus language) (also used for applying userstyles, a fork of Stylish) recently added Less support, this bug however greatly limits its use - especially since the file workaround cannot be used. |
The spec says {-token, not {-character. The parser works by consuming/ignoring tokens. The parser should read and ignore tokens until it encounters {-token, in other words: ident-token |
Less parser does not. I.e. you are right about how it should be in a perfect world (above I wrote the same) but I'm afraid how Less parser works internally has nothing to do with CSS parsing specs. |
So I thought I'd do some tests in Chrome as to what are considered valid custom properties by the CSS custom property parser: TL;DR - The theory of what's valid for custom properties (in Chrome anyway) mostly matches the way the spec seems to read, with Chrome seeming to allow for unmatched braces in some cases (probably error correction?). Results: |
* Adds permissive parsing for at-rules and custom properties * Added error tests for permissive parsing * Change custom property value to quoted-like value * Allow interpolation in unknown at-rules * Allows variables to fallback to permissive parsing * Allow escaping of blocks
I used less to write some user styles for Stylish, it have some special syntaxs, for example, this extension support
regexp("Regular expression")
. So the following codes will work well on Stylish:But it can not work with less.js:

The less.js says:
Is there a way to ignore the characters between quotation marks? Or are there other ways to solve this problem?
Thank you
The text was updated successfully, but these errors were encountered: