From c7766a2d2c9eacc5fa4b48ff920e177c07fb052b Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sun, 15 Nov 2026 12:09:39 +0100 Subject: [PATCH] =?UTF-8?q?Answer=20product-owner=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=202=20=F0=9F=9F=A1=20(0=20misread);=20refuse=20a?= =?UTF-8?q?=20stray=20data-indent-level=20and=20a=20stray=20open,=20name?= =?UTF-8?q?=20open=20in=20the=20README?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AGENTS.md | 2 +- CHANGELOG.md | 4 ++-- README.md | 6 +++--- docs/decisions.md | 16 ++++++++++------ spec/html.md | 8 ++++---- src/html/parse/html-to-adf.test.ts | 6 +++++- src/html/parse/html-to-adf.ts | 4 +++- src/html/parse/inline-block.ts | 5 ++--- src/html/text-block-attributes.ts | 6 ++++-- todo.md | 6 ++---- 10 files changed, 36 insertions(+), 27 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 193a783..16c45a9 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -40,7 +40,7 @@ In `docs/decisions.md`: - The portable reader refuses what GFM's reading would drop - The portable reader reads what GFM's reading keeps - The HTML dialect -- `htmlToAdf` also reads the dialect as a browser serializes it, and an opened `
` as the same expand +- `htmlToAdf` also reads the dialect as a browser serializes it - No runtime dependencies - Standards ship as data - fast-check diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d7dc48..3897465 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,8 +11,8 @@ heading's alignment as `style="text-align:…"`, where `0.3.1` wrote the carry element, and `htmlToAdf` reads them back. The carry element `0.3.1` wrote for them still reads. - `adfToHtml` writes a paragraph's or heading's indentation as `data-indent-level="2"`, where `0.3.1` wrote the carry - element, and `htmlToAdf` reads it back. `htmlToAdf` also reads `
`, as a browser writes an expand its - user opened, as the same expand. + element, and `htmlToAdf` reads it back. The carry element `0.3.1` wrote for it still reads. +- `htmlToAdf` reads an expand's `
`, as a browser writes one its user opened, as the same expand. - `adfToHtml` writes a panel as `
`, an expand and a nested expand as `
` with the title in a ``, a task list as `
\\n"'], ['
\n

a

\n
\n', 'unmappable-html at /content/0: a
of the dialect is a carry element, holding class="adf-carry" and then data-adf alone: found "
\n

a

\n
\n', 'unmappable-html at /content/0:
takes no open attribute'], + ['
\n

a

\n
\n', 'unmappable-html at /content/0:
takes open="" once, after its other attributes'], ['
\n

a

\n
\n', 'unsupported-node-shape at /content/0:
takes no data-title attribute'], ['
\n

a

\n
\n', 'unmappable-html at /content/0:
starts with class="adf-expand" or class="adf-nested-expand": found "
\\n

a

\\n\n
\n', 'unmappable-html at /content/0/content/0: a block element of the dialect stands here: found "
\\n"'], @@ -741,6 +741,10 @@ const pinnedRefusals: readonly (readonly [string, string])[] = [ ['

a

\n', 'unmappable-html at /content/0: style on

holds text-align:center or text-align:right'], ['

a

\n', 'unmappable-html at /content/0: data-indent-level on

holds a whole number from 1 to 6'], ['

a

\n', 'unmappable-html at /content/0: data-indent-level on

holds a whole number from 1 to 6'], + ['

a

\n', 'unmappable-html at /content/0:

takes data-indent-level once, first, before its data-* attributes'], + ['

a

\n', 'unmappable-html at /content/0:

takes data-indent-level once, first, before its data-* attributes'], + ['

a

\n', 'unmappable-html at /content/0:

takes data-indent-level once, first, before its data-* attributes'], + ['

\n

a

\n
\n', 'unmappable-html at /content/0:
takes open="" once, after its other attributes'], ['

a b

\n', 'unmappable-html at /content/0/content/1: a of the dialect is a carry element, holding class="adf-carry" and then data-adf alone, or opens with class="adf-emoji", "adf-mention" or "adf-status": found ""…'], ['

a

\n', 'unmappable-html at /content/0:
holds
straight after it, or a line feed and its first block: found "

a

\\n"'], ['
  • a
\n', 'unmappable-html at /content/0:
    holds
