citadel

My dotfiles, scripts and nix configs
git clone git://jb55.com/citadel
Log | Files | Refs | README | LICENSE

pdfsave (350B)


      1 #!/usr/bin/env bash
      2 PANDOC=pandoc-nice
      3 
      4 usage () {
      5   printf "usage: pdfsave file.md out.pdf OR <file.md pdfsave out.pdf [markdown]\n" >&2
      6   exit 1
      7 }
      8 
      9 if [ -t 0 ]; then
     10   [ $# -eq 0 ] && usage
     11   outfile=${2:-"$(mktemp)".pdf}
     12   $PANDOC "$1" -o "$outfile"
     13 else
     14   outfile=${1:-"$(mktemp)".pdf}
     15   ext="${2:-markdown}"
     16   $PANDOC -f "$ext" -o "$outfile"
     17 fi