Table of Contents

Method RenderToAnsi

Namespace
Terminal.Gui.Views
Assembly
Terminal.Gui.dll

RenderToAnsi(string?, int)

Renders the current Text (or the supplied markdown) to an ANSI escape-sequence string suitable for writing directly to a terminal.

public string RenderToAnsi(string? markdown = null, int width = 80)

Parameters

markdown string

Optional markdown text to render. If null, uses the current Text.

width int

The target column width for word-wrapping. Defaults to 80. Clamped to the range [Terminal.Gui.Views.Markdown.MIN_WRAP_WIDTH, 4096].

Returns

string

A string containing ANSI escape sequences that reproduce the styled markdown output.

Remarks

This method does not require Application to be initialized. It creates a temporary headless ANSI driver internally, performs layout and drawing into an off-screen buffer, and returns the ANSI representation.

Configuration properties set on this instance — SyntaxHighlighter, MarkdownPipeline, UseThemeBackground, and ShowHeadingPrefix — are copied to the temporary view used for rendering. Copy buttons (ShowCopyButtons) are always disabled for ANSI output because they are interactive-only controls.