Change behavior of "__" #1182
-
Hey, When you use Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
I don't think react markdown supports underlining using markdown. Here's a workaround you could use: import ReactMarkdown from "react-markdown";
import rehypeRaw from "rehype-raw";
const content = "this is an __underlined__ text";
function parseUnderline(content) {
return content.replace(/__(.*?)__/g, "<u>$1</u>");
}
export default function App() {
return (
<ReactMarkdown rehypePlugins={[rehypeRaw]}>
{parseUnderline(content)}
</ReactMarkdown>
);
} This makes use of the |
Beta Was this translation helpful? Give feedback.
-
Pass In markdown, there is a slight difference in how |
Beta Was this translation helpful? Give feedback.
I don't think react markdown supports underlining using markdown. Here's a workaround you could use:
This makes use of the
rehype-raw
plugin which allows HTML as input.The
parseUnderline
function will convert all the "__" to "u" HTML tags