GWicke has uploaded a new change for review.

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


Change subject: Bug 51219: Don't require a newline when round-tripping existing 
tables
......................................................................

Bug 51219: Don't require a newline when round-tripping existing tables

Check if the table or the following node is modified, and only require a
newline if that is the case. This means that modified or new text content will
no longer trigger a newline, but a new paragraph will. This still won't make a
difference in practice for the default serialization of new text content as
the VE will normally return new text wrapped in paragraphs or other elements.
In any case, serializing text on the same line as a table end tag is safe as
the block-level table tag will suppress paragraph wrapping in the PHP parser.

Also added two Parsoid-only test cases both for round-tripping and new content
serialization behavior.

Change-Id: I1342601ceedd28d1002f40463e3160ed6714d792
---
M js/lib/mediawiki.WikitextSerializer.js
M js/tests/parserTests.txt
2 files changed, 55 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Parsoid 
refs/changes/03/79303/1

diff --git a/js/lib/mediawiki.WikitextSerializer.js 
b/js/lib/mediawiki.WikitextSerializer.js
index 45bcb4d..9839eb5 100644
--- a/js/lib/mediawiki.WikitextSerializer.js
+++ b/js/lib/mediawiki.WikitextSerializer.js
@@ -2235,7 +2235,15 @@
                                        return {min:1, max:2};
                                }
                        },
-                       after: id({min:1, max:2}),
+                       after: function (node, otherNode) {
+                               if (DU.isNewElt(node) ||
+                                               (DU.isElt(otherNode) && 
DU.isNewElt(otherNode)))
+                               {
+                                       return {min:1, max:2};
+                               } else {
+                                       return {min:0, max:2};
+                               }
+                       },
                        firstChild: id({min:1, max:2}),
                        lastChild: id({min:1})
                }
diff --git a/js/tests/parserTests.txt b/js/tests/parserTests.txt
index bf26412..7b187a0 100644
--- a/js/tests/parserTests.txt
+++ b/js/tests/parserTests.txt
@@ -4285,6 +4285,52 @@
 </table>
 !! end
 
+!! test
+Parsoid: Round-trip tables directly followed by content (bug 51219)
+!! options
+parsoid=wt2html,wt2wt
+!! input
+{|
+|foo
+|} bar
+
+{|
+|baz
+|}<b>quux</b>
+!! result
+<table><tbody>
+<tr>
+<td>foo</td></tr></tbody></table> bar
+<table>
+<tbody>
+<tr>
+<td>baz</td></tr></tbody></table><b>quux</b>
+!! end
+
+!! test
+Parsoid: Default to a newline after tables in new content (bug 51219)
+!! options
+parsoid=html2wt
+!! input
+{|
+|-
+|foo
+|}
+<nowiki> </nowiki>bar
+{|
+|-
+|baz
+|}
+'''quux'''
+!! result
+<table><tbody>
+<tr>
+<td>foo</td></tr></tbody></table> bar
+<table><tbody>
+<tr>
+<td>baz</td></tr></tbody></table><b>quux</b>
+!! end
+
 ###
 ### Internal links
 ###

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1342601ceedd28d1002f40463e3160ed6714d792
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Parsoid
Gerrit-Branch: master
Gerrit-Owner: GWicke <[email protected]>

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

Reply via email to