From 81ced1f67d0fe9ba228870bebcf6fa7be2df123e Mon Sep 17 00:00:00 2001 From: "protze@itc.rwth-aachen.de" Date: Tue, 7 Nov 2017 17:58:32 +0100 Subject: [PATCH 1/4] Add config option to provide names for lstinline-like commands --- latexdiff | 43 +++++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/latexdiff b/latexdiff index 5af621b..1a76649 100755 --- a/latexdiff +++ b/latexdiff @@ -206,6 +206,7 @@ my %CONFIG=( LISTENV => undef , # list making environments - they will generally be kept VERBATIMENV => undef, # Environments whose content should be treated as verbatim text and not be touched VERBATIMLINEENV => undef, # Environments whose content should be treated as verbatim text and processed in line diff mode + LSTINLINEENV => undef,# Environments whose content should be treated as lstinline text and processed as lstinline ITEMCMD => 'item' # command marking item in a list environment ); # Configuration variables: these have to be visible from the subroutines @@ -222,7 +223,8 @@ my ($ARRENV, $PICTUREENV, $SCALEDELGRAPHICS, $VERBATIMENV, - $VERBATIMLINEENV + $VERBATIMLINEENV, + $LSTINLINEENV ); # my $MINWORDSBLOCK=3; # minimum number of tokens to form an independent block @@ -623,6 +625,7 @@ foreach ( keys(%CONFIG) ) { elsif ( $_ eq "ARRENV" ) { $ARRENV = liststringtoregex($CONFIG{$_}) ; } elsif ( $_ eq "VERBATIMENV" ) { $VERBATIMENV = liststringtoregex($CONFIG{$_}) ; } elsif ( $_ eq "VERBATIMLINEENV" ) { $VERBATIMLINEENV = liststringtoregex($CONFIG{$_}) ; } + elsif ( $_ eq "LSTINLINEENV" ) { $LSTINLINEENV = liststringtoregex($CONFIG{$_}) ; } elsif ( $_ eq "COUNTERCMD" ) { $COUNTERCMD = liststringtoregex($CONFIG{$_}) ; } elsif ( $_ eq "SCALEDELGRAPHICS" ) { $SCALEDELGRAPHICS = $CONFIG{$_} ; } else { die "Unknown configuration variable $_.";} @@ -1302,6 +1305,7 @@ sub show_configuration { print "SCALEDELGRAPHICS=$SCALEDELGRAPHICS\n"; print "VERBATIMENV=$VERBATIMENV\n"; print "VERBATIMLINEENV=$VERBATIMLINEENV\n"; + print "LSTINLINEENV=$LSTINLINEENV\n"; } } @@ -2419,9 +2423,12 @@ sub preprocess { # transform \lstinline{...} # s/\\lstinline(\[$brat0\])?(\{(?:.*?)\})/"\\DIFlstinline". $1 ."{". tohash(\%verbhash,"$2") ."}"/esg; # s/\\lstinline(\[$brat0\])?((\S).*?\2)/"\\DIFlstinline". $1 ."{". tohash(\%verbhash,"$2") ."}"/esg; - s/\\lstinline((?:\[$brat_n\])?)(\{(?:.*?)\})/"\\DIFlstinline". $1 ."{". tohash(\%verbhash,"$2") ."}"/esg; - s/\\lstinline((?:\[$brat_n\])?)(([^\s\w]).*?\3)/"\\DIFlstinline". $1 ."{". tohash(\%verbhash,"$2") ."}"/esg; - s/\\(verb\*?|lstinline)([^\s\w])(.*?)\2/"\\DIF${1}{". tohash(\%verbhash,"${2}${3}${2}") ."}"/esg; + + # Mark inline-verb in commented lines to be COMMENTverb (no hashing, no marking with color) + 1 while s/((? Date: Fri, 10 Nov 2017 09:52:13 +0100 Subject: [PATCH 2/4] Inline verbatim / lstinline should be single-line, so remove multiline match. --- latexdiff | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/latexdiff b/latexdiff index 1a76649..91f4ee6 100755 --- a/latexdiff +++ b/latexdiff @@ -2426,9 +2426,9 @@ sub preprocess { # Mark inline-verb in commented lines to be COMMENTverb (no hashing, no marking with color) 1 while s/((? Date: Fri, 10 Nov 2017 12:50:11 +0100 Subject: [PATCH 3/4] Remove superflous replacing, addressing comment by Frederik --- latexdiff | 2 -- 1 file changed, 2 deletions(-) diff --git a/latexdiff b/latexdiff index 91f4ee6..59ed629 100755 --- a/latexdiff +++ b/latexdiff @@ -2862,7 +2862,6 @@ sub postprocess { ###if ( defined($packages{"listings"} and $latexdiffpreamble =~ /\\RequirePackage(?:\[$brat0\])?\{color\}/)) { # mark added verbatim commands $addblock =~ s/\\DIFverb/\\DIFDIFaddverb/g; - 1 while $addblock =~ s/((? Date: Fri, 10 Nov 2017 13:08:09 +0100 Subject: [PATCH 4/4] Marking inline-code in comments is handled in the late postprocessing of inline-code --- latexdiff | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/latexdiff b/latexdiff index 59ed629..3365f86 100755 --- a/latexdiff +++ b/latexdiff @@ -2424,8 +2424,6 @@ sub preprocess { # s/\\lstinline(\[$brat0\])?(\{(?:.*?)\})/"\\DIFlstinline". $1 ."{". tohash(\%verbhash,"$2") ."}"/esg; # s/\\lstinline(\[$brat0\])?((\S).*?\2)/"\\DIFlstinline". $1 ."{". tohash(\%verbhash,"$2") ."}"/esg; - # Mark inline-verb in commented lines to be COMMENTverb (no hashing, no marking with color) - 1 while s/((?