Arlolra has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/226120

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, 9 insertions(+), 4 deletions(-)


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

diff --git a/lib/mediawiki.WikitextSerializer.js 
b/lib/mediawiki.WikitextSerializer.js
index d73b723..24dd37d 100644
--- a/lib/mediawiki.WikitextSerializer.js
+++ b/lib/mediawiki.WikitextSerializer.js
@@ -1082,8 +1082,13 @@
 
                                        // 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);
+                                       });
+
+                                       // Only suppress for the cases we've 
whitelisted.
+                                       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 +1096,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: newchange
Gerrit-Change-Id: I836a4157f03427215c1ed39b529cb2d4ce273f55
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Arlolra <[email protected]>

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

Reply via email to