Normalize SD prompt strings
| @@ -2178,6 +2178,11 @@ function getQuietPrompt(mode, trigger) { | ||
| 2178 | 2178 | return stringFormat(extension_settings.sd.prompts[mode], trigger); |
| 2179 | 2179 | } |
| 2180 | 2180 | |
| 2181 | +/** | |
| 2182 | + * Sanitizes generated prompt for image generation. | |
| 2183 | + * @param {string} str String to process | |
| 2184 | + * @returns {string} Processed reply | |
| 2185 | + */ | |
| 2181 | 2186 | function processReply(str) { |
| 2182 | 2187 | if (!str) { |
| 2183 | 2188 | return ''; |
| @@ -2187,6 +2192,7 @@ function processReply(str) { | ||
| 2187 | 2192 | str = str.replaceAll('“', ''); |
| 2188 | 2193 | str = str.replaceAll('.', ','); |
| 2189 | 2194 | str = str.replaceAll('\n', ', '); |
| 2195 | + str = str.normalize('NFD'); | |
| 2190 | 2196 | str = str.replace(/[^a-zA-Z0-9,:_(){}<>[\]\-']+/g, ' '); |
| 2191 | 2197 | str = str.replace(/\s+/g, ' '); // Collapse multiple whitespaces into one |
| 2192 | 2198 | str = str.trim(); |