mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-03 23:00:14 -05:00
refs https://github.com/TryGhost/Ghost/issues/9505 - updates mobiledoc converter's `render` method to accept a `version` argument - `1` === Ghost 1.0's markdown-only renderer output - `2` === Koenig's full mobiledoc renderer output - switch between mobiledoc renderer versions in Post model's `onSaving` hook - version 1 by default - version 2 if Koenig is enabled (currently behind dev experiments config + labs flag) - version 2 if the post's mobiledoc is not compatible with the markdown-only renderer - "version 2" full-Koenig mobiledoc renderer output - wraps content in a `.kg-post` div - removes wrapper around markdown and html card output - adds classes to image card output including selected image size/style - standardises es6 usage across mobiledoc related files
22 lines
757 B
JavaScript
22 lines
757 B
JavaScript
'use strict';
|
|
|
|
module.exports = {
|
|
name: 'markdown',
|
|
type: 'dom',
|
|
render: function (opts) {
|
|
let converters = require('../converters');
|
|
let payload = opts.payload;
|
|
let version = opts.options.version;
|
|
// convert markdown to HTML ready for insertion into dom
|
|
let html = converters.markdownConverter.render(payload.markdown || '');
|
|
|
|
// Ghost 1.0's markdown-only renderer wrapped cards
|
|
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);
|
|
}
|
|
};
|