Skip to content

Commit e4044a5

Browse files
committed
add handling of string interpolation in Prism jcubic#321
1 parent 9af38f5 commit e4044a5

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

lib/js/prism.js

+25
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,31 @@ Prism.languages.insertBefore('scheme', 'string', {
2424
greedy: true
2525
}
2626
});
27+
// modification of PrismJS JavaScript string interpolation
28+
Prism.languages.insertBefore('scheme', 'string', {
29+
'template-string': {
30+
pattern: /#"(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\"])*"/,
31+
greedy: true,
32+
inside: {
33+
'template-punctuation': {
34+
pattern: /^#"|"$/,
35+
alias: 'string'
36+
},
37+
'interpolation': {
38+
pattern: /((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,
39+
lookbehind: true,
40+
inside: {
41+
'interpolation-punctuation': {
42+
pattern: /^\$\{|\}$/,
43+
alias: 'punctuation'
44+
},
45+
rest: Prism.languages.scheme
46+
}
47+
},
48+
'string': /[\s\S]+/
49+
}
50+
}
51+
});
2752
// properties of object literals
2853
Prism.languages.insertBefore('scheme', 'string', {
2954
variable: {

0 commit comments

Comments
 (0)