Files
Matt Moyles d78eb635e0 fix(docs): stop a Markdoc warning from taking a docs page down
DocsService.parse() threw on every validation finding except
attribute-undefined, warnings included. faq.md has a bold span
hard-wrapped across lines, which Markdoc reports as a child-invalid
warning ("Can't nest 'softbreak' in 'strong'"), so the FAQ page
returned a 500 even though transform() renders it fine.

Only error and critical findings block rendering now. The Markdoc
config moves to app/utils/docs_markdoc.ts so a unit test can validate
every bundled doc against the schema the service uses. The FAQ
sentence is also joined onto one line.

Fixes #1427
2026-11-17 22:18:22 +00:00

36 lines
1.2 KiB
TypeScript

import * as assert from 'node:assert/strict'
import { readdir, readFile } from 'node:fs/promises'
import { test } from 'node:test'
import Markdoc from '@markdoc/markdoc'
import { blockingFindings, markdocConfig } from '../../app/utils/docs_markdoc.js'
function findings(content: string) {
return blockingFindings(Markdoc.validate(Markdoc.parse(content), markdocConfig))
}
test('a bold span hard-wrapped across lines does not block rendering (#1427)', () => {
const wrapped = '**8GB is workable for a small\nmodel, 16GB is comfortable.**\n'
assert.ok(Markdoc.validate(Markdoc.parse(wrapped), markdocConfig).length > 0)
assert.deepEqual(findings(wrapped), [])
})
test('an unknown tag still blocks rendering', () => {
assert.equal(findings('{% nope %}\ntext\n{% /nope %}\n').length, 1)
})
const docsDir = new URL('../../docs/', import.meta.url)
const entries = await readdir(docsDir)
const docs = entries.filter((name) => name.endsWith('.md'))
for (const name of docs) {
test(`docs/${name} passes DocsService validation`, async () => {
const content = await readFile(new URL(name, docsDir), 'utf8')
assert.deepEqual(
findings(content).map((f) => `line ${f.lines[0] + 1}: ${f.error.message}`),
[]
)
})
}