texlive[61434] trunk: latexdiff (28dec21)

commits+karl at tug.org commits+karl at tug.org
Tue Dec 28 23:52:08 CET 2021


Revision: 61434
          http://tug.org/svn/texlive?view=revision&revision=61434
Author:   karl
Date:     2021-12-28 23:52:08 +0100 (Tue, 28 Dec 2021)
Log Message:
-----------
latexdiff (28dec21)

Modified Paths:
--------------
    trunk/Build/source/texk/texlive/linked_scripts/latexdiff/latexdiff-vc.pl
    trunk/Build/source/texk/texlive/linked_scripts/latexdiff/latexdiff.pl
    trunk/Build/source/texk/texlive/linked_scripts/latexdiff/latexrevise.pl
    trunk/Master/texmf-dist/doc/man/man1/latexdiff-vc.1
    trunk/Master/texmf-dist/doc/man/man1/latexdiff-vc.man1.pdf
    trunk/Master/texmf-dist/doc/man/man1/latexdiff.1
    trunk/Master/texmf-dist/doc/man/man1/latexdiff.man1.pdf
    trunk/Master/texmf-dist/doc/man/man1/latexrevise.1
    trunk/Master/texmf-dist/doc/man/man1/latexrevise.man1.pdf
    trunk/Master/texmf-dist/doc/support/latexdiff/doc/example-diff.tex
    trunk/Master/texmf-dist/doc/support/latexdiff/doc/latexdiff-man.pdf
    trunk/Master/texmf-dist/doc/support/latexdiff/latexdiff
    trunk/Master/texmf-dist/doc/support/latexdiff/latexdiff-fast
    trunk/Master/texmf-dist/scripts/latexdiff/latexdiff-vc.pl
    trunk/Master/texmf-dist/scripts/latexdiff/latexdiff.pl
    trunk/Master/texmf-dist/scripts/latexdiff/latexrevise.pl

Modified: trunk/Build/source/texk/texlive/linked_scripts/latexdiff/latexdiff-vc.pl
===================================================================
--- trunk/Build/source/texk/texlive/linked_scripts/latexdiff/latexdiff-vc.pl	2021-12-28 22:51:15 UTC (rev 61433)
+++ trunk/Build/source/texk/texlive/linked_scripts/latexdiff/latexdiff-vc.pl	2021-12-28 22:52:08 UTC (rev 61434)
@@ -26,6 +26,13 @@
 # Detailed usage information at the end of the file
 #
 # TODO/IDEAS: - option to call external pre-processing codes
+# version 1.3.2:
+#    - bug fix: when setting config variables with the command lines it is now possible to use quotes to includes spaces in the value, e.g. "-c LATEX=pdflatex --shell-escape'
+#    - bug fix: --only-changes is not compatible with graphics markup. --graphics-markup=none is now set automatically
+#    - when --pdf or --postscript is select, then replace tildes in version names with underscores in output file (e.g. diffHEAD_1 instead of diff HEAD~1. This is necessary because pdflatex strips ~n strings at the end of the filename, when generating output file names
+
+# version 1.3.1:
+#    - bug fix, import File::Path explicitly as otherwise mkpath is not found
 # version 1.3.0 ((7 October 2018)
 #    - option --only-changes with hyperref will suppress hyperrefs (pull request jprotze)_
 #    - option --only-changes now moves (rather than copies) file with only changes 
@@ -66,13 +73,14 @@
 use File::Temp qw/tempdir/ ;
 use File::Basename qw/dirname/;
 use File::Copy;
+use File::Path;
 
 use strict ;
 use warnings ;
 
 my $versionstring=<<EOF ;
-This is LATEXDIFF-VC 1.3.1.1
-  (c) 2005-2020 F J Tilmann
+This is LATEXDIFF-VC 1.3.2
+  (c) 2005-2021 F J Tilmann
 EOF
 
 # output debug and intermediate files, set to 0 in final distribution
