Skip to content
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

ReactMarkdown fails when using in combination with rehype-raw #696

Closed
4 tasks done
ConstantinChirila opened this issue Jun 30, 2022 · 5 comments
Closed
4 tasks done
Labels
🙅 no/wontfix This is not (enough of) an issue for this project 👎 phase/no Post cannot or will not be acted on

Comments

@ConstantinChirila
Copy link

ConstantinChirila commented Jun 30, 2022

Initial checklist

Affected packages and versions

react-markdown: 8.0.3, rehype-raw: 6.1.1

Link to runnable example

https://codesandbox.io/s/upbeat-field-uj0lid?file=/src/App.js

Steps to reproduce

I've been trying to make markdown render MDX html and jsx tags using rehype-raw and i get the following error:
Cannot compile 'html' node.
Basically i followed the example laid out in the documentation:

Here is a simple example:

import ReactMarkdown from "react-markdown";
import rehypeRaw from "rehype-raw";

export default function App() {
  return (
    <div>
      <ReactMarkdown children={`<p>test</p`} remarkPlugins={[rehypeRaw]} />
    </div>
  );
}

Link to CodeSandbox example

I've also asked a question on Stack overflow

Expected behavior

I expect it to work as intended and render html tags instead of rendering them as string.

Actual behavior

It throws an error Cannot compile 'html' node.

Runtime

No response

Package manager

No response

OS

No response

Build and bundle tools

No response

@github-actions github-actions bot added 👋 phase/new Post is being triaged automatically 🤞 phase/open Post is being triaged manually and removed 👋 phase/new Post is being triaged automatically labels Jun 30, 2022
@wooorm
Copy link
Member

wooorm commented Jun 30, 2022

It's a rehype plugin. Not a remark plugin. Rehype plugins go in rehypePlugins. Remark plugins go in remarkPlugins

@wooorm wooorm added 🙅 no/wontfix This is not (enough of) an issue for this project 👎 phase/no Post cannot or will not be acted on labels Jun 30, 2022
@wooorm wooorm closed this as not planned Won't fix, can't repro, duplicate, stale Jun 30, 2022
@github-actions github-actions bot removed the 🤞 phase/open Post is being triaged manually label Jun 30, 2022
@github-actions
Copy link

Hi team! Could you describe why this has been marked as wontfix?

Thanks,
— bb

@ConstantinChirila
Copy link
Author

@wooorm Thank you so much! Typical dev mistake haha 😅

@kirs
Copy link

kirs commented Feb 12, 2023

I'm hitting the same issue and I'm very curious if anyone worked around it.

I'm using examples from react-markdown's readme which fails:

import React from 'react'
import ReactDom from 'react-dom'
import ReactMarkdown from 'react-markdown'
import rehypeRaw from 'rehype-raw'

const input = `<div class="note">

Some *emphasis* and <strong>strong</strong>!

</div>`

ReactDom.render(
  <ReactMarkdown rehypePlugins={[rehypeRaw]} children={input} />,
  document.body
)

@ChristianMurphy
Copy link
Member

@kirs sorry you ran into a spot of trouble.
The issue you are seeing is not the same as the one in this tread.
And is unlikely to be an issue in react-markdown, testing in a clean sandbox, the combo is still working.
Here is a sandbox with a runnable example: https://codesandbox.io/s/hardcore-fire-w31fjx?file=/src/app.tsx

I'm going to keep this thread closed, and lock it, as it is already resolved in #696 (comment)

If you'd like help debugging your setup, feel free to open a Q&A thread https://github.com/orgs/remarkjs/discussions/categories/q-a
With relevant details of your setup, build tools, dependency versions, and ideally a sandbox (consider forking the one provided above).
Folks are happy to help.

@remarkjs remarkjs locked as resolved and limited conversation to collaborators Feb 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🙅 no/wontfix This is not (enough of) an issue for this project 👎 phase/no Post cannot or will not be acted on
Development

No branches or pull requests

4 participants