Skip to content
Snippets Groups Projects
Commit f05a1cc5 authored by Gerrit Uitslag's avatar Gerrit Uitslag
Browse files

Wrap thead around 1st row, when 1st cell at 1st row is tableheader. Implements FS#1764

parent a467e020
No related branches found
No related tags found
No related merge requests found
......@@ -125,6 +125,7 @@ def');
array('cdata',array("\n\nabc")),
array('p_close',array()),
array('table_open',array(3, 1, 6)),
array('tablethead_open',array()),
array('tablerow_open',array()),
array('tableheader_open',array(1,NULL,1)),
array('cdata',array(' X ')),
......@@ -136,6 +137,7 @@ def');
array('cdata',array(' Z ')),
array('tableheader_close',array()),
array('tablerow_close',array()),
array('tablethead_close',array()),
array('table_close',array(19)),
array('p_open',array()),
array('cdata',array('def')),
......@@ -146,6 +148,55 @@ def');
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testTableHeadersMultilines() {
$this->P->addMode('table',new Doku_Parser_Mode_Table());
$this->P->parse('
abc
^ X | Y ^ Z |
| A | B | C |
def');
$calls = array (
array('document_start',array()),
array('p_open',array()),
array('cdata',array("\n\nabc")),
array('p_close',array()),
array('table_open',array(3, 2, 6)),
array('tablethead_open',array()),
array('tablerow_open',array()),
array('tableheader_open',array(1,NULL,1)),
array('cdata',array(' X ')),
array('tableheader_close',array()),
array('tablecell_open',array(1,NULL,1)),
array('cdata',array(' Y ')),
array('tablecell_close',array()),
array('tableheader_open',array(1,NULL,1)),
array('cdata',array(' Z ')),
array('tableheader_close',array()),
array('tablerow_close',array()),
array('tablethead_close',array()),
array('tablerow_open',array()),
array('tablecell_open',array(1,NULL,1)),
array('cdata',array(' A ')),
array('tablecell_close',array()),
array('tablecell_open',array(1,NULL,1)),
array('cdata',array(' B ')),
array('tablecell_close',array()),
array('tablecell_open',array(1,NULL,1)),
array('cdata',array(' C ')),
array('tablecell_close',array()),
array('tablerow_close',array()),
array('table_close',array(33)),
array('p_open',array()),
array('cdata',array('def')),
array('p_close',array()),
array('document_end',array()),
);
$this->assertEquals(array_map('stripbyteindex',$this->H->calls),$calls);
}
function testCellAlignment() {
$this->P->addMode('table',new Doku_Parser_Mode_Table());
......
......@@ -1278,6 +1278,7 @@ class Doku_Handler_Table {
$lastRow = 0;
$lastCell = 0;
$isThead = false;
$cellKey = array();
$toDelete = array();
......@@ -1292,6 +1293,14 @@ class Doku_Handler_Table {
$lastRow++;
$lastCell = 0;
if($lastRow === 1 && $this->tableCalls[$key+1][0] == 'tableheader_open') {
$isThead = true;
array_splice($this->tableCalls, $key, 0, array(
array('tablethead_open', array(), $call[2])));
$key += 1;
}
break;
case 'tablecell_open':
......@@ -1396,6 +1405,12 @@ class Doku_Handler_Table {
$key += 3;
}
if($isThead) {
array_splice($this->tableCalls, $key+1, 0, array(
array('tablethead_close', array(), $call[2])));
$isThead = false;
}
break;
}
......@@ -1437,7 +1452,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',
......@@ -1447,7 +1462,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',
......
......@@ -245,6 +245,10 @@ class Doku_Renderer extends DokuWiki_Plugin {
function table_close($pos = null){}
function tablethead_open(){}
function tablethead_close(){}
function tablerow_open(){}
function tablerow_close(){}
......
......@@ -946,6 +946,14 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
}
}
function tablethead_open(){
$this->doc .= DOKU_TAB . '<thead>' . DOKU_LF;
}
function tablethead_close(){
$this->doc .= DOKU_TAB . '</thead>' . DOKU_LF;
}
function tablerow_open(){
// initialize the cell counter used for classes
$this->_counter['cell_counter'] = 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment