3
0
mirror of https://github.com/larvit/adf-codec.git synced 2026-11-20 23:25:43 +01:00

Keep a node's empty marks array where a run would span it

This commit is contained in:
2026-10-31 04:13:17 +01:00
parent 45a671b3a1
commit 5e07a1e530
3 changed files with 9 additions and 2 deletions
+6 -1
View File
@@ -47,7 +47,12 @@ function heldMark(spanned: readonly AdfNode[], index: number, depth: number, car
function skipsMark(spanned: readonly AdfNode[], index: number, mark: AdfMark, carries: Carries): boolean {
const node = spanned[index]
const kind = markSpelling(mark.type)?.kind
return node !== undefined && (kind === 'emphasis' || kind === 'link') && !carries(node, index) && !takesMark(node, mark.type)
return node !== undefined && (kind === 'emphasis' || kind === 'link') && !carries(node, index) && !takesMark(node, mark.type) && !holdsEmptyMarks(node)
}
// An empty marks array is spelled `marks=empty`, which a lent mark would erase.
function holdsEmptyMarks(node: AdfNode): boolean {
return Array.isArray(node.marks) && node.marks.length === 0
}
function withMark(node: AdfNode, mark: AdfMark, depth: number): AdfNode {