Björn f184cd7e2a | 4 years ago | |
---|---|---|
.. | ||
bin | 4 years ago | |
.npmignore | 4 years ago | |
LICENSE | 4 years ago | |
README.md | 4 years ago | |
index.js | 4 years ago | |
package.json | 4 years ago |
An elegant lib that converts the chalked (ANSI) text to HTML.
$ npm install ansi-html
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.
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'
});
ansiHTML.reset();
var openTags = ansiHTML.tags.open;
var closeTags = ansiHTML.tags.close;
$ npm install -l
$ npm test