3
0
mirror of https://github.com/larvit/adf-codec.git synced 2026-11-18 22:25:44 +01:00

Answer architecture round 1: 2 🔴, 6 🟡 (0 misread); carried JSON read through adf/, one spelling home per element in html/, block readers in one table, the first paragraph's form shared, a lint boundary for html/parse, a strictness oracle

This commit is contained in:
2026-10-26 22:46:02 +01:00
committed by Lillem4n
parent 51e37f68df
commit e39ca86d74
24 changed files with 425 additions and 190 deletions
+15
View File
@@ -0,0 +1,15 @@
import type { AdfNode } from '../adf/document.ts'
import { blockNodes } from '../adf/block-nodes.ts'
import { dataAttributes } from './data-attributes.ts'
import { nodeContent } from '../adf/document.ts'
// Where a list item's first paragraph stands: `bare` on the item's line, its `element` there, or a `block` on a line of its own.
export type FirstParagraphForm = 'bare' | 'block' | 'element'
// As the writer panels picked (docs/decisions.md §The HTML dialect); a paragraph holding neither content nor an attribute, written bare, would read back as no paragraph.
export function firstParagraphForm(paragraph: AdfNode): FirstParagraphForm {
const attributes = dataAttributes(paragraph, blockNodes.paragraph.attributes, [])
if (attributes === undefined) return 'block'
if (attributes !== '') return 'element'
return nodeContent(paragraph).length === 0 ? 'block' : 'bare'
}