Skip to content

Commit 39e0632

Browse files
committed
Fix consecutive caps ending
Signed-off-by: jimtng <[email protected]>
1 parent 6a234d1 commit 39e0632

File tree

4 files changed

+5
-8
lines changed

4 files changed

+5
-8
lines changed

CHANGES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Core Grammars:
44

5-
- fix(ruby) highlight entire class name even when it contains underscores
5+
- fix(ruby) highlight entire class name even when it contains underscores or ends with consecutive caps
66

77

88
## Version 11.11.1

src/languages/ruby.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,7 @@ export default function(hljs) {
1111
const regex = hljs.regex;
1212
const RUBY_METHOD_RE = '([a-zA-Z_]\\w*[!?=]?|[-+~]@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?)';
1313
// TODO: move concepts like CAMEL_CASE into `modes.js`
14-
const CLASS_NAME_RE = regex.either(
15-
/\b([A-Z]+[a-z0-9_]+)+/,
16-
// ends in caps
17-
/\b([A-Z]+[a-z0-9_]+)+[A-Z]+/,
18-
)
19-
;
14+
const CLASS_NAME_RE = /\b([A-Z]+[a-z0-9_]+)+[A-Z]*/;
2015
const CLASS_NAME_WITH_NAMESPACE_RE = regex.concat(CLASS_NAME_RE, /(::\w+)*/)
2116
// very popular ruby built-ins that one might even assume
2217
// are actual keywords (despite that not being the case)

test/markup/ruby/classes.expect.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
<span class="hljs-title class_">Class</span>
22
<span class="hljs-title class_">ClassName</span>
33
<span class="hljs-title class_">Class_Name</span>
4+
<span class="hljs-title class_">ClassNAME</span>

test/markup/ruby/classes.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
Class
22
ClassName
3-
Class_Name
3+
Class_Name
4+
ClassNAME

0 commit comments

Comments
 (0)