# The parsoid-compatible option below is only relevant when we are running
# parser tests in integrated mode with Parsoid. This option is ignored
# when this test file is run with Parsoid in standalone mode.
!! options
version=2
parsoid-compatible=wt2html,wt2wt
!! end

# This is the standard article assumed to exist.
!! article
Main Page
!! text
blah blah
!! endarticle

!! article
Template:1x
!! text
{{{1}}}
!! endarticle

!! article
Template:tbl-start
!! text
{|
!! endarticle

!! article
Template:tbl-end
!! text
|}
!! endarticle

!! article
Template:table_attribs
!! text
<noinclude>
|</noinclude>style="color:red;"|Foo
!! endarticle

!! article
Template:table_attribs_2
!! text
<noinclude>
|</noinclude>data-sort-value="" style="color:red;"|Foo
|Bar||Baz
!! endarticle

!! article
Template:table_attribs_4
!! text
| style="background-color:#DC241f;" width="10px" |
!! endarticle

!! article
Template:table_attribs_5
!! text
<noinclude>
|</noinclude>style="color:red;"||Bar
!! endarticle

!! article
Template:table_header_cells
!! text
{{table_attribs}}!!style='color:red;'|''Bar''||style='color:brown;'|''Foo'' and Baz
!! endarticle

!! article
Template:table_cells
!! text
{{table_attribs}}||style='color:red;'|''Bar''||style='color:brown;'|''Foo'' and Baz
!! endarticle

!! article
Template:table_cell_content
!! text
{{{attr|}}}{{{cmt|}}}| foo
!! endarticle

## FIXME: Unused right now
!! article
Template:table_cell_content_with_leading_spc
!! text
 | foo
!! endarticle

!! article
Test
!! text
foo
!! end

###
### Parsoid edge case regression tests
###

# This is unlikely to ever be used in any production wikipage
# since it doesn't make any sense embedding tables in links.
# FIXME: Note that the legacy parser and Parsoid differ on this!
!! test
Tables with multiple newlines after individual lines embedded in links
!! options
parsoid=wt2html,wt2wt
!! wikitext
[[Test|
{|

|test
|}]]
!! html/php
<p><a href="/wiki/Test" title="Test">
</a></p><table>

<tbody><tr>
<td>test
</td></tr></tbody></table>
<p class="mw-empty-elt"></p>
!! html/parsoid
<p><a rel="mw:WikiLink" href="./Test" title="Test">
<table>

<tbody><tr data-parsoid='{"autoInsertedStart":true}'><td>test</td></tr>
</tbody></table></a></p>
!! end

###
### Table tests
### some content taken from http://meta.wikimedia.org/wiki/MediaWiki_User%27s_Guide:_Using_tables
###

# This should not produce <table></table> as <table><tr><td></td></tr></table>
# is the bare minimum required by the spec, see:
# https://www.w3.org/TR/xhtml-modularization/dtd_module_defs.html#a_module_Basic_Tables
# Parsoid team replies: empty table tags are legal in HTML5
!! test
A table with no data.
!! options
parsoid=wt2html
!! wikitext
{||}
!! html/php
!! html/parsoid
<table></table>
!! end

!! test
A table with no data (take 2)
!! wikitext
{|
|}
!! html/php
<table>
<tbody><tr><td></td></tr></tbody></table>
!! html/parsoid
<table></table>
!! end

!! test
A table with no data generated by a <table> markup
!! wikitext
<table></table>
!! html/php
<table></table>
!! html/parsoid
<table data-parsoid='{"stx":"html"}'></table>
!! end

# PHP has one more row in the output than Parsoid does: T208619
!! test
Parsoid: Don't paragraph-wrap fosterable content even if table syntax is unbalanced
!! options
parsoid=wt2html
!! wikitext
{|
<td>
<td>
</td>



|}
!! html/php
<table>
<tbody><tr><td>
</td><td>
</td>



</tr><tr><td></td></tr></tbody></table>
!! html/parsoid
<table>

<tbody>
<tr>
<td></td>

<td>
</td></tr>



</tbody></table>
!! end

!! test
A table with stray table end tags on start tag line (wt2html)
!! options
parsoid=wt2html
!! wikitext
{|style="color: red;"|}

{|style="color: red;" |}
|foo
|}

{|style="color: red;"|} id="foo"
|foo
|}

{|style="color: red;" |} id="foo"
|foo
|}
!! html/php
<table style="color: red;">

</table><table style="color: red;">
<tbody><tr>
<td>foo
</td></tr></tbody></table>
<table style="color: red;" id="foo">
<tbody><tr>
<td>foo
</td></tr></tbody></table>
<table style="color: red;" id="foo">
<tbody><tr>
<td>foo
</td></tr></tbody></table>
!! html/parsoid
<table style="color: red;"></table>

<table style="color: red;">
<tbody><tr>
<td>foo</td>
</tr></tbody>
</table>

<table style="color: red;" id="foo">
<tbody><tr>
<td>foo</td>
</tr></tbody>
</table>

<table style="color: red;" id="foo">
<tbody><tr>
<td>foo</td>
</tr></tbody>
</table>
!! end

# A table with nothing but a caption is invalid XHTML, we might want to render
# this as <p>caption</p>
# Parsoid team replies: table with only a caption is legal in HTML5
!! test
A table with nothing but a caption
!! wikitext
{|
|+caption
|}
!! html/php
<table>
<caption>caption
</caption><tbody><tr><td></td></tr></tbody></table>
!! html/parsoid
<table><caption>caption</caption></table>
!! end

!! test
A table with caption with default-spaced attributes and a table row
!! wikitext
{|
|+ style="color: red;" |caption1
|-
|foo
|}
!! html
<table>
<caption style="color: red;">caption1
</caption>
<tbody><tr>
<td>foo
</td></tr></tbody></table>
!! end

!! test
A table with captions with non-default spaced attributes and a table row
!! wikitext
{|
|+style="color: red;"|caption2
|+ style="color: red;"|caption3
|-
|foo
|}
!! html
<table>
<caption style="color: red;">caption2
</caption>
<caption style="color: red;">caption3
</caption>
<tbody><tr>
<td>foo
</td></tr></tbody></table>
!! end

!! test
Table td-cell syntax variations
!! wikitext
{|
|foo bar foo|baz
|foo bar foo||baz
|style='color:red;'|baz
|style='color:red;'||baz
|}
!! html
<table>
<tbody><tr>
<td>baz
</td>
<td>foo bar foo</td>
<td>baz
</td>
<td style="color:red;">baz
</td>
<td>style='color:red;'</td>
<td>baz
</td></tr></tbody></table>
!! end

!! test
Simple table
!! wikitext
{|
|1||2
|-
|3||4
|}
!! html
<table>
<tbody><tr>
<td>1</td>
<td>2
</td></tr>
<tr>
<td>3</td>
<td>4
</td></tr></tbody></table>
!! end

!! test
Simple table but with multiple dashes for row wikitext
!! wikitext
{|
|foo
|-----
|bar
|}
!! html
<table>
<tbody><tr>
<td>foo
</td></tr>
<tr>
<td>bar
</td></tr></tbody></table>
!! end

!! test
Multiplication table
!! wikitext
{| border="1" cellpadding="2"
|+Multiplication table
|-
!&times;!!1!!2!!3
|-
!1
|1||2||3
|-
!2
|2||4||6
|-
!3
|3||6||9
|-
!4
|4||8||12
|-
!5
|5||10||15
|}
!! html
<table border="1" cellpadding="2">
<caption>Multiplication table
</caption>
<tbody><tr>
<th>&#215;</th>
<th>1</th>
<th>2</th>
<th>3
</th></tr>
<tr>
<th>1
</th>
<td>1</td>
<td>2</td>
<td>3
</td></tr>
<tr>
<th>2
</th>
<td>2</td>
<td>4</td>
<td>6
</td></tr>
<tr>
<th>3
</th>
<td>3</td>
<td>6</td>
<td>9
</td></tr>
<tr>
<th>4
</th>
<td>4</td>
<td>8</td>
<td>12
</td></tr>
<tr>
<th>5
</th>
<td>5</td>
<td>10</td>
<td>15
</td></tr></tbody></table>
!! end

!! test
Accept "||" in table headings
!! wikitext
{|
!h1||h2
|}
!! html
<table>
<tbody><tr>
<th>h1</th>
<th>h2
</th></tr></tbody></table>
!! end

!! test
Accept "!!" in table data
!! wikitext
{|
|Foo!!||
|}
!! html
<table>
<tbody><tr>
<td>Foo!!</td>
<td>
</td></tr></tbody></table>
!! html/parsoid
<table>
<tbody><tr data-parsoid='{"autoInsertedStart":true}'><td data-parsoid='{}'> Foo!! </td><td data-parsoid='{"stx":"row"}'></td></tr>
</tbody></table>
!! end

!! test
Accept "||" in indented table headings
!! wikitext
:{|
!h1||h2
|}
!! html
<dl><dd><table>
<tbody><tr>
<th>h1</th>
<th>h2
</th></tr></tbody></table></dd></dl>
!! end

!! test
Accept "!!" in templates
!! wikitext
{|
!a {{1x|b!!c}}
|}
!! html/php
<table>
<tbody><tr>
<th>a b</th>
<th>c
</th></tr></tbody></table>
!! html/parsoid
<table>
<tbody><tr><th typeof="mw:Transclusion" about="#mwt1" data-parsoid='{"pi":[[{"k":"1"}]]}' data-mw='{"parts":["!a ",{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"b!!c"}},"i":0}}]}'>a b</th><th about="#mwt1">c</th></tr>
</tbody></table>
!! end

!! test
Accept "!!" in table headings after newline
!! wikitext
{|
!a
b!!c
|}
!! html/php
<table>
<tbody><tr>
<th>a
<p>b!!c
</p>
</th></tr></tbody></table>
!! html/parsoid
<table>
<tbody><tr><th>a
<p>b!!c</p></th></tr>
</tbody></table>
!! end

!! test
Accept "!!" in table data of mixed wikitext / html syntax
!! wikitext
{|
!a
<tr><td>b!!c</td></tr>
|}
!! html/php
<table>
<tbody><tr>
<th>a
</th></tr><tr><td>b!!c</td></tr>
</tbody></table>
!! html/parsoid
<table>
<tbody><tr><th>a</th></tr>
<tr data-parsoid='{"stx":"html"}'><td data-parsoid='{"stx":"html"}'>b!!c</td></tr>
</tbody></table>
!! end

!! test
Accept empty attributes in td/th cells (td/th cells starting with leading ||)
!! wikitext
{|
!|h1
||a
|}
!! html
<table>
<tbody><tr>
<th>h1
</th>
<td>a
</td></tr></tbody></table>
!! end

!!test
Accept "| !" at start of line in tables (ignore !-attribute)
!! wikitext
{|
|-
|!style="color:red"|bar
|}
!! html
<table>

<tbody><tr>
<td>bar
</td></tr></tbody></table>
!!end

!!test
Allow +/- in 2nd and later cells in a row, in 1st cell when td-attrs are present, or in 1st cell when there is a space between "|" and +/- 
!! wikitext
{|
|-
|style='color:red;'|+1
|style='color:blue;'|-1
|-
|1||2||3
|1||+2||-3
|-
| +1
| -1
|}
!! html
<table>

<tbody><tr>
<td style="color:red;">+1
</td>
<td style="color:blue;">-1
</td></tr>
<tr>
<td>1</td>
<td>2</td>
<td>3
</td>
<td>1</td>
<td>+2</td>
<td>-3
</td></tr>
<tr>
<td>+1
</td>
<td>-1
</td></tr></tbody></table>
!!end

# Differences between Parsoid and PHP re: trailing whitespace in a
# table cell.
!! test
Table rowspan
!! wikitext
{| border=1
|Cell 1, row 1
|rowspan=2|Cell 2, row 1 (and 2)
|Cell 3, row 1
|-
|Cell 1, row 2
|Cell 3, row 2
|}
!! html/php
<table border="1">
<tbody><tr>
<td>Cell 1, row 1
</td>
<td rowspan="2">Cell 2, row 1 (and 2)
</td>
<td>Cell 3, row 1
</td></tr>
<tr>
<td>Cell 1, row 2
</td>
<td>Cell 3, row 2
</td></tr></tbody></table>
!! html/parsoid
<table border="1">
<tbody><tr data-parsoid='{"autoInsertedStart":true}'><td>Cell 1, row 1</td>
<td rowspan="2">Cell 2, row 1 (and 2)</td>
<td>Cell 3, row 1</td></tr>
<tr data-parsoid='{"startTagSrc":"|-"}'>
<td>Cell 1, row 2</td>
<td>Cell 3, row 2</td></tr>
</tbody></table>
!! end

!! test
Nested table
!! wikitext
{| border=1
| &alpha;
|
{| bgcolor=#ABCDEF border=2
|nested
|-
|table
|}
|the original table again
|}
!! html
<table border="1">
<tbody><tr>
<td>&#945;
</td>
<td>
<table bgcolor="#ABCDEF" border="2">
<tbody><tr>
<td>nested
</td></tr>
<tr>
<td>table
</td></tr></tbody></table>
</td>
<td>the original table again
</td></tr></tbody></table>
!! end

