-
Notifications
You must be signed in to change notification settings - Fork 630
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LaTeX: workaround minted incompatibility with Pygments 2.8.0 #1735
Conversation
Fix: pygments#1731 Fix: pygments#1734 Upstream issue: gpoore/minted#294
%% 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
defining the restoring macro is for maximal compatibility but anyhow regarding minted problem with -
of catcode 11 it seems it happens within a group so it is unneeded to restore at end of this style file the catcode -
to its (erroneous) minted setting anyhow
@@ -129,6 +133,7 @@ def escape_tex(text, commandprefix): | |||
\def\%(cp)sZlb{[} | |||
\def\%(cp)sZrb{]} | |||
\makeatother | |||
\%(cp)s@restore@catcode@of@minus@sign |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as commented above we could also decide to go for only \catcode`\-=12
approach because nobody in his/her right mind should input a TeX/LaTeX file of macros with any other catcode for -
than 12
I think this should definitely be merged - I think tex package release cycles are quite long and we don't want to break minted. |
@Anteru pick into a branch and make a 2.8.1? |
@birkenfeld sorry for not having detected the problem at time of #1708, but I use only Sphinx! :-) |
@birkenfeld Yes, this seems important enough. I'd suggest to merge onto master and then cherry-pick into a 2.8 series branch. |
Fix: #1731 Fix: #1734 Upstream issue: gpoore/minted#294
Cherry picked as 500713d which can be used for a 2.8.1 release. |
%% 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As minted loads this file with \endlinechar=-1
setting it would have been better here to add explicitly \relax
after 12
. This is cosmetic as next line starts with a \def
which does not expand hence the TeX parsing of the digits will end correctly.
Just mentioning this out of professional sense of duty... (there is no higher level LaTeX interface to set a catcode, so I used the core level TeX syntax, but one has to be aware of some things) (I would have probably used core TeX syntax anyhow anyway as I like it)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's certainly interesting to read 😆
There was a silly oversight (they all are silly) in my latex code, which I fixed at #1736. Sorry for all the trouble! @birkenfeld |
This reverts already merged pygments#1735 (after a commit from pygments#1736 to fix it) and applies the first envisioned method discussed in pygments#1734. The reason is that the pygments#1735-pygments#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. Thus, retoring the normal meaning of - e.g. must be done slightly differently than in be defined using the weird minted -. The pygments#1735-pygments#1736 method did fix compatibility with minted but *only* for those style names not using a -, and it creates another issue if used with style "paraiso-dark" e.g. 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 pygments#1734.
This reverts already merged pygments#1735 (after a commit from pygments#1736 to fix it) and applies the first envisioned method discussed in pygments#1734. The reason is that the pygments#1735-pygments#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. Thus, restoring the normal meaning of - e.g. must be done slightly differently than in be defined using the weird minted -. The pygments#1735-pygments#1736 method did fix compatibility with minted but *only* for those style names not using a -, and it creates another issue if used with style "paraiso-dark" e.g. 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 pygments#1734.
This reverts already merged pygments#1735 (after a commit from pygments#1736 to fix it) and applies the first envisioned method discussed in pygments#1734. The reason is that the pygments#1735-pygments#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 pygments#1735-pygments#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 pygments#1734.
* 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.
* 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.
Fix: #1731
Fix: #1734
Upstream issue: gpoore/minted#294