src/Ciconia/Extension/Core/ListExtension.php
public function processList(Text $text, array $options = array(), $level = 0)
    {
        $lessThanTab = $options['tabWidth'] - 1;

        $wholeList = '
            #(                                 # $1 = whole list
              (                               # $2
                [ ]{0,' . $lessThanTab . '}
                (' . $this->getPattern() . ') # $3 = first list item marker
                [ \t]+
              )
              (?s:.+?)
              (?:                             # $4
                  \z
                |
                  \n{2,}
                  (?=\S)
                  (?!                         # Negative lookahead for another list item marker
                    [ \t]*
                    ' . $this->getPattern() . '[ \t]+
                  )
              )
            #)
        ';

        /** @noinspection PhpUnusedParameterInspection */
        $callback = function (Text $list, Text $marker) use ($options, $level) {
            $type = preg_match('{' . $this->ul . '}', $marker) ? 'ul' : 'ol';
            $list->replace('/\n{2,}/', "\n\n\n");
            $this->processListItems($list, $options, $level);

            return $this->getRenderer()->renderList($list, array('type' => $type)) . "\n\n";
        };

        if ($level) {
            $text->replace("{^$wholeList}mx", $callback);
        } else {
            $text->replace('{(?:(?<=\n\n)|\A\n?)' . $wholeList . '}mx', $callback);
        }
    }
public function processList(Text $text, array $options = array(), $level = 0)
    {
        $lessThanTab = $options['tabWidth'] - 1;

        $wholeList = '
            #(                                 # $1 = whole list
              (                               # $2
                [ ]{0,' . $lessThanTab . '}
                (' . $this->getPattern() . ') # $3 = first list item marker
                [ \t]+
              )
              (?s:.+?)
              (?:                             # $4
                  \z
                |
                  \n{2,}
                  (?=\S)
                  (?!                         # Negative lookahead for another list item marker
                    [ \t]*
                    ' . $this->getPattern() . '[ \t]+
                  )
              )
            #)
        ';

        /** @noinspection PhpUnusedParameterInspection */
        $callback = function (Text $list, Text $marker) use ($options, $level) {
            $type = preg_match('{' . $this->ul . '}', $marker) ? 'ul' : 'ol';
            $list->replace('/\n{2,}/', "\n\n\n");
            $this->processListItems($list, $options, $level);

            return $this->getRenderer()->renderList($list, array('type' => $type)) . "\n\n";
        };

        if ($level) {
            $text->replace("{^$wholeList}mx", $callback);
        } else {
            $text->replace('{(?:(?<=\n\n)|\A\n?)' . $wholeList . '}mx', $callback);
        }
    }
Form HTML ordered (numbered) and unordered (bulleted) lists.

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