!! test
Invalid attributes in table cell (T3830)
!! wikitext
{|
|Cell:|broken
|}
!! html
<table>
<tbody><tr>
<td>broken
</td></tr></tbody></table>
!! end

!! test
Table cell attributes: Pipes protected by nowikis should be treated as a plain character
!! wikitext
{|
|title="foo" |bar
|title="foo<nowiki>|</nowiki>" |bar
|title="foo<nowiki>|</nowiki>" bar
|}
!! html/php
<table>
<tbody><tr>
<td title="foo">bar
</td>
<td title="foo&#124;">bar
</td>
<td>title="foo|" bar
</td></tr></tbody></table>
!! html/parsoid
<table>
<tbody><tr><td title="foo">bar</td>
<td title="foo|" about="#mwt3" typeof="mw:ExpandedAttrs" data-parsoid='{"a":{"title":"foo|"},"sa":{"title":"foo&lt;nowiki>|&lt;/nowiki>"}}' data-mw='{"attribs":[[{"txt":"title"},{"html":"foo&lt;span typeof=\"mw:Nowiki\" data-parsoid=&apos;{\"dsr\":[32,50,8,9]}&apos;>|&lt;/span>"}]]}'>bar</td>
<td>title="foo<span typeof="mw:Nowiki">|</span>" bar</td></tr>
</tbody></table>
!! end

!! test
Table cell attributes: Pipes protected by nested nowikis should be treated as a plain character
!! wikitext
{|
|<code><nowiki>{{ACB|PG}}</nowiki></code>
|}
!! html/php
<table>
<tbody><tr>
<td><code>{{ACB|PG}}</code>
</td></tr></tbody></table>
!! html/parsoid
<table>
<tbody><tr><td><code><span typeof="mw:Nowiki">{{ACB|PG}}</span></code></td></tr>
</tbody></table>
!! end

# See: http://lists.wikimedia.org/mailman/htdig/wikitech-l/2006-April/022293.html
# N.B. The "|}" to close the table is missing from the input, so parsoid's
#      *2wt modes will fail.
!! test
Table security: embedded pipes
!! options
parsoid=wt2html,html2html
!! wikitext
{|
| |[ftp://|x||]" onmouseover="alert(document.cookie)">test
!! html/php
<table>
<tbody><tr>
<td>[<a rel="nofollow" class="external free" href="ftp://%7Cx">ftp://%7Cx</a></td>
<td>]" onmouseover="alert(document.cookie)"&gt;test
</td>
</tr>
</tbody></table>
!! html/parsoid
<table><tbody>
<tr>
<td data-parsoid='{"startTagSrc":"| ","attrSepSrc":"|"}'>[<a rel="mw:ExtLink" href="ftp://%7Cx" class="external free" data-parsoid='{"stx":"url","a":{"href":"ftp://%7Cx"},"sa":{"href":"ftp://|x"}}'>ftp://%7Cx</a></td><td data-parsoid='{"stx":"row"}'>]" onmouseover="alert(document.cookie)">test</td></tr></tbody></table>
!! end

!! test
Element attributes with double ! should not be broken up by <th>
!! wikitext
{|
!hi <div class="!!">ha</div> ho
|}
!! html/php
<table>
<tbody><tr>
<th>hi <div class="!!">ha</div> ho
</th></tr></tbody></table>
!! html/parsoid
<table>
<tbody><tr><th>hi <div class="!!" data-parsoid='{"stx":"html"}'>ha</div> ho</th></tr>
</tbody></table>
!! end

!! test
! and || in element attributes should not be parsed as <th>/<td>
!! wikitext
{|
|<div style="color: red !important;" data-contrived="put this here ||">hi</div>
|}
!! html/php
<table>
<tbody><tr>
<td><div style="color: red !important;" data-contrived="put this here &#124;&#124;">hi</div>
</td></tr></tbody></table>
!! html/parsoid
<table>
<tbody><tr><td><div style="color: red !important;" data-contrived="put this here ||" data-parsoid='{"stx":"html"}'>hi</div></td></tr>
</tbody></table>
!! end

# FIXME: The output seems broken. Filed as T110268.
!! test
! and || in td attributes should not be parsed as <th>/<td>
!! options
parsoid=wt2html
!! wikitext
{|
|style="color: red !important;" data-contrived="put this here ||"|foo
|}
!! html/php
<table>
<tbody><tr>
<td>style="color: red !important;" data-contrived="put this here</td>
<td>foo
</td></tr></tbody></table>
!! html/parsoid
<table>
<tbody><tr><td>style="color: red !important;" data-contrived="put this here</td><td data-parsoid='{"stx":"row","a":{"\"":null},"sa":{"\"":""}}'>foo</td></tr>
</tbody></table>
!! end

## We don't support roundtripping of these attributes in Parsoid.
## Selective serialization takes care of preventing dirty diffs.
## But, on edits, we dirty-diff the invalid attribute text.
!! test
Invalid text in table attributes should be discarded
!! options
parsoid=wt2html
!! wikitext
{| <span>boo</span> style='border:1px solid black'
|  <span>boo</span> style='color:blue'  |1
|<span>boo</span> style='color:blue'|2
|}
!! html/php
<table style="border:1px solid black">
<tbody><tr>
<td style="color:blue">1
</td>
<td style="color:blue">2
</td></tr></tbody></table>
!! html/parsoid
<table style="border:1px solid black">
<tr>
<td style="color:blue">1</td>
<td style="color:blue">2</td>
</tr>
</table>
!! end

!! test
Invalid text in table attributes should be preserved by selective serializer
!! options
parsoid={
  "modes": [ "selser" ],
  "changes": [
    ["td:first-child", "text", "abc"],
    ["td + td", "text", "xyz"]
  ]
}
!! wikitext
{| <span>boo</span> style='border:1px solid black'
|  <span>boo</span> style='color:blue'  | 1
|<span>boo</span> style='color:blue'| 2
|}
!! wikitext/edited
{| <span>boo</span> style='border:1px solid black'
|  <span>boo</span> style='color:blue'  | abc
|<span>boo</span> style='color:blue'| xyz
|}
!! end

!! test
1. Template-generated table cell attributes and cell content
!! wikitext
{|
|{{table_attribs}}
| {{table_attribs}}
|| {{table_attribs_5}}
| <!--foo--> <!--bar--> <!--baz--> {{table_attribs}}
|align=center {{table_attribs}}
| <!--foo--> align=center <!--bar--> {{table_attribs}}
|}
!! html
<table>
<tbody><tr>
<td style="color:red;">Foo
</td>
<td style="color:red;">Foo
</td>
<td>style="color:red;"</td>
<td>Bar
</td>
<td style="color:red;">Foo
</td>
<td align="center" style="color:red;">Foo
</td>
<td align="center" style="color:red;">Foo
</td></tr></tbody></table>
!! end

# This test introduces a newline in a fosterable position which tangentially
# tests template-wrapping behavior more explicitly tested by the # next test
# ("2b: Delete ...").
!! test
2a. Template-generated table cell attributes and cell content
!! wikitext
{|
|{{table_attribs_2}}
|}
!! html/php
<table>
<tbody><tr>
<td data-sort-value="" style="color:red;">Foo
</td>
<td>Bar</td>
<td>Baz
</td></tr></tbody></table>
!! html/parsoid
<table>
<tbody><tr><td about="#mwt1" typeof="mw:Transclusion" data-sort-value="" style="color:red;" data-mw='{"parts":["|",{"template":{"target":{"wt":"table_attribs_2","href":"./Template:Table_attribs_2"},"params":{},"i":0}}]}'>Foo</td><td about="#mwt1">Bar</td><td about="#mwt1">Baz</td></tr>
</tbody></table>
!! end

!! test
2b: Delete whitespace/comments if found in fosterable position while template-wrapping
!! options
!! wikitext
<table>
<tr>
<td>hi</td>
{{1x|<td>ho</td>
<!--comment-->
<td>hi</td>}}
<td>ho</td>
</tr>
</table>
!! html/parsoid
<table data-parsoid='{"stx":"html"}'>
<tbody><tr>
<td data-parsoid='{"stx":"html"}'>hi</td>
<td about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"&lt;td>ho&lt;/td>\n&lt;!--comment-->\n&lt;td>hi&lt;/td>"}},"i":0}}]}'>ho</td><td about="#mwt1">hi</td>
<td>ho</td>
</tr>
</tbody></table>
!! end

