3
0
mirror of https://github.com/larvit/adf-codec.git synced 2026-11-21 07:32:58 +01:00

Answer stability round 1: 1 🔴, 4 🟡 (1 misread); a line gives up its first misread emphasis run, else its first misread highlight, as shipped, the run list narrows to one run, Scan holds SharedScan, the Piece arms are named, and textOpeners and guardLinkDefinition are pinned

This commit is contained in:
2026-10-28 17:36:28 +01:00
committed by Lillem4n
parent 6636f01497
commit b388b33d31
6 changed files with 83 additions and 70 deletions
+3 -9
View File
@@ -230,7 +230,7 @@ function spellableLine(leaves: AdfNode[], container: LineContainer, path: Conver
}
function withoutFallback(leaves: readonly AdfNode[], fallback: PortableLineFallback): AdfNode[] | undefined {
if (fallback.kind === 'unspellable-run') return withoutMarks(leaves, fallback.runs)
if (fallback.kind === 'unspellable-run') return withoutMark(leaves, fallback.run)
const mark = nodeMarks(leaves[0] ?? {})[0]
if (mark === undefined || mark.type !== 'link') return undefined
let last = 0
@@ -240,12 +240,6 @@ function withoutFallback(leaves: readonly AdfNode[], fallback: PortableLineFallb
return spans ? leaves.map((leaf, index) => (index > last ? leaf : withMarks(leaf, nodeMarks(leaf).filter((held) => held.type !== 'code')))) : undefined
}
// The runs cover disjoint leaves, so one pass drops them all.
function withoutMarks(leaves: readonly AdfNode[], runs: readonly MarkRun[]): AdfNode[] {
const depths = new Map<number, number>()
for (const run of runs) for (let index = run.first; index <= run.last; index += 1) depths.set(index, run.depth)
return leaves.map((leaf, index) => {
const depth = depths.get(index)
return depth === undefined ? leaf : withMarks(leaf, nodeMarks(leaf).filter((_, held) => held !== depth))
})
function withoutMark(leaves: readonly AdfNode[], run: MarkRun): AdfNode[] {
return leaves.map((leaf, index) => (index < run.first || index > run.last ? leaf : withMarks(leaf, nodeMarks(leaf).filter((_, held) => held !== run.depth))))
}