Skip to content

Commit

Permalink
Support expandable attribute in blockquote tag (#308)
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrielFR authored Jan 27, 2025
1 parent b2ebb36 commit daf8189
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/grammers-client/src/parsers/html.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,13 @@ pub fn parse_html_message(message: &str) -> (String, Vec<tl::enums::MessageEntit
entities.push(tl::types::MessageEntityUnderline { offset, length }.into());
}
tag!("blockquote") => {
let collapsed = attrs.into_iter().any(|a| &a.name.local == "expandable");

entities.push(
tl::types::MessageEntityBlockquote {
offset,
length,
collapsed: false,
collapsed,
}
.into(),
);
Expand Down Expand Up @@ -311,7 +313,14 @@ pub fn generate_html_message(message: &str, entities: &[tl::enums::MessageEntity
insertions.push((after(i, 0, e.offset + e.length), Segment::Fixed("</del>")));
}
ME::Blockquote(e) => {
insertions.push((before(i, 0, e.offset), Segment::Fixed("<blockquote>")));
if e.collapsed {
insertions.push((
before(i, 0, e.offset),
Segment::Fixed("<blockquote expandable>"),
));
} else {
insertions.push((before(i, 0, e.offset), Segment::Fixed("<blockquote>")));
}
insertions.push((
after(i, 0, e.offset + e.length),
Segment::Fixed("</blockquote>"),
Expand Down

0 comments on commit daf8189

Please sign in to comment.