Merged changed from dev branch
This commit is contained in:
@@ -2,6 +2,9 @@
|
||||
{
|
||||
public static class Format
|
||||
{
|
||||
// Characters which need escaping
|
||||
private static string[] SensitiveCharacters = { "*", "_", "~", "`", "\\" };
|
||||
|
||||
/// <summary> Returns a markdown-formatted string with bold formatting. </summary>
|
||||
public static string Bold(string text) => $"**{text}**";
|
||||
/// <summary> Returns a markdown-formatted string with italics formatting. </summary>
|
||||
@@ -19,5 +22,15 @@
|
||||
else
|
||||
return $"`{text}`";
|
||||
}
|
||||
|
||||
/// <summary> Sanitizes the string, safely escaping any Markdown sequences. </summary>
|
||||
public static string Sanitize(string text)
|
||||
{
|
||||
foreach (string unsafeChar in SensitiveCharacters)
|
||||
{
|
||||
text = text.Replace(unsafeChar, $"\\{unsafeChar}");
|
||||
}
|
||||
return text;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user