React Markdown(II) – auto generate catalog, support math formula and customize footnotes

Last time, we have introduced how to display a Markdown document in React.(http://52.65.48.177/index.php/2023/03/13/rendering-markdown-in-react/) Now, let’s move forward to support ToC(Table of Content), Mathematical Formula and Footnote. 1. ToC (Table of Content) To support ToC and in-page jump, we need two plugins: remarkToc and rehypeSlug. RehypeSlug is a plugin to add Read more…

Rendering Markdown in React

Download dependency. yarn add react-markdown yarn add remark-gfm yarn add rehype-raw yarn add react-syntax-highlighter yarn add github-markdown-css Use fetch to fetch the contents of a Markdown file and render it using react-markdown. import React from ‘react’; import ReactMarkdown from ‘react-markdown’; const App=({url})=>{ const [mdContent, setMdContent] = useState(”) useEffect(() => { Read more…