Skip to content

Commit daf8189

Browse files
authored
Support expandable attribute in blockquote tag (#308)
Ref: https://core.telegram.org/bots/api#html-style
1 parent b2ebb36 commit daf8189

File tree

1 file changed

+11
-2
lines changed
  • lib/grammers-client/src/parsers

1 file changed

+11
-2
lines changed

lib/grammers-client/src/parsers/html.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,13 @@ pub fn parse_html_message(message: &str) -> (String, Vec<tl::enums::MessageEntit
5959
entities.push(tl::types::MessageEntityUnderline { offset, length }.into());
6060
}
6161
tag!("blockquote") => {
62+
let collapsed = attrs.into_iter().any(|a| &a.name.local == "expandable");
63+
6264
entities.push(
6365
tl::types::MessageEntityBlockquote {
6466
offset,
6567
length,
66-
collapsed: false,
68+
collapsed,
6769
}
6870
.into(),
6971
);
@@ -311,7 +313,14 @@ pub fn generate_html_message(message: &str, entities: &[tl::enums::MessageEntity
311313
insertions.push((after(i, 0, e.offset + e.length), Segment::Fixed("</del>")));
312314
}
313315
ME::Blockquote(e) => {
314-
insertions.push((before(i, 0, e.offset), Segment::Fixed("<blockquote>")));
316+
if e.collapsed {
317+
insertions.push((
318+
before(i, 0, e.offset),
319+
Segment::Fixed("<blockquote expandable>"),
320+
));
321+
} else {
322+
insertions.push((before(i, 0, e.offset), Segment::Fixed("<blockquote>")));
323+
}
315324
insertions.push((
316325
after(i, 0, e.offset + e.length),
317326
Segment::Fixed("</blockquote>"),

0 commit comments

Comments
 (0)