A little bash script to format manuscripts with Pandoc
#!/bin/sh | |
echo "Formatting manuscripts..." | |
for i in "$@" | |
do | |
case $i in | |
-f=*|--filename=*) | |
FILENAME="${i#*=}" | |
shift # past argument=value | |
;; | |
*) | |
# unknown option | |
;; | |
esac | |
done | |
echo "FILENAME: ${FILENAME}" | |
if [[ -n $1 ]]; then | |
echo "Last line of file specified as non-opt/last argument:" | |
tail -1 $1 | |
fi | |
if [ ! pandoc ]; then | |
echo "Pandoc not found; installing..." | |
sudo apt install pandoc | |
echo "Done." | |
fi | |
if [ ! -d formatted ]; then | |
echo "Creating directory for formatted manuscripts ..." | |
mkdir formatted | |
echo "Done." | |
fi | |
cd formatted/ | |
pandoc ../"${FILENAME}.md" -s --output "${FILENAME}.odt" | |
libreoffice "${FILENAME}.odt" | |
pandoc ../"${FILENAME}.md" -s --output "${FILENAME}.docx" | |
libreoffice "${FILENAME}.docx" | |
echo "Finished!" | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment