mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-06-17 18:46:40 +00:00
feat(html): add support for collapsed blockquote
This commit is contained in:
parent
8cc3781cd5
commit
4b50fc9415
@ -33,9 +33,9 @@ class HTMLToTelegramParser(HTMLParser):
|
|||||||
attrs = dict(attrs)
|
attrs = dict(attrs)
|
||||||
EntityType = None
|
EntityType = None
|
||||||
args = {}
|
args = {}
|
||||||
if tag == 'strong' or tag == 'b':
|
if tag in ('strong', 'b'):
|
||||||
EntityType = MessageEntityBold
|
EntityType = MessageEntityBold
|
||||||
elif tag == 'em' or tag == 'i':
|
elif tag in ('em', 'i'):
|
||||||
EntityType = MessageEntityItalic
|
EntityType = MessageEntityItalic
|
||||||
elif tag == 'u':
|
elif tag == 'u':
|
||||||
EntityType = MessageEntityUnderline
|
EntityType = MessageEntityUnderline
|
||||||
@ -45,6 +45,7 @@ class HTMLToTelegramParser(HTMLParser):
|
|||||||
EntityType = MessageEntitySpoiler
|
EntityType = MessageEntitySpoiler
|
||||||
elif tag == 'blockquote':
|
elif tag == 'blockquote':
|
||||||
EntityType = MessageEntityBlockquote
|
EntityType = MessageEntityBlockquote
|
||||||
|
args['collapsed'] = 'collapsed' in attrs
|
||||||
elif tag == 'code':
|
elif tag == 'code':
|
||||||
try:
|
try:
|
||||||
# If we're in the middle of a <pre> tag, this <code> tag is
|
# If we're in the middle of a <pre> tag, this <code> tag is
|
||||||
@ -137,7 +138,7 @@ ENTITY_TO_FORMATTER = {
|
|||||||
MessageEntityCode: ('<code>', '</code>'),
|
MessageEntityCode: ('<code>', '</code>'),
|
||||||
MessageEntityUnderline: ('<u>', '</u>'),
|
MessageEntityUnderline: ('<u>', '</u>'),
|
||||||
MessageEntityStrike: ('<del>', '</del>'),
|
MessageEntityStrike: ('<del>', '</del>'),
|
||||||
MessageEntityBlockquote: ('<blockquote>', '</blockquote>'),
|
MessageEntityBlockquote: lambda e, _: (f"<blockquote{' collapsed' if e.collapsed else ''}>", '</blockquote>'),
|
||||||
MessageEntityPre: lambda e, _: (
|
MessageEntityPre: lambda e, _: (
|
||||||
"<pre>\n"
|
"<pre>\n"
|
||||||
" <code class='language-{}'>\n"
|
" <code class='language-{}'>\n"
|
||||||
|
Loading…
Reference in New Issue
Block a user