Skip to content

Commit 9e16493

Browse files
Added support for s regex flag (#1846)
This adds support for the ES2018 `s` (dotall) flag for regular expressions.
1 parent d2089d8 commit 9e16493

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

components/prism-javascript.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Prism.languages.javascript['class-name'][0].pattern = /(\b(?:class|interface|ext
2626

2727
Prism.languages.insertBefore('javascript', 'keyword', {
2828
'regex': {
29-
pattern: /((?:^|[^$\w\xA0-\uFFFF."'\])\s])\s*)\/(\[(?:[^\]\\\r\n]|\\.)*]|\\.|[^/\\\[\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})\]]))/,
29+
pattern: /((?:^|[^$\w\xA0-\uFFFF."'\])\s])\s*)\/(\[(?:[^\]\\\r\n]|\\.)*]|\\.|[^/\\\[\r\n])+\/[gimyus]{0,6}(?=\s*($|[\r\n,.;})\]]))/,
3030
lookbehind: true,
3131
greedy: true
3232
},

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.

prism.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,7 @@ Prism.languages.javascript['class-name'][0].pattern = /(\b(?:class|interface|ext
787787

788788
Prism.languages.insertBefore('javascript', 'keyword', {
789789
'regex': {
790-
pattern: /((?:^|[^$\w\xA0-\uFFFF."'\])\s])\s*)\/(\[(?:[^\]\\\r\n]|\\.)*]|\\.|[^/\\\[\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})\]]))/,
790+
pattern: /((?:^|[^$\w\xA0-\uFFFF."'\])\s])\s*)\/(\[(?:[^\]\\\r\n]|\\.)*]|\\.|[^/\\\[\r\n])+\/[gimyus]{0,6}(?=\s*($|[\r\n,.;})\]]))/,
791791
lookbehind: true,
792792
greedy: true
793793
},

tests/languages/javascript/regex_feature.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/foo bar/;
2-
/foo/gimyu,
2+
/foo/gimyus,
33
/[\[\]]{2,4}(?:foo)*/;
44
/foo"test"bar/;
55
/foo\//;
@@ -13,7 +13,7 @@
1313

1414
[
1515
["regex", "/foo bar/"], ["punctuation", ";"],
16-
["regex", "/foo/gimyu"], ["punctuation", ","],
16+
["regex", "/foo/gimyus"], ["punctuation", ","],
1717
["regex", "/[\\[\\]]{2,4}(?:foo)*/"], ["punctuation", ";"],
1818
["regex", "/foo\"test\"bar/"], ["punctuation", ";"],
1919
["regex", "/foo\\//"], ["punctuation", ";"],

0 commit comments

Comments
 (0)