import clsx from 'clsx'; import { BlockProps } from '../Block'; import { Blocks } from '../Blocks'; import { highlight, HighlightLine, HighlightToken } from './highlight'; import { Inline } from '../Inline'; export async function CodeBlock(props: BlockProps) { const { block, style } = props; const lines = await highlight(block); return (
            {lines.map((line, index) => (
                
            ))}
        
); } function CodeHighlightLine(props: { block: any; line: HighlightLine; lineIndex: number; isLast: boolean; }) { const { block, line, isLast, lineIndex } = props; const content = ( <> {isLast ? null : '\n'} ); if (block.data.lineNumbers === false) { return content; } return (
{content}
); } function CodeHighlightTokens(props: { tokens: HighlightToken[] }) { const { tokens } = props; return ( <> {tokens.map((token, index) => ( ))} ); } function CodeHighlightToken(props: { token: HighlightToken }) { const { token } = props; if (token.type === 'inline') { return ( ); } if (!token.token.color) { return <>{token.token.content}; } return {token.token.content}; }