#!/bin/sh # convert.sh — Convert generated Markdown ISA doc to PDF # Usage: ./convert.sh [input.md] [output.pdf] # # Requires: pandoc + xelatex (or wkhtmltopdf) # Install: brew install pandoc mactex (macOS) # apt install pandoc texlive (Linux) set -e INPUT="${1:-../../doc/spec/isa_reference.md}" OUTPUT="${2:-../../doc/spec/isa_reference.pdf}" DIR="$(cd "$(dirname "$OUTPUT")" && pwd)" BASE="$(basename "$OUTPUT")" echo "Converting: $INPUT → $OUTPUT" if command -v pandoc >/dev/null 2>&1; then if command -v xelatex >/dev/null 2>&1; then pandoc "$INPUT" \ -o "$OUTPUT" \ --pdf-engine=xelatex \ -V geometry:margin=1in \ -V colorlinks=true \ -V linkcolor=blue \ -V toccolor=blue \ -V mainfont="Times New Roman" \ -V monofont="Courier New" \ --toc --toc-depth=3 \ --highlight-style=tango echo "PDF generated: $OUTPUT" elif command -v wkhtmltopdf >/dev/null 2>&1; then DIR="$(dirname "$INPUT")" pandoc "$INPUT" \ -o "${DIR}/isa_reference.html" \ --self-contained \ --toc --toc-depth=3 wkhtmltopdf \ --margin-top 20mm \ --margin-bottom 20mm \ --margin-left 15mm \ --margin-right 15mm \ --toc \ "${DIR}/isa_reference.html" "$OUTPUT" echo "PDF generated: $OUTPUT" else echo "Error: No PDF engine found." echo "Install: brew install pandoc mactex (macOS)" echo " or: apt install pandoc texlive-latex-base (Linux)" exit 1 fi else echo "Error: pandoc not found. Install it first." exit 1 fi