ffxiv-wiki-scripts/temp.js
2025-09-04 18:29:32 -04:00

19 lines
748 B
JavaScript

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 = //...