Method Markup
- Namespace
- Ploch.CommandLine.Spectre.Output
- Assembly
- Ploch.CommandLine.Spectre.dll
Markup(string)
Writes a string that is parsed as Spectre.Console markup to the output.
IOutput Markup(string value)
Parameters
valuestringThe markup to render, such as
"[green]ok[/]".
Returns
- IOutput
The current output instance for method chaining.
Examples
output.Markup("[bold]Done:[/] ");
output.Markup($"[green]{Markup.Escape(path)}[/]"); // or: output.MarkupInterpolated($"[green]{path}[/]")
Remarks
This is the explicit opt-in to markup parsing: Write<TMessage>(TMessage, IFormatProvider?) and
WriteLine<TMessage>(TMessage) write a string verbatim. Every [ in
value is read as the start of a style tag, so text that came from outside the source
file - a path, a user name, a configuration value - must be escaped with
Escape(string) first, or passed through MarkupInterpolated(FormattableString),
which escapes its string interpolation holes for you.
Exceptions
- ArgumentNullException
valueis null.- InvalidOperationException
valueis not well-formed markup, for example an unknown style name or an unbalanced tag.