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"><p>Hello World!</p> </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
> <pre><code class="html"><p>Hello World!</p> > </code></pre>It would be a much better idea to place the class-name on the outer element (`<pre>`) -- M?r
Le 2008-05-12 ? 1:01, Waylan Limberg a ?crit :> 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 > >Wow, that was fast! :-) There is one particularity in my implementation I think you've missed though (which is not surprising given I haven't mentioned it anywhere, yet). It touches the output when there are leading blank lines. If you try this in various browsers: <pre> a </pre> You'll notice, when serving the file as text/html, that the first newline is lost. When parsing the file as XML, it stays there however. If you then add: <pre><code> a </code></pre> you'll then notice that the first line is there in Gecko, but still lost with Web Kit. So basically, you can't just add newlines at the start of a code block and expect it to work. PHP Markdown Extra's output when you have a leading newline is as such: <pre><code><br />a </code></pre> which solves the situation in both Safari and Gecko-based browsers (haven't tested in others). If you have two leading newlines, then you'll get two <br />s, etc.> 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"><p>Hello World!</p> > </code></pre>While it has been suggested some time ago that {.class-name} stand for a class attribute applied to an arbitrary element, I'm wondering if we can't do something better than that for code blocks. I'm currently thinking of allowing the following, which I find more appealing visually: ~~~~~~~~~~~~~~ .html <p>Hello World!</p> ~~~~~~~~~~~~~~> Unfortunately, including the class > definition makes PHP Markdown Extra fail to match the block. Consider > yourself warned.Indeed. Michel Fortin michel.fortin at michelf.com http://michelf.com/