Skip to main content

multimark

PyPI Python versions Downloads MIT License CI

The multimark package has Python bindings to cmark-gfm, the C reference implementation of CommonMark with GitHub Flavored Markdown extensions.

Renders Markdown to HTML, LaTeX, groff man, XML, normalized CommonMark, and plain text: all from a single, lightweight package.

Installation

pip install multimark

Wheels are available for Linux, macOS, and Windows (Python 3.9+). No system dependencies required.

Quick Start

from multimark import markdown_to_html, markdown_to_latex

html = markdown_to_html("**Hello**, *world*!")
# '<p><strong>Hello</strong>, <em>world</em>!</p>\n'

latex = markdown_to_latex("**Hello**, *world*!")
# '\\textbf{Hello}, \\emph{world}!\n'

Renderers

Function Output Format
markdown_to_html() HTML
markdown_to_latex() LaTeX
markdown_to_man() groff man page
markdown_to_commonmark() Normalized CommonMark
markdown_to_plaintext() Readable plain text
markdown_to_xml() XML (AST representation)
from multimark import markdown_to_plaintext

markdown_to_plaintext("**Hello**, *world*!")
# 'Hello, world!\n'

Plaintext output preserves list markers, code contents, and image descriptions, but drops link destinations. GFM tables keep pipe syntax, task lists keep checkbox markers, and strikethrough uses single tildes. Raw HTML blocks (including their text) are omitted even with unsafe=True. Empty input returns "\n".

Options

Use named boolean keyword arguments for common settings:

from multimark import markdown_to_html, markdown_to_latex

# Smart punctuation (curly quotes, em-dashes)
markdown_to_html('"Hello" -- world...', smart=True)
# '<p>\u201cHello\u201d \u2013 world\u2026</p>\n'

# Allow raw HTML passthrough (safe mode is the default)
markdown_to_html('<div>hi</div>', unsafe=True)
# '<div>hi</div>\n'

# Source position attributes
markdown_to_html('**Hello**', sourcepos=True)
# '<p data-sourcepos="1:1-1:9"><strong>Hello</strong></p>\n'

# Line wrapping (LaTeX, man, CommonMark, and plaintext renderers)
markdown_to_latex('**Hello**, *world*!', width=80)
# '\\textbf{Hello}, \\emph{world}!\n'

# Footnotes
markdown_to_html('Text[^1]\n\n[^1]: A footnote\n', footnotes=True)
# '<p>Text<sup class="footnote-ref">...</sup></p>\n<section class="footnotes">...\n'

Or compose flags with the Options bitmask:

from multimark import markdown_to_html, Options

html = markdown_to_html(text, options=Options.SMART | Options.UNSAFE)

GFM Extensions

Enable GitHub Flavored Markdown extensions by name:

from multimark import markdown_to_html

# Tables
markdown_to_html('| A | B |\n|---|---|\n| 1 | 2 |\n', extensions=["table"])
# '<table>\n<thead>\n<tr>\n<th>A</th>\n<th>B</th>\n</tr>...\n'

# Strikethrough
markdown_to_html('~~deleted~~', extensions=["strikethrough"])
# '<p><del>deleted</del></p>\n'

# Multiple extensions
html = markdown_to_html(text, extensions=["table", "strikethrough", "autolink", "tasklist", "tagfilter"])

Available extensions: table, strikethrough, autolink, tagfilter, tasklist.

TeX Math

The math extension (not part of GFM) recognizes $...$ and $$...$$ math with Pandoc's delimiter rules, so dollar amounts like $5 stay text. HTML output uses the markup that MathJax and KaTeX look for:

markdown_to_html("Euler: $e^{i\\pi} + 1 = 0$, costing $5", extensions=["math"])
# '<p>Euler: <span class="math inline">\\(e^{i\\pi} + 1 = 0\\)</span>, costing $5</p>\n'

LaTeX output uses \(...\) and \[...\]; the CommonMark, man, and plaintext renderers keep the dollar delimiters.

All Renderer Parameters

Every renderer accepts:

  • text: Markdown string
  • options: raw bitmask (default 0)
  • extensions: list of extension names (default ())
  • smart: smart punctuation
  • hardbreaks: render soft breaks as <br>
  • unsafe: allow raw HTML (no effect on plaintext output)
  • normalize: consolidate adjacent text nodes
  • footnotes: enable footnote syntax

Additional parameters:

  • sourcepos: Source position attributes (HTML and XML only)
  • width: Line wrap column (LaTeX, man, CommonMark, and plaintext only; 0 = no wrap)

For plaintext, hardbreaks=True disables width-based wrapping. With width=0, soft line breaks are preserved; a positive width reflows them as spaces before wrapping. Output whitespace and trailing newlines are retained.

Why multimark?

Several Python packages wrap cmark or provide CommonMark parsing. Here's how they compare:

multimark cmarkgfm commonmark.py
Engine cmark-gfm (C, vendored) cmark-gfm (C, vendored) Pure Python
Output formats HTML, LaTeX, man, XML, CommonMark, plaintext HTML only HTML only
GFM extensions ✓ ✓ ✗
Safe by default ✓ ✓ ✗
Convenience kwargs smart=True, unsafe=True, etc. Raw bitmask only N/A
Performance Fastest (14% faster than cmarkgfm) Fast ~31× slower
Maintained Active (2026) Active (2025) Unmaintained (2019)

multimark uses the same battle-tested C library as cmarkgfm but exposes all six of cmark's output formats (not just HTML). The API is designed around keyword arguments rather than opaque bitmasks, and unsafe content is blocked by default so the safe choice requires no extra configuration.

Thanks to extension pointer caching and reduced Python-side overhead, multimark is the fastest Python Markdown-to-HTML library. Take a look at the benchmarks for more detail on this.

License

MIT and BSD-2-Clause (cmark-gfm).

Metadata

Release files for multimark 0.5.0

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

Source distribution (sdist)

Source distribution for multimark 0.5.0
File Size Uploaded Provenance Actions
multimark-0.5.0.tar.gz 1.5 MB Without provenance Details for multimark-0.5.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for multimark 0.5.0
File Actions
multimark-0.5.0-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details for multimark-0.5.0-cp39-abi3-win_amd64.whl
multimark-0.5.0-cp39-abi3-pyemscripten_2026_0_wasm32.whl CPython 3.9 abi3 PyEmscripten 2026.0+ WebAssembly Details for multimark-0.5.0-cp39-abi3-pyemscripten_2026_0_wasm32.whl
multimark-0.5.0-cp39-abi3-musllinux_1_2_x86_64.whl CPython 3.9 abi3 Linux musl 1.2+ x86-64 Details for multimark-0.5.0-cp39-abi3-musllinux_1_2_x86_64.whl
multimark-0.5.0-cp39-abi3-musllinux_1_2_aarch64.whl CPython 3.9 abi3 Linux musl 1.2+ ARM64 Details for multimark-0.5.0-cp39-abi3-musllinux_1_2_aarch64.whl
multimark-0.5.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.9 abi3 Linux glibc 2.17+ x86-64 Details for multimark-0.5.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
multimark-0.5.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.9 abi3 Linux glibc 2.17+ ARM64 Details for multimark-0.5.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
multimark-0.5.0-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details for multimark-0.5.0-cp39-abi3-macosx_11_0_arm64.whl
multimark-0.5.0-cp39-abi3-macosx_10_9_x86_64.whl CPython 3.9 abi3 macOS 10.9+ x86-64 Details for multimark-0.5.0-cp39-abi3-macosx_10_9_x86_64.whl

Total release size: 4.1 MB

Release files / multimark-0.5.0.tar.gz

Download URL multimark-0.5.0.tar.gz
Size 1.5 MB
Tags Source
SHA-256 checksum
How to use checksums
01fc167735e823968a2f3b4027144e10c4c6790a2fd6e239d1d30f83ba61488b
BLAKE2b-256 checksum
How to use checksums
6780049dfda494c163d1dd0653476a13c504ece7b889c9045b9518ee45335aac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / multimark-0.5.0-cp39-abi3-win_amd64.whl

