Clean Anilist HTML

This commit is contained in:
Daniel Odendahl Jr
2019-02-16 02:41:44 +00:00
parent 940614e57f
commit c7aaf4b5ce
4 changed files with 18 additions and 8 deletions
+12
View File
@@ -116,4 +116,16 @@ module.exports = class Util {
if (no.includes(choice)) return false;
return false;
}
static cleanAnilistHTML(html) {
let clean = html
.replace(/(<br>)+/g, '\n')
.replace(/&#039;/g, '\'')
.replace(/&quot;/g, '"')
.replace(/<\/?i>/g, '*')
.replace(/~!|!~/g, '||');
const spoilers = (clean.substr(0, 1997).match(/\|\|/g) || []).length;
if (spoilers !== 0 && (spoilers && (spoilers % 2))) clean += '||';
return clean;
}
};