Skip to content

Commit

Permalink
Improved processing for FINE math markup mode. (Partially) fixes #235 #…
Browse files Browse the repository at this point in the history
  • Loading branch information
ftilmann committed Feb 9, 2022
1 parent 12ddc9e commit 0d71987
Show file tree
Hide file tree
Showing 5 changed files with 147 additions and 64 deletions.
112 changes: 76 additions & 36 deletions latexdiff
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,26 @@
### - move --show-xxx options so that they are also capable of showing preamble (and commands) after all modificationsbased on source file packages
### - change meaning of --packages option such that this packages are used in addition of automatically detected packages (possibly introduce option --only-packages that overrides automatic choices completely
#
# Note references to issue numbers are for the github repository of latexdiff: https://github.com/ftilmann/latexdiff
#
# Version 1.3.3:
# New features:
# - Option --no-del to remove all deleted text (merge contributed by github user tdegeus PR #252, fixing issue #66
#
# Bug fixes:
# - In WHOLE and COARSE math modes, now properly treat math environments with arguments such as \alignat. Fixes #251
# - For FINE math mode, multiple improvments to the processing work flow yield more robust outcomes. In particular, changes
# to the equation type, e.g. \begin{displaymath} -> \begin{equation} without modifications now usually no longer result
# in errors. (Partially) fixes issues #235 and #244.
# - When encountering deleted math array environments such as align or eqnarray, rather than replacing them with a
# fixed replacement environment (e.g. align* or eqnarray*), a asterisk is now added to the original command, which
# fixed replacement environment (e.g. align* or eqnarray*), an asterisk is now added to the original command, which
# in amsmath (and with eqnarray) will result in the same environment but without line numbers. Config variable MATHARRREPL
# is therefore (nearly) redundant, and a depracation warning is given when it is set. Reference to MATHARRREPL are have
# been removed from the manual (there is one exception, when it's still being used: sometimes latexdiff can figure out
# that there is a deleted array environment, but does not know which one. In this case, MATHARRREPL is still being used
# to encapsulate these parts of the source, and therefore it is still set internally. But this is a quite rare situation)
# to encapsulate these parts of the source, and therefore it is still set internally. But this is a quite rare situation).
# Fixes issue #216


# Version 1.3.2
# API adaptions:
Expand Down Expand Up @@ -372,7 +379,7 @@ my @MBOXCMDLIST=(); # patterns for commands which are in principle safe but wh
my @MBOXCMDEXCL=(); # all the patterns in MBOXCMDLIST will be appended to SAFECMDLIST

my @KEEPCMDLIST=( qr/^bibitem$/ ); # patterns for commands which should not be deleted in nominally delete text passages
my @KEEPCMDEXCL=();
my @KEEPCMDEXCL=();

