mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2024-12-11 17:07:07 +01:00
Support more pairs of international quotes
This commit is contained in:
parent
a09a60ef31
commit
1055f2e1b7
@ -2002,15 +2002,33 @@ export function messageFormatting(mes, ch_name, isSystem, isUser, messageId, san
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
mes = mes.replace(/```[\s\S]*?```|``[\s\S]*?``|`[\s\S]*?`|(".+?")|(\u201C.+?\u201D)/gm, function (match, p1, p2) {
|
mes = mes.replace(
|
||||||
|
/```[\s\S]*?```|``[\s\S]*?``|`[\s\S]*?`|(".*?")|(\u201C.*?\u201D)|(\u00AB.*?\u00BB)|(\u300C.*?\u300D)|(\u300E.*?\u300F)|(\uFF02.*?\uFF02)/gm,
|
||||||
|
function (match, p1, p2, p3, p4, p5, p6) {
|
||||||
if (p1) {
|
if (p1) {
|
||||||
return '<q>"' + p1.replace(/"/g, '') + '"</q>';
|
// English double quotes
|
||||||
|
return `<q>"${p1.slice(1, -1)}"</q>`;
|
||||||
} else if (p2) {
|
} else if (p2) {
|
||||||
return '<q>“' + p2.replace(/\u201C|\u201D/g, '') + '”</q>';
|
// Curly double quotes “ ”
|
||||||
|
return `<q>“${p2.slice(1, -1)}”</q>`;
|
||||||
|
} else if (p3) {
|
||||||
|
// Guillemets « »
|
||||||
|
return `<q>«${p3.slice(1, -1)}»</q>`;
|
||||||
|
} else if (p4) {
|
||||||
|
// Corner brackets 「 」
|
||||||
|
return `<q>「${p4.slice(1, -1)}」</q>`;
|
||||||
|
} else if (p5) {
|
||||||
|
// White corner brackets 『 』
|
||||||
|
return `<q>『${p5.slice(1, -1)}』</q>`;
|
||||||
|
} else if (p6) {
|
||||||
|
// Fullwidth quotes " "
|
||||||
|
return `<q>"${p6.slice(1, -1)}"</q>`;
|
||||||
} else {
|
} else {
|
||||||
|
// Return the original match if no quotes are found
|
||||||
return match;
|
return match;
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
// Restore double quotes in tags
|
// Restore double quotes in tags
|
||||||
if (!power_user.encode_tags) {
|
if (!power_user.encode_tags) {
|
||||||
|
Loading…
Reference in New Issue
Block a user