{"id":6330,"library":"cmarkgfm","title":"cmarkgfm: GitHub Flavored Markdown (GFM) Parser","description":"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.","status":"active","version":"2025.10.22","language":"en","source_language":"en","source_url":"https://github.com/theacodes/cmarkgfm","tags":["markdown","gfm","commonmark","parser","html","c-bindings"],"install":[{"cmd":"pip install cmarkgfm","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"symbol":"markdown_to_html","correct":"from cmarkgfm import markdown_to_html"},{"symbol":"github_flavored_markdown_to_html","correct":"from cmarkgfm import github_flavored_markdown_to_html"},{"note":"Used for advanced rendering configurations (e.g., CMARK_OPT_UNSAFE, CMARK_OPT_SMART).","symbol":"Options","correct":"from cmarkgfm.cmark import Options"}],"quickstart":{"code":"import cmarkgfm\nfrom cmarkgfm.cmark import Options as cmarkgfmOptions\n\nmarkdown_text = \"# Hello CommonMark\\n\\nThis is **bold** text.\"\nhtml_commonmark = cmarkgfm.markdown_to_html(markdown_text)\nprint(\"CommonMark HTML:\\n\", html_commonmark)\n\ngfm_text = \"This is GitHub Flavored Markdown with a ~strikethrough~ and a [link](https://github.com).\"\nhtml_gfm = cmarkgfm.github_flavored_markdown_to_html(gfm_text)\nprint(\"\\nGFM HTML:\\n\", html_gfm)\n\n# Example with options: smart quotes and GitHub pre-lang\noptions = (\n    cmarkgfmOptions.CMARK_OPT_SMART |\n    cmarkgfmOptions.CMARK_OPT_GITHUB_PRE_LANG\n)\nmarkdown_with_options = \"“Smart quotes” and ```python\\nprint('hello')\\n```\"\nhtml_with_options = cmarkgfm.markdown_to_html(markdown_with_options, options)\nprint(\"\\nHTML with Options:\\n\", html_with_options)","lang":"python","description":"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."},"warnings":[{"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`).","message":"Python 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.","severity":"breaking","affected_versions":"2025.10.20 and later"},{"fix":"Review and update your CSS rules, particularly those targeting `<pre><code>` elements, to accommodate the new HTML structure for code blocks.","message":"Code 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.","severity":"breaking","affected_versions":"0.6.0 and later"},{"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)`).","message":"Unsafe 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.","severity":"gotcha","affected_versions":"0.5.0 and later"},{"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.","message":"Python Version Requirement: The library requires Python 3.9 or newer. Ensure your Python environment meets this requirement.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z"}