Skip to content

Commit

Permalink
Ruby: Ensure module syntax is not confused with symbols. Fix #1336
Browse files Browse the repository at this point in the history
  • Loading branch information
Golmote committed Mar 8, 2018
1 parent 92ffeb2 commit 31a2a69
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
5 changes: 4 additions & 1 deletion components/prism-ruby.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@
}
],
'variable': /[@$]+[a-zA-Z_]\w*(?:[?!]|\b)/,
'symbol': /:[a-zA-Z_]\w*(?:[?!]|\b)/
'symbol': {
pattern: /(^|[^:]):[a-zA-Z_]\w*(?:[?!]|\b)/,
lookbehind: true
}
});

Prism.languages.insertBefore('ruby', 'number', {
Expand Down
2 changes: 1 addition & 1 deletion components/prism-ruby.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions tests/languages/ruby/issue1336.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
:Foo
Foo::Bar

----------------------------------------------------

[
["symbol", ":Foo"],
["constant", "Foo"],
["punctuation", ":"], ["punctuation", ":"],
["constant", "Bar"]
]

----------------------------------------------------

Ensures module syntax is not confused with symbols. See #1336

0 comments on commit 31a2a69

Please sign in to comment.