From 234fd749382b7db0fd22f920d9f3457f60127e4d Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sat, 16 Mar 2024 10:28:10 +0100 Subject: [PATCH] Fix unquoted url interpolation --- Syntaxes/Less.sublime-syntax | 13 +++++++++++++ tests/syntax_test_less.less | 9 +++++++++ 2 files changed, 22 insertions(+) diff --git a/Syntaxes/Less.sublime-syntax b/Syntaxes/Less.sublime-syntax index b355100..1254e79 100644 --- a/Syntaxes/Less.sublime-syntax +++ b/Syntaxes/Less.sublime-syntax @@ -25,6 +25,7 @@ variables: tag_name_begin: (?=[[:alpha:]]|@+{) lang_range_begin: (?={{ident_start}}|\*) + unquoted_url_begin: (?={{ident_start}}|/) # Less variables @@ -354,7 +355,10 @@ contexts: - meta_prepend: true - include: less-string-interpolations +###[ CSS URL STRINGS ]######################################################### + quoted-url: + # does not yet exist in CSS but is not unlikely - match: \" scope: meta.string.css string.quoted.double.css @@ -366,6 +370,15 @@ contexts: punctuation.definition.string.begin.css set: single-quoted-url-body + unquoted-urls: + # replace CSS context to add interpolation support + - match: '{{unquoted_url_begin}}' + push: unquoted-url-body + + unquoted-url-body: + - meta_prepend: true + - include: less-string-interpolations + ###[ CSS PROTOTYPES ]########################################################## terminator-pop: diff --git a/tests/syntax_test_less.less b/tests/syntax_test_less.less index a859903..13613fd 100755 --- a/tests/syntax_test_less.less +++ b/tests/syntax_test_less.less @@ -806,6 +806,15 @@ custom-@{element}-selector {} // ^^^^^^^^ meta.string.css meta.interpolation.less // ^ - meta.string - meta.interpolation // ^^^^^^^^^^^ meta.function-call + + image: url(@{server}/assets/@{image}.png); +// ^ meta.property-value.css - meta.function-call +// ^^^ meta.property-value.css meta.function-call.identifier.css +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.property-value.css meta.function-call.arguments.css meta.group.css +// ^^^^^^^^^ meta.path.url.css meta.string.css meta.interpolation.less - string +// ^^^^^^^^ meta.path.url.css meta.string.css string.unquoted.css +// ^^^^^^^^ meta.path.url.css meta.string.css meta.interpolation.less - string +// ^^^^ meta.path.url.css meta.string.css string.unquoted.css } //=============================================================================