Arlolra has uploaded a new change for review.

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

Change subject: Don't emit a space if no bullets are returned
......................................................................

Don't emit a space if no bullets are returned

Change-Id: If577a949e584530ae9b147a465201ca00e113f35
---
M lib/html2wt/DOMHandlers.js
M tests/parserTests-blacklist.js
2 files changed, 4 insertions(+), 3 deletions(-)


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

diff --git a/lib/html2wt/DOMHandlers.js b/lib/html2wt/DOMHandlers.js
index 17763cc..ee1d2c0 100644
--- a/lib/html2wt/DOMHandlers.js
+++ b/lib/html2wt/DOMHandlers.js
@@ -166,7 +166,8 @@
                node = node.parentNode;
        }
 
-       return res + space;
+       // Don't emit a space if we aren't returning any bullets.
+       return res.length ? res + space : '';
 }
 
 function wtListEOL(node, otherNode) {
diff --git a/tests/parserTests-blacklist.js b/tests/parserTests-blacklist.js
index 95c011c..7a59f66 100644
--- a/tests/parserTests-blacklist.js
+++ b/tests/parserTests-blacklist.js
@@ -466,7 +466,7 @@
 add("html2html", "Failing to transform badly formed HTML into correct XHTML", 
"\n\n<p data-parsoid='{\"autoInsertedEnd\":true,\"dsr\":[2,2,0,0]}'><br 
data-parsoid='{\"dsr\":[2,2,0,0]}'/></p>\n");
 add("html2html", "Handling html with a br self-closing tag", "\n\n<p 
data-parsoid='{\"dsr\":[2,2,0,0]}'><br 
data-parsoid='{\"dsr\":[2,2,0,0]}'/></p>\n\n\n<p 
data-parsoid='{\"autoInsertedEnd\":true,\"dsr\":[5,5,0,0]}'><br 
data-parsoid='{\"dsr\":[5,5,0,0]}'/></p>\n");
 add("html2html", "Unbalanced closing non-block tags don't break a list\n(php 
parser relies on Tidy to fix up)", "<p data-parsoid='{\"dsr\":[0,6,0,0]}'><span 
data-parsoid='{\"stx\":\"html\",\"autoInsertedEnd\":true,\"dsr\":[0,6,6,0]}'></span></p>\n\n<ul
 data-parsoid='{\"dsr\":[8,28,0,0]}'><li data-parsoid='{\"dsr\":[8,24,1,0]}'> 
a<span data-parsoid='{\"stx\":\"html\",\"dsr\":[11,24,6,7]}'></span></li>\n<li 
data-parsoid='{\"dsr\":[25,28,1,0]}'> b</li></ul>\n\n<p 
data-parsoid='{\"dsr\":[30,37,0,0]}'></p>");
-add("html2html", "2. List embedded in a formatting tag", "<p 
data-parsoid='{\"dsr\":[0,15,0,0]}'><small 
data-parsoid='{\"stx\":\"html\",\"dsr\":[0,15,7,8]}'></small></p>\n<pre 
data-parsoid='{\"dsr\":[16,25,1,0]}'><small 
data-parsoid='{\"stx\":\"html\",\"autoInsertedEnd\":true,\"dsr\":[17,25,7,0]}'></small></pre><small
 
data-parsoid='{\"stx\":\"html\",\"autoInsertedStart\":true,\"dsr\":[25,37,0,8]}'><ul
 data-parsoid='{\"dsr\":[25,28,0,0]}'><li data-parsoid='{\"dsr\":[25,28,1,0]}'> 
a</li></ul>\n</small>\n<ul data-parsoid='{\"dsr\":[38,56,0,0]}'><li 
data-parsoid='{\"dsr\":[38,56,1,0]}'> <small 
data-parsoid='{\"stx\":\"html\",\"dsr\":[40,56,7,8]}'>b</small></li></ul>\n");
+add("html2html", "2. List embedded in a formatting tag", "<p 
data-parsoid='{\"dsr\":[0,23,0,0]}'><small 
data-parsoid='{\"stx\":\"html\",\"dsr\":[0,15,7,8]}'></small>\n<small 
data-parsoid='{\"stx\":\"html\",\"autoInsertedEnd\":true,\"dsr\":[16,23,7,0]}'></small></p><small
 
data-parsoid='{\"stx\":\"html\",\"autoInsertedStart\":true,\"dsr\":[23,36,0,8]}'>\n<ul
 data-parsoid='{\"dsr\":[24,27,0,0]}'><li data-parsoid='{\"dsr\":[24,27,1,0]}'> 
a</li></ul>\n</small>\n<ul data-parsoid='{\"dsr\":[37,55,0,0]}'><li 
data-parsoid='{\"dsr\":[37,55,1,0]}'> <small 
data-parsoid='{\"stx\":\"html\",\"dsr\":[39,55,7,8]}'>b</small></li></ul>\n");
 add("html2html", "Case-sensitive magic words, when cased differently, should 
just be template transclusions", "<p 
data-parsoid='{\"dsr\":[0,331,0,0]}'>[/index.php?title=Template:CurrentMonth&amp;action=edit&amp;redlink=1
 
Template:CurrentMonth]\n[/index.php?title=Template:Currentday&amp;action=edit&amp;redlink=1
 
Template:Currentday]\n[/index.php?title=Template:CURreNTweEK&amp;action=edit&amp;redlink=1
 
Template:CURreNTweEK]\n[/index.php?title=Template:CurrentHour&amp;action=edit&amp;redlink=1
 Template:CurrentHour]</p>\n");
 add("html2html", "Nonexistent template", "<p 
data-parsoid='{\"dsr\":[0,108,0,0]}'>[/index.php?title=Template:Thistemplatedoesnotexist&amp;action=edit&amp;redlink=1
 Template:Thistemplatedoesnotexist]</p>\n");
 add("html2html", "Template with invalid target containing wikilink", "<p 
data-parsoid='{\"dsr\":[0,17,0,0]}'>{{<a rel=\"mw:WikiLink\" 
href=\"./Main_Page\" title=\"Main Page\" 
data-parsoid='{\"stx\":\"simple\",\"a\":{\"href\":\"./Main_Page\"},\"sa\":{\"href\":\"Main
 Page\"},\"dsr\":[2,15,2,2]}'>Main Page</a>}}</p>\n");
@@ -850,7 +850,7 @@
 add("html2wt", "Unbalanced closing block tags break a list\n(php parser relies 
on Tidy to fix up)", "<div>\n\n* a\n\n</div>\n<div>\n\n* b\n\n</div>");
 add("html2wt", "Unbalanced closing non-block tags don't break a list\n(php 
parser relies on Tidy to fix up)", "<span>\n\n* a<span></span>\n* 
b\n\n</span>");
 add("html2wt", "1. List embedded in a formatting tag", "<small>\n\n* 
foo\n\n</small>");
-add("html2wt", "2. List embedded in a formatting tag", "<small></small>\n 
<small>\n* a\n</small>\n* <small>b</small>\n");
+add("html2wt", "2. List embedded in a formatting tag", 
"<small></small>\n<small>\n* a\n</small>\n* <small>b</small>\n");
 add("html2wt", "Magic Word: {{CURRENTDAY}}", "1\n");
 add("html2wt", "Magic Word: {{CURRENTDAY2}}", "01\n");
 add("html2wt", "Magic Word: {{CURRENTDAYNAME}}", "Thursday\n");

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

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