Ghost/core/server/apps/default-cards/cards/markdown.js
Kevin Ansfield 47322e4239 Re-instate mobiledoc dom rendering with bypass of SimpleDOM parsing (#8937)
closes #8757

- update the markdown card render method to use SimpleDOM's `createRawHtmlSection`. This avoids SimpleDOM parsing and tokenization of broken or unsupported free-form HTML that markdown allows
- replace markdown extraction/render with mobiledoc's renderer in the `Post` model
- removes `jsdom` as it's no longer necessary
2017-08-31 12:09:02 +02:00

20 lines
704 B
JavaScript

module.exports = {
name: 'card-markdown',
type: 'dom',
render: function (opts) {
var markdownConverter = require('../../../utils/markdown-converter'),
html, element;
// convert markdown to HTML ready for insertion into dom
html = '<div class="kg-card-markdown">'
+ markdownConverter.render(opts.payload.markdown || '')
+ '</div>';
// 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);
return element;
}
};