3
0
mirror of https://github.com/larvit/adf-codec.git synced 2026-11-18 22:25:44 +01:00

Fold unspellable-whitespace into unsupported-node-shape

This commit is contained in:
2026-10-14 00:02:58 +02:00
committed by Lillem4n
parent 3f6ed8fb3a
commit 06df26727a
8 changed files with 16 additions and 28 deletions
+1 -1
View File
@@ -107,7 +107,7 @@ export function readSoleStringAttribute(span: DirectiveSpan, key: string): Read<
// An inline directive never spans lines, and no content slot holds a null character; the emitter carries such a node.
export function slotFault(type: string, text: string): ConvertFault | undefined {
if (/[\n\r]/.test(text)) return { code: 'unspellable-whitespace', message: `the ${type} content slot holds a newline no inline directive spans` }
if (/[\n\r]/.test(text)) return unsupportedNodeShape(`the ${type} content slot holds a line ending, which no inline directive spans: write the node as !adf:carry`)
return holdsNullCharacter(text) ? unsupportedNodeShape(`the ${type} content slot holds a null character: write the node as !adf:carry`) : undefined
}
+1 -1
View File
@@ -1103,7 +1103,7 @@ test('names the content slot no lone plain text node reads back from', () => {
assert.equal(code(losslessMarkdownToAdf('!adf:status[<div>]{color=yellow}\n')), 'unmappable-html')
assert.equal(code(losslessMarkdownToAdf('!adf:date[<div>]{timestamp=1}\n')), 'unmappable-html')
assert.equal(code(losslessMarkdownToAdf('!adf:widget[<div>]\n')), 'unmappable-html')
const spans = 'unspellable-whitespace: the status content slot holds a newline no inline directive spans'
const spans = 'unsupported-node-shape: the status content slot holds a line ending, which no inline directive spans: write the node as !adf:carry'
assert.equal(content(losslessMarkdownToAdf('!adf:status[!adf:text{text="\\n"}]{color=yellow}\n')), spans)
assert.equal(content(losslessMarkdownToAdf('!adf:status[a&#10;b]{color=yellow}\n')), spans)
assert.equal(content(losslessMarkdownToAdf('!adf:status[a&#13;b]{color=yellow}\n')), spans)
-1
View File
@@ -6,7 +6,6 @@ export type ConvertErrorCode =
| 'not-an-adf-document'
| 'unknown-directive-name'
| 'unmappable-html'
| 'unspellable-whitespace'
| 'unsupported-document-version'
| 'unsupported-nesting-depth'
| 'unsupported-node-shape'