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

Answer stability round 1: 1 🔴, 3 🟡 (0 misread); drop the probe files, keep a one-cell delimiter unescaped, and fix the docs

This commit is contained in:
2026-11-09 11:38:14 +01:00
committed by Lillem4n
parent db2c395d05
commit 3b61501fe2
25 changed files with 51 additions and 45 deletions
-1
View File
@@ -1 +0,0 @@
import '../html/emit/adf-to-html.ts';
-1
View File
@@ -1 +0,0 @@
import '../markdown/flavour.ts';
-1
View File
@@ -1 +0,0 @@
import '../markdown/flavour.ts';
@@ -1 +0,0 @@
import '../../markdown/flavour.ts';
-1
View File
@@ -1 +0,0 @@
import '../emit/adf-to-html.ts';
-1
View File
@@ -1 +0,0 @@
import '../html/emit/adf-to-html.ts';
@@ -1 +0,0 @@
import '../emit/image.ts';
@@ -1 +0,0 @@
import '../../html/emit/adf-to-html.ts';
-1
View File
@@ -1 +0,0 @@
import '../parse/blocks.ts';
-1
View File
@@ -1 +0,0 @@
import '../../html/emit/adf-to-html.ts';
-1
View File
@@ -1 +0,0 @@
import '../portable/conventions.ts';
+1 -2
View File
@@ -34,8 +34,7 @@ test('escapes the delimiter row a hard break leaves opening a pipe table with no
assert.equal(broken('--- | ---'), 'a | b\\\n\\--- | ---\n')
assert.equal(broken(':--- | ---:'), 'a | b\\\n\\:--- | ---:\n')
assert.equal(broken('c | d'), 'a | b\\\nc | d\n')
const oneColumn = markdown(adfToLosslessMarkdown(document(paragraph({ text: 'a |', type: 'text' }, { type: 'hardBreak' }, { text: '--- |', type: 'text' }))))
assert.equal(oneColumn, 'a |\\\n\\--- |\n')
assert.equal(readsBack(document(paragraph({ text: 'a |', type: 'text' }, { type: 'hardBreak' }, { text: '--- |', type: 'text' }))), 'a |\\\n--- |\n')
})
test('escapes only text that would otherwise open a construct', () => {
+1 -1
View File
@@ -533,7 +533,7 @@ function openGfmTable(walk: Walk, opener: string): boolean {
return true
}
// GFM, Tables: a row without its leading `|` continues the table until a blank line or a line opening another block; a line holding no `|` is one cell.
// GFM, Tables: a row without its leading `|` continues the table until a blank line or a line opening another block, and a line holding no `|` is one cell.
function pipeTableRow(claims: Claims, line: string): string[] | undefined {
const cells = pipeCells(line)
if (cells !== undefined || claims.pipeTables !== 'gfm' || isBlankLine(line) || opensBlock(claims, line)) return cells
@@ -1 +0,0 @@
import '../emit/spelling-questions.ts';
@@ -1 +0,0 @@
import '../../html/emit/adf-to-html.ts';
@@ -1 +0,0 @@
import '../portable/conventions.ts';
-1
View File
@@ -1 +0,0 @@
import '../emit/adf-to-markdown.ts';
+3 -2
View File
@@ -4,15 +4,16 @@ import { backslashEscape, claimsPipeLine, trimSpace } from './commonmark/grammar
const alignmentCell = /^:-+:?$|^-+:$/
const delimiterCell = /^-+$/
// spec/flavour.md, Tables: the cells of a row no leading `|` claimed — GFM's form without the outer pipes, one `|` making a one-column row.
// spec/flavour.md, Tables: the cells of a row no leading `|` claimed — GFM's form without the outer pipes; a closing `|` after one cell makes a one-column row.
export function barePipeCells(line: string): string[] | undefined {
const cells = splitPipeCells(line, 0)
return cells.length > 1 ? withoutClosingCell(cells) : undefined
}
// A one-cell row is no delimiter here: the hard break before it leaves its header line ending in `\`, which splits into two cells.
export function isBareDelimiterRow(line: string): boolean {
const cells = barePipeCells(line)
return cells !== undefined && isDelimiterRow(cells)
return cells !== undefined && cells.length > 1 && isDelimiterRow(cells)
}
export function isDelimiterRow(cells: readonly string[]): boolean {
@@ -406,8 +406,10 @@ test('reads GFM\'s short row padded with empty cells, a line holding no pipe as
assert.deepEqual(read('a |\n:--- |\nb\n'), [column(['a', 'b'])])
assert.deepEqual(read('| a |\n| --- |\nb\n'), [column(['a', 'b'])])
assert.deepEqual(read('a\n--- |\n'), [said('a --- |')])
const long = portableMarkdownToAdf('a | b\n--- | ---\nc | d | e\n')
assert.deepEqual(long.ok ? undefined : long.error.code, 'malformed-pipe-table')
for (const refused of ['a | b\n--- | ---\nc | d | e\n', '| a | b |\n| --- |\n']) {
const result = portableMarkdownToAdf(refused)
assert.deepEqual(result.ok ? undefined : result.error.code, 'malformed-pipe-table', refused)
}
})
test('reads what CommonMark reads where no row reads, a directive and a carry fence among it, an image sharing its paragraph with a marker among it', () => {