Support more pairs of international quotes

1055f2e1b74c2f91afe3aa84d473010174d9a939

Cohee <18619528+Cohee1207@users.noreply.github.com>

1 files changed, +22 -4Showing whitespace changes
public/script.js+22 -4
@@ -2002,15 +2002,33 @@ export function messageFormatting(mes, ch_name, isSystem, isUser, messageId, san
20022002 });
20032003 }
20042004
2005- mes = mes.replace(/```[\s\S]*?```|``[\s\S]*?``|`[\s\S]*?`|(".+?")|(\u201C.+?\u201D)/gm, function (match, p1, p2) {
2005+ mes = mes.replace(
2006+ /```[\s\S]*?```|``[\s\S]*?``|`[\s\S]*?`|(".*?")|(\u201C.*?\u201D)|(\u00AB.*?\u00BB)|(\u300C.*?\u300D)|(\u300E.*?\u300F)|(\uFF02.*?\uFF02)/gm,
2007+ function (match, p1, p2, p3, p4, p5, p6) {
20062008 if (p1) {
2007- return '<q>"' + p1.replace(/"/g, '') + '"</q>';
2009+ // English double quotes
2010+ return `<q>"${p1.slice(1, -1)}"</q>`;
20082011 } else if (p2) {
2009- return '<q>“' + p2.replace(/\u201C|\u201D/g, '') + '”</q>';
2012+ // Curly double quotes “ ”
2013+ return `<q>“${p2.slice(1, -1)}”</q>`;
2014+ } else if (p3) {
2015+ // Guillemets « »
2016+ return `<q>«${p3.slice(1, -1)}»</q>`;
2017+ } else if (p4) {
2018+ // Corner brackets 「 」
2019+ return `<q>「${p4.slice(1, -1)}」</q>`;
2020+ } else if (p5) {
2021+ // White corner brackets 『 』
2022+ return `<q>『${p5.slice(1, -1)}』</q>`;
2023+ } else if (p6) {
2024+ // Fullwidth quotes " "
2025+ return `<q>"${p6.slice(1, -1)}"</q>`;
20102026 } else {
2027+ // Return the original match if no quotes are found
20112028 return match;
20122029 }
2013- });
2030+ }
2031+ );
20142032
20152033 // Restore double quotes in tags
20162034 if (!power_user.encode_tags) {