# 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 |style="color:red;"|Foo !! endarticle !! article Template:table_attribs_2 !! text |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 |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 ### ### Table tests ### some content taken from http://meta.wikimedia.org/wiki/MediaWiki_User%27s_Guide:_Using_tables ### # This should not produce
as
# 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
!! end !! test A table with no data (take 2) !! wikitext {| |} !! html/php
!! html/parsoid
!! end !! test A table with no data generated by a markup !! wikitext
!! html/php
!! html/parsoid
!! 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 {| |} !! html/php
!! html/parsoid
!! 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
foo
foo
foo
!! html/parsoid
foo
foo
foo
!! end # A table with nothing but a caption is invalid XHTML, we might want to render # this as

caption

# Parsoid team replies: table with only a caption is legal in HTML5 !! test A table with nothing but a caption !! wikitext {| |+caption |} !! html/php
caption
!! html/parsoid
caption
!! end !! test A table with caption with default-spaced attributes and a table row !! wikitext {| |+ style="color: red;" |caption1 |- |foo |} !! html
caption1
foo
!! 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
caption2 caption3
foo
!! end !! test Multi-line captions in tables !! wikitext {| |+line 1 of caption line 2 of caption |data |} !! html
line 1 of caption line 2 of caption
data
!! 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
baz foo bar foo baz baz style='color:red;' baz
!! end !! test Simple table !! wikitext {| |1||2 |- |3||4 |} !! html
1 2
3 4
!! end ## T387922 !! test Row-syntax table cells require that the row start with a table cell !! wikitext {| |a b||c |} !! html
a

b||c

!! end !! test Simple table but with multiple dashes for row wikitext !! wikitext {| |foo |----- |bar |} !! html
foo
bar
!! end !! test Multiplication table !! wikitext {| border="1" cellpadding="2" |+Multiplication table |- !×!!1!!2!!3 |- !1 |1||2||3 |- !2 |2||4||6 |- !3 |3||6||9 |- !4 |4||8||12 |- !5 |5||10||15 |} !! html
Multiplication table
× 1 2 3
1 1 2 3
2 2 4 6
3 3 6 9
4 4 8 12
5 5 10 15
!! end !! test Accept "||" in table headings !! wikitext {| !h1||h2 |} !! html
h1 h2
!! end !! test Accept "!!" in table data !! wikitext {| |Foo!!|| |} !! html
Foo!!
!! html/parsoid
Foo!!
!! end !! test Accept "||" in indented table headings !! wikitext :{| !h1||h2 |} !! html
h1 h2
!! end !! test Accept "!!" in templates !! wikitext {| !a {{1x|b!!c}} |} !! html/php
a b c
!! html/parsoid
a bc
!! end !! test Accept "!!" in table headings after newline !! wikitext {| !a b!!c |} !! html/php
a

b!!c

!! html/parsoid
a

b!!c

