ftilmann / latexdiff

Compares two latex files and marks up significant differences between them. Releases on www.ctan.org and mirrors
GNU General Public License v3.0
514 stars 72 forks source link

Mangled verbatim line environment #168

Closed jpbrucker closed 4 years ago

jpbrucker commented 5 years ago

It seems like commit 761ce840112c ("added standard styles for verbatim markup") introduced a regression on some verbatim environments. I first noticed this with lstlistings but could reproduce the issue using verbatim. When doing a diff of the following files with latexdiff 1.3.0, the resulting .tex doesn't compile.

verbatim-1.tex

\documentclass{report}
\begin{document}
\begin{verbatim}
1
\end{verbatim}
\begin{verbatim}
2
\end{verbatim}
\end{document}

verbatim-2.tex

\documentclass{report}
\begin{document}
\begin{verbatim}
3
\end{verbatim}
\end{document}

result.tex

...
\begin{document}
\DIFmodbegin
\begin{DIFverbatim}[alsolanguage=DIFcode]
%DIF < 1
\end{DIFverbatim}
\DIFmodend
%DIFDELCMD < \begin{verbatim}
%DIFDELCMD < %%%
%DIF < DIFVRB 2
\DIFdelend %DIF > DIFVRB 3
\end{verbatim}
\end{document}

Fails with:

! LaTeX Error: \begin{document} ended by \end{verbatim}.

git bisect pointed to commit 761ce840112c as the first one mangling the output

ftilmann commented 5 years ago

I can confirm this as a bug; thanks for finding the offending commit. Clearly something is going very wrong. Will require some investigation as I don't really want to roll back this commit, which is providing useful functionality and in most cases seems to work.

ftilmann commented 4 years ago

@jpbrucker not sure if you are still interested in this old thread, but I managed to fix the problem for the MWE (albeit with an additional empty line added, and change to the internal organisation of the verbatim environment. The fix is more a patch-up, but it did work for the MWE and didn't break any of the other test cases for verbatim environment. However, it might or might not work with more complicated documents, and might also have unwanted effects.

jpbrucker commented 3 years ago

Great, thanks for fixing it!