3
0
mirror of https://github.com/larvit/adf-codec.git synced 2026-11-20 07:05:44 +01:00

Kill the wiki writer's surviving mutants and drop checks the schema already makes

This commit is contained in:
2026-11-17 01:48:08 +01:00
committed by Lillem4n
parent 973c2a4480
commit da24c1b3fa
5 changed files with 170 additions and 14 deletions
+2 -2
View File
@@ -106,7 +106,7 @@ function headingSpelling(node: AdfNode, path: ConvertErrorPath): Result<Spelling
}
function simpleLeafText(node: AdfNode): string | undefined {
if (node.type === 'rule') return holdsExactly(node, {}) && node.content === undefined ? '----' : undefined
if (node.type === 'rule') return holdsExactly(node, {}) ? '----' : undefined
if (node.type === 'codeBlock') return codeText(node)
return node.type === 'mediaSingle' && holdsExactly(node, { layout: 'center' }) ? imageText(nodeContent(node)) : undefined
}
@@ -123,7 +123,7 @@ function codeText(node: AdfNode): string | undefined {
function imageText(content: readonly AdfNode[]): string | undefined {
const [media, ...others] = content
if (media?.type !== 'media' || others.length > 0 || media.content !== undefined || !holdsOnlyAttributes(media, ['alt', 'type', 'url'])) return undefined
if (media?.type !== 'media' || others.length > 0 || !holdsOnlyAttributes(media, ['alt', 'type', 'url'])) return undefined
const { alt, type, url } = nodeAttrs(media)
if (type !== 'external' || typeof url !== 'string' || !spellableImageUrl.test(url)) return undefined
if (alt === undefined) return `!${url}!`