mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36: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
26 lines
591 B
JavaScript
26 lines
591 B
JavaScript
const createCard = require('../create-card');
|
|
|
|
module.exports = createCard({
|
|
name: 'code',
|
|
type: 'dom',
|
|
render(opts) {
|
|
let payload = opts.payload;
|
|
let dom = opts.env.dom;
|
|
|
|
if (!payload.code) {
|
|
return '';
|
|
}
|
|
|
|
let pre = dom.createElement('pre');
|
|
let code = dom.createElement('code');
|
|
|
|
if (payload.language) {
|
|
code.setAttribute('class', `language-${payload.language}`);
|
|
}
|
|
|
|
code.appendChild(dom.createTextNode(payload.code));
|
|
pre.appendChild(code);
|
|
|
|
return pre;
|
|
}
|
|
});
|