Skip to content

Use document heading numbering in HTML previews and exports - #60

Open
PiotrCzapla wants to merge 4 commits into
mainfrom
frontmatter-numbering
Open

Use document heading numbering in HTML previews and exports#60
PiotrCzapla wants to merge 4 commits into
mainfrom
frontmatter-numbering

Conversation

@PiotrCzapla

@PiotrCzapla PiotrCzapla commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

I hope that the ipynb could become a file format that can independently be rendered to docx, pdf & html without needing to specify anything else than the file on the command line, and eventually in solveit.

This PR is the first step. Frontmatter in ipynb has a place where one can store what numbering scheme should be used.

LLM text below:
A document should carry its heading-numbering choice into HTML. Running md2html on a contract that declares legal numbering should produce numbered clauses without a separate numbering option.

For example, put this at the start of the document:

---
number_headings: legal
---

# Agreement

## Payment

### Due date

Run md2html contract.md --frontmatter. It uses that setting to display 1. Payment and (a) Due date. The document title stays unnumbered. Use decimal for decimal numbering. An explicit numbering option overrides the document's setting.

The exporter reads the setting from the parsed document. HTML previews also number headings when references display target names instead of clause numbers. Previously, that preview mode skipped heading numbering altogether.

The same frontmatter setting also applies to notebook browser previews, GFM, and Typst export. PDF command-line support is separate work.

Tests cover the document setting, explicit overrides, invalid schemes, preview numbering, GFM, Typst, and notebook previews. The original test report records 930 passing tests and one failure attributed to a missing optional dependency. It also records passing Rust tests. I have not rerun that full suite for this description update.


Original attribution:

🤖 Generated with Claude Code & Astra

@PiotrCzapla
PiotrCzapla force-pushed the title-numbering-boundary branch from 634c419 to db57d22 Compare September 3, 2026 20:51
@PiotrCzapla
PiotrCzapla force-pushed the frontmatter-numbering branch from ad0cf5f to a1069e2 Compare September 3, 2026 20:58
… numbers on request

A document's frontmatter `number_headings: legal` (or `decimal`) now drives every
exporter when the call gives no scheme: `mdhtml2html` and `mdhtml2typst` read it
from the `Mdhtml` result's `meta`, `md2gfm` extracts it from the raw source by the
dialect's own rule (new native `frontmatter_meta`), and `viewmd` reads a notebook's
frontmatter message through fastcore's `nb_frontmatter` since `dlg2md` fences that
raw cell as code. The call argument still wins when both are present.

`refs='ids'` (the live-preview mode Solveit renders in) used to skip numbering
entirely; a requested scheme now numbers the fragment's headings there too, while
nothing numbers automatically without a registry.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@PiotrCzapla
PiotrCzapla force-pushed the title-numbering-boundary branch from db57d22 to 48954ee Compare September 3, 2026 21:01
@PiotrCzapla
PiotrCzapla force-pushed the frontmatter-numbering branch from a1069e2 to 46493bc Compare September 3, 2026 21:01
@PiotrCzapla
PiotrCzapla changed the base branch from title-numbering-boundary to main September 7, 2026 08:34
@PiotrCzapla PiotrCzapla changed the title Frontmatter number_headings selects the heading numbering; refs='ids' numbers on request Use document heading numbering in HTML previews and exports Sep 7, 2026
@PiotrCzapla
PiotrCzapla marked this pull request as ready for review September 7, 2026 11:38
@PiotrCzapla
PiotrCzapla requested a review from jph00 September 7, 2026 11:42
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.

1 participant