DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:camelcase

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
plugin:camelcase [2007-02-13 17:46] 81.229.94.230plugin:camelcase [2018-05-30 21:12] (current) Klap-in
Line 1: Line 1:
 +====== CamelCase Plugin ======
  
 +---- plugin ----
 +description: A replacement for DokuWiki CamelCase syntax, uses "_" to separate words in pages names
 +author     : Christopher Smith
 +email      : chris@jalakai.co.uk
 +type       : syntax
 +lastupdate : 2008-08-13
 +compatible : 2005-09-19+
 +depends    : 
 +conflicts 
 +similar    : 
 +tags       : links
 +
 +downloadurl: http://dokuwiki.jalakai.co.uk/plugin-camelcase.tar.gz
 +----
 +
 +This plugin replaces the current DokuWiki handlers for %%CamelCase%% markup. It will create a link to a page with underscores between the %%CamelCase%% words.
 +
 +e.g.
 +  CamelCase => camel_case
 +
 +Standard DokuWiki behaviour is to create a link to a page with the %%CamelCase%% converted to all lower case (e.g. camelcase). This can result in reduced readability for the page names. An alternative is to set the config option ''[[config:useheading]]'' in your ''conf/local.php'' file.
 +
 +===== Syntax =====
 +
 +as described in DokuWiki's [[wiki:syntax]]
 +
 +
 +
 +===== Installation =====
 +
 +Search and install the plugin using the [[plugin:extension|Extension Manager]]. Refer to [[:Plugins]] on how to install plugins manually.
 +
 +
 +Plugin sources: [[http://dokuwiki.jalakai.co.uk/plugin-camelcase.zip|zip format (1k)]], [[http://dokuwiki.jalakai.co.uk/plugin-camelcase.tar.gz|tar.gz format (1k)]]
 +
 +
 +
 +
 +===== Details =====
 +
 +==== php source ====
 +
 +**''lib/plugins/camelcase/syntax.php''**
 +
 +<code php>
 +<?php
 +/**
 + * CamelCase Plugin: replaces DokuWiki's own code syntax
 + 
 + * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
 + * @author     Christopher Smith <chris@jalakai.co.uk>  
 + */
 +
 +if(!defined('DOKU_INC')) die();
 +
 +/**
 + * 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, Doku_Handler $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, Doku_Renderer $renderer, $data) {
 +      $renderer->internallink($data[0],$data[1]); 
 +    }
 +    
 +}
 +//Setup VIM: ex: et ts=4 enc=utf-8 :
 +</code>
 +
 +===== Revision History =====
 +
 +  * 2008-08-13 --- Plugin URL updated.
 +  * 2005-08-15 --- Released.
 +
 +===== To Do =====
 +
 +===== Bugs =====
 +
 +===== Discussion =====
 +>This is really nice! I've wanted this feature for a long time for my wiki.
 +----
 +>Thank you for this plugin. Is there a way to prevent selected camel case words becoming a links, such as for ex. using ~ before the word in certain other wikis?

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki