fix(parser): reset indentation in common-containers to prevent code block parsing#75
Merged
mgks merged 1 commit intodocmd-io:mainfrom Mar 9, 2026
Merged
Conversation
…lock parsing Nested containers (card, callout, collapsible) were incorrectly rendering their inner content as code blocks when indented. This happened because `createDepthTrackingContainer` used `state.md.block.tokenize()` directly, which preserved the accumulated indentation from the outer state — causing markdown-it to treat 4+ spaces of indented content as a code block. The fix mirrors the approach already used in tabs.js: - Extract raw content lines via `state.bMarks` - Apply `smartDedent` to strip minimum indentation - Use `state.md.render()` for isolated recursive parsing Closes docmd-io#74
Member
|
Funny thing, even I just found this bug yesterday trying to fix another dev server issue. Thanks for fixing this! |
Open
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
card,callout,collapsible) were rendering their inner content as code blocks when indented for readabilitycreateDepthTrackingContainercalledstate.md.block.tokenize()directly, which preserved accumulated indentation from the outer state — pushing content past markdown-it's 4-space code block thresholdtabs.js: extract raw lines, applysmartDedentto strip minimum indentation, then usestate.md.render()for isolated recursive parsingCloses #74
Test plan
card > calloutnesting renders as containers, not code blockscard > collapsiblenesting renders as containers, not code blockscard > callout > collapsible(3-level) renders correctly — exact scenario from the issuecard > card > callout > collapsible(4-level) renders correctlytabs > card > callout > collapsiblestill works (tabs path unchanged)<p>, not raw textbun test packages/parser/src/features/common-containers.test.js— all 7 tests pass