Method RenderToAnsi
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
markdownstringOptional markdown text to render. If null, uses the current Text.
widthintThe 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.