feat: Add rehype-katex dependency for rendering math equations in Markdown

This commit is contained in:
n4ze3m 2024-06-09 11:56:49 +05:30
parent 68bd3e651b
commit 52ccbc67bb
3 changed files with 6 additions and 6 deletions

BIN
bun.lockb

Binary file not shown.

View File

@ -48,6 +48,7 @@
"react-router-dom": "6.10.0",
"react-syntax-highlighter": "^15.5.0",
"react-toastify": "^10.0.4",
"rehype-katex": "6.0.3",
"rehype-mathjax": "4.0.3",
"remark-gfm": "3.0.1",
"remark-math": "5.1.1",

View File

@ -1,13 +1,12 @@
import remarkGfm from "remark-gfm"
import remarkMath from "remark-math"
import ReactMarkdown from "react-markdown"
import "property-information"
import React from "react"
import { CodeBlock } from "./CodeBlock"
export default function Markdown({ message }: { message: string }) {
return (
<React.Fragment>
<ReactMarkdown
@ -17,10 +16,10 @@ export default function Markdown({ message }: { message: string }) {
code({ node, inline, className, children, ...props }) {
const match = /language-(\w+)/.exec(className || "")
return !inline ? (
<CodeBlock
language={match ? match[1] : ""}
value={String(children).replace(/\n$/, "")}
/>
<CodeBlock
language={match ? match[1] : ""}
value={String(children).replace(/\n$/, "")}
/>
) : (
<code className={`${className} font-semibold`} {...props}>
{children}