H3y-sam commited on
Commit
f2decac
·
verified ·
1 Parent(s): 20e0ed7

Upload 54 files

Browse files
Files changed (1) hide show
  1. content/generator.py +6 -0
content/generator.py CHANGED
@@ -49,6 +49,12 @@ def _clean_markdown(text: str) -> str:
49
  text = text.replace('<', '&lt;')
50
  text = text.replace('>', '&gt;')
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('<', '&lt;')
50
  text = text.replace('>', '&gt;')
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'&lt;({tag})&gt;', rf'<\1>', text, flags=re.IGNORECASE)
56
+ text = re.sub(rf'&lt;/({tag})&gt;', 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)