diff --git a/inc/parser/handler.php b/inc/parser/handler.php
index 2088942a12564c619fd3ad40b2cff5487e88433f..0d0afa50b9687f6a4c72f7b1bec5160ae1e71d5c 100644
--- a/inc/parser/handler.php
+++ b/inc/parser/handler.php
@@ -85,9 +85,21 @@ class Doku_Handler {
 
     function header($match, $state, $pos) {
         $match = trim($match);
-
-        list($header,$title) = split(' ',$match,2);
-        $level = 7 - strlen($header);
+        $levels = array(
+            '======'=>1,
+            '====='=>2,
+            '===='=>3,
+            '==='=>4,
+            '=='=>5,
+        );
+        $hsplit = preg_split( '/(={2,})/u', $match,-1,
+            PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY );
+        // Locate the level - default to level 1 if no match (title contains == signs)
+        if ( isset($hsplit[0]) && array_key_exists($hsplit[0], $levels) ) {
+            $level = $levels[$hsplit[0]];
+        } else {
+            $level = 1;
+        }
 
         // Strip markers and whitespaces
         $title = trim($match,'=');
@@ -1486,4 +1498,4 @@ class Doku_Handler_Block {
     }
 }
 
-//Setup VIM: ex: et ts=4 enc=utf-8 :
\ No newline at end of file
+//Setup VIM: ex: et ts=4 enc=utf-8 :