aboutsummaryrefslogtreecommitdiffstats
path: root/public/prism/prism-javascript.js
diff options
context:
space:
mode:
Diffstat (limited to 'public/prism/prism-javascript.js')
-rw-r--r--public/prism/prism-javascript.js23
1 files changed, 20 insertions, 3 deletions
diff --git a/public/prism/prism-javascript.js b/public/prism/prism-javascript.js
index 9d679c2..be663f4 100644
--- a/public/prism/prism-javascript.js
+++ b/public/prism/prism-javascript.js
@@ -57,9 +57,26 @@ Prism.languages.javascript['class-name'][0].pattern =
Prism.languages.insertBefore('javascript', 'keyword', {
regex: {
- // eslint-disable-next-line regexp/no-dupe-characters-character-class
- pattern:
- /((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)\/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/,
+ pattern: RegExp(
+ // lookbehind
+ // eslint-disable-next-line regexp/no-dupe-characters-character-class
+ /((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source +
+ // Regex pattern:
+ // There are 2 regex patterns here. The RegExp set notation proposal added support for nested character
+ // classes if the `v` flag is present. Unfortunately, nested CCs are both context-free and incompatible
+ // with the only syntax, so we have to define 2 different regex patterns.
+ /\//.source +
+ '(?:' +
+ /(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/
+ .source +
+ '|' +
+ // `v` flag syntax. This supports 3 levels of nested character classes.
+ /(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/
+ .source +
+ ')' +
+ // lookahead
+ /(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source
+ ),
lookbehind: true,
greedy: true,
inside: {