Some more progress for tables and definition lists

This commit is contained in:
Gabriel Wicke 2011-11-04 12:06:49 +00:00
parent 83a80bad49
commit 7e5c196732
2 changed files with 18 additions and 12 deletions

View file

@ -174,7 +174,8 @@ es.HtmlSerializer.prototype.table = function( node ) {
attributes = es.HtmlSerializer.getHtmlAttributes( node.attributes );
lines.push( es.Html.makeOpeningTag( 'table', attributes ) );
for ( var i = 0, length = node.children.length; i < length; i++ ) {
lines.push( this.tableRow( node.children[i] ) );
var child = node.children[i];
lines.push( this[child.type]( child ) );
}
lines.push( es.Html.makeClosingTag( 'table' ) );
return lines.join( '\n' );
@ -200,6 +201,11 @@ es.HtmlSerializer.prototype.tableCell = function( node ) {
return es.Html.makeTag( symbolTable[node.type], attributes, this.document( node, true ) );
};
es.HtmlSerializer.prototype.tableCaption = function( node ) {
attributes = es.HtmlSerializer.getHtmlAttributes( node.attributes );
return es.Html.makeTag( 'caption', attributes, this.content( node.content ) );
};
es.HtmlSerializer.prototype.transclusion = function( node ) {
var title = [];
if ( node.namespace !== 'Main' ) {

View file

@ -632,9 +632,9 @@ table
var res = {type: 'table'}
var body = b !== '' ? b : [];
if (c !== '') {
res.content = [c].concat(body);
res.children = [c].concat(body);
} else {
res.content = body;
res.children = body;
}
if (tas.length > 0) {
// FIXME: actually parse and build structure
@ -659,7 +659,7 @@ table_caption
= "|+" c:inline* newline? {
return {
type: 'tableCaption',
content: c
content: c[0]
}
}
@ -679,7 +679,7 @@ table_firstrow
= td:table_data+ {
return {
type: 'tableRow',
content: td
children: td
};
}
@ -687,7 +687,7 @@ table_row
= "|-" space* newline? td:(table_data / table_header)* {
return {
type: 'tableRow',
content: td
children: td
};
}
@ -697,7 +697,7 @@ table_data
//dp("table || result:" + print_r(td));
return {
type: 'tableCell',
content: td
children: td
};
}
/ & { dp("table_data : | enter pos=" + pos); return true; }
@ -705,7 +705,7 @@ table_data
//dp("table | result:" + print_r(td));
return {
type: 'tableCell',
content: td
children: td
};
}
@ -717,14 +717,14 @@ td_attr = a:[^\n|]+ "|" !"|" {
table_header
= "!!" c:(inline / ("!" !"!") / [^!\n])* newline? {
return {
type: 'tableHeader',
content: c
type: 'tableHeading',
children: c
}
}
/ "!" c:(inline / text / '!' !'!' / [^!\n])* newline? {
return {
type: 'tableHeader',
content: c
type: 'tableHeading',
children: c
}
}