md2pdf

pandoc wrapper to convert markdown to pdf
Index Commits Files Refs README
md2pdf (765B)
   1 #!/bin/sh
   2 
   3 usage() {
   4     echo "md2pdf <inputfile>"
   5 }
   6 
   7 [ -z "$1" ] && usage && exit 1
   8 
   9 filename=$(echo "$1" | sed 's/\.[^.]*$//')
  10 extension=$(echo "$1" | sed 's/^.*\.//')
  11 md2pdf_path=$(dirname $(readlink -f $0))
  12 style_path=$md2pdf_path"/style.tex"
  13 output="$filename.pdf"
  14 input_format="markdown+startnum+tex_math_dollars+implicit_figures"\
  15 "+grid_tables+backtick_code_blocks"
  16 
  17 [ "$extension" != "md" ] && \
  18     echo "Input file not markdown" && \
  19     usage && exit 2
  20 
  21 pandoc --pdf-engine=xelatex \
  22     -V mainfont:"Helvetica" \
  23     -V colorlinks=true \
  24     -V linkcolor=teal \
  25     -V urlcolor=teal \
  26     -V fontsize:12pt \
  27     -H $style_path \
  28     -f $input_format \
  29     --shift-heading-level-by=-1 \
  30     -o "$output" \
  31     "$filename".md
  32 
  33 [ $? -ne 0 ] && exit 3
  34 
  35 echo "\`$output\` generated successfully"