From 5ddd28bf309f219322cc3e82d7afcf9c540067e2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 15 May 2019 16:42:12 +0900 Subject: [PATCH] Fix message display / html stripping --- .../Changelog/ChangelogContentGroup.cs | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs index e9ca025425..190720df04 100644 --- a/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs +++ b/osu.Game/Overlays/Changelog/ChangelogContentGroup.cs @@ -10,6 +10,7 @@ using osu.Game.Graphics.UserInterface; using osu.Game.Online.API.Requests.Responses; using System; using System.Collections.Generic; +using System.Text.RegularExpressions; using osuTK; using osuTK.Graphics; @@ -262,19 +263,23 @@ namespace osu.Game.Overlays.Changelog ChangelogEntries.Add(title); - TextFlowContainer messageContainer = new TextFlowContainer + if (!string.IsNullOrEmpty(entry.MessageHtml)) { - AutoSizeAxes = Axes.Y, - RelativeSizeAxes = Axes.X, - }; + TextFlowContainer messageContainer = new TextFlowContainer + { + AutoSizeAxes = Axes.Y, + RelativeSizeAxes = Axes.X, + }; - messageContainer.AddText($"{entry.MessageHtml?.Replace("

", "").Replace("

", "")}\n", t => - { - t.Font = OsuFont.GetFont(size: 14); // web: 12, - t.Colour = new Color4(235, 184, 254, 255); - }); + // todo: use markdown parsing once API returns markdown + messageContainer.AddText(Regex.Replace(entry.MessageHtml, @"<(.|\n)*?>", string.Empty), t => + { + t.Font = OsuFont.GetFont(size: 14); // web: 12, + t.Colour = new Color4(235, 184, 254, 255); + }); - ChangelogEntries.Add(messageContainer); + ChangelogEntries.Add(messageContainer); + } } } }