AngleSharp.Css
1.0.0-alpha-109
See the version list below for details.
dotnet add package AngleSharp.Css --version 1.0.0-alpha-109
NuGet\Install-Package AngleSharp.Css -Version 1.0.0-alpha-109
<PackageReference Include="AngleSharp.Css" Version="1.0.0-alpha-109" />
paket add AngleSharp.Css --version 1.0.0-alpha-109
#r "nuget: AngleSharp.Css, 1.0.0-alpha-109"
// Install AngleSharp.Css as a Cake Addin #addin nuget:?package=AngleSharp.Css&version=1.0.0-alpha-109&prerelease // Install AngleSharp.Css as a Cake Tool #tool nuget:?package=AngleSharp.Css&version=1.0.0-alpha-109&prerelease
AngleSharp.Css
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.
Basic Configuration
If you just want a configuration that works (as close as possible to real browsers) you should use the following code:
var config = Configuration.Default
.WithCss(); // from AngleSharp.Css
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:
- A CSS parser (implementing the
ICssParser
interface, e.g.,CssParser
) - A factory for creating CSS declarations (
IDeclarationFactory
) - The styling service that can handle CSS documents, see
CssStylingService
For an interactive DOM (i.e., to handle style
attribute changes in the HTML document) an observer needs to be registered as well.
Furthermore, for some CSSOM features (e.g., media queries) a render device is required.
var config = Configuration.Default
.WithCss()
.WithRenderDevice(new DefaultRenderDevice
{
DeviceHeight = 768,
DeviceWidth = 1024,
});
If no specific IRenderDevice
(e.g., via creating an DefaultRenderDevice
object) instance is created a default implementation will be set.
Going a bit further it is possible to Render
the current document. This render tree information can then be used to retrieve or other information, e.g.,
var tree = document.DefaultView.Render();
var node = tree.Find(document.QuerySelector("div"));
await node.DownloadResources();
The previous snippet renders the current document. Afterwards it retrieves a particular render tree node, which is related to the first found div
. Then all (CSS introduced) resources are downloaded for the node, if visible.
Advantages of AngleSharp.Css
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:
- Correct identification of edge cases
- A live CSSOM model, i.e., callbacks and everything
- Computing the styling of certain elements
- Cascades of stylesheets
- Validation (and property-based exposure) of CSS declarations
- Responsive design considerations
- Full access to the value with different converters
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.
Features
- Feature validators (e.g., for
@supports
) - Document functions (e.g., for
domain
) - Pseudo elements (e.g.,
::before
) - Declarations (e.g.,
display
) incl. knowledge of their values - Dynamic DOM coupling (i.e., to react to
style
attribute changes) - CSS custom properties (also known as CSS variables) with extensibility
- Media queries and all other commonly implemented rules
- Calculated values (i.e.,
calc(20px + 50%)
) - Window-based declaration calculations, see
window.GetComputedStyle
Participating
Participation in the project is highly welcome. For this project the same rules as for the AngleSharp core project may be applied.
If you have any question, concern, or spot an issue then please report it before opening a pull request. An initial discussion is appreciated regardless of the nature of the problem.
Live discussions can take place in our Gitter chat, which supports using GitHub accounts.
This project has adopted the code of conduct defined by the Contributor Covenant to clarify expected behavior in our community.
For more information see the .NET Foundation Code of Conduct.
.NET Foundation
This project is supported by the .NET Foundation.
License
The MIT License (MIT)
Copyright (c) 2016 - 2024 AngleSharp
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 is compatible. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 is compatible. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
- AngleSharp (>= 1.0.0 && < 2.0.0)
NuGet packages (33)
Showing the top 5 NuGet packages that depend on AngleSharp.Css:
Package | Downloads |
---|---|
HtmlSanitizer
Cleans HTML from constructs that can be used for cross-site scripting (XSS) |
|
bunit.web
bUnit.web is the web specific parts of bUnit, that enables you to easily test and verify the output of Blazor (web) component. |
|
Omnia.Fx
Package Description |
|
AngleSharp.Diffing
Provides a complete diffing model of HTML. |
|
bunit
bUnit is a testing library for Blazor components. You can easily define components under test in C# or Razor syntax and verify outcome using semantic HTML diffing/comparison logic. You can interact with and inspect the component under test, trigger event handlers, provide cascading values, and inject services. bUnit also includes a complete fake implementation of Blazor's authentication and authorization logic, navigation manager, and JSInterop. |
GitHub repositories (16)
Showing the top 5 popular GitHub repositories that depend on AngleSharp.Css:
Repository | Stars |
---|---|
ldqk/Masuit.Tools
全龄段友好的C#万能工具库,码数吐司库,包含一些常用的操作类,大都是静态类,加密解密,反射操作,权重随机筛选算法,分布式短id,表达式树,linq扩展,文件压缩,多线程下载,硬件信息,字符串扩展方法,日期时间扩展操作,中国农历,大文件拷贝,图像裁剪,验证码,断点续传,集合扩展、Excel导出等常用封装。诸多功能集一身,代码量不到2MB!
|
|
mganss/HtmlSanitizer
Cleans HTML to avoid XSS attacks
|
|
smartstore/Smartstore
A modular, scalable and ultra-fast open-source all-in-one eCommerce platform built on ASP.NET Core 7
|
|
bUnit-dev/bUnit
bUnit is a testing library for Blazor components that make tests look, feel, and runs like regular unit tests. bUnit makes it easy to render and control a component under test’s life-cycle, pass parameter and inject services into it, trigger event handlers, and verify the rendered markup from the component using a built-in semantic HTML comparer.
|
|
pnp/PnP-PowerShell
SharePoint PnP PowerShell CmdLets
|
Version | Downloads | Last updated |
---|---|---|
1.0.0-beta.144 | 205,677 | 9/20/2024 |
1.0.0-beta.139 | 1,162,125 | 2/26/2024 |
1.0.0-beta.137 | 120 | 2/26/2024 |
1.0.0-beta.130 | 172 | 2/26/2024 |
1.0.0-beta.127 | 98 | 2/26/2024 |
1.0.0-beta.122 | 257 | 2/25/2024 |
1.0.0-alpha-99 | 1,066,257 | 6/18/2023 |
1.0.0-alpha-98 | 1,302 | 6/18/2023 |
1.0.0-alpha-97 | 1,399 | 6/15/2023 |
1.0.0-alpha-117 | 1,345 | 1/19/2024 |
1.0.0-alpha-113 | 687 | 1/19/2024 |
1.0.0-alpha-111 | 762 | 1/18/2024 |
1.0.0-alpha-109 | 682 | 1/18/2024 |
1.0.0-alpha-108 | 702 | 1/17/2024 |
1.0.0-alpha-107 | 639 | 1/17/2024 |
1.0.0-alpha-106 | 694 | 1/17/2024 |
1.0.0-alpha-104 | 701 | 1/16/2024 |
1.0.0-alpha-103 | 682 | 1/16/2024 |
1.0.0-alpha-102 | 715 | 1/16/2024 |
1.0.0-alpha-101 | 715 | 1/16/2024 |
1.0.0-alpha-100 | 61,248 | 12/15/2023 |
0.17.0 | 22,337,218 | 1/15/2023 |
0.17.0-alpha-87 | 1,306 | 1/15/2023 |
0.17.0-alpha-86 | 1,309 | 1/15/2023 |
0.17.0-alpha-80 | 2,458 | 11/1/2022 |
0.17.0-alpha-78 | 28,983 | 6/2/2022 |
0.17.0-alpha-77 | 1,403 | 6/2/2022 |
0.17.0-alpha-76 | 1,292 | 6/1/2022 |
0.17.0-alpha-75 | 1,371 | 5/31/2022 |
0.16.4 | 10,736,186 | 2/15/2022 |
0.16.4-alpha-72 | 1,271 | 2/15/2022 |
0.16.4-alpha-68 | 1,563 | 2/10/2022 |
0.16.3 | 1,229,700 | 1/6/2022 |
0.16.3-alpha-65 | 1,335 | 1/6/2022 |
0.16.2 | 579,958 | 11/5/2021 |
0.16.2-alpha-62 | 2,629 | 11/26/2021 |
0.16.2-alpha-61 | 4,181 | 11/25/2021 |
0.16.2-alpha-60 | 4,235 | 11/25/2021 |
0.16.2-alpha-42 | 4,296 | 11/25/2021 |
0.16.2-alpha-35 | 1,409 | 11/6/2021 |
0.16.2-alpha-30 | 1,376 | 11/5/2021 |
0.16.2-alpha-29 | 1,449 | 11/4/2021 |
0.16.2-alpha-28 | 1,392 | 11/4/2021 |
0.16.1 | 4,630,655 | 8/10/2021 |
0.16.1-alpha-27 | 1,415 | 11/4/2021 |
0.16.1-alpha-24 | 1,386 | 8/10/2021 |
0.16.0 | 775,853 | 6/12/2021 |
0.16.0-alpha-23 | 1,366 | 6/30/2021 |
0.16.0-alpha-19 | 1,450 | 6/12/2021 |
0.15.1 | 12,468 | 6/12/2021 |
0.15.1-alpha-13 | 1,385 | 6/12/2021 |
0.15.1-alpha-11 | 92,289 | 5/10/2021 |
0.15.0 | 2,656,675 | 4/23/2021 |
0.15.0-alpha-7 | 1,381 | 4/23/2021 |
0.14.3-alpha-5 | 1,467 | 4/22/2021 |
0.14.3-alpha-4 | 1,437 | 4/22/2021 |
0.14.3-alpha-166 | 72,205 | 12/11/2020 |
0.14.3-alpha-165 | 8,084 | 6/23/2020 |
0.14.2 | 10,493,871 | 6/11/2020 |
0.14.2-alpha-163 | 1,683 | 6/11/2020 |
0.14.2-alpha-162 | 1,659 | 6/11/2020 |
0.14.1 | 4,062,657 | 5/4/2020 |
0.14.1-alpha-161 | 1,674 | 6/11/2020 |
0.14.0 | 673,761 | 4/8/2020 |
0.14.0-alpha-160 | 1,664 | 5/22/2020 |
0.14.0-alpha-154 | 1,799 | 4/6/2020 |
0.14.0-alpha-152 | 1,713 | 4/6/2020 |
0.14.0-alpha-149 | 1,845 | 4/4/2020 |
0.14.0-alpha-147 | 1,665 | 4/4/2020 |
0.14.0-alpha-145 | 1,785 | 4/4/2020 |
0.14.0-alpha-143 | 1,791 | 4/4/2020 |
0.14.0-alpha-139 | 1,828 | 3/31/2020 |
0.14.0-alpha-138 | 1,747 | 3/30/2020 |
0.13.0 | 642,754 | 9/6/2019 |
0.13.0-alpha-135 | 1,999 | 2/1/2020 |
0.13.0-alpha-131 | 1,696 | 9/6/2019 |
0.13.0-alpha-123 | 1,771 | 8/23/2019 |
0.13.0-alpha-121 | 1,738 | 8/23/2019 |
0.13.0-alpha-119 | 1,864 | 6/9/2019 |
0.13.0-alpha-117 | 1,679 | 5/28/2019 |
0.13.0-alpha-116 | 1,803 | 5/24/2019 |
0.13.0-alpha-115 | 1,793 | 5/20/2019 |
0.13.0-alpha-114 | 1,797 | 5/18/2019 |
0.13.0-alpha-113 | 1,787 | 5/18/2019 |
0.12.1 | 70,715 | 5/14/2019 |
0.12.0 | 2,092 | 5/12/2019 |
0.10.0 | 54,121 | 1/5/2019 |