From d1883b339a883c0f3db27c8558de1bf26cdb2a66 Mon Sep 17 00:00:00 2001 From: Willie Zutz Date: Sat, 19 Jul 2025 17:25:52 -0600 Subject: [PATCH] feat(markdown): Fix light theme and handle light theme style for syntax highlighting --- src/components/MarkdownRenderer.tsx | 33 +++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/src/components/MarkdownRenderer.tsx b/src/components/MarkdownRenderer.tsx index 2f18762..14739ba 100644 --- a/src/components/MarkdownRenderer.tsx +++ b/src/components/MarkdownRenderer.tsx @@ -6,7 +6,8 @@ import { CheckCheck, Copy as CopyIcon, Brain } from 'lucide-react'; import Markdown, { MarkdownToJSX } from 'markdown-to-jsx'; import { useState } from 'react'; import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter'; -import { oneDark } from 'react-syntax-highlighter/dist/cjs/styles/prism'; +import { oneDark, oneLight } from 'react-syntax-highlighter/dist/cjs/styles/prism'; +import { useTheme } from 'next-themes'; import ThinkBox from './ThinkBox'; // Helper functions for think overlay @@ -49,6 +50,8 @@ const CodeBlock = ({ className?: string; children: React.ReactNode; }) => { + const { theme } = useTheme(); + // Extract language from className (format could be "language-javascript" or "lang-javascript") let language = ''; if (className) { @@ -68,30 +71,34 @@ const CodeBlock = ({ setTimeout(() => setIsCopied(false), 2000); }; + // Choose syntax highlighting style based on theme + const syntaxStyle = theme === 'light' ? oneLight : oneDark; + const backgroundStyle = theme === 'light' ? '#fafafa' : '#1c1c1c'; + return ( -
-
+
+
{language}
+ {children} ); }, }, + strong: { + component: ({ children }) => ( + + {children} + + ), + }, pre: { component: ({ children }) => children, }, @@ -177,9 +191,10 @@ const MarkdownRenderer = ({