Skip to content

feat: katex math render for markdown.#131

Open
sqhyz55 wants to merge 5 commits intoxorbitsai:mainfrom
sqhyz55:feat/katex-math-render-and-websocket-fix
Open

feat: katex math render for markdown.#131
sqhyz55 wants to merge 5 commits intoxorbitsai:mainfrom
sqhyz55:feat/katex-math-render-and-websocket-fix

Conversation

@sqhyz55
Copy link
Collaborator

@sqhyz55 sqhyz55 commented Mar 10, 2026

No description provided.

@sqhyz55 sqhyz55 marked this pull request as draft March 11, 2026 06:08
@sqhyz55 sqhyz55 force-pushed the feat/katex-math-render-and-websocket-fix branch from 7f5d50b to 0684d99 Compare March 12, 2026 14:00
@sqhyz55 sqhyz55 marked this pull request as ready for review March 12, 2026 14:00
@sqhyz55 sqhyz55 changed the title Feat/katex math render and websocket fix Feat/katex math render Mar 12, 2026
@qinxuye qinxuye changed the title Feat/katex math render feat: katex math render for markdown. Mar 12, 2026
@qinxuye qinxuye requested a review from yiboyasss March 12, 2026 14:27
Copy link
Contributor

@yiboyasss yiboyasss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice improvement!

While testing this locally, I noticed a rendering issue with common shell commands such as: `echo $PATH ` / `echo $HOME`

The `$PATH` / `$HOME` parts are currently interpreted as math expressions and rendered by KaTeX, which breaks the expected display. These patterns are quite common in documentation and code examples.

This happens because the current implementation relies on regex replacement for $...$, which can accidentally match non-math usages of $.

It might be worth considering using a markdown AST-based approach instead, for example integrating math support directly via react-markdown with remark-math and rehype-katex:

import ReactMarkdown from "react-markdown"
import remarkMath from "remark-math"
import rehypeKatex from "rehype-katex"

<ReactMarkdown
  remarkPlugins={[remarkMath]}
  rehypePlugins={[rehypeKatex]}
>
  {markdown}
</ReactMarkdown>

@sqhyz55 sqhyz55 force-pushed the feat/katex-math-render-and-websocket-fix branch from 0684d99 to 3099fc2 Compare March 13, 2026 09:30
sqhyz55 added 5 commits March 14, 2026 11:23
- Add katex and @types/katex dependencies
- Import KaTeX CSS in globals.css
- Add renderMathInMarkdown() in markdown-renderer to support inline $...$
  and block $$...$$ formulas, skipping code blocks

Made-with: Cursor
Move MinimalRequest class definition above the conditional block so it is
in scope when filtering tools by category, avoiding potential NameError.

Made-with: Cursor
Switch MarkdownRenderer to an AST-based pipeline using react-markdown,
remark-math and rehype-katex to avoid regex-based math parsing issues
and correctly handle code blocks and shell snippets like $PATH.

Made-with: Cursor
- Skip package-lock.json in codespell (third-party metadata)
- Add jsdom and vitest setup for jest-dom matchers and @ alias
- Fix MarkdownRenderer test type-check (toBeInTheDocument)
@sqhyz55 sqhyz55 force-pushed the feat/katex-math-render-and-websocket-fix branch from 3099fc2 to 3efa74d Compare March 14, 2026 03:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants