diff options
| author | Jean-François B <jfbu@free.fr> | 2021-03-06 08:16:51 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-03-06 08:16:51 +0100 |
| commit | e1059f07d240b7292e451f466d5791dc68301e96 (patch) | |
| tree | 183a0b75a0d05ca30f2786b3cd0e3834cf82a66c | |
| parent | 61852cb0f41f55a9a0523bbcb3ffb287c13216e0 (diff) | |
| download | pygments-git-e1059f07d240b7292e451f466d5791dc68301e96.tar.gz | |
Minted compatibility patch (#1737)
* Fix #1735 pull request
* LaTeX: workaround to ensure compatibility with minted
This reverts already merged #1735 (after a commit from #1736 to fix it)
and applies the first envisioned method discussed in #1734.
The reason is that the #1735-#1736 method only partially repairs the
minted compatibility. Minted queries from Pygments the stylesheet
with a command prefix equal to the style name, which may contain
(at least, so far) characters such as - and _, which are not normally
allowed in LaTeX macros. So it modifies the meaning of - and _ before
telling LaTeX to input the Pygments provided stylesheet. Restoring
the normal meaning of - from inside the stylesheet must be carefully
localized: at top and bottom of stylesheets some macros will use in
their names the - and there the - must be the weird minted one, not
the normal one.
The #1735-#1736 method thus does fix compatibility with minted but *only*
for those style names not using a -, but it creates another issue if
used with e.g. style "paraiso-dark" which has a - character in its name.
"De guerre lasse", I feel it is simpler to use the somewhat strange
very localized hotfix of prefixing - by \string at the one spot where
we need it to be its normal self. Hence this PR.
Fix #1734.
| -rw-r--r-- | pygments/formatters/latex.py | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/pygments/formatters/latex.py b/pygments/formatters/latex.py index f21c40f2..e32fcebc 100644 --- a/pygments/formatters/latex.py +++ b/pygments/formatters/latex.py @@ -97,10 +97,6 @@ DOC_TEMPLATE = r''' STYLE_TEMPLATE = r''' \makeatletter -%% workaround a minted <= v2.5 issue, which loads this file with - having -%% catcode letter; also with _ having catcode 11 but this does not affect us -\edef\%(cp)s@restore@catcode@of@minus@sign{\catcode`\noexpand\-=\the\catcode`\-\relax} -\catcode`\-=12 \def\%(cp)s@reset{\let\%(cp)s@it=\relax \let\%(cp)s@bf=\relax%% \let\%(cp)s@ul=\relax \let\%(cp)s@tc=\relax%% \let\%(cp)s@bc=\relax \let\%(cp)s@ff=\relax} @@ -133,7 +129,6 @@ STYLE_TEMPLATE = r''' \def\%(cp)sZlb{[} \def\%(cp)sZrb{]} \makeatother -\%(cp)s@restore@catcode@of@minus@sign ''' @@ -304,7 +299,7 @@ class LatexFormatter(Formatter): cmndef += (r'\def\$$@tc##1{\textcolor[rgb]{%s}{##1}}' % rgbcolor(ndef['color'])) if ndef['border']: - cmndef += (r'\def\$$@bc##1{{\setlength{\fboxsep}{-\fboxrule}' + cmndef += (r'\def\$$@bc##1{{\setlength{\fboxsep}{\string -\fboxrule}' r'\fcolorbox[rgb]{%s}{%s}{\strut ##1}}}' % (rgbcolor(ndef['border']), rgbcolor(ndef['bgcolor']))) |
