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
506 stars 72 forks source link

Contents of \else is displayed as removed when an \iftrue block is deleted #261

Open MBradbury opened 2 years ago

MBradbury commented 2 years ago

If there is text contained within an \iftrue block and the \iftrue logic is then removed in an edit, latexdiff will display the contents of the else block as deleted. However, the contents of the produced document never contained the text in the else block. Ideally, latexdiff should not report that the document's contents have changed.

a.tex:

\documentclass{article}
\begin{document}
\iftrue
hello
\else
hi
\fi
\end{document}

b.tex:

\documentclass{article}
\begin{document}
hello
\end{document}

c.tex:

\begin{document}
\DIFdelbegin %DIFDELCMD < \iftrue
%DIFDELCMD < %%%
\DIFdel{hello
 }%DIFDELCMD < \else
%DIFDELCMD < %%%
\DIFdel{hi
}%DIFDELCMD < \fi
%DIFDELCMD <  %%%
\DIFdelend \DIFaddbegin \DIFadd{hello
 }\DIFaddend\end{document}

Version information (I'm using 4f17f7b188fdbd8f6477aaea4118d0416babf370 off master):

$ latexdiff --version
This is LATEXDIFF 1.3.3a (Algorithm::Diff 1.1903, Perl v5.30.0)
  (c) 2004-2022 F J Tilmann
ftilmann commented 4 months ago

I can see the problem but this would be very difficult to fix as latexdiff would have to follow the whole logic of the conditional expressions. The promise of latexdiff is that it works with standard latex and ignores TeX commands such as the \if statements. Sorry about that.