libvt.format

Plain-text, ANSI/DEC VT, and HTML formatters for terminal snapshots.

class libvt.format.Formatter
class libvt.format.Formatter

Bases: object

Serialize a Snapshot to plain text, VT, or HTML.

Replay VT output into a fresh Terminal of the same size and profile. See format() for the VT export contract.

Examples

>>> from libvt.terminal import Formatter, OutputFormat, Terminal
>>> term = Terminal(rows=2, cols=8)
>>> term.feed(b"\x1b[31mhello world\x1b[0m")
>>> Formatter(OutputFormat.PLAIN, unwrap=True).format_snapshot(term.committed)
'hello world'
class libvt.format.OutputFormat
class libvt.format.OutputFormat

Bases: StrEnum

Export target formats supported by Formatter.