Last active
March 30, 2017 17:19
-
-
Save curiositry/27c7be05f315a7efb406f85fa503366f to your computer and use it in GitHub Desktop.
A little bash script to format manuscripts with Pandoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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