#!/bin/bash # Turn docs/basic-manual.md into docs/basic-manual.pdf (needs python3-markdown and Chrome). set -e cd "$(dirname "$0")" python3 - <<'PY' import markdown body = markdown.markdown(open("basic-manual.md").read(), extensions=["tables", "fenced_code"]) css = """ @page { size: A4; margin: 18mm 16mm; } body { font-family: "DejaVu Serif", Georgia, serif; font-size: 10.5pt; line-height: 1.45; color: #111; } h1 { font-size: 24pt; margin: 0 0 4pt; } h1 + p { font-size: 12pt; color: #444; margin-bottom: 18pt; } h2 { font-size: 15pt; border-bottom: 1px solid #999; padding-bottom: 2pt; margin-top: 22pt; page-break-after: avoid; } h3 { font-size: 12pt; margin-top: 14pt; page-break-after: avoid; } code, pre { font-family: "DejaVu Sans Mono", monospace; font-size: 9pt; } pre { background: #f2f2f2; border-left: 3px solid #4a7; padding: 6pt 8pt; page-break-inside: avoid; } table { border-collapse: collapse; margin: 6pt 0; page-break-inside: avoid; } th, td { border: 1px solid #bbb; padding: 3pt 6pt; vertical-align: top; text-align: left; } th { background: #e8e8e8; } """ open("basic-manual.html", "w").write( "Basys 3 Z-80 BASIC" "%s" % (css, body)) PY google-chrome --headless --disable-gpu --no-pdf-header-footer \ --print-to-pdf="$PWD/basic-manual.pdf" "file://$PWD/basic-manual.html" 2>/dev/null rm basic-manual.html echo "wrote docs/basic-manual.pdf"