From 76f06da88979b2bb7e89480cd8422a88d5d560df Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sun, 11 Oct 2026 12:36:29 +0200 Subject: [PATCH] Answer stability round 1: tryImage drops an exit the comparison already takes, the README and changelog scope the linked image, and item 101 files the refusal naming its spelling --- CHANGELOG.md | 5 +++-- README.md | 2 +- src/markdown/emit/image.ts | 1 - src/markdown/emit/inline-line.ts | 1 - todo.md | 9 ++++++++- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 39a59d2..2a375be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -59,8 +59,9 @@ - **Breaking:** a link reference definition between two list items, after a blank line and at the list's own indentation, ends the list, as CommonMark reads it; `0.1.0` read one list. See `MIGRATION.md`. -- **Breaking:** `adfToLosslessMarkdown` writes an external image only a link marks as - `[![alt](url)](href)`. Convert stored markdown per `MIGRATION.md`. +- **Breaking:** `adfToLosslessMarkdown` writes a centered, uncaptioned external image whose one + mark is a link holding only `href` and `title` as `[![alt](url)](href "title")`. Convert stored + markdown per `MIGRATION.md`. - Fix the time `adfToLosslessMarkdown` and `adfToPortableMarkdown` take on text holding a long run of `*`, `_`, `~` or backticks, or a heading ending in a long run of `#`: the time is linear in the run, and a run of 20000 `*` takes milliseconds where it took seconds. diff --git a/README.md b/README.md index 8d83026..733068c 100644 --- a/README.md +++ b/README.md @@ -133,7 +133,7 @@ saving what this pair read replaces mentions, attachments and macros with text. | `decisionList` | a bullet list | — | | `mention`, `status`, `emoji`, `date` | their text: `@` kept, a mention with none `@` and its id, an emoji its `shortName` without, a date `2026-09-13` in UTC | — | | `inlineCard`, `blockCard`, `embedCard` | a link to the card's URL, else its name | — | -| external `media` | `![alt](url)` in a block, `[![alt](url)](href)` where a link marks it, `[alt](url)` inline | — | +| external `media` | in a block `![alt](url)`, or `[![alt](url)](href)` where a link marks it; inline `[alt](url)` | — | | stored `media`, `mediaInline`, `extension`, `inlineExtension` | their `alt` or `text` | — | | `layoutSection`, `bodiedExtension`, `bodiedSyncBlock`, `multiBodiedExtension`, `extensionFrame`, `caption`, a node this version does not know | its blocks or its text | — | | `placeholder` | nothing | — | diff --git a/src/markdown/emit/image.ts b/src/markdown/emit/image.ts index 1b1558c..e7edd26 100644 --- a/src/markdown/emit/image.ts +++ b/src/markdown/emit/image.ts @@ -12,7 +12,6 @@ export function tryImage(node: AdfNode): string | undefined { if (typeof url !== 'string' || (alt !== undefined && typeof alt !== 'string')) return undefined const [mark] = nodeMarks(media) const link = mark === undefined ? undefined : linkDefinition(nodeAttrs(mark)) - if (mark !== undefined && link === undefined) return undefined const read = centeredImage([externalMedia(alt ?? '', url, link)]) return serializeCanonicalJson(node, 'compact') === serializeCanonicalJson(read, 'compact') ? tryImageLine(alt, url, link) : undefined } diff --git a/src/markdown/emit/inline-line.ts b/src/markdown/emit/inline-line.ts index ec42022..5b1eb6e 100644 --- a/src/markdown/emit/inline-line.ts +++ b/src/markdown/emit/inline-line.ts @@ -68,7 +68,6 @@ export function tryPipeCell(nodes: readonly AdfNode[], path: ConvertErrorPath, f return emitted.value.line } -// `link` wraps the image as the link's whole text: `[![alt](url)](href)`. export function tryImageLine(alt: string | undefined, url: string, link?: LinkDefinition): string | undefined { if (alt !== undefined && (/^[ \t]|[ \t]$|[\n\r]/.test(alt) || holdsNullCharacter(alt))) return undefined const destination = spellDestination(url) diff --git a/todo.md b/todo.md index 28de294..9b931a9 100644 --- a/todo.md +++ b/todo.md @@ -6,7 +6,7 @@ `Bar = 9` -`Next ID = 101` +`Next ID = 102` | Goal | W | |---|---| @@ -32,6 +32,7 @@ | 59 | 0.2.1 | decision | **Group the directive grammar into `src/markdown/directive/`, move `Read` to `result.ts`, and move `Flavour` and `flavourClaims` to `markdown/flavour.ts`.** | 3 | 5 | 2 | 6 | 2 | 10.4 | | 62 | 0.2.1 | decision | **Move the portable flavour's reading out of `parse/` and its writing out of `emit/` into `markdown/portable/`, so `emit/` no longer imports `portable/`.** | 4 | 5 | 2 | 6 | 2 | 9.4 | | 96 | 0.2.1 | defect | **Read and write a text holding many unclosed backtick runs, or many `` is quadratic, in the reader and the emitter's escape walk alike. commonmark.js avoids the backtick cost by caching backtick runs by length. +### 101. Name the CommonMark spelling to write in the refusal of a directive whose node CommonMark spells. + +`directiveNode` (`src/markdown/parse/markdown-to-adf.ts`) refuses `!adf:mediaSingle` holding a linked +image with "mediaSingle takes the CommonMark spelling, not the directive form"; the README tells the +reader to write the spelling the message names, and for `[![alt](url)](href "title")` none is named. + ### 92. Lower the reading cost of the files a chunk reads most before its first commit. The last five chunks' median is 168135 new input tokens before their first commit, the five before