Socket
Socket
Sign inDemoInstall

ansi_up

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ansi_up - npm Package Compare versions

Comparing version 5.2.1 to 6.0.0

59

ansi_up.d.ts

@@ -1,25 +0,1 @@

interface AU_Color {
rgb: number[];
class_name: string;
}
interface TextWithAttr {
fg: AU_Color;
bg: AU_Color;
bold: boolean;
text: string;
}
declare enum PacketKind {
EOS = 0,
Text = 1,
Incomplete = 2,
ESC = 3,
Unknown = 4,
SGR = 5,
OSCURL = 6
}
interface TextPacket {
kind: PacketKind;
text: string;
url: string;
}
export declare class AnsiUp {

@@ -32,23 +8,40 @@ VERSION: string;

private bold;
private faint;
private italic;
private underline;
private _use_classes;
private _escape_for_html;
private _csi_regex;
private _osc_st;
private _osc_regex;
private _url_whitelist;
private _url_allowlist;
private _escape_html;
private _buffer;
private _boldStyle;
private _faintStyle;
private _italicStyle;
private _underlineStyle;
constructor();
use_classes: boolean;
escape_for_html: boolean;
url_whitelist: {};
set use_classes(arg: boolean);
get use_classes(): boolean;
set url_allowlist(arg: {});
get url_allowlist(): {};
set escape_html(arg: boolean);
get escape_html(): boolean;
set boldStyle(arg: string);
get boldStyle(): string;
set faintStyle(arg: string);
get faintStyle(): string;
set italicStyle(arg: string);
get italicStyle(): string;
set underlineStyle(arg: string);
get underlineStyle(): string;
private setup_palettes;
private escape_txt_for_html;
append_buffer(txt: string): void;
get_next_packet(): TextPacket;
private append_buffer;
private get_next_packet;
ansi_to_html(txt: string): string;
private with_state;
private process_ansi;
transform_to_html(fragment: TextWithAttr): string;
private transform_to_html;
private process_hyperlink;
}
export {};

@@ -1,20 +0,1 @@

