#!/bin/bash # Turn docs/basic-manual.md into docs/basic-manual.pdf. # The Markdown is the only source: md2tex.py converts it to LaTeX, and XeLaTeX # typesets it in IBM Plex. Needs python3-markdown, XeLaTeX (texlive-xetex, # -latex-extra for KOMA-Script, tcolorbox, xltabular) and the IBM Plex fonts # in /usr/share/fonts/truetype/ibm-plex (fonts-ibm-plex). set -e cd "$(dirname "$0")" work=$(mktemp -d) trap 'rm -rf "$work"' EXIT python3 md2tex.py basic-manual.md "$work/basic-manual.tex" # three passes: contents, then page numbers in the contents, then settled for pass in 1 2 3; do if ! (cd "$work" && xelatex -interaction=nonstopmode -halt-on-error basic-manual.tex >/dev/null); then grep -A8 '^!' "$work/basic-manual.log" >&2 || tail -40 "$work/basic-manual.log" >&2 exit 1 fi done if grep -q 'Missing character' "$work/basic-manual.log"; then echo "warning: characters missing from the fonts:" >&2 grep 'Missing character' "$work/basic-manual.log" | sort -u >&2 fi cp "$work/basic-manual.pdf" basic-manual.pdf echo "wrote docs/basic-manual.pdf"