Make it possible to add extension from the CommonMarkConverter class #1052
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In my use-case, the application is using CommonMark in a non-usual way, and I just need to add extensions to it and append configuration to the Environment (it's in a Symfony context).
However, considering the current architecture, there are only two possibilities for the package in Symfony DI's setup:
LeagueCommonMarkConverterFactoryfrom TwigExtraBundle. You can add extensions (they're injected in the constructor, and services can just be tagged, but you cannot add any configuration to thearray $configconstructor parameter.Definitionwith any DI way (I'm using Yaml, but all other formats are concerned). This allows adding custom configuration to the constructor. But to add extensions, you have to call$converter->getEnvironment()->addExtension(), which is not possible with Symfony's DI.For now, there is no way to do it, either from TwigExtra or from CommonMark itself.
I will also make a PR on TwigExtra to allow better customization of the factory itself, for more flexibility