« »

python-markdown2 1.0.1.17

Wednesday, 26 May 2010

Where?

What's new?

  • [Issue 36] Fix "cuddled-lists" extra handling for an looks-like-a-cuddled-list-but-is-indented block. See the "test/tm-cases/cuddledlistindented.text" test case.

  • Experimental new "toc" extra. The returned string from conversion will have a toc_html attribute.

  • New "header-ids" extra that will add an id attribute to headers:

    # My First Section
    

    will become:

    <h1 id="my-first-section">My First Section</h1>
    

    An argument can be give for the extra, which will be used as a prefix for the ids:

    $ cat foo.txt 
    # hi there
    $ python markdown2.py foo.txt 
    <h1>hi there</h1>
    $ python markdown2.py foo.txt -x header-ids
    <h1 id="hi-there">hi there</h1>
    $ python markdown2.py foo.txt -x header-ids=prefix
    <h1 id="prefix-hi-there">hi there</h1>
    
  • Preliminary support for "html-classes" extra: takes a dict mapping HTML tag to the string value to use for a "class" attribute for that emitted tag. Currently just supports "pre" and "code" for code blocks.

Full changelog: http://code.google.com/p/python-markdown2/source/browse/trunk/CHANGES.txt

What is ‘markdown2’?

markdown2.py is a fast and complete Python implementation of Markdown -- a text-to-HTML markup syntax.

Module 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'

Command line usage

$ cat hi.markdown
# Hello World!
$ markdown2 hi.markdown
<h1>Hello World!</h1>

This implementation of Markdown implements the full "core" syntax plus a number of extras (e.g., code syntax coloring, footnotes) as described on http://code.google.com/p/python-markdown2/wiki/Extras.

Tagged: python, programming, markdown