aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/Pygments/py3/pygments/formatters/svg.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/svg.py
parent1a9f1508fe9c8c5927ffebf33197a6108e70501d (diff)
downloadydb-bcd5bcc390793791d293d386b2ebefbe683fb4e1.tar.gz
Intermediate changes
Diffstat (limited to 'contrib/python/Pygments/py3/pygments/formatters/svg.py')
-rw-r--r--contrib/python/Pygments/py3/pygments/formatters/svg.py37
1 files changed, 17 insertions, 20 deletions
diff --git a/contrib/python/Pygments/py3/pygments/formatters/svg.py b/contrib/python/Pygments/py3/pygments/formatters/svg.py
index e3cd26955a..74019b6961 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-2023 by the Pygments team, see AUTHORS.
+ :copyright: Copyright 2006-2024 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
@@ -60,11 +60,11 @@ class SvgFormatter(Formatter):
`linenostep`
If set to a number n > 1, only every nth line number is printed.
-
+
`linenowidth`
Maximum width devoted to line numbers (default: ``3*ystep``, sufficient
- for up to 4-digit line numbers. Increase width for longer code blocks).
-
+ for up to 4-digit line numbers. Increase width for longer code blocks).
+
`xoffset`
Starting offset in X direction, defaults to ``0``.
@@ -97,10 +97,11 @@ class SvgFormatter(Formatter):
self.fontsize = options.get('fontsize', '14px')
self.xoffset = get_int_opt(options, 'xoffset', 0)
fs = self.fontsize.strip()
- if fs.endswith('px'): fs = fs[:-2].strip()
+ if fs.endswith('px'):
+ fs = fs[:-2].strip()
try:
int_fs = int(fs)
- except:
+ except ValueError:
int_fs = 20
self.yoffset = get_int_opt(options, 'yoffset', int_fs)
self.ystep = get_int_opt(options, 'ystep', int_fs + 5)
@@ -122,30 +123,27 @@ class SvgFormatter(Formatter):
y = self.yoffset
if not self.nowrap:
if self.encoding:
- outfile.write('<?xml version="1.0" encoding="%s"?>\n' %
- self.encoding)
+ outfile.write(f'<?xml version="1.0" encoding="{self.encoding}"?>\n')
else:
outfile.write('<?xml version="1.0"?>\n')
outfile.write('<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" '
'"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/'
'svg10.dtd">\n')
outfile.write('<svg xmlns="http://www.w3.org/2000/svg">\n')
- outfile.write('<g font-family="%s" font-size="%s">\n' %
- (self.fontfamily, self.fontsize))
-
- counter = self.linenostart
+ outfile.write(f'<g font-family="{self.fontfamily}" font-size="{self.fontsize}">\n')
+
+ counter = self.linenostart
counter_step = self.linenostep
counter_style = self._get_style(Comment)
line_x = x
-
+
if self.linenos:
if counter % counter_step == 0:
- outfile.write('<text x="%s" y="%s" %s text-anchor="end">%s</text>' %
- (x+self.linenowidth,y,counter_style,counter))
+ outfile.write(f'<text x="{x+self.linenowidth}" y="{y}" {counter_style} text-anchor="end">{counter}</text>')
line_x += self.linenowidth + self.ystep
counter += 1
- outfile.write('<text x="%s" y="%s" xml:space="preserve">' % (line_x, y))
+ outfile.write(f'<text x="{line_x}" y="{y}" xml:space="preserve">')
for ttype, value in tokensource:
style = self._get_style(ttype)
tspan = style and '<tspan' + style + '>' or ''
@@ -159,11 +157,10 @@ class SvgFormatter(Formatter):
y += self.ystep
outfile.write('</text>\n')
if self.linenos and counter % counter_step == 0:
- outfile.write('<text x="%s" y="%s" text-anchor="end" %s>%s</text>' %
- (x+self.linenowidth,y,counter_style,counter))
-
+ outfile.write(f'<text x="{x+self.linenowidth}" y="{y}" text-anchor="end" {counter_style}>{counter}</text>')
+
counter += 1
- outfile.write('<text x="%s" y="%s" ' 'xml:space="preserve">' % (line_x,y))
+ outfile.write(f'<text x="{line_x}" y="{y}" ' 'xml:space="preserve">')
outfile.write(tspan + parts[-1] + tspanend)
outfile.write('</text>')