Closed jprotze closed 6 years ago
This looks interesting but I am not a 100% sure how this is applied. Could you provide an example file, which uses this (and the command line with which you invoke the patched version). (I will look at your other pull requests later - busy week at work this week)
old.tex
\documentclass{book}
\usepackage{blindtext}
\newcommand{\DELblindtext}{{\color{red}\blindtext}}
\newcommand{\ADDblindtext}{{\color{blue}\blindtext}}
\newcommand{\mypar}{\paragraph{MYPAR}}
\newcommand{\DELmypar}{\paragraph{\DIFdel{MYPAR}}}
\newcommand{\ADDmypar}{\paragraph{\DIFadd{MYPAR}}}
\begin{document}
\mypar
\blindtext
\end{document}
new.tex
\documentclass{book}
\usepackage{blindtext}
\newcommand{\DELblindtext}{{\color{red}\blindtext}}
\newcommand{\ADDblindtext}{{\color{blue}\blindtext}}
\newcommand{\mypar}{\paragraph{MYPAR}}
\newcommand{\DELmypar}{\paragraph{\DIFdel{MYPAR}}}
\newcommand{\ADDmypar}{\paragraph{\DIFadd{MYPAR}}}
\begin{document}
\end{document}
And then use it like this (blindtext is actually not compatible with \DIFdel/add):
latexdiff -c 'CUSTOMDIFCMD=(?:blindtext|mypar)' old.tex new.tex > diff-del.tex
latexdiff -c 'CUSTOMDIFCMD=(?:blindtext|mypar)' new.tex old.tex > diff-add.tex
-- update: removed the \par from debugging the \blindtext issue
Merged this as is. Sorry it took such a long time.
Not that I have added a description to the man page text and also a test file for the test suite, in each case borrowing from your example (Commit 4b08bf6 )
Hey folks. Is it possible this PR doesn't properly handle when the CUSTOMDIFCMD is encountered in an add block? Near as I can tell, it replaces CUSTOMDIFCMD with ADDCUSTOMDIFCMD, leaving the original DIFadd{ intact. I can open a proper issue if I'm not somehow misunderstanding the intended behavior here.
Did you look at the behavior for the mwe, I posted above?
I did see the text above but the output wasn't shown, and I didn't test it.
I dug into this more. The issue seems to be when the command takes params. I think this is perhaps a misunderstanding of the intended use.
For example:
old.tex:
\documentclass{book}
\newcommand{\donothing}[1]{#1}
\newcommand{\ADDdonothing}[1]{{\color{blue}\donothing{#1}}}
\newcommand{\DELdonothing}[1]{{\color{red}\donothing{#1}}}
\usepackage{blindtext}
\newcommand{\DELblindtext}{{\color{red}\blindtext}}
\newcommand{\ADDblindtext}{{\color{blue}\blindtext}}
\begin{document}
First
Second
Third
Forth
\end{document}
new.tex:
\documentclass{book}
\newcommand{\donothing}[1]{#1}
\newcommand{\ADDdonothing}[1]{{\color{blue}\donothing{#1}}}
\newcommand{\DELdonothing}[1]{{\color{red}\donothing{#1}}}
\usepackage{blindtext}
\newcommand{\DELblindtext}{{\color{red}\blindtext}}
\newcommand{\ADDblindtext}{{\color{blue}\blindtext}}
\begin{document}
First
\donothing{Second}
Third
\blindtext
Forth
\end{document}
latexdiff command: latexdiff -c 'CUSTOMDIFCMD=(?:blindtext|donothing)' old.tex new.tex
Output (all but body omitted):
\begin{document}
First
\DIFdelbegin \DIFdel{Second
}\DIFdelend \DIFaddbegin \DIFadd{\ADDdonothing{Second}
}\DIFaddend
Third
\DIFaddbegin
\ADDblindtext
\DIFaddend
Forth
\end{document}
Note the inclusion of both DIFadd and ADDdonothing.
The usecase is what is described in the MAN file. I have an environment (represented here by \donothing
that won't work properly with ulem
's \uwave
. So I need to redefine the DIFadd/del's.
(More specifically, I'm dealing with an enumerate environment that i've wrapped with a dummy command in a vain attempt to battle uwave)
As I understand the issue, your locally defined command is automatically added to the SAFECMDLIST.
For now you can prevent this, by adding --exclude-safecmd=donothing
to your commandline.
I created #203 to fix this issue.
Most excellent. I confirmed that the PR resolves the issue I observed. Thank you.
Commands listed in CUSTOMDIFCMD assume to have a ADD and DEL prefixed version of the command defined by the document:
CUSTOMDIFCMD=blindtext \newcommand{\DELblindtext}{\DIFdel{\blindtext}} \newcommand{\ADDblindtext}{\DIFadd{\blindtext}}
This patch allows to show changes for commands that need special care. (We have commands for re-occuring paragraph headings. This allows to display the deleted/added paragraph name)