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

Incorrect handling of $$. #234

Open ITWOI opened 3 years ago

ITWOI commented 3 years ago

Hi,

Here is the latex code $=$$=$. You can see it can be split into two parts: $=$ and $=$. However, latexdiff mistakenly pairs the first $ and the last$, and tries to find the second $$.

I admit the code can be easily fixed by replacing the latex code with $==$, but maybe it may lead to other bugs.

ftilmann commented 3 years ago

It's a little bit pathological code, although of course technically correct. The easiest way to fix this would be to look for this pattern in pre-processing and make just the substitution you suggest. Would that be OK? - it would modify the .tex a little, so does not quite conform the ambition that the new file can be reconstructed from the diff'ed file. Is there ever a time, when this construction has its justification? Of course, latexdiff should cope with idiosyncratic but correct .tex It's easy enough to turn off detection for $$ entirely and would be theoretically justified as it's not strictly latex but original TeX. But I feel this would cause many more problems.

ITWOI commented 3 years ago

The pathological code can be easily fixed. Since it only occurs once, I have already fixed it.

It's easy enough to turn off detection for $$ entirely and would be theoretically justified as it's not strictly latex but original TeX. But I feel this would cause many more problems.

The reason for reporting this bug is that I think the way how latexdiff processes this kind of syntax is incorrect. $=$$=$ is an example, maybe there are other bug patterns.