Refuse the content a code block dropped, the last of that class
CI / gate (push) Successful in 5s

This commit is contained in:
2026-08-27 11:49:55 +02:00
parent a5b8a4654f
commit 60d703ac05
2 changed files with 9 additions and 1 deletions
+8 -1
View File
@@ -163,7 +163,14 @@ function emitCodeBlock(node: AdfNode, path: ConvertErrorPath): Result<string> {
let text = ''
for (const [index, child] of (node.content ?? []).entries()) {
const childPath = [...path, 'content', index]
if (child.type !== 'text' || typeof child.text !== 'string' || child.text === '' || (child.marks ?? []).length > 0 || Object.keys(child.attrs ?? {}).length > 0) {
if (
child.type !== 'text' ||
typeof child.text !== 'string' ||
child.text === '' ||
(child.content ?? []).length > 0 ||
(child.marks ?? []).length > 0 ||
Object.keys(child.attrs ?? {}).length > 0
) {
return failure('unsupported-node-shape', 'a codeBlock holds plain text nodes only', childPath)
}
if (/\r/.test(child.text)) return failure('unspellable-whitespace', 'a codeBlock holds no carriage return CommonMark keeps', childPath)