From d7e8115f3f60d332b17a35d50e1dfb7a2b7d9a29 Mon Sep 17 00:00:00 2001 From: Andreas Gohr <andi@splitbrain.org> Date: Wed, 12 Apr 2006 20:41:25 +0200 Subject: [PATCH] even faster header parsing using strspn darcs-hash:20060412184125-7ad00-e51f8d531bf3011d230f62cb99fd18de8f150c41.gz --- inc/parser/handler.php | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/inc/parser/handler.php b/inc/parser/handler.php index 0d0afa50b..9cc53c42f 100644 --- a/inc/parser/handler.php +++ b/inc/parser/handler.php @@ -84,26 +84,10 @@ class Doku_Handler { } function header($match, $state, $pos) { - $match = trim($match); - $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,'='); - $title = trim($title,' '); + // get level and title + $level = 7 - strspn($match,'='); + if($level < 1) $level = 1; + $title = trim($match,'= '); if ($this->status['section']) $this->_addCall('section_close',array(),$pos); -- GitLab