0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-29 13:22:40 +00:00

Short term fix for the colons in codeblocks issue.

This commit is contained in:
David Bolack
2024-08-18 21:52:29 -05:00
parent 31fcf28e3f
commit 184f182b3a

View File

@@ -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 class='blank'><\/div>/gm, (match)=>`${`:`}`);
code = `${code.replace(/\n$/, '')}\n`;
if(!lang) {
return `<pre><code>${escaped ? code : escape(code, true)}</code></pre>\n`;
}
return `<pre><code class="language-${escape(lang)}">${escaped ? code : escape(code, true)}</code></pre>\n`;
};
// Don't wrap {{ Spans alone on a line, or {{ Divs in <p> tags
renderer.paragraph = function(text){
let match;
@@ -834,7 +848,7 @@ module.exports = {
globalPageNumber = pageNumber;
rawBrewText = rawBrewText.replace(/^\\column$/gm, `\n<div class='columnSplit'></div>\n`)
.replace(/^(:+)$/gm, (match)=>`${`<div class='blank'></div>`.repeat(match.length)}\n`);
.replace(/^(:+)$/gm, (match)=>`${`<div class='blank'></div>`.repeat(match.length)}\n`);
const opts = Marked.defaults;
rawBrewText = opts.hooks.preprocess(rawBrewText);