From efeade88c1eac8aa2368dfb389a0a6910d4c0b85 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Thu, 10 May 2018 15:07:03 +0200 Subject: [PATCH] Cleaner markdown --- pyrogram/client/style/markdown.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/pyrogram/client/style/markdown.py b/pyrogram/client/style/markdown.py index 80e51ee1..2bdfd6d8 100644 --- a/pyrogram/client/style/markdown.py +++ b/pyrogram/client/style/markdown.py @@ -123,23 +123,20 @@ class Markdown: elif type == "pre": style = self.PRE_DELIMITER elif type == "text_link": - message = message[:start] + message[start:].replace( - sub, "[{}]({})".format(sub, url), 1 - ) offset += 4 + len(url) + message = message[:start] + message[start:].replace( + sub, "[{}]({})".format(sub, url), 1) continue elif type == "text_mention": - message = message[:start] + message[start:].replace( - sub, "[{}](tg://user?id={})".format(sub, user.id), 1 - ) offset += 17 + len(str(user.id)) + message = message[:start] + message[start:].replace( + sub, "[{}](tg://user?id={})".format(sub, user.id), 1) continue else: continue - message = message[:start] + message[start:].replace( - sub, "{0}{1}{0}".format(style, sub), 1 - ) offset += len(style) * 2 + message = message[:start] + message[start:].replace( + sub, "{0}{1}{0}".format(style, sub), 1) return message