From ecc143b34f1e7780fe57735a81c45d1be3db6b6a Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sat, 16 Mar 2024 10:24:09 +0100 Subject: [PATCH] Fix font-family name interpolation and termination --- Syntaxes/Less.sublime-syntax | 17 +++++++++++++++++ tests/syntax_test_css.less | 7 +++++++ tests/syntax_test_less.less | 9 +++++++++ 3 files changed, 33 insertions(+) diff --git a/Syntaxes/Less.sublime-syntax b/Syntaxes/Less.sublime-syntax index 37aae7d..b355100 100644 --- a/Syntaxes/Less.sublime-syntax +++ b/Syntaxes/Less.sublime-syntax @@ -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}}' diff --git a/tests/syntax_test_css.less b/tests/syntax_test_css.less index b8404de..920f5f3 100644 --- a/tests/syntax_test_css.less +++ b/tests/syntax_test_css.less @@ -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 */ diff --git a/tests/syntax_test_less.less b/tests/syntax_test_less.less index cffdbfc..a859903 100755 --- a/tests/syntax_test_less.less +++ b/tests/syntax_test_less.less @@ -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 } //=============================================================================