Skip to content

Commit

Permalink
Fix font-family name interpolation and termination
Browse files Browse the repository at this point in the history
  • Loading branch information
deathaxe committed Mar 16, 2024
1 parent 1a00800 commit ecc143b
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Syntaxes/Less.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,23 @@ contexts:

###[ CSS STRING CONSTANTS ]####################################################

font-family-names:
# replace CSS context to add interpolation support
- match: '{{ident_begin}}'
push: font-family-name-body

font-family-name-body:
- meta_include_prototype: false
- meta_scope: meta.string.css string.unquoted.css
- include: less-string-interpolations
# allow unquoted space separated font names
- match: (?!\s+{{ident_start}}){{break}}
pop: 1
# function call ahead, skip font name
- match: (?=\s+{{ident}}\()
pop: 1
- match: '{{unicode}}'

language-ranges:
# replace CSS context to add interpolation support
- match: '{{lang_range_begin}}'
Expand Down
7 changes: 7 additions & 0 deletions tests/syntax_test_css.less
Original file line number Diff line number Diff line change
Expand Up @@ -2497,6 +2497,13 @@
font: sans serif;
/* ^^^^^^^^^^ meta.string.css string.unquoted.css */
font: san\73 -\73 erif;
/* ^^^^^^^^^^^^^^^^ meta.string.css string.unquoted.css */
font: sans serif var(--name);
/* ^^^^^^^^^^ meta.string.css string.unquoted.css */
/* ^^^^^^^^^^^ meta.function-call */
font: inherit;
/* ^^^^^^^ support - string */
Expand Down
9 changes: 9 additions & 0 deletions tests/syntax_test_less.less
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,15 @@ custom-@{element}-selector {}
// ^^^^^ variable.other.less
// ^^^ support.constant.color.w3c.standard.css
// ^ punctuation.section.group.end.css

font: san\73 -\73 erif;
// ^^^^^^^^^^^^^^^^ meta.string.css string.unquoted.css

font: sans @{serif} var(--name);
// ^^^^^ meta.string.css string.unquoted.css
// ^^^^^^^^ meta.string.css meta.interpolation.less
// ^ - meta.string - meta.interpolation
// ^^^^^^^^^^^ meta.function-call
}

//=============================================================================
Expand Down

0 comments on commit ecc143b

Please sign in to comment.