lib/rouge/lexers/php.rb in rouge_ecl-0.0.1 vs lib/rouge/lexers/php.rb in rouge_ecl-1.0.0
- old
+ new
@@ -73,14 +73,14 @@
php_user_filter interface implements public private protected
abstract clone try catch throw this use namespace yield
)
end
- def self.detect?(text)
- return true if text.shebang?('php')
- return false if /^<\?hh/ =~ text
- return true if /^<\?php/ =~ text
+ def self.analyze_text(text)
+ return 1 if text.shebang?('php')
+ return 0.3 if /<\?(?!xml)/ =~ text
+ 0
end
state :root do
# some extremely rough heuristics to decide whether to start inline or not
rule(/\s*(?=<)/m) { delegate parent; push :template }
@@ -97,11 +97,11 @@
state :php do
rule /\?>/, Comment::Preproc, :pop!
# heredocs
rule /<<<('?)(#{id})\1\n.*?\n\2;?\n/im, Str::Heredoc
rule /\s+/, Text
- rule /#.*?$/, Comment::Single
- rule %r(//.*?$), Comment::Single
+ rule /#.*?\n/, Comment::Single
+ rule %r(//.*?\n), Comment::Single
# empty comment, otherwise seen as the start of a docstring
rule %r(/\*\*/), Comment::Multiline
rule %r(/\*\*.*?\*/)m, Str::Doc
rule %r(/\*.*?\*/)m, Comment::Multiline
rule /(->|::)(\s*)(#{id})/ do