function Markdown_Parser::doLists in Markdown 5
Same name and namespace in other branches
- 6 markdown.php \Markdown_Parser::doLists()
1 call to Markdown_Parser::doLists()
- Markdown_Parser::_processListItems_callback in ./markdown.php
File
- ./markdown.php, line 925
Class
- Markdown_Parser
Code
function doLists($text) {
$less_than_tab = $this->tab_width - 1;
$marker_ul_re = '[*+-]';
$marker_ol_re = '\\d+[.]';
$marker_any_re = "(?:{$marker_ul_re}|{$marker_ol_re})";
$markers_relist = array(
$marker_ul_re,
$marker_ol_re,
);
foreach ($markers_relist as $marker_re) {
$whole_list_re = '
( # $1 = whole list
( # $2
[ ]{0,' . $less_than_tab . '}
(' . $marker_re . ') # $3 = first list item marker
[ ]+
)
(?s:.+?)
( # $4
\\z
|
\\n{2,}
(?=\\S)
(?! # Negative lookahead for another list item marker
[ ]*
' . $marker_re . '[ ]+
)
)
)
';
if ($this->list_level) {
$text = preg_replace_callback('{
^
' . $whole_list_re . '
}mx', array(
&$this,
'_doLists_callback',
), $text);
}
else {
$text = preg_replace_callback('{
(?:(?<=\\n)\\n|\\A\\n?) # Must eat the newline
' . $whole_list_re . '
}mx', array(
&$this,
'_doLists_callback',
), $text);
}
}
return $text;
}