Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ This release has an [MSRV][] of 1.86.
### Fixed

- Parse the named colors spelled grey (`grey`, `darkgrey`, `dimgrey`, …). ([#231][] by [@lehni][])
- Parse legacy `hsl()` with whitespace before its commas. ([#232][] by [@lehni][])

## [0.3.3][] (2026-05-05)

Expand Down Expand Up @@ -245,6 +246,7 @@ This is the initial release.
[#218]: https://github.com/linebender/color/pull/218
[#219]: https://github.com/linebender/color/pull/219
[#231]: https://github.com/linebender/color/pull/231
[#232]: https://github.com/linebender/color/pull/232

[Unreleased]: https://github.com/linebender/color/compare/v0.3.3...HEAD
[0.3.3]: https://github.com/linebender/color/releases/tag/v0.3.3
Expand Down
11 changes: 11 additions & 0 deletions color/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ impl<'a> Parser<'a> {
return Err(ParseError::ExpectedArguments);
}
let h = self.angle()?;
self.ws();
let comma = self.ch(b',');
let mode = if comma { Mode::Legacy } else { Mode::Modern };
let s = self.scaled_component(1., 1.)?.map(|x| x.max(0.));
Expand Down Expand Up @@ -734,6 +735,16 @@ mod tests {
assert_close_color(transparent, parse_color("rgba(0, 0, 0, 0)").unwrap());
}

#[test]
fn legacy_hsl_with_whitespace_before_commas() {
let green = parse_color("hsl(120, 100%, 50%)").unwrap();
assert_close_color(green, parse_color("hsl( 120 , 100% , 50% )").unwrap());
assert_close_color(
green,
parse_color("hsla( 120.0 , 100.0% , 50.0% , 1 )").unwrap(),
);
}

#[test]
fn hex() {
let red = parse_color("red").unwrap();
Expand Down
Loading