Last change
on this file since bdd6491 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.4 KB
|
Line | |
---|
1 | ansi-html [![NPM version](https://badge.fury.io/js/ansi-html.svg)](http://badge.fury.io/js/ansi-html) [![Build Status](https://travis-ci.org/Tjatse/ansi-html.svg?branch=master)](https://travis-ci.org/Tjatse/ansi-html)
|
---|
2 | =========
|
---|
3 | An elegant lib that converts the chalked (ANSI) text to HTML.
|
---|
4 |
|
---|
5 | # Coverage
|
---|
6 | - All styles of [chalk](https://github.com/sindresorhus/chalk) (100%) and [colors](https://github.com/Marak/colors.js).
|
---|
7 | - There are over **150** randomized test cases under `test`.
|
---|
8 |
|
---|
9 | # Installation
|
---|
10 | ```
|
---|
11 | $ npm install ansi-html
|
---|
12 | ```
|
---|
13 |
|
---|
14 | # Usage
|
---|
15 | ```javascript
|
---|
16 | var ansiHTML = require('ansi-html');
|
---|
17 | var str = ansiHTML('[ANSI_TEXT]');
|
---|
18 | ```
|
---|
19 |
|
---|
20 | e.g.:
|
---|
21 | ```javascript
|
---|
22 | var chalk = require('chalk');
|
---|
23 |
|
---|
24 | var str = chalk.bold.red('foo') + ' bar';
|
---|
25 | console.log('[ANSI]', str)
|
---|
26 | console.log('[HTML]', ansiHTML(str));
|
---|
27 | ```
|
---|
28 |
|
---|
29 | See complete examples under `test` / `examples` directory.
|
---|
30 |
|
---|
31 | # Set Colors
|
---|
32 | ```javascript
|
---|
33 | ansiHTML.setColors({
|
---|
34 | reset: ['555', '666'], // FOREGROUND-COLOR or [FOREGROUND-COLOR] or [, BACKGROUND-COLOR] or [FOREGROUND-COLOR, BACKGROUND-COLOR]
|
---|
35 | black: 'aaa', // String
|
---|
36 | red: 'bbb',
|
---|
37 | green: 'ccc',
|
---|
38 | yellow: 'ddd',
|
---|
39 | blue: 'eee',
|
---|
40 | magenta: 'fff',
|
---|
41 | cyan: '999',
|
---|
42 | lightgrey: '888',
|
---|
43 | darkgrey: '777'
|
---|
44 | });
|
---|
45 | ```
|
---|
46 |
|
---|
47 | # Reset
|
---|
48 | ```javascript
|
---|
49 | ansiHTML.reset();
|
---|
50 | ```
|
---|
51 |
|
---|
52 | # Exposed Tags
|
---|
53 | ```javascript
|
---|
54 | var openTags = ansiHTML.tags.open;
|
---|
55 | var closeTags = ansiHTML.tags.close;
|
---|
56 | ```
|
---|
57 |
|
---|
58 | # Test
|
---|
59 | ```
|
---|
60 | $ npm install -l
|
---|
61 | $ npm test
|
---|
62 | ```
|
---|
Note:
See
TracBrowser
for help on using the repository browser.