Skip to content

Commit

Permalink
Fixes #88 - broken handling of SGR 22 in 6.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
drudru committed Aug 25, 2023
1 parent 4f80666 commit 3109614
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 12 deletions.
3 changes: 2 additions & 1 deletion ansi_up.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var PacketKind;
})(PacketKind || (PacketKind = {}));
export class AnsiUp {
constructor() {
this.VERSION = "6.0.0";
this.VERSION = "6.0.1";
this.setup_palettes();
this._use_classes = false;
this.bold = false;
Expand Down Expand Up @@ -299,6 +299,7 @@ export class AnsiUp {
}
else if (num === 22) {
this.faint = false;
this.bold = false;
}
else if (num === 23) {
this.italic = false;
Expand Down
4 changes: 2 additions & 2 deletions ansi_up.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ interface TextPacket {

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

//
// *** SEE README ON GITHUB FOR PUBLIC API ***
Expand Down Expand Up @@ -626,7 +626,7 @@ export class AnsiUp
} 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 === 22) { this.faint = false; this.bold = false;
} else if (num === 23) { this.italic = false;
} else if (num === 24) { this.underline = false;

Expand Down
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ansi_up",
"version": "6.0.0",
"version": "6.0.1",
"description": "Convert ansi sequences in strings to colorful HTML",
"keywords": [
"ansi",
Expand Down
49 changes: 49 additions & 0 deletions test/ansi_up-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,55 @@ describe('ansi_up', function () {
l.should.eql(expected);
});

it('should reset a bold attr to html', function () {
var attr = 1;
var fg = 32;
var start = "\x1B[" + attr + ";" + fg + ";21m " + attr + ";" + fg + " \x1B[0m";

var expected = "<span style=\"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 reset a faint attr to html', function () {
var attr = 2;
var fg = 32;
var start = "\x1B[" + attr + ";" + fg + ";22m " + attr + ";" + fg + " \x1B[0m";

var expected = "<span style=\"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 reset a bold and faint attr to just faint html', function () {
var attr = "1;2";
var fg = 32;
var start = "\x1B[" + attr + ";" + fg + ";21m " + 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 reset a bold and faint attr to just html', function () {
var attr = "1;2";
var fg = 32;
var start = "\x1B[" + attr + ";" + fg + ";22m " + attr + ";" + fg + " \x1B[0m";

var expected = "<span style=\"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;
Expand Down

0 comments on commit 3109614

Please sign in to comment.