Skip to content
ConsoleMonster
Cmdlet

Write-ConsoleMarkup

Module ConsoleMonster
Inputs
System.String

Writes Spectre-compatible markup as styled text.

Syntax

Write-ConsoleMarkup [-NoNewLine] [-Text] <String> [<CommonParameters>]
#
Parameter set: All Parameter Sets

Description

Writes Spectre-compatible markup as styled text.

Supports [bold], [italic], [underline], the 256-colour palette names ([red], [cadetblue], [grey50], [deepskyblue3]; in markup [darkred] is the palette colour, [console.darkred] the ConsoleColor as Write-Host shows it), [#ff8800], [rgb(1,2,3)], [white on navy], links ([link=https://example.com]text[/] or [link]https://example.com[/], clickable in Windows Terminal and VS Code) and theme tokens ([pass], [fail], [warn], [muted], [accent]). Escape brackets by doubling them ([[ and ]]) or with [ConsoleMonster.Text.Markup]::Escape($value). A tag that is not a known style is removed and its text kept when a [/] closes it; an unclosed unknown tag stays literal. Colours degrade to 256 or 16 colours, or none, as the terminal requires.

Examples

Authored help example

EXAMPLE 1

Write-ConsoleMarkup -Text 'Value'

Parameters

-NoNewLine SwitchParameter optional
Leaves the line open, as Write-Host -NoNewline does. Redirected output still gets plain text.
-Text String requiredposition: 0pipeline: True (ByValue)
The markup.

Common Parameters

This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.

For more information, see about_CommonParameters.