5b1: name the line and the offset in the input a parse refusal sits at

This commit is contained in:
2026-09-03 14:37:39 +02:00
parent becc023b51
commit d3888129b0
10 changed files with 146 additions and 66 deletions
+6 -1
View File
@@ -25,12 +25,17 @@ function path(result: Result<string>): readonly (number | string)[] {
return result.ok ? ['emitted'] : result.error.path
}
test('names the node a refusal came from', () => {
function position(result: Result<string>): unknown {
return result.ok ? 'emitted' : result.error.position
}
test('names the node a refusal came from, and no source the emitter never read', () => {
const unspellable: AdfNode = { text: 'x', type: 'paragraph' }
const list: AdfNode = { content: [{ content: [paragraph({ text: 'x', type: 'text' })], type: 'listItem' }, { content: [unspellable], type: 'listItem' }], type: 'bulletList' }
assert.deepEqual(path(adfToMarkdown(document(paragraph({ text: 'x', type: 'text' }), list))), ['content', 1, 'content', 1, 'content', 0])
assert.deepEqual(path(adfToMarkdown(document(paragraph({ text: 'x', type: 'text' }, { type: 'text' })))), ['content', 0, 'content', 1])
assert.deepEqual(path(adfToMarkdown({ type: 'doc', version: 2 })), [])
assert.equal(position(adfToMarkdown(document(paragraph({ text: 'x', type: 'text' }), list))), undefined)
})
test('refuses a value that is not an ADF document', () => {