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

Answer architecture round 1: the portable writer builds the linked image through externalMedia, the properties generate the image shapes, linkDefinition sits beside linkMark, the changelog drops a refusal no release met, and items 99 and 100 file the inline linked image and the caption reading

This commit is contained in:
2026-10-11 12:27:55 +02:00
committed by Lillem4n
parent aa73e7d673
commit 5f2c5083e9
9 changed files with 46 additions and 19 deletions
+9 -1
View File
@@ -1,7 +1,7 @@
import type { AdfAttributes, AdfMark, AdfNode } from '../adf/document.ts'
import type { AttributeVocabulary } from '../adf/attribute-vocabulary.ts'
import type { MarkType } from '../adf/mark-attributes.ts'
import type { LinkDefinition } from './commonmark/link-syntax.ts'
import type { MarkType } from '../adf/mark-attributes.ts'
import { escapeUnbalanced, spellLinkTarget } from './commonmark/link-syntax.ts'
import { holdsDirectivePrefix, spellAttributes, spellVocabulary } from './directive-syntax.ts'
import { holdsEntityReference } from './commonmark/entity-references.ts'
@@ -41,6 +41,14 @@ export function linkMark({ destination, title }: LinkDefinition): AdfMark {
return { attrs: title === undefined ? { href: destination } : { href: destination, title }, type: 'link' }
}
export function linkDefinition(attrs: AdfAttributes): LinkDefinition | undefined {
const destination = linkHref(attrs)
const title = attrs['title']
if (destination === undefined) return undefined
if (title === undefined) return { destination }
return typeof title === 'string' ? { destination, title } : undefined
}
export function linkHref(attrs: AdfAttributes): string | undefined {
const href = attrs['href']
return typeof href === 'string' ? href : undefined