diff options
author | orivej <orivej@yandex-team.ru> | 2022-02-10 16:45:01 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:01 +0300 |
commit | 2d37894b1b037cf24231090eda8589bbb44fb6fc (patch) | |
tree | be835aa92c6248212e705f25388ebafcf84bc7a1 /contrib/python/Pygments/py3/pygments/formatters/html.py | |
parent | 718c552901d703c502ccbefdfc3c9028d608b947 (diff) | |
download | ydb-2d37894b1b037cf24231090eda8589bbb44fb6fc.tar.gz |
Restoring authorship annotation for <orivej@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/python/Pygments/py3/pygments/formatters/html.py')
-rw-r--r-- | contrib/python/Pygments/py3/pygments/formatters/html.py | 72 |
1 files changed, 36 insertions, 36 deletions
diff --git a/contrib/python/Pygments/py3/pygments/formatters/html.py b/contrib/python/Pygments/py3/pygments/formatters/html.py index 11e4e6e128..f3a77a2ddf 100644 --- a/contrib/python/Pygments/py3/pygments/formatters/html.py +++ b/contrib/python/Pygments/py3/pygments/formatters/html.py @@ -40,11 +40,11 @@ def escape_html(text, table=_escape_html_table): 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): @@ -60,22 +60,22 @@ def _get_ttype_class(ttype): CSSFILE_TEMPLATE = '''\ -/* +/* generated by Pygments <https://pygments.org/> Copyright 2006-2021 by the Pygments team. -Licensed under the BSD license, see LICENSE for details. -*/ +Licensed under the BSD license, see LICENSE for details. +*/ %(styledefs)s ''' 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. -Licensed under the BSD license, see LICENSE for details. ---> +Licensed under the BSD license, see LICENSE for details. +--> <html> <head> <title>%(title)s</title> @@ -336,23 +336,23 @@ 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. 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 - `wrapcode` - Wrap the code inside ``<pre>`` blocks using ``<code>``, as recommended - by the HTML5 specification. + `wrapcode` + Wrap the code inside ``<pre>`` blocks using ``<code>``, as recommended + by the HTML5 specification. + + .. versionadded:: 2.4 - .. versionadded:: 2.4 - `debug_token_types` Add ``title`` attributes to all token ``<span>`` tags that show the name of the token. - + .. versionadded:: 2.10 @@ -423,7 +423,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) self.span_element_openers = {} self.debug_token_types = get_bool_opt(options, 'debug_token_types', False) @@ -489,7 +489,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']: @@ -497,9 +497,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 @@ -635,9 +635,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 OSError as err: err.strerror = 'Error writing CSS file: ' + err.strerror raise @@ -812,17 +812,17 @@ class HtmlFormatter(Formatter): 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>') + # 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 0, '</pre>' - def _wrap_code(self, inner): - yield 0, '<code>' + def _wrap_code(self, inner): + yield 0, '<code>' yield from inner - yield 0, '</code>' - + yield 0, '</code>' + @functools.lru_cache(maxsize=100) def _translate_parts(self, value): """HTML-escape a value and split it by newlines.""" @@ -939,10 +939,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): """ |