mirror of
https://github.com/larvit/adf-codec.git
synced 2026-11-20 23:25:43 +01:00
Write an external image a link marks as [](href) in both writers
This commit is contained in:
@@ -220,6 +220,13 @@ test('spells a card as a link to its url, or to its data url named by its data n
|
||||
assert.equal(portable(node('blockCard', { data: {} })), '_(link card not included)_\n')
|
||||
})
|
||||
|
||||
test('keeps the target of a link marking an external image', () => {
|
||||
const linked = (href: string, ...marks: AdfMark[]): AdfNode => ({ attrs: { alt: 'Moon', type: 'external', url: 'https://example.com/moon.png' }, marks: [{ attrs: { href, title: 'Docs', id: 'x' }, type: 'link' }, ...marks], type: 'media' })
|
||||
assert.equal(portable(node('mediaSingle', { layout: 'wide' }, linked('https://example.com/docs'))), '[](https://example.com/docs "Docs")\n')
|
||||
assert.equal(portable(node('mediaSingle', {}, linked('a\\b', { attrs: { color: '#000', size: 1 }, type: 'border' }), node('caption', {}, text('The moon.')))), '[](a%5Cb "Docs")\n\nThe moon.\n')
|
||||
assert.equal(portable(linked('')), '[](<> "Docs")\n')
|
||||
})
|
||||
|
||||
test('keeps an external image wherever it stands and spells a stored file as its alt text, else a note', () => {
|
||||
const media = (attrs: AdfAttributes): AdfNode => ({ attrs, type: 'media' })
|
||||
const caption: AdfNode = node('caption', {}, text('The moon.'))
|
||||
|
||||
Reference in New Issue
Block a user