Skip to content

Commit

Permalink
Merge pull request #252 from tdegeus/add
Browse files Browse the repository at this point in the history
Adding option "--no-del" to include only additions
  • Loading branch information
ftilmann authored Feb 6, 2022
2 parents 82e61ee + d2ee820 commit 7dc3a69
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 1 deletion.
12 changes: 11 additions & 1 deletion latexdiff
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ my ($type,$subtype,$floattype,$config,$preamblefile,$encoding,$nolabel,$visiblel
$replacecontext1,$appendcontext1,
$replacecontext2,$appendcontext2,
$help,$verbose,$driver,$version,$ignorewarnings,
$onlyadditions,
$enablecitmark,$disablecitmark,$allowspaces,$flatten,$nolinks,$debug,$earlylatexdiffpreamble); ###$disablemathmark,
my ($mboxsafe);
# MNEMNONICS for mathmarkup
Expand Down Expand Up @@ -413,6 +414,7 @@ my ($pkg,%packages);
# Defaults
$mathmarkup=COARSE;
$verbose=0;
$onlyadditions=0;
# output debug and intermediate files, set to 0 in final distribution
$debug=0;
# insert preamble directly after documentclass - experimental feature, set to 0 in final distribution
Expand Down Expand Up @@ -477,6 +479,7 @@ GetOptions('type|t=s' => \$type,
'filter-script=s' => \$filterscript,
'ignore-filter-stderr' => \$ignorefilterstderr,
'no-links' => \$nolinks,
'no-del' => \$onlyadditions,
'version' => \$version,
'help|h' => \$help,
'debug!' => \$debug ) or die "Use latexdiff -h to get help.\n" ;
Expand Down Expand Up @@ -2893,9 +2896,14 @@ sub postprocess {
# up. This case should be rare, so I just leave this in the diff file output. Not really elegant
# but can still be dealt with later if it results in problems.
s/%DIFDELCMD < \\RIGHTBRACE/%DIFDELCMD < \\MBLOCKRIGHTBRACE/g ;
# Replace \RIGHTBRACE by }
# Replace \RIGHTBRACE by }
s/\\RIGHTBRACE/}/g;

# Optional: Remove deleted block entirely
if ($onlyadditions) {
s/\\DIFdelbegin.*?\\DIFdelend//sg ;
}

### # change citation commands within comments to protect from processing
### if ($CITECMD){
### 1 while s/(%.*)\\($CITECMD)/$1\\CITEDIF$2/m ;
Expand Down Expand Up @@ -3827,6 +3835,8 @@ be real files (not pipes or similar) as they are opened twice.
[ Default: scan the preamble for \\usepackage commands to determine
loaded packages.]
--no-del Supress deleted text from the diff.
--show-preamble Print generated or included preamble commands to stdout.
--show-safecmd Print list of regex matching and excluding safe commands.
Expand Down
60 changes: 60 additions & 0 deletions testsuite/no-del-new.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
\documentclass[12pt,a4paper]{article}

\setlength{\topmargin}{-0.2in}
\setlength{\textheight}{9.5in}
\setlength{\oddsidemargin}{0.0in}

\setlength{\textwidth}{6in}

\title{latexdiff Example - Revised version}
\author{F Tilmann}
% Note how in the preamble visual markup is never used (even
% if some preamble might eventually end up as visible text.)

\begin{document}
\maketitle

\section*{Introduction}

This is an extremely simple document that showcases some of the latexdiff features.
Type
\begin{verbatim}
latexdiff -t UNDERLINE example-draft.tex example-rev.tex > example-diff.tex
\end{verbatim}
to create the difference file. You can inspect this file directly. Then run either
\begin{verbatim}
pdflatex example-diff.tex
xpdf example-diff.pdf
\end{verbatim}
or
\begin{verbatim}
latex example-diff.tex
dvips -o example-diff.ps example-diff.dvi
gv example-diff.ps
\end{verbatim}
to display the markup.

\section*{Yet another section title}

More things could be said were it not for the constraints of time and space.

A paragraph with a line only in the revised document. More things could be
said were it not for the constraints of time and space.

And here is a typo.

Here is a table:

\begin{tabular}{ll}
Name & Description \\
\hline
Gandalf & White \\
Saruman & Evil
\end{tabular}

And now for something completely different, with not a paragraph in sight.
No change,
no markup!
\end{document}


59 changes: 59 additions & 0 deletions testsuite/no-del-old.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
\documentclass[12pt,a4paper]{article}

\setlength{\topmargin}{-0.2in}
\setlength{\textheight}{9.5in}
\setlength{\oddsidemargin}{0.0in}

\setlength{\textwidth}{6.5in}

\title{latexdiff Example - Draft version}
\author{F Tilmann}

\begin{document}
\maketitle

\section*{Introduction}

This is an extremely simple document that showcases some of latexdiff features.
Type
\begin{verbatim}
latexdiff -t UNDERLINE example-draft.tex example-rev.tex > example-diff.tex
\end{verbatim}
to create the difference file. You can inspect this file directly. Then run either
\begin{verbatim}
pdflatex example-diff.tex
xpdf example-diff.pdf
\end{verbatim}
or
\begin{verbatim}
latex example-diff.tex
dvips -o example-diff.ps example-diff.dvi
gv example-diff.ps
\end{verbatim}
to display the markup.

\section*{Another section title}

A paragraph with a line only in the draft document. More things could be said
were it not for the constraints of time and space.

More things could be said were it not for the constraints of time and space.

And here is a tipo.

Here is a table:

\begin{tabular}{ll}
Name & Description \\
\hline
Gandalf & Grey \\
Saruman & White
\end{tabular}

And sometimes a whole paragraph gets completely rewritten. In this
case latexdiff marks up the whole paragraph even if some words in it
are identical.
No change, no markup!
\end{document}


1 change: 1 addition & 0 deletions testsuite/verify
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ DIFDELCMDBUG eqnarray eqnarray2 subscriptm delequ2 schneider gennady umesh under
delequ3 delequ4 "simplefrac --allow-spaces" "master --flatten" "subfile --flatten" "import --flatten" titlediffTest2 exampleDiff bornd2 \
"rolla --math-markup=2" mini "complex-maths --math-markup=1" margalit circonflex mwe-comment "apacite-test --flatten" quoteddollarunderscore units complicated-math move-equation2 lists "figures --graphics-markup=both" alignat "safecmd --append-safecmd=remark" verbatim verbatim2-is143 embedded-math-array "verbatim-input --flatten" anchordemo 'customdiffcmdtest --add-to-config "CUSTOMDIFCMD=blindtext;mypar;donothing;cmd"' description frac_w_space_comments \
"href-in-bibliography --append-safecmd=path" revtex-bibliography biblatex 'txtcmd-with-multiple-arguments --append-textcmd=cmd' \
"no-del --no-del" \
)

#set testroots= ( test subscript )
Expand Down

0 comments on commit 7dc3a69

Please sign in to comment.