mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Improve tilde code blocks in message formatting and TTS processing
This commit is contained in:
@@ -2133,7 +2133,7 @@ export function messageFormatting(mes, ch_name, isSystem, isUser, messageId, san
|
|||||||
}
|
}
|
||||||
|
|
||||||
mes = mes.replace(
|
mes = mes.replace(
|
||||||
/```[\s\S]*?```|``[\s\S]*?``|`[\s\S]*?`|(".*?")|(\u201C.*?\u201D)|(\u00AB.*?\u00BB)|(\u300C.*?\u300D)|(\u300E.*?\u300F)|(\uFF02.*?\uFF02)/gm,
|
/```[\s\S]*?```|~~~[\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) {
|
function (match, p1, p2, p3, p4, p5, p6) {
|
||||||
if (p1) {
|
if (p1) {
|
||||||
// English double quotes
|
// English double quotes
|
||||||
@@ -3333,7 +3333,7 @@ class StreamingProcessor {
|
|||||||
stoppingStrings: this.stoppingStrings,
|
stoppingStrings: this.stoppingStrings,
|
||||||
});
|
});
|
||||||
|
|
||||||
const charsToBalance = ['*', '"', '```'];
|
const charsToBalance = ['*', '"', '```', '~~~'];
|
||||||
for (const char of charsToBalance) {
|
for (const char of charsToBalance) {
|
||||||
if (!isFinal && isOdd(countOccurrences(processedText, char))) {
|
if (!isFinal && isOdd(countOccurrences(processedText, char))) {
|
||||||
const separator = char.length > 1 ? '\n' : '';
|
const separator = char.length > 1 ? '\n' : '';
|
||||||
|
@@ -471,6 +471,7 @@ async function processTtsQueue() {
|
|||||||
if (extension_settings.tts.skip_codeblocks) {
|
if (extension_settings.tts.skip_codeblocks) {
|
||||||
text = text.replace(/^\s{4}.*$/gm, '').trim();
|
text = text.replace(/^\s{4}.*$/gm, '').trim();
|
||||||
text = text.replace(/```.*?```/gs, '').trim();
|
text = text.replace(/```.*?```/gs, '').trim();
|
||||||
|
text = text.replace(/~~~.*?~~~/gs, '').trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (extension_settings.tts.skip_tags) {
|
if (extension_settings.tts.skip_tags) {
|
||||||
|
Reference in New Issue
Block a user