访问ReactMarkdown中的align环境



访问ReactMarkdown中的align环境。

我希望能够阅读降价文档,并在网站上呈现它们(我想我必须做一些预处理,所以如果这不完全可能,不用担心(。

我现在正在努力解决的问题之一是让ReactMarkdown识别一个等式对齐环境或找到一个等效环境。例如我写的一些胡言乱语是

markdown = `The equation for a line is $y = mx +b$.
The proof is:
\begin{align}
y &= mx + b \\
&= ab + c  
\end{align}
`
<ReactMarkdown
remarkPlugins={[remarkMath]}
rehypePlugins={[rehypeKatex]}
children={markdown}
/>

但这不起作用。。。

我还尝试用$$代替\begin{align}\end{align},并得到了类似的结果。

我已经通读了repo,找不到任何解决它的方法。我也通读了插件页面(这里和这里(,没有发现任何太有希望的东西。

我是错过了什么,还是没有类似align的环境可用?

我真的无法解释为什么,但将对齐环境封装在显示模式$$中,更重要的是导入KaTeX样式表只会使其工作,至少在CodeSandboxReact沙盒中测试时是这样:

import remarkMath from "remark-math";
import rehypeKatex from "rehype-katex";
import ReactMarkdown from "react-markdown";
import "katex/dist/katex.min.css";
const markdown = `The equation for a line is $y = mx +b$.
The proof is:
$$
\begin{align}
y &= mx + b \\
&= ab + c  
\end{align}
$$
`;
export default function App() {
return (
<ReactMarkdown
remarkPlugins={[remarkMath]}
rehypePlugins={[rehypeKatex]}
children={markdown}
/>
);
}

最新更新