#!/bin/bash
OLD="$1.tex"
NEW="$2.tex"
OUT="$3"
shift 3
if [ -z "$EDITOR" ]; then
	EDITOR=emacs
fi
echo '\setupcolors[state=start]' >"$OUT.tex"
echo '\long\def\startDeleted*#1\stopDeleted*{%
		\overstrikes{\startcolor[red]#1\stopcolor}}' >>"$OUT.tex"
echo '\long\def\startAdded*#1\stopAdded*{\startcolor[blue]#1\stopcolor}' \
	>>"$OUT.tex"
wdiff -w '\startDeleted*' -x '\stopDeleted*' \
	-y '\startAdded*' -z '\stopAdded*' "$OLD" "$NEW" >>"$OUT.tex"
echo Starting editor, so you can manually improve the ConTeXt source.
$EDITOR "$OUT.tex"
texexec "$@" "$OUT"
