Skip to content

feat: render_html, WeasyPrint as the pdf extra, themes in the wheel - #3

Merged
apiad merged 8 commits into
mainfrom
2-render-html
Oct 20, 2026
Merged

apiad merged 8 commits into
mainfrom
2-render-html

Conversation

@apiad

@apiad apiad commented Oct 5, 2026 •

Copy link
Copy Markdown
Owner

Fixes #2. Fixes #5.

What changed

  • scriptorium/render.py: prepare() (theme, vars, preprocessors, parse) and render_html(), which returns the document HTML. render_pdf() is now prepare + WeasyPrint, with its report unchanged.

  • scriptorium/emit.py: emit(), _emit_css(), page geometry and resolve_theme_name, moved verbatim out of galley.py with an AST script. galley re-exports every moved name, so existing imports keep working. galley now holds only render_pdf, page_fills and the deck path.

  • WeasyPrint is the pdf extra and is imported lazily in measure, _render_deck and render_pdf. Without it, render_pdf raises RuntimeError("PDF output needs WeasyPrint: install scriptorium[pdf]").

  • scriptorium render X --html writes the HTML document (single file or scriptorium.yaml). A deck theme raises ValueError from render_html.

  • Themes are force-included in the wheel; THEMES_DIR resolves inside the package first, then the repo root.

  • Frozen renders (Frozen renders, and execute settings for projects #5): render_html(..., frozen=True) serves .scriptorium/freeze.json hits and never runs or tangles; a miss shows the source and warns. scriptorium.yaml now forwards execute: (interpreters, timeout).

Measured

  • Suite: 253 → 265 passed (8 new tests in tests/test_render_html.py, all seen failing first).
  • Three of the new tests run in a subprocess with sys.modules['weasyprint'] = None: render_html works, the CLI --html path works, render_pdf names the extra.
  • Wheel theme files: 0 before, 66 after. An isolated uv run --with <wheel> install (no pdf extra, weasyprint not installed) renders a theme: book document.

Left out

  • No CI in this repo; the gate was uv run pytest -q locally (261 passed).
  • measure()/pack() untouched; removing galley is separate work.

First consumer: apiad/marginalia#5.

🤖 Generated with Claude Code

apiad and others added 5 commits October 4, 2026 20:37
galley keeps the deck path and render_pdf; emit.py holds page geometry,
_emit_css, emit and resolve_theme_name, and imports nothing from WeasyPrint.
galley re-exports every moved name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
prepare() runs the preprocessors and the parser; render_html() emits the
document; render_pdf() is prepare + WeasyPrint. WeasyPrint is imported only
on the PDF and deck paths.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ment

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The wheel packaged only scriptorium/, and THEMES_DIR pointed at the repo
root, so any non-editable install had no themes (0 of 24 wheel files).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
render_html/prepare take frozen=True: cache hits are served, misses show
the source with a warning, nothing is tangled or run. scriptorium.yaml can
carry `execute:` (interpreters, timeout).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
apiad added 2 commits October 20, 2026 09:58
# Conflicts:
#	scriptorium/galley.py
#	scriptorium/project.py
# Conflicts:
#	scriptorium/galley.py
#	scriptorium/project.py
@apiad
apiad merged commit b62f636 into main Oct 20, 2026
2 checks passed
@apiad
apiad deleted the 2-render-html branch October 20, 2026 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Frozen renders, and execute settings for projects Expose render_html and make the PDF stack an optional extra

1 participant