Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rewrite markdown parser #159

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 14 additions & 17 deletions docs/source/topics/text-formatting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,20 @@ To strictly use this mode, pass :obj:`~pyrogram.enums.ParseMode.MARKDOWN` to the

>blockquote

|>escaped blockquote
**>escaped blockquote

>Fist line of multi line blockquote
>Block quotation continued
>Block quotation continued
>Block quotation continued
>The last line of the block quotation

**>
The expandable block quotation started right after the previous block quotation
It is separated from the previous block quotation by expandable syntax
Expandable block quotation continued
Hidden by default part of the expandable block quotation started
Expandable block quotation continued
The last line of the expandable block quotation with the expandability mark<**
**>The expandable block quotation started right after the previous block quotation
**>It is separated from the previous block quotation by expandable syntax
**>Expandable block quotation continued
**>Hidden by default part of the expandable block quotation started
**>Expandable block quotation continued
**>The last line of the expandable block quotation with the expandability mark||

`inline fixed-width code`

Expand Down Expand Up @@ -115,21 +114,19 @@ To strictly use this mode, pass :obj:`~pyrogram.enums.ParseMode.MARKDOWN` to the

">blockquote\n"

"|>escaped blockquote\n"

">Fist line of multi line blockquote\n"
">Block quotation continued\n"
">Block quotation continued\n"
">Block quotation continued\n"
">The last line of the block quotation"

"**>\n"
"The expandable block quotation started right after the previous block quotation\n"
"It is separated from the previous block quotation by expandable syntax\n"
"Expandable block quotation continued\n"
"Hidden by default part of the expandable block quotation started\n"
"Expandable block quotation continued\n"
"The last line of the expandable block quotation with the expandability mark<**"
"||\n"
"**>The expandable block quotation started right after the previous block quotation\n"
"**>It is separated from the previous block quotation by expandable syntax\n"
"**>Expandable block quotation continued\n"
"**>Hidden by default part of the expandable block quotation started\n"
"**>Expandable block quotation continued\n"
"**>The last line of the expandable block quotation with the expandability mark||"

),
parse_mode=ParseMode.MARKDOWN
Expand Down
2 changes: 1 addition & 1 deletion pyrogram/parser/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Pyrogram - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
# Copyright (C) 2017-present <https://github.com/TelegramPlayGround>
#
# This file is part of Pyrogram.
#
Expand Down
7 changes: 2 additions & 5 deletions pyrogram/parser/html.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Pyrogram - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
# Copyright (C) 2017-present <https://github.com/TelegramPlayGround>
#
# This file is part of Pyrogram.
#
Expand Down Expand Up @@ -178,16 +178,13 @@ def parse_one(entity):
language = getattr(entity, "language", "") or ""
start_tag = f'<{name} language="{language}">' if language else f"<{name}>"
end_tag = f"</{name}>"
elif entity_type == MessageEntityType.BLOCKQUOTE:
name = entity_type.name.lower()
start_tag = f"<{name}>"
end_tag = f"</{name}>"
elif entity_type == MessageEntityType.EXPANDABLE_BLOCKQUOTE:
name = "blockquote"
start_tag = f"<{name} expandable>"
end_tag = f"</{name}>"
elif entity_type in (
MessageEntityType.CODE,
MessageEntityType.BLOCKQUOTE,
MessageEntityType.SPOILER,
):
name = entity_type.name.lower()
Expand Down
Loading