Skip to content
This repository

Extras provided by

By default's processing attempts to produce output exactly as defined by -- the "Markdown core." However, a few optional extras are also provided.

Implemented Extras

  • code-friendly: Disable _ and __ for em and strong.
  • code-color: (DEPRECATED Use fenced-code-blocks extra instead.) Pygments-based syntax coloring of <code> sections.
  • cuddled-lists: Allow lists to be cuddled to the preceding paragraph.
  • fenced-code-blocks: Allows a code block to not have to be indented by fencing it with '```' on a line before and after. Based on with support for syntax highlighting.
  • footnotes: support footnotes as in use on and implemented in other Markdown processors (tho not in v1.0.1).
  • header-ids: Adds "id" attributes to headers. The id value is a slug of the header text. (TODO: wiki page for this)
  • html-classes: Takes a dict mapping html tag names (lowercase) to a string to use for a "class" tag attribute. Currently only supports "pre", "code", and "img" tags. Add an issue if you require this for other tags.
  • link-patterns: Auto-link given regex patterns in text (e.g. bug number references, revision number references).
  • markdown-in-html: Allow the use of markdown="1" in a block HTML tag to have markdown processing be done on its contents. Similar to but with some limitations.
  • metadata: Extract metadata from a leading '---'-fenced block.
  • nofollow: Add rel="nofollow" to add <a> tags with an href. See
  • pyshell: Treats unindented Python interactive shell sessions as <code> blocks. (TODO: wiki page for this)
  • smarty-pants: Fancy quote, em-dash and ellipsis handling similar to See old issue 42 for discussion. (TODO: wiki page for this)
  • toc: The returned HTML string gets a new "toc_html" attribute which is a Table of Contents for the document. (experimental)
  • wiki-tables: Google Code Wiki table syntax support.
  • xml: Passes one-liner processing instructions and namespaced XML tags. (TODO: wiki page for this)
  • tag-friendly: Requires atx style headers to have a space between the # and the header text. Useful for applications that require twitter style tags to pass through the parser.

How to turn on extras

Extras are all off by default and turned on as follows on the command line:

python --extras name1,name2 ...

and via the module interface:

>>> import markdown2
>>> html = markdown2.markdown_path(path, ..., extras=["name1", "name2"])
>>> html = markdown2.markdown("some markdown", ..., extras=["name1", "name2"])

>>> markdowner = Markdown(..., extras=["name1", "name2"])
>>> markdowner.convert("*boo!*")

(New in v1.0.1.2) You can also now specify extras via the "markdown-extras" emacs-style local variable in the markdown text:

<!-- markdown-extras: code-friendly, footnotes -->
This markdown text will be converted with the "code-friendly" and "footnotes"
extras enabled.


This markdown text will be converted with the "code-friendly" and "footnotes"
extras enabled.

  Local Variables:
  markdown-extras: code-friendly, footnotes
Something went wrong with that request. Please try again.