Skip to content

Commit

Permalink
pyrofork: Add support for multi-line blockquote in markdown unparser
Browse files Browse the repository at this point in the history
Signed-off-by: wulan17 <[email protected]>
  • Loading branch information
wulan17 committed Mar 2, 2025
1 parent 00f3d74 commit 69cd87b
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions pyrogram/parser/markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,20 @@ def unparse(text: str, entities: list):
e = entity.offset + entity.length
delimiter = delimiters.get(entity.type, None)
if delimiter:
insert_at.append((s, i, delimiter))
insert_at.append((e, -i, delimiter))
if entity.type != MessageEntityType.BLOCKQUOTE and entity.type != MessageEntityType.EXPANDABLE_BLOCKQUOTE:
insert_at.append((s, i, delimiter))
insert_at.append((e, -i, delimiter))
else:
# Handle multiline blockquotes
text_subset = text[s:e]
lines = text_subset.splitlines()
for line_num, line in enumerate(lines):
line_start = s + sum(len(l) + 1 for l in lines[:line_num])
if entity.collapsed:
insert_at.append((line_start, i, BLOCKQUOTE_EXPANDABLE_DELIM))
else:
insert_at.append((line_start, i, BLOCKQUOTE_DELIM))
# No closing delimiter for blockquotes
else:
url = None
if entity.type == MessageEntityType.TEXT_LINK:
Expand Down

0 comments on commit 69cd87b

Please sign in to comment.