diff options
author | chris <chris@jalakai.co.uk> | 2007-02-06 02:48:21 +0100 |
---|---|---|
committer | chris <chris@jalakai.co.uk> | 2007-02-06 02:48:21 +0100 |
commit | e7856bea477397d242c532d448a8ade3f4014c68 (patch) | |
tree | 90deb8db8c036feace7e2f2b73b754921d95952c /inc/parser/metadata.php | |
parent | 34dbe7111b03874a70e60229522124c79f45f19e (diff) | |
download | rpg-e7856bea477397d242c532d448a8ade3f4014c68.tar.gz rpg-e7856bea477397d242c532d448a8ade3f4014c68.tar.bz2 |
refactor renderer header() to separate out adding toc items
adds a new render method toc_additem($id, $text, $level)
This allows toc items to be added separately from the header() function, allowing
plugins to generate their own table of content items without having to copy dw
core code (which may in the future change).
darcs-hash:20070206014821-9b6ab-218184e543f6b348e710acc2fe30a8ec329c66a8.gz
Diffstat (limited to 'inc/parser/metadata.php')
-rw-r--r-- | inc/parser/metadata.php | 21 |
1 files changed, 13 insertions, 8 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; } |