Small library to convert terminal output to html code.
This project is licensed under AGPL-3.0. See the LICENSE
file for more informations.
Basic example:
import { TerminalState, defaultTerminalState, term2html } from '../src/term2html';
const state: TerminalState = defaultTerminalState();
const text: string = '\u001B[31mhello\u001B[0m';
const html: string = term2html(text, state);
Note that term2html
always needs a state supplied; with this you can call this multiple times to transform chunks of text, without losing the current state (styles and colors).
The generated html needs some css to work; most of it is in term2html.css
inside the package.
Other then that it needs the actual colors for the 16 color palett (2 x 8 colors); they are retrieved via css variables:
-
--term2html-cX
whereX
is between 0 and 7 (inclusive) -
--term2html-bcX
whereX
is between 0 and 7 (inclusive) (brighter colors)
One example is contained with the term2html-solarized-colors.css
file, that configures the colors after the solarized color theme.
CSI codes (\u001B[?m
):
- bold, italic, underline, blinking and invisible (hidden)
- foreground & background colors (8-colors, 16-colors, indexed 256-colors, rgb)
- underline colors (indexed 256-colors, rgb)
- color reset for all color types