With the following code, nothing is rendered as the listItem node is not included in allowedTypes.
const source = `- hello`
<Markdown source={source} allowedTypes={['paragraph', 'emphasis', 'strong']} />
It would be nice to have an option to render any disallowed nodes with its markdown intact (ie. - hello). Using unwrapDisallowed doesn't quite get what I'm after as the markdown code is not included (ie. hello).
What is the HTML output you would expect from this?
Sorry, that may not have been clear. I expect the HTML output to be - hello.
I would really appreciate this behaviour too.
If I disallow nodes, I expect the text to be rendered just as the user typed.
Looks like this would be possible by deleting a tokenizer from the remark parser at runtime: https://github.com/remarkjs/remark/tree/master/packages/remark-parse#turning-off-a-tokenizer
If you want help with this, I could submit a PR.
Always happy to receive contributions!
Here's a proof of concept PR: https://github.com/rexxars/react-markdown/pull/223
@ajbeaven @sibartlett Try using the remark-disable-tokenizers plugin to ignore specific tokens:
import remarkDisableTokenizers from "remark-disable-tokenizers";
<ReactMarkdown
plugins={[
[
remarkDisableTokenizers,
{ block: ["list"] }
]
]}>
{markdownContent}
</ReactMarkdown>
The answer is indeed to use plugins
Most helpful comment
@ajbeaven @sibartlett Try using the
remark-disable-tokenizersplugin to ignore specific tokens: