summaryrefslogtreecommitdiff
path: root/inc/parser
diff options
context:
space:
mode:
Diffstat (limited to 'inc/parser')
-rw-r--r--inc/parser/metadata.php21
-rw-r--r--inc/parser/renderer.php2
-rw-r--r--inc/parser/xhtml.php15
3 files changed, 25 insertions, 13 deletions
diff --git a/inc/parser/metadata.php b/inc/parser/metadata.php
index 1bb14b674..5a9f6a122 100644
--- a/inc/parser/metadata.php
+++ b/inc/parser/metadata.php
@@ -47,25 +47,30 @@ class Doku_Renderer_metadata extends Doku_Renderer {
}
}
- function header($text, $level, $pos) {
+ function toc_additem($id, $text, $level) {
global $conf;
- if (!$this->meta['title']) $this->meta['title'] = $text;
-
- // create a unique header id
- $hid = $this->_headerToLink($text,'true');
-
- //handle TOC
+ //only add items within configured levels
if($level >= $conf['toptoclevel'] && $level <= $conf['maxtoclevel']){
// the TOC is one of our standard ul list arrays ;-)
$this->meta['description']['tableofcontents'][] = array(
- 'hid' => $hid,
+ 'hid' => $id,
'title' => $text,
'type' => 'ul',
'level' => $level-$conf['toptoclevel']+1
);
}
+ }
+
+ function header($text, $level, $pos) {
+
+ if (!$this->meta['title']) $this->meta['title'] = $text;
+
+ // add the header to the TOC
+ $hid = $this->_headerToLink($text,'true');
+ $this->toc_additem($hid, $text, $level);
+
// add to summary
if ($this->capture && ($level > 1)) $this->doc .= DOKU_LF.$text.DOKU_LF;
}
diff --git a/inc/parser/renderer.php b/inc/parser/renderer.php
index 2b6957692..a6bf0c543 100644
--- a/inc/parser/renderer.php
+++ b/inc/parser/renderer.php
@@ -70,6 +70,8 @@ class Doku_Renderer extends DokuWiki_Plugin {
function render_TOC() { return ''; }
+ function toc_additem($id, $text, $level) {}
+
function header($text, $level, $pos) {}
function section_edit($start, $end, $level, $name) {}
diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php
index 7cccb14ec..266bfcf4a 100644
--- a/inc/parser/xhtml.php
+++ b/inc/parser/xhtml.php
@@ -112,20 +112,25 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
$this->_xmlEntities($item['title']).'</a></span>';
}
- function header($text, $level, $pos) {
+ function toc_additem($id, $text, $level) {
global $conf;
- // create a unique header id
- $hid = $this->_headerToLink($text,'true');
-
//handle TOC
if($level >= $conf['toptoclevel'] && $level <= $conf['maxtoclevel']){
// the TOC is one of our standard ul list arrays ;-)
- $this->toc[] = array( 'hid' => $hid,
+ $this->toc[] = array( 'hid' => $id,
'title' => $text,
'type' => 'ul',
'level' => $level-$conf['toptoclevel']+1);
}
+ }
+
+ function header($text, $level, $pos) {
+
+ $hid = $this->_headerToLink($text,true);
+
+ //only add items within configured levels
+ $this->toc_additem($hid, $text, $level);
// write the header
$this->doc .= DOKU_LF.'<h'.$level.'><a name="'.$hid.'" id="'.$hid.'">';