Skip to content

Instantly share code, notes, and snippets.

@AdamGagorik
Created January 9, 2024 18:59
Show Gist options
  • Save AdamGagorik/ea5a7b93ef0aebbab5c31878d8da3c67 to your computer and use it in GitHub Desktop.
Save AdamGagorik/ea5a7b93ef0aebbab5c31878d8da3c67 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
INP=main.tex
OUT=main.docx
REF=reference.docx
if [[ $# -ge 1 ]]; then
INP="${1%.*}.tex"
OUT="${1%.*}.docx"
fi
if [[ ! -f ${REF} ]]; then
echo "Creating reference template (${REF})"
pandoc --print-default-data-file="${REF}" > "${REF}"
echo "Please rerun the command to create the final docx" && exit 0
fi
if [[ ! -f ${INP} ]]; then
echo "Input file (${INP}) does not exist!" && exit 1
fi
echo "Compiling document (${INP}) to word file (${OUT})"
pandoc --reference-doc="${REF}" -o "${OUT}" "${INP}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment