Skip to content

Commit

Permalink
plugin for dokuwiki, new form of links [#link], which doesn't cause b…
Browse files Browse the repository at this point in the history
…acklinks
  • Loading branch information
houshuang committed Feb 17, 2012
1 parent 3eddc8a commit 79d0efb
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
7 changes: 7 additions & 0 deletions neutrallinks/plugin.info.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
base neutrallinks
author Stian Haklev
email [email protected]
date 2011-06-14
name Neutral Links
desc Provide optional link format [#], does not cause backlinks
url http://reganmian.net/wiki/researchr:start
46 changes: 46 additions & 0 deletions neutrallinks/syntax.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php
/**
* Plugin Now: Inserts a timestamp.
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Christopher Smith <[email protected]>
*/

// must be run within DokuWiki
if(!defined('DOKU_INC')) die();

if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
require_once DOKU_PLUGIN.'syntax.php';

/**
* All DokuWiki plugins to extend the parser/rendering mechanism
* need to inherit from this class
*/
class syntax_plugin_neutrallinks extends DokuWiki_Syntax_Plugin {


function getType() { return 'substition'; }
function getSort() { return 2; }
function getAllowedTypes() { return array();}
function connectTo($mode) {
$this->Lexer->addSpecialPattern('\[#.+?\]',$mode,'plugin_neutrallinks');
// $this->Lexer->addSpecialPattern('NOW',$mode,'plugin_neutrallinks');
}

function handle($match, $state, $pos, &$handler) {
return array($match, $state, $pos);
}

function render($mode, &$renderer, $data) {
if($mode == 'xhtml'){
$text = substr($data[0],1,-1);
$split = preg_split('/\|/', $text);
// if preg_match('/\|/',$text){
$renderer->doc .= $renderer->internallink($split[0], $split[1]);
// } else{
// $renderer->doc .= $renderer->internallink($split[0]);};
return true;
}
return false;
}
}

0 comments on commit 79d0efb

Please sign in to comment.