Imported Upstream version 2.4.1 upstream/2.4.1
authorJinWang An <jinwang.an@samsung.com>
Tue, 5 Jan 2021 03:19:07 +0000 (12:19 +0900)
committerJinWang An <jinwang.an@samsung.com>
Tue, 5 Jan 2021 03:19:07 +0000 (12:19 +0900)
22 files changed:
CHANGES
PKG-INFO
Pygments.egg-info/PKG-INFO
Pygments.egg-info/SOURCES.txt
pygments/__init__.py
pygments/console.py
pygments/formatters/html.py
pygments/lexers/_mapping.py
pygments/lexers/asm.py
pygments/lexers/basic.py
pygments/lexers/dotnet.py
pygments/lexers/javascript.py
pygments/lexers/objective.py
pygments/lexers/prolog.py
pygments/lexers/shell.py
pygments/lexers/theorem.py
pygments/style.py
setup.py
tests/test_asm.py [new file with mode: 0644]
tests/test_objectiveclexer.py
tests/test_shell.py
tests/test_terminal_formatter.py

diff --git a/CHANGES b/CHANGES
index 9ebde077e2370a7d5c32cc07451cd95d11e38916..2ecbb94b2f9a613e5a6626a6cc93f6724d3f1206 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -6,6 +6,23 @@ Issue numbers refer to the tracker at
 pull request numbers to the requests at
 <https://bitbucket.org/birkenfeld/pygments-main/pull-requests/merged>.
 
+Version 2.4.1
+-------------
+(released May 24, 2019)
+
+- Updated lexers:
+
+  * Coq (#1430)
+  * MSDOS Session (PR#734)
+  * NASM (#1517)
+  * Objective-C (PR#813, #1508)
+  * Prolog (#1511)
+  * TypeScript (#1515)
+
+- Support CSS variables in stylesheets (PR#814, #1356)
+- Fix F# lexer name (PR#709)
+- Fix ``TerminalFormatter`` using bold for bright text (#1480)
+
 Version 2.4.0
 -------------
 (released May 8, 2019)
index e4f2e9736d85015b368d5f4c9582f2b386026b84..9e2824eb9c90dcee0654e4d62296f32fedb2c5bf 100644 (file)
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,28 +1,29 @@
 Metadata-Version: 1.2
 Name: Pygments
-Version: 2.4.0
+Version: 2.4.1
 Summary: Pygments is a syntax highlighting package written in Python.
 Home-page: http://pygments.org/
 Author: Georg Brandl
 Author-email: georg@python.org
 License: BSD License
-Description: Pygments
-            ~~~~~~~~
+Description: 
+        Pygments
+        ~~~~~~~~
         
-            Pygments is a syntax highlighting package written in Python.
+        Pygments is a syntax highlighting package written in Python.
         
-            It is a generic syntax highlighter suitable for use in code hosting, forums,
-            wikis or other applications that need to prettify source code.  Highlights
-            are:
+        It is a generic syntax highlighter suitable for use in code hosting, forums,
+        wikis or other applications that need to prettify source code.  Highlights
+        are:
         
-            * a wide range of over 300 languages and other text formats is supported
-            * special attention is paid to details, increasing quality by a fair amount
-            * support for new languages and formats are added easily
-            * a number of output formats, presently HTML, LaTeX, RTF, SVG, all image       formats that PIL supports and ANSI sequences
-            * it is usable as a command-line tool and as a library
+        * a wide range of over 300 languages and other text formats is supported
+        * special attention is paid to details, increasing quality by a fair amount
+        * support for new languages and formats are added easily
+        * a number of output formats, presently HTML, LaTeX, RTF, SVG, all image     formats that PIL supports and ANSI sequences
+        * it is usable as a command-line tool and as a library
         
-            :copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS.
-            :license: BSD, see LICENSE for details.
+        :copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS.
+        :license: BSD, see LICENSE for details.
         
 Keywords: syntax highlighting
 Platform: any
index e4f2e9736d85015b368d5f4c9582f2b386026b84..9e2824eb9c90dcee0654e4d62296f32fedb2c5bf 100644 (file)
@@ -1,28 +1,29 @@
 Metadata-Version: 1.2
 Name: Pygments
-Version: 2.4.0
+Version: 2.4.1
 Summary: Pygments is a syntax highlighting package written in Python.
 Home-page: http://pygments.org/
 Author: Georg Brandl
 Author-email: georg@python.org
 License: BSD License
-Description: Pygments
-            ~~~~~~~~
+Description: 
+        Pygments
+        ~~~~~~~~
         
-            Pygments is a syntax highlighting package written in Python.
+        Pygments is a syntax highlighting package written in Python.
         
-            It is a generic syntax highlighter suitable for use in code hosting, forums,
-            wikis or other applications that need to prettify source code.  Highlights
-            are:
+        It is a generic syntax highlighter suitable for use in code hosting, forums,
+        wikis or other applications that need to prettify source code.  Highlights
+        are:
         
-            * a wide range of over 300 languages and other text formats is supported
-            * special attention is paid to details, increasing quality by a fair amount
-            * support for new languages and formats are added easily
-            * a number of output formats, presently HTML, LaTeX, RTF, SVG, all image       formats that PIL supports and ANSI sequences
-            * it is usable as a command-line tool and as a library
+        * a wide range of over 300 languages and other text formats is supported
+        * special attention is paid to details, increasing quality by a fair amount
+        * support for new languages and formats are added easily
+        * a number of output formats, presently HTML, LaTeX, RTF, SVG, all image     formats that PIL supports and ANSI sequences
+        * it is usable as a command-line tool and as a library
         
-            :copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS.
-            :license: BSD, see LICENSE for details.
+        :copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS.
+        :license: BSD, see LICENSE for details.
         
 Keywords: syntax highlighting
 Platform: any
index 27d0122c2e58206fc847ac1a2ac1629900083827..0500f8ef987eddab8253acb8dcccb502164e6fe5 100644 (file)
@@ -397,6 +397,7 @@ scripts/vim2pygments.py
 tests/run.py
 tests/string_asserts.py
 tests/support.py
+tests/test_asm.py
 tests/test_basic.py
 tests/test_basic_api.py
 tests/test_bibtex.py
index 0da0649d2c4733dcbcc33b232d8ba345471d6ed5..f0043e547503b06886b177f6240706943801ffee 100644 (file)
@@ -29,7 +29,7 @@ import sys
 
 from pygments.util import StringIO, BytesIO
 
-__version__ = '2.4.0'
+__version__ = '2.4.1'
 __docformat__ = 'restructuredtext'
 
 __all__ = ['lex', 'format', 'highlight']
index e61744ce94ac4b55b684c3e552d5c37b08fee1bb..e9f30ad81829094c0152f3d3422f8ef041cdb7fa 100644 (file)
@@ -30,7 +30,7 @@ light_colors = ["brightblack", "brightred", "brightgreen", "brightyellow", "brig
 x = 30
 for d, l in zip(dark_colors, light_colors):
     codes[d] = esc + "%im" % x
-    codes[l] = esc + "%i;01m" % x
+    codes[l] = esc + "%im" % (60 + x)
     x += 1
 
 del d, l, x
index 99ab837c0bd6584dcf7aa69ce1a98f6bbca945f8..d65c09cedde6a81f9c13c80b2167c4498fb2af84 100644 (file)
@@ -41,6 +41,11 @@ def escape_html(text, table=_escape_html_table):
     """Escape &, <, > as well as single and double quotes for HTML."""
     return text.translate(table)
 
+def webify(color):
+    if color.startswith('calc') or color.startswith('var'):
+        return color
+    else:
+        return '#' + color
 
 def _get_ttype_class(ttype):
     fname = STANDARD_TYPES.get(ttype)
@@ -467,7 +472,7 @@ class HtmlFormatter(Formatter):
             name = self._get_css_class(ttype)
             style = ''
             if ndef['color']:
-                style += 'color: #%s; ' % ndef['color']
+                style += 'color: %s; ' % webify(ndef['color'])
             if ndef['bold']:
                 style += 'font-weight: bold; '
             if ndef['italic']:
@@ -475,9 +480,9 @@ class HtmlFormatter(Formatter):
             if ndef['underline']:
                 style += 'text-decoration: underline; '
             if ndef['bgcolor']:
-                style += 'background-color: #%s; ' % ndef['bgcolor']
+                style += 'background-color: %s; ' % webify(ndef['bgcolor'])
             if ndef['border']:
-                style += 'border: 1px solid #%s; ' % ndef['border']
+                style += 'border: 1px solid %s; ' % webify(ndef['border'])
             if style:
                 t2c[ttype] = name
                 # save len(ttype) to enable ordering the styles by
index e4e8cf438332a40a3fae4d6c4655411a95001560..ce1b6dfc16c4373adac5ce4de9881895e76660b4 100644 (file)
@@ -153,7 +153,7 @@ LEXERS = {
     'EvoqueLexer': ('pygments.lexers.templates', 'Evoque', ('evoque',), ('*.evoque',), ('application/x-evoque',)),
     'EvoqueXmlLexer': ('pygments.lexers.templates', 'XML+Evoque', ('xml+evoque',), ('*.xml',), ('application/xml+evoque',)),
     'EzhilLexer': ('pygments.lexers.ezhil', 'Ezhil', ('ezhil',), ('*.n',), ('text/x-ezhil',)),
-    'FSharpLexer': ('pygments.lexers.dotnet', 'FSharp', ('fsharp',), ('*.fs', '*.fsi'), ('text/x-fsharp',)),
+    'FSharpLexer': ('pygments.lexers.dotnet', 'F#', ('fsharp', 'f#'), ('*.fs', '*.fsi'), ('text/x-fsharp',)),
     'FactorLexer': ('pygments.lexers.factor', 'Factor', ('factor',), ('*.factor',), ('text/x-factor',)),
     'FancyLexer': ('pygments.lexers.ruby', 'Fancy', ('fancy', 'fy'), ('*.fy', '*.fancypack'), ('text/x-fancysrc',)),
     'FantomLexer': ('pygments.lexers.fantom', 'Fantom', ('fan',), ('*.fan',), ('application/x-fantom',)),
@@ -442,7 +442,7 @@ LEXERS = {
     'UcodeLexer': ('pygments.lexers.unicon', 'ucode', ('ucode',), ('*.u', '*.u1', '*.u2'), ()),
     'UniconLexer': ('pygments.lexers.unicon', 'Unicon', ('unicon',), ('*.icn',), ('text/unicon',)),
     'UrbiscriptLexer': ('pygments.lexers.urbi', 'UrbiScript', ('urbiscript',), ('*.u',), ('application/x-urbiscript',)),
-    'VBScriptLexer': ('pygments.lexers.basic', 'VBScript', (), ('*.vbs', '*.VBS'), ()),
+    'VBScriptLexer': ('pygments.lexers.basic', 'VBScript', ('vbscript',), ('*.vbs', '*.VBS'), ()),
     'VCLLexer': ('pygments.lexers.varnish', 'VCL', ('vcl',), ('*.vcl',), ('text/x-vclsrc',)),
     'VCLSnippetLexer': ('pygments.lexers.varnish', 'VCLSnippets', ('vclsnippets', 'vclsnippet'), (), ('text/x-vclsnippet',)),
     'VCTreeStatusLexer': ('pygments.lexers.console', 'VCTreeStatus', ('vctreestatus',), (), ()),
index b522450c3b26ae715d0a36dbd55d7287e57078b1..3d2933d6a10142f82f679463f562ce05f69a7543 100644 (file)
@@ -468,9 +468,11 @@ class NasmLexer(RegexLexer):
                 r'mm[0-7]|cr[0-4]|dr[0-367]|tr[3-7]')
     wordop = r'seg|wrt|strict'
     type = r'byte|[dq]?word'
-    directives = (r'BITS|USE16|USE32|SECTION|SEGMENT|ABSOLUTE|EXTERN|GLOBAL|'
+    # Directives must be followed by whitespace, otherwise CPU will match
+    # cpuid for instance.
+    directives = (r'(?:BITS|USE16|USE32|SECTION|SEGMENT|ABSOLUTE|EXTERN|GLOBAL|'
                   r'ORG|ALIGN|STRUC|ENDSTRUC|COMMON|CPU|GROUP|UPPERCASE|IMPORT|'
-                  r'EXPORT|LIBRARY|MODULE')
+                  r'EXPORT|LIBRARY|MODULE)\s+')
 
     flags = re.IGNORECASE | re.MULTILINE
     tokens = {
index 1aa3274c77ebdcdd72fc7ad4aa11ff38040536d2..f93d6d52e98d2c00f6eea91f8deddd51f3ca28cd 100644 (file)
@@ -510,7 +510,7 @@ class VBScriptLexer(RegexLexer):
     .. versionadded:: 2.4
     """
     name = 'VBScript'
-    aliases = []
+    aliases = ['vbscript']
     filenames = ['*.vbs', '*.VBS']
     flags = re.IGNORECASE
 
index 27ae77c54b807a200276aaaac73f2a9775f95a7e..1d3b1f38f96acbda25b6158d1444f0dd7d9dff80 100644 (file)
@@ -541,16 +541,13 @@ class VbNetAspxLexer(DelegatingLexer):
 # Very close to functional.OcamlLexer
 class FSharpLexer(RegexLexer):
     """
-    For the F# language (version 3.0).
-
-    AAAAACK Strings
-    http://research.microsoft.com/en-us/um/cambridge/projects/fsharp/manual/spec.html#_Toc335818775
+    For the `F# language <https://fsharp.org/>`_ (version 3.0).
 
     .. versionadded:: 1.5
     """
 
-    name = 'FSharp'
-    aliases = ['fsharp']
+    name = 'F#'
+    aliases = ['fsharp', 'f#']
     filenames = ['*.fs', '*.fsi']
     mimetypes = ['text/x-fsharp']
 
index 0507375f4f7b567a37a5a11961451a397e4ffeca..57e1161ed80d584050ef69b7eaa5e0480a6804ac 100644 (file)
@@ -482,7 +482,7 @@ class TypeScriptLexer(RegexLexer):
             (r'[{(\[;,]', Punctuation, 'slashstartsregex'),
             (r'[})\].]', Punctuation),
             (r'(for|in|while|do|break|return|continue|switch|case|default|if|else|'
-             r'throw|try|catch|finally|new|delete|typeof|instanceof|void|'
+             r'throw|try|catch|finally|new|delete|typeof|instanceof|void|of|'
              r'this)\b', Keyword, 'slashstartsregex'),
             (r'(var|let|with|function)\b', Keyword.Declaration, 'slashstartsregex'),
             (r'(abstract|boolean|byte|char|class|const|debugger|double|enum|export|'
index 179928e91f1b5b53d743c6c77399bcbe473ec1ba..1be28c5544962e3ebb856868622978c75cee5f2d 100644 (file)
@@ -66,7 +66,7 @@ def objective(baselexer):
                     'copy', 'retain', 'assign', 'unsafe_unretained', 'atomic', 'nonatomic',
                     'readonly', 'readwrite', 'setter', 'getter', 'typeof', 'in',
                     'out', 'inout', 'release', 'class', '@dynamic', '@optional',
-                    '@required', '@autoreleasepool'), suffix=r'\b'),
+                    '@required', '@autoreleasepool', '@import'), suffix=r'\b'),
                  Keyword),
                 (words(('id', 'instancetype', 'Class', 'IMP', 'SEL', 'BOOL',
                         'IBOutlet', 'IBAction', 'unichar'), suffix=r'\b'),
index 58e762b052dd42573f3b8edd5aac3a10dc89d698..daf8db9626197462d5ac9a69fc87847b4c225df5 100644 (file)
@@ -31,7 +31,6 @@ class PrologLexer(RegexLexer):
 
     tokens = {
         'root': [
-            (r'^#.*', Comment.Single),
             (r'/\*', Comment.Multiline, 'nested-comment'),
             (r'%.*', Comment.Single),
             # character literal
index 31bc7e948f31f12635f0e9efd8cc0a9519b25fcc..9fd6bf20216500e0e2195ece189b499b0dde6d49 100644 (file)
@@ -540,7 +540,7 @@ class MSDOSSessionLexer(ShellSessionBaseLexer):
     mimetypes = []
 
     _innerLexerCls = BatchLexer
-    _ps1rgx = r'^([^>]+>)(.*\n?)'
+    _ps1rgx = r'^([^>]*>)(.*\n?)'
     _ps2 = 'More? '
 
 
index e84a398bba420334a9cd96d2acb0bbc9b51b69fa..e7619c33c8212f5f09ba165e879d44dbc0888c06 100644 (file)
@@ -98,7 +98,6 @@ class CoqLexer(RegexLexer):
     operators = r'[!$%&*+\./:<=>?@^|~-]'
     prefix_syms = r'[!?~]'
     infix_syms = r'[=<>@^|&+\*/$%-]'
-    primitives = ('unit', 'nat', 'bool', 'string', 'ascii', 'list')
 
     tokens = {
         'root': [
@@ -115,7 +114,6 @@ class CoqLexer(RegexLexer):
             (r'\b([A-Z][\w\']*)', Name),
             (r'(%s)' % '|'.join(keyopts[::-1]), Operator),
             (r'(%s|%s)?%s' % (infix_syms, prefix_syms, operators), Operator),
-            (r'\b(%s)\b' % '|'.join(primitives), Keyword.Type),
 
             (r"[^\W\d][\w']*", Name),
 
index 89766d8c21179fbc98e4c6e4ff196913c5a7f21a..aee23f969d6ba97ed651b3fad9c5fa19ee259fa0 100644 (file)
@@ -73,9 +73,11 @@ class StyleMeta(type):
                 if len(col) == 6:
                     return col
                 elif len(col) == 3:
-                    return col[0]*2 + col[1]*2 + col[2]*2
+                    return col[0] * 2 + col[1] * 2 + col[2] * 2
             elif text == '':
                 return ''
+            elif text.startswith('var') or text.startswith('calc'):
+                return text
             assert False, "wrong color format %r" % text
 
         _styles = obj._styles = {}
index bd54b0f396b1e1f3937ccb581688047fa138c366..98259f53b1b4eb1a7bc046627dcaad1db17f7e5f 100755 (executable)
--- a/setup.py
+++ b/setup.py
@@ -1,23 +1,24 @@
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
-"""Pygments
-    ~~~~~~~~
+"""
+Pygments
+~~~~~~~~
 
-    Pygments is a syntax highlighting package written in Python.
+Pygments is a syntax highlighting package written in Python.
 
-    It is a generic syntax highlighter suitable for use in code hosting, forums,
-    wikis or other applications that need to prettify source code.  Highlights
-    are:
+It is a generic syntax highlighter suitable for use in code hosting, forums,
+wikis or other applications that need to prettify source code.  Highlights
+are:
 
-    * a wide range of over 300 languages and other text formats is supported
-    * special attention is paid to details, increasing quality by a fair amount
-    * support for new languages and formats are added easily
-    * a number of output formats, presently HTML, LaTeX, RTF, SVG, all image \
-      formats that PIL supports and ANSI sequences
-    * it is usable as a command-line tool and as a library
+* a wide range of over 300 languages and other text formats is supported
+* special attention is paid to details, increasing quality by a fair amount
+* support for new languages and formats are added easily
+* a number of output formats, presently HTML, LaTeX, RTF, SVG, all image \
+    formats that PIL supports and ANSI sequences
+* it is usable as a command-line tool and as a library
 
-    :copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS.
-    :license: BSD, see LICENSE for details.
+:copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS.
+:license: BSD, see LICENSE for details.
 """
 
 try:
@@ -48,7 +49,7 @@ else:
 
 setup(
     name = 'Pygments',
-    version = '2.4.0',
+    version = '2.4.1',
     url = 'http://pygments.org/',
     license = 'BSD License',
     author = 'Georg Brandl',
diff --git a/tests/test_asm.py b/tests/test_asm.py
new file mode 100644 (file)
index 0000000..8eaed24
--- /dev/null
@@ -0,0 +1,30 @@
+# -*- coding: utf-8 -*-
+"""
+    Basic ColdfusionHtmlLexer Test
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+    :copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS.
+    :license: BSD, see LICENSE for details.
+"""
+
+import unittest
+import os
+
+from pygments.token import Token
+from pygments.lexers import NasmLexer
+
+
+class NasmLexerTest(unittest.TestCase):
+
+    def setUp(self):
+        self.lexer = NasmLexer()
+
+    def testCPUID(self):
+        # CPU is a valid directive, and we don't want to parse this as
+        # cpu id, but as a single token. See bug #1517
+        fragment = 'cpuid'
+        expected = [
+            (Token.Name.Function, u'cpuid'),
+            (Token.Text, u'\n'),
+        ]
+        self.assertEqual(expected, list(self.lexer.get_tokens(fragment)))
index aee7db66015d741b9154f5b818e1baf25288f70d..faadb08f148abd61afeefa3365e1366971a74bf9 100644 (file)
@@ -69,7 +69,7 @@ class ObjectiveCLexerTest(unittest.TestCase):
         ]
         self.assertEqual(expected, list(self.lexer.get_tokens(fragment)))
 
-    def testLieralNumberBoolExpression(self):
+    def testLiteralNumberBoolExpression(self):
         fragment = u'@(YES);\n'
         expected = [
             (Token.Literal, u'@('),
@@ -79,3 +79,14 @@ class ObjectiveCLexerTest(unittest.TestCase):
             (Token.Text, u'\n'),
         ]
         self.assertEqual(expected, list(self.lexer.get_tokens(fragment)))
+
+    def testModuleImport(self):
+        fragment = u'@import ModuleA;\n'
+        expected = [
+            (Token.Keyword, u'@import'),
+            (Token.Text, u' '),
+            (Token.Name, u'ModuleA'),
+            (Token.Punctuation, u';'),
+            (Token.Text, u'\n'),
+        ]
+        self.assertEqual(expected, list(self.lexer.get_tokens(fragment)))
index e283793e87c62a7378e2bddd6b5f22d172802ee7..1121240aa9a9a4c106b42bcfc30bab0608136911 100644 (file)
@@ -10,7 +10,7 @@
 import unittest
 
 from pygments.token import Token
-from pygments.lexers import BashLexer, BashSessionLexer
+from pygments.lexers import BashLexer, BashSessionLexer, MSDOSSessionLexer
 
 
 class BashTest(unittest.TestCase):
@@ -140,3 +140,20 @@ class BashSessionTest(unittest.TestCase):
         ]
         self.assertEqual(tokens, list(self.lexer.get_tokens(fragment)))
 
+class MSDOSSessionTest(unittest.TestCase):
+
+    def setUp(self):
+        self.lexer = MSDOSSessionLexer()
+
+    def testGtOnlyPrompt(self):
+        fragment = u'> py\nhi\n'
+        tokens = [
+            (Token.Text, u''),
+            (Token.Generic.Prompt, u'>'),
+            (Token.Text, u' '),
+            (Token.Text, u'py'),
+            (Token.Text, u''),
+            (Token.Text, u'\n'),
+            (Token.Generic.Output, u'hi\n'),
+        ]
+        self.assertEqual(tokens, list(self.lexer.get_tokens(fragment)))
index 1f44807d626a854f7f567765b493b743a8751bf0..acc1516799f33aa3ef436039a0cc501ca2fc1153 100644 (file)
@@ -90,13 +90,13 @@ async def function(a,b,c, *d, **kwarg:Bool)->Bool:
 
     def test_256esc_seq(self):
         """
-        test that a few escape sequences are actualy used when using ansi<> color codes
+        test that a few escape sequences are actually used when using ansi<> color codes
         """
         def termtest(x):
             return highlight(x, Python3Lexer(),
                              Terminal256Formatter(style=MyStyle))
 
-        self.assertTrue('32;41' in termtest('0x123'))
-        self.assertTrue('32;42' in termtest('123'))
-        self.assertTrue('30;01' in termtest('#comment'))
-        self.assertTrue('34;41' in termtest('"String"'))
+        self.assertTrue('32;101' in termtest('0x123'))
+        self.assertTrue('92;42' in termtest('123'))
+        self.assertTrue('90' in termtest('#comment'))
+        self.assertTrue('94;41' in termtest('"String"'))