Skip to content

jander/pymarked

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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">
&gt;h1&lt;Title1<&gt;/h1&lt;
&gt;p&lt;a paragraph<&gt;/p&lt;
</code>
</pre>

options

def marked(text, environ=None, **options): function parse markdown src to html. use options to control how to parse:

  • gfm:

    Type: Boolean Default True

    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, environ: '<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: {}

    set block macros, see test.MacroTestCase

  • inline_macros:

    Type: dict Default: {}

    set inline macros, see test.MacroTestCase

License

Copyright (c) 2011-2013, jander. (MIT License)

About

A markdown parser and compiler.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages