[ANN] OCaml-css 0.1.0

Hello,

I’m pleased to announce the first release of OCaml-css, a library to parse and print CSS. It can also expand namespaces and perform computations on property values.

Parsing uses Angstrom to dynamically choose the parser when encountering a property declaration. Not all properties are handled yet but the parser can be extended by defining additional properties. Some shorthand properties are handled too. Some @rules are not handled by now, they are parsed and returned as strings, with a warning in log.

The css package should be available soon in opam.

12 Likes

Nice, it’s always cool to see other approaches to parsing CSS. I made a menhir parser and my custom parser combinator for CSS type-checking (I wish I used angstrom for this!)

I see you are supporting a small subset of CSS, what are you using this for?

Thanks and congrats for the release!

Thanks.

I had made a first attempt using regular lexer and menhir too, but css values have so many syntaxes and keywords that the value type became ridiculously complicated. Moreover, when looking at a property’s value, only a subset of the whole value type was really valid. Using Angstrom’s parser combinators is a far better approach IMHO: this ensures that only values that make sense are returned by the parser. And it can be extended by the library’s user.

I develop a web browser to read, write ans share annotations (using Stk, Ocaml-rdf and OCaml-ldp). I do not intend to support all CSS, but only the most commonly used properties to be able to display pages in a readable way (and I do not intend to support javascript either).

1 Like

Yes, I parse the values as strings and have a parser combinator which does similarly to your approach with Angstrong. I should probably spend some time refactoring to actually use ansgstrong!

I develop a web browser to read, write ans share annotations (using Stk , Ocaml-rdf and OCaml-ldp ). I do not intend to support all CSS, but only the most commonly used properties to be able to display pages in a readable way (and I do not intend to support javascript either).

That is crazy cool, where I can follow/know more about all of this? I see you are not using Github and following the development of those tools make it a little hard for me, do you plan to have mirrors?

OCaml-ldp development is hosted here. I should make a release.

Development of my browser is not public yet, I can’t work on it as much as I would like. I have no plan for mirrors regarding my repositories.

1 Like