diff --git a/AGENTS.md b/AGENTS.md index 4d36961..b0fedeb 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -25,7 +25,7 @@ In `docs/decisions.md`: - CommonMark is a subset - Tables - Links -- Every CommonMark image and empty link reads: the image where it stands alone, else a link +- Every CommonMark image and empty link reads: the image where it stands alone, else a link, `[]()` as nothing - Ids stay site-local - Portable task ids come from position - A callout title keeps its link targets diff --git a/README.md b/README.md index 30a4d1b..e447e6d 100644 --- a/README.md +++ b/README.md @@ -245,9 +245,10 @@ Serves Goals 1, 4 and 5. `[]()` as nothing. - An image anywhere but alone in a plain paragraph reads as its alt text linked to its URL, `See ![the moon](moon.png).` as `See [the moon](moon.png).`, and inside a link as plain text - the link marks. - - An image's title reads as its caption where the image stands alone in a plain paragraph, as - its link's title where it reads as alt text linked to its URL, and inside a link it drops. + the link marks — unless the link's whole text is the image and the link stands alone in a + plain paragraph, which reads as the image the link marks. + - An image's title reads as its caption where the image reads as an image, as its link's title + where it reads as alt text linked to its URL, and inside a link otherwise it drops. And three more: a list continuing past a marker change stays one list against CommonMark's two, a shortcut reference matching its definition only under Unicode case folding stays unresolved, diff --git a/docs/decisions.md b/docs/decisions.md index 3e20cdd..329beea 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -202,7 +202,7 @@ link reference definition — and a directive link CommonMark could spell is ref link — the bracket form goes literal, the directive form refused — which is CommonMark's prose where its reference implementation nests one `` in another. -## Every CommonMark image and empty link reads: the image where it stands alone, else a link +## Every CommonMark image and empty link reads: the image where it stands alone, else a link, `[]()` as nothing 2026-10-04, the maintainer and a writer panel, 3 of 3; `[]()` 2026-10-09, settled by Goals 4 and 7 as the maintainer's plan item directed. Goals 4, 5, 6 and 7. Valid while `mediaInline` carries no diff --git a/src/markdown/parse/markdown-to-adf.test.ts b/src/markdown/parse/markdown-to-adf.test.ts index 2fda780..e2c0f4c 100644 --- a/src/markdown/parse/markdown-to-adf.test.ts +++ b/src/markdown/parse/markdown-to-adf.test.ts @@ -1014,6 +1014,8 @@ test('reads a titled image alone in its paragraph as the image captioned with it test('reads an image alone in a link as the image the link marks, and the link a title gives as its own', () => { const linked = (node: AdfNode, mark: AdfMark): AdfNode => ({ ...node, content: (node.content ?? []).map((media) => ({ ...media, marks: [mark] })) }) assert.deepEqual(content(losslessMarkdownToAdf('[![a](/u)](/v "t")\n')), [linked(image('/u', 'a'), link('/v', 't'))]) + const captioned = linked(image('/u', 'a'), link('/v')) + assert.deepEqual(content(losslessMarkdownToAdf('[![a](/u "c")](/v)\n')), [{ ...captioned, content: [...(captioned.content ?? []), { content: [text('c')], type: 'caption' }] }]) assert.deepEqual(content(losslessMarkdownToAdf('[![a][i]][v]\n\n[i]: /u\n[v]: /v\n')), [linked(image('/u', 'a'), link('/v'))]) assert.deepEqual(content(losslessMarkdownToAdf('[[![a](/u)](/v)](/w)\n')), [{ content: [text('['), marked('a', link('/v')), text('](/w)')], type: 'paragraph' }]) })