1<?php 2/* 3 * Inline links [name](target "title") 4 */ 5 6if(!defined('DOKU_INC')) die(); 7if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 8require_once(DOKU_PLUGIN.'syntax.php'); 9 10class syntax_plugin_markdowku_anchorsinline extends DokuWiki_Syntax_Plugin { 11 12 function getType() { return 'substition'; } 13 function getPType() { return 'normal'; } 14 function getSort() { return 102; } 15 16 function connectTo($mode) { 17 $this->nested_brackets_re = 18 str_repeat('(?>[^\[\]]+|\[', 6). 19 str_repeat('\])*', 6); 20 $this->Lexer->addSpecialPattern( 21 '\['.$this->nested_brackets_re.'\]\([ \t]*<?.+?>?[ \t]*(?:[\'"].*?[\'"])?\)', 22 $mode, 23 'plugin_markdowku_anchorsinline' 24 ); 25 } 26 27 function handle($match, $state, $pos, Doku_Handler $handler) { 28 if ($state == DOKU_LEXER_SPECIAL) { 29 $text = preg_match( 30 '/^\[('.$this->nested_brackets_re.')\]\([ \t]*<?(.+?)>?[ \t]*(?:[\'"](.*?)[\'"])?[ \t]*?\)$/', 31 $match, 32 $matches); 33 $target = $matches[2] == '' ? $matches[3] : $matches[2]; 34 $title = $matches[1]; 35 36 $target = preg_replace('/^mailto:/', '', $target); 37 $handler->internallink($target.'|'.$title, $state, $pos); 38 } 39 return true; 40 } 41 42 function render($mode, Doku_Renderer $renderer, $data) { 43 return true; 44 } 45} 46//Setup VIM: ex: et ts=4 enc=utf-8 : 47