Skip to content

Commit

Permalink
md better?
Browse files Browse the repository at this point in the history
  • Loading branch information
SpEcHiDe committed Jul 22, 2024
1 parent fdf1f58 commit ccf76de
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions pyrogram/parser/markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
CODE_DELIM = "`"
PRE_DELIM = "```"
BLOCKQUOTE_DELIM = ">"
BLOCKQUOTE_EXPANDABLE_DELIM = "**>"

MARKDOWN_RE = re.compile(r"({d})|(!?)\[(.+?)\]\((.+?)\)".format(
d="|".join(
Expand Down Expand Up @@ -72,15 +73,27 @@ def _parse_blockquotes(self, text: str):
if line.startswith(BLOCKQUOTE_DELIM):
in_blockquote = True
current_blockquote.append(line[1:].strip())
elif line.startswith(BLOCKQUOTE_EXPANDABLE_DELIM):
in_blockquote = True
is_expandable_blockquote = True
current_blockquote.append(line[3:].strip())
else:
if in_blockquote:
in_blockquote = False
result.append(OPENING_TAG.format("blockquote") + '\n'.join(current_blockquote) + CLOSING_TAG.format("blockquote"))
result.append(
(f"<blockquote expandable>" if is_expandable_blockquote else OPENING_TAG.format("blockquote")) +
'\n'.join(current_blockquote) +
CLOSING_TAG.format("blockquote")
)
current_blockquote = []
result.append(line)

if in_blockquote:
result.append(OPENING_TAG.format("blockquote") + '\n'.join(current_blockquote) + CLOSING_TAG.format("blockquote"))
result.append(
(f"<blockquote expandable>" if is_expandable_blockquote else OPENING_TAG.format("blockquote")) +
'\n'.join(current_blockquote) +
CLOSING_TAG.format("blockquote")
)

return '\n'.join(result)

Expand Down

0 comments on commit ccf76de

Please sign in to comment.