mirror of
				https://github.com/nsnail/spectre.console.git
				synced 2025-11-04 10:35:27 +08:00 
			
		
		
		
	Add Markdown.Escape method
This commit is contained in:
		
				
					committed by
					
						
						Patrik Svensson
					
				
			
			
				
	
			
			
			
						parent
						
							70fc14e9cd
						
					
				
				
					commit
					1410cba6c5
				
			@@ -1,3 +1,5 @@
 | 
			
		||||
using System;
 | 
			
		||||
 | 
			
		||||
namespace Spectre.Console
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
@@ -6,12 +8,11 @@ namespace Spectre.Console
 | 
			
		||||
    public static class StringExtensions
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Converts the string to something that is safe to
 | 
			
		||||
        /// use in a markup string.
 | 
			
		||||
        /// Escapes text so that it won’t be interpreted as markup.
 | 
			
		||||
        /// </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)
 | 
			
		||||
        /// <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)
 | 
			
		||||
            {
 | 
			
		||||
@@ -22,5 +23,16 @@ namespace Spectre.Console
 | 
			
		||||
                .Replace("[", "[[")
 | 
			
		||||
                .Replace("]", "]]");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <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>
 | 
			
		||||
        [Obsolete("Use EscapeMarkup extension instead.", false)]
 | 
			
		||||
        public static string SafeMarkup(this string text)
 | 
			
		||||
        {
 | 
			
		||||
            return EscapeMarkup(text);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user