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

Answer principles round 2: 1 🔴, 1 🟡; bound the collapsed label at 999 too, pinned by a test

This commit is contained in:
2026-10-23 11:04:43 +02:00
committed by Lillem4n
parent f1aca51916
commit ddcfa6ee1a
3 changed files with 16 additions and 2 deletions
+3 -2
View File
@@ -432,8 +432,9 @@ function resolveTarget(scan: Scan, start: number, index: number): { definition:
}
const label = scan.source.charAt(after) === '[' ? readLabel(scan.source, after) : undefined
// CommonMark: a label holds at most 999 characters, so longer link text names no definition.
if (label === undefined && index - start > 999) return undefined
const name = label === undefined || label.value === '' ? scan.source.slice(start, index) : label.value
const labelIsText = label === undefined || label.value === ''
if (labelIsText && index - start > 999) return undefined
const name = labelIsText ? scan.source.slice(start, index) : label.value
const definition = scan.definitions.get(normalizeLabel(name))
if (definition === undefined) return undefined
return { definition, length: label?.length ?? 0 }