Markdown2 converts Markdown plain text into HTML in Python, aiming to match classic Markdown.pl behavior. Optional extras add tables, footnotes, and syntax highlighting.
Overview
Markdown2 is a Python implementation of Markdown, the light text markup format that converts writer-friendly plain text into structurally valid HTML. It was written to follow the behavior of the original Perl Markdown.pl closely while shipping optional syntax extensions called extras.
You can install it from PyPI or drop a single module file onto your Python path. It runs as an importable module or as a command-line script. Emacs-style file variables can enable per-document extras when requested on the CLI or in API calls.
Extras cover footnotes, tables, fenced code blocks with syntax coloring, auto-linking, table of contents, Smarty Pants typography, and more. The footnotes extra keeps the same reference number when a footnote is cited multiple times; the tables extra handles code spans and pipe-separated cells.
An extensive test suite uses case directories comparing input text to expected HTML, including suites derived from third-party Markdown test packages. Compared with another Python markdown package, markdown2 is positioned on speed and correctness grounds without naming a proprietary alternative.
Key features
- Markdown to HTML conversion
- Optional extras for extended syntax
- Module and CLI usage
- Emacs file variable extras
- Pygments-backed code highlighting optional
- Footnotes and tables extras
- Single-file deployment option
Use cases
- Rendering README or docs in Python apps
- Batch converting Markdown files to HTML
- Blog or CMS Markdown pipelines
- Static site preprocessing steps