r101974 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101973‎ | r101974 | r101975 >
Date:11:08, 4 November 2011
Author:gwicke
Status:deferred
Tags:
Comment:
Fixes for 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
@@ -99,13 +99,14 @@
100100 var commonPrefixLength = function (x, y) {
101101 var minLength = Math.min(x.length, y.length);
102102 for(var i = 0; i < minLength; i++) {
103 - if (x[i] !== y[i]
 103+ if (x[i] !== y[i]) {
104104 // Both definitiondata and definitionterm are
105105 // inside dls, so consider them equivalent here.
106 - && [x[i], y[i]].sort()
107 - !== ['definitiondata', 'definitionterm'] )
108 - {
 106+ var diffs = [x[i], y[i]].sort();
 107+ if (diffs[0] !== 'definitiondata'
 108+ && diffs[1] !== 'definitionterm' ) {
109109 break;
 110+ }
110111 }
111112 }
112113 return i;
Index: trunk/extensions/VisualEditor/modules/parser/pegParser.pegjs.txt
@@ -55,8 +55,8 @@
5656 var level_padding = "";
5757 var bracket_level_padding = "";
5858
59 - for (var j = 0; j < level + 1; j++) level_padding += " ";
60 - for (var b = 0; b < level; b++) bracket_level_padding += " ";
 59+ for (var j = 0; j < level + 1; j++) level_padding += " ";
 60+ for (var b = 0; b < level; b++) bracket_level_padding += " ";
6161
6262 if (typeof(arr) == 'object') { //Array/Hashes/Objects
6363 dumped_text += "Array\n";
@@ -74,8 +74,8 @@
7575
7676 }
7777 dumped_text += bracket_level_padding + ")\n\n";
78 - } else { //Stings/Chars/Numbers etc.
79 - dumped_text = "===>" + arr + "<===(" + typeof(arr) + ")";
 78+ } else { //Strings/Chars/Numbers etc.
 79+ dumped_text = "=>" + arr + "<=(" + typeof(arr) + ")";
8080 }
8181
8282 return dumped_text;
@@ -566,19 +566,20 @@
567567
568568 lists = es:(dtdd / li)+
569569 {
570 - // flatten es
 570+ // Flatten es
571571 var esLen = es.length;
572572 var flatEs = [];
573573 for (var i = 0; i < esLen; i++) {
574 - if (es[i].constructor === Array) {
575 - flatEs.concat(es[i]);
 574+ var ei = es[i];
 575+ if ($.isArray(ei)) {
 576+ flatEs = flatEs.concat(ei);
576577 } else {
577 - flatEs.push(es[i]);
 578+ flatEs.push(ei);
578579 }
579580 }
580581 return {
581582 type: 'list',
582 - children: es
 583+ children: flatEs
583584 }
584585 }
585586
@@ -598,7 +599,7 @@
599600 dtdd = bullets:list_char+
600601 c:(inline_element / [^:\n])+
601602 ":"
602 - d:(inline / anyline)
 603+ d:(inline_element / [^\n])+
603604 newline
604605 {
605606 // reject rule if bullets do not end in semicolon
@@ -609,12 +610,12 @@
610611 {
611612 type: 'listItem',
612613 attributes: {styles: bulletsToTypes(bullets)},
613 - content: c[0]
 614+ content: {text: c.join('')}
614615 }, {
615616 type: 'listItem',
616617 attributes: {styles: bulletsToTypes(
617618 bullets.slice(0, bullets.length - 1) + ':')},
618 - content: d[0]
 619+ content: {text: d.join('')}
619620 }
620621 ]
621622 }

Status & tagging log