1<?php 2/** 3 * InToc-Plugin: Renders the page's toc inside the page content 4 * Reworked form broken https://www.dokuwiki.org/plugin:inlinetoc 5 * 6 * @license GPL v2 (http://www.gnu.org/licenses/gpl.html) 7 * @author Vincent Tscherter and previous 8 */ 9 10use dokuwiki\Extention\SyntaxPlugin; 11 12class syntax_plugin_intoc extends DokuWiki_Syntax_Plugin { 13 14 /** 15 * What kind of syntax are we? 16 */ 17 function getType() { 18 return 'substition'; 19 } 20 21 /** 22 * Where to sort in? (took the same as for ~~NOTOC~~) 23 */ 24 function getSort() { 25 return 30; 26 } 27 28 /** 29 * What kind of type are we? 30 */ 31 function getPType() { 32 return 'block'; 33 } 34 35 /** 36 * Connect pattern to lexer 37 */ 38 function connectTo($mode) { 39 $this->Lexer->addSpecialPattern('~~INTOC~~', $mode, 'plugin_intoc'); 40 } 41 42 /** 43 * Handle the match 44 */ 45 function handle($match, $state, $pos, Doku_Handler $handler) { 46 return ''; 47 } 48 49 /** 50 * Add placeholder to cached page (will be replaced by action component) 51 */ 52 function render($mode, Doku_Renderer $renderer, $data) { 53 54 if ($mode == 'metadata') { 55 $renderer->meta['movetoc'] = true; 56 return true; 57 } 58 59 $renderer->doc .= '<!-- INTOCTARGET -->'; 60 } 61} 62