Fix tts.skip_tags's regex to match newlines

The extension_settings.tts.skip_tags setting is meant to skip sending
tags and their content to the TTS API provider. The original regular
expression matched content inside tags with ".*?". Unfortunately,
Javascript's engine does *not* match newlines on the "." without the /s
flag.

The /s flag was added in ES2018. To be more compatible, the regex
has been changed to "[\s\S]+?". This gives similar performance (instead
of using capture groups) and matches all content within a tag, as the
original regex intended.
This commit is contained in:
Small Eggs 2025-01-27 17:43:24 -08:00
parent 3b8fd6f62f
commit 145136059e
No known key found for this signature in database

View File

@ -466,7 +466,7 @@ async function processTtsQueue() {
}
if (extension_settings.tts.skip_tags) {
text = text.replace(/<.*?>.*?<\/.*?>/g, '').trim();
text = text.replace(/<.*?>[\s\S]*?<\/.*?>/g, '').trim();
}
if (!extension_settings.tts.pass_asterisks) {