comrak 0.0.16


pip install comrak

  Latest version

Released: Jul 27, 2026


Meta
Author: Louis Maddox
Requires Python: >=3.9

Classifiers

Intended Audience
  • Developers

License
  • OSI Approved :: MIT License

Programming Language
  • Python :: 3
  • Python :: 3.9
  • Python :: 3.10
  • Python :: 3.11
  • Python :: 3.12
  • Python :: 3.13
  • Python :: 3.14

Operating System
  • OS Independent

Typing
  • Typed

comrak

uv pdm-managed PyPI Supported Python versions License pre-commit.ci status

Python bindings for the Comrak Rust library, a fast CommonMark/GFM parser.

Currently tracking comrak 0.54.

Installation

pip install comrak

Requirements

  • Python 3.9+

Usage

>>> import comrak
>>> comrak.render_markdown("# Hello")
'<h1>Hello</h1>\n'

CommonMark output

render_commonmark renders Markdown back to normalized CommonMark instead of HTML. It takes the same extension_options/parse_options/render_options as render_markdown:

>>> comrak.render_commonmark("- one\n- two\n- three")
'- one\n- two\n- three\n'
>>> opts = comrak.RenderOptions()
>>> opts.list_style = comrak.ListStyle.Plus
>>> comrak.render_commonmark("- one\n- two\n- three", render_options=opts)
'+ one\n+ two\n+ three\n'

Options

Every option in comrak's Extension, Parse and Render structs is exposed, with the same name and the same default:

>>> opts = comrak.ExtensionOptions()
>>> comrak.render_markdown("foo :smile:", extension_options=opts)
'<p>foo :smile:</p>\n'
>>> opts.shortcodes = True
>>> comrak.render_markdown("foo :smile:", extension_options=opts)
'<p>foo ๐Ÿ˜„</p>\n'

The three option objects are independent and can be combined:

>>> ext = comrak.ExtensionOptions()
>>> ext.alerts = True
>>> render = comrak.RenderOptions()
>>> render.alert_style = comrak.AlertStyle.Semantic
>>> comrak.render_markdown("> [!note]\n> Note this!",
...                        extension_options=ext, render_options=render)
'<aside class="admonition note">\n...'

For what each option does, see comrak's own documentation. The field names match one-for-one:

Two options take enums rather than raw values: RenderOptions.alert_style (comrak.AlertStyle) and RenderOptions.list_style (comrak.ListStyle). Both compare equal to their integer discriminants.

The one naming difference from the Rust API is:

Rust Python
render.unsafe RenderOptions.unsafe_

ExtensionOptions.header_ids is a deprecated alias for header_id_prefix and raises a FutureWarning; it will be removed in a future release.

Not exposed

  • parse.broken_link_callback โ€” see tracking issue
  • extension.phoenix_heex โ€” gated behind a comrak crate feature that isn't built here
  • Plugins (syntax highlighting, heading adapters)
  • XML output (comrak::markdown_to_commonmark_xml)

render_markdown renders to HTML. render_commonmark renders to normalized CommonMark. The options that solely affect the CommonMark formatter (width, list_style, prefer_fenced, ol_width, experimental_minimize_commonmark) have no effect on render_markdown's HTML output, only on render_commonmark.

Benchmarks

Tested with small (8 lines) and medium (1200 lines) markdown strings

Contributing

Maintained by lmmx. Contributions welcome!

  1. Issues & Discussions: Please open a GitHub issue or discussion for bugs, feature requests, or questions.
  2. Pull Requests: PRs are welcome!
    • Set up with uv: uv sync
    • Build and test: uv run maturin develop && uv run pytest
    • If reporting a bug, please include the version and the error message/traceback if available.

New comrak options are caught at compile time by an exhaustiveness check in src/options.rs, and untested options are caught by TestOptionCoverage in tests/comrak_test.py. This was introduced to help keep track of new comrak features and their test coverage in this library.

License

Licensed under the 2-Clause BSD License. See LICENSE for all the details.

Wheel compatibility matrix

Platform CPython 3.9 CPython >=3.9 (abi3) CPython 3.10 CPython 3.11 CPython >=3.11 (abi3) CPython 3.12 CPython 3.13 CPython 3.14 CPython >=3.14 (abi3) CPython 3.15 (abi3t) CPython >=3.15 (abi3) CPython (additional flags: t) 3.14 PyPy 3.11 (pp73)
macosx_10_12_x86_64
macosx_11_0_arm64
manylinux1_i686
manylinux2014_aarch64
manylinux2014_armv7l
manylinux2014_ppc64le
manylinux2014_s390x
manylinux2014_x86_64
manylinux_2_17_aarch64
manylinux_2_17_armv7l
manylinux_2_17_ppc64le
manylinux_2_17_s390x
manylinux_2_17_x86_64
manylinux_2_5_i686
musllinux_1_2_aarch64
musllinux_1_2_armv7l
musllinux_1_2_i686
musllinux_1_2_x86_64
win32
win_amd64

