mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-29 22:29:56 +02:00
committed by
Bjørn Erik Pedersen
parent
db14238ba3
commit
3ed28e4bfe
@@ -56,13 +56,13 @@ func ColorToHexString(c color.Color) string {
|
||||
func hexStringToColor(s string) (color.Color, error) {
|
||||
s = strings.TrimPrefix(s, "#")
|
||||
|
||||
if len(s) != 3 && len(s) != 6 {
|
||||
if len(s) != 3 && len(s) != 4 && len(s) != 6 && len(s) != 8 {
|
||||
return nil, fmt.Errorf("invalid color code: %q", s)
|
||||
}
|
||||
|
||||
s = strings.ToLower(s)
|
||||
|
||||
if len(s) == 3 {
|
||||
if len(s) == 3 || len(s) == 4 {
|
||||
var v string
|
||||
for _, r := range s {
|
||||
v += string(r) + string(r)
|
||||
@@ -80,7 +80,9 @@ func hexStringToColor(s string) (color.Color, error) {
|
||||
}
|
||||
|
||||
// Set Alfa to white.
|
||||
s += "ff"
|
||||
if len(s) == 6 {
|
||||
s += "ff"
|
||||
}
|
||||
|
||||
b, err := hex.DecodeString(s)
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user