1
0
Fork 1
mirror of https://github.com/TeamOctolings/Octobot.git synced 2025-05-13 17:26:08 +03:00

style: move ZWSP to a const

This commit is contained in:
Octol1ttle 2023-10-12 21:42:20 +05:00
parent 2359feca7d
commit 6b9c9007d5
Signed by: Octol1ttle
GPG key ID: B77C34313AEE1FFF

View file

@ -5,6 +5,8 @@ namespace Octobot.Extensions;
public static class StringExtensions
{
private const string ZeroWidthSpace = "";
/// <summary>
/// Sanitizes a string for use in <see cref="Markdown.BlockCode(string)" /> by inserting zero-width spaces in between
/// symbols used to format the string with block code.
@ -13,7 +15,7 @@ public static class StringExtensions
/// <returns>The sanitized string that can be safely used in <see cref="Markdown.BlockCode(string)" />.</returns>
private static string SanitizeForBlockCode(this string s)
{
return s.Replace("```", "```");
return s.Replace("```", $"{ZeroWidthSpace}`{ZeroWidthSpace}`{ZeroWidthSpace}`{ZeroWidthSpace}");
}
/// <summary>
@ -25,7 +27,7 @@ public static class StringExtensions
/// <returns>The sanitized string that can be safely used in <see cref="Markdown.BlockCode(string, string)" /> with "diff" as the language.</returns>
public static string SanitizeForDiffBlock(this string s)
{
return $"{s}";
return $"{ZeroWidthSpace}{s}";
}
/// <summary>