function Markdown_Parser::doLists in Markdown 6        
                          
                  
                        Same name and namespace in other branches
- 5 markdown.php \Markdown_Parser::doLists()
 
 
1 call to Markdown_Parser::doLists()
  - Markdown_Parser::_processListItems_callback in ./markdown.php
 
  
 
File
 
   - ./markdown.php, line 960
 
  
  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,
    $marker_ol_re => $marker_ul_re,
  );
  foreach ($markers_relist as $marker_re => $other_marker_re) {
    
    $whole_list_re = '
				(								# $1 = whole list
				  (								# $2
					([ ]{0,' . $less_than_tab . '})	# $3 = number of spaces
					(' . $marker_re . ')			# $4 = first list item marker
					[ ]+
				  )
				  (?s:.+?)
				  (								# $5
					  \\z
					|
					  \\n{2,}
					  (?=\\S)
					  (?!						# Negative lookahead for another list item marker
						[ ]*
						' . $marker_re . '[ ]+
					  )
					|
					  (?=						# Lookahead for another kind of list
					    \\n
						\\3						# Must have the same indentation
						' . $other_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;
}