mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-03 23:00:14 -05:00
no issue We're creating tooling to convert HTML to Ghost flavoured mobiledoc, however we have cards that allow arbitrary content without a wrapper element which means that we're unable to do a 1:1 mapping of mobiledoc->html->mobiledoc. To work around this problem we now output HTML comments before/after the output of each card so that our converter can extract card content correctly when parsing HTML. - added `createCard` method which wraps a card's `render()` method to add begin/end comments and updated all cards to use it - only takes affect for newly added or re-saved posts/pages
28 lines
934 B
JavaScript
28 lines
934 B
JavaScript
const createCard = require('../create-card');
|
|
|
|
module.exports = createCard({
|
|
name: 'markdown',
|
|
type: 'dom',
|
|
render: function (opts) {
|
|
let converters = require('../converters');
|
|
let payload = opts.payload;
|
|
let version = opts.options && opts.options.version || 2;
|
|
// convert markdown to HTML ready for insertion into dom
|
|
let html = converters.markdownConverter.render(payload.markdown || '');
|
|
|
|
if (!html) {
|
|
return '';
|
|
}
|
|
|
|
/**
|
|
* @deprecated Ghost 1.0's markdown-only renderer wrapped cards. Remove in Ghost 3.0
|
|
*/
|
|
if (version === 1) {
|
|
html = `<div class="kg-card-markdown">${html}</div>`;
|
|
}
|
|
|
|
// use the SimpleDOM document to create a raw HTML section.
|
|
// avoids parsing/rendering of potentially broken or unsupported HTML
|
|
return opts.env.dom.createRawHTMLSection(html);
|
|
}
|
|
});
|