Note
The documentation for this module is an excerpt of the documentation available on the markdown2 project page on GitHub. Minor edits have been made to make the documentation fit on one page and to remove passages that are not relevant on iOS. Also, only a summary of available extras is included here, for more information on individual extras, please refer to the project page wiki.
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 “Extras” section below.
Quick usage:
>>> import markdown2
>>> markdown2.markdown("*boo!*") # or use `html = markdown_path(PATH)`
u'<p><em>boo!</em></p>\n'
>>> markdowner = Markdown()
>>> markdowner.convert("*boo!*")
u'<p><em>boo!</em></p>\n'
>>> markdowner.convert("**boom!**")
u'<p><strong>boom!</strong></p>\n'
By default markdown2‘s processing attempts to produce output exactly as defined by http://daringfireball.net/projects/markdown/syntax – the “Markdown core.” However, a few optional extras are also provided.
Extras are all off by default and turned on as follows:
>>> 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!*")
<em>boo!</em>
(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.
Convert the markdown-formatted text to html with the given options.
Same as markdown(), but use the text in a given file as input.