mirror of
https://github.com/larvit/adf-codec.git
synced 2026-11-19 22:55:44 +01:00
Name the CommonMark spelling a refused directive takes, split the unsupported-node-shape row by cause, and pass readAttributes its pair fault
This commit is contained in:
@@ -266,9 +266,23 @@ function directiveNode(block: DirectiveBlock, reading: Reading, path: ConvertErr
|
||||
const readable = withinEngineLimits(() => commonMarkSpelling(built.value, path, depth, { flavour: 'lossless', memo: reading.memo }))
|
||||
if (!readable.ok) return readable
|
||||
if (!readable.value) return built
|
||||
return failure('unsupported-node-shape', `${built.value.type} takes the CommonMark spelling, not the directive form`, path)
|
||||
const spelling = commonMarkSpellings.get(built.value.type)
|
||||
return failure('unsupported-node-shape', `${built.value.type} takes the CommonMark spelling, not the directive form${spelling === undefined ? '' : `: write ${spelling}`}`, path)
|
||||
}
|
||||
|
||||
// The nodes `commonMarkSpelling` spells in the lossless flavour.
|
||||
const commonMarkSpellings: ReadonlyMap<string, string> = new Map([
|
||||
['blockquote', 'each line behind `> `'],
|
||||
['bulletList', 'each item behind `- `'],
|
||||
['codeBlock', 'its text in a ``` fence'],
|
||||
['heading', 'one `#` per level before its text, `## Title` at level 2'],
|
||||
['mediaSingle', '``, or `[](href "title")` when linked'],
|
||||
['orderedList', 'each item behind `1. `'],
|
||||
['paragraph', 'its text alone'],
|
||||
['rule', '`---`'],
|
||||
['table', 'a pipe table'],
|
||||
])
|
||||
|
||||
function directiveBody(read: BlockDirectiveNode, blocks: Block[] | undefined, reading: Reading, path: ConvertErrorPath, depth: number): Result<AdfNode> {
|
||||
const { contentModel, node } = read
|
||||
if (blocks === undefined) return success(node)
|
||||
|
||||
Reference in New Issue
Block a user