52 lines
1.1 KiB
Bash
52 lines
1.1 KiB
Bash
#!/bin/bash
|
|
outfile="output.pdf"
|
|
display=false
|
|
identity=false # keep same filename, but append '.pdf'
|
|
# -o flag with argument for output file (default output.pdf)
|
|
# -i flag (short for identity) to simply add '.pdf' to the filename
|
|
# -d flag to automatically display the output file after rendering
|
|
while getopts "o:id" opt; do
|
|
case ${opt} in
|
|
o)
|
|
outfile=$OPTARG
|
|
;;
|
|
i)
|
|
identity=true
|
|
;;
|
|
d)
|
|
display=true
|
|
;;
|
|
esac
|
|
done
|
|
|
|
# remove all processed args
|
|
shift $((OPTIND - 1))
|
|
|
|
if [[ $1 == '' ]] ; then
|
|
echo "fatal: please provide an input file"
|
|
echo "usage: rndrmarkdown [-d] [-o <outfile>] infile.md"
|
|
echo "usage: rndrmarkdown [-d] [-i] infile.md"
|
|
exit 1
|
|
fi
|
|
|
|
infile=$1
|
|
|
|
if [ $identity = true ]; then
|
|
outfile="$1.pdf"
|
|
fi
|
|
|
|
echo "in $infile out $outfile display $display"
|
|
|
|
pandoc -s \
|
|
-V linkcolor:blue \
|
|
-V fontfamily:courier \
|
|
-V fontsize=12pt \
|
|
-V geometry:margin=0.85in \
|
|
-o "$outfile" "$infile"
|
|
|
|
if [[ $display == true ]] ; then
|
|
echo "opening $outfile..."
|
|
xdg-open $outfile
|
|
fi
|
|
|