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

Write an external image a link marks as [![alt](url)](href) in both writers

This commit is contained in:
2026-10-11 12:19:15 +02:00
committed by Lillem4n
parent cc40fb95f2
commit 580bc862f2
15 changed files with 86 additions and 39 deletions
+5
View File
@@ -1,6 +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 { escapeUnbalanced, spellLinkTarget } from './commonmark/link-syntax.ts'
import { holdsDirectivePrefix, spellAttributes, spellVocabulary } from './directive-syntax.ts'
import { holdsEntityReference } from './commonmark/entity-references.ts'
@@ -36,6 +37,10 @@ export function markSpelling(type: string): MarkSpelling | undefined {
return { attributes, kind: spelling.kind }
}
export function linkMark({ destination, title }: LinkDefinition): AdfMark {
return { attrs: title === undefined ? { href: destination } : { href: destination, title }, type: 'link' }
}
export function linkHref(attrs: AdfAttributes): string | undefined {
const href = attrs['href']
return typeof href === 'string' ? href : undefined