aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/Pygments/py3/pygments/formatters
diff options
context:
space:
mode:
authorshadchin <shadchin@yandex-team.ru>2022-02-10 16:44:39 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:44:39 +0300
commite9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (patch)
tree64175d5cadab313b3e7039ebaa06c5bc3295e274 /contrib/python/Pygments/py3/pygments/formatters
parent2598ef1d0aee359b4b6d5fdd1758916d5907d04f (diff)
downloadydb-e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0.tar.gz
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/python/Pygments/py3/pygments/formatters')
-rw-r--r--contrib/python/Pygments/py3/pygments/formatters/__init__.py16
-rw-r--r--contrib/python/Pygments/py3/pygments/formatters/_mapping.py4
-rw-r--r--contrib/python/Pygments/py3/pygments/formatters/bbcode.py2
-rw-r--r--contrib/python/Pygments/py3/pygments/formatters/html.py460
-rw-r--r--contrib/python/Pygments/py3/pygments/formatters/img.py182
-rw-r--r--contrib/python/Pygments/py3/pygments/formatters/irc.py2
-rw-r--r--contrib/python/Pygments/py3/pygments/formatters/latex.py124
-rw-r--r--contrib/python/Pygments/py3/pygments/formatters/other.py36
-rw-r--r--contrib/python/Pygments/py3/pygments/formatters/pangomarkup.py166
-rw-r--r--contrib/python/Pygments/py3/pygments/formatters/rtf.py58
-rw-r--r--contrib/python/Pygments/py3/pygments/formatters/svg.py80
-rw-r--r--contrib/python/Pygments/py3/pygments/formatters/terminal.py2
-rw-r--r--contrib/python/Pygments/py3/pygments/formatters/terminal256.py72
13 files changed, 602 insertions, 602 deletions
diff --git a/contrib/python/Pygments/py3/pygments/formatters/__init__.py b/contrib/python/Pygments/py3/pygments/formatters/__init__.py
index 9f73505773..66c9e9d404 100644
--- a/contrib/python/Pygments/py3/pygments/formatters/__init__.py
+++ b/contrib/python/Pygments/py3/pygments/formatters/__init__.py
@@ -4,7 +4,7 @@
Pygments formatters.
- :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
+ :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
@@ -16,7 +16,7 @@ from os.path import basename
from pygments.formatters._mapping import FORMATTERS
from pygments.plugin import find_plugin_formatters
-from pygments.util import ClassNotFound
+from pygments.util import ClassNotFound
__all__ = ['get_formatter_by_name', 'get_formatter_for_filename',
'get_all_formatters', 'load_formatter_from_file'] + list(FORMATTERS)
@@ -44,7 +44,7 @@ def _load_formatters(module_name):
def get_all_formatters():
"""Return a generator for all formatter classes."""
# NB: this returns formatter classes, not info like get_all_lexers().
- for info in FORMATTERS.values():
+ for info in FORMATTERS.values():
if info[1] not in _formatter_cache:
_load_formatters(info[0])
yield _formatter_cache[info[1]]
@@ -57,7 +57,7 @@ def find_formatter_class(alias):
Returns None if not found.
"""
- for module_name, name, aliases, _, _ in FORMATTERS.values():
+ for module_name, name, aliases, _, _ in FORMATTERS.values():
if alias in aliases:
if name not in _formatter_cache:
_load_formatters(module_name)
@@ -106,9 +106,9 @@ def load_formatter_from_file(filename, formattername="CustomFormatter",
formatter_class = custom_namespace[formattername]
# And finally instantiate it with the options
return formatter_class(**options)
- except OSError as err:
- raise ClassNotFound('cannot read %s: %s' % (filename, err))
- except ClassNotFound:
+ except OSError as err:
+ raise ClassNotFound('cannot read %s: %s' % (filename, err))
+ except ClassNotFound:
raise
except Exception as err:
raise ClassNotFound('error when loading custom formatter: %s' % err)
@@ -120,7 +120,7 @@ def get_formatter_for_filename(fn, **options):
Raises ClassNotFound if not found.
"""
fn = basename(fn)
- for modname, name, _, filenames, _ in FORMATTERS.values():
+ for modname, name, _, filenames, _ in FORMATTERS.values():
for filename in filenames:
if _fn_matches(fn, filename):
if name not in _formatter_cache:
diff --git a/contrib/python/Pygments/py3/pygments/formatters/_mapping.py b/contrib/python/Pygments/py3/pygments/formatters/_mapping.py
index 18ec4e67e5..8b5e478e39 100644
--- a/contrib/python/Pygments/py3/pygments/formatters/_mapping.py
+++ b/contrib/python/Pygments/py3/pygments/formatters/_mapping.py
@@ -8,7 +8,7 @@
Do not alter the FORMATTERS dictionary by hand.
- :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
+ :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
@@ -23,7 +23,7 @@ FORMATTERS = {
'JpgImageFormatter': ('pygments.formatters.img', 'img_jpg', ('jpg', 'jpeg'), ('*.jpg',), 'Create a JPEG image from source code. This uses the Python Imaging Library to generate a pixmap from the source code.'),
'LatexFormatter': ('pygments.formatters.latex', 'LaTeX', ('latex', 'tex'), ('*.tex',), 'Format tokens as LaTeX code. This needs the `fancyvrb` and `color` standard packages.'),
'NullFormatter': ('pygments.formatters.other', 'Text only', ('text', 'null'), ('*.txt',), 'Output the text unchanged without any formatting.'),
- 'PangoMarkupFormatter': ('pygments.formatters.pangomarkup', 'Pango Markup', ('pango', 'pangomarkup'), (), 'Format tokens as Pango Markup code. It can then be rendered to an SVG.'),
+ 'PangoMarkupFormatter': ('pygments.formatters.pangomarkup', 'Pango Markup', ('pango', 'pangomarkup'), (), 'Format tokens as Pango Markup code. It can then be rendered to an SVG.'),
'RawTokenFormatter': ('pygments.formatters.other', 'Raw tokens', ('raw', 'tokens'), ('*.raw',), 'Format tokens as a raw representation for storing token streams.'),
'RtfFormatter': ('pygments.formatters.rtf', 'RTF', ('rtf',), ('*.rtf',), 'Format tokens as RTF markup. This formatter automatically outputs full RTF documents with color information and other useful stuff. Perfect for Copy and Paste into Microsoft(R) Word(R) documents.'),
'SvgFormatter': ('pygments.formatters.svg', 'SVG', ('svg',), ('*.svg',), 'Format tokens as an SVG graphics file. This formatter is still experimental. Each line of code is a ``<text>`` element with explicit ``x`` and ``y`` coordinates containing ``<tspan>`` elements with the individual token styles.'),
diff --git a/contrib/python/Pygments/py3/pygments/formatters/bbcode.py b/contrib/python/Pygments/py3/pygments/formatters/bbcode.py
index 035752030b..586a8925c6 100644
--- a/contrib/python/Pygments/py3/pygments/formatters/bbcode.py
+++ b/contrib/python/Pygments/py3/pygments/formatters/bbcode.py
@@ -4,7 +4,7 @@
BBcode formatter.
- :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
+ :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
diff --git a/contrib/python/Pygments/py3/pygments/formatters/html.py b/contrib/python/Pygments/py3/pygments/formatters/html.py
index 4096506ad5..f3a77a2ddf 100644
--- a/contrib/python/Pygments/py3/pygments/formatters/html.py
+++ b/contrib/python/Pygments/py3/pygments/formatters/html.py
@@ -4,19 +4,19 @@
Formatter for HTML output.
- :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
+ :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
-import functools
+import functools
import os
import sys
import os.path
-from io import StringIO
+from io import StringIO
from pygments.formatter import Formatter
from pygments.token import Token, Text, STANDARD_TYPES
-from pygments.util import get_bool_opt, get_int_opt, get_list_opt
+from pygments.util import get_bool_opt, get_int_opt, get_list_opt
try:
import ctags
@@ -27,11 +27,11 @@ __all__ = ['HtmlFormatter']
_escape_html_table = {
- ord('&'): '&amp;',
- ord('<'): '&lt;',
- ord('>'): '&gt;',
- ord('"'): '&quot;',
- ord("'"): '&#39;',
+ ord('&'): '&amp;',
+ ord('<'): '&lt;',
+ ord('>'): '&gt;',
+ ord('"'): '&quot;',
+ ord("'"): '&#39;',
}
@@ -39,14 +39,14 @@ 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)
if fname:
@@ -61,8 +61,8 @@ def _get_ttype_class(ttype):
CSSFILE_TEMPLATE = '''\
/*
-generated by Pygments <https://pygments.org/>
-Copyright 2006-2021 by the Pygments team.
+generated by Pygments <https://pygments.org/>
+Copyright 2006-2021 by the Pygments team.
Licensed under the BSD license, see LICENSE for details.
*/
%(styledefs)s
@@ -72,8 +72,8 @@ DOC_HEADER = '''\
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<!--
-generated by Pygments <https://pygments.org/>
-Copyright 2006-2021 by the Pygments team.
+generated by Pygments <https://pygments.org/>
+Copyright 2006-2021 by the Pygments team.
Licensed under the BSD license, see LICENSE for details.
-->
<html>
@@ -205,10 +205,10 @@ class HtmlFormatter(Formatter):
`cssfile` exists.
`noclasses`
- If set to true, token ``<span>`` tags (as well as line number elements)
- will not use CSS classes, but inline styles. This is not recommended
- for larger pieces of code since it increases output size by quite a bit
- (default: ``False``).
+ If set to true, token ``<span>`` tags (as well as line number elements)
+ will not use CSS classes, but inline styles. This is not recommended
+ for larger pieces of code since it increases output size by quite a bit
+ (default: ``False``).
`classprefix`
Since the token types use relatively short class names, they may clash
@@ -272,9 +272,9 @@ class HtmlFormatter(Formatter):
125%``).
`hl_lines`
- Specify a list of lines to be highlighted. The line numbers are always
- relative to the input (i.e. the first line is line 1) and are
- independent of `linenostart`.
+ Specify a list of lines to be highlighted. The line numbers are always
+ relative to the input (i.e. the first line is line 1) and are
+ independent of `linenostart`.
.. versionadded:: 0.11
@@ -305,7 +305,7 @@ class HtmlFormatter(Formatter):
`lineanchors`
If set to a nonempty string, e.g. ``foo``, the formatter will wrap each
- output line in an anchor tag with an ``id`` (and `name`) of ``foo-linenumber``.
+ output line in an anchor tag with an ``id`` (and `name`) of ``foo-linenumber``.
This allows easy linking to certain lines.
.. versionadded:: 0.9
@@ -337,9 +337,9 @@ class HtmlFormatter(Formatter):
`filename`
A string used to generate a filename when rendering ``<pre>`` blocks,
- for example if displaying source code. If `linenos` is set to
- ``'table'`` then the filename will be rendered in an initial row
- containing a single `<th>` which spans both columns.
+ for example if displaying source code. If `linenos` is set to
+ ``'table'`` then the filename will be rendered in an initial row
+ containing a single `<th>` which spans both columns.
.. versionadded:: 2.1
@@ -424,7 +424,7 @@ class HtmlFormatter(Formatter):
self.tagurlformat = self._decodeifneeded(options.get('tagurlformat', ''))
self.filename = self._decodeifneeded(options.get('filename', ''))
self.wrapcode = get_bool_opt(options, 'wrapcode', False)
- self.span_element_openers = {}
+ self.span_element_openers = {}
self.debug_token_types = get_bool_opt(options, 'debug_token_types', False)
if self.tagsfile:
@@ -445,10 +445,10 @@ class HtmlFormatter(Formatter):
self.linenostep = abs(get_int_opt(options, 'linenostep', 1))
self.linenospecial = abs(get_int_opt(options, 'linenospecial', 0))
self.nobackground = get_bool_opt(options, 'nobackground', False)
- self.lineseparator = options.get('lineseparator', '\n')
+ self.lineseparator = options.get('lineseparator', '\n')
self.lineanchors = options.get('lineanchors', '')
self.linespans = options.get('linespans', '')
- self.anchorlinenos = get_bool_opt(options, 'anchorlinenos', False)
+ self.anchorlinenos = get_bool_opt(options, 'anchorlinenos', False)
self.hl_lines = set()
for lineno in get_list_opt(options, 'hl_lines', []):
try:
@@ -467,21 +467,21 @@ class HtmlFormatter(Formatter):
return ''
def _get_css_classes(self, ttype):
- """Return the CSS classes of this token type prefixed with the classprefix option."""
+ """Return the CSS classes of this token type prefixed with the classprefix option."""
cls = self._get_css_class(ttype)
while ttype not in STANDARD_TYPES:
ttype = ttype.parent
cls = self._get_css_class(ttype) + ' ' + cls
- return cls or ''
-
- def _get_css_inline_styles(self, ttype):
- """Return the inline CSS styles for this token type."""
- cclass = self.ttype2class.get(ttype)
- while cclass is None:
- ttype = ttype.parent
- cclass = self.ttype2class.get(ttype)
- return cclass or ''
-
+ return cls or ''
+
+ def _get_css_inline_styles(self, ttype):
+ """Return the inline CSS styles for this token type."""
+ cclass = self.ttype2class.get(ttype)
+ while cclass is None:
+ ttype = ttype.parent
+ cclass = self.ttype2class.get(ttype)
+ return cclass or ''
+
def _create_stylesheet(self):
t2c = self.ttype2class = {Token: ''}
c2s = self.class2style = {}
@@ -512,69 +512,69 @@ class HtmlFormatter(Formatter):
highlighting style. ``arg`` can be a string or list of selectors to
insert before the token type classes.
"""
- style_lines = []
-
- style_lines.extend(self.get_linenos_style_defs())
- style_lines.extend(self.get_background_style_defs(arg))
- style_lines.extend(self.get_token_style_defs(arg))
-
- return '\n'.join(style_lines)
-
- def get_token_style_defs(self, arg=None):
- prefix = self.get_css_prefix(arg)
-
- styles = [
- (level, ttype, cls, style)
- for cls, (style, ttype, level) in self.class2style.items()
- if cls and style
- ]
- styles.sort()
-
- lines = [
- '%s { %s } /* %s */' % (prefix(cls), style, repr(ttype)[6:])
- for (level, ttype, cls, style) in styles
- ]
-
- return lines
-
- def get_background_style_defs(self, arg=None):
- prefix = self.get_css_prefix(arg)
- bg_color = self.style.background_color
- hl_color = self.style.highlight_color
-
- lines = []
-
- if arg and not self.nobackground and bg_color is not None:
- text_style = ''
- if Text in self.ttype2class:
- text_style = ' ' + self.class2style[self.ttype2class[Text]][0]
- lines.insert(
- 0, '%s{ background: %s;%s }' % (
- prefix(''), bg_color, text_style
- )
- )
- if hl_color is not None:
- lines.insert(
- 0, '%s { background-color: %s }' % (prefix('hll'), hl_color)
- )
-
- return lines
-
- def get_linenos_style_defs(self):
- lines = [
- 'pre { %s }' % self._pre_style,
- 'td.linenos .normal { %s }' % self._linenos_style,
- 'span.linenos { %s }' % self._linenos_style,
- 'td.linenos .special { %s }' % self._linenos_special_style,
- 'span.linenos.special { %s }' % self._linenos_special_style,
- ]
-
- return lines
-
- def get_css_prefix(self, arg):
+ style_lines = []
+
+ style_lines.extend(self.get_linenos_style_defs())
+ style_lines.extend(self.get_background_style_defs(arg))
+ style_lines.extend(self.get_token_style_defs(arg))
+
+ return '\n'.join(style_lines)
+
+ def get_token_style_defs(self, arg=None):
+ prefix = self.get_css_prefix(arg)
+
+ styles = [
+ (level, ttype, cls, style)
+ for cls, (style, ttype, level) in self.class2style.items()
+ if cls and style
+ ]
+ styles.sort()
+
+ lines = [
+ '%s { %s } /* %s */' % (prefix(cls), style, repr(ttype)[6:])
+ for (level, ttype, cls, style) in styles
+ ]
+
+ return lines
+
+ def get_background_style_defs(self, arg=None):
+ prefix = self.get_css_prefix(arg)
+ bg_color = self.style.background_color
+ hl_color = self.style.highlight_color
+
+ lines = []
+
+ if arg and not self.nobackground and bg_color is not None:
+ text_style = ''
+ if Text in self.ttype2class:
+ text_style = ' ' + self.class2style[self.ttype2class[Text]][0]
+ lines.insert(
+ 0, '%s{ background: %s;%s }' % (
+ prefix(''), bg_color, text_style
+ )
+ )
+ if hl_color is not None:
+ lines.insert(
+ 0, '%s { background-color: %s }' % (prefix('hll'), hl_color)
+ )
+
+ return lines
+
+ def get_linenos_style_defs(self):
+ lines = [
+ 'pre { %s }' % self._pre_style,
+ 'td.linenos .normal { %s }' % self._linenos_style,
+ 'span.linenos { %s }' % self._linenos_style,
+ 'td.linenos .special { %s }' % self._linenos_special_style,
+ 'span.linenos.special { %s }' % self._linenos_special_style,
+ ]
+
+ return lines
+
+ def get_css_prefix(self, arg):
if arg is None:
arg = ('cssclass' in self.options and '.'+self.cssclass or '')
- if isinstance(arg, str):
+ if isinstance(arg, str):
args = [arg]
else:
args = list(arg)
@@ -587,26 +587,26 @@ class HtmlFormatter(Formatter):
tmp.append((arg and arg + ' ' or '') + cls)
return ', '.join(tmp)
- return prefix
-
- @property
- def _pre_style(self):
- return 'line-height: 125%;'
-
- @property
- def _linenos_style(self):
- return 'color: %s; background-color: %s; padding-left: 5px; padding-right: 5px;' % (
- self.style.line_number_color,
- self.style.line_number_background_color
- )
-
- @property
- def _linenos_special_style(self):
- return 'color: %s; background-color: %s; padding-left: 5px; padding-right: 5px;' % (
- self.style.line_number_special_color,
- self.style.line_number_special_background_color
- )
-
+ return prefix
+
+ @property
+ def _pre_style(self):
+ return 'line-height: 125%;'
+
+ @property
+ def _linenos_style(self):
+ return 'color: %s; background-color: %s; padding-left: 5px; padding-right: 5px;' % (
+ self.style.line_number_color,
+ self.style.line_number_background_color
+ )
+
+ @property
+ def _linenos_special_style(self):
+ return 'color: %s; background-color: %s; padding-left: 5px; padding-right: 5px;' % (
+ self.style.line_number_special_color,
+ self.style.line_number_special_background_color
+ )
+
def _decodeifneeded(self, value):
if isinstance(value, bytes):
if self.encoding:
@@ -638,7 +638,7 @@ class HtmlFormatter(Formatter):
with open(cssfilename, "w") as cf:
cf.write(CSSFILE_TEMPLATE %
{'styledefs': self.get_style_defs('body')})
- except OSError as err:
+ except OSError as err:
err.strerror = 'Error writing CSS file: ' + err.strerror
raise
@@ -652,7 +652,7 @@ class HtmlFormatter(Formatter):
styledefs=self.get_style_defs('body'),
encoding=self.encoding))
- yield from inner
+ yield from inner
yield 0, DOC_FOOTER
def _wrap_tablelinenos(self, inner):
@@ -671,100 +671,100 @@ class HtmlFormatter(Formatter):
aln = self.anchorlinenos
nocls = self.noclasses
- lines = []
-
- for i in range(fl, fl+lncount):
- print_line = i % st == 0
- special_line = sp and i % sp == 0
-
- if print_line:
- line = '%*d' % (mw, i)
- if aln:
- line = '<a href="#%s-%d">%s</a>' % (la, i, line)
- else:
- line = ' ' * mw
-
- if nocls:
- if special_line:
- style = ' style="%s"' % self._linenos_special_style
+ lines = []
+
+ for i in range(fl, fl+lncount):
+ print_line = i % st == 0
+ special_line = sp and i % sp == 0
+
+ if print_line:
+ line = '%*d' % (mw, i)
+ if aln:
+ line = '<a href="#%s-%d">%s</a>' % (la, i, line)
+ else:
+ line = ' ' * mw
+
+ if nocls:
+ if special_line:
+ style = ' style="%s"' % self._linenos_special_style
else:
- style = ' style="%s"' % self._linenos_style
- else:
- if special_line:
- style = ' class="special"'
+ style = ' style="%s"' % self._linenos_style
+ else:
+ if special_line:
+ style = ' class="special"'
else:
- style = ' class="normal"'
-
- if style:
- line = '<span%s>%s</span>' % (style, line)
-
- lines.append(line)
-
- ls = '\n'.join(lines)
-
- # If a filename was specified, we can't put it into the code table as it
- # would misalign the line numbers. Hence we emit a separate row for it.
- filename_tr = ""
- if self.filename:
- filename_tr = (
- '<tr><th colspan="2" class="filename"><div class="highlight">'
- '<span class="filename">' + self.filename + '</span></div>'
- '</th></tr>')
-
+ style = ' class="normal"'
+
+ if style:
+ line = '<span%s>%s</span>' % (style, line)
+
+ lines.append(line)
+
+ ls = '\n'.join(lines)
+
+ # If a filename was specified, we can't put it into the code table as it
+ # would misalign the line numbers. Hence we emit a separate row for it.
+ filename_tr = ""
+ if self.filename:
+ filename_tr = (
+ '<tr><th colspan="2" class="filename"><div class="highlight">'
+ '<span class="filename">' + self.filename + '</span></div>'
+ '</th></tr>')
+
# in case you wonder about the seemingly redundant <div> here: since the
# content in the other cell also is wrapped in a div, some browsers in
# some configurations seem to mess up the formatting...
- yield 0, (
- '<table class="%stable">' % self.cssclass + filename_tr +
- '<tr><td class="linenos"><div class="linenodiv"><pre>' +
- ls + '</pre></div></td><td class="code">'
- )
+ yield 0, (
+ '<table class="%stable">' % self.cssclass + filename_tr +
+ '<tr><td class="linenos"><div class="linenodiv"><pre>' +
+ ls + '</pre></div></td><td class="code">'
+ )
yield 0, dummyoutfile.getvalue()
yield 0, '</td></tr></table>'
def _wrap_inlinelinenos(self, inner):
# need a list of lines since we need the width of a single number :(
- inner_lines = list(inner)
+ inner_lines = list(inner)
sp = self.linenospecial
st = self.linenostep
num = self.linenostart
- mw = len(str(len(inner_lines) + num - 1))
- la = self.lineanchors
- aln = self.anchorlinenos
- nocls = self.noclasses
-
- for _, inner_line in inner_lines:
- print_line = num % st == 0
- special_line = sp and num % sp == 0
-
- if print_line:
- line = '%*d' % (mw, num)
+ mw = len(str(len(inner_lines) + num - 1))
+ la = self.lineanchors
+ aln = self.anchorlinenos
+ nocls = self.noclasses
+
+ for _, inner_line in inner_lines:
+ print_line = num % st == 0
+ special_line = sp and num % sp == 0
+
+ if print_line:
+ line = '%*d' % (mw, num)
+ else:
+ line = ' ' * mw
+
+ if nocls:
+ if special_line:
+ style = ' style="%s"' % self._linenos_special_style
+ else:
+ style = ' style="%s"' % self._linenos_style
+ else:
+ if special_line:
+ style = ' class="linenos special"'
+ else:
+ style = ' class="linenos"'
+
+ if style:
+ linenos = '<span%s>%s</span>' % (style, line)
+ else:
+ linenos = line
+
+ if aln:
+ yield 1, ('<a href="#%s-%d">%s</a>' % (la, num, linenos) +
+ inner_line)
else:
- line = ' ' * mw
-
- if nocls:
- if special_line:
- style = ' style="%s"' % self._linenos_special_style
- else:
- style = ' style="%s"' % self._linenos_style
- else:
- if special_line:
- style = ' class="linenos special"'
- else:
- style = ' class="linenos"'
-
- if style:
- linenos = '<span%s>%s</span>' % (style, line)
- else:
- linenos = line
-
- if aln:
- yield 1, ('<a href="#%s-%d">%s</a>' % (la, num, linenos) +
- inner_line)
- else:
- yield 1, linenos + inner_line
- num += 1
-
+ yield 1, linenos + inner_line
+ num += 1
+
def _wrap_lineanchors(self, inner):
s = self.lineanchors
# subtract 1 since we have to increment i *before* yielding
@@ -798,7 +798,7 @@ class HtmlFormatter(Formatter):
yield 0, ('<div' + (self.cssclass and ' class="%s"' % self.cssclass) +
(style and (' style="%s"' % style)) + '>')
- yield from inner
+ yield from inner
yield 0, '</div>\n'
def _wrap_pre(self, inner):
@@ -806,28 +806,28 @@ class HtmlFormatter(Formatter):
if self.prestyles:
style.append(self.prestyles)
if self.noclasses:
- style.append(self._pre_style)
+ style.append(self._pre_style)
style = '; '.join(style)
- if self.filename and self.linenos != 1:
+ if self.filename and self.linenos != 1:
yield 0, ('<span class="filename">' + self.filename + '</span>')
# the empty span here is to keep leading empty lines from being
# ignored by HTML parsers
yield 0, ('<pre' + (style and ' style="%s"' % style) + '><span></span>')
- yield from inner
+ yield from inner
yield 0, '</pre>'
def _wrap_code(self, inner):
yield 0, '<code>'
- yield from inner
+ yield from inner
yield 0, '</code>'
- @functools.lru_cache(maxsize=100)
- def _translate_parts(self, value):
- """HTML-escape a value and split it by newlines."""
- return value.translate(_escape_html_table).split('\n')
-
+ @functools.lru_cache(maxsize=100)
+ def _translate_parts(self, value):
+ """HTML-escape a value and split it by newlines."""
+ return value.translate(_escape_html_table).split('\n')
+
def _format_lines(self, tokensource):
"""
Just format the tokens, without any wrapping tags.
@@ -840,26 +840,26 @@ class HtmlFormatter(Formatter):
lspan = ''
line = []
for ttype, value in tokensource:
- try:
- cspan = self.span_element_openers[ttype]
- except KeyError:
+ try:
+ cspan = self.span_element_openers[ttype]
+ except KeyError:
title = ' title="%s"' % '.'.join(ttype) if self.debug_token_types else ''
- if nocls:
- css_style = self._get_css_inline_styles(ttype)
+ if nocls:
+ css_style = self._get_css_inline_styles(ttype)
if css_style:
css_style = self.class2style[css_style][0]
cspan = '<span style="%s"%s>' % (css_style, title)
else:
cspan = ''
- else:
- css_class = self._get_css_classes(ttype)
+ else:
+ css_class = self._get_css_classes(ttype)
if css_class:
cspan = '<span class="%s"%s>' % (css_class, title)
else:
cspan = ''
- self.span_element_openers[ttype] = cspan
+ self.span_element_openers[ttype] = cspan
- parts = self._translate_parts(value)
+ parts = self._translate_parts(value)
if tagsfile and ttype in Token.Name:
filename, linenumber = self._lookup_ctag(value)
@@ -906,7 +906,7 @@ class HtmlFormatter(Formatter):
def _lookup_ctag(self, token):
entry = ctags.TagEntry()
- if self._ctags.find(entry, token.encode(), 0):
+ if self._ctags.find(entry, token.encode(), 0):
return entry['file'], entry['lineNumber']
else:
return None, None
@@ -959,15 +959,15 @@ class HtmlFormatter(Formatter):
linewise, e.g. line number generators.
"""
source = self._format_lines(tokensource)
-
- # As a special case, we wrap line numbers before line highlighting
- # so the line numbers get wrapped in the highlighting tag.
- if not self.nowrap and self.linenos == 2:
- source = self._wrap_inlinelinenos(source)
-
+
+ # As a special case, we wrap line numbers before line highlighting
+ # so the line numbers get wrapped in the highlighting tag.
+ if not self.nowrap and self.linenos == 2:
+ source = self._wrap_inlinelinenos(source)
+
if self.hl_lines:
source = self._highlight_lines(source)
-
+
if not self.nowrap:
if self.lineanchors:
source = self._wrap_lineanchors(source)
diff --git a/contrib/python/Pygments/py3/pygments/formatters/img.py b/contrib/python/Pygments/py3/pygments/formatters/img.py
index 70ba77242a..f481afc4a4 100644
--- a/contrib/python/Pygments/py3/pygments/formatters/img.py
+++ b/contrib/python/Pygments/py3/pygments/formatters/img.py
@@ -4,7 +4,7 @@
Formatter for Pixmap output.
- :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
+ :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
@@ -13,7 +13,7 @@ import sys
from pygments.formatter import Formatter
from pygments.util import get_bool_opt, get_int_opt, get_list_opt, \
- get_choice_opt
+ get_choice_opt
import subprocess
@@ -45,9 +45,9 @@ STYLES = {
}
# A sane default for modern systems
-DEFAULT_FONT_NAME_NIX = 'DejaVu Sans Mono'
+DEFAULT_FONT_NAME_NIX = 'DejaVu Sans Mono'
DEFAULT_FONT_NAME_WIN = 'Courier New'
-DEFAULT_FONT_NAME_MAC = 'Menlo'
+DEFAULT_FONT_NAME_MAC = 'Menlo'
class PilNotAvailable(ImportError):
@@ -58,7 +58,7 @@ class FontNotFound(Exception):
"""When there are no usable fonts specified"""
-class FontManager:
+class FontManager:
"""
Manages a set of fonts: normal, italic, bold, etc...
"""
@@ -124,9 +124,9 @@ class FontManager:
for font_dir in (os.path.join(os.getenv("HOME"), 'Library/Fonts/'),
'/Library/Fonts/', '/System/Library/Fonts/'):
font_map.update(
- (os.path.splitext(f)[0].lower(), os.path.join(font_dir, f))
- for f in os.listdir(font_dir)
- if f.lower().endswith(('ttf', 'ttc')))
+ (os.path.splitext(f)[0].lower(), os.path.join(font_dir, f))
+ for f in os.listdir(font_dir)
+ if f.lower().endswith(('ttf', 'ttc')))
for name in STYLES['NORMAL']:
path = self._get_mac_font_path(font_map, self.font_name, name)
@@ -155,7 +155,7 @@ class FontManager:
valname = '%s%s%s' % (basename, style and ' '+style, suffix)
val, _ = _winreg.QueryValueEx(key, valname)
return val
- except OSError:
+ except OSError:
continue
else:
if fail:
@@ -164,43 +164,43 @@ class FontManager:
return None
def _create_win(self):
- lookuperror = None
- keynames = [ (_winreg.HKEY_CURRENT_USER, r'Software\Microsoft\Windows NT\CurrentVersion\Fonts'),
- (_winreg.HKEY_CURRENT_USER, r'Software\Microsoft\Windows\CurrentVersion\Fonts'),
- (_winreg.HKEY_LOCAL_MACHINE, r'Software\Microsoft\Windows NT\CurrentVersion\Fonts'),
- (_winreg.HKEY_LOCAL_MACHINE, r'Software\Microsoft\Windows\CurrentVersion\Fonts') ]
- for keyname in keynames:
+ lookuperror = None
+ keynames = [ (_winreg.HKEY_CURRENT_USER, r'Software\Microsoft\Windows NT\CurrentVersion\Fonts'),
+ (_winreg.HKEY_CURRENT_USER, r'Software\Microsoft\Windows\CurrentVersion\Fonts'),
+ (_winreg.HKEY_LOCAL_MACHINE, r'Software\Microsoft\Windows NT\CurrentVersion\Fonts'),
+ (_winreg.HKEY_LOCAL_MACHINE, r'Software\Microsoft\Windows\CurrentVersion\Fonts') ]
+ for keyname in keynames:
try:
- key = _winreg.OpenKey(*keyname)
- try:
- path = self._lookup_win(key, self.font_name, STYLES['NORMAL'], True)
- self.fonts['NORMAL'] = ImageFont.truetype(path, self.font_size)
- for style in ('ITALIC', 'BOLD', 'BOLDITALIC'):
- path = self._lookup_win(key, self.font_name, STYLES[style])
- if path:
- self.fonts[style] = ImageFont.truetype(path, self.font_size)
- else:
- if style == 'BOLDITALIC':
- self.fonts[style] = self.fonts['BOLD']
- else:
- self.fonts[style] = self.fonts['NORMAL']
- return
- except FontNotFound as err:
- lookuperror = err
- finally:
- _winreg.CloseKey(key)
- except OSError:
- pass
- else:
- # If we get here, we checked all registry keys and had no luck
- # We can be in one of two situations now:
- # * All key lookups failed. In this case lookuperror is None and we
- # will raise a generic error
- # * At least one lookup failed with a FontNotFound error. In this
- # case, we will raise that as a more specific error
- if lookuperror:
- raise lookuperror
- raise FontNotFound('Can\'t open Windows font registry key')
+ key = _winreg.OpenKey(*keyname)
+ try:
+ path = self._lookup_win(key, self.font_name, STYLES['NORMAL'], True)
+ self.fonts['NORMAL'] = ImageFont.truetype(path, self.font_size)
+ for style in ('ITALIC', 'BOLD', 'BOLDITALIC'):
+ path = self._lookup_win(key, self.font_name, STYLES[style])
+ if path:
+ self.fonts[style] = ImageFont.truetype(path, self.font_size)
+ else:
+ if style == 'BOLDITALIC':
+ self.fonts[style] = self.fonts['BOLD']
+ else:
+ self.fonts[style] = self.fonts['NORMAL']
+ return
+ except FontNotFound as err:
+ lookuperror = err
+ finally:
+ _winreg.CloseKey(key)
+ except OSError:
+ pass
+ else:
+ # If we get here, we checked all registry keys and had no luck
+ # We can be in one of two situations now:
+ # * All key lookups failed. In this case lookuperror is None and we
+ # will raise a generic error
+ # * At least one lookup failed with a FontNotFound error. In this
+ # case, we will raise that as a more specific error
+ if lookuperror:
+ raise lookuperror
+ raise FontNotFound('Can\'t open Windows font registry key')
def get_char_size(self):
"""
@@ -208,12 +208,12 @@ class FontManager:
"""
return self.fonts['NORMAL'].getsize('M')
- def get_text_size(self, text):
- """
- Get the text size(width, height).
- """
- return self.fonts['NORMAL'].getsize(text)
-
+ def get_text_size(self, text):
+ """
+ Get the text size(width, height).
+ """
+ return self.fonts['NORMAL'].getsize(text)
+
def get_font(self, bold, oblique):
"""
Get the font based on bold and italic flags.
@@ -255,8 +255,8 @@ class ImageFormatter(Formatter):
bold and italic fonts will be generated. This really should be a
monospace font to look sane.
- Default: "Courier New" on Windows, "Menlo" on Mac OS, and
- "DejaVu Sans Mono" on \\*nix
+ Default: "Courier New" on Windows, "Menlo" on Mac OS, and
+ "DejaVu Sans Mono" on \\*nix
`font_size`
The font size in points to be used.
@@ -424,17 +424,17 @@ class ImageFormatter(Formatter):
"""
return self.fontw
- def _get_char_x(self, linelength):
+ def _get_char_x(self, linelength):
"""
Get the X coordinate of a character position.
"""
- return linelength + self.image_pad + self.line_number_width
+ return linelength + self.image_pad + self.line_number_width
- def _get_text_pos(self, linelength, lineno):
+ def _get_text_pos(self, linelength, lineno):
"""
Get the actual position for a character and line position.
"""
- return self._get_char_x(linelength), self._get_line_y(lineno)
+ return self._get_char_x(linelength), self._get_line_y(lineno)
def _get_linenumber_pos(self, lineno):
"""
@@ -452,27 +452,27 @@ class ImageFormatter(Formatter):
fill = '#000'
return fill
- def _get_text_bg_color(self, style):
- """
- Get the correct background color for the token from the style.
- """
- if style['bgcolor'] is not None:
- bg_color = '#' + style['bgcolor']
- else:
- bg_color = None
- return bg_color
-
+ def _get_text_bg_color(self, style):
+ """
+ Get the correct background color for the token from the style.
+ """
+ if style['bgcolor'] is not None:
+ bg_color = '#' + style['bgcolor']
+ else:
+ bg_color = None
+ return bg_color
+
def _get_style_font(self, style):
"""
Get the correct font for the style.
"""
return self.fonts.get_font(style['bold'], style['italic'])
- def _get_image_size(self, maxlinelength, maxlineno):
+ def _get_image_size(self, maxlinelength, maxlineno):
"""
Get the required image size.
"""
- return (self._get_char_x(maxlinelength) + self.image_pad,
+ return (self._get_char_x(maxlinelength) + self.image_pad,
self._get_line_y(maxlineno + 0) + self.image_pad)
def _draw_linenumber(self, posno, lineno):
@@ -484,22 +484,22 @@ class ImageFormatter(Formatter):
str(lineno).rjust(self.line_number_chars),
font=self.fonts.get_font(self.line_number_bold,
self.line_number_italic),
- text_fg=self.line_number_fg,
- text_bg=None,
+ text_fg=self.line_number_fg,
+ text_bg=None,
)
- def _draw_text(self, pos, text, font, text_fg, text_bg):
+ def _draw_text(self, pos, text, font, text_fg, text_bg):
"""
Remember a single drawable tuple to paint later.
"""
- self.drawables.append((pos, text, font, text_fg, text_bg))
+ self.drawables.append((pos, text, font, text_fg, text_bg))
def _create_drawables(self, tokensource):
"""
Create drawables for the token content.
"""
lineno = charno = maxcharno = 0
- maxlinelength = linelength = 0
+ maxlinelength = linelength = 0
for ttype, value in tokensource:
while ttype not in self.styles:
ttype = ttype.parent
@@ -514,23 +514,23 @@ class ImageFormatter(Formatter):
temp = line.rstrip('\n')
if temp:
self._draw_text(
- self._get_text_pos(linelength, lineno),
+ self._get_text_pos(linelength, lineno),
temp,
font = self._get_style_font(style),
- text_fg = self._get_text_color(style),
- text_bg = self._get_text_bg_color(style),
+ text_fg = self._get_text_color(style),
+ text_bg = self._get_text_bg_color(style),
)
- temp_width, temp_hight = self.fonts.get_text_size(temp)
- linelength += temp_width
- maxlinelength = max(maxlinelength, linelength)
+ temp_width, temp_hight = self.fonts.get_text_size(temp)
+ linelength += temp_width
+ maxlinelength = max(maxlinelength, linelength)
charno += len(temp)
maxcharno = max(maxcharno, charno)
if line.endswith('\n'):
# add a line for each extra line in the value
- linelength = 0
+ linelength = 0
charno = 0
lineno += 1
- self.maxlinelength = maxlinelength
+ self.maxlinelength = maxlinelength
self.maxcharno = maxcharno
self.maxlineno = lineno
@@ -540,7 +540,7 @@ class ImageFormatter(Formatter):
"""
if not self.line_numbers:
return
- for p in range(self.maxlineno):
+ for p in range(self.maxlineno):
n = p + self.line_number_start
if (n % self.line_number_step) == 0:
self._draw_linenumber(p, n)
@@ -558,8 +558,8 @@ class ImageFormatter(Formatter):
rectw = self.image_pad + self.line_number_width - self.line_number_pad
draw.rectangle([(0, 0), (rectw, recth)],
fill=self.line_number_bg)
- if self.line_number_separator:
- draw.line([(rectw, 0), (rectw, recth)], fill=self.line_number_fg)
+ if self.line_number_separator:
+ draw.line([(rectw, 0), (rectw, recth)], fill=self.line_number_fg)
del draw
def format(self, tokensource, outfile):
@@ -574,7 +574,7 @@ class ImageFormatter(Formatter):
self._draw_line_numbers()
im = Image.new(
'RGB',
- self._get_image_size(self.maxlinelength, self.maxlineno),
+ self._get_image_size(self.maxlinelength, self.maxlineno),
self.background_color
)
self._paint_line_number_bg(im)
@@ -588,11 +588,11 @@ class ImageFormatter(Formatter):
y = self._get_line_y(linenumber - 1)
draw.rectangle([(x, y), (x + rectw, y + recth)],
fill=self.hl_color)
- for pos, value, font, text_fg, text_bg in self.drawables:
- if text_bg:
- text_size = draw.textsize(text=value, font=font)
- draw.rectangle([pos[0], pos[1], pos[0] + text_size[0], pos[1] + text_size[1]], fill=text_bg)
- draw.text(pos, value, font=font, fill=text_fg)
+ for pos, value, font, text_fg, text_bg in self.drawables:
+ if text_bg:
+ text_size = draw.textsize(text=value, font=font)
+ draw.rectangle([pos[0], pos[1], pos[0] + text_size[0], pos[1] + text_size[1]], fill=text_bg)
+ draw.text(pos, value, font=font, fill=text_fg)
im.save(outfile, self.image_format.upper())
diff --git a/contrib/python/Pygments/py3/pygments/formatters/irc.py b/contrib/python/Pygments/py3/pygments/formatters/irc.py
index c728f6075d..d8da7a39de 100644
--- a/contrib/python/Pygments/py3/pygments/formatters/irc.py
+++ b/contrib/python/Pygments/py3/pygments/formatters/irc.py
@@ -4,7 +4,7 @@
Formatter for IRC output
- :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
+ :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
diff --git a/contrib/python/Pygments/py3/pygments/formatters/latex.py b/contrib/python/Pygments/py3/pygments/formatters/latex.py
index 59ce95f36f..e32fcebc5a 100644
--- a/contrib/python/Pygments/py3/pygments/formatters/latex.py
+++ b/contrib/python/Pygments/py3/pygments/formatters/latex.py
@@ -4,16 +4,16 @@
Formatter for LaTeX fancyvrb output.
- :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
+ :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
-from io import StringIO
+from io import StringIO
from pygments.formatter import Formatter
-from pygments.lexer import Lexer, do_insertions
+from pygments.lexer import Lexer, do_insertions
from pygments.token import Token, STANDARD_TYPES
-from pygments.util import get_bool_opt, get_int_opt
+from pygments.util import get_bool_opt, get_int_opt
__all__ = ['LatexFormatter']
@@ -264,7 +264,7 @@ class LatexFormatter(Formatter):
self.right = self.escapeinside[1]
else:
self.escapeinside = ''
- self.envname = options.get('envname', 'Verbatim')
+ self.envname = options.get('envname', 'Verbatim')
self._create_stylesheet()
@@ -299,13 +299,13 @@ class LatexFormatter(Formatter):
cmndef += (r'\def\$$@tc##1{\textcolor[rgb]{%s}{##1}}' %
rgbcolor(ndef['color']))
if ndef['border']:
- cmndef += (r'\def\$$@bc##1{{\setlength{\fboxsep}{\string -\fboxrule}'
- r'\fcolorbox[rgb]{%s}{%s}{\strut ##1}}}' %
+ cmndef += (r'\def\$$@bc##1{{\setlength{\fboxsep}{\string -\fboxrule}'
+ r'\fcolorbox[rgb]{%s}{%s}{\strut ##1}}}' %
(rgbcolor(ndef['border']),
rgbcolor(ndef['bgcolor'])))
elif ndef['bgcolor']:
- cmndef += (r'\def\$$@bc##1{{\setlength{\fboxsep}{0pt}'
- r'\colorbox[rgb]{%s}{\strut ##1}}}' %
+ cmndef += (r'\def\$$@bc##1{{\setlength{\fboxsep}{0pt}'
+ r'\colorbox[rgb]{%s}{\strut ##1}}}' %
rgbcolor(ndef['bgcolor']))
if cmndef == '':
continue
@@ -320,8 +320,8 @@ class LatexFormatter(Formatter):
"""
cp = self.commandprefix
styles = []
- for name, definition in self.cmd2def.items():
- styles.append(r'\@namedef{%s@tok@%s}{%s}' % (cp, name, definition))
+ for name, definition in self.cmd2def.items():
+ styles.append(r'\@namedef{%s@tok@%s}{%s}' % (cp, name, definition))
return STYLE_TEMPLATE % {'cp': self.commandprefix,
'styles': '\n'.join(styles)}
@@ -334,25 +334,25 @@ class LatexFormatter(Formatter):
realoutfile = outfile
outfile = StringIO()
- outfile.write('\\begin{' + self.envname + '}[commandchars=\\\\\\{\\}')
+ outfile.write('\\begin{' + self.envname + '}[commandchars=\\\\\\{\\}')
if self.linenos:
start, step = self.linenostart, self.linenostep
- outfile.write(',numbers=left' +
- (start and ',firstnumber=%d' % start or '') +
- (step and ',stepnumber=%d' % step or ''))
+ outfile.write(',numbers=left' +
+ (start and ',firstnumber=%d' % start or '') +
+ (step and ',stepnumber=%d' % step or ''))
if self.mathescape or self.texcomments or self.escapeinside:
- outfile.write(',codes={\\catcode`\\$=3\\catcode`\\^=7'
- '\\catcode`\\_=8\\relax}')
+ outfile.write(',codes={\\catcode`\\$=3\\catcode`\\^=7'
+ '\\catcode`\\_=8\\relax}')
if self.verboptions:
- outfile.write(',' + self.verboptions)
- outfile.write(']\n')
+ outfile.write(',' + self.verboptions)
+ outfile.write(']\n')
for ttype, value in tokensource:
if ttype in Token.Comment:
if self.texcomments:
# Try to guess comment starting lexeme and escape it ...
start = value[0:1]
- for i in range(1, len(value)):
+ for i in range(1, len(value)):
if start[0] != value[i]:
break
start += value[i]
@@ -408,7 +408,7 @@ class LatexFormatter(Formatter):
else:
outfile.write(value)
- outfile.write('\\end{' + self.envname + '}\n')
+ outfile.write('\\end{' + self.envname + '}\n')
if self.full:
encoding = self.encoding or 'utf8'
@@ -445,44 +445,44 @@ class LatexEmbeddedLexer(Lexer):
Lexer.__init__(self, **options)
def get_tokens_unprocessed(self, text):
- # find and remove all the escape tokens (replace with an empty string)
- # this is very similar to DelegatingLexer.get_tokens_unprocessed.
- buffered = ''
- insertions = []
- insertion_buf = []
- for i, t, v in self._find_safe_escape_tokens(text):
- if t is None:
- if insertion_buf:
- insertions.append((len(buffered), insertion_buf))
- insertion_buf = []
- buffered += v
- else:
- insertion_buf.append((i, t, v))
- if insertion_buf:
- insertions.append((len(buffered), insertion_buf))
- return do_insertions(insertions,
- self.lang.get_tokens_unprocessed(buffered))
-
- def _find_safe_escape_tokens(self, text):
- """ find escape tokens that are not in strings or comments """
- for i, t, v in self._filter_to(
- self.lang.get_tokens_unprocessed(text),
- lambda t: t in Token.Comment or t in Token.String
- ):
- if t is None:
- for i2, t2, v2 in self._find_escape_tokens(v):
- yield i + i2, t2, v2
- else:
- yield i, None, v
-
- def _filter_to(self, it, pred):
- """ Keep only the tokens that match `pred`, merge the others together """
+ # find and remove all the escape tokens (replace with an empty string)
+ # this is very similar to DelegatingLexer.get_tokens_unprocessed.
+ buffered = ''
+ insertions = []
+ insertion_buf = []
+ for i, t, v in self._find_safe_escape_tokens(text):
+ if t is None:
+ if insertion_buf:
+ insertions.append((len(buffered), insertion_buf))
+ insertion_buf = []
+ buffered += v
+ else:
+ insertion_buf.append((i, t, v))
+ if insertion_buf:
+ insertions.append((len(buffered), insertion_buf))
+ return do_insertions(insertions,
+ self.lang.get_tokens_unprocessed(buffered))
+
+ def _find_safe_escape_tokens(self, text):
+ """ find escape tokens that are not in strings or comments """
+ for i, t, v in self._filter_to(
+ self.lang.get_tokens_unprocessed(text),
+ lambda t: t in Token.Comment or t in Token.String
+ ):
+ if t is None:
+ for i2, t2, v2 in self._find_escape_tokens(v):
+ yield i + i2, t2, v2
+ else:
+ yield i, None, v
+
+ def _filter_to(self, it, pred):
+ """ Keep only the tokens that match `pred`, merge the others together """
buf = ''
idx = 0
- for i, t, v in it:
- if pred(t):
+ for i, t, v in it:
+ if pred(t):
if buf:
- yield idx, None, buf
+ yield idx, None, buf
buf = ''
yield i, t, v
else:
@@ -490,16 +490,16 @@ class LatexEmbeddedLexer(Lexer):
idx = i
buf += v
if buf:
- yield idx, None, buf
+ yield idx, None, buf
- def _find_escape_tokens(self, text):
- """ Find escape tokens within text, give token=None otherwise """
- index = 0
+ def _find_escape_tokens(self, text):
+ """ Find escape tokens within text, give token=None otherwise """
+ index = 0
while text:
a, sep1, text = text.partition(self.left)
if a:
- yield index, None, a
- index += len(a)
+ yield index, None, a
+ index += len(a)
if sep1:
b, sep2, text = text.partition(self.right)
if sep2:
diff --git a/contrib/python/Pygments/py3/pygments/formatters/other.py b/contrib/python/Pygments/py3/pygments/formatters/other.py
index 4c79ddfc2c..1a12c42b96 100644
--- a/contrib/python/Pygments/py3/pygments/formatters/other.py
+++ b/contrib/python/Pygments/py3/pygments/formatters/other.py
@@ -4,12 +4,12 @@
Other formatters: NullFormatter, RawTokenFormatter.
- :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
+ :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
from pygments.formatter import Formatter
-from pygments.util import get_choice_opt
+from pygments.util import get_choice_opt
from pygments.token import Token
from pygments.console import colorize
@@ -86,44 +86,44 @@ class RawTokenFormatter(Formatter):
if self.compress == 'gz':
import gzip
outfile = gzip.GzipFile('', 'wb', 9, outfile)
-
- write = outfile.write
- flush = outfile.close
+
+ write = outfile.write
+ flush = outfile.close
elif self.compress == 'bz2':
import bz2
compressor = bz2.BZ2Compressor(9)
-
+
def write(text):
- outfile.write(compressor.compress(text))
-
+ outfile.write(compressor.compress(text))
+
def flush():
outfile.write(compressor.flush())
outfile.flush()
else:
- write = outfile.write
+ write = outfile.write
flush = outfile.flush
if self.error_color:
for ttype, value in tokensource:
- line = b"%r\t%r\n" % (ttype, value)
+ line = b"%r\t%r\n" % (ttype, value)
if ttype is Token.Error:
write(colorize(self.error_color, line))
else:
write(line)
else:
for ttype, value in tokensource:
- write(b"%r\t%r\n" % (ttype, value))
+ write(b"%r\t%r\n" % (ttype, value))
flush()
-
-TESTCASE_BEFORE = '''\
- def testNeedsName(lexer):
+
+TESTCASE_BEFORE = '''\
+ def testNeedsName(lexer):
fragment = %r
tokens = [
'''
-TESTCASE_AFTER = '''\
+TESTCASE_AFTER = '''\
]
- assert list(lexer.get_tokens(fragment)) == tokens
+ assert list(lexer.get_tokens(fragment)) == tokens
'''
@@ -149,8 +149,8 @@ class TestcaseFormatter(Formatter):
rawbuf.append(value)
outbuf.append('%s(%s, %r),\n' % (indentation, ttype, value))
- before = TESTCASE_BEFORE % (''.join(rawbuf),)
- during = ''.join(outbuf)
+ before = TESTCASE_BEFORE % (''.join(rawbuf),)
+ during = ''.join(outbuf)
after = TESTCASE_AFTER
if self.encoding is None:
outfile.write(before + during + after)
diff --git a/contrib/python/Pygments/py3/pygments/formatters/pangomarkup.py b/contrib/python/Pygments/py3/pygments/formatters/pangomarkup.py
index 222cf775ba..926ccc6d3b 100644
--- a/contrib/python/Pygments/py3/pygments/formatters/pangomarkup.py
+++ b/contrib/python/Pygments/py3/pygments/formatters/pangomarkup.py
@@ -1,83 +1,83 @@
-"""
- pygments.formatters.pangomarkup
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- Formatter for Pango markup output.
-
- :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
- :license: BSD, see LICENSE for details.
-"""
-
-from pygments.formatter import Formatter
-
-
-__all__ = ['PangoMarkupFormatter']
-
-
-_escape_table = {
- ord('&'): '&amp;',
- ord('<'): '&lt;',
-}
-
-
-def escape_special_chars(text, table=_escape_table):
- """Escape & and < for Pango Markup."""
- return text.translate(table)
-
-
-class PangoMarkupFormatter(Formatter):
- """
- Format tokens as Pango Markup code. It can then be rendered to an SVG.
-
- .. versionadded:: 2.9
- """
-
- name = 'Pango Markup'
- aliases = ['pango', 'pangomarkup']
- filenames = []
-
- def __init__(self, **options):
- Formatter.__init__(self, **options)
-
- self.styles = {}
-
- for token, style in self.style:
- start = ''
- end = ''
- if style['color']:
- start += '<span fgcolor="#%s">' % style['color']
- end = '</span>' + end
- if style['bold']:
- start += '<b>'
- end = '</b>' + end
- if style['italic']:
- start += '<i>'
- end = '</i>' + end
- if style['underline']:
- start += '<u>'
- end = '</u>' + end
- self.styles[token] = (start, end)
-
- def format_unencoded(self, tokensource, outfile):
- lastval = ''
- lasttype = None
-
- outfile.write('<tt>')
-
- for ttype, value in tokensource:
- while ttype not in self.styles:
- ttype = ttype.parent
- if ttype == lasttype:
- lastval += escape_special_chars(value)
- else:
- if lastval:
- stylebegin, styleend = self.styles[lasttype]
- outfile.write(stylebegin + lastval + styleend)
- lastval = escape_special_chars(value)
- lasttype = ttype
-
- if lastval:
- stylebegin, styleend = self.styles[lasttype]
- outfile.write(stylebegin + lastval + styleend)
-
- outfile.write('</tt>')
+"""
+ pygments.formatters.pangomarkup
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ Formatter for Pango markup output.
+
+ :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
+ :license: BSD, see LICENSE for details.
+"""
+
+from pygments.formatter import Formatter
+
+
+__all__ = ['PangoMarkupFormatter']
+
+
+_escape_table = {
+ ord('&'): '&amp;',
+ ord('<'): '&lt;',
+}
+
+
+def escape_special_chars(text, table=_escape_table):
+ """Escape & and < for Pango Markup."""
+ return text.translate(table)
+
+
+class PangoMarkupFormatter(Formatter):
+ """
+ Format tokens as Pango Markup code. It can then be rendered to an SVG.
+
+ .. versionadded:: 2.9
+ """
+
+ name = 'Pango Markup'
+ aliases = ['pango', 'pangomarkup']
+ filenames = []
+
+ def __init__(self, **options):
+ Formatter.__init__(self, **options)
+
+ self.styles = {}
+
+ for token, style in self.style:
+ start = ''
+ end = ''
+ if style['color']:
+ start += '<span fgcolor="#%s">' % style['color']
+ end = '</span>' + end
+ if style['bold']:
+ start += '<b>'
+ end = '</b>' + end
+ if style['italic']:
+ start += '<i>'
+ end = '</i>' + end
+ if style['underline']:
+ start += '<u>'
+ end = '</u>' + end
+ self.styles[token] = (start, end)
+
+ def format_unencoded(self, tokensource, outfile):
+ lastval = ''
+ lasttype = None
+
+ outfile.write('<tt>')
+
+ for ttype, value in tokensource:
+ while ttype not in self.styles:
+ ttype = ttype.parent
+ if ttype == lasttype:
+ lastval += escape_special_chars(value)
+ else:
+ if lastval:
+ stylebegin, styleend = self.styles[lasttype]
+ outfile.write(stylebegin + lastval + styleend)
+ lastval = escape_special_chars(value)
+ lasttype = ttype
+
+ if lastval:
+ stylebegin, styleend = self.styles[lasttype]
+ outfile.write(stylebegin + lastval + styleend)
+
+ outfile.write('</tt>')
diff --git a/contrib/python/Pygments/py3/pygments/formatters/rtf.py b/contrib/python/Pygments/py3/pygments/formatters/rtf.py
index c68f108961..ba071c78f4 100644
--- a/contrib/python/Pygments/py3/pygments/formatters/rtf.py
+++ b/contrib/python/Pygments/py3/pygments/formatters/rtf.py
@@ -4,12 +4,12 @@
A formatter that generates RTF files.
- :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
+ :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
from pygments.formatter import Formatter
-from pygments.util import get_int_opt, surrogatepair
+from pygments.util import get_int_opt, surrogatepair
__all__ = ['RtfFormatter']
@@ -34,7 +34,7 @@ class RtfFormatter(Formatter):
``'default'``).
`fontface`
- The used font family, for example ``Bitstream Vera Sans``. Defaults to
+ The used font family, for example ``Bitstream Vera Sans``. Defaults to
some generic font which is supposed to have fixed width.
`fontsize`
@@ -64,14 +64,14 @@ class RtfFormatter(Formatter):
self.fontsize = get_int_opt(options, 'fontsize', 0)
def _escape(self, text):
- return text.replace('\\', '\\\\') \
- .replace('{', '\\{') \
- .replace('}', '\\}')
+ return text.replace('\\', '\\\\') \
+ .replace('{', '\\{') \
+ .replace('}', '\\}')
def _escape_text(self, text):
- # empty strings, should give a small performance improvement
+ # empty strings, should give a small performance improvement
if not text:
- return ''
+ return ''
# escape text
text = self._escape(text)
@@ -84,21 +84,21 @@ class RtfFormatter(Formatter):
buf.append(str(c))
elif (2**7) <= cn < (2**16):
# single unicode escape sequence
- buf.append('{\\u%d}' % cn)
+ buf.append('{\\u%d}' % cn)
elif (2**16) <= cn:
# RTF limits unicode to 16 bits.
# Force surrogate pairs
- buf.append('{\\u%d}{\\u%d}' % surrogatepair(cn))
+ buf.append('{\\u%d}{\\u%d}' % surrogatepair(cn))
- return ''.join(buf).replace('\n', '\\par\n')
+ return ''.join(buf).replace('\n', '\\par\n')
def format_unencoded(self, tokensource, outfile):
# rtf 1.8 header
- outfile.write('{\\rtf1\\ansi\\uc0\\deff0'
- '{\\fonttbl{\\f0\\fmodern\\fprq1\\fcharset0%s;}}'
- '{\\colortbl;' % (self.fontface and
- ' ' + self._escape(self.fontface) or
- ''))
+ outfile.write('{\\rtf1\\ansi\\uc0\\deff0'
+ '{\\fonttbl{\\f0\\fmodern\\fprq1\\fcharset0%s;}}'
+ '{\\colortbl;' % (self.fontface and
+ ' ' + self._escape(self.fontface) or
+ ''))
# convert colors and save them in a mapping to access them later.
color_mapping = {}
@@ -107,15 +107,15 @@ class RtfFormatter(Formatter):
for color in style['color'], style['bgcolor'], style['border']:
if color and color not in color_mapping:
color_mapping[color] = offset
- outfile.write('\\red%d\\green%d\\blue%d;' % (
+ outfile.write('\\red%d\\green%d\\blue%d;' % (
int(color[0:2], 16),
int(color[2:4], 16),
int(color[4:6], 16)
))
offset += 1
- outfile.write('}\\f0 ')
+ outfile.write('}\\f0 ')
if self.fontsize:
- outfile.write('\\fs%d' % self.fontsize)
+ outfile.write('\\fs%d' % self.fontsize)
# highlight stream
for ttype, value in tokensource:
@@ -124,23 +124,23 @@ class RtfFormatter(Formatter):
style = self.style.style_for_token(ttype)
buf = []
if style['bgcolor']:
- buf.append('\\cb%d' % color_mapping[style['bgcolor']])
+ buf.append('\\cb%d' % color_mapping[style['bgcolor']])
if style['color']:
- buf.append('\\cf%d' % color_mapping[style['color']])
+ buf.append('\\cf%d' % color_mapping[style['color']])
if style['bold']:
- buf.append('\\b')
+ buf.append('\\b')
if style['italic']:
- buf.append('\\i')
+ buf.append('\\i')
if style['underline']:
- buf.append('\\ul')
+ buf.append('\\ul')
if style['border']:
- buf.append('\\chbrdr\\chcfpat%d' %
+ buf.append('\\chbrdr\\chcfpat%d' %
color_mapping[style['border']])
- start = ''.join(buf)
+ start = ''.join(buf)
if start:
- outfile.write('{%s ' % start)
+ outfile.write('{%s ' % start)
outfile.write(self._escape_text(value))
if start:
- outfile.write('}')
+ outfile.write('}')
- outfile.write('}')
+ outfile.write('}')
diff --git a/contrib/python/Pygments/py3/pygments/formatters/svg.py b/contrib/python/Pygments/py3/pygments/formatters/svg.py
index 09043d362b..547a7bbcdd 100644
--- a/contrib/python/Pygments/py3/pygments/formatters/svg.py
+++ b/contrib/python/Pygments/py3/pygments/formatters/svg.py
@@ -4,12 +4,12 @@
Formatter for SVG output.
- :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
+ :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
from pygments.formatter import Formatter
-from pygments.token import Comment
+from pygments.token import Comment
from pygments.util import get_bool_opt, get_int_opt
__all__ = ['SvgFormatter']
@@ -52,19 +52,19 @@ class SvgFormatter(Formatter):
The value to give the wrapping ``<g>`` element's ``font-size``
attribute, defaults to ``"14px"``.
- `linenos`
- If ``True``, add line numbers (default: ``False``).
-
- `linenostart`
- The line number for the first line (default: ``1``).
-
- `linenostep`
- If set to a number n > 1, only every nth line number is printed.
-
- `linenowidth`
- Maximum width devoted to line numbers (default: ``3*ystep``, sufficient
- for up to 4-digit line numbers. Increase width for longer code blocks).
-
+ `linenos`
+ If ``True``, add line numbers (default: ``False``).
+
+ `linenostart`
+ The line number for the first line (default: ``1``).
+
+ `linenostep`
+ If set to a number n > 1, only every nth line number is printed.
+
+ `linenowidth`
+ Maximum width devoted to line numbers (default: ``3*ystep``, sufficient
+ for up to 4-digit line numbers. Increase width for longer code blocks).
+
`xoffset`
Starting offset in X direction, defaults to ``0``.
@@ -105,10 +105,10 @@ class SvgFormatter(Formatter):
self.yoffset = get_int_opt(options, 'yoffset', int_fs)
self.ystep = get_int_opt(options, 'ystep', int_fs + 5)
self.spacehack = get_bool_opt(options, 'spacehack', True)
- self.linenos = get_bool_opt(options,'linenos',False)
- self.linenostart = get_int_opt(options,'linenostart',1)
- self.linenostep = get_int_opt(options,'linenostep',1)
- self.linenowidth = get_int_opt(options,'linenowidth', 3*self.ystep)
+ self.linenos = get_bool_opt(options,'linenos',False)
+ self.linenostart = get_int_opt(options,'linenostart',1)
+ self.linenostep = get_int_opt(options,'linenostep',1)
+ self.linenowidth = get_int_opt(options,'linenowidth', 3*self.ystep)
self._stylecache = {}
def format_unencoded(self, tokensource, outfile):
@@ -132,20 +132,20 @@ class SvgFormatter(Formatter):
outfile.write('<svg xmlns="http://www.w3.org/2000/svg">\n')
outfile.write('<g font-family="%s" font-size="%s">\n' %
(self.fontfamily, self.fontsize))
-
- counter = self.linenostart
- counter_step = self.linenostep
- counter_style = self._get_style(Comment)
- line_x = x
-
- if self.linenos:
- if counter % counter_step == 0:
- outfile.write('<text x="%s" y="%s" %s text-anchor="end">%s</text>' %
- (x+self.linenowidth,y,counter_style,counter))
- line_x += self.linenowidth + self.ystep
- counter += 1
-
- outfile.write('<text x="%s" y="%s" xml:space="preserve">' % (line_x, y))
+
+ counter = self.linenostart
+ counter_step = self.linenostep
+ counter_style = self._get_style(Comment)
+ line_x = x
+
+ if self.linenos:
+ if counter % counter_step == 0:
+ outfile.write('<text x="%s" y="%s" %s text-anchor="end">%s</text>' %
+ (x+self.linenowidth,y,counter_style,counter))
+ line_x += self.linenowidth + self.ystep
+ counter += 1
+
+ outfile.write('<text x="%s" y="%s" xml:space="preserve">' % (line_x, y))
for ttype, value in tokensource:
style = self._get_style(ttype)
tspan = style and '<tspan' + style + '>' or ''
@@ -157,13 +157,13 @@ class SvgFormatter(Formatter):
for part in parts[:-1]:
outfile.write(tspan + part + tspanend)
y += self.ystep
- outfile.write('</text>\n')
- if self.linenos and counter % counter_step == 0:
- outfile.write('<text x="%s" y="%s" text-anchor="end" %s>%s</text>' %
- (x+self.linenowidth,y,counter_style,counter))
-
- counter += 1
- outfile.write('<text x="%s" y="%s" ' 'xml:space="preserve">' % (line_x,y))
+ outfile.write('</text>\n')
+ if self.linenos and counter % counter_step == 0:
+ outfile.write('<text x="%s" y="%s" text-anchor="end" %s>%s</text>' %
+ (x+self.linenowidth,y,counter_style,counter))
+
+ counter += 1
+ outfile.write('<text x="%s" y="%s" ' 'xml:space="preserve">' % (line_x,y))
outfile.write(tspan + parts[-1] + tspanend)
outfile.write('</text>')
diff --git a/contrib/python/Pygments/py3/pygments/formatters/terminal.py b/contrib/python/Pygments/py3/pygments/formatters/terminal.py
index aced0ded52..a27594d0df 100644
--- a/contrib/python/Pygments/py3/pygments/formatters/terminal.py
+++ b/contrib/python/Pygments/py3/pygments/formatters/terminal.py
@@ -4,7 +4,7 @@
Formatter for terminal output with ANSI sequences.
- :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
+ :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
diff --git a/contrib/python/Pygments/py3/pygments/formatters/terminal256.py b/contrib/python/Pygments/py3/pygments/formatters/terminal256.py
index f2207fc65a..be6f890f44 100644
--- a/contrib/python/Pygments/py3/pygments/formatters/terminal256.py
+++ b/contrib/python/Pygments/py3/pygments/formatters/terminal256.py
@@ -10,7 +10,7 @@
Formatter version 1.
- :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
+ :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
@@ -32,12 +32,12 @@ __all__ = ['Terminal256Formatter', 'TerminalTrueColorFormatter']
class EscapeSequence:
- def __init__(self, fg=None, bg=None, bold=False, underline=False, italic=False):
+ def __init__(self, fg=None, bg=None, bold=False, underline=False, italic=False):
self.fg = fg
self.bg = bg
self.bold = bold
self.underline = underline
- self.italic = italic
+ self.italic = italic
def escape(self, attrs):
if len(attrs):
@@ -66,8 +66,8 @@ class EscapeSequence:
attrs.append("01")
if self.underline:
attrs.append("04")
- if self.italic:
- attrs.append("03")
+ if self.italic:
+ attrs.append("03")
return self.escape(attrs)
def true_color_string(self):
@@ -80,8 +80,8 @@ class EscapeSequence:
attrs.append("01")
if self.underline:
attrs.append("04")
- if self.italic:
- attrs.append("03")
+ if self.italic:
+ attrs.append("03")
return self.escape(attrs)
def reset_string(self):
@@ -90,7 +90,7 @@ class EscapeSequence:
attrs.append("39")
if self.bg is not None:
attrs.append("49")
- if self.bold or self.underline or self.italic:
+ if self.bold or self.underline or self.italic:
attrs.append("00")
return self.escape(attrs)
@@ -123,10 +123,10 @@ class Terminal256Formatter(Formatter):
`style`
The style to use, can be a string or a Style subclass (default:
``'default'``).
-
- `linenos`
- Set to ``True`` to have line numbers on the terminal output as well
- (default: ``False`` = no line numbers).
+
+ `linenos`
+ Set to ``True`` to have line numbers on the terminal output as well
+ (default: ``False`` = no line numbers).
"""
name = 'Terminal256'
aliases = ['terminal256', 'console256', '256']
@@ -141,14 +141,14 @@ class Terminal256Formatter(Formatter):
self.usebold = 'nobold' not in options
self.useunderline = 'nounderline' not in options
- self.useitalic = 'noitalic' not in options
+ self.useitalic = 'noitalic' not in options
self._build_color_table() # build an RGB-to-256 color conversion table
self._setup_styles() # convert selected style's colors to term. colors
- self.linenos = options.get('linenos', False)
- self._lineno = 0
-
+ self.linenos = options.get('linenos', False)
+ self._lineno = 0
+
def _build_color_table(self):
# colors 0..15: 16 basic colors
@@ -237,22 +237,22 @@ class Terminal256Formatter(Formatter):
escape.bold = True
if self.useunderline and ndef['underline']:
escape.underline = True
- if self.useitalic and ndef['italic']:
- escape.italic = True
+ if self.useitalic and ndef['italic']:
+ escape.italic = True
self.style_string[str(ttype)] = (escape.color_string(),
escape.reset_string())
- def _write_lineno(self, outfile):
- self._lineno += 1
- outfile.write("%s%04d: " % (self._lineno != 1 and '\n' or '', self._lineno))
-
+ def _write_lineno(self, outfile):
+ self._lineno += 1
+ outfile.write("%s%04d: " % (self._lineno != 1 and '\n' or '', self._lineno))
+
def format(self, tokensource, outfile):
return Formatter.format(self, tokensource, outfile)
def format_unencoded(self, tokensource, outfile):
- if self.linenos:
- self._write_lineno(outfile)
-
+ if self.linenos:
+ self._write_lineno(outfile)
+
for ttype, value in tokensource:
not_found = True
while ttype and not_found:
@@ -266,11 +266,11 @@ class Terminal256Formatter(Formatter):
for line in spl[:-1]:
if line:
outfile.write(on + line + off)
- if self.linenos:
- self._write_lineno(outfile)
- else:
- outfile.write('\n')
-
+ if self.linenos:
+ self._write_lineno(outfile)
+ else:
+ outfile.write('\n')
+
if spl[-1]:
outfile.write(on + spl[-1] + off)
@@ -285,11 +285,11 @@ class Terminal256Formatter(Formatter):
if not_found:
outfile.write(value)
- if self.linenos:
- outfile.write("\n")
+ if self.linenos:
+ outfile.write("\n")
+
+
-
-
class TerminalTrueColorFormatter(Terminal256Formatter):
r"""
Format tokens with ANSI color sequences, for output in a true-color
@@ -332,7 +332,7 @@ class TerminalTrueColorFormatter(Terminal256Formatter):
escape.bold = True
if self.useunderline and ndef['underline']:
escape.underline = True
- if self.useitalic and ndef['italic']:
- escape.italic = True
+ if self.useitalic and ndef['italic']:
+ escape.italic = True
self.style_string[str(ttype)] = (escape.true_color_string(),
escape.reset_string())