diff options
author | arcadia-devtools <arcadia-devtools@yandex-team.ru> | 2022-06-09 14:39:19 +0300 |
---|---|---|
committer | arcadia-devtools <arcadia-devtools@yandex-team.ru> | 2022-06-09 14:39:19 +0300 |
commit | c04b663c7bb4b750deeb8f48f620497ec13da8fa (patch) | |
tree | 151ebc8bfdd2ad918caf5e6e2d8013e14272ddf8 /contrib/python/Pygments/py3/pygments/formatters/html.py | |
parent | 0d55ca22c507d18c2f35718687e0b06d9915397b (diff) | |
download | ydb-c04b663c7bb4b750deeb8f48f620497ec13da8fa.tar.gz |
intermediate changes
ref:2d4f292087954c9344efdabb7b2a67f466263c65
Diffstat (limited to 'contrib/python/Pygments/py3/pygments/formatters/html.py')
-rw-r--r-- | contrib/python/Pygments/py3/pygments/formatters/html.py | 44 |
1 files changed, 25 insertions, 19 deletions
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) |