!! end !! test Accept "!!" in table data of mixed wikitext / html syntax !! wikitext {| !a b!!c |} !! html/php
a
b!!c
!! html/parsoid
a
b!!c
!! end !! test Accept empty attributes in td/th cells (td/th cells starting with leading ||) !! wikitext {| !|h1 ||a |} !! html
h1 a
!! end !!test Accept "| !" at start of line in tables (ignore !-attribute) !! wikitext {| |- |!style="color:red"|bar |} !! html
bar
!!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
+1 -1
1 2 3 1 +2 -3
+1 -1
!!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
Cell 1, row 1 Cell 2, row 1 (and 2) Cell 3, row 1
Cell 1, row 2 Cell 3, row 2
!! html/parsoid
Cell 1, row 1 Cell 2, row 1 (and 2) Cell 3, row 1
Cell 1, row 2 Cell 3, row 2
!! end !! test Nested table !! wikitext {| border=1 | α | {| bgcolor=#ABCDEF border=2 |nested |- |table |} |the original table again |} !! html
α
nested
table
the original table again
!! end !! test Invalid attributes in table cell (T3830) !! wikitext {| |Cell:|broken |} !! html
broken
!! end !! test Table cell attributes: Pipes protected by nowikis should be treated as a plain character !! wikitext {| |title="foo" |bar |title="foo|" |bar |title="foo|" bar |} !! html/php
bar bar title="foo|" bar
!! html/parsoid
bar bar title="foo|" bar
!! end !! test Table cell attributes: Pipes protected by nested nowikis should be treated as a plain character !! wikitext {| |{{ACB|PG}} |} !! html/php
{{ACB|PG}}
!! html/parsoid
{{ACB|PG}}
!! 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
[ftp://%7Cx ]" onmouseover="alert(document.cookie)">test
!! html/parsoid
[ftp://%7Cx]" onmouseover="alert(document.cookie)">test
!! end !! test Element attributes with double ! should not be broken up by !! wikitext {| !hi
ha
ho |} !! html/php
hi
ha
ho
!! html/parsoid
hi
ha
ho
!! end !! test ! and || in element attributes should not be parsed as / !! wikitext {| |
hi
|} !! html/php
hi
!! html/parsoid
hi
!! end # FIXME: The output seems broken. Filed as T110268. !! test ! and || in td attributes should not be parsed as / !! options parsoid=wt2html !! wikitext {| |style="color: red !important;" data-contrived="put this here ||"|foo |} !! html/php
style="color: red !important;" data-contrived="put this here foo
!! html/parsoid
style="color: red !important;" data-contrived="put this herefoo
!! 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 {| boo style='border:1px solid black' | boo style='color:blue' |1 |boo style='color:blue'|2 |} !! html/php
1 2
!! html/parsoid
1 2
!! 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 {| boo style='border:1px solid black' | boo style='color:blue' | 1 |boo style='color:blue'| 2 |} !! wikitext/edited {| boo style='border:1px solid black' | boo style='color:blue' | abc |boo style='color:blue'| xyz |} !! end !! test 1. Template-generated table cell attributes and cell content !! wikitext {| |{{table_attribs}} | {{table_attribs}} || {{table_attribs_5}} | {{table_attribs}} |align=center {{table_attribs}} | align=center {{table_attribs}} |} !! html
Foo Foo style="color:red;" Bar Foo Foo Foo
!! 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
Foo Bar Baz
!! html/parsoid
FooBarBaz
!! end !! test 2b: Delete whitespace/comments if found in fosterable position while template-wrapping !! options !! wikitext {{1x|}}
hiho hiho
!! html/parsoid
hi hohi ho
!! end !! test 3. Template-generated table cell attributes and cell content !! wikitext {| !align=center {{table_header_cells}} |- |align=center {{table_cells}} |} !! html/php
Foo Bar Foo and Baz
Foo Bar Foo and Baz
!! html/parsoid
FooBarFoo and Baz
FooBarFoo and Baz
!! 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
Foo Bar Foo and Baz
Foo Bar Foo and Baz
!! html/parsoid
FooBarFoo and Baz
FooBarFoo and Baz
!! end !! test Table with row followed by newlines and table heading !! options parsoid=wt2html,html2html !! wikitext {| |- !foo |} !! html/*
foo
!! end !! test Table with empty line following the start tag !! options parsoid=wt2html,html2html !! wikitext {| |- |foo |} !! html/*
foo
!! end !! test Table attributes with empty value !! options parsoid=wt2html,html2html !! wikitext {| | style=|hello |} !! html/php
hello
!! html/parsoid
hello
!! end !! test Wikitext table with a lot of comments !! wikitext {| |foo |- | |} !! html
foo
!! end !! test Wikitext table comments represented in parsoid dom !! wikitext {| |- |x |} !! html/php
x
!! html/parsoid
x
!! end !! test Wikitext table with double-line table cell !! wikitext {| |a b |} !! html
a

b

!! end !! test Table cell with a single comment !! wikitext {| | |a |} !! html
a
!! end !! test Table-cell after a comment-only-empty-line !! wikitext {| |a |b |} !! html
a b
!! html/parsoid
a b
!! end !! test Build table with {{!}} !! wikitext {{{!}} class="wikitable" !header !second header {{!}}- style="color:red;" {{!}}data{{!}}{{!}} style="color:red;" {{!}}second data {{!}}} !! html
header second header
data second data
!! 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
header second header
data second data
data with | second data with |
data with | second data with |
!! 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
header second header
data linktext second data linktext
data second data link|text with pipe
!! 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 {| |- foo |} !! html/parsoid
foo
!! end ## Remex doesn't account for fostered content. !! test Fostered content in tables: Plain text !! options parsoid=wt2html !! wikitext {| |- a |} !! html/php a
!! html/parsoid

a

!! 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
!! html/parsoid
!! end !! test Template generated table cell with attributes !! wikitext {| |- {{table_attribs_4}} ||a||b |} !! html/php
a b
!! html/parsoid
ab
!! 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=}} |} !! html/php
foo /* th & th combine */
foo /* td & td combine */
foo /* th & td combine */
foo /* td & th combine */
foo
foo
!! html/parsoid+standalone
foo /* th & th combine */
foo /* td & td combine */
foo /* th & td combine */
foo /* td & th combine */
foo
foo
!! html/parsoid+integrated
foo /* th & th combine */
foo /* td & td combine */
foo /* th & td combine */
foo /* td & th combine */
foo
foo
!! end # Standalone test generates the right output as well but the attribute order # is flipped and the test runner doesn't normalize output for attribute order. !! 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
foo
foo
!! html/parsoid+integrated
foo
foo
!! end !! test Templated table cell with untemplated attributes: Regression tests !! wikitext {| |class="foo" {{1x|1={{!}}bar}} |} !! html/php
class="foo" bar
!! html/parsoid
class="foo" bar
!! 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= {{!}}bar}} |} !! html/php
bar
bar
!! 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
bar
bar
!! end !! test Templated table cell with untemplated attributes !! options parsoid=wt2html !! wikitext {| |- |class="foo"{{1x|1={{!}}title="fail"{{!}}bar}} |} !! html/php
title="fail"|bar
!! html/parsoid
title="fail"|bar
!! end !! test Parsoid: Round-trip tables directly followed by content (T53219) !! options parsoid=wt2html,wt2wt !! wikitext {| |foo |} bar {| |baz |}quux !! html/php
foo

bar

baz

quux

!! html/parsoid
foo

bar

baz

quux

!! end !! test Parsoid: Default to a newline after tables in new content (T53219) !! options parsoid=html2wt !! html/parsoid
foo
bar
baz
quux !! wikitext {| |foo |} bar {| |baz |} '''quux''' !! end !! test Parsoid: Row-syntax table headings followed by comment & table cells !! options parsoid=wt2html,wt2wt !! wikitext {| !foo||bar ||baz||quux |} !! html/php
foo bar baz quux
!! html/parsoid
foobar baz quux
!! end !!test Parsoid: Recover better from broken table attributes !!options parsoid=wt2html !!wikitext {| class="foo | class="bar" | foo |} !!html/php

foo

!!html/parsoid

foo

!!end # Note: PHP parser omits empty rows !! test Tables: Digest broken attributes on table and tr tag !! options parsoid=wt2html !! wikitext {| || |} ++ |- || || ++ -- |- > [ |} !! html/php
!! html/parsoid
!! end !! test Table with missing opening tag !! options parsoid=wt2html,wt2wt !! wikitext
foo
!! html
foo
!! end # T137406: Whitespace in the HTML !! test 1. Generate correct wikitext for tables with thead/tbody/tfoot !! options parsoid=html2wt !! html/parsoid
Test
Month Savings
January $100
February $80
Sum $180
!! wikitext {| |+Test !Month !Savings |- |January |$100 |- |February |$80 |- |Sum |$180 |} !! html/php
Test
Month Savings
January $100
February $80
Sum $180
!! end # T137406: No whitespace in the HTML !! test 2. Generate correct wikitext for tables with thead/tbody/tfoot !! options parsoid=html2wt !! html/parsoid
heading
foo
!! wikitext {| !heading |- |foo |} !! end !! test Wikitext tables can be nested inside HTML tables !! options parsoid=html2wt !! html/parsoid
foo
!! wikitext
{| |foo |}
!! html/php
foo
!! 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", "Eau"] ] } !! wikitext {| |[[Eau]] |} !! wikitext/edited {| |[[Eau]] |[[Eau]] |} !! end !! test T319143 - copy-pasting of cells, after !! options parsoid={ "modes": [ "selser" ], "changes": [ ["td", "after", "Eau"] ] } !! 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", "Eau"] ] } !! 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", "Eau"] ] } !! 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", "Eau"] ] } !! 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", "Eau"] ] } !! 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", "Eau"] ] } !! 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", "Eau"] ] } !! wikitext {| |[[Eau]]||[[Abc]] |} !! wikitext/edited {| |[[Eau]]||[[Abc]] |[[Eau]] |} !! end !! test Spec syntactic differences in parsing of !! compared to || !! options parsoid=wt2html,wt2wt !! wikitext {| !!foo {{1x|!!foo}} !!foo!!bar {{1x|!!foo}}{{1x|!!bar}} |} !! html/php
!foo !foo !foo bar !foo bar
!! html/parsoid+integrated
!foo !foo !foo bar !foo bar
!! end !! test Multiline inline table line in file caption !! wikitext [[File:Foobar.jpg|thumb| {| | asdf |} ]] !! html/php
asdf
!! html/parsoid
asdf
!! end ### ### Parsoid edge case regression tests ### !! test Table lines with multiple newlines, spaces, comments embedded in file caption !! options parsoid=wt2html,wt2wt !! wikitext [[File:Foobar.jpg|thumb| {| |test |}]] !! html/php
test
!! html/parsoid
test
!! end