summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--inc/parser/handler.php20
1 files changed, 16 insertions, 4 deletions
diff --git a/inc/parser/handler.php b/inc/parser/handler.php
index 2088942a1..0d0afa50b 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 :