2017-03-14 21:07:33 +03:00
|
|
|
module.exports = {
|
2017-03-24 13:03:33 +03:00
|
|
|
name: 'card-markdown',
|
2017-03-14 21:07:33 +03:00
|
|
|
type: 'dom',
|
2017-05-23 17:15:32 +03:00
|
|
|
render: function (opts) {
|
2017-08-31 13:09:02 +03:00
|
|
|
var markdownConverter = require('../../../utils/markdown-converter'),
|
|
|
|
html, element;
|
2017-05-23 17:15:32 +03:00
|
|
|
|
2017-08-31 13:09:02 +03:00
|
|
|
// convert markdown to HTML ready for insertion into dom
|
|
|
|
html = '<div class="kg-card-markdown">'
|
|
|
|
+ markdownConverter.render(opts.payload.markdown || '')
|
|
|
|
+ '</div>';
|
2017-05-23 17:15:32 +03:00
|
|
|
|
2017-08-31 13:09:02 +03:00
|
|
|
// use the SimpleDOM document to create a raw HTML section.
|
|
|
|
// avoids parsing/rendering of potentially broken or unsupported HTML
|
|
|
|
element = opts.env.dom.createRawHTMLSection(html);
|
2017-05-23 17:15:32 +03:00
|
|
|
|
2017-08-31 13:09:02 +03:00
|
|
|
return element;
|
2017-03-14 21:07:33 +03:00
|
|
|
}
|
|
|
|
};
|