diff --git a/src/Pluf/Text/MarkDown.php b/src/Pluf/Text/MarkDown.php index 8128f2e..3b91c3e 100644 --- a/src/Pluf/Text/MarkDown.php +++ b/src/Pluf/Text/MarkDown.php @@ -3,7 +3,7 @@ # Markdown Extra - A text-to-HTML conversion tool for web writers # # PHP Markdown & Extra -# Copyright (c) 2004-2009 Michel Fortin +# Copyright (c) 2004-2012 Michel Fortin # # # Original Markdown @@ -12,8 +12,8 @@ # -define( 'MARKDOWN_VERSION', "1.0.1n" ); # Sat 10 Oct 2009 -define( 'MARKDOWNEXTRA_VERSION', "1.2.4" ); # Sat 10 Oct 2009 +define( 'MARKDOWN_VERSION', "1.0.1o" ); # Sun 8 Jan 2012 +define( 'MARKDOWNEXTRA_VERSION', "1.2.5" ); # Sun 8 Jan 2012 # @@ -68,7 +68,6 @@ function Pluf_Text_MarkDown_parse($text) { return Markdown($text); } - # # Markdown Parser Class # @@ -811,7 +810,7 @@ class Markdown_Parser { # Re-usable patterns to match list item bullets and number markers: $marker_ul_re = '[*+-]'; - $marker_ol_re = '\d+[.]'; + $marker_ol_re = '\d+[\.]'; $marker_any_re = "(?:$marker_ul_re|$marker_ol_re)"; $markers_relist = array( @@ -872,7 +871,7 @@ class Markdown_Parser { function _doLists_callback($matches) { # Re-usable patterns to match list item bullets and number markers: $marker_ul_re = '[*+-]'; - $marker_ol_re = '\d+[.]'; + $marker_ol_re = '\d+[\.]'; $marker_any_re = "(?:$marker_ul_re|$marker_ol_re)"; $list = $matches[1]; @@ -1002,17 +1001,17 @@ class Markdown_Parser { var $em_relist = array( - '' => '(?:(? '(?:(? '(?<=\S|^)(? '(?<=\S|^)(? '(?:(? '(?:(? '(?<=\S|^)(? '(?<=\S|^)(? '(?:(? '(?:(? '(?<=\S|^)(? '(?<=\S|^)(? ^ | \n ) - [ ]{'.($indent).'}~~~+[ ]*\n + [ ]{0,'.($indent).'}~~~+[ ]*\n ' : '' ). ' # End (if not is span). ) }xs'; @@ -1808,20 +1807,12 @@ class MarkdownExtra_Parser extends Markdown_Parser { } } # - # Check for: Indented code block. - # - else if ($tag{0} == "\n" || $tag{0} == " ") { - # Indented code block: pass it unchanged, will be handled - # later. - $parsed .= $tag; - } - # # Check for: Fenced code block marker. # - else if ($tag{0} == "~") { + else if (preg_match('{^\n?[ ]{0,'.($indent+3).'}~}', $tag)) { # Fenced code block marker: find matching end marker. $tag_re = preg_quote(trim($tag)); - if (preg_match('{^(?>.*\n)+?'.$tag_re.' *\n}', $text, + if (preg_match('{^(?>.*\n)+?[ ]{0,'.($indent).'}'.$tag_re.'[ ]*\n}', $text, $matches)) { # End marker found: pass text unchanged until marker. @@ -1834,6 +1825,14 @@ class MarkdownExtra_Parser extends Markdown_Parser { } } # + # Check for: Indented code block. + # + else if ($tag{0} == "\n" || $tag{0} == " ") { + # Indented code block: pass it unchanged, will be handled + # later. + $parsed .= $tag; + } + # # Check for: Opening Block level tag or # Opening Context Block tag (like ins and del) # used as a block tag (tag is alone on it's line). @@ -2449,17 +2448,17 @@ class MarkdownExtra_Parser extends Markdown_Parser { # work in the middle of a word. # var $em_relist = array( - '' => '(?:(? '(?:(? '(?<=\S|^)(? '(?<=\S|^)(? '(?:(? '(?:(? '(?<=\S|^)(? '(?<=\S|^)(? '(?:(? '(?:(? '(?<=\S|^)(? '(?<=\S|^)(?