You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
135 lines
7.8 KiB
135 lines
7.8 KiB
5 years ago
|
diff -up ./latexdiff.pl.orig ./latexdiff.pl
|
||
|
--- ./latexdiff.pl.orig 2015-12-28 19:15:33.000000000 -0500
|
||
|
+++ ./latexdiff.pl 2016-06-22 15:46:24.444571914 -0400
|
||
|
@@ -1465,7 +1465,7 @@ sub flatten {
|
||
|
$bblfile=~s/\.tex$//;
|
||
|
$bblfile.=".bbl";
|
||
|
|
||
|
- if ( ($includeonly) = ($preamble =~ m/\\includeonly{(.*?)}/ ) ) {
|
||
|
+ if ( ($includeonly) = ($preamble =~ m/\\includeonly\{(.*?)}/ ) ) {
|
||
|
$includeonly =~ s/,/|/g;
|
||
|
} else {
|
||
|
$includeonly = '.*?';
|
||
|
@@ -1474,7 +1474,7 @@ sub flatten {
|
||
|
print STDERR "DEBUG: includeonly $includeonly\n" if $debug;
|
||
|
|
||
|
# recursively replace \\input and \\include files
|
||
|
- 1 while $text=~s/(^(?:[^%\n]|\\%)*)\\input{(.*?)}|\\include{(${includeonly}(?:\.tex)?)}/{
|
||
|
+ 1 while $text=~s/(^(?:[^%\n]|\\%)*)\\input\{(.*?)}|\\include\{(${includeonly}(?:\.tex)?)}/{
|
||
|
$begline=(defined($1)? $1 : "") ;
|
||
|
$fname = $2 if defined($2) ;
|
||
|
$fname = $3 if defined($3) ;
|
||
|
@@ -1491,7 +1491,7 @@ sub flatten {
|
||
|
"$begline$newpage$replacement$newpage";
|
||
|
}/exgm;
|
||
|
# replace bibliography with bbl file if it exists
|
||
|
- $text=~s/(^(?:[^%\n]|\\%)*)\\bibliography{(.*?)}/{
|
||
|
+ $text=~s/(^(?:[^%\n]|\\%)*)\\bibliography\{(.*?)}/{
|
||
|
if ( -f $bblfile ){
|
||
|
$replacement=read_file_with_encoding(File::Spec->catfile($bblfile), $encoding);
|
||
|
} else {
|
||
|
@@ -1502,7 +1502,7 @@ sub flatten {
|
||
|
"$begline$replacement";
|
||
|
}/exgm;
|
||
|
# replace subfile with contents (subfile package)
|
||
|
- $text=~s/(^(?:[^%\n]|\\%)*)\\subfile{(.*?)}/{
|
||
|
+ $text=~s/(^(?:[^%\n]|\\%)*)\\subfile\{(.*?)}/{
|
||
|
$begline=(defined($1)? $1 : "") ;
|
||
|
$fname = $2;
|
||
|
# # add tex extension unless there is a three letter extension already
|
||
|
@@ -2244,7 +2244,7 @@ sub take_comments_and_enter_from_frac()
|
||
|
sub preprocess {
|
||
|
for (@_) {
|
||
|
# Change \{ to \QLEFTBRACE, \} to \QRIGHTBRACE, and \& to \AMPERSAND
|
||
|
- s/(?<!\\)\\{/\\QLEFTBRACE /sg;
|
||
|
+ s/(?<!\\)\\\{/\\QLEFTBRACE /sg;
|
||
|
s/(?<!\\)\\}/\\QRIGHTBRACE /sg;
|
||
|
s/(?<!\\)\\&/\\AMPERSAND /sg;
|
||
|
# replace {,} in comments with \\CLEFTBRACE,\\CRIGHTBRACE
|
||
|
@@ -2258,29 +2258,29 @@ sub preprocess {
|
||
|
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/(?<!\\)_(\s*([^{\\\s]|\\\w+))/\\SUBSCRIPTNB{$1}/g ;
|
||
|
- 1 while s/(?<!\\)_(\s*{($pat_n)})/\\SUBSCRIPT$1/g ;
|
||
|
+ 1 while s/(?<!\\)_(\s*\{($pat_n)})/\\SUBSCRIPT$1/g ;
|
||
|
# Convert ^n into \SUPERSCRIPTNB{n} and ^{nnn} into \SUPERSCRIPT{nn}
|
||
|
1 while s/(?<!\\)\^(\s*([^{\\\s]|\\\w+))/\\SUPERSCRIPTNB{$1}/g ;
|
||
|
- 1 while s/(?<!\\)\^(\s*{($pat_n)})/\\SUPERSCRIPT$1/g ;
|
||
|
+ 1 while s/(?<!\\)\^(\s*\{($pat_n)})/\\SUPERSCRIPT$1/g ;
|
||
|
# Convert \sqrt{n} into \SQRT{n} and \sqrt nn into SQRTNB{nn}
|
||
|
1 while s/(?<!\\)\\sqrt(\s*([^{\\\s]|\\\w+))/\\SQRTNB{$1}/g ;
|
||
|
- 1 while s/(?<!\\)\\sqrt(\s*{($pat_n)})/\\SQRT$1/g ;
|
||
|
+ 1 while s/(?<!\\)\\sqrt(\s*\{($pat_n)})/\\SQRT$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\{($ARRENV)}(.*?)\\end\{\1}/\\ARRAYBLOCK$1\{$2\}/sg;
|
||
|
|
||
|
take_comments_and_enter_from_frac();
|
||
|
|
||
|
- s/\\begin{($MATHENV|$MATHARRENV|SQUAREBRACKET)}(.*?)\\end{\1}/\\MATHBLOCK$1\{$2\}/sg;
|
||
|
+ s/\\begin\{($MATHENV|$MATHARRENV|SQUAREBRACKET)}(.*?)\\end\{\1}/\\MATHBLOCK$1\{$2\}/sg;
|
||
|
}
|
||
|
# add final token " STOP"
|
||
|
$_ .= " STOP"
|
||
|
@@ -2566,15 +2566,15 @@ sub postprocess {
|
||
|
# 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)\{($pat_n)\}/\\begin{$1}$2\\end{$1}/sg;
|
||
|
@@ -2652,19 +2652,19 @@ sub postprocess {
|
||
|
# undo renaming of the \begin and \end,{,} and dollars in comments
|
||
|
1 while s/(%.*)DOLLARDIF/$1\$/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/\\SUPERSCRIPT(\s*{($pat_n)})/^$1/g ;
|
||
|
- 1 while s/\\SUPERSCRIPTNB{(\s*$pat0)}/^$1/g ;
|
||
|
+ 1 while s/\\SUPERSCRIPT(\s*\{($pat_n)})/^$1/g ;
|
||
|
+ 1 while s/\\SUPERSCRIPTNB\{(\s*$pat0)}/^$1/g ;
|
||
|
# Convert \SUBSCRIPNB{n} into _n and \SUBCRIPT{nn} into _{nnn}
|
||
|
- 1 while s/\\SUBSCRIPT(\s*{($pat_n)})/_$1/g ;
|
||
|
- 1 while s/\\SUBSCRIPTNB{(\s*$pat0)}/_$1/g ;
|
||
|
+ 1 while s/\\SUBSCRIPT(\s*\{($pat_n)})/_$1/g ;
|
||
|
+ 1 while s/\\SUBSCRIPTNB\{(\s*$pat0)}/_$1/g ;
|
||
|
# Convert \SQRT{n} into \sqrt{n} and \SQRTNB{nn} into \sqrt nn
|
||
|
- 1 while s/\\SQRT(\s*{($pat_n)})/\\sqrt$1/g ;
|
||
|
- 1 while s/\\SQRTNB{(\s*$pat0)}/\\sqrt$1/g ;
|
||
|
+ 1 while s/\\SQRT(\s*\{($pat_n)})/\\sqrt$1/g ;
|
||
|
+ 1 while s/\\SQRTNB\{(\s*$pat0)}/\\sqrt$1/g ;
|
||
|
|
||
|
1 while s/(%.*)\\CRIGHTBRACE (.*)$/$1\}$2/mg ;
|
||
|
1 while s/(%.*)\\CLEFTBRACE (.*)$/$1\{$2/mg ;
|