feat: update react-markdown to 9.0.3 and integrate KaTeX for math rendering in MessageBubble

This commit is contained in:
ecwu
2025-01-27 11:29:58 +00:00
parent 3b17ca791b
commit 2193ce11df
3 changed files with 1854 additions and 187 deletions

View File

@@ -1,5 +1,8 @@
import { LightBulbIcon, XMarkIcon } from "@heroicons/react/24/outline";
import Markdown from "react-markdown";
import remarkMath from "remark-math";
import rehypeKatex from "rehype-katex";
import "katex/dist/katex.min.css";
import { useContext, useState, useMemo } from "react";
import { ChatStoreMessage } from "@/types/chatstore";
import { addTotalCost } from "@/utils/totalCost";
@@ -324,6 +327,8 @@ export default function Message(props: { messageIndex: number }) {
) : renderMarkdown ? (
<div className="message-content max-w-full md:max-w-[75%]">
<Markdown
remarkPlugins={[remarkMath]}
rehypePlugins={[rehypeKatex]}
break={true}
components={{
code: ({ children }) => (