import ReactMarkdown from 'react-markdown' import remarkGfm from 'remark-gfm' import remarkMath from 'remark-math' import rehypeKatex from 'rehype-katex' import 'katex/dist/katex.min.css' import type { ComponentPropsWithoutRef } from 'react' interface MarkdownRendererProps { content: string className?: string } export function MarkdownRenderer({ content, className = '' }: MarkdownRendererProps) { return (
& { inline?: boolean }) { return inline ? ( {children} ) : ( {children} ) }, // 自定义表格样式 table({ children, ...props }) { return (
{children}
) }, th({ children, ...props }) { return ( {children} ) }, td({ children, ...props }) { return ( {children} ) }, // 自定义链接样式 a({ children, ...props }) { return ( {children} ) }, // 自定义引用块样式 blockquote({ children, ...props }) { return (
{children}
) }, // 自定义标题样式 h1({ children, ...props }) { return (

{children}

) }, h2({ children, ...props }) { return (

{children}

) }, h3({ children, ...props }) { return (

{children}

) }, h4({ children, ...props }) { return (

{children}

) }, // 自定义列表样式 ul({ children, ...props }) { return ( ) }, ol({ children, ...props }) { return (
    {children}
) }, // 自定义段落样式 p({ children, ...props }) { return (

{children}

) }, // 自定义分隔线样式 hr({ ...props }) { return
}, }} > {content}
) }