aboutsummaryrefslogtreecommitdiff
path: root/main/src
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2018-12-28 15:04:50 +0100
committerfiaxh <git@lightrise.org>2018-12-29 13:10:24 +0100
commit5a4e50935956e9311f5471f4c8297bcc10716e9e (patch)
treebfaa4ca3acce8570199a8934de492e656a39a77f /main/src
parent49269c3173cff4a3a911aba33c52a6ca846e5b78 (diff)
downloaddino-5a4e50935956e9311f5471f4c8297bcc10716e9e.tar.gz
dino-5a4e50935956e9311f5471f4c8297bcc10716e9e.zip
Improve message markup parsing
Diffstat (limited to 'main/src')
-rw-r--r--main/src/ui/util/helper.vala7
1 files changed, 3 insertions, 4 deletions
diff --git a/main/src/ui/util/helper.vala b/main/src/ui/util/helper.vala
index da78b485..ecfe87a8 100644
--- a/main/src/ui/util/helper.vala
+++ b/main/src/ui/util/helper.vala
@@ -200,14 +200,13 @@ public static string parse_add_markup(string s_, string? highlight_word, bool pa
string[] convenience_tag = new string[]{"tt", "i", "b"};
for (int i = 0; i < markup_string.length; i++) {
- Regex regex = new Regex(Regex.escape_string(markup_string[i]) + ".+" + Regex.escape_string(markup_string[i]));
+ string markup_esc = Regex.escape_string(markup_string[i]);
+ Regex regex = new Regex("(^|\\s)" + markup_esc + "(\\S.*?\\S|\\S)" + markup_esc + "($|\\s)");
MatchInfo match_info;
regex.match(s.down(), 0, out match_info);
if (match_info.matches()) {
int start, end;
- match_info.fetch_pos(0, out start, out end);
- start += markup_string[i].length;
- end -= markup_string[i].length;
+ match_info.fetch_pos(2, out start, out end);
return parse_add_markup(s[0:start], highlight_word, parse_links, parse_text_markup, already_escaped) +
@"<$(convenience_tag[i])>" + s[start:end] + @"</$(convenience_tag[i])>" +
parse_add_markup(s[end:s.length], highlight_word, parse_links, parse_text_markup, already_escaped);