Skip to content

Commit

Permalink
fix: extract color param from ansi.Param (#5)
Browse files Browse the repository at this point in the history
Add test to ensure we parse colon separated color params correctly.
  • Loading branch information
aymanbagabas authored Oct 22, 2024
1 parent 8bbf702 commit 539a7e6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func readColor(idxp *int, params []int) (c ansi.Color) {
return
}
// Note: we accept both main and subparams here
switch param := ansi.Param(params[i+1]); param {
switch param := ansi.Param(params[i+1]); param.Param() {
case 2: // RGB
if i > paramsLen-4 {
return
Expand Down
4 changes: 2 additions & 2 deletions writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ var writer_cases = []struct {
},
{
name: "simple ansi 256 color bg",
input: "hello \x1b[48;5;196mworld\x1b[m",
expectedTrueColor: "hello \x1b[48;5;196mworld\x1b[m",
input: "hello \x1b[48:5:196mworld\x1b[m",
expectedTrueColor: "hello \x1b[48:5:196mworld\x1b[m",
expectedANSI256: "hello \x1b[48;5;196mworld\x1b[m",
expectedANSI: "hello \x1b[101mworld\x1b[m",
expectedAscii: "hello \x1b[mworld\x1b[m",
Expand Down

0 comments on commit 539a7e6

Please sign in to comment.