1<?php 2class syntax_plugin_anchor extends DokuWiki_Syntax_Plugin 3{ 4 function getType() {return 'substition';} 5 function getPType() {return 'normal';} 6 function getSort() {return 167;} 7 8 function connectTo($mode){ 9 $this->Lexer->addSpecialPattern('\{\{anchor:[^}]*\}\}', $mode, 'plugin_anchor'); 10 } 11 12 function handle($match, $state, $pos, Doku_Handler $handler) { 13 preg_match('/^\{\{anchor:([^:}]*)(?::([^}]*))?}}$/ui', $match, $result); 14 return $result; 15 } 16 17 function render($mode, Doku_Renderer $renderer, $data) { 18 $id = $data[1] ?? ''; 19 $content = $data[2] ?? ''; 20 if ($id == '') { 21 $renderer->doc .= '<div style="color:red; padding:8px; margin: 8px; border: 1px solid red">'; 22 $renderer->doc .= 'Anchor plugin: Invalid syntax.<br>'; 23 $renderer->doc .= 'Usage: {{anchor:tag:content}}'; 24 $renderer->doc .= '</div>'; 25 return; 26 } 27 $renderer->doc .= '<a id="' . $id. '">' . $content . '</a>'; 28 } 29} 30