Closed ORippler closed 2 years ago
Sorry for much delayed reaction. In line 2220, where the error occurs, the input body text is split into tokens.As for normal texts this part is fast and only a small fraction of the overall time, I don't expect there is a major problem with the way the regexes are set up. The problem could be the sheer size of the files, or more likely that they do not conform to the expectations of non-picture environment latex. If already you are running into trouble when tokenizing your input files, for sure you will be in trouble when trying to run the diff algorithm. I am not quite sure what you are trying to do here. Running latexdiff on image data does not make sense, as you cannot mark this up graphically the same way. It's designed for highlighting changes in text, and tries to do a reasonable job for equations (though not always succeeds). Skip the --flatten option and everything will probably work fine (you will just see the new version of the picture of course), obviously it does not make sense for your MWE. If you need the --flatten option due to the context missing from the MWE, you can use \newcommand to define an alias for \input which is unknown to latexdiff, and thus will not be flattened. I will close this issue for now, as it's unclear what you want to achieve. Debugging the regex to avoid this error on this large tikz-picture would be a lot of work, probably, and I cannot see the usefulness right now. If I misunderstood, please feel free to reopen and better describe your use case or ideally a smaller file triggering the recursion limit.
When compiling
latexdiff
for largetikzpicture
files (with lots of data), apparently the regex recursion limit is reached somewhere in the latexdiff script, leading to garbled / broken output.MWE
tex-file 1:
tex-file 2:
Generating the diff between the two files via
latexdiff --flatten $1 $2 > broken.tex
leads toand a garbled output when compiling the generated tex file.
fig_new.txt fig_old.txt
Note that I have to append
.txt
to the figs used in the MWE to get them to upload to Github.Possible solutions
According to the perldocs, we should refactor the affected regex to use a loop or other structures: https://perldoc.perl.org/perldiag#Complex-regular-subexpression-recursion-limit-(%25d)-exceeded
Also, since the figures are composed of largely tables with numbers, it might also be the case that a regex with nested quantifiers leads to unnecessary recursions/overlaps and could be optimized (note I haven't looked at the perl code in question since I am not familiar with perl): https://stackoverflow.com/a/34200869
Versions
For 100% reproducibility also my used Dockerfile for latex:
which can be started via
docker run --rm -it --volume "`pwd`:/workdir" $IMAGE:latest /bin/bash