npm.io
3.0.2 • Published 3 years ago

ansi-style-parser

Licence
MIT
Version
3.0.2
Deps
1
Size
6 kB
Vulns
0
Weekly
0
DeprecatedThis package is deprecated

ansi-style-parser

Parse ANSI colors and styles

Install

npm install ansi-style-parser

Usage

var c = require('chalk');
var parser = require('ansi-style-parser');

var txt = 'Some ';
txt += c.bold.green('styled ' + c.underline.bgBlack('text') + c.red('!'));

console.log(parser(txt));

Output:

[ { styles: [],
    text: 'Some ' },

  { styles: [ 'bold', 'green' ],
    text: 'styled ' },

  { styles: [ 'bold', 'green', 'underline', 'bgBlack' ],
    text: 'text' },

  { styles: [ 'bold', 'red' ],
    text: '!' } ]

License

MIT

Keywords