3
0
mirror of https://github.com/larvit/adf-codec.git synced 2026-11-19 22:55:44 +01:00

Answer product-owner round 1: 0 🔴, 2 🟡 (0 misread); refuse a stray data-indent-level and a stray open, name open in the README

This commit is contained in:
2026-11-15 12:09:39 +01:00
committed by Lillem4n
parent 0b88649dd8
commit c7766a2d2c
10 changed files with 36 additions and 27 deletions
+4 -2
View File
@@ -15,7 +15,7 @@ function alignments(): ReadonlyMap<string, string> {
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] } }
}