Skip to content

Commit 4a3afd9

Browse files
author
jneen
committed
use the keywords api for coffeescript
1 parent 6d00f9a commit 4a3afd9

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

lib/rouge/lexers/coffeescript.rb

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -126,18 +126,11 @@ def self.builtins
126126

127127
rule %r/#{id}(?=\s*:)/, Name::Attribute, :slash_starts_regex
128128

129-
rule %r/#{id}/ do |m|
130-
if self.class.keywords.include? m[0]
131-
token Keyword
132-
elsif self.class.constants.include? m[0]
133-
token Name::Constant
134-
elsif self.class.builtins.include? m[0]
135-
token Name::Builtin
136-
else
137-
token Name::Other
138-
end
139-
140-
push :slash_starts_regex
129+
keywords id do
130+
rule :keywords, Keyword, :slash_starts_regex
131+
rule :constants, Name::Constant, :slash_starts_regex
132+
rule :builtins, Name::Builtin, :slash_starts_regex
133+
default Name::Other, :slash_starts_regex
141134
end
142135

143136
rule %r/[{(\[;,]/, Punctuation, :slash_starts_regex

0 commit comments

Comments
 (0)