Fix TabsExtension breaking TableOfContentsExtension#140
Merged
dereuromark merged 1 commit intomasterfrom Mar 28, 2026
Merged
Conversation
The TabsExtension was calling $converter->render() for nested tab content, which triggered clear() on all extensions including TOC. This wiped out all headings collected before the tabs div. Now uses the renderer directly via $converter->getRenderer() to avoid the clear() call, preserving extension state during nested rendering. Fixes #139
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #140 +/- ##
=========================================
Coverage 94.21% 94.21%
Complexity 2570 2570
=========================================
Files 88 88
Lines 6846 6847 +1
=========================================
+ Hits 6450 6451 +1
Misses 396 396 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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
Fixes #139
The
TabsExtensionwas calling$converter->render()for nested tab content, which triggeredclear()on all extensions includingTableOfContentsExtension. This wiped out all headings collected before the tabs div, causing TOC to only show headings that appeared after the tabs.Root Cause
In
DjotConverter::render():When
TabsExtensioncalled$converter->render($tempDoc)to render tab panel content, it triggered thisclear()which reset the TOC's$this->toc = [].Fix
Use the renderer directly via
$converter->getRenderer()->render()instead of$converter->render()to avoid triggering theclear()call on extensions.Changes
TabsExtensionto use renderer directly for nested contenttestCompatibilityWithTableOfContents- verifies all headings before/after tabs are capturedtestTocCapturesHeadingsInsideTabs- verifies H2s around tabs are capturedtestTocWithTabsUsingLabelAttribute- verifies headings inside tabs with label attribute are captured