{"id":2115,"library":"marko","title":"Marko (Python Markdown Parser)","description":"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.","status":"active","version":"2.2.2","language":"en","source_language":"en","source_url":"https://github.com/frostming/marko","tags":["markdown","parser","commonmark","extensible","html"],"install":[{"cmd":"pip install marko","lang":"bash","label":"Install latest version"},{"cmd":"pip install marko[toc]","lang":"bash","label":"Install with Table of Contents (TOC) extension dependencies"},{"cmd":"pip install marko[codehilite]","lang":"bash","label":"Install with Code Highlighting extension dependencies"}],"dependencies":[{"reason":"Required for the 'toc' (Table of Contents) extension.","package":"python-slugify","optional":true},{"reason":"Required for the 'codehilite' (Code Highlight) extension.","package":"Pygments","optional":true}],"imports":[{"symbol":"convert","correct":"import marko\nhtml = marko.convert(markdown_text)"},{"symbol":"Markdown","correct":"from marko import Markdown\nmarkdown = Markdown(extensions=['footnote'])"},{"symbol":"make_extension","correct":"from marko.ext.footnote import make_extension"},{"symbol":"gfm","correct":"from marko.ext.gfm import gfm"}],"quickstart":{"code":"import marko\n\nmarkdown_text = \"\"\"\n# Hello Marko!\n\nThis is **bold** text and *italic* text.\n\n- Item 1\n- Item 2\n\n```python\nprint('Hello from a code block')\n```\n\"\"\"\n\nhtml_output = marko.convert(markdown_text)\nprint(html_output)\n\n# Example with an extension\nfrom marko import Markdown\nmarkdown = Markdown(extensions=['footnote'])\nhtml_with_footnote = markdown.convert('Footnotes[^1]\\n\\n[^1]: My footnote.')\nprint(html_with_footnote)","lang":"python","description":"A basic example demonstrating how to convert Markdown text to HTML using `marko.convert()`. It also includes a brief example of initializing the `Markdown` class with a built-in extension."},"warnings":[{"fix":"Consider `Python-Markdown` or `Mistune` if performance is critical and strict CommonMark compliance is less important.","message":"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.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Refer to the official documentation for the updated extension API when migrating from versions prior to 0.5.0.","message":"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.","severity":"breaking","affected_versions":"<0.5.0"},{"fix":"Upgrade your Python environment to 3.9 or newer. Alternatively, pin your `marko` version to a compatible release.","message":"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.","severity":"breaking","affected_versions":"<1.3.0 (for Python 3.6), <2.2.1 (for Python 3.8)"},{"fix":"Instantiate `marko.Markdown()` within each thread or use thread-local storage for instances.","message":"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.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Install these extensions with their respective extras, e.g., `pip install marko[toc]` or `pip install marko[codehilite]`.","message":"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`.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}