Would love to see the markdown parser become more extensible. Seems like this would just be a matter of adding an "alias class" on top of ParsedownExtra. Then we could use the service container to bind / alias a class which extends the markdown parser. Perhaps it could be called MarkdownParser and live in the statamic namespaces? This class would extend ParsedownExtra (which has no namespace).
This would allow for v3 users and addon developers to easily build markdown extensions. For example, let's say you wanted to have a special content block for hot tips. 馃敟 The markdown would look like this:
:::tip
Some amazing tip text
:::
Currently ParsedownExtra is used in the Markdown fieldtype and in the Statamic\Support\Html class.
I just tried to use the service container to bind my own implementation of ParsedownExtra.... but this becomes problematic because that (vendor) class has no namespace. So once you overwrite the root namespace entry for it, you can't extend the base class.
If this sounds like an acceptable FR, I'd be happy to make a PR to the proper v3 repository.
Thank you!
I've been wanting to do this. Good idea.
Actually, I've just noticed that Laravel now requires league/commonmark instead of Parsedown.
See https://github.com/laravel/framework/pull/30982 and https://github.com/laravel/framework/pull/30973
The league/commonmark library allows custom extensions to be created.
https://commonmark.thephpleague.com/1.0/customization/overview/
I think I would want to change to commonmark, and then allow developers to add extensions, which would be used by Statamic\Support\Html::markdown()
If we switch to commonmark, need to make sure these work:
Most helpful comment
Actually, I've just noticed that Laravel now requires league/commonmark instead of Parsedown.
See https://github.com/laravel/framework/pull/30982 and https://github.com/laravel/framework/pull/30973
The league/commonmark library allows custom extensions to be created.
https://commonmark.thephpleague.com/1.0/customization/overview/
I think I would want to change to commonmark, and then allow developers to add extensions, which would be used by
Statamic\Support\Html::markdown()