Skip to content
ConsoleMonster

API Reference

Class

ConsoleExporter

Namespace ConsoleMonster.Export
Assembly ConsoleMonster
Modifiers static

Exports a widget, a rendered frame or a live-session snapshot to self-contained HTML (inline CSS, selectable text, a light and a dark rendering that follow prefers-color-scheme), SVG (crisp shapes for box, block and braille characters, selectable text, no external assets) or plain text. Cell geometry is kept exactly: every glyph sits on the grid, colours and styles are kept, and OSC 8 links become links (web and mail links only).

Inheritance

  • Object
  • ConsoleExporter

Methods

Export 2 overloads
public static String Export(IWidget widget, ExportFormat format, ExportOptions? options = null) #
Returns: String

Exports a widget in a format.

Parameters

widget ConsoleMonster.Layout.IWidget requiredposition: 0
The widget.
format ConsoleMonster.Export.ExportFormat requiredposition: 1
Html, Svg or Text.
options ConsoleMonster.Export.ExportOptions? = null optionalposition: 2
The options.

Returns

The exported document.

public static String Export(CellBuffer frame, ExportFormat format, ExportOptions? options = null) #
Returns: String

Exports a frame in a format.

Parameters

frame ConsoleMonster.Canvas.CellBuffer requiredposition: 0
The frame.
format ConsoleMonster.Export.ExportFormat requiredposition: 1
Html, Svg or Text.
options ConsoleMonster.Export.ExportOptions? = null optionalposition: 2
The options.

Returns

The exported document.

public static ExportFormat FormatFor(String path) #
Returns: ExportFormat

The format a file extension implies.

Parameters

path System.String requiredposition: 0
The path.

Returns

Html for .html/.htm, Svg for .svg, Asciicast for .cast, Text otherwise.

public static CellBuffer Render(IWidget widget, ExportOptions options, ITheme theme) #
Returns: CellBuffer

Renders a widget the way an export does (fixed size, the export's glyph tier and colour depth).

Parameters

widget ConsoleMonster.Layout.IWidget requiredposition: 0
The widget.
options ConsoleMonster.Export.ExportOptions requiredposition: 1
The options.
theme ConsoleMonster.Styling.ITheme requiredposition: 2
The theme.

Returns

The frame.

public static Void Save(IWidget widget, String path, ExportFormat? format = null, ExportOptions? options = null) #
Returns: Void

Writes an export to a file as UTF-8 without a byte order mark.

Parameters

widget ConsoleMonster.Layout.IWidget requiredposition: 0
The widget.
path System.String requiredposition: 1
The file.
format ConsoleMonster.Export.ExportFormat? = null optionalposition: 2
The format; null picks it from the extension (.html/.htm, .svg, anything else text).
options ConsoleMonster.Export.ExportOptions? = null optionalposition: 3
The options.
ToHtml 3 overloads
public static String ToHtml(IWidget widget, ExportOptions? options = null) #
Returns: String

Exports a widget as an HTML page.

Parameters

widget ConsoleMonster.Layout.IWidget requiredposition: 0
The widget.
options ConsoleMonster.Export.ExportOptions? = null optionalposition: 1
Size, theme, font and window frame.

Returns

The HTML.

public static String ToHtml(CellBuffer frame, ExportOptions? options = null) #
Returns: String

Exports a rendered frame as an HTML page. Theme Auto keeps the frame's colours and lets default text follow the viewer.

Parameters

frame ConsoleMonster.Canvas.CellBuffer requiredposition: 0
The frame.
options ConsoleMonster.Export.ExportOptions? = null optionalposition: 1
Theme, font and window frame (the size is the frame's).

Returns

The HTML.

public static String ToHtml(LiveSession session, ExportOptions? options = null) #
Returns: String

Exports what a live session shows now as an HTML page.

Parameters

session ConsoleMonster.Live.LiveSession requiredposition: 0
The session.
options ConsoleMonster.Export.ExportOptions? = null optionalposition: 1
Theme, font and window frame.

Returns

The HTML.

ToSvg 3 overloads
public static String ToSvg(IWidget widget, ExportOptions? options = null) #
Returns: String

Exports a widget as an SVG image.

Parameters

widget ConsoleMonster.Layout.IWidget requiredposition: 0
The widget.
options ConsoleMonster.Export.ExportOptions? = null optionalposition: 1
Size, theme, font and window frame.

Returns

The SVG.

public static String ToSvg(CellBuffer frame, ExportOptions? options = null) #
Returns: String

Exports a rendered frame as an SVG image.

Parameters

frame ConsoleMonster.Canvas.CellBuffer requiredposition: 0
The frame.
options ConsoleMonster.Export.ExportOptions? = null optionalposition: 1
Theme, font and window frame.

Returns

The SVG.

public static String ToSvg(LiveSession session, ExportOptions? options = null) #
Returns: String

Exports what a live session shows now as an SVG image.

Parameters

session ConsoleMonster.Live.LiveSession requiredposition: 0
The session.
options ConsoleMonster.Export.ExportOptions? = null optionalposition: 1
Theme, font and window frame.

Returns

The SVG.

ToText 3 overloads
public static String ToText(IWidget widget, ExportOptions? options = null) #
Returns: String

Exports a widget as plain text (trailing spaces and empty last lines trimmed).

Parameters

widget ConsoleMonster.Layout.IWidget requiredposition: 0
The widget.
options ConsoleMonster.Export.ExportOptions? = null optionalposition: 1
Size and glyph tier.

Returns

The text.

public static String ToText(CellBuffer frame, ExportOptions? options = null) #
Returns: String

Exports a rendered frame as plain text.

Parameters

frame ConsoleMonster.Canvas.CellBuffer requiredposition: 0
The frame.
options ConsoleMonster.Export.ExportOptions? = null optionalposition: 1
Unused; for symmetry with the other formats.

Returns

The text.

public static String ToText(LiveSession session, ExportOptions? options = null) #
Returns: String

Exports what a live session shows now as plain text.

Parameters

session ConsoleMonster.Live.LiveSession requiredposition: 0
The session.
options ConsoleMonster.Export.ExportOptions? = null optionalposition: 1
Unused; for symmetry with the other formats.

Returns

The text.

Properties

public static String PlayerScript { get; } #

The recording player script (a native asset, player.js): include it once on a page with ConsoleExporter.PlayerStyles, then mark each player with data-cm-recording pointing at data from Recording.ExportPlayerData (a URL, or #id of an inline application/json script element); data-cm-autoplay asks to autoplay. The HTML recording export embeds it.

public static String PlayerStyles { get; } #

The recording player styles (a native asset, player.css); see ConsoleExporter.PlayerScript.