0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-03 04:02:44 +00:00

Add to migrate document and update colon-replacement for the markdown renderer

This commit is contained in:
Charlie Humphreys
2021-12-10 20:25:31 -06:00
parent b817148d1c
commit f1c4910993
2 changed files with 22 additions and 10 deletions

View File

@@ -535,7 +535,24 @@ module.exports = {
marked : Markdown,
render : (rawBrewText)=>{
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, _, i)=>{
let test, matches=[];
const codeBlock = /`/gm, inlineCodeBlock = /[^`]`[^`]/g;
while (test = codeBlock.exec(rawBrewText)) {
matches.push(test);
}
// console.log(match, m, i, indexes);
if(matches.filter((m)=>m.index < i).length % 2 !== 0) return match;
// matches = [];
// while (test = inlineCodeBlock.exec(rawBrewText)) {
// matches.push(test);
// }
// console.log(matches, match, i);
// if(matches.filter((m)=>m.index < i).length % 2 !== 0) return match;
return `${`<div class='blank'></div>`.repeat(match.length)}\n`;
});
return Markdown(
sanatizeScriptTags(rawBrewText),
{ renderer: renderer }