You are here

protected function Markdown::doLists in Express 8

* Form HTML ordered (numbered) and unordered (bulleted) lists. *

Parameters

string $text: * @return string

1 call to Markdown::doLists()
Markdown::_processListItems_callback in vendor/michelf/php-markdown/Michelf/Markdown.php
* List item parsing callback *

File

vendor/michelf/php-markdown/Michelf/Markdown.php, line 998

Class

Markdown
Markdown Parser Class

Namespace

Michelf

Code

protected function doLists($text) {
  $less_than_tab = $this->tab_width - 1;

  // Re-usable patterns to match list item bullets and number markers:
  $marker_ul_re = '[*+-]';
  $marker_ol_re = '\\d+[\\.]';
  $markers_relist = array(
    $marker_ul_re => $marker_ol_re,
    $marker_ol_re => $marker_ul_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 . '})	# $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 . '[ ]+
					  )
				  )
				)
			';

    // mx
    // We use a different prefix before nested lists than top-level lists.

    //See extended comment in _ProcessListItems().
    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;
}