PHP Markdown Extra 1.1.2
This commit is contained in:
parent
07f1eebb09
commit
128de3aa97
3 changed files with 96 additions and 49 deletions
|
|
@ -1,5 +1,5 @@
|
|||
PHP Markdown & Extra
|
||||
Copyright (c) 2004-2006 Michel Fortin
|
||||
Copyright (c) 2004-2007 Michel Fortin
|
||||
<http://www.michelf.com/>
|
||||
All rights reserved.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
PHP Markdown Extra
|
||||
==================
|
||||
|
||||
Version 1.1.1 - Thu 28 Dec 2006
|
||||
Version 1.1.2 - Wed 7 Feb 2007
|
||||
|
||||
by Michel Fortin
|
||||
<http://www.michelf.com/>
|
||||
|
|
@ -155,7 +155,7 @@ perform the conversion to HTML. You can update PHP Markdown -- or
|
|||
replace it with PHP Markdown Extra -- 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
|
||||
|
|
@ -207,6 +207,46 @@ expected; (3) the output PHP Markdown actually produced.
|
|||
Version History
|
||||
---------------
|
||||
|
||||
Extra 1.1.2 (7 Feb 2007)
|
||||
|
||||
* Fixed an issue where headers preceded too closely by a paragraph
|
||||
(with no blank line separating them) where put inside the paragraph.
|
||||
|
||||
* Added the missing TextileRestricted method that was added to regular
|
||||
PHP Markdown since 1.0.1d but which I forgot to add to Extra.
|
||||
|
||||
|
||||
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.
|
||||
|
||||
|
||||
Extra 1.1.1 (28 Dec 2006)
|
||||
|
||||
* Fixed a problem where whitespace at the end of the line of an atx-style
|
||||
|
|
@ -409,7 +449,7 @@ Extra 1.0b2 - 26 July 2005
|
|||
|
||||
* Added the pipe character to the backlash escape character lists.
|
||||
|
||||
1.0b1 (25 Jun 2005)
|
||||
Extra 1.0b1 (25 Jun 2005)
|
||||
|
||||
* First public release of PHP Markdown Extra.
|
||||
|
||||
|
|
|
|||
97
markdown.php
97
markdown.php
|
|
@ -3,7 +3,7 @@
|
|||
# Markdown Extra - A text-to-HTML conversion tool for web writers
|
||||
#
|
||||
# PHP Markdown & Extra
|
||||
# Copyright (c) 2004-2006 Michel Fortin
|
||||
# Copyright (c) 2004-2007 Michel Fortin
|
||||
# <http://www.michelf.com/projects/php-markdown/>
|
||||
#
|
||||
# Original Markdown
|
||||
|
|
@ -12,8 +12,8 @@
|
|||
#
|
||||
|
||||
|
||||
define( 'MARKDOWN_VERSION', "1.0.1e" ); # Thu 28 Dec 2006
|
||||
define( 'MARKDOWNEXTRA_VERSION', "1.1.1" ); # Thu 28 Dec 2006
|
||||
define( 'MARKDOWN_VERSION', "1.0.1f" ); # Wed 7 Feb 2007
|
||||
define( 'MARKDOWNEXTRA_VERSION', "1.1.2" ); # Wed 7 Feb 2007
|
||||
|
||||
|
||||
#
|
||||
|
|
@ -71,7 +71,7 @@ function Markdown($text) {
|
|||
Plugin Name: Markdown Extra
|
||||
Plugin URI: http://www.michelf.com/projects/php-markdown/
|
||||
Description: <a href="http://daringfireball.net/projects/markdown/syntax">Markdown syntax</a> allows you to write using an easy-to-read, easy-to-write plain text format. Based on the original Perl version by <a href="http://daringfireball.net/">John Gruber</a>. <a href="http://www.michelf.com/projects/php-markdown/">More...</a>
|
||||
Version: 1.1.1
|
||||
Version: 1.1.2
|
||||
Author: Michel Fortin
|
||||
Author URI: http://www.michelf.com/
|
||||
*/
|
||||
|
|
@ -125,12 +125,14 @@ if (isset($wp_version)) {
|
|||
}
|
||||
|
||||
function mdwp_add_p($text) {
|
||||
if (strlen($text) == 0) return;
|
||||
if (strcasecmp(substr($text, -3), '<p>') == 0) return $text;
|
||||
return '<p>'.$text.'</p>';
|
||||
if (!preg_match('{^$|^<(p|ul|ol|dl|pre|blockquote)>}i', $text)) {
|
||||
$text = '<p>'.$text.'</p>';
|
||||
$text = preg_replace('{\n{2,}}', "</p>\n\n<p>", $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;
|
||||
|
|
@ -182,6 +184,10 @@ if (strcasecmp(substr(__FILE__, -16), "classTextile.php") == 0) {
|
|||
if (function_exists('SmartyPants')) $text = SmartyPants($text);
|
||||
return $text;
|
||||
}
|
||||
# Fake restricted version: restrictions are not supported for now.
|
||||
function TextileRestricted($text, $lite='', $noimage='') {
|
||||
return $this->TextileThis($text, $lite);
|
||||
}
|
||||
# Workaround to ensure compatibility with TextPattern 4.0.3.
|
||||
function blockLite($text) { return $text; }
|
||||
}
|
||||
|
|
@ -465,7 +471,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
|
||||
|
|
@ -899,14 +905,17 @@ class Markdown_Parser {
|
|||
return $text;
|
||||
}
|
||||
function _doHeaders_callback_setext_h1($matches) {
|
||||
return $this->hashBlock("<h1>".$this->runSpanGamut($matches[1])."</h1>")."\n\n";
|
||||
$block = "<h1>".$this->runSpanGamut($matches[1])."</h1>";
|
||||
return "\n" . $this->hashBlock($block) . "\n\n";
|
||||
}
|
||||
function _doHeaders_callback_setext_h2($matches) {
|
||||
return $this->hashBlock("<h2>".$this->runSpanGamut($matches[1])."</h2>")."\n\n";
|
||||
$block = "<h2>".$this->runSpanGamut($matches[1])."</h2>";
|
||||
return "\n" . $this->hashBlock($block) . "\n\n";
|
||||
}
|
||||
function _doHeaders_callback_atx($matches) {
|
||||
$level = strlen($matches[1]);
|
||||
return $this->hashBlock("<h$level>".$this->runSpanGamut($matches[2])."</h$level>")."\n\n";
|
||||
$block = "<h$level>".$this->runSpanGamut($matches[2])."</h$level>";
|
||||
return "\n" . $this->hashBlock($block) . "\n\n";
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -978,9 +987,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>");
|
||||
|
|
@ -1024,8 +1031,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);
|
||||
|
|
@ -1037,9 +1044,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:
|
||||
|
|
@ -1221,7 +1231,7 @@ class Markdown_Parser {
|
|||
$bq = preg_replace_callback('{(\s*<pre>.+?</pre>)}sx',
|
||||
array(&$this, '_DoBlockQuotes_callback2'), $bq);
|
||||
|
||||
return $this->hashBlock("<blockquote>\n$bq\n</blockquote>")."\n\n";
|
||||
return "\n". $this->hashBlock("<blockquote>\n$bq\n</blockquote>")."\n\n";
|
||||
}
|
||||
function _doBlockQuotes_callback2($matches) {
|
||||
$pre = $matches[1];
|
||||
|
|
@ -1312,7 +1322,7 @@ class Markdown_Parser {
|
|||
'&', $text);;
|
||||
|
||||
# Encode naked <'s
|
||||
$text = preg_replace('{<(?![a-z/?\$!])}i', '<', $text);
|
||||
$text = preg_replace('{<(?![a-z/?\$!%])}i', '<', $text);
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
|
@ -1331,8 +1341,8 @@ class Markdown_Parser {
|
|||
|
||||
|
||||
function doAutoLinks($text) {
|
||||
$text = preg_replace('{<((https?|ftp|dict):[^\'">\s]+)>}',
|
||||
'<a href="\1">\1</a>', $text);
|
||||
$text = preg_replace_callback('{<((https?|ftp|dict):[^\'">\s]+)>}',
|
||||
array(&$this, '_doAutoLinks_url_callback'), $text);
|
||||
|
||||
# Email addresses: <address@domain.foo>
|
||||
$text = preg_replace_callback('{
|
||||
|
|
@ -1345,15 +1355,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 = "<a href=\"$url\">$url</a>";
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1461,7 +1476,7 @@ class Markdown_Parser {
|
|||
$str = $parts[2];
|
||||
|
||||
# Skip the whole code span, pass as text token.
|
||||
if (preg_match('/^(.*(?<!`\\\\)'.$parts[1].'(?!`))(.*)$/',
|
||||
if (preg_match('/^(.*(?<!`\\\\)'.$parts[1].'(?!`))(.*)$/sm',
|
||||
$str, $matches))
|
||||
{
|
||||
$tokens[] = array('text', $matches[1]);
|
||||
|
|
@ -1485,8 +1500,8 @@ class Markdown_Parser {
|
|||
}
|
||||
|
||||
|
||||
# Strlen function that will be used by detab. _initDetab will create a
|
||||
# function to hanlde UTF-8 if the default function does not exist.
|
||||
# String length function for detab. `_initDetab` will create a function to
|
||||
# hanlde UTF-8 if the default function does not exist.
|
||||
var $utf8_strlen = 'mb_strlen';
|
||||
|
||||
function detab($text) {
|
||||
|
|
@ -2071,18 +2086,18 @@ class MarkdownExtra_Parser extends Markdown_Parser {
|
|||
function _doHeaders_callback_setext_h1($matches) {
|
||||
$attr = $this->_doHeaders_attr($id =& $matches[2]);
|
||||
$block = "<h1$attr>".$this->runSpanGamut($matches[1])."</h1>";
|
||||
return $this->hashBlock($block) . "\n\n";
|
||||
return "\n" . $this->hashBlock($block) . "\n\n";
|
||||
}
|
||||
function _doHeaders_callback_setext_h2($matches) {
|
||||
$attr = $this->_doHeaders_attr($id =& $matches[2]);
|
||||
$block = "<h2$attr>".$this->runSpanGamut($matches[1])."</h2>";
|
||||
return $this->hashBlock($block) . "\n\n";
|
||||
return "\n" . $this->hashBlock($block) . "\n\n";
|
||||
}
|
||||
function _doHeaders_callback_atx($matches) {
|
||||
$level = strlen($matches[1]);
|
||||
$attr = $this->_doHeaders_attr($id =& $matches[3]);
|
||||
$block = "<h$level$attr>".$this->runSpanGamut($matches[2])."</h$level>";
|
||||
return $this->hashBlock($block) . "\n\n";
|
||||
return "\n" . $this->hashBlock($block) . "\n\n";
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -2671,7 +2686,9 @@ Version History
|
|||
|
||||
See Readme file for details.
|
||||
|
||||
Extra 1.1.1 (21 Dec 2006)
|
||||
Extra 1.1.2 (7 Feb 2007)
|
||||
|
||||
Extra 1.1.1 (28 Dec 2006)
|
||||
|
||||
Extra 1.1 (1 Dec 2006)
|
||||
|
||||
|
|
@ -2680,21 +2697,11 @@ Extra 1.0.1 (9 Dec 2005)
|
|||
Extra 1.0 (5 Sep 2005)
|
||||
|
||||
|
||||
Author & Contributors
|
||||
---------------------
|
||||
|
||||
Original Markdown by John Gruber
|
||||
<http://daringfireball.net/>
|
||||
|
||||
PHP port and extras by Michel Fortin
|
||||
<http://www.michelf.com/>
|
||||
|
||||
|
||||
Copyright and License
|
||||
---------------------
|
||||
|
||||
PHP Markdown & Extra
|
||||
Copyright (c) 2004-2006 Michel Fortin
|
||||
Copyright (c) 2004-2007 Michel Fortin
|
||||
<http://www.michelf.com/>
|
||||
All rights reserved.
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue