Read the container blocks, and part a nested list the tight spelling would swallow #32

Merged
lilleman merged 6 commits from tick-3c into main 2026-08-30 21:02:45 +02:00
2 changed files with 7 additions and 2 deletions
Showing only changes of commit bb93bc61d5 - Show all commits
+6 -1
View File
@@ -134,8 +134,9 @@ test('refuses two adjacent lists of the same kind, the marker spelling being wha
const list: AdfNode = { content: [{ content: [paragraph({ text: 'x', type: 'text' })], type: 'listItem' }], type: 'bulletList' } const list: AdfNode = { content: [{ content: [paragraph({ text: 'x', type: 'text' })], type: 'listItem' }], type: 'bulletList' }
assert.equal(code(adfToMarkdown(document(list, list))), 'unspellable-adjacent-lists') assert.equal(code(adfToMarkdown(document(list, list))), 'unspellable-adjacent-lists')
const carried: AdfNode = { ...list, attrs: { unknown: 'x' } } const carried: AdfNode = { ...list, attrs: { unknown: 'x' } }
assert.ok(markdown(adfToMarkdown(document(carried, carried))).startsWith('```adf\n')) assert.ok(markdown(adfToMarkdown(document(carried, carried))).includes('```\n\n```adf\n'))
assert.ok(markdown(adfToMarkdown(document(carried, list))).endsWith('```\n\n- x\n')) assert.ok(markdown(adfToMarkdown(document(carried, list))).endsWith('```\n\n- x\n'))
assert.ok(markdown(adfToMarkdown(document(list, carried))).startsWith('- x\n\n```adf\n'))
}) })
test('carries a node type no section spells', () => { test('carries a node type no section spells', () => {
@@ -273,6 +274,10 @@ test('parts a nested list the tight spelling would swallow from the block above
assert.equal(markdown(adfToMarkdown(outer(text('a'), { ...ordered, attrs: { order: 1 } }))), '- a\n 1. b\n') assert.equal(markdown(adfToMarkdown(outer(text('a'), { ...ordered, attrs: { order: 1 } }))), '- a\n 1. b\n')
assert.equal(markdown(adfToMarkdown(outer(text('a'), { content: [item()], type: 'bulletList' }))), '- a\n\n -\n') assert.equal(markdown(adfToMarkdown(outer(text('a'), { content: [item()], type: 'bulletList' }))), '- a\n\n -\n')
assert.equal(markdown(adfToMarkdown(outer(text('a'), { content: [item(text('b'))], type: 'bulletList' }))), '- a\n - b\n') assert.equal(markdown(adfToMarkdown(outer(text('a'), { content: [item(text('b'))], type: 'bulletList' }))), '- a\n - b\n')
const list: AdfNode = { content: [item(text('b'))], type: 'bulletList' }
const panel: AdfNode = { attrs: { panelType: 'info' }, content: [text('p')], type: 'panel' }
assert.equal(markdown(adfToMarkdown(outer(panel, list))), '- :::panel info\n p\n :::\n\n - b\n')
assert.ok(markdown(adfToMarkdown(outer(text('a'), { ...list, attrs: { unknown: 'x' } }))).startsWith('- a\n\n ```adf\n'))
}) })
test('refuses marks and attributes nested deeper than the emitter carries', () => { test('refuses marks and attributes nested deeper than the emitter carries', () => {
+1 -1
View File
@@ -55,7 +55,7 @@ function emitBlocks(nodes: readonly AdfNode[], container: BlockContainer, path:
function separationBetween(previous: PlacedBlock, next: PlacedBlock, container: BlockContainer): Result<string> { function separationBetween(previous: PlacedBlock, next: PlacedBlock, container: BlockContainer): Result<string> {
const plainPair = previous.spelling !== 'directive' && next.spelling !== 'directive' const plainPair = previous.spelling !== 'directive' && next.spelling !== 'directive'
if (next.spelling === 'list') { if (plainPair && next.spelling === 'list') {
if (previous.spelling === 'list' && previous.node.type === next.node.type) { if (previous.spelling === 'list' && previous.node.type === next.node.type) {
return failure('unspellable-adjacent-lists', `two adjacent ${next.node.type} nodes read back as one list`, next.path) return failure('unspellable-adjacent-lists', `two adjacent ${next.node.type} nodes read back as one list`, next.path)
} }