Skip to content

Commit

Permalink
Merge pull request ftilmann#205 from jprotze/multiline-customdifcmd
Browse files Browse the repository at this point in the history
Support multiline customdifcmd
  • Loading branch information
ftilmann authored Jul 3, 2020
2 parents 38f2d67 + c19fc6b commit 4b12356
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
10 changes: 8 additions & 2 deletions latexdiff
Original file line number Diff line number Diff line change
Expand Up @@ -1558,7 +1558,7 @@ sub add_safe_commands {
print STDERR "DEBUG Checking new command: maybe_to_test, should_be_safe: $1 $2\n" if $debug;
my $success = 0;
# skip custom diff commands
next if ($maybe_to_test =~ m/${CUSTOMDIFCMD}/);
next if ($maybe_to_test =~ m/^${CUSTOMDIFCMD}$/);
# test if all latex commands inside it are safe
$success = 1;
if ($should_be_safe =~ m/\\\\/) {
Expand Down Expand Up @@ -2773,6 +2773,12 @@ sub fromhash {
return $retstr;
}

sub stripdelcmdopen {
my ($str) = $_[0];
$str =~ s/${DELCMDOPEN}//mg;
return $str;
}

# writedebugfile(string, label)
# if $debug set writes <string> to file latexdiff.debug.<label>
# otherwise do nothing
Expand Down Expand Up @@ -3019,7 +3025,7 @@ sub postprocess {
# Mark deleted verbose commands
$delblock =~ s/(${DELCMDOPEN}\\DIF((?:verb\*?|lstinline(?:\[$brat_n\])?)\{([-\d]*?)\}\s*).*)$/%\n\\DIFDIFdel$2${AUXCMD}\n$1/gm;
if ( $CUSTOMDIFCMD ) {
$delblock =~ s/(${DELCMDOPEN}.*)\\($CUSTOMDIFCMD)/$1${DELCMDCLOSE}\\DEL$2/gm;
$delblock =~ s/(${DELCMDOPEN}.*)\\($CUSTOMDIFCMD)((?:\[${brat_n}\])*?(?:\s*\{${pat_n}\})*)/"$1${DELCMDCLOSE}\\DEL$2". stripdelcmdopen($3) ." ${DELCMDOPEN}"/egms;
}
# splice in modified delblock
Expand Down
7 changes: 7 additions & 0 deletions testsuite/customdiffcmdtest-old.tex
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,12 @@
\donothing{test}
\mypar
\blindtext

\donothing{

multiline

}

\end{document}

0 comments on commit 4b12356

Please sign in to comment.