aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/Pygments/py3/pygments/formatters
diff options
context:
space:
mode:
authorarcadia-devtools <arcadia-devtools@yandex-team.ru>2022-06-09 14:39:19 +0300
committerarcadia-devtools <arcadia-devtools@yandex-team.ru>2022-06-09 14:39:19 +0300
commitc04b663c7bb4b750deeb8f48f620497ec13da8fa (patch)
tree151ebc8bfdd2ad918caf5e6e2d8013e14272ddf8 /contrib/python/Pygments/py3/pygments/formatters
parent0d55ca22c507d18c2f35718687e0b06d9915397b (diff)
downloadydb-c04b663c7bb4b750deeb8f48f620497ec13da8fa.tar.gz
intermediate changes
ref:2d4f292087954c9344efdabb7b2a67f466263c65
Diffstat (limited to 'contrib/python/Pygments/py3/pygments/formatters')
-rw-r--r--contrib/python/Pygments/py3/pygments/formatters/__init__.py2
-rw-r--r--contrib/python/Pygments/py3/pygments/formatters/_mapping.py6
-rw-r--r--contrib/python/Pygments/py3/pygments/formatters/bbcode.py2
-rw-r--r--contrib/python/Pygments/py3/pygments/formatters/groff.py4
-rw-r--r--contrib/python/Pygments/py3/pygments/formatters/html.py44
-rw-r--r--contrib/python/Pygments/py3/pygments/formatters/img.py2
-rw-r--r--contrib/python/Pygments/py3/pygments/formatters/irc.py2
-rw-r--r--contrib/python/Pygments/py3/pygments/formatters/latex.py38
-rw-r--r--contrib/python/Pygments/py3/pygments/formatters/other.py2
-rw-r--r--contrib/python/Pygments/py3/pygments/formatters/pangomarkup.py2
-rw-r--r--contrib/python/Pygments/py3/pygments/formatters/rtf.py2
-rw-r--r--contrib/python/Pygments/py3/pygments/formatters/svg.py2
-rw-r--r--contrib/python/Pygments/py3/pygments/formatters/terminal.py2
-rw-r--r--contrib/python/Pygments/py3/pygments/formatters/terminal256.py2
14 files changed, 65 insertions, 47 deletions
diff --git a/contrib/python/Pygments/py3/pygments/formatters/__init__.py b/contrib/python/Pygments/py3/pygments/formatters/__init__.py
index 66c9e9d404..887015c8b9 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-2022 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
diff --git a/contrib/python/Pygments/py3/pygments/formatters/_mapping.py b/contrib/python/Pygments/py3/pygments/formatters/_mapping.py
index 8b5e478e39..15c3fe7dd7 100644
--- a/contrib/python/Pygments/py3/pygments/formatters/_mapping.py
+++ b/contrib/python/Pygments/py3/pygments/formatters/_mapping.py
@@ -2,13 +2,13 @@
pygments.formatters._mapping
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Formatter mapping definitions. This file is generated by itself. Everytime
+ Formatter mapping definitions. This file is generated by itself. Every time
you change something on a builtin formatter definition, run this script from
the formatters folder to update it.
Do not alter the FORMATTERS dictionary by hand.
- :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
+ :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
@@ -67,7 +67,7 @@ if __name__ == '__main__': # pragma: no cover
content = fp.read()
# replace crnl to nl for Windows.
#
- # Note that, originally, contributers should keep nl of master
+ # Note that, originally, contributors should keep nl of master
# repository, for example by using some kind of automatic
# management EOL, like `EolExtension
# <https://www.mercurial-scm.org/wiki/EolExtension>`.
diff --git a/contrib/python/Pygments/py3/pygments/formatters/bbcode.py b/contrib/python/Pygments/py3/pygments/formatters/bbcode.py
index 586a8925c6..8b23b354fa 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-2022 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
diff --git a/contrib/python/Pygments/py3/pygments/formatters/groff.py b/contrib/python/Pygments/py3/pygments/formatters/groff.py
index 5aafe6d2f2..7d409baa36 100644
--- a/contrib/python/Pygments/py3/pygments/formatters/groff.py
+++ b/contrib/python/Pygments/py3/pygments/formatters/groff.py
@@ -4,7 +4,7 @@
Formatter for groff output.
- :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
+ :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
@@ -144,6 +144,8 @@ class GroffFormatter(Formatter):
self._write_lineno(outfile)
for ttype, value in tokensource:
+ while ttype not in self.styles:
+ ttype = ttype.parent
start, end = self.styles[ttype]
for line in value.splitlines(True):
diff --git a/contrib/python/Pygments/py3/pygments/formatters/html.py b/contrib/python/Pygments/py3/pygments/formatters/html.py
index f3a77a2ddf..791f749a38 100644
--- a/contrib/python/Pygments/py3/pygments/formatters/html.py
+++ b/contrib/python/Pygments/py3/pygments/formatters/html.py
@@ -4,7 +4,7 @@
Formatter for HTML output.
- :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
+ :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
@@ -62,7 +62,7 @@ def _get_ttype_class(ttype):
CSSFILE_TEMPLATE = '''\
/*
generated by Pygments <https://pygments.org/>
-Copyright 2006-2021 by the Pygments team.
+Copyright 2006-2022 by the Pygments team.
Licensed under the BSD license, see LICENSE for details.
*/
%(styledefs)s
@@ -73,7 +73,7 @@ DOC_HEADER = '''\
"http://www.w3.org/TR/html4/strict.dtd">
<!--
generated by Pygments <https://pygments.org/>
-Copyright 2006-2021 by the Pygments team.
+Copyright 2006-2022 by the Pygments team.
Licensed under the BSD license, see LICENSE for details.
-->
<html>
@@ -385,7 +385,7 @@ class HtmlFormatter(Formatter):
class CodeHtmlFormatter(HtmlFormatter):
- def wrap(self, source, outfile):
+ def wrap(self, source, *, include_div):
return self._wrap_code(source)
def _wrap_code(self, source):
@@ -667,7 +667,7 @@ class HtmlFormatter(Formatter):
mw = len(str(lncount + fl - 1))
sp = self.linenospecial
st = self.linenostep
- la = self.lineanchors
+ anchor_name = self.lineanchors or self.linespans
aln = self.anchorlinenos
nocls = self.noclasses
@@ -680,7 +680,7 @@ class HtmlFormatter(Formatter):
if print_line:
line = '%*d' % (mw, i)
if aln:
- line = '<a href="#%s-%d">%s</a>' % (la, i, line)
+ line = '<a href="#%s-%d">%s</a>' % (anchor_name, i, line)
else:
line = ' ' * mw
@@ -707,20 +707,21 @@ class HtmlFormatter(Formatter):
filename_tr = ""
if self.filename:
filename_tr = (
- '<tr><th colspan="2" class="filename"><div class="highlight">'
- '<span class="filename">' + self.filename + '</span></div>'
+ '<tr><th colspan="2" class="filename">'
+ '<span class="filename">' + self.filename + '</span>'
'</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 +
+ yield 0, (f'<table class="{self.cssclass}table">' + filename_tr +
'<tr><td class="linenos"><div class="linenodiv"><pre>' +
- ls + '</pre></div></td><td class="code">'
- )
+ ls + '</pre></div></td><td class="code">')
+ yield 0, '<div>'
yield 0, dummyoutfile.getvalue()
+ yield 0, '</div>'
yield 0, '</td></tr></table>'
+
def _wrap_inlinelinenos(self, inner):
# need a list of lines since we need the width of a single number :(
@@ -729,7 +730,7 @@ class HtmlFormatter(Formatter):
st = self.linenostep
num = self.linenostart
mw = len(str(len(inner_lines) + num - 1))
- la = self.lineanchors
+ anchor_name = self.lineanchors or self.linespans
aln = self.anchorlinenos
nocls = self.noclasses
@@ -759,7 +760,7 @@ class HtmlFormatter(Formatter):
linenos = line
if aln:
- yield 1, ('<a href="#%s-%d">%s</a>' % (la, num, linenos) +
+ yield 1, ('<a href="#%s-%d">%s</a>' % (anchor_name, num, linenos) +
inner_line)
else:
yield 1, linenos + inner_line
@@ -933,16 +934,20 @@ class HtmlFormatter(Formatter):
else:
yield 1, value
- def wrap(self, source, outfile):
+ def wrap(self, source):
"""
Wrap the ``source``, which is a generator yielding
individual lines, in custom generators. See docstring
for `format`. Can be overridden.
"""
+
+ output = source
if self.wrapcode:
- return self._wrap_div(self._wrap_pre(self._wrap_code(source)))
- else:
- return self._wrap_div(self._wrap_pre(source))
+ output = self._wrap_code(output)
+
+ output = self._wrap_pre(output)
+
+ return output
def format_unencoded(self, tokensource, outfile):
"""
@@ -973,9 +978,10 @@ class HtmlFormatter(Formatter):
source = self._wrap_lineanchors(source)
if self.linespans:
source = self._wrap_linespans(source)
- source = self.wrap(source, outfile)
+ source = self.wrap(source)
if self.linenos == 1:
source = self._wrap_tablelinenos(source)
+ source = self._wrap_div(source)
if self.full:
source = self._wrap_full(source, outfile)
diff --git a/contrib/python/Pygments/py3/pygments/formatters/img.py b/contrib/python/Pygments/py3/pygments/formatters/img.py
index f481afc4a4..08400407ab 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-2022 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
diff --git a/contrib/python/Pygments/py3/pygments/formatters/irc.py b/contrib/python/Pygments/py3/pygments/formatters/irc.py
index d8da7a39de..fd263bb0b0 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-2022 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 e32fcebc5a..d33b686d8f 100644
--- a/contrib/python/Pygments/py3/pygments/formatters/latex.py
+++ b/contrib/python/Pygments/py3/pygments/formatters/latex.py
@@ -4,7 +4,7 @@
Formatter for LaTeX fancyvrb output.
- :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
+ :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
@@ -159,6 +159,8 @@ class LatexFormatter(Formatter):
\PY{k}{pass}
\end{Verbatim}
+ Wrapping can be disabled using the `nowrap` option.
+
The special command used here (``\PY``) and all the other macros it needs
are output by the `get_style_defs` method.
@@ -171,6 +173,11 @@ class LatexFormatter(Formatter):
Additional options accepted:
+ `nowrap`
+ If set to ``True``, don't wrap the tokens at all, not even inside a
+ ``\begin{Verbatim}`` environment. This disables most other options
+ (default: ``False``).
+
`style`
The style to use, can be a string or a Style subclass (default:
``'default'``).
@@ -248,6 +255,7 @@ class LatexFormatter(Formatter):
def __init__(self, **options):
Formatter.__init__(self, **options)
+ self.nowrap = get_bool_opt(options, 'nowrap', False)
self.docclass = options.get('docclass', 'article')
self.preamble = options.get('preamble', '')
self.linenos = get_bool_opt(options, 'linenos', False)
@@ -334,18 +342,19 @@ class LatexFormatter(Formatter):
realoutfile = outfile
outfile = StringIO()
- 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 ''))
- if self.mathescape or self.texcomments or self.escapeinside:
- outfile.write(',codes={\\catcode`\\$=3\\catcode`\\^=7'
- '\\catcode`\\_=8\\relax}')
- if self.verboptions:
- outfile.write(',' + self.verboptions)
- outfile.write(']\n')
+ if not self.nowrap:
+ 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 ''))
+ if self.mathescape or self.texcomments or self.escapeinside:
+ outfile.write(',codes={\\catcode`\\$=3\\catcode`\\^=7'
+ '\\catcode`\\_=8\\relax}')
+ if self.verboptions:
+ outfile.write(',' + self.verboptions)
+ outfile.write(']\n')
for ttype, value in tokensource:
if ttype in Token.Comment:
@@ -408,7 +417,8 @@ class LatexFormatter(Formatter):
else:
outfile.write(value)
- outfile.write('\\end{' + self.envname + '}\n')
+ if not self.nowrap:
+ outfile.write('\\end{' + self.envname + '}\n')
if self.full:
encoding = self.encoding or 'utf8'
diff --git a/contrib/python/Pygments/py3/pygments/formatters/other.py b/contrib/python/Pygments/py3/pygments/formatters/other.py
index 1a12c42b96..8c7ee280a0 100644
--- a/contrib/python/Pygments/py3/pygments/formatters/other.py
+++ b/contrib/python/Pygments/py3/pygments/formatters/other.py
@@ -4,7 +4,7 @@
Other formatters: NullFormatter, RawTokenFormatter.
- :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
+ :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
diff --git a/contrib/python/Pygments/py3/pygments/formatters/pangomarkup.py b/contrib/python/Pygments/py3/pygments/formatters/pangomarkup.py
index 926ccc6d3b..91c1b0161e 100644
--- a/contrib/python/Pygments/py3/pygments/formatters/pangomarkup.py
+++ b/contrib/python/Pygments/py3/pygments/formatters/pangomarkup.py
@@ -4,7 +4,7 @@
Formatter for Pango markup output.
- :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
+ :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
diff --git a/contrib/python/Pygments/py3/pygments/formatters/rtf.py b/contrib/python/Pygments/py3/pygments/formatters/rtf.py
index ba071c78f4..ccdfb0a734 100644
--- a/contrib/python/Pygments/py3/pygments/formatters/rtf.py
+++ b/contrib/python/Pygments/py3/pygments/formatters/rtf.py
@@ -4,7 +4,7 @@
A formatter that generates RTF files.
- :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
+ :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
diff --git a/contrib/python/Pygments/py3/pygments/formatters/svg.py b/contrib/python/Pygments/py3/pygments/formatters/svg.py
index 547a7bbcdd..32d40cb640 100644
--- a/contrib/python/Pygments/py3/pygments/formatters/svg.py
+++ b/contrib/python/Pygments/py3/pygments/formatters/svg.py
@@ -4,7 +4,7 @@
Formatter for SVG output.
- :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
+ :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
diff --git a/contrib/python/Pygments/py3/pygments/formatters/terminal.py b/contrib/python/Pygments/py3/pygments/formatters/terminal.py
index a27594d0df..23d3a71ef0 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-2022 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 be6f890f44..addba42960 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-2022 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""