I have problem on my markdown site using Next and react-markdown. I want to add some script like a embed tag of Github gist, but all the characters escaped. Is there any solution to unescape characters inside script tag?
I add rehypePlugins={[rehypeRaw]}
to the so the HTML enabled:
// pages/post/[id].tsx
...
<ReactMarkdown components={components} rehypePlugins={[rehypeRaw]}>
{markdownBody}
</ReactMarkdown>
...
I tried:
// posts/somemarkdwon.md
## H1 title here
normal text here
<p>hi<br />hi</span></p>
<script>const hi = "3"; alert(hi);</script>
Output:
<h2>H1 title here</h2>
<p>normal text here</p>
<p>hi<br/>hi</p>
<script>const hi = "3"; alert(hi);</script>
"3" converted to "3"
and the script got error.
Does anyone has good solution?
0 Replies