#!/bin/bash
BASE="$1"
IN="${BASE}.md"
OUT="${BASE}.pdf"
CSS="${BASE}-pdf.css"

if [ ! -r "$IN" ]
then
    echo <<USAGE
usage: $0 <basename>

    ...where basename is something like doc/manual such that a manual.md
    file exists where the caller says it should be.

USAGE
fi

/Applications/calibre.app/Contents/MacOS/ebook-convert \
    "$IN" "$OUT" \
    --pdf-mono-family  'Source Code Pro' \
    --pdf-sans-family  'Myriad Pro' \
    --pdf-serif-family 'Adobe Garamond Pro' \
    --page-breaks-before / \
    --extra-css "$CSS" &&
    fossil uv add "$OUT" &&
    fossil uv sync
