Announcing Common Lisp bindings for libcmark

Hello everyone,

I would like to announce a new project: cl-cmark. It’s a Common Lisp system (what we call libraries) which wraps the reference implementation via FFI. There are two systems provided:

  • libcmark exposes low-level 1:1 bindings to the C library
  • cmark exposes a lispy interface using CLOS classes, Lisp functions, and all the other good stuff

The cmark system is what most people will want to use, libcmark is just an escape hatch and people can write their how high-level bindings if they don’t like mine. Implementation-wise cmark is almost completely written in Lisp, the C library is only used for parsing. This means that I had to re-implement all the algorithms, such as tree traversal. I made that choice because it was easier than wrapping node pointers and making sure to avoid dangling pointers if a node is garbage-collected. This comes with a performance penalty because now I first need to parse a document in C, allocate the entire tree, then allocate a new tree in Lisp on to of the first tree, before finally freeing the C tree. Does the difference matter? Probably not.

The project is currently in beta state. Everything has been tested and the most important parts are implemented. It could be used in production right now. Nevertheless, there are some minor but nice to have features missing. There is no documentation either, I want to write it last and give myself some freedom to change the API. Once the documentation is done, that will be the 1.0 release.

I hope someone enjoys this library. Feedback is always welcome.