" . get_string('tableofcontents', 'wiki') . "
$toc
";
}
/**
* List helpers
*/
private function process_block_list($listitems) {
$list = array();
foreach ($listitems as $li) {
$text = str_replace("\n", "", $li[2]);
$this->rules($text);
if ($li[1][0] == '*') {
$type = 'ul';
} else {
$type = 'ol';
}
$list[] = array(strlen($li[1]), $text, $type);
}
$type = $list[0][2];
return "<$type>" . "\n" . $this->generate_list($list) . "\n" . "$type>" . "\n";
}
/**
* List generation function from an array of array(level, text)
*/
protected function generate_list($listitems) {
$list = "";
$current_depth = 1;
$next_depth = 1;
$liststack = array();
for ($lc = 0; $lc < count($listitems) && $next_depth; $lc++) {
$cli = $listitems[$lc];
$nli = isset($listitems[$lc + 1]) ? $listitems[$lc + 1] : null;
$text = $cli[1];
$current_depth = $next_depth;
$next_depth = $nli ? $nli[0] : null;
if ($next_depth == $current_depth || $next_depth == null) {
$list .= parser_utils::h('li', $text) . "\n";
} else if ($next_depth > $current_depth) {
$next_depth = $current_depth + 1;
$list .= "