!! test
3. Template-generated table cell attributes and cell content
!! wikitext
{|
!align=center {{table_header_cells}}
|-
|align=center {{table_cells}}
|}
!! html/php
<table>
<tbody><tr>
<th align="center" style="color:red;">Foo</th>
<th style="color:red;"><i>Bar</i></th>
<th style="color:brown;"><i>Foo</i> and Baz
</th></tr>
<tr>
<td align="center" style="color:red;">Foo</td>
<td style="color:red;"><i>Bar</i></td>
<td style="color:brown;"><i>Foo</i> and Baz
</td></tr></tbody></table>
!! html/parsoid
<table>
<tbody><tr><th align="center" style="color:red;" typeof="mw:Transclusion" about="#mwt1" data-mw='{"parts":["!align=center ",{"template":{"target":{"wt":"table_header_cells","href":"./Template:Table_header_cells"},"params":{},"i":0}}]}'>Foo</th><th about="#mwt1" style="color:red;"><i about="#mwt1">Bar</i></th><th about="#mwt1" style="color:brown;"><i about="#mwt1">Foo</i> and Baz</th></tr><tr>
<td align="center" style="color:red;" typeof="mw:Transclusion" about="#mwt1" data-mw='{"parts":["|align=center ",{"template":{"target":{"wt":"table_cells","href":"./Template:Table_cells"},"params":{},"i":0}}]}'>Foo</td><td about="#mwt1" style="color:red;"><i about="#mwt1">Bar</i></td><td about="#mwt1" style="color:brown;"><i about="#mwt1">Foo</i> and Baz</td></tr>
</tbody></table>
!! end

!! test
4. Template-generated table cell attributes and cell content inside a templated table
!! wikitext
{{tbl-start}}
!align=center {{table_header_cells}}
|-
|align=center {{table_cells}}
{{tbl-end}}
!! html/php
<table>
<tbody><tr>
<th align="center" style="color:red;">Foo</th>
<th style="color:red;"><i>Bar</i></th>
<th style="color:brown;"><i>Foo</i> and Baz
</th></tr>
<tr>
<td align="center" style="color:red;">Foo</td>
<td style="color:red;"><i>Bar</i></td>
<td style="color:brown;"><i>Foo</i> and Baz
</td></tr></tbody></table>
!! html/parsoid
<table about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[],[],[],[]]}' data-mw='{"parts":[{"template":{"target":{"wt":"tbl-start","href":"./Template:Tbl-start"},"params":{},"i":0}},"\n!align=center ",{"template":{"target":{"wt":"table_header_cells","href":"./Template:Table_header_cells"},"params":{},"i":1}},"\n|-\n|align=center ",{"template":{"target":{"wt":"table_cells","href":"./Template:Table_cells"},"params":{},"i":2}},"\n",{"template":{"target":{"wt":"tbl-end","href":"./Template:Tbl-end"},"params":{},"i":3}}]}'>
<tbody><tr><th align="center" style="color:red;">Foo</th><th style="color:red;"><i>Bar</i></th><th style="color:brown;"><i>Foo</i> and Baz</th></tr>
<tr>
<td align="center" style="color:red;">Foo</td><td style="color:red;"><i>Bar</i></td><td style="color:brown;"><i>Foo</i> and Baz</td></tr>
</tbody></table>
!! end

