Don’t pass `processor` as argument to `attacher`s
wooorm opened this issue · 1 comments
wooorm commented
Attachers should be invoked with the processor as the context object, instead of a parameter.
Often, attachers don’t even need to interact with the processor, so it makes no sense to pass it first.
Removing it from the arguments makes it easier to use attachers to without unified, such as in the following code:
var toc = require('remark-toc')();
var tree = {type: 'root', children: [/* … */]};
console.log(toc(tree));
wooorm commented
Here’s an example which this change would make much prettier: https://github.com/wooorm/rehype-format/blob/7715bf1f6f6d56025bd8fe260ea599d6954e75dd/index.js#L4