Lexer->addSpecialPattern('\[a link.+?\[/a\]',$mode,'plugin_bbcodeextensions_alink'); } function handle($match, $state, $pos, Doku_Handler $handler) { $match = substr($match, 8, -4); if (preg_match('/^".+?"$/',$match)) $match = substr($match, 1, -1); $match = preg_split('/\]/u',$match,2); if ( !isset($match[0]) ) { $url = $match[1]; $title = $match[1]; } else { $url = $match[0]; $title = $match[1]; } $match= [ $url, $url ]; switch ($state) { case DOKU_LEXER_ENTER : return array($state, $match); case DOKU_LEXER_UNMATCHED : return array($state, $match); case DOKU_LEXER_EXIT : return array($state, ''); case DOKU_LEXER_SPECIAL : return array($state, $match); } return array(); } function render($mode, Doku_Renderer $renderer, $data) { list ($state, $match) = $data; switch ($state) { case DOKU_LEXER_ENTER : break; //case DOKU_LEXER_UNMATCHED : case DOKU_LEXER_SPECIAL : if(in_array($mode, ['xhtml', 's5'], true)) { //$match= substr($match, 3, -4); $ref= $match[0]; $title= $match[1]; // renderer for some weird reason converts anchors to lowercase //$ref= $renderer->_xmlEntities($ref); // htmlspecialchars($match); //$title= htmlspecialchars($title); // $renderer->_xmlEntities($title); $renderer->doc .= <<{$title} EOF; } else if ($mode==='text') { $renderer->doc .= $this->getConf('anchor_symbol'); $renderer->doc .= '['. $ref. ']'; } else { $renderer->doc .= '#['. $ref. '] '; } break; case DOKU_LEXER_EXIT: break; } return false; } }