fix(#4725): write normalization preserves tight paragraph-list shape (#4842)

* test(#4725): write normalization must not reflow untouched prose (failing first)

* fix(#4725): stop write normalization injecting a blank before a list after prose

* test(#4725): repair ordered-list fixture and list-spacing snapshot

* test(#4725): assert whole-file prose stability, fix heading-list comment

* chore(#4725): backfill changeset PR number (4842)

---------

Co-authored-by: sim <sim@local>
This commit is contained in:
Tom Boucher
2026-09-18 01:38:14 -04:00
committed by GitHub
parent c9a5cc3e12
commit 8d0b6868ae
6 changed files with 222 additions and 18 deletions

View File

@@ -420,7 +420,9 @@ describe('normalizeMd behavioral equivalence', () => {
assert.ok(result.includes('\n\n## Section One\n\n'), 'Section One heading needs blank lines');
assert.ok(result.includes('\n\n## Section Two\n\n'), 'Section Two heading needs blank lines');
assert.ok(result.includes('\n\n## Section Three\n\n'), 'Section Three heading needs blank lines');
assert.ok(result.includes('Paragraph text.\n\n- item 1'), 'list should have blank line before');
// #4725: paragraph→list is preserved byte-identical — the removed
// before-a-bullet rule used to inject a blank here (tight list turned loose).
assert.ok(result.includes('Paragraph text.\n- item 1'), 'tight paragraph→list stays byte-identical');
assert.ok(result.includes('\n\n```bash'), 'code block should have blank line before');
assert.ok(result.includes('```\n\nAfter code.'), 'code block should have blank line after');
assert.ok(result.includes('echo hello'), 'code content should be preserved');
@@ -458,7 +460,10 @@ describe('normalizeMd snapshot tests', () => {
test('snapshot - list spacing', () => {
const input = 'Paragraph\n- item 1\n- item 2\nAnother paragraph';
const expected = 'Paragraph\n\n- item 1\n- item 2\n\nAnother paragraph\n';
// #4725: the paragraph→list transition is preserved byte-identical (the
// removed before-a-bullet rule used to inject a blank there); the
// list→prose separation below is the after-a-bullet rule and stays.
const expected = 'Paragraph\n- item 1\n- item 2\n\nAnother paragraph\n';
const result = normalizeMd(input);
assert.strictEqual(result, expected,
`List spacing snapshot mismatch.\nGot: ${JSON.stringify(result)}\nExpected: ${JSON.stringify(expected)}`