SPB Git

Repository Public

generate.sh 1.5 KB 37 lines shellscript

1#!/usr/bin/env bash2# ORIX Docs3# File: Packages/ORIXDocsKit/Tests/DocDOCXTests/Corpus/generate.sh4# Description: Regenerates the tool-produced part of the DOCX reference corpus from the fixtures in sources/5#              (pandoc for Markdown, LibreOffice headless for HTML and flat ODT). Needs no network and opens no window.6#7# Author: Simon-Pierre Boucher8# Contact: contact@spboucher.ai9set -euo pipefail10cd "$(dirname "$0")"11PANDOC="${PANDOC:-$(command -v pandoc || echo /opt/homebrew/bin/pandoc)}"12SOFFICE="${SOFFICE:-$(command -v soffice || echo /opt/homebrew/bin/soffice)}"1314if [ -x "$PANDOC" ]; then15  for name in basic lists tables footnotes math images unicode; do16    (cd sources && "$PANDOC" -f markdown -t docx "$name.md" -o "../pandoc-$name.docx")17  done18  (cd sources && "$PANDOC" -f markdown -t docx --toc --toc-depth=2 toc.md -o ../pandoc-toc.docx)19  echo "pandoc: $("$PANDOC" --version | head -1)"20else21  echo "pandoc not found; pandoc fixtures not regenerated" >&222fi2324if [ -x "$SOFFICE" ]; then25  PROFILE="$(mktemp -d)"26  OUT="$(mktemp -d)"27  for src in merged.html pagesetup.fodt; do28    "$SOFFICE" "-env:UserInstallation=file://$PROFILE" --headless --convert-to docx:"MS Word 2007 XML" --outdir "$OUT" "sources/$src" >/dev/null 2>&129    base="${src%.*}"30    cp "$OUT/$base.docx" "libreoffice-$base.docx"31  done32  rm -rf "$PROFILE" "$OUT"33  echo "libreoffice: $("$SOFFICE" --version | head -1)"34else35  echo "soffice not found; LibreOffice fixtures not regenerated" >&236fi37
Files main
Menu

Theme