!! test
Table with row followed by newlines and table heading
!! options
parsoid=wt2html,html2html
!! wikitext
{|
|-

!foo
|}
!! html/*
<table>


<tbody><tr>
<th>foo
</th></tr></tbody></table>
!! end

!! test
Table with empty line following the start tag
!! options
parsoid=wt2html,html2html
!! wikitext
{|

|-
|foo
|}
!! html/*
<table>


<tbody><tr>
<td>foo
</td></tr></tbody></table>
!! end

!! test
Table attributes with empty value
!! options
parsoid=wt2html,html2html
!! wikitext
{|
| style=|hello
|}
!! html/php
<table>
<tbody><tr>
<td style="">hello
</td></tr></tbody></table>
!! html/parsoid
<table>
<tbody><tr><td style="">hello</td></tr>
</tbody></table>
!! end

!! test
Wikitext table with a lot of comments
!! wikitext
{|
<!-- c0 -->
|foo
<!-- c1 -->
|-<!-- c2 -->
<!-- c3 -->
|<!-- c4 -->
<!-- c5 -->
|}
!! html
<table>
<tbody><tr>
<td>foo
</td></tr>
<tr>
<td>
</td></tr></tbody></table>
!! end

!! test
Wikitext table comments represented in parsoid dom
!! wikitext
{|<!--c1--><!--c2-->
|-<!--c3-->
|x
|}
!! html/php
<table>

<tbody><tr>
<td>x
</td></tr></tbody></table>
!! html/parsoid
<table><!--c1--><!--c2-->
<tbody><tr data-parsoid='{"startTagSrc":"|-"}'><!--c3-->
<td data-parsoid='{}'>x</td></tr>
</tbody></table>
!! end

!! test
Wikitext table with double-line table cell
!! wikitext
{|
|a
b
|}
!! html
<table>
<tbody><tr>
<td>a
<p>b
</p>
</td></tr></tbody></table>
!! end

!! test
Table cell with a single comment
!! wikitext
{|
|<!-- c1 -->
|a
|}
!! html
<table>
<tbody><tr>
<td>
</td>
<td>a
</td></tr></tbody></table>
!! end

!! test
Table-cell after a comment-only-empty-line
!! wikitext
{|
|a
<!--c1-->
<!--c2-->|b
|}
!! html
<table>
<tbody><tr>
<td>a
</td>
<td>b
</td></tr></tbody></table>
!! html/parsoid
<table>
<tbody><tr data-parsoid='{"autoInsertedStart":true}'><td data-parsoid='{}'>a
<!--c1-->
<!--c2--></td><td data-parsoid='{}'>b</td></tr>
</tbody></table>
!! end

!! test
Build table with {{!}}
!! wikitext
{{{!}} class="wikitable"
!header
!second header
{{!}}- style="color:red;"
{{!}}data{{!}}{{!}} style="color:red;" {{!}}second data
{{!}}}
!! html
<table class="wikitable">
<tbody><tr>
<th>header
</th>
<th>second header
</th></tr>
<tr style="color:red;">
<td>data</td>
<td style="color:red;">second data
</td></tr></tbody></table>
!! end

!! test
Build table with pipe as data
!! wikitext
{| class="wikitable"
!header
!second header
|- style="color:red;"
|data|| style="color:red;" |second data
|-
| style="color:red;" |data with | || style="color:red;" | second data with |
|-
||data with | |||second data with |
|}
!! html
<table class="wikitable">
<tbody><tr>
<th>header
</th>
<th>second header
</th></tr>
<tr style="color:red;">
<td>data</td>
<td style="color:red;">second data
</td></tr>
<tr>
<td style="color:red;">data with |</td>
<td style="color:red;">second data with |
</td></tr>
<tr>
<td>data with |</td>
<td>second data with |
</td></tr></tbody></table>
!! end

!! test
Build table with wikilink
!! wikitext
{| class="wikitable"
!header||second header
|- style="color:red;"
|data [[Main Page|linktext]]||second data [[Main Page|linktext]]
|-
|data||second data [[Main Page|link|text with pipe]]
|}
!! html
<table class="wikitable">
<tbody><tr>
<th>header</th>
<th>second header
</th></tr>
<tr style="color:red;">
<td>data <a href="/wiki/Main_Page" title="Main Page">linktext</a></td>
<td>second data <a href="/wiki/Main_Page" title="Main Page">linktext</a>
</td></tr>
<tr>
<td>data</td>
<td>second data <a href="/wiki/Main_Page" title="Main Page">link|text with pipe</a>
</td></tr></tbody></table>
!! end

# The expected HTML structure in this test is debatable. The PHP parser does
# not parse this kind of table at all. The main focus for Parsoid is on
# round-tripping, so this output is ok for now. TODO: revisit!
!! test
Wikitext table with html-syntax row
!! wikitext
{|
|-
<td>foo</td>
|}
!! html/parsoid
<table>
<tbody>
<tr>
<td>foo</td></tr></tbody></table>
!! end

## Remex doesn't account for fostered content.
!! test
Fostered content in tables: Plain text
!! options
parsoid=wt2html
!! wikitext
{|
|-
a
|}
!! html/php


a
<table></table>
!! html/parsoid
<p data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true}'>
a</p>
<table>
<tbody><tr class="mw-empty-elt" data-parsoid='{"startTagSrc":"|-"}'></tr></tbody></table>
!! end

# selser tests are needed below as a regression test for T233815
# they also demonstrate DSR errors in fostered content (T254412)
!! test
Fostered content in tables: Lists
!! options
parsoid={ "modes": ["wt2html","selser"], "suppressErrors": true }
!! wikitext
{|
|-
*a
*b
|}
!! html/php
<ul><li>a</li>
<li>b</li></ul><table>


</table>
!! html/parsoid
<ul data-parsoid='{"fostered":true,"autoInsertedEnd":true}'><li>a</li><li>b</li></ul><table>
<tbody><tr class="mw-empty-elt" data-parsoid='{"startTagSrc":"|-"}'>

</tr></tbody></table>
!! end

!! test
Template generated table cell with attributes
!! wikitext
{|
|-
{{table_attribs_4}} ||a||b
|}
!! html/php
<table>

<tbody><tr>
<td style="background-color:#DC241f;" width="10px"></td>
<td>a</td>
<td>b
</td></tr></tbody></table>
!! html/parsoid
<table>
<tbody><tr data-parsoid='{"startTagSrc":"|-"}'>
<td style="background-color:#DC241f;" width="10px" about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"table_attribs_4","href":"./Template:Table_attribs_4"},"params":{},"i":0}}," ||a||b"]}'></td><td about="#mwt1">a</td><td about="#mwt1">b</td></tr>
</tbody></table>
!! end

## FIXME: The only difference between the standalone & integrated modes
## is the ordering of attributes. This could perhaps be fixed differently
## in the test runner.
!! test
Templated table cell with untemplated attributes: Cell combination tests
!! wikitext
{|
|-
!class="test"{{table_cell_content|attr=! align=left}} /* th & th combine */
|-
|class="test"{{table_cell_content}} /* td & td combine */
|-
!class="test"{{table_cell_content}} /* th & td combine */
|-
|class="test"{{table_cell_content|attr=! align=left}} /* td & th combine */
|-
|class="test"{{table_cell_content|attr=style='color:red;'}}
|-
|class="test"{{table_cell_content|cmt=<!--bar-->}}
|}
!! html/php
<table>

