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:
@@ -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 }
|
||||
|
||||
Reference in New Issue
Block a user