quantizor / markdown-to-jsx

🏭 The most lightweight, customizable React markdown component.
https://markdown-to-jsx.quantizor.dev/
MIT License
1.96k stars 169 forks source link

Editing overrides in nested markdown #593

Open SKOLZ opened 2 months ago

SKOLZ commented 2 months ago

Hello! I have defined some overrides to used for some markdown but I want to define in one of those overrides an override to the overrides. Something like:

<Markdown
    children={source}
    overrides={{
        h1: ({children}) => (<h2>{children}</h2>),
        CustomComponent: ({children}) => (
            <Markdown
                children={children}
                overrides={{
                    h1: ({children}) => (<h3>{children}</h3>)
                }}
            />
        )
    }}
/>

this doesn't work because the children my overrides component function receives is no longer a string. After searching a bunch and not being able to find a solution I was wondering, Is there any way to achieve this? maybe a "decompile" function to revert the children object back to markdown or something along those lines? Thank you for the help!