Download client/src/components/code-block.tsx from automindy/fokemal: direct link, hf CLI and curl.
- Browser
- Download file 854 Bytes
-
https://huggingface.co/spaces/automindy/fokemal/resolve/main/client/src/components/code-block.tsx
- Command line
-
hf download hf://spaces/automindy/fokemal/client/src/components/code-block.tsx
-
curl -L -o code-block.tsx https://huggingface.co/spaces/automindy/fokemal/resolve/main/client/src/components/code-block.tsx
854 Bytes
| import { useMemo } from 'react' | |
| import { cn } from '@/lib/utils' | |
| import { highlightCode } from '@/lib/highlight' | |
| // Highlighted source: the reply code blocks and the artifact panel's Code tab. | |
| // highlightCode returns escaped HTML with hljs-* spans, so injecting it is | |
| // safe; the token colours live in index.css under `.code-highlight`. | |
| export interface CodeBlockProps { | |
| code: string | |
| language?: string | null | |
| className?: string | |
| } | |
| export function CodeBlock({ code, language, className }: CodeBlockProps) { | |
| const { html, language: applied } = useMemo(() => highlightCode(code, language), [code, language]) | |
| return ( | |
| <code | |
| className={cn('code-highlight block font-mono text-[12.5px] leading-relaxed whitespace-pre', className)} | |
| data-language={applied ?? undefined} | |
| dangerouslySetInnerHTML={{ __html: html }} | |
| /> | |
| ) | |
| } | |