#!/usr/bin/env python3
"""Render the frozen Markdown readers with exact TeX mathematics."""
from pathlib import Path
import argparse, hashlib, json, re, subprocess
ROOT=Path(__file__).resolve().parent.parent
parser=argparse.ArgumentParser()
parser.add_argument('kind',choices=['main','technical'])
args=parser.parse_args()
stem={'main':'490d_Chronological_Families_Explanation_C1431','technical':'490d_Technical_Companion_C1431'}[args.kind]
source=ROOT/'deliverables'/(stem+'.md')
out=ROOT/'deliverables'/(stem+'.pdf')
work=ROOT/'prep'/'render';work.mkdir(exist_ok=True)
text=source.read_text()
title=text.splitlines()[0].removeprefix('# ')
text='\n'.join(text.splitlines()[1:]).lstrip()
text=re.sub(r'sandbox:/workspace/scratch/1b40da62dcbd/c1132_c1431/',str(ROOT)+'/',text)
prepared=work/(args.kind+'.md');prepared.write_text(text)
header=work/'header.tex'
header.write_text(r'\usepackage{etoolbox}'+'\n'+r'\AtBeginEnvironment{longtable}{\small}'+'\n'+r'\emergencystretch=3em'+'\n')
cmd=['pandoc',str(prepared),'-f','markdown+tex_math_single_backslash','--standalone','--pdf-engine=xelatex','--toc','--toc-depth=2','-V','mainfont=DejaVu Serif','-V','sansfont=DejaVu Sans','-V','mathfont=Latin Modern Math','-V','monofont=DejaVu Sans Mono','-V','fontsize=10pt','-V','geometry:margin=0.7in','-V','linestretch=1.08','-V','papersize=a4','-M','title='+title,'-M','date=September 28, 2026','--include-in-header='+str(header),'-o',str(out)]
result=subprocess.run(cmd,text=True,capture_output=True)
log=work/(args.kind+'_pandoc.log');log.write_text(result.stdout+result.stderr)
if result.returncode:raise SystemExit(result.returncode)
print(json.dumps({'source':str(source),'source_sha256':hashlib.sha256(source.read_bytes()).hexdigest(),'pdf':str(out),'pdf_sha256':hashlib.sha256(out.read_bytes()).hexdigest(),'bytes':out.stat().st_size,'log':str(log)}))
Evidence
render readers.py
Edition and provenance
render_readers.py
SHA-256 754ff8b3d9212c5fe9226e03c9e850bfa417a1fe450e393c7ebd6b894f2920a2
C480–C1634/Research_Cycles/C1132_C1431_Recovered/evidence/render_readers.py