aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJohn MacFarlane <[email protected]>2023-12-18 12:06:59 -0800
committerJohn MacFarlane <[email protected]>2023-12-18 12:06:59 -0800
commit0849baef1e6844c85956e4e56db681d78af1b5cc (patch)
treebc307bc8559de3759380947db0ce22e4b2c7b84b /tools
parent1d2ccb41ed97fa5b6675083be6cb17320f3db946 (diff)
Add custom validate-docx.sh script.
This checks files other than document.xml in a docx container. Thanks to @edwintorok.
Diffstat (limited to 'tools')
-rw-r--r--tools/validate-docx.sh21
1 files changed, 21 insertions, 0 deletions
diff --git a/tools/validate-docx.sh b/tools/validate-docx.sh
new file mode 100644
index 000000000..99874111b
--- /dev/null
+++ b/tools/validate-docx.sh
@@ -0,0 +1,21 @@
+#!/bin/sh
+# Modified by edwintorok from https://github.com/devoidfury/docx-validator
+# to look at more files than just document.xml.
+# Further modified by jgm for portability.
+tmpdir=$(mktemp -d)
+errors=0
+for file in "$@"; do
+ echo "*** Checking $file"
+ rm -rf "$tmpdir"
+ unzip -q -o -j "$file" -d "$tmpdir"
+ for i in comments document fontTable footnotes numbering settings styles theme1 webSettings; do
+ xmllint --format "$tmpdir/${i}.xml" > "$tmpdir/${i}-pretty.xml"
+ done
+ XSD="./docx-validator/schemas/microsoft/wml-2010.xsd"
+ for i in "$tmpdir"/*-pretty.xml; do
+ xmllint -noout -nonet \
+ -schema "${XSD}" \
+ "${i}" 2>&1 || errors=$((errors + 1))
+ done
+done
+exit $errors