ConsoleExporter
ConsoleMonster.Export
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), plain text. HTML, SVG and text keep cell geometry: 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
public static OutputFormat FormatFor(string path) #The format a file extension implies.
Parameters
- path string
- The path.
Returns
OutputFormat Html for .html/.htm, Svg for .svg, Asciicast for .cast, Markdown for .md/.markdown, Png for .png, Text otherwise.public static int MeasureContentColumns(CellBuffer frame) #Measures occupied columns across all rows, including wide glyphs, painted backgrounds and decorations. An empty screen retains one column.
Parameters
- frame ConsoleMonster.Canvas.CellBuffer
Returns
intpublic static int MeasureContentRows(CellBuffer frame) #Measures occupied rows, including painted backgrounds, without trailing empty terminal rows. An empty screen retains one row.
Parameters
- frame ConsoleMonster.Canvas.CellBuffer
Returns
intpublic static ExportFrameSize MeasureFrame(int columns, int rows, ExportOptions? options = null) #Measures the same rounded cell geometry, padding and chrome used by SVG exports.
Parameters
- columns int
- rows int
- options ConsoleMonster.Export.ExportOptions? = null
Returns
ExportFrameSizepublic static CellBuffer Render(IWidget widget, ExportOptions options, ITheme theme) #Renders a widget the way an export does (fixed size, the export's glyph tier and colour depth).
Parameters
- widget ConsoleMonster.Layout.IWidget
- The widget.
- options ConsoleMonster.Export.ExportOptions
- The options.
- theme ConsoleMonster.Styling.ITheme
- The theme.
public static string ToHtml(IWidget widget, ExportOptions? options = null) #Exports a widget as an HTML page.
Parameters
- widget ConsoleMonster.Layout.IWidget
- The widget.
- options ConsoleMonster.Export.ExportOptions? = null
- Size, theme, font and window frame.
Returns
string The HTML.public static string ToHtml(CellBuffer frame, ExportOptions? options = null) #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
- The frame.
- options ConsoleMonster.Export.ExportOptions? = null
- Theme, font and window frame (the size is the frame's).
Returns
string The HTML.public static string ToHtml(LiveSession session, ExportOptions? options = null) #Exports what a live session shows now as an HTML page.
Parameters
- session ConsoleMonster.Live.LiveSession
- The session.
- options ConsoleMonster.Export.ExportOptions? = null
- Theme, font and window frame.
Returns
string The HTML.public static string ToSvg(IWidget widget, ExportOptions? options = null) #Exports a widget as an SVG image.
Parameters
- widget ConsoleMonster.Layout.IWidget
- The widget.
- options ConsoleMonster.Export.ExportOptions? = null
- Size, theme, font and window frame.
Returns
string The SVG.public static string ToSvg(CellBuffer frame, ExportOptions? options = null) #Exports a rendered frame as an SVG image.
Parameters
- frame ConsoleMonster.Canvas.CellBuffer
- The frame.
- options ConsoleMonster.Export.ExportOptions? = null
- Theme, font and window frame.
Returns
string The SVG.public static string ToSvg(LiveSession session, ExportOptions? options = null) #Exports what a live session shows now as an SVG image.
Parameters
- session ConsoleMonster.Live.LiveSession
- The session.
- options ConsoleMonster.Export.ExportOptions? = null
- Theme, font and window frame.
Returns
string The SVG.public static string ToText(IWidget widget, ExportOptions? options = null) #Exports a widget as plain text (trailing spaces and empty last lines trimmed).
Parameters
- widget ConsoleMonster.Layout.IWidget
- The widget.
- options ConsoleMonster.Export.ExportOptions? = null
- Size and glyph tier.
Returns
string The text.public static string ToText(CellBuffer frame, ExportOptions? options = null) #Exports a rendered frame as plain text.
Parameters
- frame ConsoleMonster.Canvas.CellBuffer
- The frame.
- options ConsoleMonster.Export.ExportOptions? = null
- Unused; for symmetry with the other formats.
Returns
string The text.public static string ToText(LiveSession session, ExportOptions? options = null) #Exports what a live session shows now as plain text.
Parameters
- session ConsoleMonster.Live.LiveSession
- The session.
- options ConsoleMonster.Export.ExportOptions? = null
- Unused; for symmetry with the other formats.
Returns
string The text.Inherited Methods
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.ToPlayerData (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.