Registry / serialization / cmarkgfm

cmarkgfm

JSON →
library2025.10.22pypypi✓ verified 86d ago

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 cmarkgfm
INSTALL
IMPORT
SIG · CMARKGFM
C
cmarkgfm
serializationpythonv2025.10.22
Install
1.9s avg
Import
Disk
19MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2025.10.22 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 20.3MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 1.9s · import 0.000s · 21MB
19MB installed
● package 19MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

markdown_to_html
from cmarkgfm import markdown_to_html
github_flavored_markdown_to_html
from cmarkgfm import github_flavored_markdown_to_html
Options
from cmarkgfm.cmark import Options
Used for advanced rendering configurations (e.g., CMARK_OPT_UNSAFE, CMARK_OPT_SMART).

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.

import cmarkgfm from cmarkgfm.cmark import Options as cmarkgfmOptions markdown_text = "# Hello CommonMark\n\nThis is **bold** text." html_commonmark = cmarkgfm.markdown_to_html(markdown_text) print("CommonMark HTML:\n", html_commonmark) gfm_text = "This is GitHub Flavored Markdown with a ~strikethrough~ and a [link](https://github.com)." html_gfm = cmarkgfm.github_flavored_markdown_to_html(gfm_text) print("\nGFM HTML:\n", html_gfm) # Example with options: smart quotes and GitHub pre-lang options = ( cmarkgfmOptions.CMARK_OPT_SMART | cmarkgfmOptions.CMARK_OPT_GITHUB_PRE_LANG ) markdown_with_options = "“Smart quotes” and ```python\nprint('hello')\n```" html_with_options = cmarkgfm.markdown_to_html(markdown_with_options, options) print("\nHTML with Options:\n", html_with_options)
Debug
Known issues
breakingPython Version Support Changes: Version `2025.10.20` dropped support for Python 3.6, 3.7, and 3.8. Users on these versions must upgrade Python or pin `cmarkgfm` to an older version.
fix
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`).
affects: 2025.10.20 and later
breakingCode Block HTML Output Changed: In version `0.6.0`, the HTML output for code blocks changed to align with `github.com`'s output. This may break existing CSS rules if they depended on the previous structure.
fix
Review and update your CSS rules, particularly those targeting `<pre><code>` elements, to accommodate the new HTML structure for code blocks.
affects: 0.6.0 and later
gotchaUnsafe HTML/Link Rendering Default: Since version `0.5.0`, the default rendering behavior is *safe*, meaning potentially unsafe HTML (like raw HTML, JavaScript, unsafe links) is not rendered. Earlier versions defaulted to unsafe.
fix
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)`).
affects: 0.5.0 and later
gotchaPython Version Requirement: The library requires Python 3.9 or newer. Ensure your Python environment meets this requirement.
fix
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.
affects: All versions
Errors
Common errors & fixes
ERROR: Failed building wheel for cmarkgfm
This generic error indicates that pip failed to compile the C extension for `cmarkgfm`, often due to missing build tools or an improperly configured development environment on systems without pre-built wheels.
fix
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.
fatal error: cmark-gfm.h: No such file or directory
The C compiler cannot find the necessary header files for the underlying `cmark-gfm` C library, which are required to build the Python bindings.
fix
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`.
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
On macOS, this error indicates that the Xcode Command Line Tools are either not installed, are outdated, or their path is incorrectly set, preventing the C compiler from being found during the build process.
fix
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.
error: invalid argument '-std=c99' not allowed with 'C++'
This error occurs during compilation when the build system attempts to compile C code (which uses C99 standard) with a C++ compiler, which does not support the `-std=c99` flag directly.
fix
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.
Upgrade
Version history
2025.10.22latest on PyPI · released Oct 22, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
25 hits · last 30 days
node
24
OpenAI (training)
1
Resources
cmarkgfm — pip install cmarkgfm · libregistry