3
0
mirror of https://github.com/larvit/adf-codec.git synced 2026-11-19 14:45:44 +01:00

Answer architecture round 3: one joinsBreaks flag in place of the parted set and its retry loops, a directive link spells its break, and takesMarks names the table's field

This commit is contained in:
2026-10-09 11:55:32 +02:00
committed by Lillem4n
parent e04f026676
commit 77a6806160
6 changed files with 52 additions and 65 deletions
+2 -2
View File
@@ -325,7 +325,7 @@ function linkMark({ destination, title }: LinkDefinition): AdfMark {
return { attrs: title === undefined ? { href: destination } : { href: destination, title }, type: 'link' }
}
// ADF holds no empty text node and a hard break takes no marks, so the destination text carries the link.
// ADF holds no empty text node and a hard break takes no marks, so the destination text carries the link ahead of the text's hard breaks; an empty destination leaves the breaks alone.
function linkTo(nodes: readonly Inline[], definition: LinkDefinition): Inline[] {
if (!nodes.every(takesNoMarks)) return applyMark(nodes, linkMark(definition))
return definition.destination === '' ? [...nodes] : [{ marks: [linkMark(definition)], text: definition.destination, type: 'text' }, ...nodes]
@@ -349,7 +349,7 @@ function partText(items: readonly Inline[], scan: Scan): Result<AdfNode[]> {
}
function takesNoMarks(item: Inline): boolean {
return isNode(item) && inlineNodeModel(item.type)?.marks === false
return isNode(item) && inlineNodeModel(item.type)?.takesMarks === false
}
function isNode(item: Inline): item is AdfNode {