<tbody><tr>
<th class="test" align="left">foo /* th &amp; th combine */
</th></tr>
<tr>
<td class="test">foo /* td &amp; td combine */
</td></tr>
<tr>
<th class="test">foo /* th &amp; td combine */
</th></tr>
<tr>
<td class="test" align="left">foo /* td &amp; th combine */
</td></tr>
<tr>
<td class="test" style="color:red;">foo
</td></tr>
<tr>
<td class="test">foo
</td></tr></tbody></table>
!! html/parsoid+standalone
<table>
<tbody><tr data-parsoid='{"startTagSrc":"|-"}'>
<th class="test" align="left" typeof="mw:Transclusion" about="#mwt1" data-mw='{"parts":["!class=\"test\"",{"template":{"target":{"wt":"table_cell_content","href":"./Template:Table_cell_content"},"params":{"attr":{"wt":"! align=left"}},"i":0}}," /* th &amp; th combine */"]}'>foo /* th &amp; th combine */</th></tr>
<tr data-parsoid='{"startTagSrc":"|-"}'>
<td class="test" typeof="mw:Transclusion" about="#mwt2" data-mw='{"parts":["|class=\"test\"",{"template":{"target":{"wt":"table_cell_content","href":"./Template:Table_cell_content"},"params":{},"i":0}}," /* td &amp; td combine */"]}'>foo /* td &amp; td combine */</td></tr>
<tr data-parsoid='{"startTagSrc":"|-"}'>
<th class="test" typeof="mw:Transclusion" about="#mwt3" data-mw='{"parts":["!class=\"test\"",{"template":{"target":{"wt":"table_cell_content","href":"./Template:Table_cell_content"},"params":{},"i":0}}," /* th &amp; td combine */"]}'>foo /* th &amp; td combine */</th></tr>
<tr data-parsoid='{"startTagSrc":"|-"}'>
<td class="test" align="left" about="#mwt4" typeof="mw:Transclusion" data-mw='{"parts":["|class=\"test\"",{"template":{"target":{"wt":"table_cell_content","href":"./Template:Table_cell_content"},"params":{"attr":{"wt":"! align=left"}},"i":0}}," /* td &amp; th combine */"]}'>foo /* td &amp; th combine */</td>
<tr data-parsoid='{"startTagSrc":"|-"}'>
<td class="test" style="color:red;" typeof="mw:Transclusion" about="#mwt5" data-parsoid='{"pi":[[{"k":"attr","named":true}]]}' data-mw='{"parts":["|class=\"test\"",{"template":{"target":{"wt":"table_cell_content","href":"./Template:Table_cell_content"},"params":{"attr":{"wt":"style=&apos;color:red;&apos;"}},"i":0}}]}'>foo</td></tr>
<tr data-parsoid='{"startTagSrc":"|-"}'>
<td class="test" typeof="mw:Transclusion" about="#mwt6" data-parsoid='{"pi":[[{"k":"cmt","named":true}]]}' data-mw='{"parts":["|class=\"test\"",{"template":{"target":{"wt":"table_cell_content","href":"./Template:Table_cell_content"},"params":{"cmt":{"wt":"&lt;!--bar-->"}},"i":0}}]}'>foo</td></tr>
</tbody></table>
!! html/parsoid+integrated
<table>
<tbody><tr data-parsoid='{"startTagSrc":"|-"}'>
<th align="left" typeof="mw:Transclusion" class="test" about="#mwt1" data-mw='{"parts":["!class=\"test\"",{"template":{"target":{"wt":"table_cell_content","href":"./Template:Table_cell_content"},"params":{"attr":{"wt":"! align=left"}},"i":0}}," /* th &amp; th combine */"]}'>foo /* th &amp; th combine */</th></tr>
<tr data-parsoid='{"startTagSrc":"|-"}'>
<td typeof="mw:Transclusion" class="test" about="#mwt2" data-mw='{"parts":["|class=\"test\"",{"template":{"target":{"wt":"table_cell_content","href":"./Template:Table_cell_content"},"params":{},"i":0}}," /* td &amp; td combine */"]}'>foo /* td &amp; td combine */</td></tr>
<tr data-parsoid='{"startTagSrc":"|-"}'>
<th typeof="mw:Transclusion" class="test" about="#mwt3" data-mw='{"parts":["!class=\"test\"",{"template":{"target":{"wt":"table_cell_content","href":"./Template:Table_cell_content"},"params":{},"i":0}}," /* th &amp; td combine */"]}'>foo /* th &amp; td combine */</th></tr>
<tr data-parsoid='{"startTagSrc":"|-"}'>
<td align="left" typeof="mw:Transclusion" class="test" about="#mwt4" data-mw='{"parts":["|class=\"test\"",{"template":{"target":{"wt":"table_cell_content","href":"./Template:Table_cell_content"},"params":{"attr":{"wt":"! align=left"}},"i":0}}," /* td &amp; th combine */"]}'>foo /* td &amp; th combine */</td>
<tr data-parsoid='{"startTagSrc":"|-"}'>
<td class="test" style="color:red;" typeof="mw:Transclusion" about="#mwt5" data-parsoid='{"pi":[[{"k":"attr","named":true}]]}' data-mw='{"parts":["|class=\"test\"",{"template":{"target":{"wt":"table_cell_content","href":"./Template:Table_cell_content"},"params":{"attr":{"wt":"style=&apos;color:red;&apos;"}},"i":0}}]}'>foo</td></tr>
<tr data-parsoid='{"startTagSrc":"|-"}'>
<td typeof="mw:Transclusion" class="test" about="#mwt6" data-parsoid='{"pi":[[{"k":"cmt","named":true}]]}' data-mw='{"parts":["|class=\"test\"",{"template":{"target":{"wt":"table_cell_content","href":"./Template:Table_cell_content"},"params":{"cmt":{"wt":"&lt;!--bar-->"}},"i":0}}]}'>foo</td></tr>
</tbody></table>
!! end

# The failure in T343874 is only exercised in integrated mode
!! test
T343874: Templated table that has a templated cell with untemplated attributes
!! options
parsoid=wt2html
!! wikitext
{{tbl-start}}
|-
|class="test"{{table_cell_content}}
|-
|class="test"{{table_cell_content|attr=! align=left}}
{{tbl-end}}
!! html/php
<table>

<tbody><tr>
<td class="test">foo
</td></tr>
<tr>
<td class="test" align="left">foo
</td></tr></tbody></table>
!! html/parsoid+integrated
<table typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"tbl-start","href":"./Template:Tbl-start"},"params":{},"i":0}},"\n|-\n|class=\"test\"",{"template":{"target":{"wt":"table_cell_content","href":"./Template:Table_cell_content"},"params":{},"i":1}},"\n|-\n|class=\"test\"",{"template":{"target":{"wt":"table_cell_content","href":"./Template:Table_cell_content"},"params":{"attr":{"wt":"! align=left"}},"i":2}},"\n",{"template":{"target":{"wt":"tbl-end","href":"./Template:Tbl-end"},"params":{},"i":3}}]}'>
<tbody>
<tr><td class="test">foo</td></tr>
<tr><td align="left" class="test">foo</td></tr>
</tbody></table>
!! end

