aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui/util
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2022-02-04 13:19:28 +0100
committerfiaxh <git@lightrise.org>2022-02-04 13:39:46 +0100
commit454c00ac0b830b4a1a953c07ab21f2d1d8890e9e (patch)
treea85a3afbc928ddcbd150492a9a07f6cde51bb456 /main/src/ui/util
parentf94d95fa442ca347d014d54781ee64078898a183 (diff)
downloaddino-454c00ac0b830b4a1a953c07ab21f2d1d8890e9e.tar.gz
dino-454c00ac0b830b4a1a953c07ab21f2d1d8890e9e.zip
Apply message quote style prior to urls
fixup 795af2d, 4e9e09a
Diffstat (limited to 'main/src/ui/util')
-rw-r--r--main/src/ui/util/helper.vala33
1 files 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 ? "&gt;" : ">";
+ 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) +
+ @"<span color='$dim_color'>$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) + "</span>" +
+ 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)&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) +
- @"<span color='$dim_color'>&gt; " + parse_add_markup_theme(s[start + "&gt; ".len():end], highlight_word, parse_links, parse_text_markup, dark_theme, ref theme_dependent, already_escaped) + "</span>" +
- 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"};