Ember addon that uses markdown-it to parse markdown language to html.
ember install ember-cli-markdown-it
{{markdown-html text options plugins}}
Where
- text - string to be parsed by markdown-it
- options - object to pass to markdown-it
- plugins - list of plugins
See the options and how they work in their project here
Example of a component using ember-highlightjs-shim
to highlight some code syntax
import Ember from 'ember';
import hljs from highlight;
export default Ember.Component.extend({
markdownOptions: {
// options to include highlight.js
highlight: function (str, lang) {
let codeValue;
if (lang && hljs.getLanguage(lang)) {
codeValue = hljs.highlight(lang, str, true).value;
} else {
codeValue = hljs.highlightAuto(str).value;
}
return `<pre><code class="hljs ${lang}">${codeValue}</code></pre>`;
}
}
});
and then
{{markdown-html "my content" options=markdownOptions}}
import Ember from 'ember';
import MarkdownItAttrs from "npm:markdown-it-attrs";
import MarkdownItEmoji from "npm:markdown-it-emoji";
export default Ember.Component.extend({
markdownPlugins: [
MarkdownItAttrs,
MarkdownItEmoji
]
});
// {{markdown-html "my content" plugins=markdownPlugins}}
If you have any question or suggestion, please open an issue.
git clone https://github.com/rennomarcus/ember-cli-markdown-it.git
ember s
ember test
orember s
and go to /tests