From 38d024312e802c0b6203bdd7a980d15c75112ebf Mon Sep 17 00:00:00 2001 From: Nick80835 <24271245+Nick80835@users.noreply.github.com> Date: Sat, 1 Feb 2025 11:20:56 -0500 Subject: [PATCH] Unconditionally match text and link text in markdown Fixes cases where there's a nested [] in the text by matching until "](" is reached. This doesn't match newlines in URLs because that makes no sense. --- telethon/extensions/markdown.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/telethon/extensions/markdown.py b/telethon/extensions/markdown.py index 82e90345..dda1ae5e 100644 --- a/telethon/extensions/markdown.py +++ b/telethon/extensions/markdown.py @@ -22,7 +22,7 @@ DEFAULT_DELIMITERS = { '```': MessageEntityPre } -DEFAULT_URL_RE = re.compile(r'\[([^\]]+)\]\(([^)]+)\)') +DEFAULT_URL_RE = re.compile(r'\[([\s\S]+)\]\((.+)\)') DEFAULT_URL_FORMAT = '[{0}]({1})'