-
Notifications
You must be signed in to change notification settings - Fork 2.3k
feat : add support for math / science symbology via katex #5773
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat : add support for math / science symbology via katex #5773
Conversation
Signed-off-by: Abhijay007 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds LaTeX math rendering support to the desktop UI using KaTeX, enabling proper display of mathematical and scientific expressions in markdown messages. Previously, LaTeX expressions were shown as raw text (e.g., \frac, \sqrt), but now they render as proper mathematical symbols with support for both inline ($...$) and block ($$...$$) math syntax.
Key Changes
- Integrated KaTeX rendering into the markdown pipeline using
remark-mathandrehype-katexplugins - Added custom styling for math expressions with theme-aware colors and proper layout
- Added three new dependencies:
katex,remark-math, andrehype-katex
Reviewed Changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| ui/desktop/src/components/MarkdownContent.tsx | Added KaTeX plugins to the ReactMarkdown component with error handling configuration |
| ui/desktop/src/styles/main.css | Added CSS styling for math expressions with proper theme support for light and dark modes |
| ui/desktop/package.json | Added three new dependencies for KaTeX rendering support |
| ui/desktop/package-lock.json | Lock file updates for new dependencies and their transitive dependencies |
Files not reviewed (1)
- ui/desktop/package-lock.json: Language not supported
|
I like this - tagging @zanesq who may have thoughts as well. Only possible downside are those new dependencies but they seem pretty well maintained and nice, kudos @Abhijay007 ! |
zanesq
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
* main: docs: add DataHub MCP server extension documentation (#5769) docs: lowercase goose in remaining topics (#5861) docs: lowercase goose in getting-started and guides topics (#5857) Fix multi tool calling (#5855) fix(#5626 #5832): handle multiple content chunks & images better (#5839) chore: some old code hanging around, and mention configure cli (#5822) feat : add support for math / science symbology via katex (#5773) feat : add ability to see error message in toast (#5851)
Signed-off-by: Abhijay007 <[email protected]>
Signed-off-by: Abhijay007 <[email protected]> Signed-off-by: Sai Karthik <[email protected]>
Signed-off-by: Abhijay007 <[email protected]> Signed-off-by: Blair Allan <[email protected]>
Fixes issue where underscores and dollar signs in plain text were being interpreted as LaTeX/KaTeX syntax, causing rendering issues in the UI. The problem was introduced in PR block#5773 which added KaTeX support via remarkMath and rehypeKatex plugins. These plugins interpret: - `_` as subscript markers - `$...$` as inline math delimiters This caused issues with: - Shell commands like: cmd "$FOO" --opt="$BAR" - Variable names: variable_name, another_variable - File paths: /path/to/my_file_name.txt - Log output with underscores and dollar signs Solution: - Added escapeLatexOutsideCode() function that identifies code blocks and inline code sections - Escapes `_` to `\_` and `$` to `\$` only in plain text - Preserves original characters inside code blocks and inline code - Also escapes backslashes to prevent double-escaping issues Added comprehensive tests covering: - Underscores in plain text vs code - Dollar signs in shell commands vs code blocks - Mixed content scenarios - File paths and environment variables - Log output with special characters
|
@Abhijay007 we've had some reports internally about LaTeX text rendering issues. Do you want to look into it or revert this for now?
|


Related Issue : #3858 and Discussion : #5737
PR Description
This PR adds LaTeX math rendering to markdown messages using KaTeX. It supports inline math (
$...$) and block math ($$...$$) with proper styling for both light and dark themes. It also fixes the issue where math and scientific expressions were shown as raw LaTeX (e.g.,\frac,\sqrt) instead of rendered symbols.Changes Made
In
ui/desktop/src/components/MarkdownContent.tsxfileremark-math,rehype-katex, and KaTeX CSSremarkMathtoremarkPluginsrehypeKatextorehypePluginswith error handlingIn
ui/desktop/src/styles/main.cssfileIn
ui/desktop/package.jsonfile : Addedkatex@^0.16.25, Addedremark-math@^6.0.0, Addedrehype-katex@^7.0.1Type of Change
AI Assistance
Testing
Tested in the desktop UI with multiple test messages, both with and without math blocks, in dark and light modes.
Screenshots / Demos (for UX changes)
Before:
After: