summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--diffpreamble.tex2
-rwxr-xr-xfixupdiff.pl18
-rwxr-xr-xmakediffpdf.sh2
3 files changed, 22 insertions, 0 deletions
diff --git a/diffpreamble.tex b/diffpreamble.tex
index 6dc177c..8abb737 100644
--- a/diffpreamble.tex
+++ b/diffpreamble.tex
@@ -13,6 +13,8 @@
\providecommand{\DIFdelbegin}{\protect\color{red}}
\providecommand{\DIFdelend}{\protect\color{black}}
%DIF END COLOR PREAMBLE
+\providecommand{\DIFaddtext}[1]{\textcolor{blue}{\sf #1}}
+\providecommand{\DIFdeltext}[1]{\textcolor{red}{\footnotesize \sout{#1}}}
%DIF FLOATSAFE PREAMBLE: SEEMS UNUSED BUT JUST IN CASE
\providecommand{\DIFaddFL}[1]{\DIFadd{#1}}
diff --git a/fixupdiff.pl b/fixupdiff.pl
new file mode 100755
index 0000000..69d4e6e
--- /dev/null
+++ b/fixupdiff.pl
@@ -0,0 +1,18 @@
+#!/usr/bin/perl -pi
+
+# Too many \color directives (generated by DIFdel/addbegin/end)
+# confuse xetex, producing errors:
+# WARNING ** Color stack overflow. Just ignore.
+# and resulting in corrupted color in output.
+# As a work-around, detect cases where it's safe, and replace \color with
+# \textcolor.
+# As a result, number of \color directives goes does sufficiently
+# enough to avoid the overflow error.
+
+s/\\DIFdelbegin \\DIFdel{([^}]*)}\\DIFdelend/\\DIFdeltext{$1}/;
+s/\\DIFaddbegin \\DIFadd{([^}]*)}\\DIFaddend/\\DIFaddtext{$1}/;
+
+# external \color does not seem to apply to footnotes.
+# detect and replace with \textcolor within footnotes
+s/(\\footnote\s*{[^}]*)\\DIFadd{/$1\\DIFaddtext{$2/;
+s/(\\footnote\s*{[^}]*)\\DIFdel{/$1\\DIFdeltext{$2/;
diff --git a/makediffpdf.sh b/makediffpdf.sh
index 2eb2fbd..34904bf 100755
--- a/makediffpdf.sh
+++ b/makediffpdf.sh
@@ -28,6 +28,8 @@ cd "${cur}"
#wget http://mirror.math.ku.edu/tex-archive/support/latexdiff/latexdiff-fast
#chmod +x latexdiff-fast
latexdiff-fast -p diffpreamble.tex old/flat.tex new/flat.tex > virtio-diff.tex
+perl -pi fixupdiff.pl virtio-diff.tex
+SPECDOC="${SPECDOC}-diff"
rm $SPECDOC.aux $SPECDOC.pdf $SPECDOC.out
xelatex --jobname $SPECDOC virtio-diff.tex
xelatex --jobname $SPECDOC virtio-diff.tex