32 - a mark's attribute depth is counted from its value, the marks spelling refusing its own #121

Merged
lilleman merged 3 commits from 32 into main 2026-09-23 22:53:35 +02:00
2 changed files with 5 additions and 4 deletions
Showing only changes of commit 6715c97599 - Show all commits
+1 -2
View File
@@ -61,8 +61,7 @@ test('rejects a node whose shape ProseMirror JSON cannot hold', () => {
}) })
test('names the attribute nesting past the levels the parser reads one at, and still calls the value a document', () => { test('names the attribute nesting past the levels the parser reads one at, and still calls the value a document', () => {
const deeper = (key: string, type: string, levels: number = largestNesting): string => const deeper = (key: string, type: string): string => `the ${key} attribute of ${type} nests deeper than the ${largestNesting} levels an attribute carries`
`the ${key} attribute of ${type} nests deeper than the ${levels} levels an attribute carries`
assert.equal(fault(withAttribute(nested(largestNesting))), 'accepted') assert.equal(fault(withAttribute(nested(largestNesting))), 'accepted')
assert.equal(fault(withAttribute(nested(largestNesting + 1))), deeper('a', 'paragraph')) assert.equal(fault(withAttribute(nested(largestNesting + 1))), deeper('a', 'paragraph'))
assert.equal(faultCode(withAttribute(nested(largestNesting + 1))), 'unsupported-nesting-depth') assert.equal(faultCode(withAttribute(nested(largestNesting + 1))), 'unsupported-nesting-depth')
+4 -2
View File
@@ -353,8 +353,8 @@ test('refuses marks and attributes nested deeper than the emitter carries', () =
assert.equal(code(adfToMarkdown(document(paragraph({ marks, text: 'x', type: 'text' })))), 'unsupported-nesting-depth') assert.equal(code(adfToMarkdown(document(paragraph({ marks, text: 'x', type: 'text' })))), 'unsupported-nesting-depth')
let attrs: AdfMark['attrs'] = { depth: 'x' } let attrs: AdfMark['attrs'] = { depth: 'x' }
for (let depth = 0; depth < 600; depth += 1) attrs = { depth: attrs } for (let depth = 0; depth < 600; depth += 1) attrs = { depth: attrs }
const deeper = (key: string, type: string, levels: number = largestNesting): string => const deeper = (key: string, type: string): string =>
`unsupported-nesting-depth: the ${key} attribute of ${type} nests deeper than the ${levels} levels an attribute carries` `unsupported-nesting-depth: the ${key} attribute of ${type} nests deeper than the ${largestNesting} levels an attribute carries`
const nested = (levels: number): JsonValue => { const nested = (levels: number): JsonValue => {
let value: JsonValue = 1 let value: JsonValue = 1
for (let level = 0; level < levels; level += 1) value = [value] for (let level = 0; level < levels; level += 1) value = [value]
@@ -385,6 +385,8 @@ test('refuses marks and attributes nested deeper than the emitter carries', () =
roundTrips(paragraph(card(largestNesting))) roundTrips(paragraph(card(largestNesting)))
assert.equal(markdown(adfToMarkdown(document(marked(largestNesting - 2)))), deeper('marks', 'panel')) assert.equal(markdown(adfToMarkdown(document(marked(largestNesting - 2)))), deeper('marks', 'panel'))
assert.deepEqual(path(adfToMarkdown(document(marked(largestNesting - 2)))), ['content', 0]) assert.deepEqual(path(adfToMarkdown(document(marked(largestNesting - 2)))), ['content', 0])
const markedCode: AdfNode = { content: [{ text: 'x', type: 'text' }], marks: [{ attrs: { deep: nested(largestNesting - 2) }, type: 'em' }], type: 'codeBlock' }
assert.equal(markdown(adfToMarkdown(document(markedCode))), deeper('marks', 'codeBlock'))
roundTrips(marked(largestNesting - 3)) roundTrips(marked(largestNesting - 3))
}) })