You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+29Lines changed: 29 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,6 +11,23 @@
11
11
12
12
AngleSharp.Css extends the core AngleSharp library with some more powerful CSS capabilities. This repository is the home of the source for the AngleSharp.Css NuGet package.
13
13
14
+
## Basic Configuration
15
+
16
+
If you just want a configuration *that works* (as close as possible to real browsers) you should use the following code:
17
+
18
+
```cs
19
+
varconfig=Configuration.Default
20
+
.WithCss(); // from AngleSharp.Css
21
+
```
22
+
23
+
This will register a parser for CSS related content. The CSS parsing options and more could be set with parameters of the `WithCss` method. Alternatively, all the (desired) parts may be registered individually as well. That mostly boils down to three elementary parts:
24
+
25
+
- A CSS parser (implementing the `ICssParser` interface, e.g., `CssParser`)
26
+
- A factory for creating CSS declarations (`IDeclarationFactory`)
27
+
- The styling service that can handle CSS documents, see `CssStylingService`
28
+
29
+
For an interactive DOM (i.e., to handle `style` attribute changes in the HTML document) an observer needs to be registered as well.
30
+
14
31
## Advantages of AngleSharp.Css
15
32
16
33
The core library already contains the CSS selector parser and the most basic classes and interfaces for dealing with the CSSOM. AngleSharp.Css brings the following advantages and use cases to life:
@@ -25,6 +42,18 @@ The core library already contains the CSS selector parser and the most basic cla
25
42
26
43
The main idea behind AngleSharp.Css is to expose the CSSOM as it would be in the browser (and potentially beyond, i.e., useful for being used by editors). Originally, most of the code found here was embedded in the AngleSharp.Core library, however, due to the overhead for HTML use cases it was decided to transfer the code into its own repository.
27
44
45
+
## Features
46
+
47
+
- Feature validators (e.g., for `@supports`)
48
+
- Document functions (e.g., for `domain`)
49
+
- Pseudo elements (e.g., `::before`)
50
+
- Declarations (e.g., `display`) incl. knowledge of their values
51
+
- Dynamic DOM coupling (i.e., to react to `style` attribute changes)
52
+
- CSS custom properties (also known as CSS variables) with extensibility
53
+
- Media queries and all other commonly implemented rules
54
+
- Calculated values (i.e., `calc(20px + 50%)`)
55
+
- Window-based declaration calculations, see `window.GetComputedStyle`
56
+
28
57
## Participating
29
58
30
59
Participation in the project is highly welcome. For this project the same rules as for the AngleSharp core project may be applied.
0 commit comments