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

Revert HAST to String #31

Closed
4 tasks done
gustavomm19 opened this issue Jan 23, 2024 · 5 comments
Closed
4 tasks done

Revert HAST to String #31

gustavomm19 opened this issue Jan 23, 2024 · 5 comments
Labels
🙋 no/question This does not need any changes 👎 phase/no Post cannot or will not be acted on

Comments

@gustavomm19
Copy link

Initial checklist

Problem

Is there a way to make the convertion optional for some components? I have a custom component in the Markdown Parser from react-markdown and I need it to keep its children always as a string, but if there is html content inside that content, that content gets parsed as nodes. Is there a way to prevent that? I need the plugin to make that convertion in other components but NOT in this one. Here is an example of my code

<ReactMarkdown
        remarkPlugins={[remarkGfm, remarkGemoji, remarkMath]}
        rehypePlugins={[rehypeRaw, rehypeKatex]}
        components={{
          codeviewer: CodeViewerComponent,
        }}
      >
        {preParsedContent}
      </ReactMarkdown>

Solution

Maybe if there were a function to unparse the children of a component

Alternatives

Or a list of components to just receive the children unparsed

@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 Jan 23, 2024
@JounQin
Copy link
Member

JounQin commented Jan 24, 2024

@wooorm
Copy link
Member

wooorm commented Jan 24, 2024

I don’t think you’re working with html. HTML does not have that at all. It looks like you want jsx.

that’s not this project. You are likely looking for MDX

@gustavomm19
Copy link
Author

I solved this problem by using the position indexes of the node that comes as a prop, to extract the parts that I needed from the original content before it is parsed by the markdown parser

@wooorm
Copy link
Member

wooorm commented Jan 24, 2024

I think you’re going in the wrong direction; there might be dragons, but good luck.

@wooorm wooorm closed this as not planned Won't fix, can't repro, duplicate, stale Jan 24, 2024
@wooorm wooorm added the 🙋 no/question This does not need any changes label Jan 24, 2024

This comment has been minimized.

@github-actions github-actions bot added 👎 phase/no Post cannot or will not be acted on and removed 🤞 phase/open Post is being triaged manually labels Jan 24, 2024
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 👎 phase/no Post cannot or will not be acted on
Development

No branches or pull requests

3 participants