diff --git a/lib/parsecolor/parsecolor.go b/lib/parsecolor/parsecolor.go index f4782117..d77a30de 100644 --- a/lib/parsecolor/parsecolor.go +++ b/lib/parsecolor/parsecolor.go @@ -50,7 +50,10 @@ func Parse(s string) (nrgba color.NRGBA, ok bool) { if !startsWithHash { adjustment, p, n := 0, 0, len(s) - if string(buf[:4]) == "dark" { + if ((n == 4) && (string(buf[:4]) == "none")) || + ((n == 11) && (string(buf[:11]) == "transparent")) { + return color.NRGBA{}, true + } else if string(buf[:4]) == "dark" { adjustment = 1 p += 4 n -= 4 diff --git a/lib/parsecolor/parsecolor_test.go b/lib/parsecolor/parsecolor_test.go index e54b9acd..5e161bb0 100644 --- a/lib/parsecolor/parsecolor_test.go +++ b/lib/parsecolor/parsecolor_test.go @@ -39,6 +39,11 @@ func TestParse(tt *testing.T) { {color.NRGBA{0x77, 0x88, 0x99, 0xff}, true, "789"}, {color.NRGBA{0x88, 0x99, 0xaa, 0x77}, true, "789a"}, + {color.NRGBA{0x00, 0x00, 0x00, 0xff}, true, "000"}, + {color.NRGBA{0x00, 0x00, 0x00, 0x00}, true, "0000"}, + {color.NRGBA{0x00, 0x00, 0x00, 0x00}, true, "none"}, + {color.NRGBA{0x00, 0x00, 0x00, 0x00}, true, "transparent"}, + {color.NRGBA{0x00, 0x00, 0x00, 0x00}, false, "#asdf"}, {color.NRGBA{0x00, 0x00, 0x00, 0x00}, false, "darkabc123"}, {color.NRGBA{0x00, 0x00, 0x00, 0x00}, false, "dark#abc123"}, diff --git a/snippet/parse-color.c b/snippet/parse-color.c index 6ebd2d8d..40d98efc 100644 --- a/snippet/parse-color.c +++ b/snippet/parse-color.c @@ -85,7 +85,10 @@ parse_color(const char* s_ptr, size_t s_len) { const char* b_ptr = &buf[0]; size_t b_len = s_len; int adjustment = 0; - if ((b_len > 4) && !memcmp(buf, "dark", 4)) { + if (((b_len == 4) && !memcmp(buf, "none", 4)) || + ((b_len == 11) && !memcmp(buf, "transparent", 11))) { + return 0; + } else if ((b_len > 4) && !memcmp(buf, "dark", 4)) { adjustment = 1; b_ptr += 4; b_len -= 4;