Permalink
Browse files

Lists can now have empty items.

  • Loading branch information...
1 parent a98a3aa commit 4ba5b3209e72ef7813ad3ed62deefccad31cb6b2 @michelf committed Jun 7, 2008
Showing with 15 additions and 4 deletions.
  1. +5 −0 PHP Markdown Readme.text
  2. +10 −4 markdown.php
View
@@ -200,6 +200,11 @@ expected; (3) the output PHP Markdown actually produced.
Version History
---------------
+Current:
+
+* Lists can now have empty items.
+
+
1.0.1l:
* Now removing the UTF-8 BOM at the start of a document, if present.
View
@@ -897,6 +897,10 @@ function doHeaders($text) {
return $text;
}
function _doHeaders_callback_setext($matches) {
+ # Terrible hack to check we haven't found an empty list item.
+ if ($matches[2] == '-' && preg_match('{^-(?: |$)}', $matches[1]))
+ return $matches[0];
+
$level = $matches[2]{0} == '=' ? 1 : 2;
$block = "<h$level>".$this->runSpanGamut($matches[1])."</h$level>";
return "\n" . $this->hashBlock($block) . "\n\n";
@@ -1018,11 +1022,13 @@ function processListItems($list_str, $marker_any_re) {
$list_str = preg_replace_callback('{
(\n)? # leading line = $1
- (^[ ]*) # leading whitespace = $2
- ('.$marker_any_re.' [ ]+) # list marker and space = $3
- ((?s:.+?)) # list item text = $4
+ (^[ ]*) # leading whitespace = $2
+ ('.$marker_any_re.' # list marker and space = $3
+ (?:[ ]+|(?=\n)) # space only required if item is not empty
+ )
+ ((?s:.*?)) # list item text = $4
(?:(\n+(?=\n))|\n) # tailing blank line = $5
- (?= \n* (\z | \2 ('.$marker_any_re.') [ ]+))
+ (?= \n* (\z | \2 ('.$marker_any_re.') (?:[ ]+|(?=\n))))
}xm',
array(&$this, '_processListItems_callback'), $list_str);

0 comments on commit 4ba5b32

Please sign in to comment.