r101982 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101981‎ | r101982 | r101983 >
Date:12:06, 4 November 2011
Author:gwicke
Status:deferred
Tags:
Comment:
Some more progress for tables and definition lists
Modified paths:
  • /trunk/extensions/VisualEditor/modules/es/serializers/es.HtmlSerializer.js (modified) (history)
  • /trunk/extensions/VisualEditor/modules/parser/pegParser.pegjs.txt (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/modules/es/serializers/es.HtmlSerializer.js
@@ -174,7 +174,8 @@
175175 attributes = es.HtmlSerializer.getHtmlAttributes( node.attributes );
176176 lines.push( es.Html.makeOpeningTag( 'table', attributes ) );
177177 for ( var i = 0, length = node.children.length; i < length; i++ ) {
178 - lines.push( this.tableRow( node.children[i] ) );
 178+ var child = node.children[i];
 179+ lines.push( this[child.type]( child ) );
179180 }
180181 lines.push( es.Html.makeClosingTag( 'table' ) );
181182 return lines.join( '\n' );
@@ -200,6 +201,11 @@
201202 return es.Html.makeTag( symbolTable[node.type], attributes, this.document( node, true ) );
202203 };
203204
 205+es.HtmlSerializer.prototype.tableCaption = function( node ) {
 206+ attributes = es.HtmlSerializer.getHtmlAttributes( node.attributes );
 207+ return es.Html.makeTag( 'caption', attributes, this.content( node.content ) );
 208+};
 209+
204210 es.HtmlSerializer.prototype.transclusion = function( node ) {
205211 var title = [];
206212 if ( node.namespace !== 'Main' ) {
Index: trunk/extensions/VisualEditor/modules/parser/pegParser.pegjs.txt
@@ -632,9 +632,9 @@
633633 var res = {type: 'table'}
634634 var body = b !== '' ? b : [];
635635 if (c !== '') {
636 - res.content = [c].concat(body);
 636+ res.children = [c].concat(body);
637637 } else {
638 - res.content = body;
 638+ res.children = body;
639639 }
640640 if (tas.length > 0) {
641641 // FIXME: actually parse and build structure
@@ -659,7 +659,7 @@
660660 = "|+" c:inline* newline? {
661661 return {
662662 type: 'tableCaption',
663 - content: c
 663+ content: c[0]
664664 }
665665 }
666666
@@ -679,7 +679,7 @@
680680 = td:table_data+ {
681681 return {
682682 type: 'tableRow',
683 - content: td
 683+ children: td
684684 };
685685 }
686686
@@ -687,7 +687,7 @@
688688 = "|-" space* newline? td:(table_data / table_header)* {
689689 return {
690690 type: 'tableRow',
691 - content: td
 691+ children: td
692692 };
693693 }
694694
@@ -697,7 +697,7 @@
698698 //dp("table || result:" + print_r(td));
699699 return {
700700 type: 'tableCell',
701 - content: td
 701+ children: td
702702 };
703703 }
704704 / & { dp("table_data : | enter pos=" + pos); return true; }
@@ -705,7 +705,7 @@
706706 //dp("table | result:" + print_r(td));
707707 return {
708708 type: 'tableCell',
709 - content: td
 709+ children: td
710710 };
711711 }
712712
@@ -717,14 +717,14 @@
718718 table_header
719719 = "!!" c:(inline / ("!" !"!") / [^!\n])* newline? {
720720 return {
721 - type: 'tableHeader',
722 - content: c
 721+ type: 'tableHeading',
 722+ children: c
723723 }
724724 }
725725 / "!" c:(inline / text / '!' !'!' / [^!\n])* newline? {
726726 return {
727 - type: 'tableHeader',
728 - content: c
 727+ type: 'tableHeading',
 728+ children: c
729729 }
730730 }
731731

Status & tagging log