diff --git a/src/Kook.Net.Core/Format.cs b/src/Kook.Net.Core/Format.cs index e072421c..7b7242e0 100644 --- a/src/Kook.Net.Core/Format.cs +++ b/src/Kook.Net.Core/Format.cs @@ -364,14 +364,18 @@ public static string BlockQuote(this string? text, bool sanitize = true) return result.ToString(); } + /// + [Obsolete("Use StripMarkdown instead.")] + public static string StripMarkDown(this string text) => StripMarkdown(text); + /// /// Remove Kook supported markdown from text. /// /// The to remove markdown from. /// Gets the unformatted text. - public static string StripMarkDown(this string text) => + public static string StripMarkdown(this string text) => // Remove KOOK supported markdown - Regex.Replace(text, @"(\*|\(ins\)|\(spl\)|`|~|>|\\)", "", RegexOptions.Compiled); + Regex.Replace(text, @"\*|\(ins\)|\(spl\)|`|~|>|\\|-{2,}", "", RegexOptions.Compiled); /// /// Formats a user's username + identify number while maintaining bidirectional unicode diff --git a/src/Kook.Net.Rest/Entities/Messages/MessageHelper.cs b/src/Kook.Net.Rest/Entities/Messages/MessageHelper.cs index 16e4cd0c..36cf57b7 100644 --- a/src/Kook.Net.Rest/Entities/Messages/MessageHelper.cs +++ b/src/Kook.Net.Rest/Entities/Messages/MessageHelper.cs @@ -335,7 +335,7 @@ public static string SanitizeMessage(IMessage message) string newContent = MentionUtils.Resolve(message, 0, TagHandling.FullName, TagHandling.FullName, TagHandling.FullName, TagHandling.FullName, TagHandling.FullName); - return newContent.StripMarkDown(); + return newContent.StripMarkdown(); } public static ImmutableArray ParseTags(string text, IMessageChannel? channel, IGuild? guild, diff --git a/test/Kook.Net.Tests.Unit/FormatTests.cs b/test/Kook.Net.Tests.Unit/FormatTests.cs index 359a4ba2..f089f76b 100644 --- a/test/Kook.Net.Tests.Unit/FormatTests.cs +++ b/test/Kook.Net.Tests.Unit/FormatTests.cs @@ -60,13 +60,14 @@ public void Code() [InlineData(">>uwu", "uwu")] [InlineData("```uwu```", "uwu")] [InlineData("~uwu~", "uwu")] + [InlineData("uwu\n---\nuwu", "uwu\n\nuwu")] [InlineData("(ins)uwu(ins)", "uwu")] [InlineData("(spl)uwu(spl)", "uwu")] [InlineData("berries and *Cream**, I'm a little lad who loves berries and cream", "berries and Cream, I'm a little lad who loves berries and cream")] public void StripMarkdown(string input, string expected) { - string test = input.StripMarkDown(); + string test = input.StripMarkdown(); Assert.Equal(expected, test); } }