From 9690088e0110045421567203fbd1dc6911d2fb34 Mon Sep 17 00:00:00 2001 From: AndrielFR Date: Sun, 26 Jan 2025 03:03:30 -0300 Subject: [PATCH 1/3] feat(html): support collapsed attribute in blockquote tag - Added logic to check for the 'collapsed' attribute in blockquote tags. - Updated MessageEntityBlockquote to use the collapsed attribute value. --- lib/grammers-client/src/parsers/html.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/grammers-client/src/parsers/html.rs b/lib/grammers-client/src/parsers/html.rs index c0171363..4c23223c 100644 --- a/lib/grammers-client/src/parsers/html.rs +++ b/lib/grammers-client/src/parsers/html.rs @@ -59,11 +59,13 @@ pub fn parse_html_message(message: &str) -> (String, Vec { + let collapsed = attrs.into_iter().any(|a| &a.name.local == "collapsed"); + entities.push( tl::types::MessageEntityBlockquote { offset, length, - collapsed: false, + collapsed, } .into(), ); From 83c64ad52b79ee429d872c46e61cd80536f51158 Mon Sep 17 00:00:00 2001 From: AndrielFR Date: Sun, 26 Jan 2025 16:19:41 -0300 Subject: [PATCH 2/3] refactor(html): follow the bot api regarding the collapsed blockquote - 'collapsed' -> 'expandable' - ref: https://core.telegram.org/bots/api#html-style --- lib/grammers-client/src/parsers/html.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/grammers-client/src/parsers/html.rs b/lib/grammers-client/src/parsers/html.rs index 4c23223c..1c840107 100644 --- a/lib/grammers-client/src/parsers/html.rs +++ b/lib/grammers-client/src/parsers/html.rs @@ -59,7 +59,7 @@ pub fn parse_html_message(message: &str) -> (String, Vec { - let collapsed = attrs.into_iter().any(|a| &a.name.local == "collapsed"); + let collapsed = attrs.into_iter().any(|a| &a.name.local == "expandable"); entities.push( tl::types::MessageEntityBlockquote { From 1ed0e9a423bd58de6c507e23c1d02862adcc414c Mon Sep 17 00:00:00 2001 From: AndrielFR Date: Sun, 26 Jan 2025 16:29:38 -0300 Subject: [PATCH 3/3] feat(html): add `expandable` on `.html_text()` --- lib/grammers-client/src/parsers/html.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/grammers-client/src/parsers/html.rs b/lib/grammers-client/src/parsers/html.rs index 1c840107..fe07790b 100644 --- a/lib/grammers-client/src/parsers/html.rs +++ b/lib/grammers-client/src/parsers/html.rs @@ -313,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(""))); } ME::Blockquote(e) => { - insertions.push((before(i, 0, e.offset), Segment::Fixed("
"))); + if e.collapsed { + insertions.push(( + before(i, 0, e.offset), + Segment::Fixed("
"), + )); + } else { + insertions.push((before(i, 0, e.offset), Segment::Fixed("
"))); + } insertions.push(( after(i, 0, e.offset + e.length), Segment::Fixed("
"),