diff --git a/MIGRATION.md b/MIGRATION.md index e738b91..b737053 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -22,6 +22,17 @@ class that keeps its fields behind getters (Vue 2, MobX) is refused too: hand in `JSON.parse(JSON.stringify(document))`. A document holding more than 10,000,000 JSON values is `unsupported-node-shape`. +`adfToHtml` writes a table cell's background as `data-background-color="…"`, where `0.3.1` wrote +`style="background-color:…"`. A page that shows the HTML loses the cell's colour unless it sets the colour from +the attribute, as this script does for cells and for colour marks: + +```js +for (const element of document.querySelectorAll('[data-background-color]')) element.style.backgroundColor = element.dataset.backgroundColor +for (const element of document.querySelectorAll('[data-text-color]')) element.style.color = element.dataset.textColor +``` + +`htmlToAdf` still reads the HTML `0.3.1` wrote. + `portableMarkdownToAdf` reads more of GFM's pipe table: - A body row holding fewer cells than the header is padded with empty cells, where `0.3.1` diff --git a/src/html/cell-element.ts b/src/html/cell-element.ts index 344c89f..bb3ee88 100644 --- a/src/html/cell-element.ts +++ b/src/html/cell-element.ts @@ -34,7 +34,7 @@ export function readCellAttributes(pairs: readonly (readonly [string, string])[] const released = name === 'data-background-color' && first?.[0] === 'style' if (first?.[0] !== name && !released) continue const value = released ? releasedBackground.exec(first[1])?.[1] : ownValue(name, first[1]) - if (value === undefined) return { fault: { code: name === 'data-colwidth' ? 'unsupported-node-shape' : 'unmappable-html', message: `${first[0]} on <${element}> spells no value adfToHtml writes there` } } + if (value === undefined) return { fault: { code: name === 'data-colwidth' ? 'unsupported-node-shape' : 'unmappable-html', message: released ? `style on <${element}> holds background-color:, then letters and digits after an optional #, as 0.3.1 wrote it; adfToHtml writes data-background-color` : `${name} on <${element}> spells no value adfToHtml writes there` } } attrs[ownKey(name)] = value rest = rest.slice(1) } diff --git a/src/html/parse/html-to-adf.test.ts b/src/html/parse/html-to-adf.test.ts index b5d98cb..ffec9da 100644 --- a/src/html/parse/html-to-adf.test.ts +++ b/src/html/parse/html-to-adf.test.ts @@ -745,17 +745,18 @@ const pinnedRefusals: readonly (readonly [string, string])[] = [ ['
a
\n', 'unmappable-html at /content/0: data-indent-level onholds a whole number from 1 to 6'], ['
a
\n', 'unmappable-html at /content/0: data-indent-level onholds a whole number from 1 to 6'], ['
a
\n', 'unmappable-html at /content/0: data-indent-level onholds a whole number from 1 to 6'], - ['
a
\n', 'unmappable-html at /content/0:takes one of data-align and data-indent-level, first, before its data-* attributes'], + ['
a
\n', 'unmappable-html at /content/0:holds at most one of data-align and data-indent-level, as its first attribute'], ['
\n\n', 'unsupported-node-shape at /content/0:a
\n
takes no data-indent-level attribute'], ['a
\n', 'unmappable-html at /content/0: data-indent-level onholds a whole number from 1 to 6'], - ['
a
\n', 'unmappable-html at /content/0:takes one of data-align and data-indent-level, first, before its data-* attributes'], - ['
a
\n', 'unmappable-html at /content/0:takes one of data-align and data-indent-level, first, before its data-* attributes'], - ['
a
\n', 'unmappable-html at /content/0:takes one of data-align and data-indent-level, first, before its data-* attributes'], + ['
a
\n', 'unmappable-html at /content/0:holds at most one of data-align and data-indent-level, as its first attribute'], + ['
a
\n', 'unmappable-html at /content/0:holds at most one of data-align and data-indent-level, as its first attribute'], + ['
a
\n', 'unmappable-html at /content/0:holds at most one of data-align and data-indent-level, as its first attribute'], ['\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, opens with class="adf-emoji", "adf-mention" or "adf-status", or holds data-text-color alone: found ""…'], ['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, opens with class="adf-emoji", "adf-mention" or "adf-status", or holds data-text-color alone: found ""…'], ['a b
\n', 'unmappable-html at /content/0/content/1: a of the dialect holds data-background-color alone: found "\n\n\n\n\n', 'unmappable-html at /content/0/content/0/content/0: style on a spells no value adfToHtml writes there'], + [' \n\n
\n', 'unmappable-html at /content/0/content/0/content/0: rowspan on\n\n a spells no value adfToHtml writes there'], + [' \n\n
\n', 'unmappable-html at /content/0/content/0/content/0: style on\n\n a holds background-color:, then letters and digits after an optional #, as 0.3.1 wrote it; adfToHtml writes data-background-color'], [' \n\n
\n', 'unmappable-html at /content/0/content/0/content/0:\n\n a takes colspan, rowspan, data-background-color and data-colwidth first, each once and in that order: found data-background-color out of place'], [' a b
\n', 'unmappable-html at /content/0/content/1: a of the dialect holds data-background-color alone: found "b\\n"'], ['\n', 'unmappable-html at /content/0:a
holdsstraight after it, or a line feed and its first block: found "a
\\n"'],