r107626 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r107625‎ | r107626 | r107627 >
Date:09:35, 30 December 2011
Author:gwicke
Status:deferred
Tags:
Comment:
Fix suffix handling for wiki links.
Modified paths:
  • /trunk/extensions/VisualEditor/modules/parser/pegTokenizer.pegjs.txt (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/modules/parser/pegTokenizer.pegjs.txt
@@ -30,6 +30,8 @@
3131 };
3232
3333 // Remove escaped quotes from attributes etc
 34+ // This was in the original PEG parser, but could not find anything in
 35+ // MediaWiki that supports \' and \"-style escaping. So remove? -- gwicke
3436 var unquote = function (quotec, text) {
3537 return text.replace('\\' + quotec, quotec);
3638 };
@@ -683,6 +685,7 @@
684686 obj.args[position] = param[1];
685687 position++;
686688 } else {
 689+ // Last value wins for duplicates.
687690 obj.args[param[0]] = param[1];
688691 }
689692 }
@@ -736,7 +739,7 @@
737740 = "[["
738741 ! url
739742 target:link_target
740 - ltext:( "|" lt:link_text { return lt } )*
 743+ lcontent:( "|" lt:link_text { return lt } )*
741744 "]]"
742745 suffix:(![ \]] tc:text_char { return tc })* {
743746 var obj = {
@@ -745,17 +748,22 @@
746749 attribs: [
747750 ['data-type', 'internal']
748751 ]
749 - };
 752+ },
 753+ suffixTokens = [],
 754+ textTokens = [];
750755 obj.attribs.push(['href', target]);
751 - if (ltext && ltext.length) {
752 - var textTokens = ltext;
 756+ if (lcontent && lcontent.length) {
 757+ textTokens = lcontent;
 758+ if (suffix) {
 759+ suffixTokens = [{ type: 'TEXT', value: suffix.join('') }];
 760+ }
753761 } else {
754762 if (suffix) {
755763 target += suffix.join('');
756764 }
757 - var textTokens = [{type: 'TEXT', value: target}];
 765+ textTokens = [{type: 'TEXT', value: target}];
758766 }
759 - return [obj].concat(textTokens, [{type: 'ENDTAG', name: 'a'}]);
 767+ return [obj].concat(textTokens, [{type: 'ENDTAG', name: 'a'}], suffixTokens);
760768 }
761769
762770 link_target

Status & tagging log