diff --git a/ghost/admin/lib/koenig-editor/addon/options/parser-plugins.js b/ghost/admin/lib/koenig-editor/addon/options/parser-plugins.js index 54156499d9..d0914cd166 100644 --- a/ghost/admin/lib/koenig-editor/addon/options/parser-plugins.js +++ b/ghost/admin/lib/koenig-editor/addon/options/parser-plugins.js @@ -42,9 +42,25 @@ export function hrToCard(node, builder, {addSection, nodeFinished}) { nodeFinished(); } +export function preCodeToCard(node, builder, {addSection, nodeFinished}) { + if (node.nodeType !== 1 || node.tagName !== 'PRE') { + return; + } + + let [codeElement] = node.children; + + if (codeElement && codeElement.tagName === 'CODE') { + let payload = {code: codeElement.textContent}; + let cardSection = builder.createCardSection('code', payload); + addSection(cardSection); + nodeFinished(); + } +} + export default [ brToSoftBreakAtom, removeLeadingNewline, imgToCard, - hrToCard + hrToCard, + preCodeToCard ];