({ code, language = "xml" }: CodeBlockProps)
| 8 | } |
| 9 | |
| 10 | export function CodeBlock({ code, language = "xml" }: CodeBlockProps) { |
| 11 | return ( |
| 12 | <div className="overflow-hidden w-full"> |
| 13 | <Highlight theme={themes.github} code={code} language={language}> |
| 14 | {({ |
| 15 | className: _className, |
| 16 | style, |
| 17 | tokens, |
| 18 | getLineProps, |
| 19 | getTokenProps, |
| 20 | }) => ( |
| 21 | <pre |
| 22 | className="text-[11px] leading-relaxed overflow-x-auto overflow-y-auto max-h-48 scrollbar-thin break-all" |
| 23 | style={{ |
| 24 | ...style, |
| 25 | fontFamily: |
| 26 | "var(--font-mono), ui-monospace, monospace", |
| 27 | backgroundColor: "transparent", |
| 28 | margin: 0, |
| 29 | padding: 0, |
| 30 | wordBreak: "break-all", |
| 31 | whiteSpace: "pre-wrap", |
| 32 | }} |
| 33 | > |
| 34 | {tokens.map((line, i) => ( |
| 35 | <div |
| 36 | key={i} |
| 37 | {...getLineProps({ line })} |
| 38 | style={{ wordBreak: "break-all" }} |
| 39 | > |
| 40 | {line.map((token, key) => ( |
| 41 | <span |
| 42 | key={key} |
| 43 | {...getTokenProps({ token })} |
| 44 | /> |
| 45 | ))} |
| 46 | </div> |
| 47 | ))} |
| 48 | </pre> |
| 49 | )} |
| 50 | </Highlight> |
| 51 | </div> |
| 52 | ) |
| 53 | } |
nothing calls this directly
no outgoing calls
no test coverage detected