Gathering detailed insights and metrics for ansi_up_react
Gathering detailed insights and metrics for ansi_up_react
npm install ansi_up_react
Typescript
Module System
Min. Node Version
Node Version
NPM Version
73.8
Supply Chain
98.9
Quality
75
Maintenance
100
Vulnerability
100
License
JavaScript (98.27%)
Makefile (1.73%)
Total Downloads
3,331
Last Day
1
Last Week
4
Last Month
13
Last Year
126
80 Commits
1 Watching
2 Branches
1 Contributors
Minified
Minified + Gzipped
Latest Version
1.4.7
Package Id
ansi_up_react@1.4.7
Size
69.43 kB
NPM Version
2.15.1
Node Version
4.4.3
Cumulative downloads
Total Downloads
Last day
0%
1
Compared to previous day
Last week
0%
4
Compared to previous week
Last month
333.3%
13
Compared to previous month
Last year
-52.1%
126
Compared to previous year
ansi_up is a simple library for converting text that contains ANSI color escape codes into equivalent HTML spans. At the same, it also properly escapes HTML unsafe characters (&,<,>,etc.) into their proper HTML representation. It can also transform any text that looks like a URL into an HTML anchor tag.
This is compliant with AMD (require.js). This code has been used in production since early 2012. This project is actively maintained and welcomes all feedback. Thanks for reading.
Turn this terminal output:
ESC[1;Foreground
[1;30m 30 [1;30m 30 [1;30m 30 [1;30m 30 [1;30m 30 [1;30m 30 [1;30m 30 [1;30m 30 [0m
[1;31m 31 [1;31m 31 [1;31m 31 [1;31m 31 [1;31m 31 [1;31m 31 [1;31m 31 [1;31m 31 [0m
[1;32m 32 [1;32m 32 [1;32m 32 [1;32m 32 [1;32m 32 [1;32m 32 [1;32m 32 [1;32m 32 [0m
...
Into this browser output:
1 <script src="ansi_up.js" type="text/javascript"></script>
2 <script type="text/javascript">
3
4 var txt = "\n\n\033[1;33;40m 33;40 \033[1;33;41m 33;41 \033[1;33;42m 33;42 \033[1;33;43m 33;43 \033[1;33;44m 33;44 \033[1;33;45m 33;45 \033[1;33;46m 33;46 \033[1m\033[0\n\n\033[1;33;42m >> Tests OK\n\n"
5
6 var html = ansi_up.ansi_to_html(txt);
7
8 var cdiv = document.getElementById("console");
9
10 cdiv.innerHTML = html;
11
12 </script>
1 var ansi_up = require('ansi_up');
2
3 var txt = "\n\n\033[1;33;40m 33;40 \033[1;33;41m 33;41 \033[1;33;42m 33;42 \033[1;33;43m 33;43 \033[1;33;44m 33;44 \033[1;33;45m 33;45 \033[1;33;46m 33;46 \033[1m\033[0\n\n\033[1;33;42m >> Tests OK\n\n"
4
5 var html = ansi_up.ansi_to_html(txt);
There are examples in the repo that demonstrate an AMD/require.js/ jQuery example as well as a simple browser example.
$ npm install ansi_up
ansi_up should be called via the functions defined on the module. It is recommended that the HTML is rendered with a monospace font and black background. See the examples, for a basic theme as a CSS definition.
This replaces ANSI terminal escape codes with SPAN tags that wrap the content. See the example output above.
This function only interprets ANSI SGR (Select Graphic Rendition) codes that can be represented in HTML. For example, cursor movement codes are ignored and hidden from output.
The default style uses colors that are very close to the prescribed standard. The standard assumes that the text will have a black background. These colors are set as inline styles on the SPAN tags. Another option is to set 'use_classes: true' in the options argument. This will instead set classes on the spans so the colors can be set via CSS. The class names used are of the format ansi-*-fg/bg
and ansi-bright-*-fg/bg
where * is the colour name, i.e black/red/green/yellow/blue/magenta/cyan/white. See the examples directory for a complete CSS theme for these classes.
This does the minimum escaping of text to make it compliant with HTML. In particular, the '&','<', and '>' characters are escaped. This should be run prior to ansi_to_html.
This replaces any links in the text with anchor tags that display the link. The links should have at least one whitespace character surrounding it. Also, you should apply this after you have run ansi_to_html on the text.
This just uses 'make'. The result is just one file. Feel free to include the file in your asset minification process.
To run the tests for ansi_up, run npm install
to install dependencies and then:
$ make test
This code was developed by Dru Nelson (https://github.com/drudru).
Thanks goes to the following contributors for their patches:
(The MIT License)
Copyright (c) 2011 Dru Nelson
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WIT
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
no SAST tool detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
license file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-01-20
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More