Browse Source

Add a script to convert ipython notebooks to PDFs

Samuel W. Flint 1 year ago
parent
commit
d8a120bedc
1 changed files with 31 additions and 0 deletions
  1. 31 0
      pdfipynb

+ 31 - 0
pdfipynb

@@ -0,0 +1,31 @@
+#!/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}