diff options
author | John MacFarlane <jgm@berkeley.edu> | 2019-07-10 20:28:21 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2019-07-10 20:28:21 -0700 |
commit | 2c2d4e2138c85f4669c2c7f8868697c9047bbd00 (patch) | |
tree | 70ed050d5408842c32c1a776e3a8c0bfc73dd29b /tools | |
parent | 1d9ff85b451f976b1d140f06e9eee56bc3fadf33 (diff) | |
download | pandoc-2c2d4e2138c85f4669c2c7f8868697c9047bbd00.tar.gz |
Add diff-docx.sh to tools.
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/diff-docx.sh | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tools/diff-docx.sh b/tools/diff-docx.sh new file mode 100755 index 000000000..62e165ae5 --- /dev/null +++ b/tools/diff-docx.sh @@ -0,0 +1,22 @@ +#!/bin/sh +f1="$1" +f2="$2" +test -f "$f1" -a -f "$f2" || { + echo "Usage: diff-docx first.docx second.docx" && exit 1 +} +WORKDIR=$(mktemp -d -t diff-docx) +trap "{ rm -r $WORKDIR; }" EXIT +unzip -q -d "$WORKDIR/a" "$f1" +unzip -q -d "$WORKDIR/b" "$f2" +cd "$WORKDIR" +mkdir tidy +for x in a b; do + cp -r $x tidy/ + find $x -iname '*.xml' -exec sh -c 'mkdir -p "$(dirname tidy/$1)" && tidy -q -xml -utf8 -i "$1" > "tidy/$1"' _ {} \; + find $x -iname '*.rels' -exec sh -c 'mkdir -p "$(dirname tidy/$1)" && tidy -q -xml -utf8 -i "$1" > "tidy/$1"' _ {} \; +done +cd tidy +mkdir c +cp -r a/* c/ +cp -r b/* c/ +find c -type f -exec sh -c 'echo "\033[1m=== ${1#*/} ===\033[0m" ; diff -u "a/${1#*/}" "b/${1#*/}" 2>&1' _ {} \; |