0

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>

1 Answers1

0

May be using a custom render function for the paragraph node type.I don't exact thing but may be this will help.

import React from 'react';
import ReactMarkdown from 'react-markdown';

const renderers = {
  paragraph: ({ node, ...props }) => {
    return <p {...props}><span>Your additional content here</span>{node.children}</p>;
  },
  // Use your custom renderers as needed
};

const content = 'Your markdown content here';

const App = () => {
  return (
    <ReactMarkdown renderers={renderers}>
      {content}
    </ReactMarkdown>
  );
};

export default App;
Abhishek K V
  • 49
  • 2
  • 8