From 536672219d7266803530f76b73081ea2c5ace221 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Tue, 25 Aug 2026 16:19:58 +0200 Subject: [PATCH] Bind the pipe guard and the attribute vocabulary to the milestones that inherit them --- spec/flavour.md | 6 ++++-- src/adf-to-markdown.test.ts | 6 ++++-- todo.md | 14 ++++++++++---- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/spec/flavour.md b/spec/flavour.md index f481966..906addd 100644 --- a/spec/flavour.md +++ b/spec/flavour.md @@ -43,7 +43,8 @@ normalizes to it through the round-trip. repeat — with the opener literal the closer parses as text, so `*not emphasis*` is `\*not emphasis*`, one backslash. - Blocks separated by one blank line at document level, inside a blockquote and between CommonMark - blocks; two directive blocks inside a container take none. No trailing whitespace outside a code block's + blocks; two directive blocks inside a container take none. No trailing whitespace outside a code + block's content, single trailing newline; a document with no blocks is the empty string. ## Directives @@ -215,7 +216,8 @@ and every cell carry no attrs and no marks, the first row is all `tableHeader` a `tableCell`, every row has the header's cell count, and every cell holds exactly one attr-less, mark-less paragraph — an empty cell holds one empty paragraph — with no `|` in a code span, link destination or link title: backslash escapes are inert in everything the inline layer spells -as syntax, so pipe form cannot spell that pipe and the table takes the directive form. A pipe table parses back to exactly that shape. +as syntax, so pipe form cannot spell that pipe and the table takes the directive form. A pipe table +parses back to exactly that shape. ``` | Part | Qty | diff --git a/src/adf-to-markdown.test.ts b/src/adf-to-markdown.test.ts index fa6c96c..ac6aee1 100644 --- a/src/adf-to-markdown.test.ts +++ b/src/adf-to-markdown.test.ts @@ -336,8 +336,10 @@ test('spells the image form for exactly the centered external media shape', () = assert.equal(markdown(adfToMarkdown(single({ alt: 'a [b] c', type: 'external', url }))), `![a \\[b\\] c](${url})\n`) const fallback = (attrs: AdfAttributes): boolean => markdown(adfToMarkdown(single(attrs))).startsWith(':::mediaSingle {layout=center}') assert.ok(fallback({ alt: '', type: 'external', url })) - assert.ok(fallback({ alt: 'a\nb', type: 'external', url }) && fallback({ alt: 'a\u0000b', type: 'external', url })) - assert.ok(fallback({ type: 'external', url: 'https://example.com/a b>c' }) && fallback({ alt: ' moon ', type: 'external', url })) + assert.ok(fallback({ alt: 'a\nb', type: 'external', url })) + assert.ok(fallback({ alt: 'a\u0000b', type: 'external', url })) + assert.ok(fallback({ type: 'external', url: 'https://example.com/a b>c' })) + assert.ok(fallback({ alt: ' moon ', type: 'external', url })) assert.equal(code(adfToMarkdown(single({ alt: 4, type: 'external', url }))), 'unsupported-node-shape') assert.equal(code(adfToMarkdown(single({ type: 'external', url: 4 }))), 'unsupported-node-shape') assert.equal(code(adfToMarkdown(single({ type: 'external', url }, paragraph()))), 'unsupported-node-shape') diff --git a/todo.md b/todo.md index b497c82..6562ae8 100644 --- a/todo.md +++ b/todo.md @@ -33,7 +33,8 @@ detail is settled at its own milestone. value: a `codeBlock` whose info string is empty, and an `orderedList` starting at 1, independent of the totality answer since `order: 9` keeps the markdown form either way. Neither has a second spelling to fall back to, which is what settled the third — a `media` - with an empty `alt` takes the directive form (`spec/flavour.md`, the CommonMark image). **Also blocked**: the link rule covers destination spaces only, so two shapes + with an empty `alt` takes the directive form (`spec/flavour.md`, the CommonMark image). + **Also blocked**: the link rule covers destination spaces only, so two shapes have no spelling and are refused meanwhile — href `https://example.com/a)b` and title `He said "hi"`, both in `corpus/unspellable/`. Two defensible spellings each — angle brackets or a backslash escape, and for titles `'…'` or `(…)` besides — so §8 leaves @@ -42,7 +43,9 @@ detail is settled at its own milestone. `panel` (`panelType` `warning`) holding "B" spells `A` and `:::panel warning` either on consecutive lines or with a blank line between. Two defensible spellings, so §8 leaves the pick here; `unspelled-block-separation` refuses the pair meanwhile, an empty paragraph's - `::paragraph` beside a CommonMark block included. + `::paragraph` beside a CommonMark block included — and, since a `mediaSingle`'s spelling now + follows whether CommonMark can spell its URL, two sibling images differing only by an + `&` land in the same refusal. - [x] **1d1 — The CommonMark subset**: blockquote, bulletList, codeBlock, heading, orderedList, paragraph, rule, listItem, hardBreak, text, code spans, and the `code`, `em`, `link`, `strike` and `strong` marks — one mark per text node; nesting is 1d3's. @@ -72,7 +75,9 @@ detail is settled at its own milestone. its two axes here — escapability (`attribute` for `:text{text="…"}`, `backslash`, `none`) and the emphasis role — rather than gaining a third value that means one of each. A lone surrogate in a text node emits verbatim and becomes U+FFFD on any UTF-8 encode, a §2 break - plain text still holds open — attribute values already escape it. + plain text still holds open — attribute values already escape it. The inline directives + arriving here emit their attribute values as syntax, so `spellsPipeAsSyntax` grows with + them alongside the `|` escaping `spec/flavour.md` already mandates in a pipe cell. - [ ] **2d — The opaque carry** (§3). Fixtures and emitter together, into `corpus/round-trip/opaque-carry/`: an unknown node in both positions, the reserved `adf` info string, and the `codeBlock` whose language is `adf`. @@ -105,7 +110,8 @@ detail is settled at its own milestone. `markdown/`, `html/`, the grammar module shared inside `markdown/` — while the rename is still mechanical. `block-directives.ts` is the one file that does not move whole: the node table is ADF knowledge milestones 6-7 need too and belongs in `adf/`, `spellDirectiveHeader` - in `markdown/`. The table is a second copy of `spec/flavour.md`'s prose with no drift guard, + in `markdown/`. `AttributeKind` stays above both — it is the vocabulary a string-typed + attribute grammar needs, which is why HTML will want it too, not a markdown spelling. The table is a second copy of `spec/flavour.md`'s prose with no drift guard, and a mistyped attribute name degrades into a false refusal no test catches. - [ ] **4 — Round-trip property tests** over the corpus, both ways — the thing that proves 2 and 3. Editor-normal (§2) gets its implementation here — `toEditorNormal(doc)` and the equality