Skip to main content

mkconvert

PyPI License Package status Monthly downloads Distribution format Wheel availability Python version Implementation Releases Github Contributors Github Forks Github Issues Github Issues Github Watchers Github Stars Github Repository size Github last commit Github release date Github language count Github commits this month Package status PyUp

Read the documentation!

One API for many Markdown → HTML parsers (Rust and Python), with a common set of options that maps onto every parser, parser-specific options on top, and the same pattern for HTML → Markdown. Every backend is an optional extra: install only what you use.

Installation

pip install "mkconvert[comrak]"            # Rust-based comrak (recommended)
pip install "mkconvert[pyromark,htmd-py]"  # pulldown-cmark parser + Rust HTML -> Markdown

Parser extras: comrak, pyromark, cmarkgfm, mistune, markdown-it-py (markdown-it-py + mdit-py-plugins), marko, markdown2, markdown (Python-Markdown + pymdown-extensions), and the deprecated markdown_it_pyrs. HTML → Markdown: htmd-py, markdownify. Sanitizing: nh3.

Parser Python 3.14 Python 3.15 Notes
comrak (≥ 0.0.16) ✓ wheels ✓ abi3 wheels also free-threaded (3.14t / 3.15t)
pyromark (≥ 0.10.6) ✓ wheels ✓ wheels also free-threaded
cmarkgfm ✓ wheels sdist (needs a C compiler)
mistune, markdown-it-py, marko, markdown2, Python-Markdown ✓ ✓ pure Python
markdown-it-pyrs ✗ ✗ Deprecated, removed in 3.0: unmaintained, wheels only up to 3.12, segfaults when built for 3.14+; the extra installs nothing there

Which parser fits which Markdown dialect, and how fast they are on real documentation: see Parsers by dialect.

Quickstart

import mkconvert
from mkconvert import MarkdownOptions

html = mkconvert.to_html("# Hello\n\n~~old~~ **new**", options=MarkdownOptions.gfm())

# Pick a parser, add common options and parser-specific ones:
html = mkconvert.to_html(
    "# Title\n\nx^2^",
    parser="comrak",
    options=MarkdownOptions(heading_ids=True, footnotes=True),
    superscript=True,  # comrak-specific
)

# Reuse a configured parser for many documents:
parser = mkconvert.get_parser("comrak", MarkdownOptions.gfm(math=True))
pages = [parser.convert(text) for text in ["# A", "# B"]]

# Or use the classes directly (typed, documented parameters):
from mkconvert import ComrakParser

html = ComrakParser(MarkdownOptions(tables=True), header_id_prefix="h-").convert("| a |\n|---|")

Without parser=, the first installed parser is used, in this order: comrak, pyromark, cmarkgfm, mistune, markdown-it-py, marko, markdown2, python-markdown, markdown-it-pyrs. mkconvert.list_parsers(available_only=True) lists the installed ones. A missing package raises MissingDependencyError naming the extra to install.

Common options

MarkdownOptions() is plain CommonMark (all extensions off, raw HTML passed through), except that a leading --- front matter block is dropped (front_matter=False renders it). MarkdownOptions.gfm(**changes) turns on tables, strikethrough, autolinks and task lists.

Option comrak pyromark markdown-it-pyrs cmarkgfm mistune markdown-it-py marko markdown2 python-markdown
tables ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓
strikethrough ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓
autolinks ✓ – ✓ ✓ ✓¹ ✓ ✓ – ✓
task_lists ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓
footnotes ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓
heading_ids ✓ – ✓ – ✓ ✓ ✓ ✓ ✓
alerts ✓ ✓ – – – ✓ ✓ ✓ –
math ✓ ✓ – – ✓ ✓ – – ✓
definition_lists ✓ ✓ ✓ – ✓ ✓ – – ✓
hard_breaks ✓ – – ✓ ✓ ✓ ✓ ✓ ✓
smart_punctuation ✓ ✓ ✓ ✓ – ✓ – ✓ ✓
raw_html=False ✓ – ✓ ✓² ✓ ✓ ✓ ✓ ✓
front_matter ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓

¹ bare https:// URLs only, not www. ² raw HTML is omitted instead of escaped.

Each option is documented on MarkdownOptions. A parser's supported_options tells what it can do (mkconvert.get_parser_class("pyromark").supported_options). Setting an option the parser can't honour warns (UnsupportedOptionWarning) and is ignored; on_unsupported="raise" raises UnsupportedOptionError instead, "ignore" stays quiet.

