mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-06 19:08:59 -05:00
[GH-ISSUE #21612] bug: LaTeX Rendering Fails for API-Connected Models Using Standard Delimiter Conventions #58204
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @BrutchsamaJeanLouis on GitHub (Feb 19, 2026).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/21612
Check Existing Issues
Installation Method
Docker
Open WebUI Version
v0.8.3
Ollama Version (if applicable)
Latest (issue primarily affects API-connected models, not Ollama-specific)
Operating System
Reproducible across Windows, macOS, Linux
Browser (if applicable)
Reproducible across Chrome, Firefox, Brave (latest stable versions)
Confirmation
README.md.Expected Behavior
All standard LaTeX delimiter formats should render correctly and consistently:
$x^2$$$\sum_{i=1}^{n} i$$\(x^2\)\[\sum_{i=1}^{n} i\]$O(n \log n)$Mixed content like the following should render seamlessly:
Expected result: Inline expression renders within the sentence. Display expression renders as a centered block. Surrounding markdown (bold, headers, paragraphs) is unaffected.
Actual Behavior
Single
$inline math fails to render. Models default to$...$for inline math (standard LaTeX convention). OpenWebUI's KaTeX configuration historically requires$$...$$even for inline expressions, or silently fails.Multi-line display math with
\[...\]breaks. When\[and\]appear on separate lines (which models frequently produce for readability), rendering fails entirely and raw LaTeX syntax is shown to the user.Inconsistent rendering within a single response. Some expressions render while others in the same message do not. There is no predictable pattern — identical delimiter formats can succeed or fail depending on surrounding markdown context (e.g., expressions adjacent to bold text, inside lists, or following headers).
Streaming rendering artifacts. During streamed responses, partially received LaTeX expressions can trigger KaTeX parse errors that persist even after the full expression is received, requiring a page refresh.
Model instruction workarounds are unreliable. Adding system prompt instructions like "always use $$ delimiters" does not reliably change model output. Models inconsistently follow delimiter format instructions — sometimes using
\\,\\\, or\\\\for the same escape sequence, and reverting to single$for inline math regardless of instructions.Root Cause Analysis:
$as a delimiter by default. This is a configuration choice, not a KaTeX limitation.$characters before KaTeX can identify them as math delimiters.Steps to Reproduce
$...$expressions appear as raw text instead of rendered math.$$...$$blocks render, others do not, especially when interleaved with markdown formatting.Contrast: The same model producing the same tokens renders all math correctly in its native interface (claude.ai, chat.openai.com), because those platforms control both generation and rendering pipelines.
Note: This issue has been reported across versions 0.3.x, 0.4.x, 0.5.x, and 0.8.x. See related issues: #2365, #2615, #3581, #8299, #8437, and Discussion #18508.
Logs & Screenshots
This is a rendering/configuration issue rather than a crash — no specific error logs are produced. The failure mode is silent: LaTeX delimiters are passed through as raw text rather than triggering KaTeX rendering. In the browser console, KaTeX parse errors may occasionally appear during streaming when partial LaTeX expressions are received.
Additional Information
Proposed Solutions (in order of implementation effort)
1. Enable single
$delimiters in KaTeX configurationAdd
{left: "$", right: "$", display: false}to the KaTeX auto-render delimiter configuration. This is a one-line change that resolves the most common failure mode.2. Add a LaTeX normalization pipeline stage
Implement a pre-render pass that normalizes model output before it reaches the markdown parser:
\(...\)→$...$\[...\]→$$...$$This is similar to what the community LaTeX Display Optimization filter does, but should be built into the core rendering pipeline rather than requiring user-installed functions.
3. Configurable math renderer (KaTeX vs MathJax)
As raised in Discussion #18508 — provide an option to switch to MathJax, which handles delimiter ambiguity more gracefully and supports a wider range of LaTeX commands. This could be a user-facing setting in Settings > Interface.
4. Render-time delimiter detection
Implement intelligent delimiter detection that identifies probable LaTeX content even when delimiters are non-standard or ambiguous, similar to how VS Code's markdown preview handles mixed math content.
Impact
This issue disproportionately affects:
The current state forces users to choose between: (a) degraded rendering quality, (b) system prompt workarounds that unreliably constrain model output, or (c) installing community filter functions that add maintenance overhead and don't fully resolve the issue.
Related Issues and Discussions
Models tested: Claude 3.5/4 via Anthropic API, GPT-4 via OpenAI-compatible endpoint, Llama 3 via Ollama
@pr-validator-bot commented on GitHub (Feb 19, 2026):
⚠️ Missing Issue Title Prefix
@BrutchsamaJeanLouis, your issue title is missing a prefix (e.g.,
bug:,feat:,docs:).Please update your issue title to include one of the following prefixes:
Example:
bug: Login fails when using special characters in password@tjbck commented on GitHub (Feb 20, 2026):
Intended. If we blindly enable this will break the actual text rendering. Open to discussion.