diff options
author | blackbird <devnull@localhost> | 2007-03-28 22:08:03 +0200 |
---|---|---|
committer | blackbird <devnull@localhost> | 2007-03-28 22:08:03 +0200 |
commit | 732839419f6a3772c40bfed74dcf05f18d95306f (patch) | |
tree | 8160c67f41ac44b0dfbbfb28c966f7d56a1502c3 | |
parent | da36a7ad31253086a004fb3c493f1c1c69a9837d (diff) | |
download | pygments-732839419f6a3772c40bfed74dcf05f18d95306f.tar.gz |
[svn] fixed debugging annoyance in pygments and added support for a "-" after a tag/variable in thy jinja/django highlighter
-rw-r--r-- | pygments/lexer.py | 2 | ||||
-rw-r--r-- | pygments/lexers/templates.py | 18 |
2 files changed, 10 insertions, 10 deletions
diff --git a/pygments/lexer.py b/pygments/lexer.py index ab7fdf2f..2bf1d2c6 100644 --- a/pygments/lexer.py +++ b/pygments/lexer.py @@ -371,7 +371,7 @@ class RegexLexerMeta(LexerMeta): (tdef[0], state, cls, err)) assert type(tdef[1]) is _TokenType or callable(tdef[1]), \ - 'token type must be simple type or callable, not %r' % tdef[1] + 'token type must be simple type or callable, not %r' % (tdef[1],) if len(tdef) == 2: new_state = None diff --git a/pygments/lexers/templates.py b/pygments/lexers/templates.py index cc1e1396..fc4a54f0 100644 --- a/pygments/lexers/templates.py +++ b/pygments/lexers/templates.py @@ -209,21 +209,21 @@ class DjangoLexer(RegexLexer): 'root': [ (r'[^\{]+', Other), (r'\{\{', Comment.Preproc, 'var'), - # jinja comments - (r'\{\*.*?\*\}', Comment), + # jinja/django comments + (r'\{[*#].*?[*#]\}', Comment), # django comments - (r'(\{\%)(\s*)(comment)(\s*)(\%\})(.*?)' - r'(\{\%)(\s*)(endcomment)(\s*)(\%\})', + (r'(\{\%)(\-?\s*)(comment)(\s*\-?)(\%\})(.*?)' + r'(\{\%)(\-?\s*)(endcomment)(\s*\-?)(\%\})', bygroups(Comment.Preproc, Text, Keyword, Text, Comment.Preproc, Comment, Comment.Preproc, Text, Keyword, Text, Comment.Preproc)), # raw jinja blocks - (r'(\{\%)(\s*)(raw)(\s*)(\%\})(.*?)' - r'(\{\%)(\s*)(endraw)(\s*)(\%\})', + (r'(\{\%)(\-?\s*)(raw)(\s*\-?)(\%\})(.*?)' + r'(\{\%)(\-?\s*)(endraw)(\s*\-?)(\%\})', bygroups(Comment.Preproc, Text, Keyword, Text, Comment.Preproc, Text, Comment.Preproc, Text, Keyword, Text, Comment.Preproc)), - (r'(\{\%)(\s*)([a-zA-Z_][a-zA-Z0-9_]*)', + (r'(\{\%)(\-?\s*)([a-zA-Z_][a-zA-Z0-9_]*)', bygroups(Comment.Preproc, Text, Keyword), 'block'), (r'\{', Other) ], @@ -245,12 +245,12 @@ class DjangoLexer(RegexLexer): ], 'var': [ (r'\s+', Text), - (r'\}\}', Comment.Preproc, '#pop'), + (r'(\-?)(\}\})', bygroups(Text, Comment.Preproc), '#pop'), include('varnames') ], 'block': [ (r'\s+', Text), - (r'\%\}', Comment.Preproc, '#pop'), + (r'(\-?)(\%\})', bygroups(Text, Comment.Preproc), '#pop'), include('varnames'), (r'.', Punctuation) ] |