Files in release

comrak-0.0.16-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (608.4KiB)
comrak-0.0.16-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl (632.8KiB)
comrak-0.0.16-cp311-abi3-macosx_10_12_x86_64.whl (539.3KiB)
comrak-0.0.16-cp311-abi3-macosx_11_0_arm64.whl (531.4KiB)
comrak-0.0.16-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (604.4KiB)
comrak-0.0.16-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl (629.3KiB)
comrak-0.0.16-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (603.8KiB)
comrak-0.0.16-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl (627.6KiB)
comrak-0.0.16-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (603.6KiB)
comrak-0.0.16-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.whl (627.7KiB)
comrak-0.0.16-cp314-abi3-win32.whl (408.6KiB)
comrak-0.0.16-cp314-abi3-win_amd64.whl (420.8KiB)
comrak-0.0.16-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (603.6KiB)
comrak-0.0.16-cp314-cp314-manylinux_2_5_i686.manylinux1_i686.whl (627.4KiB)
comrak-0.0.16-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (676.5KiB)
comrak-0.0.16-cp314-cp314t-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (634.0KiB)
comrak-0.0.16-cp314-cp314t-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (698.7KiB)
comrak-0.0.16-cp314-cp314t-manylinux_2_17_s390x.manylinux2014_s390x.whl (740.5KiB)
comrak-0.0.16-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (604.1KiB)
comrak-0.0.16-cp314-cp314t-manylinux_2_5_i686.manylinux1_i686.whl (627.6KiB)
comrak-0.0.16-cp314-cp314t-musllinux_1_2_aarch64.whl (851.4KiB)
comrak-0.0.16-cp314-cp314t-musllinux_1_2_armv7l.whl (898.9KiB)
comrak-0.0.16-cp314-cp314t-musllinux_1_2_i686.whl (833.7KiB)
comrak-0.0.16-cp314-cp314t-musllinux_1_2_x86_64.whl (858.5KiB)
comrak-0.0.16-cp315-abi3.abi3t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (608.3KiB)
comrak-0.0.16-cp315-abi3.abi3t-manylinux_2_5_i686.manylinux1_i686.whl (631.2KiB)
comrak-0.0.16-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (683.8KiB)
comrak-0.0.16-cp39-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (640.6KiB)
comrak-0.0.16-cp39-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (703.3KiB)
comrak-0.0.16-cp39-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl (747.5KiB)
comrak-0.0.16-cp39-abi3-musllinux_1_2_aarch64.whl (858.8KiB)
comrak-0.0.16-cp39-abi3-musllinux_1_2_armv7l.whl (908.9KiB)
comrak-0.0.16-cp39-abi3-musllinux_1_2_i686.whl (839.8KiB)
comrak-0.0.16-cp39-abi3-musllinux_1_2_x86_64.whl (865.0KiB)
comrak-0.0.16-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (611.2KiB)
comrak-0.0.16-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.whl (633.9KiB)
comrak-0.0.16-pp311-pypy311_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (678.9KiB)
comrak-0.0.16-pp311-pypy311_pp73-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (638.1KiB)
comrak-0.0.16-pp311-pypy311_pp73-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (700.0KiB)
comrak-0.0.16-pp311-pypy311_pp73-manylinux_2_17_s390x.manylinux2014_s390x.whl (742.2KiB)
comrak-0.0.16-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (606.4KiB)
comrak-0.0.16-pp311-pypy311_pp73-manylinux_2_5_i686.manylinux1_i686.whl (631.5KiB)
comrak-0.0.16-pp311-pypy311_pp73-musllinux_1_2_aarch64.whl (853.3KiB)
comrak-0.0.16-pp311-pypy311_pp73-musllinux_1_2_armv7l.whl (905.5KiB)
comrak-0.0.16-pp311-pypy311_pp73-musllinux_1_2_i686.whl (837.0KiB)
comrak-0.0.16-pp311-pypy311_pp73-musllinux_1_2_x86_64.whl (861.1KiB)
comrak-0.0.16.tar.gz (54.8KiB)
No dependencies