From e41c4da9b8ec98a022a91b04f7c5d7bbee54b6c9 Mon Sep 17 00:00:00 2001 From: Andreas Gohr <andi@splitbrain.org> Date: Sun, 19 Feb 2006 17:47:26 +0100 Subject: [PATCH] some TOC fixes darcs-hash:20060219164726-7ad00-eb637e1db83e2f3b6c3629da18214b6587590b24.gz --- inc/parser/handler.php | 4 +--- inc/parser/renderer.php | 5 +++++ inc/parser/xhtml.php | 7 ++++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/inc/parser/handler.php b/inc/parser/handler.php index 4653cf603..dc5315fdd 100644 --- a/inc/parser/handler.php +++ b/inc/parser/handler.php @@ -11,8 +11,6 @@ class Doku_Handler { var $meta = array( 'section' => FALSE, - 'toc' => TRUE, - 'cache' => TRUE, ); var $rewriteBlocks = TRUE; @@ -115,7 +113,7 @@ class Doku_Handler { } function notoc($match, $state, $pos) { - $this->meta['toc'] = FALSE; + $this->_addCall('notoc',array(),$pos); return TRUE; } diff --git a/inc/parser/renderer.php b/inc/parser/renderer.php index a9c86c3f5..303af3db3 100644 --- a/inc/parser/renderer.php +++ b/inc/parser/renderer.php @@ -13,6 +13,7 @@ require_once DOKU_INC . 'inc/pluginutils.php'; class Doku_Renderer { var $info = array( 'cache' => TRUE, // may the rendered result cached? + 'toc' => TRUE, // render the TOC? ); @@ -20,6 +21,10 @@ class Doku_Renderer { $this->info['cache'] = FALSE; } + function notoc() { + $this->info['toc'] = FALSE; + } + //handle plugin rendering function plugin($name,$data){ $plugin =& plugin_load('syntax',$name); diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php index a54e5bcab..9950f28ce 100644 --- a/inc/parser/xhtml.php +++ b/inc/parser/xhtml.php @@ -89,7 +89,9 @@ class Doku_Renderer_xhtml extends Doku_Renderer { } // prepend the TOC - $this->doc = $this->render_TOC().$this->doc; + if($this->info['toc']){ + $this->doc = $this->render_TOC().$this->doc; + } } /** @@ -98,7 +100,7 @@ class Doku_Renderer_xhtml extends Doku_Renderer { * @author Andreas Gohr <andi@splitbrain.org> */ function render_TOC(){ - if(!count($this->toc)) return ''; + if(count($this->toc) < 3) return ''; global $lang; $out = '<div class="toc">'.DOKU_LF; $out .= '<div class="tocheader toctoggle" id="toc__header">'; @@ -175,7 +177,6 @@ class Doku_Renderer_xhtml extends Doku_Renderer { $hid = $this->_headerToLink($text,'true'); //handle TOC -//FIXME if($this->meta['toc'] && if($level >= $conf['toptoclevel'] && $level <= $conf['maxtoclevel']){ // the TOC is one of our standard ul list arrays ;-) $this->toc[] = array( 'hid' => $hid, -- GitLab