diff --git a/scripts/docs-site/mdx-ish.mjs b/scripts/docs-site/mdx-ish.mjs index 0f8f81804..ef9ad25bb 100644 --- a/scripts/docs-site/mdx-ish.mjs +++ b/scripts/docs-site/mdx-ish.mjs @@ -40,7 +40,9 @@ function highlightCode(code, rawLang = "") { const lang = normalizeLang(rawLang); if (isShell(lang, code)) return highlightWith(code, shellToken, shellTokenClass); if (["json", "jsonc"].includes(lang)) return highlightWith(code, jsonToken, jsonTokenClass); - if (["js", "jsx", "mjs", "cjs", "ts", "tsx"].includes(lang)) return highlightWith(code, jsToken, jsTokenClass); + if (["js", "javascript", "jsx", "mjs", "cjs", "ts", "typescript", "tsx", "json5"].includes(lang)) { + return highlightWith(code, jsToken, jsTokenClass); + } if (["yaml", "yml"].includes(lang)) return highlightWith(code, yamlToken, yamlTokenClass); if (["toml", "ini", "env"].includes(lang)) return highlightWith(code, configToken, configTokenClass); return escapeHtml(code); @@ -72,7 +74,7 @@ function highlightWith(code, tokenPattern, tokenClass) { const shellToken = /(?channels<\/span>/.test(index) + || !/class="tok-string">"\+15555550123"<\/span>/.test(index) + || !/class="tok-literal">true<\/span>/.test(index)) { + throw new Error("index: json5 config example was not syntax-highlighted"); +} const modelsMarkdown = fs.readFileSync(path.join(site, "concepts/models.md"), "utf8"); if (!/^---\nsummary: /m.test(modelsMarkdown) || !/title: "Models CLI"/m.test(modelsMarkdown)) { throw new Error("concepts/models.md: source markdown was not emitted");