| ... | ... | @@ -1,8 +1,4 @@ |
| 1 | | import { |
| 2 | | getSharedHighlighter, |
| 3 | | type DiffsHighlighter, |
| 4 | | type SupportedLanguages, |
| 5 | | } from "@pierre/diffs"; |
| 1 | import { DiffsHighlighter, getSharedHighlighter, SupportedLanguages } from "@pierre/diffs"; |
| 6 | 2 | import { CheckIcon, CopyIcon } from "lucide-react"; |
| 7 | 3 | import React, { |
| 8 | 4 | Children, |
| ... | ... | @@ -213,7 +209,12 @@ function SuspenseShikiCodeBlock({ |
| 213 | 209 | const highlightedHtml = useMemo(() => { |
| 214 | 210 | try { |
| 215 | 211 | return highlighter.codeToHtml(code, { lang: language, theme: themeName }); |
| 216 | | } catch { |
| 212 | } catch (error) { |
| 213 | // Log highlighting failures for debugging while falling back to plain text |
| 214 | console.warn( |
| 215 | `Code highlighting failed for language "${language}", falling back to plain text.`, |
| 216 | error instanceof Error ? error.message : error, |
| 217 | ); |
| 217 | 218 | // If highlighting fails for this language, render as plain text |
| 218 | 219 | return highlighter.codeToHtml(code, { lang: "text", theme: themeName }); |
| 219 | 220 | } |