Added support for single-line code blocks

This commit is contained in:
RogueException
2015-10-15 03:27:29 -03:00
parent cf352dfda4
commit 2d54504de8

View File

@@ -103,7 +103,12 @@ namespace Discord
/// <summary> Returns a markdown-formatted string with strikeout formatting, optionally escaping the contents. </summary>
public static string Code(string text, string language = null, bool escape = true)
=> $"```{language ?? ""}\n{(escape ? Escape(text) : text)}\n```";
{
if (text.Contains("\n"))
return $"```{language ?? ""}\n{(escape ? Escape(text) : text)}\n```";
else
return $"`{(escape ? Escape(text) : text)}`";
}
/// <summary> Returns a markdown-formatted string with multiple formatting, optionally escaping the contents. </summary>
public static string Multiple(string text, bool escape = true,