Announcement: Ruby wrapper for libcmark

I’d like to announce the introduction of CommonMarker, a Ruby implementation of the CommonMark spec. Unlike other Ruby implementations I found, this directly wraps the native C library, which means performance is nearly on-par with using raw C.

The project was taken over by me from @jgm at some point last week. My eternal thanks to him for starting it–I had to change only very little.

All of the C tests are passing. The Ruby implementation also offers the ability to build a custom renderer, though this is a bit slower than just using CMark natively. It’s kept simply as a Git submodule.

Pull requests are welcomed! I’ll try to keep in sync with CMark as often as possible.

1 Like

Excellent! I’ve added this to the list of

One query: “Make sure to always call free when you’re done.” Is there a way to set things up so that the ruby object calls free automatically when it is garbage-collected? I know that is possible with Haskell FFI.

Yes, absolutely. I also want to use the AST walk in C, as you originally suggested. I wanted to get a release out there first, though, to gauge interest in the project, before investing more time wading through the extension. :smile:

Version 0.1.3 now no longer requires you to call free.