File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
src/Elastic.Documentation.Site/Assets/web-components/SearchOrAskAi/AskAi Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -28,9 +28,15 @@ import { useEffect, useMemo } from 'react'
2828const createMarkedInstance = ( ) => {
2929 const renderer : RendererObject = {
3030 code ( { text, lang } : Tokens . Code ) : string {
31- const highlighted = lang
32- ? hljs . highlight ( text , { language : lang } ) . value
33- : hljs . highlightAuto ( text ) . value
31+ let highlighted : string
32+ try {
33+ highlighted = lang
34+ ? hljs . highlight ( text , { language : lang } ) . value
35+ : hljs . highlightAuto ( text ) . value
36+ } catch {
37+ // Fallback to auto highlighting if the specified language is not found
38+ highlighted = hljs . highlightAuto ( text ) . value
39+ }
3440 return `<div class="highlight">
3541 <pre>
3642 <code class="language-${ lang } ">${ highlighted } </code>
You can’t perform that action at this time.
0 commit comments