MCPcopy Index your code
hub / github.com/simstudioai/sim / highlightOrEscape

Function highlightOrEscape

packages/emcn/src/components/code/code.tsx:108–112  ·  view source on GitHub ↗

* Highlights a single line of code, falling back to escaped plaintext when Prism * has not loaded yet or the language grammar is unavailable. * * @param prism - The loaded Prism module, or `null` while loading * @param text - The line of code to highlight * @param language - The language key (e

(prism: PrismModule | null, text: string, language: string)

Source from the content-addressed store, hash-verified

106 * @returns Highlighted HTML, or escaped plaintext as a fallback
107 */
108function highlightOrEscape(prism: PrismModule | null, text: string, language: string): string {
109 if (!prism) return escapeHtml(text)
110 const grammar = prism.languages[language] || prism.languages.javascript
111 return prism.highlight(text, grammar, language)
112}
113
114/**
115 * Code editor configuration and constants.

Callers 1

code.tsxFile · 0.85

Calls 1

escapeHtmlFunction · 0.70

Tested by

no test coverage detected