Skip to content

Commit 0b5b0e6

Browse files
committed
Refine rendering of equations in chat pane
1 parent 62cd22c commit 0b5b0e6

File tree

8 files changed

+157
-264
lines changed

8 files changed

+157
-264
lines changed

‎frontend/package.json‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
"@radix-ui/react-use-callback-ref": "~1.1.1",
9393
"@radix-ui/react-use-controllable-state": "~1.2.2",
9494
"@replit/codemirror-vim": "^6.3.0",
95+
"@streamdown/math": "^1.0.1",
9596
"@tailwindcss/postcss": "^4.1.18",
9697
"@tailwindcss/typography": "^0.5.19",
9798
"@tanstack/react-table": "^8.21.3",
@@ -165,7 +166,7 @@
165166
"remark-gfm": "^4.0.1",
166167
"rpc-anywhere": "^1.7.0",
167168
"sql-formatter": "^15.6.12",
168-
"streamdown": "^1.6.10",
169+
"streamdown": "^2.1.0",
169170
"string-dedent": "^3.0.2",
170171
"swiper": "^11.2.10",
171172
"tailwind-merge": "^2.6.0",
@@ -181,6 +182,7 @@
181182
"vega-tooltip": "^1.1.0",
182183
"vscode-jsonrpc": "^8.2.1",
183184
"vscode-languageserver-protocol": "^3.17.5",
185+
"vscode-languageserver-types": "^3.17.5",
184186
"web-vitals": "^4.2.4",
185187
"zod": "^4.3.4"
186188
},

‎frontend/src/components/markdown/markdown-renderer.tsx‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* Copyright 2026 Marimo. All rights reserved. */
22

33
import { EditorView } from "@codemirror/view";
4+
import { math } from "@streamdown/math";
45
import { useAtomValue } from "jotai";
56
import { BetweenHorizontalStartIcon } from "lucide-react";
67
import { memo, Suspense, useState } from "react";
@@ -184,7 +185,11 @@ const COMPONENTS: Components = {
184185

185186
export const MarkdownRenderer = memo(({ content }: { content: string }) => {
186187
return (
187-
<Streamdown components={COMPONENTS} className="mo-markdown-renderer">
188+
<Streamdown
189+
components={COMPONENTS}
190+
plugins={{ math }}
191+
className="mo-markdown-renderer"
192+
>
188193
{content}
189194
</Streamdown>
190195
);

‎marimo/_server/ai/prompts.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@
2727
"If an import already exists, do not import it again.",
2828
"If a variable is already defined, use another name, or make it private by adding an underscore at the beginning.",
2929
],
30-
"markdown": [],
30+
"markdown": [
31+
"Use double dollar signs ($$) for ALL mathematical expressions (both inline and block) in markdown responses.",
32+
"Example: $$E=mc^2$$",
33+
"Do NOT use single dollar signs or square brackets for math.",
34+
],
3135
"sql": [
3236
"The SQL must use duckdb syntax.",
3337
],

‎pixi.lock‎

Lines changed: 3 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)