The Crystal Programming Language Forum

Introducing cr-cmark-gfm for advanced processing of Github Flavored Markdown

Hi everyone! I’m new to the Crystal community, but so far my experience has been really positive.

For a project I needed Markdown parsing and manipulation, with support for GFM and custom nodes. Given that I was already using Crystal I decided to create cr-cmark-gfm a shard that binds to the C cmark-gfm library.

Features:

  • Simple parsing and rendering of markdown content
  • Render any node of the markdown AST in the following formats:
    • HTML
    • XML
    • Plaintext
    • Commonmark (including GFM-only nodes)
    • Groff man pages
    • LaTeX
  • Create custom renderers or customize the included crystal HTML renderer, which outputs the same HTML as the library’s C renderer
  • Getters and setters for almost all of the properties of AST nodes
  • Tree traversal and manipulation
  • Directly create and customize nodes

The shard automatically downloads and compiles cmark-gfm and is fully documented, so it should be easy to give it a try.

Let me know what you think. :slight_smile:

5 Likes

That looks interesting.

Did you use some binding generator? And how well did that work if so?

Looks awesome! I’m going to give this a go on https://github.com/luckyframework/website

We’ve wanted some of the features this seems to have. Thanks for making it!

2 Likes

I didn’t use a binding generator. However both crystal-cmark and crystal-cmark-gfm, which I list as alternatives, used crystal_lib. At the beginning I only needed some functions that were well documented on the man 3 pages of the library. However my as my needs grew, especially with the GFM extensions that are not as well documented, I had to rely more and more on the C source code.

Hi Paul, love your work with Lucky. Let me know if you need more information or have issues using cr-cmark-gfm. I’ll be glad to help.