Created
April 12, 2023 08:38
-
-
Save tjsudarsan/169998f883d97462efabd37a8fd1e2ee to your computer and use it in GitHub Desktop.
Rendering math with react-markdown [UPDATED]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ReactMarkdown from "react-markdown"; | |
import remarkMath from "remark-math"; | |
import rehypeKatex from "rehype-katex"; | |
import "katex/dist/katex.min.css"; | |
const App = (props) => { | |
const md = `The equation for softmax function is:\n\n$$\\sigma(z)_j = \\frac{e^{z_j}}{\\sum\\limits_{k=1}^{K}e^{z_k}}$$\n\nwhere $z$ is the input vector of length $K$ and $\\sigma(z)$ is the output vector of length $K$, with each element representing the probability of the input belonging to that class.`; | |
return ( | |
<ReactMarkdown remarkPlugins={[remarkMath]} rehypePlugins={[rehypeKatex]}> | |
{md} | |
</ReactMarkdown> | |
); | |
}; | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment