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

Change subject: Categories in templates shouldn't force a line break during 
html2wt
......................................................................


Categories in templates shouldn't force a line break during html2wt

* Followup to 0337bb3b.
* Bug found in rt-testing.
* Added couple explicit tests to clarify expectation.
* Undid changes to:
  - the parser test that was incorrectly updated
    in 0337bb3b to prevent it from failing.
  - mocha tests that were also incorrectly updated
    in 0337bb3b to prevent them from failing.

Change-Id: I04f7ade6c4da701e57ba927dba4e2a3752bf5f40
---
M lib/wts.TagHandlers.js
M tests/mocha/jsapi.js
M tests/parserTests.txt
3 files changed, 29 insertions(+), 5 deletions(-)

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



diff --git a/lib/wts.TagHandlers.js b/lib/wts.TagHandlers.js
index 0f42bd4..2c1a605 100644
--- a/lib/wts.TagHandlers.js
+++ b/lib/wts.TagHandlers.js
@@ -1171,7 +1171,9 @@
                sepnls: {
                        before: function(node, otherNode) {
                                // sol-transparent link nodes are the only 
thing on their line
-                               if (DU.isSolTransparentLink(node) && 
!DU.isBody(otherNode)) {
+                               if (DU.isSolTransparentLink(node) &&
+                                       !DU.isEncapsulationWrapper(node) &&
+                                       !DU.isBody(otherNode)) {
                                        return { min: 1 };
                                } else {
                                        return {};
@@ -1179,7 +1181,9 @@
                        },
                        after: function(node, otherNode, state) {
                                // sol-transparent link nodes are the only 
thing on their line
-                               if (DU.isSolTransparentLink(node) && 
!DU.isBody(otherNode)) {
+                               if (DU.isSolTransparentLink(node) &&
+                                       !DU.isEncapsulationWrapper(node) &&
+                                       !DU.isBody(otherNode)) {
                                        return { min: 1 };
                                } else {
                                        return {};
diff --git a/tests/mocha/jsapi.js b/tests/mocha/jsapi.js
index 8acad1b..c777365 100644
--- a/tests/mocha/jsapi.js
+++ b/tests/mocha/jsapi.js
@@ -87,7 +87,7 @@
                                        template.name = 'bar-stub';
                                }
                        });
-                       String(pdoc).should.equal("{{cleanup|date = July 2012}} 
'''Foo''' is a [[bar]]. {{bar-stub}}\n");
+                       String(pdoc).should.equal("{{cleanup|date = July 2012}} 
'''Foo''' is a [[bar]]. {{bar-stub}}");
                });
        });
 });
@@ -105,7 +105,7 @@
                                        template.add('test2', 
Parsoid.PNodeList.fromHTML(pdoc, "I'm so <b>bold</b>!"));
                                }
                        });
-                       String(pdoc).should.equal("{{echo|{{cleanup|date = July 
2012|test1 = <nowiki>{{foo}}</nowiki>&bar{{!}}bat<nowiki><p></nowiki>|test2 = 
I'm so '''bold'''!}} '''Foo''' is a [[bar]].}} {{uncategorized}}\n");
+                       String(pdoc).should.equal("{{echo|{{cleanup|date = July 
2012|test1 = <nowiki>{{foo}}</nowiki>&bar{{!}}bat<nowiki><p></nowiki>|test2 = 
I'm so '''bold'''!}} '''Foo''' is a [[bar]].}} {{uncategorized}}");
                });
        });
        it('is safe to mutate template arguments', function() {
diff --git a/tests/parserTests.txt b/tests/parserTests.txt
index 15f1cd1..89386a1 100644
--- a/tests/parserTests.txt
+++ b/tests/parserTests.txt
@@ -24932,7 +24932,7 @@
 !! html/parsoid
 <h2><span about="#mwt1" typeof="mw:Transclusion" data-parsoid="{}" 
data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo
 [[Category:Foo]]"}},"i":0}}]}'>foo </span><link rel="mw:PageProp/Category" 
href="./Category:Foo" about="#mwt1" data-parsoid="{}" /></h2>
 !! wikitext
-== {{echo|foo [[Category:Foo]]}}  ==
+== {{echo|foo [[Category:Foo]]}} ==
 !! end
 
 !! test
@@ -25682,6 +25682,26 @@
 # --------------------------------------------
 
 !! test
+1. Categories should always be serialized on their own line
+!! options
+parsoid=html2wt
+!! html/parsoid
+foo<link rel="mw:PageProp/Category" href="./Category:Foo">bar
+!! wikitext
+foo
+[[Category:Foo]]
+bar
+!! end
+
+!! test
+2. Categories that are part of templates should not introduce a line break
+!! wikitext
+foo {{echo|<span>bar</span> [[Category:baz]]}} bar
+!! html/parsoid
+<p>foo <span about="#mwt1" typeof="mw:Transclusion" 
data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;span>bar&lt;/span>
 [[Category:baz]]"}},"i":0}}]}'>bar</span><span about="#mwt1"> </span><link 
rel="mw:PageProp/Category" href="./Category:Baz" about="#mwt1" 
data-parsoid='{"stx":"simple","a":{"href":"./Category:Baz"},"sa":{"href":"Category:baz"}}'/>
 bar</p>
+!! end
+
+!! test
 Lists: Add space after bullets
 !! options
 parsoid=html2wt

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

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

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

Reply via email to