Skip to content

Alternative to cmarkgfm #339

@miketheman

Description

@miketheman

I recently spent some time modernizing cmarkgfm, and as I spent more time with it, I started asking questions about the underlying cmark-gfm spec, which hasn't seen a released update in over 2 years.

cmarkgfm has been pretty stable, possibly in no small part to the spec also not changing.

In researching some of the reported issues here, as well as in cmarkgfm, and on pypi/warehouse, I've since learned that (this can get confusing, sorry if it seems obvious!):

  • GitHub uses a gem named github-markup to decide which renderer to use to render an input
  • To render Markdown, github-markup in turn calls on commonmarker gem
  • commonmarker prior to version 1.0.0 wrapped the libcmark C library, similar to how cmarkgfm (Python) wraps cmark-gfm (C). commonmarker since 1.0.0 (December 24, 2023) wraps a Rust crate comrak instead.

comrak (Rust) appears to be used by Reddit, docs.rs, crates.io, GitLab as well.

Apparently GitHub has abandoned the effort of trying to maintain their own specification changes to be compatible with the Commonmark spec, as evidenced by the differences on their repo:

Image

and at least one query has not received a reply, as well as another noting the differences in the source vs the published HTML sepc.

This leads me to ask: Should we continue trying to use cmarkgfm Python package and the underlying cmark-gfm C library, or use the same underlying library that GitHub uses?

comrak (Rust) supports the same extensions as cmark-gfm and note their relationship to cmark-gfm. The main comrak contributor also currently appears to work for GitHub, and there a couple other contributors, so it's not a single-maintainer project. And with GitHub using it to render their markdown content, it has a higher probability of continued maintenance and feature-parity.

2025 saw the release of a Python wrapper: https://pypi.org/project/comrak/

Converting the existing use cases to use comrak instead of cmarkgfm is relatively easy, and enables us to explore new features that have landed on services like GitHub.com that our end users have had to find creative workarounds.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions