From 1104c57c0eae6428917c28c0b592cab736415533 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Fri, 25 Sep 2026 19:13:26 +0200 Subject: [PATCH] 10a - a rule opening a list item gives way, and the list stays a list --- src/markdown/emit/plain-reduction.test.ts | 3 ++- src/markdown/emit/plain-reduction.ts | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/markdown/emit/plain-reduction.test.ts b/src/markdown/emit/plain-reduction.test.ts index ec8d5f2..ad116b5 100644 --- a/src/markdown/emit/plain-reduction.test.ts +++ b/src/markdown/emit/plain-reduction.test.ts @@ -216,7 +216,8 @@ test('spells a node no row names, or one standing where no spelling holds it, as assert.equal(plain(bulletList(said('stray'), item(said('b')), text('loose'))), '- stray\n- b\n- loose\n') assert.equal(plain(bulletList()), '') assert.equal(plain(bulletList(item({ content: [text('a\n \nb')], type: 'codeBlock' }))), '- ```\n a\n\n b\n ```\n') - assert.equal(plain(bulletList(item(node('rule', {}), said('x')))), '---\n\nx\n') + assert.equal(plain(bulletList(item(node('rule', {}), said('Install')), item(said('Configure')))), '- Install\n- Configure\n') + assert.equal(plain(bulletList(item(bulletList(item(bulletList(item())))))), '- -\n') assert.equal(plain(node('nestedExpand', {}, node('tableCell', {}, said('c')))), '> [!NOTE]-\n>\n> c\n') }) diff --git a/src/markdown/emit/plain-reduction.ts b/src/markdown/emit/plain-reduction.ts index 48eb9e0..2d1de39 100644 --- a/src/markdown/emit/plain-reduction.ts +++ b/src/markdown/emit/plain-reduction.ts @@ -212,9 +212,9 @@ function listItem(blocks: Result): Result { return blocks.ok ? success([itemOf(blocks.value)]) : blocks } -// A list item holds no line of spaces alone, and a code line of them is what a reader does not see. +// A list item's first line reads as no rule and holds no line of spaces alone: the rule and the spaces give way. function itemOf(blocks: readonly AdfNode[]): AdfNode { - const content = blocks.map((block) => (block.type === 'codeBlock' ? { ...block, content: nodeContent(block).map(blankedLines) } : block)) + const content = (blocks[0]?.type === 'rule' ? blocks.slice(1) : blocks).map((block) => (block.type === 'codeBlock' ? { ...block, content: nodeContent(block).map(blankedLines) } : block)) return { content, type: 'listItem' } }