Skip to content
ConsoleMonster

Coming from Spectre.Console

Spectre.Console concepts and their ConsoleMonster counterparts, with the markup dialect the two share and where it differs.

Spectre.Console is a widely used .NET library for rich console output, and its markup syntax is familiar to many .NET developers. ConsoleMonster is a separate library with its own parser and renderer. Its markup follows the same dialect, so a reader who knows one can read the other. This page maps the concepts from one to the other and notes where they behave differently.

markup.ps1 PowerShell 7.6
Markup in the Spectre.Console dialect: cadetblue, grey50, deepskyblue3
#ff8800, rgb(120,200,90), color(208) and  theme roles 
[brackets] are literal, unknown tags keep their text, and links use OSC 8
PowerShellmarkup.ps1
Write-ConsoleMarkup '[bold red]Markup[/] in the [italic]Spectre.Console[/] dialect: [cadetblue]cadetblue[/], [grey50]grey50[/], [deepskyblue3]deepskyblue3[/]'
Write-ConsoleMarkup '[#ff8800]#ff8800[/], [rgb(120,200,90)]rgb(120,200,90)[/], [color(208)]color(208)[/] and [white on fail] theme roles [/]'
Write-ConsoleMarkup '[[brackets]] are literal, [nosuchcolour]unknown tags[/] keep their text, and [link=https://consolemonster.dev]links[/] use OSC 8'
Write-ConsoleMarkup in PowerShell 7: palette names, hex and rgb() colours, theme roles as backgrounds, escaped brackets, an unknown tag and a link.

Markup

Spectre.ConsoleConsoleMonsterNotes
[bold], [dim], [italic], [underline], [strikethrough], [invert]the sameCombined the same way, as in [bold red on blue].
[/], [[ and ]]the same[/] closes the innermost tag.
Colour names, [#ff8800], [rgb(1,2,3)], [color(208)]the same, plus [208] and [default]Names are the 256 xterm names. A name that appears twice in the xterm list takes _1, _2, as in [blue3_1]. Colours are reduced to what the console can show.
[link=https://example.com]text[/], [link]…[/]the sameOSC 8 hyperlinks in terminals that support them, plain text elsewhere. Only absolute http, https, mailto and ftp targets link.
:emoji: shortcodesnot supportedWrite the emoji character itself; it is measured as two cells.
An unknown style is an errorremoved, its text keptAn unknown tag that is never closed stays literal, since it is most likely text such as [x]. Markup.Strict = true throws a FormatException instead, and Markup.Validate reports the first problem without throwing.
—theme roles: [pass], [fail], [warn], [muted], [accent] and othersRoles follow the active theme and also work as backgrounds ([white on fail]).

In markup, a colour name is the 256-colour palette name, so [darkred] is palette colour 52 and [grey] palette colour 8. ConsoleMonster's PowerShell cmdlets also take -Color and -BackgroundColor parameters, where a name keeps its Write-Host meaning. Either meaning can be asked for in either place: console.<name> is the ConsoleColor as Write-Host shows it ([console.darkred] in markup), and palette.<name> is the palette colour (-Color palette.darkred).

NameMarkup [name]-Color name
red / bluebright red / bright blue (ANSI 9 / 12)the same
darkred / darkbluepalette 52 / 18ANSI red / blue (1 / 4)
grey, grayANSI 8ANSI 7 (Write-Host Gray)
darkgrayANSI 8ANSI 8

Writing output

Spectre.ConsoleConsoleMonsterNotes
AnsiConsole.Write(renderable)Terminal.Write(widget)Widgets measure themselves for the console width.
AnsiConsole.Markup(...) / MarkupLine(...)Terminal.WriteMarkup(...) / Terminal.WriteMarkupLine(...)WriteMarkup does not end the line.
Markup.Escape(value)Markup.Escape(value) or value.EscapeMarkup()
AnsiConsole.MarkupInterpolated($"...")Markup.Interpolate($"...")Escapes every argument after its format specifier.
AnsiConsole.Clear()Terminal.Clear()
AnsiConsole.WriteException(ex)Terminal.Write(new ExceptionView(ex))
AnsiConsole.Profile.CapabilitiesCapabilityDetector and TerminalProfileColour depth, glyph tier, links and interactivity; see capability detection.
Terminal.WriteMarkupLine(Markup.Interpolate($"[pass]{server}[/] answered in [muted]{elapsed:N1}s[/]"));

Widgets

Spectre.ConsoleConsoleMonsterNotes
TableTableColumns carry a priority, a minimum and maximum width and an overflow rule. Tables fit the console width, and below a set width rows become cards; see tables.
TreeTree
PanelPanel
RuleRule
BarChart / BreakdownChartBarChart / StackedBarConsoleMonster also has Sparkline, Histogram and LineChart.
Columns, Rows, Grid, Padder, AlignColumns, Rows, Grid, Stack, Align
LayoutDashboard and DashboardBuilderNamed panels in a header, body and footer, sized to the window.
FigletTextLogoPixel lettering in a built-in font.
CanvasPixelCanvas, BrailleCanvas, HalfBlockCanvas, CharacterCanvas
JsonText (Spectre.Console.Json)CodeView with JsonHighlighter, Format-ConsoleJson in PowerShell
Calendar—No counterpart.

The widget gallery shows each ConsoleMonster widget with its C# and PowerShell source.

Status, progress and live output

Spectre.ConsoleConsoleMonsterNotes
AnsiConsole.Status().Start(...)Terminal.Status("...", ctx =&gt; ...), Terminal.StatusAsync
AnsiConsole.Progress().Start(...)Lanes and ProgressBar, usually in a LiveSessionProgress columns are a column model; see live sessions.
AnsiConsole.Live(renderable).Start(ctx =&gt; ...)LiveSessionUpdates are events addressed to widgets by name and can come from any thread.
AnsiConsole.Record() / ExportHtml()ConsoleExporter.ToHtml(...), LiveRecorderExports a frame, or records a session's events for replay and export.
Terminal.Status("Resolving…", ctx => {
    foreach (string dc in controllers) {
        ctx.Update(Markup.Interpolate($"Querying [accent]{dc}[/]"));
        Query(dc);
    }
});

Terminal.Status draws a one-line spinner as an inline live area. Console output written meanwhile scrolls above it, and the line is removed when the work ends, also when it throws. Redirected output, CI logs and plain mode get each new status text once, as a plain line.

Prompts

Spectre.ConsoleConsoleMonster
TextPrompt<T>TextPrompt, NumberPrompt, PathPrompt
SelectionPrompt<T>SelectPrompt<T>
MultiSelectionPrompt<T>MultiSelectPrompt<T>
ConfirmationPromptConfirmPrompt, TypedConfirmPrompt

ConsoleMonster also has forms, menus and a grid; the interactive page shows them.

Outside this mapping

  • Spectre.Console.Cli parses command lines and maps them to commands. ConsoleMonster has no command-line parser and can be used next to one.
  • Testing. Spectre.Console.Testing provides a TestConsole. ConsoleMonster renders to a fixed profile in memory: TerminalProfile.Fixed with ConsoleExporter.ToText, and ScreenCapture with scripted keys for prompts.

Edit this page on GitHub