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

Answer architecture round 4: the forecast and the indent leave, a writer refuses a document whose text alone passes the bound, and the joins are the one bound left

This commit is contained in:
2026-10-12 18:03:58 +02:00
committed by Lillem4n
parent ae1a47f1bc
commit a0bb09b80d
17 changed files with 110 additions and 141 deletions
+1 -5
View File
@@ -82,16 +82,12 @@ export function identicalMarks(left: readonly AdfMark[], right: readonly AdfMark
return marksKey(left) === marksKey(right)
}
export function textLength(node: AdfNode): number {
return node.text?.length ?? 0
}
// The length of the text the nodes hold, the nodes below them included.
export function heldTextLength(nodes: readonly AdfNode[]): number {
let length = 0
const pending = [...nodes]
for (let node = pending.pop(); node !== undefined; node = pending.pop()) {
length += textLength(node)
length += node.text?.length ?? 0
for (const child of nodeContent(node)) pending.push(child)
}
return length