TTY format
The TTY format is an ASCII text format designed to provide formatting controls within the capabilities of the original ASCII C0 control code set and with respect to the functionality of teletypewriter style printers. The recommended file extension for such files is .tty.
Features
TTY text provides a subset of the usual "rich text" features, namely bold text, underlining, and differential colouring. Bold text is accomplished through a string of backspaces followed by a repeating of the bolded substring, mimicking the way a typewriter would bold text by rewriting it over itself. Underlining is accomplished with the same lengthwise backspacing but followed with an equally long string of underscore characters instead of the original text. Differential colouring uses the ASCII codes shift in and shift out: one "shifts out" to the alternate colour, which is conventionally red but may be any colour the rendering user so chooses, and can later "shift back in" to the default black. Red was chosen as it has good contrast in both print and digital display.
Editors displaying TTY text should support the full dynamics of the following ASCII control codes:
- Backspace (
BS,0x08) - Horizontal Tabulation (
HT,0x09) - Line Feed (
LF,0x0A) - Vertical Tabulation (
VT,0x0B) - Form Feed (
FF,0x0C) - Carriage Return (
CR,0x0D) - Shift Out (
SO,0x0E) - Shift In (
SI,0x0F)
Overlap
This means the TTY format makes it possible to overlap text on top of itself within a single line, creating a kind of spooky cryptic effect normally not possible with any text rendering system. Backspaces can be used to achieve this piecewise or a carriage return may be issued that resets the write head to the line start.
Rendering
The principal method of rendering is supposed to be inside a text editor, preferably one used for code editing. Writing a parser for TTY should be pretty straightforward, as it is almost entirely a task of simulating the motions of the teletypewriter according to this spec. Of course, TTY is also designed to be piped directly to 9-pin serial printers unmodified.
Purpose
TTY exists to provide a better literate experience within the rigid and well-defined contours of monospaced teletypewriter printing. It is a low-level format that provides no "truly" rich-text experiences such as hyperlinking, tables of contents, organisational grouping tools, or diagrams of anything except those made in ASCII.
Eventually, TTY will be targeted by a roff-like "high level" format that provides such things with respect to the intended output being compatible with TTY, while also providing rendering to more conventional formats such as XHTML, PostScript, DVI and PDF.
Warts and specification
Light Lempel–Ziv compression (such as LZ4) can be used (outside the scope of the file format itself) to overcome the nominal "waste" of repeating characters to encode formatting. Such algorithms are supersets of run-length encoding using dictionaries and thus are virtually ideal for compressing such strings.
Eventually a formal specification can be put out fully describing TTY once the need arises, but for now it's more important to get it into use so that technical document authorship can commence in earnest with respect to web browsers, PDFs and printed documents alike.