Rewrote quote recolor regex

Found some more issues with quote recoloring, particularly in relation to numbered lists.

Tested this change a bit more thoroughly, including multiple sets of backtick-enclosed quote marks on the same line, all seems to be working properly now.
This commit is contained in:
Halsey1006
2023-04-24 17:50:42 -07:00
committed by GitHub
parent 36607dd3fe
commit d6801975a0

View File

@ -878,14 +878,17 @@ function messageFormating(mes, ch_name, isSystem, forceAvatar) {
.replace(/\*\*(.+?)\*\*/g, "<b>$1</b>")
.replace(/\n/g, "<br/>");
} else if (!isSystem) {
mes = mes.replace(/```[\s\S]*?```|``[\s\S]*?``|`[\s\S]*?`|(\".+?\")/gm, function(match, p1) {
if (p1) {
return "<q>" + p1.replace(/\"/g, "") + "</q>";
} else {
return match;
}
});
mes = converter.makeHtml(mes);
//mes = mes.replace(/{.*}/g, "");
mes = mes.replace(/{{(\*?.+?\*?)}}/g, "");
mes = mes.replace(/(<code[^>]*>[\s\S]*?<\/code>)|\"(.+?)\"/g, function (match, code, quote) {
return code ? code : `<q>${quote}</q>`;
});
mes = mes.replace(/\n/g, "<br/>");
mes = mes.trim();