3
0
mirror of https://github.com/larvit/adf-codec.git synced 2026-11-13 12:18:28 +01:00

Answer stability round 1: tryImage drops an exit the comparison already takes, the README and changelog scope the linked image, and item 101 files the refusal naming its spelling

This commit is contained in:
2026-10-11 12:36:29 +02:00
committed by Lillem4n
parent 7c42356a78
commit 5fa53cb795
5 changed files with 12 additions and 6 deletions
-1
View File
@@ -12,7 +12,6 @@ export function tryImage(node: AdfNode): string | undefined {
if (typeof url !== 'string' || (alt !== undefined && typeof alt !== 'string')) return undefined
const [mark] = nodeMarks(media)
const link = mark === undefined ? undefined : linkDefinition(nodeAttrs(mark))
if (mark !== undefined && link === undefined) return undefined
const read = centeredImage([externalMedia(alt ?? '', url, link)])
return serializeCanonicalJson(node, 'compact') === serializeCanonicalJson(read, 'compact') ? tryImageLine(alt, url, link) : undefined
}
-1
View File
@@ -68,7 +68,6 @@ export function tryPipeCell(nodes: readonly AdfNode[], path: ConvertErrorPath, f
return emitted.value.line
}
// `link` wraps the image as the link's whole text: `[![alt](url)](href)`.
export function tryImageLine(alt: string | undefined, url: string, link?: LinkDefinition): string | undefined {
if (alt !== undefined && (/^[ \t]|[ \t]$|[\n\r]/.test(alt) || holdsNullCharacter(alt))) return undefined
const destination = spellDestination(url)