Commits

Tim Hatch committed b96849d

Cleanups by regexlint for #977

Comments (0)

Files changed (1)

pygments/lexers/templates.py

 
     tokens = {
         'root': [
-            (r'[^\{]+', Text),
+            (r'[^{]+', Text),
             # tags and block tags
             (r'(\{%)(\s*)', bygroups(Punctuation, Whitespace), 'tag-or-block'),
             # output tags
-            (r'(\{\{)(\s*)([^\s(\}\})]+)',
+            (r'({{)(\s*)([^\s}]+)',
              bygroups(Punctuation, Whitespace, using(this, state = 'generic')),
              'output'),
-            (r'\{', Text)
+            (r'{', Text)
         ],
 
         'tag-or-block': [
              bygroups(Name.Tag, None, Whitespace, Punctuation), '#pop'),
 
             # builtin tags (assign and include are handled together with usual tags)
-            (r'(cycle)(\s+)(([^\s:]*)(:))?(\s*)',
-             bygroups(Name.Tag, Whitespace, None,
+            (r'(cycle)(\s+)(?:([^\s:]*)(:))?(\s*)',
+             bygroups(Name.Tag, Whitespace,
                       using(this, state='generic'), Punctuation, Whitespace),
              'variable-tag-markup'),
 
             include('end-of-block'),
             include('whitespace'),
 
-            (r'([^\s=!><]+)(\s*)([=!><]=?)(\s*)([^\s]+)(\s*)(%\})',
+            (r'([^\s=!><]+)(\s*)([=!><]=?)(\s*)(\S+)(\s*)(%\})',
              bygroups(using(this, state = 'generic'), Whitespace, Operator,
                       Whitespace, using(this, state = 'generic'), Whitespace,
                       Punctuation)),
-            (r'\b((!)|(not\b))', bygroups(None, Operator, Operator.Word)),
+            (r'\b!', Operator),
+            (r'\bnot\b', Operator.Word),
             (r'([\w\.\'"]+)(\s+)(contains)(\s+)([\w\.\'"]+)',
              bygroups(using(this, state = 'generic'), Whitespace, Operator.Word,
                       Whitespace, using(this, state = 'generic'))),