Is there a way to reliably programmatically escape/ignore html in mdx? #1477
-
My situation is as follows: What I want to do is to assemble a set of blocks into a pages rendered by MDX. Which works well most of the time, but things fail parsing (and the build) when there is malformed html present in the source. My question is - is there a reliable programmatic way to escape html within mdx so it will get parsed as a plain text. Or configure parser to ignore html elements in particular contexts somehow (by wrapping them in special element or something like that)? https://maxschmitt.me/posts/escape-html-mdx/ is the only thing I found on the topic and it doesn't really provide a solution that works in all contexts (inline, multiline, and not disfiguring code inside code-fences) Context: Building a static site with |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 20 replies
-
HTML and JSX are incompatible, There are a few options:
|
Beta Was this translation helpful? Give feedback.
-
@Stvad Have you solved this problem, please? Do you have any solutions? |
Beta Was this translation helpful? Give feedback.
HTML and JSX are incompatible,
mdx
parses JSX.There are a few options:
mdx
builds onremark
,mdx
replacesremark
's HTML parser with a JSX parser)