Skip to content

Commit f7cca6e

Browse files
Allow comments after regexes
1 parent 9e2983f commit f7cca6e

3 files changed

Lines changed: 20 additions & 3 deletions

File tree

components/prism-ruby.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
}
5454
},
5555
{
56-
pattern: /(^|[^/])\/(?!\/)(?:\[[^\r\n\]]+\]|\\.|[^[/\\\r\n])+\/[gim]{0,3}(?=\s*(?:$|[\r\n,.;})]))/,
56+
pattern: /(^|[^/])\/(?!\/)(?:\[[^\r\n\]]+\]|\\.|[^[/\\\r\n])+\/[gim]{0,3}(?=\s*(?:$|[\r\n,.;})#]))/,
5757
lookbehind: true,
5858
greedy: true,
5959
inside: {

components/prism-ruby.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.

tests/languages/ruby/regex_feature.test

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
%r[foo?bar#{39+3}]
99
%r<foo?bar#{39+3}>
1010

11+
/foo/ # comment
12+
/foo#{bar}/ # comment
13+
1114
----------------------------------------------------
1215

1316
[
@@ -88,7 +91,21 @@
8891
["delimiter", "}"]
8992
]],
9093
">"
91-
]]
94+
]],
95+
96+
["regex", ["/foo/"]],
97+
["comment", "# comment"],
98+
99+
["regex", [
100+
"/foo",
101+
["interpolation", [
102+
["delimiter", "#{"],
103+
"bar",
104+
["delimiter", "}"]
105+
]],
106+
"/"
107+
]],
108+
["comment", "# comment"]
92109
]
93110

94111
----------------------------------------------------

0 commit comments

Comments
 (0)