# This file will hold tests for table fixup dom handlers. # For now, we are only adding tests for unsupported scenarios here. # Eventually, once the monolithic parser test file is split up, # all table fixup tests will move here. !! options version=2 parsoid-compatible=wt2html,wt2wt !! end !! article Main Page !! text blah blah !! endarticle !! article Template:1x !! text {{{1}}} !! endarticle !! article Template:td_class !! text class="foo" !! endarticle !! article Template:td_content !! text | foobar !! endarticle !! article Template:td_attrs_and_content !! text {{{1}}} | foobar !! endarticle !! article Template:td_attrs_and_content_with_newlines !! text class="foo" | foobar baz !! endarticle !! article No Merging Here !! text Dummy article to suppress redlinks in tests !! end ## This fixup requires reaching across a boundary to ## merge a child of with a node. ## We won't likely support this unless this is really necessary. !! test Unsupported scenario: Cell combining with captions !! options parsoid=wt2html !! wikitext {| |+class="foo"{{1x|{{!}}some caption}} |bar |} !! html/php
some caption
bar
!! html/parsoid
class="foo"
some caption bar
!! end !! test Unsupported scenario: Templated cell merge with another templated cell !! options parsoid=wt2html !! wikitext {| |{{1x|1=class="foo"}}{{1x|{{!}}foo}} |} !! html/php
foo
!! html/parsoid
foo
!! end ## FIXME:Same as "6. table-fixups td-td cell-combining: prev=single_pipe,attrs,no_content; cell=attrs" ## This test fails in standalone mode and hence marked +integrated only !! test Templated cell with attributes merging with previous cell !! options parsoid=wt2html !! wikitext {| |class="foo"{{1x|1={{!}}title="foo"{{!}}foo}} |} !! html/php
title="foo"|foo
!! html/parsoid+integrated
title="foo"|foo
!! end ## FIXME:Same as "7. table-fixups td-td cell-combining: prev=single_pipe,attrs,content; cell=no_attrs" !! test Templated cell merging with previous cell with attributes !! wikitext {| |class="foo"|title="foo"{{1x|{{!}}foo}} |} !! html/php
title="foo"|foo
!! html/parsoid
title="foo"|foo
!! end ## FIXME:Same as "1. table-fixups td-td cell-combining: prev=single_pipe,no_attrs,no_content; cell=no_attrs" !! test Merge tds (T52603) !! wikitext {| |{{1x|{{!}} foo}} |} !! html/php
foo
!! html/parsoid
foo
!! end !! test Merge tds in nested transclusion content (T52603) !! wikitext {{1x|
}} {| |{{1x|{{!}} foo}} |} {{1x|
}} !! html/php
foo
!! html/parsoid
foo
!! end !! test Table cell attributes and content from multiple templates !! wikitext {| |- | {{td_class}} {{td_attrs_and_content|1=style='border:1px solid blue'}} baz |} !! html/php
foobar baz
!! html/parsoid
foobar baz
!! end !! test Table cell attribute merging edge cases !! config wgParserEnableLegacyMediaDOM=false !! wikitext {| | {{td_attrs_and_content|1=
foo
class="foo"}} baz |- |{{td_attrs_and_content|1=[[No Merging Here]] class="foo"}} baz |- |{{td_attrs_and_content|1=[[wikipedia:No Merging Here]] class="foo"}} baz |- |{{td_attrs_and_content|1=[[en:No Merging Here]] class="foo"}} baz |- |{{td_attrs_and_content|1=[[Category:No Merging Here]] class="foo"}} baz |- |{{td_attrs_and_content|1=[[File:Foo.jpg]] class="foo"}} baz |} !! html/php
foobar baz
No Merging Here class="foo" | foobar baz
wikipedia:No Merging Here class="foo" | foobar baz
class="foo" | foobar baz
class="foo" | foobar baz
File:Foo.jpg class="foo" | foobar baz
!! html/parsoid
foobar baz
No Merging Here class="foo" | foobar baz
wikipedia:No Merging Here class="foo" | foobar baz
class="foo" | foobar baz
class="foo" | foobar baz
File:Foo.jpg class="foo" | foobar baz
!! end !! test Fixup of interrupted table-cell parsing because of multi-line transclusion !! wikitext {| ! class="c1" |Col 1.1!! class="c2" |{{1x| 1=Col 1.2}}!! class="c3" |Col 1.3!! class="c4" |Col 1.4 ! class="d1" |Col 2.1!! class="d2" |{{1x| 1=Col 2.2}}!! class="d3" |Col 2.3! abcd!! class="d4" |Col 2.4 | class="e1" |Col 3.1|| class="e2" |{{1x| 1=Col 3.2}}|| class="e3" |Col 3.3| abcd|| class="e4" |Col 3.4 |} !! html/php
Col 1.1 Col 1.2 Col 1.3 Col 1.4 Col 2.1 Col 2.2 Col 2.3! abcd Col 2.4 Col 3.1 Col 3.2 Col 3.3| abcd Col 3.4
!! html/parsoid
Col 1.1Col 1.2Col 1.3Col 1.4 Col 2.1Col 2.2Col 2.3! abcdCol 2.4 Col 3.1Col 3.2Col 3.3| abcdCol 3.4
!! end !! test Ensure newlines in collected attribute doesn't trip up reparsing !! wikitext {| |rowspan="1" {{td_attrs_and_content_with_newlines}} |} !! html/php
foobar
 baz
