#!/bin/sh # zecrazytux # Released under the WTFPL (http://sam.zoy.org/wtfpl/COPYING) # -- user style # must be an absolute path CSS="$(pwd)/style.css" # -- executables MARKDOWN="markdown-discount" WKHTMLTOPDF="wkhtmltopdf" # -- helpers ok() { echo -e "\033[1;32m$@\033[0m" } error() { echo -e "$0: \033[1;31m$@\033[0m" exit 1 } # -- check usage, init variables if [ $# -lt 1 -o $# -gt 2 ]; then cat >&2 << EOF $0 inputfile inputfile: markdown formatted text file outputfile (optional): output PDF filename (guessed by default) EOF exit 1 fi INPUTFILE="$1" OUTPUTFILE=$(echo $INPUTFILE | sed -re 's/\.mk?d$//' -e 's/$/&.pdf/') [ -n "$2" ] && OUTPUTFILE="$2" # -- let's go { # xhtml header cat << EOF Curriculum Vitae EOF # convert markdown file to xhtml $MARKDOWN $INPUTFILE || error "Error while converting markdown to xhtml" # xhtml footer cat << EOF EOF # pipe the xhtml output to wkhtmltopdf to generate the PDF file } | $WKHTMLTOPDF - $OUTPUTFILE 2> /dev/null || error "Error while generating the PDF file" ok "Sucessfully generated $OUTPUTFILE from $INPUTFILE" exit 0