minted
minted copied to clipboard
escapeinside argument is expanded
I tried to set backquotes as escape characters but failed to get it working. For example, the following is not working:
\begin{minted}[escapeinside=``]{python}
1 `\textcolor{red}{!=}` 2
\end{minted}
It appears that the backquotes are expanded because the option
escapeinside
is put in double-quote when passed to the shell (line
612) of minted.sty).
A simple fix is to use quotes instead of double-quotes. So use
\minted@def@optcl@e{escapeinside}{-P 'escapeinside}{#1'}
instead of
\minted@def@optcl@e{escapeinside}{-P "escapeinside}{#1"}
I don't know but it could introduce some regressions.
Regards,
The following minimal example cannot reproduce your problem.
% minted-escape.tex
\documentclass{article}
\usepackage{minted}
\begin{document}
\begin{minted}[escapeinside=``]{python}
1 `\textcolor{red}{!=}` 2
\end{minted}
\end{document}
$ pdflatex -shell-escape minted-escape.tex
Maybe your problem came from other settings of your document. For example, symbol '
is set to be active character by \MakeShortVerb{\'}
.
I still have the problem with the MWE. This is really an escaping problem when calling the shell, backquotes are interpreted by the shell (bash for me). This might not be the case for all shells.
When escaping characters from inside the LaTeX source (not ideal), things are working.
\documentclass{article}
\usepackage{minted}
\begin{document}
\begin{minted}[escapeinside=\\`\\`]{python}
1 `\textcolor{red}{!=}` 2
\end{minted}
\end{document}
This is really an escaping problem when calling the shell, backquotes are interpreted by the shell (bash for me). This might not be the case for all shells.
Oh, I missed this.
This should be fixed as of minted
v2.7 (2022/12/12). The upcoming minted
v3.0 will completely eliminate the entire class of bugs related to shell quoting.