• pairs * The regex contains some useful comments for which parts are stored in the array of matches. * * @param string String of text to parse for creating a list * @return string The converted string with HTML tags */ function do_list( $text ) { $text = str_replace( "\n", "\n\n", $text ); // Re-usable patterns to match the entire list $list_regex = '( # $1 = whole list ( # $2 ([ ]{0,3}) # $3 = number of spaces ([*-]) # $4 = first list item marker ) (?s:.+?) ( # $5 \z | \n{2,} (?=\S) (?! # Negative lookahead for another list item marker [ ]* [*-] ) ) )'; // Run our regex through the callback, get the eventual text a few levels down and return it back to P2 here. $text = preg_replace_callback( '{^' . $list_regex . '}mx', array( &$this, '_do_list_callback' ), $text ); $text = str_replace( "\n\n", "\n", $text ); $text = str_replace( "\n
  • ", "", $text ); return $text; } /** * Pads the list (if found) with the