Subramanya Sastry has uploaded a new change for review.

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


Change subject: Fix selser bug while serializing templates; bug in cite output
......................................................................

Fix selser bug while serializing templates; bug in cite output

* When multiple DOM nodes emitted by a template are unmodified
  and both happen to have valid DSR, selser emitted tpl source
  for each such DOM node (which led to duplicate citation output
  in several cases).  This makes selser more robust.

* But, the fact that multiple content nodes of an encapsulated tpl/ext.
  has the same top-level dsr is a different bug.  This currently
  happens with citations because marker metas aren't getting deleted.
  Initial investigates point to a bug either in the handleLinkNeighbors
  DOM post-processor or the DOMTraverser class in some edge case.
  Will be investigated separately.

* Based on a bug report submitted on parsoid.wmflabs.org
  /mnt/bugs/2013-04-29T09:48:52.536Z-Religion_in_Eritrea

* Unrelated: Fixed a JSHint warning

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


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Parsoid 
refs/changes/89/61389/1

diff --git a/js/lib/mediawiki.WikitextSerializer.js 
b/js/lib/mediawiki.WikitextSerializer.js
index 85a2a2c..e4b2838 100644
--- a/js/lib/mediawiki.WikitextSerializer.js
+++ b/js/lib/mediawiki.WikitextSerializer.js
@@ -675,7 +675,11 @@
                // 2. we have an open bracket, and
                //    - text has an unmatched bracket
                //    - the combined text will get parsed as a link (expensive 
check)
-               if (cl.hasOpenHeadingChar && opts.isLastChild && 
text.match(/=$/) ||
+               //
+               // NOTE: Escaping the "=" char in the regexp because JSHint 
complains that
+               // it can be confused by other developers.
+               // See 
http://jslinterrors.com/a-regular-expression-literal-can-be-confused-with/
+               if (cl.hasOpenHeadingChar && opts.isLastChild && 
text.match(/\=$/) ||
                    cl.hasOpenBrackets && text.match(/^[^\[]*\]/) &&
                                this.wteHandlers.hasWikitextTokens(state, sol, 
cl.text + text, true))
                {
@@ -2885,8 +2889,15 @@
                                                node,  domHandler);
                        }
 
-                       var handled = false;
-                       if (state.selserMode && !state.inModifiedContent) {
+                       var handled = false,
+                               about = node.getAttribute('about') || null;
+
+                       // We have 2 global checks here for selser-mode
+                       // 1. WTS is not in a subtree with a modification flag 
that applies to every
+                       //    node of a subtree (rather than an indication that 
some node in the
+                       //    subtree is modified).
+                       // 2. WTS not processing template content that has 
already been emitted.
+                       if (state.selserMode && !state.inModifiedContent && 
(!about || about !== state.activeTemplateId)) {
                                // To serialize from source, we need 2 things 
of the node:
                                // -- it should not have a diff marker
                                // -- it should have valid, usable DSR
@@ -2936,7 +2947,7 @@
                                        // can be ignored, if necessary.
                                        var nodeTypeOf = node.getAttribute( 
'typeof' ) || '';
                                        if (nodeTypeOf && 
nodeTypeOf.match(/\bmw:Object(\/[^\s]+|\b)/)) {
-                                               state.activeTemplateId = 
node.getAttribute('about') || null;
+                                               state.activeTemplateId = about;
                                        }
                                }
                        }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8a3808b3d0e36b7e3de7c5f4aa774f78881d63e4
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry <[email protected]>

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

Reply via email to