3
0
mirror of https://github.com/larvit/adf-codec.git synced 2026-11-16 21:30:25 +01:00

Answer prose round 1: 0 🔴, 6 🟡; the changelog names what breaks, the fallback reads as untyped mark, attribute or value, the spec's value list and marks paragraph split, messages name the JSON array to write

This commit is contained in:
2026-10-14 10:28:50 +02:00
committed by Lillem4n
parent 168ca1cea2
commit aefcd4b9e3
10 changed files with 37 additions and 35 deletions
+2 -2
View File
@@ -132,7 +132,7 @@ function readNamedMark(type: string, text: string, index: number, path: ConvertE
const name = readDirectiveName(text, index)
if (name === undefined) return failure('unsupported-node-shape', unnamedMarks(type), path)
const vocabulary = markVocabularies.get(name)
if (vocabulary === undefined) return failure('unsupported-node-shape', `the ${marksAttribute} attribute of ${type} names ${name}, no mark the flavour lists: spell an unlisted mark in the JSON array`, path)
if (vocabulary === undefined) return failure('unsupported-node-shape', `the ${marksAttribute} attribute of ${type} names ${name}, no mark the flavour lists: write the marks as their JSON array, marks="[{\\"type\\":\\"${name}\\"}]"`, path)
const start = index + name.length
const attributes = text.charAt(start) === '{' ? readAttributes(text, start) : { value: { attributes: new Map<string, DirectiveValue>(), end: start } }
if (attributes.fault !== undefined) {
@@ -145,7 +145,7 @@ function readNamedMark(type: string, text: string, index: number, path: ConvertE
}
function unnamedMarks(type: string): string {
return `the ${marksAttribute} attribute of ${type} names each mark with its {attrs}, one space apart: this one does not`
return `the ${marksAttribute} attribute of ${type} names its marks one space apart, each as its type and any {attrs}: this one does not`
}
function namedNode(type: string, attrs: AdfAttributes, marks: readonly AdfMark[] | undefined, empty: ReadonlySet<EmptyKey>): AdfNode {
+2 -2
View File
@@ -550,7 +550,7 @@ test('reads the reserved marks key as a JSON array where a mark is one the table
test('names the marks key no marks read back from', () => {
const array = 'unsupported-node-shape: the marks attribute of rule is its marks array in canonical JSON: this one is not'
const named = 'unsupported-node-shape: the marks attribute of rule names each mark with its {attrs}, one space apart: this one does not'
const named = 'unsupported-node-shape: the marks attribute of rule names its marks one space apart, each as its type and any {attrs}: this one does not'
assert.equal(content(losslessMarkdownToAdf('!adf:rule {marks="[]"}\n')), array)
assert.equal(content(losslessMarkdownToAdf('!adf:rule {marks="[1]"}\n')), array)
assert.equal(content(losslessMarkdownToAdf('!adf:rule {marks="{}"}\n')), named)
@@ -562,7 +562,7 @@ test('names the marks key no marks read back from', () => {
assert.equal(content(losslessMarkdownToAdf('!adf:rule {marks="breakout{mode=wide"}\n')), inBreakout('the {attrs} closing brace is missing'))
assert.equal(content(losslessMarkdownToAdf('!adf:rule {marks="em{attrs=empty}strong"}\n')), named)
assert.equal(content(losslessMarkdownToAdf('!adf:rule {marks="em{attrs=x}"}\n')), 'unsupported-node-shape: the reserved key attrs takes only the value empty: this one spells attrs=x')
assert.equal(content(losslessMarkdownToAdf('!adf:rule {marks=x}\n')), 'unsupported-node-shape: the marks attribute of rule names x, no mark the flavour lists: spell an unlisted mark in the JSON array')
assert.equal(content(losslessMarkdownToAdf('!adf:rule {marks=x}\n')), 'unsupported-node-shape: the marks attribute of rule names x, no mark the flavour lists: write the marks as their JSON array, marks="[{\\"type\\":\\"x\\"}]"')
assert.equal(content(losslessMarkdownToAdf('!adf:rule {marks="breakout{width=wide}"}\n')), 'unsupported-node-shape: the width attribute of breakout is no number')
assert.equal(content(losslessMarkdownToAdf('!adf:rule {marks="breakout{bogus=1}"}\n')), 'unsupported-node-shape: breakout holds no bogus attribute: this one spells it')
})