Skip to content

fix(website): avoid exponential pandoc parse on sidebar titles#14638

Merged
cderv merged 2 commits into
mainfrom
fix/issue-14576
Jun 30, 2026
Merged

fix(website): avoid exponential pandoc parse on sidebar titles#14638
cderv merged 2 commits into
mainfrom
fix/issue-14576

Conversation

@cderv

@cderv cderv commented Jun 30, 2026

Copy link
Copy Markdown
Member

When a website sidebar lists many pages whose titles contain double-underscore (dunder) names — e.g. Transcript.__getitem__() — rendering hangs. A site with ~20 such titles pushes a single page render past 180s, with nothing user-visible to debug.

Root Cause

Sidebar titles are rendered through the navigation envelope: each title becomes a hidden inline span, the spans are concatenated into one markdown document, Pandoc renders it, and the results are read back (src/core/markdown-pipeline.ts). Every title landed in a single paragraph of consecutive bracketed inlines. Pandoc's markdown reader backtracks exponentially over the unresolved _-emphasis candidates across consecutive bracketed inlines (jgm/pandoc#11687), so parse time blows up with the number of dunder-bearing titles.

Fix

Join the spans with a blank line so each title is its own paragraph. Pandoc parses each independently and parse time stays linear. This keeps markdown processing in titles intact (shortcodes, icons, bold, code), unlike escaping or raw-wrapping the injected content — which the upstream thread rejected for breaking exactly those.

Tests

A unit test asserts the envelope separates inline spans with a blank line. A site smoke test generates the project on the fly (many dunder titles plus bold/code titles), renders it, and asserts titles render correctly with no spurious emphasis; it carries a render-time budget (a new optional timeout on the test command) so a regression fails fast instead of hanging the suite.

Fixes #14576

@posit-snyk-bot

posit-snyk-bot commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

The navigation envelope concentrated every injected inline title into a
single hidden markdown paragraph. Pandoc's markdown reader backtracks
exponentially over unresolved emphasis candidates inside consecutive
bracketed inlines (jgm/pandoc#11687), so a site whose page titles merely
contain double-underscore names (e.g. `Class.__method__()`) hung on every
page render: ~20 such titles pushed parse time past 180s, with nothing
user-visible to debug.

Joining the spans with a blank line puts each title in its own paragraph,
so pandoc parses each independently and parse time stays linear. This keeps
markdown processing intact (shortcodes, icons, bold/code in titles still
render), unlike escaping or raw-wrapping the injected content.
@cderv cderv force-pushed the fix/issue-14576 branch from 352a88b to dacba76 Compare June 30, 2026 14:01
@cderv cderv merged commit 895a449 into main Jun 30, 2026
51 checks passed
@cderv cderv deleted the fix/issue-14576 branch June 30, 2026 14:54
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.

Website render hangs when sidebar titles contain __dunder__ names (pandoc markdown blowup via navigation envelope)

2 participants