diff options
author | blackbird <devnull@localhost> | 2007-01-12 05:25:09 +0100 |
---|---|---|
committer | blackbird <devnull@localhost> | 2007-01-12 05:25:09 +0100 |
commit | a41305771899a6b3310c186ae1753e6004eceb54 (patch) | |
tree | 82748d5842bde71f81442dd0fd9197ba9e36cf30 | |
parent | c70e9a8d949549dd2a0ef8edc9e57437a2e6ec0d (diff) | |
download | pygments-a41305771899a6b3310c186ae1753e6004eceb54.tar.gz |
[svn] fixed bug in pytb lexer declaration, added ben bangerts mako lexers, documented missing lexers, updated CHANGES
-rw-r--r-- | CHANGES | 6 | ||||
-rw-r--r-- | docs/src/lexers.txt | 108 | ||||
-rw-r--r-- | docs/src/tokens.txt | 2 | ||||
-rw-r--r-- | pygments/lexers/_mapping.py | 7 | ||||
-rw-r--r-- | pygments/lexers/agile.py | 2 | ||||
-rw-r--r-- | pygments/lexers/templates.py | 93 |
6 files changed, 211 insertions, 7 deletions
@@ -9,8 +9,14 @@ Version 0.7 - Added Python traceback lexer, thanks to Tim Hatch. +- Added Mako lexers by Ben Bangert. + - Added "fruity" style, another dark background originally vim-based theme. +- Added sources.list lexer by Dennis Kaarsemaker. + + +======= - Fixed tickets #167, #178, #179, #180. - Added token stream filters. diff --git a/docs/src/lexers.txt b/docs/src/lexers.txt index 7a02de6c..262f92f2 100644 --- a/docs/src/lexers.txt +++ b/docs/src/lexers.txt @@ -81,10 +81,11 @@ Agile languages >>> a = 'foo' >>> print a - 'foo' - >>> 1/0 + foo + >>> 1 / 0 Traceback (most recent call last): - ... + File "<stdin>", line 1, in <module> + ZeroDivisionError: integer division or modulo by zero :Aliases: ``pycon`` :Filename patterns: None @@ -341,6 +342,7 @@ Template languages :Aliases: ``erb`` :Filename patterns: None + :Mimetypes: None `RhtmlLexer` @@ -352,6 +354,7 @@ Template languages :Aliases: ``rhtml``, ``html+erb``, ``html+ruby`` :Filename patterns: ``*.rhtml`` + :Mimetypes: None `XmlErbLexer` @@ -361,6 +364,7 @@ Template languages :Aliases: ``xml+erb``, ``xml+ruby`` :Filename patterns: None + :Mimetypes: None `CssErbLexer` @@ -369,6 +373,7 @@ Template languages :Aliases: ``css+erb``, ``css+ruby`` :Filename patterns: None + :Mimetypes: None `JavascriptErbLexer` @@ -378,6 +383,7 @@ Template languages :Aliases: ``js+erb``, ``javascript+erb``, ``js+ruby``, ``javascript+ruby`` :Filename patterns: None + :Mimetypes: None `HtmlPhpLexer` @@ -399,6 +405,7 @@ Template languages :Aliases: ``xml+php`` :Filename patterns: None + :Mimetypes: None `CssPhpLexer` @@ -407,6 +414,7 @@ Template languages :Aliases: ``css+php`` :Filename patterns: None + :Mimetypes: None `JavascriptPhpLexer` @@ -416,6 +424,7 @@ Template languages :Aliases: ``js+php``, ``javascript+php`` :Filename patterns: None + :Mimetypes: None `DjangoLexer` @@ -428,6 +437,7 @@ Template languages :Aliases: ``django``, ``jinja`` :Filename patterns: None + :Mimetypes: None `HtmlDjangoLexer` @@ -439,6 +449,7 @@ Template languages :Aliases: ``html+django``, ``html+jinja`` :Filename patterns: None + :Mimetypes: None `XmlDjangoLexer` @@ -448,6 +459,7 @@ Template languages :Aliases: ``xml+django``, ``xml+jinja`` :Filename patterns: None + :Mimetypes: None `CssDjangoLexer` @@ -457,6 +469,7 @@ Template languages :Aliases: ``css+django``, ``css+jinja`` :Filename patterns: None + :Mimetypes: None `JavascriptDjangoLexer` @@ -467,6 +480,7 @@ Template languages :Aliases: ``javascript+django``, ``js+django``, ``javascript+jinja``, ``js+jinja`` :Filename patterns: None + :Mimetypes: None `SmartyLexer` @@ -478,6 +492,7 @@ Template languages :Aliases: ``smarty`` :Filename patterns: None + :Mimetypes: None `HtmlSmartyLexer` @@ -489,6 +504,7 @@ Template languages :Aliases: ``html+smarty`` :Filename patterns: None + :Mimetypes: None `XmlSmartyLexer` @@ -498,6 +514,7 @@ Template languages :Aliases: ``xml+smarty`` :Filename patterns: None + :Mimetypes: None `CssSmartyLexer` @@ -507,6 +524,7 @@ Template languages :Aliases: ``css+smarty`` :Filename patterns: None + :Mimetypes: None `JavascriptSmartyLexer` @@ -516,6 +534,7 @@ Template languages :Aliases: ``javascript+smarty`` :Filename patterns: None + :Mimetypes: None `GenshiTextLexer` @@ -525,6 +544,7 @@ Template languages :Aliases: ``genshitext`` :Filename patterns: None + :Mimetypes: None `HtmlGenshiLexer` @@ -534,6 +554,7 @@ Template languages :Aliases: ``html+genshi``, ``html+kid`` :Filename patterns: None + :Mimetypes: None `GenshiLexer` @@ -543,6 +564,7 @@ Template languages :Aliases: ``genshi``, ``kid``, ``xml+genshi``, ``xml.kid`` :Filename patterns: ``*.kid`` + :Mimetypes: None `JavascriptGenshiLexer` @@ -552,6 +574,7 @@ Template languages :Aliases: ``js+genshitext``, ``js+genshi``, ``javascript+genshitext``, ``javascript+genshi`` :Filename patterns: None + :Mimetypes: None `CssGenshiLexer` @@ -560,6 +583,7 @@ Template languages :Aliases: ``css+genshitext``, ``css+genshi`` :Filename patterns: None + :Mimetypes: None `MyghtyLexer` @@ -573,6 +597,7 @@ Template languages :Aliases: ``myghty`` :Filename patterns: ``*.myt``, ``autodelegate`` + :Mimetypes: None `MyghtyHtmlLexer` @@ -584,6 +609,7 @@ Template languages :Aliases: ``html+myghty`` :Filename patterns: None + :Mimetypes: None `MyghtyXmlLexer` @@ -595,6 +621,7 @@ Template languages :Aliases: ``xml+myghty`` :Filename patterns: None + :Mimetypes: None `MyghtyJavascriptLexer` @@ -606,6 +633,7 @@ Template languages :Aliases: ``js+myghty``, ``javascript+myghty`` :Filename patterns: None + :Mimetypes: None `MyghtyCssLexer` @@ -617,6 +645,69 @@ Template languages :Aliases: ``css+myghty`` :Filename patterns: None + :Mimetypes: None + + +`MakoLexer` + + Generic `mako templates`_ lexer. Code that isn't Mako + markup is yielded as `Token.Other`. + + *New in Pygments 0.7.* + + .. _mako templates: http://www.makotemplates.org/ + + :Aliases: ``mako`` + :Filename patterns: ``*.mao`` + :Mimetypes: None + + +`MakoHtmlLexer` + + Subclass of the `MakoLexer` that highlights unlexer data + with the `HtmlLexer`. + + *New in Pygments 0.7.* + + :Aliases: ``html+mako`` + :Filename patterns: None + :Mimetypes: None + + +`MakoXmlLexer` + + Subclass of the `MakoLexer` that highlights unlexer data + with the `XmlLexer`. + + *New in Pygments 0.7.* + + :Aliases: ``xml+mako`` + :Filename patterns: None + :Mimetypes: None + + +`MakoJavascriptLexer` + + Subclass of the `MakoLexer` that highlights unlexer data + with the `JavascriptLexer`. + + *New in Pygments 0.7.* + + :Aliases: ``js+mako``, ``javascript+mako`` + :Filename patterns: None + :Mimetypes: None + + +`MakoCssLexer` + + Subclass of the `MakoLexer` that highlights unlexer data + with the `CssLexer`. + + *New in Pygments 0.7.* + + :Aliases: ``css+mako`` + :Filename patterns: None + :Mimetypes: None Other languages @@ -725,6 +816,17 @@ Text lexers :Mimetypes: None +`SourcesListLexer` + + Lexer that highlights debian sources.list files. + + *New in Pygments 0.7.* + + :Aliases: ``sources.list``, ``sourceslist`` + :Filename patterns: ``sources.list`` + :Mimetypes: None + + `BBCodeLexer` A Lexer that highlights BBCode(-like) syntax. diff --git a/docs/src/tokens.txt b/docs/src/tokens.txt index ea314dbb..113f0a8c 100644 --- a/docs/src/tokens.txt +++ b/docs/src/tokens.txt @@ -302,3 +302,5 @@ highlight a programming language but a patch file. `Generic.Traceback` Marks the token value as a part of an error traceback. + +.. _filters: filters.txt diff --git a/pygments/lexers/_mapping.py b/pygments/lexers/_mapping.py index eb695411..0ee8a0e0 100644 --- a/pygments/lexers/_mapping.py +++ b/pygments/lexers/_mapping.py @@ -51,6 +51,11 @@ LEXERS = { 'JavascriptSmartyLexer': ('pygments.lexers.templates', 'JavaScript+Smarty', ('js+smarty', 'javascript+smarty'), (), ()), 'LuaLexer': ('pygments.lexers.agile', 'Lua', ('lua',), ('*.lua',), ('text/x-lua', 'application/x-lua')), 'MakefileLexer': ('pygments.lexers.text', 'Makefile', ('make', 'makefile', 'mf'), ('*.mak', 'Makefile', 'makefile'), ('text/x-makefile',)), + 'MakoCssLexer': ('pygments.lexers.templates', 'CSS+Mako', ('css+mako',), (), ()), + 'MakoHtmlLexer': ('pygments.lexers.templates', 'HTML+Mako', ('html+mako',), (), ()), + 'MakoJavascriptLexer': ('pygments.lexers.templates', 'JavaScript+Mako', ('js+mako', 'javascript+mako'), (), ()), + 'MakoLexer': ('pygments.lexers.templates', 'Mako', ('mako',), ('*.mao',), ()), + 'MakoXmlLexer': ('pygments.lexers.templates', 'XML+Mako', ('xml+mako',), (), ()), 'MoinWikiLexer': ('pygments.lexers.text', 'MoinMoin/Trac Wiki markup', ('trac-wiki', 'moin'), (), ('text/x-trac-wiki',)), 'MyghtyCssLexer': ('pygments.lexers.templates', 'CSS+Myghty', ('css+myghty',), (), ()), 'MyghtyHtmlLexer': ('pygments.lexers.templates', 'HTML+Myghty', ('html+myghty',), (), ()), @@ -61,7 +66,7 @@ LEXERS = { 'PhpLexer': ('pygments.lexers.web', 'PHP', ('php', 'php3', 'php4', 'php5'), ('*.php', '*.php[345]'), ()), 'PythonConsoleLexer': ('pygments.lexers.agile', 'Python console session', ('pycon',), (), ()), 'PythonLexer': ('pygments.lexers.agile', 'Python', ('python', 'py'), ('*.py', '*.pyw'), ('text/x-python', 'application/x-python')), - 'PythonTracebackLexer': ('pygments.lexers.agile', ('PythonTraceback',), ('pytb',), ('*.pytb',), ('text/x-python-traceback',)), + 'PythonTracebackLexer': ('pygments.lexers.agile', 'PythonTraceback', ('pytb',), ('*.pytb',), ('text/x-python-traceback',)), 'RawTokenLexer': ('pygments.lexers.special', 'Raw token data', ('raw',), ('*.raw',), ('application/x-pygments-tokens',)), 'RhtmlLexer': ('pygments.lexers.templates', 'RHTML', ('rhtml', 'html+erb', 'html+ruby'), ('*.rhtml',), ()), 'RubyConsoleLexer': ('pygments.lexers.agile', 'Ruby irb session', ('rbcon', 'irb'), (), ()), diff --git a/pygments/lexers/agile.py b/pygments/lexers/agile.py index e980bc2b..7337b323 100644 --- a/pygments/lexers/agile.py +++ b/pygments/lexers/agile.py @@ -207,7 +207,7 @@ class PythonConsoleLexer(Lexer): class PythonTracebackLexer(RegexLexer): - name = 'PythonTraceback', + name = 'PythonTraceback' aliases = ['pytb'] filenames = ['*.pytb'] mimetypes = ['text/x-python-traceback'] diff --git a/pygments/lexers/templates.py b/pygments/lexers/templates.py index be8070c3..694b85d2 100644 --- a/pygments/lexers/templates.py +++ b/pygments/lexers/templates.py @@ -5,7 +5,8 @@ Lexers for various template engines. - :copyright: 2006 by Armin Ronacher, Georg Brandl, Matt Good. + :copyright: 2006 by Armin Ronacher, Georg Brandl, Matt Good, + Ben Bangert. :license: BSD, see LICENSE for more details. """ @@ -33,7 +34,9 @@ __all__ = ['HtmlPhpLexer', 'XmlPhpLexer', 'CssPhpLexer', 'JavascriptDjangoLexer', 'GenshiLexer', 'HtmlGenshiLexer', 'GenshiTextLexer', 'CssGenshiLexer', 'JavascriptGenshiLexer', 'MyghtyLexer', 'MyghtyHtmlLexer', 'MyghtyXmlLexer', - 'MyghtyCssLexer', 'MyghtyJavascriptLexer'] + 'MyghtyCssLexer', 'MyghtyJavascriptLexer', 'MakoLexer', + 'MakoHtmlLexer', 'MakoXmlLexer', 'MakoJavascriptLexer', + 'MakoCssLexer'] class ErbLexer(Lexer): @@ -298,6 +301,92 @@ class MyghtyCssLexer(DelegatingLexer): **options) +class MakoLexer(RegexLexer): + name = 'Mako' + aliases = ['mako'] + filenames = ['*.mao'] + + tokens = { + 'root': [ + (r'(\s*)(\%)(\s*end(?:\w+))(\n|\Z)', + bygroups(Text, Comment.Preproc, Keyword, Other)), + (r'(\s*)(\%)([^\n]*)(\n|\Z)', + bygroups(Text, Comment.Preproc, using(PythonLexer), Other)), + (r'(\s*)(#[^\n]*)(\n|\Z)', + bygroups(Text, Comment.Preproc, Other)), + (r'(<%)(def|call|namespace|text)', bygroups(Comment.Preproc, Name.Builtin), 'tag'), + (r'(</%)(def|call|namespace|text)(>)', bygroups(Comment.Preproc, Name.Builtin, Comment.Preproc)), + (r'<%(?=(include|inherit|namespace|page))', Comment.Preproc, 'ondeftags'), + (r'(<%(?:!?))(.*?)(%>)(?s)', bygroups(Comment.Preproc, using(PythonLexer), Comment.Preproc)), + (r'(\$\{)(.*?)(\})', + bygroups(Comment.Preproc, using(PythonLexer), Comment.Preproc)), + (r'''(?sx) + (.+?) # anything, followed by: + (?: + (?<=\n)(?=[%#]) | # an eval or comment line + (?=</?%) | # a python block + # call start or end + (?=\$\{) | # a substitution + (?<=\n)(?=\s*%) | + # - don't consume + (\\\n) | # an escaped newline + \Z # end of string + ) + ''', bygroups(Other, Operator)), + (r'\s+', Text), + ], + 'ondeftags': [ + (r'<%', Comment.Preproc), + (r'(?<=<%)(include|inherit|namespace|page)', Name.Builtin), + include('tag'), + ], + 'tag': [ + (r'((?:\w+)\s*=)\s*(".*?")', + bygroups(Name.Attribute, String)), + (r'/?\s*>', Comment.Preproc, '#pop'), + (r'\s+', Text), + ], + 'attr': [ + ('".*?"', String, '#pop'), + ("'.*?'", String, '#pop'), + (r'[^\s>]+', String, '#pop'), + ], + } + + +class MakoHtmlLexer(DelegatingLexer): + name = 'HTML+Mako' + aliases = ['html+mako'] + + def __init__(self, **options): + super(MakoHtmlLexer, self).__init__(HtmlLexer, MakoLexer, + **options) + +class MakoXmlLexer(DelegatingLexer): + name = 'XML+Mako' + aliases = ['xml+mako'] + + def __init__(self, **options): + super(MakoXmlLexer, self).__init__(XmlLexer, MakoLexer, + **options) + +class MakoJavascriptLexer(DelegatingLexer): + name = 'JavaScript+Mako' + aliases = ['js+mako', 'javascript+mako'] + + def __init__(self, **options): + super(MakoJavascriptLexer, self).__init__(JavascriptLexer, + MakoLexer, **options) + +class MakoCssLexer(DelegatingLexer): + name = 'CSS+Mako' + aliases = ['css+mako'] + + def __init__(self, **options): + super(MakoCssLexer, self).__init__(CssLexer, MakoLexer, + **options) + + # Genshi lexers courtesy of Matt Good. class GenshiTextLexer(RegexLexer): |