GithubHelp home page GithubHelp logo

Comments (7)

colinodell avatar colinodell commented on May 23, 2024

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.

dshafik avatar dshafik commented on May 23, 2024

I've implemented this almost identically (by accident) in #44, see:

from commonmark.

colinodell avatar colinodell commented on May 23, 2024

Nice! I really like how that looks.

Do you think we should call them Extensions instead and allow multiple to be registered? This would make it easier to mix and match different classes from different pacakges.

from commonmark.

colinodell avatar colinodell commented on May 23, 2024

If that doesn't make much sense then I'm fine with your approach @dshafik

from commonmark.

dshafik avatar dshafik commented on May 23, 2024

@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.

dshafik avatar dshafik commented on May 23, 2024

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.

colinodell avatar colinodell commented on May 23, 2024

Yeah, I think there's going to be 3 types of users and use cases:

  1. User wants the default CommonMark stuff
  2. User wants to use a different predefined set of parsers/renderers
  3. 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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.