fix: exclude headings inside blockquotes from sidebar TOC#2691
Open
Bowl42 wants to merge 3 commits intodocsifyjs:developfrom
Open
fix: exclude headings inside blockquotes from sidebar TOC#2691Bowl42 wants to merge 3 commits intodocsifyjs:developfrom
Bowl42 wants to merge 3 commits intodocsifyjs:developfrom
Conversation
Headings inside blockquotes (e.g. `> # Title`) were being added to the sidebar table of contents, which is incorrect — they are quoted content, not page structure headings. The fix introduces an `insideBlockquote` flag on the compiler instance: - The blockquote compiler sets this flag to `true` before parsing its child tokens, and resets it to `false` afterward - The heading compiler checks this flag and skips adding the heading to `compiler.toc` when inside a blockquote The headings are still rendered correctly in the page content — they just no longer appear in the sidebar navigation. Fixes docsifyjs#1951 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@Bowl42 is attempting to deploy a commit to the Docsify Team on Vercel. A member of the Team first needs to authorize it. |
Replace the boolean `insideBlockquote` flag with a `blockquoteDepth` counter to correctly handle nested blockquotes. The boolean approach would reset to `false` when an inner blockquote finished parsing, causing headings in the outer blockquote after the nested one to incorrectly appear in the sidebar TOC. Also wrap the parse call in try/finally to ensure the counter is always decremented, and initialize `blockquoteDepth` in the Compiler constructor. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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
> # Title) are incorrectly added to the sidebar table of contents. They should only render as headings within the blockquote content, not appear as navigation items.heading.js) unconditionally pushes every heading tocompiler.toc, with no awareness of whether it's inside a blockquote. When the blockquote compiler (blockquote.js) callsthis.parser.parse(tokens), any headings within are processed and added to the TOC.blockquoteDepthcounter on the compiler instance. The blockquote compiler increments it before parsing child tokens and decrements it in afinallyblock. The heading compiler checks this counter and skips TOC insertion when depth > 0. A counter (rather than a boolean flag) correctly handles nested blockquotes.Changes
src/core/render/compiler.jsthis.blockquoteDepth = 0in the Compiler constructorcompiler: thistoblockquoteCompiler()so it can access the compiler instancesrc/core/render/compiler/blockquote.jscompilerfrom the options parametercompiler.blockquoteDepthbefore parsing child tokensfinallyblock to ensure cleanup even if parsing throwssrc/core/render/compiler/heading.jscompiler.toc.push(nextToc)in a check: only push when!compiler.blockquoteDepthTest plan
> # Quoted Title> > # Nested) also exclude headings from TOC> [!NOTE]) with headings also exclude those headings from TOCFixes #1951
🤖 Generated with Claude Code