Log in to post a comment.
Published on 10/26/20 at 8:05 PM. Updated on 10/31/20 at 4:55 PM.
A Symfony bundle for an easy league/commonmark integration.
Published on 10/26/20 at 8:05 PM. Updated on 10/31/20 at 4:55 PM.
A Symfony bundle for an easy league/commonmark integration.
I recently published a Symfony bundle (my first one), so I'm presenting it to you today.
If you just want to see the code: AymDev/CommonMarkBundle.
I write a lot of MarkDown content on my website: courses and blog posts. It's convenient, and I may not be the only one to think so as it's used on GitHub, StackOverflow, ...
Until now I was using ParseDown (which is great and easy to use), but I wanted to make something specific: make external links open in a new tab.
While searching, I stumbled upon an extension: taufik-nurrohman/parsedown-extra-plugin.
But this library isn't available on Packagist and does not respect semantic versioning. I finally started to look for ParseDown alternatives.
I quickly found PHP League's library: CommonMark. It's easy to use too, but it provides extensions including one about external links !
I made my choice. But then, how to integrate it within Symfony ?
As of the library's basic usage, I thought I could add manual service configuration to my services.yaml. But with the multipleextensions and the different configurations I could do, I thought that a bundle would make things easier.
The issue: there's no official bundle, and those I found were using league/commonmark in v0.x, or weren't available on Packagist, or didn't allow for multiple "converters".
Conclusion: build my own bundle.
I never built a bundle before. I read Symfony's documentation about it, began coding, to end up crying during the bundle's configuration class.
I then took a course on how the service container works, how it is compiled in cache, the bundle extensions, compiler pass, ...
And I finally came to the end despite some errors !
Here's AymDev/CommonMarkBundle !
You will find the complete documentation in the README. It solves what I did not find elsewhere:
aymdev/commonmark-bundle
league/commonmark
in v1.5 minimumIf you read until there, know that this post has been converted by a converter configured by the bundle, another one is converting the comments.
It is still important to mention the tools I use to render my content:
Give me a feedback if you try the bundle !
Log in to post a comment.
K4gur0
16/01/2021 - 02:58
Félicitation Aymeric pour ton first bundle ! Ça me donne envi de m'y lancer, un de ces 4 je publierais les miens aussi :p
Ça mérite une étoile en plus sur ton Repo Github
Good job :)
bogdanradoi
04/11/2020 - 10:37
Hello Aymeric, ça à l'air TOP
ton bundle Markdown. Je vais le tester. :)