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

Keep both targets of a linked external image standing inline in adfToPortableMarkdown

This commit is contained in:
2026-10-14 22:17:59 +02:00
committed by Lillem4n
parent 251c8193e6
commit 3f3d0bdde7
7 changed files with 30 additions and 11 deletions
+4 -1
View File
@@ -85,7 +85,10 @@ function mediaLeaves(attrs: Readonly<AdfAttributes>, marks: readonly AdfMark[],
const alt = nonEmpty(attrs['alt'])
const url = nonEmpty(attrs['url'])
if (attrs['type'] !== 'external' || url === undefined) return textLeaves(alt, marks, container, 'image')
return linkedLeaves(alt ?? url, url, marks, container)
const href = nodeAttrs(marks.find((mark) => mark.type === 'link') ?? {})['href']
if (href === url) return textLeaves(alt ?? url, marks, container)
if (typeof href !== 'string') return linkedLeaves(alt ?? url, url, marks, container)
return [...textLeaves(alt ?? url, marks, container), textLeaf(' (', []), ...linkedLeaves('image', url, marks, container), textLeaf(')', [])]
}
function noteLeaves(name: string): AdfNode[] {