Skip to content

Commit ecc143b

Browse files
committed
Fix font-family name interpolation and termination
1 parent 1a00800 commit ecc143b

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

Syntaxes/Less.sublime-syntax

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,23 @@ contexts:
324324

325325
###[ CSS STRING CONSTANTS ]####################################################
326326

327+
font-family-names:
328+
# replace CSS context to add interpolation support
329+
- match: '{{ident_begin}}'
330+
push: font-family-name-body
331+
332+
font-family-name-body:
333+
- meta_include_prototype: false
334+
- meta_scope: meta.string.css string.unquoted.css
335+
- include: less-string-interpolations
336+
# allow unquoted space separated font names
337+
- match: (?!\s+{{ident_start}}){{break}}
338+
pop: 1
339+
# function call ahead, skip font name
340+
- match: (?=\s+{{ident}}\()
341+
pop: 1
342+
- match: '{{unicode}}'
343+
327344
language-ranges:
328345
# replace CSS context to add interpolation support
329346
- match: '{{lang_range_begin}}'

tests/syntax_test_css.less

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2497,6 +2497,13 @@
24972497
font: sans serif;
24982498
/* ^^^^^^^^^^ meta.string.css string.unquoted.css */
24992499
2500+
font: san\73 -\73 erif;
2501+
/* ^^^^^^^^^^^^^^^^ meta.string.css string.unquoted.css */
2502+
2503+
font: sans serif var(--name);
2504+
/* ^^^^^^^^^^ meta.string.css string.unquoted.css */
2505+
/* ^^^^^^^^^^^ meta.function-call */
2506+
25002507
font: inherit;
25012508
/* ^^^^^^^ support - string */
25022509

tests/syntax_test_less.less

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,15 @@ custom-@{element}-selector {}
797797
// ^^^^^ variable.other.less
798798
// ^^^ support.constant.color.w3c.standard.css
799799
// ^ punctuation.section.group.end.css
800+
801+
font: san\73 -\73 erif;
802+
// ^^^^^^^^^^^^^^^^ meta.string.css string.unquoted.css
803+
804+
font: sans @{serif} var(--name);
805+
// ^^^^^ meta.string.css string.unquoted.css
806+
// ^^^^^^^^ meta.string.css meta.interpolation.less
807+
// ^ - meta.string - meta.interpolation
808+
// ^^^^^^^^^^^ meta.function-call
800809
}
801810

802811
//=============================================================================

0 commit comments

Comments
 (0)