Fenced-Code-Blocks in Python-Markdown

Waylan Limberg waylan at gmail.com
Mon May 12 01:01:37 EDT 2008


I'd like to announce a beta release of the Fenced-Code-Blocks
Extension for Python-Markdown.

<http://www.freewisdom.org/projects/python-markdown/Available_Extensions>

The latest code for Python-Markdown and packaged extensions are now
available on Gitorious.

<http://gitorious.org/projects/python-markdown>

The same syntax is used as the just released PHP Markdown Extra 1.2. I
did add the option to define a class on the block for language
identification. Here's an example:

~~~~~~~~~~~~
<p>Hello World!</p>
~~~~~~~~~~~~{.html}

Becomes:

<pre><code class="html">&lt;p&gt;Hello World!&lt;/p&gt;
</code></pre>

This should work nicely with Highlight.js [1] if one so desires. Of
course, as this is optional, if you leave the class definition off, it
works like PHP Markdown Extra. Unfortunately, including the class
definition makes PHP Markdown Extra fail to match the block. Consider
yourself warned.

[1]: http://softwaremaniacs.org/soft/highlight/en/



On Sun, May 11, 2008 at 8:31 AM, Michel Fortin
<michel.fortin at michelf.com> wrote:
[snip]

>

> This new version of PHP Markdown Extra adds support for "fenced" code blocks

> (which I was previously calling "flat"). Fenced code blocks overcome many

> limitations of Markdown's indented code blocks: they can can be put

> immediately following a list item, can start and end with blank lines, and

> can be put one after the other as two consecutive code blocks. Also, if

> you're using an editor which cannot indent automatically a selected block of

> text, such as a text box in your web browser, it's easier to paste code in.

>

[snip]

>

> Extra 1.2 (11 May 2008):

>

> * Added fenced code block syntax which don't require indentation

> and can start and end with blank lines. A fenced code block

> starts with a line of consecutive tilde (~) and ends on the

> next line with the same number of consecutive tilde. Here's an

> example:

>

> ~~~~~~~~~~~~

> Hello World!

> ~~~~~~~~~~~~

>

[snip]



--
----
Waylan Limberg
waylan at gmail.com


More information about the Markdown-Discuss mailing list