!! test
Templated table cell with untemplated attributes: Regression tests
!! wikitext
{|
|class="foo"
{{1x|1={{!}}bar}}
|}
!! html/php
<table>
<tbody><tr>
<td>class="foo"
</td>
<td>bar
</td></tr></tbody></table>
!! html/parsoid
<table>
<tbody><tr>
<td>class="foo"</td>
<td about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1","named":true}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"{{!}}bar"}},"i":0}}]}'>bar</td></tr>
</tbody></table>

!! end

!! test
Templated table cell with untemplated attributes: Unsupported (standalone mode) Scenarios
!! options
parsoid=wt2html
!! wikitext
{|
|-
|class="foo"{{1x|1= {{!}}bar}}
|-
|class="foo"{{1x|1=&nbsp;{{!}}bar}}
|}
!! html/php
<table>

<tbody><tr>
<td class="foo">bar
</td></tr>
<tr>
<td class="foo">bar
</td></tr></tbody></table>
!! html/parsoid+standalone
This test fails both the two table cell scenarios for different reasons
because of differences how preprocessing works in standalone mode.
We don't intend to support this here.
!! html/parsoid+integrated
<table>
<tbody><tr>
<td about="#mwt1" typeof="mw:Transclusion" class="foo" data-mw='{"parts":["|class=\"foo\"",{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"{{!}}bar"}},"i":0}}]}'>bar</td></tr>
<tr>
<td class="foo" typeof="mw:Transclusion" about="#mwt2" data-mw='{"parts":["|class=\"foo\"",{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"&amp;nbsp;{{!}}bar"}},"i":0}}]}'>bar</td></tr>
</tbody></table>
!! end

!! test
Templated table cell with untemplated attributes: Unsupported Scenario
!! options
parsoid=wt2html
!! wikitext
{|
|-
|class="foo"{{1x|1={{!}}title="fail"{{!}}bar}}
|}
!! html/php
<table>

<tbody><tr>
<td class="foo">title="fail"|bar
</td></tr></tbody></table>
!! html/parsoid
For now, we are deliberately not supporting this use cases in Parsoid unless
required or we find a simpler solution that covers everything uniformly.
!! end

!! test
Parsoid: Round-trip tables directly followed by content (T53219)
!! options
parsoid=wt2html,wt2wt
!! wikitext
{|
|foo
|} bar

{|
|baz
|}<b>quux</b>
!! html/php
<table>
<tbody><tr>
<td>foo
</td></tr></tbody></table><p> bar
</p><table>
<tbody><tr>
<td>baz
</td></tr></tbody></table><p><b>quux</b></p>
!! html/parsoid
<table>
<tbody><tr data-parsoid='{"autoInsertedStart":true}'><td>foo</td></tr>
</tbody></table><p> bar</p>

<table>
<tbody><tr data-parsoid='{"autoInsertedStart":true}'><td>baz</td></tr>
</tbody></table><p><b data-parsoid='{"stx":"html"}'>quux</b></p>
!! end

!! test
Parsoid: Default to a newline after tables in new content (T53219)
!! options
parsoid=html2wt
!! html/parsoid
<table><tbody>
<tr><td>foo</td></tr></tbody></table> bar
<table><tbody>
<tr><td>baz</td></tr></tbody></table><b>quux</b>
!! wikitext
{|
|foo
|}
bar
{|
|baz
|}
'''quux'''
!! end

!! test
Parsoid: Row-syntax table headings followed by comment & table cells
!! options
parsoid=wt2html,wt2wt
!! wikitext
{|
!foo||bar
<!-- foo -->  ||baz||quux
|}
!! html/php
<table>
<tbody><tr>
<th>foo</th>
<th>bar
</th>
<td>baz</td>
<td>quux
</td></tr></tbody></table>
!! html/parsoid
<table>
<tbody><tr><th>foo</th><th>bar
<!-- foo --></th><td> baz </td><td>quux</td></tr>
</tbody></table>
!! end

!!test
Parsoid: Recover better from broken table attributes
!!options
parsoid=wt2html
!!wikitext
{| class="foo
| class="bar" |
foo
|}
!!html/php
<table class="foo">
<tbody><tr>
<td class="bar">
<p>foo
</p>
</td></tr></tbody></table>
!!html/parsoid
<table class="foo">
<tr>
<td class="bar">
<p>foo</p></td></tr>
</tbody></table>
!!end

# Note: PHP parser omits empty rows
!! test
Tables: Digest broken attributes on table and tr tag
!! options
parsoid=wt2html
!! wikitext
{| || |} ++
|- || || ++ --
|- > [
|}
!! html/php
<table>


</table>
!! html/parsoid
<table>
<tbody>
<tr class='mw-empty-elt'></tr>
<tr class='mw-empty-elt'></tr>
</tbody></table>
!! end

!! test
Table with missing opening <tr> tag
!! options
parsoid=wt2html,wt2wt
!! wikitext
<table>
<td>foo</td>
</tr>
</table>
!! html
<table>
<tbody><tr><td>foo</td>
</tr>
</tbody></table>
!! end

# T137406: Whitespace in the HTML
!! test
1. Generate correct wikitext for tables with thead/tbody/tfoot
!! options
parsoid=html2wt
!! html/parsoid
<table>
<caption>Test</caption>
<thead>
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
</thead>
<tbody>
<tr>
<td>January</td>
<td>$100</td>
</tr>
<tr>
<td>February</td>
<td>$80</td>
</tr>
</tbody>
<tfoot>
<tr>
<td>Sum</td>
<td>$180</td>
</tr>
</tfoot>
</table>
!! wikitext
{|
|+Test
!Month
!Savings
|-
|January
|$100
|-
|February
|$80
|-
|Sum
|$180
|}
!! html/php
<table>
<caption>Test
</caption>
<tbody><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></tbody></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

!! test
Wikitext tables can be nested inside HTML tables
!! options
parsoid=html2wt
!! html/parsoid
<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>
!! html/php
<table>
<tbody><tr><td>
<table>
<tbody><tr>
<td>foo
</td></tr></tbody></table>
</td></tr>
</tbody></table>
!! end

!! article
Eau
!! text
Dummy article to suppress redlinks in tests
!! end

