lib/rouge/lexers/xml.rb in rouge-3.20.0 vs lib/rouge/lexers/xml.rb in rouge-3.21.0

- old
+ new

@@ -10,10 +10,12 @@ filenames '*.xml', '*.xsl', '*.rss', '*.xslt', '*.xsd', '*.wsdl', '*.svg', '*.plist' mimetypes 'text/xml', 'application/xml', 'image/svg+xml', 'application/rss+xml', 'application/atom+xml' + # Documentation: https://www.w3.org/TR/xml11/#charsets and https://www.w3.org/TR/xml11/#sec-suggested-names + def self.detect?(text) return false if text.doctype?(/html/) return true if text =~ /\A<\?xml\b/ return true if text.doctype? end @@ -25,24 +27,24 @@ rule %r/<!--/, Comment, :comment rule %r/<\?.*?\?>/, Comment::Preproc rule %r/<![^>]*>/, Comment::Preproc # open tags - rule %r(<\s*[\w:.-]+)m, Name::Tag, :tag + rule %r(<\s*[\p{L}:_][\p{Word}\p{Cf}:.·-]*)m, Name::Tag, :tag # self-closing tags - rule %r(<\s*/\s*[\w:.-]+\s*>)m, Name::Tag + rule %r(<\s*/\s*[\p{L}:_][\p{Word}\p{Cf}:.·-]*\s*>)m, Name::Tag end state :comment do rule %r/[^-]+/m, Comment rule %r/-->/, Comment, :pop! rule %r/-/, Comment end state :tag do rule %r/\s+/m, Text - rule %r/[\w.:-]+\s*=/m, Name::Attribute, :attr + rule %r/[\p{L}:_][\p{Word}\p{Cf}:.·-]*\s*=/m, Name::Attribute, :attr rule %r(/?\s*>), Name::Tag, :pop! end state :attr do rule %r/\s+/m, Text