straight after it, or a line feed and its first item: found "
  • a
  • \\n"'], diff --git a/src/html/parse/html-to-adf.ts b/src/html/parse/html-to-adf.ts index 37bb375..09f9126 100644 --- a/src/html/parse/html-to-adf.ts +++ b/src/html/parse/html-to-adf.ts @@ -244,7 +244,9 @@ function readDetails(html: string, tag: StartTag, place: Place, open: Open): Res if (type === undefined) return refused('unmappable-html', `
    starts with class="${expandClasses.expand}" or class="${expandClasses.nestedExpand}": ${foundAt(html, tag.start)}`, html, tag.start, place) const last = pairs.at(-1) const opened = last?.[0] === 'open' && last[1] === '' - const data = readDataAttributes(opened ? pairs.slice(0, -1) : pairs, tag.name, blockNodes[type].attributes, ['title']) + const rest = opened ? pairs.slice(0, -1) : pairs + if (rest.some(([name]) => name === 'open')) return refused('unmappable-html', '
    takes open="" once, after its other attributes', html, tag.start, place) + const data = readDataAttributes(rest, tag.name, blockNodes[type].attributes, ['title']) if (data.fault !== undefined) return refused(data.fault.code, data.fault.message, html, tag.start, place) const summary = html.startsWith('\n', tag.end) ? readSummary(html, tag.end + 1, place) : undefined if (summary?.ok === false) return summary diff --git a/src/html/parse/inline-block.ts b/src/html/parse/inline-block.ts index bedb17e..5da5fea 100644 --- a/src/html/parse/inline-block.ts +++ b/src/html/parse/inline-block.ts @@ -10,9 +10,8 @@ import { success } from '../../result.ts' // `own`: the attributes the element itself writes, such as a heading's level. export function readInlineBlock(html: string, tag: StartTag, type: string, vocabulary: AttributeVocabulary, own: AdfAttributes, place: Place): ReadNode { const written = Object.keys(own) - // Only a paragraph or heading takes an alignment or an indentation, as the attribute that spells it. - const aligned = type === 'paragraph' || type === 'heading' - const held = aligned ? readTextBlockAttributes(tag.attributes, tag.name, vocabulary, written) : readUnmarked(tag, vocabulary, written) + const marked = type === 'paragraph' || type === 'heading' + const held = marked ? readTextBlockAttributes(tag.attributes, tag.name, vocabulary, written) : readUnmarked(tag, vocabulary, written) if (held.fault !== undefined) return refused(held.fault.code, held.fault.message, html, tag.start, place) const inline = readInline(html, tag.end, place) if (!inline.ok) return inline diff --git a/src/html/text-block-attributes.ts b/src/html/text-block-attributes.ts index f089336..0d70496 100644 --- a/src/html/text-block-attributes.ts +++ b/src/html/text-block-attributes.ts @@ -15,7 +15,7 @@ function alignments(): ReadonlyMap { const indentAttribute = 'data-indent-level' const indentLevels = ['1', '2', '3', '4', '5', '6'] -// A paragraph's or heading's attributes: its one alignment or indentation mark as the attribute that spells it, then the rest as `dataAttributes` writes them; `undefined` where it holds a mark the attribute does not spell, or a second one. +// A paragraph's or heading's attributes: its one alignment or indentation mark as the attribute that spells it, then the rest as `dataAttributes` writes them; `undefined` where it holds a second mark, or a mark that no such attribute spells. export function textBlockAttributes(node: AdfNode, vocabulary: AttributeVocabulary, written: readonly string[]): string | undefined { const [mark, ...others] = nodeMarks(node) if (mark === undefined) return dataAttributes(node, vocabulary, written) @@ -40,7 +40,9 @@ export function readTextBlockAttributes(pairs: readonly (readonly [string, strin const [first] = pairs const mark = first === undefined ? undefined : readMark(first, element) if (mark?.fault !== undefined) return mark - const data = readDataAttributes(mark === undefined ? pairs : pairs.slice(1), element, vocabulary, written) + const rest = mark === undefined ? pairs : pairs.slice(1) + if (rest.some(([name]) => name === indentAttribute)) return { fault: { code: 'unmappable-html', message: `<${element}> takes ${indentAttribute} once, first, before its data-* attributes` } } + const data = readDataAttributes(rest, element, vocabulary, written) if (data.fault !== undefined) return data return { value: { attrs: data.value, marks: mark === undefined ? [] : [mark.value] } } } diff --git a/todo.md b/todo.md index 02f403a..27cd752 100644 --- a/todo.md +++ b/todo.md @@ -50,11 +50,9 @@ ### 188. Write no `style` attribute in `adfToHtml`: spell text and background colours, alignment and a cell's background with classes or `data-*` attributes, and read them back in `htmlToAdf`. -README goal 10 holds the dialect to semantic names, classes, ids and `data-*` attributes, never a style; styling is the consumer's, in a stylesheet of their own. The unreleased dialect writes four: `style="text-align:center|right"` on a paragraph or heading, ``, `` and a cell's `style="background-color:…"`. +The unreleased dialect writes four `style` attributes, which README goal 10 rules out: `style="text-align:center|right"` on a paragraph or heading, ``, `` and a cell's `style="background-color:…"`. -Colours are arbitrary hex values, so a class per colour cannot spell them; a `data-*` attribute holding the value, beside a class naming the element, is the likely spelling, and an alignment a class such as `adf-align-center`. Each spelling is settled by a writer panel (AGENTS.md §7), then written in `spec/html.md`, the README table and `docs/decisions.md` §The HTML dialect, whose style-spelling lines this item replaces. The carry element `0.3.1` wrote still reads; the style spellings were never released, so `htmlToAdf` stops reading them. - -Release 0.4.0 holds this item, so it is not ready to cut before this lands; the release's contents are the maintainer's, and this item is filed under the goal they stated on 2026-11-15. +A colour is any run of letters and digits after an optional `#`, so a class per colour cannot spell it. The likely spelling is a `data-*` attribute holding the value beside a class naming the element, and for an alignment a class such as `adf-align-center`. Each spelling is settled by a writer panel (AGENTS.md §7), then written in `spec/html.md`, the README table, the `CHANGELOG.md` bullets that name the `style` spellings and `docs/decisions.md` §The HTML dialect, whose style lines this item replaces. The carry element `0.3.1` wrote still reads; the style spellings were never released, so `htmlToAdf` stops reading them. ### 46. Publish the bundle size in the README, failing the release pipeline when it drifts.