Skip to content

Commit 560e6ff

Browse files
committed
feat: latex equation support for md
1 parent 1dd6dbb commit 560e6ff

12 files changed

+389
-95
lines changed

package-lock.json

Lines changed: 237 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"framer-motion": "^11.0.24",
1616
"front-matter": "^4.0.2",
1717
"html2canvas": "^1.4.1",
18+
"katex": "^0.16.27",
1819
"marked": "^16.4.1",
1920
"piml": "^1.1.1",
2021
"prismjs": "^1.30.0",
@@ -29,8 +30,10 @@
2930
"react-slick": "^0.31.0",
3031
"react-snap": "github:fezcode/react-snap",
3132
"react-syntax-highlighter": "^16.1.0",
33+
"rehype-katex": "^7.0.1",
3234
"rehype-raw": "^7.0.0",
3335
"remark-gfm": "^4.0.1",
36+
"remark-math": "^6.0.0",
3437
"rss": "^1.2.2",
3538
"slick-carousel": "^1.8.1",
3639
"stackblur-canvas": "^2.7.0",

src/components/MarkdownContent.jsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import React, { useState } from 'react';
22
import ReactMarkdown from 'react-markdown';
33
import remarkGfm from 'remark-gfm';
4+
import remarkMath from 'remark-math';
45
import rehypeRaw from 'rehype-raw';
6+
import rehypeKatex from 'rehype-katex';
57
import { ImagesIcon } from '@phosphor-icons/react';
68
import ImageModal from './ImageModal';
79

@@ -39,8 +41,8 @@ const MarkdownContent = ({ content, components = {}, className = '' }) => {
3941
<>
4042
<div className={className}>
4143
<ReactMarkdown
42-
remarkPlugins={[remarkGfm]}
43-
rehypePlugins={[rehypeRaw]}
44+
remarkPlugins={[remarkGfm, remarkMath]}
45+
rehypePlugins={[rehypeRaw, rehypeKatex]}
4446
components={defaultComponents}
4547
>
4648
{content}

src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22
import ReactDOM from 'react-dom/client';
33
import './index.css';
4+
import 'katex/dist/katex.min.css';
45
import App from './App';
56
import reportWebVitals from './reportWebVitals';
67

0 commit comments

Comments
 (0)