mirror of
https://github.com/larvit/adf-codec.git
synced 2026-11-12 19:58:28 +01:00
12 lines
624 B
TypeScript
12 lines
624 B
TypeScript
import type { AdfNode } from '../adf/document.ts'
|
|
|
|
// spec/flavour.md, The CommonMark image: `` reads to `centeredImage([externalMedia(alt, url)])`, the only shape `adfToLosslessMarkdown` writes as ``.
|
|
export function centeredImage(content: AdfNode[]): AdfNode {
|
|
return { attrs: { layout: 'center' }, content, type: 'mediaSingle' }
|
|
}
|
|
|
|
// `` builds no `alt`, so a media holding an empty one takes the directive form.
|
|
export function externalMedia(alt: string, url: string): AdfNode {
|
|
return { attrs: alt === '' ? { type: 'external', url } : { alt, type: 'external', url }, type: 'media' }
|
|
}
|