Antoine Trouve
Antoine Trouve

Reputation: 1273

Whitelist HTML tags for ReactMarkdown

I have been happily using ReactMarkdown and I was wondering what is the easiest way to passthrough a whitelisted selection of HTML tags.

Let's use the kbd element for now as an example. I have this markdown:

Please press key <kbd>CTRL</kbd>

For obvious safety reasons, ReactMarkdown escapes <kbd> and </kbd> and it does not render as kbd HTML elements.

I know I can use the plugin rehype-raw, but is very large and I don't need to support the whole HTML: I would be happy with a compact yet brittle regexp-based implementation.

My understanding is that I have two options:

In concrete terms, my questions are:

Upvotes: 2

Views: 289

Answers (0)

Related Questions