Skip to main content

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:

Example:

  >>> from python_comrak import markdown_to_html
  >>> markdown_to_html("\tfoo\tbaz\t\tbim\n")
  "<pre><code>foo\tbaz\t\tbim\n</code></pre>\n"

markdown_to_html activates the extensions:

Raw HTML is not rendered: it's replaced by <!-- raw HTML omitted -->.

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")
  "<pre><code>foo\tbaz\t\tbim\n</code></pre>\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.

Benchmarks

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('README.md', 'r') as f:
...     contents = f.read()

>>> 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)

Metadata

Release files for python-comrak 0.10.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for python-comrak 0.10.0
File Interpreter ABI Platform Actions
python_comrak-0.10.0-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.12 abi3 Linux glibc 2.17+ x86-64 Details for python_comrak-0.10.0-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Release files / python_comrak-0.10.0-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL python_comrak-0.10.0-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 705.8 kB
Tags CPython 3.12 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
04102f593e415f4020eef89110737b021c6db75b2429ac5e0a55fa926f6cc899
BLAKE2b-256 checksum
How to use checksums
4a010031fad34192b131d952b4d012f340e3636c8edb0a1b90381567c6181356
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Alpine Linux","version":"3.23.7","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for python-comrak 0.10.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page