Skip to content

fix: preserve section anchors on manual headings - #983

Open
ejgallego wants to merge 1 commit into
leanprover:mainfrom
ejgallego:fix/split-page-section-anchors-main
Open

ejgallego wants to merge 1 commit into
leanprover:mainfrom
ejgallego:fix/split-page-section-anchors-main

Conversation

@ejgallego

Copy link
Copy Markdown
Contributor

This PR restores missing id anchors on manual title pages and split chapter pages. We now emit each registered section ID on its heading, matching the existing behavior for sections rendered when in single-page output mode.

For example, render this Verso manual with htmlDepth := 1:

#docs (Manual) doc "Example" :=
:::::::
See {ref "tagged-chapter"}[the chapter].

# Tagged Chapter
%%%
tag := "tagged-chapter"
%%%

Chapter content.
:::::::

The reference points to /Tagged-Chapter/#tagged-chapter. Previously, the split-page renderer constructed its own heading without the ID. The relevant HTML changes as follows (simplified):

 <section>
-  <h1>...</h1>
+  <h1 id="tagged-chapter">...</h1>
   ...
 </section>

The link now resolves to the chapter heading correctly.

Title pages have the same missing-anchor problem, including in single-page output.

We now share the anchor, numbering, and permalink construction through a partHeading helper, used by ordinary sections, split chapters, and title pages. The helper represents the result as a Heading with explicit level, optional ID, and content, and render it through Heading.toHtml.

Breaking change: Html.titlePage now takes a Heading as its first argument. Callers passing plain title HTML must instead supply a heading with its level, ID, and content; manual renderers can use partHeading to obtain the registered anchor and existing numbering/permalink behavior.

Codex with GPT-6 was used to prepare this PR.

@ejgallego ejgallego added the bug Something isn't working label Sep 12, 2026
This PR restores missing `id` anchors on manual title pages and split chapter pages. We now emit each registered section ID on its heading, matching the existing behavior for sections rendered when in single-page output mode.

For example, render this Verso manual with `htmlDepth := 1`:

```lean
#docs (Manual) doc "Example" :=
:::::::
See {ref "tagged-chapter"}[the chapter].

# Tagged Chapter
%%%
tag := "tagged-chapter"
%%%

Chapter content.
:::::::
```

The reference points to `/Tagged-Chapter/#tagged-chapter`. Previously, the split-page renderer constructed its own heading without the ID. The relevant HTML changes as follows (simplified):

```diff
 <section>
-  <h1>...</h1>
+  <h1 id="tagged-chapter">...</h1>
   ...
 </section>
```

The link now resolves to the chapter heading correctly.

Title pages have the same missing-anchor problem, including in single-page output.

We now share the anchor, numbering, and permalink construction through a `partHeading` helper, used by ordinary sections, split chapters, and title pages. The helper represents the result as a `Heading` with explicit level, optional ID, and content, and render it through `Heading.toHtml`.

Breaking change: `Html.titlePage` now takes a `Heading` as its first argument. Callers passing plain title HTML must instead supply a heading with its level, ID, and content; manual renderers can use `partHeading` to obtain the registered anchor and existing numbering/permalink behavior.

Codex with GPT-6 was used to prepare this PR.
@ejgallego
ejgallego force-pushed the fix/split-page-section-anchors-main branch from c64479e to 5ac8de3 Compare September 12, 2026 15:30

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant