module Text.Highlighter.Lexers.Xml (lexer) where import Text.Regex.PCRE.Light import Text.Highlighter.Types lexer :: Lexer lexer = Lexer { lName = "XML" , lAliases = ["xml"] , lExtensions = [".xml", ".xsl", ".rss", ".xslt", ".xsd", ".wsdl"] , lMimetypes = ["text/xml", "application/xml", "image/svg+xml", "application/rss+xml", "application/atom+xml", "application/xsl+xml", "application/xslt+xml"] , lStart = root' , lFlags = [multiline, dotall] } comment' :: TokenMatcher comment' = [ tok "[^-]+" (Arbitrary "Comment") , tokNext "-->" (Arbitrary "Comment") Pop , tok "-" (Arbitrary "Comment") ] tag' :: TokenMatcher tag' = [ tok "\\s+" (Arbitrary "Text") , tokNext "[a-zA-Z0-9_.:-]+\\s*=" (Arbitrary "Name" :. Arbitrary "Attribute") (GoTo attr') , tokNext "/?\\s*>" (Arbitrary "Name" :. Arbitrary "Tag") Pop ] root' :: TokenMatcher root' = [ tok "[^<&]+" (Arbitrary "Text") , tok "&\\S*?;" (Arbitrary "Name" :. Arbitrary "Entity") , tok "\\<\\!\\[CDATA\\[.*?\\]\\]\\>" (Arbitrary "Comment" :. Arbitrary "Preproc") , tokNext "