Skip to content

Commit 234fd74

Browse files
committed
Fix unquoted url interpolation
1 parent ecc143b commit 234fd74

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

Syntaxes/Less.sublime-syntax

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ variables:
2525
tag_name_begin: (?=[[:alpha:]]|@+{)
2626

2727
lang_range_begin: (?={{ident_start}}|\*)
28+
unquoted_url_begin: (?={{ident_start}}|/)
2829

2930
# Less variables
3031

@@ -354,7 +355,10 @@ contexts:
354355
- meta_prepend: true
355356
- include: less-string-interpolations
356357

358+
###[ CSS URL STRINGS ]#########################################################
359+
357360
quoted-url:
361+
# does not yet exist in CSS but is not unlikely
358362
- match: \"
359363
scope:
360364
meta.string.css string.quoted.double.css
@@ -366,6 +370,15 @@ contexts:
366370
punctuation.definition.string.begin.css
367371
set: single-quoted-url-body
368372

373+
unquoted-urls:
374+
# replace CSS context to add interpolation support
375+
- match: '{{unquoted_url_begin}}'
376+
push: unquoted-url-body
377+
378+
unquoted-url-body:
379+
- meta_prepend: true
380+
- include: less-string-interpolations
381+
369382
###[ CSS PROTOTYPES ]##########################################################
370383

371384
terminator-pop:

tests/syntax_test_less.less

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,15 @@ custom-@{element}-selector {}
806806
// ^^^^^^^^ meta.string.css meta.interpolation.less
807807
// ^ - meta.string - meta.interpolation
808808
// ^^^^^^^^^^^ meta.function-call
809+
810+
image: url(@{server}/assets/@{image}.png);
811+
// ^ meta.property-value.css - meta.function-call
812+
// ^^^ meta.property-value.css meta.function-call.identifier.css
813+
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.property-value.css meta.function-call.arguments.css meta.group.css
814+
// ^^^^^^^^^ meta.path.url.css meta.string.css meta.interpolation.less - string
815+
// ^^^^^^^^ meta.path.url.css meta.string.css string.unquoted.css
816+
// ^^^^^^^^ meta.path.url.css meta.string.css meta.interpolation.less - string
817+
// ^^^^ meta.path.url.css meta.string.css string.unquoted.css
809818
}
810819

811820
//=============================================================================

0 commit comments

Comments
 (0)