--- latexdiff.pl.orig 2013-06-26 18:57:37.000000000 -0400
+++ latexdiff.pl 2015-12-17 14:20:49.041293857 -0500
@@ -1238,7 +1238,7 @@
require File::Spec ;
$dirname = File::Basename::dirname($filename);
- if ( ($includeonly) = ($preamble =~ m/\\includeonly{(.*?)}/ ) ) {
+ if ( ($includeonly) = ($preamble =~ m/\\includeonly\{(.*?)}/ ) ) {
$includeonly =~ s/,/|/g;
} else {
$includeonly = '.*?';
@@ -1246,7 +1246,7 @@
print STDERR "DEBUG: includeonly $includeonly\n" if $debug;
- $text=~s/(^(?:[^%\n]|\\%)*)\\input{(.*?)}|\\include{(${includeonly}(?:\.tex)?)}/{
+ $text=~s/(^(?:[^%\n]|\\%)*)\\input\{(.*?)}|\\include\{(${includeonly}(?:\.tex)?)}/{
$fname = $2 if defined($2) ;
$fname = $3 if defined($3) ;
# # add tex extension unless there is a three letter extension already
@@ -1917,7 +1917,7 @@
s/^(\s*)//s;
push(@leadin,$1);
# Change \{ to \QLEFTBRACE and \} to \QRIGHTBRACE
- s/(?<!\\)\\{/\\QLEFTBRACE /sg;
+ s/(?<!\\)\\\{/\\QLEFTBRACE /sg;
s/(?<!\\)\\}/\\QRIGHTBRACE /sg;
# change begin and end commands within comments such that they
# don't disturb the pattern matching (if there are several \begin or \end in one line
@@ -1932,23 +1932,23 @@
s/\\begin\{(verbatim\*?)\}(.*?)\\end\{\1\}/"\\${1}{". tohash(\%verbhash,"${2}") . "}"/esg;
# Convert _n or _\cmd into \SUBSCRIPTNB{n} or \SUBSCRIPTNB{\cmd} and _{nnn} into \SUBSCRIPT{nn}
1 while s/(?<!\\)_([^{\\]|\\\w+)/\\SUBSCRIPTNB{$1}/g ;
- 1 while s/(?<!\\)_{($pat6)}/\\SUBSCRIPT{$1}/g ;
+ 1 while s/(?<!\\)_\{($pat6)}/\\SUBSCRIPT{$1}/g ;
# Convert ^n into \SUPERSCRIPTNB{n} and ^{nnn} into \SUPERSCRIPT{nn}
1 while s/(?<!\\)\^([^{\\]|\\\w+)/\\SUPERSCRIPTNB{$1}/g ;
- 1 while s/(?<!\\)\^{($pat6)}/\\SUPERSCRIPT{$1}/g ;
+ 1 while s/(?<!\\)\^\{($pat6)}/\\SUPERSCRIPT{$1}/g ;
# Convert $$ $$ into \begin{DOLLARDOLLAR} \end{DOLLARDOLLAR}
s/\$\$(.*?)\$\$/\\begin{DOLLARDOLLAR}$1\\end{DOLLARDOLLAR}/sg;
# Convert \[ \] into \begin{SQUAREBRACKET} \end{SQUAREBRACKET}
s/(?<!\\)\\\[/\\begin{SQUAREBRACKET}/sg;
s/\\\]/\\end{SQUAREBRACKET}/sg;
# Convert all picture environmentent (\begin{PICTUREENV} .. \end{PICTUREENV} \PICTUREBLOCKenv
- s/\\begin{($PICTUREENV)}(.*?)\\end{\1}/\\PICTUREBLOCK$1\{$2\}/sg;
+ s/\\begin\{($PICTUREENV)}(.*?)\\end\{\1}/\\PICTUREBLOCK$1\{$2\}/sg;
# For --block-math-markup option -convert all \begin{MATH} .. \end{MATH}
# into \MATHBLOCKMATH{...} commands, where MATH is any valid math environment
# Also convert all array environments into ARRAYBLOCK environments
if ( $mathmarkup != FINE ) {
- s/\\begin{($ARRENV)}(.*?)\\end{\1}/\\ARRAYBLOCK$1\{$2\}/sg;
- s/\\begin{($MATHENV|$MATHARRENV|SQUAREBRACKET)}(.*?)\\end{\1}/\\MATHBLOCK$1\{$2\}/sg;
+ s/\\begin\{($ARRENV)}(.*?)\\end\{\1}/\\ARRAYBLOCK$1\{$2\}/sg;
+ s/\\begin\{($MATHENV|$MATHARRENV|SQUAREBRACKET)}(.*?)\\end\{\1}/\\MATHBLOCK$1\{$2\}/sg;
}
# add final token " STOP"
$_ .= " STOP"
@@ -2207,15 +2207,15 @@
# environments) are between the \begin{$MATHENV} and \end{MATHMODE} commands. This is necessary as the minimal matching
# is not globally minimal but only 'locally' (matching is beginning from the left side of the string)
if ( $mathmarkup == FINE ) {
- 1 while s/\\begin{((?:$MATHENV)|(?:$MATHARRENV)|SQUAREBRACKET)}((?:.(?!(?:\\end{(?:(?:$MATHENV)|(?:$MATHARRENV)|SQUAREBRACKET)}|\\begin{MATHMODE})))*?)\\end{MATHMODE}/\\begin{$1}$2\\end{$1}/s;
- 1 while s/\\begin{MATHMODE}((?:.(?!\\end{MATHMODE}))*?)\\end{((?:$MATHENV)|(?:$MATHARRENV)|SQUAREBRACKET)}/\\begin{$2}$1\\end{$2}/s;
- # convert remaining \begin{MATHMODE} \end{MATHMODE} (and not containing & or \\ )into MATHREPL environments
- s/\\begin{MATHMODE}((?:(.(?!(?<!\\)\&|\\\\))*)?)\\end{MATHMODE}/\\begin{$MATHREPL}$1\\end{$MATHREPL}/sg;
+ 1 while s/\\begin\{((?:$MATHENV)|(?:$MATHARRENV)|SQUAREBRACKET)}((?:.(?!(?:\\end\{(?:(?:$MATHENV)|(?:$MATHARRENV)|SQUAREBRACKET)}|\\begin\{MATHMODE})))*?)\\end\{MATHMODE}/\\begin{$1}$2\\end{$1}/s;
+ 1 while s/\\begin\{MATHMODE}((?:.(?!\\end\{MATHMODE}))*?)\\end\{((?:$MATHENV)|(?:$MATHARRENV)|SQUAREBRACKET)}/\\begin{$2}$1\\end{$2}/s;
+ # convert remaining \begin\{MATHMODE} \end{MATHMODE} (and not containing & or \\ )into MATHREPL environments
+ s/\\begin\{MATHMODE}((?:(.(?!(?<!\\)\&|\\\\))*)?)\\end\{MATHMODE}/\\begin{$MATHREPL}$1\\end{$MATHREPL}/sg;
# others into MATHARRREPL
- s/\\begin{MATHMODE}(.*?)\\end{MATHMODE}/\\begin{$MATHARRREPL}$1\\end{$MATHARRREPL}/sg;
+ s/\\begin\{MATHMODE}(.*?)\\end\{MATHMODE}/\\begin{$MATHARRREPL}$1\\end{$MATHARRREPL}/sg;
# now look for AUXCMD math-mode pairs which have only comments (or empty lines between them), and remove the added commands
- s/\\begin{((?:$MATHENV)|(?:$MATHARRENV)|SQUAREBRACKET)}$AUXCMD\n((?:\s*%.[^\n]*\n)*)\\end{\1}$AUXCMD\n/$2/sg;
+ s/\\begin\{((?:$MATHENV)|(?:$MATHARRENV)|SQUAREBRACKET)}$AUXCMD\n((?:\s*%.[^\n]*\n)*)\\end{\1}$AUXCMD\n/$2/sg;
} else {
# math modes OFF,WHOLE,COARSE: Convert \MATHBLOCKmath{..} commands back to environments
s/\\MATHBLOCK($MATHENV|$MATHARRENV|SQUAREBRACKET)\{($pat6)\}/\\begin{$1}$2\\end{$1}/sg;
@@ -2299,18 +2299,18 @@
1 while s/(%.*)\\CITEDIF($CITECMD)/$1\\$2/mg ;
}
# Convert \begin{SQUAREBRACKET} \end{SQUAREBRACKET} into \[ \]
- s/\\end{SQUAREBRACKET}/\\\]/sg;
- s/\\begin{SQUAREBRACKET}/\\\[/sg;
+ s/\\end\{SQUAREBRACKET}/\\\]/sg;
+ s/\\begin\{SQUAREBRACKET}/\\\[/sg;
# 4. Convert \begin{DOLLARDOLLAR} \end{DOLLARDOLLAR} into $$ $$
s/\\begin\{DOLLARDOLLAR\}(.*?)\\end\{DOLLARDOLLAR\}/\$\$$1\$\$/sg;
# 5. Convert \SUPERSCRIPTNB{n} into ^n and \SUPERSCRIPT{nn} into ^{nnn}
- 1 while s/\\SUPERSCRIPTNB{($pat0)}/^$1/g ;
- 1 while s/\\SUPERSCRIPT{($pat6)}/^{$1}/g ;
+ 1 while s/\\SUPERSCRIPTNB\{($pat0)}/^$1/g ;
+ 1 while s/\\SUPERSCRIPT\{($pat6)}/^{$1}/g ;
# Convert \SUBSCRIPNB{n} into _n and \SUBCRIPT{nn} into _{nnn}
- 1 while s/\\SUBSCRIPTNB{($pat0)}/_$1/g ;
- 1 while s/\\SUBSCRIPT{($pat6)}/_{$1}/g ;
+ 1 while s/\\SUBSCRIPTNB\{($pat0)}/_$1/g ;
+ 1 while s/\\SUBSCRIPT\{($pat6)}/_{$1}/g ;
# Change \QLEFTBRACE, \QRIGHTBRACE to \{,\}
- s/\\QLEFTBRACE /\\{/sg;
+ s/\\QLEFTBRACE /\\\{/sg;
s/\\QRIGHTBRACE /\\}/sg;
return;