raw_html=False keeps raw HTML out of the output, but it is no sanitizer. For untrusted input run the result through mkconvert.sanitize(html) (nh3).

Parser-specific options

Passed as keyword arguments to to_html / get_parser or the parser class:

Parser Options
comrak header_id_prefix, tagfilter, superscript, subscript, underline, spoiler, greentext, wikilinks, multiline_block_quotes, math_code, relaxed_autolinks, relaxed_tasklist_matching, default_info_string, github_pre_lang, full_info_string, sourcepos
pyromark heading_attributes, superscript, subscript, wikilinks, old_footnotes, highlight
markdown-it-pyrs xhtml, sourcepos, plugins (deprecated parser)
markdown-it-py plugins (mdit-py-plugins, e.g. admon_plugin), xhtml, heading_levels
cmarkgfm tagfilter, github_pre_lang, sourcepos
mistune plugins (names like ["abbr", "mark"] or plugin objects such as directives)
marko extensions (e.g. ["codehilite", "pangu"])
markdown2 extras, highlight, html4tags
python-markdown extensions, extension_configs, output_format

HTML → Markdown

from mkconvert import HtmlToMarkdownOptions, to_markdown

md = to_markdown("<h1>Title</h1><p><b>bold</b></p>")
md = to_markdown(
    html,
    converter="markdownify",
    options=HtmlToMarkdownOptions(heading_style="setext", skip_tags=("script", "style")),
    code_language="python",  # markdownify-specific
)
Option htmd markdownify
heading_style ("atx", "setext") ✓ ✓
bullet_marker ("-", "*") ✓ ✓
emphasis_marker ("*", "_") – ✓
code_block_style ("fenced", "indented") ✓ –
code_fence ("```", "~~~") ✓ –
line_break ("spaces", "backslash") ✓ ✓
link_style ("inline", "reference") ✓ –
skip_tags ✓ ✓

Converter-specific options: htmd: hr_style, link_reference_style, preformatted_code, ul_bullet_spacing, ol_number_spacing, translation_mode; markdownify: bullets, strip, convert, autolinks, default_title, code_language, code_language_callback, escape_asterisks, escape_underscores, escape_misc, sub_symbol, sup_symbol, table_infer_header, wrap, wrap_width, strip_document.

Helpers

  • sanitize(html, extra_attributes=None, **nh3_options): clean HTML with nh3, e.g. sanitize(html, extra_attributes={"*": {"id", "class"}}) to keep heading ids and code classes.
  • extract_title(html): text of the first <h1>, or None.
  • split_front_matter(text): (front_matter, body) for a leading --- block.

Custom parsers

Subclass MarkdownParser (set name, requires, extra, supported_options, implement _render) and register it with mkconvert.register_parser; likewise HtmlToMarkdownConverter and register_converter.

Metadata

Release files for mkconvert 2.1.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 mkconvert 2.1.0
File Size Uploaded Provenance Actions
mkconvert-2.1.0.tar.gz 27.1 kB With provenance Details for mkconvert-2.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mkconvert 2.1.0
File Interpreter ABI Platform Actions
mkconvert-2.1.0-py3-none-any.whl Python 3 none any Details for mkconvert-2.1.0-py3-none-any.whl

Total release size: 58.2 kB

Release files / mkconvert-2.1.0.tar.gz

Download URL mkconvert-2.1.0.tar.gz
Size 27.1 kB
Tags Source
SHA-256 checksum
How to use checksums
37373161d4d09815b18789b15b2663254b1ef81cea8ca32621baecc827e0db95
BLAKE2b-256 checksum
How to use checksums
bf8e17159973b3e702ae9eb0fbbbcc0e097f1c1eefb69ea96301e2389448b4b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Release files / mkconvert-2.1.0-py3-none-any.whl

Download URL mkconvert-2.1.0-py3-none-any.whl
Size 31.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a536cc33ed68b334b704e29d6ece5e77b1e0d9811cc04364bfc7f8e7f3a6d5e8
BLAKE2b-256 checksum
How to use checksums
430e2e66168a045bd28e001989fb73f6a82445a1ca4d3fdbb183e7ecf0146f6b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Security for mkconvert 2.1.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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for mkconvert-2.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

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