PyMarked
A markdown parser and compiler, written in Python, translated from marked which written in javascrpt.
usage
simple example
>>> from pymarked import marked
>>> print marked('I am using __markdown__.')
>>> <p>I am using <i>markdown</i>.</p>
options usage example
>>> src = """
<h1>Title1</h1>
<p>a paragraph</p>
"""
>>> print marked(src, gfm=True, langPrefix='x-')
>>> <pre>
<code class="x-python">
>h1<Title1<>/h1<
>p<a paragraph<>/p<
</code>
</pre>
options
marked(src, **options)
function parse markdown src to html.
use options to control how to parse:
-
gfm:
Type:
Boolean
DefaultTrue
Enable GitHub flavored markdown.
-
breaks:
Type:
Boolean
Default:False
Enable GFM line breaks. This option requires the gfm option to be True.
-
sanitize:
Type:
Boolean
Default:False
Sanitize the output. Ignore any HTML that has been input.
-
smartLists:
Type:
Boolean
Default:True
Use smarter list behavior than the original markdown.
-
langPrefix:
Type:
String
Default:'lang-'
Set the prefix for code block classes.
-
smartypants:
Type:
Boolean
Default:False
Use "smart" typograhic punctuation for things like quotes and dashes.
-
header_id:
Type:
Boolean
Default:False
Enable header_id for h1~h4
-
toc:
Type:
Boolean
Default:False
Enable toc the document. This option requires the header_id to be True.
-
wikilink:
Type:
Function
Default:
lambda groups: '<a href="{href}" class="wiki">{text}</a>'.format( href=groups.wikilink_name, text=groups.get('wikilink_text', None) or groups.wikilink_name)
Enable parse wiki link:
[[a_wiki_page]]
or[[a_wiki_page | wiki link text]]
. -
macros:
Type:
dict
Default:{}
Enalbe block macros, see
test.MacroTestCase
-
inline_macros:
Type:
dict
Default:{}
Enalbe inline macros, see
test.MacroTestCase
License
Copyright (c) 2011-2013, jander. (MIT License)