erusev / parsedown

Better Markdown Parser in PHP
https://parsedown.org
MIT License
14.76k stars 1.12k forks source link

Custom markup #788

Open grumpygamer opened 4 years ago

grumpygamer commented 4 years ago

I have some custom replacements I want to do, but they can't happen in pre or code blocks. I can't do the replacements after the markdown has been done because it will replace them in code and pre blocks.

I assume this is a job for extensions, but I can't figure out how. Any advice?

taufik-nurrohman commented 4 years ago

I can't do the replacements after the markdown has been done because it will replace them in code and pre blocks.

You can do this way → https://stackoverflow.com/a/63653055/1163000

Make sure to extend the regex pattern to exclude code elements too:

'/(<code(?:\s[^>]*)?>[\s\S]*?<\/code>|<[^>]+>)/'