my ($i,$j,$l);
my ($old,$new);
Expand Down Expand Up @@ -831,7 +838,8 @@ push(@SAFECMDLIST, qr/^QLEFTBRACE$/, qr/^QRIGHTBRACE$/);
my $oneletcmd='\\\\.\*?(?:\['.$brat_n.'\]|\{'. $pat_n . '\})*';
### the commented out version is simpler but for some reason cannot cope with newline (in spite of s option) - need to include \newline explicitly
### my $math='\$(?:[^$]|\\\$)*?\$|\\\\[(].*?\\\\[)]';
my $math='\$(?:[^$]|\\\$)*?\$|\\\\[(](?:.|\n)*?\\\\[)]';
# inline math $....$ or \(..\)
my $math='\$(?:[^$]|\\\$)*?\$|\\\\[(](?:.|\n)*?\\\\[)]';
### test version (this seems to give the same results as version above)
## the current maths command cannot cope with newline within the math expression
### my $math='\$(?:[^$]|\\\$)*?\$|\\[(].*?\\[)]';
Expand Down Expand Up @@ -2851,7 +2859,8 @@ sub writedebugfile {
# carry out the following post-processing steps for all arguments:
# * Remove STOP token from the end
# * Replace \RIGHTBRACE by }
# * change citation commands within comments to protect from processing (using marker CITEDIF)
### NO LONGER DONE * change citation commands within comments to protect from processing (using marker CITEDIF)
# * If option --no-del is set delete all deleted blocks
# 1. Check all deleted blocks:
# a.where a deleted block contains a matching \begin and
# \end environment (these will be disabled by a %DIFDELCMD statements), for selected environments enable
Expand Down Expand Up @@ -2897,9 +2906,9 @@ sub writedebugfile {
# Note have to manually synchronize substitution commands below and
# DIF.. command names in the header
sub postprocess {
my ($begin,$len,$cnt,$float,$delblock,$addblock);
my ($begin,$len,$float,$delblock,$addblock); ### $cnt
# second level blocks
my ($begin2,$cnt2,$len2,$eqarrayblock,$mathblock);
my ($begin2,$len2,$eqarrayblock,$eqblock,$mathblock); ### $cnt2

my (@textparts,@newtextparts,@liststack,$listtype,$listlast);

Expand Down Expand Up @@ -2936,13 +2945,16 @@ sub postprocess {
# is properly within math mode). For math mode environments replace numbered equation
# environments with their display only variety (so that equation numbers in new file and
# diff file are identical)
writedebugfile($_,'postprocess1');


while ( m/\\DIFdelbegin.*?\\DIFdelend/sg ) {
# special processing within each deleted block
### while ( m/\\DIFdelbegin.*?\\DIFdelend/sg ) {
### print STDERR "DEBUG Match delblock \n||||$&||||\n at ",pos,"\n";
my $arrenv; # dummy variable only needed within this block
my @symbols; # another temporary variable
$cnt=0;
### $cnt=0;
$len=length($&);
$begin=pos($_) - $len;
$delblock=$&;
Expand All @@ -2965,21 +2977,26 @@ sub postprocess {
###0.5: $delblock=~ s/(\%DIFDELCMD < \s*\\begin\{((?:$MATHENV)|SQUAREBRACKET)\}\s*?(?:$DELCMDCLOSE|\n))(.*?[^\n]?)\n?(\%DIFDELCMD < \s*\\end\{\2\})/\\begin{$MATHREPL}$AUXCMD\n$1$3\n\\end{$MATHREPL}$AUXCMD\n$4/sg;

if ($mathmarkup == FINE ) {
# if block contains both beginning and and markers for an explicit math environment, restore opening and closing commands
$delblock=~ s/(\%DIFDELCMD < \s*\\begin\{((?:$MATHENV)|SQUAREBRACKET)\}.*?(?:$DELCMDCLOSE|\n))(.*?[^\n]?)\n?(\%DIFDELCMD < \s*\\end\{\2\})/\\begin{$MATHREPL}$AUXCMD\n$1$3\n\\end{$MATHREPL}$AUXCMD\n$4/sg;
# also transform the opposite pair \end{displaymath} .. \begin{displaymath} but we have to be careful not to interfere with the results of the transformation in the line directly above
### pre-0.42 obsolete version which did not work on eqnarray test $delblock=~ s/(?<!${AUXCMD}\n)(\%DIFDELCMD < \s*\\end\{($MATHENV)\}\s*?\n)(.*?[^\n]?)\n?(?<!${AUXCMD}\n)(\%DIFDELCMD < \s*\\begin\{\2\})/$1\\end{$MATHREPL}$AUXCMD\n$3\n\\begin{$MATHREPL}$AUXCMD\n$4/sg;
###0.5: $delblock=~ s/(?<!${AUXCMD}\n)(\%DIFDELCMD < \s*\\end\{((?:$MATHENV)|SQUAREBRACKET)\}\s*?(?:$DELCMDCLOSE|\n))(.*?[^\n]?)\n?(?<!${AUXCMD}\n)(\%DIFDELCMD < \s*\\begin\{\2\})/\\end{MATHMODE}$AUXCMD\n$1$3\n\\begin{MATHMODE}$AUXCMD\n$4/sg;
$delblock=~ s/(?<!${AUXCMD}\n)(\%DIFDELCMD < \s*\\end\{((?:$MATHENV)|SQUAREBRACKET)\}.*?(?:$DELCMDCLOSE|\n))(.*?[^\n]?)\n?(?<!${AUXCMD}\n)(\%DIFDELCMD < \s*\\begin\{\2\})/\\end\{MATHMODE\}$AUXCMD\n$1$3\n\\begin\{MATHMODE\}$AUXCMD\n$4/sg;
$delblock=~ s/(?<!${AUXCMD}\n)(\%DIFDELCMD < \h*\\end\{((?:$MATHENV)|SQUAREBRACKET)\}.*?(?:$DELCMDCLOSE|\n))(.*?[^\n]?)\n?(?<!${AUXCMD}\n)(\%DIFDELCMD < \h*\\begin\{\2\})/\\end\{MATHMODE\}$AUXCMD\n$1$3\n\\begin\{MATHMODE\}$AUXCMD\n$4/sg;

# now look for unpaired %DIFDELCMD < \begin{MATHENV}; if found add \begin{$MATHREPL} and insert \end{$MATHREPL}
# just before end of block; again we use look-behind assertion to avoid matching constructions which have already been converted
if ($delblock=~ s/(?<!${AUXCMD}\n)(\%DIFDELCMD < \s*\\begin\{((?:$MATHENV)|SQUAREBRACKET)\}\s*?(?:$DELCMDCLOSE|\n))/$1\\begin{$MATHREPL}$AUXCMD\n/sg ) {
if ($delblock=~ s/(?<!${AUXCMD}\n)(\%DIFDELCMD < \h*\\begin\{((?:$MATHENV)|SQUAREBRACKET)\}\s*?(?:$DELCMDCLOSE|\n))/$1\\begin{$MATHREPL}$AUXCMD\n/sg ) {
### print STDERR "BINGO: begin block: \nBefore: |" . substr($_,$begin,$len) . "|\n" if $debug ;
$delblock =~ s/(\\DIFdelend$)/\\end{$MATHREPL}$AUXCMD\n$1/s ;
### print STDERR "After: |" . $delblock . "|\n\n" if $debug ;
}
# now look for unpaired %DIFDELCMD < \end{MATHENV}; if found add \end{MATHMODE} and insert \begin{MATHMODE}
# just before end of block; again we use look-behind assertion to avoid matching constructions which have already been converted
if ($delblock=~ s/(?<!${AUXCMD}\n)(\%DIFDELCMD < \s*\\end\{((?:$MATHENV)|SQUAREBRACKET)\}\s*?(?:$DELCMDCLOSE|\n))/$1\\end\{MATHMODE\}$AUXCMD\n/sg ) {
if ($delblock=~ s/(?<!${AUXCMD}\n)(\%DIFDELCMD < \h*\\end\{((?:$MATHENV)|SQUAREBRACKET)\}\s*?(?:$DELCMDCLOSE|\n))/$1\\end\{MATHMODE\}$AUXCMD\n/sg ) {
### print STDERR "BINGO: end block:\nBefore: |" . substr($_,$begin,$len) . "|\n" if $debug;
$delblock =~ s/(\\DIFdelend$)/\\begin\{MATHMODE\}$AUXCMD\n$1/s ;
### print STDERR "After: |" . $delblock . "|\n\n" if $debug ;
}

### pre-0.42 # same as above for special case \[.\] (latex abbreviation for displaymath)
Expand All @@ -2994,17 +3011,20 @@ sub postprocess {
# Example Output:\begin{alignat*}{2}%DIFAUXCMD\n\%DIFDELCMD\begin{align}\n\exp(ix)&=&\cos(x)+i\sin(x)\n\end{align*}%DIFAUXCMD\n%DIFDELCMD > \end{alignat*}
$delblock=~ s/(\%DIFDELCMD < \s*\\begin\{($MATHARRENV)\}(.*?)(?:$DELCMDCLOSE|\n))(.*?[^\n]?)\n?(\%DIFDELCMD < \s*\\end\{\2\})/\\begin{$2*}$3$AUXCMD\n$1$4\n\\end{$2*}$AUXCMD\n$5/sg;
### pre-0.42 obsolete version which did not work on eqnarray test $delblock=~ s/(?<!${AUXCMD}\n)(\%DIFDELCMD < \s*\\end\{($MATHARRENV)\}\s*?\n)(.*?[^\n]?)\n?(?<!${AUXCMD}\n)(\%DIFDELCMD < \s*\\begin\{\2\})/$1\\end{$MATHARRREPL}$AUXCMD\n$3\n\\begin{$MATHARRREPL}$AUXCMD\n$4/sg;
$delblock=~ s/(?<!${AUXCMD}\n)(\%DIFDELCMD < \s*\\end\{($MATHARRENV)\}\s*?(?:$DELCMDCLOSE|\n))(.*?[^\n]?)\n?(?<!${AUXCMD}\n)(\%DIFDELCMD < \s*\\begin\{\2\})/\\end{MATHMODE}$AUXCMD\n$1$3\n\\begin{MATHMODE}$AUXCMD\n$4/sg;
$delblock=~ s/(?<!${AUXCMD}\n)(\%DIFDELCMD < \h*\\end\{($MATHARRENV)\}\s*?(?:$DELCMDCLOSE|\n))(.*?[^\n]?)\n?(?<!${AUXCMD}\n)(\%DIFDELCMD < \h*\\begin\{\2\})/\\end{MATHMODE}$AUXCMD\n$1$3\n\\begin{MATHMODE}$AUXCMD\n$4/sg;
### print STDERR "STEP1: |" . $delblock . "|\n\n" if $debug ;

# now look for unpaired %DIFDELCMD < \begin{MATHARRENV}; if found add \begin{$MATHARRREPL} and insert \end{$MATHARRREPL}
# just before end of block; again we use look-behind assertion to avoid matching constructions which have already been converted
if ($delblock=~ s/(?<!${AUXCMD}\n)(\%DIFDELCMD < \s*\\begin\{($MATHARRENV)\}(.*?)(?:$DELCMDCLOSE|\n))/$1\\begin{$2*}$3$AUXCMD\n/sg ) {
if ($delblock=~ s/(?<!${AUXCMD}\n)(\%DIFDELCMD < \h*\\begin\{($MATHARRENV)\}(.*?)(?:$DELCMDCLOSE|\n))/$1\\begin{$2*}$3$AUXCMD\n/sg ) {
$arrenv=$2;
$delblock =~ s/(\\DIFdelend$)/\\end{$arrenv*}}$AUXCMD\n$1/s ;
}
### print STDERR "STEP2: |" . $delblock . "|\n\n" if $debug ;

# now look for unpaired %DIFDELCMD < \end{MATHENV}; if found add \end{MATHMODE} and insert \begin{MATHMODE}
# just before end of block; again we use look-behind assertion to avoid matching constructions which have already been converted
if ($delblock=~ s/(?<!${AUXCMD}\n)(\%DIFDELCMD < \s*\\end\{($MATHARRENV)\}\s*?(?:$DELCMDCLOSE|\n))/$1\\end{MATHMODE}$AUXCMD\n/sg ) {
if ($delblock=~ s/(?<!${AUXCMD}\n)(\%DIFDELCMD < \h*\\end\{($MATHARRENV)\}\s*?(?:$DELCMDCLOSE|\n))/$1\\end{MATHMODE}$AUXCMD\n/sg ) {
$delblock =~ s/(\\DIFdelend$)/\\begin{MATHMODE}$AUXCMD\n$1/s ;
}

Expand All @@ -3013,7 +3033,7 @@ sub postprocess {
### while ( $delblock =~ m/\\begin\Q{$MATHARRREPL}$AUXCMD\E\n.*?\n\\end\Q{$MATHARRREPL}$AUXCMD\E\n/sg ) {
while ( $delblock =~ m/\\begin\{$MATHARRENV\*}[^\n]*?$AUXCMD\n.*?\n\\end\{$MATHARRENV\*\}$AUXCMD\n/sg ) {
### print STDERR "DEBUG Match eqarrayblock $& at ",pos,"\n";
$cnt2=0;
### $cnt2=0;
$len2=length($&);
$begin2=pos($delblock) - $len2;
$eqarrayblock=$&;
Expand All @@ -3025,7 +3045,7 @@ sub postprocess {
@symbols= grep ( m@&|\\\\\s*@, @symbols); # select & and \\ (and subsequent spaces)
"$1@symbols$AUXCMD\n"
/eg ;
### print STDERR "Modified block:|$eqarrayblock|\n" if $debug;
### print STDERR "Modified block:|$eqarrayblock|\n" if $debug;
# splice in modified block
substr($delblock,$begin2,$len2)=$eqarrayblock;
pos($delblock) = $begin2 + length($eqarrayblock);
Expand All @@ -3035,16 +3055,19 @@ sub postprocess {
# Convert MATHBLOCKmath commands to their uncounted numbers (e.g. convert equation -> displaymath
# (environments defined in $MATHENV will be replaced by $MATHREPL, and environments in $MATHARRENV
# will be replaced by their starred variety
$delblock=~ s/\\MATHBLOCK($MATHENV)(\[$brat_n\])?\{($pat_n)\}/\\MATHBLOCK$MATHREPL$2\{$3\}/sg;
$delblock=~ s/\\MATHBLOCK($MATHARRENV)(\[$brat_n\])?\{($pat_n)\}/\\MATHBLOCK$1\*$2\{$3\}/sg;
$delblock=~ s/\\MATHBLOCK($MATHENV)((?:\[$brat_n\])?)\{($pat_n)\}/\\MATHBLOCK$MATHREPL$2\{$3\}/sg;
$delblock=~ s/\\MATHBLOCK($MATHARRENV)((?:\[$brat_n\])?)\{($pat_n)\}/\\MATHBLOCK$1\*$2\{$3\}/sg;
}

# Replacing math array environments with their starred varieties in deleted blocks as implemented now causes double asterisks
# in situation where there had been starred already, e.g. \begin{alignat*} is turned into \begin{alignat**}
# The following command seeks to undo this double-starring. It is a little bit of a hack because it relies on the fact that **
# double-starred math array environment does not occur naturally
$delblock =~ s/($MATHARRENV)(?<=\*)\*/$1/sg;


print STDERR "DELBLOCK after maths processing: |" . $delblock . "|\n\n" if $debug ;


# Reinstate completely deleted list environments. note that items within the
# environment will still be commented out. They will be restored later
$delblock=~ s/(\%DIFDELCMD < \s*\\begin\{($LISTENV)\}\s*?(?:\n|$DELCMDCLOSE))(.*?)(\%DIFDELCMD < \s*\\end\{\2\})/{
Expand Down Expand Up @@ -3072,7 +3095,7 @@ sub postprocess {
# c. If in-line math mode contains array environment, enclose the whole environment in \mbox'es
while ( $delblock =~ m/($math)(\s*)/sg ) {
## print STDERR "DEBUG Delblock Match math $& at ",pos,"\n";
$cnt2=0;
### $cnt2=0;
$len2=length($&);
$begin2=pos($delblock) - $len2;
$mathblock="%\n\\mbox{$AUXCMD\n$1\n}$AUXCMD\n";
Expand Down Expand Up @@ -3116,26 +3139,24 @@ sub postprocess {
# if there is a sequence of several commands in the same row only the first will be converted due to the need to be connected to the DELCMDOPEN. To mop these up, just add the DEL to the front of any remaining cmd's in the deleted block
$delblock =~ s/\\($CUSTOMDIFCMD)/\\DEL$1/g; # this will also convert comments but I guess it does not matter much
}
writedebugfile($_,'postprocess1');
# splice in modified delblock
substr($_,$begin,$len)=$delblock;
pos = $begin + length($delblock);
}
### print STDERR "<<<$_>>>\n" if $debug;
writedebugfile($_,'postprocess1');
# make the array modification in added blocks
while ( m/\\DIFaddbegin.*?\\DIFaddend/sg ) {
$cnt=0;
### $cnt=0;
$len=length($&);
$begin=pos($_) - $len;
$addblock=$&;
while ( $addblock =~ m/($math)(\s*)/sg ) {
### print STDERR "DEBUG Addblock Match math |$1| (head:NA tail |$2| at ",pos,"\n";
$cnt2=0;
### $cnt2=0;
$len2=length($&);
$begin2=pos($addblock) - $len2;
$mathblock="%\n\\mbox{$AUXCMD\n$1\n}$AUXCMD\n";
Expand Down Expand Up @@ -3221,22 +3242,40 @@ sub postprocess {
### 1 while s/(%.*)\{(.*)$/$1\\CLEFTBRACED $2/mg ;
### 1 while s/(%.*)\}(.*)$/$1\\CRIGHTBRACED $2/mg ;
# Replace MATHMODE environments from step 1a above by the correct Math environment
# The next line is complicated. The negative look-ahead insertion makes sure that no \end{$MATHENV} (or other mathematical
# 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)
# Replace MATHMODE environments from step 1a above by the correct Math environment and remove unncessary pairings
### print STDERR "DEBUG: before mathmode replacement\n $_ ------------ \n";
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;
# look for AUXCMD math-mode pairs which have only comments (or empty lines between them), and remove the added commands
# \begin{..} ... \end{..} pairs
s/\\begin\{((?:$MATHENV)|(?:$MATHARRENV)|SQUAREBRACKET|MATHMODE)\}$AUXCMD\n((?:\s*%.[^\n]*\n)*)\\end\{\1\}$AUXCMD\n/$2/sg;
# \end{..} .... \begin{..} pairs
s/\\end\{((?:$MATHENV)|(?:$MATHARRENV)|SQUAREBRACKET|MATHMODE)\}$AUXCMD\n((?:\s*%.[^\n]*\n)*)\\begin\{\1\}$AUXCMD\n/$2/sg;
writedebugfile($_,'postprocess15');
# The next line is complicated. The negative look-ahead insertion makes sure that no \end{$MATHENV} (or other mathematical
# 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)
# [NB: Do not be tempted to prettify the expression with /x modified. It seems this is applied after strings are expanded so will ignore spaces in strings
1 while s/(?<!$DELCMDOPEN)\\begin\{((?:$MATHENV)|(?:$MATHARRENV)|SQUAREBRACKET)}((?:${DELCMDOPEN}[^\n]*|.(?!(?:\\end\{(?:(?:$MATHENV)|(?:$MATHARRENV)|SQUAREBRACKET)}|\\begin\{MATHMODE})))*?)\\end\{MATHMODE}/\\begin{$1}$2\\end{$1}/s;
writedebugfile($_,'postprocess16');
1 while s/\\begin\{MATHMODE}((?:.(?!\\end\{MATHMODE}))*?)(?<!$DELCMDOPEN)\\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;
# 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;
# Final cleanup of all equation environments: Sometimes I end up with %DIFDELCMD < \PAR lines, which I need to make sure do not get expanded into
# actual empty lines within equation environments (later part)
while ( m/\\begin\{((?:$MATHENV|$MATHARRENV|SQUAREBRACKET)\*?)}.*?(?<!\%DIFDELCMD < )\\end\{\1}/sg ) {
$len=length($&);
$begin=pos($_) - $len;
$eqblock=$&;
$eqblock =~ s/(%DIFDELCMD < )([^\n]*?)\\PAR\n/$1$2\n$1\n/sg;
# splice in modified delblock
print STDERR "DEBUG EQBLOCK: |$eqblock|\n\n" if $debug;
substr($_,$begin,$len)=$eqblock;
pos = $begin + length($eqblock);
}
} else {
# math modes OFF,WHOLE,COARSE: Convert \MATHBLOCKmath{..} commands back to environments
# with optionl argument to MATHBLOCK, e.g \MATHBLOCKalignat[{3}]{ ...}
Expand Down Expand Up @@ -3275,7 +3314,7 @@ sub postprocess {
### explict negative lookahear while ( m/(?<!%DIFDELCMD < )\\begin\{($FLOATENV)\}.*?(?<!%DIFDELCMD < )\\end\{\1\}/sg ) {
while ( m/\\begin\{($FLOATENV)\}.*?\\end\{\1\}/sg ) {
### print STDERR "DEBUGL MatchFloat $& at ",pos,"\n";
$cnt=0;
### $cnt=0;
$len=length($&);
$begin=pos($_) - $len;
$float=$&;
Expand Down Expand Up @@ -5217,6 +5256,7 @@ DIFnomarkup
%%BEGIN MATHENV CONFIG
equation[*]?
displaymath
math
DOLLARDOLLAR
%%END MATHENV CONFIG
Expand Down
Loading

0 comments on commit 0d71987

Please sign in to comment.