I use react-markdown to build the virtual dom which allows for updating only the changing DOM instead of completely overwriting. It generate the content in
tag. I want to add tag inside
tag.
<ReactMarkdown
components={
{
code({ node, inline, className, children, ...props }) {
const match = /language-(\w+)/.exec(className || '');
return !inline && match ? (
<SyntaxHighlighter
{...props}
style={a11yDark}
language={match[1]}
PreTag="div"
>
{String(children).replace(/\n$/, '')}
</SyntaxHighlighter>
) : (
<code {...props} className={className}>
{children}
</code>
);
},
}}
>
{content}
</ReactMarkdown>
May be using a custom render function for the paragraph node type.I don't exact thing but may be this will help.