Skip to content

Release 1.0.0 #157

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 64 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
2a2f5da
Empty string behaves like null
FlorianRappl Feb 16, 2023
8ecae08
Update ColorParser.cs
jogibear9988 Apr 20, 2023
49b4877
Merge pull request #141 from jogibear9988/patch-1
FlorianRappl Apr 20, 2023
6ab7166
WIP
FlorianRappl Jun 6, 2023
c8321b8
Working on new media list parser
FlorianRappl Jun 10, 2023
3b89d01
Fixed serialization due to broken longhands #129
FlorianRappl Jun 14, 2023
b9aef4c
Fixed appending eof character #123
FlorianRappl Jun 14, 2023
6905fa5
Fixed missing semicolon separator #135
FlorianRappl Jun 14, 2023
1f3d718
Fixed keyframe stop truncation #128
FlorianRappl Jun 14, 2023
12f61a1
Fixed grid and grid-gap ordering #137
FlorianRappl Jun 14, 2023
ad7aff4
Improved CSS minification of grid #89
FlorianRappl Jun 14, 2023
78740fe
Added more tests for background-size
FlorianRappl Jun 14, 2023
6d52e79
Updated media parsing #133
FlorianRappl Jun 15, 2023
10845f2
Added test to verify fix for #133
FlorianRappl Jun 15, 2023
314805d
Added test to validate #140
FlorianRappl Jun 15, 2023
9fe8a86
Added 8-digit hex color #132
FlorianRappl Jun 15, 2023
50d8e9d
WIP #136
FlorianRappl Jun 15, 2023
15cb522
Validate that #126 can be done
FlorianRappl Jun 16, 2023
c9bc34e
Added rgb function syntax L4 #131
FlorianRappl Jun 18, 2023
4ceb46c
Prepare for more color functions
FlorianRappl Jun 18, 2023
649beb7
Added implementation of new color functions #131
FlorianRappl Jun 18, 2023
240cee3
Update Directory.Build.props
FlorianRappl Dec 15, 2023
7a96a55
Added support for recent list-type
FlorianRappl Jan 16, 2024
dba9069
Fixed text align behavior
FlorianRappl Jan 16, 2024
6ab4a63
Improved rule prios
FlorianRappl Jan 16, 2024
0c3aa78
Fix for GetInnerText #155
FlorianRappl Jan 16, 2024
c39af8a
Working on CSS nesting
FlorianRappl Jan 17, 2024
bf4db74
Allow disabling of nesting
FlorianRappl Jan 17, 2024
06b15e3
Updated nested implementation #148
FlorianRappl Jan 17, 2024
e97935a
Added margin and padding decls
FlorianRappl Jan 17, 2024
a5bcabf
Improved render tree
FlorianRappl Jan 17, 2024
baca67a
Improved computation #136
FlorianRappl Jan 17, 2024
1c9efd4
Prepared computation model
FlorianRappl Jan 18, 2024
8295892
Implemented CSS variable resolution #62
FlorianRappl Jan 18, 2024
9abdd1b
Added new metric values
FlorianRappl Jan 18, 2024
ed2b542
Activated disabled test
FlorianRappl Jan 18, 2024
64df5cf
Refactored naming to be consistent
FlorianRappl Jan 18, 2024
e8dab26
Refactored value model names
FlorianRappl Jan 18, 2024
2a44071
Extended model for css integer
FlorianRappl Jan 19, 2024
d856b31
Integrate percentage
FlorianRappl Jan 19, 2024
8205cf8
Added extra API method for computing style
FlorianRappl Jan 19, 2024
caab82a
Added test for new API
FlorianRappl Jan 19, 2024
c51cd43
Use latest version of AngleSharp
FlorianRappl Jan 19, 2024
973d83c
Prepare docs update
FlorianRappl Jan 19, 2024
b755de0
Updated CI/CD
FlorianRappl Jan 19, 2024
adba277
Updated CI/CD
FlorianRappl Feb 25, 2024
0652a66
Re-added dropped character
FlorianRappl Feb 25, 2024
333885b
Fix NullReferenceException in ChangeDeclarations
meziantou Feb 26, 2024
b36924d
review
meziantou Feb 26, 2024
46635ab
Fix nullable reference exception in CssOriginValue
meziantou Feb 26, 2024
c1c83ee
Merge pull request #160 from meziantou/fix-nre
FlorianRappl Feb 26, 2024
e68db8f
Update CssOriginValue.cs
meziantou Feb 26, 2024
102cc32
Merge pull request #162 from meziantou/nre-CssOriginValue
FlorianRappl Feb 26, 2024
dbf8aca
Uniformize CssValue.Equals implementation
meziantou Feb 26, 2024
151244d
Fix NullReferenceException in CssShadowValue
meziantou Feb 26, 2024
1d40f1c
Merge pull request #163 from meziantou/uniformize-cssvalue-comparison
FlorianRappl Feb 26, 2024
ff33ad7
Merge pull request #164 from meziantou/fix-nre-CssShadowValue
FlorianRappl Feb 26, 2024
4c9f16a
Get declarations
SebastianStehle Sep 19, 2024
459b48c
Merge pull request #176 from SebastianStehle/devel
FlorianRappl Sep 20, 2024
67c87c0
Updated license ref
FlorianRappl Jan 26, 2025
465b500
Updated to 2025
FlorianRappl Jan 26, 2025
5617e86
Updated year
FlorianRappl Jan 26, 2025
8889e06
Fix "transform: rotateZ" becoming "transform: rotateY"
NSGolova May 24, 2025
4b4d41e
Merge pull request #185 from NSGolova/devel
FlorianRappl May 25, 2025
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
Prev Previous commit
Next Next commit
Added rgb function syntax L4 #131
  • Loading branch information
