Fenced-Code-Blocks in Python-Markdown

2008-05-11 Thread Waylan Limberg
I'd like to announce a beta release of the Fenced-Code-Blocks
Extension for Python-Markdown.



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



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:


Hello World!
{.html}

Becomes:

Hello World!

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 <[EMAIL PROTECTED]> 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 [EMAIL PROTECTED] ___ Markdown-Discuss mailing list Markdown-Discuss@six.pairlist.net http://six.pairlist.net/mailman/listinfo/markdown-discuss

Re: Markdown Extra Spec: Parsing Section

2008-05-11 Thread Michel Fortin

Le 2008-05-11 à 20:55, Jacob Rus a écrit :

You should write it in something closer to a BNF-like format.  The  
current version is about 10x more verbose than necessary, and it  
makes reading the spec considerably more difficult.


The reason I'm doing it like this is that I doubt everything will be  
expressible in a BNF format. Using plain english descriptions allows  
me to not bother about fitting things to a specific grammar and just  
write what I feel is the most natural and the easier to understand.


Shopping for a more formal and less verbose grammar, if we need one,  
will be much easier once we know what we need, once we can compare  
existing grammars against a checklist of what is necessary to  
implement the given parsing algorithm.


If you remember the timetable I've given, you'll see that I've booked  
about half a year for polishing things out. This includes rephrasing  
sentences, refactorizing the syntax, and reformatting the spec to make  
it easier to understand. This *could* include switching to a new  
grammar format if it makes things more intuitive and readable.



Also, you're still going to have quite a few sticky edge cases with  
your current parsing model.  What happens when we have a `<>`- 
delimited URL inside a blockquote?  For instance:


> what about this  google.com/> case?



Well, currently newlines aren't allowed inside automatic links in  
Markdown.pl, PHP Markdown and some others. Implementations who see an  
automatic link there sees it as a link to "http://  
google.com/" (notice the space) or "http://"; (notice what's missing).


 


Anyway, with the parsing model in three passes I'm currently defining  
it's pretty trivial to do correctly: the block elements pass extracts  
the text of the blockquote, leaving this to parse by the span element  
pass:


what about this  case?

The span element pass would then see an autolink and just ignore any  
newline it finds in the URL.



Michel Fortin
[EMAIL PROTECTED]
http://michelf.com/


___
Markdown-Discuss mailing list
Markdown-Discuss@six.pairlist.net
http://six.pairlist.net/mailman/listinfo/markdown-discuss


Re: Markdown Extra Spec: Parsing Section

2008-05-11 Thread Jacob Rus

Michel Fortin wrote:
I've began writing the parsing section of the spec, and I though I'd 
let you know about where I'm heading with all this.


Also, you're still going to have quite a few sticky edge cases with your 
current parsing model.  What happens when we have a `<>`-delimited URL 
inside a blockquote?  For instance:


> what about this  google.com/> case?

-Jacob

___
Markdown-Discuss mailing list
Markdown-Discuss@six.pairlist.net
http://six.pairlist.net/mailman/listinfo/markdown-discuss


Re: Markdown Extra Spec: Parsing Section

2008-05-11 Thread Jacob Rus

Michel Fortin wrote:
I've began writing the parsing section of the spec, and I though I'd let 
you know about where I'm heading with all this.


You should write it in something closer to a BNF-like format.  The 
current version is about 10x more verbose than necessary, and it makes 
reading the spec considerably more difficult.


___
Markdown-Discuss mailing list
Markdown-Discuss@six.pairlist.net
http://six.pairlist.net/mailman/listinfo/markdown-discuss


PHP Markdown 1.0.1l & Extra 1.2

2008-05-11 Thread Michel Fortin

Time for an update to PHP Markdown and PHP Markdown Extra.



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.





1.0.1l (11 May 2008):

*   Now removing the UTF-8 BOM at the start of a document, if present.

*   Now accepting capitalized URI schemes (such as HTTP:) in automatic
links, such as ``.

*   Fixed a problem where `<[EMAIL PROTECTED]>` was seen as a horizontal
rule instead of an automatic link.

*   Fixed an issue where some characters in Markdown-generated HTML
attributes weren't properly escaped with entities.

*   Fix for code blocks as first element of a list item. Previously,
this didn't create any code block for item 2:

*   Item 1 (regular paragraph)

*   Item 2 (code block)

*   A code block starting on the second line of a document wasn't seen
as a code block. This has been fixed.

*   Added programatically-settable parser properties `predef_urls` and
`predef_titles` for predefined URLs and titles for reference-style
links. To use this, your PHP code must call the parser this way:

$parser = new Markdwon_Parser;
$parser->predef_urls = array('linkref' => 'http://example.com');
$html = $parser->transform($text);

You can then use the URL as a normal link reference:

[my link][linkref]  
[my link][linkRef]

Reference names in the parser properties *must* be lowercase.
Reference names in the Markdown source may have any case.

*   Added `setup` and `teardown` methods which can be used by subclassers
as hook points to arrange the state of some parser variables before and
after parsing.


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!


*   Rewrote parts of the HTML block parser to better accomodate
fenced code blocks.

*   Footnotes may now be referenced from within another footnote.

*   Added programatically-settable parser property `predef_attr` for
predefined attribute definitions.

*   Fixed an issue where an indented code block preceded by a blank
line containing some other whitespace would confuse the HTML
block parser into creating an HTML block when it should have
been code.


Michel Fortin
[EMAIL PROTECTED]
http://michelf.com/


___
Markdown-Discuss mailing list
Markdown-Discuss@six.pairlist.net
http://six.pairlist.net/mailman/listinfo/markdown-discuss