This commit is contained in:
Erin 2025-09-04 18:29:32 -04:00
parent b25a111a1e
commit 855c1571f9
Signed by: erin
SSH key fingerprint: SHA256:clvLPaxKthBet+VUQTKQdDkjaqg2/KnYHQaPASp5pFE

19
temp.js Normal file
View file

@ -0,0 +1,19 @@
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 <br> or <br /> etc
.replace(/(?<!<br\s*\/?>)\n/g, '<br>\n')
// spans that set color via inline style instead of using {{colorize}}
.replace(/<span style="color: #00cc22;">([^<]+)<\/span>/g, '`$1`')
.replace(/<span style="color: #ffff66;">([^<]+)<\/span>/g, '``$1``')
return pageContent.replace(flavorTextRegexp, flavorTextReplacement(newFlavorText));
}
const pages = //...