[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: [PATCH v2] makediffpdf.sh: tool to create marked-up diff
make pdf diff using latexpand and latexdiff-fast styles are set in diffpreamble.tex: new text is blue, old text is red and is crossed-out. in diff, links are coloured green instead of blue Must be run within a git-svn clone of the spec repository. Note: latexdiff has --flatten option, this and options to select diff style don't seem to work well. So flatten by script myself, and add our own preamble. A script fixupdiff works around xetex bugs - \color{ \footnote{text} } does not work, replace with \footnote{\textcolor{}} - too many \color instructions produce "color stack overflow. Just ignore" error and xetex skips some \color instructions. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> --- Changes from v1: work around xetex bugs Output looks ok to me now, plan to commit tomorrow. Comments? diff --git a/diffpreamble.tex b/diffpreamble.tex new file mode 100644 index 0000000..8abb737 --- /dev/null +++ b/diffpreamble.tex @@ -0,0 +1,28 @@ +%% diffpreable.tex start + +%DIF FONTSTRIKE PREAMBLE +\RequirePackage[normalem]{ulem} +\providecommand{\DIFadd}[1]{{\sf #1}} +\providecommand{\DIFdel}[1]{{\footnotesize \sout{#1}}} +%DIF END FONTSTRIKE PREAMBLE + +%DIF COLOR PREAMBLE +\RequirePackage{color} +\providecommand{\DIFaddbegin}{\protect\color{blue}} +\providecommand{\DIFaddend}{\protect\color{black}} +\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}} +\providecommand{\DIFdelFL}[1]{\DIFdel{#1}} +\providecommand{\DIFaddbeginFL}{} +\providecommand{\DIFaddendFL}{} +\providecommand{\DIFdelbeginFL}{} +\providecommand{\DIFdelendFL}{} +%DIF END FLOATSAFE PREAMBLE + +%% diffpreable.tex end 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 new file mode 100755 index 0000000..34904bf --- /dev/null +++ b/makediffpdf.sh @@ -0,0 +1,36 @@ +#make pdf diff using latexpand and latexdiff-fast +#preamble in diffpreamble.tex +#in diff, links are coloured green instead of blue +PATH=.:${PATH} +cur="$PWD" +rm -fr old new +git clone $PWD old +cd "${cur}/old" +git checkout ec1ffbf27a8f0a06ca65cd498a69c7f89bd97dc1 +mv specvars.tex specvars-orig.tex +#make links green to avoid confusion +sed s/blue/green/ specvars-orig.tex > specvars.tex +SPECDOC=${SPECDOC:-`cat REVISION`} +./make-setup-generated.sh "$SPECDOC" +#wget http://www.ctan.org/pkg/latexpand +#chmod +x latexpand +latexpand virtio.tex -o flat.tex +cd "${cur}" +git clone $PWD new +cd "${cur}/new" +mv specvars.tex specvars-orig.tex +#make links green to avoid confusion +sed s/blue/green/ specvars-orig.tex > specvars.tex +SPECDOC=${SPECDOC:-`cat REVISION`} +./make-setup-generated.sh "$SPECDOC" +latexpand virtio.tex -o flat.tex +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 +xelatex --jobname $SPECDOC virtio-diff.tex
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]