import React, { useEffect } from 'react'; import ReactMarkdown from 'react-markdown'; import remarkGfm from 'remark-gfm'; import rehypeHighlight from 'rehype-highlight'; import hljs from 'highlight.js'; interface MarkdownRendererProps { content: string; className?: string; summaryMode?: boolean; } const MarkdownRenderer: React.FC = ({ content, className = '', summaryMode = false, }) => { useEffect(() => { // Configure highlight.js hljs.configure({ languages: [ 'javascript', 'typescript', 'python', 'java', 'css', 'html', 'json', 'bash', 'sql', 'yaml', 'xml', 'dockerfile', 'nginx', 'apache', ], }); // Manual highlighting for any missed code blocks const timer = setTimeout(() => { const codeBlocks = document.querySelectorAll('pre code:not(.hljs)'); codeBlocks.forEach((block) => { hljs.highlightElement(block as HTMLElement); }); }, 100); return () => clearTimeout(timer); }, [content]); return (
summaryMode ? ( ) : (

), h2: ({ ...props }) => summaryMode ? ( ) : (

), h3: ({ ...props }) => summaryMode ? ( ) : (

), h4: ({ ...props }) => summaryMode ? ( ) : (

), h5: ({ ...props }) => summaryMode ? ( ) : (
), h6: ({ ...props }) => summaryMode ? ( ) : (
), // Customize paragraph styles p: ({ ...props }) => (

), // Customize list styles ul: ({ ...props }) => (