From b48ec0a48df6129d9506b6ea9a28cd4193bfc676 Mon Sep 17 00:00:00 2001 From: inubimambo Date: Sat, 12 Jul 2025 14:06:54 +0800 Subject: [PATCH] Fix unsupported start tag ul --- main.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 61bff77..e61f123 100644 --- a/main.py +++ b/main.py @@ -31,11 +31,25 @@ async def handle_message(update: Update, context: ContextTypes.DEFAULT_TYPE) -> # Simple markdown to HTML conversion html = markdown.markdown(response_text) - # Basic cleanup for Telegram + # Basic cleanup for Telegram HTML compatibility html = html.replace('', '').replace('', '') html = html.replace('', '').replace('', '') html = re.sub(r'

(.*?)

', r'\1\n\n', html, flags=re.DOTALL) + # Handle lists - convert to simple bullet points + html = re.sub(r'', '', html) + html = re.sub(r'
  • (.*?)
  • ', r'• \1\n', html, flags=re.DOTALL) + + # Clean up any other unsupported tags that might be present + html = re.sub(r'
      \s*', '', html) + html = re.sub(r'\s*
    ', '', html) + html = re.sub(r'(.*?)', r'\1\n', html, flags=re.DOTALL) + + # Clean up extra whitespace + html = re.sub(r'\n\s*\n', '\n\n', html) + html = html.strip() + # Send the formatted message using HTML parse mode await update.message.reply_text(html.strip(), parse_mode='HTML')