Table of Contents

Class HtmlSink

Namespace
ItTiger.TigerCli.Terminal
Assembly
ItTiger.TigerCli.dll
An ICliRenderSink that renders TigerCli text segments to deterministic HTML — for snapshot tests (internal and external) and for generating documentation examples from real rendering. It is not a browser UI framework: output is plain <pre class="tigercli"> + <span> (and optionally <a>) markup.

This sink renders the CliCharStyle it receives; it does not reconstruct the original semantic token (e.g. [Heading]) once it has been resolved to a concrete style. Text decorations and the link role map to stable CSS classes (tc-bold, tc-italic, tc-underline, tc-link); foreground/background colours map to a deterministic inline #RRGGBB hex derived from CliColorPalette (the 256-colour palette has no stable CSS class names). Text content is HTML-escaped, attribute values are attribute-escaped, and whitespace/line breaks are preserved via the <pre> wrapper. No ANSI is ever emitted.

Like the ANSI sink, link text is always written visibly and copyably. In Anchor a non-empty, safe HyperlinkTarget is additionally wrapped in <a href="…">; an empty or unsafe target (control characters, or a javascript:/vbscript:/data: scheme) falls back to a styled span.

public sealed class HtmlSink : ICliRenderSink
Inheritance
HtmlSink
Implements
Inherited Members

Constructors

HtmlSink(TextWriter, HtmlSinkOptions?)

Creates an HTML sink writing to writer. When options is null, the conservative defaults (HtmlSinkOptions) are used.
public HtmlSink(TextWriter writer, HtmlSinkOptions? options = null)

Parameters

writer TextWriter
options HtmlSinkOptions

Properties

MaxHeight

Hard height constraint reported to grid measurement, or null when unbounded.
public int? MaxHeight { get; }

Property Value

int?

MaxWidth

Hard width constraint reported to grid measurement, or null when unbounded.
public int? MaxWidth { get; }

Property Value

int?

SoftMaxHeight

Soft height constraint reported to grid measurement, or null when unbounded.
public int? SoftMaxHeight { get; }

Property Value

int?

SoftMaxWidth

The optional emulated terminal width used during grid measurement.
public int? SoftMaxWidth { get; }

Property Value

int?

WindowTitle

The most recently captured, sanitized window title.
public string? WindowTitle { get; }

Property Value

string

Methods

Flush()

Closes the optional wrapper and flushes the underlying writer.
public void Flush()

NewLine()

Writes a deterministic line feed to the HTML output.
public void NewLine()

Reset()

Resets sink state; this sink has no buffered style state to clear.
public void Reset()

SetWindowTitle(string)

Captures a sanitized window title without writing terminal controls.
public void SetWindowTitle(string title)

Parameters

title string
The window title to capture.

Write(CliTextSegment)

Writes a styled text segment as escaped HTML.
public void Write(CliTextSegment segment)

Parameters

segment CliTextSegment
The styled text segment to write.