Skip to content

Commit 3dd90e2

Browse files
committed
Make sure template literals work correctly
Fixes #1 Fixes #2 For the most part. There is still a minor issue with regards to JSX blocks that are surrounded by parenthesis.
1 parent 15bea92 commit 3dd90e2

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

JSX.sublime-syntax

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ file_extensions:
77
uuid: 0ca76258-89e6-4055-9fe0-5c45dfea987c
88
contexts:
99

10-
# This is stolen from the JavaScript.sublime-syntax
10+
# These are stolen from the JavaScript.sublime-syntax
1111
comments:
1212
# - include: special-comments-conditional-compilation
1313
- match: /\*\*(?!/)
@@ -31,10 +31,38 @@ contexts:
3131
- match: \n
3232
pop: true
3333

34+
string-content:
35+
- match: \\\s*\n
36+
scope: constant.character.escape.newline.js
37+
- match: '\\(x[\da-fA-F][\da-fA-F]|u[\da-fA-F][\da-fA-F][\da-fA-F][\da-fA-F]|.)'
38+
scope: constant.character.escape.js
39+
40+
literal-string-template:
41+
- match: '`'
42+
scope: punctuation.definition.string.template.begin.js
43+
set:
44+
- meta_include_prototype: false
45+
- meta_scope: string.template.js
46+
- match: "`"
47+
scope: punctuation.definition.string.template.end.js
48+
pop: true
49+
- match: '\$\{'
50+
captures:
51+
0: punctuation.definition.template-expression.begin.js
52+
push:
53+
- clear_scopes: 1
54+
- meta_scope: meta.template.expression.js
55+
- meta_content_scope: source.js.embedded.expression
56+
- match: '\}'
57+
scope: punctuation.definition.template-expression.end.js
58+
pop: true
59+
- include: string-content
60+
3461
main:
3562
- match: ''
3663
push: 'scope:source.js'
3764
with_prototype:
65+
- include: literal-string-template
3866
- include: comments
3967
- match: \s*\(?(?=<([a-zA-Z]+|\/))
4068
scope: punctuation.section.embedded.begin.jsx

0 commit comments

Comments
 (0)