Skip to content

Commit c884428

Browse files
Highlight JS tagged template literals (#1931)
This adds support for highlighting embedded languages in JavaScript tagged template literals.
1 parent 452d5c7 commit c884428

File tree

21 files changed

+901
-41
lines changed

21 files changed

+901
-41
lines changed

components.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,18 @@
466466
],
467467
"owner": "RunDevelopment"
468468
},
469+
"js-templates": {
470+
"title": "JS Templates",
471+
"require": "javascript",
472+
"peerDependencies": [
473+
"css",
474+
"css-extras",
475+
"graphql",
476+
"markdown",
477+
"markup"
478+
],
479+
"owner": "RunDevelopment"
480+
},
469481
"json": {
470482
"title": "JSON",
471483
"owner": "CupOfTea696"
@@ -750,7 +762,8 @@
750762
"require": ["markup", "javascript"],
751763
"peerDependencies": [
752764
"jsdoc",
753-
"js-extras"
765+
"js-extras",
766+
"js-templates"
754767
],
755768
"owner": "vkbansal"
756769
},
@@ -892,6 +905,7 @@
892905
"typescript": {
893906
"title": "TypeScript",
894907
"require": "javascript",
908+
"peerDependencies": "js-templates",
895909
"alias": "ts",
896910
"owner": "vkbansal"
897911
},

components/prism-javascript.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,16 @@ Prism.languages.insertBefore('javascript', 'keyword', {
6161

6262
Prism.languages.insertBefore('javascript', 'string', {
6363
'template-string': {
64-
pattern: /`(?:\\[\s\S]|\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})+}|[^\\`])*`/,
64+
pattern: /`(?:\\[\s\S]|\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})+}|(?!\${)[^\\`])*`/,
6565
greedy: true,
6666
inside: {
67+
'template-punctuation': {
68+
pattern: /^`|`$/,
69+
alias: 'string'
70+
},
6771
'interpolation': {
68-
pattern: /\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})+}/,
72+
pattern: /((?:^|[^\\])(?:\\{2})*)\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})+}/,
73+
lookbehind: true,
6974
inside: {
7075
'interpolation-punctuation': {
7176
pattern: /^\${|}$/,

components/prism-javascript.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)