r101822 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101821‎ | r101822 | r101823 >
Date:15:16, 3 November 2011
Author:gwicke
Status:deferred
Tags:
Comment:
Start by handling paragraphs, at least a bit.
Modified paths:
  • /trunk/extensions/VisualEditor/modules/es/serializers/es.Document.HtmlSerializer.js (modified) (history)
  • /trunk/extensions/VisualEditor/modules/parser/pegParser.pegjs.txt (modified) (history)
  • /trunk/extensions/VisualEditor/tests/parser/parserTests.js (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/tests/parser/parserTests.js
@@ -50,6 +50,7 @@
5151 _require(pj('es', 'bases', 'es.EventEmitter.js'));
5252 _require(pj('es', 'bases', 'es.Document.js'));
5353 _require(pj('es', 'bases', 'es.Document.Serializer.js'));
 54+_require(pj('es', 'serializers', 'es.AnnotationSerializer.js'));
5455 _require(pj('es', 'serializers', 'es.Document.HtmlSerializer.js'));
5556 _require(pj('es', 'serializers', 'es.Document.WikitextSerializer.js'));
5657 _require(pj('es', 'serializers', 'es.Document.JsonSerializer.js'));
Index: trunk/extensions/VisualEditor/modules/es/serializers/es.Document.HtmlSerializer.js
@@ -58,9 +58,8 @@
5959
6060 es.Document.HtmlSerializer.prototype.serializeParagraph = function( paragraph, raw ) {
6161 var out = [];
62 - for ( var l = 0, lMax = paragraph.lines.length; l < lMax; l++ ) {
63 - out.push( this.serializeLine( paragraph.lines[l] ) );
64 - }
 62+ // XXX: fix content to be single oblect with text and annotations!
 63+ out.push( this.serializeLine( paragraph.content[0] ) );
6564 if ( raw ) {
6665 return out.join( '\n' );
6766 } else {
Index: trunk/extensions/VisualEditor/modules/parser/pegParser.pegjs.txt
@@ -116,17 +116,17 @@
117117 + ", matched: " + str.substr(0,m));
118118 // reverse parser position
119119 pos -= str.length - m;
120 - return str.substr(0,m);
 120+ return {text: str.substr(0,m)};
121121 } else {
122122 if (m == 0) {
123123 pos -= str.length;
124124 return null;
125125 } else {
126 - return str;
 126+ return {text: str};
127127 }
128128 }
129129 } else {
130 - return str;
 130+ return {text: str};
131131 }
132132 }
133133
@@ -143,17 +143,17 @@
144144 pos -= str.length - m;
145145 dp("anyline reverse " + (str.length - m)
146146 + ", matched: " + str.substr(0,m));
147 - return str.substr(0,m);
 147+ return {text: str.substr(0,m)};
148148 } else {
149149 if (m == 0) {
150150 pos -= str.length;
151151 return null;
152152 } else {
153 - return str;
 153+ return {text : str};
154154 }
155155 }
156156 } else {
157 - return str;
 157+ return {text: str};
158158 }
159159 }
160160
@@ -286,8 +286,8 @@
287287 }
288288 if (text.length) {
289289 out.push({
290 - type: 'text',
291 - text: text
 290+ text: text,
 291+ //annotations: []
292292 });
293293 }
294294 return out;

Status & tagging log