# \[ANN\] OCaml-css 0.1.0

**URL:** <https://discuss.ocaml.org/t/ann-ocaml-css-0-1-0/11809>\
**Category:** Community\
**Tags:** css, announce\
**Created:** [March 28, 2023, 8:58am UTC](https://discuss.ocaml.org/t/ann-ocaml-css-0-1-0/11809 "2023-03-28T08:58:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zoggy](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/zoggy/32/2919_2.png) [@Zoggy](https://discuss.ocaml.org/u/Zoggy)\
**Post date:** [March 28, 2023, 8:58am UTC](https://discuss.ocaml.org/t/ann-ocaml-css-0-1-0/11809/1 "2023-03-28T08:58:39Z")

</div>

Hello,

I’m pleased to announce the first release of [OCaml-css](https://zoggy.frama.io/ocaml-css/), a library to parse and print CSS. It can also expand namespaces and perform computations on property values.

Parsing uses [Angstrom](https://github.com/inhabitedtype/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 `@rule`s 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.

---

<div class="post-metadata">

**Author:** ![davesnx](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/davesnx/32/2949_2.png) [@davesnx](https://discuss.ocaml.org/u/davesnx)\
**Post date:** [March 28, 2023, 10:30am UTC](https://discuss.ocaml.org/t/ann-ocaml-css-0-1-0/11809/2 "2023-03-28T10:30:00Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Zoggy](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/zoggy/32/2919_2.png) [@Zoggy](https://discuss.ocaml.org/u/Zoggy)\
**Post date:** [March 28, 2023, 5:27pm UTC](https://discuss.ocaml.org/t/ann-ocaml-css-0-1-0/11809/3 "2023-03-28T17:27:05Z")

</div>

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](https://zoggy.frama.io/ocaml-stk/), [Ocaml-rdf](https://www.good-eris.net/ocaml-rdf/) and [OCaml-ldp](https://zoggy.frama.io/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).

---

<div class="post-metadata">

**Author:** ![davesnx](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/davesnx/32/2949_2.png) [@davesnx](https://discuss.ocaml.org/u/davesnx)\
**Post date:** [March 29, 2023, 10:26am UTC](https://discuss.ocaml.org/t/ann-ocaml-css-0-1-0/11809/4 "2023-03-29T10:26:09Z")

</div>

> [@Zoggy](#):
>
> but css values have so many syntaxes and keywords that the value type became ridiculously complicated

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](https://zoggy.frama.io/ocaml-stk/), [Ocaml-rdf](https://www.good-eris.net/ocaml-rdf/) and [OCaml-ldp](https://zoggy.frama.io/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?

---

<div class="post-metadata">

**Author:** ![Zoggy](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/zoggy/32/2919_2.png) [@Zoggy](https://discuss.ocaml.org/u/Zoggy)\
**Post date:** [March 29, 2023, 8:09pm UTC](https://discuss.ocaml.org/t/ann-ocaml-css-0-1-0/11809/5 "2023-03-29T20:09:15Z")

</div>

> [@davesnx](#):
>
> 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](https://framagit.org/zoggy/ocaml-ldp). 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.
