1
0
mirror of https://github.com/erusev/parsedown.git synced 2023-08-10 21:13:06 +03:00
This commit is contained in:
Emanuil 2013-07-26 00:08:52 +03:00
parent 7d7e89f5c3
commit 609ad47c38
3 changed files with 23 additions and 8 deletions

View File

@ -157,7 +157,6 @@ class Parsedown
{ {
$markup .= '<'.$list_type.'>'."\n"; $markup .= '<'.$list_type.'>'."\n";
# Of the same type and indentation.
$list_items = preg_split('/^([ ]{'.$list_indentation.'})'.$list_marker_pattern.'[ ]/m', $list, -1, PREG_SPLIT_NO_EMPTY); $list_items = preg_split('/^([ ]{'.$list_indentation.'})'.$list_marker_pattern.'[ ]/m', $list, -1, PREG_SPLIT_NO_EMPTY);
foreach ($list_items as $list_item) foreach ($list_items as $list_item)
@ -175,7 +174,7 @@ class Parsedown
} }
else else
{ {
$list_item = $this->parse_lines($list_item); $list_item = $this->parse_lines($list_item, TRUE);
} }
$markup .= "\n".$list_item; $markup .= "\n".$list_item;
@ -277,7 +276,7 @@ class Parsedown
{ {
if (strpos($block, "\n")) if (strpos($block, "\n"))
{ {
$markup .= $this->parse_lines($block); $markup .= $this->parse_lines($block, TRUE);
} }
else else
{ {
@ -292,7 +291,7 @@ class Parsedown
return $markup; return $markup;
} }
private function parse_lines($text) private function parse_lines($text, $paragraph_based = FALSE)
{ {
$text = trim($text, "\n"); $text = trim($text, "\n");
@ -473,9 +472,11 @@ class Parsedown
{ {
if (isset($paragraph)) if (isset($paragraph))
{ {
$element_text = $this->parse_inline_elements($paragraph); $paragraph_text = $this->parse_inline_elements($paragraph);
$markup .= '<p>'.$element_text.'</p>'."\n"; $markup .= $markup === '' && $paragraph_based === FALSE
? $paragraph_text
: '<p>'.$paragraph_text.'</p>'."\n";
unset($paragraph); unset($paragraph);
} }

View File

@ -15,3 +15,10 @@
<p>Here's one with no space after markers:</p> <p>Here's one with no space after markers:</p>
<p>-list item <p>-list item
-another list item</p> -another list item</p>
<p>Here's one where items contain line breaks:</p>
<ul>
<li>list
item</li>
<li>another
list item</li>
</ul>

View File

@ -18,3 +18,10 @@ Here's one with no space after markers:
-list item -list item
-another list item -another list item
Here's one where items contain line breaks:
- list
item
- another
list item