Spaces:
Running
Running
Upload 54 files
Browse files- content/generator.py +6 -0
content/generator.py
CHANGED
|
@@ -49,6 +49,12 @@ def _clean_markdown(text: str) -> str:
|
|
| 49 |
text = text.replace('<', '<')
|
| 50 |
text = text.replace('>', '>')
|
| 51 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
# 4. Convert **bold** or *bold* → <b>bold</b>
|
| 53 |
text = re.sub(r'\*\*(.+?)\*\*', r'<b>\1</b>', text, flags=re.DOTALL)
|
| 54 |
text = re.sub(r'\*([^\*\n]+?)\*', r'<b>\1</b>', text)
|
|
|
|
| 49 |
text = text.replace('<', '<')
|
| 50 |
text = text.replace('>', '>')
|
| 51 |
|
| 52 |
+
# Restore permitted HTML tags that Gemini might have generated (since prompt asks for <b>)
|
| 53 |
+
allowed_tags = ['b', 'i', 'code', 'u', 's', 'pre', 'strong', 'em']
|
| 54 |
+
for tag in allowed_tags:
|
| 55 |
+
text = re.sub(rf'<({tag})>', rf'<\1>', text, flags=re.IGNORECASE)
|
| 56 |
+
text = re.sub(rf'</({tag})>', rf'</\1>', text, flags=re.IGNORECASE)
|
| 57 |
+
|
| 58 |
# 4. Convert **bold** or *bold* → <b>bold</b>
|
| 59 |
text = re.sub(r'\*\*(.+?)\*\*', r'<b>\1</b>', text, flags=re.DOTALL)
|
| 60 |
text = re.sub(r'\*([^\*\n]+?)\*', r'<b>\1</b>', text)
|