#!/usr/bin/env bash

# See 'usage' below.

set -o errexit # Exit on error.
set -o nounset # Treat unset vars as errors.
# set -o pipefail # Exit on error in a pipe of commands.
# set -o xtrace # Print expanded commands before executing them.

stderr() {
    # Print message on stderr
    # Done this long way instead of redirecting to make stderred add color.
    python3 -c "import sys; print('$*', file=sys.stderr)"
}

err() {
    # Print error message on stderr
    stderr "Error: $*"
}

usage() {
    echo "Usage: md2html [args] [filenames]"
    echo "Forwards [args] to pandoc conversion of each markdown filename to HTML."
}

css="$HOME/.config/watch-markdown/style.css"
pandoc --from markdown --to html --embed-resources --standalone -c "${css}" "$@"

# TODO: Pre-processing to redner pikchr diagrams? Can that be generalized,
# a notation to invoke arbitrary executables to render an image?
# Can pandoc do it for us?
