How to get the original text of <pre>? I want to use it for copy function. #1302
-
const Pre = ({ children }) => {
return (
<div className="highlight">
<pre>{children}</pre>
<CopyCodeContainer children={children} />
</div>
);
};
<Markdown
remarkPlugins={[remarkGfm]}
rehypePlugins={[rehypeHighlight]}
skipHtml={true} // 禁止 react-markdown 将 HTML 标签包裹在 <p> 元素内部
components={{ pre: Pre }}
>
{markdown}
</Markdown> "Above is a part of my code. I hope to directly pass the original code string to CopyCodeContainer, instead of a JavaScript object." |
Beta Was this translation helpful? Give feedback.
Answered by
ChristianMurphy
Mar 25, 2024
Replies: 2 comments 3 replies
-
We don’t have any chinese speakers in our team. Please use English. |
Beta Was this translation helpful? Give feedback.
0 replies
-
欢迎来到 Unified JS 社区 @caihai123! 👋 On your question of how to access the raw text of a |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'd recommend looking at the solutions in https://github.com/orgs/mdx-js/discussions/1948 which should work here as well.