You are here

function Markdown_Parser::_processListItems_callback in Markdown 5

Same name and namespace in other branches
  1. 6 markdown.php \Markdown_Parser::_processListItems_callback()

File

./markdown.php, line 1048

Class

Markdown_Parser

Code

function _processListItems_callback($matches) {
  $item = $matches[4];
  $leading_line =& $matches[1];
  $leading_space =& $matches[2];
  $marker_space = $matches[3];
  $tailing_blank_line =& $matches[5];
  if ($leading_line || $tailing_blank_line || preg_match('/\\n{2,}/', $item)) {

    # Replace marker with the appropriate whitespace indentation
    $item = $leading_space . str_repeat(' ', strlen($marker_space)) . $item;
    $item = $this
      ->runBlockGamut($this
      ->outdent($item) . "\n");
  }
  else {

    # Recursion for sub-lists:
    $item = $this
      ->doLists($this
      ->outdent($item));
    $item = preg_replace('/\\n+$/', '', $item);
    $item = $this
      ->runSpanGamut($item);
  }
  return "<li>" . $item . "</li>\n";
}