Skip to content

Commit 31a2a69

Browse files
committed
Ruby: Ensure module syntax is not confused with symbols. Fix #1336
1 parent 92ffeb2 commit 31a2a69

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

components/prism-ruby.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,10 @@
6969
}
7070
],
7171
'variable': /[@$]+[a-zA-Z_]\w*(?:[?!]|\b)/,
72-
'symbol': /:[a-zA-Z_]\w*(?:[?!]|\b)/
72+
'symbol': {
73+
pattern: /(^|[^:]):[a-zA-Z_]\w*(?:[?!]|\b)/,
74+
lookbehind: true
75+
}
7376
});
7477

7578
Prism.languages.insertBefore('ruby', 'number', {

components/prism-ruby.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/languages/ruby/issue1336.test

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
:Foo
2+
Foo::Bar
3+
4+
----------------------------------------------------
5+
6+
[
7+
["symbol", ":Foo"],
8+
["constant", "Foo"],
9+
["punctuation", ":"], ["punctuation", ":"],
10+
["constant", "Bar"]
11+
]
12+
13+
----------------------------------------------------
14+
15+
Ensures module syntax is not confused with symbols. See #1336

0 commit comments

Comments
 (0)