diff --git a/latexdiff b/latexdiff index a7a27da..b365c9c 100755 --- a/latexdiff +++ b/latexdiff @@ -2570,15 +2570,15 @@ sub take_comments_and_newline_from_frac() { # some special magic for common usage of frac, which does not conform to the latexdiff requirements but can be made to fit # note that this is a rare exception to the general rule that the new tex can be reconstructed from the diff file - # \frac12 -> \frac{1}{2} - s/\\frac(\d)(\w)/\\frac\{$1\}\{$2\}/g; - - # \frac1{2b} -> \frac{1}{2b} - s/\\frac(\d)/\\frac\{$1\}/g; - - # delete space and comment characters between \frac arguments -# s/\\frac(?:\s*?%[^\n]*?)*?(\{$pat_n\})\s*(\{$pat_n\})/\\frac$1$2/g; - s/\\frac(?:\s|%[^\n]*?)*(\{$pat_n\})(?:\s|%[^\n]*?)*(\{$pat_n\})/\\frac$1$2/g; + # regex that matches space and comment characters + my $space = qr/\s|%[^\n]*?/; + # \frac {abc} -> \frac{abc} + # \frac1 -> \frac{1} + # \frac a -> \frac{a} + # \frac \lambda -> \frac{\lambda} + s/\\frac(?|${space}+\{($pat_n)\}|${space}*(\d)|${space}+(\w)|${space}*(\\[a-zA-Z]+))/\\frac\{$1\}/g; + # same as above for the second argument of frac + s/\\frac(\{$pat_n\})(?|${space}*\{($pat_n)\}|${space}*(\d)|${space}+(\w)|${space}*(\\[a-zA-Z]+))/\\frac$1\{$2\}/g; } # preprocess($string, ..)