From 454c00ac0b830b4a1a953c07ab21f2d1d8890e9e Mon Sep 17 00:00:00 2001 From: fiaxh Date: Fri, 4 Feb 2022 13:19:28 +0100 Subject: [PATCH] Apply message quote style prior to urls fixup 795af2d, 4e9e09a --- main/src/ui/util/helper.vala | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/main/src/ui/util/helper.vala b/main/src/ui/util/helper.vala index 2e1dc023..58abe810 100644 --- a/main/src/ui/util/helper.vala +++ b/main/src/ui/util/helper.vala @@ -246,6 +246,24 @@ public static string parse_add_markup_theme(string s_, string? highlight_word, b string s = s_; bool already_escaped = already_escaped_; + if (parse_text_markup) { + string gt = already_escaped ? ">" : ">"; + Regex quote_regex = new Regex("((?<=\n)" + gt + ".*(\n|$))|(^" + gt + ".*(\n|$))"); + MatchInfo quote_match_info; + quote_regex.match(s.down(), 0, out quote_match_info); + if (quote_match_info.matches()) { + int start, end; + + string dim_color = dark_theme ? "#BDBDBD": "#707070"; + + theme_dependent = true; + quote_match_info.fetch_pos(0, out start, out end); + return parse_add_markup_theme(s[0:start], highlight_word, parse_links, parse_text_markup, dark_theme, ref theme_dependent, already_escaped) + + @"$gt " + parse_add_markup_theme(s[start + gt.length + 1:end], highlight_word, parse_links, parse_text_markup, dark_theme, ref theme_dependent, already_escaped) + "" + + parse_add_markup_theme(s[end:s.length], highlight_word, parse_links, parse_text_markup, dark_theme, ref theme_dependent, already_escaped); + } + } + if (parse_links && !already_escaped) { MatchInfo match_info; get_url_regex().match(s.down(), 0, out match_info); @@ -319,21 +337,6 @@ public static string parse_add_markup_theme(string s_, string? highlight_word, b } if (parse_text_markup) { - Regex quote_regex = new Regex("((?<=\n)>.*(\n|$))|(^>.*(\n|$))"); - MatchInfo quote_match_info; - quote_regex.match(s.down(), 0, out quote_match_info); - if (quote_match_info.matches()) { - int start, end; - - string dim_color = dark_theme ? "#BDBDBD": "#707070"; - - theme_dependent = true; - quote_match_info.fetch_pos(0, out start, out end); - return parse_add_markup_theme(s[0:start], highlight_word, parse_links, parse_text_markup, dark_theme, ref theme_dependent, already_escaped) + - @"> " + parse_add_markup_theme(s[start + "> ".len():end], highlight_word, parse_links, parse_text_markup, dark_theme, ref theme_dependent, already_escaped) + "" + - parse_add_markup_theme(s[end:s.length], highlight_word, parse_links, parse_text_markup, dark_theme, ref theme_dependent, already_escaped); - } - string[] markup_string = new string[]{"`", "_", "*", "~"}; string[] convenience_tag = new string[]{"tt", "i", "b", "s"};