3
0
mirror of https://github.com/larvit/adf-codec.git synced 2026-11-12 11:48:29 +01:00

Answer prose round 1: 0 🔴, 1 🟡 (0 misread); move the taskBlocks comment to the branch it governs

This commit is contained in:
2026-11-09 08:28:13 +01:00
committed by Lillem4n
parent 38e7bcfaca
commit 2bf8e37283
+1 -1
View File
@@ -65,7 +65,6 @@ function placedBlock(node: AdfNode, path: ConvertErrorPath, depth: number, writi
return block.ok ? success({ blocks: [{ ...block.value, node }], headroom: block.value.headroom }) : block
}
// A block task item reaches here holding two or more paragraphs, so the marker leads the first (`itemParts` in task-list.ts).
function taskBlocks(task: AdfNode, path: ConvertErrorPath, depth: number, writing: Writing): Result<PlacedBlocks> {
const marker = taskMarker(nodeAttrs(task)['state'])
if (task.type === 'taskItem') {
@@ -74,6 +73,7 @@ function taskBlocks(task: AdfNode, path: ConvertErrorPath, depth: number, writin
if (!line.ok) return line
return success({ blocks: [{ node: { type: 'paragraph' }, spelling: 'commonmark', text: blockText(line.value === '' ? marker : `${marker} ${line.value}`) }], headroom: Number.POSITIVE_INFINITY })
}
// `itemParts` in task-list.ts leaves a block task item holding only paragraphs, two or more, so the marker leads the first.
const walk = walkBlocks(nodeContent(task), path, depth, writing)
if (!walk.ok) return walk
const blocks = walk.value.blocks.map((block, index) => (index === 0 ? { ...block, text: prefixedText(`${marker} `, '', block.text) } : block))