3 * Manlinks plugin: convert manpage descriptions to links to the manpages.
6 if(!defined('DOKU_INC')) die();
7 if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
8 require_once(DOKU_PLUGIN.'syntax.php');
10 class syntax_plugin_manlink extends DokuWiki_Syntax_Plugin {
12 function getType() { return 'substition'; }
13 function getPType() { return 'normal'; }
14 function getSort() { return 361; }
16 function connectTo($mode) {
17 $this->Lexer->addSpecialPattern(
18 '\!?[a-zA-Z0-9_.+\[\]-]*\([0-9]\)',
23 function handle($match, $state, $pos, Doku_Handler $handler){
24 if ($state != DOKU_LEXER_SPECIAL)
27 if (substr($match, 0, 1) == "!") {
28 $handler->_addCall('cdata', array(substr($match, 1)), $pos);
32 $mantarget = $this->getconf('mantarget');
33 $manpage = preg_replace('/^([a-zA-Z0-9_+\[\].-]*)\(([0-9])\)$/', '\1', $match);
34 $section = preg_replace('/^([a-zA-Z0-9_+\[\].-]*)\(([0-9])\)$/', '\2', $match);
36 if ($mantarget == 'NetBSD')
37 $target = 'http://mdoc.su/n/'.$manpage.'.'.$section;
38 elseif ($mantarget == 'FreeBSD')
39 $target = 'http://mdoc.su/f/'.$manpage.'.'.$section;
40 elseif ($mantarget == 'OpenBSD')
41 $target = 'http://mdoc.su/o/'.$manpage.'.'.$section;
42 elseif ($mantarget == 'DragonFlyBSD')
43 $target = 'http://mdoc.su/d/'.$manpage.'.'.$section;
45 $handler->addCall('externallink', array($target, $match), $pos);
49 function render($format, Doku_Renderer $renderer, $data) {