fix(markup): add heading support to _md_to_html (h1/h2/h3)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Christian Gick
2026-02-23 11:51:48 +02:00
parent 42ba3c09d0
commit 040d4c9285

4
bot.py
View File

@@ -1497,6 +1497,10 @@ class Bot:
safe = re.sub(r"\[([^\]]+)\]\(([^)]+)\)", _link_repl, safe)
# Bare URLs (not already in an <a> tag)
safe = re.sub(r'(?<!href=")(?<!">)(https?://[^\s<]+)', r'<a href="\1">\1</a>', safe)
# Headings (### before ## before # to match longest first)
safe = re.sub(r"^### (.+)$", r"<h3>\1</h3>", safe, flags=re.MULTILINE)
safe = re.sub(r"^## (.+)$", r"<h2>\1</h2>", safe, flags=re.MULTILINE)
safe = re.sub(r"^# (.+)$", r"<h1>\1</h1>", safe, flags=re.MULTILINE)
# Line breaks
safe = safe.replace("\n", "<br/>")
return safe