lib/rouge/lexers/xml.rb in rouge-0.2.15 vs lib/rouge/lexers/xml.rb in rouge-0.3.0
- old
+ new
@@ -11,12 +11,14 @@
application/rss+xml
application/atom+xml
)
def self.analyze_text(text)
- return 0.5 if text.doctype?
- return 0.5 if text[0..1000] =~ %r(<.+?>.*?</.+?>)m
+ return 0.9 if text.doctype?
return 0.8 if text =~ /\A<\?xml\b/
+ start = text[0..1000]
+ return 0.6 if start =~ %r(<xml\b)
+ return 0.3 if start =~ %r(<.+?>.*?</.+?>)m
end
state :root do
rule /[^<&]+/, 'Text'
rule /&\S*?;/, 'Name.Entity'