Comments (7)
Or, instead of an interface
, perhaps we do an abstract
class so you can override just the methods you need? I think that's what Twig does.
from commonmark.
I've implemented this almost identically (by accident) in #44, see:
EnvironmentInterface
: https://github.com/thephpleague/commonmark/pull/44/files#diff-4Environment::createEnvironment
: https://github.com/thephpleague/commonmark/pull/44/files#diff-2604a7b7168c0a191cd22408d907dd44L218
from commonmark.
Nice! I really like how that looks.
Do you think we should call them Extension
s instead and allow multiple to be registered? This would make it easier to mix and match different classes from different pacakges.
from commonmark.
If that doesn't make much sense then I'm fine with your approach @dshafik
from commonmark.
@colinodell on the surface, I like the idea of multiple, however there are some order of operations that matter when it comes to processing the markdown (see here) which would make it very difficult without having some sort of conflict resolution or complex ordering mechanisms (e.g. insteadOf(), insertBefore(), insertAfter() type thing)
from commonmark.
Just for the record, I think the correct way to do this for the end-user is to create their own Environment composed of whatever elements/parsers/renderers they want.
from commonmark.
Yeah, I think there's going to be 3 types of users and use cases:
- User wants the default CommonMark stuff
- User wants to use a different predefined set of parsers/renderers
- User wants full control of everything
For that first group, Environment::createCommonMarkEnvironment()
should be sufficient.
The new $environment->addExtension(...)
method caters to the second group as basically uses the same approach you suggested.
And lastly, I've left the addXXParser and addXXRenderer methods intact for people who want to truly customize the environment to fit their needs.
All three methods use the same underlying principle of composing the environment with whatever bits you need.
from commonmark.
Related Issues (20)
- Last backslash before a heading/table gets preserved HOT 1
- Delimeter processor doesn't run in links and images HOT 3
- Delimiter processor cannot have a space right after opener and/or before closer HOT 1
- Weird interaction of code block with other block parsers HOT 1
- [Feature Request] Symfony Bundle HOT 2
- Invalid multibyte support HOT 1
- "League\Config\ConfigurationProviderInterface" not found HOT 3
- Support Chinese Character in $slug HOT 4
- Table centering is producing `align="center"` instead of `style="text-align: center"` HOT 3
- Promote 'delim' to property
- Possible bug report with HTML and MD HOT 1
- BlockQuote is not rendering correct in GithubFlavoredMarkdownExtension HOT 3
- Simplify custom renderers
- Weird glitch with Footnote Extension HOT 3
- Code blocks sometimes don't render first character HOT 1
- Question: Disable some elements HOT 1
- Allow setting attributes without values in Attributes extension HOT 1
- Heading levels HOT 3
- Algolia Search Not Giving Any Results HOT 1
- LinkRenderer always adding `rel="noopener noreferrer"` when opening in new window HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from commonmark.