Skip to content

Commit

Permalink
Pyrofork: Add blockquote markdown unparser
Browse files Browse the repository at this point in the history
Signed-off-by: wulan17 <wulan17@nusantararom.org>
  • Loading branch information
wulan17 committed Jan 11, 2024
1 parent d636e0b commit 0640619
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion pyrogram/parser/markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,21 @@ def unparse(text: str, entities: list):
start_tag = f"{PRE_DELIM}{language}\n"
end_tag = f"\n{PRE_DELIM}"
elif entity_type == MessageEntityType.BLOCKQUOTE:
start_tag = BLOCKQUOTE_DELIM
start_tag = BLOCKQUOTE_DELIM + " "
end_tag = ""
blockquote_text = text[start:end]
lines = blockquote_text.split("\n")
last_length = 0
for line in lines:
if len(line) == 0 and last_length == end:
continue
start_offset = start+last_length
last_length = last_length+len(line)
end_offset = start_offset+last_length
entities_offsets.append((start_tag, start_offset,))
entities_offsets.append((end_tag, end_offset,))
last_length = last_length+1
continue
elif entity_type == MessageEntityType.SPOILER:
start_tag = end_tag = SPOILER_DELIM
elif entity_type == MessageEntityType.TEXT_LINK:
Expand Down

0 comments on commit 0640619

Please sign in to comment.