mirror of
https://github.com/jgm/pandoc.git
synced 2026-08-23 16:56:43 +00:00
Add custom validate-docx.sh script.
This checks files other than document.xml in a docx container. Thanks to @edwintorok.
This commit is contained in:
@@ -239,7 +239,7 @@ validate-docx-golden-tests: ## validate docx golden tests against schema
|
||||
which xmllint || ("xmllint is required" && exit 1)
|
||||
test -d ./docx-validator || \
|
||||
git clone https://github.com/devoidfury/docx-validator
|
||||
cd docx-validator && for f in ../test/docx/golden/*.docx; do ./validate $$f || exit 1 ; done
|
||||
sh ./tools/validate-docx.sh test/docx/golden/*.docx
|
||||
.PHONY: validate-docx-golden-tests
|
||||
|
||||
validate-epub: ## generate an epub and validate it with epubcheck
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user