johno / ember-remarkable

Ember addon for Remarkable markdown parsing helpers and components.
MIT License
26 stars 20 forks source link

Custom remarkable plugins? #7

Closed crunchtime-ali closed 7 years ago

crunchtime-ali commented 9 years ago

I'll need to add some custom plugins to remarkable (to embed videos etc.). Since there's no way to teach linkify that I'll have to pull your source into my application and do it myself.

Would you be interested in adding the possibility in ember-remarkable to add custom plugins?

johno commented 9 years ago

Yeah, absolutely. I've been pondering adding plugin support for a little while, but I wasn't sure if it was functionality that people were looking for. However, it looks like you've encountered a use case/need already!

So its definitely something to put onto the radar. I'm thinking that remarkable plugins can be added as an array in the App options, something like:

var pluginOne = require('plugin-one');
var pluginTwo = require('plugin-two');

var app = EmberApp({
  remarkablePlugins: [pluginOne(), pluginTwo()]
});
crunchtime-ali commented 9 years ago

Yeah having them as App options would suit my use-case really good. People who need different plugins for several places would be out of the picture but that shouldn't be to common either.

One more thing: Writing plugins for Remarkable isn't straight forward. Therefore I use https://github.com/rlidwka/remarkable-regexp. How about integrating that with your plugin-support?

johno commented 9 years ago

Yeah, that's the one concern I had, was when to enable or disable plugins. However I'm not sure how to integrate that. I will ponder it a bit.

I will put the remarkable-regexp on the radar for supporting, too.

johno commented 9 years ago

Ohhhhh, I think I got it. We can pass in all plugins like before, in the App options, but as an array of objects:

var app = EmberApp({
  remarkablePlugins: [{
    name: 'foo',
    plugin: pluginOne()
  }, {
    name: 'bar',
    plugin: pluginTwo()
  }]
});

Then, if you want to change the plugins you can extend the component and ignore/specify plugins:

components/md-bar-text

import MarkdownComponent from 'ember-remarkable/components/md-text';

export default MarkdownComponent.extend({
  usePlugins: ['bar']
});

That way, the above component will only use the bar plugin. How does that sound?

crunchtime-ali commented 9 years ago

That sounds like a great and future-proof solution to me. I'll switch back to using ember-remarkable the minute you implement it <3

johno commented 9 years ago

: )

davidpett commented 8 years ago

@johnotander any progress on this? I just came across the need to add the markdown-toc to be used on ember-fastboot.com. tried to spike it out, but then saw this issue and a path forward.

let me know how i can help

johno commented 8 years ago

Hey @davidpett. I haven't made any progress on this. After specing out how the API might work I was pulled on to other work and this was left by the wayside. I'm going to be pretty bogged down for the next week, but I can schedule some time after that to start taking a whack.

Also, if you have time this next week and want to contribute, I'd be happy to add you as a collaborator/owner and let you get started (I definitely want to see this feature) -- even if it is just a WIP PR. Let me know what your thoughts are, and thanks!

maciek134 commented 7 years ago

I've added a PR with plugin support that worked for me, let me know if it works for you or needs any changes.

johno commented 7 years ago

Closed with #29, thanks @maciek134!