diff options
author | Georg Brandl <georg@python.org> | 2014-09-19 23:57:16 +0200 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2014-09-19 23:57:16 +0200 |
commit | ed8910f067a347021854227f194f374c5b8cce2d (patch) | |
tree | 570cd80ca3431fdec19877440f7af4bc44209db7 | |
parent | 9d3184ead0ddafd2fe7278bd94eb815523773599 (diff) | |
download | pygments-ed8910f067a347021854227f194f374c5b8cce2d.tar.gz |
fix templates
-rw-r--r-- | pygments/lexers/templates.py | 54 |
1 files changed, 31 insertions, 23 deletions
diff --git a/pygments/lexers/templates.py b/pygments/lexers/templates.py index 0a7ce17d..b55ba4a9 100644 --- a/pygments/lexers/templates.py +++ b/pygments/lexers/templates.py @@ -14,6 +14,7 @@ import re from pygments.lexers.html import HtmlLexer, XmlLexer from pygments.lexers.javascript import JavascriptLexer, LassoLexer from pygments.lexers.css import CssLexer +from pygments.lexers.php import PhpLexer from pygments.lexers.python import PythonLexer from pygments.lexers.perl import PerlLexer from pygments.lexers.jvm import JavaLexer, TeaLangLexer @@ -106,7 +107,7 @@ class ErbLexer(Lexer): data = tokens.pop() r_idx = 0 for r_idx, r_token, r_value in \ - self.ruby_lexer.get_tokens_unprocessed(data): + self.ruby_lexer.get_tokens_unprocessed(data): yield r_idx + idx, r_token, r_value idx += len(data) state = 2 @@ -119,7 +120,7 @@ class ErbLexer(Lexer): yield idx, Comment.Preproc, tag[0] r_idx = 0 for r_idx, r_token, r_value in \ - self.ruby_lexer.get_tokens_unprocessed(tag[1:]): + self.ruby_lexer.get_tokens_unprocessed(tag[1:]): yield idx + 1 + r_idx, r_token, r_value idx += len(tag) state = 0 @@ -205,7 +206,7 @@ class VelocityLexer(RegexLexer): name = 'Velocity' aliases = ['velocity'] - filenames = ['*.vm','*.fhtml'] + filenames = ['*.vm', '*.fhtml'] flags = re.MULTILINE | re.DOTALL @@ -284,12 +285,12 @@ class VelocityHtmlLexer(DelegatingLexer): name = 'HTML+Velocity' aliases = ['html+velocity'] - alias_filenames = ['*.html','*.fhtml'] + alias_filenames = ['*.html', '*.fhtml'] mimetypes = ['text/html+velocity'] def __init__(self, **options): super(VelocityHtmlLexer, self).__init__(HtmlLexer, VelocityLexer, - **options) + **options) class VelocityXmlLexer(DelegatingLexer): @@ -301,7 +302,7 @@ class VelocityXmlLexer(DelegatingLexer): name = 'XML+Velocity' aliases = ['xml+velocity'] - alias_filenames = ['*.xml','*.vm'] + alias_filenames = ['*.xml', '*.vm'] mimetypes = ['application/xml+velocity'] def __init__(self, **options): @@ -653,7 +654,8 @@ class MakoHtmlLexer(DelegatingLexer): def __init__(self, **options): super(MakoHtmlLexer, self).__init__(HtmlLexer, MakoLexer, - **options) + **options) + class MakoXmlLexer(DelegatingLexer): """ @@ -669,7 +671,8 @@ class MakoXmlLexer(DelegatingLexer): def __init__(self, **options): super(MakoXmlLexer, self).__init__(XmlLexer, MakoLexer, - **options) + **options) + class MakoJavascriptLexer(DelegatingLexer): """ @@ -687,7 +690,8 @@ class MakoJavascriptLexer(DelegatingLexer): def __init__(self, **options): super(MakoJavascriptLexer, self).__init__(JavascriptLexer, - MakoLexer, **options) + MakoLexer, **options) + class MakoCssLexer(DelegatingLexer): """ @@ -703,7 +707,7 @@ class MakoCssLexer(DelegatingLexer): def __init__(self, **options): super(MakoCssLexer, self).__init__(CssLexer, MakoLexer, - **options) + **options) # Genshi and Cheetah lexers courtesy of Matt Good. @@ -1416,7 +1420,7 @@ class EvoqueLexer(RegexLexer): String, Punctuation)), # directives: evoque, overlay # see doc for handling first name arg: /directives/evoque/ - #+ minor inconsistency: the "name" in e.g. $overlay{name=site_base} + # + minor inconsistency: the "name" in e.g. $overlay{name=site_base} # should be using(PythonLexer), not passed out as String (r'(\$)(evoque|overlay)(\{(%)?)(\s*[#\w\-"\'.]+[^=,%}]+?)?' r'(.*?)((?(4)%)\})', @@ -1442,6 +1446,7 @@ class EvoqueLexer(RegexLexer): ], } + class EvoqueHtmlLexer(DelegatingLexer): """ Subclass of the `EvoqueLexer` that highlights unlexed data with the @@ -1458,6 +1463,7 @@ class EvoqueHtmlLexer(DelegatingLexer): super(EvoqueHtmlLexer, self).__init__(HtmlLexer, EvoqueLexer, **options) + class EvoqueXmlLexer(DelegatingLexer): """ Subclass of the `EvoqueLexer` that highlights unlexed data with the @@ -1474,6 +1480,7 @@ class EvoqueXmlLexer(DelegatingLexer): super(EvoqueXmlLexer, self).__init__(XmlLexer, EvoqueLexer, **options) + class ColdfusionLexer(RegexLexer): """ Coldfusion statements @@ -1554,7 +1561,7 @@ class ColdfusionMarkupLexer(RegexLexer): (r'[^#<]+', Other), (r'(#)(.*?)(#)', bygroups(Punctuation, using(ColdfusionLexer), Punctuation)), - #(r'<cfoutput.*?>', Name.Builtin, '#push'), + # (r'<cfoutput.*?>', Name.Builtin, '#push'), (r'</cfoutput.*?>', Name.Builtin, '#pop'), include('tags'), (r'(?s)<[^<>]*', Other), @@ -1593,7 +1600,7 @@ class ColdfusionCFCLexer(DelegatingLexer): def __init__(self, **options): super(ColdfusionCFCLexer, self).__init__(ColdfusionHtmlLexer, ColdfusionLexer, - **options) + **options) class SspLexer(DelegatingLexer): @@ -1634,13 +1641,13 @@ class TeaTemplateRootLexer(RegexLexer): (r'<%\S?', Keyword, 'sec'), (r'[^<]+', Other), (r'<', Other), - ], + ], 'sec': [ (r'%>', Keyword, '#pop'), # note: '\w\W' != '.' without DOTALL. (r'[\w\W]+?(?=%>|\Z)', using(TeaLangLexer)), - ], - } + ], + } class TeaTemplateLexer(DelegatingLexer): @@ -1773,6 +1780,7 @@ class LassoJavascriptLexer(DelegatingLexer): rv += 0.2 return rv + class HandlebarsLexer(RegexLexer): """ Generic `handlebars <http://handlebarsjs.com/>` template lexer. @@ -1912,14 +1920,14 @@ class LiquidLexer(RegexLexer): 'output': [ include('whitespace'), - ('\}\}', Punctuation, '#pop'), # end of output + ('\}\}', Punctuation, '#pop'), # end of output (r'\|', Punctuation, 'filters') ], 'filters': [ include('whitespace'), - (r'\}\}', Punctuation, ('#pop', '#pop')), # end of filters and output + (r'\}\}', Punctuation, ('#pop', '#pop')), # end of filters and output (r'([^\s\|:]+)(:?)(\s*)', bygroups(Name.Function, Punctuation, Whitespace), 'filter-markup') @@ -1992,22 +2000,22 @@ class LiquidLexer(RegexLexer): 'default-param-markup': [ include('param-markup'), - (r'.', Text) # fallback for switches / variables / un-quoted strings / ... + (r'.', Text) # fallback for switches / variables / un-quoted strings / ... ], 'variable-param-markup': [ include('param-markup'), include('variable'), - (r'.', Text) # fallback + (r'.', Text) # fallback ], 'tag-markup': [ - (r'%\}', Punctuation, ('#pop', '#pop')), # end of tag + (r'%\}', Punctuation, ('#pop', '#pop')), # end of tag include('default-param-markup') ], 'variable-tag-markup': [ - (r'%\}', Punctuation, ('#pop', '#pop')), # end of tag + (r'%\}', Punctuation, ('#pop', '#pop')), # end of tag include('variable-param-markup') ], @@ -2031,7 +2039,7 @@ class LiquidLexer(RegexLexer): (r'\d+', Number.Integer) ], - 'generic': [ # decides for variable, string, keyword or number + 'generic': [ # decides for variable, string, keyword or number include('keyword'), include('string'), include('number'), |