[fractal] Don't trim paragraph tags on multiple paragraphs
- From: Alexandre Franke <afranke src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [fractal] Don't trim paragraph tags on multiple paragraphs
- Date: Wed, 11 Aug 2021 17:43:51 +0000 (UTC)
commit e0b4f0250372e2807e6872aae96a3e8f89f1622c
Author: Amanda Graven <amanda amandag net>
Date: Mon Aug 9 20:58:28 2021 +0200
Don't trim paragraph tags on multiple paragraphs
fractal-gtk/src/appop/message.rs | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
---
diff --git a/fractal-gtk/src/appop/message.rs b/fractal-gtk/src/appop/message.rs
index f7823eac..bea29145 100644
--- a/fractal-gtk/src/appop/message.rs
+++ b/fractal-gtk/src/appop/message.rs
@@ -238,15 +238,15 @@ impl AppOp {
if let Some(room) = self.active_room.clone() {
if let Some(sender) = self.login_data.as_ref().map(|ld| ld.uid.clone()) {
- let body = msg.clone();
- let mtype = String::from("m.text");
+ let mut body = msg.clone();
+ let mtype = if msg.starts_with("/me ") {
+ body = msg.trim_start_matches("/me ").to_owned();
+ String::from("m.emote")
+ } else {
+ String::from("m.text")
+ };
let mut m = Message::new(room, sender, body, mtype, None);
- if msg.starts_with("/me ") {
- m.body = msg.trim_start_matches("/me ").to_owned();
- m.mtype = String::from("m.emote");
- }
-
// Element (Riot) does not properly show emotes with Markdown;
// Emotes with markdown have a newline after the username
if m.mtype != "m.emote" && self.md_enabled {
@@ -257,7 +257,13 @@ impl AppOp {
// Removing wrap tag: <p>..</p>\n
let limit = md_parsed_msg.len() - 5;
let trim = match (md_parsed_msg.get(0..3), md_parsed_msg.get(limit..)) {
- (Some(open), Some(close)) if open == "<p>" && close == "</p>\n" => true,
+ (Some(open), Some(close)) if open == "<p>" && close == "</p>\n" => {
+ match md_parsed_msg.get(3..limit) {
+ // Don't trim if there's a <p> tag in the middle
+ Some(middle) => !middle.contains("<p>"),
+ None => true,
+ }
+ }
_ => false,
};
if trim {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]