Skip to content

Commit

Permalink
[CSS] Add rounding strategy keywords (#4049)
Browse files Browse the repository at this point in the history
This commit adds scopes to highlight round() strategies.

Note:

round() uses common `calc-function-arguments-content` context, so these keywords
are also highlighted in other functions, they don't have special meaning in.

Chances to run into conflicts are however too low to justify a new dedicated
context for round() arguments.

see: https://developer.mozilla.org/en-US/docs/Web/CSS/round#rounding-strategy
  • Loading branch information
deathaxe authored Sep 29, 2024
1 parent 6c84049 commit 7538d08
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CSS/CSS.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -2819,6 +2819,10 @@ contexts:
- include: function-arguments-prototype
- include: comma-delimiters
- include: attr-functions
# round() keywords
- match: (?:down|nearest|to-zero|up){{break}}
scope: keyword.other.round.strategy.css
# common constants
- match: (?:e|pi){{break}}
scope: constant.language.css
- match: -?infinity{{break}}
Expand Down
34 changes: 34 additions & 0 deletions CSS/syntax_test_css.css
Original file line number Diff line number Diff line change
Expand Up @@ -3615,6 +3615,40 @@
/* ^^ constant.language.css */
}

.test-round-function {
top: round(down 10px var(--interval));
/* ^^^^^ meta.function-call.identifier.css support.function.calc.css */
/* ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.css meta.group.css */
/* ^^^^ keyword.other.round.strategy.css */
/* ^^^^ meta.number.integer.decimal.css */
/* ^^^ support.function.var.css */
/* ^^^^^^^^^^ variable.other.custom-property.css */

top: round(nearest 10px var(--interval));
/* ^^^^^ meta.function-call.identifier.css support.function.calc.css */
/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.css meta.group.css */
/* ^^^^^^^ keyword.other.round.strategy.css */
/* ^^^^ meta.number.integer.decimal.css */
/* ^^^ support.function.var.css */
/* ^^^^^^^^^^ variable.other.custom-property.css */

top: round(to-zero 10px var(--interval));
/* ^^^^^ meta.function-call.identifier.css support.function.calc.css */
/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.css meta.group.css */
/* ^^^^^^^ keyword.other.round.strategy.css */
/* ^^^^ meta.number.integer.decimal.css */
/* ^^^ support.function.var.css */
/* ^^^^^^^^^^ variable.other.custom-property.css */

top: round(up 10px var(--interval));
/* ^^^^^ meta.function-call.identifier.css support.function.calc.css */
/* ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.arguments.css meta.group.css */
/* ^^ keyword.other.round.strategy.css */
/* ^^^^ meta.number.integer.decimal.css */
/* ^^^ support.function.var.css */
/* ^^^^^^^^^^ variable.other.custom-property.css */
}

.test-toggle-function {
top: toggle(5px red preserve-3d);
/* ^^^^^^ support.function.toggle.css */
Expand Down

0 comments on commit 7538d08

Please sign in to comment.