--- Heading.php	2007-01-11 13:25:24.000000000 +0100
+++ Heading.php2	2007-01-11 09:11:04.000000000 +0100
@@ -9,7 +9,7 @@
  * @package    Text_Wiki
  * @author     Paul M. Jones <pmjones@php.net>
  * @license    http://www.gnu.org/copyleft/lesser.html  LGPL License 2.1
- * @version    CVS: $Id: Heading.php,v 1.2 2007/01/11 12:25:24 julien Exp $
+ * @version    CVS: $Id: Heading.php,v 1.1 2006/09/21 07:51:45 julien Exp $
  * @link       http://pear.php.net/package/Text_Wiki
  */
 
@@ -38,14 +38,34 @@
     {
     	$collapse = null;
         static $jsOutput = false;
+        static $headerIndex;
+
+
         // get nice variable names (id, type, level)
         extract($options);
 
         switch($type) {
         case 'start':
+        	$headerPrefix = "";
+        	if($this->getConf('headingIndexes')) {
+	        	if (!isset($headerIndex[$level])){
+		        	$headerIndex[$level] = 1;
+		        } else {
+		        	$headerIndex[$level]++;
+		        	for ($i = $level + 1; $i <= 6; $i ++){
+		        		$headerIndex[$i] = 0;
+		        	}
+		        }
+		        foreach ($headerIndex as $value){
+	            	if ($value > 0){
+	            		$headerPrefix .= $value .".";
+	            	}
+            	}
+            	$headerPrefix .= " "; // add a space between the last dot and the headervalue
+        	}
             $css = $this->formatConf(' class="%s"', "css_h$level");
-            return '
-<h'.$level.$css.' id="'.$id.'"'.($collapse !== null ? ' onclick="hideTOC(\''.$id.'\');"' : '').'>';
+            return  '<h'.$level.$css.' id="'.$id.'"'.($collapse !== null ? ' onclick="hideTOC(\''.$id.'\');"' : '').'>'. $headerPrefix;
+
 
         case 'end':
             return '</h'.$level.'>
@@ -85,4 +105,4 @@
         }
     }
 }
-?>
\ No newline at end of file
+?>
