From bfd68419cf89a52facf2a029d191673643c3cf70 Mon Sep 17 00:00:00 2001 From: Andreas Gohr <andi@splitbrain.org> Date: Mon, 10 Apr 2006 21:43:33 +0200 Subject: [PATCH] reverted method to determine the header level darcs-hash:20060410194333-7ad00-abb8bc33f647ccd8587edbcc151bc60895dd3ae0.gz --- inc/parser/handler.php | 20 ++++++++++++++++---- 1 file 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 : -- GitLab