!! html/parsoid
foobar
 baz 
!! end !! test Ensure a cell with newlines doesn't combine with following cell !! wikitext {| |- | combined-and-lost {{td_content|}} |- |not combined {{td_content|}} |} !! html/php
foobar
not combined foobar
!! html/parsoid
foobar
not combined foobar
!! end !! test Table cell attributes and nested transclusions !! wikitext {| | '''{{td_attrs_and_content|1=style='border:1px solid blue;'}}''' |} !! html/php
foobar
!! html/parsoid
foobar
!! end !! test T331486: Newline entities should be properly handled while fixing up table cells !! wikitext {| |{{td_attrs_and_content|1=title="a b" class="xyz"}} |} !! html/php
foobar
!! html/parsoid
foobar
!! end !! article Template:tdfoo !! text || y !! endarticle # This test currently fails in Parsoid !! test Ensure td-cell-type is switched to th when the first cell in a row is a !! wikitext {| !a||b !c{{tdfoo}} |} !! html/php
a b c y
!! html/parsoid
ab cy
!! end ## --------------------------------------------------------------------- ## Semi-exhaustive list of tests for TableFixups::reparseWithPreviousell ## A bunch of these tests fail standalone mode, but pass integrated mode ## Those tests use html/parsoid+integrated sections only ## --------------------------------------------------------------------- !! test 1. table-fixups td-td cell-combining: prev=single_pipe,no_attrs,no_content; cell=no_attrs !! wikitext {| |{{1x|{{!}}y}} |} !! html/php
y
!! html/parsoid
y
!! end ## In standalone mode, Parsoid fails this test because the template parses as ## two cells instead of a single cell. !! test 2. table-fixups td-td cell-combining: prev=single_pipe,no_attrs,no_content; cell=attrs !! wikitext {| |{{1x|1={{!}}class='x'{{!}}y}} |} !! html/php
class='x'|y
!! html/parsoid+integrated
class='x'|y
!! end !! test 3. table-fixups td-td cell-combining: prev=single_pipe,no_attrs,content; cell=no_attrs !! wikitext {| | b {{1x|{{!}}y}} |} !! html/php
y
!! html/parsoid
y
!! end !! test 4. table-fixups td-td cell-combining: prev=single_pipe,no_attrs,content; cell=attrs !! wikitext {| | b {{1x|1={{!}}class='x'{{!}}y}} |} !! html/php
class='x'|y
!! html/parsoid+integrated !! end !! test 5. table-fixups td-td cell-combining: prev=single_pipe,attrs,no_content; cell=no_attrs !! wikitext {| |title='a'|{{1x|{{!}}y}} |} !! html/php
class='x'|y
title='a' y
!! html/parsoid
title='a'y
!! end !! test 6. table-fixups td-td cell-combining: prev=single_pipe,attrs,no_content; cell=attrs !! wikitext {| |title='a'|{{1x|1={{!}}class='x'{{!}}y}} |} !! html/php
title='a' y
!! html/parsoid+integrated
title='a'y
!! end !! test 7. table-fixups td-td cell-combining: prev=single_pipe,attrs,content; cell=no_attrs !! wikitext {| |title='a'| b {{1x|{{!}}y}} |} !! html/php
b |y
!! html/parsoid
b |y
!! end !! test 8. table-fixups td-td cell-combining: prev=single_pipe,attrs,content; cell=attrs !! wikitext {| |title='a'| b {{1x|1={{!}}class='x'{{!}}y}} |} !! html/php
b |class='x'|y
!! html/parsoid+integrated
b |class='x'|y
!! end !! test 9. table-fixups td-td cell-combining: prev=double_pipe,no_content; cell=no_attrs !! wikitext {| ||{{1x|{{!}}y}} |} !! html/php
y
!! html/parsoid
y
!! end !! test 10. table-fixups td-td cell-combining: prev=double_pipe,no_content; cell=attrs !! wikitext {| ||{{1x|1={{!}}class='x'{{!}}y}} |} !! html/php
y
!! html/parsoid+integrated
y
!! end !! test 11. table-fixups td-td cell-combining: prev=double_pipe,content; cell=no_attrs !! wikitext {| || a {{1x|{{!}}y}} |} !! html/php
a |y
!! html/parsoid
a |y
!! end !! test 12. table-fixups td-td cell-combining: prev=double_pipe,content; cell=attrs !! wikitext {| || a {{1x|1={{!}}class='x'{{!}}y}} |} !! html/php
a |class='x'|y
!! html/parsoid+integrated
a |class='x'|y
!! end ## These are the only interesting th-th combination scenarios that are different from td-td !! test 1. table-fixups th-th cell-combining: cell=no-attrs !! wikitext {| !{{1x|!y}} |} !! html/php
!y
!! html/parsoid
!y
!! end # NOTE: the whitespace in "! class='x'" is important # because "!!class='x'" and ""!! class='x'"" parse differently. # That seems like a bug in legacy (which Parsoid replicates). !! test 2. table-fixups th-th cell-combining: cell=attrs !! wikitext {| !{{1x|1=! class="x"{{!}}y}} |} !! html/php
y
!! html/parsoid+integrated
y
!! end !! test Templated cell not merging with previous cell with attributes and trailing vertical bar !! wikitext {| | class="foo" |content|{{1x|{{!}}foo}} |} !! html/php
content foo
!! html/parsoid
contentfoo
!! end !! test Templated cell not merging with previous cell and trailing vertical bar !! wikitext {| |[[Main Page]] content|{{1x|{{!}}foo}} |} !! html/php
Main Page content foo
!! html/parsoid
Main Page contentfoo
!! end !! test Templated cell not merging with previous cell and trailing vertical bar, attributes and row syntax !! wikitext {| |one||[[two]]||three|{{1x|{{!}}four}} |} !! html/php
one two three four
!! html/parsoid
onetwothreefour
!! end !! test Convert non-plaintext attributes to content !! wikitext {| |test [http://google.com 123]|{{1x|{{!}}four}} |} !! html/php
test 123 four
!! html/parsoid
test 123four
!! end !! test Convert multiple expanded attributes to content !! wikitext {| |{{1x|title}}='a' class='234'|{{1x|{{!}}y}} |title='{{1x|a}}'|{{1x|{{!}}y}} |} !! html/php
title='a' class='234' y title='a' y
!! html/parsoid
title='a' class='234'y title='a'y
!! end !! test Combine with a previous cell that follows fostered content !! options parsoid=wt2html !! wikitext {| {{1x|{{!}}-}} q |{{1x|{{!}}test}} |} !! html/php q
test
!! html/parsoid+integrated

q

test
!! end !! test Pipes in nowikis should suppress table fixups !! options parsoid=wt2html !! wikitext {| |- |foo||||bar |- |{{1x|foo||}}||bar |} !! html/php
foo|| bar
foo|| bar
!! html/parsoid
foo||bar
foo||bar
!! end