Compile one exam-workspace chapter into a readable, self-contained HTML study guide and an optional printable PDF. Keep Markdown and JSON as the auditable sources of truth. Treat study_guide/chNN.html as a derived reading view; never use it to overwrite a source file.
Use this module only after the exam workspace and current chapter are confirmed. Restore the current phase and effective artifact_mode from study_state.json before selecting <N>. A missing/legacy/unknown mode is chat and does not auto-activate this module. Proceed only for a recognized explicit visual standing preference, or for a direct one-shot request for a readable handout/HTML/PDF; a one-shot request does not rewrite the stored preference. Never inspect or infer the student's subscription. Preserve the parent exam-coach language and provenance contracts in all chat summaries.
-
Persist every new substantive explanation first with scripts/notebook.py add-entry. This renderer compiles existing evidence; it does not replace notebook-first and it never invents a quiz.
-
Resolve output intent. chat without a direct artifact request stops here and returns to conversational tutoring. visual requests the printable path; a one-shot request follows exactly the requested HTML/PDF scope. Persist a standing choice only through update_progress.py set --artifact-mode chat|visual.
-
Before rendering, read docs/pdf-capability-adapters.md and probe the machine-readable routes in docs/pdf-capability-adapters.json. Never infer availability from an agent name. Select exactly one backend:
native: an already installed host PDF capability can print/convert the exact validated study_guide/chNN.html to study_guide/chNN.pdf and can render the result for QA;
browser: use the repository fallback with a detected local Edge/Chrome;
html: HTML-only request, so no PDF backend is required.
-
Run the content/backend-aware preflight after the chapter sources exist but before invoking the renderer:
python scripts/check_deps.py --workspace <ws> --chapter <N> --artifact-mode visual --pdf-backend <native|browser|html>
Formula conversion becomes required only when the selected chapter actually contains standard $...$ / $$...$$ math. Edge/Chrome becomes required only for --pdf-backend browser. On exit 5, explain only the dependency that this exact path needs and obtain consent before installing it.
-
After the preflight succeeds, render the selected chapter HTML:
python scripts/study_guide_render.py --workspace <ws> --chapter <N>
-
Open study_guide/chNN.html. Confirm that formulas are native MathML, images are data URIs, all four content layers are present, and every empty layer is described honestly.
-
For PDF/print output, create the PDF only after HTML validation. For native, use the installed adapter to print/convert the validated HTML to the canonical study_guide/chNN.pdf path without rewriting course content. For browser, run:
python scripts/study_guide_render.py --workspace <ws> --chapter <N> --pdf
Do not call --pdf for native; that flag specifically selects the repository's local-browser print implementation.
-
Render every PDF page to an image with the selected adapter and inspect every page. Verify formula layout, glyphs, clipping, image clarity, prompt-before-answer order, expanded print answers, tables, code, margins, page breaks, orphan headings, and abnormal blank space. Fix the source or renderer, regenerate, and restart inspection from page one after any defect.