From 430be681b52d915f8d8e39fcf8e2114dcfb290be Mon Sep 17 00:00:00 2001 From: Frederik Tilmann Date: Sat, 5 Mar 2022 22:56:06 +0100 Subject: [PATCH] Add \begin and \end as UNSAFEMATHCMD. Remove split from MATHARRENV. Fixes #258. Fixes #109 --- latexdiff | 10 +++++++--- testsuite/split-new.tex | 19 +++++++++++++++++++ testsuite/split-old.tex | 32 ++++++++++++++++++++++++++++++++ testsuite/verify | 2 +- 4 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 testsuite/split-new.tex create mode 100644 testsuite/split-old.tex diff --git a/latexdiff b/latexdiff index 3c8476d..c862e91 100755 --- a/latexdiff +++ b/latexdiff @@ -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) @@ -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 @@ -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=(".*"); @@ -5278,8 +5281,9 @@ array [pbvBV]?matrix smallmatrix cases -split %%END ARRENV CONFIG +# split + %%BEGIN COUNTERCMD CONFIG footnote diff --git a/testsuite/split-new.tex b/testsuite/split-new.tex new file mode 100644 index 0000000..f8388fb --- /dev/null +++ b/testsuite/split-new.tex @@ -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} + diff --git a/testsuite/split-old.tex b/testsuite/split-old.tex new file mode 100644 index 0000000..7bd2347 --- /dev/null +++ b/testsuite/split-old.tex @@ -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} + diff --git a/testsuite/verify b/testsuite/verify index 588a803..40605ce 100755 --- a/testsuite/verify +++ b/testsuite/verify @@ -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" \