CamelCase plugin

camelcase plugin by Christopher Smith
A replacement for DokuWiki CamelCase syntax, uses "_" to separate words in pages names

Last updated on 2008-08-13. Provides Syntax.
Compatible with DokuWiki 2005-09-19+.

Tagged with links.

    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 useheading in your conf/local.php file.

    Syntax

    as described in DokuWiki's syntax

    Installation

    Plugin sources: zip format (1k), tar.gz format (1k)

    Download the source to your plugin folder, lib/plugins and extract its contents. That will create a new plugin folder, lib/plugins/camelcase and install the plugin there.

    The folder will contain:

    syntax.php                             syntax plugin script

    The plugin is now installed.

    Details

    php source

    lib/plugins/camelcase/syntax.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')) 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 :

    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.
     
    plugin/camelcase.txt · Last modified: 2009/10/06 12:00 by laynee
     
    Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
    Imprint Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki
    WikiForumIRCBugsGitXRefTranslate