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

Possible to get the HTML output instead of it being rendered? #536

Closed
ahmetskilinc opened this issue Jan 21, 2021 · 2 comments
Closed

Possible to get the HTML output instead of it being rendered? #536

ahmetskilinc opened this issue Jan 21, 2021 · 2 comments
Labels
🙋 no/question This does not need any changes

Comments

@ahmetskilinc
Copy link

I'm not sure if this has been posted.

I want to be able to get the RAW html that is output so I can maybe copy it and use it elsewhere. Say for instance a Markdown editor, where a user can write markdown, and it is output to the page by react-markdown. Is it possible to get the HTML instead of going to inspect element?

@ahmetskilinc ahmetskilinc added 🙉 open/needs-info This needs some more info 🦋 type/enhancement This is great to have labels Jan 21, 2021
@ChristianMurphy
Copy link
Member

ChristianMurphy commented Jan 22, 2021

Short answer:
Is possible to get HTML from unified/micromark? yes (these are the underlying libraries for react-markdown and are maintained by the same team)
Will react-markdown specifically support it? probably not the library is designed specifically to generate React components.


Context:

Micromark is the underlying markdown parser used in react-markdown, it can be used directly to take markdown to HTML.
Remark and Rehype builds on Micromark, allowing content to be transformed with Plugins along the way.
react-markdown builds on remark (and soon rehype) to output React components specifically.

Generating HTML is a non-goal for react-markdown specifically, because it, as the name implies, targets React.
However other libraries (micromark, remark, and rehype) in the same organization, with the same maintainers, are designed to do what you are looking for and go from markdown to HTML.


Examples of how to use Micromark and Remark+Rehype to transform Markdown to HTML:
Micromark: https://codesandbox.io/s/micromark-debug-y9vz3
Remark-rehype: https://codesandbox.io/s/remark-rehype-debug-4cz8v

@ChristianMurphy ChristianMurphy added 🙋 no/question This does not need any changes and removed 🙉 open/needs-info This needs some more info 🦋 type/enhancement This is great to have labels Jan 22, 2021
@ahmetskilinc
Copy link
Author

@ChristianMurphy Okay. Thank you. I managed to do exactly what I wanted to do using Micromark!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🙋 no/question This does not need any changes
Development

No branches or pull requests

2 participants