10a - a rule opening a list item gives way, and the list stays a list
This commit is contained in:
@@ -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(said('stray'), item(said('b')), text('loose'))), '- stray\n- b\n- loose\n')
|
||||||
assert.equal(plain(bulletList()), '')
|
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({ 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')
|
assert.equal(plain(node('nestedExpand', {}, node('tableCell', {}, said('c')))), '> [!NOTE]-\n>\n> c\n')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -212,9 +212,9 @@ function listItem(blocks: Result<AdfNode[]>): Result<AdfNode[]> {
|
|||||||
return blocks.ok ? success([itemOf(blocks.value)]) : blocks
|
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 {
|
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' }
|
return { content, type: 'listItem' }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user