# latexdiff incompatible with half brackets

I recently encountered some problem using latexdiff when the tex file contains matched half brackets like \left(\. or \.\right). For example, I have two files, one is test-old.tex,

\documentclass{article}
\begin{document}
this is the old one, with

$$\label{eq:1} \left( full~bracket \right)$$
\end{document}


the other is test-new.tex,

\documentclass{article}
\begin{document}
this is the new one, with
$$\label{eq:1} \left( half~bracket \right.$$
\end{document}


I use the command latexdiff test-old.tex test-new.tex > test-diff.tex to generate the compared file test-diff.tex as follows,

\documentclass{article}
%DIF LATEXDIFF DIFFERENCE FILE
%DIF DEL test-old.tex   Wed Feb  3 21:05:52 2016
%DIF ADD test-new.tex   Wed Feb  3 21:05:58 2016
%DIF PREAMBLE EXTENSION ADDED BY LATEXDIFF
%DIF UNDERLINE PREAMBLE %DIF PREAMBLE
\RequirePackage[normalem]{ulem} %DIF PREAMBLE
\RequirePackage{color}\definecolor{RED}{rgb}{1,0,0}\definecolor{BLUE}{rgb}{0,0,1} %DIF PREAMBLE
\providecommand{\DIFdel}[1]{{\protect\color{red}\sout{#1}}}                      %DIF PREAMBLE
%DIF SAFE PREAMBLE %DIF PREAMBLE
\providecommand{\DIFdelbegin}{} %DIF PREAMBLE
\providecommand{\DIFdelend}{} %DIF PREAMBLE
%DIF FLOATSAFE PREAMBLE %DIF PREAMBLE
\providecommand{\DIFdelFL}[1]{\DIFdel{#1}} %DIF PREAMBLE
\providecommand{\DIFdelbeginFL}{} %DIF PREAMBLE
\providecommand{\DIFdelendFL}{} %DIF PREAMBLE
%DIF END PREAMBLE EXTENSION ADDED BY LATEXDIFF

\begin{document}
\DIFdelbegin %DIFDELCMD <

%DIFDELCMD < %%%
\DIFdelend $$\label{eq:1} \left( \DIFdelbegin \DIFdel{full}\DIFdelend \DIFaddbegin \DIFadd{half}\DIFaddend ~bracket \DIFdelbegin %DIFDELCMD < \right) %DIFDELCMD < %%% \DIFdelend \DIFaddbegin \right\DIFadd{. }\DIFaddend$$
\end{document}


which does not compile to pdf, mainly due to the third line from bottom

\DIFdelend \DIFaddbegin \right\DIFadd{.


where \right is separated from ., hence the matching is ruined.

How does this happen? Is there a proper way to avoid this? Thanks!

P.S.

My latexdiff --version produces

This is LATEXDIFF 1.0.2  (Algorithm::Diff 1.15 so, Perl v5.18.2)


which I know is not the latest, but I did not find any related information on this (possible) bug.

At this stage, I have tried two methods to at least make test-diff.tex compile. One is to modify the file, delete the related part in the generated file(or add a dot manually after \right); but this not only adds debugging effort, I have to do it every time after comparison. The other way is to define a new macro for the half brackets(or parentheses), and use the new macro instead in the files to be compared.

It is a simple bug in the script, forgetting to add . as a possible bracket. You can correct it by replacing the line starting my $cmdleftright= by  my$cmdleftright='\\\$$?:left|right|[Bb]igg?[lrm]?|middle)\s*(?:[<>()|\.]|\\\\(?:[|{}]|\w+))';  The change being to add \. in the group [<>...]. You should report this as a bug to the maintainer. • You are amazing! I guess I cannot test this myself (as I know nothing of perl etc), but I'll try to report the bug as you suggested. – davyjones Feb 3 '16 at 14:23 • Another thing I notice is that, if the formulas are inline (between ), then everything is ok. Why this different standard? – davyjones Feb 4 '16 at 5:34 • but not ok if I try \($$ or  – davyjones Feb 4 '16 at 5:49