Arlolra has uploaded a new change for review.

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

Change subject: Only emit shared prefix bullets for the right parents
......................................................................

Only emit shared prefix bullets for the right parents

 * In the other cases (ie. when this child doesn't match expectations),
   we'll have already emitted bullets for the parent node, which is why
   we're seeing duplicates.

 * Fixes a regression introduced in e7e1cf2dc8c5b7683b9207b268dea10d7dfd53f5

 * Identified in rt https://gerrit.wikimedia.org/r/#/c/262723/

Change-Id: Iae4dc35fdfd3058ae3bb12bc950f57e416398cb2
---
M lib/html2wt/DOMHandlers.js
1 file changed, 16 insertions(+), 1 deletion(-)


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

diff --git a/lib/html2wt/DOMHandlers.js b/lib/html2wt/DOMHandlers.js
index ca66f51..beef6b9 100644
--- a/lib/html2wt/DOMHandlers.js
+++ b/lib/html2wt/DOMHandlers.js
@@ -1287,9 +1287,24 @@
        },
 });
 
+var parentMap = {
+       LI: { UL: 1, OL: 1},
+       DT: { DL: 1 },
+       DD: { DL: 1 },
+};
+
+// FIXME: parentNode here should probably skip builder inserted elements,
+// as in `isBuilderInsertedElt`.
+function bulletsHaventAlreadyBeenEmitted(node) {
+       return (DU.isList(node) && DU.isListItem(node.parentNode)) ||
+               (DU.isListItem(node) &&
+                       node.parentNode.nodeName in parentMap[node.nodeName]);
+}
+
 function handleListPrefix(node, state) {
        var bullets = '';
-       if (DU.isListOrListItem(node) && !DU.previousNonSepSibling(node) &&
+       if (bulletsHaventAlreadyBeenEmitted(node) &&
+                       !DU.previousNonSepSibling(node) &&
                        isTplListWithoutSharedPrefix(node) &&
                        // Nothing to do for definition list rows,
                        // since we're emitting for the parent node.

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

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