From 89dafd4a13f05262de9900c9fc2f77c0f7c85049 Mon Sep 17 00:00:00 2001 From: Michel Fortin Date: Tue, 14 Aug 2007 16:41:04 -0400 Subject: [PATCH] PHP Markdown 1.0.1g --- PHP Markdown Readme.text | 53 ++++++++++++- markdown.php | 166 +++++++++++++-------------------------- 2 files changed, 107 insertions(+), 112 deletions(-) diff --git a/PHP Markdown Readme.text b/PHP Markdown Readme.text index 1a69717..1c8e6e5 100644 --- a/PHP Markdown Readme.text +++ b/PHP Markdown Readme.text @@ -1,7 +1,7 @@ PHP Markdown ============ -Version 1.0.2b8 - Mon 21 May 2007 +Version 1.0.1g - Tue 3 Jul 2007 by Michel Fortin @@ -203,6 +203,57 @@ expected; (3) the output PHP Markdown actually produced. Version History --------------- +1.0.1g (3 Jul 2007): + +* Fix for PHP 5 compiled without the mbstring module. Previous fix to + calculate the length of UTF-8 strings in `detab` when `mb_strlen` is + not available was only working with PHP 4. + +* Fixed a problem with WordPress 2.x where full-content posts in RSS feeds + were not processed correctly by Markdown. + +* Now supports URLs containing literal parentheses for inline links + and images, such as: + + [WIMP](http://en.wikipedia.org/wiki/WIMP_(computing)) + + Such parentheses may be arbitrarily nested, but must be + balanced. Unbalenced parentheses are allowed however when the URL + when escaped or when the URL is enclosed in angle brakets `<>`. + +* Fixed a performance problem where the regular expression for strong + emphasis introduced in version 1.0.1d could sometime be long to process, + give slightly wrong results, and in some circumstances could remove + entirely the content for a whole paragraph. + +* Some change in version 1.0.1d made possible the incorrect nesting of + anchors within each other. This is now fixed. + +* Fixed a rare issue where certain MD5 hashes in the content could + be changed to their corresponding text. For instance, this: + + The MD5 value for "+" is "26b17225b626fb9238849fd60eabdf60". + + was incorrectly changed to this in previous versions of PHP Markdown: + +

The MD5 value for "+" is "+".

+ +* Now convert escaped characters to their numeric character + references equivalent. + + This fix an integration issue with SmartyPants and backslash escapes. + Since Markdown and SmartyPants have some escapable characters in common, + it was sometime necessary to escape them twice. Previously, two + backslashes were sometime required to prevent Markdown from "eating" the + backslash before SmartyPants sees it: + + Here are two hyphens: \\-- + + Now, only one backslash will do: + + Here are two hyphens: \-- + + 1.0.1f (7 Feb 2007): * Fixed an issue with WordPress where manually-entered excerpts, but diff --git a/markdown.php b/markdown.php index 589398b..d6ceb17 100644 --- a/markdown.php +++ b/markdown.php @@ -12,7 +12,7 @@ # -define( 'MARKDOWN_VERSION', "1.0.2b8" ); # Mon 21 May 2007 +define( 'MARKDOWN_VERSION', "1.0.1g" ); # Tue 3 Jul 2007 # @@ -62,7 +62,7 @@ function Markdown($text) { Plugin Name: Markdown Plugin URI: http://www.michelf.com/projects/php-markdown/ Description: Markdown syntax allows you to write using an easy-to-read, easy-to-write plain text format. Based on the original Perl version by John Gruber. More... -Version: 1.0.2b8 +Version: 1.0.1g Author: Michel Fortin Author URI: http://www.michelf.com/ */ @@ -110,7 +110,7 @@ if (isset($wp_version)) { global $wp_markdown_hidden; $wp_markdown_hidden[1] = '

 
  • '; - $wp_markdown_hidden[2] = explode(str_rot13( + $wp_markdown_hidden[2] = explode(' ', str_rot13( 'pEj07ZbbBZ U1kqgh4w4p pre2zmeN6K QTi31t9pre ol0MP1jzJR '. 'ML5IjmbRol ulANi1NsGY J7zRLJqPul liA8ctl16T K9nhooUHli')); } @@ -410,7 +410,7 @@ class Markdown_Parser { [ ]* # trailing spaces/tabs (?=\n+|\Z) # followed by a newline or end of document ) - }xm', + }xmi', array(&$this, '_hashHTMLBlocks_callback'), $text); @@ -427,7 +427,7 @@ class Markdown_Parser { [ ]* # trailing spaces/tabs (?=\n+|\Z) # followed by a newline or end of document ) - }xm', + }xmi', array(&$this, '_hashHTMLBlocks_callback'), $text); @@ -448,7 +448,7 @@ class Markdown_Parser { [ ]* (?=\n{2,}|\Z) # followed by a blank line or end of document ) - }x', + }xi', array(&$this, '_hashHTMLBlocks_callback'), $text); @@ -719,14 +719,14 @@ class Markdown_Parser { # These must come last in case you've also got [link test][1] # or [link test](/foo) # - $text = preg_replace_callback('{ - ( # wrap whole match in $1 - \[ - ([^\[\]]+) # link text = $2; can\'t contain [ or ] - \] - ) - }xs', - array(&$this, '_doAnchors_reference_callback'), $text); +// $text = preg_replace_callback('{ +// ( # wrap whole match in $1 +// \[ +// ([^\[\]]+) # link text = $2; can\'t contain [ or ] +// \] +// ) +// }xs', +// array(&$this, '_doAnchors_reference_callback'), $text); $this->in_anchor = false; return $text; @@ -1285,41 +1285,41 @@ class Markdown_Parser { if (isset($this->html_blocks[$graf])) { $block = $this->html_blocks[$graf]; $graf = $block; - if (preg_match('{ - \A - ( # $1 =
    tag -
    ]* - \b - markdown\s*=\s* ([\'"]) # $2 = attr quote char - 1 - \2 - [^>]* - > - ) - ( # $3 = contents - .* - ) - (
    ) # $4 = closing tag - \z - }xs', $block, $matches)) - { - list(, $div_open, , $div_content, $div_close) = $matches; - - # We can't call Markdown(), because that resets the hash; - # that initialization code should be pulled into its own sub, though. - $div_content = $this->hashHTMLBlocks($div_content); - - # Run document gamut methods on the content. - foreach ($this->document_gamut as $method => $priority) { - $div_content = $this->$method($div_content); - } - - $div_open = preg_replace( - '{\smarkdown\s*=\s*([\'"]).+?\1}', '', $div_open); - - $graf = $div_open . "\n" . $div_content . "\n" . $div_close; - } +// if (preg_match('{ +// \A +// ( # $1 =
    tag +//
    ]* +// \b +// markdown\s*=\s* ([\'"]) # $2 = attr quote char +// 1 +// \2 +// [^>]* +// > +// ) +// ( # $3 = contents +// .* +// ) +// (
    ) # $4 = closing tag +// \z +// }xs', $block, $matches)) +// { +// list(, $div_open, , $div_content, $div_close) = $matches; +// +// # We can't call Markdown(), because that resets the hash; +// # that initialization code should be pulled into its own sub, though. +// $div_content = $this->hashHTMLBlocks($div_content); +// +// # Run document gamut methods on the content. +// foreach ($this->document_gamut as $method => $priority) { +// $div_content = $this->$method($div_content); +// } +// +// $div_open = preg_replace( +// '{\smarkdown\s*=\s*([\'"]).+?\1}', '', $div_open); +// +// $graf = $div_open . "\n" . $div_content . "\n" . $div_close; +// } $grafs[$key] = $graf; } } @@ -1517,7 +1517,7 @@ class Markdown_Parser { # tab characters. Then we reconstruct every line by adding the # appropriate number of space between each blocks. - $strlen = $this->utf8_strlen; # best strlen function for UTF-8. + $strlen = $this->utf8_strlen; # strlen function for UTF-8. $lines = explode("\n", $text); $text = ""; @@ -1540,18 +1540,14 @@ class Markdown_Parser { function _initDetab() { # # Check for the availability of the function in the `utf8_strlen` property - # (probably `mb_strlen`). If the function is not available, create a + # (initially `mb_strlen`). If the function is not available, create a # function that will loosely count the number of UTF-8 characters with a # regular expression. # if (function_exists($this->utf8_strlen)) return; - $this->utf8_strlen = 'Markdown_UTF8_strlen'; - - if (function_exists($this->utf8_strlen)) return; - function Markdown_UTF8_strlen($text) { - return preg_match_all('/[\x00-\xBF]|[\xC0-\xFF][\x80-\xBF]*/', - $text, $m); - } + $this->utf8_strlen = create_function('$text', 'return preg_match_all( + "/[\\\\x00-\\\\xBF]|[\\\\xC0-\\\\xFF][\\\\x80-\\\\xBF]*/", + $text, $m);'); } @@ -1608,52 +1604,7 @@ Version History See the readme file for detailed release notes for this version. -1.0.2b8 (21 May 2007): - -* Fixed a problem with WordPress 2.x where full-content posts in RSS feeds - were not processed correctly by Markdown. - -* Now supports URLs containing literal parentheses for inline links - and images, such as: - - [WIMP](http://en.wikipedia.org/wiki/WIMP_(computing)) - - Such parentheses may be arbitrarily nested, but must be - balanced. Unbalenced parentheses are allowed however when the URL - when escaped or when the URL is enclosed in angle brakets `<>`. - -* Fixed a performance problem with the regular expression for strong - emphasis introduced in version 1.0.1d could sometime be long to process, - give slightly wrong results, and in some circumstances could remove - entirely the content for a whole paragraph. - -* Some change in version 1.0.1d made possible the incorrect nesting of - anchors within each other. This is now fixed. - -* Fixed a rare issue where certain MD5 hashes in the content could - be changed to their corresponding text. For instance, this: - - The MD5 value for "+" is "26b17225b626fb9238849fd60eabdf60". - - was incorrectly changed to this in previous versions of PHP Markdown: - -

    The MD5 value for "+" is "+".

    - -* Now convert the escaped characters to their numeric character - references equivalent. - - This fix an integration issue with SmartyPants and backslash escapes. - Since Markdown and SmartyPants have some escapable characters in common, - it was sometime necessary to escape them twice. Previously, two - backslashes were sometime required to prevent Markdown from "eating" the - backslash before SmartyPants sees it: - - Here are two hyphens: \\-- - - Now, only one backslash will do: - - Here are two hyphens: \-- - +1.0.1g (3 Jul 2007) 1.0.1f (7 Feb 2007) @@ -1661,13 +1612,6 @@ See the readme file for detailed release notes for this version. 1.0.1d (1 Dec 2006) -1.0.1b7 (16 Sep 2006): - -* Filthy hack to support markdown='1' in div tags. - -* Experimental support for [this] as a synonym for [this][]. - - 1.0.1c (9 Dec 2005) 1.0.1b (6 Jun 2005)