From faae4a77fdaa9ad63967976107f868b4382d6757 Mon Sep 17 00:00:00 2001
From: Lilleman auf Larv ab
a > b
\n', ['& as &', '< as <', 'found "> b\\n"']], - ['\n', ['', '& as &', '" as "', 'found "b\\">a\\n"']], - ['&b
\n', ['& as &', '< as <', 'found "&b\\n"']], - ['a&b\n', ['& as &', '< as <', 'found "&b\\n"']],
- ['a 
\n', ['& as &', '< as <', 'found " \\n"']], - ['ax\n', ['', 'found "\na\n', ['< as <', 'found "\\n"']],
- ['\n- ab
\n
\n', ['', 'found "b \\n\\n"']],
- ['\n- if a < b
\n
\n', ['< as <', 'found "< b\\n\\n"']],
- ['\n- see x
\n
\n', ['', '& as &', '" as "', 'found "&b=2\\">x\\n\\n"']],
- ['\na
x \n
\n', ['found "x\\n"…']],
- ['\n- Bolt
\n- a
\n
\n
\n', ['found "\\n- a
\\n
\na b \n\n', ['found "b \\n\\n"']],
- ['\n- a\n
- b
\n
\n', ['found "b \\n\\n"']],
- ['x
\n', ['', 'found "x\\n"']],
- ['
x
\n', ['
', 'found "
x\\n"']],
- ['
\n', ['found "\\n"']],
- ['\n', ['', '& as &', '" as "', 'found "&b=2\\">x"…']],
- [`a
\n${carry('div', panel, 'Check the collation.
')}\n`, ['to change the node, edit its ADF and write the HTML again', 'found "collation.a\n', ['found "a\\n"']],
- ['\n', ['found "{ "type":""…']],
- [`${documentCarry}\n
\n`, ['found "\\n
\\n"']],
- [`
\n${documentCarry}\n`, ['found "\nBolt
\n\n', ['found "Bolt
\\n\\n"']],
- ['\n \n
\n', ['found "\\n\\n"']],
- ['\n- \n\n
\n
\n', ['found "
b\n', ['found "b\\n"']],
- ['
\n', ['found "
"…']],
- ['\n- a
\n
\n', ['found "03\\">\\na \\n\\n"']],
- ['a
\n', ['', 'takes no class attribute']],
- ['
a
\n', ['', 'takes no data-color attribute']],
- ['
\n- a
\n
\n', ['', 'found start after data-local-id']],
- ['\n- a
\n
\n', ['', 'found start after start']],
- ['\n- a
\n
\n', ['', 'takes no data-bogus attribute']],
+ ['ab
\n', [' as written here is no inline element of the dialect', 'found "b\\n"']],
+ ['a > b
\n', ['text escapes & as &', '> as >', 'found "> b\\n"']],
+ ['\n', [' holds its attributes as name="value"', '" as "', 'found "b\\">a\\n"']],
+ ['&b
\n', ['text escapes & as &', 'found "&b\\n"']],
+ ['a&b
\n', ['text escapes & as &', 'found "&b\\n"']],
+ ['a 
\n', ['text escapes & as &', 'found " \\n"']],
+ ['a
', 'found "x\n', [' as written here is no code element of the dialect', 'found "\n- a\n', ['the line ends at
', '< as <', 'found "\\n"']],
+ ['\n- ab
\n
\n', [' as written here is no inline element of the dialect', 'found "b\\n\\n"']],
+ ['\n- if a < b
\n
\n', ['the line ends at ', '< as <', 'found "< b\\n\\n"']],
+ ['\n- see x
\n
\n', [' holds its attributes as name="value"', '& as &', '" as "', 'found "&b=2\\">x\\n\\n"']],
+ ['\na
x \n
\n', ['the line ends at ', 'found "x\\n"…']],
+ ['\n- Bolt
\n- a
\n
\n
\n', ['the line ends at ', 'found "\\n- a
\\n
\n- a
- b
\n\n', ['the line ends at ', 'found "- b
\\n\\n"']],
+ ['\n- a\n
- b
\n
\n', ['the line ends at ', 'found "- b
\\n\\n"']],
+ ['x
\n', [' as written here is no mark element of the dialect', 'found "x\\n"']],
+ ['
x
\n', ['
as written here is no mark element of the dialect', 'found "
x\\n"']],
+ ['
\n', ['a mark element holds text', 'found "\\n"']],
+ ['\n', [' holds its attributes as name="value"', '& as &', '" as "', 'found "&b=2\\">x"…']],
+ [`a
\n${carry('div', panel, 'Check the collation.
')}\n`, ['a carry element shows what adfToHtml writes for its node', 'to change the node, edit its ADF and write the HTML again', 'found "collation.a\n', ['a of the dialect is a carry element', 'found "a\\n"']],
+ ['\n', ['a carry element spells its node\'s JSON canonically', 'found "{ "type":""…']],
+ [`${documentCarry}\n
\n`, ['a carry element holding the document stands alone', 'found "\\n
\\n"']],
+ [`
\n${documentCarry}\n`, ['a carry element holding the document stands alone', 'found "\nBolt
\n\n', ['an item\'s or cell\'s first paragraph holding content and no attribute stands bare on the line of the item\'s or cell\'s start tag', 'found "Bolt
\\n\\n"']],
+ ['\n \n
\n', ['an item\'s or cell\'s first paragraph holding neither content nor an attribute stands on a line of its own', 'found "\\n\\n"']],
+ ['\n- \n\n
\n
\n', ['an item\'s or cell\'s first paragraph holding an attribute stands as its straight after the item\'s or cell\'s start tag', 'found "
b\n', ['an image stands alone in its paragraph as
', 'found "b\\n"']],
+ ['
\n', ['an image stands alone in its paragraph as
', 'found "
"…']],
+ ['\n- a
\n
\n', ['an ordered list starts at an integer', 'found "03\\">\\n- a
\\n\\n"']],
+ ['a
\n', ['', 'no class attribute']],
+ ['
a
\n', ['', 'no data-color attribute']],
+ ['
\n- a
\n
\n', [' takes start once', 'found start after data-local-id']],
+ ['\n- a
\n
\n', [' takes start once', 'found start after start']],
+ ['\n- a
\n
\n', ['', 'no data-bogus attribute']],
['x
\n', ['data-wrap', 'boolean']],
- ['
\n', ['', 'found "\\n"']],
- ['\n', ['', 'to change the card, change them together', 'found "Spec\\n"']],
- [`\n`, ['', 'to change the card, change them together', 'found "Plan\\n"']],
- ['\n', ['\\n"']],
- ['a
\n', ['', 'takes no data-size attribute']],
- ['a&b
\n', ['& as &', '< as <', 'found "&b\\n"']],
+ ['
\n', [' holds its text', 'found "\\n"']],
+ ['\n', [' holds one URL', 'to change the card, change them together', 'found "Spec\\n"']],
+ [`\n`, [' holds one URL', 'to change the card, change them together', 'found "Plan\\n"']],
+ ['\n', ['\\n"']],
+ ['a
\n', ['', 'no data-size attribute']],
+ ['a&b
\n', ['text escapes & as &', 'found "&b\\n"']],
]
for (const [html, facts] of messages) test(`names what it found where reading stopped, a character no one sees as its escape: ${JSON.stringify(html)}`, () => names(htmlToAdf(html), ...facts))
diff --git a/src/markdown/parse/markdown-to-adf.test.ts b/src/markdown/parse/markdown-to-adf.test.ts
index 1635f22..c44fdd8 100644
--- a/src/markdown/parse/markdown-to-adf.test.ts
+++ b/src/markdown/parse/markdown-to-adf.test.ts
@@ -139,7 +139,7 @@ test('builds an empty document from input holding no block, and one holding no c
assert.deepEqual(losslessMarkdownToAdf('\n \n\t\n'), { ok: true, value: { content: [], type: 'doc', version: 1 } })
assert.deepEqual(losslessMarkdownToAdf('!adf:doc {content=none}\n'), { ok: true, value: { type: 'doc', version: 1 } })
assert.deepEqual(losslessMarkdownToAdf('\n!adf:doc {content=none}\n\n'), { ok: true, value: { type: 'doc', version: 1 } })
- const form = ['!adf:doc {content=none}']
+ const form = ['!adf:doc {content=none}', 'spells another']
refused(losslessMarkdownToAdf('!adf:doc\n'), 'unsupported-node-shape', ...form)
refused(losslessMarkdownToAdf('!adf:doc x {content=none}\n'), 'unsupported-node-shape', ...form)
refused(losslessMarkdownToAdf('!adf:doc {content=empty}\n'), 'unsupported-node-shape', 'empty markdown', '!adf:doc {content=none}', 'content=empty')
@@ -147,7 +147,7 @@ test('builds an empty document from input holding no block, and one holding no c
const alone = ['delete the !adf:doc {content=none} line', 'whole document']
refused(losslessMarkdownToAdf('x\n\n!adf:doc {content=none}\n'), 'unsupported-node-shape', ...alone)
refused(losslessMarkdownToAdf('!adf:panel info\n!adf:doc {content=none}\n!adf:/panel\n'), 'unsupported-node-shape', ...alone)
- refused(losslessMarkdownToAdf('!adf:doc\n!adf:/doc\n'), 'malformed-directive', '!adf:/doc', '\\!adf:')
+ refused(losslessMarkdownToAdf('!adf:doc\n!adf:/doc\n'), 'malformed-directive', 'takes no body', '!adf:/doc', '\\!adf:')
refused(losslessMarkdownToAdf('a !adf:doc{content=none}\n'), 'unsupported-node-shape', '!adf:doc', 'inline form')
})
@@ -248,8 +248,8 @@ test('names the pipe table a claimed line does not spell', () => {
refused(losslessMarkdownToAdf('| a | b |\n'), 'malformed-pipe-table', '`-`', '\\|')
refused(losslessMarkdownToAdf('| a |\n| x |\n'), 'malformed-pipe-table', '`-`', '\\|')
refused(losslessMarkdownToAdf('| a | b |\n| :--- | ---: |\n'), 'malformed-pipe-table', 'alignment colon')
- refused(losslessMarkdownToAdf('| a | b |\n| --- |\n'), 'malformed-pipe-table', '1 cell', '2 cells')
- refused(losslessMarkdownToAdf('| a |\n| --- |\n| b | c |\n'), 'malformed-pipe-table', '2 cells', '1 cell')
+ refused(losslessMarkdownToAdf('| a | b |\n| --- |\n'), 'malformed-pipe-table', 'row holds 1 cell', 'header holds 2 cells')
+ refused(losslessMarkdownToAdf('| a |\n| --- |\n| b | c |\n'), 'malformed-pipe-table', 'row holds 2 cells', 'header holds 1 cell')
assert.deepEqual(path(losslessMarkdownToAdf('Part.\n\n| a |\n')), ['content', 1])
})
@@ -261,7 +261,7 @@ test('names the pipe table whose rows open with no pipe', () => {
refused(losslessMarkdownToAdf('a | b\n:--- | ---:\n'), 'malformed-pipe-table', ...bare)
refused(losslessMarkdownToAdf('a |\n--- |\n'), 'malformed-pipe-table', ...bare)
assert.deepEqual(content(losslessMarkdownToAdf('| a | b |\n| --- | --- |\nc\n')), [table(row(cell('tableHeader', text('a')), cell('tableHeader', text('b')))), paragraph('c')])
- refused(losslessMarkdownToAdf('| a | b |\n| --- | --- |\n| c |\n'), 'malformed-pipe-table', '1 cell', '2 cells')
+ refused(losslessMarkdownToAdf('| a | b |\n| --- | --- |\n| c |\n'), 'malformed-pipe-table', 'row holds 1 cell', 'header holds 2 cells')
assert.deepEqual(content(losslessMarkdownToAdf('a | b\nc | d\n')), [paragraph('a | b c | d')])
assert.deepEqual(content(losslessMarkdownToAdf('a | b\n--- | --- | ---\n')), [paragraph('a | b --- | --- | ---')])
assert.deepEqual(content(losslessMarkdownToAdf('a \\| b\n--- | ---\n')), [paragraph('a | b --- | ---')])
@@ -314,7 +314,7 @@ test('claims a block line the prefix opens with no directive to parse it', () =>
assert.equal(code(losslessMarkdownToAdf('!adf:/panel\n')), 'malformed-directive')
assert.equal(code(losslessMarkdownToAdf('!adf:panel info\n')), 'malformed-directive')
assert.equal(code(losslessMarkdownToAdf('!adf:panel {a=1 a=2}\n!adf:/panel\n')), 'malformed-directive')
- refused(losslessMarkdownToAdf('!adf:Panel\n'), 'malformed-directive', '\\!adf:')
+ refused(losslessMarkdownToAdf('!adf:Panel\n'), 'malformed-directive', 'no directive', '\\!adf:')
assert.deepEqual(content(losslessMarkdownToAdf(':::panel info\nPart.\n:::\n')), [paragraph(':::panel info Part. :::')])
assert.deepEqual(content(losslessMarkdownToAdf('::rule\n')), [paragraph('::rule')])
})
@@ -385,7 +385,7 @@ test('names the closer that finds no container open where it stands', () => {
})
test('names the leaf given a body at its opener, ahead of any refusal the leaf holds itself', () => {
- refused(losslessMarkdownToAdf('!adf:rule\nPart.\n!adf:/rule\n'), 'malformed-directive', '!adf:/rule', '\\!adf:')
+ refused(losslessMarkdownToAdf('!adf:rule\nPart.\n!adf:/rule\n'), 'malformed-directive', 'takes no body', '!adf:/rule', '\\!adf:')
assert.deepEqual(position(losslessMarkdownToAdf('Part.\n\n!adf:rule\nPart.\n!adf:/rule\n')), { line: 3, offset: 7 })
assert.deepEqual(path(losslessMarkdownToAdf('!adf:rule {localId=a-1}\n!adf:rule {localId=a-2}\nPart.\n!adf:/rule\n')), ['content', 1])
assert.deepEqual(path(losslessMarkdownToAdf('!adf:rule {localId=a-1}\n!adf:/rule\n!adf:/rule\n')), ['content', 0])