diff options
-rw-r--r-- | AUTHORS | 1 | ||||
-rw-r--r-- | CHANGES | 1 | ||||
-rw-r--r-- | pygments/lexers/_mapping.py | 1 | ||||
-rw-r--r-- | pygments/lexers/web.py | 46 |
4 files changed, 48 insertions, 1 deletions
@@ -37,6 +37,7 @@ Other contributors, listed alphabetically, are: * David Oliva -- Rebol lexer * Ronny Pfannschmidt -- BBCode lexer * Benjamin Peterson -- Test suite refactoring +* Justin Reidy -- MXML lexer * Andre Roberge -- Tango style * Mario Ruggier -- Evoque lexers * Stou Sandalski -- NumPy, FORTRAN, tcsh and XSLT lexers @@ -15,6 +15,7 @@ Version 1.1 * Evoque * Modelica * Rebol + * MXML - Fix a bug lexing extended Ruby strings. diff --git a/pygments/lexers/_mapping.py b/pygments/lexers/_mapping.py index ba3e3866..64d57cda 100644 --- a/pygments/lexers/_mapping.py +++ b/pygments/lexers/_mapping.py @@ -109,6 +109,7 @@ LEXERS = { 'ModelicaLexer': ('pygments.lexers.other', 'Modelica', ('modelica',), ('*.mo',), ('text/x-modelica',)), 'MoinWikiLexer': ('pygments.lexers.text', 'MoinMoin/Trac Wiki markup', ('trac-wiki', 'moin'), (), ('text/x-trac-wiki',)), 'MuPADLexer': ('pygments.lexers.math', 'MuPAD', ('mupad',), ('*.mu',), ()), + 'MxmlLexer': ('pygments.lexers.web', 'MXML', ('mxml',), ('*.mxml',), ()), 'MySqlLexer': ('pygments.lexers.other', 'MySQL', ('mysql',), (), ('text/x-mysql',)), 'MyghtyCssLexer': ('pygments.lexers.templates', 'CSS+Myghty', ('css+myghty',), (), ('text/css+myghty',)), 'MyghtyHtmlLexer': ('pygments.lexers.templates', 'HTML+Myghty', ('html+myghty',), (), ('text/html+myghty',)), diff --git a/pygments/lexers/web.py b/pygments/lexers/web.py index 757e51ec..2f9c9570 100644 --- a/pygments/lexers/web.py +++ b/pygments/lexers/web.py @@ -23,7 +23,8 @@ from pygments.util import get_bool_opt, get_list_opt, looks_like_xml, \ __all__ = ['HtmlLexer', 'XmlLexer', 'JavascriptLexer', 'CssLexer', - 'PhpLexer', 'ActionScriptLexer', 'XsltLexer', 'ActionScript3Lexer'] + 'PhpLexer', 'ActionScriptLexer', 'XsltLexer', 'ActionScript3Lexer', + 'MxmlLexer'] class JavascriptLexer(RegexLexer): @@ -653,3 +654,46 @@ class XsltLexer(XmlLexer): def analyse_text(text): if looks_like_xml(text) and '<xsl' in text: return 0.8 + + + +class MxmlLexer(RegexLexer): + """ + For MXML markup. + Nested AS3 in <script> tags is highlighted by the appropriate lexer. + """ + flags = re.MULTILINE | re.DOTALL + name = 'MXML' + aliases = ['mxml'] + filenames = ['*.mxml'] + mimetimes = ['text/xml', 'application/xml'] + + tokens = { + 'root': [ + ('[^<&]+', Text), + (r'&\S*?;', Name.Entity), + (r'(\<\!\[CDATA\[)(.*?)(\]\]\>)', + bygroups(String, using(ActionScript3Lexer), String)), + ('<!--', Comment, 'comment'), + (r'<\?.*?\?>', Comment.Preproc), + ('<![^>]*>', Comment.Preproc), + (r'<\s*[a-zA-Z0-9:._-]+', Name.Tag, 'tag'), + (r'<\s*/\s*[a-zA-Z0-9:._-]+\s*>', Name.Tag), + ], + 'comment': [ + ('[^-]+', Comment), + ('-->', Comment, '#pop'), + ('-', Comment), + ], + 'tag': [ + (r'\s+', Text), + (r'[a-zA-Z0-9_.:-]+\s*=', Name.Attribute, 'attr'), + (r'/?\s*>', Name.Tag, '#pop'), + ], + 'attr': [ + ('\s+', Text), + ('".*?"', String, '#pop'), + ("'.*?'", String, '#pop'), + (r'[^\s>]+', String, '#pop'), + ], + } |