openclaw - 💡(How to fix) Fix Add LaTeX math formula rendering (KaTeX) to markdown renderer

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Add LaTeX/math formula rendering support to the built-in markdown renderer (e.g. via KaTeX).

Root Cause

Add LaTeX/math formula rendering support to the built-in markdown renderer (e.g. via KaTeX).

Fix Action

Fix / Workaround

  • Affected users/systems/channels: All channels using markdown rendering (webchat, QQ Bot, Telegram, Feishu, etc.)
  • Severity: Annoying — doesn't break functionality but forces ugly workarounds
  • Frequency: Common for academic/technical users; every math-heavy conversation is affected
  • Consequence: Users either give up writing math in OpenClaw, or use screenshots/external tools

Code Example

{
    \"markdown\": {
      \"mathRendering\": \"katex\"  // or \"off\" (default), or \"mathjax\"
    }
  }
RAW_BUFFERClick to expand / collapse

Summary

Add LaTeX/math formula rendering support to the built-in markdown renderer (e.g. via KaTeX).

Problem to solve

Many users need to write mathematical formulas in chat messages — $E=mc^2$, $$\int_0^1 x^2 dx$$, matrices, integrals, summations, etc. Currently, writing LaTeX syntax in OpenClaw messages displays as raw text with no rendering. This is a common pain point for researchers, students, and technical professionals.

Proposed solution

Integrate KaTeX (preferred over MathJax for performance) into the markdown rendering pipeline:

  1. Backend (send-hHuodC8E.js): Extend the existing markdown-it instance with markdown-it-katex or equivalent math block/inline token rules, so $...$ (inline) and $$...$$ (block) expressions are rendered to HTML with proper KaTeX output.
  2. Frontend (Control UI): Load KaTeX CSS/JS in index.html and ensure the frontend markdown renderer (also markdown-it based) handles math expressions consistently.

Both the sender-side (when composing) and receiver-side (when viewing) should render math identically.

Alternatives considered

ApproachWhy it's weaker
Canvas embed ([embed url=\"data:text/html,...\"])URL is extremely long, fragile, requires manual encoding, degrades readability
External image generation + paste imageExtra steps per message; images can't be edited
Userscript / browser extensionNot portable across devices; requires per-user setup
Third-party markdown-it plugin (external CDN)Security concern; depends on external resource availability

Impact

  • Affected users/systems/channels: All channels using markdown rendering (webchat, QQ Bot, Telegram, Feishu, etc.)
  • Severity: Annoying — doesn't break functionality but forces ugly workarounds
  • Frequency: Common for academic/technical users; every math-heavy conversation is affected
  • Consequence: Users either give up writing math in OpenClaw, or use screenshots/external tools

Evidence / Prior art

Nearly every modern note-taking and messaging platform supports LaTeX math rendering:

  • GitHub (readmes, issues) — KaTeX
  • Notion — native
  • Obsidian — KaTeX plugin (default in many configs)
  • Typora — native
  • Discord — KaTeX (via bots)
  • Mattermost — KaTeX
  • Stack Overflow — KaTeX

Supporting math rendering would bring OpenClaw in line with user expectations for a modern AI agent platform.

Additional context

  • KaTeX is MIT licensed, lightweight (~400KB vs MathJax's ~2MB), and renders 10-100x faster.
  • markdown-it ecosystem has mature KaTeX integration: markdown-it-katex, markdown-it-mathjax, or custom token rules.
  • The backend already uses markdown-it (send-hHuodC8E.js line 264), so the plugin hook point is already there — only the plugin registration and KaTeX dependency are missing.
  • Configuration could be a simple boolean toggle in openclaw.json:
    {
      \"markdown\": {
        \"mathRendering\": \"katex\"  // or \"off\" (default), or \"mathjax\"
      }
    }

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix Add LaTeX math formula rendering (KaTeX) to markdown renderer