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)
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
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
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
from pygments.util import StringIO, BytesIO
-__version__ = '2.4.0'
+__version__ = '2.4.1'
__docformat__ = 'restructuredtext'
__all__ = ['lex', 'format', 'highlight']
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
"""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)
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']:
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
'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',)),
'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',), (), ()),
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 = {
.. versionadded:: 2.4
"""
name = 'VBScript'
- aliases = []
+ aliases = ['vbscript']
filenames = ['*.vbs', '*.VBS']
flags = re.IGNORECASE
# 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']
(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|'
'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'),
tokens = {
'root': [
- (r'^#.*', Comment.Single),
(r'/\*', Comment.Multiline, 'nested-comment'),
(r'%.*', Comment.Single),
# character literal
mimetypes = []
_innerLexerCls = BatchLexer
- _ps1rgx = r'^([^>]+>)(.*\n?)'
+ _ps1rgx = r'^([^>]*>)(.*\n?)'
_ps2 = 'More? '
operators = r'[!$%&*+\./:<=>?@^|~-]'
prefix_syms = r'[!?~]'
infix_syms = r'[=<>@^|&+\*/$%-]'
- primitives = ('unit', 'nat', 'bool', 'string', 'ascii', 'list')
tokens = {
'root': [
(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),
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 = {}
#!/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:
setup(
name = 'Pygments',
- version = '2.4.0',
+ version = '2.4.1',
url = 'http://pygments.org/',
license = 'BSD License',
author = 'Georg Brandl',
--- /dev/null
+# -*- 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)))
]
self.assertEqual(expected, list(self.lexer.get_tokens(fragment)))
- def testLieralNumberBoolExpression(self):
+ def testLiteralNumberBoolExpression(self):
fragment = u'@(YES);\n'
expected = [
(Token.Literal, u'@('),
(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)))
import unittest
from pygments.token import Token
-from pygments.lexers import BashLexer, BashSessionLexer
+from pygments.lexers import BashLexer, BashSessionLexer, MSDOSSessionLexer
class BashTest(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)))
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"'))