Tim Hatch avatar Tim Hatch committed 9555040

Simplify character classes
---
pygments/lexers/text.py | 20 +++++++++++---------
pygments/lexers/web.py | 14 +++++++-------
2 files changed, 18 insertions(+), 16 deletions(-)

Comments (0)

Files changed (2)

pygments/lexers/text.py

             # /me msgs
             ("^" + timestamp + r"""
                 (\s*[*]\s+)            # Star
-                ([^\s]+\s+.*?\n)       # Nick + rest of message """,
+                (\S+\s+.*?\n)          # Nick + rest of message """,
              bygroups(Comment.Preproc, Keyword, Generic.Inserted)),
             # join/part msgs
             ("^" + timestamp + r"""
             (r'^(Description)', Keyword, 'description'),
             (r'^(Maintainer)(:\s*)', bygroups(Keyword, Text), 'maintainer'),
             (r'^((Build-)?Depends)', Keyword, 'depends'),
-            (r'^((?:Python-)?Version)(:\s*)([^\s]+)$',
+            (r'^((?:Python-)?Version)(:\s*)(\S+)$',
              bygroups(Keyword, Text, Number)),
-            (r'^((?:Installed-)?Size)(:\s*)([^\s]+)$',
+            (r'^((?:Installed-)?Size)(:\s*)(\S+)$',
              bygroups(Keyword, Text, Number)),
-            (r'^(MD5Sum|SHA1|SHA256)(:\s*)([^\s]+)$',
+            (r'^(MD5Sum|SHA1|SHA256)(:\s*)(\S+)$',
              bygroups(Keyword, Text, Number)),
             (r'^([a-zA-Z\-0-9\.]*?)(:\s*)(.*?)$',
              bygroups(Keyword, Whitespace, String)),
             (r'.', Text),
         ],
         'description': [
-            (r'(.*)(Homepage)(: )([^\s]+)',
+            (r'(.*)(Homepage)(: )(\S+)',
              bygroups(Text, String, Name, Name.Class)),
             (r':.*\n', Generic.Strong),
             (r' .*\n', Text),
             (r'\|', Operator),
             (r'[\s]+', Text),
             (r'[}\)]\s*$', Text, '#pop'),
-            (r'[}]', Text),
+            (r'}', Text),
             (r'[^,]$', Name.Function, '#pop'),
             (r'([\+\.a-zA-Z0-9-])(\s*)', bygroups(Name.Function, Text)),
             (r'\[.*?\]', Name.Entity),
         # ignored and regular whitespaces in quoted scalars
         'quoted-scalar-whitespaces': [
             # leading and trailing whitespaces are ignored
-            (r'^[ ]+|[ ]+$', Text),
+            (r'^[ ]+', Text),
+            (r'[ ]+$', Text),
             # line breaks are ignored
             (r'\n+', Text),
             # other whitespaces are a part of the value
             # the scalar ends with a comment
             (r'[ ]+(?=#)', Text, '#pop'),
             # leading and trailing whitespaces are ignored
-            (r'^[ ]+|[ ]+$', Text),
+            (r'^[ ]+', Text),
+            (r'[ ]+$', Text),
             # line breaks are ignored
             (r'\n+', Text),
             # other whitespaces are a part of the value
         ],
         "jit-backend-counts": [
             (r"\[\w+\] jit-backend-counts}$", Keyword, "#pop"),
-            (r"[:]", Punctuation),
+            (r":", Punctuation),
             (r"\d+", Number),
             include("extra-stuff"),
         ],

pygments/lexers/web.py

         'root': [
             include('common'),
 
-            (r'(<!ELEMENT)(\s+)([^\s]+)',
+            (r'(<!ELEMENT)(\s+)(\S+)',
                 bygroups(Keyword, Text, Name.Tag), 'element'),
-            (r'(<!ATTLIST)(\s+)([^\s]+)',
+            (r'(<!ATTLIST)(\s+)(\S+)',
                 bygroups(Keyword, Text, Name.Tag), 'attlist'),
-            (r'(<!ENTITY)(\s+)([^\s]+)',
+            (r'(<!ENTITY)(\s+)(\S+)',
                 bygroups(Keyword, Text, Name.Entity), 'entity'),
-            (r'(<!NOTATION)(\s+)([^\s]+)',
+            (r'(<!NOTATION)(\s+)(\S+)',
                 bygroups(Keyword, Text, Name.Tag), 'notation'),
             (r'(<!\[)([^\[\s]+)(\s*)(\[)', # conditional sections
                 bygroups(Keyword, Name.Entity, Text, Keyword)),
 
         'import': [
             (r'[ \t]+', Text),
-            (r'[^\s]+', String),
+            (r'\S+', String),
             (r'\n', Text, 'root'),
         ],
 
             (r'//|/|\+|-|;|,|\(|\)', Punctuation),
 
             # STANDALONE QNAMES
-            (qname + r'(?=\s*[{])', Name.Variable, 'qname_braren'),
-            (qname + r'(?=\s*[(])', Name.Function, 'qname_braren'),
+            (qname + r'(?=\s*{)', Name.Variable, 'qname_braren'),
+            (qname + r'(?=\s*\()', Name.Function, 'qname_braren'),
             (qname, Name.Variable, 'operator'),
         ]
     }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.