Skip to content

smallhelm/ansi-style-parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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