@@ -205,7 +213,8 @@
 
 $configlatexdiff="";
 foreach $assign ( @config ) {
-  $assign=~ m/\s*(\w*)\s*=\s*(\S*)\s*$/ or die "Illegal assignment $assign in configuration list (must be variable=value)";  
+    $assign=~ m/\s*(\w*)\s*=\s*(.*?)\s*$/ 
+      or die "Illegal assignment |$assign| in configuration list (must be variable=value)";  
   if ( defined($CFG{$1})) {
     # known latexdiff-vc option
     $CFG{$1}=$2;
@@ -342,7 +351,7 @@
 
 # impose ZLABEL subtype if --only-changes option
 if ( $onlychanges ) {
-  push @ldoptions, "-s", "ZLABEL","-f","IDENTICAL","--no-links" ;
+  push @ldoptions, "-s", "ZLABEL","-f","IDENTICAL","--no-links", "--graphics-markup=none" ;
 }
 
 if ( scalar(@revs) == 0 ) {
@@ -378,6 +387,12 @@
   $append = "-diff";
 }
 
+if ( defined($pdf) or defined($postscript) ) {
+  # when using options such as -r HEAD~1  the ~1 is ignored by pdflatex in generating output file names; this could
+  # be confusing and actually causes error to only-changes mode
+  $append =~ s/~/_/g ;
+}
+
 if ( defined ($dir) && ! $dir ) {
   # bare -d option => choose directory name
   ($dir=$append) =~ s/^-//;
@@ -532,7 +547,7 @@
       #print STDERR "Generated postscript file $ps\n";
     } elsif ( $run ) {
       if ( $onlychanges ) {
-	my @pages=findchangedpages("$diffbase.aux");
+	my @pages=compresspages(findchangedpages("$diffbase.aux"));
         my $gs = `which gs`;
         $gs =~ s/^\s+|\s+$//g;
         my $qpdf = `which qpdf`;
@@ -540,7 +555,7 @@
         my $pdftk = `which pdftk`;
         $pdftk =~ s/^\s+|\s+$//g;
         my $command;
-        if (-x $gs && `gs --version` >= 9.20) {
+        if (-x $gs && `$gs --version` >= 9.20) {
           $command="gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dSAFER -sPageList=" . join(",", @pages) . " -sOutputFile=\"$diffbase-changedpage.pdf\" \"$diffbase.pdf\"";
         } elsif (-x $pdftk) {
           $command="pdftk \"$diffbase.pdf\" cat " . join(" ", at pages) . " output \"$diffbase-changedpage.pdf\"";
@@ -588,6 +603,45 @@
   return(sort {$a <=> $b} keys(%pages));
 }
 
+# inspired by a python version posted at https://stackoverflow.com/a/54714846/8136338
+# compresspages(@pages)
+# @pages: sorted array of unique integers (pages)
+# return a list of pages and page ranges. 3 or more consecutive numbers are merged into a "begin-end" string
+#
+# example: join(",", compresspages([1,3,4,5,7,8])) -> join(",", [1,"3-5",7,8]) -> "1,3-5,7,8"
+sub compresspages {
+  my (@pages) = @_;
+  my @res;
+  my $begin=$pages[0];
+  my $end =$pages[0];
+  my $page;
+  foreach $page ( @pages ) {
+    next if ($page == $begin);
+    if ($page == $end+1) { # handle continuous pages
+      $end = $page;
+      next;
+    } elsif ($begin == $end) { # push single continuous page
+      push @res, $begin;
+      $begin = $end = $page;
+    } elsif ($begin + 1 == $end) { # push two continuous pages
+      push @res, $begin, $end;
+      $begin = $end = $page;
+    } else { # push multiple continuous pages
+      push @res, "$begin-$end";
+      $begin = $end = $page;
+    }
+  }
+  # Finally just check in the same manner for the end element
+  if ($begin == $end) {
+    push @res, $begin;
+  } elsif ($begin + 1 == $end) {
+    push @res, $begin, $end;
+  } else {
+    push @res, "$begin-$end";
+  }
+  return @res;
+}
+
 # checkout_dir(rev,dirname)
 # checks out revision rev and stores it in dirname
 # uses global variables: $vc, $rootdir
@@ -594,7 +648,7 @@
 sub checkout_dir {
   my ($rev,$dirname)=@_;
 
-  unless (-e $dirname) { mkdir $dirname or die "Cannot mkdir $dirname ." ;}
+  unless (-e $dirname) { mkpath([ $dirname ]) or die "Cannot mkdir $dirname ." ;}
   if ( $vc eq "SVN" ) {
     system("svn checkout -r $rev $rootdir $dirname")==0 or die "Something went wrong in executing:  svn checkout -r $rev $rootdir $dirname";
   } elsif ( $vc eq "GIT" ) {
@@ -717,7 +771,8 @@
 
 Post-process the output such that only pages with changes on them are displayed. This requires the use of subtype ZLABEL 
 in latexdiff, which will be set automatically, but any manually set -s option will be overruled (also requires zref package to 
-be installed). (note that this option must be combined with --ps or --pdf to make sense)
+be installed). This option also disables internal links (as implemented by hyperref package) and graphics markup.
+(note that this option must be combined with --ps or --pdf to make sense)
 
 =item B<--force>
 

Modified: trunk/Build/source/texk/texlive/linked_scripts/latexdiff/latexdiff.pl
===================================================================
--- trunk/Build/source/texk/texlive/linked_scripts/latexdiff/latexdiff.pl	2021-12-28 22:51:15 UTC (rev 61433)
+++ trunk/Build/source/texk/texlive/linked_scripts/latexdiff/latexdiff.pl	2021-12-28 22:52:08 UTC (rev 61434)
@@ -22,7 +22,23 @@
 #
 # Detailed usage information at the end of the file
 #
-
+#
+# Version 1.3.2
+# API adaptions:
+#  - latexdiff now completes with exit code 0 after --help or --version command (see issue #248)
+# New features / feature extensions
+#  - extend CUSTOMDIFCMD related postprocessing to deal properly with multiline commands, or a sequence of several commands in the same line (see github issue #204)
+#  - Support for additional macros from import package (\import, \inputfrom, \includefrom, \subimport,\subinputfrom, \subincludefrom). Provided by janniklasrose in PR #243 (fixes #239)
+#  - replace default driver dvips->pdftex
+# Bug fixes:
+#  - fix issue #206 affecting proper markup of text commands which are not safe cmd's at the same time and have multiple arguments
+#  - fix issue #210 by adding \eqref (amsmath package) to the list of safe commands
+#  - fix bug reported in issue #168 mangled verbatim line environment 
+#  - fix bug reported in issue #218 by replacing \hspace{0pt} after \mbox{..} auxiliary commands with \hskip0pt.
+#  - more ways to process \frac correctly with atomic arguments (committed by julianuu PR #246
+#  - fix a bug in biblatex mode, which prevented proper processing of modified \textcite (see: https://tex.stackexchange.com/questions/555157/latexdiff-and-biblatex-citation-commands)
+#  - -h string fix: add -driver option
+#
 # Version 1.3.1.1
 #  - remove spurious \n to fix error: Unknown regexp modifier "/n" at .../latexdiff line 1974, near "=~ " (see github issue #201)
 #
@@ -660,8 +676,8 @@
 
 
 my ($versionstring)=<<EOF ;
-This is LATEXDIFF 1.3.1.1 (Algorithm::Diff $Algorithm::Diff::VERSION, Perl $^V)
-  (c) 2004-2020 F J Tilmann
+This is LATEXDIFF 1.3.2 (Algorithm::Diff $Algorithm::Diff::VERSION, Perl $^V)
+  (c) 2004-2021 F J Tilmann
 EOF
 
 # Hash with defaults for configuration variables. These marked undef have default values constructed from list defined in the DATA block
@@ -718,7 +734,7 @@
 # my $MATHREPL='displaymath';  # Environment introducing deleted maths blocks
 # my $MATHARRENV='(?:eqnarray|align|alignat|gather|multline|flalign)[*]?' ;           # Environments turning on eqnarray math mode
 # my $MATHARRREPL='eqnarray*';  # Environment introducing deleted maths blocks
-# my $ARRENV='(?:aligned|gathered|array|[pbvBV]?matrix|smallmatrix|cases|split)'; # Environments making arrays in math mode.  The underlining style does not cope well with those - as a result in-text math environments are surrounded by \mbox{ } if any of these commands is used in an inline math block
+# my $ARRENV='(?:aligned|gathered|multlined|array|[pbvBV]?matrix|smallmatrix|cases|split)'; # Environments making arrays in math mode.  The underlining style does not cope well with those - as a result in-text math environments are surrounded by \mbox{ } if any of these commands is used in an inline math block
 # my $COUNTERCMD='(?:footnote|part|chapter|section|subsection|subsubsection|paragraph|subparagraph)';  # textcmds which are associated with a counter
 #                                         # If any of these commands occur in a deleted block
 #                                         # they will be succeeded by an \addtocounter{...}{-1}
@@ -915,7 +931,8 @@
 
 
 if ( $version ) {
-  die $versionstring ; 
+  print STDERR $versionstring ; 
+  exit 0;
 }
 
 print STDERR $versionstring if $verbose; 
@@ -960,7 +977,7 @@
 
 if ( defined($driver) ) {
   # for changebar only
-  $latexdiffpreamble=~s/\[dvips\]/[$driver]/sg;
+  $latexdiffpreamble=~s/\[pdftex\]/[$driver]/sg;
 }
 # setting up @SAFECMDLIST and @SAFECMDEXCL
 if (defined($replacesafe)) {
@@ -1191,7 +1208,9 @@
   my $predefinedcmdoptseq='(?:'.$predefinedcmdoptseq12.'|'.$predefinedcmdoptseq01.'|'.$predefinedbibitem.')';
 
   my $cmdleftright='\\\\(?:left|right|[Bb]igg?[lrm]?|middle)\s*(?:[<>()\[\]|\.]|\\\\(?:[|{}]|\w+))';
-  my $cmdoptseq='\\\\[\w\d@\*]+'.$extraspace.'(?:(?:<'.$abrat0.'>|\['.$brat_n.'\]|\{'. $pat_n . '\}|\(' . $coords .'\))'.$extraspace.')*';
+# standard $cmdoptseq (default: no intrevening spaces, controlled by extraspcae) - a final open parentheses is merged to the commend if it exists to deal properly with multi-argument text command
+  my $cmdoptseq='\\\\[\w\d@\*]+'.$extraspace.'(?:(?:<'.$abrat0.'>|\['.$brat_n.'\]|\{'. $pat_n . '\}|\(' . $coords .'\))'.$extraspace.')*\{?';
+# Handle tex \def macro: \def\MAKRONAME#1[#2]#3{DEFINITION}
   my $defseq='\\\\def\\\\[\w\d@\*]+(?:#\d+|\[#\d+\])+(?:\{'. $pat_n . '\})?';
   my $backslashnl='\\\\\n';
   my $oneletcmd='\\\\.\*?(?:\['.$brat_n.'\]|\{'. $pat_n . '\})*';
@@ -1410,6 +1429,9 @@
 # If listings is being used or can be found in the latexdiff search path, add to the preamble auxiliary code to enable line-by-line markup
 if ( defined($packages{"listings"}) or `kpsewhich listings.sty` ne "" ) {
   my @listingpreamble=extrapream("LISTINGS");
+  if ($latexdiffpreamble =~ /\\RequirePackage(?:\[$brat_n\])?\{color\}/ ) {
+    @listingpreamble=extrapream("COLORLISTINGS");
+  }
   my @listingDIFcode=();
   my $replaced;
   # note that in case user supplies preamblefile the type might not reflect well the 
@@ -1572,6 +1594,7 @@
 } elsif (defined $packages{"biblatex"}) {
   print STDERR "biblatex package detected.\n" if $verbose ;
   $citpat='(?:[cC]ites?|(?:[pP]aren|foot|[Tt]ext|[sS]mart|super)cites?\*?|footnotecitetex)';
+  push(@TEXTCMDEXCL, qr/^textcite$/);
 } else {
   # citation command pattern for all other citation schemes
   $citpat='(?:cite\w*|nocite)';
@@ -1848,6 +1871,9 @@
     my $should_be_safe = $2;
     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/^(?:ADD|DEL)?${CUSTOMDIFCMD}$/);
+    ###print STDERR "DEBUG: really test it. \n";
     # test if all latex commands inside it are safe
     $success = 1;
     if ($should_be_safe =~ m/\\\\/) {
@@ -1890,6 +1916,7 @@
 # expands \input and \include commands within text
 # expands \bibliography command with corresponding bbl file if available
 # expands \subfile command (from subfiles package - not part of standard text distribution)
+# expands \import etc commands (from import package - not part of standard text distribution)
 # preamble is scanned for includeonly commands
 # encoding is the encoding
 sub flatten {
@@ -1917,15 +1944,16 @@
   # Run through filter, to let filterscript have a pass if it was set
   $text = filter($text);
 
-  # Recursively replace \\import and \\subimport files
-  $text =~ s/(^(?:[^%\n]|\\%)*)(\\subimport\{(.*?)\}|\\import\{(.*?)\})(?:[\s]*)\{(.*?)\}/{
+  # Recursively replace \\import, \\subimport, and related import commands
+  $text =~ s/(^(?:[^%\n]|\\%)*)(\\(sub)?(?:import|inputfrom|includefrom))\{(.*?)\}(?:[\s]*)\{(.*?)\}/{
+          #  (--------1-------)(--(=3=)-------------2-------------------)  (-4-)             (-5-)
           # $1 is begline
-          # $3 is directory if subimport
-          # $4 is directory if import
+          # $2 is the import macro name
+          # $3 is (optional) prefix "sub"
+          # $4 is directory
           # $5 is filename
           $begline = (defined($1)? $1 : "");
-          $subdir = $3 if defined($3);
-          $subdir = $4 if defined($4);
+          $subdir = $4;
           $fname = $5;
           $fname .= ".tex" unless $fname =~ m|\.\w{3,4}$|;
           print STDERR "DEBUG begline:", $begline, "\n" if $debug;
@@ -1940,12 +1968,13 @@
           print STDERR "importing importfilepath:", $importfilepath,"\n" if $verbose;
           if ( -f $importfilepath ) {
               # If file exists, replace input or include command with expanded input
+              #TODO: need remove_endinput & newpage similar to other replacements inside flatten
               $replacement=flatten(read_file_with_encoding($importfilepath, $encoding), $preamble,$importfilepath,$encoding) or die "Could not open file ",$fullfile,": $!";
           } else {
               # if file does not exist, do not expand include or input command (do not warn if fname contains #[0-9] as it is then likely part of a command definition
               # and is not meant to be expanded directly 
               print STDERR "WARNING: Could not find included file ",$importfilepath,". I will continue but not expand |$2|\n";
-              $replacement=(defined($3)? "\\subimport" : "\\import");
+              $replacement = $2;
               $replacement .= "{$subdir}{$fname} % Processed";
           }
           "$begline$replacement";
@@ -2615,9 +2644,10 @@
 
 
 # split this block to split sequences joined in pass1
+  ### print STDERR "DEBUG: marktags before splitlatex blocksplit ",join("|",@$block),"\n" if $debug;
   @$block=splitlatex(join "",@$block);
   ### print STDERR "DEBUG: marktags $openmark,$closemark,$open,$close,$opencmd,$closecmd,$comment\n" if $debug;
-  ### print STDERR "DEBUG: marktags blocksplit ",join("|",@$block),"\n" if $debug;
+  print STDERR "DEBUG: after splitlatex ",join("|",@$block),"\n" if $debug;
 
   # we redefine locally $extraspace (shadowing the global definition) to capture command sequences with intervening spaces no matter what the global setting
   # this is done so we can capture those commands with a predefined number of arguments without having to introduce them again explicitly here
@@ -2673,6 +2703,7 @@
         #            $2 (the command) is in context2, just treat it as an ordinary command (i.e. comment it open with $opencmd)
         # Because we do not want to disable this command
 	# here we do not use $opencmd and $closecmd($opencmd is empty) 
+	print STDERR "DEBUG: Detected text |$word| but not safe command \$2: $2 \$3: $3\n." if $debug;
 	if ($cmd==1) {
 	  push (@$retval,$closecmd) ;
 	} elsif ($cmd==0) { 
@@ -2731,7 +2762,7 @@
       if ( $word =~ /^\\(?!\()(\\|[`'^"~=.]|[\w*@]+)(.*?)(\s*)$/s &&  iscmd($1,\@MBOXCMDLIST,\@MBOXCMDEXCL)) {
 	# $word is a safe command in MBOXCMDLIST
 	###print STDERR "DEBUG Mboxsafecmd detected:$word:\n" if $debug ;
-	push(@$retval,"\\mbox{$AUXCMD\n\\" . $1 . $2 . $3 ."}\\hspace{0pt}$AUXCMD\n" );
+	push(@$retval,"\\mbox{$AUXCMD\n\\" . $1 . $2 . $3 ."}\\hskip0pt$AUXCMD\n" );
       } else {
 	# $word is a normal word or a safe command (not in MBOXCMDLIST)
 	push (@$retval,$word);
@@ -2751,15 +2782,15 @@
   # some special magic for common usage of frac, which does not conform to the latexdiff requirements but can be made to fit
   # note that this is a rare exception to the general rule that the new tex can be reconstructed from the diff file
 
-  # \frac12 -> \frac{1}{2}
-  s/\\frac(\d)(\w)/\\frac\{$1\}\{$2\}/g;
-
-  # \frac1{2b} -> \frac{1}{2b}
-  s/\\frac(\d)/\\frac\{$1\}/g;
-
-  # delete space and comment characters between \frac arguments
-#  s/\\frac(?:\s*?%[^\n]*?)*?(\{$pat_n\})\s*(\{$pat_n\})/\\frac$1$2/g;
-  s/\\frac(?:\s|%[^\n]*?)*(\{$pat_n\})(?:\s|%[^\n]*?)*(\{$pat_n\})/\\frac$1$2/g;
+  # regex that matches space and comment characters
+  my $space = qr/\s|%[^\n]*?/;
+  # \frac {abc} -> \frac{abc}
+  # \frac1 -> \frac{1}
+  # \frac a -> \frac{a}
+  # \frac \lambda -> \frac{\lambda}
+  s/\\frac(?|${space}+\{($pat_n)\}|${space}*(\d)|${space}+(\w)|${space}*(\\[a-zA-Z]+))/\\frac\{$1\}/g;
+  # same as above for the second argument of frac
+  s/\\frac(\{$pat_n\})(?|${space}*\{($pat_n)\}|${space}*(\d)|${space}+(\w)|${space}*(\\[a-zA-Z]+))/\\frac$1\{$2\}/g;
 }
 
 # preprocess($string, ..)
@@ -2766,7 +2797,7 @@
 # carry out the following pre-processing steps for all arguments:
 # 1. Remove leading white-space
 #    Change \{ to \QLEFTBRACE and \} to \QRIGHTBRACE and \& to \AMPERSAND
-# #.   Change {,} in comments to \CLEFTBRACE, \CRIGHTBRACE
+# #.   Change {,},\frac in comments to \CLEFTBRACE, \CRIGHTBRACE, \CFRAC
 # 2. mark all first empty line (in block of several) with \PAR tokens
 # 3. Convert all '\%' into '\PERCENTAGE ' and all '\$' into \DOLLAR to make parsing regular expressions easier
 # 4. Convert all \verb|some verbatim text| commands (where | can be an arbitrary character)
@@ -2802,9 +2833,11 @@
     s/(?<!\\)\\\{/\\QLEFTBRACE /sg;
     s/(?<!\\)\\\}/\\QRIGHTBRACE /sg;
     s/(?<!\\)\\&/\\AMPERSAND /sg;
-# replace {,} in comments with \\CLEFTBRACE,\\CRIGHTBRACE
+# replace {,}, \frac in comments with \\CLEFTBRACE,\\CRIGHTBRACE, CFRAC to protect from special treatment
     1 while s/((?<!\\)%.*)\{(.*)$/$1\\CLEFTBRACE $2/mg ;
     1 while s/((?<!\\)%.*)\}(.*)$/$1\\CRIGHTBRACE $2/mg ;
+    1 while s/((?<!\\)%.*)\\frac(.*)$/$1\\CFRAC $2/mg ;
+
     s/(?<!\\)\\%/\\PERCENTAGE /g ;  # (?<! is negative lookbehind assertion to prevent \\% from being converted
     s/(?<!\\)\\\$/\\DOLLAR /g ;  # (?<! is negative lookbehind assertion to prevent \\$ from being converted
     s/\\begin\{($VERBATIMENV)\}(.*?)\\end\{\1\}/"\\${1}{". tohash(\%verbhash,"${2}") . "}"/esg;
@@ -2868,7 +2901,7 @@
 # remove DIFVRB comments but leave changed lines marked 
 sub reverselinecomment {
   my ($environment, $verbatimtext)=@_;
-  ###print STDERR "OLD VERBATIMTEXT: |$verbatimtext|\n";
+  ### print STDERR "DEBUG REVERSELINECOMMENT input: $environment,|$verbatimtext|\n" if $debug;
   # remove markup added by latexdiff
   # (this should occur only if the type of verbatim environment was changed)
   # (note that this destroys some information in old file)
@@ -2903,7 +2936,7 @@
   } else {
     $verbatimtext = "\\begin{${environment}}${verbatimtext}\\end{${environment}}"
   }
-  ###print STDERR "NEW VERBATIMTEXT: |$verbatimtext|\n";
+  ### print STDERR "DEBUG REVERSELINECOMMENT output: |$verbatimtext|\n" if $debug;
   return($verbatimtext);
 }
 
@@ -2945,6 +2978,14 @@
   return $retstr;
 }
 
+# stripdelcmpopen(string)
+# return string with $DELCMDOPEN removed
+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
@@ -3183,10 +3224,15 @@
       ###  $delblock =~ s/\\DIFverb\{/\\DIFDIFdelverb\{/g;
       ###  $delblock =~ s/\\DIFlstinline/\\DIFDIFdellstinline/g;
       ###}
-      # Mark deleted verbose commands
+      # Mark deleted verbatim 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;
+        ###$delblock =~ s/(${DELCMDOPEN}.*)\\($CUSTOMDIFCMD)/$1${DELCMDCLOSE}\\DEL$2/gm;
+        # ($1 ? "${DELCMDOPEN}$1${DELCMDCLOSE}":"") : only add the DELCMDOPEN / DELCMDCLOSE pair if there are actually any commands in between, otherwise this is redundant
+	$delblock    =~ s/${DELCMDOPEN}(.*?)\\($CUSTOMDIFCMD)((?:\[${brat_n}\])*?(?:\s*\{${pat_n}\})*)/($1 ? "${DELCMDOPEN}$1${DELCMDCLOSE}":"") ."\\DEL$2". stripdelcmdopen($3)/egs;
+        # if there is a sequence of several commands in the same row only the first will be converted due to the need to be connected to the DELCMDOPEN. To mop these up, just add the DEL to the front of any remaining cmd's in the deleted block
+        $delblock =~ s/\\($CUSTOMDIFCMD)/\\DEL$1/g;     # this will also convert comments but I guess it does not matter much
       }
 
       #     splice in modified delblock
@@ -3193,7 +3239,6 @@
       substr($_,$begin,$len)=$delblock;
       pos = $begin + length($delblock);
     }
-    ###writedebugfile($_,'postprocess');
 
     ### print STDERR "<<<$_>>>\n" if $debug;
 
@@ -3223,7 +3268,7 @@
       $addblock =~ s/\\DIFverb/\\DIFDIFaddverb/g;
       $addblock =~ s/\\DIFlstinline/\\DIFDIFaddlstinline/g;
       if( $CUSTOMDIFCMD ) {
-        $addblock =~ s/\\($CUSTOMDIFCMD)/\\ADD$1/g;
+        $addblock =~ s/\\($CUSTOMDIFCMD)/\\ADD$1/g;     # this will also convert comments but I guess it does not matter much
       }
       # markup the optional arguments of \item
       $addblock =~ s/(\\$ITEMCMD$extraspace(?:<$abrat0>)?$extraspace)\[($brat_n)\]/
@@ -3333,10 +3378,22 @@
     # remove empty DIFCMD < lines
     s/^\Q${DELCMDOPEN}\E\n//msg;
 
-    # Expand hashes of verb and verbatim environments (note negative look behind assertion to not leak out of DIFDELCMD comments
+    # Expand hashes of verb and verbatim environments 
     s/${DELCMDOPEN}\\($VERBATIMENV)\{([-\d]*?)\}/"${DELCMDOPEN}\\begin{${1}}".fromhash(\%verbhash,$2,$DELCMDOPEN)."${DELCMDOPEN}\\end{${1}}"/esg;
-    # revert changes to verbatim environments for line diffs (and add code to mark up changes)
-    s/(?<!$DELCMDOPEN)\\begin\{($VERBATIMLINEENV)\}(.*?)\\end\{\1\}/"". reverselinecomment($1, $2) .""/esg;
+    # revert changes to verbatim environments for line diffs (and add code to mark up changes) (note negative look behind assertions to not leak out of DIFDELCMD comments)
+    # Example:
+    # < \begin{verbatim}
+    # < %DIF < DIFVRB old verbatim line
+    # < %DIF > DIFVRB new verbatim line
+    # < \end{verbatim}
+    # ---
+    # > \DIFmodbegin
+    # > \begin{verbatim}[alsolanguage=DIFcode]
+    # > %DIF < old verbatim line
+    # > %DIF > new verbatim line
+    # > \end{verbatim}
+    # > \DIFmodend
+    s/(?<!$DELCMDOPEN)\\begin\{($VERBATIMLINEENV)\}(.*?)(?<!$DELCMDOPEN)\\end\{\1\}/"". reverselinecomment($1, $2) .""/esg;
 #    # we do the same for deleted environments but additionally reinstate the framing commands
 #   s/$DELCMDOPEN\\begin\{($VERBATIMLINEENV)\}$extraspace(?:\[$brat0\])?$DELCMDCLOSE(.*?)$DELCMDOPEN\\end\{\1\}$DELCMDCLOSE/"\\begin{$1}". reverselinecomment($2) . "\\end{$1}"/esg;
 ##    s/$DELCMDOPEN\\begin\{($VERBATIMLINEENV)\}($extraspace(?:\[$brat0\])?\s*)(?:\n|$DELCMDOPEN)*$DELCMDCLOSE((?:\%$DELCOMMENT$VERBCOMMENT.*?\n)*)($DELCMDOPEN\\end\{\1\}(?:\n|\s|$DELCMDOPEN)*$DELCMDCLOSE)/"SUBSTITUTION: \\begin{$1}$2 INTERIOR: |$3| END: |$4|"/esg;
@@ -3355,6 +3412,7 @@
             . " $AUXCMD\n"  # close the auxiliary environment
             . $5               # and again leave the original deleted closing environment as is
       /esgx;  # Modifiers of substitution command
+    writedebugfile($_,'postprocess2');
     # where changes have occurred in verbatim environment, change verbatim to DIFverbatim to allow mark-up
     # (I use the presence of optional paramater to verbatim environment as the marker - normal verbatim 
     # environment does not take optional arguments)
@@ -3362,7 +3420,6 @@
 
     s/\\($VERBATIMENV)\{([-\d]*?)\}/"\\begin{${1}}".fromhash(\%verbhash,$2)."\\end{${1}}"/esg;
 
-
     # remove all \PAR tokens (taking care to properly keep commented out PAR's
     # from introducing uncommented newlines - next line)
     s/(%DIF < )([^\n]*?)\\PAR\n/$1$2\n$1\n/sg;
@@ -3408,6 +3465,7 @@
     1 while s/\\SQRT(\s*\{($pat_n)\})/\\sqrt$1/g ;
     1 while s/\\SQRTNB\{(\s*$pat0)\}/\\sqrt$1/g ;
  
+    1 while s/(%.*)\\CFRAC (.*)$/$1\\frac$2/mg ;
     1 while s/(%.*)\\CRIGHTBRACE (.*)$/$1\}$2/mg ;
     1 while s/(%.*)\\CLEFTBRACE (.*)$/$1\{$2/mg ;
 
@@ -3416,7 +3474,7 @@
     s/\\QLEFTBRACE /\\\{/sg;
     s/\\QRIGHTBRACE /\\\}/sg;
     s/\\AMPERSAND /\\&/sg;
-    # Highligh added inline verbatim commands if possible
+    # Highlight added inline verbatim commands if possible
     if ( $latexdiffpreamble =~ /\\RequirePackage(?:\[$brat_n\])?\{color\}/ )   { 
       # wrap added verb commands with color commands
       s/\\DIFDIFadd((?:verb\*?|lstinline(?:\[$brat_n\])?)\{[-\d]*?\}[\s\n]*)/\{\\color{blue}$AUXCMD\n\\DIF$1%\n\}$AUXCMD\n/sg;
@@ -3476,7 +3534,7 @@
   my ($line,$cmd,$optarg,$arg,$optargnew,$optargold,$optargdiff,$argold,$argnew,$argdiff,$auxline);
 
   my $warnmsgdetail = <<EOF ;
-     This should not occur for standard styles, but can occur for some specifiy styles, document classes,
+     This should not occur for standard styles, but can occur for some specific styles, document classes,
      e.g. journal house styles.
      Workaround: Use --replace-context2cmd option to specifically set those commands, which are not repeated.
 EOF
@@ -3742,7 +3800,7 @@
 
 
 sub usage {
-  die <<"EOF"; 
+  print STDERR <<"EOF"; 
 Usage: $0 [options] old.tex new.tex > diff.tex
 
 Compares two latex files and writes tex code to stdout, which has the same format as new.tex but 
@@ -3936,6 +3994,9 @@
                                 variable SCALEDELGRAPHICS to set size of deleted figures.
                       Note that changes to the optional parameters will make the figure appear as changed 
                       to latexdiff, and this figure will thus be highlighted.
+                      In some circumstances "Misplaced \\noalign" errors can occur if there are certain types
+                      of changes in tables. In this case please use option --graphics-markup=none as a 
+                      work-around. 
 
 --disable-citation-markup 
 --disable-auto-mbox    Suppress citation markup and markup of other vulnerable commands in styles 
@@ -3947,7 +4008,7 @@
                        with \\mbox command, i.e. use default behaviour for ulem package for other packages
                        (the two options are identical and are simply aliases)
 
-Miscelleneous options
+Miscellaneous options
 
 --label=label
 -L label               Sets the labels used to describe the old and new files.  The first use
@@ -3978,8 +4039,11 @@
 --ignore-filter-stderr When running with --filter-script, STDERR from the script may cause readability issues.
                        Turn this flag on to ignore STDERR from the filter script.
 
+--driver=type          Choose driver for changebar package (only relevant for styles using
+                       changebar: CCHANGEBAR CFONTCHBAR CULINECHBAR CHANGEBAR). Possible
+                       drivers are listed in changebar manual, e.g. pdftex,dvips,dvitops
+                       [Default: pdftex]
 
-
 --help
 -h                     Show this help text.
 
@@ -3999,6 +4063,7 @@
 --no-links             Suppress generation of hyperreferences, used for minimal diffs 
                        (option --only-changes of latexdiff-vc).
 EOF
+  exit 0; 
 }
 
 =head1 NAME
@@ -4470,8 +4535,13 @@
 variable SCALEDELGRAPHICS to set size of deleted figures.
 
 Note that changes to the optional parameters will make the figure appear as changed 
-to latexdiff, and this figure will thus be highlighted
+to latexdiff, and this figure will thus be highlighted.
 
+In some circumstances "Misplaced \noalign" error can occur if there are certain types
+of changes in tables. In this case please use C<--graphics-markup=none> as a 
+work-around. 
+
+
 =item B<--disable-citation-markup> or B<--disable-auto-mbox>
 
 Suppress citation markup and markup of other vulnerable commands in styles 
@@ -4500,7 +4570,7 @@
 Choose driver for changebar package (only relevant for styles using
    changebar: CCHANGEBAR CFONTCHBAR CULINECHBAR CHANGEBAR). Possible
 drivers are listed in changebar manual, e.g. pdftex,dvips,dvitops
-  [Default: dvips]
+  [Default: pdftex]
 
 =item B<--ignore-warnings>
 
@@ -4895,8 +4965,8 @@
 
 =head1 AUTHOR
 
-Version 1.3.0
-Copyright (C) 2004-2018 Frederik Tilmann
+Version 1.3.2
+Copyright (C) 2004-2021 Frederik Tilmann
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License Version 3
@@ -4922,6 +4992,7 @@
 mbox
 pageref
 ref
+eqref
 symbol
 raisebox
 rule
@@ -5222,6 +5293,7 @@
 %%BEGIN ARRENV CONFIG
 aligned
 gathered
+multlined
 array
 [pbvBV]?matrix
 smallmatrix
@@ -5291,7 +5363,7 @@
 %DIF END FONTSTRIKE PREAMBLE
 
 %DIF CCHANGEBAR PREAMBLE
-\RequirePackage[dvips]{changebar}
+\RequirePackage[pdftex]{changebar}
 \RequirePackage{color}\definecolor{RED}{rgb}{1,0,0}\definecolor{BLUE}{rgb}{0,0,1}
 \providecommand{\DIFadd}[1]{\protect\cbstart{\protect\color{blue}#1}\protect\cbend}
 \providecommand{\DIFdel}[1]{\protect\cbdelete{\protect\color{red}#1}\protect\cbdelete}
@@ -5298,7 +5370,7 @@
 %DIF END CCHANGEBAR PREAMBLE
 
 %DIF CFONTCHBAR PREAMBLE
-\RequirePackage[dvips]{changebar}
+\RequirePackage[pdftex]{changebar}
 \RequirePackage{color}\definecolor{RED}{rgb}{1,0,0}\definecolor{BLUE}{rgb}{0,0,1}
 \providecommand{\DIFadd}[1]{\protect\cbstart{\protect\color{blue}\sf #1}\protect\cbend}
 \providecommand{\DIFdel}[1]{\protect\cbdelete{\protect\color{red}\scriptsize #1}\protect\cbdelete}
@@ -5306,7 +5378,7 @@
 
 %DIF CULINECHBAR PREAMBLE
 \RequirePackage[normalem]{ulem}
-\RequirePackage[dvips]{changebar}
+\RequirePackage[pdftex]{changebar}
 \RequirePackage{color}\definecolor{RED}{rgb}{1,0,0}\definecolor{BLUE}{rgb}{0,0,1}
 \providecommand{\DIFadd}[1]{\protect\cbstart{\protect\color{blue}\uwave{#1}}\protect\cbend}
 \providecommand{\DIFdel}[1]{\protect\cbdelete{\protect\color{red}\sout{#1}}\protect\cbdelete}
@@ -5313,7 +5385,7 @@
 %DIF END CULINECHBAR PREAMBLE
 
 %DIF CHANGEBAR PREAMBLE
-\RequirePackage[dvips]{changebar}
+\RequirePackage[pdftex]{changebar}
 \providecommand{\DIFadd}[1]{\protect\cbstart{#1}\protect\cbend}
 \providecommand{\DIFdel}[1]{\protect\cbdelete}
 %DIF END CHANGEBAR PREAMBLE
@@ -5560,7 +5632,6 @@
 
 %DIF LISTINGS PREAMBLE
 \RequirePackage{listings}
-\RequirePackage{color}
 \lstdefinelanguage{DIFcode}{
   % note that the definitions in the following two lines are overwritten dependent on the markup type selected %DIFCODE TEMPLATE
   morecomment=[il]{\%DIF\ <\ },          %DIFCODE TEMPLATE
@@ -5576,6 +5647,24 @@
 \lstnewenvironment{DIFverbatim*}{\lstset{style=DIFverbatimstyle,showspaces=true}}{}
 %DIF END LISTINGS PREAMBLE
 
+%DIF COLORLISTINGS PREAMBLE
+\RequirePackage{listings}
+\RequirePackage{color}
+\lstdefinelanguage{DIFcode}{
+  % note that the definitions in the following two lines are overwritten dependent on the markup type selected %DIFCODE TEMPLATE
+  morecomment=[il]{\%DIF\ <\ },          %DIFCODE TEMPLATE
+  moredelim=[il][\bfseries]{\%DIF\ >\ }  %DIFCODE TEMPLATE
+}
+\lstdefinestyle{DIFverbatimstyle}{
+	language=DIFcode,
+	basicstyle=\ttfamily,
+	columns=fullflexible,
+	keepspaces=true
+}
+\lstnewenvironment{DIFverbatim}{\lstset{style=DIFverbatimstyle}}{}
+\lstnewenvironment{DIFverbatim*}{\lstset{style=DIFverbatimstyle,showspaces=true}}{}
+%DIF END COLORLISTINGS PREAMBLE
+
 %DIF DIFCODE_UNDERLINE
   moredelim=[il][\color{red}\sout]{\%DIF\ <\ },
   moredelim=[il][\color{blue}\uwave]{\%DIF\ >\ }

Modified: trunk/Build/source/texk/texlive/linked_scripts/latexdiff/latexrevise.pl
===================================================================
--- trunk/Build/source/texk/texlive/linked_scripts/latexdiff/latexrevise.pl	2021-12-28 22:51:15 UTC (rev 61433)
+++ trunk/Build/source/texk/texlive/linked_scripts/latexdiff/latexrevise.pl	2021-12-28 22:52:08 UTC (rev 61434)
@@ -21,6 +21,9 @@
 #
 # Detailed usage information at the end of the file
 # Note: version number now keeping up with latexdiff
+# Version 1.3.2 
+#   - Functionality -c option: if comment to be deleted is the last in the line replace new line by space character. This is done to avoid errors or unintended line breaks from empty lines after deletion (which are implicit \par)
+#   - Introduce option -r / --replace which removes markup of the form \replaced{new text}{old text} in the changes package
 # Version 1.3.1  (Bug fix) Remove some deprecation warnings due to uncommented left parentheses 
 # Version 1.0.2  Option --version
 # Version 1.0.1   no changes to latexrevise
@@ -32,8 +35,8 @@
 use warnings;
 
 my $versionstring=<<EOF ;
-This is LATEXREVISE 1.3.1.1
-  (c) 2005-2020 F J Tilmann
+This is LATEXREVISE 1.3.2
+  (c) 2005-2021 F J Tilmann
 EOF
 
 # Markup strings (make sure that this are set to the same value as in 
@@ -92,7 +95,7 @@
 my ($cnt,$prematch,$postmatch);
 my ($help,$version);
 my ($verbose,$quiet,$accept,$decline,$simplify)=(0,0,0,0,0);
-my ($comment,$comenv,$markup,$markenv);
+my ($comment,$comenv,$markup,$markenv,$replace);
 
 # A word unlikely ever to be used in a real latex file
 my $someword='gobbledegooksygook';
@@ -105,6 +108,7 @@
 	   'comment-environment|e=s' => \$comenv,
 	   'markup|m=s' => \$markup,
 	   'markup-environment|n=s' => \$markenv,
+	   'replace|r=s' => \$replace,
 	   'no-warnings|q' => \$verbose,
            'version' => \$version,
 	   'verbose|V' => \$verbose,
@@ -115,7 +119,8 @@
 }
 
 if ( $version ) {
-  die $versionstring ; 
+  print STDERR $versionstring ; 
+  exit 0;
 }
 
 
@@ -259,7 +264,7 @@
   # protect $comments in comments by making them look different
   $body =~ s/(%.*)${comment}(.*)$/$1${someword}$2/mg ;
   # carry out the substitution
-  $cnt = 0 + $body =~ s/\\${comment}(?:\[${brat0}\])?\{${pat_n}\}//sg ;
+  $cnt = 0 + $body =~ s/\\${comment}(?:\[${brat0}\])?\{${pat_n}\}(?: *\n)?//sg ;
   print STDERR "$cnt matches found and removed.\n" if $verbose;
   # and undo the protection substitution
   $body =~ s/(%.*)${someword}(.*)$/$1${comment}$2/mg ;
@@ -292,6 +297,16 @@
   $body =~ s/(%.*)${someword}/$1${markenv}/mg ;
 }
 
+if (defined($replace)) {
+  print STDERR "Removing \\$replace\{..\}\{..\} commands (leaving 1st and discarding 2nd argument))..." if $verbose;
+  # protect $markups in comments by making them look different
+  $body =~ s/(%.*)${replace}(.*)$/$1${someword}$2/mg ;
+  # carry out the substitution
+  $cnt = 0 + $body =~ s/\\${replace}(?:\[${brat0}\])?\{(${pat_n})\}\s?\{(${pat_n})\}/$1/sg ;
+  print STDERR "$cnt matches found and removed.\n" if $verbose;
+  # and undo the protection substitution
+  $body =~ s/(%.*)${someword}(.*)$/$1${replace}$2/mg ;
+}
 
 if ( length $preamble ) {
   print "$preamble\\begin{document}${body}\\end{document}$post";
@@ -349,7 +364,7 @@
 
 
 sub usage {
-  die <<"EOF"; 
+  print STDERR <<"EOF"; 
 Usage: $0 [OPTIONS] [diff.tex] > revised.tex
 
 Read a file diff.tex (output of latexdiff), and remove its markup. 
@@ -390,7 +405,7 @@
 
 Note that the three mode options are mutually exclusive. If no mode option is given,
 latexrevise simply removes user annotations and markup according to the following four
-options.
+options; these functions can be very useful outside the latexdiff context, too.
 
 
 -c cmd
@@ -414,6 +429,11 @@
 --markup-environment=envir  
                   Similarly, remove \\begin{envir} and \\end{envir} commands,
                   but leave content of the environment in the text.
+
+
+-r cmd
+--replace=cmd    For constructions \\cmd{..}{..}, remove the command, leave the 
+                 content of first argument, and delete second argument. 
                   
 -q
 --no-warnings     Do not warn users about \\DIDadd{..} or \\DIFdel statements
@@ -423,6 +443,7 @@
 --verbose         Verbose output
 
 EOF
+  exit 0;
 }
 
 =head1 NAME
@@ -480,7 +501,7 @@
 
 Note that the three mode options are mutually exclusive.  If no mode option is given,
 I<latexrevise> simply removes user annotations and markup according to the following four
-options.
+options. These functions can be very useful outside the latexdiff context, too
 
 =over 4
 
@@ -509,6 +530,13 @@
 
 Similarly, remove C<\begin{envir}> and C<\end{envir}> commands but 
 leave content of the environment in the text.
+
+=item B<-r cmd> or B<--replace=cmd>
+
+For constructions C<\\cmd{..}{..}>, remove the command, leave the 
+content of first argument, and delete second argument, i.e. turn 
+C<\cmd{abc}{def}> into C<abc>.
+
                   
 
 =item B<-V> or B<--verbose>

Modified: trunk/Master/texmf-dist/doc/man/man1/latexdiff-vc.1
===================================================================
--- trunk/Master/texmf-dist/doc/man/man1/latexdiff-vc.1	2021-12-28 22:51:15 UTC (rev 61433)
+++ trunk/Master/texmf-dist/doc/man/man1/latexdiff-vc.1	2021-12-28 22:52:08 UTC (rev 61434)
@@ -1,4 +1,4 @@
-.\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.29)
+.\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.35)
 .\"
 .\" Standard preamble:
 .\" ========================================================================
@@ -46,7 +46,7 @@
 .ie \n(.g .ds Aq \(aq
 .el       .ds Aq '
 .\"
-.\" If the F register is turned on, we'll generate index entries on stderr for
+.\" If the F register is >0, we'll generate index entries on stderr for
 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
 .\" entries marked with X<> in POD.  Of course, you'll have to process the
 .\" output yourself in some meaningful fashion.
@@ -56,12 +56,12 @@
 ..
 .nr rF 0
 .if \n(.g .if rF .nr rF 1
-.if (\n(rF:(\n(.g==0)) \{
-.    if \nF \{
+.if (\n(rF:(\n(.g==0)) \{\
+.    if \nF \{\
 .        de IX
 .        tm Index:\\$1\t\\n%\t"\\$2"
 ..
-.        if !\nF==2 \{
+.        if !\nF==2 \{\
 .            nr % 0
 .            nr F 2
 .        \}
@@ -133,7 +133,7 @@
 .\" ========================================================================
 .\"
 .IX Title "LATEXDIFF-VC 1"
-.TH LATEXDIFF-VC 1 "2020-06-13" "perl v5.22.1" " "
+.TH LATEXDIFF-VC 1 "2021-12-27" "perl v5.30.0" " "
 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
 .\" way too many mistakes in technical documents.
 .if n .ad l
@@ -211,9 +211,10 @@
 With \f(CW\*(C`\-\-flatten=keep\-intermediate\*(C'\fR, the intermediate revision snapshots are kept in the current directory (Default is to store them in a temporary directory and delete them after generating the diff file.)
 .IP "\fB\-\-only\-changes\fR" 4
 .IX Item "--only-changes"
-Post-process the output such that only pages with changes on them are displayed. This requires the use of subtype \s-1ZLABEL \s0
+Post-process the output such that only pages with changes on them are displayed. This requires the use of subtype \s-1ZLABEL\s0 
 in latexdiff, which will be set automatically, but any manually set \-s option will be overruled (also requires zref package to 
-be installed). (note that this option must be combined with \-\-ps or \-\-pdf to make sense)
+be installed). This option also disables internal links (as implemented by hyperref package) and graphics markup.
+(note that this option must be combined with \-\-ps or \-\-pdf to make sense)
 .IP "\fB\-\-force\fR" 4
 .IX Item "--force"
 Overwrite existing diff files without asking for confirmation. Default 

Modified: trunk/Master/texmf-dist/doc/man/man1/latexdiff-vc.man1.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/man/man1/latexdiff.1
===================================================================
--- trunk/Master/texmf-dist/doc/man/man1/latexdiff.1	2021-12-28 22:51:15 UTC (rev 61433)
+++ trunk/Master/texmf-dist/doc/man/man1/latexdiff.1	2021-12-28 22:52:08 UTC (rev 61434)
@@ -1,4 +1,4 @@
-.\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.29)
+.\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.35)
 .\"
 .\" Standard preamble:
 .\" ========================================================================
@@ -46,7 +46,7 @@
 .ie \n(.g .ds Aq \(aq
 .el       .ds Aq '
 .\"
-.\" If the F register is turned on, we'll generate index entries on stderr for
+.\" If the F register is >0, we'll generate index entries on stderr for
 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
 .\" entries marked with X<> in POD.  Of course, you'll have to process the
 .\" output yourself in some meaningful fashion.
@@ -56,12 +56,12 @@
 ..
 .nr rF 0
 .if \n(.g .if rF .nr rF 1
-.if (\n(rF:(\n(.g==0)) \{
-.    if \nF \{
+.if (\n(rF:(\n(.g==0)) \{\
+.    if \nF \{\
 .        de IX
 .        tm Index:\\$1\t\\n%\t"\\$2"
 ..
-.        if !\nF==2 \{
+.        if !\nF==2 \{\
 .            nr % 0
 .            nr F 2
 .        \}
@@ -133,7 +133,7 @@
 .\" ========================================================================
 .\"
 .IX Title "LATEXDIFF 1"
-.TH LATEXDIFF 1 "2020-06-13" "perl v5.22.1" " "
+.TH LATEXDIFF 1 "2021-12-27" "perl v5.30.0" " "
 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
 .\" way too many mistakes in technical documents.
 .if n .ad l
@@ -305,7 +305,7 @@
 If this option is used, then old.tex, new.tex are only opened once.
 [Default encoding is utf8 unless the first few lines of the preamble contain
 an invocation \f(CW\*(C`\eusepackage[..]{inputenc}\*(C'\fR in which case the 
-encoding chosen by this command is asssumed. Note that \s-1ASCII \s0(standard
+encoding chosen by this command is asssumed. Note that \s-1ASCII\s0 (standard
 latex) is a subset of utf8]
 .IP "\fB\-\-preamble=file\fR or \fB\-p file\fR" 4
 .IX Item "--preamble=file or -p file"
@@ -566,7 +566,11 @@
 variable \s-1SCALEDELGRAPHICS\s0 to set size of deleted figures.
 .Sp
 Note that changes to the optional parameters will make the figure appear as changed 
-to latexdiff, and this figure will thus be highlighted
+to latexdiff, and this figure will thus be highlighted.
+.Sp
+In some circumstances \*(L"Misplaced \enoalign\*(R" error can occur if there are certain types
+of changes in tables. In this case please use \f(CW\*(C`\-\-graphics\-markup=none\*(C'\fR as a 
+work-around.
 .IP "\fB\-\-disable\-citation\-markup\fR or \fB\-\-disable\-auto\-mbox\fR" 4
 .IX Item "--disable-citation-markup or --disable-auto-mbox"
 Suppress citation markup and markup of other vulnerable commands in styles 
@@ -588,7 +592,7 @@
 Choose driver for changebar package (only relevant for styles using
    changebar: \s-1CCHANGEBAR CFONTCHBAR CULINECHBAR CHANGEBAR\s0). Possible
 drivers are listed in changebar manual, e.g. pdftex,dvips,dvitops
-  [Default: dvips]
+  [Default: pdftex]
 .IP "\fB\-\-ignore\-warnings\fR" 4
 .IX Item "--ignore-warnings"
 Suppress warnings about inconsistencies in length between input and
@@ -923,8 +927,8 @@
 \&\fIlatexdiff-fast\fR requires the \fIdiff\fR command to be present.
 .SH "AUTHOR"
 .IX Header "AUTHOR"
-Version 1.3.0
-Copyright (C) 2004\-2018 Frederik Tilmann
+Version 1.3.2
+Copyright (C) 2004\-2021 Frederik Tilmann
 .PP
 This program is free software; you can redistribute it and/or modify
 it under the terms of the \s-1GNU\s0 General Public License Version 3

Modified: trunk/Master/texmf-dist/doc/man/man1/latexdiff.man1.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/man/man1/latexrevise.1
===================================================================
--- trunk/Master/texmf-dist/doc/man/man1/latexrevise.1	2021-12-28 22:51:15 UTC (rev 61433)
+++ trunk/Master/texmf-dist/doc/man/man1/latexrevise.1	2021-12-28 22:52:08 UTC (rev 61434)
@@ -1,4 +1,4 @@
-.\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.29)
+.\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.35)
 .\"
 .\" Standard preamble:
 .\" ========================================================================
@@ -46,7 +46,7 @@
 .ie \n(.g .ds Aq \(aq
 .el       .ds Aq '
 .\"
-.\" If the F register is turned on, we'll generate index entries on stderr for
+.\" If the F register is >0, we'll generate index entries on stderr for
 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
 .\" entries marked with X<> in POD.  Of course, you'll have to process the
 .\" output yourself in some meaningful fashion.
@@ -56,12 +56,12 @@
 ..
 .nr rF 0
 .if \n(.g .if rF .nr rF 1
-.if (\n(rF:(\n(.g==0)) \{
-.    if \nF \{
+.if (\n(rF:(\n(.g==0)) \{\
+.    if \nF \{\
 .        de IX
 .        tm Index:\\$1\t\\n%\t"\\$2"
 ..
-.        if !\nF==2 \{
+.        if !\nF==2 \{\
 .            nr % 0
 .            nr F 2
 .        \}
@@ -133,7 +133,7 @@
 .\" ========================================================================
 .\"
 .IX Title "LATEXREVISE 1"
-.TH LATEXREVISE 1 "2020-06-13" "perl v5.22.1" " "
+.TH LATEXREVISE 1 "2021-12-27" "perl v5.30.0" " "
 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
 .\" way too many mistakes in technical documents.
 .if n .ad l
@@ -183,7 +183,7 @@
 .PP
 Note that the three mode options are mutually exclusive.  If no mode option is given,
 \&\fIlatexrevise\fR simply removes user annotations and markup according to the following four
-options.
+options. These functions can be very useful outside the latexdiff context, too
 .IP "\fB\-c cmd\fR or \fB\-\-comment=cmd\fR" 4
 .IX Item "-c cmd or --comment=cmd"
 Remove \f(CW\*(C`\ecmd{...}\*(C'\fR sequences.  \f(CW\*(C`cmd\*(C'\fR is supposed to mark some explicit 
@@ -208,6 +208,11 @@
 .IX Item "-n envir or --markup-environment=envir"
 Similarly, remove \f(CW\*(C`\ebegin{envir}\*(C'\fR and \f(CW\*(C`\eend{envir}\*(C'\fR commands but 
 leave content of the environment in the text.
+.IP "\fB\-r cmd\fR or \fB\-\-replace=cmd\fR" 4
+.IX Item "-r cmd or --replace=cmd"
+For constructions \f(CW\*(C`\e\ecmd{..}{..}\*(C'\fR, remove the command, leave the 
+content of first argument, and delete second argument, i.e. turn 
+\&\f(CW\*(C`\ecmd{abc}{def}\*(C'\fR into \f(CW\*(C`abc\*(C'\fR.
 .IP "\fB\-V\fR or \fB\-\-verbose\fR" 4
 .IX Item "-V or --verbose"
 Verbose output

Modified: trunk/Master/texmf-dist/doc/man/man1/latexrevise.man1.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/support/latexdiff/doc/example-diff.tex
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexdiff/doc/example-diff.tex	2021-12-28 22:51:15 UTC (rev 61433)
+++ trunk/Master/texmf-dist/doc/support/latexdiff/doc/example-diff.tex	2021-12-28 22:52:08 UTC (rev 61434)
@@ -37,7 +37,7 @@
 \providecommand{\DIFaddendFL}{} %DIF PREAMBLE
 \providecommand{\DIFdelbeginFL}{} %DIF PREAMBLE
 \providecommand{\DIFdelendFL}{} %DIF PREAMBLE
-%DIF LISTINGS PREAMBLE %DIF PREAMBLE
+%DIF COLORLISTINGS PREAMBLE %DIF PREAMBLE
 \RequirePackage{listings} %DIF PREAMBLE
 \RequirePackage{color} %DIF PREAMBLE
 \lstdefinelanguage{DIFcode}{ %DIF PREAMBLE

Modified: trunk/Master/texmf-dist/doc/support/latexdiff/doc/latexdiff-man.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/support/latexdiff/latexdiff
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexdiff/latexdiff	2021-12-28 22:51:15 UTC (rev 61433)
+++ trunk/Master/texmf-dist/doc/support/latexdiff/latexdiff	2021-12-28 22:52:08 UTC (rev 61434)
@@ -22,7 +22,23 @@
 #
 # Detailed usage information at the end of the file
 #
-
+#
+# Version 1.3.2
+# API adaptions:
+#  - latexdiff now completes with exit code 0 after --help or --version command (see issue #248)
+# New features / feature extensions
+#  - extend CUSTOMDIFCMD related postprocessing to deal properly with multiline commands, or a sequence of several commands in the same line (see github issue #204)
+#  - Support for additional macros from import package (\import, \inputfrom, \includefrom, \subimport,\subinputfrom, \subincludefrom). Provided by janniklasrose in PR #243 (fixes #239)
+#  - replace default driver dvips->pdftex
+# Bug fixes:
+#  - fix issue #206 affecting proper markup of text commands which are not safe cmd's at the same time and have multiple arguments
+#  - fix issue #210 by adding \eqref (amsmath package) to the list of safe commands
+#  - fix bug reported in issue #168 mangled verbatim line environment 
+#  - fix bug reported in issue #218 by replacing \hspace{0pt} after \mbox{..} auxiliary commands with \hskip0pt.
+#  - more ways to process \frac correctly with atomic arguments (committed by julianuu PR #246
+#  - fix a bug in biblatex mode, which prevented proper processing of modified \textcite (see: https://tex.stackexchange.com/questions/555157/latexdiff-and-biblatex-citation-commands)
+#  - -h string fix: add -driver option
+#
 # Version 1.3.1.1
 #  - remove spurious \n to fix error: Unknown regexp modifier "/n" at .../latexdiff line 1974, near "=~ " (see github issue #201)
 #
@@ -203,8 +219,8 @@
 
 
 my ($versionstring)=<<EOF ;
-This is LATEXDIFF 1.3.1.1 (Algorithm::Diff $Algorithm::Diff::VERSION, Perl $^V)
-  (c) 2004-2020 F J Tilmann
+This is LATEXDIFF 1.3.2 (Algorithm::Diff $Algorithm::Diff::VERSION, Perl $^V)
+  (c) 2004-2021 F J Tilmann
 EOF
 
 # Hash with defaults for configuration variables. These marked undef have default values constructed from list defined in the DATA block
@@ -261,7 +277,7 @@
 # my $MATHREPL='displaymath';  # Environment introducing deleted maths blocks
 # my $MATHARRENV='(?:eqnarray|align|alignat|gather|multline|flalign)[*]?' ;           # Environments turning on eqnarray math mode
 # my $MATHARRREPL='eqnarray*';  # Environment introducing deleted maths blocks
-# my $ARRENV='(?:aligned|gathered|array|[pbvBV]?matrix|smallmatrix|cases|split)'; # Environments making arrays in math mode.  The underlining style does not cope well with those - as a result in-text math environments are surrounded by \mbox{ } if any of these commands is used in an inline math block
+# my $ARRENV='(?:aligned|gathered|multlined|array|[pbvBV]?matrix|smallmatrix|cases|split)'; # Environments making arrays in math mode.  The underlining style does not cope well with those - as a result in-text math environments are surrounded by \mbox{ } if any of these commands is used in an inline math block
 # my $COUNTERCMD='(?:footnote|part|chapter|section|subsection|subsubsection|paragraph|subparagraph)';  # textcmds which are associated with a counter
 #                                         # If any of these commands occur in a deleted block
 #                                         # they will be succeeded by an \addtocounter{...}{-1}
@@ -458,7 +474,8 @@
 
 
 if ( $version ) {
-  die $versionstring ; 
+  print STDERR $versionstring ; 
+  exit 0;
 }
 
 print STDERR $versionstring if $verbose; 
@@ -503,7 +520,7 @@
 
 if ( defined($driver) ) {
   # for changebar only
-  $latexdiffpreamble=~s/\[dvips\]/[$driver]/sg;
+  $latexdiffpreamble=~s/\[pdftex\]/[$driver]/sg;
 }
 # setting up @SAFECMDLIST and @SAFECMDEXCL
 if (defined($replacesafe)) {
@@ -734,7 +751,9 @@
   my $predefinedcmdoptseq='(?:'.$predefinedcmdoptseq12.'|'.$predefinedcmdoptseq01.'|'.$predefinedbibitem.')';
 
   my $cmdleftright='\\\\(?:left|right|[Bb]igg?[lrm]?|middle)\s*(?:[<>()\[\]|\.]|\\\\(?:[|{}]|\w+))';
-  my $cmdoptseq='\\\\[\w\d@\*]+'.$extraspace.'(?:(?:<'.$abrat0.'>|\['.$brat_n.'\]|\{'. $pat_n . '\}|\(' . $coords .'\))'.$extraspace.')*';
+# standard $cmdoptseq (default: no intrevening spaces, controlled by extraspcae) - a final open parentheses is merged to the commend if it exists to deal properly with multi-argument text command
+  my $cmdoptseq='\\\\[\w\d@\*]+'.$extraspace.'(?:(?:<'.$abrat0.'>|\['.$brat_n.'\]|\{'. $pat_n . '\}|\(' . $coords .'\))'.$extraspace.')*\{?';
+# Handle tex \def macro: \def\MAKRONAME#1[#2]#3{DEFINITION}
   my $defseq='\\\\def\\\\[\w\d@\*]+(?:#\d+|\[#\d+\])+(?:\{'. $pat_n . '\})?';
   my $backslashnl='\\\\\n';
   my $oneletcmd='\\\\.\*?(?:\['.$brat_n.'\]|\{'. $pat_n . '\})*';
@@ -953,6 +972,9 @@
 # If listings is being used or can be found in the latexdiff search path, add to the preamble auxiliary code to enable line-by-line markup
 if ( defined($packages{"listings"}) or `kpsewhich listings.sty` ne "" ) {
   my @listingpreamble=extrapream("LISTINGS");
+  if ($latexdiffpreamble =~ /\\RequirePackage(?:\[$brat_n\])?\{color\}/ ) {
+    @listingpreamble=extrapream("COLORLISTINGS");
+  }
   my @listingDIFcode=();
   my $replaced;
   # note that in case user supplies preamblefile the type might not reflect well the 
@@ -1115,6 +1137,7 @@
 } elsif (defined $packages{"biblatex"}) {
   print STDERR "biblatex package detected.\n" if $verbose ;
   $citpat='(?:[cC]ites?|(?:[pP]aren|foot|[Tt]ext|[sS]mart|super)cites?\*?|footnotecitetex)';
+  push(@TEXTCMDEXCL, qr/^textcite$/);
 } else {
   # citation command pattern for all other citation schemes
   $citpat='(?:cite\w*|nocite)';
@@ -1391,6 +1414,9 @@
     my $should_be_safe = $2;
     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/^(?:ADD|DEL)?${CUSTOMDIFCMD}$/);
+    ###print STDERR "DEBUG: really test it. \n";
     # test if all latex commands inside it are safe
     $success = 1;
     if ($should_be_safe =~ m/\\\\/) {
@@ -1433,6 +1459,7 @@
 # expands \input and \include commands within text
 # expands \bibliography command with corresponding bbl file if available
 # expands \subfile command (from subfiles package - not part of standard text distribution)
+# expands \import etc commands (from import package - not part of standard text distribution)
 # preamble is scanned for includeonly commands
 # encoding is the encoding
 sub flatten {
@@ -1460,15 +1487,16 @@
   # Run through filter, to let filterscript have a pass if it was set
   $text = filter($text);
 
-  # Recursively replace \\import and \\subimport files
-  $text =~ s/(^(?:[^%\n]|\\%)*)(\\subimport\{(.*?)\}|\\import\{(.*?)\})(?:[\s]*)\{(.*?)\}/{
+  # Recursively replace \\import, \\subimport, and related import commands
+  $text =~ s/(^(?:[^%\n]|\\%)*)(\\(sub)?(?:import|inputfrom|includefrom))\{(.*?)\}(?:[\s]*)\{(.*?)\}/{
+          #  (--------1-------)(--(=3=)-------------2-------------------)  (-4-)             (-5-)
           # $1 is begline
-          # $3 is directory if subimport
-          # $4 is directory if import
+          # $2 is the import macro name
+          # $3 is (optional) prefix "sub"
+          # $4 is directory
           # $5 is filename
           $begline = (defined($1)? $1 : "");
-          $subdir = $3 if defined($3);
-          $subdir = $4 if defined($4);
+          $subdir = $4;
           $fname = $5;
           $fname .= ".tex" unless $fname =~ m|\.\w{3,4}$|;
           print STDERR "DEBUG begline:", $begline, "\n" if $debug;
@@ -1483,12 +1511,13 @@
           print STDERR "importing importfilepath:", $importfilepath,"\n" if $verbose;
           if ( -f $importfilepath ) {
               # If file exists, replace input or include command with expanded input
+              #TODO: need remove_endinput & newpage similar to other replacements inside flatten
               $replacement=flatten(read_file_with_encoding($importfilepath, $encoding), $preamble,$importfilepath,$encoding) or die "Could not open file ",$fullfile,": $!";
           } else {
               # if file does not exist, do not expand include or input command (do not warn if fname contains #[0-9] as it is then likely part of a command definition
               # and is not meant to be expanded directly 
               print STDERR "WARNING: Could not find included file ",$importfilepath,". I will continue but not expand |$2|\n";
-              $replacement=(defined($3)? "\\subimport" : "\\import");
+              $replacement = $2;
               $replacement .= "{$subdir}{$fname} % Processed";
           }
           "$begline$replacement";
@@ -2158,9 +2187,10 @@
 
 
 # split this block to split sequences joined in pass1
+  ### print STDERR "DEBUG: marktags before splitlatex blocksplit ",join("|",@$block),"\n" if $debug;
   @$block=splitlatex(join "",@$block);
   ### print STDERR "DEBUG: marktags $openmark,$closemark,$open,$close,$opencmd,$closecmd,$comment\n" if $debug;
-  ### print STDERR "DEBUG: marktags blocksplit ",join("|",@$block),"\n" if $debug;
+  print STDERR "DEBUG: after splitlatex ",join("|",@$block),"\n" if $debug;
 
   # we redefine locally $extraspace (shadowing the global definition) to capture command sequences with intervening spaces no matter what the global setting
   # this is done so we can capture those commands with a predefined number of arguments without having to introduce them again explicitly here
@@ -2216,6 +2246,7 @@
         #            $2 (the command) is in context2, just treat it as an ordinary command (i.e. comment it open with $opencmd)
         # Because we do not want to disable this command
 	# here we do not use $opencmd and $closecmd($opencmd is empty) 
+	print STDERR "DEBUG: Detected text |$word| but not safe command \$2: $2 \$3: $3\n." if $debug;
 	if ($cmd==1) {
 	  push (@$retval,$closecmd) ;
 	} elsif ($cmd==0) { 
@@ -2274,7 +2305,7 @@
       if ( $word =~ /^\\(?!\()(\\|[`'^"~=.]|[\w*@]+)(.*?)(\s*)$/s &&  iscmd($1,\@MBOXCMDLIST,\@MBOXCMDEXCL)) {
 	# $word is a safe command in MBOXCMDLIST
 	###print STDERR "DEBUG Mboxsafecmd detected:$word:\n" if $debug ;
-	push(@$retval,"\\mbox{$AUXCMD\n\\" . $1 . $2 . $3 ."}\\hspace{0pt}$AUXCMD\n" );
+	push(@$retval,"\\mbox{$AUXCMD\n\\" . $1 . $2 . $3 ."}\\hskip0pt$AUXCMD\n" );
       } else {
 	# $word is a normal word or a safe command (not in MBOXCMDLIST)
 	push (@$retval,$word);
@@ -2294,15 +2325,15 @@
   # some special magic for common usage of frac, which does not conform to the latexdiff requirements but can be made to fit
   # note that this is a rare exception to the general rule that the new tex can be reconstructed from the diff file
 
-  # \frac12 -> \frac{1}{2}
-  s/\\frac(\d)(\w)/\\frac\{$1\}\{$2\}/g;
-
-  # \frac1{2b} -> \frac{1}{2b}
-  s/\\frac(\d)/\\frac\{$1\}/g;
-
-  # delete space and comment characters between \frac arguments
-#  s/\\frac(?:\s*?%[^\n]*?)*?(\{$pat_n\})\s*(\{$pat_n\})/\\frac$1$2/g;
-  s/\\frac(?:\s|%[^\n]*?)*(\{$pat_n\})(?:\s|%[^\n]*?)*(\{$pat_n\})/\\frac$1$2/g;
+  # regex that matches space and comment characters
+  my $space = qr/\s|%[^\n]*?/;
+  # \frac {abc} -> \frac{abc}
+  # \frac1 -> \frac{1}
+  # \frac a -> \frac{a}
+  # \frac \lambda -> \frac{\lambda}
+  s/\\frac(?|${space}+\{($pat_n)\}|${space}*(\d)|${space}+(\w)|${space}*(\\[a-zA-Z]+))/\\frac\{$1\}/g;
+  # same as above for the second argument of frac
+  s/\\frac(\{$pat_n\})(?|${space}*\{($pat_n)\}|${space}*(\d)|${space}+(\w)|${space}*(\\[a-zA-Z]+))/\\frac$1\{$2\}/g;
 }
 
 # preprocess($string, ..)
@@ -2309,7 +2340,7 @@
 # carry out the following pre-processing steps for all arguments:
 # 1. Remove leading white-space
 #    Change \{ to \QLEFTBRACE and \} to \QRIGHTBRACE and \& to \AMPERSAND
-# #.   Change {,} in comments to \CLEFTBRACE, \CRIGHTBRACE
+# #.   Change {,},\frac in comments to \CLEFTBRACE, \CRIGHTBRACE, \CFRAC
 # 2. mark all first empty line (in block of several) with \PAR tokens
 # 3. Convert all '\%' into '\PERCENTAGE ' and all '\$' into \DOLLAR to make parsing regular expressions easier
 # 4. Convert all \verb|some verbatim text| commands (where | can be an arbitrary character)
@@ -2345,9 +2376,11 @@
     s/(?<!\\)\\\{/\\QLEFTBRACE /sg;
     s/(?<!\\)\\\}/\\QRIGHTBRACE /sg;
     s/(?<!\\)\\&/\\AMPERSAND /sg;
-# replace {,} in comments with \\CLEFTBRACE,\\CRIGHTBRACE
+# replace {,}, \frac in comments with \\CLEFTBRACE,\\CRIGHTBRACE, CFRAC to protect from special treatment
     1 while s/((?<!\\)%.*)\{(.*)$/$1\\CLEFTBRACE $2/mg ;
     1 while s/((?<!\\)%.*)\}(.*)$/$1\\CRIGHTBRACE $2/mg ;
+    1 while s/((?<!\\)%.*)\\frac(.*)$/$1\\CFRAC $2/mg ;
+
     s/(?<!\\)\\%/\\PERCENTAGE /g ;  # (?<! is negative lookbehind assertion to prevent \\% from being converted
     s/(?<!\\)\\\$/\\DOLLAR /g ;  # (?<! is negative lookbehind assertion to prevent \\$ from being converted
     s/\\begin\{($VERBATIMENV)\}(.*?)\\end\{\1\}/"\\${1}{". tohash(\%verbhash,"${2}") . "}"/esg;
@@ -2411,7 +2444,7 @@
 # remove DIFVRB comments but leave changed lines marked 
 sub reverselinecomment {
   my ($environment, $verbatimtext)=@_;
-  ###print STDERR "OLD VERBATIMTEXT: |$verbatimtext|\n";
+  ### print STDERR "DEBUG REVERSELINECOMMENT input: $environment,|$verbatimtext|\n" if $debug;
   # remove markup added by latexdiff
   # (this should occur only if the type of verbatim environment was changed)
   # (note that this destroys some information in old file)
@@ -2446,7 +2479,7 @@
   } else {
     $verbatimtext = "\\begin{${environment}}${verbatimtext}\\end{${environment}}"
   }
-  ###print STDERR "NEW VERBATIMTEXT: |$verbatimtext|\n";
+  ### print STDERR "DEBUG REVERSELINECOMMENT output: |$verbatimtext|\n" if $debug;
   return($verbatimtext);
 }
 
@@ -2488,6 +2521,14 @@
   return $retstr;
 }
 
+# stripdelcmpopen(string)
+# return string with $DELCMDOPEN removed
+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
@@ -2726,10 +2767,15 @@
       ###  $delblock =~ s/\\DIFverb\{/\\DIFDIFdelverb\{/g;
       ###  $delblock =~ s/\\DIFlstinline/\\DIFDIFdellstinline/g;
       ###}
-      # Mark deleted verbose commands
+      # Mark deleted verbatim 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;
+        ###$delblock =~ s/(${DELCMDOPEN}.*)\\($CUSTOMDIFCMD)/$1${DELCMDCLOSE}\\DEL$2/gm;
+        # ($1 ? "${DELCMDOPEN}$1${DELCMDCLOSE}":"") : only add the DELCMDOPEN / DELCMDCLOSE pair if there are actually any commands in between, otherwise this is redundant
+	$delblock    =~ s/${DELCMDOPEN}(.*?)\\($CUSTOMDIFCMD)((?:\[${brat_n}\])*?(?:\s*\{${pat_n}\})*)/($1 ? "${DELCMDOPEN}$1${DELCMDCLOSE}":"") ."\\DEL$2". stripdelcmdopen($3)/egs;
+        # if there is a sequence of several commands in the same row only the first will be converted due to the need to be connected to the DELCMDOPEN. To mop these up, just add the DEL to the front of any remaining cmd's in the deleted block
+        $delblock =~ s/\\($CUSTOMDIFCMD)/\\DEL$1/g;     # this will also convert comments but I guess it does not matter much
       }
 
       #     splice in modified delblock
@@ -2736,7 +2782,6 @@
       substr($_,$begin,$len)=$delblock;
       pos = $begin + length($delblock);
     }
-    ###writedebugfile($_,'postprocess');
 
     ### print STDERR "<<<$_>>>\n" if $debug;
 
@@ -2766,7 +2811,7 @@
       $addblock =~ s/\\DIFverb/\\DIFDIFaddverb/g;
       $addblock =~ s/\\DIFlstinline/\\DIFDIFaddlstinline/g;
       if( $CUSTOMDIFCMD ) {
-        $addblock =~ s/\\($CUSTOMDIFCMD)/\\ADD$1/g;
+        $addblock =~ s/\\($CUSTOMDIFCMD)/\\ADD$1/g;     # this will also convert comments but I guess it does not matter much
       }
       # markup the optional arguments of \item
       $addblock =~ s/(\\$ITEMCMD$extraspace(?:<$abrat0>)?$extraspace)\[($brat_n)\]/
@@ -2876,10 +2921,22 @@
     # remove empty DIFCMD < lines
     s/^\Q${DELCMDOPEN}\E\n//msg;
 
-    # Expand hashes of verb and verbatim environments (note negative look behind assertion to not leak out of DIFDELCMD comments
+    # Expand hashes of verb and verbatim environments 
     s/${DELCMDOPEN}\\($VERBATIMENV)\{([-\d]*?)\}/"${DELCMDOPEN}\\begin{${1}}".fromhash(\%verbhash,$2,$DELCMDOPEN)."${DELCMDOPEN}\\end{${1}}"/esg;
-    # revert changes to verbatim environments for line diffs (and add code to mark up changes)
-    s/(?<!$DELCMDOPEN)\\begin\{($VERBATIMLINEENV)\}(.*?)\\end\{\1\}/"". reverselinecomment($1, $2) .""/esg;
+    # revert changes to verbatim environments for line diffs (and add code to mark up changes) (note negative look behind assertions to not leak out of DIFDELCMD comments)
+    # Example:
+    # < \begin{verbatim}
+    # < %DIF < DIFVRB old verbatim line
+    # < %DIF > DIFVRB new verbatim line
+    # < \end{verbatim}
+    # ---
+    # > \DIFmodbegin
+    # > \begin{verbatim}[alsolanguage=DIFcode]
+    # > %DIF < old verbatim line
+    # > %DIF > new verbatim line
+    # > \end{verbatim}
+    # > \DIFmodend
+    s/(?<!$DELCMDOPEN)\\begin\{($VERBATIMLINEENV)\}(.*?)(?<!$DELCMDOPEN)\\end\{\1\}/"". reverselinecomment($1, $2) .""/esg;
 #    # we do the same for deleted environments but additionally reinstate the framing commands
 #   s/$DELCMDOPEN\\begin\{($VERBATIMLINEENV)\}$extraspace(?:\[$brat0\])?$DELCMDCLOSE(.*?)$DELCMDOPEN\\end\{\1\}$DELCMDCLOSE/"\\begin{$1}". reverselinecomment($2) . "\\end{$1}"/esg;
 ##    s/$DELCMDOPEN\\begin\{($VERBATIMLINEENV)\}($extraspace(?:\[$brat0\])?\s*)(?:\n|$DELCMDOPEN)*$DELCMDCLOSE((?:\%$DELCOMMENT$VERBCOMMENT.*?\n)*)($DELCMDOPEN\\end\{\1\}(?:\n|\s|$DELCMDOPEN)*$DELCMDCLOSE)/"SUBSTITUTION: \\begin{$1}$2 INTERIOR: |$3| END: |$4|"/esg;
@@ -2898,6 +2955,7 @@
             . " $AUXCMD\n"  # close the auxiliary environment
             . $5               # and again leave the original deleted closing environment as is
       /esgx;  # Modifiers of substitution command
+    writedebugfile($_,'postprocess2');
     # where changes have occurred in verbatim environment, change verbatim to DIFverbatim to allow mark-up
     # (I use the presence of optional paramater to verbatim environment as the marker - normal verbatim 
     # environment does not take optional arguments)
@@ -2905,7 +2963,6 @@
 
     s/\\($VERBATIMENV)\{([-\d]*?)\}/"\\begin{${1}}".fromhash(\%verbhash,$2)."\\end{${1}}"/esg;
 
-
     # remove all \PAR tokens (taking care to properly keep commented out PAR's
     # from introducing uncommented newlines - next line)
     s/(%DIF < )([^\n]*?)\\PAR\n/$1$2\n$1\n/sg;
@@ -2951,6 +3008,7 @@
     1 while s/\\SQRT(\s*\{($pat_n)\})/\\sqrt$1/g ;
     1 while s/\\SQRTNB\{(\s*$pat0)\}/\\sqrt$1/g ;
  
+    1 while s/(%.*)\\CFRAC (.*)$/$1\\frac$2/mg ;
     1 while s/(%.*)\\CRIGHTBRACE (.*)$/$1\}$2/mg ;
     1 while s/(%.*)\\CLEFTBRACE (.*)$/$1\{$2/mg ;
 
@@ -2959,7 +3017,7 @@
     s/\\QLEFTBRACE /\\\{/sg;
     s/\\QRIGHTBRACE /\\\}/sg;
     s/\\AMPERSAND /\\&/sg;
-    # Highligh added inline verbatim commands if possible
+    # Highlight added inline verbatim commands if possible
     if ( $latexdiffpreamble =~ /\\RequirePackage(?:\[$brat_n\])?\{color\}/ )   { 
       # wrap added verb commands with color commands
       s/\\DIFDIFadd((?:verb\*?|lstinline(?:\[$brat_n\])?)\{[-\d]*?\}[\s\n]*)/\{\\color{blue}$AUXCMD\n\\DIF$1%\n\}$AUXCMD\n/sg;
@@ -3019,7 +3077,7 @@
   my ($line,$cmd,$optarg,$arg,$optargnew,$optargold,$optargdiff,$argold,$argnew,$argdiff,$auxline);
 
   my $warnmsgdetail = <<EOF ;
-     This should not occur for standard styles, but can occur for some specifiy styles, document classes,
+     This should not occur for standard styles, but can occur for some specific styles, document classes,
      e.g. journal house styles.
      Workaround: Use --replace-context2cmd option to specifically set those commands, which are not repeated.
 EOF
@@ -3285,7 +3343,7 @@
 
 
 sub usage {
-  die <<"EOF"; 
+  print STDERR <<"EOF"; 
 Usage: $0 [options] old.tex new.tex > diff.tex
 
 Compares two latex files and writes tex code to stdout, which has the same format as new.tex but 
@@ -3479,6 +3537,9 @@
                                 variable SCALEDELGRAPHICS to set size of deleted figures.
                       Note that changes to the optional parameters will make the figure appear as changed 
                       to latexdiff, and this figure will thus be highlighted.
+                      In some circumstances "Misplaced \\noalign" errors can occur if there are certain types
+                      of changes in tables. In this case please use option --graphics-markup=none as a 
+                      work-around. 
 
 --disable-citation-markup 
 --disable-auto-mbox    Suppress citation markup and markup of other vulnerable commands in styles 
@@ -3490,7 +3551,7 @@
                        with \\mbox command, i.e. use default behaviour for ulem package for other packages
                        (the two options are identical and are simply aliases)
 
-Miscelleneous options
+Miscellaneous options
 
 --label=label
 -L label               Sets the labels used to describe the old and new files.  The first use
@@ -3521,8 +3582,11 @@
 --ignore-filter-stderr When running with --filter-script, STDERR from the script may cause readability issues.
                        Turn this flag on to ignore STDERR from the filter script.
 
+--driver=type          Choose driver for changebar package (only relevant for styles using
+                       changebar: CCHANGEBAR CFONTCHBAR CULINECHBAR CHANGEBAR). Possible
+                       drivers are listed in changebar manual, e.g. pdftex,dvips,dvitops
+                       [Default: pdftex]
 
-
 --help
 -h                     Show this help text.
 
@@ -3542,6 +3606,7 @@
 --no-links             Suppress generation of hyperreferences, used for minimal diffs 
                        (option --only-changes of latexdiff-vc).
 EOF
+  exit 0; 
 }
 
 =head1 NAME
@@ -4013,8 +4078,13 @@
 variable SCALEDELGRAPHICS to set size of deleted figures.
 
 Note that changes to the optional parameters will make the figure appear as changed 
-to latexdiff, and this figure will thus be highlighted
+to latexdiff, and this figure will thus be highlighted.
 
+In some circumstances "Misplaced \noalign" error can occur if there are certain types
+of changes in tables. In this case please use C<--graphics-markup=none> as a 
+work-around. 
+
+
 =item B<--disable-citation-markup> or B<--disable-auto-mbox>
 
 Suppress citation markup and markup of other vulnerable commands in styles 
@@ -4043,7 +4113,7 @@
 Choose driver for changebar package (only relevant for styles using
    changebar: CCHANGEBAR CFONTCHBAR CULINECHBAR CHANGEBAR). Possible
 drivers are listed in changebar manual, e.g. pdftex,dvips,dvitops
-  [Default: dvips]
+  [Default: pdftex]
 
 =item B<--ignore-warnings>
 
@@ -4438,8 +4508,8 @@
 
 =head1 AUTHOR
 
-Version 1.3.0
-Copyright (C) 2004-2018 Frederik Tilmann
+Version 1.3.2
+Copyright (C) 2004-2021 Frederik Tilmann
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License Version 3
@@ -4465,6 +4535,7 @@
 mbox
 pageref
 ref
+eqref
 symbol
 raisebox
 rule
@@ -4765,6 +4836,7 @@
 %%BEGIN ARRENV CONFIG
 aligned
 gathered
+multlined
 array
 [pbvBV]?matrix
 smallmatrix
@@ -4834,7 +4906,7 @@
 %DIF END FONTSTRIKE PREAMBLE
 
 %DIF CCHANGEBAR PREAMBLE
-\RequirePackage[dvips]{changebar}
+\RequirePackage[pdftex]{changebar}
 \RequirePackage{color}\definecolor{RED}{rgb}{1,0,0}\definecolor{BLUE}{rgb}{0,0,1}
 \providecommand{\DIFadd}[1]{\protect\cbstart{\protect\color{blue}#1}\protect\cbend}
 \providecommand{\DIFdel}[1]{\protect\cbdelete{\protect\color{red}#1}\protect\cbdelete}
@@ -4841,7 +4913,7 @@
 %DIF END CCHANGEBAR PREAMBLE
 
 %DIF CFONTCHBAR PREAMBLE
-\RequirePackage[dvips]{changebar}
+\RequirePackage[pdftex]{changebar}
 \RequirePackage{color}\definecolor{RED}{rgb}{1,0,0}\definecolor{BLUE}{rgb}{0,0,1}
 \providecommand{\DIFadd}[1]{\protect\cbstart{\protect\color{blue}\sf #1}\protect\cbend}
 \providecommand{\DIFdel}[1]{\protect\cbdelete{\protect\color{red}\scriptsize #1}\protect\cbdelete}
@@ -4849,7 +4921,7 @@
 
 %DIF CULINECHBAR PREAMBLE
 \RequirePackage[normalem]{ulem}
-\RequirePackage[dvips]{changebar}
+\RequirePackage[pdftex]{changebar}
 \RequirePackage{color}\definecolor{RED}{rgb}{1,0,0}\definecolor{BLUE}{rgb}{0,0,1}
 \providecommand{\DIFadd}[1]{\protect\cbstart{\protect\color{blue}\uwave{#1}}\protect\cbend}
 \providecommand{\DIFdel}[1]{\protect\cbdelete{\protect\color{red}\sout{#1}}\protect\cbdelete}
@@ -4856,7 +4928,7 @@
 %DIF END CULINECHBAR PREAMBLE
 
 %DIF CHANGEBAR PREAMBLE
-\RequirePackage[dvips]{changebar}
+\RequirePackage[pdftex]{changebar}
 \providecommand{\DIFadd}[1]{\protect\cbstart{#1}\protect\cbend}
 \providecommand{\DIFdel}[1]{\protect\cbdelete}
 %DIF END CHANGEBAR PREAMBLE
@@ -5103,7 +5175,6 @@
 
 %DIF LISTINGS PREAMBLE
 \RequirePackage{listings}
-\RequirePackage{color}
 \lstdefinelanguage{DIFcode}{
   % note that the definitions in the following two lines are overwritten dependent on the markup type selected %DIFCODE TEMPLATE
   morecomment=[il]{\%DIF\ <\ },          %DIFCODE TEMPLATE
@@ -5119,6 +5190,24 @@
 \lstnewenvironment{DIFverbatim*}{\lstset{style=DIFverbatimstyle,showspaces=true}}{}
 %DIF END LISTINGS PREAMBLE
 
+%DIF COLORLISTINGS PREAMBLE
+\RequirePackage{listings}
+\RequirePackage{color}
+\lstdefinelanguage{DIFcode}{
+  % note that the definitions in the following two lines are overwritten dependent on the markup type selected %DIFCODE TEMPLATE
+  morecomment=[il]{\%DIF\ <\ },          %DIFCODE TEMPLATE
+  moredelim=[il][\bfseries]{\%DIF\ >\ }  %DIFCODE TEMPLATE
+}
+\lstdefinestyle{DIFverbatimstyle}{
+	language=DIFcode,
+	basicstyle=\ttfamily,
+	columns=fullflexible,
+	keepspaces=true
+}
+\lstnewenvironment{DIFverbatim}{\lstset{style=DIFverbatimstyle}}{}
+\lstnewenvironment{DIFverbatim*}{\lstset{style=DIFverbatimstyle,showspaces=true}}{}
+%DIF END COLORLISTINGS PREAMBLE
+
 %DIF DIFCODE_UNDERLINE
   moredelim=[il][\color{red}\sout]{\%DIF\ <\ },
   moredelim=[il][\color{blue}\uwave]{\%DIF\ >\ }

Modified: trunk/Master/texmf-dist/doc/support/latexdiff/latexdiff-fast
===================================================================
--- trunk/Master/texmf-dist/doc/support/latexdiff/latexdiff-fast	2021-12-28 22:51:15 UTC (rev 61433)
+++ trunk/Master/texmf-dist/doc/support/latexdiff/latexdiff-fast	2021-12-28 22:52:08 UTC (rev 61434)
@@ -22,7 +22,23 @@
 #
 # Detailed usage information at the end of the file
 #
-
+#
+# Version 1.3.2
+# API adaptions:
+#  - latexdiff now completes with exit code 0 after --help or --version command (see issue #248)
+# New features / feature extensions
+#  - extend CUSTOMDIFCMD related postprocessing to deal properly with multiline commands, or a sequence of several commands in the same line (see github issue #204)
+#  - Support for additional macros from import package (\import, \inputfrom, \includefrom, \subimport,\subinputfrom, \subincludefrom). Provided by janniklasrose in PR #243 (fixes #239)
+#  - replace default driver dvips->pdftex
+# Bug fixes:
+#  - fix issue #206 affecting proper markup of text commands which are not safe cmd's at the same time and have multiple arguments
+#  - fix issue #210 by adding \eqref (amsmath package) to the list of safe commands
+#  - fix bug reported in issue #168 mangled verbatim line environment 
+#  - fix bug reported in issue #218 by replacing \hspace{0pt} after \mbox{..} auxiliary commands with \hskip0pt.
+#  - more ways to process \frac correctly with atomic arguments (committed by julianuu PR #246
+#  - fix a bug in biblatex mode, which prevented proper processing of modified \textcite (see: https://tex.stackexchange.com/questions/555157/latexdiff-and-biblatex-citation-commands)
+#  - -h string fix: add -driver option
+#
 # Version 1.3.1.1
 #  - remove spurious \n to fix error: Unknown regexp modifier "/n" at .../latexdiff line 1974, near "=~ " (see github issue #201)
 #
@@ -764,8 +780,8 @@
 
 
 my ($versionstring)=<<EOF ;
-This is LATEXDIFF 1.3.1.1 (Algorithm::Diff $Algorithm::Diff::VERSION, Perl $^V)
-  (c) 2004-2020 F J Tilmann
+This is LATEXDIFF 1.3.2 (Algorithm::Diff $Algorithm::Diff::VERSION, Perl $^V)
+  (c) 2004-2021 F J Tilmann
 EOF
 
 # Hash with defaults for configuration variables. These marked undef have default values constructed from list defined in the DATA block
@@ -822,7 +838,7 @@
 # my $MATHREPL='displaymath';  # Environment introducing deleted maths blocks
 # my $MATHARRENV='(?:eqnarray|align|alignat|gather|multline|flalign)[*]?' ;           # Environments turning on eqnarray math mode
 # my $MATHARRREPL='eqnarray*';  # Environment introducing deleted maths blocks
-# my $ARRENV='(?:aligned|gathered|array|[pbvBV]?matrix|smallmatrix|cases|split)'; # Environments making arrays in math mode.  The underlining style does not cope well with those - as a result in-text math environments are surrounded by \mbox{ } if any of these commands is used in an inline math block
+# my $ARRENV='(?:aligned|gathered|multlined|array|[pbvBV]?matrix|smallmatrix|cases|split)'; # Environments making arrays in math mode.  The underlining style does not cope well with those - as a result in-text math environments are surrounded by \mbox{ } if any of these commands is used in an inline math block
 # my $COUNTERCMD='(?:footnote|part|chapter|section|subsection|subsubsection|paragraph|subparagraph)';  # textcmds which are associated with a counter
 #                                         # If any of these commands occur in a deleted block
 #                                         # they will be succeeded by an \addtocounter{...}{-1}
@@ -1019,7 +1035,8 @@
 
 
 if ( $version ) {
-  die $versionstring ; 
+  print STDERR $versionstring ; 
+  exit 0;
 }
 
 print STDERR $versionstring if $verbose; 
@@ -1064,7 +1081,7 @@
 
 if ( defined($driver) ) {
   # for changebar only
-  $latexdiffpreamble=~s/\[dvips\]/[$driver]/sg;
+  $latexdiffpreamble=~s/\[pdftex\]/[$driver]/sg;
 }
 # setting up @SAFECMDLIST and @SAFECMDEXCL
 if (defined($replacesafe)) {
@@ -1295,7 +1312,9 @@
   my $predefinedcmdoptseq='(?:'.$predefinedcmdoptseq12.'|'.$predefinedcmdoptseq01.'|'.$predefinedbibitem.')';
 
   my $cmdleftright='\\\\(?:left|right|[Bb]igg?[lrm]?|middle)\s*(?:[<>()\[\]|\.]|\\\\(?:[|{}]|\w+))';
-  my $cmdoptseq='\\\\[\w\d@\*]+'.$extraspace.'(?:(?:<'.$abrat0.'>|\['.$brat_n.'\]|\{'. $pat_n . '\}|\(' . $coords .'\))'.$extraspace.')*';
+# standard $cmdoptseq (default: no intrevening spaces, controlled by extraspcae) - a final open parentheses is merged to the commend if it exists to deal properly with multi-argument text command
+  my $cmdoptseq='\\\\[\w\d@\*]+'.$extraspace.'(?:(?:<'.$abrat0.'>|\['.$brat_n.'\]|\{'. $pat_n . '\}|\(' . $coords .'\))'.$extraspace.')*\{?';
+# Handle tex \def macro: \def\MAKRONAME#1[#2]#3{DEFINITION}
   my $defseq='\\\\def\\\\[\w\d@\*]+(?:#\d+|\[#\d+\])+(?:\{'. $pat_n . '\})?';
   my $backslashnl='\\\\\n';
   my $oneletcmd='\\\\.\*?(?:\['.$brat_n.'\]|\{'. $pat_n . '\})*';
@@ -1514,6 +1533,9 @@
 # If listings is being used or can be found in the latexdiff search path, add to the preamble auxiliary code to enable line-by-line markup
 if ( defined($packages{"listings"}) or `kpsewhich listings.sty` ne "" ) {
   my @listingpreamble=extrapream("LISTINGS");
+  if ($latexdiffpreamble =~ /\\RequirePackage(?:\[$brat_n\])?\{color\}/ ) {
+    @listingpreamble=extrapream("COLORLISTINGS");
+  }
   my @listingDIFcode=();
   my $replaced;
   # note that in case user supplies preamblefile the type might not reflect well the 
@@ -1676,6 +1698,7 @@
 } elsif (defined $packages{"biblatex"}) {
   print STDERR "biblatex package detected.\n" if $verbose ;
   $citpat='(?:[cC]ites?|(?:[pP]aren|foot|[Tt]ext|[sS]mart|super)cites?\*?|footnotecitetex)';
+  push(@TEXTCMDEXCL, qr/^textcite$/);
 } else {
   # citation command pattern for all other citation schemes
   $citpat='(?:cite\w*|nocite)';
@@ -1952,6 +1975,9 @@
     my $should_be_safe = $2;
     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/^(?:ADD|DEL)?${CUSTOMDIFCMD}$/);
+    ###print STDERR "DEBUG: really test it. \n";
     # test if all latex commands inside it are safe
     $success = 1;
     if ($should_be_safe =~ m/\\\\/) {
@@ -1994,6 +2020,7 @@
 # expands \input and \include commands within text
 # expands \bibliography command with corresponding bbl file if available
 # expands \subfile command (from subfiles package - not part of standard text distribution)
+# expands \import etc commands (from import package - not part of standard text distribution)
 # preamble is scanned for includeonly commands
 # encoding is the encoding
 sub flatten {
@@ -2021,15 +2048,16 @@
   # Run through filter, to let filterscript have a pass if it was set
   $text = filter($text);
 
-  # Recursively replace \\import and \\subimport files
-  $text =~ s/(^(?:[^%\n]|\\%)*)(\\subimport\{(.*?)\}|\\import\{(.*?)\})(?:[\s]*)\{(.*?)\}/{
+  # Recursively replace \\import, \\subimport, and related import commands
+  $text =~ s/(^(?:[^%\n]|\\%)*)(\\(sub)?(?:import|inputfrom|includefrom))\{(.*?)\}(?:[\s]*)\{(.*?)\}/{
+          #  (--------1-------)(--(=3=)-------------2-------------------)  (-4-)             (-5-)
           # $1 is begline
-          # $3 is directory if subimport
-          # $4 is directory if import
+          # $2 is the import macro name
+          # $3 is (optional) prefix "sub"
+          # $4 is directory
           # $5 is filename
           $begline = (defined($1)? $1 : "");
-          $subdir = $3 if defined($3);
-          $subdir = $4 if defined($4);
+          $subdir = $4;
           $fname = $5;
           $fname .= ".tex" unless $fname =~ m|\.\w{3,4}$|;
           print STDERR "DEBUG begline:", $begline, "\n" if $debug;
@@ -2044,12 +2072,13 @@
           print STDERR "importing importfilepath:", $importfilepath,"\n" if $verbose;
           if ( -f $importfilepath ) {
               # If file exists, replace input or include command with expanded input
+              #TODO: need remove_endinput & newpage similar to other replacements inside flatten
               $replacement=flatten(read_file_with_encoding($importfilepath, $encoding), $preamble,$importfilepath,$encoding) or die "Could not open file ",$fullfile,": $!";
           } else {
               # if file does not exist, do not expand include or input command (do not warn if fname contains #[0-9] as it is then likely part of a command definition
               # and is not meant to be expanded directly 
               print STDERR "WARNING: Could not find included file ",$importfilepath,". I will continue but not expand |$2|\n";
-              $replacement=(defined($3)? "\\subimport" : "\\import");
+              $replacement = $2;
               $replacement .= "{$subdir}{$fname} % Processed";
           }
           "$begline$replacement";
@@ -2719,9 +2748,10 @@
 
 
 # split this block to split sequences joined in pass1
+  ### print STDERR "DEBUG: marktags before splitlatex blocksplit ",join("|",@$block),"\n" if $debug;
   @$block=splitlatex(join "",@$block);
   ### print STDERR "DEBUG: marktags $openmark,$closemark,$open,$close,$opencmd,$closecmd,$comment\n" if $debug;
-  ### print STDERR "DEBUG: marktags blocksplit ",join("|",@$block),"\n" if $debug;
+  print STDERR "DEBUG: after splitlatex ",join("|",@$block),"\n" if $debug;
 
   # we redefine locally $extraspace (shadowing the global definition) to capture command sequences with intervening spaces no matter what the global setting
   # this is done so we can capture those commands with a predefined number of arguments without having to introduce them again explicitly here
@@ -2777,6 +2807,7 @@
         #            $2 (the command) is in context2, just treat it as an ordinary command (i.e. comment it open with $opencmd)
         # Because we do not want to disable this command
 	# here we do not use $opencmd and $closecmd($opencmd is empty) 
+	print STDERR "DEBUG: Detected text |$word| but not safe command \$2: $2 \$3: $3\n." if $debug;
 	if ($cmd==1) {
 	  push (@$retval,$closecmd) ;
 	} elsif ($cmd==0) { 
@@ -2835,7 +2866,7 @@
       if ( $word =~ /^\\(?!\()(\\|[`'^"~=.]|[\w*@]+)(.*?)(\s*)$/s &&  iscmd($1,\@MBOXCMDLIST,\@MBOXCMDEXCL)) {
 	# $word is a safe command in MBOXCMDLIST
 	###print STDERR "DEBUG Mboxsafecmd detected:$word:\n" if $debug ;
-	push(@$retval,"\\mbox{$AUXCMD\n\\" . $1 . $2 . $3 ."}\\hspace{0pt}$AUXCMD\n" );
+	push(@$retval,"\\mbox{$AUXCMD\n\\" . $1 . $2 . $3 ."}\\hskip0pt$AUXCMD\n" );
       } else {
 	# $word is a normal word or a safe command (not in MBOXCMDLIST)
 	push (@$retval,$word);
@@ -2855,15 +2886,15 @@
   # some special magic for common usage of frac, which does not conform to the latexdiff requirements but can be made to fit
   # note that this is a rare exception to the general rule that the new tex can be reconstructed from the diff file
 
-  # \frac12 -> \frac{1}{2}
-  s/\\frac(\d)(\w)/\\frac\{$1\}\{$2\}/g;
-
-  # \frac1{2b} -> \frac{1}{2b}
-  s/\\frac(\d)/\\frac\{$1\}/g;
-
-  # delete space and comment characters between \frac arguments
-#  s/\\frac(?:\s*?%[^\n]*?)*?(\{$pat_n\})\s*(\{$pat_n\})/\\frac$1$2/g;
-  s/\\frac(?:\s|%[^\n]*?)*(\{$pat_n\})(?:\s|%[^\n]*?)*(\{$pat_n\})/\\frac$1$2/g;
+  # regex that matches space and comment characters
+  my $space = qr/\s|%[^\n]*?/;
+  # \frac {abc} -> \frac{abc}
+  # \frac1 -> \frac{1}
+  # \frac a -> \frac{a}
+  # \frac \lambda -> \frac{\lambda}
+  s/\\frac(?|${space}+\{($pat_n)\}|${space}*(\d)|${space}+(\w)|${space}*(\\[a-zA-Z]+))/\\frac\{$1\}/g;
+  # same as above for the second argument of frac
+  s/\\frac(\{$pat_n\})(?|${space}*\{($pat_n)\}|${space}*(\d)|${space}+(\w)|${space}*(\\[a-zA-Z]+))/\\frac$1\{$2\}/g;
 }
 
 # preprocess($string, ..)
@@ -2870,7 +2901,7 @@
 # carry out the following pre-processing steps for all arguments:
 # 1. Remove leading white-space
 #    Change \{ to \QLEFTBRACE and \} to \QRIGHTBRACE and \& to \AMPERSAND
-# #.   Change {,} in comments to \CLEFTBRACE, \CRIGHTBRACE
+# #.   Change {,},\frac in comments to \CLEFTBRACE, \CRIGHTBRACE, \CFRAC
 # 2. mark all first empty line (in block of several) with \PAR tokens
 # 3. Convert all '\%' into '\PERCENTAGE ' and all '\$' into \DOLLAR to make parsing regular expressions easier
 # 4. Convert all \verb|some verbatim text| commands (where | can be an arbitrary character)
@@ -2906,9 +2937,11 @@
     s/(?<!\\)\\\{/\\QLEFTBRACE /sg;
     s/(?<!\\)\\\}/\\QRIGHTBRACE /sg;
     s/(?<!\\)\\&/\\AMPERSAND /sg;
-# replace {,} in comments with \\CLEFTBRACE,\\CRIGHTBRACE
+# replace {,}, \frac in comments with \\CLEFTBRACE,\\CRIGHTBRACE, CFRAC to protect from special treatment
     1 while s/((?<!\\)%.*)\{(.*)$/$1\\CLEFTBRACE $2/mg ;
     1 while s/((?<!\\)%.*)\}(.*)$/$1\\CRIGHTBRACE $2/mg ;
+    1 while s/((?<!\\)%.*)\\frac(.*)$/$1\\CFRAC $2/mg ;
+
     s/(?<!\\)\\%/\\PERCENTAGE /g ;  # (?<! is negative lookbehind assertion to prevent \\% from being converted
     s/(?<!\\)\\\$/\\DOLLAR /g ;  # (?<! is negative lookbehind assertion to prevent \\$ from being converted
     s/\\begin\{($VERBATIMENV)\}(.*?)\\end\{\1\}/"\\${1}{". tohash(\%verbhash,"${2}") . "}"/esg;
@@ -2972,7 +3005,7 @@
 # remove DIFVRB comments but leave changed lines marked 
 sub reverselinecomment {
   my ($environment, $verbatimtext)=@_;
-  ###print STDERR "OLD VERBATIMTEXT: |$verbatimtext|\n";
+  ### print STDERR "DEBUG REVERSELINECOMMENT input: $environment,|$verbatimtext|\n" if $debug;
   # remove markup added by latexdiff
   # (this should occur only if the type of verbatim environment was changed)
   # (note that this destroys some information in old file)
@@ -3007,7 +3040,7 @@
   } else {
     $verbatimtext = "\\begin{${environment}}${verbatimtext}\\end{${environment}}"
   }
-  ###print STDERR "NEW VERBATIMTEXT: |$verbatimtext|\n";
+  ### print STDERR "DEBUG REVERSELINECOMMENT output: |$verbatimtext|\n" if $debug;
   return($verbatimtext);
 }
 
@@ -3049,6 +3082,14 @@
   return $retstr;
 }
 
+# stripdelcmpopen(string)
+# return string with $DELCMDOPEN removed
+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
@@ -3287,10 +3328,15 @@
       ###  $delblock =~ s/\\DIFverb\{/\\DIFDIFdelverb\{/g;
       ###  $delblock =~ s/\\DIFlstinline/\\DIFDIFdellstinline/g;
       ###}
-      # Mark deleted verbose commands
+      # Mark deleted verbatim 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;
+        ###$delblock =~ s/(${DELCMDOPEN}.*)\\($CUSTOMDIFCMD)/$1${DELCMDCLOSE}\\DEL$2/gm;
+        # ($1 ? "${DELCMDOPEN}$1${DELCMDCLOSE}":"") : only add the DELCMDOPEN / DELCMDCLOSE pair if there are actually any commands in between, otherwise this is redundant
+	$delblock    =~ s/${DELCMDOPEN}(.*?)\\($CUSTOMDIFCMD)((?:\[${brat_n}\])*?(?:\s*\{${pat_n}\})*)/($1 ? "${DELCMDOPEN}$1${DELCMDCLOSE}":"") ."\\DEL$2". stripdelcmdopen($3)/egs;
+        # if there is a sequence of several commands in the same row only the first will be converted due to the need to be connected to the DELCMDOPEN. To mop these up, just add the DEL to the front of any remaining cmd's in the deleted block
+        $delblock =~ s/\\($CUSTOMDIFCMD)/\\DEL$1/g;     # this will also convert comments but I guess it does not matter much
       }
 
       #     splice in modified delblock
@@ -3297,7 +3343,6 @@
       substr($_,$begin,$len)=$delblock;
       pos = $begin + length($delblock);
     }
-    ###writedebugfile($_,'postprocess');
 
     ### print STDERR "<<<$_>>>\n" if $debug;
 
@@ -3327,7 +3372,7 @@
       $addblock =~ s/\\DIFverb/\\DIFDIFaddverb/g;
       $addblock =~ s/\\DIFlstinline/\\DIFDIFaddlstinline/g;
       if( $CUSTOMDIFCMD ) {
-        $addblock =~ s/\\($CUSTOMDIFCMD)/\\ADD$1/g;
+        $addblock =~ s/\\($CUSTOMDIFCMD)/\\ADD$1/g;     # this will also convert comments but I guess it does not matter much
       }
       # markup the optional arguments of \item
       $addblock =~ s/(\\$ITEMCMD$extraspace(?:<$abrat0>)?$extraspace)\[($brat_n)\]/
@@ -3437,10 +3482,22 @@
     # remove empty DIFCMD < lines
     s/^\Q${DELCMDOPEN}\E\n//msg;
 
-    # Expand hashes of verb and verbatim environments (note negative look behind assertion to not leak out of DIFDELCMD comments
+    # Expand hashes of verb and verbatim environments 
     s/${DELCMDOPEN}\\($VERBATIMENV)\{([-\d]*?)\}/"${DELCMDOPEN}\\begin{${1}}".fromhash(\%verbhash,$2,$DELCMDOPEN)."${DELCMDOPEN}\\end{${1}}"/esg;
-    # revert changes to verbatim environments for line diffs (and add code to mark up changes)
-    s/(?<!$DELCMDOPEN)\\begin\{($VERBATIMLINEENV)\}(.*?)\\end\{\1\}/"". reverselinecomment($1, $2) .""/esg;
+    # revert changes to verbatim environments for line diffs (and add code to mark up changes) (note negative look behind assertions to not leak out of DIFDELCMD comments)
+    # Example:
+    # < \begin{verbatim}
+    # < %DIF < DIFVRB old verbatim line
+    # < %DIF > DIFVRB new verbatim line
+    # < \end{verbatim}
+    # ---
+    # > \DIFmodbegin
+    # > \begin{verbatim}[alsolanguage=DIFcode]
+    # > %DIF < old verbatim line
+    # > %DIF > new verbatim line
+    # > \end{verbatim}
+    # > \DIFmodend
+    s/(?<!$DELCMDOPEN)\\begin\{($VERBATIMLINEENV)\}(.*?)(?<!$DELCMDOPEN)\\end\{\1\}/"". reverselinecomment($1, $2) .""/esg;
 #    # we do the same for deleted environments but additionally reinstate the framing commands
 #   s/$DELCMDOPEN\\begin\{($VERBATIMLINEENV)\}$extraspace(?:\[$brat0\])?$DELCMDCLOSE(.*?)$DELCMDOPEN\\end\{\1\}$DELCMDCLOSE/"\\begin{$1}". reverselinecomment($2) . "\\end{$1}"/esg;
 ##    s/$DELCMDOPEN\\begin\{($VERBATIMLINEENV)\}($extraspace(?:\[$brat0\])?\s*)(?:\n|$DELCMDOPEN)*$DELCMDCLOSE((?:\%$DELCOMMENT$VERBCOMMENT.*?\n)*)($DELCMDOPEN\\end\{\1\}(?:\n|\s|$DELCMDOPEN)*$DELCMDCLOSE)/"SUBSTITUTION: \\begin{$1}$2 INTERIOR: |$3| END: |$4|"/esg;
@@ -3459,6 +3516,7 @@
             . " $AUXCMD\n"  # close the auxiliary environment
             . $5               # and again leave the original deleted closing environment as is
       /esgx;  # Modifiers of substitution command
+    writedebugfile($_,'postprocess2');
     # where changes have occurred in verbatim environment, change verbatim to DIFverbatim to allow mark-up
     # (I use the presence of optional paramater to verbatim environment as the marker - normal verbatim 
     # environment does not take optional arguments)
@@ -3466,7 +3524,6 @@
 
     s/\\($VERBATIMENV)\{([-\d]*?)\}/"\\begin{${1}}".fromhash(\%verbhash,$2)."\\end{${1}}"/esg;
 
-
     # remove all \PAR tokens (taking care to properly keep commented out PAR's
     # from introducing uncommented newlines - next line)
     s/(%DIF < )([^\n]*?)\\PAR\n/$1$2\n$1\n/sg;
@@ -3512,6 +3569,7 @@
     1 while s/\\SQRT(\s*\{($pat_n)\})/\\sqrt$1/g ;
     1 while s/\\SQRTNB\{(\s*$pat0)\}/\\sqrt$1/g ;
  
+    1 while s/(%.*)\\CFRAC (.*)$/$1\\frac$2/mg ;
     1 while s/(%.*)\\CRIGHTBRACE (.*)$/$1\}$2/mg ;
     1 while s/(%.*)\\CLEFTBRACE (.*)$/$1\{$2/mg ;
 
@@ -3520,7 +3578,7 @@
     s/\\QLEFTBRACE /\\\{/sg;
     s/\\QRIGHTBRACE /\\\}/sg;
     s/\\AMPERSAND /\\&/sg;
-    # Highligh added inline verbatim commands if possible
+    # Highlight added inline verbatim commands if possible
     if ( $latexdiffpreamble =~ /\\RequirePackage(?:\[$brat_n\])?\{color\}/ )   { 
       # wrap added verb commands with color commands
       s/\\DIFDIFadd((?:verb\*?|lstinline(?:\[$brat_n\])?)\{[-\d]*?\}[\s\n]*)/\{\\color{blue}$AUXCMD\n\\DIF$1%\n\}$AUXCMD\n/sg;
@@ -3580,7 +3638,7 @@
   my ($line,$cmd,$optarg,$arg,$optargnew,$optargold,$optargdiff,$argold,$argnew,$argdiff,$auxline);
 
   my $warnmsgdetail = <<EOF ;
-     This should not occur for standard styles, but can occur for some specifiy styles, document classes,
+     This should not occur for standard styles, but can occur for some specific styles, document classes,
      e.g. journal house styles.
      Workaround: Use --replace-context2cmd option to specifically set those commands, which are not repeated.
 EOF
@@ -3846,7 +3904,7 @@
 
 
 sub usage {
-  die <<"EOF"; 
+  print STDERR <<"EOF"; 
 Usage: $0 [options] old.tex new.tex > diff.tex
 
 Compares two latex files and writes tex code to stdout, which has the same format as new.tex but 
@@ -4040,6 +4098,9 @@
                                 variable SCALEDELGRAPHICS to set size of deleted figures.
                       Note that changes to the optional parameters will make the figure appear as changed 
                       to latexdiff, and this figure will thus be highlighted.
+                      In some circumstances "Misplaced \\noalign" errors can occur if there are certain types
+                      of changes in tables. In this case please use option --graphics-markup=none as a 
+                      work-around. 
 
 --disable-citation-markup 
 --disable-auto-mbox    Suppress citation markup and markup of other vulnerable commands in styles 
@@ -4051,7 +4112,7 @@
                        with \\mbox command, i.e. use default behaviour for ulem package for other packages
                        (the two options are identical and are simply aliases)
 
-Miscelleneous options
+Miscellaneous options
 
 --label=label
 -L label               Sets the labels used to describe the old and new files.  The first use
@@ -4082,8 +4143,11 @@
 --ignore-filter-stderr When running with --filter-script, STDERR from the script may cause readability issues.
                        Turn this flag on to ignore STDERR from the filter script.
 
+--driver=type          Choose driver for changebar package (only relevant for styles using
+                       changebar: CCHANGEBAR CFONTCHBAR CULINECHBAR CHANGEBAR). Possible
+                       drivers are listed in changebar manual, e.g. pdftex,dvips,dvitops
+                       [Default: pdftex]
 
-
 --help
 -h                     Show this help text.
 
@@ -4103,6 +4167,7 @@
 --no-links             Suppress generation of hyperreferences, used for minimal diffs 
                        (option --only-changes of latexdiff-vc).
 EOF
+  exit 0; 
 }
 
 =head1 NAME
@@ -4574,8 +4639,13 @@
 variable SCALEDELGRAPHICS to set size of deleted figures.
 
 Note that changes to the optional parameters will make the figure appear as changed 
-to latexdiff, and this figure will thus be highlighted
+to latexdiff, and this figure will thus be highlighted.
 
+In some circumstances "Misplaced \noalign" error can occur if there are certain types
+of changes in tables. In this case please use C<--graphics-markup=none> as a 
+work-around. 
+
+
 =item B<--disable-citation-markup> or B<--disable-auto-mbox>
 
 Suppress citation markup and markup of other vulnerable commands in styles 
@@ -4604,7 +4674,7 @@
 Choose driver for changebar package (only relevant for styles using
    changebar: CCHANGEBAR CFONTCHBAR CULINECHBAR CHANGEBAR). Possible
 drivers are listed in changebar manual, e.g. pdftex,dvips,dvitops
-  [Default: dvips]
+  [Default: pdftex]
 
 =item B<--ignore-warnings>
 
@@ -4999,8 +5069,8 @@
 
 =head1 AUTHOR
 
-Version 1.3.0
-Copyright (C) 2004-2018 Frederik Tilmann
+Version 1.3.2
+Copyright (C) 2004-2021 Frederik Tilmann
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License Version 3
@@ -5026,6 +5096,7 @@
 mbox
 pageref
 ref
+eqref
 symbol
 raisebox
 rule
@@ -5326,6 +5397,7 @@
 %%BEGIN ARRENV CONFIG
 aligned
 gathered
+multlined
 array
 [pbvBV]?matrix
 smallmatrix
@@ -5395,7 +5467,7 @@
 %DIF END FONTSTRIKE PREAMBLE
 
 %DIF CCHANGEBAR PREAMBLE
-\RequirePackage[dvips]{changebar}
+\RequirePackage[pdftex]{changebar}
 \RequirePackage{color}\definecolor{RED}{rgb}{1,0,0}\definecolor{BLUE}{rgb}{0,0,1}
 \providecommand{\DIFadd}[1]{\protect\cbstart{\protect\color{blue}#1}\protect\cbend}
 \providecommand{\DIFdel}[1]{\protect\cbdelete{\protect\color{red}#1}\protect\cbdelete}
@@ -5402,7 +5474,7 @@
 %DIF END CCHANGEBAR PREAMBLE
 
 %DIF CFONTCHBAR PREAMBLE
-\RequirePackage[dvips]{changebar}
+\RequirePackage[pdftex]{changebar}
 \RequirePackage{color}\definecolor{RED}{rgb}{1,0,0}\definecolor{BLUE}{rgb}{0,0,1}
 \providecommand{\DIFadd}[1]{\protect\cbstart{\protect\color{blue}\sf #1}\protect\cbend}
 \providecommand{\DIFdel}[1]{\protect\cbdelete{\protect\color{red}\scriptsize #1}\protect\cbdelete}
@@ -5410,7 +5482,7 @@
 
 %DIF CULINECHBAR PREAMBLE
 \RequirePackage[normalem]{ulem}
-\RequirePackage[dvips]{changebar}
+\RequirePackage[pdftex]{changebar}
 \RequirePackage{color}\definecolor{RED}{rgb}{1,0,0}\definecolor{BLUE}{rgb}{0,0,1}
 \providecommand{\DIFadd}[1]{\protect\cbstart{\protect\color{blue}\uwave{#1}}\protect\cbend}
 \providecommand{\DIFdel}[1]{\protect\cbdelete{\protect\color{red}\sout{#1}}\protect\cbdelete}
@@ -5417,7 +5489,7 @@
 %DIF END CULINECHBAR PREAMBLE
 
 %DIF CHANGEBAR PREAMBLE
-\RequirePackage[dvips]{changebar}
+\RequirePackage[pdftex]{changebar}
 \providecommand{\DIFadd}[1]{\protect\cbstart{#1}\protect\cbend}
 \providecommand{\DIFdel}[1]{\protect\cbdelete}
 %DIF END CHANGEBAR PREAMBLE
@@ -5664,7 +5736,6 @@
 
 %DIF LISTINGS PREAMBLE
 \RequirePackage{listings}
-\RequirePackage{color}
 \lstdefinelanguage{DIFcode}{
   % note that the definitions in the following two lines are overwritten dependent on the markup type selected %DIFCODE TEMPLATE
   morecomment=[il]{\%DIF\ <\ },          %DIFCODE TEMPLATE
@@ -5680,6 +5751,24 @@
 \lstnewenvironment{DIFverbatim*}{\lstset{style=DIFverbatimstyle,showspaces=true}}{}
 %DIF END LISTINGS PREAMBLE
 
+%DIF COLORLISTINGS PREAMBLE
+\RequirePackage{listings}
+\RequirePackage{color}
+\lstdefinelanguage{DIFcode}{
+  % note that the definitions in the following two lines are overwritten dependent on the markup type selected %DIFCODE TEMPLATE
+  morecomment=[il]{\%DIF\ <\ },          %DIFCODE TEMPLATE
+  moredelim=[il][\bfseries]{\%DIF\ >\ }  %DIFCODE TEMPLATE
+}
+\lstdefinestyle{DIFverbatimstyle}{
+	language=DIFcode,
+	basicstyle=\ttfamily,
+	columns=fullflexible,
+	keepspaces=true
+}
+\lstnewenvironment{DIFverbatim}{\lstset{style=DIFverbatimstyle}}{}
+\lstnewenvironment{DIFverbatim*}{\lstset{style=DIFverbatimstyle,showspaces=true}}{}
+%DIF END COLORLISTINGS PREAMBLE
+
 %DIF DIFCODE_UNDERLINE
   moredelim=[il][\color{red}\sout]{\%DIF\ <\ },
   moredelim=[il][\color{blue}\uwave]{\%DIF\ >\ }

Modified: trunk/Master/texmf-dist/scripts/latexdiff/latexdiff-vc.pl
===================================================================
--- trunk/Master/texmf-dist/scripts/latexdiff/latexdiff-vc.pl	2021-12-28 22:51:15 UTC (rev 61433)
+++ trunk/Master/texmf-dist/scripts/latexdiff/latexdiff-vc.pl	2021-12-28 22:52:08 UTC (rev 61434)
@@ -26,6 +26,13 @@
 # Detailed usage information at the end of the file
 #
 # TODO/IDEAS: - option to call external pre-processing codes
+# version 1.3.2:
+#    - bug fix: when setting config variables with the command lines it is now possible to use quotes to includes spaces in the value, e.g. "-c LATEX=pdflatex --shell-escape'
+#    - bug fix: --only-changes is not compatible with graphics markup. --graphics-markup=none is now set automatically
+#    - when --pdf or --postscript is select, then replace tildes in version names with underscores in output file (e.g. diffHEAD_1 instead of diff HEAD~1. This is necessary because pdflatex strips ~n strings at the end of the filename, when generating output file names
+
+# version 1.3.1:
+#    - bug fix, import File::Path explicitly as otherwise mkpath is not found
 # version 1.3.0 ((7 October 2018)
 #    - option --only-changes with hyperref will suppress hyperrefs (pull request jprotze)_
 #    - option --only-changes now moves (rather than copies) file with only changes 
@@ -66,13 +73,14 @@
 use File::Temp qw/tempdir/ ;
 use File::Basename qw/dirname/;
 use File::Copy;
+use File::Path;
 
 use strict ;
 use warnings ;
 
 my $versionstring=<<EOF ;
-This is LATEXDIFF-VC 1.3.1.1
-  (c) 2005-2020 F J Tilmann
+This is LATEXDIFF-VC 1.3.2
+  (c) 2005-2021 F J Tilmann
 EOF
 
 # output debug and intermediate files, set to 0 in final distribution
@@ -205,7 +213,8 @@
 
 $configlatexdiff="";
 foreach $assign ( @config ) {
-  $assign=~ m/\s*(\w*)\s*=\s*(\S*)\s*$/ or die "Illegal assignment $assign in configuration list (must be variable=value)";  
+    $assign=~ m/\s*(\w*)\s*=\s*(.*?)\s*$/ 
+      or die "Illegal assignment |$assign| in configuration list (must be variable=value)";  
   if ( defined($CFG{$1})) {
     # known latexdiff-vc option
     $CFG{$1}=$2;
@@ -342,7 +351,7 @@
 
 # impose ZLABEL subtype if --only-changes option
 if ( $onlychanges ) {
-  push @ldoptions, "-s", "ZLABEL","-f","IDENTICAL","--no-links" ;
+  push @ldoptions, "-s", "ZLABEL","-f","IDENTICAL","--no-links", "--graphics-markup=none" ;
 }
 
 if ( scalar(@revs) == 0 ) {
@@ -378,6 +387,12 @@
   $append = "-diff";
 }
 
+if ( defined($pdf) or defined($postscript) ) {
+  # when using options such as -r HEAD~1  the ~1 is ignored by pdflatex in generating output file names; this could
+  # be confusing and actually causes error to only-changes mode
+  $append =~ s/~/_/g ;
+}
+
 if ( defined ($dir) && ! $dir ) {
   # bare -d option => choose directory name
   ($dir=$append) =~ s/^-//;
@@ -532,7 +547,7 @@
       #print STDERR "Generated postscript file $ps\n";
     } elsif ( $run ) {
       if ( $onlychanges ) {
-	my @pages=findchangedpages("$diffbase.aux");
+	my @pages=compresspages(findchangedpages("$diffbase.aux"));
         my $gs = `which gs`;
         $gs =~ s/^\s+|\s+$//g;
         my $qpdf = `which qpdf`;
@@ -540,7 +555,7 @@
         my $pdftk = `which pdftk`;
         $pdftk =~ s/^\s+|\s+$//g;
         my $command;
-        if (-x $gs && `gs --version` >= 9.20) {
+        if (-x $gs && `$gs --version` >= 9.20) {
           $command="gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dSAFER -sPageList=" . join(",", @pages) . " -sOutputFile=\"$diffbase-changedpage.pdf\" \"$diffbase.pdf\"";
         } elsif (-x $pdftk) {
           $command="pdftk \"$diffbase.pdf\" cat " . join(" ", at pages) . " output \"$diffbase-changedpage.pdf\"";
@@ -588,6 +603,45 @@
   return(sort {$a <=> $b} keys(%pages));
 }
 
+# inspired by a python version posted at https://stackoverflow.com/a/54714846/8136338
+# compresspages(@pages)
+# @pages: sorted array of unique integers (pages)
+# return a list of pages and page ranges. 3 or more consecutive numbers are merged into a "begin-end" string
+#
+# example: join(",", compresspages([1,3,4,5,7,8])) -> join(",", [1,"3-5",7,8]) -> "1,3-5,7,8"
+sub compresspages {
+  my (@pages) = @_;
+  my @res;
+  my $begin=$pages[0];
+  my $end =$pages[0];
+  my $page;
+  foreach $page ( @pages ) {
+    next if ($page == $begin);
+    if ($page == $end+1) { # handle continuous pages
+      $end = $page;
+      next;
+    } elsif ($begin == $end) { # push single continuous page
+      push @res, $begin;
+      $begin = $end = $page;
+    } elsif ($begin + 1 == $end) { # push two continuous pages
+      push @res, $begin, $end;
+      $begin = $end = $page;
+    } else { # push multiple continuous pages
+      push @res, "$begin-$end";
+      $begin = $end = $page;
+    }
+  }
+  # Finally just check in the same manner for the end element
+  if ($begin == $end) {
+    push @res, $begin;
+  } elsif ($begin + 1 == $end) {
+    push @res, $begin, $end;
+  } else {
+    push @res, "$begin-$end";
+  }
+  return @res;
+}
+
 # checkout_dir(rev,dirname)
 # checks out revision rev and stores it in dirname
 # uses global variables: $vc, $rootdir
@@ -594,7 +648,7 @@
 sub checkout_dir {
   my ($rev,$dirname)=@_;
 
-  unless (-e $dirname) { mkdir $dirname or die "Cannot mkdir $dirname ." ;}
+  unless (-e $dirname) { mkpath([ $dirname ]) or die "Cannot mkdir $dirname ." ;}
   if ( $vc eq "SVN" ) {
     system("svn checkout -r $rev $rootdir $dirname")==0 or die "Something went wrong in executing:  svn checkout -r $rev $rootdir $dirname";
   } elsif ( $vc eq "GIT" ) {
@@ -717,7 +771,8 @@
 
 Post-process the output such that only pages with changes on them are displayed. This requires the use of subtype ZLABEL 
 in latexdiff, which will be set automatically, but any manually set -s option will be overruled (also requires zref package to 
-be installed). (note that this option must be combined with --ps or --pdf to make sense)
+be installed). This option also disables internal links (as implemented by hyperref package) and graphics markup.
+(note that this option must be combined with --ps or --pdf to make sense)
 
 =item B<--force>
 

Modified: trunk/Master/texmf-dist/scripts/latexdiff/latexdiff.pl
===================================================================
--- trunk/Master/texmf-dist/scripts/latexdiff/latexdiff.pl	2021-12-28 22:51:15 UTC (rev 61433)
+++ trunk/Master/texmf-dist/scripts/latexdiff/latexdiff.pl	2021-12-28 22:52:08 UTC (rev 61434)
@@ -22,7 +22,23 @@
 #
 # Detailed usage information at the end of the file
 #
-
+#
+# Version 1.3.2
+# API adaptions:
+#  - latexdiff now completes with exit code 0 after --help or --version command (see issue #248)
+# New features / feature extensions
+#  - extend CUSTOMDIFCMD related postprocessing to deal properly with multiline commands, or a sequence of several commands in the same line (see github issue #204)
+#  - Support for additional macros from import package (\import, \inputfrom, \includefrom, \subimport,\subinputfrom, \subincludefrom). Provided by janniklasrose in PR #243 (fixes #239)
+#  - replace default driver dvips->pdftex
+# Bug fixes:
+#  - fix issue #206 affecting proper markup of text commands which are not safe cmd's at the same time and have multiple arguments
+#  - fix issue #210 by adding \eqref (amsmath package) to the list of safe commands
+#  - fix bug reported in issue #168 mangled verbatim line environment 
+#  - fix bug reported in issue #218 by replacing \hspace{0pt} after \mbox{..} auxiliary commands with \hskip0pt.
+#  - more ways to process \frac correctly with atomic arguments (committed by julianuu PR #246
+#  - fix a bug in biblatex mode, which prevented proper processing of modified \textcite (see: https://tex.stackexchange.com/questions/555157/latexdiff-and-biblatex-citation-commands)
+#  - -h string fix: add -driver option
+#
 # Version 1.3.1.1
 #  - remove spurious \n to fix error: Unknown regexp modifier "/n" at .../latexdiff line 1974, near "=~ " (see github issue #201)
 #
@@ -660,8 +676,8 @@
 
 
 my ($versionstring)=<<EOF ;
-This is LATEXDIFF 1.3.1.1 (Algorithm::Diff $Algorithm::Diff::VERSION, Perl $^V)
-  (c) 2004-2020 F J Tilmann
+This is LATEXDIFF 1.3.2 (Algorithm::Diff $Algorithm::Diff::VERSION, Perl $^V)
+  (c) 2004-2021 F J Tilmann
 EOF
 
 # Hash with defaults for configuration variables. These marked undef have default values constructed from list defined in the DATA block
@@ -718,7 +734,7 @@
 # my $MATHREPL='displaymath';  # Environment introducing deleted maths blocks
 # my $MATHARRENV='(?:eqnarray|align|alignat|gather|multline|flalign)[*]?' ;           # Environments turning on eqnarray math mode
 # my $MATHARRREPL='eqnarray*';  # Environment introducing deleted maths blocks
-# my $ARRENV='(?:aligned|gathered|array|[pbvBV]?matrix|smallmatrix|cases|split)'; # Environments making arrays in math mode.  The underlining style does not cope well with those - as a result in-text math environments are surrounded by \mbox{ } if any of these commands is used in an inline math block
+# my $ARRENV='(?:aligned|gathered|multlined|array|[pbvBV]?matrix|smallmatrix|cases|split)'; # Environments making arrays in math mode.  The underlining style does not cope well with those - as a result in-text math environments are surrounded by \mbox{ } if any of these commands is used in an inline math block
 # my $COUNTERCMD='(?:footnote|part|chapter|section|subsection|subsubsection|paragraph|subparagraph)';  # textcmds which are associated with a counter
 #                                         # If any of these commands occur in a deleted block
 #                                         # they will be succeeded by an \addtocounter{...}{-1}
@@ -915,7 +931,8 @@
 
 
 if ( $version ) {
-  die $versionstring ; 
+  print STDERR $versionstring ; 
+  exit 0;
 }
 
 print STDERR $versionstring if $verbose; 
@@ -960,7 +977,7 @@
 
 if ( defined($driver) ) {
   # for changebar only
-  $latexdiffpreamble=~s/\[dvips\]/[$driver]/sg;
+  $latexdiffpreamble=~s/\[pdftex\]/[$driver]/sg;
 }
 # setting up @SAFECMDLIST and @SAFECMDEXCL
 if (defined($replacesafe)) {
@@ -1191,7 +1208,9 @@
   my $predefinedcmdoptseq='(?:'.$predefinedcmdoptseq12.'|'.$predefinedcmdoptseq01.'|'.$predefinedbibitem.')';
 
   my $cmdleftright='\\\\(?:left|right|[Bb]igg?[lrm]?|middle)\s*(?:[<>()\[\]|\.]|\\\\(?:[|{}]|\w+))';
-  my $cmdoptseq='\\\\[\w\d@\*]+'.$extraspace.'(?:(?:<'.$abrat0.'>|\['.$brat_n.'\]|\{'. $pat_n . '\}|\(' . $coords .'\))'.$extraspace.')*';
+# standard $cmdoptseq (default: no intrevening spaces, controlled by extraspcae) - a final open parentheses is merged to the commend if it exists to deal properly with multi-argument text command
+  my $cmdoptseq='\\\\[\w\d@\*]+'.$extraspace.'(?:(?:<'.$abrat0.'>|\['.$brat_n.'\]|\{'. $pat_n . '\}|\(' . $coords .'\))'.$extraspace.')*\{?';
+# Handle tex \def macro: \def\MAKRONAME#1[#2]#3{DEFINITION}
   my $defseq='\\\\def\\\\[\w\d@\*]+(?:#\d+|\[#\d+\])+(?:\{'. $pat_n . '\})?';
   my $backslashnl='\\\\\n';
   my $oneletcmd='\\\\.\*?(?:\['.$brat_n.'\]|\{'. $pat_n . '\})*';
@@ -1410,6 +1429,9 @@
 # If listings is being used or can be found in the latexdiff search path, add to the preamble auxiliary code to enable line-by-line markup
 if ( defined($packages{"listings"}) or `kpsewhich listings.sty` ne "" ) {
   my @listingpreamble=extrapream("LISTINGS");
+  if ($latexdiffpreamble =~ /\\RequirePackage(?:\[$brat_n\])?\{color\}/ ) {
+    @listingpreamble=extrapream("COLORLISTINGS");
+  }
   my @listingDIFcode=();
   my $replaced;
   # note that in case user supplies preamblefile the type might not reflect well the 
@@ -1572,6 +1594,7 @@
 } elsif (defined $packages{"biblatex"}) {
   print STDERR "biblatex package detected.\n" if $verbose ;
   $citpat='(?:[cC]ites?|(?:[pP]aren|foot|[Tt]ext|[sS]mart|super)cites?\*?|footnotecitetex)';
+  push(@TEXTCMDEXCL, qr/^textcite$/);
 } else {
   # citation command pattern for all other citation schemes
   $citpat='(?:cite\w*|nocite)';
@@ -1848,6 +1871,9 @@
     my $should_be_safe = $2;
     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/^(?:ADD|DEL)?${CUSTOMDIFCMD}$/);
+    ###print STDERR "DEBUG: really test it. \n";
     # test if all latex commands inside it are safe
     $success = 1;
     if ($should_be_safe =~ m/\\\\/) {
@@ -1890,6 +1916,7 @@
 # expands \input and \include commands within text
 # expands \bibliography command with corresponding bbl file if available
 # expands \subfile command (from subfiles package - not part of standard text distribution)
+# expands \import etc commands (from import package - not part of standard text distribution)
 # preamble is scanned for includeonly commands
 # encoding is the encoding
 sub flatten {
@@ -1917,15 +1944,16 @@
   # Run through filter, to let filterscript have a pass if it was set
   $text = filter($text);
 
-  # Recursively replace \\import and \\subimport files
-  $text =~ s/(^(?:[^%\n]|\\%)*)(\\subimport\{(.*?)\}|\\import\{(.*?)\})(?:[\s]*)\{(.*?)\}/{
+  # Recursively replace \\import, \\subimport, and related import commands
+  $text =~ s/(^(?:[^%\n]|\\%)*)(\\(sub)?(?:import|inputfrom|includefrom))\{(.*?)\}(?:[\s]*)\{(.*?)\}/{
+          #  (--------1-------)(--(=3=)-------------2-------------------)  (-4-)             (-5-)
           # $1 is begline
-          # $3 is directory if subimport
-          # $4 is directory if import
+          # $2 is the import macro name
+          # $3 is (optional) prefix "sub"
+          # $4 is directory
           # $5 is filename
           $begline = (defined($1)? $1 : "");
-          $subdir = $3 if defined($3);
-          $subdir = $4 if defined($4);
+          $subdir = $4;
           $fname = $5;
           $fname .= ".tex" unless $fname =~ m|\.\w{3,4}$|;
           print STDERR "DEBUG begline:", $begline, "\n" if $debug;
@@ -1940,12 +1968,13 @@
           print STDERR "importing importfilepath:", $importfilepath,"\n" if $verbose;
           if ( -f $importfilepath ) {
               # If file exists, replace input or include command with expanded input
+              #TODO: need remove_endinput & newpage similar to other replacements inside flatten
               $replacement=flatten(read_file_with_encoding($importfilepath, $encoding), $preamble,$importfilepath,$encoding) or die "Could not open file ",$fullfile,": $!";
           } else {
               # if file does not exist, do not expand include or input command (do not warn if fname contains #[0-9] as it is then likely part of a command definition
               # and is not meant to be expanded directly 
               print STDERR "WARNING: Could not find included file ",$importfilepath,". I will continue but not expand |$2|\n";
-              $replacement=(defined($3)? "\\subimport" : "\\import");
+              $replacement = $2;
               $replacement .= "{$subdir}{$fname} % Processed";
           }
           "$begline$replacement";
@@ -2615,9 +2644,10 @@
 
 
 # split this block to split sequences joined in pass1
+  ### print STDERR "DEBUG: marktags before splitlatex blocksplit ",join("|",@$block),"\n" if $debug;
   @$block=splitlatex(join "",@$block);
   ### print STDERR "DEBUG: marktags $openmark,$closemark,$open,$close,$opencmd,$closecmd,$comment\n" if $debug;
-  ### print STDERR "DEBUG: marktags blocksplit ",join("|",@$block),"\n" if $debug;
+  print STDERR "DEBUG: after splitlatex ",join("|",@$block),"\n" if $debug;
 
   # we redefine locally $extraspace (shadowing the global definition) to capture command sequences with intervening spaces no matter what the global setting
   # this is done so we can capture those commands with a predefined number of arguments without having to introduce them again explicitly here
@@ -2673,6 +2703,7 @@
         #            $2 (the command) is in context2, just treat it as an ordinary command (i.e. comment it open with $opencmd)
         # Because we do not want to disable this command
 	# here we do not use $opencmd and $closecmd($opencmd is empty) 
+	print STDERR "DEBUG: Detected text |$word| but not safe command \$2: $2 \$3: $3\n." if $debug;
 	if ($cmd==1) {
 	  push (@$retval,$closecmd) ;
 	} elsif ($cmd==0) { 
@@ -2731,7 +2762,7 @@
       if ( $word =~ /^\\(?!\()(\\|[`'^"~=.]|[\w*@]+)(.*?)(\s*)$/s &&  iscmd($1,\@MBOXCMDLIST,\@MBOXCMDEXCL)) {
 	# $word is a safe command in MBOXCMDLIST
 	###print STDERR "DEBUG Mboxsafecmd detected:$word:\n" if $debug ;
-	push(@$retval,"\\mbox{$AUXCMD\n\\" . $1 . $2 . $3 ."}\\hspace{0pt}$AUXCMD\n" );
+	push(@$retval,"\\mbox{$AUXCMD\n\\" . $1 . $2 . $3 ."}\\hskip0pt$AUXCMD\n" );
       } else {
 	# $word is a normal word or a safe command (not in MBOXCMDLIST)
 	push (@$retval,$word);
@@ -2751,15 +2782,15 @@
   # some special magic for common usage of frac, which does not conform to the latexdiff requirements but can be made to fit
   # note that this is a rare exception to the general rule that the new tex can be reconstructed from the diff file
 
-  # \frac12 -> \frac{1}{2}
-  s/\\frac(\d)(\w)/\\frac\{$1\}\{$2\}/g;
-
-  # \frac1{2b} -> \frac{1}{2b}
-  s/\\frac(\d)/\\frac\{$1\}/g;
-
-  # delete space and comment characters between \frac arguments
-#  s/\\frac(?:\s*?%[^\n]*?)*?(\{$pat_n\})\s*(\{$pat_n\})/\\frac$1$2/g;
-  s/\\frac(?:\s|%[^\n]*?)*(\{$pat_n\})(?:\s|%[^\n]*?)*(\{$pat_n\})/\\frac$1$2/g;
+  # regex that matches space and comment characters
+  my $space = qr/\s|%[^\n]*?/;
+  # \frac {abc} -> \frac{abc}
+  # \frac1 -> \frac{1}
+  # \frac a -> \frac{a}
+  # \frac \lambda -> \frac{\lambda}
+  s/\\frac(?|${space}+\{($pat_n)\}|${space}*(\d)|${space}+(\w)|${space}*(\\[a-zA-Z]+))/\\frac\{$1\}/g;
+  # same as above for the second argument of frac
+  s/\\frac(\{$pat_n\})(?|${space}*\{($pat_n)\}|${space}*(\d)|${space}+(\w)|${space}*(\\[a-zA-Z]+))/\\frac$1\{$2\}/g;
 }
 
 # preprocess($string, ..)
@@ -2766,7 +2797,7 @@
 # carry out the following pre-processing steps for all arguments:
 # 1. Remove leading white-space
 #    Change \{ to \QLEFTBRACE and \} to \QRIGHTBRACE and \& to \AMPERSAND
-# #.   Change {,} in comments to \CLEFTBRACE, \CRIGHTBRACE
+# #.   Change {,},\frac in comments to \CLEFTBRACE, \CRIGHTBRACE, \CFRAC
 # 2. mark all first empty line (in block of several) with \PAR tokens
 # 3. Convert all '\%' into '\PERCENTAGE ' and all '\$' into \DOLLAR to make parsing regular expressions easier
 # 4. Convert all \verb|some verbatim text| commands (where | can be an arbitrary character)
@@ -2802,9 +2833,11 @@
     s/(?<!\\)\\\{/\\QLEFTBRACE /sg;
     s/(?<!\\)\\\}/\\QRIGHTBRACE /sg;
     s/(?<!\\)\\&/\\AMPERSAND /sg;
-# replace {,} in comments with \\CLEFTBRACE,\\CRIGHTBRACE
+# replace {,}, \frac in comments with \\CLEFTBRACE,\\CRIGHTBRACE, CFRAC to protect from special treatment
     1 while s/((?<!\\)%.*)\{(.*)$/$1\\CLEFTBRACE $2/mg ;
     1 while s/((?<!\\)%.*)\}(.*)$/$1\\CRIGHTBRACE $2/mg ;
+    1 while s/((?<!\\)%.*)\\frac(.*)$/$1\\CFRAC $2/mg ;
+
     s/(?<!\\)\\%/\\PERCENTAGE /g ;  # (?<! is negative lookbehind assertion to prevent \\% from being converted
     s/(?<!\\)\\\$/\\DOLLAR /g ;  # (?<! is negative lookbehind assertion to prevent \\$ from being converted
     s/\\begin\{($VERBATIMENV)\}(.*?)\\end\{\1\}/"\\${1}{". tohash(\%verbhash,"${2}") . "}"/esg;
@@ -2868,7 +2901,7 @@
 # remove DIFVRB comments but leave changed lines marked 
 sub reverselinecomment {
   my ($environment, $verbatimtext)=@_;
-  ###print STDERR "OLD VERBATIMTEXT: |$verbatimtext|\n";
+  ### print STDERR "DEBUG REVERSELINECOMMENT input: $environment,|$verbatimtext|\n" if $debug;
   # remove markup added by latexdiff
   # (this should occur only if the type of verbatim environment was changed)
   # (note that this destroys some information in old file)
@@ -2903,7 +2936,7 @@
   } else {
     $verbatimtext = "\\begin{${environment}}${verbatimtext}\\end{${environment}}"
   }
-  ###print STDERR "NEW VERBATIMTEXT: |$verbatimtext|\n";
+  ### print STDERR "DEBUG REVERSELINECOMMENT output: |$verbatimtext|\n" if $debug;
   return($verbatimtext);
 }
 
@@ -2945,6 +2978,14 @@
   return $retstr;
 }
 
+# stripdelcmpopen(string)
+# return string with $DELCMDOPEN removed
+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
@@ -3183,10 +3224,15 @@
       ###  $delblock =~ s/\\DIFverb\{/\\DIFDIFdelverb\{/g;
       ###  $delblock =~ s/\\DIFlstinline/\\DIFDIFdellstinline/g;
       ###}
-      # Mark deleted verbose commands
+      # Mark deleted verbatim 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;
+        ###$delblock =~ s/(${DELCMDOPEN}.*)\\($CUSTOMDIFCMD)/$1${DELCMDCLOSE}\\DEL$2/gm;
+        # ($1 ? "${DELCMDOPEN}$1${DELCMDCLOSE}":"") : only add the DELCMDOPEN / DELCMDCLOSE pair if there are actually any commands in between, otherwise this is redundant
+	$delblock    =~ s/${DELCMDOPEN}(.*?)\\($CUSTOMDIFCMD)((?:\[${brat_n}\])*?(?:\s*\{${pat_n}\})*)/($1 ? "${DELCMDOPEN}$1${DELCMDCLOSE}":"") ."\\DEL$2". stripdelcmdopen($3)/egs;
+        # if there is a sequence of several commands in the same row only the first will be converted due to the need to be connected to the DELCMDOPEN. To mop these up, just add the DEL to the front of any remaining cmd's in the deleted block
+        $delblock =~ s/\\($CUSTOMDIFCMD)/\\DEL$1/g;     # this will also convert comments but I guess it does not matter much
       }
 
       #     splice in modified delblock
@@ -3193,7 +3239,6 @@
       substr($_,$begin,$len)=$delblock;
       pos = $begin + length($delblock);
     }
-    ###writedebugfile($_,'postprocess');
 
     ### print STDERR "<<<$_>>>\n" if $debug;
 
@@ -3223,7 +3268,7 @@
       $addblock =~ s/\\DIFverb/\\DIFDIFaddverb/g;
       $addblock =~ s/\\DIFlstinline/\\DIFDIFaddlstinline/g;
       if( $CUSTOMDIFCMD ) {
-        $addblock =~ s/\\($CUSTOMDIFCMD)/\\ADD$1/g;
+        $addblock =~ s/\\($CUSTOMDIFCMD)/\\ADD$1/g;     # this will also convert comments but I guess it does not matter much
       }
       # markup the optional arguments of \item
       $addblock =~ s/(\\$ITEMCMD$extraspace(?:<$abrat0>)?$extraspace)\[($brat_n)\]/
@@ -3333,10 +3378,22 @@
     # remove empty DIFCMD < lines
     s/^\Q${DELCMDOPEN}\E\n//msg;
 
-    # Expand hashes of verb and verbatim environments (note negative look behind assertion to not leak out of DIFDELCMD comments
+    # Expand hashes of verb and verbatim environments 
     s/${DELCMDOPEN}\\($VERBATIMENV)\{([-\d]*?)\}/"${DELCMDOPEN}\\begin{${1}}".fromhash(\%verbhash,$2,$DELCMDOPEN)."${DELCMDOPEN}\\end{${1}}"/esg;
-    # revert changes to verbatim environments for line diffs (and add code to mark up changes)
-    s/(?<!$DELCMDOPEN)\\begin\{($VERBATIMLINEENV)\}(.*?)\\end\{\1\}/"". reverselinecomment($1, $2) .""/esg;
+    # revert changes to verbatim environments for line diffs (and add code to mark up changes) (note negative look behind assertions to not leak out of DIFDELCMD comments)
+    # Example:
+    # < \begin{verbatim}
+    # < %DIF < DIFVRB old verbatim line
+    # < %DIF > DIFVRB new verbatim line
+    # < \end{verbatim}
+    # ---
+    # > \DIFmodbegin
+    # > \begin{verbatim}[alsolanguage=DIFcode]
+    # > %DIF < old verbatim line
+    # > %DIF > new verbatim line
+    # > \end{verbatim}
+    # > \DIFmodend
+    s/(?<!$DELCMDOPEN)\\begin\{($VERBATIMLINEENV)\}(.*?)(?<!$DELCMDOPEN)\\end\{\1\}/"". reverselinecomment($1, $2) .""/esg;
 #    # we do the same for deleted environments but additionally reinstate the framing commands
 #   s/$DELCMDOPEN\\begin\{($VERBATIMLINEENV)\}$extraspace(?:\[$brat0\])?$DELCMDCLOSE(.*?)$DELCMDOPEN\\end\{\1\}$DELCMDCLOSE/"\\begin{$1}". reverselinecomment($2) . "\\end{$1}"/esg;
 ##    s/$DELCMDOPEN\\begin\{($VERBATIMLINEENV)\}($extraspace(?:\[$brat0\])?\s*)(?:\n|$DELCMDOPEN)*$DELCMDCLOSE((?:\%$DELCOMMENT$VERBCOMMENT.*?\n)*)($DELCMDOPEN\\end\{\1\}(?:\n|\s|$DELCMDOPEN)*$DELCMDCLOSE)/"SUBSTITUTION: \\begin{$1}$2 INTERIOR: |$3| END: |$4|"/esg;
@@ -3355,6 +3412,7 @@
             . " $AUXCMD\n"  # close the auxiliary environment
             . $5               # and again leave the original deleted closing environment as is
       /esgx;  # Modifiers of substitution command
+    writedebugfile($_,'postprocess2');
     # where changes have occurred in verbatim environment, change verbatim to DIFverbatim to allow mark-up
     # (I use the presence of optional paramater to verbatim environment as the marker - normal verbatim 
     # environment does not take optional arguments)
@@ -3362,7 +3420,6 @@
 
     s/\\($VERBATIMENV)\{([-\d]*?)\}/"\\begin{${1}}".fromhash(\%verbhash,$2)."\\end{${1}}"/esg;
 
-
     # remove all \PAR tokens (taking care to properly keep commented out PAR's
     # from introducing uncommented newlines - next line)
     s/(%DIF < )([^\n]*?)\\PAR\n/$1$2\n$1\n/sg;
@@ -3408,6 +3465,7 @@
     1 while s/\\SQRT(\s*\{($pat_n)\})/\\sqrt$1/g ;
     1 while s/\\SQRTNB\{(\s*$pat0)\}/\\sqrt$1/g ;
  
+    1 while s/(%.*)\\CFRAC (.*)$/$1\\frac$2/mg ;
     1 while s/(%.*)\\CRIGHTBRACE (.*)$/$1\}$2/mg ;
     1 while s/(%.*)\\CLEFTBRACE (.*)$/$1\{$2/mg ;
 
@@ -3416,7 +3474,7 @@
     s/\\QLEFTBRACE /\\\{/sg;
     s/\\QRIGHTBRACE /\\\}/sg;
     s/\\AMPERSAND /\\&/sg;
-    # Highligh added inline verbatim commands if possible
+    # Highlight added inline verbatim commands if possible
     if ( $latexdiffpreamble =~ /\\RequirePackage(?:\[$brat_n\])?\{color\}/ )   { 
       # wrap added verb commands with color commands
       s/\\DIFDIFadd((?:verb\*?|lstinline(?:\[$brat_n\])?)\{[-\d]*?\}[\s\n]*)/\{\\color{blue}$AUXCMD\n\\DIF$1%\n\}$AUXCMD\n/sg;
@@ -3476,7 +3534,7 @@
   my ($line,$cmd,$optarg,$arg,$optargnew,$optargold,$optargdiff,$argold,$argnew,$argdiff,$auxline);
 
   my $warnmsgdetail = <<EOF ;
-     This should not occur for standard styles, but can occur for some specifiy styles, document classes,
+     This should not occur for standard styles, but can occur for some specific styles, document classes,
      e.g. journal house styles.
      Workaround: Use --replace-context2cmd option to specifically set those commands, which are not repeated.
 EOF
@@ -3742,7 +3800,7 @@
 
 
 sub usage {
-  die <<"EOF"; 
+  print STDERR <<"EOF"; 
 Usage: $0 [options] old.tex new.tex > diff.tex
 
 Compares two latex files and writes tex code to stdout, which has the same format as new.tex but 
@@ -3936,6 +3994,9 @@
                                 variable SCALEDELGRAPHICS to set size of deleted figures.
                       Note that changes to the optional parameters will make the figure appear as changed 
                       to latexdiff, and this figure will thus be highlighted.
+                      In some circumstances "Misplaced \\noalign" errors can occur if there are certain types
+                      of changes in tables. In this case please use option --graphics-markup=none as a 
+                      work-around. 
 
 --disable-citation-markup 
 --disable-auto-mbox    Suppress citation markup and markup of other vulnerable commands in styles 
@@ -3947,7 +4008,7 @@
                        with \\mbox command, i.e. use default behaviour for ulem package for other packages
                        (the two options are identical and are simply aliases)
 
-Miscelleneous options
+Miscellaneous options
 
 --label=label
 -L label               Sets the labels used to describe the old and new files.  The first use
@@ -3978,8 +4039,11 @@
 --ignore-filter-stderr When running with --filter-script, STDERR from the script may cause readability issues.
                        Turn this flag on to ignore STDERR from the filter script.
 
+--driver=type          Choose driver for changebar package (only relevant for styles using
+                       changebar: CCHANGEBAR CFONTCHBAR CULINECHBAR CHANGEBAR). Possible
+                       drivers are listed in changebar manual, e.g. pdftex,dvips,dvitops
+                       [Default: pdftex]
 
-
 --help
 -h                     Show this help text.
 
@@ -3999,6 +4063,7 @@
 --no-links             Suppress generation of hyperreferences, used for minimal diffs 
                        (option --only-changes of latexdiff-vc).
 EOF
+  exit 0; 
 }
 
 =head1 NAME
@@ -4470,8 +4535,13 @@
 variable SCALEDELGRAPHICS to set size of deleted figures.
 
 Note that changes to the optional parameters will make the figure appear as changed 
-to latexdiff, and this figure will thus be highlighted
+to latexdiff, and this figure will thus be highlighted.
 
+In some circumstances "Misplaced \noalign" error can occur if there are certain types
+of changes in tables. In this case please use C<--graphics-markup=none> as a 
+work-around. 
+
+
 =item B<--disable-citation-markup> or B<--disable-auto-mbox>
 
 Suppress citation markup and markup of other vulnerable commands in styles 
@@ -4500,7 +4570,7 @@
 Choose driver for changebar package (only relevant for styles using
    changebar: CCHANGEBAR CFONTCHBAR CULINECHBAR CHANGEBAR). Possible
 drivers are listed in changebar manual, e.g. pdftex,dvips,dvitops
-  [Default: dvips]
+  [Default: pdftex]
 
 =item B<--ignore-warnings>
 
@@ -4895,8 +4965,8 @@
 
 =head1 AUTHOR
 
-Version 1.3.0
-Copyright (C) 2004-2018 Frederik Tilmann
+Version 1.3.2
+Copyright (C) 2004-2021 Frederik Tilmann
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License Version 3
@@ -4922,6 +4992,7 @@
 mbox
 pageref
 ref
+eqref
 symbol
 raisebox
 rule
@@ -5222,6 +5293,7 @@
 %%BEGIN ARRENV CONFIG
 aligned
 gathered
+multlined
 array
 [pbvBV]?matrix
 smallmatrix
@@ -5291,7 +5363,7 @@
 %DIF END FONTSTRIKE PREAMBLE
 
 %DIF CCHANGEBAR PREAMBLE
-\RequirePackage[dvips]{changebar}
+\RequirePackage[pdftex]{changebar}
 \RequirePackage{color}\definecolor{RED}{rgb}{1,0,0}\definecolor{BLUE}{rgb}{0,0,1}
 \providecommand{\DIFadd}[1]{\protect\cbstart{\protect\color{blue}#1}\protect\cbend}
 \providecommand{\DIFdel}[1]{\protect\cbdelete{\protect\color{red}#1}\protect\cbdelete}
@@ -5298,7 +5370,7 @@
 %DIF END CCHANGEBAR PREAMBLE
 
 %DIF CFONTCHBAR PREAMBLE
-\RequirePackage[dvips]{changebar}
+\RequirePackage[pdftex]{changebar}
 \RequirePackage{color}\definecolor{RED}{rgb}{1,0,0}\definecolor{BLUE}{rgb}{0,0,1}
 \providecommand{\DIFadd}[1]{\protect\cbstart{\protect\color{blue}\sf #1}\protect\cbend}
 \providecommand{\DIFdel}[1]{\protect\cbdelete{\protect\color{red}\scriptsize #1}\protect\cbdelete}
@@ -5306,7 +5378,7 @@
 
 %DIF CULINECHBAR PREAMBLE
 \RequirePackage[normalem]{ulem}
-\RequirePackage[dvips]{changebar}
+\RequirePackage[pdftex]{changebar}
 \RequirePackage{color}\definecolor{RED}{rgb}{1,0,0}\definecolor{BLUE}{rgb}{0,0,1}
 \providecommand{\DIFadd}[1]{\protect\cbstart{\protect\color{blue}\uwave{#1}}\protect\cbend}
 \providecommand{\DIFdel}[1]{\protect\cbdelete{\protect\color{red}\sout{#1}}\protect\cbdelete}
@@ -5313,7 +5385,7 @@
 %DIF END CULINECHBAR PREAMBLE
 
 %DIF CHANGEBAR PREAMBLE
-\RequirePackage[dvips]{changebar}
+\RequirePackage[pdftex]{changebar}
 \providecommand{\DIFadd}[1]{\protect\cbstart{#1}\protect\cbend}
 \providecommand{\DIFdel}[1]{\protect\cbdelete}
 %DIF END CHANGEBAR PREAMBLE
@@ -5560,7 +5632,6 @@
 
 %DIF LISTINGS PREAMBLE
 \RequirePackage{listings}
-\RequirePackage{color}
 \lstdefinelanguage{DIFcode}{
   % note that the definitions in the following two lines are overwritten dependent on the markup type selected %DIFCODE TEMPLATE
   morecomment=[il]{\%DIF\ <\ },          %DIFCODE TEMPLATE
@@ -5576,6 +5647,24 @@
 \lstnewenvironment{DIFverbatim*}{\lstset{style=DIFverbatimstyle,showspaces=true}}{}
 %DIF END LISTINGS PREAMBLE
 
+%DIF COLORLISTINGS PREAMBLE
+\RequirePackage{listings}
+\RequirePackage{color}
+\lstdefinelanguage{DIFcode}{
+  % note that the definitions in the following two lines are overwritten dependent on the markup type selected %DIFCODE TEMPLATE
+  morecomment=[il]{\%DIF\ <\ },          %DIFCODE TEMPLATE
+  moredelim=[il][\bfseries]{\%DIF\ >\ }  %DIFCODE TEMPLATE
+}
+\lstdefinestyle{DIFverbatimstyle}{
+	language=DIFcode,
+	basicstyle=\ttfamily,
+	columns=fullflexible,
+	keepspaces=true
+}
+\lstnewenvironment{DIFverbatim}{\lstset{style=DIFverbatimstyle}}{}
+\lstnewenvironment{DIFverbatim*}{\lstset{style=DIFverbatimstyle,showspaces=true}}{}
+%DIF END COLORLISTINGS PREAMBLE
+
 %DIF DIFCODE_UNDERLINE
   moredelim=[il][\color{red}\sout]{\%DIF\ <\ },
   moredelim=[il][\color{blue}\uwave]{\%DIF\ >\ }

Modified: trunk/Master/texmf-dist/scripts/latexdiff/latexrevise.pl
===================================================================
--- trunk/Master/texmf-dist/scripts/latexdiff/latexrevise.pl	2021-12-28 22:51:15 UTC (rev 61433)
+++ trunk/Master/texmf-dist/scripts/latexdiff/latexrevise.pl	2021-12-28 22:52:08 UTC (rev 61434)
@@ -21,6 +21,9 @@
 #
 # Detailed usage information at the end of the file
 # Note: version number now keeping up with latexdiff
+# Version 1.3.2 
+#   - Functionality -c option: if comment to be deleted is the last in the line replace new line by space character. This is done to avoid errors or unintended line breaks from empty lines after deletion (which are implicit \par)
+#   - Introduce option -r / --replace which removes markup of the form \replaced{new text}{old text} in the changes package
 # Version 1.3.1  (Bug fix) Remove some deprecation warnings due to uncommented left parentheses 
 # Version 1.0.2  Option --version
 # Version 1.0.1   no changes to latexrevise
@@ -32,8 +35,8 @@
 use warnings;
 
 my $versionstring=<<EOF ;
-This is LATEXREVISE 1.3.1.1
-  (c) 2005-2020 F J Tilmann
+This is LATEXREVISE 1.3.2
+  (c) 2005-2021 F J Tilmann
 EOF
 
 # Markup strings (make sure that this are set to the same value as in 
@@ -92,7 +95,7 @@
 my ($cnt,$prematch,$postmatch);
 my ($help,$version);
 my ($verbose,$quiet,$accept,$decline,$simplify)=(0,0,0,0,0);
-my ($comment,$comenv,$markup,$markenv);
+my ($comment,$comenv,$markup,$markenv,$replace);
 
 # A word unlikely ever to be used in a real latex file
 my $someword='gobbledegooksygook';
@@ -105,6 +108,7 @@
 	   'comment-environment|e=s' => \$comenv,
 	   'markup|m=s' => \$markup,
 	   'markup-environment|n=s' => \$markenv,
+	   'replace|r=s' => \$replace,
 	   'no-warnings|q' => \$verbose,
            'version' => \$version,
 	   'verbose|V' => \$verbose,
@@ -115,7 +119,8 @@
 }
 
 if ( $version ) {
-  die $versionstring ; 
+  print STDERR $versionstring ; 
+  exit 0;
 }
 
 
@@ -259,7 +264,7 @@
   # protect $comments in comments by making them look different
   $body =~ s/(%.*)${comment}(.*)$/$1${someword}$2/mg ;
   # carry out the substitution
-  $cnt = 0 + $body =~ s/\\${comment}(?:\[${brat0}\])?\{${pat_n}\}//sg ;
+  $cnt = 0 + $body =~ s/\\${comment}(?:\[${brat0}\])?\{${pat_n}\}(?: *\n)?//sg ;
   print STDERR "$cnt matches found and removed.\n" if $verbose;
   # and undo the protection substitution
   $body =~ s/(%.*)${someword}(.*)$/$1${comment}$2/mg ;
@@ -292,6 +297,16 @@
   $body =~ s/(%.*)${someword}/$1${markenv}/mg ;
 }
 
+if (defined($replace)) {
+  print STDERR "Removing \\$replace\{..\}\{..\} commands (leaving 1st and discarding 2nd argument))..." if $verbose;
+  # protect $markups in comments by making them look different
+  $body =~ s/(%.*)${replace}(.*)$/$1${someword}$2/mg ;
+  # carry out the substitution
+  $cnt = 0 + $body =~ s/\\${replace}(?:\[${brat0}\])?\{(${pat_n})\}\s?\{(${pat_n})\}/$1/sg ;
+  print STDERR "$cnt matches found and removed.\n" if $verbose;
+  # and undo the protection substitution
+  $body =~ s/(%.*)${someword}(.*)$/$1${replace}$2/mg ;
+}
 
 if ( length $preamble ) {
   print "$preamble\\begin{document}${body}\\end{document}$post";
@@ -349,7 +364,7 @@
 
 
 sub usage {
-  die <<"EOF"; 
+  print STDERR <<"EOF"; 
 Usage: $0 [OPTIONS] [diff.tex] > revised.tex
 
 Read a file diff.tex (output of latexdiff), and remove its markup. 
@@ -390,7 +405,7 @@
 
 Note that the three mode options are mutually exclusive. If no mode option is given,
 latexrevise simply removes user annotations and markup according to the following four
-options.
+options; these functions can be very useful outside the latexdiff context, too.
 
 
 -c cmd
@@ -414,6 +429,11 @@
 --markup-environment=envir  
                   Similarly, remove \\begin{envir} and \\end{envir} commands,
                   but leave content of the environment in the text.
+
+
+-r cmd
+--replace=cmd    For constructions \\cmd{..}{..}, remove the command, leave the 
+                 content of first argument, and delete second argument. 
                   
 -q
 --no-warnings     Do not warn users about \\DIDadd{..} or \\DIFdel statements
@@ -423,6 +443,7 @@
 --verbose         Verbose output
 
 EOF
+  exit 0;
 }
 
 =head1 NAME
@@ -480,7 +501,7 @@
 
 Note that the three mode options are mutually exclusive.  If no mode option is given,
 I<latexrevise> simply removes user annotations and markup according to the following four
-options.
+options. These functions can be very useful outside the latexdiff context, too
 
 =over 4
 
@@ -509,6 +530,13 @@
 
 Similarly, remove C<\begin{envir}> and C<\end{envir}> commands but 
 leave content of the environment in the text.
+
+=item B<-r cmd> or B<--replace=cmd>
+
+For constructions C<\\cmd{..}{..}>, remove the command, leave the 
+content of first argument, and delete second argument, i.e. turn 
+C<\cmd{abc}{def}> into C<abc>.
+
                   
 
 =item B<-V> or B<--verbose>



More information about the tex-live-commits mailing list.