minted icon indicating copy to clipboard operation
minted copied to clipboard

Effect of multiple `gobble=<int>` accumulate, not overwrite

Open muzimuzhi opened this issue 3 years ago • 2 comments

The total effect of \setminted{gobble=1, gobble=2} is gobble=3, but the expected is gobble=2.

From https://tex.stackexchange.com/q/650135

Example:

\documentclass{article}
\usepackage{minted}
\parindent=0pt

\begin{document}
\subsection*{minted works wrong}

\setminted{gobble=1, gobble=2}
expected: 3456
\begin{minted}{text}
123456
\end{minted}

\subsection*{fvextra is ok}
\fvset{gobble=1, gobble=2}
expected: 3456
\begin{Verbatim}
123456
\end{Verbatim}
\end{document}

image

Currently gobble is defined by https://github.com/gpoore/minted/blob/d46f1ba2d248f2f3504bcc795dd39c613bd3c5a0/source/minted.dtx#L2662-L2664 Hence \setminted{gobble=1, gobble=2} will become pygmentize options -F gobble:n=1 -F gobble:n=2.

muzimuzhi avatar Jul 10 '22 02:07 muzimuzhi

I don't know if there is an easy way to fix this. The current system for working with pygmentize is based on the assumption that later options override earlier ones instead of combining. So one solution would involve a complete redesign of pygmentize option handling. Another possibility is to do gobble in LaTeX when writing the code to the temp file. That is possible, but will require special handling of UTF-8 code points for pdflatex.

I expect that there are other bugs related to pygmentize options combining rather than overriding, so even if it's possible to fix this by switching the processing to the LaTeX side, the pygmentize processing probably needs to be reimplemented anyway.

gpoore avatar Jul 10 '22 02:07 gpoore

So one solution would involve a complete redesign of pygmentize option handling.

+1 to a general fix for \minted@def@optcl.

muzimuzhi avatar Jul 10 '22 02:07 muzimuzhi