cMarkdown
Markdown for Python, accelerated by C.
Installation
$ pip install cMarkdown
Usage
>>> import cMarkdown as markdown
>>> markdown.markdown('# Hello, world!')
'<h1>Hello, world!</h1>\n'
Rendering flags
These are keyword arguments to pass to markdown()
. They all default to
False
.
-
skip_html=True
: Any HTML in the input will be escaped on output. -
skip_style=True
: Any<style>
elements in the input will be escaped on output. -
skip_images=True
: Any<img>
elements in the input will be escaped on output. -
skip_links=True
: Any<a>
elements in the input will be escaped on output. -
smartypants=True
: Applies smart punctuation transformations. -
toc=True
: Inserts anchors before<h1>
,<h2>
, et al. for linking in-document from a table of contents. -
hard_wrap=True
: Inserts<br/>
tags before newlines in paragraphs.
Markdown extension flags
These keyword arguments to markdown()
, which default to False
, enable
various extensions to the Markdown language.
-
tables=True
: Enables a tabular format that renders to<table>
in HTML. -
fenced_code=True
: Enables the use of three```
to delimit the beginning and end of a literal code block. -
autolink=True
: Enables the conversion of bare URLs to links in HTML. -
strikethrough=True
: Enables the use of two~~
before and after text to wrap it in the<del>
tag in HTML.
Credits
Inspired by redcarpet for Ruby. Like with redcarpet, all the hard work is done by the (unfortunately named) upskirt C library. cMarkdown just makes this Markdown parsing and rendering library available to Python.