-
Notifications
You must be signed in to change notification settings - Fork 658
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
[css-values] Other options for value-agnostic delimiters #6705
Comments
Brainstorming: What about |
Note that About |
@Loirooriol |
|
@Crissov Consider |
A top-level But I'm not convinced we should avoid |
Yeah, given the existence of custom properties, semicolon and Wrapping delimiters, like |
No, the issue is that these tools rely on similar parsing logic to CSS, so they won't parse
That's not strictly true—not all |
Just brainstorming: A lot of languages (and the css syntax notation) use |
I like |
For the record, |
Any serious CSS tooling should have already built in pairing of parens, brackets, and braces, which should render this a non-issue. This is a core piece of CSS's forwards-compatible parsing rules, and it's needed for correct error-handling and for correct error-highlighting. What specific tools are so naive as to choke on this, and is the breakage really so bad that we need to alter core CSS to compensate? Fwiw, I'm very strongly against any syntax that requires wrapping in parentheses or brackets, this is just very noisy and annoying, and if it's optional it's also confusing. If we're picking a different delimiter, it needs to be one that can function like a comma. (And for that purpose, semicolon is the most natural one to use: it is effectively defined as a stronger comma in natural language usage, and in CSS it is guaranteed to not cause a syntactic conflict in the future.) |
Why should it? If a tool wants to naïvely determine the start and end of a given declaration, currently it can do so by simply consuming tokens until it hits
Sass is a specific example of a tool that will choke on this, although not so much because it's naïve as that it needs to do a semantic parse of all expression syntax. The Sass breakage isn't bad enough to be worth altering CSS on its own, since we could easily add support for this new syntax. The core objection here is that it would break many tools—particularly small, ad hoc tools that are likely maintained by individual organizations rather than widely-used open source tools which have stronger pressures on them to support every edge case. |
Given the resolution here #9539 (comment) I believe we have opted-in to the tooling pain of using semicolons as delimiters |
In #581, a semicolon has been proposed as a delimiter in the function
mix( <percentage> ; <start-value> ; <end-value>)
. Commas can't be naïvely used as delimiters here because<start-value>
and<end-value>
need to be able to be any valid property value, some of which may include commas of their own. But as @LeaVerou points out in #581 (comment), introducing a semicolon as a valid character in a value context is likely to break existing tooling fairly severely. Tools will eventually update to support it—in Sass for example we could probably make it work by adding semicolon as a new form of list delimiter—but until that update happens and is widely adopted by all users of these tools, it's likely that this syntax will render themix()
function painful or impossible to use by many people.Given that, I thought I'd toss out an alternative idea for how to structure this syntax in a way that's easier for existing tools to parse (and possibly also more similar to existing CSS functions), while also allowing arbitrary property values. I'm not particularly married to any particular configuration of this solution, but I'd like to avoid the semicolon if possible and I'm hoping this can at least inspire some useful discussion of how that might be accomplished.
My core idea would be to wrap the
<start-value>
and<end-value>
productions in some other syntax to make the scope of the values unambiguous, similarly to howcalc()
wraps an unusual syntactic context. This could look more explicit likemix( <percentage> , value( <start-value> ) , value( <end-value> ) )
or more terse likemix( <percentage> , [ <start-value> ] , [ <end-value> ] )
.If the verbosity is too annoying, you could also say that the wrapper is only required when it would otherwise be ambiguous. In other words, say that
<start-value>
and<end-value>
can contain any value syntax other than top-level commas (and square brackets if you go with the terser option), so thatmix(70%, 0%, 100%)
works without wrapping butmix(70%, value(a, b, c), value(d, e, f))
needs to be wrapped.The text was updated successfully, but these errors were encountered: