From f4f02a0fc609c9599c14acc0d1a430d80516e5a6 Mon Sep 17 00:00:00 2001 From: chris Date: Tue, 6 Jun 2006 15:12:00 +0200 Subject: bug#701 - partial fix This patch resolves issues with how call writers merge their instructions into the main handler instruction list. - writeCalls will now only merge instructions into the list of the next higher call writer - all call writers have been given a finalise() method to use when the call writer needs to be terminated gracefully at the end of parsing when the wiki markup didn't provide its expected exit syntax. I have only tested finalise with lists. It still requires testing with wiki markup which results in improperly closed tables, quotes and preformatted text (it may not be possible to improperly terminate some of these syntax modes). darcs-hash:20060606131200-9b6ab-1fcde7e25e173de014e2f99bfdee22279b2d911d.gz --- inc/parser/handler.php | 49 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 4 deletions(-) (limited to 'inc/parser') diff --git a/inc/parser/handler.php b/inc/parser/handler.php index b8454ed69..a0adb24d5 100644 --- a/inc/parser/handler.php +++ b/inc/parser/handler.php @@ -29,6 +29,8 @@ class Doku_Handler { function _finalize(){ + $this->CallWriter->finalise(); + if ( $this->status['section'] ) { $last_call = end($this->calls); array_push($this->calls,array('section_close',array(), $last_call[2])); @@ -661,6 +663,11 @@ class Doku_Handler_CallWriter { function writeCalls($calls) { $this->Handler->calls = array_merge($this->Handler->calls, $calls); } + + // function is required, but since this call writer is first/highest in + // the chain it is not required to do anything + function finalise() { + } } //------------------------------------------------------------------------ @@ -683,11 +690,20 @@ class Doku_Handler_List { // Probably not needed but just in case... function writeCalls($calls) { $this->calls = array_merge($this->calls, $calls); - $this->CallWriter->writeCalls($this->calls); +# $this->CallWriter->writeCalls($this->calls); + } + + function finalise() { + $last_call = end($this->calls); + $this->writeCall(array('list_close',array(), $last_call[2])); + + $this->process(); + $this->CallWriter->finalise(); } //------------------------------------------------------------------------ function process() { + foreach ( $this->calls as $call ) { switch ($call[0]) { case 'list_item': @@ -869,7 +885,15 @@ class Doku_Handler_Preformatted { // Probably not needed but just in case... function writeCalls($calls) { $this->calls = array_merge($this->calls, $calls); - $this->CallWriter->writeCalls($this->calls); +# $this->CallWriter->writeCalls($this->calls); + } + + function finalise() { + $last_call = end($this->calls); + $this->writeCall(array('preformatted_end',array(), $last_call[2])); + + $this->process(); + $this->CallWriter->finalise(); } function process() { @@ -890,6 +914,7 @@ class Doku_Handler_Preformatted { } } } + } //------------------------------------------------------------------------ @@ -912,7 +937,15 @@ class Doku_Handler_Quote { // Probably not needed but just in case... function writeCalls($calls) { $this->calls = array_merge($this->calls, $calls); - $this->CallWriter->writeCalls($this->calls); +# $this->CallWriter->writeCalls($this->calls); + } + + function finalise() { + $last_call = end($this->calls); + $this->writeCall(array('quote_end',array(), $last_call[2])); + + $this->process(); + $this->CallWriter->finalise(); } function process() { @@ -1000,7 +1033,15 @@ class Doku_Handler_Table { // Probably not needed but just in case... function writeCalls($calls) { $this->calls = array_merge($this->calls, $calls); - $this->CallWriter->writeCalls($this->calls); +# $this->CallWriter->writeCalls($this->calls); + } + + function finalise() { + $last_call = end($this->calls); + $this->writeCall(array('table_end',array(), $last_call[2])); + + $this->process(); + $this->CallWriter->finalise(); } //------------------------------------------------------------------------ -- cgit v1.2.3