https://github.com/smallhelm/ansi-style-parser
Parse ansi colors and styles
https://github.com/smallhelm/ansi-style-parser
Last synced: 10 months ago
JSON representation
Parse ansi colors and styles
- Host: GitHub
- URL: https://github.com/smallhelm/ansi-style-parser
- Owner: smallhelm
- License: mit
- Created: 2016-04-26T16:13:14.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2023-03-08T04:37:50.000Z (about 3 years ago)
- Last Synced: 2024-11-10T11:33:16.743Z (over 1 year ago)
- Language: JavaScript
- Size: 17.6 KB
- Stars: 10
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ansi-style-parser
Parse ANSI colors and styles
## Install
`npm install ansi-style-parser`
## Usage
```js
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:
```js
[ { styles: [],
text: 'Some ' },
{ styles: [ 'bold', 'green' ],
text: 'styled ' },
{ styles: [ 'bold', 'green', 'underline', 'bgBlack' ],
text: 'text' },
{ styles: [ 'bold', 'red' ],
text: '!' } ]
```
## License
MIT