Fix for adjacent list of different kind.

This commit is contained in:
Michel Fortin 2009-01-01 09:29:26 -05:00
parent bf6366481e
commit 4bd7facc2b
2 changed files with 21 additions and 6 deletions

View file

@ -200,6 +200,12 @@ expected; (3) the output PHP Markdown actually produced.
Version History
---------------
Current:
* Fix for adjacent list of different kind where the second list could
end as a sublist of the first when not separated by an empty line.
1.0.1m (21 Jun 2008):
* Lists can now have empty items.

View file

@ -929,19 +929,22 @@ class Markdown_Parser {
$marker_ol_re = '\d+[.]';
$marker_any_re = "(?:$marker_ul_re|$marker_ol_re)";
$markers_relist = array($marker_ul_re, $marker_ol_re);
$markers_relist = array(
$marker_ul_re => $marker_ol_re,
$marker_ol_re => $marker_ul_re,
);
foreach ($markers_relist as $marker_re) {
foreach ($markers_relist as $marker_re => $other_marker_re) {
# Re-usable pattern to match any entirel ul or ol list:
$whole_list_re = '
( # $1 = whole list
( # $2
[ ]{0,'.$less_than_tab.'}
('.$marker_re.') # $3 = first list item marker
([ ]{0,'.$less_than_tab.'}) # $3 = number of spaces
('.$marker_re.') # $4 = first list item marker
[ ]+
)
(?s:.+?)
( # $4
( # $5
\z
|
\n{2,}
@ -950,6 +953,12 @@ class Markdown_Parser {
[ ]*
'.$marker_re.'[ ]+
)
|
(?= # Lookahead for another kind of list
\n
\3 # Must have the same indentation
'.$other_marker_re.'[ ]+
)
)
)
'; // mx
@ -982,7 +991,7 @@ class Markdown_Parser {
$marker_any_re = "(?:$marker_ul_re|$marker_ol_re)";
$list = $matches[1];
$list_type = preg_match("/$marker_ul_re/", $matches[3]) ? "ul" : "ol";
$list_type = preg_match("/$marker_ul_re/", $matches[4]) ? "ul" : "ol";
$marker_any_re = ( $list_type == "ul" ? $marker_ul_re : $marker_ol_re );