function _DoLists_callback($matches) { $list_type = $matches[3] == "*" ? "ul" : "ol"; $list = $matches[1]; $list = preg_replace("/\n{2,}/", "\n\n\n", $list); $result = _ProcessListItems($list); $result = "<{$list_type}>\n" . $result . "</{$list_type}>\n"; return $result; }
function _DoLists_callback($matches) { # Re-usable patterns to match list item bullets and number markers: $marker_ul = '[*+-]'; $marker_ol = '\\d+[.]'; $marker_any = "(?:{$marker_ul}|{$marker_ol})"; $list = $matches[1]; $list_type = preg_match("/{$marker_ul}/", $matches[3]) ? "ul" : "ol"; # Turn double returns into triple returns, so that we can make a # paragraph for the last item in a list, if necessary: $list = preg_replace("/\n{2,}/", "\n\n\n", $list); $result = _ProcessListItems($list, $marker_any); $result = "<{$list_type}>\n" . $result . "</{$list_type}>\n"; return $result; }