2017-03-14 21:07:33 +03:00
|
|
|
module.exports = {
|
2018-02-01 14:40:49 +03:00
|
|
|
name: 'markdown',
|
2017-11-01 16:44:54 +03:00
|
|
|
type: 'dom',
|
|
|
|
render: function (opts) {
|
2017-12-14 14:09:54 +03:00
|
|
|
var converters = require('../converters'),
|
2017-11-01 16:44:54 +03:00
|
|
|
html, element;
|
2017-05-23 17:15:32 +03:00
|
|
|
|
2017-11-01 16:44:54 +03:00
|
|
|
// convert markdown to HTML ready for insertion into dom
|
|
|
|
html = '<div class="kg-card-markdown">'
|
2017-12-14 14:09:54 +03:00
|
|
|
+ converters.markdownConverter.render(opts.payload.markdown || '')
|
2017-11-01 16:44:54 +03:00
|
|
|
+ '</div>';
|
2017-05-23 17:15:32 +03:00
|
|
|
|
2017-11-01 16:44:54 +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-11-01 16:44:54 +03:00
|
|
|
return element;
|
|
|
|
}
|
|
|
|
};
|