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

Name the marker a list takes after a list of its kind, from the list right before it

This commit is contained in:
2026-10-14 12:58:31 +02:00
committed by Lillem4n
parent 39a7f16b95
commit 0789e87c31
2 changed files with 4 additions and 4 deletions
+2 -2
View File
@@ -333,10 +333,10 @@ test('names the CommonMark spelling to write for the directive form a node Commo
assert.equal(content(losslessMarkdownToAdf('!adf:blockquote\nPart.\n!adf:/blockquote\n')), named('blockquote', 'each line behind `> `'))
assert.equal(content(losslessMarkdownToAdf('!adf:heading {level=2}\nPart.\n!adf:/heading\n')), named('heading', 'one `#` per level before its text, `## Title` at level 2'))
assert.equal(content(losslessMarkdownToAdf('!adf:paragraph\nPart.\n!adf:/paragraph\n')), named('paragraph', 'its text alone'))
assert.equal(content(losslessMarkdownToAdf('!adf:bulletList\n!adf:listItem\nPart.\n!adf:/listItem\n!adf:/bulletList\n')), named('bulletList', 'each item behind `- `, or behind `* ` right after another bullet list'))
assert.equal(content(losslessMarkdownToAdf('!adf:bulletList\n!adf:listItem\nPart.\n!adf:/listItem\n!adf:/bulletList\n')), named('bulletList', 'each item behind `- `, or behind `* ` where the list right before it takes `- `'))
assert.equal(
content(losslessMarkdownToAdf('!adf:orderedList {order=5}\n!adf:listItem\nPart.\n!adf:/listItem\n!adf:/orderedList\n')),
named('orderedList', 'each item behind its number, counting up from `5. `, or from `5) ` right after another ordered list'),
named('orderedList', 'each item behind its number, counting up from `5. `, or from `5) ` where the list right before it takes `.`'),
)
assert.equal(content(losslessMarkdownToAdf('!adf:codeBlock\n```\nx\n```\n!adf:/codeBlock\n')), named('codeBlock', 'its text in a fence of more backticks than any run it holds, its language after the opening fence'))
assert.equal(
+2 -2
View File
@@ -273,13 +273,13 @@ function directiveNode(block: DirectiveBlock, reading: Reading, path: ConvertErr
function spellingToWrite(node: AdfNode): string | undefined {
if (node.type !== 'orderedList') return commonMarkSpellings.get(node.type)
const order = String(nodeAttrs(node)['order'])
return `each item behind its number, counting up from \`${order}. \`, or from \`${order}) \` right after another ordered list`
return `each item behind its number, counting up from \`${order}. \`, or from \`${order}) \` where the list right before it takes \`.\``
}
// One entry per node `commonMarkSpelling` spells in the lossless flavour, kept here because this refusal is its only reader; a node missing here is refused naming no spelling.
const commonMarkSpellings: ReadonlyMap<string, string> = new Map([
['blockquote', 'each line behind `> `'],
['bulletList', 'each item behind `- `, or behind `* ` right after another bullet list'],
['bulletList', 'each item behind `- `, or behind `* ` where the list right before it takes `- `'],
['codeBlock', 'its text in a fence of more backticks than any run it holds, its language after the opening fence'],
['heading', 'one `#` per level before its text, `## Title` at level 2'],
['mediaSingle', '`![alt](url)`, or `[![alt](url)](href)` when linked'],