ansi-html
An elegant lib that converts the chalked (ANSI) text to HTML.
Last updated 9 years ago by tjatse .
Apache, Version 2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ npm install ansi-html 
SYNC missed versions from official npm registry.

ansi-html NPM version Build Status

An elegant lib that converts the chalked (ANSI) text to HTML.

Coverage

  • All styles of chalk (100%) and colors.
  • There are over 150 randomized test cases under test.

Installation

$ npm install ansi-html

Usage

var ansiHTML = require('ansi-html');
var str = ansiHTML('[ANSI_TEXT]');

e.g.:

var chalk = require('chalk');

var str = chalk.bold.red('foo') + ' bar';
console.log('[ANSI]', str)
console.log('[HTML]', ansiHTML(str));

See complete examples under test / examples directory.

Set Colors

ansiHTML.setColors({
  reset: ['555', '666'], // FOREGROUND-COLOR or [FOREGROUND-COLOR] or [, BACKGROUND-COLOR] or [FOREGROUND-COLOR, BACKGROUND-COLOR]
  black: 'aaa',	// String
  red: 'bbb',
  green: 'ccc',
  yellow: 'ddd',
  blue: 'eee',
  magenta: 'fff',
  cyan: '999',
  lightgrey: '888',
  darkgrey: '777'
});

Reset

ansiHTML.reset();

Exposed Tags

var openTags = ansiHTML.tags.open;
var closeTags = ansiHTML.tags.close;

Test

$ npm install -l
$ npm test

Current Tags

  • 0.0.9                                ...           latest (3 years ago)

9 Versions

  • 0.0.9                                ...           3 years ago
  • 0.0.8                                ...           3 years ago
  • 0.0.7                                ...           8 years ago
  • 0.0.6                                ...           8 years ago
  • 0.0.5                                ...           9 years ago
  • 0.0.4                                ...           10 years ago
  • 0.0.3                                ...           10 years ago
  • 0.0.2                                ...           10 years ago
  • 0.0.1                                ...           10 years ago

© 2010 - cnpmjs.org x YWFE | Home | YWFE