# 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_attribs_7
!! text
|style{{=}}"background:#f9f9f9;"|Foo[foo]
!! 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 PHP 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
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
!! html/parsoid
!! 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
!! html/parsoid
!! end
!! test
A table with caption with default-spaced attributes and a table row
!! wikitext
{|
|+ style="color: red;" |caption1
|-
|foo
|}
!! html
!! 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
!! 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
!! end
!! test
Simple table but with multiple dashes for row wikitext
!! wikitext
{|
|foo
|-----
|bar
|}
!! html
!! 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
!! end
!! test
Accept "!!" in table data
!! wikitext
{|
|Foo!!||
|}
!! html
!! html/parsoid
!! end
!! test
Accept "||" in indented table headings
!! wikitext
:{|
!h1||h2
|}
!! html
!! end
!! test
Accept "!!" in templates
!! wikitext
{|
!a {{1x|b!!c}}
|}
!! html/php
!! html/parsoid
!! end
!! test
Accept "!!" in table headings after newline
!! wikitext
{|
!a
b!!c
|}
!! html/php
!! html/parsoid
!! end
!! test
Accept "!!" in table data of mixed wikitext / html syntax
!! wikitext
{|
!a
b!!c |
|}
!! html/php
!! html/parsoid
!! end
!! test
Accept empty attributes in td/th cells (td/th cells starting with leading ||)
!! wikitext
{|
!|h1
||a
|}
!! html
!! end
!!test
Accept "| !" at start of line in tables (ignore !-attribute)
!! wikitext
{|
|-
|!style="color:red"|bar
|}
!! html
!!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
α
|
|
the original table again
|
!! end
!! test
Invalid attributes in table cell (T3830)
!! wikitext
{|
|Cell:|broken
|}
!! html
!! 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
!! html/parsoid
!! end
!! test
Table cell attributes: Pipes protected by nested nowikis should be treated as a plain character
!! wikitext
{|
|{{ACB|PG}}
|}
!! html/php
!! html/parsoid
!! 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
!! html/parsoid
!! end
!! test
! and || in element attributes should not be parsed as | / |
!! wikitext
{|
| hi
|}
!! html/php
!! html/parsoid
!! 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 here | foo |
!! 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
!! html/parsoid
!! 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
!! test
2. Template-generated table cell attributes and cell content
!! wikitext
{|
|{{table_attribs_2}}
|}
!! html/php
!! html/parsoid
!! 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
Foo | Bar | Foo and Baz |
---|
Foo | Bar | Foo 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
Foo | Bar | Foo and Baz |
Foo | Bar | Foo and Baz |
!! end
## Edge case fix to prevent future regressions
!! test
T107652: [s in templates that also generate table cell attributes should be rendered properly
!! wikitext
{|
|{{table_attribs_7}}
|}
!! html/parsoid
!! end
!! test
Table with row followed by newlines and table heading
!! options
parsoid=wt2html,html2html
!! wikitext
{|
|-
!foo
|}
!! html/*
!! end
!! test
Table with empty line following the start tag
!! options
parsoid=wt2html,html2html
!! wikitext
{|
|-
|foo
|}
!! html/*
!! end
!! test
Table attributes with empty value
!! options
parsoid=wt2html,html2html
!! wikitext
{|
| style=|hello
|}
!! html/php
!! html/parsoid
!! end
!! test
Wikitext table with a lot of comments
!! wikitext
{|
|foo
|-
|
|}
!! html
!! end
!! test
Wikitext table comments represented in parsoid dom
!! wikitext
{|
|-
|x
|}
!! html/php
!! html/parsoid
!! end
!! test
Wikitext table with double-line table cell
!! wikitext
{|
|a
b
|}
!! html
!! end
!! test
Table cell with a single comment
!! wikitext
{|
|
|a
|}
!! html
!! end
!! test
Table-cell after a comment-only-empty-line
!! wikitext
{|
|a
|b
|}
!! html
!! html/parsoid
!! 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
!! 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
!! 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
!! html/parsoid
!! 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: Common use cases
!! wikitext
{|
|-
!class="test"{{table_cell_content}} /* th & td combine */
|-
|class="test"{{table_cell_content}} /* td & td combine */
|
|class="test"{{table_cell_content|attr=style='color:red;'}}
|
|class="test"{{table_cell_content|cmt=}}
|}
!! html/php
foo /* th & td combine */
|
foo /* td & td combine */
|
|
foo
|
|
foo
|
!! html/parsoid+standalone
foo /* th & td combine */ |
foo /* td & td combine */ |
|
foo |
|
foo |
!! html/parsoid+integrated
foo /* th & td combine */ |
foo /* td & td combine */ |
|
foo |
|
foo |
!! end
!! test
Templated table cell with untemplated attributes: Regression tests
!! wikitext
{|
|class="foo"
{{1x|1={{!}}bar}}
|}
!! html/php
!! html/parsoid
!! 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
!! 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
!! end
!! test
Templated table cell with untemplated attributes: Unsupported Scenario
!! options
parsoid=wt2html
!! wikitext
{|
|-
|class="foo"{{1x|1={{!}}title="fail"{{!}}bar}}
|}
!! html/php
!! 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
|}quux
!! html/php
bar
quux
!! html/parsoid
bar
quux
!! end
!! test
Parsoid: Default to a newline after tables in new content (T53219)
!! options
parsoid=html2wt
!! html/parsoid
bar
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
!! html/parsoid
!! end
!!test
Parsoid: Recover better from broken table attributes
!!options
parsoid=wt2html
!!wikitext
{| class="foo
| class="bar" |
foo
|}
!!html/php
!!html/parsoid
!!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
!! html
!! 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
!! wikitext
{|
!heading
|-
|foo
|}
!! end
!! test
Wikitext tables can be nested inside HTML tables
!! options
parsoid=html2wt
!! html/parsoid
!! wikitext
!! html/php
!! 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
|