fix: keep a list item's non-paragraph first child nested on save - #248
Merged
Conversation
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
list_itemschema isparagraph block*, so parsing such an item fills an empty paragraph ahead of the block, and the serializer faithfully writes that paragraph as the blank marker line. Serializing the item without the filled paragraph puts the block back on the marker line, which reparses inside the item.extendSchemacreates a new slice rather than updating the commonmark one, so an override onlistItemSchemanever reaches the schema the editor holds.Related Issue
Closes #247
Verification
markdownCompatibility.test.tsxcovers a list item whose first child is fenced code, a table, a blockquote, a nested list, a heading, or a thematic break, under both ordered and unordered markers, each asserting the source serializes back unchanged. Indented code is covered separately since it normalizes to fenced, and an empty list item is asserted to stay a bare marker.Convergence over
corpus/commonmark/,corpus/gfm/, andcorpus/isolated/end-of-file/was measured with the prototype from #135, run against the branch and not committed: 13 of 16 files converged before the change and all 16 after, withcommonmark/lists-and-blockquotes.md,commonmark/text-and-breaks.md, andgfm/tables.mdas the three that moved. The same run covered the fourteen first-child cases above; one converged before, all fourteen after.Not verified: no manual pass in the desktop app. The save path writes
getMilkdownEditorMarkdownoutput verbatim, which is the function the tests call.Notes
block+would remove the filled paragraph at the source, but Milkdown's ownsplitListItem,liftListItem, andsinkListItemassume the paragraph-first shape. Not attempted here.corpus/stays with Determine whether the Markdown corpus can drive automated round-trip tests #135 as the follow-up that guards this fix.