MCPcopy Create free account
hub / github.com/api-platform/website / highlightCode

Function highlightCode

pwa/utils/highlighter.ts:19–32  ·  view source on GitHub ↗
(code: string, language: string)

Source from the content-addressed store, hash-verified

17}
18
19export function highlightCode(code: string, language: string) {
20 try {
21 language = language.toLowerCase();
22 const langExists = getLoadedLanguages().includes(language as Lang);
23 const lang = langExists ? language : "shell";
24
25 return (
26 highlighter.codeToHtml(code, { lang, theme: "one-dark-pro" }) +
27 highlighter.codeToHtml(code, { lang, theme: "github-light" })
28 );
29 } catch {
30 return code;
31 }
32}

Callers

nothing calls this directly

Calls 1

getLoadedLanguagesFunction · 0.85

Tested by

no test coverage detected