Marko (Python Markdown Parser)
Marko is a pure Python markdown parser, version 2.2.2, designed for high extensibility and strict adherence to CommonMark's spec v0.31.2. It supports Python 3.9 and higher, with its latest release on January 5, 2026. The library offers a flexible extension system for custom features, although its strict compliance can result in slower performance compared to some other parsers.
Warnings
- gotcha Marko prioritizes strict CommonMark compliance, which can result in slower performance compared to other Python markdown parsers (e.g., Python-Markdown, Mistune) if raw parsing speed is the primary concern.
- breaking The extension system underwent a significant change in version 0.5.0. Users migrating from older versions (pre-0.5.0) will need to update their extension implementations to the new API.
- breaking Support for Python 3.6 was dropped in v1.3.0, and support for Python 3.8 was dropped in v2.2.1. The current version (2.2.2) requires Python 3.9 or higher.
- gotcha Instances of the `marko.Markdown` class are not thread-safe. In multi-threaded applications, a new `Markdown` instance should be created for each thread to avoid unexpected behavior.
- gotcha Certain built-in extensions, such as 'toc' (Table of Contents) and 'codehilite' (Code Highlight), require additional, optional dependencies (`python-slugify` and `Pygments` respectively). These are not installed by default with `pip install marko`.
Install
-
pip install marko -
pip install marko[toc] -
pip install marko[codehilite]
Imports
- convert
import marko html = marko.convert(markdown_text)
- Markdown
from marko import Markdown markdown = Markdown(extensions=['footnote'])
- make_extension
from marko.ext.footnote import make_extension
- gfm
from marko.ext.gfm import gfm
Quickstart
import marko
markdown_text = """
# Hello Marko!
This is **bold** text and *italic* text.
- Item 1
- Item 2
```python
print('Hello from a code block')
```
"""
html_output = marko.convert(markdown_text)
print(html_output)
# Example with an extension
from marko import Markdown
markdown = Markdown(extensions=['footnote'])
html_with_footnote = markdown.convert('Footnotes[^1]\n\n[^1]: My footnote.')
print(html_with_footnote)