Skip to content

Commit de97ef7

Browse files
authored
Merge branch 'rouge-ruby:master' into feat.bicepLexer
2 parents 450356d + b274a10 commit de97ef7

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/rouge/lexers/javascript.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,14 @@ def self.id_regex
190190

191191
rule %r/function(?=(\(.*\)))/, Keyword::Declaration # For anonymous functions
192192

193-
rule %r/(#{id})[ \t]*(?=(\(.*\)))/m, Name::Function
193+
rule %r/(#{id})[ \t]*(?=(\(.*\)))/m do |m|
194+
if self.class.keywords.include? m[1]
195+
# "if" in "if (...)" or "switch" in "switch (...)" are recognized as keywords.
196+
token Keyword
197+
else
198+
token Name::Function
199+
end
200+
end
194201

195202
rule %r/[{}]/, Punctuation, :statement
196203

0 commit comments

Comments
 (0)