Skip to content

Commit

Permalink
MDL-28616 wiki: use class variable for toc header depth
Browse files Browse the repository at this point in the history
  • Loading branch information
mackensen committed Sep 14, 2012
1 parent 2264828 commit b4de35e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion mod/wiki/parser/markups/html.php
Expand Up @@ -20,7 +20,7 @@ public function __construct() {
$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"
);
}

Expand Down
3 changes: 2 additions & 1 deletion mod/wiki/parser/markups/wikimarkup.php
Expand Up @@ -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 = "")
Expand Down Expand Up @@ -183,7 +184,7 @@ protected function generate_header($text, $level) {
$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;
Expand Down

0 comments on commit b4de35e

Please sign in to comment.