diff options
-rw-r--r-- | libmatrix.c | 4 | ||||
-rw-r--r-- | libmatrix.h | 1 | ||||
-rw-r--r-- | matrix-room.c | 10 |
3 files changed, 13 insertions, 2 deletions
diff --git a/libmatrix.c b/libmatrix.c index 4783056..a422e0f 100644 --- a/libmatrix.c +++ b/libmatrix.c @@ -372,6 +372,10 @@ static void matrixprpl_init(PurplePlugin *plugin) _("On reconnect, skip messages which were received in a " "previous session"), PRPL_ACCOUNT_OPT_SKIP_OLD_MESSAGES, FALSE)); + protocol_options = g_list_append(protocol_options, + purple_account_option_bool_new( + _("Prefer Markdown over HTML"), + PRPL_ACCOUNT_OPT_PREFER_MARKDOWN, FALSE)); prpl_info.protocol_options = protocol_options; } diff --git a/libmatrix.h b/libmatrix.h index 852d5f8..c894723 100644 --- a/libmatrix.h +++ b/libmatrix.h @@ -115,6 +115,7 @@ #define PRPL_ACCOUNT_OPT_HOME_SERVER "home_server" #define PRPL_ACCOUNT_OPT_NEXT_BATCH "next_batch" #define PRPL_ACCOUNT_OPT_SKIP_OLD_MESSAGES "skip_old_messages" +#define PRPL_ACCOUNT_OPT_PREFER_MARKDOWN "prefer_markdown" /* Pickled account info from olm_pickle_account */ #define PRPL_ACCOUNT_OPT_OLM_ACCOUNT_KEYS "olm_account_keys" /* Access token, after a login */ diff --git a/matrix-room.c b/matrix-room.c index b26d036..cd17ae7 100644 --- a/matrix-room.c +++ b/matrix-room.c @@ -1094,8 +1094,14 @@ void matrix_room_handle_timeline_event(PurpleConversation *conv, } flags = PURPLE_MESSAGE_RECV; - if (purple_strequal(matrix_json_object_get_string_member(json_content_obj, "format"), "org.matrix.custom.html")) { - escaped_body = g_strdup(matrix_json_object_get_string_member(json_content_obj, "formatted_body")); + gboolean prefer_markdown = purple_account_get_bool(conv->account, + PRPL_ACCOUNT_OPT_PREFER_MARKDOWN, FALSE); + if (!prefer_markdown) { + if (purple_strequal(matrix_json_object_get_string_member(json_content_obj, "format"), "org.matrix.custom.html")) { + escaped_body = g_strdup(matrix_json_object_get_string_member(json_content_obj, "formatted_body")); + } else { + escaped_body = purple_markup_escape_text(tmp_body ? tmp_body : msg_body, -1); + } } else { escaped_body = purple_markup_escape_text(tmp_body ? tmp_body : msg_body, -1); } |