123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- #!/usr/bin/env bash
- set -euo pipefail
- IFS=$'\n\t'
- if [ $# -lt 1 ] ; then
- echo "$(basename $0) MARKDOWN-FILE" >&2
- exit 1
- fi
- MDFILE=$1
- PDFFILE=$(basename $MDFILE .md).pdf
- FILE=$(mktemp XXXXXXXXXX-${MDFILE})
- HAS_METADATA=0
- if head -n 1 ${MDFILE} | grep -- '---' > /dev/null ; then
- echo "Metadata Block Found"
- HAS_METADATA=1
- fi
- cat <<EOF >> $FILE
- ---
- documentclass: scrartcl
- classoption:
- - DIV=14
- papersize: a5
- fontsize: 10pt
- mainfont: LucidaBrightOT
- mainFontOptions:
- - Numbers=OldStyle
- sansfont: LucidaSansOT
- mathFont: LucidaBrightMathOT
- monofont: IBMPlexMono
- monofontoptions:
- - Scale=MatchLowercase
- - StylisticSet=3
- csquotes: true
- links-as-notes: true
- highlight-style: monochrome
- citemethod: biblatex
- pdfa: true
- hyperrefoptions:
- - breaklinks=true
- - bookmarks=true
- EOF
- if [ $HAS_METADATA -eq 1 ] ; then
- cat $MDFILE | sed '1 d' >> $FILE
- else
- echo "..." >> $FILE
- cat $MDFILE >> $FILE
- fi
- echo "Processing file to PDF."
- pandoc -f markdown \
- -s -t pdf \
- --highlight-style monochrome \
- --pdf-engine='lualatex' \
- -o $PDFFILE \
- $FILE
- echo "Done."
- rm $FILE
|