Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@
"preview": "vite preview"
},
"dependencies": {
"katex": "^0.16.44",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The version 0.16.44 for katex does not appear to exist on npm. The current latest version in the 0.16.x branch is 0.16.11. This typo will likely cause installation or build failures.

Suggested change
"katex": "^0.16.44",
"katex": "^0.16.11",

"react": "^19.2.0",
"react-dom": "^19.2.0",
"react-markdown": "^10.1.0",
"react-syntax-highlighter": "^16.1.1",
"remark-gfm": "^4.0.1"
"rehype-katex": "^7.0.1",
"remark-gfm": "^4.0.1",
"remark-math": "^6.0.0"
},
"devDependencies": {
"@eslint/js": "^9.39.1",
Expand Down
10 changes: 10 additions & 0 deletions src/components/MarkdownRenderer/MarkdownRenderer.css
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,13 @@
.markdown-body h2 {
margin-top: 0px !important;
}

.katex {
color: #e0e0e0;
font-size: 1.1em;
}

.katex-display {
margin: 1.5em 0;
overflow-x: auto;
}
6 changes: 5 additions & 1 deletion src/components/MarkdownRenderer/MarkdownRenderer.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import ReactMarkdown from 'react-markdown';
import remarkGfm from 'remark-gfm';
import remarkMath from 'remark-math';
import rehypeKatex from 'rehype-katex';
import 'katex/dist/katex.min.css';
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
import { vscDarkPlus } from 'react-syntax-highlighter/dist/esm/styles/prism';
import './MarkdownRenderer.css'
Expand Down Expand Up @@ -64,7 +67,8 @@ export default function MarkdownRenderer({ content }) {
)}

<ReactMarkdown
remarkPlugins={[remarkGfm]}
remarkPlugins={[remarkGfm, remarkMath]}
rehypePlugins={[rehypeKatex]}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

By default, rehype-katex will throw an error if it encounters invalid LaTeX syntax, which can crash the entire rendering of the component. It is safer to set throwOnError: false so that KaTeX renders the problematic string as-is (usually in red) instead of throwing an exception.

Suggested change
rehypePlugins={[rehypeKatex]}
rehypePlugins={[[rehypeKatex, { throwOnError: false }]]}

components={MarkdownComponents}
>
{cleanContent}
Expand Down
Loading