From aa92c4ccfaf7462eb8f336c6a4e8e2b1468cfada Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Thu, 12 Aug 2010 13:46:14 +0200 Subject: clean up table parser handler --- inc/parser/handler.php | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'inc/parser') diff --git a/inc/parser/handler.php b/inc/parser/handler.php index 8639c5ad8..8de0c7490 100644 --- a/inc/parser/handler.php +++ b/inc/parser/handler.php @@ -1175,7 +1175,7 @@ class Doku_Handler_Table { $this->tableStart($call); break; case 'table_row': - $this->tableRowClose(array('tablerow_close',$call[1],$call[2])); + $this->tableRowClose($call); $this->tableRowOpen(array('tablerow_open',$call[1],$call[2])); break; case 'tableheader': @@ -1183,7 +1183,7 @@ class Doku_Handler_Table { $this->tableCell($call); break; case 'table_end': - $this->tableRowClose(array('tablerow_close', array())); + $this->tableRowClose($call); $this->tableEnd($call); break; default: @@ -1221,7 +1221,7 @@ class Doku_Handler_Table { break; } } - $this->tableCalls[] = $call; + $this->tableCalls[] = array('tablerow_close', array(), $call[2]); if ( $this->currentCols > $this->maxCols ) { $this->maxCols = $this->currentCols; @@ -1281,17 +1281,21 @@ class Doku_Handler_Table { // that contain colspans foreach ( $this->tableCalls as $key => $call ) { - if ( $call[0] == 'tablerow_open' ) { + switch ($call[0]) { + case 'tablerow_open': $lastRow++; $lastCell = 0; + break; - } else if ( $call[0] == 'tablecell_open' || $call[0] == 'tableheader_open' ) { + case 'tablecell_open': + case 'tableheader_open': $lastCell++; $cellKey[$lastRow][$lastCell] = $key; + break; - } else if ( $call[0] == 'table_align' ) { + case 'table_align': $prev = in_array($this->tableCalls[$key-1][0], array('tablecell_open', 'tableheader_open')); $next = in_array($this->tableCalls[$key+1][0], array('tablecell_close', 'tableheader_close')); @@ -1315,8 +1319,9 @@ class Doku_Handler_Table { // Now convert the whitespace back to cdata $this->tableCalls[$key][0] = 'cdata'; + break; - } else if ( $call[0] == 'colspan' ) { + case 'colspan': $this->tableCalls[$key-1][1][0] = false; @@ -1336,8 +1341,9 @@ class Doku_Handler_Table { $toDelete[] = $key-1; $toDelete[] = $key; $toDelete[] = $key+1; + break; - } else if ( $call[0] == 'rowspan' ) { + case 'rowspan': if ( $this->tableCalls[$key-1][0] == 'cdata' ) { // ignore rowspan if previous call was cdata (text mixed with :::) we don't have to check next call as that wont match regex @@ -1362,8 +1368,10 @@ class Doku_Handler_Table { $toDelete[] = $key-1; $toDelete[] = $key; - $toDelete[] = $key+1; + $toDelete[] = $key+1; } + break; + } } -- cgit v1.2.3