3
0
mirror of https://github.com/larvit/adf-codec.git synced 2026-11-12 11:48:29 +01:00

Answer stability round 1: 1 🔴, 2 🟡; a line indented four columns stays code under a table, tests pin the claim checks, the error row names a ragged body row

This commit is contained in:
2026-10-14 00:47:22 +02:00
committed by Lillem4n
parent 696ee21e63
commit 8a5e7dfa45
3 changed files with 7 additions and 2 deletions
+2 -2
View File
@@ -378,7 +378,7 @@ function readBlockLine(walk: Walk, line: Line): void {
return
}
if (leaf?.kind === 'pipe-table') {
const cells = pipeTableRow(walk.claims, removeColumns(line, largestOpenerIndentation).text)
const cells = leadingColumns(line) < indentedCodeColumns ? pipeTableRow(walk.claims, removeColumns(line, largestOpenerIndentation).text) : undefined
if (cells !== undefined) {
leaf.rows.push(cells)
return
@@ -421,7 +421,7 @@ function openLeaf(walk: Walk, line: Line): void {
else pushFault(walk, directive.fault)
return
}
if (openGfmTable(walk, opener)) return
if (leadingColumns(line) < indentedCodeColumns && openGfmTable(walk, opener)) return
const cells = walk.claims.pipeTables === false ? undefined : pipeCells(opener)
if (cells !== undefined) {
closeLeaf(walk)
@@ -237,6 +237,7 @@ test('claims the line a pipe opens and gives the rest back to the block walk', (
assert.deepEqual(content(losslessMarkdownToAdf('> | a |\n> | --- |\n')), [quote(header)])
assert.deepEqual(content(losslessMarkdownToAdf('- | a |\n | --- |\n')), [bulletList(item(header))])
assert.deepEqual(content(losslessMarkdownToAdf('| a |\n| --- |\n x\n')), [header, { content: [text('x')], type: 'codeBlock' }])
assert.deepEqual(content(losslessMarkdownToAdf('| a | b |\n| --- | --- |\nc | d\n')), [table(row(cell('tableHeader', text('a')), cell('tableHeader', text('b')))), paragraph('c | d')])
assert.deepEqual(content(losslessMarkdownToAdf('\\| a |\n')), [paragraph('| a |')])
})
@@ -293,6 +293,10 @@ test('reads GFM\'s pipe table without its leading pipes or with alignment colons
assert.deepEqual(read('a | b\n--- | --- | ---\n'), [said('a | b --- | --- | ---')])
assert.deepEqual(read('- a | b\n--- | ---\n'), [bare('bulletList', bare('listItem', said('a | b --- | ---')))])
assert.deepEqual(read('a | b\n--- | ---\nc\n'), [bare('table', table.content?.[0] ?? said('')), said('c')])
assert.deepEqual(read('a | b\nc | d\n'), [said('a | b c | d')])
assert.deepEqual(read('| a | b |\n| --- | --- |\n | c | d |\n'), [bare('table', table.content?.[0] ?? said('')), bare('codeBlock', text('| c | d |'))])
assert.deepEqual(read('a | b\n--- | ---\n c | d\n'), [bare('table', table.content?.[0] ?? said('')), bare('codeBlock', text('c | d'))])
assert.deepEqual(read('a | b\n --- | ---\nc | d\n'), [said('a | b --- | --- c | d')])
const ragged = portableMarkdownToAdf('Intro.\na | b\n--- | ---\nc | d | e\n')
assert.deepEqual(ragged.ok ? undefined : [ragged.error.code, ragged.error.position], ['malformed-pipe-table', { line: 2, offset: 7 }])
})