Giter Club home page Giter Club logo

Comments (6)

ChristianMurphy avatar ChristianMurphy commented on August 21, 2024 1

It sounds like you want to make a preset?
If so https://github.com/wooorm/remark-preset-wooorm gives an example of how that can look

from unified.

wooorm avatar wooorm commented on August 21, 2024

Yeah, this is intentional. First the plugins are added to a list, and not called yet. Only when they are needed, they are called, at which point your anonymous plugin adds plugin1 also to the list.

from unified.

siefkenj avatar siefkenj commented on August 21, 2024

I see. So what is the proper way for a plugin to push many transformers onto the stack?

from unified.

wooorm avatar wooorm commented on August 21, 2024
function myPlugin()
  return function manyTransforms(tree, file) {
    transformOne(tree, file)
    transformTwo(tree, file)
  }
}

from unified.

siefkenj avatar siefkenj commented on August 21, 2024

To use your example above, transformOne is the actual transform function and not the plugin, right? So to do with plugins, I would do

function myPlugin(){
   return (tree, file) => {
      plugin1()(tree, file)
      plugin2()(tree, file)
   }
}

?

And if the transform returned a new tree instead of mutating the existing tree, I assume that would need to be manually accounted for?

from unified.

wooorm avatar wooorm commented on August 21, 2024

If you have multiple transforms, do what I did, not what you do.
If you have multiple plugins, use a preset as Christian points out, not what you do.

If transforms return things, you have to handle that.

This all seems like an XY problem. You are asking about a solution and not about your problem. Perhaps you can formulate your question in more words.

from unified.

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.