Skip to content

Restore numbered section links - #355

Merged
HamptonMakes merged 4 commits into
mainfrom
hampton-fix-numbered-section-links
Nov 30, 2026
Merged

HamptonMakes merged 4 commits into
mainfrom
hampton-fix-numbered-section-links

Conversation

@HamptonMakes

@HamptonMakes HamptonMakes commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

What changed and why

Numbered links such as #section-3-1 lost their scroll target and preview when Commonmarker 2.9 moved the generated slug onto the heading. Coplan now adds a numbered alias when the heading already has an ID, so both fragments reach the same heading. Slides match the full document's numbered aliases, including when more than one slide repeats a section number. The outline opens the target’s branch and direct URLs clear the sticky header. Existing rendered pages refresh when the standard 15-minute cache expires.

Commonmarker heading ID change

Evidence

I checked the numbered link in the browser. Focusing §3 opened the “3. Invalidation” preview, and following the link or opening its URL directly landed below the sticky header.

Numbered section preview in light mode

Numbered section preview in dark mode

How to try it

Open the demo library and choose Search latency: cutting p95 with a two-tier cache. Hover over §3 in the first paragraph to see the preview, then click it to jump to 3. Invalidation.

Testing

  • Added browser coverage for previewing and following both fragments, for loading the numbered fragment directly, and for opening the slide that owns a repeated number. The outline spec also checks that an alias opens the target and its parent.

  • Covered existing IDs, duplicate section numbers, preview markup, and alias alignment across slides.

  • Ran the 16 reference browser specs with Commonmarker 2.10.0 in an alternate bundle. All passed.

  • Ran 118 Markdown helper, plan helper, and content editing specs with Commonmarker 2.6.3 and 2.10.0. All passed.

  • Verified the outline case with both Commonmarker 2.6.3 and 2.10.0. It fails at the target’s outline toggle if alias resolution is removed.

  • Checked the numbered link in light and dark mode and attached screenshots.

Generated with Codex

@HamptonMakes
HamptonMakes marked this pull request as ready for review November 24, 2026 23:20
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T23:21:44.261000Z 02de00c Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

if (!id) return

const target = document.getElementById(id)
const headingId = target?.hasAttribute("data-heading-alias") ? target.closest("h1, h2, h3, h4, h5, h6")?.id : id

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No test covers the new step that maps a numbered alias in the URL to its heading in the outline. For example, opening #section-4-1 on a heading whose ID is 41-findings must expand the collapsed outline section that holds that heading. The new browser specs in spec/system/references_spec.rb check only that the heading is visible below the sticky header. They do not look at the outline. If this mapping breaks, the alias is not an outline entry, nothing expands, and every test still passes. Add a case next to "unfolds the target of a section link" in spec/system/outline_collapse_spec.rb that visits a numbered alias fragment on a heading with its own ID. Assert that the outline section that holds it is expanded.

content-mutation broadcast. skip_digest avoids the template-digest cost
on write paths; expiry picks up renderer changes within 15 minutes. -%>
<% cache [Coplan::EmbedDomain.order(:hostname).pluck(:hostname), request&.host, "coplan/plan-content-body-with-title", plan.id, plan.current_plan_version&.content_sha256 || plan.current_revision], expires_in: 15.minutes, skip_digest: true do %>
<% cache [Coplan::EmbedDomain.order(:hostname).pluck(:hostname), request&.host, "coplan/plan-content-body-v2", plan.id, plan.current_plan_version&.content_sha256 || plan.current_revision], expires_in: 15.minutes, skip_digest: true do %>

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this 'v2' thing? this seems like code smell...

<h2 id="gamma">1. Gamma</h2>

</section>
MARKDOWN

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this feels weird... why do we have HTML as MARKDOWN?

@HamptonMakes
HamptonMakes merged commit 6bfe165 into main Nov 30, 2026
15 checks passed
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.

2 participants