diff options
author | Gerrit Uitslag <klapinklapin@gmail.com> | 2014-09-28 15:36:21 +0200 |
---|---|---|
committer | Gerrit Uitslag <klapinklapin@gmail.com> | 2014-09-28 15:36:21 +0200 |
commit | 0c1b02bead38d5a58032a1c88cf3ca53bbc4a4d9 (patch) | |
tree | b9cb574a1964f28dda648795010a5be056b80618 /inc/parser/handler.php | |
parent | 618191d008b98cb421694c541145c863d7b300ce (diff) | |
parent | da9572711f54d13ce3c5506971154b0bc359723f (diff) | |
download | rpg-0c1b02bead38d5a58032a1c88cf3ca53bbc4a4d9.tar.gz rpg-0c1b02bead38d5a58032a1c88cf3ca53bbc4a4d9.tar.bz2 |
Merge remote-tracking branch 'origin/master' into FS#2697searchpagereadonly
Conflicts:
inc/lang/hr/searchpage.txt
inc/lang/ko/searchpage.txt
Diffstat (limited to 'inc/parser/handler.php')
-rw-r--r-- | inc/parser/handler.php | 73 |
1 files changed, 64 insertions, 9 deletions
diff --git a/inc/parser/handler.php b/inc/parser/handler.php index 8ae991209..a1040d12e 100644 --- a/inc/parser/handler.php +++ b/inc/parser/handler.php @@ -12,6 +12,7 @@ class Doku_Handler { var $status = array( 'section' => false, + 'doublequote' => 0, ); var $rewriteBlocks = true; @@ -401,11 +402,17 @@ class Doku_Handler { function doublequoteopening($match, $state, $pos) { $this->_addCall('doublequoteopening',array(), $pos); + $this->status['doublequote']++; return true; } function doublequoteclosing($match, $state, $pos) { - $this->_addCall('doublequoteclosing',array(), $pos); + if ($this->status['doublequote'] <= 0) { + $this->doublequoteopening($match, $state, $pos); + } else { + $this->_addCall('doublequoteclosing',array(), $pos); + $this->status['doublequote'] = max(0, --$this->status['doublequote']); + } return true; } @@ -1149,6 +1156,9 @@ class Doku_Handler_Table { var $currentCols = 0; var $firstCell = false; var $lastCellType = 'tablecell'; + var $inTableHead = true; + var $currentRow = array('tableheader' => 0, 'tablecell' => 0); + var $countTableHeadRows = 0; function Doku_Handler_Table(& $CallWriter) { $this->CallWriter = & $CallWriter; @@ -1216,15 +1226,24 @@ class Doku_Handler_Table { $this->firstCell = true; $this->lastCellType = 'tablecell'; $this->maxRows++; + if ($this->inTableHead) { + $this->currentRow = array('tablecell' => 0, 'tableheader' => 0); + } } function tableRowClose($call) { + if ($this->inTableHead && ($this->inTableHead = $this->isTableHeadRow())) { + $this->countTableHeadRows++; + } // Strip off final cell opening and anything after it while ( $discard = array_pop($this->tableCalls ) ) { if ( $discard[0] == 'tablecell_open' || $discard[0] == 'tableheader_open') { break; } + if (!empty($this->currentRow[$discard[0]])) { + $this->currentRow[$discard[0]]--; + } } $this->tableCalls[] = array('tablerow_close', array(), $call[2]); @@ -1233,7 +1252,20 @@ class Doku_Handler_Table { } } + function isTableHeadRow() { + $td = $this->currentRow['tablecell']; + $th = $this->currentRow['tableheader']; + + if (!$th || $td > 2) return false; + if (2*$td > $th) return false; + + return true; + } + function tableCell($call) { + if ($this->inTableHead) { + $this->currentRow[$call[0]]++; + } if ( !$this->firstCell ) { // Increase the span @@ -1281,6 +1313,13 @@ class Doku_Handler_Table { $cellKey = array(); $toDelete = array(); + // if still in tableheader, then there can be no table header + // as all rows can't be within <THEAD> + if ($this->inTableHead) { + $this->inTableHead = false; + $this->countTableHeadRows = 0; + } + // Look for the colspan elements and increment the colspan on the // previous non-empty opening cell. Once done, delete all the cells // that contain colspans @@ -1288,6 +1327,14 @@ class Doku_Handler_Table { $call = $this->tableCalls[$key]; switch ($call[0]) { + case 'table_open' : + if($this->countTableHeadRows) { + array_splice($this->tableCalls, $key+1, 0, array( + array('tablethead_open', array(), $call[2])) + ); + } + break; + case 'tablerow_open': $lastRow++; @@ -1357,15 +1404,19 @@ class Doku_Handler_Table { } else { $spanning_cell = null; - for($i = $lastRow-1; $i > 0; $i--) { - if ( $this->tableCalls[$cellKey[$i][$lastCell]][0] == 'tablecell_open' || $this->tableCalls[$cellKey[$i][$lastCell]][0] == 'tableheader_open' ) { + // can't cross thead/tbody boundary + if (!$this->countTableHeadRows || ($lastRow-1 != $this->countTableHeadRows)) { + for($i = $lastRow-1; $i > 0; $i--) { - if ($this->tableCalls[$cellKey[$i][$lastCell]][1][2] >= $lastRow - $i) { - $spanning_cell = $i; - break; - } + if ( $this->tableCalls[$cellKey[$i][$lastCell]][0] == 'tablecell_open' || $this->tableCalls[$cellKey[$i][$lastCell]][0] == 'tableheader_open' ) { + + if ($this->tableCalls[$cellKey[$i][$lastCell]][1][2] >= $lastRow - $i) { + $spanning_cell = $i; + break; + } + } } } if (is_null($spanning_cell)) { @@ -1396,6 +1447,10 @@ class Doku_Handler_Table { $key += 3; } + if($this->countTableHeadRows == $lastRow) { + array_splice($this->tableCalls, $key+1, 0, array( + array('tablethead_close', array(), $call[2]))); + } break; } @@ -1438,7 +1493,7 @@ class Doku_Handler_Block { var $blockOpen = array( 'header', 'listu_open','listo_open','listitem_open','listcontent_open', - 'table_open','tablerow_open','tablecell_open','tableheader_open', + 'table_open','tablerow_open','tablecell_open','tableheader_open','tablethead_open', 'quote_open', 'code','file','hr','preformatted','rss', 'htmlblock','phpblock', @@ -1448,7 +1503,7 @@ class Doku_Handler_Block { var $blockClose = array( 'header', 'listu_close','listo_close','listitem_close','listcontent_close', - 'table_close','tablerow_close','tablecell_close','tableheader_close', + 'table_close','tablerow_close','tablecell_close','tableheader_close','tablethead_close', 'quote_close', 'code','file','hr','preformatted','rss', 'htmlblock','phpblock', |