From b23f6a5aaad0301428ab506e1f1f328842b3123d Mon Sep 17 00:00:00 2001 From: xintaofei Date: Wed, 1 Apr 2026 17:48:46 +0800 Subject: [PATCH] fix: enable inline math formula rendering with single dollar signs Co-Authored-By: Claude Opus 4.6 (1M context) --- src/components/ai-elements/message.tsx | 3 ++- src/components/ai-elements/reasoning.tsx | 3 ++- src/components/files/file-workspace-panel.tsx | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/ai-elements/message.tsx b/src/components/ai-elements/message.tsx index a2f15b6..3d5c9ad 100644 --- a/src/components/ai-elements/message.tsx +++ b/src/components/ai-elements/message.tsx @@ -15,7 +15,7 @@ import { cn } from "@/lib/utils" import { useTranslations } from "next-intl" import { cjk } from "@streamdown/cjk" import { code } from "@streamdown/code" -import { math } from "@streamdown/math" +import { createMathPlugin } from "@streamdown/math" import { mermaid } from "@streamdown/mermaid" import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react" import { @@ -326,6 +326,7 @@ export const MessageBranchPage = ({ export type MessageResponseProps = ComponentProps +const math = createMathPlugin({ singleDollarTextMath: true }) const streamdownPlugins = { cjk, code, math, mermaid } function MessageResponseImpl({ className, ...props }: MessageResponseProps) { diff --git a/src/components/ai-elements/reasoning.tsx b/src/components/ai-elements/reasoning.tsx index 7a9c2d0..4410fd0 100644 --- a/src/components/ai-elements/reasoning.tsx +++ b/src/components/ai-elements/reasoning.tsx @@ -12,7 +12,7 @@ import { import { cn } from "@/lib/utils" import { cjk } from "@streamdown/cjk" import { code } from "@streamdown/code" -import { math } from "@streamdown/math" +import { createMathPlugin } from "@streamdown/math" import { mermaid } from "@streamdown/mermaid" import { BrainIcon, ChevronDownIcon } from "lucide-react" import { @@ -212,6 +212,7 @@ export type ReasoningContentProps = ComponentProps< children: string } +const math = createMathPlugin({ singleDollarTextMath: true }) const streamdownPlugins = { cjk, code, math, mermaid } export const ReasoningContent = memo( diff --git a/src/components/files/file-workspace-panel.tsx b/src/components/files/file-workspace-panel.tsx index 7d81137..1da34c3 100644 --- a/src/components/files/file-workspace-panel.tsx +++ b/src/components/files/file-workspace-panel.tsx @@ -18,13 +18,14 @@ import { } from "@/components/ui/context-menu" import { cjk } from "@streamdown/cjk" import { code } from "@streamdown/code" -import { math } from "@streamdown/math" +import { createMathPlugin } from "@streamdown/math" import { mermaid } from "@streamdown/mermaid" import { Streamdown } from "streamdown" import { readFileBase64 } from "@/lib/api" import { defineMonacoThemes, useMonacoThemeSync } from "@/lib/monaco-themes" import "@/lib/monaco-local" +const math = createMathPlugin({ singleDollarTextMath: true }) const previewPlugins = { cjk, code, math, mermaid } function resolveRelativePath(base: string, relative: string): string {