Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

Refine rendering of equations in chat pane (#7961)

faysouebb621e9e1eb
diff --git a/frontend/package.json b/frontend/package.json
index 11beb27939..dfcd701cf1 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -92,6 +92,7 @@
"@radix-ui/react-use-callback-ref": "~1.1.1",
"@radix-ui/react-use-controllable-state": "~1.2.2",
"@replit/codemirror-vim": "^6.3.0",
+ "@streamdown/math": "^1.0.1",
"@tailwindcss/postcss": "^4.1.18",
"@tailwindcss/typography": "^0.5.19",
"@tanstack/react-table": "^8.21.3",
@@ -165,7 +166,7 @@
"remark-gfm": "^4.0.1",
"rpc-anywhere": "^1.7.0",
"sql-formatter": "^15.6.12",
- "streamdown": "^1.6.10",
+ "streamdown": "^2.1.0",
"string-dedent": "^3.0.2",
"swiper": "^11.2.10",
"tailwind-merge": "^2.6.0",
diff --git a/frontend/src/components/markdown/markdown-renderer.tsx b/frontend/src/components/markdown/markdown-renderer.tsx
index 79db1c6726..81b8302685 100644
--- a/frontend/src/components/markdown/markdown-renderer.tsx
+++ b/frontend/src/components/markdown/markdown-renderer.tsx
@@ -1,6 +1,7 @@
/* Copyright 2026 Marimo. All rights reserved. */
import { EditorView } from "@codemirror/view";
+import { math } from "@streamdown/math";
import { useAtomValue } from "jotai";
import { BetweenHorizontalStartIcon } from "lucide-react";
import { memo, Suspense, useState } from "react";
@@ -184,7 +185,11 @@ const COMPONENTS: Components = {
export const MarkdownRenderer = memo(({ content }: { content: string }) => {
return (
- <Streamdown components={COMPONENTS} className="mo-markdown-renderer">
+ <Streamdown
+ components={COMPONENTS}
+ plugins={{ math }}
+ className="mo-markdown-renderer"
+ >
{content}
</Streamdown>
);
diff --git a/marimo/_server/ai/prompts.py b/marimo/_server/ai/prompts.py
index ec7bca09f5..2509c08533 100644
--- a/marimo/_server/ai/prompts.py
+++ b/marimo/_server/ai/prompts.py
@@ -27,7 +27,11 @@ language_rules: dict[Language, list[str]] = {
"If an import already exists, do not import it again.",
"If a variable is already defined, use another name, or make it private by adding an underscore at the beginning.",
],
- "markdown": [],
+ "markdown": [
+ "Use double dollar signs ($$) for ALL mathematical expressions (both inline and block) in markdown responses.",
+ "Example: $$E=mc^2$$",
+ "Do NOT use single dollar signs or square brackets for math.",
+ ],
"sql": [
"The SQL must use duckdb syntax.",
],
diff --git a/pixi.lock b/pixi.lock
index 892b0468d6..77c75b060a 100644
--- a/pixi.lock
+++ b/pixi.lock
@@ -5,8 +5,6 @@ environments:
- url: https://conda.anaconda.org/conda-forge/
indexes:
- https://pypi.org/simple
- options:
- pypi-prerelease-mode: if-necessary-or-explicit
packages:
linux-64:
- conda: https://conda.anaconda.org/conda-forge/linux-64/_libgcc_mutex-0.1-conda_forge.tar.bz2
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 4e20e62422..0a9a60e0f7 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -250,6 +250,9 @@ importers:
'@replit/codemirror-vim':
specifier: ^6.3.0
version: 6.3.0(@codemirror/[email protected])(@codemirror/[email protected])(@codemirror/[email protected])(@codemirror/[email protected])(@codemirror/[email protected])
+ '@streamdown/math':
+ specifier: ^1.0.1
+ version: 1.0.1([email protected])
'@tailwindcss/postcss':
specifier: ^4.1.18
version: 4.1.18
@@ -470,8 +473,8 @@ importers:
specifier: ^15.6.12
version: 15.6.12
streamdown:
- specifier: ^1.6.10
+ specifier: ^2.1.0
+ version: 2.1.0([email protected])
string-dedent:
specifier: ^3.0.2
version: 3.0.2
@@ -3610,27 +3613,6 @@ packages:
cpu: [x64]
os: [win32]
- '@shikijs/[email protected]':
- resolution: {integrity: sha512-L1Safnhra3tX/oJK5kYHaWmLEBJi1irASwewzY3taX5ibyXyMkkSDZlq01qigjryOBwrXSdFgTiZ3ryzSNeu7Q==}
-
- '@shikijs/[email protected]':
- resolution: {integrity: sha512-Nm3/azSsaVS7hk6EwtHEnTythjQfwvrO5tKqMlaH9TwG1P+PNaR8M0EAKZ+GaH2DFwvcr4iSfTveyxMIvXEHMw==}
-
- '@shikijs/[email protected]':
- resolution: {integrity: sha512-hozwnFHsLvujK4/CPVHNo3Bcg2EsnG8krI/ZQ2FlBlCRpPZW4XAEQmEwqegJsypsTAN9ehu2tEYe30lYKSZW/w==}
-
- '@shikijs/[email protected]':
- resolution: {integrity: sha512-bVx5PfuZHDSHoBal+KzJZGheFuyH4qwwcwG/n+MsWno5cTlKmaNtTsGzJpHYQ8YPbB5BdEdKU1rga5/6JGY8ww==}
-
- '@shikijs/[email protected]':
- resolution: {integrity: sha512-fTR3QAgnwYpfGczpIbzPjlRnxyONJOerguQv1iwpyQZ9QXX4qy/XFQqXlf17XTsorxnHoJGbH/LXBvwtqDsF5A==}
-
- '@shikijs/[email protected]':
- resolution: {integrity: sha512-K5UIBzxCyv0YoxN3LMrKB9zuhp1bV+LgewxuVwHdl4Gz5oePoUFrr9EfgJlGlDeXCU1b/yhdnXeuRvAnz8HN8Q==}
-
- '@shikijs/[email protected]':
- resolution: {integrity: sha512-83yeghZ2xxin3Nj8z1NMd/NCuca+gsYXswywDy5bHvwlWL8tpTQmzGeUuHd9FC3E/SBEMvzJRwWEOz5gGes9Qg==}
-
'@sinclair/[email protected]':
resolution: {integrity: sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==}
@@ -3716,6 +3698,11 @@ packages:
typescript:
optional: true
+ '@streamdown/[email protected]':
+ resolution: {integrity: sha512-R9WdHbpERiRU7WeO7oT1aIbnLJ/jraDr89F7X9x2OM//Y8G8UMATRnLD/RUwg4VLr8Nu7QSIJ0Pa8lXd2meM4Q==}
+ peerDependencies:
+ react: ^19.2.3
+
'@swc-jotai/[email protected]':
resolution: {integrity: sha512-TXCQJ/eZ8mZXGnO0W1nK73VKGDt5dVsrPd3wSYypLOth5tSdBRtbU2opYeUJEXY4iUI5sVu1zUAmRJSJ7V+h8A==}
@@ -6499,8 +6486,8 @@ packages:
resolution: {integrity: sha512-Y8/SBAHkZGoNkpzqqfCldijcuUKh7/su31kEBp67cFY09Wy0mTRgtsLYsiIxMJxlu0f6AA5SUTbDR8K0rxnbUw==}
- resolution: {integrity: sha512-OguPdidb+fbHQSU4Q4ZiLKnzWo8Wwsf5bZfbvu7//a9oTYoqD/fWpe96NuHkoS9h0ccGOTe0C4NGXdtS0iObOw==}
+ resolution: {integrity: sha512-3yTWghByc50aGS7JlGhk61SPenfE/p1oaFeNwkOOyrscaOkMGrcW9+Cy/QAIOBpZxP1yqDIzFMR0+Np0i0+usg==}
resolution: {integrity: sha512-zl6s8LwNyo1P9uw+XJGvZtdFF1GdAkOg8ujOw+4Pyb76874fLps4ueHXDhXWdk6YHQ6OgUtinliG7RsYvCbbBg==}
@@ -6514,10 +6501,6 @@ packages:
resolution: {integrity: sha512-88JUN06ipLwsnv+dVn+OIYOvAuvBMy/Qoi6O7mQHxdPXpjy+Cd6xRkWwux7DKO+4sYILtLBRIKgsdpS2gQc7qw==}
- resolution: {integrity: sha512-vFUqlRV5C+xqP76Wwq2SrM0kipnmpxJm7OfvVXpB35Fp+Fn4MV+ozr+JZr5qFvyR1q/U+Foim2x+3P+x9S1PLA==}
- deprecated: Renamed to rehype
-
resolution: {integrity: sha512-g7df9rMFX/SPi34tyGCyUBREQoKkapwdY/T04Qn9TDWfHhAYt4/I0gMVirzK5wEzeUqIjEB+LXC/ypb7Aqno5w==}
@@ -7298,11 +7281,6 @@ packages:
resolution: {integrity: sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==}
- resolution: {integrity: sha512-w3hD8/SQB7+lzU2r4VdFyzzOzKnUjTZIF/MQJGSSvni7Llewni4vuViRppfRAa2guOsY5k4jZyxw/i9DQHv+dw==}
- peerDependencies:
- react: ^19.2.3
-
resolution: {integrity: sha512-82hOAu7y0dbVuFfmO4bYF1XEwYk/mEbM5E+b1jgci/udUBEE/R7LF5Ip0CCEmXe8AybRM8L+04eP+LGZeDvkiw==}
peerDependencies:
@@ -7342,6 +7320,11 @@ packages:
engines: {node: '>= 20'}
hasBin: true
+ resolution: {integrity: sha512-boeBdiS0ghpWcSwoNm/jJBwdpFaMnZWRzjA6SkUMYb40SVaN1x7mmfGKp0jvexGcx+7y2La5zRZsYFZI6Qpypg==}
+ engines: {node: '>= 20'}
+ hasBin: true
+
resolution: {integrity: sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==}
engines: {node: '>= 0.4'}
@@ -7442,35 +7425,6 @@ packages:
resolution: {integrity: sha512-RDBrHEMSxVFLg6xvnXmb1Ayr2WzLAWjeSATAoxwKYJV94TeNavgoIdA0a9ytzDSVzBy2YKFK+emCPOEibLeCrg==}
- resolution: {integrity: sha512-gSPnxgHDDqXYOBvQRq6lerrq9mjDhdtKn+7XETuXjxWcL62yZEfUdA28Ml1I2vDIPfAOIKLa0h2XDSGkInGHFQ==}
- engines: {node: '>=16'}
- peerDependencies:
- micromark: ^4.0.0
- micromark-util-types: ^2.0.0
- peerDependenciesMeta:
- micromark-util-types:
- optional: true
-
- resolution: {integrity: sha512-egs6+12JU2yutskHY55FyR48ZiEcFOJFyk9rsiyIhcJ6IvWB6ABBqVrBw8IobqJTDZ/wdSr9eoXDPb5S2nW1bg==}
- engines: {node: '>=16'}
- peerDependencies:
- micromark-util-types: '*'
- peerDependenciesMeta:
- micromark-util-types:
- optional: true
-
- resolution: {integrity: sha512-gRzVLUdjXBLX6zNPSnHGDoo+ZTp5zy+MZm0g3sv+3chPXY7l9gW+DnrcHcZh/jiPR6MjPKO4AEJNp4Aw6V9z5Q==}
- engines: {node: '>=16'}
- peerDependencies:
- micromark: ^4.0.0
- micromark-util-types: ^2.0.0
- peerDependenciesMeta:
- micromark-util-types:
- optional: true
-
resolution: {integrity: sha512-oOg7knzhicgQ3t4QCjCWgTmfNhvQbDDnJeVu9v81r7NltNCVmhPy1fJRX27pISafdjL+SVc4d3l48Gb6pbRypw==}
@@ -7782,12 +7736,6 @@ packages:
resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==}
- resolution: {integrity: sha512-8Unqkvk1RYc6yq2WBYRj4hdnsAxVze8i7iPfQr8e4uSP3tRv0rpZcbGUDvxfQQcdwHt/e9PrMvGCsa8OqG9X3w==}
-
- resolution: {integrity: sha512-rPiZhzC3wXwE59YQMRDodUwwT9FZ9nNBwQQfsd1wfdtlKEyCdRV0avrTcSZ5xlIvGRVPd/cx6ZN45ECmS39xvg==}
-
resolution: {integrity: sha512-YgBpdJHPyQ2UE5x+hlSXcnejzAvD0b22U2OuAP+8OnlJT+PjWPxtgmGqKKc+RgTM63U9gN0YzrYc71R2WT/hTA==}
engines: {node: '>=18'}
@@ -8687,15 +8635,6 @@ packages:
resolution: {integrity: sha512-00o4I+DVrefhv+nX0ulyi3biSHCPDe+yLv5o/p6d/UVlirijB8E16FtfwSAi4g3tcqrQ4lRAqQSoFEZJehYEcw==}
engines: {node: '>= 0.4'}
- resolution: {integrity: sha512-0YCaSCq2VRIebiaUviZNs0cBz1kg5kVS2UKUfNIx8YVs1cN3AV7NTctO5FOKBA+UT2BPJIWZauYHPqJODG50cg==}
-
- resolution: {integrity: sha512-8VhliFJAWRaUiVvREIiW2NXXTmHs4vMNnSzuJVhscgmGav3g9VDxLrQndI3dZZVVdp0ZO/5v0xmX516/7M9cng==}
-
- resolution: {integrity: sha512-uorlqlzAKjKQZ5P+kTJr3eeJGSVroLKoHmquUj4zHWuR+hEyNqlXsSKlYYF5F4NI6nl7tWCs0apKJ0lmfsXAPA==}
-
resolution: {integrity: sha512-iETxpjK6YoRWJG5o6hXLwvjYAoW+FEZn9os0PD/b6AP6xQwsa/Y7lCVgIixBbUPMfhu+i2LtdeAqVTgGlQarfA==}
hasBin: true
@@ -8723,8 +8662,8 @@ packages:
resolution: {integrity: sha512-+IOGrxl3FZ8ZM9ixCWQZzFRiRn7Rzn9bu3iFHwg/yz4tlOUQgbO4PHLgG+1ZT60zcIV8tief6Qrmyl8qcoJP0g==}
- resolution: {integrity: sha512-5WyX6BFEWYmmbCF/S2gNRklfgPGTiGjviAjbseO4XlpqEilWBkvWwve6uU/JB3C0JvG/qxCZa3rBn8+ajy4i/A==}
+ resolution: {integrity: sha512-j5DY0YSK2YavvNGV+qBHma15J9m0WZmRe8posT5AtKDS6TNWtMVTo6RiqF8SidfcASYz8f3k2J/1RWmq5zTXUw==}
resolution: {integrity: sha512-OiM2wrZ/wuhKkigASodFoo8wimG3H12LWQaH8qSPVJn9apWKFSH3YOCtbKpBorTVw/eI7cuT21XBbvwEswbIOA==}
@@ -8732,25 +8671,8 @@ packages:
resolution: {integrity: sha512-/aE8hCfKlQeA8LmyeyQvQF3eBiLRGNlfBJEvWH7ivp9sBqs7TNqBL5X3v157rM4IFETqDnIOO+z5M/biZbo9Ww==}
- resolution: {integrity: sha512-bXfMZtsaomK6ysNN/UGRIcasQAYkC10NtPmP0oOHOV8YOhA2TXmwRXCku4qOzjIFxAPfish5+XS0eIug2PzNZA==}
- engines: {node: '>=16'}
- peerDependencies:
- '@types/mdast': ^4.0.0
- unified: ^11.0.0
- peerDependenciesMeta:
- '@types/mdast':
- optional: true
-
- resolution: {integrity: sha512-UvAgxwlNk+l9Oqgl/9MWK2eWRS7zgBW/nXX9AthV7nd/3lNejF138E7Xbmk9Zs4WjTJGs721r7fAEc7tNFoH7g==}
- engines: {node: '>=16'}
- peerDependencies:
- '@types/mdast': ^4.0.0
- unified: ^11.0.0
- peerDependenciesMeta:
- '@types/mdast':
- optional: true
+ resolution: {integrity: sha512-CsnhKNsyI8Tub6L4sm5ZFsme4puGfc6pYylvXo1AeqaGbjOYyzNv3qZPwvs0oMJ39eryyeOdmxwUIo94IpEhqg==}
resolution: {integrity: sha512-1quofZ2RQ9EWdeN34S79+KExV1764+wCUGop5CPL1WGdD0ocPpu91lzPGbwWMECpEpd42kJGQwzRfyov9j4yNg==}
@@ -8767,8 +8689,8 @@ packages:
resolution: {integrity: sha512-1OSmLd3awB/t8qdoEOMazZkNsfVTeY4fTsgzcQFdXNq8ToTN4ZGwrMnlda4K6smTFKD+GRV6O48i6Z4iKgPPpw==}
- resolution: {integrity: sha512-152puVH0qMoRJQFnaMG+rVDdf01Jq/CaED+MBuXExurJgdbkLp0c3TIe4R12o28Klx8uyGsjvFNG05aFG69G9w==}
+ resolution: {integrity: sha512-JENGyuIhTwzUfCarW43X4r9cehoqTo9QyYxfNDZSud2AmqeuWjZ5pfybasTa4q0dxTJAj5m8NB+wR+YueAFpxQ==}
resolution: {integrity: sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw==}
@@ -9012,9 +8934,6 @@ packages:
resolution: {integrity: sha512-ObmnIF4hXNg1BqhnHmgbDETF8dLPCggZWBjkQfhZpbszZnYur5DUljTcCHii5LC3J5E0yeO/1LIMyH+UvHQgyw==}
engines: {node: '>= 0.4'}
- resolution: {integrity: sha512-uIrKI+f9IPz1zDT+GMz+0RjzKJiijVr6WDWm9Pe3NNY6QigKCfifCEv9v9R2mDASKKjzjQ2QpFLcxaR3iHSnMA==}
-
resolution: {integrity: sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==}
engines: {node: '>= 0.4'}
@@ -9136,8 +9055,8 @@ packages:
resolution: {integrity: sha512-76ORR0DO1o1hlKwTbi/DM3EXWGf3ZJYO8cXX5RJwnul2DEg2oyoZyjLNoQM8WsvZiFKCRfC1O0J7iCvie3RZmQ==}
- resolution: {integrity: sha512-B4Y3Z/qiXl1Dc+LzAB5c52Cd1QGRiFjaDwP+ERoj1JtCykdRDM8X6HwQnn3YkpkSk0x3R7S/6LrGe1nQiElHQQ==}
+ resolution: {integrity: sha512-u9gWd0AmjKg1d+74P44XaPlGrMeC21oDOSIhjGNEYMAttDMzCzlJO6lpTyJ9JkSinQQF65YcK4eOd3q9iTvULw==}
peerDependencies:
react: ^19.2.3
@@ -9365,8 +9284,8 @@ packages:
resolution: {integrity: sha512-P+Vu1qXfzediirmHOC3xKGAYeZtPcV9g76X+xg2FD4tYgR71ewMA35Y3sCz3zhiN/dwefRpJX0yBcgwi1fXNQA==}
- resolution: {integrity: sha512-gBXpgUm/3rp1lMZZrM/w7D8GKqshif0zAymAhbCyIt8KMe+0v9DQ7cdYLR4FHH/cKpdTXb+A/tKKU3eolfsI+g==}
+ resolution: {integrity: sha512-uSaO4gnW+b3Y2aWoWfFpX62vn2sR3skfhbjsEnaBI81WD1wBLlHZe5sWf0AqjksNdYTbGBEd0UasQMT3SNV15g==}
resolution: {integrity: sha512-bl6mpH3T7I3UFxuvDEXLxy/VuFxBk5bbzplh7tXI68mwMokNYd1t9qPBHlnyTwfa4JGC4zP516I1hYYtQ/vspA==}
@@ -14091,39 +14010,6 @@ snapshots:
'@rollup/[email protected]':
optional: true
- '@shikijs/[email protected]':
- dependencies:
- '@shikijs/types': 3.12.2
- '@shikijs/vscode-textmate': 10.0.2
- '@types/hast': 3.0.4
- hast-util-to-html: 9.0.5
-
- '@shikijs/[email protected]':
- dependencies:
- '@shikijs/types': 3.12.2
- '@shikijs/vscode-textmate': 10.0.2
- oniguruma-to-es: 4.3.3
-
- '@shikijs/[email protected]':
- dependencies:
- '@shikijs/types': 3.12.2
- '@shikijs/vscode-textmate': 10.0.2
-
- '@shikijs/[email protected]':
- dependencies:
- '@shikijs/types': 3.12.2
-
- '@shikijs/[email protected]':
- dependencies:
- '@shikijs/types': 3.12.2
-
- '@shikijs/[email protected]':
- dependencies:
- '@shikijs/vscode-textmate': 10.0.2
- '@types/hast': 3.0.4
-
- '@shikijs/[email protected]': {}
-
'@sinclair/[email protected]': {}
'@sourcegraph/[email protected]':
@@ -14230,6 +14116,15 @@ snapshots:
transitivePeerDependencies:
- supports-color
+ dependencies:
+ katex: 0.16.27
+ react: 19.2.3
+ rehype-katex: 7.0.1
+ remark-math: 6.0.0
+ transitivePeerDependencies:
+ - supports-color
+
'@swc-jotai/[email protected]': {}
@@ -17462,19 +17357,11 @@ snapshots:
web-namespaces: 2.0.1
zwitch: 2.0.4
dependencies:
'@types/hast': 3.0.4
- '@types/unist': 3.0.3
- ccount: 2.0.1
- comma-separated-tokens: 2.0.3
- hast-util-whitespace: 3.0.0
- html-void-elements: 3.0.0
- mdast-util-to-hast: 13.2.0
- property-information: 7.1.0
- space-separated-tokens: 2.0.2
- stringify-entities: 4.0.4
- zwitch: 2.0.4
+ '@ungap/structured-clone': 1.3.0
+ unist-util-position: 5.0.0
dependencies:
@@ -17517,8 +17404,6 @@ snapshots:
dependencies:
'@types/hast': 3.0.4
-
dependencies:
'@types/hast': 3.0.4
@@ -18229,10 +18114,6 @@ snapshots:
dependencies:
yallist: 3.1.1
- dependencies:
- react: 19.2.3
-
dependencies:
react: 19.2.3
@@ -18311,6 +18192,8 @@ snapshots:
+
@@ -18548,38 +18431,6 @@ snapshots:
micromark-util-symbol: 2.0.1
micromark-util-types: 2.0.2
- dependencies:
- devlop: 1.1.0
- get-east-asian-width: 1.4.0
- micromark: 4.0.2
- micromark-extension-cjk-friendly-util: 2.1.1([email protected])
- micromark-util-character: 2.1.1
- micromark-util-chunked: 2.0.1
- micromark-util-resolve-all: 2.0.1
- micromark-util-symbol: 2.0.1
- optionalDependencies:
- micromark-util-types: 2.0.2
-
- dependencies:
- get-east-asian-width: 1.4.0
- micromark-util-character: 2.1.1
- micromark-util-symbol: 2.0.1
- optionalDependencies:
- micromark-util-types: 2.0.2
-
- dependencies:
- devlop: 1.1.0
- micromark: 4.0.2
- micromark-extension-cjk-friendly-util: 2.1.1([email protected])
- micromark-util-chunked: 2.0.1
- micromark-util-resolve-all: 2.0.1
- micromark-util-symbol: 2.0.1
- optionalDependencies:
- micromark-util-types: 2.0.2
-
dependencies:
micromark-util-character: 2.1.1
@@ -19029,14 +18880,6 @@ snapshots:
dependencies:
wrappy: 1.0.2
-
- dependencies:
- oniguruma-parser: 0.12.1
- regex: 6.0.1
- regex-recursion: 6.0.2
-
dependencies:
default-browser: 5.4.0
@@ -20125,16 +19968,6 @@ snapshots:
get-proto: 1.0.1
which-builtin-type: 1.2.1
- dependencies:
- regex-utilities: 2.3.0
-
-
- dependencies:
- regex-utilities: 2.3.0
-
@@ -20205,7 +20038,7 @@ snapshots:
dependencies:
unist-util-visit: 5.0.0
@@ -20225,25 +20058,10 @@ snapshots:
hast-util-raw: 9.1.0
vfile: 6.0.3
dependencies:
- micromark-extension-cjk-friendly-gfm-strikethrough: 1.2.3([email protected])([email protected])
- unified: 11.0.5
- optionalDependencies:
- '@types/mdast': 4.0.4
- transitivePeerDependencies:
- - micromark
- - micromark-util-types
-
- dependencies:
- micromark-extension-cjk-friendly: 1.2.3([email protected])([email protected])
- unified: 11.0.5
- optionalDependencies:
- '@types/mdast': 4.0.4
- transitivePeerDependencies:
- - micromark
- - micromark-util-types
+ '@types/hast': 3.0.4
+ hast-util-sanitize: 5.0.2
dependencies:
@@ -20288,7 +20106,7 @@ snapshots:
mdast-util-to-markdown: 2.1.2
unified: 11.0.5
dependencies:
@@ -20591,17 +20409,6 @@ snapshots:
- dependencies:
- '@shikijs/core': 3.12.2
- '@shikijs/engine-javascript': 3.12.2
- '@shikijs/engine-oniguruma': 3.12.2
- '@shikijs/langs': 3.12.2
- '@shikijs/themes': 3.12.2
- '@shikijs/types': 3.12.2
- '@shikijs/vscode-textmate': 10.0.2
- '@types/hast': 3.0.4
-
dependencies:
es-errors: 1.3.0
@@ -20760,35 +20567,24 @@ snapshots:
dependencies:
clsx: 2.1.1
- hast: 1.0.0
hast-util-to-jsx-runtime: 2.3.6
html-url-attributes: 3.0.1
- katex: 0.16.27
- lucide-react: 0.542.0([email protected])
- marked: 16.2.1
- mermaid: 11.12.2
+ marked: 17.0.1
react: 19.2.3
- rehype-harden: 1.1.6
- rehype-katex: 7.0.1
+ rehype-harden: 1.1.7
rehype-raw: 7.0.0
- remark-cjk-friendly-gfm-strikethrough: 1.2.3(@types/[email protected])([email protected])([email protected])([email protected])
+ rehype-sanitize: 6.0.0
remark-gfm: 4.0.1
- remark-math: 6.0.0
remark-parse: 11.0.0
remark-rehype: 11.1.2
- remend: 1.0.1
- shiki: 3.12.2
- tailwind-merge: 3.3.1
+ remend: 1.1.0
+ tailwind-merge: 3.4.0
unified: 11.0.5
unist-util-visit: 5.0.0
transitivePeerDependencies:
- - '@types/mdast'
- - micromark
- - micromark-util-types
- supports-color
@@ -21097,7 +20893,7 @@ snapshots:
dependencies:
diff --git a/tests/_server/ai/snapshots/chat_system_prompts.txt b/tests/_server/ai/snapshots/chat_system_prompts.txt
index 80b3f0902f..50e1045779 100644
--- a/tests/_server/ai/snapshots/chat_system_prompts.txt
+++ b/tests/_server/ai/snapshots/chat_system_prompts.txt
@@ -139,6 +139,11 @@ chart
6. If an import already exists, do not import it again.
7. If a variable is already defined, use another name, or make it private by adding an underscore at the beginning.
+## Rules for markdown:
+1. Use double dollar signs ($$) for ALL mathematical expressions (both inline and block) in markdown responses.
+2. Example: $$E=mc^2$$
+3. Do NOT use single dollar signs or square brackets for math.
+
## Rules for sql:
1. The SQL must use duckdb syntax.
@@ -281,6 +286,11 @@ chart
6. If an import already exists, do not import it again.
7. If a variable is already defined, use another name, or make it private by adding an underscore at the beginning.
+## Rules for markdown:
+1. Use double dollar signs ($$) for ALL mathematical expressions (both inline and block) in markdown responses.
+2. Example: $$E=mc^2$$
+3. Do NOT use single dollar signs or square brackets for math.
+
## Rules for sql:
1. The SQL must use duckdb syntax.
@@ -426,6 +436,11 @@ chart
6. If an import already exists, do not import it again.
7. If a variable is already defined, use another name, or make it private by adding an underscore at the beginning.
+## Rules for markdown:
+1. Use double dollar signs ($$) for ALL mathematical expressions (both inline and block) in markdown responses.
+2. Example: $$E=mc^2$$
+3. Do NOT use single dollar signs or square brackets for math.
+
## Rules for sql:
1. The SQL must use duckdb syntax.
@@ -571,6 +586,11 @@ chart
6. If an import already exists, do not import it again.
7. If a variable is already defined, use another name, or make it private by adding an underscore at the beginning.
+## Rules for markdown:
+1. Use double dollar signs ($$) for ALL mathematical expressions (both inline and block) in markdown responses.
+2. Example: $$E=mc^2$$
+3. Do NOT use single dollar signs or square brackets for math.
+
## Rules for sql:
1. The SQL must use duckdb syntax.
@@ -722,6 +742,11 @@ chart
6. If an import already exists, do not import it again.
7. If a variable is already defined, use another name, or make it private by adding an underscore at the beginning.
+## Rules for markdown:
+1. Use double dollar signs ($$) for ALL mathematical expressions (both inline and block) in markdown responses.
+2. Example: $$E=mc^2$$
+3. Do NOT use single dollar signs or square brackets for math.
+
## Rules for sql:
1. The SQL must use duckdb syntax.
@@ -881,6 +906,11 @@ chart
6. If an import already exists, do not import it again.
7. If a variable is already defined, use another name, or make it private by adding an underscore at the beginning.
+## Rules for markdown:
+1. Use double dollar signs ($$) for ALL mathematical expressions (both inline and block) in markdown responses.
+2. Example: $$E=mc^2$$
+3. Do NOT use single dollar signs or square brackets for math.
+
## Rules for sql:
1. The SQL must use duckdb syntax.
@@ -1043,6 +1073,11 @@ chart
2. This will automatically display the result in the UI. You do not need to return the dataframe in the cell.
3. The SQL must use the syntax of the database engine specified in the `engine` variable. If no engine, then use duckdb syntax.
+## Rules for markdown:
+1. Use double dollar signs ($$) for ALL mathematical expressions (both inline and block) in markdown responses.
+2. Example: $$E=mc^2$$
+3. Do NOT use single dollar signs or square brackets for math.
+
## Rules for inserting cells:
For markdown cells, use `mo.md(f"""{content}""")`
For sql cells, use `mo.sql(f"""{content}""")`. If a database engine is specified, use `mo.sql(f"""{content}""", engine=engine)` instead.
@@ -1187,6 +1222,11 @@ chart
6. If an import already exists, do not import it again.
7. If a variable is already defined, use another name, or make it private by adding an underscore at the beginning.
+## Rules for markdown:
+1. Use double dollar signs ($$) for ALL mathematical expressions (both inline and block) in markdown responses.
+2. Example: $$E=mc^2$$
+3. Do NOT use single dollar signs or square brackets for math.
+
## Rules for sql:
1. The SQL must use duckdb syntax.
diff --git a/tests/_server/ai/snapshots/system_prompts.txt b/tests/_server/ai/snapshots/system_prompts.txt
index 8902f4cdb9..7bab6bbf63 100644
--- a/tests/_server/ai/snapshots/system_prompts.txt
+++ b/tests/_server/ai/snapshots/system_prompts.txt
@@ -37,6 +37,11 @@ Immediately start with the following format. Do NOT comment on the code, just ou
{CELL_CODE}
```
+## Rules for markdown
+1. Use double dollar signs ($$) for ALL mathematical expressions (both inline and block) in markdown responses.
+2. Example: $$E=mc^2$$
+3. Do NOT use single dollar signs or square brackets for math.
+
Again, just output the code itself and make sure to return the code as just markdown.
==================== sql ====================
@@ -351,6 +356,11 @@ Separate logic into multiple cells to keep the code organized and readable.
2. This will automatically display the result in the UI. You do not need to return the dataframe in the cell.
3. The SQL must use the syntax of the database engine specified in the `engine` variable. If no engine, then use duckdb syntax.
+## Rules for markdown:
+1. Use double dollar signs ($$) for ALL mathematical expressions (both inline and block) in markdown responses.
+2. Example: $$E=mc^2$$
+3. Do NOT use single dollar signs or square brackets for math.
+
## Available variables from other cells:
- variable: `df`
- value_type: DataFrame
diff --git a/tests/_server/ai/test_prompts.py b/tests/_server/ai/test_prompts.py
index 6e9e7d9a97..c03a824e85 100644
--- a/tests/_server/ai/test_prompts.py
+++ b/tests/_server/ai/test_prompts.py
@@ -349,6 +349,40 @@ def test_chat_system_prompts():
snapshot("chat_system_prompts.txt", result)
+def test_markdown_rules_include_latex():
+ from marimo._server.ai.prompts import (
+ get_chat_system_prompt,
+ get_refactor_or_insert_notebook_cell_system_prompt,
+ )
+
+ # Test refactor prompt
+ refactor_prompt = get_refactor_or_insert_notebook_cell_system_prompt(
+ language="markdown",
+ is_insert=False,
+ support_multiple_cells=False,
+ custom_rules=None,
+ cell_code=None,
+ selected_text=None,
+ other_cell_codes=None,
+ context=None,
+ )
+ assert "double dollar signs ($$)" in refactor_prompt
+ assert "$$E=mc^2$$" in refactor_prompt
+ assert "Do NOT use single dollar signs" in refactor_prompt
+
+ # Test chat prompt
+ chat_prompt = get_chat_system_prompt(
+ custom_rules=None,
+ include_other_code="",
+ context=None,
+ mode="manual",
+ session_id=SessionId("test"),
+ )
+ assert "double dollar signs ($$)" in chat_prompt
+ assert "$$E=mc^2$$" in chat_prompt
+ assert "Do NOT use single dollar signs" in chat_prompt
+
+
def test_format_variables():
"""Test the _format_variables function."""
# Test empty variables