• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..22-Nov-2021-

lib/H03-May-2022-108

README.mdH A D22-Nov-20212.1 KiB10171

package.jsonH A D22-Nov-20211.3 KiB6160

README.md

1# ansi-to-react
2
3This package convert ANSI escape codes to formatted text output for React.
4
5## Installation
6
7```
8$ yarn add ansi-to-react
9```
10
11```
12$ npm install --save ansi-to-react
13```
14
15## Usage
16
17### Basic
18
19The example below shows how we can use this package to render a string with ANSI escape codes.
20
21```javascript
22import Ansi from "ansi-to-react";
23
24export function () => {
25  return <Ansi>
26    {'\u001b[34mhello world'}
27  </Ansi>;
28};
29```
30
31Will render:
32
33```javascript
34<code>
35  <span style="color:rgb(0, 0, 187)">hello world</span>
36</code>
37```
38
39### Classes
40
41Style with classes instead of `style` attribute.
42
43```javascript
44<Ansi useClasses>{"\u001b[34mhello world"}</Ansi>
45```
46
47Will render
48
49```javascript
50<code>
51  <span class="ansi-blue-fg">hello world</span>
52</code>
53```
54
55#### Class Names
56
57| Font color             | Background Color |
58| ---------------------- | ---------------- |
59| ansi-black-fg          | ansi-black-bg    |
60| ansi-red-fg            | ansi-red-bg      |
61| ansi-green-fg          | ansi-green-bg    |
62| ansi-yellow-fg         | ansi-yellow-bg   |
63| ansi-blue-fg           | ansi-blue-bg     |
64| ansi-magenta-fg        | ansi-magenta-bg  |
65| ansi-cyan-fg           | ansi-cyan-bg     |
66| ansi-white-fg          | ansi-white-bg    |
67| ansi-bright-black-fg   |
68| ansi-bright-red-fg     |
69| ansi-bright-green-fg   |
70| ansi-bright-yellow-fg  |
71| ansi-bright-blue-fg    |
72| ansi-bright-magenta-fg |
73| ansi-bright-cyan-fg    |
74| ansi-bright-white-fg   |
75
76## Development
77
78To develop on this project, fork and clone this repository on your local machine. Before making modifications, install the project's dependencies.
79
80```
81$ npm install
82```
83
84To run the test suite for this project, run:
85
86```
87$ npm test
88```
89
90## Documentation
91
92We're working on adding more documentation for this component. Stay tuned by watching this repository!
93
94## Support
95
96If you experience an issue while using this package or have a feature request, please file an issue on the [issue board](https://github.com/nteract/ansi-to-react/issues),
97
98## License
99
100[BSD-3-Clause](https://choosealicense.com/licenses/bsd-3-clause/)
101