Skip to content

Commit

Permalink
Add documentation and test files for CUSTOMDIFCMD functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
ftilmann committed May 12, 2018
1 parent 23c9119 commit 4b08bf6
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 6 deletions.
29 changes: 26 additions & 3 deletions latexdiff
Expand Up @@ -40,6 +40,7 @@
# - added to textcmds: \intertext
# Bug fixes:
# - pattern matching of \verb and \lstinline commands had an error which meant they would trigger on commands beginning with \verb.
# - new config variable CUSTOMDIFCMD to allow defining special versions of commands in added or deleted blocks (Pull request by jprotze
#
# Version 1.2.1 (22 June 2017)
# - add "DeclareOldFontCommand" to styles using \bf or \sf old style font commands (fixies issue #92 )
Expand Down Expand Up @@ -606,13 +607,13 @@ foreach $key ( keys(%CONFIG) ) {

### print STDERR "configuration: |$config| , #@config#\n";
foreach $assign ( @addtoconfig ) {
### print STDERR "assign:|$assign|\n";
###print STDERR "assign:|$assign|\n";
$assign=~ m/\s*(\w*)\s*=\s*(\S*)\s*$/ or die "Illegal assignment $assign in configuration list (must be variable=value)";
exists $CONFIG{$1} or die "Unknown configuration variable $1.";
$CONFIG{$1}.=";$2";
}

# Map from hash to variables (we do this to have more concise code later, change from comma-separeted list)
# Map from hash to variables (we do this to have more concise code later, change from comma-separated list)
foreach ( keys(%CONFIG) ) {
if ( $_ eq "MINWORDSBLOCK" ) { $MINWORDSBLOCK = $CONFIG{$_}; }
elsif ( $_ eq "FLOATENV" ) { $FLOATENV = liststringtoregex($CONFIG{$_}) ; }
Expand Down Expand Up @@ -4056,6 +4057,8 @@ C<ARRENV> (RegEx)
C<COUNTERCMD> (RegEx)
C<CUSTODIFCMD> (RegEx)
C<FLOATENV> (RegEx)
C<ITEMCMD> (RegEx)
Expand All @@ -4076,10 +4079,11 @@ C<PICTUREENV> (RegEx)
C<SCALEDELGRAPHICS> (Float)
=item B<--add-to-config varenv1=pattern1,varenv2=pattern2,...>
For configuration variables, which are a regular expression (essentially those ending
in ENV, and COUNTERCMD, see list above) this provides an alternative way to modify the configuration
in ENV, COUNTERCMD and CUSTOMDIFCMD, see list above) this option provides an alternative way to modify the configuration
variables. Instead of setting the complete pattern, with this option it is possible to add an
alternative pattern. C<varenv> must be one of the variables listed above that take a regular
expression as argument, and pattern is any regular expression (which might need to be
Expand Down Expand Up @@ -4396,6 +4400,25 @@ numbering in the new file.
C<|subsubsection|paragraph|subparagraph)> ]
=item C<CUSTOMDIFCMD>
This option is for advanced users and allows definition of special versions of commands, which do not work as safe commands.
Commands in C<CUSTOMDIFCMD> that occur in added or deleted blocks will be given an ADD or DEL prefix.
The prefixed versions of the command must be defined in the preamble, either by putting them
in the preamble of at least the new file, or by creating a custom preamble file (Option --preamble).
For example the command C<\blindtext> (from package blindtext) does not interact well with underlining, so that
for the standard markup type, it is not satisfactory to define it as a safe command. Instead, a customised versions
without underlining can be defined in the preamble:
C<\newcommand{\DELblindtext}{{\color{red}\blindtext}}>
C<\newcommand{\ADDblindtext}{{\color{blue}\blindtext}}>
and then latexdiff should be invoked with the option C<-c CUSTOMDIFCMD=blindtext>.
[ Default: none ]
=item C<FLOATENV>
Environments whose name matches the regular expression in C<FLOATENV> are
Expand Down
11 changes: 11 additions & 0 deletions testsuite/customdiffcmdtest-new.tex
@@ -0,0 +1,11 @@
% Code by J Protze
\documentclass{book}
\usepackage{blindtext}
\newcommand{\DELblindtext}{{\color{red}\blindtext}}
\newcommand{\ADDblindtext}{{\color{blue}\blindtext}}
\newcommand{\mypar}{\paragraph{MYPAR}}
\newcommand{\DELmypar}{\paragraph{\DIFdel{MYPAR}}}
\newcommand{\ADDmypar}{\paragraph{\DIFadd{MYPAR}}}
\begin{document}
\end{document}

13 changes: 13 additions & 0 deletions testsuite/customdiffcmdtest-old.tex
@@ -0,0 +1,13 @@
% Code by J Protze
\documentclass{book}
\usepackage{blindtext}
\newcommand{\DELblindtext}{{\color{red}\blindtext}}
\newcommand{\ADDblindtext}{{\color{blue}\blindtext}}
\newcommand{\mypar}{\paragraph{MYPAR}}
\newcommand{\DELmypar}{\paragraph{\DIFdel{MYPAR}}}
\newcommand{\ADDmypar}{\paragraph{\DIFadd{MYPAR}}}
\begin{document}
\mypar
\blindtext
\end{document}

7 changes: 4 additions & 3 deletions testsuite/verify
@@ -1,4 +1,4 @@
#!/bin/tcsh
#!/bin/tcsh
set refversion=1.2.2a
#set refversion=1.1.0
# for comparison with 0.5:
Expand All @@ -20,7 +20,7 @@ set testroots=( test rapine_et_al island_obs2004 texdiffsample gershwin12 "gersh
delequ latin9 pollack move-equation nomarkup subscript doubledollar intertext \
DIFDELCMDBUG eqnarray subscriptm delequ2 schneider gennady umesh underwood endfloat endfloat2 outerrise \
delequ3 delequ4 "simplefrac --allow-spaces" "master --flatten" "subfile --flatten" titlediffTest2 exampleDiff bornd2 \
"rolla --math-markup=2" mini "complex-maths --math-markup=1" margalit circonflex mwe-comment "apacite-test --flatten" quoteddollarunderscore units complicated-math move-equation2 lists "figures --graphics-markup=both" alignat "safecmd --append-safecmd=remark" verbatim embedded-math-array "verbatim-input --flatten" anchordemo \
"rolla --math-markup=2" mini "complex-maths --math-markup=1" margalit circonflex mwe-comment "apacite-test --flatten" quoteddollarunderscore units complicated-math move-equation2 lists "figures --graphics-markup=both" alignat "safecmd --append-safecmd=remark" verbatim embedded-math-array "verbatim-input --flatten" anchordemo 'customdiffcmdtest --add-to-config "CUSTOMDIFCMD=blindtext;mypar"' \
)

#set testroots= ( test subscript )
Expand Down Expand Up @@ -61,9 +61,10 @@ if ( ! $?reset ) then
latexdiff --version >>& $reportfile
echo "--------" >> $reportfile
endif
set nonomatch
while ( $#testroots >= 1 )
#foreach test ( $testroots)
echo $testroots[1]
echo "$testroots[1]"
set sample=( $testroots[1] )
shift testroots
if ( $#sample > 1 ) then
Expand Down

0 comments on commit 4b08bf6

Please sign in to comment.