diff --git a/latexdiff b/latexdiff index 27be330..b6fe990 100755 --- a/latexdiff +++ b/latexdiff @@ -36,7 +36,7 @@ # - improved pattern matching: now allows nested angular brackets, and is no longer confused by escaped curly braces # - improved pattern matching in COARSE mode: occasionally, the closing bracket or some other elements would be matched in an 'unnatural' way due to another sequence being more minimal in the computational sense, sometimes even causing errors due to tokens moving in or out of the scope of math environments. This is now discouraged by adding internal \DIFANCHOR commands (which are removed again in post-processing) (fixes issues reported via email by li_ruomeng . # - verbatim and lstlisting environments are marked-up with line-by-line in a similar style to non-verbatim text (requires the listing package to be installed) -# (see new configuration variable VERBATIMLINEENV) +# (see new configuration variable VERBATIMLINEENV) (several issues and pull requests by jprotze) # - --flatten: now supports \verbatiminput and \lstlistinput # - --flatten: if file is not found, do not fail, simply warn and leave command unexpanded (inspired by issue #112). Don't warn if file name contains #[0-9] as it is then most likely an argument within a command definition rather than an actual file (applies to \input, \subfile, \include commands) # - added to textcmds: \intertext @@ -2563,10 +2563,10 @@ sub linecomment { return(join("\n%$VERBCOMMENT",@verbatimlines)."\n"); } -# $simple=reverselinecomment($string) +# $simple=reverselinecomment($env $string) # remove DIFVRB comments but leave changed lines marked sub reverselinecomment { - my ($verbatimtext)=@_; + my ($environment, $verbatimtext)=@_; ###print STDERR "OLD VERBATIMTEXT: |$verbatimtext|\n"; # remove markup added by latexdiff # (this should occur only if the type of verbatim environment was changed) @@ -2585,7 +2585,7 @@ sub reverselinecomment { # remove part of the markup in changed lines # if any of these substitution was made, then there was at least # one changed line, and we have to extend the style - if ( $verbatimtext=~ s/$VERBCOMMENT//g ) { + if ( $verbatimtext=~ s/$VERBCOMMENT//g ) { # in the next line we add ~alsolanguage~ modifier, but also deletes the rest of the line after the optional argument, as lstlisting commands gets sometimes # very confused by what is there (and othertimes seems to ignore this anyway) unless ( $verbatimtext =~ s/^(\s*)\[($brat_n)\](.*)\n/$1\[$2,alsolanguage=DIFcode\]\n/ ) { @@ -2598,6 +2598,9 @@ sub reverselinecomment { # There is a bug in listings package (at least v1.5b) for empty comments where the actual comment command is not made invisible # I therefore have to introduce an artificial '-' character at the end of empty added or deleted lines $verbatimtext =~ s/($DELCOMMENT\s*)$/$1-/mg; + $verbatimtext = "\\DIFmodbegin\n\\begin{${environment}}${verbatimtext}\\end{${environment}}\n\\DIFmodend" + } else { + $verbatimtext = "\\begin{${environment}}${verbatimtext}\\end{${environment}}" } ###print STDERR "NEW VERBATIMTEXT: |$verbatimtext|\n"; return($verbatimtext); @@ -3069,7 +3072,7 @@ sub postprocess { ### s/(?