jenkins-bot has submitted this change and it was merged.

Change subject: Serializer: Add 1 space, if necessary, around '=' in tpl 
transclusions
......................................................................


Serializer: Add 1 space, if necessary, around '=' in tpl transclusions

* So far, templates marked modified were serialized where template
  param values are not preceded by any whitespace -- the value was
  being emitted as is. This often results in visually not so pleasing
  serialization of multi-line params like "a    =foo".

  This patch changes the default to include a single space before
  and after the '=' char where necessary.

* This patch only changes the default for transclusions known to be
  template translucions (as opposed to parser functions, since we are
  yet to investigate if leading whitespace is semantically insignificant).

* Some examples of how this patch changes serialization in edit mode:

  {{echo|foo}}   ==> {{echo|foo}}
  {{echo|a=b}}   ==> {{echo|a = b}}
  {{echo|a = b}} ==> {{echo|a = b}}

  {{lc:FOO|a=b}} ==> {{lc:FOO|a=b}}
  {{{{echo|echo}}|a=b}} ==> {{{{echo|echo}}|a=b}}

Change-Id: I11cfed279d96a7e13f0c45601930e8d7dda9d717
---
M js/lib/mediawiki.WikitextSerializer.js
1 file changed, 5 insertions(+), 2 deletions(-)

Approvals:
  GWicke: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/js/lib/mediawiki.WikitextSerializer.js 
b/js/lib/mediawiki.WikitextSerializer.js
index a73b3d0..407a23d 100644
--- a/js/lib/mediawiki.WikitextSerializer.js
+++ b/js/lib/mediawiki.WikitextSerializer.js
@@ -2586,7 +2586,8 @@
                serializer = this;
        srcParts.map(function(part) {
                var tpl = part.template;
-               if (tpl) {
+               if (tpl) { // transclusion: tpl or parser function
+                       var isTpl = typeof(tpl.target.href) === 'string';
                        buf.push("{{");
 
                        // tpl target
@@ -2603,7 +2604,9 @@
                                        if (k === (i+1).toString()) {
                                                argBuf.push(v);
                                        } else {
-                                               argBuf.push(k + "=" + v);
+                                               var kStr = k + (isTpl && 
!k.match(/\s$/) ? ' ' : ''),
+                                                       vStr = (isTpl && 
!v.match(/^\s/) ? ' ' : '') + v;
+                                               argBuf.push(kStr + "=" + vStr);
                                        }
                                }
                                buf.push("|");

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I11cfed279d96a7e13f0c45601930e8d7dda9d717
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry <[email protected]>
Gerrit-Reviewer: GWicke <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to