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

Change subject: Only disable single-line in selser where whitelisted
......................................................................


Only disable single-line in selser where whitelisted

 * We should only disable single-line context when reusing content from
   selser in the same scenarios where it's disabled in normal
   serialization.

 * There's an edge case here where nested templates will serialize to a
   single line where, strictly speaking, they don't need to.

Change-Id: I836a4157f03427215c1ed39b529cb2d4ce273f55
---
M lib/mediawiki.WikitextSerializer.js
1 file changed, 11 insertions(+), 4 deletions(-)

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



diff --git a/lib/mediawiki.WikitextSerializer.js 
b/lib/mediawiki.WikitextSerializer.js
index d5df07b..3a70fc1 100644
--- a/lib/mediawiki.WikitextSerializer.js
+++ b/lib/mediawiki.WikitextSerializer.js
@@ -1082,8 +1082,15 @@
 
                                        // console.warn("USED ORIG");
                                        this.trace("ORIG-src with DSR", 
function() {
-                                                       return '[' + dp.dsr[0] 
+ ',' + dp.dsr[1] + '] = ' + JSON.stringify(out);
-                                               });
+                                               return '[' + dp.dsr[0] + ',' + 
dp.dsr[1] + '] = ' + JSON.stringify(out);
+                                       });
+
+                                       // When reusing source, we should only 
suppress serializing
+                                       // to a single line for the cases we've 
whitelisted in
+                                       // normal serialization.
+                                       var suppressSLC = 
DU.isFirstEncapsulationWrapperNode(node) ||
+                                               ['DL', 'UL', 
'OL'].indexOf(node.nodeName) > -1;
+
                                        // Use selser to serialize this text!  
The original
                                        // wikitext is `out`.  But first allow
                                        // `ConstrainedText.fromSelSer` to 
figure out the right
@@ -1091,11 +1098,11 @@
                                        // `out`, based on the node type.  
Since we might actually
                                        // have to break this wikitext into 
multiple chunks,
                                        // `fromSelSer` returns an array.
-                                       state.singleLineContext.disable();
+                                       if (suppressSLC) { 
state.singleLineContext.disable(); }
                                        ConstrainedText.fromSelSer(out, node, 
dp, state.env).forEach(function(ct) {
                                                cb(ct, ct.node);
                                        });
-                                       state.singleLineContext.pop();
+                                       if (suppressSLC) { 
state.singleLineContext.pop(); }
 
                                        // Skip over encapsulated content since 
it has already been serialized
                                        if 
(DU.isFirstEncapsulationWrapperNode(node)) {

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I836a4157f03427215c1ed39b529cb2d4ce273f55
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Arlolra <abrea...@wikimedia.org>
Gerrit-Reviewer: Cscott <canan...@wikimedia.org>
Gerrit-Reviewer: Subramanya Sastry <ssas...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to