From dbf3bd490eb59dda0c8bf3ce7f8b6076f32c7dda Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Thu, 7 May 2026 00:15:38 +0100 Subject: [PATCH] fix: highlight json5 docs examples --- scripts/docs-site/mdx-ish.mjs | 10 +++++++--- scripts/docs-site/smoke.mjs | 5 +++++ 2 files changed, 12 insertions(+), 3 deletions(-) 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");