Skip to main content

𝓜𝓪𝓻𝓴𝓸

A markdown parser with high extensibility.

PyPI PyPI - Python Version Documentation Status CommonMark Spec

Build Status codecov Codacy Badge

Marko is a pure Python markdown parser that adheres to the specifications of CommonMark's spec v0.31.2. It has been designed with high extensibility in mind, as detailed in the Extensions section.

Marko requires Python 3.9 or higher.

Why Marko

Of all the Python markdown parsers available, a common issue is the difficulty for users to add their own features. Additionally, both Python-Markdown and mistune do not comply with CommonMark specifications. This has prompted me to develop a new markdown parser.

Marko's compliance with the complex CommonMark specification can impact its performance. However, using a parser that does not adhere to this spec may result in unexpected rendering outcomes. According to benchmark results, Marko is three times slower than Python-Markdown but slightly faster than Commonmark-py and significantly slower than mistune. If prioritizing performance over spec compliance is crucial for you, it would be best to opt for another parser.

Use Marko

The installation is very simple:

$ pip install marko

And to use it:

import marko

print(marko.convert(text))

Marko also provides a simple CLI, for example, to render a document and output to a html file:

$ cat my_article.md | marko > my_article.html

Extensions

It is super easy to use an extension:

from marko import Markdown
from marko.ext.footnote import make_extension
# Add footnote extension
markdown = Markdown(extensions=[make_extension()])
# Or you can just:
markdown = Markdown(extensions=['footnote'])
# Alternatively you can register an extension later
markdown.use(make_extension())

An example of using an extension with the command-line version of Marko:

$ cat this_has_footnote.txt | marko -e footnote > hi_world.html

Marko is shipped with 4 extensions: 'footnote', 'toc' 'pangu', 'codehilite'. They are not included in CommonMark's spec but are common in other markdown parsers.

Marko also provides a Github flavored markdown parser which can be found at marko.ext.gfm.gfm.

Please refer to Extend Marko about how to write your own extension.

License

Marko is released under MIT License

Change Log

Metadata

Release files for marko 2.2.5

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

Source distribution (sdist)

Source distribution for marko 2.2.5
File Size Uploaded Provenance
marko-2.2.5.tar.gz 153.3 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 200.5 kB

Release files / marko-2.2.5.tar.gz

Download URL marko-2.2.5.tar.gz
Size 153.3 kB
Tags Source
SHA-256 checksum
How to use checksums
3a5bac3a2e3ccb53cd97dcd29e422c4f701c29ec7c61be4c0d827321ef057553
BLAKE2b-256 checksum
How to use checksums
65557ba85e14361632d734998b6a7f676de73d986a2ebb15b1008c794bf70ccf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / marko-2.2.5-py3-none-any.whl

Download URL marko-2.2.5-py3-none-any.whl
Size 47.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
26380a6b037b5b49cec3847ee3585ba66f6782a4b9aec0d1216b7194ec5871ee
BLAKE2b-256 checksum
How to use checksums
6367be743617363627442717c2b865993eba99d17f2d1e0ad814bf703f190afb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Security for marko 2.2.5

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.

Release history Release notifications | RSS feed

This release

2.2.5 This release

2 release files No provenance

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