Skip to content

Commit

Permalink
add handling of string interpolation in Prism #321
Browse files Browse the repository at this point in the history
  • Loading branch information
jcubic committed May 13, 2024
1 parent 224a3de commit 19abe58
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions lib/js/prism.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,31 @@ Prism.languages.insertBefore('scheme', 'string', {
greedy: true
}
});
// modification of PrismJS JavaScript string interpolation
Prism.languages.insertBefore('scheme', 'string', {
'template-string': {
pattern: /#"(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\"])*"/,
greedy: true,
inside: {
'template-punctuation': {
pattern: /^#"|"$/,
alias: 'string'
},
'interpolation': {
pattern: /((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,
lookbehind: true,
inside: {
'interpolation-punctuation': {
pattern: /^\$\{|\}$/,
alias: 'punctuation'
},
rest: Prism.languages.scheme
}
},
'string': /[\s\S]+/
}
}
});
// properties of object literals
Prism.languages.insertBefore('scheme', 'string', {
variable: {
Expand Down

0 comments on commit 19abe58

Please sign in to comment.