/* ansi_up.js
* author : Dru Nelson
* license : MIT
* http://github.com/drudru/ansi_up
*/
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['exports'], factory);
} else if (typeof exports === 'object' && typeof exports.nodeName !== 'string') {
// CommonJS
factory(exports);
} else {
// Browser globals
var exp = {};
factory(exp);
root.AnsiUp = exp.default;
}
}(this, function (exports) {
"use strict";

@@ -35,8 +16,9 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {

})(PacketKind || (PacketKind = {}));
var AnsiUp = (function () {
function AnsiUp() {
this.VERSION = "5.2.1";
export class AnsiUp {
constructor() {
this.VERSION = "6.0.0";
this.setup_palettes();
this._use_classes = false;
this.bold = false;
this.faint = false;
this.italic = false;

@@ -46,37 +28,36 @@ this.underline = false;

this._buffer = '';
this._url_whitelist = { 'http': 1, 'https': 1 };
this._url_allowlist = { 'http': 1, 'https': 1 };
this._escape_html = true;
this.boldStyle = 'font-weight:bold';
this.faintStyle = 'opacity:0.7';
this.italicStyle = 'font-style:italic';
this.underlineStyle = 'text-decoration:underline';
}
Object.defineProperty(AnsiUp.prototype, "use_classes", {
get: function () {
return this._use_classes;
},
set: function (arg) {
this._use_classes = arg;
},
enumerable: false,
configurable: true
});
Object.defineProperty(AnsiUp.prototype, "url_whitelist", {
get: function () {
return this._url_whitelist;
},
set: function (arg) {
this._url_whitelist = arg;
},
enumerable: false,
configurable: true
});
Object.defineProperty(AnsiUp.prototype, "escape_html", {
get: function () {
return this._escape_html;
},
set: function (arg) {
this._escape_html = arg;
},
enumerable: false,
configurable: true
});
AnsiUp.prototype.setup_palettes = function () {
var _this = this;
set use_classes(arg) {
this._use_classes = arg;
}
get use_classes() {
return this._use_classes;
}
set url_allowlist(arg) {
this._url_allowlist = arg;
}
get url_allowlist() {
return this._url_allowlist;
}
set escape_html(arg) {
this._escape_html = arg;
}
get escape_html() {
return this._escape_html;
}
set boldStyle(arg) { this._boldStyle = arg; }
get boldStyle() { return this._boldStyle; }
set faintStyle(arg) { this._faintStyle = arg; }
get faintStyle() { return this._faintStyle; }
set italicStyle(arg) { this._italicStyle = arg; }
get italicStyle() { return this._italicStyle; }
set underlineStyle(arg) { this._underlineStyle = arg; }
get underlineStyle() { return this._underlineStyle; }
setup_palettes() {
this.ansi_colors =

@@ -106,12 +87,12 @@ [

this.palette_256 = [];
this.ansi_colors.forEach(function (palette) {
palette.forEach(function (rec) {
_this.palette_256.push(rec);
this.ansi_colors.forEach(palette => {
palette.forEach(rec => {
this.palette_256.push(rec);
});
});
var levels = [0, 95, 135, 175, 215, 255];
for (var r = 0; r < 6; ++r) {
for (var g = 0; g < 6; ++g) {
for (var b = 0; b < 6; ++b) {
var col = { rgb: [levels[r], levels[g], levels[b]], class_name: 'truecolor' };
let levels = [0, 95, 135, 175, 215, 255];
for (let r = 0; r < 6; ++r) {
for (let g = 0; g < 6; ++g) {
for (let b = 0; b < 6; ++b) {
let col = { rgb: [levels[r], levels[g], levels[b]], class_name: 'truecolor' };
this.palette_256.push(col);

@@ -121,12 +102,12 @@ }

}
var grey_level = 8;
for (var i = 0; i < 24; ++i, grey_level += 10) {
var gry = { rgb: [grey_level, grey_level, grey_level], class_name: 'truecolor' };
let grey_level = 8;
for (let i = 0; i < 24; ++i, grey_level += 10) {
let gry = { rgb: [grey_level, grey_level, grey_level], class_name: 'truecolor' };
this.palette_256.push(gry);
}
};
AnsiUp.prototype.escape_txt_for_html = function (txt) {
}
escape_txt_for_html(txt) {
if (!this._escape_html)
return txt;
return txt.replace(/[&<>"']/gm, function (str) {
return txt.replace(/[&<>"']/gm, (str) => {
if (str === "&")

@@ -143,8 +124,8 @@ return "&amp;";

});
};
AnsiUp.prototype.append_buffer = function (txt) {
}
append_buffer(txt) {
var str = this._buffer + txt;
this._buffer = str;
};
AnsiUp.prototype.get_next_packet = function () {
}
get_next_packet() {
var pkt = {

@@ -185,5 +166,5 @@ kind: PacketKind.EOS,

if (!this._csi_regex) {
this._csi_regex = rgx(__makeTemplateObject(["\n ^ # beginning of line\n #\n # First attempt\n (?: # legal sequence\n \u001B[ # CSI\n ([<-?]?) # private-mode char\n ([d;]*) # any digits or semicolons\n ([ -/]? # an intermediate modifier\n [@-~]) # the command\n )\n | # alternate (second attempt)\n (?: # illegal sequence\n \u001B[ # CSI\n [ -~]* # anything legal\n ([\0-\u001F:]) # anything illegal\n )\n "], ["\n ^ # beginning of line\n #\n # First attempt\n (?: # legal sequence\n \\x1b\\[ # CSI\n ([\\x3c-\\x3f]?) # private-mode char\n ([\\d;]*) # any digits or semicolons\n ([\\x20-\\x2f]? # an intermediate modifier\n [\\x40-\\x7e]) # the command\n )\n | # alternate (second attempt)\n (?: # illegal sequence\n \\x1b\\[ # CSI\n [\\x20-\\x7e]* # anything legal\n ([\\x00-\\x1f:]) # anything illegal\n )\n "]));
this._csi_regex = rgx(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ^ # beginning of line\n #\n # First attempt\n (?: # legal sequence\n \u001B[ # CSI\n ([<-?]?) # private-mode char\n ([d;]*) # any digits or semicolons\n ([ -/]? # an intermediate modifier\n [@-~]) # the command\n )\n | # alternate (second attempt)\n (?: # illegal sequence\n \u001B[ # CSI\n [ -~]* # anything legal\n ([\0-\u001F:]) # anything illegal\n )\n "], ["\n ^ # beginning of line\n #\n # First attempt\n (?: # legal sequence\n \\x1b\\[ # CSI\n ([\\x3c-\\x3f]?) # private-mode char\n ([\\d;]*) # any digits or semicolons\n ([\\x20-\\x2f]? # an intermediate modifier\n [\\x40-\\x7e]) # the command\n )\n | # alternate (second attempt)\n (?: # illegal sequence\n \\x1b\\[ # CSI\n [\\x20-\\x7e]* # anything legal\n ([\\x00-\\x1f:]) # anything illegal\n )\n "])));
}
var match = this._buffer.match(this._csi_regex);
let match = this._buffer.match(this._csi_regex);
if (match === null) {

@@ -221,12 +202,12 @@ pkt.kind = PacketKind.Incomplete;

if (!this._osc_st) {
this._osc_st = rgxG(__makeTemplateObject(["\n (?: # legal sequence\n (\u001B\\) # ESC | # alternate\n (\u0007) # BEL (what xterm did)\n )\n | # alternate (second attempt)\n ( # illegal sequence\n [\0-\u0006] # anything illegal\n | # alternate\n [\b-\u001A] # anything illegal\n | # alternate\n [\u001C-\u001F] # anything illegal\n )\n "], ["\n (?: # legal sequence\n (\\x1b\\\\) # ESC \\\n | # alternate\n (\\x07) # BEL (what xterm did)\n )\n | # alternate (second attempt)\n ( # illegal sequence\n [\\x00-\\x06] # anything illegal\n | # alternate\n [\\x08-\\x1a] # anything illegal\n | # alternate\n [\\x1c-\\x1f] # anything illegal\n )\n "]));
this._osc_st = rgxG(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n (?: # legal sequence\n (\u001B\\) # ESC | # alternate\n (\u0007) # BEL (what xterm did)\n )\n | # alternate (second attempt)\n ( # illegal sequence\n [\0-\u0006] # anything illegal\n | # alternate\n [\b-\u001A] # anything illegal\n | # alternate\n [\u001C-\u001F] # anything illegal\n )\n "], ["\n (?: # legal sequence\n (\\x1b\\\\) # ESC \\\n | # alternate\n (\\x07) # BEL (what xterm did)\n )\n | # alternate (second attempt)\n ( # illegal sequence\n [\\x00-\\x06] # anything illegal\n | # alternate\n [\\x08-\\x1a] # anything illegal\n | # alternate\n [\\x1c-\\x1f] # anything illegal\n )\n "])));
}
this._osc_st.lastIndex = 0;
{
var match_1 = this._osc_st.exec(this._buffer);
if (match_1 === null) {
let match = this._osc_st.exec(this._buffer);
if (match === null) {
pkt.kind = PacketKind.Incomplete;
return pkt;
}
if (match_1[3]) {
if (match[3]) {
pkt.kind = PacketKind.ESC;

@@ -239,8 +220,8 @@ pkt.text = this._buffer.slice(0, 1);

{
var match_2 = this._osc_st.exec(this._buffer);
if (match_2 === null) {
let match = this._osc_st.exec(this._buffer);
if (match === null) {
pkt.kind = PacketKind.Incomplete;
return pkt;
}
if (match_2[3]) {
if (match[3]) {
pkt.kind = PacketKind.ESC;

@@ -253,5 +234,5 @@ pkt.text = this._buffer.slice(0, 1);

if (!this._osc_regex) {
this._osc_regex = rgx(__makeTemplateObject(["\n ^ # beginning of line\n #\n \u001B]8; # OSC Hyperlink\n [ -:<-~]* # params (excluding ;)\n ; # end of params\n ([!-~]{0,512}) # URL capture\n (?: # ST\n (?:\u001B\\) # ESC | # alternate\n (?:\u0007) # BEL (what xterm did)\n )\n ([ -~]+) # TEXT capture\n \u001B]8;; # OSC Hyperlink End\n (?: # ST\n (?:\u001B\\) # ESC | # alternate\n (?:\u0007) # BEL (what xterm did)\n )\n "], ["\n ^ # beginning of line\n #\n \\x1b\\]8; # OSC Hyperlink\n [\\x20-\\x3a\\x3c-\\x7e]* # params (excluding ;)\n ; # end of params\n ([\\x21-\\x7e]{0,512}) # URL capture\n (?: # ST\n (?:\\x1b\\\\) # ESC \\\n | # alternate\n (?:\\x07) # BEL (what xterm did)\n )\n ([\\x20-\\x7e]+) # TEXT capture\n \\x1b\\]8;; # OSC Hyperlink End\n (?: # ST\n (?:\\x1b\\\\) # ESC \\\n | # alternate\n (?:\\x07) # BEL (what xterm did)\n )\n "]));
this._osc_regex = rgx(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n ^ # beginning of line\n #\n \u001B]8; # OSC Hyperlink\n [ -:<-~]* # params (excluding ;)\n ; # end of params\n ([!-~]{0,512}) # URL capture\n (?: # ST\n (?:\u001B\\) # ESC | # alternate\n (?:\u0007) # BEL (what xterm did)\n )\n ([ -~]+) # TEXT capture\n \u001B]8;; # OSC Hyperlink End\n (?: # ST\n (?:\u001B\\) # ESC | # alternate\n (?:\u0007) # BEL (what xterm did)\n )\n "], ["\n ^ # beginning of line\n #\n \\x1b\\]8; # OSC Hyperlink\n [\\x20-\\x3a\\x3c-\\x7e]* # params (excluding ;)\n ; # end of params\n ([\\x21-\\x7e]{0,512}) # URL capture\n (?: # ST\n (?:\\x1b\\\\) # ESC \\\n | # alternate\n (?:\\x07) # BEL (what xterm did)\n )\n ([\\x20-\\x7e]+) # TEXT capture\n \\x1b\\]8;; # OSC Hyperlink End\n (?: # ST\n (?:\\x1b\\\\) # ESC \\\n | # alternate\n (?:\\x07) # BEL (what xterm did)\n )\n "])));
}
var match = this._buffer.match(this._osc_regex);
let match = this._buffer.match(this._osc_regex);
if (match === null) {

@@ -276,4 +257,4 @@ pkt.kind = PacketKind.ESC;

}
};
AnsiUp.prototype.ansi_to_html = function (txt) {
}
ansi_to_html(txt) {
this.append_buffer(txt);

@@ -297,14 +278,16 @@ var blocks = [];

return blocks.join("");
};
AnsiUp.prototype.with_state = function (pkt) {
return { bold: this.bold, italic: this.italic, underline: this.underline, fg: this.fg, bg: this.bg, text: pkt.text };
};
AnsiUp.prototype.process_ansi = function (pkt) {
var sgr_cmds = pkt.text.split(';');
}
with_state(pkt) {
return { bold: this.bold, faint: this.faint, italic: this.italic, underline: this.underline, fg: this.fg, bg: this.bg, text: pkt.text };
}
process_ansi(pkt) {
let sgr_cmds = pkt.text.split(';');
while (sgr_cmds.length > 0) {
var sgr_cmd_str = sgr_cmds.shift();
var num = parseInt(sgr_cmd_str, 10);
let sgr_cmd_str = sgr_cmds.shift();
let num = parseInt(sgr_cmd_str, 10);
if (isNaN(num) || num === 0) {
this.fg = this.bg = null;
this.fg = null;
this.bg = null;
this.bold = false;
this.faint = false;
this.italic = false;

@@ -316,2 +299,5 @@ this.underline = false;

}
else if (num === 2) {
this.faint = true;
}
else if (num === 3) {

@@ -323,5 +309,8 @@ this.italic = true;

}
else if (num === 22) {
else if (num === 21) {
this.bold = false;
}
else if (num === 22) {
this.faint = false;
}
else if (num === 23) {

@@ -353,6 +342,6 @@ this.italic = false;

if (sgr_cmds.length > 0) {
var is_foreground = (num === 38);
var mode_cmd = sgr_cmds.shift();
let is_foreground = (num === 38);
let mode_cmd = sgr_cmds.shift();
if (mode_cmd === '5' && sgr_cmds.length > 0) {
var palette_index = parseInt(sgr_cmds.shift(), 10);
let palette_index = parseInt(sgr_cmds.shift(), 10);
if (palette_index >= 0 && palette_index <= 255) {

@@ -366,7 +355,7 @@ if (is_foreground)

if (mode_cmd === '2' && sgr_cmds.length > 2) {
var r = parseInt(sgr_cmds.shift(), 10);
var g = parseInt(sgr_cmds.shift(), 10);
var b = parseInt(sgr_cmds.shift(), 10);
let r = parseInt(sgr_cmds.shift(), 10);
let g = parseInt(sgr_cmds.shift(), 10);
let b = parseInt(sgr_cmds.shift(), 10);
if ((r >= 0 && r <= 255) && (g >= 0 && g <= 255) && (b >= 0 && b <= 255)) {
var c = { rgb: [r, g, b], class_name: 'truecolor' };
let c = { rgb: [r, g, b], class_name: 'truecolor' };
if (is_foreground)

@@ -381,5 +370,5 @@ this.fg = c;

}
};
AnsiUp.prototype.transform_to_html = function (fragment) {
var txt = fragment.text;
}
transform_to_html(fragment) {
let txt = fragment.text;
if (txt.length === 0)

@@ -390,17 +379,19 @@ return txt;

return txt;
var styles = [];
var classes = [];
var fg = fragment.fg;
var bg = fragment.bg;
let styles = [];
let classes = [];
let fg = fragment.fg;
let bg = fragment.bg;
if (fragment.bold)
styles.push('font-weight:bold');
styles.push(this._boldStyle);
if (fragment.faint)
styles.push(this._faintStyle);
if (fragment.italic)
styles.push('font-style:italic');
styles.push(this._italicStyle);
if (fragment.underline)
styles.push('text-decoration:underline');
styles.push(this._underlineStyle);
if (!this._use_classes) {
if (fg)
styles.push("color:rgb(" + fg.rgb.join(',') + ")");
styles.push(`color:rgb(${fg.rgb.join(',')})`);
if (bg)
styles.push("background-color:rgb(" + bg.rgb + ")");
styles.push(`background-color:rgb(${bg.rgb})`);
}

@@ -410,6 +401,6 @@ else {

if (fg.class_name !== 'truecolor') {
classes.push(fg.class_name + "-fg");
classes.push(`${fg.class_name}-fg`);
}
else {
styles.push("color:rgb(" + fg.rgb.join(',') + ")");
styles.push(`color:rgb(${fg.rgb.join(',')})`);
}

@@ -419,52 +410,40 @@ }

if (bg.class_name !== 'truecolor') {
classes.push(bg.class_name + "-bg");
classes.push(`${bg.class_name}-bg`);
}
else {
styles.push("background-color:rgb(" + bg.rgb.join(',') + ")");
styles.push(`background-color:rgb(${bg.rgb.join(',')})`);
}
}
}
var class_string = '';
var style_string = '';
let class_string = '';
let style_string = '';
if (classes.length)
class_string = " class=\"" + classes.join(' ') + "\"";
class_string = ` class="${classes.join(' ')}"`;
if (styles.length)
style_string = " style=\"" + styles.join(';') + "\"";
return "<span" + style_string + class_string + ">" + txt + "</span>";
};
style_string = ` style="${styles.join(';')}"`;
return `<span${style_string}${class_string}>${txt}</span>`;
}
;
AnsiUp.prototype.process_hyperlink = function (pkt) {
var parts = pkt.url.split(':');
process_hyperlink(pkt) {
let parts = pkt.url.split(':');
if (parts.length < 1)
return '';
if (!this._url_whitelist[parts[0]])
if (!this._url_allowlist[parts[0]])
return '';
var result = "<a href=\"" + this.escape_txt_for_html(pkt.url) + "\">" + this.escape_txt_for_html(pkt.text) + "</a>";
let result = `<a href="${this.escape_txt_for_html(pkt.url)}">${this.escape_txt_for_html(pkt.text)}</a>`;
return result;
};
return AnsiUp;
}());
function rgx(tmplObj) {
var subst = [];
for (var _i = 1; _i < arguments.length; _i++) {
subst[_i - 1] = arguments[_i];
}
var regexText = tmplObj.raw[0];
var wsrgx = /^\s+|\s+\n|\s*#[\s\S]*?\n|\n/gm;
var txt2 = regexText.replace(wsrgx, '');
}
function rgx(tmplObj, ...subst) {
let regexText = tmplObj.raw[0];
let wsrgx = /^\s+|\s+\n|\s*#[\s\S]*?\n|\n/gm;
let txt2 = regexText.replace(wsrgx, '');
return new RegExp(txt2);
}
function rgxG(tmplObj) {
var subst = [];
for (var _i = 1; _i < arguments.length; _i++) {
subst[_i - 1] = arguments[_i];
}
var regexText = tmplObj.raw[0];
var wsrgx = /^\s+|\s+\n|\s*#[\s\S]*?\n|\n/gm;
var txt2 = regexText.replace(wsrgx, '');
function rgxG(tmplObj, ...subst) {
let regexText = tmplObj.raw[0];
let wsrgx = /^\s+|\s+\n|\s*#[\s\S]*?\n|\n/gm;
let txt2 = regexText.replace(wsrgx, '');
return new RegExp(txt2, 'g');
}
//# sourceMappingURL=ansi_up.js.map
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = AnsiUp;
}));
var templateObject_1, templateObject_2, templateObject_3;

@@ -26,2 +26,3 @@ /* ansi_up.js

bold:boolean;
faint:boolean;
italic: boolean;

@@ -54,5 +55,5 @@ underline: boolean;

class AnsiUp
export class AnsiUp
{
VERSION = "5.2.1";
VERSION = "6.0.0";

@@ -71,2 +72,3 @@ //

private bold:boolean;
private faint:boolean;
private italic: boolean;

@@ -81,3 +83,3 @@ private underline:boolean;

private _url_whitelist:{};
private _url_allowlist:{};
private _escape_html:boolean;

@@ -87,2 +89,8 @@

private _boldStyle:string;
private _faintStyle:string;
private _italicStyle:string;
private _underlineStyle:string;
constructor()

@@ -95,2 +103,3 @@ {

this.bold = false;
this.faint = false;
this.italic = false;

@@ -102,4 +111,9 @@ this.underline = false;

this._url_whitelist = { 'http':1, 'https':1 };
this._url_allowlist = { 'http':1, 'https':1 };
this._escape_html = true;
this.boldStyle = 'font-weight:bold';
this.faintStyle = 'opacity:0.7';
this.italicStyle = 'font-style:italic';
this.underlineStyle = 'text-decoration:underline'
}

@@ -117,10 +131,10 @@

set url_whitelist(arg:{})
set url_allowlist(arg:{})
{
this._url_whitelist = arg;
this._url_allowlist = arg;
}
get url_whitelist():{}
get url_allowlist():{}
{
return this._url_whitelist;
return this._url_allowlist;
}

@@ -138,3 +152,12 @@

set boldStyle(arg:string) { this._boldStyle = arg; }
get boldStyle():string { return this._boldStyle; }
set faintStyle(arg:string) { this._faintStyle = arg; }
get faintStyle():string { return this._faintStyle; }
set italicStyle(arg:string) { this._italicStyle = arg; }
get italicStyle():string { return this._italicStyle; }
set underlineStyle(arg:string) { this._underlineStyle = arg; }
get underlineStyle():string { return this._underlineStyle; }
private setup_palettes():void

@@ -582,3 +605,3 @@ {

private with_state(pkt:TextPacket):TextWithAttr {
return { bold: this.bold, italic: this.italic, underline: this.underline, fg: this.fg, bg: this.bg, text: pkt.text };
return { bold: this.bold, faint: this.faint, italic: this.italic, underline: this.underline, fg: this.fg, bg: this.bg, text: pkt.text };
}

@@ -596,2 +619,3 @@

// ... because some commands consume the params that follow !
while (sgr_cmds.length > 0) {

@@ -601,31 +625,29 @@ let sgr_cmd_str = sgr_cmds.shift();

// TODO
// AT SOME POINT, JUST CONVERT TO A LOOKUP TABLE
if (isNaN(num) || num === 0) {
this.fg = this.bg = null;
this.bold = false;
this.italic = false;
this.fg = null;
this.bg = null;
this.bold = false;
this.faint = false;
this.italic = false;
this.underline = false;
} else if (num === 1) {
this.bold = true;
} else if (num === 3) {
this.italic = true;
} else if (num === 4) {
this.underline = true;
} else if (num === 22) {
this.bold = false;
} else if (num === 23) {
this.italic = false;
} else if (num === 24) {
this.underline = false;
} else if (num === 39) {
this.fg = null;
} else if (num === 49) {
this.bg = null;
} else if ((num >= 30) && (num < 38)) {
this.fg = this.ansi_colors[0][(num - 30)];
} else if ((num >= 40) && (num < 48)) {
this.bg = this.ansi_colors[0][(num - 40)];
} else if ((num >= 90) && (num < 98)) {
this.fg = this.ansi_colors[1][(num - 90)];
} else if ((num >= 100) && (num < 108)) {
this.bg = this.ansi_colors[1][(num - 100)];
} else if (num === 1) { this.bold = true;
} else if (num === 2) { this.faint = true;
} else if (num === 3) { this.italic = true;
} else if (num === 4) { this.underline = true;
} else if (num === 21) { this.bold = false;
} else if (num === 22) { this.faint = false;
} else if (num === 23) { this.italic = false;
} else if (num === 24) { this.underline = false;
} else if (num === 39) { this.fg = null;
} else if (num === 49) { this.bg = null;
} else if ((num >= 30) && (num < 38)) { this.fg = this.ansi_colors[0][(num - 30)];
} else if ((num >= 40) && (num < 48)) { this.bg = this.ansi_colors[0][(num - 40)];
} else if ((num >= 90) && (num < 98)) { this.fg = this.ansi_colors[1][(num - 90)];
} else if ((num >= 100) && (num < 108)) { this.bg = this.ansi_colors[1][(num - 100)];
} else if (num === 38 || num === 48) {

@@ -691,11 +713,7 @@

// Note on bold: https://stackoverflow.com/questions/6737005/what-are-some-advantages-to-using-span-style-font-weightbold-rather-than-b?rq=1
if (fragment.bold)
styles.push('font-weight:bold');
if (fragment.italic)
styles.push('font-style:italic');
if (fragment.bold) styles.push(this._boldStyle);
if (fragment.faint) styles.push(this._faintStyle);
if (fragment.italic) styles.push(this._italicStyle);
if (fragment.underline) styles.push(this._underlineStyle);
if (fragment.underline)
styles.push('text-decoration:underline');
if (!this._use_classes) {

@@ -744,3 +762,3 @@ // USE INLINE STYLES

if (! this._url_whitelist[parts[0]])
if (! this._url_allowlist[parts[0]])
return '';

@@ -747,0 +765,0 @@

{
"name": "ansi_up",
"version": "5.2.1",
"version": "6.0.0",
"description": "Convert ansi sequences in strings to colorful HTML",

@@ -12,2 +12,3 @@ "keywords": [

"main": "./ansi_up.js",
"type": "module",
"types": "./dist/ansi_up.d.ts",

@@ -29,7 +30,7 @@ "repository": {

"devDependencies": {
"npm": "^9.6.3",
"mocha": "^10.2.0",
"npm": "^9.8.1",
"should": "*",
"typescript": "^3.9.10"
"typescript": "^5.1.0"
}
}

@@ -6,3 +6,3 @@ # ansi_up.js

This module is a single Javascript file with no dependencies.
This module is a single ES6 Javascript file with no dependencies.
It is "isomorphic" javascript. This is just another way of saying that

@@ -29,8 +29,9 @@ the ansi_up.js file will work in both the browser or node.js.

```HTML
<script src="ansi_up.js" type="text/javascript"></script>
<script type="text/javascript">
<script type="module" type="text/javascript">
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"
var ansi_up = new AnsiUp;
import { AnsiUp } from './ansi_up.js'
var ansi_up = new AnsiUp();

@@ -49,4 +50,4 @@ var html = ansi_up.ansi_to_html(txt);

```JavaScript
var AU = require('ansi_up');
var ansi_up = new AU.default;
import { AnsiUp } from './ansi_up.js'
var ansi_up = new AnsiUp();

@@ -63,6 +64,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"

```TypeScript
import {
default as AnsiUp
} from 'ansi_up';
import { AnsiUp } from './ansi_up.js'
const ansi_up = new AnsiUp();

@@ -80,2 +78,3 @@

## Versions
* Version 6.0 - Switch to ES6 module. Add faint styles. Style css configurable.
* Version 5.1 - Add italic and underline styles (@DaoDaoNoCode)

@@ -139,7 +138,16 @@ * Version 5.0 - Security fix for OSC URLs

#### url_whitelist
(default: { 'http':1, 'https':1 };
#### url_allowlist
(default: { 'http':1, 'https':1 })
This mapping is a whitelist of URI schemes that will be allowed to render HTML anchor tags.
This mapping is an 'allow' list of URI schemes that will be allowed to render HTML anchor tags.
#### boldStyle
(default: 'font-weight:bold')
#### faintStyle
(default: 'opacity:0.7')
#### italicStyle
(default: 'font-style:italic')
#### underlineStyle
(default: 'text-decoration:underline')
## Buffering

@@ -146,0 +154,0 @@

@@ -1,5 +0,3 @@

var AU = require('../ansi_up');
var AnsiUp = AU.default;
var should = require('should');
import { AnsiUp } from '../ansi_up.js';

@@ -179,5 +177,5 @@ describe('ansi_up', function () {

"should have no color",
"\033[" + attr + ";" + fg + "m " + "should be bold with green foreground" + "\033[0m",
"\033[" + attr + ";" + bg + ";" + fg + "m " + "should have bold with red background with green foreground" + "\033[0m",
"\033[" + bg + ";" + fg + "m " + "should have red background with green foreground" + "\033[0m"
"\x1B[" + attr + ";" + fg + "m " + "should be bold with green foreground" + "\x1B[0m",
"\x1B[" + attr + ";" + bg + ";" + fg + "m " + "should have bold with red background with green foreground" + "\x1B[0m",
"\x1B[" + bg + ";" + fg + "m " + "should have red background with green foreground" + "\x1B[0m"
];

@@ -233,3 +231,3 @@

var fg = 32;
var start = "\033[" + fg + "m " + fg + " \033[0m";
var start = "\x1B[" + fg + "m " + fg + " \x1B[0m";

@@ -247,3 +245,3 @@ var expected = "<span style=\"color:rgb(0,187,0)\"> " + fg + " </span>";

var fg = 32;
var start = "\033[" + attr + ";" + fg + "m " + fg + " \033[0m";
var start = "\x1B[" + attr + ";" + fg + "m " + fg + " \x1B[0m";

@@ -260,3 +258,3 @@ var expected = "<span style=\"color:rgb(0,187,0)\"> " + fg + " </span>";

var fg = 32;
var start = "\033[" + attr + ";" + fg + "m " + fg + " \033[m x";
var start = "\x1B[" + attr + ";" + fg + "m " + fg + " \x1B[m x";

@@ -273,3 +271,3 @@ var expected = "<span style=\"color:rgb(0,187,0)\"> " + fg + " </span> x";

var fg = 32;
var start = "\033[" + attr + ";" + fg + "m " + attr + ";" + fg + " \033[0m";
var start = "\x1B[" + attr + ";" + fg + "m " + attr + ";" + fg + " \x1B[0m";

@@ -283,6 +281,18 @@ var expected = "<span style=\"font-weight:bold;color:rgb(0,187,0)\"> " + attr + ";" + fg + " </span>";

it('should transform a faint attr;foreground to html', function () {
var attr = 2;
var fg = 32;
var start = "\x1B[" + attr + ";" + fg + "m " + attr + ";" + fg + " \x1B[0m";
var expected = "<span style=\"opacity:0.7;color:rgb(0,187,0)\"> " + attr + ";" + fg + " </span>";
var au = new AnsiUp();
var l = au.ansi_to_html(start);
l.should.eql(expected);
});
it('should transform an italic attr;foreground to html', function () {
var attr = 3;
var fg = 32;
var start = "\033[" + attr + ";" + fg + "m " + attr + ";" + fg + " \033[0m";
var start = "\x1B[" + attr + ";" + fg + "m " + attr + ";" + fg + " \x1B[0m";

@@ -299,3 +309,3 @@ var expected = "<span style=\"font-style:italic;color:rgb(0,187,0)\"> " + attr + ";" + fg + " </span>";

var fg = 32;
var start = "\033[" + attr + ";" + fg + "m " + attr + ";" + fg + " \033[0m";
var start = "\x1B[" + attr + ";" + fg + "m " + attr + ";" + fg + " \x1B[0m";

@@ -311,3 +321,3 @@ var expected = "<span style=\"text-decoration:underline;color:rgb(0,187,0)\"> " + attr + ";" + fg + " </span>";

var fg = 92;
var start = "\033[" + fg + "m " + fg + " \033[0m";
var start = "\x1B[" + fg + "m " + fg + " \x1B[0m";

@@ -325,3 +335,3 @@ var expected = "<span style=\"color:rgb(0,255,0)\"> " + fg + " </span>";

var bg = 42;
var start = "\033[" + attr + ";" + bg + ";" + fg + "m " + attr + ";" + bg + ";" + fg + " \033[0m";
var start = "\x1B[" + attr + ";" + bg + ";" + fg + "m " + attr + ";" + bg + ";" + fg + " \x1B[0m";

@@ -338,3 +348,3 @@ var expected = "<span style=\"font-weight:bold;color:rgb(187,187,0);background-color:rgb(0,187,0)\"> " + attr + ";" + bg + ";" + fg + " </span>";

var bg = 102;
var start = "\033[" + bg + ";" + fg + "m " + bg + ";" + fg + " \033[0m";
var start = "\x1B[" + bg + ";" + fg + "m " + bg + ";" + fg + " \x1B[0m";

@@ -353,3 +363,3 @@ var expected = "<span style=\"color:rgb(187,187,0);background-color:rgb(0,255,0)\"> " + bg + ";" + fg + " </span>";

var bg = 42;
var start = "\n \033[" + fg + "m " + fg + " \033[0m \n \033[" + bg + "m " + bg + " \033[0m \n zimpper ";
var start = "\n \x1B[" + fg + "m " + fg + " \x1B[0m \n \x1B[" + bg + "m " + bg + " \x1B[0m \n zimpper ";

@@ -366,3 +376,3 @@ var expected = "\n <span style=\"color:rgb(0,187,0)\"> " + fg + " </span> \n <span style=\"background-color:rgb(0,187,0)\"> " + bg + " </span> \n zimpper ";

var bg = 42;
var start = "\n\033[40m \033[49m\033[" + fg + ";" + bg + "m " + bg + " \033[39m foobar ";
var start = "\n\x1B[40m \x1B[49m\x1B[" + fg + ";" + bg + "m " + bg + " \x1B[39m foobar ";

@@ -379,3 +389,3 @@ var expected = "\n<span style=\"background-color:rgb(0,0,0)\"> </span><span style=\"color:rgb(255,255,255);background-color:rgb(0,187,0)\"> " + bg + " </span><span style=\"background-color:rgb(0,187,0)\"> foobar </span>";

var bg = 42;
var start = "\n\033[40m \033[49m\033[" + fg + ";" + bg + "m " + fg + " \033[49m foobar ";
var start = "\n\x1B[40m \x1B[49m\x1B[" + fg + ";" + bg + "m " + fg + " \x1B[49m foobar ";

@@ -392,3 +402,3 @@ var expected = "\n<span style=\"background-color:rgb(0,0,0)\"> </span><span style=\"color:rgb(255,255,255);background-color:rgb(0,187,0)\"> " + fg + " </span><span style=\"color:rgb(255,255,255)\"> foobar </span>";

var bg = 42;
var start = "\n\033[40m \033[49m\033[" + fg + ";" + bg + "m " + fg + ';' + bg + " \033[39;49m foobar ";
var start = "\n\x1B[40m \x1B[49m\x1B[" + fg + ";" + bg + "m " + fg + ';' + bg + " \x1B[39;49m foobar ";

@@ -404,3 +414,3 @@ var expected = "\n<span style=\"background-color:rgb(0,0,0)\"> </span><span style=\"color:rgb(255,255,255);background-color:rgb(0,187,0)\"> " + fg + ';' + bg + " </span> foobar ";

it('system color, foreground', function () {
var start = "\033[38;5;1m" + "red" + "\033[0m";
var start = "\x1B[38;5;1m" + "red" + "\x1B[0m";
var expected = '<span style="color:rgb(187,0,0)">red</span>';

@@ -413,3 +423,3 @@ var au = new AnsiUp();

it('system color, foreground (bright)', function () {
var start = "\033[38;5;9m" + "red" + "\033[0m";
var start = "\x1B[38;5;9m" + "red" + "\x1B[0m";
var expected = '<span style="color:rgb(255,85,85)">red</span>';

@@ -422,3 +432,3 @@ var au = new AnsiUp();

it('system color, background', function () {
var start = "\033[48;5;1m" + "red" + "\033[0m";
var start = "\x1B[48;5;1m" + "red" + "\x1B[0m";
var expected = '<span style="background-color:rgb(187,0,0)">red</span>';

@@ -431,3 +441,3 @@ var au = new AnsiUp();

it('system color, background (bright)', function () {
var start = "\033[48;5;9m" + "red" + "\033[0m";
var start = "\x1B[48;5;9m" + "red" + "\x1B[0m";
var expected = '<span style="background-color:rgb(255,85,85)">red</span>';

@@ -440,3 +450,3 @@ var au = new AnsiUp();

it('palette, foreground', function () {
var start = "\033[38;5;171m" + "foo" + "\033[0m";
var start = "\x1B[38;5;171m" + "foo" + "\x1B[0m";
var expected = '<span style="color:rgb(215,95,255)">foo</span>';

@@ -449,3 +459,3 @@ var au = new AnsiUp();

it('palette, background', function () {
var start = "\033[48;5;171m" + "foo" + "\033[0m";
var start = "\x1B[48;5;171m" + "foo" + "\x1B[0m";
var expected = '<span style="background-color:rgb(215,95,255)">foo</span>';

@@ -458,3 +468,3 @@ var au = new AnsiUp();

it('combination of bold and palette', function () {
var start = "\033[1;38;5;171m" + "foo" + "\033[0m";
var start = "\x1B[1;38;5;171m" + "foo" + "\x1B[0m";
var expected = '<span style="font-weight:bold;color:rgb(215,95,255)">foo</span>';

@@ -467,3 +477,3 @@ var au = new AnsiUp();

it('combination of palette and bold', function () {
var start = "\033[38;5;171;1m" + "foo" + "\033[0m";
var start = "\x1B[38;5;171;1m" + "foo" + "\x1B[0m";
var expected = '<span style="font-weight:bold;color:rgb(215,95,255)">foo</span>';

@@ -478,3 +488,3 @@ var au = new AnsiUp();

it('foreground', function () {
var start = "\033[38;2;42;142;242m" + "foo" + "\033[0m";
var start = "\x1B[38;2;42;142;242m" + "foo" + "\x1B[0m";
var expected = '<span style="color:rgb(42,142,242)">foo</span>';

@@ -486,3 +496,3 @@ var au = new AnsiUp();

it('background', function () {
var start = "\033[48;2;42;142;242m" + "foo" + "\033[0m";
var start = "\x1B[48;2;42;142;242m" + "foo" + "\x1B[0m";
var expected = '<span style="background-color:rgb(42,142,242)">foo</span>';

@@ -494,3 +504,3 @@ var au = new AnsiUp();

it('both foreground and background', function () {
var start = "\033[38;2;42;142;242;48;2;1;2;3m" + "foo" + "\033[0m";
var start = "\x1B[38;2;42;142;242;48;2;1;2;3m" + "foo" + "\x1B[0m";
var expected = '<span style="color:rgb(42,142,242);background-color:rgb(1,2,3)">foo</span>';

@@ -508,3 +518,3 @@ var au = new AnsiUp();

var fg = 32;
var start = "\033[" + fg + "m " + fg + " \033[0m";
var start = "\x1B[" + fg + "m " + fg + " \x1B[0m";

@@ -522,3 +532,3 @@ var expected = "<span class=\"ansi-green-fg\"> " + fg + " </span>";

var fg = 32;
var start = "\033[" + attr + ";" + fg + "m " + fg + " \033[0m";
var start = "\x1B[" + attr + ";" + fg + "m " + fg + " \x1B[0m";

@@ -536,3 +546,3 @@ var expected = "<span class=\"ansi-green-fg\"> " + fg + " </span>";

var fg = 32;
var start = "\033[" + attr + ";" + fg + "m " + attr + ";" + fg + " \033[0m";
var start = "\x1B[" + attr + ";" + fg + "m " + attr + ";" + fg + " \x1B[0m";

@@ -550,3 +560,3 @@ var expected = '<span style="font-weight:bold"' + " class=\"ansi-green-fg\"> " + attr + ";" + fg + " </span>";

var fg = 92;
var start = "\033[" + attr + ";" + fg + "m " + attr + ";" + fg + " \033[0m";
var start = "\x1B[" + attr + ";" + fg + "m " + attr + ";" + fg + " \x1B[0m";

@@ -565,3 +575,3 @@ var expected = '<span style="font-weight:bold"' + " class=\"ansi-bright-green-fg\"> " + attr + ";" + fg + " </span>";

var bg = 42;
var start = "\033[" + attr + ";" + bg + ";" + fg + "m " + attr + ";" + bg + ";" + fg + " \033[0m";
var start = "\x1B[" + attr + ";" + bg + ";" + fg + "m " + attr + ";" + bg + ";" + fg + " \x1B[0m";

@@ -580,3 +590,3 @@ var expected = '<span style="font-weight:bold"' + " class=\"ansi-yellow-fg ansi-green-bg\"> " + attr + ";" + bg + ";" + fg + " </span>";

var bg = 102;
var start = "\033[" + attr + ";" + bg + ";" + fg + "m " + attr + ";" + bg + ";" + fg + " \033[0m";
var start = "\x1B[" + attr + ";" + bg + ";" + fg + "m " + attr + ";" + bg + ";" + fg + " \x1B[0m";

@@ -595,3 +605,3 @@ var expected = '<span style="font-weight:bold"' + " class=\"ansi-yellow-fg ansi-bright-green-bg\"> " + attr + ";" + bg + ";" + fg + " </span>";

var bg = 102;
var start = "\033[" + attr + ";" + bg + ";" + fg + "m " + attr + ";" + bg + ";" + fg + " \033[0m";
var start = "\x1B[" + attr + ";" + bg + ";" + fg + "m " + attr + ";" + bg + ";" + fg + " \x1B[0m";

@@ -610,3 +620,3 @@ var expected = '<span style="font-style:italic"' + " class=\"ansi-yellow-fg ansi-bright-green-bg\"> " + attr + ";" + bg + ";" + fg + " </span>";

var bg = 102;
var start = "\033[" + attr + ";" + bg + ";" + fg + "m " + attr + ";" + bg + ";" + fg + " \033[0m";
var start = "\x1B[" + attr + ";" + bg + ";" + fg + "m " + attr + ";" + bg + ";" + fg + " \x1B[0m";

@@ -625,3 +635,3 @@ var expected = '<span style="text-decoration:underline"' + " class=\"ansi-yellow-fg ansi-bright-green-bg\"> " + attr + ";" + bg + ";" + fg + " </span>";

var bg = 42;
var start = "\n \033[" + fg + "m " + fg + " \033[0m \n \033[" + bg + "m " + bg + " \033[0m \n zimpper ";
var start = "\n \x1B[" + fg + "m " + fg + " \x1B[0m \n \x1B[" + bg + "m " + bg + " \x1B[0m \n zimpper ";

@@ -638,3 +648,3 @@ var expected = "\n <span class=\"ansi-green-fg\"> " + fg + " </span> \n <span class=\"ansi-green-bg\"> " + bg + " </span> \n zimpper ";

it('system color, foreground', function () {
var start = "\033[38;5;1m" + "red" + "\033[0m";
var start = "\x1B[38;5;1m" + "red" + "\x1B[0m";
var expected = '<span class="ansi-red-fg">red</span>';

@@ -648,3 +658,3 @@ var au = new AnsiUp();

it('system color, foreground (bright)', function () {
var start = "\033[38;5;9m" + "red" + "\033[0m";
var start = "\x1B[38;5;9m" + "red" + "\x1B[0m";
var expected = '<span class="ansi-bright-red-fg">red</span>';

@@ -658,3 +668,3 @@ var au = new AnsiUp();

it('system color, background', function () {
var start = "\033[48;5;1m" + "red" + "\033[0m";
var start = "\x1B[48;5;1m" + "red" + "\x1B[0m";
var expected = '<span class="ansi-red-bg">red</span>';

@@ -668,3 +678,3 @@ var au = new AnsiUp();

it('system color, background (bright)', function () {
var start = "\033[48;5;9m" + "red" + "\033[0m";
var start = "\x1B[48;5;9m" + "red" + "\x1B[0m";
var expected = '<span class="ansi-bright-red-bg">red</span>';

@@ -678,3 +688,3 @@ var au = new AnsiUp();

it('palette, foreground', function () {
var start = "\033[38;5;171m" + "foo" + "\033[0m";
var start = "\x1B[38;5;171m" + "foo" + "\x1B[0m";
var expected = '<span style="color:rgb(215,95,255)">foo</span>';

@@ -688,3 +698,3 @@ var au = new AnsiUp();

it('palette, background', function () {
var start = "\033[48;5;171m" + "foo" + "\033[0m";
var start = "\x1B[48;5;171m" + "foo" + "\x1B[0m";
var expected = '<span style="background-color:rgb(215,95,255)">foo</span>';

@@ -698,3 +708,3 @@ var au = new AnsiUp();

it('combination of bold and palette', function () {
var start = "\033[1;38;5;171m" + "foo" + "\033[0m";
var start = "\x1B[1;38;5;171m" + "foo" + "\x1B[0m";
var expected = '<span style="font-weight:bold;color:rgb(215,95,255)">foo</span>';

@@ -708,3 +718,3 @@ var au = new AnsiUp();

it('combination of palette and bold', function () {
var start = "\033[38;5;171;1m" + "foo" + "\033[0m";
var start = "\x1B[38;5;171;1m" + "foo" + "\x1B[0m";
var expected = '<span style="font-weight:bold;color:rgb(215,95,255)">foo</span>';

@@ -720,3 +730,3 @@ var au = new AnsiUp();

it('foreground', function () {
var start = "\033[38;2;42;142;242m" + "foo" + "\033[0m";
var start = "\x1B[38;2;42;142;242m" + "foo" + "\x1B[0m";
var expected = '<span style="color:rgb(42,142,242)">foo</span>';

@@ -729,3 +739,3 @@ var au = new AnsiUp();

it('background', function () {
var start = "\033[48;2;42;142;242m" + "foo" + "\033[0m";
var start = "\x1B[48;2;42;142;242m" + "foo" + "\x1B[0m";
var expected = '<span style="background-color:rgb(42,142,242)">foo</span>';

@@ -738,3 +748,3 @@ var au = new AnsiUp();

it('both foreground and background', function () {
var start = "\033[38;2;42;142;242;48;2;1;2;3m" + "foo" + "\033[0m";
var start = "\x1B[38;2;42;142;242;48;2;1;2;3m" + "foo" + "\x1B[0m";
var expected = '<span style="color:rgb(42,142,242);background-color:rgb(1,2,3)">foo</span>';

@@ -753,3 +763,3 @@ var au = new AnsiUp();

// "[1;31m" is a plain text. not an escape sequence.
var start = "foo\033[1@bar[1;31mbaz\033[0m";
var start = "foo\x1B[1@bar[1;31mbaz\x1B[0m";
var au = new AnsiUp();

@@ -765,3 +775,3 @@ var l = au.ansi_to_html(start);

it('(cursor-up)', function () {
var start = "foo\033[1Abar";
var start = "foo\x1B[1Abar";
var au = new AnsiUp();

@@ -773,3 +783,3 @@ var l = au.ansi_to_html(start);

// <ESC>[1 @ (including ascii space)
var start = "foo\033[1 @bar";
var start = "foo\x1B[1 @bar";
var au = new AnsiUp();

@@ -780,3 +790,3 @@ var l = au.ansi_to_html(start);

it('(DECMC)', function () {
var start = "foo\033[?11ibar";
var start = "foo\x1B[?11ibar";
var au = new AnsiUp();

@@ -788,3 +798,3 @@ var l = au.ansi_to_html(start);

it('(RLIMGCP)', function () {
var start = "foo\033[<!3ibar";
var start = "foo\x1B[<!3ibar";
var au = new AnsiUp();

@@ -796,3 +806,3 @@ var l = au.ansi_to_html(start);

it('(DECSCL)', function () {
var start = "foo\033[61;0\"pbar"
var start = "foo\x1B[61;0\"pbar"
var au = new AnsiUp();

@@ -807,3 +817,3 @@ var l = au.ansi_to_html(start);

it('Designate G0 Character Set (UK)', function () {
var start = "foo\033(Abar";
var start = "foo\x1B(Abar";
var au = new AnsiUp();

@@ -822,4 +832,4 @@ var l = au.ansi_to_html(start);

var fg = 32;
var start1 = "\033[" + attr + ";";
var start2 = fg + "m " + fg + " \033[0m";
var start1 = "\x1B[" + attr + ";";
var start2 = fg + "m " + fg + " \x1B[0m";

@@ -838,4 +848,4 @@ var expected = "<span style=\"color:rgb(0,187,0)\"> " + fg + " </span>";

var fg = 32;
var start1 = "xyz \033";
var start2 = "[" + attr + ";" + fg + "m " + fg + " \033[0m";
var start1 = "xyz \x1B";
var start2 = "[" + attr + ";" + fg + "m " + fg + " \x1B[0m";

@@ -858,3 +868,3 @@ var expected = "<span style=\"color:rgb(0,187,0)\"> " + fg + " </span>";

it('should remove color sequence', function () {
var start = "foo \033[1;32mbar\033[0m baz";
var start = "foo \x1B[1;32mbar\x1B[0m baz";
var au = new AnsiUp();

@@ -865,3 +875,3 @@ var l = au.ansi_to_text(start);

it('should remove unsupported sequence', function () {
var start = "foo \033[1Abar";
var start = "foo \x1B[1Abar";
var au = new AnsiUp();

@@ -872,3 +882,3 @@ var l = au.ansi_to_text(start);

it('should keep multiline', function () {
var start = "foo \033[1;32mbar\nbaz\033[0m qux";
var start = "foo \x1B[1;32mbar\nbaz\x1B[0m qux";
var au = new AnsiUp();

@@ -875,0 +885,0 @@ var l = au.ansi_to_text(start);

{
"compilerOptions": {
"target": "es5",
"module": "none",
"target": "es6",
"module": "es6",
"noEmitOnError": true,
"removeComments": true,
"sourceMap": true,
"declaration": true,
"noImplicitUseStrict": true,
"outDir": "dist"
},
"exclude": [ "node_modules", "dist" ]
"sourceMap": false,
"declaration": true
}
}

Sorry, the diff of this file is not supported yet

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