fix: render math formulas in chat minimap outline - #349
Open
zhudatou630 wants to merge 1 commit into
Open
Conversation
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.
There was a problem hiding this comment.
Pull request overview
This PR fixes math rendering in the chat minimap’s assistant outline by aligning its markdown rendering pipeline with the existing markdown preview pipeline, so headings containing LaTeX render as KaTeX rather than raw source.
Changes:
- Add
markdownPreviewRehypePlugins(incl.rehype-katex) to the minimap outline’sReactMarkdownrenderer. - Normalize display/inline math delimiters via
normalizeDisplayMath()before parsing. - Add small KaTeX-specific CSS adjustments for the narrow outline panel.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| components/ChatMinimap.tsx | Runs the same remark+rehype (KaTeX) pipeline as markdown previews and normalizes math delimiters before rendering outline content. |
| components/ChatMinimap.module.css | Tweaks KaTeX sizing/display specifically within the minimap outline for better fit. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
174
to
179
| a: ({ children }) => <>{children}</>, | ||
| code: ({ children }) => <>{children}</>, | ||
| }} | ||
| > | ||
| {markdown} | ||
| {normalizeDisplayMath(markdown)} | ||
| </ReactMarkdown> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
remark-math, but never ranrehype-katex, so headings with formulas showed raw LaTeX.normalizeDisplayMath+markdownPreviewRehypePlugins) already used by markdown previews.Root cause
AssistantOutlineinChatMinimapusedmarkdownPreviewRemarkPlugins(includesremarkMath) withoutmarkdownPreviewRehypePlugins(includesrehype-katex). Math nodes fell through as code/text and the outline'scoderenderer flattened them to raw LaTeX.Test plan
$...$/\(...\)mathf_{k,t+1}/\ln...)