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

Change subject: Only normalize new nodes
......................................................................


Only normalize new nodes

 * Includes a fix to nl suppression in single-line context so the tests
   passes. The closing tag should be emitted with suppression enabled to
   catch the last separator.

Change-Id: I04439bbf9631c6035e154316a095cd6a0718915e
---
M lib/wts.TagHandlers.js
M lib/wts.normalizeDOM.js
M tests/parserTests.txt
3 files changed, 14 insertions(+), 5 deletions(-)

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



diff --git a/lib/wts.TagHandlers.js b/lib/wts.TagHandlers.js
index 3fdb0ce..08715fa 100644
--- a/lib/wts.TagHandlers.js
+++ b/lib/wts.TagHandlers.js
@@ -42,13 +42,12 @@
                                }
                        }
                        cb(headingWT + space, node);
+                       state.singleLineContext.enforce();
 
                        if (node.childNodes.length) {
                                var headingHandler = state.serializer
                                        
.wteHandlers.headingHandler.bind(state.serializer.wteHandlers, node);
-                               state.singleLineContext.enforce();
                                state.serializeChildren(node, cb, 
headingHandler);
-                               state.singleLineContext.pop();
                        } else {
                                // Deal with empty headings
                                cb('<nowiki/>', node);
@@ -64,6 +63,7 @@
                                }
                        }
                        cb(space + headingWT, node);
+                       state.singleLineContext.pop();
                },
                sepnls: {
                        before: function(node, otherNode) {
diff --git a/lib/wts.normalizeDOM.js b/lib/wts.normalizeDOM.js
index 8dc3bd8..50d2ab9 100644
--- a/lib/wts.normalizeDOM.js
+++ b/lib/wts.normalizeDOM.js
@@ -113,14 +113,19 @@
  */
 
 function normalizeNode(env, node) {
+       // Right now, only newly inserted elements are normalized
+       if (!DU.isNewElt(node)) {
+               return node;
+       }
+
        var isHeading = /^H[1-6]$/.test(node.nodeName);
        if (isHeading) {
                hoistLinks(env, node, false);
                hoistLinks(env, node, true);
        }
 
-       // Right now, only newly inserted elements are normalized
-       if (!env.scrubWikitext || !DU.isNewElt(node)) {
+       // This can be moved up when VE enables it.
+       if (!env.scrubWikitext) {
                return node;
        }
 
diff --git a/tests/parserTests.txt b/tests/parserTests.txt
index 1a9fb3f..0c481a4 100644
--- a/tests/parserTests.txt
+++ b/tests/parserTests.txt
@@ -23759,7 +23759,7 @@
 !! end
 
 !! test
-Headings: Force metas to serialize before/after
+Headings: Force metas to serialize before/after new headings
 !! options
 parsoid=html2wt
 !! html
@@ -23768,6 +23768,8 @@
 
 <h2><!--foo-->  <link href="Category:A3" rel="mw:PageProp/Category" />   how 
goes it</h2>
 <h2>it goes well   <link href="Category:A4" rel="mw:PageProp/Category" />  
<!--bar--></h2>
+
+<h2 data-parsoid='{}'>howdy<link href="Category:A5" rel="mw:PageProp/Category" 
/></h2>
 !! wikitext
 == hello there ==
 [[Category:A1]]
@@ -23781,6 +23783,8 @@
 
 == it goes well ==
 [[Category:A4]]  <!--bar-->
+
+==howdy [[Category:A5]] ==
 !! end
 
 !! test

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I04439bbf9631c6035e154316a095cd6a0718915e
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Arlolra <[email protected]>
Gerrit-Reviewer: Cscott <[email protected]>
Gerrit-Reviewer: Subramanya Sastry <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to