Skip to content

Commit

Permalink
feat(md): support math with katex
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Jul 4, 2023
1 parent cb7e913 commit d12c378
Show file tree
Hide file tree
Showing 4 changed files with 1,243 additions and 2 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,10 @@
"hls.js": "^1.2.1",
"lightgallery": "^2.5.0",
"mitt": "^3.0.0",
"rehype-katex": "^6.0.3",
"rehype-raw": "^6.1.1",
"remark-gfm": "^3.0.1",
"remark-math": "^5.1.1",
"seemly": "^0.3.6",
"solid-contextmenu": "0.0.2",
"solid-icons": "^1.0.1",
Expand Down
131 changes: 131 additions & 0 deletions pnpm-lock.yaml

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

7 changes: 5 additions & 2 deletions src/components/Markdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { hljs } from "./highlight.js"
import SolidMarkdown from "solid-markdown"
import remarkGfm from "remark-gfm"
import rehypeRaw from "rehype-raw"
import reMarkMath from "remark-math"
import rehypeKatex from "rehype-katex"
import "./markdown.css"
import "./katex.css"
import { onMount } from "solid-js"
import { clsx } from "clsx"

Expand All @@ -14,8 +17,8 @@ export const Markdown = (props: { children?: string; class?: string }) => {
return (
<SolidMarkdown
class={clsx("markdown-body", props.class)}
remarkPlugins={[remarkGfm]}
rehypePlugins={[rehypeRaw]}
remarkPlugins={[remarkGfm, reMarkMath]}
rehypePlugins={[rehypeRaw, rehypeKatex]}
children={props.children}
/>
)
Expand Down

0 comments on commit d12c378

Please sign in to comment.