diff options
-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) ] |