Skip to content

Commit

Permalink
Add \begin and \end as UNSAFEMATHCMD. Remove split from MATHARRENV. F…
Browse files Browse the repository at this point in the history
…ixes #258. Fixes #109
  • Loading branch information
ftilmann committed Mar 5, 2022
1 parent 7074889 commit 430be68
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 4 deletions.
10 changes: 7 additions & 3 deletions latexdiff
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,12 @@
# 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).
# Fixes issue #216
# - Unlike 'array' environment, 'split' (amsmath) does not work in argument of \DIFadd or \DIFdl in UNDERLINE modes; therefore remove it from ARRENV configuration variable.
Exclude \begin and \end in math environments in COARSE and WHOLE modes. Fixes #258. Fixes #109
# - --flatten now works for empty files. Fixes issue #242



# Version 1.3.2
# API adaptions:
# - latexdiff now completes with exit code 0 after --help or --version command (see issue #248)
Expand Down Expand Up @@ -320,7 +323,7 @@ my ($ARRENV,


my $LABELCMD='(?:label)'; # matching commands are disabled within deleted blocks - mostly useful for maths mode, as otherwise it would be fine to just not add those to SAFECMDLIST
my @UNSAFEMATHCMD=('qedhere','intertext'); # Commands which are definitely unsafe for marking up in math mode (amsmath qedhere only tested to not work with UNDERLINE markup) (only affects WHOLE and COARSE math markup modes). Note that unlike text mode (or FINE math mode0 deleted unsafe commands are not deleted but simply taken outside \DIFdel
my @UNSAFEMATHCMD=('qedhere','intertext','begin','end'); # Commands which are definitely unsafe for marking up in math mode (amsmath qedhere only tested to not work with UNDERLINE markup) (only affects WHOLE and COARSE math markup modes). Note that unlike text mode (or FINE math mode0 deleted unsafe commands are not deleted but simply taken outside \DIFdel
###my $CITECMD=0 ; # \cite-type commands which need to be protected within an mbox in UNDERLINE and other modes using ulem; pattern simply designed to never match; will be overwritten later for selected styles
###my $CITE2CMD=0; # \cite-type commands which should be reinstated in deleted blocks
my $MBOXINLINEMATH=0; # if set to 1 then surround marked-up inline maths expression with \mbox ( to get around compatibility
Expand Down Expand Up @@ -2544,7 +2547,7 @@ sub marktags {
# for latexrevise
push (@$retval,$command,"%\n{$AUXCMD\n",marktags("","",$open,$close,$opencmd,$closecmd,$comment,\@argtext),$closingbracket);
} elsif ( iscmd($commandword,,\@MATHTEXTCMDLIST, \@MATHTEXTCMDEXCL) ) {
# MATHBLOCK pseudo command: consider all commands safe, except & and \\
# MATHBLOCK pseudo command: consider all commands safe, except & and \\, \begin and \end and a few package sprcific one (look at UNSAFEMATHCMD definition)
# Keep these commands even in deleted blocks, hence set $opencmd and $closecmd (5th and 6th argument of marktags) to
# ""
local @SAFECMDLIST=(".*");
Expand Down Expand Up @@ -5278,8 +5281,9 @@ array
[pbvBV]?matrix
smallmatrix
cases
split
%%END ARRENV CONFIG
# split
%%BEGIN COUNTERCMD CONFIG
footnote
Expand Down
19 changes: 19 additions & 0 deletions testsuite/split-new.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
\documentclass{article}
\usepackage{amsmath}
\begin{document}

Issue 258:
\begin{align}
\begin{split}
x &= y \\
& z
\end{split} \label{eq:1} \\
\begin{split}
a &= b \\
& q
\end{split} \label{eq:2}
\end{align}

Issue 109:
\end{document}

32 changes: 32 additions & 0 deletions testsuite/split-old.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
\documentclass{article}
\usepackage{amsmath}
\begin{document}

Issue 258:
\begin{equation}\label{eq:1}
\begin{split}
x &= y \\
& z
\end{split}
\end{equation}

\begin{equation}\label{eq:2}
\begin{split}
a &= b \\
& q
\end{split}
\end{equation}


Issue 109:
\begin{align}
\begin{split}
\dot{x} &= s (y - x)\label{eqn:lorenz}\\
\dot{y} &= r x - y - x z \\
\dot{z} &= x y - b z,
\end{split}
\end{align}


\end{document}

2 changes: 1 addition & 1 deletion testsuite/verify
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ set bodydiff=0
set testroots=( test rapine_et_al island_obs2004 texdiffsample gershwin12 "gershwin34 --graphics-markup=none" example utf \
delequ latin9 pollack move-equation nomarkup subscript doubledollar intertext \
DIFDELCMDBUG eqnarray eqnarray2 subscriptm delequ2 schneider gennady umesh underwood endfloat endfloat2 outerrise \
delequ3 delequ4 "simplefrac --allow-spaces" "master --flatten" "subfile --flatten" "import --flatten" titlediffTest2 exampleDiff bornd2 \
delequ3 delequ4 "simplefrac --allow-spaces" "master --flatten" "subfile --flatten" "import --flatten" titlediffTest2 exampleDiff bornd2 split \
"rolla --math-markup=2" mini "complex-maths --math-markup=1" margalit oubmath circonflex mwe-comment "apacite-test --flatten" quoteddollarunderscore units complicated-math move-equation2 lists "figures --graphics-markup=both" alignat "safecmd --append-safecmd=remark" verbatim verbatim2-is143 embedded-math-array "verbatim-input --flatten" anchordemo 'customdiffcmdtest --add-to-config "CUSTOMDIFCMD=blindtext;mypar;donothing;cmd"' description frac_w_space_comments \
"href-in-bibliography --append-safecmd=path" revtex-bibliography biblatex 'txtcmd-with-multiple-arguments --append-textcmd=cmd' \
"no-del --no-del" \
Expand Down

0 comments on commit 430be68

Please sign in to comment.