mirror of
				https://github.com/nsnail/spectre.console.git
				synced 2025-11-04 18:40:50 +08:00 
			
		
		
		
	Add Markdown.Escape method
This commit is contained in:
		
				
					committed by
					
						
						Patrik Svensson
					
				
			
			
				
	
			
			
			
						parent
						
							70fc14e9cd
						
					
				
				
					commit
					1410cba6c5
				
			@@ -199,7 +199,7 @@ namespace Spectre.Console
 | 
			
		||||
 | 
			
		||||
            if (ShowHeader)
 | 
			
		||||
            {
 | 
			
		||||
                var heading = new DateTime(Year, Month, Day).ToString("Y", culture).SafeMarkup();
 | 
			
		||||
                var heading = new DateTime(Year, Month, Day).ToString("Y", culture).EscapeMarkup();
 | 
			
		||||
                table.Heading = new Title(heading, HeaderStyle);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,4 @@
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using Spectre.Console.Internal;
 | 
			
		||||
using Spectre.Console.Rendering;
 | 
			
		||||
@@ -46,5 +47,20 @@ namespace Spectre.Console
 | 
			
		||||
        {
 | 
			
		||||
            return ((IRenderable)_paragraph).Render(context, maxWidth);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <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 Escape(string text)
 | 
			
		||||
        {
 | 
			
		||||
            if (text is null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(text));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return text.EscapeMarkup();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user