diff options
author | orivej <orivej@yandex-team.ru> | 2022-02-10 16:44:49 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:44:49 +0300 |
commit | 718c552901d703c502ccbefdfc3c9028d608b947 (patch) | |
tree | 46534a98bbefcd7b1f3faa5b52c138ab27db75b7 /contrib/python/Pygments/py2/pygments/formatters/html.py | |
parent | e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (diff) | |
download | ydb-718c552901d703c502ccbefdfc3c9028d608b947.tar.gz |
Restoring authorship annotation for <orivej@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/python/Pygments/py2/pygments/formatters/html.py')
-rw-r--r-- | contrib/python/Pygments/py2/pygments/formatters/html.py | 86 |
1 files changed, 43 insertions, 43 deletions
diff --git a/contrib/python/Pygments/py2/pygments/formatters/html.py b/contrib/python/Pygments/py2/pygments/formatters/html.py index 042f04cfb1..3004290984 100644 --- a/contrib/python/Pygments/py2/pygments/formatters/html.py +++ b/contrib/python/Pygments/py2/pygments/formatters/html.py @@ -5,7 +5,7 @@ Formatter for HTML output. - :copyright: Copyright 2006-2019 by the Pygments team, see AUTHORS. + :copyright: Copyright 2006-2019 by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details. """ @@ -41,11 +41,11 @@ def escape_html(text, table=_escape_html_table): """Escape &, <, > as well as single and double quotes for HTML.""" return text.translate(table) -def webify(color): - if color.startswith('calc') or color.startswith('var'): - return color - else: - return '#' + color +def 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) @@ -60,11 +60,11 @@ def _get_ttype_class(ttype): CSSFILE_TEMPLATE = '''\ -/* -generated by Pygments <http://pygments.org> -Copyright 2006-2019 by the Pygments team. -Licensed under the BSD license, see LICENSE for details. -*/ +/* +generated by Pygments <http://pygments.org> +Copyright 2006-2019 by the Pygments team. +Licensed under the BSD license, see LICENSE for details. +*/ td.linenos { background-color: #f0f0f0; padding-right: 10px; } span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; } pre { line-height: 125%%; } @@ -74,11 +74,11 @@ pre { line-height: 125%%; } DOC_HEADER = '''\ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> -<!-- -generated by Pygments <http://pygments.org> -Copyright 2006-2019 by the Pygments team. -Licensed under the BSD license, see LICENSE for details. ---> +<!-- +generated by Pygments <http://pygments.org> +Copyright 2006-2019 by the Pygments team. +Licensed under the BSD license, see LICENSE for details. +--> <html> <head> <title>%(title)s</title> @@ -336,18 +336,18 @@ class HtmlFormatter(Formatter): .. versionadded:: 1.6 `filename` - A string used to generate a filename when rendering ``<pre>`` blocks, + A string used to generate a filename when rendering ``<pre>`` blocks, for example if displaying source code. .. versionadded:: 2.1 - `wrapcode` - Wrap the code inside ``<pre>`` blocks using ``<code>``, as recommended - by the HTML5 specification. - - .. versionadded:: 2.4 - + `wrapcode` + Wrap the code inside ``<pre>`` blocks using ``<code>``, as recommended + by the HTML5 specification. + .. versionadded:: 2.4 + + **Subclassing the HTML formatter** .. versionadded:: 0.7 @@ -415,7 +415,7 @@ class HtmlFormatter(Formatter): self.tagsfile = self._decodeifneeded(options.get('tagsfile', '')) self.tagurlformat = self._decodeifneeded(options.get('tagurlformat', '')) self.filename = self._decodeifneeded(options.get('filename', '')) - self.wrapcode = get_bool_opt(options, 'wrapcode', False) + self.wrapcode = get_bool_opt(options, 'wrapcode', False) if self.tagsfile: if not ctags: @@ -472,7 +472,7 @@ class HtmlFormatter(Formatter): name = self._get_css_class(ttype) style = '' if ndef['color']: - style += 'color: %s; ' % webify(ndef['color']) + style += 'color: %s; ' % webify(ndef['color']) if ndef['bold']: style += 'font-weight: bold; ' if ndef['italic']: @@ -480,9 +480,9 @@ class HtmlFormatter(Formatter): if ndef['underline']: style += 'text-decoration: underline; ' if ndef['bgcolor']: - style += 'background-color: %s; ' % webify(ndef['bgcolor']) + style += 'background-color: %s; ' % webify(ndef['bgcolor']) if ndef['border']: - style += 'border: 1px solid %s; ' % webify(ndef['border']) + style += 'border: 1px solid %s; ' % webify(ndef['border']) if style: t2c[ttype] = name # save len(ttype) to enable ordering the styles by @@ -556,9 +556,9 @@ class HtmlFormatter(Formatter): # write CSS file only if noclobber_cssfile isn't given as an option. try: if not os.path.exists(cssfilename) or not self.noclobber_cssfile: - with open(cssfilename, "w") as cf: - cf.write(CSSFILE_TEMPLATE % - {'styledefs': self.get_style_defs('body')}) + with open(cssfilename, "w") as cf: + cf.write(CSSFILE_TEMPLATE % + {'styledefs': self.get_style_defs('body')}) except IOError as err: err.strerror = 'Error writing CSS file: ' + err.strerror raise @@ -722,19 +722,19 @@ class HtmlFormatter(Formatter): if self.filename: 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>') + # 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>') for tup in inner: yield tup yield 0, '</pre>' - def _wrap_code(self, inner): - yield 0, '<code>' - for tup in inner: - yield tup - yield 0, '</code>' - + def _wrap_code(self, inner): + yield 0, '<code>' + for tup in inner: + yield tup + yield 0, '</code>' + def _format_lines(self, tokensource): """ Just format the tokens, without any wrapping tags. @@ -841,10 +841,10 @@ class HtmlFormatter(Formatter): individual lines, in custom generators. See docstring for `format`. Can be overridden. """ - if self.wrapcode: - return self._wrap_div(self._wrap_pre(self._wrap_code(source))) - else: - return self._wrap_div(self._wrap_pre(source)) + if self.wrapcode: + return self._wrap_div(self._wrap_pre(self._wrap_code(source))) + else: + return self._wrap_div(self._wrap_pre(source)) def format_unencoded(self, tokensource, outfile): """ |