Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ansi-to-html

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ansi-to-html - npm Package Compare versions

Comparing version 0.6.8 to 0.6.9

28

lib/ansi_to_html.js

@@ -111,2 +111,4 @@ 'use strict';

result = pushForegroundColor(stack, options.colors[data]);
} else if (token === 'rgb') {
result = handleRgb(stack, data);
}

@@ -119,2 +121,19 @@

* @param {Array} stack
* @param {string} data
* @returns {*}
*/
function handleRgb(stack, data) {
data = data.substring(2).slice(0, -1);
var operation = +data.substr(0, 2);
var color = data.substring(5).split(';');
var rgb = color.map(function (value) {
return ('0' + Number(value).toString(16)).substr(-2);
}).join('');
return pushStyle(stack, (operation === 38 ? 'color:#' : 'background-color:#') + rgb);
}
/**
* @param {Array} stack
* @param {number} code

@@ -372,2 +391,8 @@ * @param {object} options

function rgb(m) {
callback('rgb', m);
return '';
}
/* eslint no-control-regex:0 */

@@ -384,2 +409,5 @@ var tokens = [{

}, {
pattern: /^\x1b\[[34]8;2;\d+;\d+;\d+m/,
sub: rgb
}, {
pattern: /^\x1b\[38;5;(\d+)m/,

@@ -386,0 +414,0 @@ sub: removeXterm256

6

package.json
{
"name": "ansi-to-html",
"version": "0.6.8",
"version": "0.6.9",
"description": "Convert ansi escaped text streams to html.",

@@ -75,4 +75,6 @@ "main": "lib/ansi_to_html.js",

"babel": {
"presets": ["env"]
"presets": [
"env"
]
}
}

@@ -151,2 +151,16 @@ /* globals describe, it*/

it('renders foreground rgb sequences', function (done) {
const text = '\x1b[38;2;210;60;114mhello';
const result = '<span style="color:#d23c72">hello</span>';
return test(text, result, done);
});
it('renders background rgb sequences', function (done) {
const text = '\x1b[48;2;155;42;45mhello';
const result = '<span style="background-color:#9b2a2d">hello</span>';
return test(text, result, done);
});
it('handles resetting to default foreground color', function (done) {

@@ -153,0 +167,0 @@ const text = '\x1b[30mblack\x1b[39mdefault';

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc