#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'

if [ $# -lt 2 ] ; then
    echo "$(basename $0) IPYNB PDF" >&2
    exit 1
fi

IPYNB=$1
PDFFILE=$2

pandoc -f ipynb+raw_html \
       -s -t pdf \
       --highlight-style monochrome \
       --pdf-engine='lualatex' \
       --lua-filter=parse-raw-blocks.lua \
       -V classoption=DIV=14 \
       -V documentclass=scrartcl \
       -V fontsize=9pt \
       -V mainfont=LucidaBrightOT \
       -V mainfontoptions=Numbers=OldStyle \
       -V sansfont=LucidaSansOT \
       -V mathfont=LucidaBrightMathOT \
       -V monofont=IBMPlexMono \
       -V monofontoptions=Scale=MatchLowercase,StylisticSet=3 \
       -V csquotes=true \
       -V pdfa=true \
       -V hyperrefoptions=breaklinks=true,bookmarks=true \
       --output=${PDFFILE}\
       ${IPYNB}