Repository navigation
Fix Markdown rendering for sidebar sections with href - #14521
Open
cliffckerr wants to merge 1 commit into
Open
cliffckerr wants to merge 1 commit into
cliffckerr wants to merge 1 commit into
Conversation
Collaborator
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
3 tasks done
Collaborator
|
Thanks. |
Author
|
@mcanouil Added, let me know if it looks ok! (Edit: I see a test is failing, but it seems to have something to do with Windows/Julia and isn't related to this commit.) |
cliffckerr
force-pushed
the
fix/issue14520-section-sidebar-formatting
branch
from
October 28, 2026 23:57
f12f7d9 to
1a88396
Compare
Author
|
Hi @mcanouil -- I've made some updates so hopefully the PR is a little cleaner now. Happy to make more changes if you want! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Markdown in sidebar section titles (e.g.
**More info**) render correctly when the section has nohref, but is left as raw Markdown when the section has anhref. HTML in the same title (e.g.<b>More info</b>) renders bold in both cases. This PR fixes the Markdown case.Closes #14520.
Cause
Sidebar item text is emitted by
sidebaritem.ejsvia lodash<%= item.text %>, which is unescaped interpolation, so any raw HTML in the title passes through to the browser as-is. Markdown requires a separate post-render pass to be converted to HTML:sidebarContentsHandlerinsrc/project/types/website/website-navigation-md.ts:getUnrendered()collects each section's text and hands it to pandoc, keyed bysectionId.processRendered()walks the rendered DOM, identifies each section by readingdata-bs-targetoff.sidebar-item-text, and swaps the pandoc-rendered HTML back in.The two branches of
sidebaritem.ejsproduce different markup for the.sidebar-item-textelement:href:<a ... data-bs-toggle="collapse" data-bs-target="#<sectionId>">— hasdata-bs-target.href:<a href="..." class="sidebar-item-text sidebar-link">— nodata-bs-target.So when a section has an
href,processRenderedcan't recover thesectionId, falls through silently, and the raw markdown (**More info**) is left in the DOM.Fix
The sibling
.sidebar-item-toggleelement (the chevron button) always carriesdata-bs-target="#<sectionId>", regardless of whether the section has anhref. When.sidebar-item-textlacks the attribute, fall back to the sibling toggle.(NB: PR written with the help of Claude, but reviewed and validated by me.)