Skip to content

Commit

Permalink
Handle backticked names
Browse files Browse the repository at this point in the history
  • Loading branch information
lordcodes committed Sep 21, 2018
1 parent 913f081 commit f2635cd
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/rouge/lexers/kotlin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ class Kotlin < RegexLexer
)

name = %r'@?[_\p{Lu}\p{Ll}\p{Lt}\p{Lm}\p{Nl}][\p{Lu}\p{Ll}\p{Lt}\p{Lm}\p{Nl}\p{Nd}\p{Pc}\p{Cf}\p{Mn}\p{Mc}]*'
name_backtick = %r'#{name}|`#{name}`'

id = %r'(#{name}|`#{name}`)'
id = %r'(#{name_backtick})'

state :root do
rule %r'^\s*\[.*?\]', Name::Attribute
Expand Down Expand Up @@ -76,10 +77,10 @@ class Kotlin < RegexLexer
end

state :function do
rule %r'(<)(#{name}(?:(?:,\s*#{name})*))(>)(\s+)' do
rule %r'(<)(#{name_backtick}(?:(?:,\s*#{name_backtick})*))(>)(\s+)' do
groups Punctuation, Text, Punctuation, Text
end
rule %r'(#{name})(\.)' do
rule %r'(#{name_backtick})(\.)' do
groups Name::Class, Punctuation
end
rule id, Name::Function, :pop!
Expand Down

0 comments on commit f2635cd

Please sign in to comment.