[dokuwiki] A humble proposal for CamelCase links

First of all thank you folks for your good and hard work making one of
the best wikis around :)

Guys there's one feature i definitely missing in dokuwiki - converting
CamelCase  internal  links to lower_case ones transparently.

What  does  it  actually mean? Let me be more specific. Say i have the
following wiki content somewhere in the playground:

[[FooBar]]

When rendered this produces the following xhtml content(i left only relevant
stuff):

<a href="/wiki/doku.php?id=wiki:foobar" [...] 
title="wiki:foobar"[...]>FooBar</a>

Now if i create this non-existing page, history will also reflect
that and it will look something like this:

start » syntax » playground » foobar

Which is not very readable for long names(e.g. SysMaterializedPathTreeDbTable
becomes sysmaterializedpathtreedbtable)

Ok, you can suggest writing:

[[foo_bar|FooBar]]

instead  of simply [[FooBar]] but it's way harder IMHO to mantain wiki
in the long run this way.

What i'm proposing is to convert all FooBar internal links into
foo_bar ones during renedering.

I did a quick inc/parser/xhtml.php hack in order to implement this, here's
a diff for the latest dokuwiki official release(2005-07-13):
================================================================================
*** xhtml.php   Wed Jul 13 21:40:11 2005
--- xhtml.php.new       Wed Jul 27 15:13:38 2005
***************
*** 449,456 ****
--- 449,460 ----
      function internallink($id, $name = NULL, $search=NULL,$returnonly=false) {
          global $conf;
          global $ID;
+
          // default name is based on $id as given
          $default = $this->_simpleTitle($id);
+
+       $id = $this->_StudlyCaps2lower_case($id);
+
          // now first resolve and clean up the $id
          resolve_pageid(getNS($ID),$id,$exists);
          $name = $this->_getLinkTitle($name, $default, $isImage, $id);
***************
*** 992,997 ****
--- 996,1008 ----
                                $img['height'],
                                $img['cache']);
      }
+
+     function _StudlyCaps2lower_case($str) {
+               return ltrim(preg_replace('~([a-z])?([A-Z])([a-z])~e', 
"'\\1_'.strtolower('\\2').'\\3'",
+                      $str),
+                    '_');
+     }
+
  }

  //Setup VIM: ex: et ts=4 enc=utf-8 :
================================================================================

Here's what happes once inc/parser/xhtml.php is patched:

[[FooBar]]

produces:

<a href="/wiki/doku.php?id=wiki:foo_bar" [...] 
title="wiki:foo_bar"[...]>FooBar</a>

And we have the neat history:

start » syntax » playground » foo_bar

This CamelCase convertion can be optional and controlled somewhere in global
settings in conf/dukuwiki.php:

/* Advanced Options */
$conf['CamelCase2lower_case']  = 1;

What do you think about it?

Best regards, Pavel
--
Pavel Shevaev, pacha.shevaev@xxxxxxxxx
LIMB - http://limb-project.com
Bureau of Information Technologies - http://www.bit-creative.com

Other related posts: