Sync up with Parsoid parserTests.
[lhc/web/wiklou.git] / tests / parser / parserTests.txt
index 6c3841d..bd67258 100644 (file)
@@ -35,7 +35,7 @@
 #
 # You can also set the following parser properties via test options:
 #  wgEnableUploads, wgAllowExternalImages, wgMaxTocLevel,
-#  wgLinkHolderBatchSize, wgRawHtml
+#  wgLinkHolderBatchSize, wgRawHtml, wgInterwikiMagic
 #
 # For testing purposes, temporary articles can created:
 # !!article / NAMESPACE:TITLE / !!text / ARTICLE TEXT / !!endarticle
@@ -6572,13 +6572,15 @@ T107652: <ref>s in templates that also generate table cell attributes should be
 
 !! test
 Table with row followed by newlines and table heading
+!! options
+parsoid=wt2html,html2html
 !! wikitext
 {|
 |-
 
 ! foo
 |}
-!! html
+!! html/*
 <table>
 
 
@@ -6590,13 +6592,15 @@ Table with row followed by newlines and table heading
 
 !! test
 Table with empty line following the start tag
+!! options
+parsoid=wt2html,html2html
 !! wikitext
 {|
 
 |-
 | foo
 |}
-!! html
+!! html/*
 <table>
 
 
@@ -7082,12 +7086,14 @@ parsoid=wt2html
 </tbody></table>
 !! end
 
+# T137406: Whitespace in the HTML
 !! test
-Strip unsupported table tags
+1. Generate correct wikitext for tables with thead/tbody/tfoot
 !! options
 parsoid=html2wt
 !! html/parsoid
 <table>
+<caption>Test</caption>
 <thead>
 <tr>
 <th>Month</th>
@@ -7113,20 +7119,53 @@ parsoid=html2wt
 </table>
 !! wikitext
 {|
-
+|+Test
 !Month
 !Savings
-
+|-
 |January
 |$100
-
 |-
 |February
 |$80
-
+|-
 |Sum
 |$180
+|}
+!! html/php+tidy
+<table>
+<caption>Test</caption>
+<tr>
+<th>Month</th>
+<th>Savings</th>
+</tr>
+<tr>
+<td>January</td>
+<td>$100</td>
+</tr>
+<tr>
+<td>February</td>
+<td>$80</td>
+</tr>
+<tr>
+<td>Sum</td>
+<td>$180</td>
+</tr>
+</table>
+!! end
 
+# T137406: No whitespace in the HTML
+!! test
+2. Generate correct wikitext for tables with thead/tbody/tfoot
+!! options
+parsoid=html2wt
+!! html/parsoid
+<table><thead><tr><th>heading</th></tr></thead><tbody><tr><td>foo</td></tr></tbody></table>
+!! wikitext
+{|
+!heading
+|-
+|foo
 |}
 !! end
 
@@ -7170,6 +7209,129 @@ parsoid={
 |}
 !!end
 
+!! test
+Testing selser after addition of new row before first row (T125419)
+!! options
+parsoid={
+  "modes": ["wt2wt", "selser"],
+  "changes": [
+    [ "tr", "before", "<tr><td>X</td></tr>" ]
+  ]
+}
+!! wikitext
+{|
+|a
+|}
+!! wikitext/edited
+{|
+|X
+|-
+|a
+|}
+!! end
+
+!! test
+Serialize new table rows in a HTML table using HTML tags
+!! options
+parsoid={
+  "modes": ["wt2wt", "selser"],
+  "changes": [
+    [ "tr", "before", "<tr><td>X</td></tr>" ]
+  ]
+}
+!! wikitext
+<table><tr><td>a</td></tr></table>
+!! wikitext/edited
+<table><tr><td>X</td></tr><tr><td>a</td></tr></table>
+!! end
+
+!! test
+Serialize new table cells in a HTML row using HTML tags
+!! options
+parsoid={
+  "modes": ["wt2wt", "selser"],
+  "changes": [
+    [ "td", "before", "<td>X</td>" ]
+  ]
+}
+!! wikitext
+<table><tr><td>a</td></tr></table>
+!! wikitext/edited
+<table><tr><td>X</td><td>a</td></tr></table>
+!! end
+
+!! test
+Wikitext tables can be nested inside HTML tables
+!! options
+parsoid=html2wt
+!! html
+<table data-parsoid='{"stx":"html"}'>
+<tr><td>
+<table>
+<tr><td>foo</td></tr>
+</table>
+</td></tr>
+</table>
+!! wikitext
+<table>
+<tr><td>
+{|
+|foo
+|}
+</td></tr>
+</table>
+!! end
+
+!! test
+Serialize wikitext list items as HTML list items when embedded in a HTML list
+!! options
+parsoid=html2wt
+!! html
+<ul data-parsoid='{"stx": "html"}'>
+<li data-parsoid='{}'>a</li>
+<li>b</li>
+</ul>
+!! wikitext
+<ul>
+<li>a</li>
+<li>b</li>
+</ul>
+!! end
+
+# SSS FIXME: Is this actually a good thing given the
+# odd nested list output that is generated by MW?
+# <ul><li>foo<ul>..</ul></li></ul> instead of
+# <ul><li>foo</li><ul>..</ul></ul>
+!! test
+Wikitext lists can be nested inside HTML lists
+!! options
+parsoid=html2wt
+!! html
+<ul data-parsoid='{"stx": "html"}'>
+<li data-parsoid='{"stx": "html"}'>a
+<ul><li>b</li></ul>
+</li>
+</ul>
+
+<ul data-parsoid='{"stx": "html"}'>
+<li>x
+<ul><li>y</li></ul>
+</li>
+</ul>
+!! wikitext
+<ul>
+<li>a
+* b
+</li>
+</ul>
+
+<ul>
+<li>x
+* y
+</li>
+</ul>
+!! end
+
 ###
 ### Internal links
 ###
@@ -8188,8 +8350,6 @@ parsoid=wt2html,wt2wt,html2html
 
 !! test
 Interlanguage link
-!! options
-parsoid=wt2html,wt2wt,html2html
 !! wikitext
 Blah blah blah
 [[zh:Chinese]]
@@ -8201,6 +8361,7 @@ Blah blah blah
 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
 !! end
 
+## parsoid html2wt will lose the space variations
 !! test
 Interlanguage link with spacing
 !! options
@@ -8218,8 +8379,6 @@ Blah blah blah
 
 !! test
 Double interlanguage link
-!! options
-parsoid=wt2html,wt2wt,html2html
 !! wikitext
 Blah blah blah
 [[es:Spanish]]
@@ -8233,6 +8392,7 @@ Blah blah blah
 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
 !! end
 
+## parsoid html2wt will lose the space variations
 !! test
 Interlanguage link variations
 !! options
@@ -8252,6 +8412,7 @@ Blah blah blah
 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo_bar" />
 !! end
 
+## parsoid html2wt will normalize the space to _
 !! test
 Space and question mark encoding in interlanguage links (T95473)
 !! options
@@ -8312,6 +8473,34 @@ Blah blah blah
 <link rel="mw:PageProp/Language" title="Multilingual" href="http://wikisource.org/wiki/Article"/>
 !! end
 
+## PHP parser tests script needs an update
+## Parsoid html2wt will normalize output to [[:zh:Chinese]]
+!! test
+Language links render as inline links if $wgInterwikiMagic=false
+!! options
+wgInterwikiMagic=false
+parsoid=wt2html,wt2wt,html2html
+!! wikitext
+Blah blah blah
+[[zh:Chinese]]
+!! html/parsoid
+<p>Blah blah blah <a rel="mw:ExtLink" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese">zh:Chinese</a></p>
+!! end
+
+## PHP parser tests script needs an update
+## Parsoid html2wt will normalize output to [[:zh:Chinese]]
+!! test
+Language links render as inline links in the Talk namespace
+!! options
+title=Talk:Foo
+parsoid=wt2html,wt2wt,html2html
+!! wikitext
+Blah blah blah
+[[zh:Chinese]]
+!! html/parsoid
+<p>Blah blah blah <a rel="mw:ExtLink" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese">zh:Chinese</a></p>
+!! end
+
 !! test
 Parsoid-specific test: Wikilinks with &nbsp; should RT properly
 !! options
@@ -9797,7 +9986,7 @@ Magic Word: {{NUMBEROFFILES}}
 !! wikitext
 {{NUMBEROFFILES}}
 !! html
-<p>6
+<p>7
 </p>
 !! end
 
@@ -10866,7 +11055,7 @@ int keyword - non-existing message
 !! wikitext
 {{int:var}}
 !! html
-<p>&lt;var&gt;
+<p>⧼var⧽
 </p>
 !! end
 
@@ -23018,14 +23207,12 @@ Tables: 2c. Nested in td -- no escaping needed
 parsoid=html2wt
 !! html/*
 <table>
-
 <tr>
 <td>foo!!bar
 </td></tr></table>
 
 !! wikitext
 {|
-
 |foo!!bar
 |}
 !! end
@@ -23036,14 +23223,12 @@ Tables: 3a. Nested in th
 parsoid=html2wt
 !! html/*
 <table>
-
 <tr>
 <th>foo!bar
 </th></tr></table>
 
 !! wikitext
 {|
-
 !foo!bar
 |}
 !! end
@@ -23110,7 +23295,6 @@ Tables: 4a. Escape -
 parsoid=html2wt
 !! html/*
 <table>
-
 <tr>
 <th>-bar
 </th></tr>
@@ -23120,9 +23304,7 @@ parsoid=html2wt
 
 !! wikitext
 {|
-
 !-bar
-
 |-
 |<nowiki>-bar</nowiki>
 |}
@@ -23134,7 +23316,6 @@ Tables: 4b. Escape +
 parsoid=html2wt
 !! html/*
 <table>
-
 <tr>
 <th>+bar
 </th></tr>
@@ -23144,9 +23325,7 @@ parsoid=html2wt
 
 !! wikitext
 {|
-
 !+bar
-
 |-
 |<nowiki>+bar</nowiki>
 |}
@@ -26917,6 +27096,21 @@ B <ref group="X" name="b" />
 </references>
 !! end
 
+!! test
+DOMDiff: Edits to content nested in elements with templated attributes should not be lost (T139388)
+!! options
+parsoid={
+  "modes": ["selser"],
+  "changes": [
+    [ "div:first-child", "text", "bar" ]
+  ]
+}
+!! wikitext
+<div style="{{1x|color:red;}}%">foo</div>
+!! wikitext/edited
+<div style="{{1x|color:red;}}%">bar</div>
+!! end
+
 !! test
 Empty LI (T49673)
 !! wikitext
@@ -26927,8 +27121,8 @@ Empty LI (T49673)
 !! html/php+tidy
 <ul>
 <li>a</li>
-<li class="mw-empty-li"></li>
-<li class="mw-empty-li"></li>
+<li class="mw-empty-elt"></li>
+<li class="mw-empty-elt"></li>
 <li>b</li>
 </ul>
 !! end