Download URL multimark-0.5.0-cp39-abi3-win_amd64.whl
Size 145.5 kB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
25d700683c9937eb812fd2732499c942d51283f36020310727a980913e7aa5ff
BLAKE2b-256 checksum
How to use checksums
63156791a2ecf6641eb3ab8d043de82422ee8f89d6c80175700bba319e0122d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / multimark-0.5.0-cp39-abi3-pyemscripten_2026_0_wasm32.whl

Download URL multimark-0.5.0-cp39-abi3-pyemscripten_2026_0_wasm32.whl
Size 119.8 kB
Tags CPython 3.9 PyEmscripten 2026.0+ WebAssembly abi3
SHA-256 checksum
How to use checksums
6920522da8639fb68935364de59bb83e30e1fb5e19e77af5555a57ce12526f43
BLAKE2b-256 checksum
How to use checksums
8ee8c418ea1a48c885d5ee7edf4b2634d0b9a3292a57f04cd73f54826ffa9e34
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / multimark-0.5.0-cp39-abi3-musllinux_1_2_x86_64.whl

Download URL multimark-0.5.0-cp39-abi3-musllinux_1_2_x86_64.whl
Size 517.6 kB
Tags CPython 3.9 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
3198337442fc3cb0d9aff8533d81ff445bb2765c98d5b1ef1abbfeeb1517065f
BLAKE2b-256 checksum
How to use checksums
1574a408f3e50f3ec2b027f35a62bc75e60fb5f85b3f8a5dea4322131fb20d7c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / multimark-0.5.0-cp39-abi3-musllinux_1_2_aarch64.whl

Download URL multimark-0.5.0-cp39-abi3-musllinux_1_2_aarch64.whl
Size 511.6 kB
Tags CPython 3.9 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
1010c32a8527d68c7d85ee5a08217f43fed977ce99fa877758a5e76a49468605
BLAKE2b-256 checksum
How to use checksums
9fea6200b2636fb923a717a99c8f7d21ec20c71946b9e569131f186896ecce2b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / multimark-0.5.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL multimark-0.5.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 514.0 kB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
cf87c8be7bf5416b6aa25cd97277047d0b678885bb9be4711d96d2a3b86bc3af
BLAKE2b-256 checksum
How to use checksums
cdbfbf0ddc0d56e4c11abf7fa9b524e4c54ecd46a3477ff8c4d6b4e1011aff64
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / multimark-0.5.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL multimark-0.5.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 508.4 kB
Tags CPython 3.9 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
44a1977c8ca46893107918d1a7f15f73c91c725dc1218bbde00adc11b89843b1
BLAKE2b-256 checksum
How to use checksums
89df2453bb0e519ce1110ffa185cae48f6a0fcbfd2f8fb5a4bea1bb8ec1648ff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / multimark-0.5.0-cp39-abi3-macosx_11_0_arm64.whl

Download URL multimark-0.5.0-cp39-abi3-macosx_11_0_arm64.whl
Size 152.5 kB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
86f2fbb1bd69688db3930f823d90b5e61ceca125228557bd5e2faf8023aa9f43
BLAKE2b-256 checksum
How to use checksums
8c5f4e7d7bb6afb9db4e0cf2c25aff83654978d230e27dcfac697719716bfa74
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / multimark-0.5.0-cp39-abi3-macosx_10_9_x86_64.whl

Download URL multimark-0.5.0-cp39-abi3-macosx_10_9_x86_64.whl
Size 157.3 kB
Tags CPython 3.9 abi3 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
54a6ca5bffcbad1c8816c33d34bb48ae656d73e3cebe04c7217662385b726fef
BLAKE2b-256 checksum
How to use checksums
218271bc7f0f7d8924f59468ca5755630ac8d489a6bb0e37eaed959048b87483
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for multimark 0.5.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