[csswg-drafts] [css-values-5] Adding a way to express which keywords are valid in calculations in syntax definitions (#11505)

romainmenke has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-values-5] Adding a way to express which keywords are valid in calculations in syntax definitions ==
Some examples:

```css
color: rgb(from purple r g calc( b / 2 ));
height: calc-size(auto, calc(size / 2));
```

Currently there is no way to express in syntax definitions which keywords are valid in which context.
This can only be done in prose.

This would be useful for static analysis tools (i.e. linters)

With the addition of the [boolean expression multiplier](https://drafts.csswg.org/css-values-5/#boolean) there is bit of a precedent to define and communicate such things.

Could we use this or something similar for math expressions?

```
<modern-rgb-syntax> = rgb( [ from <color> ]?
        [ <number> | <percentage> | <math-function[ r | g | b ]> | none]{3}
        [ / [<alpha-value> | <math-function[ alpha ]> | none] ]?  )
```

Where `<math-function[ foo ]>` is equivalant to `calc( <calc-sum[ foo ]> ) | min( <calc-sum[ foo ]> ) | ...`

```
<calc-size()> = calc-size( <calc-size-basis>, <calc-sum[ size ]> )
```


Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/11505 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 15 January 2025 08:52:27 UTC