fix(ui): add KaTeX CSS and normalize LaTeX math delimiters for proper formula rendering

Import KaTeX CSS in layout.tsx to ensure math formulas display correctly
in both dev and production modes. Convert LaTeX-style `\[...\]` / `\(...\)`
delimiters to `$$...$$` / `$...$` since remark-math only supports dollar
sign delimiters, fixing formula rendering for agents like Codex.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
xintaofei
2026-04-08 23:27:40 +08:00
co-authored by Claude Opus 4.6
parent 0b866eddb4
commit c367117392
4 changed files with 47 additions and 6 deletions
@@ -22,6 +22,7 @@ import { createMathPlugin } from "@streamdown/math"
import { mermaid } from "@streamdown/mermaid"
import { Streamdown } from "streamdown"
import { readFileBase64 } from "@/lib/api"
import { normalizeMathDelimiters } from "@/components/ai-elements/message"
import { defineMonacoThemes, useMonacoThemeSync } from "@/lib/monaco-themes"
import "@/lib/monaco-local"
@@ -1354,9 +1355,8 @@ export function FileWorkspacePanel() {
const relativeFileDir = activeFileTab.path?.includes("/")
? activeFileTab.path.replace(/\/[^/]*$/, "")
: ""
const preprocessedContent = preprocessMarkdownPaths(
renderedContent,
relativeFileDir
const preprocessedContent = normalizeMathDelimiters(
preprocessMarkdownPaths(renderedContent, relativeFileDir)
)
return (