Skip to main content

Markdown HTML converters for Python made in Rust

Project description

Markdown HTML converters for Python made in Rust

Exposes two Rust crates which parse markdown to Python using PyO3.

Using Comrak

The first crate exposed is comrak from which we inherited the name:


  >>> from python_comrak import markdown_to_html
  >>> markdown_to_html("\tfoo\tbaz\t\tbim\n")

markdown_to_html activates the extensions:

Using pulldown-cmark

The second crate is pulldown-cmark. Example:

  >>> from python_comrak import commonmark_to_html
  >>> commonmark_to_html("\tfoo\tbaz\t\tbim\n")

commonmark_to_html activates the extensions:

Notice that pulldown-cmark doesn't implement 100% of CommonMark yet. Also it doesn't have the same set of extensions we use with comrak.


This implementation is quite simple and doesn't allow much of the underlying crates. The extensions and options are fixed. The following is just a micro-benchmark parsing the text of this README file:

>>> with open('', 'r') as f:
...     contents =

>>> from python_comrak import markdown_to_html, commonmark_to_html

>>> %timeit markdown_to_html(contents)
54.4 µs ± 1.24 µs per loop (mean ± std. dev. of 7 runs, 10000 loops each)

>>> %timeit commonmark_to_html(contents)
12.5 µs ± 97.3 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

python_comrak-0.9.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.4 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

python_comrak-0.9.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.4 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

python_comrak-0.9.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.4 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

python_comrak-0.9.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.4 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

python_comrak-0.9.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.4 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page