From 3e62171164d16ef576ae6e6bc99fb60ef2600b6d Mon Sep 17 00:00:00 2001 From: Mishig Date: Fri, 3 Jul 2026 22:53:20 +0200 Subject: [PATCH] fix(kit): repair nesting for Svelte 5 compatibility MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Svelte 5 raises a hard compile error (node_invalid_placement) when is a direct child of
, which is a common raw-HTML idiom in doc markdown (e.g. hub-docs transformers-js.md) and broke downstream doc builds after #792. Wrap direct-child rows in an explicit after mdsvex processing — the resulting DOM is identical to what browsers auto-inserted for the old output. Also silence the new element_invalid_self_closing_tag warning, which md-generated content triggers pervasively (` is a + * direct child of `
`, because browsers auto-insert `` during + * parsing, which would break hydration. Raw-HTML tables in doc markdown + * commonly omit `` (e.g. `
...`), so add it explicitly — + * the resulting DOM is identical to what browsers produced for the old output. + * @param {string} code + */ +function wrapTableRowsInTbody(code) { + return code + .replace(/(]*>)(\s*)($3") + .replace(/(<\/tr>)(\s*)(<\/table>)/g, "$1$2$3"); +} + function addFullWidthClassToTables(code) { return code.replace(/]*)>/g, (match, attrs) => { if (attrs.includes('class="')) { @@ -68,6 +82,7 @@ export const mdsvexPreprocess = { const processed = await _mdsvexPreprocess.markup({ content, filename }); processed.code = renderKatex(processed.code, markedKatex); processed.code = renderCode(processed.code, filename); + processed.code = wrapTableRowsInTbody(processed.code); if (stretchTables) { processed.code = addFullWidthClassToTables(processed.code); } diff --git a/kit/svelte.config.js b/kit/svelte.config.js index 910d2bae..5ae59234 100644 --- a/kit/svelte.config.js +++ b/kit/svelte.config.js @@ -53,7 +53,9 @@ const config = { if ( warning.message.includes("unused export property") || warning.code?.startsWith("a11y") || - warning.message.includes("A11y") + warning.message.includes("A11y") || + // md-generated doc content is full of `