src/Ciconia/Extension/Core/ListExtension.php
public function processListItems(Text $list, array $options = array(), $level = 0)
    {
        $list->replace('/\n{2,}\z/', "\n");

        /** @noinspection PhpUnusedParameterInspection */
        $list->replace('{
            (\n)?                                 # leading line = $1
            (^[ \t]*)                             # leading whitespace = $2
            (' . $this->getPattern() . ') [ \t]+  # list marker = $3
            ((?s:.+?)                             # list item text   = $4
            (\n{1,2}))
            (?= \n* (\z | \2 (' . $this->getPattern() . ') [ \t]+))
        }mx', function (Text $w, Text $leadingLine, Text $ls, Text $m, Text $item) use ($options, $level) {
            if ((string)$leadingLine || $item->match('/\n{2,}/')) {
                $this->markdown->emit('outdent', array($item));
                $this->markdown->emit('block', array($item));
            } else {
                $this->markdown->emit('outdent', array($item));
                $this->processList($item, $options, ++$level);
                $item->rtrim();
                $this->markdown->emit('inline', array($item));
            }

            return $this->getRenderer()->renderListItem($item) . "\n";
        });
    }
public function processListItems(Text $list, array $options = array(), $level = 0)
    {
        $list->replace('/\n{2,}\z/', "\n");

        /** @noinspection PhpUnusedParameterInspection */
        $list->replace('{
            (\n)?                                 # leading line = $1
            (^[ \t]*)                             # leading whitespace = $2
            (' . $this->getPattern() . ') [ \t]+  # list marker = $3
            ((?s:.+?)                             # list item text   = $4
            (\n{1,2}))
            (?= \n* (\z | \2 (' . $this->getPattern() . ') [ \t]+))
        }mx', function (Text $w, Text $leadingLine, Text $ls, Text $m, Text $item) use ($options, $level) {
            if ((string)$leadingLine || $item->match('/\n{2,}/')) {
                $this->markdown->emit('outdent', array($item));
                $this->markdown->emit('block', array($item));
            } else {
                $this->markdown->emit('outdent', array($item));
                $this->processList($item, $options, ++$level);
                $item->rtrim();
                $this->markdown->emit('inline', array($item));
            }

            return $this->getRenderer()->renderListItem($item) . "\n";
        });
    }
Process the contents of a single ordered or unordered list, splitting it into individual list items.

@param Text  $list
@param array $options
@param int   $level