Repository navigation
fix(muya): preserve tight list block boundaries on save - #5854
Conversation
|
Friendly bump: the first-time-contributor workflows are parked for approval (Muya Lint, Muya Test, Muya Spec, Muya Build, Muya E2E, Muya Circular Dep Check), so the PR currently shows no checks. Could someone approve the runs? Lint, types, the unit suite and the spec suite are green locally. |
3ac9975 to
e36b698
Compare
e458851 to
40e7b0e
Compare
… saving A tight list item whose content is more than one block was serialized with a blank line between the blocks. CommonMark makes a list loose when one of its items directly contains two block-level elements separated by a blank line, so saving such a file changed how it renders: every item picks up paragraph spacing, and the next save changed the file again. The blank line is now written only for pairs that would otherwise end up as one block - a second paragraph, a setext underline, a dash-only thematic break, an indented code block, a footnote definition - and for the block kinds the serializer stays conservative about (an HTML block, whose block type the state does not record, and a GitHub alert, whose marker needs a blank-line delimited block). The new tests cover each shape that stays tight and each pair that keeps the separator.
40e7b0e to
ad944b8
Compare
|
Filed #5861 and linked it; thanks for the pointer, should have opened it first. The workflow runs on the latest push are still waiting for approval if you have a sec. |
|
Since I've been dealing with this type of issues recently, to keep things consistent going forward, I went ahead and made the changes directly in the PR base on your design. Thanks for your contribution. |
|
Thanks, splitting the rules into a resolver is cleaner than what I had. Ping me if anything falls out of the e2e run or if you want a follow-up on the indented-code rewrite. |
Saving a tight list whose item contains a paragraph followed by a fenced code block inserts a blank line, reopening the list as loose. A second save then adds spacing between its items. This preserves the block boundaries so the list keeps its original meaning across saves.
Closes #5861.
The serializer now delegates separator decisions to
BlockBoundaryResolver, which distinguishes adjacent blocks, required blank lines, and boundaries that require a different output spelling. Tight-item context remains local to the item's direct children. The rules cover fenced code, headings, thematic breaks, blockquote interruption, and HTML boundaries while preserving necessary separators for two paragraphs, indented code after a paragraph, Setext ambiguity, and alerts.HTML boundaries are derived from the import lexer's grammar and cached for one export, so edited HTML is classified from its current text without introducing another HTML parser or stale document metadata. Adjacent indented-code state nodes are kept as separate blocks by fencing the next block on output; this also applies outside lists and does not mutate the document state.
Regression coverage includes CommonMark example 321 / GFM example 301, HTML termination and interruption, lazy blockquote continuation, task and ordered-task items, nested lists, loose parents, footnote containers, fence safety, and repeated round trips. Source-format preservation remains tracked in #2189; editing-state looseness updates remain tracked in #5297.
Validation:
pnpm run lintandpnpm run typecheckpassed. Existing lint warnings remain.By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.