fix: preserve lazy continuation lines in ordered lists (CommonMark)#7694
fix: preserve lazy continuation lines in ordered lists (CommonMark)#7694
Conversation
…s\n\nAdd regression test; ensure non-indented continuation lines before a blank line remain part of the current list item. Fixes #7677.
✅ Deploy Preview for tiptap-embed ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
🦋 Changeset detectedLatest commit: d755a5d 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 |
There was a problem hiding this comment.
Pull request overview
This PR updates the ordered-list Markdown tokenizer in @tiptap/extension-list to better match CommonMark behavior for “lazy continuation lines”, ensuring non-indented continuation lines remain inside the current ordered list item (until a blank line ends the item). It also adds Markdown-level regression tests to confirm parsing behavior (including marked line-break handling).
Changes:
- Adjust ordered-list item collection to include non-indented lazy continuation lines until a blank line or the next ordered list marker.
- Split list-item content into “paragraph” vs “block” parts to preserve inline continuation while still allowing nested block parsing.
- Add Markdown parsing regression tests and a changeset for the user-facing behavior change.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
packages/markdown/__tests__/ordered-list-lazy-continuation.spec.ts |
Adds regression tests covering lazy continuation lines, nested bullets, and blank-line termination. |
packages/extension-list/src/ordered-list/utils.ts |
Implements updated ordered-list item collection and content splitting to preserve lazy continuations. |
.changeset/ordered-list-lazy-continuation.md |
Adds a patch changeset documenting the ordered-list parsing fix. |
| function isBlockContentLine(line: string): boolean { | ||
| const trimmedLine = line.trimStart() | ||
|
|
||
| return ( | ||
| /^[-+*]\s+/.test(trimmedLine) || | ||
| /^\d+\.\s+/.test(trimmedLine) || | ||
| /^>\s?/.test(trimmedLine) || | ||
| /^```/.test(trimmedLine) || | ||
| /^~~~/.test(trimmedLine) | ||
| ) | ||
| } |
There was a problem hiding this comment.
Could there be other block content elements that are not covered here?
Changes Overview
Fix ordered-list markdown parsing so non-indented lazy continuation lines are kept as part of the current list item (CommonMark §5.3). This prevents continuation text from being dropped when
markedis configured withbreaks: trueand preserves nested list behavior.Implementation Approach
collectOrderedListItemsinpackages/extension-list/src/ordered-list/utils.tsto track whether a blank line has been seen and treat non-indented, non-list lines before a blank line as "lazy continuation" belonging to the current list item.contentLinesonOrderedListItem,splitItemContent(), andisBlockContentLine()helpers to separate paragraph (inline) lines from block-level lines.buildNestedStructure()to create the first paragraph usinglexer.inlineTokens()for the joined paragraph lines (sobreaks: trueproduceshardBreaktokens), and to parse later block content throughlexer.blockTokens()so nested lists / block nodes remain intact.packages/markdown/__tests__/ordered-list-lazy-continuation.spec.tsthat runs withmarkedOptions: { breaks: true }and verifies lazy continuation, nested bullet preservation, and blank-line termination..changeset/ordered-list-lazy-continuation.md.Testing Done
pnpm vitest run packages/markdown/__tests__/ordered-list-lazy-continuation.spec.ts— all tests passed.pnpm vitest run packages/markdown/__tests__/conversion.spec.ts— all tests passed.Verification Steps
git fetch && git checkout fix/ordered-list-lazy-continuationAdditional Notes
inlineTokens()to preservehardBreaknodes whenbreaks: true, while later block content is parsed viablockTokens()to retain nested lists and block nodes.Checklist
Related Issues
Fixes: #7677