# 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 !! 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 !! 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:Foobar.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
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
class="foo" | foobar baz
!! 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+integrated
!y
!! html/parsoid+standalone
!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 !! article Template:Multi cell output !! text n2 || n3 || style="background:#9F9;" class="table-yes" | Yes !! endarticle !! article Template:Multi cell output with empty cells !! text a |||| b !! endarticle !! test Template emitting multi-cell output as plain content should be reparsed as multiple cells !! wikitext {| | {{multi cell output}} |} !! html/php
n2 n3 Yes
!! html/parsoid
n2n3Yes
!! end !! test Attribute-suppressing content should not prevent multi-cell output split !! wikitext {| | [[Main Page]] {{multi cell output}} |} !! html/php
Main Page n2 n3 Yes
!! html/parsoid
Main Page n2n3Yes
!! end !! test Empty cells should not prevent multi-cell output split !! wikitext {| | [[Main Page]] {{multi cell output with empty cells}} |} !! html/php
Main Page a b
!! html/parsoid
Main Page ab
!! end