MDL-28616 wiki: use class variable for toc header depth

This commit is contained in:
Charles Fulton 2012-08-02 06:31:47 -07:00
parent 2264828fd0
commit b4de35e632
2 changed files with 3 additions and 2 deletions

View File

@ -20,7 +20,7 @@ class html_parser extends nwiki_parser {
$this->tagrules = array('link' => $this->tagrules['link'], 'url' => $this->tagrules['url']);
// Headers are considered tags here.
$this->tagrules['header'] = array('expression' => "/<\s*h([1-6])\s*>(.+?)<\/h[1-6]>/is"
$this->tagrules['header'] = array('expression' => "/<\s*h([1-$this->maxheaderdepth])\s*>(.+?)<\/h[1-$this->maxheaderdepth]>/is"
);
}

View File

@ -24,6 +24,7 @@ abstract class wiki_markup_parser extends generic_parser {
//header & ToC
protected $toc = array();
protected $maxheaderdepth = 3;
/**
* function wiki_parser_link_callback($link = "")
@ -183,7 +184,7 @@ abstract class wiki_markup_parser extends generic_parser {
$text .= parser_utils::h('a', '['.get_string('editsection', 'wiki').']', array('href' => "edit.php?pageid={$this->wiki_page_id}&section=" . urlencode($text), 'class' => 'wiki_edit_section'));
}
if ($level < 4) {
if ($level <= $this->maxheaderdepth) {
$this->toc[] = array($level, $text);
$num = count($this->toc);
$text = parser_utils::h('a', "", array('name' => "toc-$num")) . $text;