https://www.mediawiki.org/wiki/Special:Code/MediaWiki/105423

Revision: 105423
Author:   gwicke
Date:     2011-12-07 11:51:24 +0000 (Wed, 07 Dec 2011)
Log Message:
-----------
Fix a bug in doQuotes (bitten by surprising JS sort() behavior), and improve
tag-only-line handling. 180 parser tests now passing.

Modified Paths:
--------------
    trunk/extensions/VisualEditor/modules/parser/pegParser.pegjs.txt

Modified: trunk/extensions/VisualEditor/modules/parser/pegParser.pegjs.txt
===================================================================
--- trunk/extensions/VisualEditor/modules/parser/pegParser.pegjs.txt    
2011-12-07 11:45:05 UTC (rev 105422)
+++ trunk/extensions/VisualEditor/modules/parser/pegParser.pegjs.txt    
2011-12-07 11:51:24 UTC (rev 105423)
@@ -199,10 +199,15 @@
             var index = bolds[i];
             var txt = out[index - 1];
             txt.value += "'";
-            bolds = bolds.slice(0, i)
-                .concat(bolds.slice(i + 1, bolds.length - i - 1));
+            if ( i > 0 ) {
+                bolds = bolds.slice(0, i-1)
+                    .concat(bolds.slice(i + 1, bolds.length - i - 1));
+            } else {
+                bolds.shift();
+            }
+
             italics.push(index);
-            italics.sort();
+            italics.sort(function(a,b) { return a - b });
         };
 
         // convert italics/bolds into tags
@@ -295,12 +300,12 @@
                                     firstspace = j;
                                 } else if (lastchar !== ' ') {
                                     if ( secondtolastchar === ' ' && 
-                                            firstsingleletterword === -1) {
-                                                firstsingleletterword = j;
-                                            } else if ( secondtolastchar && 
-                                                    secondtolastchar !== ' ') {
-                                                        firstmultiletterword = 
j;
-                                                    }
+                                            firstsingleletterword === -1) 
+                                    {
+                                        firstsingleletterword = j;
+                                    } else if ( firstmultiletterword == -1) {
+                                        firstmultiletterword = j;
+                                    }
                                 }
                             }
                         }
@@ -475,7 +480,16 @@
 space
   = s:[ \t]+ { return s.join(''); }
 
+spaceTokenList
+  = s:space* {
+      if ( s.length ) {
+          return [{type: 'TEXT', value: s.join('')}];
+      } else {
+          return [];
+      }
+  }
 
+
 // Start of line
 sol = (newline / & { return pos === 0; } { return true; }) 
       cn:(c:comment n:newline? { return [c, {type: 'TEXT', value: n}] })* {
@@ -537,7 +551,11 @@
   / table
   / lists
   // tag-only lines should not trigger pre
-  / space* bt:block_tag space* &eolf { return bt }
+  / st:spaceTokenList 
+    bt:(bts:block_tag stl:spaceTokenList { return bts.concat(stl) })+ 
+    &eolf { 
+        return st.concat(bt); 
+    }
   / pre_indent
   / pre
 
@@ -935,7 +953,7 @@
         } else {
             res.type = 'TAG';
         }
-        return res;
+        return [res];
     }
 
 /* Generic XML-like tags
@@ -1127,7 +1145,7 @@
     ("||" / newline "|") 
     ! [}+-]
     //& { dp('before attrib, pos=' + pos); return true; }
-    a:(as:generic_attribute+ space* "|" !"|" { console.log('bla'); return as } 
)?
+    a:(as:generic_attribute+ space* "|" !"|" { return as } )?
     //& { dp('past attrib, pos=' + pos); return true; }
     // use inline_breaks to break on tr etc
     td:(!inline_breaks 


_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to