cmarkgfm provides minimalist Python bindings to GitHub's fork of cmark, the C reference implementation of CommonMark. It allows parsing and rendering CommonMark and GitHub Flavored Markdown (GFM) to HTML, offering fast and accurate conversions. The library is actively maintained with frequent releases, currently at version 2025.10.22, and aims to stay up-to-date with Python versions and the underlying `cmark-gfm` C library.
pip install cmarkgfmVerified import paths — ran on the pinned version, not inferred.
This example demonstrates rendering both standard CommonMark and GitHub Flavored Markdown to HTML. It also shows how to use advanced rendering options, such as enabling smart quotes and GitHub-style code block language tags.
Upgrade your Python environment to 3.9 or newer, or pin `cmarkgfm` to a version prior to 2025.10.20 (e.g., `pip install cmarkgfm<2025.10.20`).
Review and update your CSS rules, particularly those targeting `<pre><code>` elements, to accommodate the new HTML structure for code blocks.
If you explicitly need to render potentially unsafe HTML or links and trust the input source, pass the `cmarkgfm.cmark.Options.CMARK_OPT_UNSAFE` flag to the rendering functions (e.g., `cmarkgfm.markdown_to_html(text, options=cmarkgfmOptions.CMARK_OPT_UNSAFE)`).
Ensure your Python interpreter is version 3.9 or later. Wheels are provided for Python 3.9, 3.10, 3.11, 3.12, 3.13, and 3.14.
Ensure you have a C compiler installed and configured correctly for your operating system. On Linux (Debian/Ubuntu), install `build-essential` and `python3-dev`. On macOS, install Xcode Command Line Tools by running `xcode-select --install`. On Windows, install 'Desktop development with C++' from Visual Studio Installer.
Install the development headers for the `cmark-gfm` C library through your system's package manager. For Debian/Ubuntu, use `sudo apt-get install libcmark-gfm-dev`. For Fedora, use `sudo dnf install cmark-gfm-devel`. On macOS, use `brew install cmark-gfm`.
Install or update the Xcode Command Line Tools by running `xcode-select --install` in your terminal. After installation, you might need to restart your terminal or shell.
This issue is often resolved by ensuring your build environment correctly distinguishes between C and C++ compilation or by using a version of the library that is compatible with your compiler setup. Upgrading `pip` and `setuptools` (`pip install --upgrade pip setuptools`) can sometimes help, as newer versions might handle compiler flags more robustly. If the problem persists, it may indicate an underlying incompatibility that could be addressed by installing a specific C compiler version or consulting the project's issue tracker for workarounds.
No dependency data recorded yet.