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
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
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 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
Yuque2md - Offline download the markdown file and image from yuque

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

JiaJianHuang 4 Oct 30, 2022
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
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
Preview GitHub README.md files locally before committing them.

Grip -- GitHub Readme Instant Preview Render local readme files before sending off to GitHub. Grip is a command-line server application written in Pyt

Joe Esposito 5.9k Jan 08, 2023
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
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 lightweight and fast-to-use Markdown document generator based on Python

A lightweight and fast-to-use Markdown document generator based on Python

快乐的老鼠宝宝 1 Jan 10, 2022
A command line tool that can convert Day One data into markdown files.

Introduction Features Before Start Export data from Day One Check Integrity Special Cases for Photo Extension Name Audio Extension Name Usage Known Is

gyro永不抽风 26 Dec 31, 2022
An interactive, terminal-based markdown presenter

lookatme lookatme is an interactive, extensible, terminal-based markdown presentation tool. TOC TOC Features Tour Navigating the Presentation CLI Opti

James Johnson 1.4k Jan 01, 2023
Awesome Django Markdown Editor, supported for Bootstrap & Semantic-UI

martor Martor is a Markdown Editor plugin for Django, supported for Bootstrap & Semantic-UI. Features Live Preview Integrated with Ace Editor Supporte

659 Jan 04, 2023
A minimal platform for Markdown-based blogs

madblog This project provides a minimal blogging platform based on Markdown files. Demos This project powers the following blogs: Platypush My persona

Fabio Manganiello 2 Aug 02, 2022
Provides syntax for Python-Markdown which allows for the inclusion of the contents of other Markdown documents.

Markdown-Include This is an extension to Python-Markdown which provides an "include" function, similar to that found in LaTeX (and also the C pre-proc

Chris MacMackin 85 Dec 30, 2022
A Straightforward Markdown Journal

Introducing Pepys: A straightforward markdown journal "It is rightly made for those who love to document their daily life events" - FOSSBytes Pepys is

Luke Briggs 23 Nov 12, 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
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
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
Convert mind maps to markdown for import into Roam.

Mind Map to Markdown for Roam import Got a Mind Map with contents you'd like to import into Roam? Soon, this Python application might do what just you

Romilly Cocking 3 Dec 09, 2021