mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-04-16 08:52:50 +08:00

Removed the verbs from all extension methods that manipulate properties which makes the API more succinct and easier to read. Also added implicit conversion from string to Style. As a good OSS citizen, I've obsoleted the old methods with a warning for now, so this shouldn't break anyone using the old methods.
26 lines
699 B
C#
26 lines
699 B
C#
namespace Spectre.Console
|
||
{
|
||
/// <summary>
|
||
/// Contains extension methods for <see cref="string"/>.
|
||
/// </summary>
|
||
public static class StringExtensions
|
||
{
|
||
/// <summary>
|
||
/// Escapes text so that it won’t be interpreted as markup.
|
||
/// </summary>
|
||
/// <param name="text">The text to escape.</param>
|
||
/// <returns>A string that is safe to use in markup.</returns>
|
||
public static string EscapeMarkup(this string text)
|
||
{
|
||
if (text == null)
|
||
{
|
||
return string.Empty;
|
||
}
|
||
|
||
return text
|
||
.Replace("[", "[[")
|
||
.Replace("]", "]]");
|
||
}
|
||
}
|
||
}
|