DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:camelcase

CamelCase Plugin

Compatible with DokuWiki

2005-09-19+

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

Last updated on
2008-08-13
Provides
Syntax

This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.

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')) 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 :

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?
plugin/camelcase.txt · Last modified: 2016-01-24 19:14 by Aleksandr