fix(core): merge task-item wrapped continuation lines instead of dropping them - #8016
Conversation
…ping them Fixes ueberdosis#7909 A task-item continuation line aligned under the marker's text column (e.g. six columns for `- [ ] `, a common authoring style that LLMs also emit) was collected as nested content and dedented by a fixed `indentLevel + baseIndentSize` amount. When the continuation was indented more than that, >= 4 residual leading spaces survived, so marked parsed the line as an indented code block — which cannot interrupt a paragraph in CommonMark, so the line was silently dropped (outright data loss on parse, worsening on every markdown round-trip). parseIndentedBlocks now peels leading lazy paragraph-continuation lines (non-blank lines directly following the item text that are not themselves block starts) into the item's mainContent, which the caller tokenizes inline — so they merge into the item's paragraph as a single paragraph, matching CommonMark renderers. Remaining genuinely-nested content is dedented by its common minimum indentation rather than a fixed amount, so a nested block indented past the base is no longer left with residual whitespace either. An isBlockStart() guard keeps real nested list items, blockquotes, fenced code, headings, and thematic breaks parsing as nested blocks. Adds regression tests (single- and multi-line continuation merge, plus a guard that a genuine nested task item still nests). Verified the two merge tests fail with only the source reverted and pass with the fix. Full markdown + core + extension-list suites (808 tests) pass.
🦋 Changeset detectedLatest commit: 6f3059d The changes in this PR will be included in the next version bump. This PR includes changesets to release 72 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ Deploy Preview for tiptap-embed ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughSummary
WalkthroughTask-item markdown parsing now merges aligned continuation lines into the item paragraph, preserves genuinely nested blocks through common-indentation dedenting, and adds regression tests for wrapped and nested task items. ChangesTask-item continuation parsing
Estimated code review effort: 3 (Moderate) | ~20 minutes Suggested labels: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Comment |
| // Peel off leading lazy paragraph-continuation lines into the item's main | ||
| // content. A soft-wrapped line that directly follows the item's text — no | ||
| // blank line separating it, and not itself the start of a new block — is a | ||
| // continuation of the item's paragraph in CommonMark, not new nested | ||
| // content. Authors (and LLMs) commonly align such wrapped lines under the | ||
| // marker's *text* column (e.g. six columns for `- [ ] `). Previously these | ||
| // were treated as nested content, dedented by a fixed amount that left >= 4 | ||
| // residual spaces, and parsed by `marked` as an indented code block — which | ||
| // cannot interrupt a paragraph, so the line was silently dropped. Merging | ||
| // them into `mainContent` (which is tokenized inline by the caller) yields a | ||
| // single paragraph, matching CommonMark renderers. |
There was a problem hiding this comment.
Make the explanatory comments more concise. Explanatory comments should help understand the code. If they are too long, they have the opposite effect of decreasing legibility.
Do not mention the previous behavior: "Previously these were treated as nested content..."
Do not mention irrelevant info: "Authors (and LLMs)..." is irrelevant, it doesn't matter who wrote the markdown content.
Make the language simple and clear to understand. A beginner developer would not know what "Peel off" means.
| // Dedent by the smallest leading indentation shared by the non-blank | ||
| // nested lines rather than a fixed `indentLevel + baseIndentSize`, so a | ||
| // genuinely-nested block indented past `indentLevel + baseIndentSize` is | ||
| // not left with residual leading whitespace (which `marked` would parse | ||
| // as an indented code block). Deeper content keeps its relative | ||
| // indentation. |
There was a problem hiding this comment.
Same here. This comment is very hard to understand. Make it clearer, make the sentences shorter. TWrite the explanatory comment yourself, do not have an LLM write it for you.
Fixes
Fixes #7909
Changes and Review
- [ ]were dedented incorrectly, leaving 4+ leading spaces — which CommonMark parses as an indented code block and silently drops.Checklist
Responsibility