-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtopdf
executable file
·34 lines (32 loc) · 960 Bytes
/
topdf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env bash
# topdf is a wrapper for a standard Pandoc configuration for rendering a
# simple Markdown file as a PDF. Requires pandoc, xelatex.
#
# Usage:
# pandoc <filename.md>
# # You can pass additional pandoc arguments.
# pandoc <filename.md> --toc
# ARG WRANGLING
if [[ $# -eq 0 ]] ; then
blog error "No input file specified.";
bashdoc "$BASH_SOURCE";
exit 1;
fi
INFILE=$1
NAME=${1%.md}
PDFNAME=${NAME}.pdf
# PROCESSING
sed -e 's/––/---/g' ${INFILE} | # Better em-dashes
sed -e 's/<br>/\\\newline /g' | # Support <br> for line breaks. Add any other operations after this...
pandoc --from=markdown --pdf-engine=xelatex -o ${PDFNAME} --variable urlcolor=NavyBlue "${@:2:99}" # ...and before this.
# Exit code from the last command.
pandoc_status="$?"
case $pandoc_status in
0)
blog info "Created $PDFNAME."
;;
*)
blog error "Failed to generate PDF. See above for details."
exit $pandoc_status
;;
esac