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/xhtml.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/xhtml.php')
-rw-r--r-- | inc/parser/xhtml.php | 15 |
1 files changed, 10 insertions, 5 deletions
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.'">'; |