Last active
August 29, 2015 14:25
-
-
Save denten/a680f8e6031c2acaea2c to your computer and use it in GitHub Desktop.
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/bash | |
# this bash script simplifies long pandoc incantations | |
# sh print.sh [-d|p|m] filename.md | |
# remember to update the cases with your own paths / pandoc commands | |
# pass the file name as an argument | |
if [ $# -eq 0 ] | |
then | |
echo "pass the file name" | |
exit | |
fi | |
source=$2 | |
# Use parameter expansion to strip the name | |
target="${source%%.*}" | |
# handle three options with getopts: | |
# -d for .docx | |
# -p for .pdf | |
# -m for .md > .md to strip hard wrap and to prettify the markdown | |
while getopts ":d:p:m:" opt; do | |
case $opt in | |
d) | |
echo "printing $target.docx to print-plates/" >&2 | |
pandoc --filter pandoc-citeproc --csl csl/mla-note.csl -So \ | |
print-plates/"$target".docx "$source" | |
;; | |
p) | |
echo "printing $target.pdf to print-plates/" >&2 | |
pandoc --latex-engine=xelatex --filter pandoc-citeproc --csl \ | |
csl/mla-note.csl -So print-plates/"$target".pdf "$source" | |
;; | |
m) | |
echo "printing $target.md to print-plates/" >&2 | |
pandoc "$source" -f markdown -t markdown+hard_line_breaks -So \ | |
print-plates/"$target".md | |
;; | |
\?) | |
echo "Invalid option: -$OPTARG" >&2 | |
;; | |
esac | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment