diff options
author | Adrian Lang <lang@cosmocode.de> | 2010-08-12 13:46:14 +0200 |
---|---|---|
committer | Adrian Lang <lang@cosmocode.de> | 2010-08-13 11:37:15 +0200 |
commit | aa92c4ccfaf7462eb8f336c6a4e8e2b1468cfada (patch) | |
tree | 10d5b569b79c2b36b97feb2d6415ed1057d9fe06 /inc/parser/handler.php | |
parent | d259f728f887b2ad76a2531705eac51b7dda8676 (diff) | |
download | rpg-aa92c4ccfaf7462eb8f336c6a4e8e2b1468cfada.tar.gz rpg-aa92c4ccfaf7462eb8f336c6a4e8e2b1468cfada.tar.bz2 |
clean up table parser handler
Diffstat (limited to 'inc/parser/handler.php')
-rw-r--r-- | inc/parser/handler.php | 26 |
1 files changed, 17 insertions, 9 deletions
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; + } } |