-
-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issues running in browser with react-markdown #1
Comments
I didn’t realize this at the moment of writing, but this is another breaking change. I’ll add this to the release notes. Both I recommend to stay on
A fix for this hast just been merged (mermaid-js/mermaid#4350 (comment)). This warning will go away soon. |
@remcohaszing They have merged it. I hope this issue gets fixed soon. |
remarkjs/react-markdown#680 is still open. As for the warning, that has been fixed. You may need to regenerate your lockfile. |
- pin rehype-raw to v6.1.1 while waiting for type updates remarkjs/react-markdown#769 - pin remark-mermaidjs to v4.1.1 according to a similar issue remcohaszing/rehype-mermaid#1
Thanks for all your work with this the mermaid rehype and remark plugins @remcohaszing 🙏 It looks like remarkjs/react-markdown#680 will take a while to resolve. Out of curiosity, do you recommend any other React markdown renderer that works well with rehype-mermaid / remark-mermaid? :) |
You can use unified with rehype-mermaid directly! |
☝️ This. |
Thanks @wooorm & @remcohaszing for the quick reply! I'm still new to the My use case is to render Markdown that gets streamed as a message coming from an LLM which contains Mermaid diagrams, these are then rendered in a React.js application. Going directly from Markdown to Mermaid using // Option 1
<Markdown
remarkPlugins={[remarkMermaid]}
components={{
code: Code,
table: Table,
}}
>
{content}
</Markdown> If I use unified directly, I suppose one would implement it in such a way: // Option 2
const production = {Fragment: prod.Fragment, jsx: prod.jsx, jsxs: prod.jsxs}
const text = `Here is a Mermaid diagram: \`\`\`mermaid
flowchart LR
A[Hard] -->|Text| B(Round)
B --> C{Decision}
C -->|One| D[Result 1]
C -->|Two| E[Result 2]
\`\`\`
`;
function useProcessor(text) {
const [Content, setContent] = useState(createElement(Fragment));
useEffect(
function () {
(async function () {
const file = await unified()
.use(remarkParse)
.use(remarkRehype)
.use(rehypeDocument)
.use(rehypeFormat)
.use(rehypeReact, production)
.process(text);
setContent(file.result);
})();
},
[text]
);
return Content;
} Hence, I'm wondering:
|
It’s better to post such adjacent questions into discussions. You’re missing something. Do not use I’d call the 1st approach less flexible. It abstracts things away. With approach 2, you can do more things. You don’t need How to do “streaming” is not much related to this. It is also often asked already. See for example https://github.com/orgs/remarkjs/discussions/1372#discussioncomment-10784489. |
Based on the warning in the recent release of remark-mermaidjs, I've tried migrating to
rehype-mermaidjs
. I'm having some issues using it as a drop-in replacement for what I had previously.Here is what I'm doing:
This ends up crashing like so at runtime:
I also note that upon installation, I get this warning:
My goal is to be able to use a plugin to render Mermaid blocks in React Markdown. Perhaps this package isn't the best fit? Or maybe I'm missing something.
The text was updated successfully, but these errors were encountered: