From 3e99611b1b8dc77bf90348ca94c888d252203e15 Mon Sep 17 00:00:00 2001 From: zhujunshen Date: Sun, 2 Aug 2026 08:44:52 +0800 Subject: [PATCH] fix: render math formulas in chat minimap outline The minimap outline enabled remark-math but never ran rehype-katex, so headings with formulas showed raw LaTeX. Reuse the existing preview math pipeline and keep KaTeX sized for the narrow outline. --- components/ChatMinimap.module.css | 9 +++++++++ components/ChatMinimap.tsx | 9 +++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/components/ChatMinimap.module.css b/components/ChatMinimap.module.css index 57735b33e..8cfd70e3c 100644 --- a/components/ChatMinimap.module.css +++ b/components/ChatMinimap.module.css @@ -139,6 +139,15 @@ gap: 0; } +.outline :global(.katex) { + font-size: 1em; +} + +.outline :global(.katex-display) { + display: inline; + margin: 0; +} + .heading, .paragraph { display: block; diff --git a/components/ChatMinimap.tsx b/components/ChatMinimap.tsx index 583ab34fc..b98437d03 100644 --- a/components/ChatMinimap.tsx +++ b/components/ChatMinimap.tsx @@ -2,7 +2,11 @@ import { memo, useEffect, useRef, useState, useCallback, useMemo, type RefObject } from "react"; import ReactMarkdown from "react-markdown"; -import { markdownPreviewRemarkPlugins } from "@/lib/markdown"; +import { + markdownPreviewRehypePlugins, + markdownPreviewRemarkPlugins, + normalizeDisplayMath, +} from "@/lib/markdown"; import { splitFinalAssistantBlocks } from "@/lib/message-display"; import type { AgentMessage, AssistantMessage, TextContent, UserMessage } from "@/lib/types"; import styles from "./ChatMinimap.module.css"; @@ -144,6 +148,7 @@ const AssistantOutline = memo(function AssistantOutline({
{children}, h2: ({ children, node }) => {children}, @@ -170,7 +175,7 @@ const AssistantOutline = memo(function AssistantOutline({ code: ({ children }) => <>{children}, }} > - {markdown} + {normalizeDisplayMath(markdown)}
);