From 184f182b3a390afeee284d149513c88fe8e0872c Mon Sep 17 00:00:00 2001 From: David Bolack Date: Sun, 18 Aug 2024 21:52:29 -0500 Subject: [PATCH] Short term fix for the colons in codeblocks issue. --- shared/naturalcrit/markdown.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/shared/naturalcrit/markdown.js b/shared/naturalcrit/markdown.js index 9388e912a..894c084b6 100644 --- a/shared/naturalcrit/markdown.js +++ b/shared/naturalcrit/markdown.js @@ -69,6 +69,20 @@ renderer.html = function (html) { return html; }; +renderer.code = function(code, infostring, escaped) { + const lang = (infostring || '').match(/^\S*/)?.[0]; + + code = code.replace(/
<\/div>/gm, (match)=>`${`:`}`); + + code = `${code.replace(/\n$/, '')}\n`; + + if(!lang) { + return `
${escaped ? code : escape(code, true)}
\n`; + } + + return `
${escaped ? code : escape(code, true)}
\n`; +}; + // Don't wrap {{ Spans alone on a line, or {{ Divs in

tags renderer.paragraph = function(text){ let match; @@ -834,7 +848,7 @@ module.exports = { globalPageNumber = pageNumber; rawBrewText = rawBrewText.replace(/^\\column$/gm, `\n

\n`) - .replace(/^(:+)$/gm, (match)=>`${`
`.repeat(match.length)}\n`); + .replace(/^(:+)$/gm, (match)=>`${`
`.repeat(match.length)}\n`); const opts = Marked.defaults; rawBrewText = opts.hooks.preprocess(rawBrewText);