Skip to content

Instantly share code, notes, and snippets.

@alexwall
Created February 25, 2011 17:46
Show Gist options
  • Save alexwall/844179 to your computer and use it in GitHub Desktop.
Save alexwall/844179 to your computer and use it in GitHub Desktop.
takes template with -t option and searches in a custom templates dir
#!/bin/bash
# Autor: Alex Wall
# Licence: GPLv3
# pandoc (markdown2pdf) needs an path to a template
# this script searches for a template in a custom folder (TEMPLATE_DIR)
# you can pass any other option (e.g. xetex), it will be passed to markdown2pdf
# the default custom pandoc template (latex.template) in ~/.pandoc/templates
TEMPLATE="latex.template"
TEMPLATE_DIR=$HOME/.pandoc/templates/
while getopts 't:' OPTION ; do
case $OPTION in
t) TEMPLATE=$TEMPLATE_DIR$OPTARG.template
shift $((OPTIND-1));;
\?) # do nothing
;;
:) echo "Option \"-$OPTARG\" needs an argument"
echo $HELP ; exit 1;;
esac
done
# run markdown2pdf with options
markdown2pdf --template=$TEMPLATE $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment