TheVera commited on
Commit
ed1b5fc
·
verified ·
1 Parent(s): 2d01dcd

Update script.js

Browse files
Files changed (1) hide show
  1. script.js +18 -9
script.js CHANGED
@@ -189,15 +189,24 @@ function startNewChat() {
189
  chatBody.scrollTop = chatBody.scrollHeight;
190
  }
191
 
192
- function remove_special_chars(text):
193
- """Remove special characters from text, allowing only specified characters."""
194
- allow = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 :,.?!"
195
- text = text.replace("<br>","")
196
- newtxt = ""
197
- for i in text:
198
- if i in allow:
199
- newtxt += i
200
- return newtxt
 
 
 
 
 
 
 
 
 
201
 
202
 
203
  // Text-to-Speech function
 
189
  chatBody.scrollTop = chatBody.scrollHeight;
190
  }
191
 
192
+ function remove_special_chars(text) {
193
+ // Allow only specified characters
194
+ const allow = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 :,.?!";
195
+
196
+ // Replace <br> with a space for better readability
197
+ text = text.replace(/<br>/g, " ");
198
+
199
+ let newtxt = "";
200
+
201
+ // Iterate through the text and include only allowed characters
202
+ for (let char of text) {
203
+ if (allow.includes(char)) {
204
+ newtxt += char;
205
+ }
206
+ }
207
+
208
+ return newtxt;
209
+ }
210
 
211
 
212
  // Text-to-Speech function