Table of Contents

Method MarkupInterpolated

Namespace
Ploch.CommandLine.Spectre.Output
Assembly
Ploch.CommandLine.Spectre.dll

MarkupInterpolated(FormattableString)

Writes an interpolated string as Spectre.Console markup: the literal parts are parsed as markup and the string values in the holes are escaped, so a string containing [ is printed rather than parsed.

[SuppressMessage("ReSharper", "UnusedMethodReturnValue.Global", Justification = "Part of the public API: the return value exists for chaining by consumers, whether or not the library chains it.")]
IOutput MarkupInterpolated(FormattableString value)

Parameters

value FormattableString

The interpolated string, such as $"[green]{path}[/]".

Returns

IOutput

The current output instance for method chaining.

Remarks

This is the safe way to put caller strings inside markup: the same string built with string.Format and passed to Markup(string) would have its values parsed as tags. Only string holes are escaped (Spectre.Console's rule): a value of any other type is formatted by string.Format and its text is parsed as markup, so convert such a value to a string first ({value.ToString()}) when its text can contain [; do not Markup.Escape it as well, because a string hole is escaped here already. The holes are formatted with the current culture; use Write<TMessage>(TMessage, IFormatProvider?) with a FormattableString and a format provider to control that.

Exceptions

ArgumentNullException

value is null.