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
531 stars 75 forks source link

Lines including new paragraph placed inside texttt (causing invalid LaTeX) when processing large diff #300

Open mikebeaton opened 6 months ago

mikebeaton commented 6 months ago

After a sequence of large (but move only) changes inside a large .tex file (specifically this change https://github.com/acidanthera/OpenCorePkg/pull/537), latexdiff is producing invalid LaTeX: in two or three instances, it is placing several lines of diff, including a new paragraph, inside texttt, which is invalid LaTeX for subsequent processing.

The issue occurs cross-platform, and on 1.3.1 as well as 1.3.3.

This is the error shown after using pdflatex to process the output:

Runaway argument?
{\DIFdelbegin \DIFdel {Acidanthera}\DIFdel {. }
! Paragraph ended before \text@command was complete.
<to be read again>
                   \par
l.6495 ...lend \DIFaddbegin \DIFadd{ARTFrequency}}
                                                   \DIFadd{in

This is the fragment of the diff file, with the close brace of the texttt, which starts on line 6488, highlighted on line 6495, several lines below:

image

Also in plain text:

\begin{enumerate}
\DIFaddbegin 

\DIFaddend \item
  \texttt{\DIFdelbegin \DIFdel{SpoofVendor}\DIFdelend \DIFaddbegin \DIFadd{ARTFrequency}\DIFaddend }\\
  \textbf{Type}: \texttt{plist\ \DIFdelbegin \DIFdel{boolean}\DIFdelend \DIFaddbegin \DIFadd{integer}\DIFaddend }\DIFaddbegin \DIFadd{, 64-bit}\DIFaddend \\
  \textbf{Failsafe}: \texttt{\DIFdelbegin \DIFdel{false}\DIFdelend \DIFaddbegin \DIFadd{0}\DIFaddend } \DIFaddbegin \DIFadd{(Automatic)}\DIFaddend \\
  \textbf{Description}: Sets \DIFdelbegin \DIFdel{SMBIOS vendor fields to }\DIFdelend \texttt{\DIFdelbegin \DIFdel{Acidanthera}%DIFDELCMD < \MBLOCKRIGHTBRACE%%%
\DIFdel{.
}%DIFDELCMD < 

%DIFDELCMD <   %%%
\DIFdel{It can be dangerous to use ``Apple'' in
  SMBIOS vendor fields for reasons outlined in the
  }\DIFdelend \DIFaddbegin \DIFadd{ARTFrequency}} \DIFadd{in
  }\DIFaddend \texttt{\DIFdelbegin \DIFdel{SystemManufacturer}%DIFDELCMD < \MBLOCKRIGHTBRACE %%%
\DIFdel{description.
However, certain firmware may not provide
  valid values otherwise, which could obstruct the operation of some software.
}\DIFdelend \DIFaddbegin \DIFadd{gEfiProcessorSubClassGuid}}\DIFadd{.
}\DIFaddend 

The same issue occurs three times in the diff file. I can manually fix up the invalid LaTeX and the diff file is otherwise fine.

ftilmann commented 6 months ago

Thanks for reporting. I just had a quick look at the diff listing of the commit https://github.com/acidanthera/OpenCorePkg/pull/537/commits/140f35529a908c8b67ac4181ec2aa78b5f964c38 and I can see there are many changes involving \item lists, which is a somewhat fragile part of latexdiff processing. You could experiment with --exclude-textcmd=texttt but even if it work it would probably mean you lose all the markup. There are some other long-standing bug reports related to itemised lists,, and if I am able to address those, I might have a look at your case again.