# ConTeXt equivalent of latexdiff

I was just wondering if anyone knows of a ConTeXt equivalent to latexdiff?

For those not familiar with latexdiff: it is a Perl script that marks up differences between 2 latex files. It is included with many LaTeX distributions.

It is used as follows:

\$ latexdiff old.tex new.tex > diff.tex


Then when you compile the output diff.tex, it shows added text in blue, and deleted text in red strikethrough. E.g., http://haakoh.at.ifi.uio.no/latexdiff/

Does anyone knows of a ConTeXt tool that achieves something similar?

If not, can anyone offer any pointers on how the latexdiff Perl script might be leveraged/ported to a "contextdiff" equivalent?

• Could you expand your question as to how exactly the tool you mention works differently from common diff? Context users might not be familiar with Latex specific programs. Oct 30, 2012 at 12:24

Try texdiff. It should work with ConTeXt.

• Thanks, that's exactly what i was looking for. In my answer below I outline the ConTeXt pre-amble i used to get texdiff working similarly to latexdiff. Oct 31, 2012 at 10:09

@user21568 is right, texdiff works with ConTeXt.

However while the texdiff doco lists an example preamble for LaTeX, it doesn't offer any advice for ConTeXt.

So for the benefit of anyone else interested in using texdiff with ConTeXt, here is a preamble that i have found useful:

% Define a blue underline bar for insertions
\definebar[insbar][color=blue, offset=-0.4, continue=yes]

% Define a red strikethrough bar for deletions
\definebar[delbar][color=red, offset=0.5, continue=yes]

% Define the insertion macro. Note the inmargin marker.
\def\TLSins#1{{\inmargin{\color[blue]{--->}}\startbar[insbar]\color[blue]{#1}\stopbar}}

% Define the deletion macro.
\def\TLSdel#1{{\inmargin{\color[red]{--->}}\startbar[delbar]\color[red]{#1}\stopbar}}

% Override ConTeXt protect command to do nothing.
% This might have undesired consequences for advanced ConTeXt users?
\def\protect{}


Note the redefinition of protect: this is a workaround of the fact that the protect commands that texdiff generates do not compile under ConTeXt - it seems that this command has different usage in ConTeXt than in LaTeX.

• \protect reinstates the common catcodes, see its definition. Generally it is not safe to redefine but if you do make sure you don’t load any modules after that. You could try replacing the \protect calls in the generated code (but not in Context code) with \unexpanded or \normalprotected). Oct 31, 2012 at 10:56