C. Scott Ananian has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/348992 )

Change subject: Match [[:mw:Preprocessor_ABNF]] behavior for "broken link".
......................................................................

Match [[:mw:Preprocessor_ABNF]] behavior for "broken link".

Match the behavior of the PHP preprocessor for links missing their
close brackets.

Change-Id: Ied94e2224d5d72d6b36906f4bb5fd8b55e645210
---
M lib/wt2html/pegTokenizer.pegjs
1 file changed, 20 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid 
refs/changes/92/348992/1

diff --git a/lib/wt2html/pegTokenizer.pegjs b/lib/wt2html/pegTokenizer.pegjs
index cd25d08..4abf3ac 100644
--- a/lib/wt2html/pegTokenizer.pegjs
+++ b/lib/wt2html/pegTokenizer.pegjs
@@ -954,18 +954,34 @@
     target:wikilink_preprocessor_text?
     tpos:("" { return endOffset(); })
     lcontent:wikilink_content?
-    "]]"
+    closed:"]]"?
   {
       if (lcontent === null) {
           lcontent = { content: [] };
       }
 
-      if (target === null || lcontent.pipetrick) {
-        return [text()];
+      var textTokens = [];
+      if (target === null || lcontent.pipetrick || !closed) {
+        // !closed => "broken-link" rule; see [[:mw:Preprocessor_ABNF]]
+        textTokens.push("[[");
+        if (target) {
+          textTokens.push(target);
+        }
+        if (lcontent.pipetrick) {
+          textTokens.push("|");
+        }
+        lcontent.content.forEach(function(a) {
+          // a is a mw:maybeContent attribute
+          textTokens.push("|");
+          textTokens.push(a.v);
+        });
+        if (closed) {
+          textTokens.push("]]");
+        }
+        return textTokens;
       }
 
       var obj = new SelfclosingTagTk('wikilink');
-      var textTokens = [];
       var hrefKV = new KV('href', target);
       hrefKV.vsrc = input.substring(startOffset() + 2, tpos);
       // XXX: Point to object with path, revision and input information

-- 
To view, visit https://gerrit.wikimedia.org/r/348992
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ied94e2224d5d72d6b36906f4bb5fd8b55e645210
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: C. Scott Ananian <canan...@wikimedia.org>

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

Reply via email to