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

Change subject: Strip [[ ]] from parser tests options in the parser
......................................................................

Strip [[ ]] from parser tests options in the parser

This is a (long-delayed) follow-up to
https://gerrit.wikimedia.org/r/#/c/281037/25..29/bin/parserTests.js

Bug: T140155
Change-Id: I6a14da69c4ac4496109f7f8b4b78df430ac9af7a
---
M bin/parserTests.js
M tests/parserTests.pegjs
2 files changed, 6 insertions(+), 5 deletions(-)


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

diff --git a/bin/parserTests.js b/bin/parserTests.js
index 7d78803..cd03108 100755
--- a/bin/parserTests.js
+++ b/bin/parserTests.js
@@ -691,13 +691,11 @@
 
                if (item.options.title !== undefined &&
                                !Array.isArray(item.options.title)) {
-                       // Strip the [[]] markers.
-                       var title = item.options.title.replace(/^\[\[|\]\]$/g, 
'');
                        // This sets the page name as well as the relative link 
prefix
                        // for the rest of the parse.  Do this redundantly with 
the above
                        // so that we start from the defaultPageName when 
resolving
                        // absolute subpages.
-                       this.env.initializeForPageName(title);
+                       this.env.initializeForPageName(item.options.title);
                }
                // Page language matches "wiki language" (which is set by
                // the item 'language' option).
diff --git a/tests/parserTests.pegjs b/tests/parserTests.pegjs
index c28fc9b..e8804a3 100644
--- a/tests/parserTests.pegjs
+++ b/tests/parserTests.pegjs
@@ -210,9 +210,12 @@
     return v;
 }
 
-link_target_value = v:("[[" (c:[^\]]* { return c.join(''); }) "]]")
+link_target_value = "[[" v:[^\]]* "]]"
 {
-    return v.join('');
+    // Perhaps we should canonicalize the title?
+    // Protect with JSON.stringify just in case the link target starts with
+    // double-quote or open-brace.
+    return JSON.stringify(v.join(''));
 }
 
 quoted_value = [\"] v:( [^\\\"] / ("\\" c:. { return "\\"+c; } ) )* [\"]

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6a14da69c4ac4496109f7f8b4b78df430ac9af7a
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