fix: enable inline math formula rendering in web UI#1474
fix: enable inline math formula rendering in web UI#1474Br1an67 wants to merge 1 commit intoMoonshotAI:mainfrom
Conversation
6c57004 to
5d4f199
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5d4f1991dc
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| import { StrictMode } from "react"; | ||
| import { createRoot } from "react-dom/client"; | ||
| import "./index.css"; | ||
| import "katex/dist/katex.min.css"; |
There was a problem hiding this comment.
Declare katex as a direct web dependency
Importing katex/dist/katex.min.css here relies on katex being hoisted from streamdown’s transitive dependencies, but web/package.json does not declare katex itself. This can break the web build in environments that don't hoist transitive packages (or after future dependency graph changes), where Vite will fail to resolve the import at startup; adding katex as a direct dependency avoids that fragility.
Useful? React with 👍 / 👎.
5d4f199 to
5fe090c
Compare
Block math formulas (using $$...$$) rendered correctly, but inline math (using $...$) was not rendered because the katex rehype plugin was disabled along with all other plugins. Re-enable the katex rehype plugin specifically, as it only processes math delimiters and does not pose an XSS risk (unlike the 'raw' and 'harden' plugins which remain disabled). Import katex CSS for proper formula styling. Fixes MoonshotAI#1420
5fe090c to
0c15ebe
Compare
Problem
Block math (
$$...$$) renders correctly, but inline math ($...$) does not because all rehype plugins are disabled in the streamdown configuration.Fix
Re-enable the
'katex'rehype plugin specifically. KaTeX only processes math delimiters and does not pose an XSS risk (unlike the'raw'and'harden'plugins which remain disabled).Also import
katex/dist/katex.min.cssfor proper formula styling. The katex package is already a transitive dependency of streamdown (confirmed in package-lock.json).Fixes #1420