empress / ember-cli-showdown

Ember component to render markdown into HTML.
https://empress.github.io/ember-cli-showdown/
MIT License
101 stars 35 forks source link

showdown-highlight #62

Closed RobbieTheWagner closed 6 years ago

RobbieTheWagner commented 6 years ago

Hi, thanks for the addon!

I see I can write my own extensions, but how can I use this one? https://github.com/Bloggify/showdown-highlight

jasonmit commented 6 years ago

So long as you're import/bundle the extension within your app, it would look something like below. This plugin exports a function, which is the extension function. https://github.com/Bloggify/showdown-highlight/blob/master/lib/index.js#L8

import showdownHightlight from 'showdown-highlight'; 
import showdown from 'showdown';

/**
  * Somewhere in your app code before the component is rendered.
  * perhaps an initializer or route hook?
  */

showdown.extension("showdownHighlight", showdownHightlight);
{{markdown-to-html
  markdown=postContent
  extensions='showdownHighlight'}}

Worth noting, this package doesn't actually ship an AMD module with its deps rolled up (highlight.js and html-encoder-decoder). Unsure how you want to handle rolling up these dependencies as well, perhaps use something like ember-browserify or contribute back to showdown-highlight.

RobbieTheWagner commented 6 years ago

@jasonmit I've been trying all day to get this working. All the various ember rollup solutions do not work, and there seems to be no way to do this. If you know of a way that works, that would be great!

jasonmit commented 6 years ago

@rwwagner90 okay I have an idea that I'll kick the tires on. I'll publish an addon called ember-showdown-highlight and make you the co-owner if you want to carry the torch forward afterwards.

RobbieTheWagner commented 6 years ago

@jasonmit I already published an addon to try to do it with https://github.com/shipshapecode/ember-showdown-highlight I just added you as a collaborator.

aalimovs commented 6 years ago

Anyone else stumbling on this, @rwwagner90's addon works great along with the @jasonmit's initializer above.

Just don't forget to add the highlight.js's css.

edit: except this https://github.com/Bloggify/showdown-highlight/issues/11