Skip to content

Commit

Permalink
Improve matching for use and namespace in php
Browse files Browse the repository at this point in the history
  • Loading branch information
mcfedr committed Jul 9, 2019
1 parent df08855 commit 9af0a08
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/rouge/lexers/php.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ def self.detect?(text)
rule %r/[~!%^&*+=\|:.<>\/?@-]+/, Operator
rule %r/[\[\]{}();,]/, Punctuation
rule %r/(class|interface|trait)\b/, Keyword::Declaration, :classname
rule %r/use(\b (function|const))?\b/, Keyword::Namespace, :classname
rule %r/namespace\b/, Keyword::Namespace, :namespace
# anonymous functions
rule %r/(function)(\s*)(?=\()/ do
groups Keyword, Text
Expand Down Expand Up @@ -159,6 +161,11 @@ def self.detect?(text)
rule %r/\s+/, Text
rule %r/#{nsid}/, Name::Class, :pop!
end

state :namespace do
rule %r/\s+/, Text
rule %r/#{nsid}/, Name::Namespace, :pop!
end

state :funcname do
rule %r/#{id}/, Name::Function, :pop!
Expand Down

0 comments on commit 9af0a08

Please sign in to comment.