All Projects → AngleSharp → Anglesharp.css

AngleSharp / Anglesharp.css

Licence: mit
👼 Library to enable support for cascading stylesheets in AngleSharp.

Projects that are alternatives of or similar to Anglesharp.css

Go Deb Version
A golang library for parsing deb package versions
Stars: ✭ 21 (-22.22%)
Mutual labels:  parser, library
Length.js
📏 JavaScript library for length units conversion.
Stars: ✭ 292 (+981.48%)
Mutual labels:  parser, library
Sdk
Library for using Grafana' structures in Go programs and client for Grafana REST API.
Stars: ✭ 193 (+614.81%)
Mutual labels:  parser, library
Phplrt
PHP Language Recognition Tool
Stars: ✭ 127 (+370.37%)
Mutual labels:  parser, library
Swaggen
OpenAPI/Swagger 3.0 Parser and Swift code generator
Stars: ✭ 385 (+1325.93%)
Mutual labels:  parser, library
Libnmea
Lightweight C library for parsing NMEA 0183 sentences
Stars: ✭ 146 (+440.74%)
Mutual labels:  parser, library
Php Svg
Vector graphics (SVG) library for PHP
Stars: ✭ 256 (+848.15%)
Mutual labels:  parser, library
Argumentum
C++ command line parsing library
Stars: ✭ 92 (+240.74%)
Mutual labels:  parser, library
Anglesharp
👼 The ultimate angle brackets parser library parsing HTML5, MathML, SVG and CSS to construct a DOM based on the official W3C specifications.
Stars: ✭ 4,018 (+14781.48%)
Mutual labels:  parser, library
Shortcode
Advanced shortcode (BBCode) parser and engine for PHP
Stars: ✭ 331 (+1125.93%)
Mutual labels:  parser, library
Typin
Declarative framework for interactive CLI applications
Stars: ✭ 126 (+366.67%)
Mutual labels:  parser, library
Compiler
The Hoa\Compiler library.
Stars: ✭ 458 (+1596.3%)
Mutual labels:  parser, library
Commonmark Java
Java library for parsing and rendering CommonMark (Markdown)
Stars: ✭ 1,675 (+6103.7%)
Mutual labels:  parser, library
Isobmff
C++ Library for ISO/IEC 14496-12 - ISO Base Media File Format (QuickTime, MPEG-4, HEIF, etc)
Stars: ✭ 157 (+481.48%)
Mutual labels:  parser, library
Simplepie
A simple Atom/RSS parsing library for PHP.
Stars: ✭ 1,389 (+5044.44%)
Mutual labels:  parser, library
Vmime
VMime Mail Library
Stars: ✭ 218 (+707.41%)
Mutual labels:  parser, library
Internettools
XPath/XQuery 3.1 interpreter for Pascal with compatibility modes for XPath 2.0/XQuery 1.0/3.0, custom and JSONiq extensions, XML/HTML parsers and classes for HTTP/S requests
Stars: ✭ 82 (+203.7%)
Mutual labels:  parser, library
Rst
PHP library to parse reStructuredText documents
Stars: ✭ 90 (+233.33%)
Mutual labels:  parser, library
Regex
The Hoa\Regex library.
Stars: ✭ 308 (+1040.74%)
Mutual labels:  parser, library
Javalang
Pure Python Java parser and tools
Stars: ✭ 408 (+1411.11%)
Mutual labels:  parser, library

logo

AngleSharp.Css

Build Status GitHub Tag NuGet Count Issues Open Gitter Chat StackOverflow Questions CLA Assistant

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 - 2020 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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].