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/latex.py | |
parent | 0d55ca22c507d18c2f35718687e0b06d9915397b (diff) | |
download | ydb-c04b663c7bb4b750deeb8f48f620497ec13da8fa.tar.gz |
intermediate changes
ref:2d4f292087954c9344efdabb7b2a67f466263c65
Diffstat (limited to 'contrib/python/Pygments/py3/pygments/formatters/latex.py')
-rw-r--r-- | contrib/python/Pygments/py3/pygments/formatters/latex.py | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/contrib/python/Pygments/py3/pygments/formatters/latex.py b/contrib/python/Pygments/py3/pygments/formatters/latex.py index e32fcebc5a..d33b686d8f 100644 --- a/contrib/python/Pygments/py3/pygments/formatters/latex.py +++ b/contrib/python/Pygments/py3/pygments/formatters/latex.py @@ -4,7 +4,7 @@ Formatter for LaTeX fancyvrb 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. """ @@ -159,6 +159,8 @@ class LatexFormatter(Formatter): \PY{k}{pass} \end{Verbatim} + Wrapping can be disabled using the `nowrap` option. + The special command used here (``\PY``) and all the other macros it needs are output by the `get_style_defs` method. @@ -171,6 +173,11 @@ class LatexFormatter(Formatter): Additional options accepted: + `nowrap` + If set to ``True``, don't wrap the tokens at all, not even inside a + ``\begin{Verbatim}`` environment. This disables most other options + (default: ``False``). + `style` The style to use, can be a string or a Style subclass (default: ``'default'``). @@ -248,6 +255,7 @@ class LatexFormatter(Formatter): def __init__(self, **options): Formatter.__init__(self, **options) + self.nowrap = get_bool_opt(options, 'nowrap', False) self.docclass = options.get('docclass', 'article') self.preamble = options.get('preamble', '') self.linenos = get_bool_opt(options, 'linenos', False) @@ -334,18 +342,19 @@ class LatexFormatter(Formatter): realoutfile = outfile outfile = StringIO() - outfile.write('\\begin{' + self.envname + '}[commandchars=\\\\\\{\\}') - if self.linenos: - start, step = self.linenostart, self.linenostep - outfile.write(',numbers=left' + - (start and ',firstnumber=%d' % start or '') + - (step and ',stepnumber=%d' % step or '')) - if self.mathescape or self.texcomments or self.escapeinside: - outfile.write(',codes={\\catcode`\\$=3\\catcode`\\^=7' - '\\catcode`\\_=8\\relax}') - if self.verboptions: - outfile.write(',' + self.verboptions) - outfile.write(']\n') + if not self.nowrap: + outfile.write('\\begin{' + self.envname + '}[commandchars=\\\\\\{\\}') + if self.linenos: + start, step = self.linenostart, self.linenostep + outfile.write(',numbers=left' + + (start and ',firstnumber=%d' % start or '') + + (step and ',stepnumber=%d' % step or '')) + if self.mathescape or self.texcomments or self.escapeinside: + outfile.write(',codes={\\catcode`\\$=3\\catcode`\\^=7' + '\\catcode`\\_=8\\relax}') + if self.verboptions: + outfile.write(',' + self.verboptions) + outfile.write(']\n') for ttype, value in tokensource: if ttype in Token.Comment: @@ -408,7 +417,8 @@ class LatexFormatter(Formatter): else: outfile.write(value) - outfile.write('\\end{' + self.envname + '}\n') + if not self.nowrap: + outfile.write('\\end{' + self.envname + '}\n') if self.full: encoding = self.encoding or 'utf8' |