Skip to content

Commit 99cb82e

Browse files
committed
add fallback
1 parent 858a238 commit 99cb82e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/site-kit/src/lib/markdown/renderer.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,10 @@ async function syntax_highlight({
861861
html = replace_blank_lines(html);
862862
} else {
863863
const highlighted = highlighter.codeToHtml(source, {
864-
lang: SHIKI_LANGUAGE_MAP[language as keyof typeof SHIKI_LANGUAGE_MAP],
864+
// fallback to the passing the language as is if it doesn't exist in our map
865+
// this ensures we get an error if we're using an unsupported language
866+
// rather than silently not highlighting the code block as expected
867+
lang: SHIKI_LANGUAGE_MAP[language as keyof typeof SHIKI_LANGUAGE_MAP] ?? language,
865868
theme
866869
});
867870

0 commit comments

Comments
 (0)