*/ if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); 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_camelcase extends DokuWiki_Syntax_Plugin { /** * return some info */ function getInfo(){ return array( 'author' => 'Christopher Smith', 'email' => 'chris@jalakai.co.uk', 'date' => '2008-08-13', 'name' => 'Camel Case', 'desc' => 'Override default dokuwiki CamelCase syntax', 'url' => 'http://www.dokuwiki.org/plugin:camelcase', ); } /** * Syntax Type * * Needs to return one of the mode types defined in $PARSER_MODES in parser.php */ function getType(){ return('substition'); } function connectTo($mode) { $this->Lexer->addSpecialPattern( '\b[A-Z]+[a-z]+[A-Z][A-Za-z]*\b',$mode,'plugin_camelcase' ); } function getSort() { return 275; // needs to be lower than 290 } /** * Handler to prepare matched data for the rendering process */ function handle($match, $state, $pos, &$handler){ preg_match_all('/[A-Z][^A-Z]*/u',$match, $matches); $link = implode('_',$matches[0]); return array($link, $match); } /** * Handles the actual output creation. */ function render($format, &$renderer, $data) { $renderer->internallink($data[0],$data[1]); } } //Setup VIM: ex: et ts=4 enc=utf-8 :