Skip to content

feat(themes): formal theme, and per-document header and footer lines - #7

Merged
apiad merged 2 commits into
mainfrom
6-formal-theme
Oct 5, 2026
Merged

apiad merged 2 commits into
mainfrom
6-formal-theme

Conversation

@apiad

@apiad apiad commented Oct 5, 2026

Copy link
Copy Markdown
Member

Fixes #6.

What changed

  • themes/formal/: extends base. All vars are black. Body and headings use Liberation Serif 12pt (Times New Roman metrics) with 2.5 cm margins. Text is justified with hyphens: manual, which matches a word processor's default.
    • ::: clauses numbers its ## headings 1., 2. and the ordered lists under them 1.1, 1.2, restarting under each clause. The theme registers it as keep_together: false, because a contract body is one long block.
    • ::: signatures holds ::: signature {name=… role=…} blocks side by side, with signing space above a rule.
    • ::: right and ::: center align a date line or a seal line.
    • The default footer is {page} / {total}.
  • Per-document header: / footer: (galley._furniture_css): left/center/right templates as @page margin boxes on every page. {page}/{total} count pages, and any other {key} reads the frontmatter or a project's vars:. A theme's top-level keys are the default; frontmatter or scriptorium.yaml replaces the whole mapping, and false removes it. A non-mapping value raises ValueError. project.py now passes header/footer through as content keys.
  • _tpl_to_css_content escapes \, " and newlines. Before, a value containing a double quote ended the CSS string and the whole margin box dropped silently.
  • Docs: README (themes table, a header/footer paragraph), themes/README.md, the authoring know-how, the CHANGELOG. examples/formal.md is a two-page services agreement that uses everything above, with citations and a footnote.

Measured

  • Suite: 262 passed locally (9 new tests in test_furniture.py and test_formal.py). This repo has no CI, so the local run is the gate.
  • Mutation checks: with the quote escaping removed, the quote test fails. With the project-key allowlist line removed, the project test fails. With one woff2 deleted, the font-URL test fails.
  • The rendered examples/formal.md has 0 colored pixels at 150 dpi (no pixel with |max−min| > 8). The same check on examples/article.md page 1 finds 7985, so the check can fail.
  • pdffonts: Liberation Serif regular, bold and italic are embedded. DejaVu Serif also appears, but only for the ↩ back-link glyph, which Liberation Serif lacks.

Tried and dropped

  • Suppressing furniture on full-page masters: a test showed a book title page already carries none, because the master's @page has zero margin. The test stays as a guard.
  • pdffonts as the font check: it cannot fail on a machine with Liberation Serif installed system-wide, so the test checks that the rewritten @font-face URLs point at existing vendored files.

Left out

  • The ↩ back-links in footnotes and references are bare text emitted by the engine, so the theme cannot hide them.
  • <html lang='en'> is hardcoded in emit(). formal does not hyphenate, so it is unaffected, but every other theme hyphenates Spanish text with English rules.
  • Conflicts with feat: render_html, WeasyPrint as the pdf extra, themes in the wheel #3, which moves _emit_css into emit.py: whichever lands second moves _furniture_css with it.
  • The fonts are full WOFF2 conversions (≈580 KB for four faces), not subsets. Subsetting would make them a Modified Version under the OFL Reserved Font Name clause.

🤖 Generated with Claude Code

apiad and others added 2 commits October 5, 2026 06:34
`formal` is the word-processor document for contracts and official letters:
all black, Liberation Serif 12pt (Times New Roman metrics, vendored), 2.5 cm
margins, `::: clauses` numbering, `::: signatures`, a page-number footer.

Frontmatter or scriptorium.yaml `header:` / `footer:` take left/center/right
templates that repeat on every page; a theme may ship defaults and `false`
removes them. Running-head values are now escaped for CSS.

Fixes #6

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@apiad
apiad merged commit 40c431a into main Oct 5, 2026
@apiad
apiad deleted the 6-formal-theme branch October 5, 2026 12:58
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.

A formal theme for contracts and official letters

1 participant