From f04d6c1b140a82088d3226b017c0403506fae777 Mon Sep 17 00:00:00 2001
From: Michel Fortin
Date: Tue, 14 Aug 2007 16:38:35 -0400
Subject: [PATCH] PHP Markdown 1.0.1f
---
License.text | 2 +-
PHP Markdown Readme.text | 37 +++++++++++++++--
markdown.php | 85 +++++++++++++++++++++-------------------
3 files changed, 80 insertions(+), 44 deletions(-)
diff --git a/License.text b/License.text
index 7ce147f..fe04d40 100644
--- a/License.text
+++ b/License.text
@@ -1,5 +1,5 @@
PHP Markdown
-Copyright (c) 2004-2006 Michel Fortin
+Copyright (c) 2004-2007 Michel Fortin
All rights reserved.
diff --git a/PHP Markdown Readme.text b/PHP Markdown Readme.text
index 6fbdf82..0012a79 100644
--- a/PHP Markdown Readme.text
+++ b/PHP Markdown Readme.text
@@ -1,7 +1,7 @@
PHP Markdown
============
-Version 1.0.1e - Thu 28 Dec 2006
+Version 1.0.1f - Wed 7 Feb 2007
by Michel Fortin
@@ -122,7 +122,7 @@ Many web applications now ship with PHP Markdown, or have plugins to
perform the conversion to HTML. You can update PHP Markdown in many of
these programs by swapping the old "markdown.php" file for the new one.
-Here is a short non-exaustive list of some programs and where they
+Here is a short non-exhaustive list of some programs and where they
hide the "markdown.php" file.
| Program | Path to Markdown
@@ -203,6 +203,37 @@ expected; (3) the output PHP Markdown actually produced.
Version History
---------------
+1.0.1f (7 Feb 2007):
+
+* Fixed an issue with WordPress where manually-entered excerpts, but
+ not the auto-generated ones, would contain nested paragraphs.
+
+* Fixed an issue introduced in 1.0.1d where headers and blockquotes
+ preceded too closely by a paragraph (not separated by a blank line)
+ where incorrectly put inside the paragraph.
+
+* Fixed an issue introduced in 1.0.1d in the tokenizeHTML method where
+ two consecutive code spans would be merged into one when together they
+ form a valid tag in a multiline paragraph.
+
+* Fixed an long-prevailing issue where blank lines in code blocks would
+ be doubled when the code block is in a list item.
+
+ This was due to the list processing functions relying on artificially
+ doubled blank lines to correctly determine when list items should
+ contain block-level content. The list item processing model was thus
+ changed to avoid the need for double blank lines.
+
+* Fixed an issue with `<% asp-style %>` instructions used as inline
+ content where the opening `<` was encoded as `<`.
+
+* Fixed a parse error occuring when PHP is configured to accept
+ ASP-style delimiters as boundaries for PHP scripts.
+
+* Fixed a bug introduced in 1.0.1d where underscores in automatic links
+ got swapped with emphasis tags.
+
+
1.0.1e (28 Dec 2006)
* Added support for internationalized domain names for email addresses in
@@ -515,7 +546,7 @@ Copyright and License
---------------------
PHP Markdown
-Copyright (c) 2004-2006 Michel Fortin
+Copyright (c) 2004-2007 Michel Fortin
All rights reserved.
diff --git a/markdown.php b/markdown.php
index 547aeac..b83596d 100644
--- a/markdown.php
+++ b/markdown.php
@@ -3,7 +3,7 @@
# Markdown - A text-to-HTML conversion tool for web writers
#
# PHP Markdown
-# Copyright (c) 2004-2006 Michel Fortin
+# Copyright (c) 2004-2007 Michel Fortin
#
#
# Original Markdown
@@ -12,7 +12,7 @@
#
-define( 'MARKDOWN_VERSION', "1.0.1e" ); # Thu 28 Dec 2006
+define( 'MARKDOWN_VERSION', "1.0.1f" ); # Wed 7 Feb 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.1e
+Version: 1.0.1f
Author: Michel Fortin
Author URI: http://www.michelf.com/
*/
@@ -116,12 +116,14 @@ if (isset($wp_version)) {
}
function mdwp_add_p($text) {
- if (strlen($text) == 0) return;
- if (strcasecmp(substr($text, -3), '') == 0) return $text;
- return '
'.$text.'
';
+ if (!preg_match('{^$|^<(p|ul|ol|dl|pre|blockquote)>}i', $text)) {
+ $text = ''.$text.'
';
+ $text = preg_replace('{\n{2,}}', "
\n\n", $text);
+ }
+ return $text;
}
- function mdwp_strip_p($t) { return preg_replace('{?[pP]>}', '', $t); }
+ function mdwp_strip_p($t) { return preg_replace('{?p>}i', '', $t); }
function mdwp_hide_tags($text) {
global $markdown_hidden_tags;
@@ -460,7 +462,7 @@ class Markdown_Parser {
array(&$this, '_hashHTMLBlocks_callback'),
$text);
- # PHP and ASP-style processor instructions ( and <%...%>)
+ # PHP and ASP-style processor instructions ( and <%)
$text = preg_replace_callback('{
(?:
(?<=\n\n) # Starting after a blank line
@@ -894,14 +896,17 @@ class Markdown_Parser {
return $text;
}
function _doHeaders_callback_setext_h1($matches) {
- return $this->hashBlock("
".$this->runSpanGamut($matches[1])."
")."\n\n";
+ $block = "".$this->runSpanGamut($matches[1])."
";
+ return "\n" . $this->hashBlock($block) . "\n\n";
}
function _doHeaders_callback_setext_h2($matches) {
- return $this->hashBlock("".$this->runSpanGamut($matches[1])."
")."\n\n";
+ $block = "".$this->runSpanGamut($matches[1])."
";
+ return "\n" . $this->hashBlock($block) . "\n\n";
}
function _doHeaders_callback_atx($matches) {
$level = strlen($matches[1]);
- return $this->hashBlock("".$this->runSpanGamut($matches[2])."")."\n\n";
+ $block = "".$this->runSpanGamut($matches[2])."";
+ return "\n" . $this->hashBlock($block) . "\n\n";
}
@@ -973,9 +978,7 @@ class Markdown_Parser {
$marker_any = ( $list_type == "ul" ? $marker_ul : $marker_ol );
- # Turn double returns into triple returns, so that we can make a
- # paragraph for the last item in a list, if necessary:
- $list = preg_replace("/\n{2,}/", "\n\n\n", $list);
+ $list .= "\n";
$result = $this->processListItems($list, $marker_any);
$result = $this->hashBlock("<$list_type>\n" . $result . "$list_type>");
@@ -1019,8 +1022,8 @@ class Markdown_Parser {
(\n)? # leading line = $1
(^[ \t]*) # leading whitespace = $2
('.$marker_any.') [ \t]+ # list marker = $3
- ((?s:.+?) # list item text = $4
- (\n{1,2}))
+ ((?s:.+?)) # list item text = $4
+ (?:(\n+(?=\n))|\n) # tailing blank line = $5
(?= \n* (\z | \2 ('.$marker_any.') [ \t]+))
}xm',
array(&$this, '_processListItems_callback'), $list_str);
@@ -1032,9 +1035,12 @@ class Markdown_Parser {
$item = $matches[4];
$leading_line =& $matches[1];
$leading_space =& $matches[2];
+ $tailing_blank_line =& $matches[5];
- if ($leading_line || preg_match('/\n{2,}/', $item)) {
- $item = $this->runBlockGamut($this->outdent($item));
+ if ($leading_line || $tailing_blank_line ||
+ preg_match('/\n{2,}/', $item))
+ {
+ $item = $this->runBlockGamut($this->outdent($item)."\n");
}
else {
# Recursion for sub-lists:
@@ -1216,7 +1222,7 @@ class Markdown_Parser {
$bq = preg_replace_callback('{(\s*.+?
)}sx',
array(&$this, '_DoBlockQuotes_callback2'), $bq);
- return $this->hashBlock("\n$bq\n
")."\n\n";
+ return "\n". $this->hashBlock("\n$bq\n
")."\n\n";
}
function _doBlockQuotes_callback2($matches) {
$pre = $matches[1];
@@ -1307,7 +1313,7 @@ class Markdown_Parser {
'&', $text);;
# Encode naked <'s
- $text = preg_replace('{<(?![a-z/?\$!])}i', '<', $text);
+ $text = preg_replace('{<(?![a-z/?\$!%])}i', '<', $text);
return $text;
}
@@ -1326,8 +1332,8 @@ class Markdown_Parser {
function doAutoLinks($text) {
- $text = preg_replace('{<((https?|ftp|dict):[^\'">\s]+)>}',
- '\1', $text);
+ $text = preg_replace_callback('{<((https?|ftp|dict):[^\'">\s]+)>}',
+ array(&$this, '_doAutoLinks_url_callback'), $text);
# Email addresses:
$text = preg_replace_callback('{
@@ -1340,15 +1346,20 @@ class Markdown_Parser {
)
>
}xi',
- array(&$this, '_doAutoLinks_callback'), $text);
+ array(&$this, '_doAutoLinks_email_callback'), $text);
return $text;
}
- function _doAutoLinks_callback($matches) {
+ function _doAutoLinks_url_callback($matches) {
+ $url = $this->encodeAmpsAndAngles($matches[1]);
+ $link = "$url";
+ return $this->hashSpan($link);
+ }
+ function _doAutoLinks_email_callback($matches) {
$address = $matches[1];
$address = $this->unescapeSpecialChars($address);
- $address = $this->encodeEmailAddress($address);
- return $this->hashSpan($address);
+ $link = $this->encodeEmailAddress($address);
+ return $this->hashSpan($link);
}
@@ -1456,7 +1467,7 @@ class Markdown_Parser {
$str = $parts[2];
# Skip the whole code span, pass as text token.
- if (preg_match('/^(.*(?
-
-PHP port and extras by Michel Fortin
-
-
-
Copyright and License
---------------------
-Copyright (c) 2004-2006 Michel Fortin
+PHP Markdown
+Copyright (c) 2004-2007 Michel Fortin
All rights reserved.
+Based on Markdown
Copyright (c) 2003-2006 John Gruber
All rights reserved.
@@ -1647,4 +1652,4 @@ negligence or otherwise) arising in any way out of the use of this
software, even if advised of the possibility of such damage.
*/
-?>
+?>
\ No newline at end of file