!! test
T319143 - copy-pasting of cells, before
!! options
parsoid={
  "modes": [ "selser" ],
  "changes": [
    ["td", "before", "<td data-parsoid=\"{}\"><a href=\"./Eau\" rel=\"mw:WikiLink\" title=\"Eau\" data-parsoid='{\"stx\":\"simple\",\"a\":{\"href\":\"./Eau\"},\"sa\":{\"href\":\"Eau\"},\"dsr\":[4,11,2,2]}'>Eau</a></td>"]
  ]
}
!! wikitext
{|
|[[Eau]]
|}
!! wikitext/edited
{|
|[[Eau]]
|[[Eau]]
|}
!! end

!! test
T319143 - copy-pasting of cells, after
!! options
parsoid={
  "modes": [ "selser" ],
  "changes": [
    ["td", "after", "<td data-parsoid=\"{}\"><a href=\"./Eau\" rel=\"mw:WikiLink\" title=\"Eau\" data-parsoid='{\"stx\":\"simple\",\"a\":{\"href\":\"./Eau\"},\"sa\":{\"href\":\"Eau\"},\"dsr\":[4,11,2,2]}'>Eau</a></td>"]
  ]
}
!! wikitext
{|
|[[Eau]]
|}
!! wikitext/edited
{|
|[[Eau]]
|[[Eau]]
|}
!! end

!! test
T319143 - copy-pasting of cells, before multiple cells
!! options
parsoid={
  "modes": [ "selser" ],
  "changes": [
    ["td:first-child", "before", "<td data-parsoid='{\"stx\":\"row\"}'><a href=\"./Eau\" rel=\"mw:WikiLink\" title=\"Eau\" data-parsoid='{\"stx\":\"simple\",\"a\":{\"href\":\"./Eau\"},\"sa\":{\"href\":\"Eau\"},\"dsr\":[4,11,2,2]}'>Eau</a></td>"]
  ]
}
!! wikitext
{|
|[[Eau]]||[[Abc]]
|}
!! wikitext/edited
{|
|[[Eau]]
|[[Eau]]||[[Abc]]
|}
!! end

!! test
T319143 - copy-pasting of cells, before multiple cells, without "row"
!! options
parsoid={
  "modes": [ "selser" ],
  "changes": [
    ["td:first-child", "before", "<td data-parsoid='{}'><a href=\"./Eau\" rel=\"mw:WikiLink\" title=\"Eau\" data-parsoid='{\"stx\":\"simple\",\"a\":{\"href\":\"./Eau\"},\"sa\":{\"href\":\"Eau\"},\"dsr\":[4,11,2,2]}'>Eau</a></td>"]
  ]
}
!! wikitext
{|
|[[Eau]]||[[Abc]]
|}
!! wikitext/edited
{|
|[[Eau]]
|[[Eau]]||[[Abc]]
|}
!! end

!! test
T319143 - copy-pasting of cells, between multiple cells
!! options
parsoid={
  "modes": [ "selser" ],
  "changes": [
    ["td:first-child", "after", "<td data-parsoid='{\"stx\":\"row\"}'><a href=\"./Eau\" rel=\"mw:WikiLink\" title=\"Eau\" data-parsoid='{\"stx\":\"simple\",\"a\":{\"href\":\"./Eau\"},\"sa\":{\"href\":\"Eau\"},\"dsr\":[4,11,2,2]}'>Eau</a></td>"]
  ]
}
!! wikitext
{|
|[[Eau]]||[[Abc]]
|}
!! wikitext/edited
{|
|[[Eau]]||[[Eau]]||[[Abc]]
|}
!! end

!! test
T319143 - copy-pasting of cells, between multiple cells, without "row"
!! options
parsoid={
  "modes": [ "selser" ],
  "changes": [
    ["td:first-child", "after", "<td data-parsoid='{}'><a href=\"./Eau\" rel=\"mw:WikiLink\" title=\"Eau\" data-parsoid='{\"stx\":\"simple\",\"a\":{\"href\":\"./Eau\"},\"sa\":{\"href\":\"Eau\"},\"dsr\":[4,11,2,2]}'>Eau</a></td>"]
  ]
}
!! wikitext
{|
|[[Eau]]||[[Abc]]
|}
!! wikitext/edited
{|
|[[Eau]]
|[[Eau]]||[[Abc]]
|}
!! end

!! test
T319143 - copy-pasting of cells, after multiple cells
!! options
parsoid={
  "modes": [ "selser" ],
  "changes": [
    ["td:last-child", "after", "<td data-parsoid='{\"stx\":\"row\"}'><a href=\"./Eau\" rel=\"mw:WikiLink\" title=\"Eau\" data-parsoid='{\"stx\":\"simple\",\"a\":{\"href\":\"./Eau\"},\"sa\":{\"href\":\"Eau\"},\"dsr\":[4,11,2,2]}'>Eau</a></td>"]
  ]
}
!! wikitext
{|
|[[Eau]]||[[Abc]]
|}
!! wikitext/edited
{|
|[[Eau]]||[[Abc]]||[[Eau]]
|}
!! end

!! test
T319143 - copy-pasting of cells, after multiple cells, without "row"
!! options
parsoid={
  "modes": [ "selser" ],
  "changes": [
    ["td:last-child", "after", "<td data-parsoid='{}'><a href=\"./Eau\" rel=\"mw:WikiLink\" title=\"Eau\" data-parsoid='{\"stx\":\"simple\",\"a\":{\"href\":\"./Eau\"},\"sa\":{\"href\":\"Eau\"},\"dsr\":[4,11,2,2]}'>Eau</a></td>"]
  ]
}
!! wikitext
{|
|[[Eau]]||[[Abc]]
|}
!! wikitext/edited
{|
|[[Eau]]||[[Abc]]
|[[Eau]]
|}
!! end

!! test
Spec syntactic differences in parsing of !! compared to ||
!! options
parsoid=wt2html,wt2wt
!! wikitext
{|
<!--cmt-->!!foo
{{1x|!!foo}}
<!--cmt-->!!foo!!bar
{{1x|!!foo}}{{1x|!!bar}}
|}
!! html/php
<table>
<tbody><tr>
<th>!foo
</th>
<th>!foo
</th>
<th>!foo</th>
<th>bar
</th>
<th>!foo</th>
<th>bar
</th></tr></tbody></table>
!! html/parsoid+integrated
<table><!--cmt-->
<tbody>
<tr>
<th>!foo</th>
<th about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"!!foo"}},"i":0}}]}'>!foo</th>
<!--cmt-->
<th>!foo</th>
<th>bar</th>
<th about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"!!foo"}},"i":0}}]}'>!foo</th>
<th about="#mwt3" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"!!bar"}},"i":0}}]}'>bar</th>
</tr>
</tbody>
</table>
!! end
