markdown2: A fast and complete implementation of Markdown in Python

Overview

Markdown is a light text markup format and a processor to convert that to HTML. The originator describes it as follows:

Markdown is a text-to-HTML conversion tool for web writers. Markdown allows you to write using an easy-to-read, easy-to-write plain text format, then convert it to structurally valid XHTML (or HTML).

-- http://daringfireball.net/projects/markdown/

This (markdown2) is a fast and complete Python implementation of Markdown. It was written to closely match the behaviour of the original Perl-implemented Markdown.pl. Markdown2 also comes with a number of extensions (called "extras") for things like syntax coloring, tables, header-ids. See the "Extra Syntax" section below. "markdown2" supports all Python versions 2.6+ or 3.3+ (and pypy and jython, though I don't frequently test those).

There is another Python markdown.py. However, at least at the time this project was started, markdown2.py was faster (see the Performance Notes) and, to my knowledge, more correct (see Testing Notes). That was a while ago though, so you shouldn't discount Python-markdown from your consideration.

Follow @trentmick for updates to python-markdown2.

Travis-ci.org test status: Build Status

Install

To install it in your Python installation run one of the following:

pip install markdown2
pypm install markdown2      # if you use ActivePython (activestate.com/activepython)
easy_install markdown2      # if this is the best you have
python setup.py install

However, everything you need to run this is in "lib/markdown2.py". If it is easier for you, you can just copy that file to somewhere on your PythonPath (to use as a module) or executable path (to use as a script).

Quick Usage

As a module:

>>> import markdown2
>>> markdown2.markdown("*boo!*")  # or use `html = markdown_path(PATH)`
u'<p><em>boo!</em></p>\n'

>>> from markdown2 import Markdown
>>> markdowner = Markdown()
>>> markdowner.convert("*boo!*")
u'<p><em>boo!</em></p>\n'
>>> markdowner.convert("**boom!**")
u'<p><strong>boom!</strong></p>\n'

As a script (CLI):

$ python markdown2.py foo.md > foo.html

or

$ python -m markdown2 foo.md > foo.html

I think pip-based installation will enable this as well:

$ markdown2 foo.md > foo.html

See the project wiki, lib/markdown2.py docstrings and/or python markdown2.py --help for more details.

Extra Syntax (aka extensions)

Many Markdown processors include support for additional optional syntax (often called "extensions") and markdown2 is no exception. With markdown2 these are called "extras". Using the "footnotes" extra as an example, here is how you use an extra ... as a module:

$ python markdown2.py --extras footnotes foo.md > foo.html

as a script:

>>> import markdown2
>>> markdown2.markdown("*boo!*", extras=["footnotes"])
u'<p><em>boo!</em></p>\n'

There are a number of currently implemented extras for tables, footnotes, syntax coloring of <pre>-blocks, auto-linking patterns, table of contents, Smarty Pants (for fancy quotes, dashes, etc.) and more. See the Extras wiki page for full details.

Project

The python-markdown2 project lives at https://github.com/trentm/python-markdown2/. (Note: On Mar 6, 2011 this project was moved from Google Code to here on Github.) See also, markdown2 on the Python Package Index (PyPI).

The change log: https://github.com/trentm/python-markdown2/blob/master/CHANGES.md

To report a bug: https://github.com/trentm/python-markdown2/issues

Contributing

We welcome pull requests from the community. Please take a look at the TODO for opportunities to help this project. For those wishing to submit a pull request to python-markdown2 please ensure it fulfills the following requirements:

  • It must pass PEP8.
  • It must include relevant test coverage.
  • Bug fixes must include a regression test that exercises the bug.
  • The entire test suite must pass.
  • The README and/or docs are updated accordingly.

Test Suite

This markdown implementation passes a fairly extensive test suite. To run it:

make test

The crux of the test suite is a number of "cases" directories -- each with a set of matching .text (input) and .html (expected output) files. These are:

tm-cases/                   Tests authored for python-markdown2 (tm=="Trent Mick")
markdowntest-cases/         Tests from the 3rd-party MarkdownTest package
php-markdown-cases/         Tests from the 3rd-party MDTest package
php-markdown-extra-cases/   Tests also from MDTest package

See the Testing Notes wiki page for full details.

Owner
Trent Mick
Trent Mick
Extensions for Python Markdown

PyMdown Extensions Extensions for Python Markdown. Documentation Extension documentation is found here: https://facelessuser.github.io/pymdown-extensi

Isaac Muse 685 Jan 01, 2023
A super simple script which uses the GitHub API to convert your markdown files to GitHub styled HTML site.

A super simple script which uses the GitHub API to convert your markdown files to GitHub styled HTML site.

Çalgan Aygün 213 Dec 22, 2022
A markdown template manager for writing API docs in python.

DocsGen-py A markdown template manager for writing API docs in python. Contents Usage API Reference Usage You can install the latest commit of this re

Ethan Evans 1 May 10, 2022
Converts a grading Excel sheet into Markdown documents.

GradeDocs Turns Excel worksheets into grade/score documents. Example Given such an Excel Worksheet (see examples/example.xlsx): The following commands

Patrick Bucher 1 Dec 19, 2021
An automated scanning, enumeration, and note taking tool for pentesters

EV1L J3ST3R An automated scanning, enumeration, and note taking tool Created by S1n1st3r Meant to help easily go through Hack The Box machine and TryH

14 Oct 02, 2022
😸Awsome markdown readme for your profile or your portfolio

GitHub Profile Readme Description That's a simple and minimalist README.md for your profile Usage You can download or copy to your repository and make

0 Jul 24, 2022
A Discord Bot for rendering Markdown

Markdown to PDF Bot A discord bot that accepts markdown files (or messages) and displays them as images. Prerequisite To install, you must have have :

1 Oct 21, 2021
Convert HTML to Markdown-formatted text.

html2text html2text is a Python script that converts a page of HTML into clean, easy-to-read plain ASCII text. Better yet, that ASCII also happens to

Alireza Savand 1.3k Dec 31, 2022
WyPyPlus is a minimal wiki in 42 lines of Python code.

🍦 WyPyPlus: A personal wiki in 42 lines of code 🍦 WyPyPlus (pronounced "whippy plus") is a minimalist wiki server in 42 lines of code based on wypy

Leo Chen 8 Apr 07, 2022
Markdown Presentations for Tech Conferences, Training, Developer Advocates, and Educators.

March 1, 2021: Service on gitpitch.com has been shutdown permanently. GitPitch 4.0 Docs Twitter About Watch the Introducing GitPitch 4.0 Video Visit t

David Russell 5.4k Jan 05, 2023
A Python implementation of John Gruber’s Markdown with Extension support.

Python-Markdown This is a Python implementation of John Gruber's Markdown. It is almost completely compliant with the reference implementation, though

Python-Markdown 3.1k Dec 30, 2022
A automated python script that creates mark-down files to read for the aes keys and other useful information.

Archive A automated python script that creates mark-down files to read for the aes keys and other useful information. Table of Contents Benbot Automat

Tector 13 Dec 14, 2022
A Python library to retrieve annotations and notes from Zotero and save them into Markdown files.

Zotero to Markdown Generate Markdown files from Zotero annotations and notes. With new Zotero PDF Reader, all highlights are saved in the Zotero datab

Essi Alizadeh 20 Nov 03, 2022
Lightweight Markdown dialect for Python desktop apps

Litemark is a lightweight Markdown dialect originally created to be the markup language for the Codegame Platform project. When you run litemark from the command line interface without any arguments,

10 Apr 23, 2022
CiteURL is an extensible tool that parses legal citations and makes links to websites where you can read the cited language for free.

CiteURL is an extensible tool that parses legal citations and makes links to websites where you can read the cited language for free. It can be used t

15 Dec 27, 2022
Livemark is a static page generator that extends Markdown with interactive charts, tables, and more.

Livermark This software is in the early stages and is not well-tested Livemark is a static site generator that extends Markdown with interactive chart

Frictionless Data 86 Dec 25, 2022
Remarkable Markdown Debian Package Fix

Remarkable debian package fix For some reason the Debian package for remarkable markdown editor has not been made to install properly on Ubuntu 20.04

Eric Seifert 37 Jan 02, 2023
A markdown lexer and parser which gives the programmer atomic control over markdown parsing to html.

A markdown lexer and parser which gives the programmer atomic control over markdown parsing to html.

stonepresto 4 Aug 13, 2022
Yuque2md - Offline download the markdown file and image from yuque

yuque2md 按照语雀知识库里的目录,导出语雀知识库中所有的markdown文档,并离线图片到本地 使用 安装 Python3.x clone 项目 下载依

JiaJianHuang 4 Oct 30, 2022
markdown2: A fast and complete implementation of Markdown in Python

Markdown is a light text markup format and a processor to convert that to HTML. The originator describes it as follows: Markdown is a text-to-HTML con

Trent Mick 2.4k Dec 30, 2022