Because I really needed this function, I decided to develop my own. It was indeed a daunting task to reverse engineer, but I finally got it working. I use jQuery to do the job. Here's the code:
<?php
/**
* autonumber headings in DokuWiki modification, by nocnoc.
*
* Add this script to /lib/tpl/dokuwiki/main.php line92 just below <!-- /site -->
*
* @description : This modification allows autonumbering the headings
* with multiples levels, within the same DokuWiki page.
*
* @syntax (Base) : ~~#~~
* --> Where ~~#~~ will be replaced by a number.
* Auto increments on multiple usage within page.
* Use this when you require autonumbered headings.
*
* @syntax (multilevel) : ~~##~~ or ~~###~~ or ~~####~~ or ~~#####~~
* --> Where the num of # represent a sublevel and can be
* repeated up to 5 levels corresponding
* the 5 heading levels within DokuWiki.
*
* don't forget to make the following changes to /inc/html.php:
*
* line237 FIND: if($INFO['prependTOC']) $html = tpl_toc(true).$html;
* ABOVE ADD: $html = '<div id="nocnoc">'.$html.'</div>';
*
* line246 FIND: if($INFO['prependTOC']) $html = tpl_toc(true).$html;
* ABOVE ADD: $html = '<div id="nocnoc">'.$html.'</div>';
*
* line1745 FIND: $out .= '<div>'.DOKU_LF;
* CHANGE TO: $out .= '<div><div id="toctoc">'.DOKU_LF;
*
* Line1749 FIND: $out .= '</div>'.DOKU_LF.'</div>'.DOKU_LF;
* CHANGE TO: $out .= '</div></div>'.DOKU_LF.'</div>'.DOKU_LF;
*
*
* @license : GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
* @author : nocnoc - feel free to modify
* @lastupdate : 2013-03-17
* @compatible : 2012-10-13 "Adora Belle"
*/
?>
<script>
//count the number of occurences
function count( string, subString ) {
if( subString.length <= 0 ) return string.length + 1;
var n = 0, pos = 0;
while(true){
pos = string.indexOf(subString,pos);
if(pos >= 0){ n++; pos+=1; } else break;
}
return(n);
}
//the autonumbering conversion function
function autonumHeadings(s) {
var a=0, b=0, c=0, d=0, e=0;
var o=jQuery(s).html().split('\n'); //array of lines in o
for (var i=0;i<o.length;i++) { //scan every line
var x=o[i].match(/~~#+~~/g);
if ( x!=null ) {
x=x.toString();
if ( count(x,"#") == 5 ) { e++; o[i] = o[i].replace(/~~#####~~/g, a + '.' + b + '.' + c + '.' + d + '.' + e + '. ' ); }
if ( count(x,"#") == 4 ) { d++; o[i] = o[i].replace(/~~####~~/g, a + '.' + b + '.' + c + '.' + d + '. ' ); e=0; }
if ( count(x,"#") == 3 ) { c++; o[i] = o[i].replace(/~~###~~/g, a + '.' + b + '.' + c + '. ' ); d = 0, e = 0; }
if ( count(x,"#") == 2 ) { b++; o[i] = o[i].replace(/~~##~~/g, a+ '.' + b + '. ' ); c = 0, d = 0, e = 0; }
if ( count(x,"#") == 1 ) { a++; o[i] = o[i].replace(/~~#~~/g, a + '. ' ); b = 0, c = 0, d = 0, e = 0; }
}
}
jQuery(s).html(o.join('\n'));
}
jQuery( function() {
// don't forget to define the nocnoc & toctoc divs in the /inc/html.php, please see the instructions above !!!
if (jQuery('#dokuwiki__content').html().indexOf('<div id="toctoc">') != -1) autonumHeadings('#toctoc'); //skip pages with ~~NOTOC~~
if (jQuery('#dokuwiki__content').html().indexOf('<div id="nocnoc">') != -1) autonumHeadings('#nocnoc'); //skip pages lacking nocnoc div
}); //fire it up when the DOM is ready
</script> <!-- end of autonumber headings in DokuWiki modification -->
cheers!