FlorianRappl committed Jun 18, 2023
commit c9bc34ea65abe9ee72b15d91eb29f5f9f35cf5b6
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Released on tbd.
- Added further compactification of CSS tuples (#89, #93)
- Added support for 8-digit hex color codes (#132)
- Added more CSSOM possibilities and helpers (#6)
- Added parts of recent color spec update such as `rgb` with spaces (#131)

# 0.17.0

Expand Down
33 changes: 33 additions & 0 deletions src/AngleSharp.Css.Tests/Functions/CssColorFunction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,39 @@ public void ColorNotParsedCorrectly_Issue109()
var color = s.GetColor();
Assert.AreEqual("rgba(0, 17, 0, 1)", color);
}

[Test]
public void ParseRgbWithSpacesL4_Issue131()
{
var html = @"<p style='color: rgb(255 122 127 / 80%)'>Text</p>";
var dom = ParseDocument(html);
var p = dom.QuerySelector("p");
var s = p.GetStyle();
var color = s.GetColor();
Assert.AreEqual("rgba(255, 122, 127, 0.8)", color);
}

[Test]
public void ParseRgbWithSpacesInPercentL4_Issue131()
{
var html = @"<p style='color: rgb(100% 10% 50% / 0.7)'>Text</p>";
var dom = ParseDocument(html);
var p = dom.QuerySelector("p");
var s = p.GetStyle();
var color = s.GetColor();
Assert.AreEqual("rgba(255, 26, 128, 0.7)", color);
}

[Test]
public void ParseRgbWithSpacesAndNoneL4_Issue131()
{
var html = @"<p style='color: rgb(100% none 50% / 35%)'>Text</p>";
var dom = ParseDocument(html);
var p = dom.QuerySelector("p");
var s = p.GetStyle();
var color = s.GetColor();
Assert.AreEqual("rgba(255, 0, 128, 0.35)", color);
}
}
}

69 changes: 68 additions & 1 deletion src/AngleSharp.Css/Parser/Micro/ColorParser.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace AngleSharp.Css.Parser
{
using AngleSharp.Css.Values;
using AngleSharp.Io;
using AngleSharp.Text;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -92,6 +93,52 @@ static class ColorParser
}

private static Color? ParseRgba(StringSource source)
{
var pos = source.Index;
var color = ParseRgbaLegacy(source);

if (!color.HasValue)
{
source.BackTo(pos);
return ParseRgbaModern(source);
}

return color.Value;
}

private static Color? ParseRgbaModern(StringSource source)
{
var r = ParseRgbOrNoneComponent(source);
source.SkipSpacesAndComments();
var g = ParseRgbOrNoneComponent(source);
source.SkipSpacesAndComments();
var b = ParseRgbOrNoneComponent(source);
source.SkipSpacesAndComments();
var c = source.Current;
var a = new Nullable<Double>(1.0);

if (r != null && g != null && b != null)
{
source.SkipCurrentAndSpaces();

if (c == Symbols.Solidus)
{
a = ParseAlpha(source);
source.SkipSpacesAndComments();
c = source.Current;
source.SkipCurrentAndSpaces();
}

if (c == Symbols.RoundBracketClose)
{
return Color.FromRgba(r.Value, g.Value, b.Value, a.Value);
}
}

return null;
}

private static Color? ParseRgbaLegacy(StringSource source)
{
var r = ParseRgbComponent(source);
var c1 = source.SkipGetSkip();
Expand Down Expand Up @@ -205,6 +252,26 @@ static class ColorParser
return null;
}

private static Byte? ParseRgbOrNoneComponent(StringSource source)
{
var pos = source.Index;
var value = ParseRgbComponent(source);

if (value.HasValue)
{
return value;
}

source.BackTo(pos);

if (source.IsIdentifier(CssKeywords.None))
{
return 0;
}

return null;
}

private static Byte? ParseRgbComponent(StringSource source)
{
var unit = source.ParseUnit();
Expand All @@ -214,7 +281,7 @@ static class ColorParser
{
if (unit.Dimension == "%")
{
return (Byte)((255f * value) / 100f);
return (Byte)Math.Round((255.0 * value) / 100.0);
}
else if (unit.Dimension == String.Empty)
{
Expand Down