mirror of
https://github.com/spectreconsole/spectre.console.git
synced 2025-10-25 15:19:23 +00:00
27 lines
734 B
C#
27 lines
734 B
C#
namespace Spectre.Console
|
|
{
|
|
/// <summary>
|
|
/// Contains extension methods for <see cref="string"/>.
|
|
/// </summary>
|
|
public static class StringExtensions
|
|
{
|
|
/// <summary>
|
|
/// Converts the string to something that is safe to
|
|
/// use in a markup string.
|
|
/// </summary>
|
|
/// <param name="text">The text to convert.</param>
|
|
/// <returns>A string that is safe to use in a markup string.</returns>
|
|
public static string SafeMarkup(this string text)
|
|
{
|
|
if (text == null)
|
|
{
|
|
return string.Empty;
|
|
}
|
|
|
|
return text
|
|
.Replace("[", "[[")
|
|
.Replace("]", "]]");
|
|
}
|
|
}
|
|
}
|