stylist: Apply CSS styles to a document tree.

[ gpl, language, library ] [ Propose Tags ] [ Report a vulnerability ]

Reusable CSS engine allowing you to parse CSS stylesheets and to query the style properties for a given element. It covers CSS parsing, selection, cascade, and inheritance, whilst allowing you to declaratively define supported properties and at-rules. The hope is that this would be useful for implementing new browser engines, web development tools, and UI frameworks.


[Skip to Readme]

Downloads

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 1.0.0.0, 1.1.0.0, 1.1.1.0, 1.2.0.0, 2.0.0.0, 2.2.0.0, 2.3.0.0, 2.4.0.0, 2.4.0.1, 2.4.0.2, 2.5.0.0, 2.5.0.1, 2.6.0.0, 2.7.0.0, 2.7.0.1
Change log ChangeLog.md
Dependencies async (>=2.1 && <2.3), base (>=4.9 && <5), css-syntax (>=0.1 && <0.2), file-embed (>=0.0.10 && <0.1), hashable (>=1.4.2 && <1.5), network-uri (>=2.6 && <2.7), regex-tdfa (>=1.3 && <1.4), stylist-traits (>=0.1.2 && <0.2), text (>=1.2.4 && <2.1), unordered-containers (>=0.2 && <0.3) [details]
License GPL-3.0-only
Copyright Adrian Cochrane copyright 2019
Author Adrian Cochrane
Maintainer alcinnz@lavabit.com
Revised Revision 1 made by alcinnz at 2023-07-03T23:46:04Z
Category Language
Source repo head: git clone https://git.adrian.geek.nz/haskell-stylist.git
Uploaded by alcinnz at 2023-06-20T01:59:11Z
Distributions
Reverse Dependencies 1 direct, 1 indirect [details]
Downloads 2613 total (19 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for stylist-2.7.0.1

[back to package description]

Haskell Stylist

Repository | Issue Tracker | Hackage

Generic CSS style engine for Haskell, intended to aid the development of new browser engines.

Haskell Stylist implements CSS selection and cascade (but not inheritance) independant of the CSS at-rules and properties understood by the caller. It is intended to ease the development of new browser engines, independant of their output targets.

For more interesting projects see: https://argonaut-constellation.org/

Versioning

The second major number indicates that more of CSS has been implemented within the existing API. Until then the error recovery rules will ensure as yet invalid CSS won't have any effect.

The first major number indicates any other change to the API, and might break your code.

API

To parse a CSS stylesheet call Data.CSS.Syntax.StyleSheet.parse which returns a variant of the passed in StyleSheet. StyleSheet is a typeclass specifying methods for parsing at-rules (parseAtRule), storing parsed style rules (addRule), and optionally setting the stylesheet's priority (setPriority).

If these ultimately call down into a Data.CSS.Syntax.Style.QueryableStyleSheet you can call cascade to resolve them into any instance of PropertyParser. Or you can use queryRules/cascade' to handle the pseudoelements yourself before applying the cascade.

PropertyParser allows to declaratively (via Haskell pattern matching) specify how to parse CSS properties, and how they're impacted by CSS inheritance. It has four methods: longhand and shorthand specify how to parse CSS properties, whilst temp and inherit specifies what the default values should be.

Building

  1. Install ghc and cabal-install. (Debian package names listed here)
  2. From within the git repository, run cabal install. This'll compile Stylist and all it's other dependencies.
  3. Run cabal test after every change you make.

Contributing

Please send patches to our issue tracker by either:

Whichever you find most convenient.

If you'd prefer to not make your email address public please contact alcinnz@argonaut-constellation.org !