Skip to content

[css-values-5] Express which keywords are valid in calculations in syntax definitions #11505

Open
@romainmenke

Description

@romainmenke

Some examples:

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 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 ]> )

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions