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

Change subject: (Bug 50771) Add space after bullets for new lists
......................................................................


(Bug 50771) Add space after bullets for new lists

* For prettier wikitext output, this patch adds space after bullets
  for newer lists (only if necessary).

* Added new html2wt test.

* For now, blacklisted lot of failing lists tests in html2wt and
  html2html mode because of the extra space (and where all php html
  looks like new html to parsoid during serialization).  Better to

* TODO: Fix our html test output normalization to be smarter about when
  to fail html2html tests.

Change-Id: I04d3b2f505d944aa3980ba7e715e39ba48787419
---
M js/lib/mediawiki.WikitextSerializer.js
M js/tests/parserTests-blacklist.js
M js/tests/parserTests.txt
3 files changed, 99 insertions(+), 2 deletions(-)

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



diff --git a/js/lib/mediawiki.WikitextSerializer.js 
b/js/lib/mediawiki.WikitextSerializer.js
index fbe92f0..4a56fde 100644
--- a/js/lib/mediawiki.WikitextSerializer.js
+++ b/js/lib/mediawiki.WikitextSerializer.js
@@ -1833,6 +1833,16 @@
                dd: ':'
        }, res = '';
 
+       // For new elements, for prettier wikitext serialization,
+       // emit a space after the last bullet (if required)
+       var space = '';
+       if (DU.isNewElt(node)) {
+               var fc = node.firstChild;
+               if (fc && (!DU.isText(fc) || !fc.nodeValue.match(/^\s/))) {
+                       space = ' ';
+               }
+       }
+
        while (node) {
                var nodeName = node.nodeName.toLowerCase(),
                        dp = node.data.parsoid;
@@ -1846,7 +1856,7 @@
                node = node.parentNode;
        }
 
-       return res;
+       return res + space;
 };
 
 
diff --git a/js/tests/parserTests-blacklist.js 
b/js/tests/parserTests-blacklist.js
index 282af51..d84bf2e 100644
--- a/js/tests/parserTests-blacklist.js
+++ b/js/tests/parserTests-blacklist.js
@@ -706,6 +706,7 @@
 add("html2html", "Italics and bold: other quote tests: (3,2,3,2)");
 add("html2html", "Italics and bold: other quote tests: (3,2,3,3) (parsoid)");
 add("html2html", "Italicized possessive");
+add("html2html", "nowiki 3");
 add("html2html", "Preformatted text");
 add("html2html", "<pre> with attributes (bug 3202)");
 add("html2html", "<pre> with width attribute (bug 3202)");
