Improve tilde code blocks in message formatting and TTS processing
| @@ -2133,7 +2133,7 @@ export function messageFormatting(mes, ch_name, isSystem, isUser, messageId, san | |||
| 2133 | } | 2133 | } |
| 2134 | 2134 | ||
| 2135 | mes = mes.replace( | 2135 | mes = mes.replace( |
| 2136 | /```[\s\S]*?```|``[\s\S]*?``|`[\s\S]*?`|(".*?")|(\u201C.*?\u201D)|(\u00AB.*?\u00BB)|(\u300C.*?\u300D)|(\u300E.*?\u300F)|(\uFF02.*?\uFF02)/gm, | 2136 | /```[\s\S]*?```|~~~[\s\S]*?~~~|``[\s\S]*?``|`[\s\S]*?`|(".*?")|(\u201C.*?\u201D)|(\u00AB.*?\u00BB)|(\u300C.*?\u300D)|(\u300E.*?\u300F)|(\uFF02.*?\uFF02)/gm, |
| 2137 | function (match, p1, p2, p3, p4, p5, p6) { | 2137 | function (match, p1, p2, p3, p4, p5, p6) { |
| 2138 | if (p1) { | 2138 | if (p1) { |
| 2139 | // English double quotes | 2139 | // English double quotes |
| @@ -3333,7 +3333,7 @@ class StreamingProcessor { | |||
| 3333 | stoppingStrings: this.stoppingStrings, | 3333 | stoppingStrings: this.stoppingStrings, |
| 3334 | }); | 3334 | }); |
| 3335 | 3335 | ||
| 3336 | const charsToBalance = ['*', '"', '```']; | 3336 | const charsToBalance = ['*', '"', '```', '~~~']; |
| 3337 | for (const char of charsToBalance) { | 3337 | for (const char of charsToBalance) { |
| 3338 | if (!isFinal && isOdd(countOccurrences(processedText, char))) { | 3338 | if (!isFinal && isOdd(countOccurrences(processedText, char))) { |
| 3339 | const separator = char.length > 1 ? '\n' : ''; | 3339 | const separator = char.length > 1 ? '\n' : ''; |
| @@ -471,6 +471,7 @@ async function processTtsQueue() { | |||
| 471 | if (extension_settings.tts.skip_codeblocks) { | 471 | if (extension_settings.tts.skip_codeblocks) { |
| 472 | text = text.replace(/^\s{4}.*$/gm, '').trim(); | 472 | text = text.replace(/^\s{4}.*$/gm, '').trim(); |
| 473 | text = text.replace(/```.*?```/gs, '').trim(); | 473 | text = text.replace(/```.*?```/gs, '').trim(); |
| 474 | text = text.replace(/~~~.*?~~~/gs, '').trim(); | ||
| 474 | } | 475 | } |
| 475 | 476 | ||
| 476 | if (extension_settings.tts.skip_tags) { | 477 | if (extension_settings.tts.skip_tags) { |