aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/Pygments/py3/pygments/formatters/html.py
diff options
context:
space:
mode:
authorrobot-piglet <robot-piglet@yandex-team.com>2024-05-20 07:58:40 +0300
committerrobot-piglet <robot-piglet@yandex-team.com>2024-05-20 08:05:00 +0300
commitbcd5bcc390793791d293d386b2ebefbe683fb4e1 (patch)
treec93e3b8c847237e7e7626f4a07f1b657bb34f04d /contrib/python/Pygments/py3/pygments/formatters/html.py
parent1a9f1508fe9c8c5927ffebf33197a6108e70501d (diff)
downloadydb-bcd5bcc390793791d293d386b2ebefbe683fb4e1.tar.gz
Intermediate changes
Diffstat (limited to 'contrib/python/Pygments/py3/pygments/formatters/html.py')
-rw-r--r--contrib/python/Pygments/py3/pygments/formatters/html.py75
1 files changed, 36 insertions, 39 deletions
diff --git a/contrib/python/Pygments/py3/pygments/formatters/html.py b/contrib/python/Pygments/py3/pygments/formatters/html.py
index df2469e2a5..3330c1d588 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-2023 by the Pygments team, see AUTHORS.
+ :copyright: Copyright 2006-2024 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-2023 by the Pygments team.
+Copyright 2006-2024 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-2023 by the Pygments team.
+Copyright 2006-2024 by the Pygments team.
Licensed under the BSD license, see LICENSE for details.
-->
<html>
@@ -488,7 +488,7 @@ class HtmlFormatter(Formatter):
name = self._get_css_class(ttype)
style = ''
if ndef['color']:
- style += 'color: %s; ' % webify(ndef['color'])
+ style += 'color: {}; '.format(webify(ndef['color']))
if ndef['bold']:
style += 'font-weight: bold; '
if ndef['italic']:
@@ -496,9 +496,9 @@ class HtmlFormatter(Formatter):
if ndef['underline']:
style += 'text-decoration: underline; '
if ndef['bgcolor']:
- style += 'background-color: %s; ' % webify(ndef['bgcolor'])
+ style += 'background-color: {}; '.format(webify(ndef['bgcolor']))
if ndef['border']:
- style += 'border: 1px solid %s; ' % webify(ndef['border'])
+ style += 'border: 1px solid {}; '.format(webify(ndef['border']))
if style:
t2c[ttype] = name
# save len(ttype) to enable ordering the styles by
@@ -530,7 +530,7 @@ class HtmlFormatter(Formatter):
styles.sort()
lines = [
- '%s { %s } /* %s */' % (prefix(cls), style, repr(ttype)[6:])
+ f'{prefix(cls)} {{ {style} }} /* {repr(ttype)[6:]} */'
for (level, ttype, cls, style) in styles
]
@@ -548,24 +548,24 @@ class HtmlFormatter(Formatter):
if Text in self.ttype2class:
text_style = ' ' + self.class2style[self.ttype2class[Text]][0]
lines.insert(
- 0, '%s{ background: %s;%s }' % (
+ 0, '{}{{ background: {};{} }}'.format(
prefix(''), bg_color, text_style
)
)
if hl_color is not None:
lines.insert(
- 0, '%s { background-color: %s }' % (prefix('hll'), hl_color)
+ 0, '{} {{ background-color: {} }}'.format(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,
+ f'pre {{ {self._pre_style} }}',
+ f'td.linenos .normal {{ {self._linenos_style} }}',
+ f'span.linenos {{ {self._linenos_style} }}',
+ f'td.linenos .special {{ {self._linenos_special_style} }}',
+ f'span.linenos.special {{ {self._linenos_special_style} }}',
]
return lines
@@ -594,17 +594,15 @@ class HtmlFormatter(Formatter):
@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
- )
+ color = self.style.line_number_color
+ background_color = self.style.line_number_background_color
+ return f'color: {color}; background-color: {background_color}; padding-left: 5px; padding-right: 5px;'
@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
- )
+ color = self.style.line_number_special_color
+ background_color = self.style.line_number_special_background_color
+ return f'color: {color}; background-color: {background_color}; padding-left: 5px; padding-right: 5px;'
def _decodeifneeded(self, value):
if isinstance(value, bytes):
@@ -685,9 +683,9 @@ class HtmlFormatter(Formatter):
if nocls:
if special_line:
- style = ' style="%s"' % self._linenos_special_style
+ style = f' style="{self._linenos_special_style}"'
else:
- style = ' style="%s"' % self._linenos_style
+ style = f' style="{self._linenos_style}"'
else:
if special_line:
style = ' class="special"'
@@ -695,7 +693,7 @@ class HtmlFormatter(Formatter):
style = ' class="normal"'
if style:
- line = '<span%s>%s</span>' % (style, line)
+ line = f'<span{style}>{line}</span>'
lines.append(line)
@@ -744,9 +742,9 @@ class HtmlFormatter(Formatter):
if nocls:
if special_line:
- style = ' style="%s"' % self._linenos_special_style
+ style = f' style="{self._linenos_special_style}"'
else:
- style = ' style="%s"' % self._linenos_style
+ style = f' style="{self._linenos_style}"'
else:
if special_line:
style = ' class="linenos special"'
@@ -754,7 +752,7 @@ class HtmlFormatter(Formatter):
style = ' class="linenos"'
if style:
- linenos = '<span%s>%s</span>' % (style, line)
+ linenos = f'<span{style}>{line}</span>'
else:
linenos = line
@@ -791,13 +789,13 @@ class HtmlFormatter(Formatter):
style = []
if (self.noclasses and not self.nobackground and
self.style.background_color is not None):
- style.append('background: %s' % (self.style.background_color,))
+ style.append(f'background: {self.style.background_color}')
if self.cssstyles:
style.append(self.cssstyles)
style = '; '.join(style)
- yield 0, ('<div' + (self.cssclass and ' class="%s"' % self.cssclass) +
- (style and (' style="%s"' % style)) + '>')
+ yield 0, ('<div' + (self.cssclass and f' class="{self.cssclass}"') +
+ (style and (f' style="{style}"')) + '>')
yield from inner
yield 0, '</div>\n'
@@ -814,7 +812,7 @@ class HtmlFormatter(Formatter):
# 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 0, ('<pre' + (style and f' style="{style}"') + '><span></span>')
yield from inner
yield 0, '</pre>'
@@ -843,18 +841,18 @@ class HtmlFormatter(Formatter):
try:
cspan = self.span_element_openers[ttype]
except KeyError:
- title = ' title="%s"' % '.'.join(ttype) if self.debug_token_types else ''
+ title = ' title="{}"'.format('.'.join(ttype)) if self.debug_token_types else ''
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)
+ cspan = f'<span style="{css_style}"{title}>'
else:
cspan = ''
else:
css_class = self._get_css_classes(ttype)
if css_class:
- cspan = '<span class="%s"%s>' % (css_class, title)
+ cspan = f'<span class="{css_class}"{title}>'
else:
cspan = ''
self.span_element_openers[ttype] = cspan
@@ -927,11 +925,10 @@ class HtmlFormatter(Formatter):
if self.noclasses:
style = ''
if self.style.highlight_color is not None:
- style = (' style="background-color: %s"' %
- (self.style.highlight_color,))
- yield 1, '<span%s>%s</span>' % (style, value)
+ style = (f' style="background-color: {self.style.highlight_color}"')
+ yield 1, f'<span{style}>{value}</span>'
else:
- yield 1, '<span class="hll">%s</span>' % value
+ yield 1, f'<span class="hll">{value}</span>'
else:
yield 1, value