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

feat(html): support collapsed attribute in blockquote tag #308

Merged
merged 3 commits into from
Jan 27, 2025
Merged
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
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
Loading