Wajahat698 commited on
Commit
13954ce
·
verified ·
1 Parent(s): 799c695

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -17
app.py CHANGED
@@ -147,26 +147,13 @@ def send_feedback_via_email(name, email, feedback):
147
 
148
 
149
  def clean_text(text):
150
- # Replace escaped newlines with actual newlines
151
  text = text.replace('\\n', '\n')
152
 
153
- # Remove any span and italic tags
154
- text = re.sub(r'<[^>]+>', '', text)
155
-
156
- text = re.sub(r'<span[^>]*>', '', text)
157
- text = re.sub(r'</span>', '', text)
158
- text = re.sub(r'<i[^>]*>', '', text)
159
- text = re.sub(r'</i>', '', text)
160
- text = re.sub(r'<span[^>]*>.*?</span>', '', text, flags=re.DOTALL)
161
- text = re.sub(r'<span[^>]*>.*?</span>', '', text, flags=re.DOTALL)
162
- text = re.sub(r'<span class="mord mathnormal"[^>]*>([^<]+)</span>', r'\1', text)
163
-
164
-
165
-
166
-
167
 
168
- # Preserve and correctly format markdown links (don't modify URLs)
169
- #text = re.sub(r'\[([^\]]+)\]\((https?://[^\)]+)\)', r'\1: \2', text)
170
 
171
  # Split the text into paragraphs
172
  paragraphs = text.split('\n\n')
@@ -200,6 +187,8 @@ def clean_text(text):
200
  cleaned_text = '\n\n'.join(para for para in cleaned_paragraphs if para)
201
 
202
  return cleaned_text
 
 
203
  def get_trust_tip_and_suggestion():
204
  trust_tip = random.choice(trust_tips)
205
  suggestion = random.choice(suggestions)
 
147
 
148
 
149
  def clean_text(text):
 
150
  text = text.replace('\\n', '\n')
151
 
152
+ # Remove all HTML tags, including nested structures
153
+ text = re.sub(r'<[^>]*>', '', text)
 
 
 
 
 
 
 
 
 
 
 
 
154
 
155
+ # Remove any remaining < or > characters
156
+ text = text.replace('<', '').replace('>', '')
157
 
158
  # Split the text into paragraphs
159
  paragraphs = text.split('\n\n')
 
187
  cleaned_text = '\n\n'.join(para for para in cleaned_paragraphs if para)
188
 
189
  return cleaned_text
190
+
191
+
192
  def get_trust_tip_and_suggestion():
193
  trust_tip = random.choice(trust_tips)
194
  suggestion = random.choice(suggestions)