@@ -719,12 +720,30 @@
 add("html2html", "5. White-space in indent-pre\nNOTE: the white-space char on 
2nd line is significant");
 add("html2html", "HTML-pre: 1. embedded newlines");
 add("html2html", "HTML-pre: 3: other wikitext");
+add("html2html", "Definition list with no space");
+add("html2html", "Definition list with bracketed URL link");
 add("html2html", "Definition list with wikilink containing colon");
 add("html2html", "Definition lists: colon in HTML attribute");
 add("html2html", "Definition lists: self-closed tag");
+add("html2html", "Bug 11748: Literal closing tags");
+add("html2html", "Nested definition lists using html syntax");
+add("html2html", "Definition Lists: No nesting: Multiple dd's");
+add("html2html", "Definition Lists: Indentation: Regular");
+add("html2html", "Definition Lists: Indentation: Missing 1st level");
+add("html2html", "Definition Lists: Indentation: Multi-level indent");
+add("html2html", "Definition Lists: Hacky use to indent tables");
+add("html2html", "Table / list interaction: indented table with lists in table 
contents");
+add("html2html", "Table / list interaction: lists nested in tables nested in 
indented lists");
 add("html2html", "Definition Lists: Nesting: Multi-level (Parsoid only)");
 add("html2html", "Definition Lists: Nesting: Test 2 (Parsoid only)");
 add("html2html", "Definition Lists: Nesting: Test 3 (Parsoid only)");
+add("html2html", "Definition Lists: Nesting: Test 4");
+add("html2html", "Definition Lists: Mixed Lists: Test 4");
+add("html2html", "Definition Lists: Mixed Lists: Test 5");
+add("html2html", "Definition Lists: Mixed Lists: Test 6");
+add("html2html", "Definition Lists: Mixed Lists: Test 9");
+add("html2html", "Definition Lists: Mixed Lists: Test 10");
+add("html2html", "Definition Lists: Mixed Lists: Test 11 (parsoid)");
 add("html2html", "External image");
 add("html2html", "External image from https");
 add("html2html", "External links: Clickable images");
@@ -742,6 +761,7 @@
 add("html2html", "Brackets in urls");
 add("html2html", "IPv6 urls (bug 21261)");
 add("html2html", "Unclosed and unmatched quotes (parsoid)");
+add("html2html", "Accept \"||\" in indented table headings");
 add("html2html", "Table security: embedded pipes 
(http://lists.wikimedia.org/mailman/htdig/wikitech-l/2006-April/022293.html)");
 add("html2html", "Indented table markup mixed with indented pre content 
(proposed in bug 6200)");
 add("html2html", "Plain link, capitalized");
@@ -795,10 +815,22 @@
 add("html2html", "Failing to transform badly formed HTML into correct XHTML");
 add("html2html", "Handling html with a br self-closing tag");
 add("html2html", "Horizontal ruler (should it add that extra space?)");
+add("html2html", "Common list");
+add("html2html", "Numbered list");
+add("html2html", "Mixed list");
+add("html2html", "Nested lists 1");
+add("html2html", "Nested lists 2");
+add("html2html", "Nested lists 3 (first element empty)");
+add("html2html", "Nested lists 4 (first element empty)");
+add("html2html", "1. Lists with start-of-line-transparent tokens before 
bullets: Comments");
+add("html2html", "2. Lists with start-of-line-transparent tokens before 
bullets: Template close");
+add("html2html", "Unbalanced closing block tags break a list\n(Parsoid-only 
since php parser generates broken html -- relies on Tidy to fix up)");
+add("html2html", "Unbalanced closing non-block tags don't break a 
list\n(Parsoid-only since php parser generates broken html -- relies on Tidy to 
fix up)");
 add("html2html", "List embedded in a non-block tag\n(Ugly Parsoid output -- 
worth fixing; Disabled for PHP parser since it relies on Tidy)");
 add("html2html", "List items are not parsed correctly following a <pre> block 
(bug 785)");
 add("html2html", "List interrupted by empty line or heading");
 add("html2html", "Multiple list tags generated by templates");
+add("html2html", "Single-comment whitespace lines dont break lists, but 
multi-comment whitespace lines do");
 add("html2html", "Case-sensitive magic words, when cased differently, should 
just be template transclusions");
 add("html2html", "Magic links: internal link to RFC (bug 479)");
 add("html2html", "Magic links: ISBN (bug 1937)");
@@ -993,6 +1025,14 @@
 add("html2html", "Sanitizer: Validating the contents of the id attribute (bug 
4515)");
 add("html2html", "Sanitizer: Validating id attribute uniqueness (bug 4515, bug 
6301)");
 add("html2html", "Sanitizer: Validating that <meta> and <link> work, but only 
for Microdata");
+add("html2html", "HTML bullet list, closed tags (bug 5497)");
+add("html2html", "HTML bullet list, unclosed tags (bug 5497)");
+add("html2html", "HTML ordered list, closed tags (bug 5497)");
+add("html2html", "HTML ordered list, unclosed tags (bug 5497)");
+add("html2html", "HTML nested bullet list, closed tags (bug 5497)");
+add("html2html", "HTML nested bullet list, open tags (bug 5497)");
+add("html2html", "HTML nested ordered list, closed tags (bug 5497)");
+add("html2html", "HTML nested ordered list, open tags (bug 5497)");
 add("html2html", "HTML ordered list item with parameters oddity");
 add("html2html", "Fuzz testing: Parser14");
 add("html2html", "Fuzz testing: Parser14-table");
@@ -1069,6 +1109,7 @@
 add("html2html", "Parents of subpages, one level up, not named");
 add("html2html", "Parents of subpages, two levels up");
 add("html2html", "Parents of subpages, two levels up, with lots of extra 
trailing slashes.");
+add("html2html", "Definition list code coverage");
 add("html2html", "RAW magic word");
 add("html2html", "Inclusion of !userCanEdit() content");
 add("html2html", "Out-of-order TOC heading levels");
@@ -1149,6 +1190,11 @@
 add("html2html", "Headings: 6b. Heading chars in SOL context (with trailing 
newlines)");
 add("html2html", "Headings: 6c. Heading chars in SOL context (leading newline 
break)");
 add("html2html", "Headings: 6d. Heading chars in SOL context (with 
interspersed comments)");
+add("html2html", "Lists: 1. Nested inside html");
+add("html2html", "Lists: 2. Inside definition lists");
+add("html2html", "Lists: 3. Only bullets at start of text should be escaped");
+add("html2html", "Lists: 4. No escapes needed");
+add("html2html", "Lists: 5. No unnecessary escapes");
 add("html2html", "Links 1. Quote marks in link text");
 add("html2html", "Links 2. WikiLinks: Escapes needed");
 add("html2html", "Links 3. WikiLinks: No escapes needed");
@@ -1259,13 +1305,20 @@
 add("html2wt", "Definition and unordered list using wiki syntax nested in 
unordered list using html tags.");
 add("html2wt", "\nDefinition list with empty definition and following 
paragraph");
 add("html2wt", "Nested definition lists using html syntax");
+add("html2wt", "Definition Lists: No nesting: Multiple dd's");
+add("html2wt", "Definition Lists: Indentation: Regular");
+add("html2wt", "Definition Lists: Indentation: Missing 1st level");
+add("html2wt", "Definition Lists: Indentation: Multi-level indent");
 add("html2wt", "Definition Lists: Hacky use to indent tables");
 add("html2wt", "Table / list interaction: indented table with lists in table 
contents");
 add("html2wt", "Table / list interaction: lists nested in tables nested in 
indented lists");
 add("html2wt", "Definition Lists: Nesting: Multi-level (Parsoid only)");
 add("html2wt", "Definition Lists: Nesting: Test 2 (Parsoid only)");
 add("html2wt", "Definition Lists: Nesting: Test 3 (Parsoid only)");
+add("html2wt", "Definition Lists: Nesting: Test 4");
 add("html2wt", "Definition Lists: Mixed Lists: Test 4");
+add("html2wt", "Definition Lists: Mixed Lists: Test 5");
+add("html2wt", "Definition Lists: Mixed Lists: Test 6");
 add("html2wt", "Definition Lists: Mixed Lists: Test 9");
 add("html2wt", "Definition Lists: Mixed Lists: Test 10");
 add("html2wt", "Definition Lists: Mixed Lists: Test 11 (parsoid)");
@@ -1413,8 +1466,13 @@
 add("html2wt", "Handling html with a br self-closing tag");
 add("html2wt", "Horizontal ruler (should it add that extra space?)");
 add("html2wt", "Horizontal ruler -- eats additional dashes on the same line");
+add("html2wt", "Common list");
+add("html2wt", "Numbered list");
 add("html2wt", "Mixed list");
+add("html2wt", "Nested lists 1");
+add("html2wt", "Nested lists 2");
 add("html2wt", "Nested lists 3 (first element empty)");
+add("html2wt", "Nested lists 4 (first element empty)");
 add("html2wt", "Nested lists 6 (both elements empty)");
 add("html2wt", "1. Lists with start-of-line-transparent tokens before bullets: 
Comments");
 add("html2wt", "2. Lists with start-of-line-transparent tokens before bullets: 
Template close");
@@ -2051,6 +2109,11 @@
 add("html2wt", "References: 2. references tag with group only outputs 
references from that group");
 add("html2wt", "References: 4. only referenced group should be cleared after 
processing references");
 add("html2wt", "References: 5. ref tags in references should be processed 
while ignoring all other content");
+add("html2wt", "Lists: 1. Nested inside html");
+add("html2wt", "Lists: 2. Inside definition lists");
+add("html2wt", "Lists: 3. Only bullets at start of text should be escaped");
+add("html2wt", "Lists: 4. No escapes needed");
+add("html2wt", "Lists: 5. No unnecessary escapes");
 add("html2wt", "Tables: 1b. No escaping needed");
 add("html2wt", "Tables: 1c. No escaping needed");
 add("html2wt", "Tables: 1d. No escaping needed");
diff --git a/js/tests/parserTests.txt b/js/tests/parserTests.txt
index 47e34c3..eb56e87 100644
--- a/js/tests/parserTests.txt
+++ b/js/tests/parserTests.txt
@@ -16061,8 +16061,15 @@
 </p>
 !!end
 
+# -----------------------------------------------------------------
+# The following section of tests are primarily to spec requirements
+# around serialization of new/edited content.
+#
+# All these tests are marked Parsoid html2wt and html2html only
+# ----------------------------------------------------------------
+
 !! test
-Image: Modifying size of an imge
+Image: Modifying size of an image
 !! options
 parsoid=html2wt
 !! input
@@ -16083,6 +16090,23 @@
 <p>123</p><figure typeof="mw:Image/Thumb" class="mw-halign-right"><a 
href="./File:Wiki.png"><img 
src="http://192.168.142.128/mw/images/thumb/b/bc/Wiki.png/131px-Wiki.png"; 
width="131" height="150" resource="./File:Wiki.png"></a></figure><p>456</p>
 !!end
 
+!! test
+Lists: Add space after bullets
+!! options
+parsoid=html2wt
+!! input
+
+* foo
+* bar
+* <span> baz</span>
+!! result
+<ul>
+<li>foo</li>
+<li> bar</li>
+<li><span> baz</span></li>
+</ul>
+!! end
+
 TODO:
 more images
 more tables

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I04d3b2f505d944aa3980ba7e715e39ba48787419
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry <[email protected]>
Gerrit-Reviewer: GWicke <[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