diff --git a/corpus/errors/carry-fence-type-unspellable.error b/corpus/errors/carry-fence-type-unspellable.error new file mode 100644 index 0000000..a811539 --- /dev/null +++ b/corpus/errors/carry-fence-type-unspellable.error @@ -0,0 +1 @@ +unsupported-node-shape diff --git a/corpus/errors/carry-fence-type-unspellable.md b/corpus/errors/carry-fence-type-unspellable.md new file mode 100644 index 0000000..26231ce --- /dev/null +++ b/corpus/errors/carry-fence-type-unspellable.md @@ -0,0 +1,3 @@ +```adf:\\ +{} +``` diff --git a/src/markdown/opaque-carry.ts b/src/markdown/opaque-carry.ts index 0a113d6..d70e116 100644 --- a/src/markdown/opaque-carry.ts +++ b/src/markdown/opaque-carry.ts @@ -33,6 +33,9 @@ export function carriedInline(node: AdfNode, path: ConvertErrorPath): Result { + if (type !== '' && !infoStringCarries(type)) { + return { fault: unsupportedNodeShape(`the carry fence names a type no info string carries back: spell it ${carryFencePrefix} with the type in the JSON`) } + } const read = readCarriedJson(body, 'two-space', largestNesting - depth, type) if (read.fault !== undefined || type !== '' || !infoStringCarries(read.value.type)) return read return { fault: unsupportedNodeShape(`the carry fence names a type its info string carries: spell it ${carryFencePrefix}${read.value.type}`) } diff --git a/src/markdown/parse/markdown-to-adf.test.ts b/src/markdown/parse/markdown-to-adf.test.ts index 490975e..320b1d6 100644 --- a/src/markdown/parse/markdown-to-adf.test.ts +++ b/src/markdown/parse/markdown-to-adf.test.ts @@ -375,6 +375,8 @@ test('reads the carry fence back to the node its info string names and its JSON ) assert.equal(content(markdownToAdf('```adf:\n{\n "type": "blockCard"\n}\n```\n')), 'unsupported-node-shape: the carry fence names a type its info string carries: spell it adf:blockCard') assert.equal(content(markdownToAdf('```adf:\n{}\n```\n')), "unsupported-node-shape: the opaque carry holds one ADF node's JSON: this JSON is no ADF node") + const unnamed = 'unsupported-node-shape: the carry fence names a type no info string carries back: spell it adf: with the type in the JSON' + assert.equal(content(markdownToAdf('```adf:\\\\\n{}\n```\n')), unnamed) }) test('reads the inline carry back to the node its json attribute holds', () => {