Closed DopamineDriven closed 3 years ago
The TypeScript error is correct, with-html
was replaced with rehype in version 6.
You can see this in the changelog https://github.com/remarkjs/react-markdown/blob/main/changelog.md#remove-buggy-html-in-markdown-parser along with an example of how to use rehype.
As for allowing more content than rehype-sanitized
usually allows, there are two options:
rehype-sanitize
with-html.d.ts file restoration or an alternative plugin to replace its functionality indicated in the docs
I use headless-wordpress, nextjs, typescript, apollo client, graphql, etc for most of my client projects. I have been using
react-markdown/with-html
with the gfm parser and React-Syntax-Highlighter renderer to parse incoming dangerouslySetInnerHtml or otherwise for about 10 months now. I updated the react-markdown package from v5.0.3 to v6.0.1 and didn't realize that typescript support forwith-html
had been removed until the linter caught it on a pre-push husky hook.Problem
If the feature requests relates to a problem, please describe the problem you are trying to solve here.
As expected, this was resolved by rolling back to v5.0.3.
Expected behavior
The contents of this file should remain available for those who have projects built out using react-markdown/with-html globally. Expected the contents of this file to be present:
with-html.d.ts
Note: While I use this prop as little as possible since exposing XSS vector sites isn't ideal, it is necessary when parsing the body or content of an external source for example. Other props such as title or image don't require one to dangerously escape innerHtml or not nearly as often.
Alternatives
Publish a solution for those who used the
allowDangerousHtml
prop in your documentation, such as an external albeit compatible html parser to achieve the same level of support thatwith-html
provided.