Class MarkupParser
- Namespace
- SharpConsoleUI.Parsing
- Assembly
- SharpConsoleUI.dll
Parses Spectre-compatible markup strings directly into Cell sequences, bypassing the ANSI roundtrip. Supports [bold red on blue]text[/] syntax, [rgb(r,g,b)], [#RRGGBB], and nested/closing tags.
public static class MarkupParser
- Inheritance
-
MarkupParser
- Inherited Members
Methods
Escape(string)
Escapes brackets in plain text so they won't be interpreted as markup.
public static string Escape(string text)
Parameters
textstring
Returns
Parse(string, Color, Color)
Parses markup into a sequence of cells using the given default colors.
public static List<Cell> Parse(string markup, Color defaultFg, Color defaultBg)
Parameters
Returns
ParseLines(string, int, Color, Color)
Parses markup with word-wrapping into multiple lines of cells. Carries the active style stack across line breaks.
public static List<List<Cell>> ParseLines(string markup, int width, Color defaultFg, Color defaultBg)
Parameters
markupstringMarkup string to parse and wrap.
widthintMaximum width per line in visible characters.
defaultFgColorDefault foreground color.
defaultBgColorDefault background color.
Returns
Remove(string)
Removes all markup tags from a string, returning only the plain text content. Escaped brackets ([[, ]]) are converted to single brackets.
public static string Remove(string markup)
Parameters
markupstring
Returns
StripLength(string)
Returns the visible character length of a markup string (strips all tags).
public static int StripLength(string markup)
Parameters
markupstring
Returns
Truncate(string, int)
Truncates a markup string to maxLength visible characters, preserving and properly closing all tags.
public static string Truncate(string markup, int maxLength)