Cascade: A Typed CSS Toolkit in OCaml

I’m happy to announce the first release of cascade available in opam (opam install cascade) and in brew (brew install samoht/tap/cascade).

Cascade is a library:

  • a typed AST to represent CSS documents;
  • a set of (cascade-order preserving) transformations over that AST. This includes: minification of (leaf) values (lots of fun with colour-space coordinate), optimisations (aka semantic-preserving node rewrites following the great SatCSS paper), semantic-preserving canonisation, and more;
  • a diff function to compare those (optionally canonised) ASTs;
  • an apply function to apply a CSS value to an HTML document as style attributes, preserving the cascade-order.

But cascade is also a CLI tool! All of those operations are available as subcommands (with cascade fmt, cascade diff and cascade apply).

You can read more details here: Thomas Gazagnaire :: Cascade: A Typed CSS Toolkit in OCaml

You are very welcome to report issues or discuss about ideas on the GH tracker.

I have just released cascade 1.1.0 (which was just merged in opam) which improves the diff output quite a bit (especially on CSS sheets that user layers, containers, medias or other fancy structural elements) and adds something I wanted to rely on for a long time but for some reasons didn’t think about adding earlier: a differential testing harness to test how a (headless) browser interpret a random CSS sheet on optimized vs. non-optimized mode. This allowed me to find quite a few issues (most of them as corner cases, but some were a bit embarassing) and explain the size of the CHANGELOG.

Happy to get any feedback on it, especially if the documentation is useful at all (I have tried without success to get some magic odoc runes to embed runnable CSS fragments in there, is this possible at all?)