[MediaWiki-commits] [Gerrit] Bug 51219: Don't require a newline when round-tripping exist... - change (mediawiki...Parsoid)

2013-08-16 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

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(-)

Approvals:
  Subramanya Sastry: Looks good to me, approved
  Cscott: Looks good to me, but someone else must approve
  jenkins-bot: Verified



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
+|}bquux/b
+!! result
+tabletbody
+tr
+tdfoo/td/tr/tbody/table bar
+table
+tbody
+tr
+tdbaz/td/tr/tbody/tablebquux/b
+!! end
+
+!! test
+Parsoid: Default to a newline after tables in new content (bug 51219)
+!! options
+parsoid=html2wt
+!! input
+{|
+|-
+|foo
+|}
+nowiki /nowikibar
+{|
+|-
+|baz
+|}
+'''quux'''
+!! result
+tabletbody
+tr
+tdfoo/td/tr/tbody/table bar
+tabletbody
+tr
+tdbaz/td/tr/tbody/tablebquux/b
+!! end
+
 ###
 ### Internal links
 ###

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I1342601ceedd28d1002f40463e3160ed6714d792
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Parsoid
Gerrit-Branch: master
Gerrit-Owner: GWicke gwi...@wikimedia.org
Gerrit-Reviewer: Cscott canan...@wikimedia.org
Gerrit-Reviewer: Subramanya Sastry ssas...@wikimedia.org
Gerrit-Reviewer: jenkins-bot

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Bug 51219: Don't require a newline when round-tripping exist... - change (mediawiki...Parsoid)

2013-08-15 Thread GWicke (Code Review)
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
+|}bquux/b
+!! result
+tabletbody
+tr
+tdfoo/td/tr/tbody/table bar
+table
+tbody
+tr
+tdbaz/td/tr/tbody/tablebquux/b
+!! end
+
+!! test
+Parsoid: Default to a newline after tables in new content (bug 51219)
+!! options
+parsoid=html2wt
+!! input
+{|
+|-
+|foo
+|}
+nowiki /nowikibar
+{|
+|-
+|baz
+|}
+'''quux'''
+!! result
+tabletbody
+tr
+tdfoo/td/tr/tbody/table bar
+tabletbody
+tr
+tdbaz/td/tr/tbody/tablebquux/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 gwi...@wikimedia.org

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits