From b203781f585feed7ea2233eee056635b24b0e47b Mon Sep 17 00:00:00 2001 From: Ben Coburn <btcoburn@silicodon.net> Date: Sun, 18 Jun 2006 00:37:23 +0200 Subject: [PATCH] fixing edit section bugs - Final edit section now ignored when there is only one header. - The configuration property 'maxseclevel' is now honored again. - Instructions are not created by the handler for edit sections that have a level higher than 'maxseclevel'. These ignored edit sections are merged into the previous edit section. darcs-hash:20060617223723-05dcb-a1282e827468de00977179c8c8924fb00ec2d56c.gz --- _test/cases/inc/parser/parser_headers.test.php | 6 ------ inc/parser/handler.php | 18 ++++++++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/_test/cases/inc/parser/parser_headers.test.php b/_test/cases/inc/parser/parser_headers.test.php index 1ec6dd50b..c32c14cf2 100644 --- a/_test/cases/inc/parser/parser_headers.test.php +++ b/_test/cases/inc/parser/parser_headers.test.php @@ -78,14 +78,12 @@ class TestOfDoku_Parser_Headers extends TestOfDoku_Parser { array('p_open',array()), array('cdata',array("\nabc \n")), array('p_close',array()), - array('section_edit',array(-1,5,1,'')), array('header',array('Header',4,6)), array('section_open',array(4)), array('p_open',array()), array('cdata',array("\n def\n")), array('p_close',array()), array('section_close',array()), - array('section_edit',array(6,0,4,'Header')), array('document_end',array()), ); $this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls); @@ -99,14 +97,12 @@ class TestOfDoku_Parser_Headers extends TestOfDoku_Parser { array('p_open',array()), array('cdata',array("\nabc \n")), array('p_close',array()), - array('section_edit',array(-1,5,1,'')), array('header',array('Header',5,6)), array('section_open',array(5)), array('p_open',array()), array('cdata',array("\n def\n")), array('p_close',array()), array('section_close',array()), - array('section_edit',array(6,0,5,'Header')), array('document_end',array()), ); $this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls); @@ -218,14 +214,12 @@ class TestOfDoku_Parser_Headers extends TestOfDoku_Parser { array('p_open',array()), array('cdata',array("\nabc \n")), array('p_close',array()), - array('section_edit',array(-1,5,1,'')), array('header',array('====== Header ======',5,6)), array('section_open',array(5)), array('p_open',array()), array('cdata',array("\n def\n")), array('p_close',array()), array('section_close',array()), - array('section_edit',array(6,0,5,'====== Header ======')), array('document_end',array()), ); $this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls); diff --git a/inc/parser/handler.php b/inc/parser/handler.php index a0adb24d5..519336caa 100644 --- a/inc/parser/handler.php +++ b/inc/parser/handler.php @@ -34,8 +34,10 @@ class Doku_Handler { if ( $this->status['section'] ) { $last_call = end($this->calls); array_push($this->calls,array('section_close',array(), $last_call[2])); - array_push($this->calls,array('section_edit',array($this->status['section_edit_start'], 0, - $this->status['section_edit_level'], $this->status['section_edit_title']), $last_call[2])); + if ($this->status['section_edit_start']>1) { + // ignore last edit section if there is only one header + array_push($this->calls,array('section_edit',array($this->status['section_edit_start'], 0, $this->status['section_edit_level'], $this->status['section_edit_title']), $last_call[2])); + } } if ( $this->rewriteBlocks ) { @@ -88,6 +90,8 @@ class Doku_Handler { } function header($match, $state, $pos) { + global $conf; + // get level and title $title = trim($match); $level = 7 - strspn($title,'='); @@ -97,10 +101,12 @@ class Doku_Handler { if ($this->status['section']) $this->_addCall('section_close',array(),$pos); - $this->_addCall('section_edit',array($this->status['section_edit_start'], $pos-1, $this->status['section_edit_level'], $this->status['section_edit_title']), $pos); - $this->status['section_edit_start'] = $pos; - $this->status['section_edit_level'] = $level; - $this->status['section_edit_title'] = $title; + if ($level<=$conf['maxseclevel']) { + $this->_addCall('section_edit',array($this->status['section_edit_start'], $pos-1, $this->status['section_edit_level'], $this->status['section_edit_title']), $pos); + $this->status['section_edit_start'] = $pos; + $this->status['section_edit_level'] = $level; + $this->status['section_edit_title'] = $title; + } $this->_addCall('header',array($title,$level,$pos), $pos); -- GitLab