ansi-to-html

Convert ansi escaped text streams to html.

npm install ansi-to-html
56 downloads in the last day
539 downloads in the last week
2 561 downloads in the last month

Ansi to Html

This is a port of the ansi to html converter from bcat to Javascript.

It has a few additions:

  • The API has been altered to accept options in the constructor, and input in toHtml().
  • ANSI codes for setting the foreground or background color to default are handled. Default foreground and background colors can be set with the fg and bg options.
  • Newlines are converted to <br/> if the newline option is true

Installation

npm install ansi-to-html

Usage

var Convert = require('ansi-to-html');

var convert = new Convert()

console.log(convert.toHtml('\x1b[30mblack\x1b[37mwhite'));

/*
    prints:
    <span style="color:#000">black<span style="color:#AAA">white</span></span>
*/
npm loves you