const flavorTextRegexp = /\| flavor-text = ([\s\S]+?)\n\|/;
const flavorTextReplacement = newFlavorText => `| flavor-text = ${newFlavorText}\n|`
function fixPageContent (pageContent) {
let match = pageContent.match(flavorTextRegexp);
if (!match) return pageContent;
let flavorText = match[1];
let newFlavorText = flavorText
// linebreaks with no preceding
or
etc
.replace(/(?)\n/g, '
\n')
// spans that set color via inline style instead of using {{colorize}}
.replace(/([^<]+)<\/span>/g, '`$1`')
.replace(/([^<]+)<\/span>/g, '``$1``')
return pageContent.replace(flavorTextRegexp, flavorTextReplacement(newFlavorText));
}
const pages = //...