aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/Matrix.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-05-19 00:24:27 +0200
committerdec05eba <dec05eba@protonmail.com>2021-05-19 00:24:27 +0200
commit6beaa000d590db342bc0198590686cbbd6304eb4 (patch)
treed0b91fa35c19ae366677ed810025c8f4923e2033 /src/plugins/Matrix.cpp
parent9cbba813ff41549467af38a9f0ce3eb28d4c157b (diff)
Disable mention formatting in single line code blocks
Diffstat (limited to 'src/plugins/Matrix.cpp')
-rw-r--r--src/plugins/Matrix.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp
index bf988ca..4328888 100644
--- a/src/plugins/Matrix.cpp
+++ b/src/plugins/Matrix.cpp
@@ -2751,14 +2751,16 @@ namespace QuickMedia {
return std::string::npos;
}
- static void formatted_body_add_line(std::string &formatted_body, const std::string &line_str) {
+ void Matrix::formatted_body_add_line(RoomData *room, std::string &formatted_body, const std::string &line_str) {
size_t index = 0;
while(true) {
size_t backquote_start_index = find_backquote_index_with_escape(line_str, index);
if(backquote_start_index != std::string::npos) {
size_t backquote_end_index = find_backquote_index_with_escape(line_str, backquote_start_index + 1);
if(backquote_end_index != std::string::npos) {
- formatted_body += line_str.substr(index, backquote_start_index - index);
+ std::string str_to_append = line_str.substr(index, backquote_start_index - index);
+ replace_mentions(room, str_to_append);
+ formatted_body += std::move(str_to_append);
formatted_body += "<code>";
formatted_body += line_str.substr(backquote_start_index + 1, backquote_end_index - (backquote_start_index + 1));
formatted_body += "</code>";
@@ -2767,7 +2769,9 @@ namespace QuickMedia {
}
}
- formatted_body += line_str.substr(index);
+ std::string str_to_append = line_str.substr(index);
+ replace_mentions(room, str_to_append);
+ formatted_body += std::move(str_to_append);
break;
}
}
@@ -2856,15 +2860,13 @@ namespace QuickMedia {
} else {
if(!is_inside_code_block && size > 0 && str[0] == '>') {
formatted_body += "<font color=\"#789922\">";
- replace_mentions(room, line_str);
- formatted_body_add_line(formatted_body, line_str);
+ formatted_body_add_line(room, formatted_body, line_str);
formatted_body += "</font>";
} else {
if(is_inside_code_block) {
formatted_body += line_str;
} else {
- replace_mentions(room, line_str);
- formatted_body_add_line(formatted_body, line_str);
+ formatted_body_add_line(room, formatted_body, line_str);
}
}
is_first_line = false;