summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
authorChristopher Smith <chris@jalakai.co.uk>2014-03-13 17:52:03 +0000
committerChristopher Smith <chris@jalakai.co.uk>2014-03-16 18:58:44 +0000
commitcef031c123914a2d88f125a8363c0917011e8ed0 (patch)
treed4cf88038d8adaaf0c79df95423eda2f0cede105 /inc
parent4e60057c8ccbee18b94a64208311f9bbb338eec6 (diff)
downloadrpg-cef031c123914a2d88f125a8363c0917011e8ed0.tar.gz
rpg-cef031c123914a2d88f125a8363c0917011e8ed0.tar.bz2
implement rules for when the top rows of a table qualify for a THEAD element
1. TD < 2 in a row 2. TD <= 50% of total cells 3. Not all table rows can be THEAD rows
Diffstat (limited to 'inc')
-rw-r--r--inc/parser/handler.php30
1 files changed, 27 insertions, 3 deletions
diff --git a/inc/parser/handler.php b/inc/parser/handler.php
index c4104dac9..d8382e7fc 100644
--- a/inc/parser/handler.php
+++ b/inc/parser/handler.php
@@ -1150,6 +1150,7 @@ class Doku_Handler_Table {
var $firstCell = false;
var $lastCellType = 'tablecell';
var $inTableHead = true;
+ var $currentRow = array('tableheader' => 0, 'tablecell' => 0);
var $countTableHeadRows = 0;
function Doku_Handler_Table(& $CallWriter) {
@@ -1218,10 +1219,13 @@ 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) {
+ if ($this->inTableHead && ($this->inTableHead = $this->isTableHeadRow())) {
$this->countTableHeadRows++;
}
// Strip off final cell opening and anything after it
@@ -1230,6 +1234,9 @@ class Doku_Handler_Table {
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]);
@@ -1238,9 +1245,19 @@ 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 ($call[0] != 'tableheader') {
- $this->inTableHead = false;
+ if ($this->inTableHead) {
+ $this->currentRow[$call[0]]++;
}
if ( !$this->firstCell ) {
@@ -1289,6 +1306,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