diff options
Diffstat (limited to 'www/wiki/tests/parser/parserTests.txt')
-rw-r--r-- | www/wiki/tests/parser/parserTests.txt | 30829 |
1 files changed, 30829 insertions, 0 deletions
diff --git a/www/wiki/tests/parser/parserTests.txt b/www/wiki/tests/parser/parserTests.txt new file mode 100644 index 00000000..451c50f5 --- /dev/null +++ b/www/wiki/tests/parser/parserTests.txt @@ -0,0 +1,30829 @@ +# MediaWiki Parser test cases +# Some taken from https://meta.wikimedia.org/wiki/Parser_testing +# All (C) their respective authors and released under the GPL +# +# The syntax should be fairly self-explanatory. +# +# Currently supported test options: +# One of the following three: +# +# (default) generate HTML output +# pst apply pre-save transform +# msg apply message transform +# +# Plus any combination of these: +# +# cat add category links +# (ignored by Parsoid, since it emits <link>s) +# ill add inter-language links +# (ignored by Parsoid, since it emits <link>s) +# subpage enable subpages (disabled by default) +# title=[[XXX]] run test using article title XXX +# language=XXX set content language to XXX for this test +# variant=XXX set the variant of language for this test (eg zh-tw) +# disabled do not run test +# parsoid parsoid-specific options (not run by PHP parser unless +# the test includes an html/php section) +# php php-only test (not run by the parsoid parser unless +# the test includes an html/parsoid section) +# showtitle make the first line the title +# showindicators make the first lines the page status indicators +# comment run through Linker::formatComment() instead of main parser +# local format section links in edit comment text as local links +# notoc disable table of contents +# thumbsize=NNN set the default thumb size to NNNpx for this test +# wrap include the normal wrapper <div class="mw-parser-output"> (since 1.30) +# +# You can also set the following parser properties via test options: +# wgEnableUploads, wgAllowExternalImages, wgMaxTocLevel, +# wgLinkHolderBatchSize, wgRawHtml, wgInterwikiMagic, +# wgEnableMagicLinks +# +# For testing purposes, temporary articles can created: +# !!article / NAMESPACE:TITLE / !!text / ARTICLE TEXT / !!endarticle +# where '/' denotes a newline. + +# This is the standard article assumed to exist. +!! article +Main Page +!! text +blah blah +!! endarticle + +!!article +Foo +!!text +FOO +!!endarticle + +!!article +Template:Foo +!!text +FOO +!!endarticle + +!! article +Template:Blank +!! text +!! endarticle + +!! article +Template:pipe +!! text +| +!! endarticle + +!! article +Template:= +!! text +<nowiki>=</nowiki> +!! endarticle + +!!article +MediaWiki:bad image list +!!text +* [[File:Bad.jpg]] except [[Nasty page]] +!!endarticle + +!! article +Template:inner list +!! text +* item 1 +!! endarticle + +!! article +Template:tbl-start +!! text +{| +!! endarticle + +!! article +Template:tbl-end +!! text +|} +!! endarticle + +!! article +Template:echo +!! text +{{{1}}} +!! endarticle + +// For Serbian; localize Template namespace +!! article +Шаблон:Echo +!! text +{{{1}}} +!! endarticle + +!! article +Template:echo_with_span +!! text +<span>{{{1}}}</span> +!! endarticle + +!! article +Template:echo_with_div +!! text +<div>{{{1}}}</div> +!! endarticle + +!! article +Template:blank_param +!! text +{{{1}}} +{{{}}} +!! endarticle + +!! article +Template:table_attribs +!! text +<noinclude> +|</noinclude>style="color:red;"|Foo +!! endarticle + +!! article +Template:table_attribs_2 +!! text +<noinclude> +|</noinclude>style="color:red;"|Foo +|Bar||Baz +!! endarticle + +!! article +Template:table_attribs_3 +!! text +<noinclude> +|</noinclude>style{{=}}"background:#f9f9f9;"|Foo +!! 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_attribs_6 +!! text +style="background: <nowiki> + + +red;</nowiki>" | +!! endarticle + +!! article +Template:table_attribs_7 +!! text +<noinclude> +|</noinclude>style{{=}}"background:#f9f9f9;"|Foo<ref>foo</ref> +!! 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:PartialTable +!! text +{| +|- +!! endarticle + +!! article +Template:image_attribs +!! text +<noinclude> +[[File:foobar.jpg|</noinclude>right|Caption text<noinclude>]]</noinclude> +!! endarticle + +## See T48811 for details +!! article +Template:mixed_attr_content_template +!! text +style="color:red;" title="T48811" +|- +|foo +!! endarticle + +!! article +Template:definition_list +!! text +one +::two +!! endarticle + +!! article +A?b +!! text +Weirdo titles! +!! endarticle + +!!article +Template:Bullet +!!text +* Bar +!!endarticle + +!!article +Template:OpenTable +!!text +{| +!!endarticle + +!!article +Template:EmptyLITest +!!text +*a +* +* +*b +!!endarticle + +!!article +Template:EmptyTRTest +!!text +{| +|- +|- +|foo +|- +|- +|bar +|} +!!endarticle + +!!article +Template:EmptyTRWithHTMLAttrTest +!!text +<table> +<tr align="center"></tr> +<tr><td>foo</td></tr> +<tr align="center"></tr> +<tr><td>bar</td></tr> +</table> +!!endarticle + +!! article +Template:With: Colon +!! text +Template with colon +!! endarticle + +### +### Basic tests +### + +!! test +Blank input +!! wikitext +!! html +!! end + +!! test +Simple paragraph +!! wikitext +This is a simple paragraph. +!! html +<p>This is a simple paragraph. +</p> +!! end + +!! test +Paragraphs with extra newline spacing +!! wikitext +foo + +bar + + +baz + + + +booz +!! html +<p>foo +</p><p>bar +</p><p><br /> +baz +</p><p><br /> +</p><p>booz +</p> +!! end + +!! test +Paragraphs with newline spacing with comment lines in between +!! wikitext +---- +a +<!--foo--> +b +---- +a +<!--foo--><!--More than 1 comment, still stripped--> +b +---- +a + <!--foo--> <!----> <!-- bar --> +b +---- +a +<!--foo--> + +b +---- +a + +<!--foo--> +b +---- +a +<!--foo--> + + +b +---- +a + + +<!--foo--> +b +---- +!! html +<hr /> +<p>a +b +</p> +<hr /> +<p>a +b +</p> +<hr /> +<p>a +b +</p> +<hr /> +<p>a +</p><p>b +</p> +<hr /> +<p>a +</p><p>b +</p> +<hr /> +<p>a +</p><p><br /> +b +</p> +<hr /> +<p>a +</p><p><br /> +b +</p> +<hr /> + +!! end + +!! test +Paragraphs with newline spacing with non-empty white-space lines in between +!! wikitext +---- +a + +b +---- +a + + +b +---- +!! html +<hr /> +<p>a +</p><p>b +</p> +<hr /> +<p>a +</p><p><br /> +b +</p> +<hr /> + +!! end + +!! test +Paragraphs with newline spacing with non-empty mixed comment and white-space lines in between +!! wikitext +---- +a + <!--foo--> +b +---- +a + <!--foo--><!--More than 1 comment doesn't disable stripping of this line!--> +b +---- +a + +<!--foo--> + <!--bar--> +b +---- +a + + <!--foo--> + <!--bar--> + +b +---- +!! html +<hr /> +<p>a +b +</p> +<hr /> +<p>a +b +</p> +<hr /> +<p>a +</p><p>b +</p> +<hr /> +<p>a +</p><p><br /> +b +</p> +<hr /> + +!! end + +!! test +Extra newlines: More paragraphs with indented comment +!! wikitext +a + + <!--boo--> + +b +!! html +<p>a +</p><p><br /> +b +</p> +!!end + +!! test +Extra newlines followed by heading +!! wikitext +a + + + +=b= +[[a]] + + +=b= +!! html +<p>a +</p><p><br /> +</p> +<h1><span class="mw-headline" id="b">b</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: b">edit</a><span class="mw-editsection-bracket">]</span></span></h1> +<p><a href="/index.php?title=A&action=edit&redlink=1" class="new" title="A (page does not exist)">a</a> +</p><p><br /> +</p> +<h1><span class="mw-headline" id="b_2">b</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: b">edit</a><span class="mw-editsection-bracket">]</span></span></h1> + +!! end + +!! test +Extra newlines between heading and content are swallowed +!! wikitext +=b= + + + +[[a]] +!! html +<h1><span class="mw-headline" id="b">b</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: b">edit</a><span class="mw-editsection-bracket">]</span></span></h1> +<p><a href="/index.php?title=A&action=edit&redlink=1" class="new" title="A (page does not exist)">a</a> +</p> +!! end + +!! test +Heading with line break in nowiki +!! options +parsoid=wt2html +!! config +wgFragmentMode=[ 'html5', 'legacy' ] +!! wikitext +==A <nowiki>B +C</nowiki>== +!! html/php +<h2><span id="A_B.0AC"></span><span class="mw-headline" id="A_B +C">A B +C</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: A B C">edit</a><span class="mw-editsection-bracket">]</span></span></h2> + +!! html/parsoid +<h2 id="A_B +C"><span id="A_B.0AC" typeof="mw:FallbackId"></span>A <span typeof="mw:Nowiki">B +C</span></h2> +!! end + +!! test +Parsing an URL +!! wikitext +http://fr.wikipedia.org/wiki/🍺 +<!-- EasterEgg we love beer, better be able be able to link to it --> +!! html +<p><a rel="nofollow" class="external free" href="http://fr.wikipedia.org/wiki/🍺">http://fr.wikipedia.org/wiki/🍺</a> +</p> +!! end + +!! test +Simple list +!! wikitext +*Item 1 +*Item 2 +!! html +<ul><li>Item 1</li> +<li>Item 2</li></ul> + +!! end + +!! test +Italics and bold +!! wikitext +*plain +*plain''italic''plain +*plain''italic''plain''italic''plain +*plain'''bold'''plain +*plain'''bold'''plain'''bold'''plain +*plain''italic''plain'''bold'''plain +*plain'''bold'''plain''italic''plain +*plain''italic'''bold-italic'''italic''plain +*plain'''bold''bold-italic''bold'''plain +*plain'''''bold-italic'''italic''plain +*plain'''''bold-italic''bold'''plain +*plain''italic'''bold-italic'''''plain +*plain'''bold''bold-italic'''''plain +*plain l'''italic''plain +*plain l''''bold''' plain +!! html +<ul><li>plain</li> +<li>plain<i>italic</i>plain</li> +<li>plain<i>italic</i>plain<i>italic</i>plain</li> +<li>plain<b>bold</b>plain</li> +<li>plain<b>bold</b>plain<b>bold</b>plain</li> +<li>plain<i>italic</i>plain<b>bold</b>plain</li> +<li>plain<b>bold</b>plain<i>italic</i>plain</li> +<li>plain<i>italic<b>bold-italic</b>italic</i>plain</li> +<li>plain<b>bold<i>bold-italic</i>bold</b>plain</li> +<li>plain<i><b>bold-italic</b>italic</i>plain</li> +<li>plain<b><i>bold-italic</i>bold</b>plain</li> +<li>plain<i>italic<b>bold-italic</b></i>plain</li> +<li>plain<b>bold<i>bold-italic</i></b>plain</li> +<li>plain l'<i>italic</i>plain</li> +<li>plain l'<b>bold</b> plain</li></ul> + +!! end + +# this example taken from the [[simple:Moon]] article (T49326) +!! test +Italics and possessives (1) +!! wikitext +obtained by ''[[Lunar Prospector]]'''s gamma-ray spectrometer +!! html +<p>obtained by <i><a href="/index.php?title=Lunar_Prospector&action=edit&redlink=1" class="new" title="Lunar Prospector (page does not exist)">Lunar Prospector</a>'</i>s gamma-ray spectrometer +</p> +!! end + +# this example taken from [[en:Flaming Pie]] (T51926) +!! test +Italics and possessives (2) +!! wikitext +'''''Flaming Pie''''' is ... released in 1997. In ''Flaming Pie'''s liner notes +!! html +<p><i><b>Flaming Pie</b></i> is ... released in 1997. In <i>Flaming Pie'</i>s liner notes +</p> +!! end + +# this example taken from [[en:Dictionary]] (T51926) +!! test +Italics and possessives (3) +!! wikitext +The first monolingual dictionary written in a Romance language was ''Sebastián Covarrubias''' ''Tesoro de la lengua castellana o española'', published in 1611 in Madrid. In 1612 the first edition of the ''Vocabolario dell'[[Accademia della Crusca]]'', for Italian, was published. In 1690 in Rotterdam was published, posthumously, the ''Dictionnaire Universel''. +!! html +<p>The first monolingual dictionary written in a Romance language was <i>Sebastián Covarrubias'</i> <i>Tesoro de la lengua castellana o española</i>, published in 1611 in Madrid. In 1612 the first edition of the <i>Vocabolario dell'<a href="/index.php?title=Accademia_della_Crusca&action=edit&redlink=1" class="new" title="Accademia della Crusca (page does not exist)">Accademia della Crusca</a></i>, for Italian, was published. In 1690 in Rotterdam was published, posthumously, the <i>Dictionnaire Universel</i>. +</p> +!! end + + +### +### 2-quote opening sequence tests +### +!! test +Italics and bold: 2-quote opening sequence: (2,2) +!! wikitext +''foo'' +!! html +<p><i>foo</i> +</p> +!!end + +!! test +Italics and bold: 2-quote opening sequence: (2,3) +!! wikitext +''foo''' +!! html/* +<p><i>foo'</i> +</p> +!!end + +!! test +Italics and bold: 2-quote opening sequence: (2,4) +!! options +parsoid=wt2html +!! wikitext +''foo'''' +!! html/* +<p><i>foo''</i> +</p> +!!end + +# same html as previous, but wikitext adjusted to match parsoid html2wt +!! test +Italics and bold: 2-quote opening sequence: (2,4) w/ nowiki +!! wikitext +''foo<nowiki>''</nowiki>'' +!! html +<p><i>foo''</i> +</p> +!! end + +# The PHP parser strips the empty tags out for giggles; parsoid doesn't. +!! test +Italics and bold: 2-quote opening sequence: (2,5) +!! options +parsoid=wt2html +!! wikitext +''foo''''' +!! html/php +<p><i>foo</i> +</p> +!! html/parsoid +<p><i>foo</i><b></b> +</p> +!!end + +# same html as previous, but wikitext adjusted to match parsoid html2wt +!! test +Italics and bold: 2-quote opening sequence: (2,5+3) w/ nowiki +!! wikitext +''foo'''''<nowiki/>''' +!! html/php +<p><i>foo</i> +</p> +!! html/parsoid +<p><i>foo</i><b></b> +</p> +!! end + + +### +### 3-quote opening sequence tests +### + +!! test +Italics and bold: 3-quote opening sequence: (3,2) +!! wikitext +'''foo'' +!! html/* +<p>'<i>foo</i> +</p> +!!end + +!! test +Italics and bold: 3-quote opening sequence: (3,3) +!! wikitext +'''foo''' +!! html +<p><b>foo</b> +</p> +!!end + +!! test +Italics and bold: 3-quote opening sequence: (3,4) +!! wikitext +'''foo'''' +!! html/* +<p><b>foo'</b> +</p> +!!end + +# The PHP parser strips the empty tags out for giggles; parsoid doesn't. +!! test +Italics and bold: 3-quote opening sequence: (3,5) +!! options +parsoid=wt2html +!! wikitext +'''foo''''' +!! html/php +<p><b>foo</b> +</p> +!! html/parsoid +<p><b>foo</b><i></i> +</p> +!!end + +# same html as previous, but wikitext adjusted to match parsoid html2wt +!! test +Italics and bold: 3-quote opening sequence: (3,5+2) w/ nowiki +!! wikitext +'''foo'''''<nowiki/>'' +!! html/php +<p><b>foo</b> +</p> +!! html/parsoid +<p><b>foo</b><i></i> +</p> +!! end + + +### +### 4-quote opening sequence tests +### + +!! test +Italics and bold: 4-quote opening sequence: (4,2) +!! options +parsoid=wt2html +!! wikitext +''''foo'' +!! html/* +<p>''<i>foo</i> +</p> +!!end + +# same html as previous, but wikitext adjusted to match parsoid html2wt +!! test +Italics and bold: 4-quote opening sequence: (4,2) w/ nowiki +!! wikitext +<nowiki>''</nowiki>''foo'' +!! html +<p>''<i>foo</i> +</p> +!! end + +!! test +Italics and bold: 4-quote opening sequence: (4,3) +!! wikitext +''''foo''' +!! html/* +<p>'<b>foo</b> +</p> +!!end + +!! test +Italics and bold: 4-quote opening sequence: (4,4) +!! options +parsoid=wt2html +!! wikitext +''''foo'''' +!! html/* +<p>'<b>foo'</b> +</p> +!!end + +# same html as previous, but wikitext adjusted to match parsoid html2wt +!! test +Italics and bold: 4-quote opening sequence: (4,4) w/ nowiki +!! wikitext +'<nowiki/>'''foo'''' +!! html +<p>'<b>foo'</b> +</p> +!! end + +# The PHP parser strips the empty tags out for giggles; parsoid doesn't. +!! test +Italics and bold: 4-quote opening sequence: (4,5) +!! options +parsoid=wt2html +!! wikitext +''''foo''''' +!! html/php +<p>'<b>foo</b> +</p> +!! html/parsoid +<p>'<b>foo</b><i></i> +</p> +!!end + +# same html as previous, but wikitext adjusted to match parsoid html2wt +!! test +Italics and bold: 4-quote opening sequence: (4,5+2) w/ nowiki +!! wikitext +'<nowiki/>'''foo'''''<nowiki/>'' +!! html/php +<p>'<b>foo</b> +</p> +!! html/parsoid +<p>'<b>foo</b><i></i> +</p> +!! end + + +### +### 5-quote opening sequence tests +### + +!! test +Italics and bold: 5-quote opening sequence: (5,2) +!! options +parsoid=wt2html +!! wikitext +'''''foo'' +!! html/* +<p><b><i>foo</i></b> +</p> +!!end + +# same html as previous, but wikitext adjusted to match parsoid html2wt +!! test +Italics and bold: 5-quote opening sequence: (5,2+3) +!! wikitext +'''''foo''''' +!! html/* +<p><i><b>foo</b></i> +</p> +!! end + +!! test +Italics and bold: 5-quote opening sequence: (5,3) +!! options +parsoid=wt2html +!! wikitext +'''''foo''' +!! html/* +<p><i><b>foo</b></i> +</p> +!!end + +# same html as previous, but wikitext adjusted to match parsoid html2wt +!! test +Italics and bold: 5-quote opening sequence: (5,3+2) +!! wikitext +'''''foo''''' +!! html +<p><i><b>foo</b></i> +</p> +!! end + +!! test +Italics and bold: 5-quote opening sequence: (5,4) +!! options +parsoid=wt2html +!! wikitext +'''''foo'''' +!! html/* +<p><i><b>foo'</b></i> +</p> +!!end + +!! test +Italics and bold: 5-quote opening sequence: (5,5) +!! wikitext +'''''foo''''' +!! html +<p><i><b>foo</b></i> +</p> +!!end + +!! test +Italics and bold: 5-quote opening sequence: (5,6) +!! wikitext +'''''foo'''''' +!! html/* +<p><i><b>foo'</b></i> +</p> +!! end + +### +### multiple quote sequences in a line +### + +!! test +Italics and bold: multiple quote sequences: (2,4,2) +!! options +parsoid=wt2html +!! wikitext +''foo''''bar'' +!! html/* +<p><i>foo'<b>bar</b></i> +</p> +!! end + +# same html as previous, but wikitext adjusted to match parsoid html2wt +!! test +Italics and bold: multiple quote sequences: (2,4,2+3) w/ nowiki +!! wikitext +''foo'<nowiki/>'''bar''''' +!! html +<p><i>foo'<b>bar</b></i> +</p> +!! end + +!! test +Italics and bold: multiple quote sequences: (2,4,3) +!! options +parsoid=wt2html +!! wikitext +''foo''''bar''' +!! html/* +<p><i>foo'<b>bar</b></i> +</p> +!! end + +# same html as previous, but wikitext adjusted to match parsoid html2wt +!! test +Italics and bold: multiple quote sequences: (2,4,3+2) w/ nowiki +!! wikitext +''foo'<nowiki/>'''bar''''' +!! html +<p><i>foo'<b>bar</b></i> +</p> +!! end + +!! test +Italics and bold: multiple quote sequences: (2,4,4) +!! options +parsoid=wt2html +!! wikitext +''foo''''bar'''' +!! html/* +<p><i>foo'<b>bar'</b></i> +</p> +!! end + +# same html as previous, but wikitext adjusted to match parsoid html2wt +!! test +Italics and bold: multiple quote sequences: (2,4,4+2) w/ nowiki +!! wikitext +''foo'<nowiki/>'''bar'<nowiki/>''''' +!! html +<p><i>foo'<b>bar'</b></i> +</p> +!! end + +# The PHP parser strips the empty tags out for giggles; parsoid doesn't. +!! test +Italics and bold: multiple quote sequences: (3,4,2) +!! options +parsoid=wt2html +!! wikitext +'''foo''''bar'' +!! html/php +<p><b>foo'</b>bar +</p> +!! html/parsoid +<p><b>foo'</b>bar<i></i> +</p> +!! end + +# same html as previous, but wikitext adjusted to match parsoid html2wt +!! test +Italics and bold: multiple quote sequences: (3,4,2+2) w/ nowiki +!! wikitext +'''foo''''bar''<nowiki/>'' +!! html/php +<p><b>foo'</b>bar +</p> +!! html/parsoid +<p><b>foo'</b>bar<i></i> +</p> +!! end + +# The PHP parser strips the empty tags out for giggles; parsoid doesn't. +!! test +Italics and bold: multiple quote sequences: (3,4,3) +!! options +parsoid=wt2html +!! wikitext +'''foo''''bar''' +!! html/php +<p><b>foo'</b>bar +</p> +!! html/parsoid +<p><b>foo'</b>bar<b></b> +</p> +!! end + +# same html as previous, but wikitext adjusted to match parsoid html2wt +!! test +Italics and bold: multiple quote sequences: (3,4,3+3) w/ nowiki +!! wikitext +'''foo''''bar'''<nowiki/>''' +!! html/php +<p><b>foo'</b>bar +</p> +!! html/parsoid +<p><b>foo'</b>bar<b></b> +</p> +!! end + +### +### other quote tests +### +!! test +Italics and bold: other quote tests: (2,3,5) +!! wikitext +''this is about '''foo's family''''' +!! html +<p><i>this is about <b>foo's family</b></i> +</p> +!!end + + +!! test +Italics and bold: other quote tests: (2,(3,3),2) +!! wikitext +''this is about '''foo's''' family'' +!! html +<p><i>this is about <b>foo's</b> family</i> +</p> +!!end + + +!! test +Italics and bold: other quote tests: (3,2,3,2) +!! options +parsoid=wt2html +!! wikitext +'''this is about ''foo'''s family'' +!! html/* +<p><b>this is about <i>foo</i></b><i>s family</i> +</p> +!!end + + +# same html as previous, but wikitext adjusted to match parsoid html2wt +!! test +Italics and bold: other quote tests: (3,2,3+2+2,2) +!! wikitext +'''this is about ''foo'''''<nowiki/>''s family'' +!! html +<p><b>this is about <i>foo</i></b><i>s family</i> +</p> +!! end + + +!! test +Italics and bold: other quote tests: (3,2,3,3) +!! wikitext +'''this is about ''foo'''s family''' +!! html/* +<p>'<i>this is about </i>foo<b>s family</b> +</p> +!!end + + +!! test +Italics and bold: other quote tests: (3,(2,2),3) +!! wikitext +'''this is about ''foo's'' family''' +!! html +<p><b>this is about <i>foo's</i> family</b> +</p> +!!end + + +!! test +Italicized possessive +!! wikitext +The ''[[Main Page]]'''s talk page. +!! html/php +<p>The <i><a href="/wiki/Main_Page" title="Main Page">Main Page</a>'</i>s talk page. +</p> +!! html/parsoid +<p>The <i><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a>'</i>s talk page.</p> +!! end + +!! test +Quote balancing context should be restricted to td/th cells on the same wikitext line +!! options +parsoid=wt2html,wt2wt +!! wikitext +{| +!''a!!''b +|''a||''b +|} +!! html+tidy +<table> +<tbody><tr> +<th><i>a</i></th> +<th><i>b</i> +</th> +<td><i>a</i></td> +<td><i>b</i> +</td></tr></tbody></table> +!! end + +### +### Non-html5 tags +### + +!! test +Non-html5 tags should be accepted +!! wikitext +<center>''foo''</center> +<big>''foo''</big> +<font>''foo''</font> +<strike>''foo''</strike> +<tt>''foo''</tt> +!! html +<center><i>foo</i></center> +<p><big><i>foo</i></big> +<font><i>foo</i></font> +<strike><i>foo</i></strike> +<tt><i>foo</i></tt> +</p> +!! end + +!! test +<wbr> is valid wikitext (T54468) +!! wikitext +<wbr> +!! html +<p><wbr /> +</p> +!! end + +# <strike> is HTML4, <s> is HTML4/5. +!! test +<s> or <strike> for strikethrough +!! wikitext +<strike>strike</strike> + +<s>s</s> +!! html +<p><strike>strike</strike> +</p><p><s>s</s> +</p> +!! end + +## a not permitted +## i,b,br omitted +!! test +Text-level semantic html elements in wikitext +!! wikitext +<em>text</em> +<strong>text</strong> +<small>text</small> +<s>text</s> +<cite>text</cite> +<q>text</q> +<dfn>text</dfn> +<abbr>text</abbr> +<data>text</data> +<time>text</time> +<code>text</code> +<var>text</var> +<samp>text</samp> +<kbd>text</kbd> +<sub>text</sub> +<u>text</u> +<mark>text</mark> +<ruby><rb>明日</rb><rp>(</rp><rt>Ashita</rt><rp> </rp><rtc>あした</rtc><rp>)</rp></ruby> +<bdi>text</bdi> +<bdo>text</bdo> +<span>text</span> +<wbr /> +!! html +<p><em>text</em> +<strong>text</strong> +<small>text</small> +<s>text</s> +<cite>text</cite> +<q>text</q> +<dfn>text</dfn> +<abbr>text</abbr> +<data>text</data> +<time>text</time> +<code>text</code> +<var>text</var> +<samp>text</samp> +<kbd>text</kbd> +<sub>text</sub> +<u>text</u> +<mark>text</mark> +<ruby><rb>明日</rb><rp>(</rp><rt>Ashita</rt><rp> </rp><rtc>あした</rtc><rp>)</rp></ruby> +<bdi>text</bdi> +<bdo>text</bdo> +<span>text</span> +<wbr /> +</p> +!! end + +# test cases taken from +# https://www.w3.org/TR/html5/text-level-semantics.html#the-ruby-element +!! test +Ruby markup (W3C-style) +!! wikitext +;Mono-ruby for individual base characters +:<ruby>日<rt>に</rt>本<rt>ほん</rt>語<rt>ご</rt></ruby> +;Group ruby +:<ruby>今日<rt>きょう</rt></ruby> +;Jukugo ruby +:<ruby>法<rb>華</rb><rb>経</rb><rt>ほ</rt><rt>け</rt><rt>きょう</rt></ruby> +;Inline ruby +:<ruby>東<rb>京</rb><rp>(</rp><rt>とう</rt><rt>きょう</rt><rp>)</rp></ruby> +;Double-sided ruby +:<ruby><rb>旧</rb><rb>金</rb><rb>山</rb><rt>jiù</rt><rt>jīn</rt><rt>shān</rt><rtc>San Francisco</rtc></ruby> + +<ruby> +<rb>♥</rb><rtc><rt>Heart</rt></rtc><rtc lang="fr"><rt>Cœur</rt></rtc> +<rb>☘</rb><rtc><rt>Shamrock</rt></rtc><rtc lang="fr"><rt>Trèfle</rt></rtc> +<rb>✶</rb><rtc><rt>Star</rt></rtc><rtc lang="fr"><rt>Étoile</rt></rtc> +</ruby> +!! html +<dl><dt>Mono-ruby for individual base characters</dt> +<dd><ruby>日<rt>に</rt>本<rt>ほん</rt>語<rt>ご</rt></ruby></dd> +<dt>Group ruby</dt> +<dd><ruby>今日<rt>きょう</rt></ruby></dd> +<dt>Jukugo ruby</dt> +<dd><ruby>法<rb>華</rb><rb>経</rb><rt>ほ</rt><rt>け</rt><rt>きょう</rt></ruby></dd> +<dt>Inline ruby</dt> +<dd><ruby>東<rb>京</rb><rp>(</rp><rt>とう</rt><rt>きょう</rt><rp>)</rp></ruby></dd> +<dt>Double-sided ruby</dt> +<dd><ruby><rb>旧</rb><rb>金</rb><rb>山</rb><rt>jiù</rt><rt>jīn</rt><rt>shān</rt><rtc>San Francisco</rtc></ruby></dd></dl> +<p><ruby> +<rb>♥</rb><rtc><rt>Heart</rt></rtc><rtc lang="fr"><rt>Cœur</rt></rtc> +<rb>☘</rb><rtc><rt>Shamrock</rt></rtc><rtc lang="fr"><rt>Trèfle</rt></rtc> +<rb>✶</rb><rtc><rt>Star</rt></rtc><rtc lang="fr"><rt>Étoile</rt></rtc> +</ruby> +</p> +!! end + +# The next two test different paths in the sanitizer. +!! test +Non-word characters don't terminate tag names (T19663, T42670, T54022) +!! wikitext +<blockquote|>a</blockquote> + +<b→> doesn't terminate </b→> + +<bä> doesn't terminate </bä> + +<boo> doesn't terminate </boo> + +<s.foo> doesn't terminate </s.foo> + +<sub-ID#1> +!! html +<p><blockquote|>a</blockquote> +</p><p><b→> doesn't terminate </b→> +</p><p><bä> doesn't terminate </bä> +</p><p><boo> doesn't terminate </boo> +</p><p><s.foo> doesn't terminate </s.foo> +</p><p><sub-ID#1> +</p> +!! end + +!! test +Non-word characters don't terminate tag names +!! wikitext +<blockquote|>a</blockquote> + +<b→> doesn't terminate </b→> + +<bä> doesn't terminate </bä> + +<boo> doesn't terminate </boo> + +<s.foo> doesn't terminate </s.foo> + +<sub-ID#1> +!! html+tidy +<p><blockquote|>a +</p><p><b→> doesn't terminate </b→> +</p><p><bä> doesn't terminate </bä> +</p><p><boo> doesn't terminate </boo> +</p><p><s.foo> doesn't terminate </s.foo> +</p><p><sub-ID#1> +</p> +!! end + +### +### See tests/parser/parserTestsParserHook.php for the <tåg> extension) +### This checks that HTML5 tags (with non-word characters in the tag +### name) make it safely through the parser -- the Sanitizer will +### munge them later, as it should. +### +!! test +Non-word characters are valid in extension tags (T19663) +!! wikitext +<tåg>tåg</tåg> +!! html/php +<pre> +'tåg' +array ( +) +</pre> + +!! html/parsoid +<pre typeof="mw:Extension/tåg" data-mw='{"name":"tåg","attrs":{},"body":{"extsrc":"tåg"}}' data-parsoid='{}' about="#mwt2"></pre> +!! end + +!! test +Isolated close tags should be treated as literal text (T54760) +!! options +parsoid=wt2html +!! wikitext +</b> + +<s.foo>s</s> +!! html/php+tidy +<p class="mw-empty-elt"> +</p><p><s.foo>s +</p> +!! html/parsoid +<p><s.foo>s</p> +!! end + +### +### Special characters +### + +!! test +Bare pipe character (T54363) +!! wikitext +| +!! html +<p>| +</p> +!! end + +!! test +Bare pipe character from a template (T54363) +!! wikitext +{{pipe}} +!! html +<p>| +</p> +!! end + +### +### <nowiki> test cases +### + +!! test +<nowiki> unordered list +!! wikitext +<nowiki>* This is not an unordered list item.</nowiki> +!! html/php +<p>* This is not an unordered list item. +</p> +!! html/parsoid +<p><span typeof="mw:Nowiki">* This is not an unordered list item.</span></p> +!! end + +!! test +<nowiki> spacing +!! wikitext +<nowiki>Lorem ipsum dolor + +sed abit. + sed nullum. + +:and a colon +</nowiki> +!! html/php +<p>Lorem ipsum dolor + +sed abit. + sed nullum. + +:and a colon + +</p> +!! html/parsoid +<p><span typeof="mw:Nowiki">Lorem ipsum dolor + +sed abit. + sed nullum. + +:and a colon +</span></p> +!! end + +!! test +Don't parse <nowiki><span class="error"></nowiki> (T149622) +!! wikitext +<nowiki><span class="error"></nowiki> +!! html/php +<p><span class="error"> +</p> +!! html/parsoid +<p><span typeof="mw:Nowiki"><span class="error"></span></p> +!! end + +!! test +nowiki 3 +!! wikitext +:There is not nowiki. +:There is <nowiki>nowiki</nowiki>. + +#There is not nowiki. +#There is <nowiki>nowiki</nowiki>. + +*There is not nowiki. +*There is <nowiki>nowiki</nowiki>. +!! html/php +<dl><dd>There is not nowiki.</dd> +<dd>There is nowiki.</dd></dl> +<ol><li>There is not nowiki.</li> +<li>There is nowiki.</li></ol> +<ul><li>There is not nowiki.</li> +<li>There is nowiki.</li></ul> + +!! html/parsoid +<dl><dd data-parsoid='{}'>There is not nowiki.</dd> +<dd data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</dd></dl> + +<ol><li data-parsoid='{}'>There is not nowiki.</li> +<li data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</li></ol> + +<ul><li data-parsoid='{}'>There is not nowiki.</li> +<li data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</li></ul> +!! end + +!! test +Entities inside <nowiki> +!! wikitext +<nowiki><</nowiki> +!! html/php +<p>< +</p> +!! html/parsoid +<p><span typeof="mw:Nowiki"><span typeof="mw:Entity" data-parsoid='{"src":"&lt;","srcContent":"<"}'><</span></span></p> +!! end + +!! test +Entities inside template parameters +!! wikitext +{{echo|–}} +!! html/php+tidy +<p>– +</p> +!! html/parsoid +<p><span typeof="mw:Transclusion mw:Entity" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&ndash;"}},"i":0}}]}'>–</span></p> +!! end + +!! test +Properly escape nowiki when combined with other wiki markup +!! options +parsoid=html2wt +!! html/parsoid +<p>* </nowiki> tag</p> +!! wikitext +<nowiki>*</nowiki> <nowiki></nowiki></nowiki> tag +!! end + +!! test +T93824: Put escaped HTML tags inside nowiki +!! options +parsoid=html2wt +!! html/parsoid +<p><h2>foo</h2></p> +!! wikitext +<nowiki><h2>foo</h2></nowiki> +!! end + +!! test +T71950: 1. Put nowiki as close to cause as possible, even with non-quote escapable chars +!! options +parsoid=html2wt +!! html/parsoid +<p>This text: L'<a rel="mw:WikiLink" href="./Foo">Foo</a> +This text: L''<a rel="mw:WikiLink" href="./Foo">Foo</a> +This text: L'''<a rel="mw:WikiLink" href="./Foo">Foo</a>''</p> +!! wikitext +This text: L'[[Foo]] +This text: L<nowiki>''</nowiki>[[Foo]] +This text: L<nowiki>'''</nowiki>[[Foo]]<nowiki>''</nowiki> +!! end + +# This test fails because wikitext whitespace is not normalized before comparing. +!! test +T71950: 2. Put nowiki as close to cause as possible, after ' :' +!! options +parsoid=html2wt +!! html/parsoid +<p>This text : L''<a rel="mw:WikiLink" href="./Foo">Foo</a> +</p> +!! wikitext +This text : L<nowiki>''</nowiki>[[Foo]] +!! end + +# This test and the next one are html2wt only as they test that incorrect wikitext +# passed in template arguments gets escaped or wrapped in nowikis where required. +!! test +T71482: Use {{!}} instead of nowiki for single pipe in template argument +!! options +parsoid=html2wt +!! html/parsoid +<p><span typeof="mw:Transclusion" data-mw="{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo|bar"}},"i":0}}]}" about="#mwt1"></span> +<span typeof="mw:Transclusion" data-mw="{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo|bar |[["}},"i":0}}]}" about="#mwt2"></p> +!! wikitext +{{echo|foo{{!}}bar}} +{{echo|<nowiki>foo|bar |[[</nowiki>}} +!! end + +!! test +T53961: Output correct nowikis in template arguments +!! options +parsoid=html2wt +!! html/parsoid +<p><span typeof="mw:Transclusion" data-mw="{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"a [ b"}},"i":0}}]}" about="#mwt1"></span> +<span typeof="mw:Transclusion" data-mw="{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"a }} b"}},"i":0}}]}" about="#mwt2"></span> +<span typeof="mw:Transclusion" data-mw="{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"a [[ b"}},"i":0}}]}" about="#mwt3"></span> +<span typeof="mw:Transclusion" data-mw="{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"a | {{ ]]"}},"i":0}}]}" about="#mwt4"></span> +<span typeof="mw:Transclusion" data-mw="{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"a }"}},"i":0}}]}" about="#mwt5"></span></p> +!! wikitext +{{echo|a [ b}} +{{echo|<nowiki>a }} b</nowiki>}} +{{echo|<nowiki>a [[ b</nowiki>}} +{{echo|<nowiki>a | {{ ]]</nowiki>}} +{{echo|a <nowiki>}</nowiki>}} +!! end + +!! test +Cases where "!!" needs nowiki protection +!! options +parsoid=html2wt +!! html/parsoid +<table> +<tr><th>this needs protection !! here</th></tr> +</table> + +<table> +<tr><th>this does not need +protection !! here</th></tr> +</table> +!! wikitext +{| +!<nowiki>this needs protection !! here</nowiki> +|} + +{| +!this does not need +protection !! here +|} +!! end + +### +### Comments +### +!! test +Comments and Indent-Pre +!! wikitext +<!-- comment 1 --> asdf + +<!-- comment 1 --> asdf +<!-- comment 2 --> + +<!-- comment 1 --> asdf +<!-- comment 2 -->xyz + +<!-- comment 1 --> asdf +<!-- comment 2 --> xyz +!! html +<pre>asdf +</pre> +<pre>asdf +</pre> +<pre>asdf +</pre> +<p>xyz +</p> +<pre>asdf +xyz +</pre> +!! end + +!! test +Comment test 2a +!! wikitext +asdf +<!-- comment 1 --> +jkl +!! html +<p>asdf +jkl +</p> +!! end + +!! test +Comment test 2b +!! wikitext +asdf +<!-- comment 1 --> + +jkl +!! html +<p>asdf +</p><p>jkl +</p> +!! end + +!! test +Comment test 3 +!! wikitext +asdf +<!-- comment 1 --> +<!-- comment 2 --> +jkl +!! html +<p>asdf +jkl +</p> +!! end + +!! test +Comment test 4 +!! wikitext +asdf<!-- comment 1 -->jkl +!! html +<p>asdfjkl +</p> +!! end + +!! test +Comment spacing +!! wikitext +a + <!-- foo --> b <!-- bar --> +c +!! html +<p>a +</p> +<pre> b +</pre> +<p>c +</p> +!! end + +!! test +Comment whitespace +!! wikitext +<!-- returns a single newline, not nothing, since the newline after > is not stripped --> +!! html + +!! end + +!! test +Comment semantics and delimiters +!! wikitext +<!-- --><!----><!-----><!------> +!! html/php + +!! html/parsoid +<!-- --><!----><!-----><!------> +!! end + +!! test +Comment semantics and delimiters, redux +!! wikitext +<!-- In SGML every "foo" here would actually show up in the text -- foo -- bar +-- foo -- funky huh? ... --> +!! html/php + +!! html/parsoid +<!-- In SGML every "foo" here would actually show up in the text -- foo -- bar +-- foo -- funky huh? ... --> +!! end + +!! test +Comment semantics and delimiters: directors cut +!! wikitext +<!-- ... However we like to keep things simple and somewhat XML-ish so we eat +everything starting with < followed by !-- until the first -- and > we see, +that wouldn't be valid XML however, since in XML -- has to terminate a comment +-->--> +!! html/php +<p>--> +</p> +!! html/parsoid +<!-- ... However we like to keep things simple and somewhat XML-ish so we eat +everything starting with < followed by !-- until the first -- and > we see, +that wouldn't be valid XML however, since in XML -- has to terminate a comment +--><p>--></p> +!! end + +!! test +Comment semantics: nesting +!! wikitext +<!--<!-- no, we're not going to do anything fancy here -->--> +!! html/php +<p>--> +</p> +!! html/parsoid +<!--<!-- no, we're not going to do anything fancy here --><p>--></p> +!! end + +# Parsoid closes the unclosed comment, even if it means a slight +# round-trip diff. +!! test +Comment semantics: unclosed comment at end +!! options +parsoid=wt2html,html2html +!! wikitext +<!--This comment will run out to the end of the document +!! html/php + +!! html/parsoid +<!--This comment will run out to the end of the document--> +!! end + +!! test +Comment semantics: normalize comments to play nice with XML and browsers +!! wikitext +<!-- Browsers --!> think this is closed --> +<!--> This would normally be text --> +<!---> As would this --> +<!-- XML doesn't like trailing dashes --------> +<!-- Nor doubled hyphens -- anywhere in the data --> +But this is not a comment. +!! html/php +<p>But this is not a comment. +</p> +!! html/parsoid +<!-- Browsers --!> think this is closed --> +<!--> This would normally be text --> +<!---> As would this --> +<!-- XML doesn't like trailing dashes --------> +<!-- Nor doubled hyphens -- anywhere in the data --> +<p>But this is not a comment.</p> +!! end + +!! test +Comment semantics: round-trip even text which contains encoded --> +!! wikitext +<!-- hello & goodbye - > --> --&gt; --&xx --> +!! html/parsoid +<!-- hello & goodbye - > --> --&gt; --&xx --> +!! end + +!! test +Comment in template title +!! wikitext +{{f<!---->oo}} +!! html +<p>FOO +</p> +!! end + +!! test +Comment on its own line post-expand +!! wikitext +a +{{blank}}<!----> +b +!! html +<p>a +</p><p>b +</p> +!! end + +!! test +Comment on its own line post-expand with non-significant whitespace +!! wikitext +a + {{blank}} <!----> +b +!! html +<p>a +</p><p>b +</p> +!! end + +!! test +Multiple comments should still parse as SOL-transparent +!! options +parsoid=wt2html,wt2wt +!! wikitext +<!--c1-->*a +<!--c2--><!--c3--><!--c4-->*b +!! html/php +<ul><li>a</li> +<li>b</li></ul> + +!! html/parsoid +<!--c1--><ul> +<li>a +</li> +<!--c2--><!--c3--><!--c4--> +<li>b +</li> +</ul> +!! end + +## Make sure ">" gets escaped in comments to avoid XSS +!! test +IE conditional comments +!! wikitext +<!--[if lt IE 9]> + <script>alert('hi');</script> +<![endif]--> +!! html/parsoid +<!--[if lt IE 9]> + <script>alert('hi');</script> +<![endif]--> +!! end + +### +### paragraph wrapping tests +### + +!! test +No block tags +!! wikitext +a + +b +!! html +<p>a +</p><p>b +</p> +!! end + +!! test +Block tag on one line (<div>) +!! wikitext +a <div>foo</div> + +b +!! html +a <div>foo</div> +<p>b +</p> +!! html+tidy +<p>a </p><div>foo</div> +<p>b +</p> +!! end + +# Remex wraps empty tag runs with p-tags. +# Parsoid strips them out during p-wrapping. +!! test +No p-wrappable content +!! wikitext +<span><div>x</div></span> +<span><s><div>x</div></s></span> +<small><em></em></small><span><s><div>x</div></s></span> +!! html/php+tidy +<span><div>x</div></span> +<span><s><div>x</div></s></span> +<p><small><em></em></small></p><span><s><div>x</div></s></span> +!! html/parsoid +<span><div>x</div></span> +<span><s><div>x</div></s></span> +<small><em></em></small><span><s><div>x</div></s></span> +!! end + +# T177612: Parsoid-only test +!! test +Transclusion meta tags shouldn't trip Parsoid's useless p-wrapper stripping code +!! wikitext +{{echo|<span><div>x</div></span>}} +x +!! html/parsoid +<span about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"stx":"html","pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"<span><div>x</div></span>"}},"i":0}}]}'><div>x</div></span> +<p>x</p> +!! end + +!! test +Block tag on one line (<blockquote>) +!! wikitext +a <blockquote>foo</blockquote> + +b +!! html +a <blockquote>foo</blockquote> +<p>b +</p> +!! html+tidy +<p>a </p><blockquote><p>foo</p></blockquote> +<p>b +</p> +!! end + +!! test +Block tag on both lines (<div>) +!! wikitext +a <div>foo</div> + +b <div>foo</div> +!! html +a <div>foo</div> +b <div>foo</div> + +!! html+tidy +<p>a </p><div>foo</div><p> +b </p><div>foo</div> +!! end + +!! test +Block tag on both lines (<blockquote>) +!! wikitext +a <blockquote>foo</blockquote> + +b <blockquote>foo</blockquote> +!! html +a <blockquote>foo</blockquote> +b <blockquote>foo</blockquote> + +!! html+tidy +<p>a </p><blockquote><p>foo</p></blockquote><p> +b </p><blockquote><p>foo</p></blockquote> +!! end + +!! test +Multiple lines without block tags +!! wikitext +<div>foo</div> a +b +c +d<!--foo--> e +x <div>foo</div> z +!! html +<div>foo</div> a +<p>b +c +d e +</p> +x <div>foo</div> z + +!! html+tidy +<div>foo</div><p> a +</p><p>b +c +d e +</p><p> +x </p><div>foo</div><p> z +</p> +!! end + +# The difference between Parsoid & Remex here +# is because of Parsoid's Tidy-emulation code +# for p-wrapping. We'll start work to remove this +# emulation code in Parsoid sooner than later. +# Remex wraps empty tag runs with p-tags. +# Parsoid strips them out in a separate pass. +!! test +Empty lines between lines with block tags +!! wikitext +<div></div> + + +<div></div>a + +b +<div>a</div>b + +<div>b</div>d + + +<div>e</div> +!! html +<div></div> +<p><br /> +</p> +<div></div>a +<p>b +</p> +<div>a</div>b +<div>b</div>d +<p><br /> +</p> +<div>e</div> + +!! html+tidy +<div></div> +<p><br /> +</p> +<div></div><p>a +</p><p>b +</p> +<div>a</div><p>b +</p><div>b</div><p>d +</p><p><br /> +</p> +<div>e</div> +!! html/parsoid +<div data-parsoid='{"stx":"html"}'></div> + +<p><br /></p> +<div data-parsoid='{"stx":"html"}'></div><p>a</p> + +<p>b</p> +<div data-parsoid='{"stx":"html"}'>a</div><p>b</p> + +<div data-parsoid='{"stx":"html"}'>b</div><p>d</p> + +<p><br /></p> +<div data-parsoid='{"stx":"html"}'>e</div> +!! end + +!! test +Unclosed HTML p-tags should be handled properly +!! wikitext +<div><p>foo</div> +a + +b +!! html/php+tidy +<div><p>foo</p></div> +<p>a +</p><p>b +</p> +!! html/parsoid +<div data-parsoid='{"stx":"html"}'><p data-parsoid='{"stx":"html", "autoInsertedEnd":true}'>foo</p></div> +<p>a</p> +<p>b</p> +!! end + +## SSS FIXME: I can come up with other scenarios where this doesn't work because +## of eager output of buffered tokens in the p-wrapper. But, I'm going to ignore +## them for now. +!! test +1. P-wrapping should leave sol-transparent tags outside p-tags where possible +!! options +parsoid=wt2html +!! wikitext +a [[Category:A1]] [[Category:A2]] +[[Category:A3]] +[[Category:A4]] +!! html/parsoid +<p>a</p> +<link rel="mw:PageProp/Category" href="./Category:A1"/> <link rel="mw:PageProp/Category" href="./Category:A2"/> <link rel="mw:PageProp/Category" href="./Category:A3"/> <link rel="mw:PageProp/Category" href="./Category:A4"/> +!! end + +!! test +2. P-wrapping should leave sol-transparent tags outside p-tags where possible +!! options +parsoid=wt2html +!! wikitext +[[Category:A1]]a +!! html/parsoid +<link rel="mw:PageProp/Category" href="./Category:A1"/><p>a</p> +!! end + +!! test +No paragraph necessary for SOL transparent template +!! wikitext +<span><div>foo</div></span> +[[Category:Foo]] + +<span><div>foo</div></span> +{{echo|[[Category:Foo]]}} +!! html/php +<span><div>foo</div></span> +<span><div>foo</div></span> + +!! html/parsoid +<span data-parsoid='{"stx":"html"}'><div data-parsoid='{"stx":"html"}'>foo</div></span> +<link rel="mw:PageProp/Category" href="./Category:Foo"/> + +<span data-parsoid='{"stx":"html"}'><div data-parsoid='{"stx":"html"}'>foo</div></span> +<link rel="mw:PageProp/Category" href="./Category:Foo" about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[Category:Foo]]"}},"i":0}}]}'/> +!! end + +!! test +Avoid expanding multiline sol transparent template ranges unnecessarily +!! wikitext +hi + + +{{echo|<br/> +}} + +[[Category:Ho]] +!! html/php +<p>hi +</p><p><br /> +<br /> +</p> +!! html/parsoid +<p>hi</p> + +<p><br /> +<br about="#mwt1" typeof="mw:Transclusion" data-parsoid='{}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"<br/>\n"}},"i":0}}]}'/><span about="#mwt1"> +</span></p> + +<link rel="mw:PageProp/Category" href="./Category:Ho" /> +!! end + +### +### Preformatted text +### + +!! test +Preformatted text +!! wikitext + This is some + Preformatted text + With ''italic'' + And '''bold''' + And a [[Main Page|link]] +!! html +<pre>This is some +Preformatted text +With <i>italic</i> +And <b>bold</b> +And a <a href="/wiki/Main_Page" title="Main Page">link</a> +</pre> +!! end + +!! test +Tabs don't trigger preformatted text +!! wikitext + This is not + preformatted text. + This is preformatted text. + So is this. +!! html/php +<p> This is not + preformatted text. +</p> +<pre>This is preformatted text. + So is this. +</pre> +!! html/parsoid +<p> This is not + preformatted text.</p> +<pre>This is preformatted text. + So is this.</pre> +!! end + +!! test +Space before tab needs nowiki pre protection +!! options +parsoid=html2wt +!! html/parsoid +<p> a</p> +!! wikitext +<nowiki> </nowiki> a +!! end + +!! test +Ident preformatting with inline content +!! wikitext + a + ''b'' +!! html +<pre>a +<i>b</i> +</pre> +!! end + +!! test +<pre> with <nowiki> inside (compatibility with 1.6 and earlier) +!! wikitext +<pre><nowiki> +<b> +<cite> +<em> +</nowiki></pre> +!! html +<pre> +<b> +<cite> +<em> +</pre> + +!! end + +!! test +Regression with preformatted in <center> +!! wikitext +<center> + Blah +</center> +!! html +<center> +<pre>Blah +</pre> +</center> + +!! end + +!! test +T54763: Preformatted in <blockquote> +!! wikitext +<blockquote> + Blah +{| +| + indented cell (no pre-wrapping!) +|} +</blockquote> +!! html +<blockquote> +<p> Blah +</p> +<table> +<tr> +<td> +<p> indented cell (no pre-wrapping!) +</p> +</td></tr></table> +</blockquote> + +!! end + +!! test +T53086: Double newlines in blockquotes should be turned into paragraphs +!! wikitext +<blockquote> +Foo + +Bar +</blockquote> +!! html +<blockquote> +<p>Foo +</p><p>Bar +</p> +</blockquote> + +!! end + +!! test +T17491: <ins>/<del> in blockquote +!! wikitext +<blockquote> +Foo <del>bar</del> <ins>baz</ins> quux +</blockquote> +!! html +<blockquote> +<p>Foo <del>bar</del> <ins>baz</ins> quux +</p> +</blockquote> + +!! html+tidy +<blockquote> +<p>Foo <del>bar</del> <ins>baz</ins> quux +</p> +</blockquote> +!! end + +!! test +T17491: <ins>/<del> in blockquote (2) +!! wikitext +<blockquote>Foo <del>bar</del> <ins>baz</ins> quux +</blockquote> +!! html +<blockquote>Foo <del>bar</del> <ins>baz</ins> quux +</blockquote> + +!! html+tidy +<blockquote><p>Foo <del>bar</del> <ins>baz</ins> quux +</p></blockquote> +!! end + +!! test +<pre> with attributes (T5202) +!! wikitext +<pre style="background: blue; color:white">Bluescreen of WikiDeath</pre> +!! html +<pre style="background: blue; color:white">Bluescreen of WikiDeath</pre> + +!! end + +!! test +<pre> with width attribute (T5202) +!! wikitext +<pre width="8">Narrow screen goodies</pre> +!! html +<pre width="8">Narrow screen goodies</pre> + +!! end + +!! test +<pre> with forbidden attribute (T5202) +!! wikitext +<pre width="8" onmouseover="alert(document.cookie)">Narrow screen goodies</pre> +!! html +<pre width="8">Narrow screen goodies</pre> + +!! end + +!! test +Entities inside <pre> +!! wikitext +<pre><</pre> +!! html +<pre><</pre> + +!! end + +!! test +<pre> with forbidden attribute values (T5202) +!! wikitext +<pre width="8" style="border-width: expression(alert(document.cookie))">Narrow screen goodies</pre> +!! html +<pre width="8" style="/* insecure input */">Narrow screen goodies</pre> + +!! end + +!! test +<nowiki> inside <pre> (T15238) +!! wikitext +<pre> +<nowiki> +</pre> +<pre> +<nowiki></nowiki> +</pre> +<pre><nowiki><nowiki></nowiki>Foo<nowiki></nowiki></nowiki></pre> +!! html +<pre> +<nowiki> +</pre> +<pre> + +</pre> +<pre><nowiki>Foo</nowiki></pre> + +!! end + +!! test +<nowiki> inside of #tag:pre +!! wikitext +{{#tag:pre|Foo <nowiki>→bar</nowiki>}} +!! html/php +<pre>Foo →bar</pre> + +!! html/parsoid +<pre about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"#tag:pre","function":"tag"},"params":{"1":{"wt":"Foo <nowiki>&rarr;bar</nowiki>"}},"i":0}}]}'>Foo <span typeof="mw:Entity">→</span>bar</pre> +!! end + +## Don't expect this to rt, Parsoid drops the unmatched closing pre tags that +## aren't enclosed in nowikis. +!! test +<nowiki> and <pre> preference (first one wins) +!! options +parsoid=wt2html +!! wikitext +<pre> +<nowiki> +</pre> +</nowiki> +</pre> + +<nowiki> +<pre> +<nowiki> +</pre> +</nowiki> +</pre> + +!! html/php +<pre> +<nowiki> +</pre> +<p></nowiki> +</pre> +</p><p> +<pre> +<nowiki> +</pre> + +</pre> +</p> +!! html/parsoid +<pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n<nowiki>\n"}}'><nowiki> +</pre> +<p></nowiki></p> + + +<p><span typeof="mw:Nowiki"> +<pre> +<nowiki> +</pre> +</span></p> +!! end + +!! test +</pre> inside nowiki +!! wikitext +<nowiki></pre></nowiki> +!! html +<p></pre> +</p> +!! end + +!! test +Empty pre; pre inside other HTML tags (T56946) +!! wikitext +a + +<div><pre> +foo +</pre></div> +<pre></pre> +!! html/php+tidy +<p>a +</p> +<div><pre>foo +</pre></div> +<pre></pre> +!! html/parsoid +<p>a</p> + +<div data-parsoid='{"stx":"html"}'><pre typeof="mw:Extension/pre" about="#mwt2" data-parsoid='{"stx":"html"}' data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\nfoo\n"}}'>foo +</pre></div> +<pre typeof="mw:Extension/pre" about="#mwt4" data-parsoid='{"stx":"html"}' data-mw='{"name":"pre","attrs":{},"body":{"extsrc":""}}'></pre> +!! end + +!! test +HTML pre followed by indent-pre +!! wikitext +<pre>foo</pre> + bar +!! html +<pre>foo</pre> +<pre>bar +</pre> +!! end + +!! test +Block tag pre +!! wikitext +<p><pre>foo</pre></p> +!! html/php+tidy +<p class="mw-empty-elt"></p><pre>foo</pre><p class="mw-empty-elt"></p> +!! html/parsoid +<p class='mw-empty-elt' data-parsoid='{"stx":"html","autoInsertedEnd":true}'></p><pre typeof="mw:Extension/pre" about="#mwt2" data-parsoid='{"stx":"html"}' data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo"}}'>foo</pre><p class='mw-empty-elt' data-parsoid='{"autoInsertedStart":true,"stx":"html"}'></p> +!! end + +!!test +Templates: Indent-Pre: 1a. Templates that break a line should suppress <pre> +!! wikitext + {{echo|}} +!! html + +!!end + +!!test +Templates: Indent-Pre: 1b. Templates that break a line should suppress <pre> +!! wikitext + {{echo| +foo}} +!! html +<p>foo +</p> +!!end + +!! test +Templates: Indent-Pre: 1c: Wrapping should be based on expanded content +!! wikitext + {{echo|a +b}} +!! html +<pre>a +</pre> +<p>b +</p> +!!end + +!! test +Templates: Indent-Pre: 1d: Wrapping should be based on expanded content +!! wikitext + {{echo|a +b +c + d +e +}} +!! html +<pre>a +</pre> +<p>b +c +</p> +<pre>d +</pre> +<p>e +</p> +!!end + +!!test +Templates: Indent-Pre: 1e. Wrapping should be based on expanded content +!! wikitext +{{echo| foo}} + +{{echo| foo}}{{echo| bar}} + +{{echo| foo}} +{{echo| bar}} + +{{echo|<!--cmt--> foo}} + +<!--cmt-->{{echo| foo}} + +{{echo|{{echo| }}bar}} +!! html +<pre>foo +</pre> +<pre>foo bar +</pre> +<pre>foo +bar +</pre> +<pre>foo +</pre> +<pre>foo +</pre> +<pre>bar +</pre> +!!end + +!! test +Templates: Indent-Pre: 1f: Wrapping should be based on expanded content +!! wikitext +{{echo| }}a + +{{echo| + }}a + +{{echo| + b}} + +{{echo|a + }}b + +{{echo|a +}} b +!! html +<pre>a +</pre> +<p><br /> +</p> +<pre>a +</pre> +<p><br /> +</p> +<pre>b +</pre> +<p>a +</p> +<pre>b +</pre> +<p>a +</p> +<pre>b +</pre> +!!end + +## Hmm, should Parsoid rt this? +!! test +Pres with newline attributes +!! options +parsoid=wt2html,html2html +!! wikitext +<pre class="one +two">hi</pre> +!! html/php +<pre class="one two">hi</pre> + +!! html/parsoid +<pre typeof="mw:Extension/pre" about="#mwt2" class="one two" data-mw='{"name":"pre","attrs":{"class":"one two"},"body":{"extsrc":"hi"}}'>hi</pre> +!! end + +!! test +Things that look like <pre> tags aren't treated as such +!! wikitext +Barack Obama <President> of the United States +<President></President> +!! html +<p>Barack Obama <President> of the United States +<President></President> +</p> +!! end + +!! test +Handle broken pre-like tags (T66025) +!! options +parsoid=wt2html +!! wikitext +{{echo|<pre <pre>x</pre>}} + +<table><pre </table> +!! html/php +<pre>x</pre> +<table><pre </table> + +!! html/php+tidy +<pre>x</pre> +<pre <table></table> +!! html/parsoid +<pre about="#mwt1" typeof="mw:Transclusion mw:Extension/pre" data-parsoid='{"a":{"<pre":null},"sa":{"<pre":""},"stx":"html","pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"<pre <pre>x</pre>"}},"i":0}}]}'>x</pre> + + +<p><pre </p> + +<table></table> +!! end + +!! test +Parsoid: handle pre with space after attribute +!! options +parsoid=wt2html +!! wikitext +<pre style="width:50%;" >{{echo|foo}}</pre> +!! html/php +<pre style="width:50%;">{{echo|foo}}</pre> + +!! html/parsoid +<pre typeof="mw:Extension/pre" about="#mwt2" style="width:50%;" data-mw='{"name":"pre","attrs":{"style":"width:50%;"},"body":{"extsrc":"{{echo|foo}}"}}'>{{echo|foo}}</pre> +!! end + +# TODO / maybe: fix wt2wt for this +!! test +Parsoid: Don't paragraph-wrap fosterable content +!! options +parsoid=wt2html +!! wikitext +{| +<td></td> +<td></td> + + + +|} +!! html +<table> + +<tbody> +<tr> +<td></td> + +<td></td></tr> + + + +</tbody></table> +!! end + +!! test +Self-closed pre +!! wikitext +<pre /> +!! html/php +<pre></pre> + +!! html/parsoid +<pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":null}'></pre> +!! end + +!! test +Parsoid: Don't paragraph-wrap fosterable content even if table syntax is unbalanced +!! options +parsoid=wt2html +!! wikitext +{| +<td> +<td> +</td> + + + +|} +!! html +<table> + +<tbody> +<tr> +<td></td> + +<td> +</td></tr> + + + +</tbody></table> +!! end + + +#-------------------------------------------------------------------- +# Transclusion parameter whitespace stripping tests +# Behavior is different for positional and named parameters +#-------------------------------------------------------------------- +!! test +Templates: Strip leading and trailing whitespace from named-param values +!! wikitext +{{echo|1= a }} + +{{echo|1= {{echo|b}} }} + +{{echo| 1 = + c }} + +{{echo| 1 = +* d +}} +!! html +<p>a +</p><p>b +</p><p>c +</p> +<ul><li>d</li></ul> + +!! end + +!! test +Templates: Don't strip whitespace from positional-param values +!! wikitext +{{echo|a }} + +{{echo|{{echo|b}} }} + +{{echo| c +}} + +{{echo| {{echo|d}} +}} + +{{echo| + e}} + +{{echo| +*f}} + +{{echo| + }}g +!! html +<p>a +</p><p>b +</p> +<pre>c +</pre> +<p><br /> +</p> +<pre>d +</pre> +<p><br /> +</p> +<pre>e +</pre> +<p><br /> +</p> +<ul><li>f</li></ul> +<p><br /> +</p> +<pre>g +</pre> +!! end + +!! test +Templates: Don't recognize targets split by newlines +!! options +parsoid=wt2html +!! wikitext +{{ech +o|foo}} +!! html/php +<p>{{ech +o|foo}} +</p> +!! html/parsoid +<p>{{ech +o|foo}}</p> +!! end + +!! test +Templates: Recognize targets when newlines and comments don't split the target +!! options +parsoid=wt2html +!! wikitext +{{ + <!--X--> ech<!--X-->o<!--X--> + <!--X--> <!--X--> + + |foo}} +!! html/php +<p>foo +</p> +!! html/parsoid +<p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"ech<!--X-->o<!--X--> \n <!--X--> <!--X-->\n\n ","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</p> +!! end + +!! test +Templates: Handle empty comment-and-ws-only lines correctly +!! wikitext +{{echo|foo +<!--should be ignored--> + <!--should be ignored as well--> +bar}} +!! html/php +<p>foo +bar +</p> +!! html/parsoid +<p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo\n<!--should be ignored-->\n <!--should be ignored as well-->\nbar"}},"i":0}}]}'>foo <!--should be ignored--> <!--should be ignored as well--> bar</p> +!! end + +!! test +Templates: Handle comments in the target +!! wikitext +{{echo +<!-- should be ignored --> +|foo}} + +{{echo +<!-- should be ignored and spaces on next line should not trip us up (T147742) --> + |foo}} + +{{echo<!-- should be ignored --> +|foo}} + +{{echo<!-- should be ignored -->|foo}} + +{{<!-- should be ignored -->echo|foo}} +!! html/php +<p>foo +</p><p>foo +</p><p>foo +</p><p>foo +</p><p>foo +</p> +!! html/parsoid +<p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo\n<!-- should be ignored -->\n","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</p> + +<p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo\n<!-- should be ignored and spaces on next line should not trip us up (T147742) -->\n ","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</p> + +<p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo<!-- should be ignored -->\n","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</p> + +<p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo<!-- should be ignored -->","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</p> + +<p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</p> +!! end + +!! test +Templates: Handle comments in parameter names (T69657) +!! wikitext +{{echo|1 +<!-- should be ignored --> +=foo}} + +{{echo| +<!-- should be ignored --> +1 = foo}} + +{{echo|1<!-- should be ignored -->=foo}} + +{{echo|<!-- should be ignored -->1=foo}} +!! html/php +<p>foo +</p><p>foo +</p><p>foo +</p><p>foo +</p> +!! html/parsoid +<p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo","key":{"wt":"1\n<!-- should be ignored -->"}}},"i":0}}]}'>foo</p> + +<p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo","key":{"wt":"<!-- should be ignored -->\n1"}}},"i":0}}]}'>foo</p> + +<p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo","key":{"wt":"1<!-- should be ignored -->"}}},"i":0}}]}'>foo</p> + +<p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo","key":{"wt":"<!-- should be ignored -->1"}}},"i":0}}]}'>foo</p> +!! end + +!! test +Templates: Other wikitext in parameter names (T69657) +!! wikitext +{{echo|''1''=foo}} +!! html/php +<p>{{{1}}} +</p> +!! html/parsoid +<p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"''1''":{"wt":"foo"}},"i":0}}]}'>{{{1}}}</p> +!! end + +!! test +Templates: With colons +!! wikitext +{{With: Colon}} +!! html/php +<p>Template with colon +</p> +!! html/parsoid +<p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"With: Colon","href":"./Template:With:_Colon"},"params":{},"i":0}}]}'>Template with colon</p> +!! end + +#-------------------------------------------------------------------- +# Transclusion parameter escaping tests +#-------------------------------------------------------------------- + +!! test +Templates: Parsoid parameter escaping test 1 +!! wikitext +{{echo|[foo]|{{echo|[bar]}}}} +!! html/php+tidy +<p>[foo] +</p> +!! html/parsoid +<p about="#mwt1" typeof="mw:Transclusion" +data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[foo]"},"2":{"wt":"{{echo|[bar]}}"}},"i":0}}]}'>[foo]</p> +!! end + +!! test +Parsoid: Pipes in external links in template parameter +!! wikitext +{{echo|[{{echo|http://example.com}} link]}} +!! html/php+tidy +<p><a rel="nofollow" class="external text" href="http://example.com">link</a> +</p> +!! html/parsoid +<p><a rel="mw:ExtLink" class="external text" href="http://example.com" about="#mwt31" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[{{echo|http://example.com}} link]"}},"i":0}}]}'>link</a></p> +!! end + +!! test +Parsoid: pipe in transclusion parameter +!! wikitext +{{echo|http://foo.com/a|b}} +!! html/php+tidy +<p><a rel="nofollow" class="external free" href="http://foo.com/a%7Cb">http://foo.com/a%7Cb</a> +</p> +!! html/parsoid +<p><a rel="mw:ExtLink" class="external free" href="http://foo.com/a%7Cb" about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"http://foo.com/a&#124;b"}},"i":0}}]}'>http://foo.com/a%7Cb</a></p> +!! end + +!! test +Parsoid: Pipe in external link target and content in template parameter +!! options +parsoid=html2wt,wt2wt +!! wikitext +{{echo|[http://foo.com/a|b a|b]}} +!! html/php+tidy +<p><a rel="nofollow" class="external text" href="http://foo.com/a%7Cb">a|b</a> +</p> +!! html/parsoid +<p><a rel="mw:ExtLink" href="http://foo.com/a|b" about="#mwt1" +typeof="mw:Transclusion" +data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"}, +"params":{"1":{"wt":"[http://foo.com/a|b a|b]"}},"i":0}}]}'>a|b</a></p> +!! end + +!! test +Parsoid: Pipe in template with nested template in external link target in template parameter (seriously) +!! options +parsoid +!! wikitext +{{echo|[{{fullurl:{{FULLPAGENAME}}|action=edit}} bar]}} +!! html +<p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[{{fullurl:{{FULLPAGENAME}}|action=edit}} bar]"}},"i":0}}]}'>[Main Page bar]</p> +!! end + +!! test +Templates: Don't escape already nowiki-escaped text in template parameters +!! options +parsoid=html2wt,wt2wt +!! wikitext +{{echo|foo<nowiki>|</nowiki>bar}} +{{echo|<nowiki><div></nowiki>}} +{{echo|<nowiki></nowiki>}} +!! html/php+tidy +<p>foo|bar +<div> + +</p> +!! html/parsoid +<p><span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo<nowiki>|</nowiki>bar"}},"i":0}}]}'}'>foo</span><span typeof="mw:Nowiki" about="#mwt1">|</span><span about="#mwt1">bar</span> +<span typeof="mw:Transclusion mw:Nowiki" about="#mwt2" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"<nowiki>&lt;div&gt;</nowiki>"}},"i":0}}]}'><span typeof="mw:Entity"><</span>div<span typeof="mw:Entity">></span></span> +<span typeof="mw:Transclusion mw:Nowiki" about="#mwt3" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"<nowiki></nowiki>"}},"i":0}}]}'></span> +</p> +!! end + +## T54824 +!! test +Templates: '=' char in nested transclusions should not trigger nowiki escapes or conversion to named param +!! options +parsoid=html2wt,wt2wt +!! wikitext +{{echo|{{echo|1=bar}}}} +!! html/php+tidy +<p>bar +</p> +!! html/parsoid +<p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"{{echo|1=bar}}"}},"i":0}}]}'>bar</p> +!! end + +## T58733 +!! test +Templates parameters with special tokenizing behavior dont get modified because of arg escaping +!! wikitext +{{echo|a : b}} +!! html/php+tidy +<p>a : b +</p> +!! html/parsoid +<p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"a : b"}},"i":0}}]}'>a<span typeof="mw:DisplaySpace mw:Placeholder" data-parsoid='{"isDisplayHack":true}'> </span>: b</p> +!! end + +## T73412 +!! test +Templates: Preserve blank parameter names +!! wikitext +{{echo|=foo}} +!! html/php+tidy +<p>{{{1}}} +</p> +!! html/parsoid +<p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"":{"wt":"foo"}},"i":0}}]}'>{{{1}}}</p> +!! end + +!! test +Templates: Preserve blank parameter names in other positions +!! wikitext +{{blank_param|bar|=foo}} +!! html/php+tidy +<p>bar +foo +</p> +!! html/parsoid +<p about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1"},{"k":"","named":true}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"blank_param","href":"./Template:Blank_param"},"params":{"1":{"wt":"bar"},"":{"wt":"foo"}},"i":0}}]}'>bar +foo</p> +!! end + +### +### Parsoid-centric tests for testing RT edge cases for pre +### + +!!test +1a. Indent-Pre and Comments +!! wikitext + a +<!--a--> +c +!! html +<pre>a +</pre> +<p>c +</p> +!!end + +!!test +1b. Indent-Pre and Comments +!! wikitext + a + <!--a--> +c +!! html +<pre>a +</pre> +<p>c +</p> +!!end + +!!test +1c. Indent-Pre and Comments +!! wikitext +<!--a--> a + + <!--a--> a +!! html +<pre> a +</pre> +<pre> a +</pre> +!!end + +!!test +1d. Indent-Pre and Comments +(Pre-handler currently cannot distinguish between comment/ws order and normalizes them to [comment,ws] order) +!! wikitext +<!--a--> a + + <!--b-->b +!! html +<pre>a +</pre> +<pre>b +</pre> +!!end + +!!test +2a. Indent-Pre and tables +!! wikitext + {| + |- + !h1!!h2 + |foo||bar + |} +!! html +<table> + +<tr> +<th>h1</th> +<th>h2 +</th> +<td>foo</td> +<td>bar +</td></tr></table> + +!!end + +!!test +2b. Indent-Pre and tables +!! wikitext + {| + |- +|foo +|} +!! html +<table> + +<tr> +<td>foo +</td></tr></table> + +!!end + +!!test +2c. Indent-Pre and tables (T44252) +!! wikitext +{| + |+foo + ! |bar +|} +!! html +<table> +<caption>foo +</caption> +<tr> +<th>bar +</th></tr></table> + +!!end + +!!test +2d. Indent-Pre and tables +!! wikitext + a + {| + |b + |} +!! html/php +<pre>a +</pre> +<table> +<tr> +<td>b +</td></tr></table> + +!! html/parsoid +<pre>a</pre> + <table> + <tbody><tr><td> b</td></tr> + </tbody></table> +!!end + +!!test +2e. Indent-Pre and table-line syntax +!! wikitext + a + | b + | c +!! html/php +<pre>a +| b +| c +</pre> +!!end + +!!test +2f. Indent-pre started by table-line syntax +!! wikitext +a + | b + | c +!! html/php +<p>a +</p> +<pre>| b +| c +</pre> +!! html/parsoid +<p>a</p> +<pre> +| b +| c</pre> +!!end + +!! test +2g. Indented table markup mixed with indented pre content (proposed in T8200) +!! wikitext + <table> + <tr> + <td> + Text that should be rendered preformatted + </td> + </tr> + </table> +!! html + <table> + <tr> + <td> +<pre>Text that should be rendered preformatted +</pre> + </td> + </tr> + </table> + +!! end + +!!test +3a. Indent-Pre and block tags (single-line html) +!! wikitext + a <p> foo </p> + b <div> foo </div> + c <blockquote> foo </blockquote> + <span> foo </span> +!! html + a <p> foo </p> + b <div> foo </div> + c <blockquote> foo </blockquote> +<pre><span> foo </span> +</pre> +!! html/parsoid + <p>a </p><p data-parsoid='{"stx":"html"}'> foo </p> + <p>b </p><div data-parsoid='{"stx":"html"}'> foo </div> + <p>c </p><blockquote data-parsoid='{"stx":"html"}'> foo </blockquote> +<pre><span> foo </span> +</pre> +!! html/php+tidy +<p> a </p><p> foo </p><p> + b </p><div> foo </div><p> + c </p><blockquote><p> foo </p></blockquote> +<pre><span> foo </span> +</pre> +!! end + +!!test +3b. Indent-Pre and block tags (multi-line html) +!! wikitext + a <span>foo</span> + b <div> foo </div> +!! html +<pre>a <span>foo</span> +</pre> + b <div> foo </div> + +!! html/parsoid +<pre>a <span data-parsoid='{"stx":"html"}'>foo</span></pre> + b <div data-parsoid='{"stx":"html"}'> foo </div> +!! html/php+tidy +<pre>a <span>foo</span> +</pre><p> + b </p><div> foo </div> +!!end + +!!test +3c. Indent-Pre and block tags (pre-content on separate line) +!! wikitext +<p> + foo +</p> + +<div> + foo +</div> + +<center> + foo +</center> + +<blockquote> + foo +</blockquote> + +<blockquote> +<pre> +foo +</pre> +</blockquote> + +<table><tr><td> + foo +</td></tr></table> + +<ul><li> + foo +</li></ul> + +!! html +<p> + foo +</p> +<div> +<pre>foo +</pre> +</div> +<center> +<pre>foo +</pre> +</center> +<blockquote> +<p> foo +</p> +</blockquote> +<blockquote> +<pre> +foo +</pre> +</blockquote> +<table><tr><td> +<pre>foo +</pre> +</td></tr></table> +<ul><li> + foo +</li></ul> + +!!end + +!! test +4. Indent-Pre and extension tags +!! wikitext + a <tag /> +!! html/php + a <pre> +NULL +array ( +) +</pre> + +!! html/parsoid + a <pre typeof="mw:Extension/tag" about="#mwt2" data-parsoid='{}' data-mw='{"name":"tag","attrs":{},"body":null}'></pre> +!! end + +!! test +5. Indent-Pre and html pre +!! wikitext + <pre class="123">hi</pre> +!! html/php + <pre class="123">hi</pre> + +!! html/parsoid + <pre typeof="mw:Extension/pre" about="#mwt2" class="123" data-mw='{"name":"pre","attrs":{"class":"123"},"body":{"extsrc":"hi"}}'>hi</pre> +!! end + +!!test +Render paragraphs when indent-pre is suppressed in blocklevels +!! wikitext +<blockquote> + foo + + bar +</blockquote> +!! html +<blockquote> +<p> foo +</p><p> bar +</p> +</blockquote> + +!!end + +!!test +4. Multiple spaces at start-of-line +!! wikitext + <p> foo </p> + foo + {| +|foo +|} +!! html + <p> foo </p> +<pre> foo +</pre> +<table> +<tr> +<td>foo +</td></tr></table> + +!!end + +## NOTE: the leading white-space chars on empty line are significant +!! test +5a. White-space in indent-pre +!! wikitext + a<br /> + + b +!! html +<pre>a<br /> + +b +</pre> +!! end + +## NOTE: the leading white-space chars on empty line are significant +!! test +5b. White-space in indent-pre +!! wikitext + a + + b + + + c +!! html +<pre>a + +b + + +c +</pre> +!! end + +!! test +5c. White-space in indent-pre +!! wikitext + ''a'' + ''b'' + ''c'' +!! html +<pre><i>a</i> + <i>b</i> + <i>c</i> +</pre> +!! end + +!! test +6. Pre-blocks should extend across lines with leading WS even when there is no wrappable content +!! wikitext + a + + <!-- continue --> + b + + c + +d +!! html +<pre>a + +b +</pre> +<pre>c + +</pre> +<p>d +</p> +!! end + +!! test +7a. Indent-pre and category links +!! options +parsoid=wt2html,wt2wt +!! wikitext + [[Category:foo]] <!-- No pre-wrapping --> +{{echo| [[Category:foo]]}} <!-- No pre-wrapping --> +!! html/php+tidy +!! html/parsoid + <link rel="mw:PageProp/Category" href="./Category:Foo"> <!-- No pre-wrapping --> +<span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":" [[Category:foo]]"}},"i":0}}]}'> </span><link rel="mw:PageProp/Category" href="./Category:Foo" about="#mwt1"> <!-- No pre-wrapping --> +!! end + +## We used to, but no longer wt2wt this test since the default serializer +## will normalize all categories to serialize on their own line. +## This wikitext usage is going to be fairly uncommon in production and +## selser will take care of preserving formatting in those scenarios. +!! test +7b. Indent-pre and category links +!! options +parsoid=wt2html +!! wikitext + [[Category:foo]] a + [[Category:foo]] {{echo|b}} +!! html/parsoid +<pre><link rel="mw:PageProp/Category" href="./Category:Foo"> a + <link rel="mw:PageProp/Category" href="./Category:Foo"> <span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"b"}},"i":0}}]}'>b</span></pre> +!! end + +!! test +Indent-Pre: Newlines in comments shouldn't affect sol state +!! wikitext +a <!-- +foo +--> b +!! html/php+tidy +<p>a b +</p> +!! html/parsoid +<p>a <!-- +foo +--> b</p> +!! end + +### +### HTML-pre (some to spec PHP parser behavior and some Parsoid-RT-centric) +### + +!!test +HTML-pre: 1. embedded newlines +!! wikitext +<pre>foo</pre> + +<pre> +foo +</pre> + +<pre> + +foo +</pre> + +<pre> + + +foo +</pre> +!! html/php+tidy +<pre>foo</pre> +<pre>foo +</pre> +<pre> + +foo +</pre> +<pre> + + +foo +</pre> +!! html/parsoid +<pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo"}}'>foo</pre> + +<pre typeof="mw:Extension/pre" about="#mwt4" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\nfoo\n"}}'>foo +</pre> + +<pre typeof="mw:Extension/pre" about="#mwt6" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n\nfoo\n"}}'> + +foo +</pre> + +<pre typeof="mw:Extension/pre" about="#mwt8" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n\n\nfoo\n"}}'> + + +foo +</pre> +!!end + +!! test +HTML-pre: big spaces +!! wikitext +<pre> + + + + +haha + + + + +haha + + + + +</pre> +!! html/php+tidy +<pre> + + + + +haha + + + + +haha + + + + +</pre> +!! html/parsoid +<pre typeof="mw:Extension/pre" about="#mwt2" data-parsoid='{"stx":"html"}' data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n\n\n\n\nhaha\n\n\n\n\nhaha\n\n\n\n\n"}}'> + + + + +haha + + + + +haha + + + + +</pre> +!! end + +!!test +HTML-pre: 2: indented text +!! wikitext +<pre> + foo +</pre> +!! html +<pre> + foo +</pre> + +!!end + +!!test +HTML-pre: 3: other wikitext +!! wikitext +<pre> +* foo +# bar += no-h = +'' no-italic '' +[[ NoLink ]] +</pre> +!! html/php +<pre> +* foo +# bar += no-h = +'' no-italic '' +[[ NoLink ]] +</pre> + +!! html/parsoid +<pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n* foo\n# bar\n= no-h =\n'' no-italic ''\n[[ NoLink ]]\n"}}'>* foo +# bar += no-h = +'' no-italic '' +[[ NoLink ]] +</pre> +!!end + +### +### Definition lists +### +!! test +Simple definition +!! wikitext +;name :Definition +!! html +<dl><dt>name </dt> +<dd>Definition</dd></dl> + +!! end + +!! test +Definition list for indentation only +!! wikitext +:Indented text +!! html +<dl><dd>Indented text</dd></dl> + +!! end + +!! test +Definition list with no space +!! wikitext +;name:Definition +!! html +<dl><dt>name</dt> +<dd>Definition</dd></dl> + +!!end + +!! test +Definition list with URL link +!! wikitext +;http://example.com/ :definition +!! html +<dl><dt><a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a> </dt> +<dd>definition</dd></dl> + +!! end + +!! test +Definition list with bracketed URL link +!! wikitext +;[http://www.example.com/ Example]:Something about it +!! html +<dl><dt><a rel="nofollow" class="external text" href="http://www.example.com/">Example</a></dt> +<dd>Something about it</dd></dl> + +!! end + +!! test +Definition list with wikilink containing colon +!! wikitext +; [[Help:FAQ]]:The least-read page on Wikipedia +!! html +<dl><dt><a href="/index.php?title=Help:FAQ&action=edit&redlink=1" class="new" title="Help:FAQ (page does not exist)">Help:FAQ</a></dt> +<dd>The least-read page on Wikipedia</dd></dl> + +!! end + +# At Brion's and JeLuF's insistence... :) +!! test +Definition list with news link containing colon +!! wikitext +;news:alt.wikipedia.rox: This isn't even a real newsgroup! +!! html/php +<dl><dt><a rel="nofollow" class="external free" href="news:alt.wikipedia.rox">news:alt.wikipedia.rox</a></dt> +<dd>This isn't even a real newsgroup!</dd></dl> + +!! html/parsoid +<dl><dt> <a rel="mw:ExtLink" class="external free" href="news:alt.wikipedia.rox" data-parsoid='{"stx":"url"}'>news:alt.wikipedia.rox</a></dt><dd data-parsoid='{"stx":"row"}'>This isn't even a real newsgroup!</dd></dl> +!! end + +!! test +Malformed definition list with colon +!! wikitext +; news:alt.wikipedia.rox -- don't crash or enter an infinite loop +!! html +<dl><dt><a rel="nofollow" class="external free" href="news:alt.wikipedia.rox">news:alt.wikipedia.rox</a> -- don't crash or enter an infinite loop</dt></dl> + +!! end + +!! test +Definition lists: colon in external link text +!! wikitext +;[http://www.wikipedia2.org/ Wikipedia :The Next Generation] :OK, I made that up +!! html +<dl><dt><a rel="nofollow" class="external text" href="http://www.wikipedia2.org/">Wikipedia :The Next Generation</a> </dt> +<dd>OK, I made that up</dd></dl> + +!! end + +!! test +Definition lists: colon in HTML attribute +!! wikitext +;<b style="display: inline">bold</b> +!! html +<dl><dt><b style="display: inline">bold</b></dt></dl> + +!! end + +!! test +Definition lists: self-closed tag +!! wikitext +;one<br/>two :two-line fun +!! html +<dl><dt>one<br />two </dt> +<dd>two-line fun</dd></dl> + +!! end + +!! test +Definition lists: ignore colons inside tags +!! wikitext +;one <b>two : tag <i>fun:</i>:</b>:def +!! html +<dl><dt>one <b>two : tag <i>fun:</i>:</b></dt> +<dd>def</dd></dl> + +!! end + +!! test +Definition lists: excess closed tags +!! wikitext +;one</b>two :bad tag fun +!! html/php+tidy +<dl><dt>onetwo </dt> +<dd>bad tag fun</dd></dl> +!! html/parsoid +<dl> +<dt>onetwo</dt> +<dd>bad tag fun</dd> +</dl> +!! end + +!! test +T13748: Literal closing tags +!! wikitext +<dl> +<dt>test 1</dt> +<dd>test test test test test</dd> +<dt>test 2</dt> +<dd>test test test test test</dd> +</dl> +!! html +<dl> +<dt>test 1</dt> +<dd>test test test test test</dd> +<dt>test 2</dt> +<dd>test test test test test</dd> +</dl> + +!! end + +!! test +Definition and unordered list using wiki syntax nested in unordered list using html tags. +!! wikitext +<ul><li> +;term :description +*unordered +</li></ul> +!! html +<ul><li> +<dl><dt>term </dt> +<dd>description</dd></dl> +<ul><li>unordered</li></ul> +</li></ul> + +!! end + +!! test +Definition list with empty definition and following paragraph +!! wikitext +;term: + +Paragraph text +!! html +<dl><dt>term</dt> +<dd></dd></dl> +<p>Paragraph text +</p> +!! end + +!! test +Nested definition lists using html syntax +!! wikitext +<dl><dt>x</dt> +<dd>a</dd> +<dd>b</dd></dl> +!! html +<dl><dt>x</dt> +<dd>a</dd> +<dd>b</dd></dl> + +!! end + +!! test +Definition Lists: No nesting: Multiple dd's +!! wikitext +;x +:a +:b +!! html +<dl><dt>x</dt> +<dd>a</dd> +<dd>b</dd></dl> + +!! end + +!! test +Definition Lists: Indentation: Regular +!! wikitext +:i1 +::i2 +:::i3 +!! html +<dl><dd>i1 +<dl><dd>i2 +<dl><dd>i3</dd></dl></dd></dl></dd></dl> + +!! end + +!! test +Definition Lists: Indentation: Missing 1st level +!! wikitext +::i2 +:::i3 +!! html +<dl><dd><dl><dd>i2 +<dl><dd>i3</dd></dl></dd></dl></dd></dl> + +!! end + +!! test +Definition Lists: Indentation: Multi-level indent +!! wikitext +:::i3 +!! html +<dl><dd><dl><dd><dl><dd>i3</dd></dl></dd></dl></dd></dl> + +!! end + +!! test +Definition Lists: Hacky use to indent tables +!! wikitext +::{| +|foo +|bar +|} +this text +should be left alone +!! html +<dl><dd><dl><dd><table> +<tr> +<td>foo +</td> +<td>bar +</td></tr></table></dd></dl></dd></dl> +<p>this text +should be left alone +</p> +!! end + +!! test +Definition Lists: Hacky use to indent tables (with content following table) +!! wikitext +:{| +|foo +|bar +|} <!--c1--> this text should be part of the dl +!! html/php+tidy +<dl><dd><table> +<tbody><tr> +<td>foo +</td> +<td>bar +</td></tr></tbody></table> this text should be part of the dl</dd></dl> +!! html/parsoid +<dl><dd><table> +<tbody><tr> +<td>foo +</td> +<td>bar +</td></tr></tbody></table> <!--c1--> this text should be part of the dl</dd></dl> +!! end + +!! test +Definition Lists: Hacky use to indent tables, with comments (T65979) +!! wikitext +<!-- foo --> +::{| +|foo +|bar +|}<!-- bar --> +this text +should be left alone +!! html/parsoid +<!-- foo --> +<dl><dd><dl><dd><table><tr> +<td>foo</td> +<td>bar</td> +</tr></table><!-- bar --></dd></dl></dd></dl> +<p>this text +should be left alone</p> +!! end + +!! test +Definition Lists: Hacky use to indent tables, with comment before table +!! wikitext +::<!-- foo -->{| +|foo +|} +!! html/parsoid +<dl><dd><dl><dd><!-- foo --><table><tr> +<td>foo</td> +</tr></table></dd></dl></dd></dl> +!! end + +# The trailing whitespace in this test is to catch a regression in +# Parsoid after T54473. +!! test +Definition Lists: Hacky use to indent tables (WS-insensitive) +!! wikitext +: {| +|a +|} +!! html/php +<dl><dd><table> +<tr> +<td>a +</td></tr></table></dd></dl> + +!! html/parsoid +<dl><dd> <table> +<tbody><tr><td>a</td></tr> +</tbody></table> </dd></dl> +!! end + +## The PHP parser treats : items (dd) without a corresponding ; item (dt) +## as an empty dt item. It also ignores all but the last ";" when followed +## by ":" later on. So, ";" are not ignored in ";;;t3" but are ignored in +## ";;;t3 :d1". So, PHP parser behavior is a little inconsistent wrt multiple +## ";"s. +## +## Ex: ";;t2 ::d2" is transformed into: +## +## <dl> +## <dt>t2 </dt> +## <dd> +## <dl> +## <dt></dt> +## <dd>d2</dd> +## </dl> +## </dd> +## </dl> +## +## But, Parsoid treats "; :" as a tight atomic unit and excess ":" as plain text +## So, the same wikitext above (;;t2 ::d2) is transformed into: +## +## <dl> +## <dt> +## <dl> +## <dt>t2 </dt> +## <dd>:d2</dd> +## </dl> +## </dt> +## </dl> +## +## All Parsoid only definition list tests have this difference. +## +## See also: https://phabricator.wikimedia.org/T8569 +## and https://lists.wikimedia.org/pipermail/wikitext-l/2011-November/000483.html + +!! test +Table / list interaction: indented table with lists in table contents +!! wikitext +:{| +|- +|a + +*b +|- +|c + +*d +|} +!! html +<dl><dd><table> + +<tr> +<td>a +<ul><li>b</li></ul> +</td></tr> +<tr> +<td>c +<ul><li>d</li></ul> +</td></tr></table></dd></dl> + +!! end + +!!test +Table / list interaction: lists nested in tables nested in indented lists +!! wikitext +:{| +| +:a +:b +| +*c +*d +|} + +*e +*f +!! html +<dl><dd><table> +<tr> +<td> +<dl><dd>a</dd> +<dd>b</dd></dl> +</td> +<td> +<ul><li>c</li> +<li>d</li></ul> +</td></tr></table></dd></dl> +<ul><li>e</li> +<li>f</li></ul> + +!!end + +!! test +Definition Lists: Nesting: Multi-level (Parsoid only) +!! wikitext +;t1 :d1 +;;t2 ::d2 +;;;t3 :::d3 +!! html/parsoid +<dl> + <dt>t1 </dt> + <dd>d1</dd> + <dt> + <dl> + <dt>t2 </dt> + <dd>:d2</dd> + <dt> + <dl> + <dt>t3 </dt> + <dd>::d3</dd> + </dl> + </dt> + </dl> + </dt> +</dl> + + +!! end + + +!! test +Definition Lists: Nesting: Test 2 +!! wikitext +;t1 +::d2 +!! html+tidy +<dl><dt>t1</dt> +<dd> +<dl><dd>d2</dd></dl></dd></dl> +!! end + + +!! test +Definition Lists: Nesting: Test 3 +!! wikitext +:;t1 +::::d2 +!! html+tidy +<dl><dd><dl><dt>t1</dt> +<dd> +<dl><dd><dl><dd>d2</dd></dl></dd></dl></dd></dl></dd></dl> +!! end + + +!! test +Definition Lists: Nesting: Test 4 +!! wikitext +::;t3 +:::d3 +!! html +<dl><dd><dl><dd><dl><dt>t3</dt> +<dd>d3</dd></dl></dd></dl></dd></dl> + +!! end + + +## The Parsoid team believes the following three test exposes a +## bug in the PHP parser. (Parsoid team thinks the PHP parser is +## wrong to close the <dl> after the <dt> containing the <ul>.) +## It also exposes a "misfeature" in tidy, which doesn't like +## <dl> tags with a single <dt> child; it converts the <dt> into +## a <dd> in that case. (Parsoid leaves the <dt> alone!) +!! test +Definition Lists: Mixed Lists: Test 1 +!! wikitext +:;*foo +::*bar +:;baz +!! html/php +<dl><dd><dl><dt><ul><li>foo</li> +<li>bar</li></ul></dt></dl> +<dl><dt>baz</dt></dl></dd></dl> + +!! html/php+tidy +<dl><dd><dl><dt><ul><li>foo</li> +<li>bar</li></ul></dt></dl> +<dl><dt>baz</dt></dl></dd></dl> +!! html/parsoid +<dl> +<dd><dl> +<dt><ul> +<li>foo +</li> +</ul></dt> +<dd><ul> +<li>bar +</li> +</ul></dd> +<dt>baz</dt> +</dl></dd> +</dl> +!! end + +!! test +Definition Lists: Mixed Lists: Test 2 +!! wikitext +*:d1 +*:d2 +!! html +<ul><li><dl><dd>d1</dd> +<dd>d2</dd></dl></li></ul> + +!! end + + +!! test +Definition Lists: Mixed Lists: Test 3 +!! wikitext +*:::d1 +*:::d2 +!! html +<ul><li><dl><dd><dl><dd><dl><dd>d1</dd> +<dd>d2</dd></dl></dd></dl></dd></dl></li></ul> + +!! end + + +!! test +Definition Lists: Mixed Lists: Test 4 +!! wikitext +*;d1 :d2 +*;d3 :d4 +!! html +<ul><li><dl><dt>d1 </dt> +<dd>d2</dd> +<dt>d3 </dt> +<dd>d4</dd></dl></li></ul> + +!! end + + +!! test +Definition Lists: Mixed Lists: Test 5 +!! wikitext +*:d1 +*::d2 +!! html +<ul><li><dl><dd>d1 +<dl><dd>d2</dd></dl></dd></dl></li></ul> + +!! end + + +!! test +Definition Lists: Mixed Lists: Test 6 +!! wikitext +#*:d1 +#*:::d3 +!! html +<ol><li><ul><li><dl><dd>d1 +<dl><dd><dl><dd>d3</dd></dl></dd></dl></dd></dl></li></ul></li></ol> + +!! end + + +!! test +Definition Lists: Mixed Lists: Test 7 +!! wikitext +:*d1 +:*d2 +!! html +<dl><dd><ul><li>d1</li> +<li>d2</li></ul></dd></dl> + +!! end + + +!! test +Definition Lists: Mixed Lists: Test 8 +!! wikitext +:*d1 +::*d2 +!! html +<dl><dd><ul><li>d1</li></ul> +<dl><dd><ul><li>d2</li></ul></dd></dl></dd></dl> + +!! end + + +!! test +Definition Lists: Mixed Lists: Test 9 +!! wikitext +*;foo :bar +!! html +<ul><li><dl><dt>foo </dt> +<dd>bar</dd></dl></li></ul> + +!! end + + +!! test +Definition Lists: Mixed Lists: Test 10 +!! wikitext +*#;foo :bar +!! html +<ul><li><ol><li><dl><dt>foo </dt> +<dd>bar</dd></dl></li></ol></li></ul> + +!! end + +# The Parsoid team disagrees with the PHP parser's seemingly-random +# rules regarding dd/dt on the next few tests. Parsoid is more +# consistent, and recognizes the shared nesting and keeps the +# still-open tags around until the nesting is complete. + +# This is a regression test for T175099 +!! test +Definition Lists: Mixed Lists: Test 11 +!! wikitext +;a +:*b +!! html/php +<dl><dt>a</dt> +<dd> +<ul><li>b</li></ul></dd></dl> + +!! html/parsoid +<dl><dt>a +<dd><ul><li>b</li></ul></dd></dl> +!! end + +# FIXME: Maybe get rid of this test? +!! test +Definition Lists: Mixed Lists: Test 12 +!! wikitext +*#*#;*;;foo :bar +*#*#;boo :baz +!! html/php +<ul><li><ol><li><ul><li><ol><li><dl><dt>foo </dt> +<dd><ul><li><dl><dt><dl><dt>bar</dt></dl></dd></dl></li></ul></dd></dl> +<dl><dt>boo </dt> +<dd>baz</dd></dl></li></ol></li></ul></li></ol></li></ul> + +!! html/php+tidy +<ul><li><ol><li><ul><li><ol><li><dl><dt>foo </dt> +<dd><ul><li><dl><dt><dl><dt>bar</dt></dl></dt></dl></li></ul></dd></dl></li></ol></li></ul> +<dl><dt>boo </dt> +<dd>baz</dd></dl></li></ol></li></ul> +!! html/parsoid +<ul> +<li> +<ol> +<li> +<ul> +<li> +<ol> +<li> +<dl> +<dt> +<ul> +<li> +<dl> +<dt> +<dl> +<dt>foo<span typeof="mw:Placeholder" data-parsoid='{"src":" "}'> </span></dt> +<dd data-parsoid='{"stx":"row"}'>bar</dd> +</dl></dt> +</dl></li> +</ul></dt> +<dt>boo<span typeof="mw:Placeholder" data-parsoid='{"src":" "}'> </span></dt> +<dd data-parsoid='{"stx":"row"}'>baz</dd> +</dl></li> +</ol></li> +</ul></li> +</ol></li> +</ul> +!! end + +# FIXME: Maybe get rid of this test? +# From whitelist: +# * The test is wrong, there are two colons where there should be :; +# * The PHP parser is wrong to close the <dl> after the <dt> containing the <ul>. +!! test +Definition Lists: Weird Ones: Test 1 +!! wikitext +*#;*::;;foo :bar (who uses this?) +!! html/php+tidy +<ul><li><ol><li><dl><dt>foo </dt> +<dd><ul><li><dl><dd><dl><dd><dl><dt><dl><dt>bar (who uses this?)</dt></dl></dt></dl></dd></dl></dd></dl></li></ul></dd></dl></li></ol></li></ul> +!! html/parsoid +<ul> +<li> +<ol> +<li> +<dl> +<dt> +<ul> +<li> +<dl> +<dd> +<dl> +<dd> +<dl> +<dt> +<dl> +<dt>foo<span typeof="mw:DisplaySpace mw:Placeholder" data-parsoid='{"src":" ","isDisplayHack":true}'> </span></dt> +<dd data-parsoid='{"stx":"row"}'>bar (who uses this?)</dd> +</dl></dt> +</dl></dd> +</dl></dd> +</dl></li> +</ul></dt> +</dl></li> +</ol></li> +</ul> +!! end + +!! test +Definition Lists: colons occurring in tags +!! wikitext +;a:b +;'''a:b''' +;<i>a:b</i> +;<span>a:b</span> +;<div>a:b</div> +;<div>a +:b</div> +;{{echo|a:b}} +;{{echo|''a:b''}} +;;;''a:b'' +!! html+tidy +<dl><dt>a</dt> +<dd>b</dd> +<dt><b>a:b</b></dt> +<dt><i>a:b</i></dt> +<dt><span>a:b</span></dt> +<dt><div>a:b</div></dt> +<dt><div>a</div></dt> +<dd>b</dd> +<dt>a</dt> +<dd>b</dd> +<dt><i>a:b</i></dt></dl> +<dl><dt><dl><dt><dl><dt><i>a:b</i></dt></dl></dt></dl></dt></dl> +!! html/parsoid +<dl><dt>a</dt><dd data-parsoid='{"stx":"row"}'>b</dd> +<dt><b>a:b</b></dt> +<dt><i data-parsoid='{"stx":"html"}'>a:b</i></dt> +<dt><span data-parsoid='{"stx":"html"}'>a:b</span></dt> +<dt><div data-parsoid='{"stx":"html"}'>a:b</div></dt> +<dt><div data-parsoid='{"stx":"html","autoInsertedEnd":true}'>a</div></dt> +<dd>b</dd> +<dt><span about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"a:b"}},"i":0}}]}'>a:b</span></dt> +<dt><i about="#mwt2" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"''a:b''"}},"i":0}}]}'>a:b</i> +<dl><dt><dl><dt><i>a:b</i></dt></dl></dt></dl></dt></dl> +!! end + +# Parsoid's output differs here again because it shares +# nesting between the two lists unlike the PHP parser. +# Unsure which is more desirable. +!! test +Definition Lists: colons and tables 1 +!! wikitext +:{| +|x +|} +:{| +|y +|} +!! html/php +<dl><dd><table> +<tr> +<td>x +</td></tr></table></dd></dl> +<dl><dd><table> +<tr> +<td>y +</td></tr></table></dd></dl> + +!! html/parsoid +<dl><dd><table> +<tr> +<td>x +</td></tr></table></dd> +<dd><table> +<tr> +<td>y +</td></tr></table></dd></dl> +!! end + +# FIXME: Does this need a html/php section? +!! test +Definition Lists: template interaction +!! wikitext +::{{definition_list}} + +:one +::{{definition_list}} +:::two +:::three +::four +!! html/parsoid +<dl><dd><dl data-parsoid='{}'><dd about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[]]}' data-mw='{"parts":[":",{"template":{"target":{"wt":"definition_list","href":"./Template:Definition_list"},"params":{},"i":0}}]}'>one</dd><span about="#mwt1"> +</span><dd about="#mwt1">two</dd></dl></dd></dl> + +<dl><dd data-parsoid='{}'>one +<dl><dd about="#mwt2" typeof="mw:Transclusion" data-parsoid='{"pi":[[]]}' data-mw='{"parts":["::",{"template":{"target":{"wt":"definition_list","href":"./Template:Definition_list"},"params":{},"i":0}},"\n:::two\n:::three"]}'>one</dd><span about="#mwt2"> +</span><dd about="#mwt2">two +<dl><dd>two</dd> +<dd>three</dd></dl></dd> +<dd data-parsoid='{}'>four</dd></dl></dd></dl> +!! end + + +### +### External links +### +!! test +External links: non-bracketed +!! wikitext +Non-bracketed: http://example.com +!! html +<p>Non-bracketed: <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> +</p> +!! end + +# parsoid doesn't explicitly mark autonumbered links, see T55505 +!! test +External links: numbered +!! wikitext +Numbered: [http://example.com] +Numbered: [http://example.net] +Numbered: [http://example.com] +!! html/php +<p>Numbered: <a rel="nofollow" class="external autonumber" href="http://example.com">[1]</a> +Numbered: <a rel="nofollow" class="external autonumber" href="http://example.net">[2]</a> +Numbered: <a rel="nofollow" class="external autonumber" href="http://example.com">[3]</a> +</p> +!! html/parsoid +<p>Numbered: <a rel="mw:ExtLink" class="external autonumber" href="http://example.com"></a> +Numbered: <a rel="mw:ExtLink" class="external autonumber" href="http://example.net"></a> +Numbered: <a rel="mw:ExtLink" class="external autonumber" href="http://example.com"></a></p> +!!end + +!! test +External links: specified text +!! wikitext +Specified text: [http://example.com link] +!! html +<p>Specified text: <a rel="nofollow" class="external text" href="http://example.com">link</a> +</p> +!!end + +!! test +External links: trail +!! wikitext +Linktrails should not work for external links: [http://example.com link]s +!! html +<p>Linktrails should not work for external links: <a rel="nofollow" class="external text" href="http://example.com">link</a>s +</p> +!! end + +!! test +External links: dollar sign in URL +!! wikitext +http://example.com/1$2345 +!! html +<p><a rel="nofollow" class="external free" href="http://example.com/1$2345">http://example.com/1$2345</a> +</p> +!! end + +# parsoid doesn't explicitly mark autonumbered links, see T55505 +!! test +External links: dollar sign in URL (autonumber) +!! wikitext +[http://example.com/1$2345] +!! html/php +<p><a rel="nofollow" class="external autonumber" href="http://example.com/1$2345">[1]</a> +</p> +!! html/parsoid +<p><a rel="mw:ExtLink" class="external autonumber" href="http://example.com/1$2345"></a></p> +!!end + +!! test +External links: open square bracket forbidden in URL (T6377) +!! options +parsoid=wt2html,wt2wt,html2html +!! wikitext +http://example.com/1[2345 +!! html/php +<p><a rel="nofollow" class="external free" href="http://example.com/1">http://example.com/1</a>[2345 +</p> +!! html/parsoid +<p><a rel="mw:ExtLink" class="external free" href="http://example.com/1">http://example.com/1</a>[2345</p> +!! end + +!! test +External links: open square bracket forbidden in URL (named) (T6377) +!! options +parsoid=wt2html,html2html +!! wikitext +[http://example.com/1[2345] +!! html/php +<p><a rel="nofollow" class="external text" href="http://example.com/1">[2345</a> +</p> +!! html/parsoid +<p><a rel="mw:ExtLink" class="external text" href="http://example.com/1">[2345</a></p> +!!end + +# parsoid adds a space before the link name +!! test +External links: open square bracket forbidden in URL (named) (T6377) +Parsoid variant. +!! wikitext +[http://example.com/1 [2345] +!! html +<p><a rel="nofollow" class="external text" href="http://example.com/1">[2345</a> +</p> +!!end + +!! test +External links: nowiki in URL link text (T8230) +!! wikitext +[http://example.com/ <nowiki>''example site''</nowiki>] +!! html +<p><a rel="nofollow" class="external text" href="http://example.com/">''example site''</a> +</p> +!! end + +!! test +External links: newline forbidden in text (T8230 regression check) +!! wikitext +[http://example.com/ first +second] +!! html +<p>[<a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a> first +second] +</p> +!!end + +!! test +External links: Pipe char between url and text +!! wikitext +[http://example.com | link] +!! html +<p><a rel="nofollow" class="external text" href="http://example.com">| link</a> +</p> +!!end + +!! test +External links: protocol-relative URL in brackets +!! wikitext +[//example.com/ Test] +!! html +<p><a rel="nofollow" class="external text" href="//example.com/">Test</a> +</p> +!! end + +# parsoid doesn't explicitly mark autonumbered links, see T55505 +!! test +External links: protocol-relative URL in brackets without text +!! wikitext +[//example.com] +!! html/php +<p><a rel="nofollow" class="external autonumber" href="//example.com">[1]</a> +</p> +!! html/parsoid +<p><a rel="mw:ExtLink" class="external autonumber" href="//example.com"></a></p> +!! end + +!! test +External links: protocol-relative URL in free text is left alone +!! wikitext +//example.com/Foo +!! html +<p>//example.com/Foo +</p> +!!end + +!! test +External links: protocol-relative URL in the middle of a word is left alone (T32269) +!! wikitext +foo//example.com/Foo +!! html +<p>foo//example.com/Foo +</p> +!! end + +## html2wt and html2html will fail because we will prefer the :en: interwiki prefix over wikipedia: +!! test +External links: with no contents +!! options +parsoid=wt2html,wt2wt +!! wikitext +[http://en.wikipedia.org/wiki/Foo] + +[[wikipedia:Foo|Bar]] + +[[wikipedia:Foo|<span>Bar</span>]] +!! html/php +<p><a rel="nofollow" class="external autonumber" href="http://en.wikipedia.org/wiki/Foo">[1]</a> +</p><p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo">Bar</a> +</p><p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo"><span>Bar</span></a> +</p> +!! html/parsoid +<p><a rel="mw:ExtLink" class="external autonumber" href="http://en.wikipedia.org/wiki/Foo"></a></p> +<p><a rel="mw:WikiLink/Interwiki" href="http://en.wikipedia.org/wiki/Foo" title="wikipedia:Foo">Bar</a></p> +<p><a rel="mw:WikiLink/Interwiki" href="http://en.wikipedia.org/wiki/Foo" title="wikipedia:Foo"><span>Bar</span></a></p> +!! end + +!! test +External links: Free with trailing punctuation +!! wikitext +http://example.com, +http://example.com; +http://example.com\ +http://example.com. +http://example.com: +http://example.com! +http://example.com? +http://example.com) +http://example.com/url_with_(brackets) +(http://example.com/url_without_brackets) +http://example.com/url_with_entity& +http://example.com/url_with_entity& +http://example.com/url_with_entity& +http://example.com/url_with_entity +http://example.com/url_with_entity  +http://example.com/url_with_entity  +http://example.com/url_with_entity< +http://example.com/url_with_entity< +http://example.com/url_with_entity< +!! html/php +<p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>, +<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>; +<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>\ +<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>. +<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>: +<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>! +<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>? +<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>) +<a rel="nofollow" class="external free" href="http://example.com/url_with_(brackets)">http://example.com/url_with_(brackets)</a> +(<a rel="nofollow" class="external free" href="http://example.com/url_without_brackets">http://example.com/url_without_brackets</a>) +<a rel="nofollow" class="external free" href="http://example.com/url_with_entity&">http://example.com/url_with_entity&</a> +<a rel="nofollow" class="external free" href="http://example.com/url_with_entity&">http://example.com/url_with_entity&</a> +<a rel="nofollow" class="external free" href="http://example.com/url_with_entity&">http://example.com/url_with_entity&</a> +<a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>  +<a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>  +<a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>  +<a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>< +<a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>< +<a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>< +</p> +!! html/parsoid +<p><a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>, +<a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>; +<a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>\ +<a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>. +<a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>: +<a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>! +<a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>? +<a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>) +<a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_(brackets)">http://example.com/url_with_(brackets)</a> +(<a rel="mw:ExtLink" class="external free" href="http://example.com/url_without_brackets">http://example.com/url_without_brackets</a>) +<a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_entity&">http://example.com/url_with_entity&</a> +<a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_entity&">http://example.com/url_with_entity&</a> +<a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_entity&">http://example.com/url_with_entity&</a> +<a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a><span typeof="mw:Entity" data-parsoid='{"src":"&nbsp;","srcContent":" "}'> </span> +<a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a><span typeof="mw:Entity" data-parsoid='{"src":"&#xA0;","srcContent":" "}'> </span> +<a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a><span typeof="mw:Entity" data-parsoid='{"src":"&#160;","srcContent":" "}'> </span> +<a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a><span typeof="mw:Entity" data-parsoid='{"src":"&lt;","srcContent":"<"}'><</span> +<a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a><span typeof="mw:Entity" data-parsoid='{"src":"&#x3C;","srcContent":"<"}'><</span> +<a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a><span typeof="mw:Entity" data-parsoid='{"src":"&#60;","srcContent":"<"}'><</span></p> +!! end + +!! test +External links: tricky Parsoid html2html case +!! options +parsoid=wt2html,wt2wt,html2html +!! wikitext +http://example.com/url_with_entity&amp; +!! html/php +<p><a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp">http://example.com/url_with_entity&amp</a>; +</p> +!! html/parsoid +<p><a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_entity&amp">http://example.com/url_with_entity&amp</a>;</p> +!! end + +!! test +External links: Free with trailing quotes (T113666) +!! wikitext +'''News:''' Stuff here + +news:'a'b''c''d e +!! html/php +<p><b>News:</b> Stuff here +</p><p><a rel="nofollow" class="external free" href="news:'a'b">news:'a'b</a><i>c</i>d e +</p> +!! html/parsoid +<p><b>News:</b> Stuff here</p> +<p><a rel="mw:ExtLink" class="external free" href="news:'a'b">news:'a'b</a><i>c</i>d e</p> +!! end + +!! test +External links: with entity +!! wikitext +[http:// www.librarieswithoutborders.org Libraries without borders] +!! html/php +<p><a rel="nofollow" class="external text" href="http://+www.librarieswithoutborders.org">Libraries without borders</a> +</p> +!! html/parsoid +<p><a rel="mw:ExtLink" class="external text" href="http://+www.librarieswithoutborders.org" data-parsoid='{"a":{"href":"http://+www.librarieswithoutborders.org"},"sa":{"href":"http://&#x20;www.librarieswithoutborders.org"}}'>Libraries without borders</a></p> +!! end + +!! test +External links: Lone protocols are never linked (T105697) +!! wikitext +http:// +http://; +(http://) +bitcoin: +bitcoin:; +(bitcoin:) +!! html +<p>http:// +http://; +(http://) +bitcoin: +bitcoin:; +(bitcoin:) +</p> +!! end + +!! test +External links: No preceding word characters allowed (T67278) +!! wikitext +NOPEhttp://example.com +N0http://example.com +ok:http://example.com +ok-http://example.com +!! html +<p>NOPEhttp://example.com +N0http://example.com +ok:<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> +ok-<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> +</p> +!! end + +!! test +External links: nofollow domain exception +!! wikitext +A [https://no-nofollow.org/foobar link], and another [https://example.org link]. +!! html +<p>A <a class="external text" href="https://no-nofollow.org/foobar">link</a>, and another <a rel="nofollow" class="external text" href="https://example.org">link</a>. +</p> +!!end + +!! test +External image +!! wikitext +External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png +!! html +<p>External image: <img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png"/> +</p> +!! end + +!! test +External image from https +!! wikitext +External image from https: https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png +!! html +<p>External image from https: <img src="https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png"/> +</p> +!! end + +!! test +External image (when not allowed) +!! options +wgAllowExternalImages=0 +!! wikitext +External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png +!! html +<p>External image: <a rel="nofollow" class="external free" href="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png">http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png</a> +</p> +!! end + +!! test +Link to non-http image, no img tag +!! wikitext +Link to non-http image, no img tag: ftp://example.com/test.jpg +!! html +<p>Link to non-http image, no img tag: <a rel="nofollow" class="external free" href="ftp://example.com/test.jpg">ftp://example.com/test.jpg</a> +</p> +!! end + +!! test +External links: terminating separator +!! wikitext +Terminating separator: http://example.com/thing, +!! html +<p>Terminating separator: <a rel="nofollow" class="external free" href="http://example.com/thing">http://example.com/thing</a>, +</p> +!! end + +!! test +External links: intervening separator +!! wikitext +Intervening separator: http://example.com/1,2,3 +!! html +<p>Intervening separator: <a rel="nofollow" class="external free" href="http://example.com/1,2,3">http://example.com/1,2,3</a> +</p> +!! end + +!! test +External links: old bug with URL in query +!! wikitext +Old bug with URL in query: [http://example.com/thing?url=http://example.com link] +!! html +<p>Old bug with URL in query: <a rel="nofollow" class="external text" href="http://example.com/thing?url=http://example.com">link</a> +</p> +!! end + +!! test +External links: old URL-in-URL bug, mixed protocols +!! wikitext +And again with mixed protocols: [ftp://example.com?url=http://example.com link] +!! html +<p>And again with mixed protocols: <a rel="nofollow" class="external text" href="ftp://example.com?url=http://example.com">link</a> +</p> +!!end + +# Since Parsoid is starting to emit canonical wikitext for links, +# [http://example.com http://example.com] will not RT back to that +# form anymore. +!! test +External links: URL in text +!! options +parsoid=wt2html +!! wikitext +URL in text: [http://example.com http://example.com] +!! html/php +<p>URL in text: <a rel="nofollow" class="external text" href="http://example.com">http://example.com</a> +</p> +!! html/parsoid +<p>URL in text: <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a></p> +!! end + +!! test +External links: Clickable images +!! wikitext +ja-style clickable images: [http://example.com http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png] +!! html/php +<p>ja-style clickable images: <a rel="nofollow" class="external text" href="http://example.com"><img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png"/></a> +</p> +!! html/parsoid +<p>ja-style clickable images: <a rel="mw:ExtLink" class="external text" href="http://example.com"><img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png" data-parsoid='{"type":"extlink"}'/></a></p> +!! end + +!! test +External links: raw ampersand +!! wikitext +Old & use: http://x&y +!! html +<p>Old & use: <a rel="nofollow" class="external free" href="http://x&y">http://x&y</a> +</p> +!! end + +!! test +External links: encoded ampersand +!! wikitext +Old & use: http://x&y +!! html/php +<p>Old & use: <a rel="nofollow" class="external free" href="http://x&y">http://x&y</a> +</p> +!! html/parsoid +<p>Old <span typeof="mw:Entity">&</span> use: <a rel="mw:ExtLink" class="external free" href="http://x&y">http://x&y</a></p> +!! end + +!! test +External links: encoded equals (T8102) +!! wikitext +http://example.com/?foo=bar +!! html/php +<p><a rel="nofollow" class="external free" href="http://example.com/?foo=bar">http://example.com/?foo=bar</a> +</p> +!! html/parsoid +<p><a rel="mw:ExtLink" class="external free" href="http://example.com/?foo=bar">http://example.com/?foo=bar</a></p> +!! end + +## +## Note that parsoid doesn't explicit mark autonumbered links, nor +## does it number them. As discussed in T55505, we can identify +## autonumbered links via CSS. +## + +!! test +External links: [raw ampersand] +!! wikitext +Old & use: [http://x&y] +!! html/php +<p>Old & use: <a rel="nofollow" class="external autonumber" href="http://x&y">[1]</a> +</p> +!! html/parsoid +<p>Old <span typeof="mw:Entity">&</span> use: <a rel="mw:ExtLink" class="external autonumber" href="http://x&y"></a></p> +!! end + +# note that parsoid html is identical to [raw ampersand] case; so html2wt +# mode will return the [raw ampersand] wikitext +!! test +External links: [encoded ampersand] +!! options +parsoid=wt2html,wt2wt,html2html +!! wikitext +Old & use: [http://x&y] +!! html/php +<p>Old & use: <a rel="nofollow" class="external autonumber" href="http://x&y">[1]</a> +</p> +!! html/parsoid +<p>Old <span typeof="mw:Entity">&</span> use: <a rel="mw:ExtLink" class="external autonumber" href="http://x&y"></a></p> +!! end + +!! test +External links: [raw equals] +!! wikitext +[http://example.com/?foo=bar] +!! html/php +<p><a rel="nofollow" class="external autonumber" href="http://example.com/?foo=bar">[1]</a> +</p> +!! html/parsoid +<p><a rel="mw:ExtLink" class="external autonumber" href="http://example.com/?foo=bar"></a></p> +!! end + +# note that parsoid html is identical to [raw equals] case; so html2wt +# mode will return the [raw equals] wikitext +!! test +External links: [encoded equals] (T8102) +!! options +parsoid=wt2html,wt2wt,html2html +!! wikitext +[http://example.com/?foo=bar] +!! html/php +<p><a rel="nofollow" class="external autonumber" href="http://example.com/?foo=bar">[1]</a> +</p> +!! html/parsoid +<p><a rel="mw:ExtLink" class="external autonumber" href="http://example.com/?foo=bar"></a></p> +!! end + +# xxx parsoid strips the IDN character, so the round-trip tests will +# obviously fail and are disabled. --cscott +!! test +External links: [IDN ignored character reference in hostname; strip it right off] +!! options +parsoid=wt2html,wt2wt,html2html +!! wikitext +[http://e‌xample.com/] +!! html/php +<p><a rel="nofollow" class="external autonumber" href="http://example.com/">[1]</a> +</p> +!! html/parsoid +<p><a rel="mw:ExtLink" class="external autonumber" href="http://example.com/"></a></p> +!! end + +# FIXME: This test (the IDN characters in the text of a link) is an inconsistency. +# Where an external link could easily circumvent the sanitization of the text of +# a link like this (where an IDN-ignore character is in the URL somewhere), this +# test demands a higher standard. That's a bit strange. +# +# Example: +# +# http://example.com -> [http://example.com|http://example.com] +# [http://example.com|http://example.com] -> [http://example.com|http://example.com] +# +# The first example is sanitized, but the second is not. Any security benefits +# from this production are trivial to circumvent. Either remove this test and +# let the parser(s) do their thing unaccosted, or fix the inconsistency and change +# the test accordingly. +# +# All our love, +# The Parsoid team. +# xxx parsoid strips the IDN character, so the round-trip tests will +# obviously fail and are disabled. --cscott +!! test +External links: IDN ignored character reference in hostname; strip it right off +!! options +parsoid=wt2html,html2html +!! wikitext +http://e‌xample.com/ +!! html/php +<p><a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a> +</p> +!! html/parsoid +<p><a rel="mw:ExtLink" class="external free" href="http://example.com/">http://example.com/</a></p> +!! end + +!! test +External links: www.jpeg.org (T2554) +!! wikitext +http://www.jpeg.org +!! html +<p><a rel="nofollow" class="external free" href="http://www.jpeg.org">http://www.jpeg.org</a> +</p> +!! end + +# parsoid doesn't explicitly mark autonumbered links, see T55505 +!! test +External links: URL within URL (T2002) +!! wikitext +[http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp] +!! html/php +<p><a rel="nofollow" class="external autonumber" href="http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp">[1]</a> +</p> +!! html/parsoid +<p><a rel="mw:ExtLink" class="external autonumber" href="http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp"></a></p> +!! end + +!! test +T2361: URL inside bracketed URL +!! wikitext +[http://www.example.com/foo http://www.example.com/bar] +!! html +<p><a rel="nofollow" class="external text" href="http://www.example.com/foo">http://www.example.com/bar</a> +</p> +!! end + +!! test +T2361: URL within URL, not bracketed +!! wikitext +http://www.example.com/foo?=http://www.example.com/bar +!! html +<p><a rel="nofollow" class="external free" href="http://www.example.com/foo?=http://www.example.com/bar">http://www.example.com/foo?=http://www.example.com/bar</a> +</p> +!! end + +!! test +T2289: ">"-token in URL-tail +!! wikitext +http://www.example.com/<hello> +!! html +<p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a><hello> +</p> +!!end + +!! test +T2289: literal ">"-token in URL-tail +!! wikitext +http://www.example.com/<b>html</b> +!! html/php +<p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a><b>html</b> +</p> +!! html/parsoid +<p><a rel="mw:ExtLink" class="external free" href="http://www.example.com/" data-parsoid='{"stx":"url"}'>http://www.example.com/</a><b data-parsoid='{"stx":"html"}'>html</b></p> +!! end + +!! test +T2289: ">"-token in bracketed URL +!! wikitext +[http://www.example.com/<hello> stuff] +!! html +<p><a rel="nofollow" class="external text" href="http://www.example.com/"><hello> stuff</a> +</p> +!!end + +!! test +T2289: literal ">"-token in bracketed URL +!! wikitext +[http://www.example.com/<b>html</b> stuff] +!! html +<p><a rel="nofollow" class="external text" href="http://www.example.com/"><b>html</b> stuff</a> +</p> +!!end + +!! test +T2289: literal double quote at end of URL +!! wikitext +http://www.example.com/"hello" +!! html +<p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a>"hello" +</p> +!!end + +!! test +T2289: literal double quote in bracketed URL +!! wikitext +[http://www.example.com/"hello" stuff] +!! html +<p><a rel="nofollow" class="external text" href="http://www.example.com/">"hello" stuff</a> +</p> +!!end + +!! test +External links: multiple legal whitespace is fine, Magnus. Don't break it please. (T7081) +!! wikitext +[http://www.example.com test] +!! html +<p><a rel="nofollow" class="external text" href="http://www.example.com">test</a> +</p> +!! end + +!! test +External links: link text with spaces +!! wikitext +[http://www.example.com a b c] +[http://www.example.com ''a'' ''b''] +!! html +<p><a rel="nofollow" class="external text" href="http://www.example.com">a b c</a> +<a rel="nofollow" class="external text" href="http://www.example.com"><i>a</i> <i>b</i></a> +</p> +!! end + +# Note edge case difference between PHP and Parsoid here. +!! test +External links: wiki links within external link (T5695) +!! options +parsoid=wt2html,html2html +!! wikitext +[http://example.com [[wikilink]] embedded in ext link] + +[http://example.com test [[wikilink]] embedded in ext link] +!! html/php +<p><a rel="nofollow" class="external text" href="http://example.com"></a><a href="/index.php?title=Wikilink&action=edit&redlink=1" class="new" title="Wikilink (page does not exist)">wikilink</a><a rel="nofollow" class="external text" href="http://example.com"> embedded in ext link</a> +</p><p><a rel="nofollow" class="external text" href="http://example.com">test </a><a href="/index.php?title=Wikilink&action=edit&redlink=1" class="new" title="Wikilink (page does not exist)">wikilink</a><a rel="nofollow" class="external text" href="http://example.com"> embedded in ext link</a> +</p> +!! html/parsoid +<p><a rel="mw:ExtLink" class="external autonumber" href="http://example.com"></a><a rel="mw:WikiLink" href="./Wikilink" title="Wikilink">wikilink</a><span> embedded in ext link</span></p> +<p><a rel="mw:ExtLink" class="external text" href="http://example.com">test </a><a rel="mw:WikiLink" href="./Wikilink" title="Wikilink">wikilink</a><span> embedded in ext link</span></p> +!! end + +!! test +T2787: Links with one slash after the url protocol are invalid +!! wikitext +http:/example.com + +[http:/example.com title] +!! html +<p>http:/example.com +</p><p>[http:/example.com title] +</p> +!! end + +!! test +Bracketed external links with template-generated invalid target +!! wikitext +[{{echo|http:/example.com}} title] +!! html +<p>[http:/example.com title] +</p> +!! end + +# wt2html only because Parsoid would want to add <nowiki>s coming from html +!! test +Broken wikilinks (but not external links) prevent templates from closing +!! options +parsoid=wt2html +!! wikitext +[http://example.com x + +{{echo|[http://example.com x}} + +[[Foo + +{{echo|[[Foo}} +!! html/php +<p>[<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> x +</p><p>[<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> x +</p><p>[[Foo +</p><p>{{echo|[[Foo}} +</p> +!! html/parsoid +<p>[<a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a> x</p> +<p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[http://example.com x"}},"i":0}}]}'>[<a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a> x</p> +<p>[[Foo</p> +<p>{{echo|[[Foo}}</p> +!! end + +!! test +Wikilinks with embedded newlines are not broken +!! wikitext +{{echo|[[ Foo +B +C]]}} +!! html/php +<p>[[ Foo +B +C]] +</p> +!! html/parsoid +<p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[ Foo\nB\nC]]"}},"i":0}}]}'>[[ Foo B C]]</p> +!! end + +!! test +Broken templates +!! options +parsoid=wt2html +!! wikitext +{{echo|[[Foo|}}]] + +[[Foo|{{echo|]]}} +!! html/php +<p>{{echo|<a href="/wiki/Foo" title="Foo">}}</a> +</p><p>[[Foo|]] +</p> +!! html/parsoid +<p>{{echo|<a rel="mw:WikiLink" href="./Foo" title="Foo">}}</a></p> +<p>[[Foo|<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"]]"}},"i":0}}]}'>]]</span></p> +!! end + +!! test +T4702: Mismatched <i>, <b> and <a> tags are invalid +!! wikitext +''[http://example.com text''] +[http://example.com '''text]''' +''Something [http://example.com in italic''] +''Something [http://example.com mixed''''', even bold]''' +'''''Now [http://example.com both'''''] +!! html +<p><a rel="nofollow" class="external text" href="http://example.com"><i>text</i></a> +<a rel="nofollow" class="external text" href="http://example.com"><b>text</b></a> +<i>Something </i><a rel="nofollow" class="external text" href="http://example.com"><i>in italic</i></a> +<i>Something </i><a rel="nofollow" class="external text" href="http://example.com"><i>mixed</i><b>, even bold</b></a> +<i><b>Now </b></i><a rel="nofollow" class="external text" href="http://example.com"><i><b>both</b></i></a> +</p> +!! end + + +!! test +T6781: %26 in URL +!! wikitext +http://www.example.com/?title=AT%26T +!! html/php +<p><a rel="nofollow" class="external free" href="http://www.example.com/?title=AT%26T">http://www.example.com/?title=AT%26T</a> +</p> +!! html/parsoid +<p><a rel="mw:ExtLink" class="external free" href="http://www.example.com/?title=AT%26T">http://www.example.com/?title=AT%26T</a></p> +!! end + +# According to https://www.w3.org/TR/2011/WD-html5-20110525/Overview.html#parsing-urls a plain +# % is actually legal in HTML5. Any change in output would need testing though. +!! test +T6781, T7267: %25 in URL +!! wikitext +http://www.example.com/?title=100%25_Bran +!! html/php +<p><a rel="nofollow" class="external free" href="http://www.example.com/?title=100%25_Bran">http://www.example.com/?title=100%25_Bran</a> +</p> +!! html/parsoid +<p><a rel="mw:ExtLink" class="external free" href="http://www.example.com/?title=100%25_Bran">http://www.example.com/?title=100%25_Bran</a></p> +!! end + +!! test +T6781, T7267: %28, %29 in URL +!! wikitext +http://www.example.com/?title=Ben-Hur_%281959_film%29 +!! html/php +<p><a rel="nofollow" class="external free" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">http://www.example.com/?title=Ben-Hur_%281959_film%29</a> +</p> +!! html/parsoid +<p><a rel="mw:ExtLink" class="external free" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">http://www.example.com/?title=Ben-Hur_%281959_film%29</a></p> +!! end + + +!! test +T6781: %26 in autonumber URL +!! wikitext +[http://www.example.com/?title=AT%26T] +!! html/php +<p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=AT%26T">[1]</a> +</p> +!! html/parsoid +<p><a rel="mw:ExtLink" class="external autonumber" href="http://www.example.com/?title=AT%26T"></a></p> +!! end + +!! test +T6781, T7267: %26 in autonumber URL +!! wikitext +[http://www.example.com/?title=100%25_Bran] +!! html/php +<p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=100%25_Bran">[1]</a> +</p> +!! html/parsoid +<p><a rel="mw:ExtLink" class="external autonumber" href="http://www.example.com/?title=100%25_Bran"></a></p> +!! end + +!! test +T6781, T7267: %28, %29 in autonumber URL +!! wikitext +[http://www.example.com/?title=Ben-Hur_%281959_film%29] +!! html/php +<p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">[1]</a> +</p> +!! html/parsoid +<p><a rel="mw:ExtLink" class="external autonumber" href="http://www.example.com/?title=Ben-Hur_%281959_film%29"></a></p> +!! end + + +!! test +T6781: %26 in bracketed URL +!! wikitext +[http://www.example.com/?title=AT%26T link] +!! html/php +<p><a rel="nofollow" class="external text" href="http://www.example.com/?title=AT%26T">link</a> +</p> +!! html/parsoid +<p><a rel="mw:ExtLink" class="external text" href="http://www.example.com/?title=AT%26T">link</a></p> +!! end + +!! test +T6781, T7267: %25 in bracketed URL +!! wikitext +[http://www.example.com/?title=100%25_Bran link] +!! html +<p><a rel="nofollow" class="external text" href="http://www.example.com/?title=100%25_Bran">link</a> +</p> +!! end + +!! test +T6781, T7267: %28, %29 in bracketed URL +!! wikitext +[http://www.example.com/?title=Ben-Hur_%281959_film%29 link] +!! html/php +<p><a rel="nofollow" class="external text" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">link</a> +</p> +!! html/parsoid +<p><a rel="mw:ExtLink" class="external text" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">link</a></p> +!! end + +!! test +External link containing a period in the anchor. (T65947) +!! wikitext +[//foo.org/bar#baz. bang] + +[//foo.org/bar. bang] +!! html/php +<p><a rel="nofollow" class="external text" href="//foo.org/bar#baz.">bang</a> +</p><p><a rel="nofollow" class="external text" href="//foo.org/bar.">bang</a> +</p> +!! html/parsoid +<p><a rel="mw:ExtLink" class="external text" href="//foo.org/bar#baz.">bang</a></p> +<p><a rel="mw:ExtLink" class="external text" href="//foo.org/bar.">bang</a></p> +!! end + +!! test +External link containing a single quote. (T65947) +!! wikitext +[//foo.org/bar'baz] + +[//foo.org/bar'baz bang] +!! html/php +<p><a rel="nofollow" class="external autonumber" href="//foo.org/bar'baz">[1]</a> +</p><p><a rel="nofollow" class="external text" href="//foo.org/bar'baz">bang</a> +</p> +!! html/parsoid +<p><a rel="mw:ExtLink" class="external autonumber" href="//foo.org/bar'baz"></a></p> +<p><a rel="mw:ExtLink" class="external text" href="//foo.org/bar'baz">bang</a></p> +!! end + +!! test +External link containing double-single-quotes in text '' (T6598 sanity check) +!! wikitext +Some [http://example.com/ pretty ''italics'' and stuff]! +!! html +<p>Some <a rel="nofollow" class="external text" href="http://example.com/">pretty <i>italics</i> and stuff</a>! +</p> +!! end + +!! test +External link containing double-single-quotes in text embedded in italics (T6598 sanity check) +!! wikitext +''Some [http://example.com/ pretty ''italics'' and stuff]!'' +!! html +<p><i>Some </i><a rel="nofollow" class="external text" href="http://example.com/"><i>pretty </i>italics<i> and stuff</i></a><i>!</i> +</p> +!! end + +# Don't add the html/php section since the output is broken and there isn't any reason to spec it +!! test +External link containing double-single-quotes with no space separating the url from text in italics +!! wikitext +[http://www.musee-picasso.fr/pages/page_id18528_u1l2.htm''La muerte de Casagemas'' (1901) en el sitio de [[Museo Picasso (París)|Museo Picasso]].] +!! html/php+tidy +<p><a rel="nofollow" class="external text" href="http://www.musee-picasso.fr/pages/page_id18528_u1l2.htm"><i>La muerte de Casagemas</i> (1901) en el sitio de </a><a href="/index.php?title=Museo_Picasso_(Par%C3%ADs)&action=edit&redlink=1" class="new" title="Museo Picasso (París) (page does not exist)">Museo Picasso</a>. +</p> +!! html/parsoid +<p><a rel="mw:ExtLink" class="external text" href="http://www.musee-picasso.fr/pages/page_id18528_u1l2.htm"><i>La muerte de Casagemas</i> (1901) en el sitio de </a><a rel="mw:WikiLink" href="./Museo_Picasso_(París)" title="Museo Picasso (París)">Museo Picasso</a><span>.</span></p> +!! end + +!! test +External link with comments in link text +!! wikitext +[http://www.google.com Google <!-- comment -->] +!! html/php +<p><a rel="nofollow" class="external text" href="http://www.google.com">Google </a> +</p> +!! html/parsoid +<p><a rel="mw:ExtLink" class="external text" href="http://www.google.com">Google <!-- comment --></a></p> +!! end + +!! test +External link to bare IPv4 address +!! wikitext +[http://192.168.0.1 Link] +!! html/php +<p><a rel="nofollow" class="external text" href="http://192.168.0.1">Link</a> +</p> +!! html/parsoid +<p><a rel="mw:ExtLink" class="external text" href="http://192.168.0.1">Link</a></p> +!! end + +!! test +URL-encoding in URL functions (single parameter) +!! wikitext +{{localurl:Some page|amp=&}} +!! html +<p>/index.php?title=Some_page&amp=& +</p> +!! end + +!! test +URL-encoding in URL functions (multiple parameters) +!! wikitext +{{localurl:Some page|q=?&=&}} +!! html +<p>/index.php?title=Some_page&q=?&amp=& +</p> +!! end + +!! test +Brackets in urls +!! wikitext +http://example.com/index.php?foozoid%5B%5D=bar + +http://example.com/index.php?foozoid[]=bar +!! html/php +<p><a rel="nofollow" class="external free" href="http://example.com/index.php?foozoid%5B%5D=bar">http://example.com/index.php?foozoid%5B%5D=bar</a> +</p><p><a rel="nofollow" class="external free" href="http://example.com/index.php?foozoid%5B%5D=bar">http://example.com/index.php?foozoid%5B%5D=bar</a> +</p> +!! html/parsoid +<p><a rel="mw:ExtLink" class="external free" href="http://example.com/index.php?foozoid%5B%5D=bar">http://example.com/index.php?foozoid%5B%5D=bar</a></p> + +<p><a rel="mw:ExtLink" class="external free" href="http://example.com/index.php?foozoid%5B%5D=bar" data-parsoid='{"stx":"url","a":{"href":"http://example.com/index.php?foozoid%5B%5D=bar"},"sa":{"href":"http://example.com/index.php?foozoid&#x5B;&#x5D;=bar"}}'>http://example.com/index.php?foozoid%5B%5D=bar</a></p> +!! end + +!! test +IPv6 urls, autolink format (T23261) +!! wikitext +http://[2404:130:0:1000::187:2]/index.php + +Examples from RFC 2373, section 2.2: + +*http://[1080::8:800:200C:417A]/unicast +*http://[FF01::101]/multicast +*http://[::1]/loopback +*http://[::]/unspecified +*http://[::13.1.68.3]/ipv4compat +*http://[::FFFF:129.144.52.38]/ipv4compat + +Examples from RFC 2732, section 2: + +*http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html +*http://[1080:0:0:0:8:800:200C:417A]/index.html +*http://[3ffe:2a00:100:7031::1] +*http://[1080::8:800:200C:417A]/foo +*http://[::192.9.5.5]/ipng +*http://[::FFFF:129.144.52.38]:80/index.html +*http://[2010:836B:4179::836B:4179] +!! html/php +<p><a rel="nofollow" class="external free" href="http://[2404:130:0:1000::187:2]/index.php">http://[2404:130:0:1000::187:2]/index.php</a> +</p><p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc2373">RFC 2373</a>, section 2.2: +</p> +<ul><li><a rel="nofollow" class="external free" href="http://[1080::8:800:200C:417A]/unicast">http://[1080::8:800:200C:417A]/unicast</a></li> +<li><a rel="nofollow" class="external free" href="http://[FF01::101]/multicast">http://[FF01::101]/multicast</a></li> +<li><a rel="nofollow" class="external free" href="http://[::1]/loopback">http://[::1]/loopback</a></li> +<li><a rel="nofollow" class="external free" href="http://[::]/unspecified">http://[::]/unspecified</a></li> +<li><a rel="nofollow" class="external free" href="http://[::13.1.68.3]/ipv4compat">http://[::13.1.68.3]/ipv4compat</a></li> +<li><a rel="nofollow" class="external free" href="http://[::FFFF:129.144.52.38]/ipv4compat">http://[::FFFF:129.144.52.38]/ipv4compat</a></li></ul> +<p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc2732">RFC 2732</a>, section 2: +</p> +<ul><li><a rel="nofollow" class="external free" href="http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html">http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html</a></li> +<li><a rel="nofollow" class="external free" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">http://[1080:0:0:0:8:800:200C:417A]/index.html</a></li> +<li><a rel="nofollow" class="external free" href="http://[3ffe:2a00:100:7031::1]">http://[3ffe:2a00:100:7031::1]</a></li> +<li><a rel="nofollow" class="external free" href="http://[1080::8:800:200C:417A]/foo">http://[1080::8:800:200C:417A]/foo</a></li> +<li><a rel="nofollow" class="external free" href="http://[::192.9.5.5]/ipng">http://[::192.9.5.5]/ipng</a></li> +<li><a rel="nofollow" class="external free" href="http://[::FFFF:129.144.52.38]:80/index.html">http://[::FFFF:129.144.52.38]:80/index.html</a></li> +<li><a rel="nofollow" class="external free" href="http://[2010:836B:4179::836B:4179]">http://[2010:836B:4179::836B:4179]</a></li></ul> + +!! html/parsoid +<p><a rel="mw:ExtLink" class="external free" href="http://[2404:130:0:1000::187:2]/index.php">http://[2404:130:0:1000::187:2]/index.php</a></p> + +<p>Examples from <a href="https://tools.ietf.org/html/rfc2373" rel="mw:ExtLink" class="external text">RFC 2373</a>, section 2.2:</p> +<ul><li><a rel="mw:ExtLink" class="external free" href="http://[1080::8:800:200C:417A]/unicast">http://[1080::8:800:200C:417A]/unicast</a></li> +<li><a rel="mw:ExtLink" class="external free" href="http://[FF01::101]/multicast">http://[FF01::101]/multicast</a></li> +<li><a rel="mw:ExtLink" class="external free" href="http://[::1]/loopback">http://[::1]/loopback</a></li> +<li><a rel="mw:ExtLink" class="external free" href="http://[::]/unspecified">http://[::]/unspecified</a></li> +<li><a rel="mw:ExtLink" class="external free" href="http://[::13.1.68.3]/ipv4compat">http://[::13.1.68.3]/ipv4compat</a></li> +<li><a rel="mw:ExtLink" class="external free" href="http://[::FFFF:129.144.52.38]/ipv4compat">http://[::FFFF:129.144.52.38]/ipv4compat</a></li></ul> + +<p>Examples from <a href="https://tools.ietf.org/html/rfc2732" rel="mw:ExtLink" class="external text">RFC 2732</a>, section 2:</p> +<ul><li><a rel="mw:ExtLink" class="external free" href="http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html">http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html</a></li> +<li><a rel="mw:ExtLink" class="external free" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">http://[1080:0:0:0:8:800:200C:417A]/index.html</a></li> +<li><a rel="mw:ExtLink" class="external free" href="http://[3ffe:2a00:100:7031::1]">http://[3ffe:2a00:100:7031::1]</a></li> +<li><a rel="mw:ExtLink" class="external free" href="http://[1080::8:800:200C:417A]/foo">http://[1080::8:800:200C:417A]/foo</a></li> +<li><a rel="mw:ExtLink" class="external free" href="http://[::192.9.5.5]/ipng">http://[::192.9.5.5]/ipng</a></li> +<li><a rel="mw:ExtLink" class="external free" href="http://[::FFFF:129.144.52.38]:80/index.html">http://[::FFFF:129.144.52.38]:80/index.html</a></li> +<li><a rel="mw:ExtLink" class="external free" href="http://[2010:836B:4179::836B:4179]">http://[2010:836B:4179::836B:4179]</a></li></ul> +!! end + +!! test +IPv6 urls, bracketed format (T23261) +!! wikitext +[http://[2404:130:0:1000::187:2]/index.php test] + +Examples from RFC 2373, section 2.2: + +*[http://[1080::8:800:200C:417A] unicast] +*[http://[FF01::101] multicast] +*[http://[::1]/ loopback] +*[http://[::] unspecified] +*[http://[::13.1.68.3] ipv4compat] +*[http://[::FFFF:129.144.52.38] ipv4compat] + +Examples from RFC 2732, section 2: + +*[http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html 1] +*[http://[1080:0:0:0:8:800:200C:417A]/index.html 2] +*[http://[3ffe:2a00:100:7031::1] 3] +*[http://[1080::8:800:200C:417A]/foo 4] +*[http://[::192.9.5.5]/ipng 5] +*[http://[::FFFF:129.144.52.38]:80/index.html 6] +*[http://[2010:836B:4179::836B:4179] 7] +!! html/php +<p><a rel="nofollow" class="external text" href="http://[2404:130:0:1000::187:2]/index.php">test</a> +</p><p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc2373">RFC 2373</a>, section 2.2: +</p> +<ul><li><a rel="nofollow" class="external text" href="http://[1080::8:800:200C:417A]">unicast</a></li> +<li><a rel="nofollow" class="external text" href="http://[FF01::101]">multicast</a></li> +<li><a rel="nofollow" class="external text" href="http://[::1]/">loopback</a></li> +<li><a rel="nofollow" class="external text" href="http://[::]">unspecified</a></li> +<li><a rel="nofollow" class="external text" href="http://[::13.1.68.3]">ipv4compat</a></li> +<li><a rel="nofollow" class="external text" href="http://[::FFFF:129.144.52.38]">ipv4compat</a></li></ul> +<p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc2732">RFC 2732</a>, section 2: +</p> +<ul><li><a rel="nofollow" class="external text" href="http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html">1</a></li> +<li><a rel="nofollow" class="external text" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">2</a></li> +<li><a rel="nofollow" class="external text" href="http://[3ffe:2a00:100:7031::1]">3</a></li> +<li><a rel="nofollow" class="external text" href="http://[1080::8:800:200C:417A]/foo">4</a></li> +<li><a rel="nofollow" class="external text" href="http://[::192.9.5.5]/ipng">5</a></li> +<li><a rel="nofollow" class="external text" href="http://[::FFFF:129.144.52.38]:80/index.html">6</a></li> +<li><a rel="nofollow" class="external text" href="http://[2010:836B:4179::836B:4179]">7</a></li></ul> + +!! html/parsoid +<p><a rel="mw:ExtLink" class="external text" href="http://[2404:130:0:1000::187:2]/index.php">test</a></p> + +<p>Examples from <a href="https://tools.ietf.org/html/rfc2373" rel="mw:ExtLink" class="external text">RFC 2373</a>, section 2.2:</p> +<ul><li><a rel="mw:ExtLink" class="external text" href="http://[1080::8:800:200C:417A]">unicast</a></li> +<li><a rel="mw:ExtLink" class="external text" href="http://[FF01::101]">multicast</a></li> +<li><a rel="mw:ExtLink" class="external text" href="http://[::1]/">loopback</a></li> +<li><a rel="mw:ExtLink" class="external text" href="http://[::]">unspecified</a></li> +<li><a rel="mw:ExtLink" class="external text" href="http://[::13.1.68.3]">ipv4compat</a></li> +<li><a rel="mw:ExtLink" class="external text" href="http://[::FFFF:129.144.52.38]">ipv4compat</a></li></ul> + +<p>Examples from <a href="https://tools.ietf.org/html/rfc2732" rel="mw:ExtLink" class="external text">RFC 2732</a>, section 2:</p> +<ul><li><a rel="mw:ExtLink" class="external text" href="http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html">1</a></li> +<li><a rel="mw:ExtLink" class="external text" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">2</a></li> +<li><a rel="mw:ExtLink" class="external text" href="http://[3ffe:2a00:100:7031::1]">3</a></li> +<li><a rel="mw:ExtLink" class="external text" href="http://[1080::8:800:200C:417A]/foo">4</a></li> +<li><a rel="mw:ExtLink" class="external text" href="http://[::192.9.5.5]/ipng">5</a></li> +<li><a rel="mw:ExtLink" class="external text" href="http://[::FFFF:129.144.52.38]:80/index.html">6</a></li> +<li><a rel="mw:ExtLink" class="external text" href="http://[2010:836B:4179::836B:4179]">7</a></li></ul> +!! end + +!! test +Non-extlinks in brackets +!! wikitext +[foo] +[foo bar] +[foo ''bar''] +[fool's] errand +[fool's errand] +[{{echo|foo}}] +[{{echo|foo}} bar] +[{{echo|foo}} ''bar''] +[{{echo|foo}}l's] errand +[{{echo|foo}}l's errand] +[url={{echo|foo}}] +[url=http://example.com] +[http:// bare protocols don't count] +!! html/php +<p>[foo] +[foo bar] +[foo <i>bar</i>] +[fool's] errand +[fool's errand] +[foo] +[foo bar] +[foo <i>bar</i>] +[fool's] errand +[fool's errand] +[url=foo] +[url=<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>] +[http:// bare protocols don't count] +</p> +!! html/parsoid +<p>[foo] +[foo bar] +[foo <i>bar</i>] +[fool's] errand +[fool's errand] +[<span about="#mwt19" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</span>] +[<span about="#mwt20" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</span> bar] +[<span about="#mwt21" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</span> <i>bar</i>] +[<span about="#mwt22" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</span>l's] errand +[<span about="#mwt23" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</span>l's errand] +[url=<span about="#mwt24" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</span>] +[url=<a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>] +[http:// bare protocols don't count]</p> +!! end + +!! test +Percent encoding in external links +!! wikitext +[https://github.com/search?l=&q=ResourceLoader+%40wikimedia Search] +!! html/php +<p><a rel="nofollow" class="external text" href="https://github.com/search?l=&q=ResourceLoader+%40wikimedia">Search</a> +</p> +!! html/parsoid +<p><a rel="mw:ExtLink" class="external text" href="https://github.com/search?l=&q=ResourceLoader+%40wikimedia">Search</a></p> +!! end + +!! test +Use url link syntax for links where the content is equal the link target +!! wikitext +http://example.com +!! html/php +<p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> +</p> +!! html/parsoid +<p><a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a></p> +!! end + +!! test +Parenthesis in external links, especially URL links +!! wikitext +http://example.com) + +http://example.com/test) + +http://example.com/(test) + +http://example.com/((test) + +(http://example.com/(test)) + +(http://example.com/(test))))) + +http://example.com/a)b + +[http://example.com) foo] +!! html/php +<p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>) +</p><p><a rel="nofollow" class="external free" href="http://example.com/test">http://example.com/test</a>) +</p><p><a rel="nofollow" class="external free" href="http://example.com/(test)">http://example.com/(test)</a> +</p><p><a rel="nofollow" class="external free" href="http://example.com/((test)">http://example.com/((test)</a> +</p><p>(<a rel="nofollow" class="external free" href="http://example.com/(test))">http://example.com/(test))</a> +</p><p>(<a rel="nofollow" class="external free" href="http://example.com/(test)))))">http://example.com/(test)))))</a> +</p><p><a rel="nofollow" class="external free" href="http://example.com/a)b">http://example.com/a)b</a> +</p><p><a rel="nofollow" class="external text" href="http://example.com)">foo</a> +</p> +!! html/parsoid +<p><a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>)</p> +<p><a rel="mw:ExtLink" class="external free" href="http://example.com/test">http://example.com/test</a>)</p> +<p><a rel="mw:ExtLink" class="external free" href="http://example.com/(test)">http://example.com/(test)</a></p> +<p><a rel="mw:ExtLink" class="external free" href="http://example.com/((test)">http://example.com/((test)</a></p> +<p>(<a rel="mw:ExtLink" class="external free" href="http://example.com/(test))">http://example.com/(test))</a></p> +<p>(<a rel="mw:ExtLink" class="external free" href="http://example.com/(test)))))">http://example.com/(test)))))</a></p> +<p><a rel="mw:ExtLink" class="external free" href="http://example.com/a)b">http://example.com/a)b</a></p> +<p><a rel="mw:ExtLink" class="external text" href="http://example.com)">foo</a></p> +!! end + +!! test +Parenthesis in external links, w/ transclusion or comment +!! wikitext +(http://example.com/{{echo|hi}}) + +(http://example.com<!-- hi -->) +!! html/php +<p>(<a rel="nofollow" class="external free" href="http://example.com/hi">http://example.com/hi</a>) +</p><p>(<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>) +</p> +!! html/parsoid +<p>(<a typeof="mw:ExpandedAttrs" about="#mwt2" rel="mw:ExtLink" class="external free" href="http://example.com/hi" data-parsoid='{"stx":"url","a":{"href":"http://example.com/hi"},"sa":{"href":"http://example.com/{{echo|hi}}"}}' data-mw='{"attribs":[[{"txt":"href"},{"html":"http://example.com/<span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid='{\"pi\":[[{\"k\":\"1\"}]],\"dsr\":[20,31,null,null]}' data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"hi\"}},\"i\":0}}]}'>hi</span>"}]]}'>http://example.com/hi</a>)</p> + +<p>(<a rel="mw:ExtLink" class="external free" href="http://example.com" data-parsoid='{"stx":"url","a":{"href":"http://example.com"},"sa":{"href":"http://example.com<!-- hi -->"}}'>http://example.com</a>)</p> +!! end + +!! test +Serialize <a> tags with invalid link targets as plain text +!! options +parsoid={ "modes": ["html2wt"], "suppressErrors": true } +!! html/parsoid +<a rel="mw:WikiLink" href="[[foo]]">text</a> +<a rel="mw:WikiLink" href="[[foo]]">*text</a> +<a rel="mw:WikiLink" href="[[foo]]">[[foo]]</a> +<a rel="mw:WikiLink" href="[[foo]]">*a [[foo]]</a> +!! wikitext +text +<nowiki>*</nowiki>text +<nowiki>[[foo]]</nowiki> +<nowiki>*</nowiki>a <nowiki>[[foo]]</nowiki> +!! end + +!! test +mw:ExtLink -vs- mw:WikiLink (T94723) +!! options +parsoid=html2wt +!! html/parsoid +<a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"piped","a":{"href":"./Foo"},"sa":{"href":"Foo"}}'>Bar</a> +<a rel="mw:WikiLink" href="./Foo" title="Foo">Bar</a> +<a rel="mw:WikiLink" href="http://en.wikipedia.org/wiki/Foo" title="Foo">Bar</a> +<a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/Foo" title="Foo">Bar</a> +<p> +<a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/European_Robin">European Robin</a> +<a rel="mw:WikiLink" href="http://en.wikipedia.org/wiki/European_Robin">European Robin</a> +</p> +!! wikitext +[[Foo|Bar]] +[[Foo|Bar]] +[[:en:Foo|Bar]] +[[:en:Foo|Bar]] + +[[:en:European_Robin|European Robin]] +[[:en:European_Robin|European Robin]] +!! end + +!! test +mw:ExtLink linking to a interwiki URL can be round-tripped losslessly (T94723) +!! options +parsoid=wt2wt +!! wikitext +[http://en.wikipedia.org/wiki/European_Robin European Robin] +!! html/parsoid +THIS SECTION IS NOT USED (but Parsoid won't run the test without it) +!! end + + +### +### Quotes +### + +!! test +Quotes +!! wikitext +Normal text. '''Bold text.''' Normal text. ''Italic text.'' + +Normal text. '''''Bold italic text.''''' Normal text. +!! html +<p>Normal text. <b>Bold text.</b> Normal text. <i>Italic text.</i> +</p><p>Normal text. <i><b>Bold italic text.</b></i> Normal text. +</p> +!! end + + +# Parsoid inserts an empty bold tag pair at the end of the line, that the PHP +# parser strips. The wikitext contains just the first half of the bold +# quote pair. +!! test +Unclosed and unmatched quotes +!! wikitext +'''''Bold italic text '''with bold deactivated''' in between.''''' + +'''''Bold italic text ''with italic deactivated'' in between.''''' + +'''Bold text.. + +..spanning two paragraphs (should not work).''' + +'''Bold tag left open + +''Italic tag left open + +Normal text. + +<!-- Unmatching number of opening, closing tags: --> +'''This year''''s election ''should'' beat '''last year''''s. + +''Tom'''s car is bigger than ''Susan'''s. + +Plain ''italic'''s plain +!! html/php +<p><i><b>Bold italic text </b>with bold deactivated<b> in between.</b></i> +</p><p><b><i>Bold italic text </i>with italic deactivated<i> in between.</i></b> +</p><p><b>Bold text..</b> +</p><p>..spanning two paragraphs (should not work). +</p><p><b>Bold tag left open</b> +</p><p><i>Italic tag left open</i> +</p><p>Normal text. +</p><p><b>This year'</b>s election <i>should</i> beat <b>last year'</b>s. +</p><p><i>Tom<b>s car is bigger than </b></i><b>Susan</b>s. +</p><p>Plain <i>italic'</i>s plain +</p> +!! html/parsoid +<p><i><b>Bold italic text </b>with bold deactivated<b> in between.</b></i> +</p><p><b><i>Bold italic text </i>with italic deactivated<i> in between.</i></b> +</p><p><b>Bold text..</b> +</p><p>..spanning two paragraphs (should not work).<b></b> +</p><p><b>Bold tag left open</b> +</p><p><i>Italic tag left open</i> +</p><p>Normal text. +</p> +<!-- Unmatching number of opening, closing tags: --> +<p><b>This year'</b>s election <i>should</i> beat <b>last year'</b>s. +</p><p><i>Tom<b>s car is bigger than </b></i><b>Susan</b>s. +</p><p>Plain <i>italic'</i>s plain +</p> +!! end + +### +### Tables +### +### 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 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 +<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 + +!! test +A table with no data (take 2) +!! wikitext +{| +|} +!! html/parsoid +<table></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><tr><td></td></tr></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> +<tr> +<td>foo +</td></tr></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> +<tr> +<td>foo +</td></tr></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> +<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></table> + +!! end + +!! test +Simple table +!! wikitext +{| +|1||2 +|- +|3||4 +|} +!! html +<table> +<tr> +<td>1</td> +<td>2 +</td></tr> +<tr> +<td>3</td> +<td>4 +</td></tr></table> + +!! end + +!! test +Simple table but with multiple dashes for row wikitext +!! wikitext +{| +|foo +|----- +|bar +|} +!! html +<table> +<tr> +<td>foo +</td></tr> +<tr> +<td>bar +</td></tr></table> + +!! 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 +<table border="1" cellpadding="2"> +<caption>Multiplication table +</caption> +<tr> +<th>×</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></table> + +!! end + +!! test +Accept "||" in table headings +!! wikitext +{| +!h1||h2 +|} +!! html +<table> +<tr> +<th>h1</th> +<th>h2 +</th></tr></table> + +!! end + +!! test +Accept "!!" in table data +!! wikitext +{| +|Foo!!|| +|} +!! html +<table> +<tr> +<td>Foo!!</td> +<td> +</td></tr></table> + +!! html/parsoid +<table> +<tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'> Foo!! </td><td data-parsoid='{"stx":"row","autoInsertedEnd":true}'></td></tr> +</tbody></table> +!! end + +!! test +Accept "||" in indented table headings +!! wikitext +:{| +!h1||h2 +|} +!! html +<dl><dd><table> +<tr> +<th>h1</th> +<th>h2 +</th></tr></table></dd></dl> + +!! end + +!! test +Accept "!!" in templates +!! wikitext +{| +!a {{echo|b!!c}} +|} +!! html/php +<table> +<tr> +<th>a b</th> +<th>c +</th></tr></table> + +!! html/parsoid +<table> +<tbody><tr><th typeof="mw:Transclusion" about="#mwt1" data-parsoid='{"autoInsertedEnd":true,"pi":[[{"k":"1"}]]}' data-mw='{"parts":["!a ",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"b!!c"}},"i":0}}]}'>a b</th><th about="#mwt1">c</th></tr> +!! end + +!! test +Accept "!!" in table headings after newline +!! wikitext +{| +!a +b!!c +|} +!! html/php +<table> +<tr> +<th>a +<p>b!!c +</p> +</th></tr></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+tidy +<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> +<tr> +<th>h1 +</th> +<td>a +</td></tr></table> + +!! end + +!!test +Accept "| !" at start of line in tables (ignore !-attribute) +!! wikitext +{| +|- +|!style="color:red"|bar +|} +!! html +<table> + +<tr> +<td>bar +</td></tr></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> + +<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></table> + +!!end + +!! 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 +<table border="1"> +<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></table> + +!! end + +!! test +Nested table +!! wikitext +{| border=1 +| α +| +{| bgcolor=#ABCDEF border=2 +|nested +|- +|table +|} +|the original table again +|} +!! html +<table border="1"> +<tr> +<td>α +</td> +<td> +<table bgcolor="#ABCDEF" border="2"> +<tr> +<td>nested +</td></tr> +<tr> +<td>table +</td></tr></table> +</td> +<td>the original table again +</td></tr></table> + +!! end + +!! test +Invalid attributes in table cell (T3830) +!! wikitext +{| +|Cell:|broken +|} +!! html +<table> +<tr> +<td>broken +</td></tr></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> +<tr> +<td title="foo">bar +</td> +<td title="foo|">bar +</td> +<td>title="foo|" bar +</td></tr></table> + +!! html/parsoid +<table> +<tbody><tr><td title="foo">bar</td> +<td title="foo|" data-parsoid='{"a":{"title":"foo|"},"sa":{"title":"foo<nowiki>|</nowiki>"},"autoInsertedEnd":true}'>bar</td> +<td> title="foo<span typeof="mw:Nowiki">|</span>" bar</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> +<tr> +<td>[<a rel="nofollow" class="external free" href="ftp://%7Cx">ftp://%7Cx</a></td> +<td>]" onmouseover="alert(document.cookie)">test +</td> +</tr> +</table> + +!! html/parsoid +<table><tbody> +<tr> +<td data-parsoid='{"startTagSrc":"| ","attrSepSrc":"|","autoInsertedEnd":true}'>[<a rel="mw:ExtLink" class="external free" href="ftp://%7Cx" data-parsoid='{"stx":"url","a":{"href":"ftp://%7Cx"},"sa":{"href":"ftp://|x"}}'>ftp://%7Cx</a></td><td data-parsoid='{"stx":"row","autoInsertedEnd":true}'>]" 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> +<tr> +<th>hi <div class="!!">ha</div> ho +</th></tr></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> +<tr> +<td><div style="color: red !important;" data-contrived="put this here ||">hi</div> +</td></tr></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> +<tr> +<td>style="color: red !important;" data-contrived="put this here</td> +<td>foo +</td></tr></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":{"\"":""},"autoInsertedEnd":true}'>foo</td></tr> +</tbody></table> +!! end + +!! test +Break on | in element attribute in template +!! options +parsoid=wt2html,html2html +!! wikitext +{{echo|1=<div class="hi|ho">ha</div>}} +!! html/php +<p>ho">ha</div> +</p> +!! html/parsoid +<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"ho\">ha</div>"}},"i":0}}]}'>ho">ha</span> +!! end + +!! test +Break on | in element attribute name in template +!! wikitext +{{echo|<div cla|ss="hiho">ha</div>}} +!! html/parsoid +<p about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1"},{"k":"ss","named":true}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"<div cla"},"ss":{"wt":"\"hiho\">ha</div>"}},"i":0}}]}'><div cla</p> +!! end + +!! test +Don't break on | in extension attribute in template +!! wikitext +{{echo|<ref name="hi|ho">ha</ref>}} + +<references /> +!! html/parsoid +<p><sup about="#mwt2" class="mw-ref" id="cite_ref-hi|ho_1-0" rel="dc:references" typeof="mw:Transclusion mw:Extension/ref" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"<ref name=\"hi|ho\">ha</ref>"}},"i":0}}]}'><a href="./Main_Page#cite_note-hi|ho-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></sup></p> + +<ol class="mw-references references" typeof="mw:Extension/references" about="#mwt5" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-hi|ho-1" id="cite_note-hi|ho-1"><a href="./Main_Page#cite_ref-hi|ho_1-0" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-hi|ho-1" class="mw-reference-text">ha</span></li></ol> +!! 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"> +<tr> +<td style="color:blue">1 +</td> +<td style="color:blue">2 +</td></tr></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> +<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></table> + +!! end + +!! test +2. Template-generated table cell attributes and cell content +!! wikitext +{| +|{{table_attribs_2}} +|} +!! html/php +<table> +<tr> +<td style="color:red;">Foo +</td> +<td>Bar</td> +<td>Baz +</td></tr></table> + +!! html/parsoid +<table> +<tbody><tr><td about="#mwt1" typeof="mw:Transclusion" 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 +3. Template-generated table cell attributes and cell content +!! wikitext +{| +!align=center {{table_header_cells}} +|- +|align=center {{table_cells}} +|} +!! html/php +<table> +<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></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> +<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></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 + +## Edge case fix to prevent future regressions +!! test +T107652: <ref>s in templates that also generate table cell attributes should be rendered properly +!! wikitext +{| +|{{table_attribs_7}} +|} +<references /> +!! html/parsoid +<table> +<tbody><tr><td style="background:#f9f9f9;" typeof="mw:Transclusion" about="#mwt1" data-mw='{"parts":["|",{"template":{"target":{"wt":"table_attribs_7","href":"./Template:Table_attribs_7"},"params":{},"i":0}}]}'>Foo<sup class="mw-ref" id="cite_ref-1" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","body":{"id":"mw-reference-text-cite_note-1"},"attrs":{}}'><a href="./Main_Page#cite_note-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></s></td></tr> +</tbody></table> +<ol class="mw-references references" typeof="mw:Extension/references" about="#mwt5" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text" data-parsoid="{}">foo</span></li></ol> +!! end + +!! test +Table with row followed by newlines and table heading +!! options +parsoid=wt2html,html2html +!! wikitext +{| +|- + +!foo +|} +!! html/* +<table> + + +<tr> +<th>foo +</th></tr></table> + +!! end + +!! test +Table with empty line following the start tag +!! options +parsoid=wt2html,html2html +!! wikitext +{| + +|- +|foo +|} +!! html/* +<table> + + +<tr> +<td>foo +</td></tr></table> + +!! end + +!! test +Table attributes with empty value +!! options +parsoid=wt2html,html2html +!! wikitext +{| +| style=|hello +|} +!! html/php +<table> +<tr> +<td style="">hello +</td></tr></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> +<tr> +<td>foo +</td></tr> +<tr> +<td> +</td></tr></table> + +!! end + +!! test +Wikitext table comments represented in parsoid dom +!! wikitext +{|<!--c1--><!--c2--> +|-<!--c3--> +|x +|} +!! html/php+tidy +<table> + +<tbody><tr> +<td>x +</td></tr></tbody></table> +!! html/parsoid +<table><!--c1--><!--c2--> +<tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'><!--c3--> +<td data-parsoid='{"autoInsertedEnd":true}'>x</td></tr> +</tbody></table> +!! end + +!! test +Wikitext table with double-line table cell +!! wikitext +{| +|a +b +|} +!! html +<table> +<tr> +<td>a +<p>b +</p> +</td></tr></table> + +!! end + +!! test +Table cell with a single comment +!! wikitext +{| +| <!-- c1 --> +|a +|} +!! html +<table> +<tr> +<td> +</td> +<td>a +</td></tr></table> + +!! end + +!! test +Table-cell after a comment-only-empty-line +!! wikitext +{| +|a +<!--c1--> +<!--c2-->|b +|} +!! html +<table> +<tr> +<td>a +</td> +<td>b +</td></tr></table> + +!! html/parsoid +<table> +<tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'>a</td> +<!--c1--> +<!--c2--><td data-parsoid='{"autoInsertedEnd":true}'>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"> +<tr> +<th>header +</th> +<th>second header +</th></tr> +<tr style="color:red;"> +<td>data</td> +<td style="color:red;">second data +</td></tr></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"> +<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></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"> +<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></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 + +!! test +Fostered content in tables: Plain text +!! options +parsoid=wt2html,html2html +!! wikitext +{| +|- +a +|} +!! html/php +<table> + +a +</table> + +!! html/php+tidy + + +a +<table></table> +!! html/parsoid +<p data-parsoid='{"fostered":true,"autoInsertedEnd":true}'>a</p><table> +<tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'> + +</tr></tbody></table> +!! end + +!! test +Fostered content in tables: Lists +!! options +parsoid=wt2html,html2html +!! wikitext +{| +|- +*a +|} +!! html/php +<table> + +<ul><li>a</li></ul> +</table> + +!! html/php+tidy +<ul><li>a</li></ul><table> + + +</table> +!! html/parsoid +<ul data-parsoid='{"fostered":true,"autoInsertedEnd":true}'><li>a</li></ul><table> +<tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'> + +</tr></tbody></table> +!! end + +!! test +Template generated table cell with attributes +!! wikitext +{| +|- +{{table_attribs_4}} ||a||b +|} +!! html/php+tidy +<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":"|-","autoInsertedEnd":true}'> +<td style="background-color:#DC241f;" width="10px" about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"autoInsertedEnd":true,"pi":[[]]}' 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> +!! end + +!! test +Parsoid: Round-trip tables directly followed by content (T53219) +!! options +parsoid=wt2html,wt2wt +!! wikitext +{| +|foo +|} bar + +{| +|baz +|}<b>quux</b> +!! html+tidy +<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> +!! 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 +|} +<nowiki> </nowiki>bar +{| +|baz +|} +'''quux''' +!! end + +!! test +Parsoid: newline inducing block nodes don't suppress <nowiki> +!! options +parsoid=html2wt +!! html/parsoid + a<h1>foo</h1> +!! wikitext +<nowiki> </nowiki>a + += foo = +!! 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> +<tr> +<th>foo</th> +<th>bar +</th> +<td>baz</td> +<td>quux +</td></tr></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+tidy +<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 + +!! test +Tables: Digest broken attributes on table and tr tag +!! options +parsoid=wt2html +!! wikitext +{| || |} ++ +|- || || ++ -- +|- > [ +|} +!! html +<table> +<tbody> +<tr class='mw-empty-elt'></tr> +<tr class='mw-empty-elt'></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+tidy +<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 +Testing serialization after deletion in references +!! options +parsoid={ + "modes": ["wt2wt"], + "changes": [ + ["#x", "remove"] + ] +} +!! wikitext +hi <ref><div id="x">ho</div></ref> + +<references /> +!! wikitext/edited +hi <ref></ref> + +<references /> +!! end + +!!test +Testing serialization after deletion of table cells +!!options +parsoid={ + "modes": ["wt2wt", "selser"], + "changes": [ + ["#x", "remove"] + ] +} +!!wikitext +{| +!h1 !!h2 !!h3 +| id="x" |c1 {{!}}{{!}}{{!}}c2 |||c3 +|} +!! wikitext/edited +{| +!h1 !!h2 !!h3 +|c2 |||c3 +|} +!!end + +!! test +Testing selser after addition of new row before first row (T125419) +!! options +parsoid={ + "modes": ["wt2wt", "selser"], + "changes": [ + [ "tr", "before", "<tr><td>X</td></tr>" ] + ] +} +!! wikitext +{| +|a +|} +!! wikitext/edited +{| +|X +|- +|a +|} +!! end + +!! test +Serialize new table rows in a HTML table using HTML tags +!! options +parsoid={ + "modes": ["wt2wt", "selser"], + "changes": [ + [ "tr", "before", "<tr><td>X</td></tr>" ] + ] +} +!! wikitext +<table><tr><td>a</td></tr></table> +!! wikitext/edited +<table><tr><td>X</td></tr><tr><td>a</td></tr></table> +!! end + +!! test +Serialize new table cells in a HTML row using HTML tags +!! options +parsoid={ + "modes": ["wt2wt", "selser"], + "changes": [ + [ "td", "before", "<td>X</td>" ] + ] +} +!! wikitext +<table><tr><td>a</td></tr></table> +!! wikitext/edited +<table><tr><td>X</td><td>a</td></tr></table> +!! end + +!! test +Wikitext tables can be nested inside HTML tables +!! options +parsoid=html2wt +!! html +<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> +!! end + +!! test +Serialize wikitext list items as HTML list items when embedded in a HTML list +!! options +parsoid=html2wt +!! html +<ul data-parsoid='{"stx": "html"}'> +<li data-parsoid='{}'>a</li> +<li>b</li> +</ul> +!! wikitext +<ul> +<li>a</li> +<li>b</li> +</ul> +!! end + +# SSS FIXME: Is this actually a good thing given the +# odd nested list output that is generated by MW? +# <ul><li>foo<ul>..</ul></li></ul> instead of +# <ul><li>foo</li><ul>..</ul></ul> +!! test +Wikitext lists can be nested inside HTML lists +!! options +parsoid=html2wt +!! html +<ul data-parsoid='{"stx": "html"}'> +<li data-parsoid='{"stx": "html"}'>a +<ul><li>b</li></ul> +</li> +</ul> + +<ul data-parsoid='{"stx": "html"}'> +<li>x +<ul><li>y</li></ul> +</li> +</ul> +!! wikitext +<ul> +<li>a +* b +</li> +</ul> + +<ul> +<li>x +* y +</li> +</ul> +!! end + +### +### Internal links +### +!! test +Plain link, capitalized +!! wikitext +[[Main Page]] +!! html +<p><a href="/wiki/Main_Page" title="Main Page">Main Page</a> +</p> +!! end + +!! test +Plain link, uncapitalized +!! wikitext +[[main Page]] +!! html +<p><a href="/wiki/Main_Page" title="Main Page">main Page</a> +</p> +!! end + +!! test +Piped link +!! wikitext +[[Main Page|The Main Page]] +!! html +<p><a href="/wiki/Main_Page" title="Main Page">The Main Page</a> +</p> +!! end + +!! test +Piped link with comment in link text +!! wikitext +[[Main Page|The Main<!--front--> Page]] +!! html +<p><a href="/wiki/Main_Page" title="Main Page">The Main Page</a> +</p> +!! end + +!! test +Piped link with multiple pipe characters in link text +!! wikitext +[[Main Page||The|Main|Page|]] +!! html/php +<p><a href="/wiki/Main_Page" title="Main Page">|The|Main|Page|</a> +</p> +!! html/parsoid +<p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">|The|Main|Page|</a></p> +!! end + +!! test +Piped link with no link text +!! wikitext +[[Thomas Bek (bishop of St David's)|]] +!! html/php +<p>[[Thomas Bek (bishop of St David's)|]] +</p> +!! html/parsoid +<p>[[Thomas Bek (bishop of St David's)|]]</p> +!! end + +!! test +Piped link with empty link text +!! wikitext +[[Main Page|<nowiki/>]] - empty nowiki +[[Main Page| ]] - empty space +[[Main Page| ]] - empty non breaking space +!! html/php +<p><a href="/wiki/Main_Page" title="Main Page"></a> - empty nowiki +<a href="/wiki/Main_Page" title="Main Page"> </a> - empty space +<a href="/wiki/Main_Page" title="Main Page"> </a> - empty non breaking space +</p> +!! html/parsoid +<p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page"><span typeof="mw:Nowiki"></span></a> - empty nowiki +<a rel="mw:WikiLink" href="./Main_Page" title="Main Page"> </a> - empty space +<a rel="mw:WikiLink" href="./Main_Page" title="Main Page"><span typeof="mw:Entity" data-parsoid='{"src":"&nbsp;","srcContent":" "}'> </span></a> - empty non breaking space</p> +!! end + +!! test +Broken link +!! wikitext +[[Zigzagzogzagzig]] +!! html +<p><a href="/index.php?title=Zigzagzogzagzig&action=edit&redlink=1" class="new" title="Zigzagzogzagzig (page does not exist)">Zigzagzogzagzig</a> +</p> +!! end + +!! test +Broken link with fragment +!! wikitext +[[Zigzagzogzagzig#zug]] +!! html +<p><a href="/index.php?title=Zigzagzogzagzig&action=edit&redlink=1" class="new" title="Zigzagzogzagzig (page does not exist)">Zigzagzogzagzig#zug</a> +</p> +!! end + +!! test +Special page link with fragment +!! wikitext +[[Special:Version#anchor]] +!! html +<p><a href="/wiki/Special:Version#anchor" title="Special:Version">Special:Version#anchor</a> +</p> +!! end + +!! test +Nonexistent special page link with fragment +!! wikitext +[[Special:ThisNameWillHopefullyNeverBeUsed#anchor]] +!! html +<p><a href="/wiki/Special:ThisNameWillHopefullyNeverBeUsed" class="new" title="Special:ThisNameWillHopefullyNeverBeUsed (page does not exist)">Special:ThisNameWillHopefullyNeverBeUsed#anchor</a> +</p> +!! end + +!! test +Link with prefix +!! wikitext +xxx[[main Page]], xxx[[Main Page]], Xxx[[main Page]] XXX[[main Page]], XXX[[Main Page]] +!! html +<p>xxx<a href="/wiki/Main_Page" title="Main Page">main Page</a>, xxx<a href="/wiki/Main_Page" title="Main Page">Main Page</a>, Xxx<a href="/wiki/Main_Page" title="Main Page">main Page</a> XXX<a href="/wiki/Main_Page" title="Main Page">main Page</a>, XXX<a href="/wiki/Main_Page" title="Main Page">Main Page</a> +</p> +!! end + +!! test +Link with suffix +!! wikitext +[[Main Page]]xxx, [[Main Page]]XXX, [[Main Page]]!!! +!! html +<p><a href="/wiki/Main_Page" title="Main Page">Main Pagexxx</a>, <a href="/wiki/Main_Page" title="Main Page">Main Page</a>XXX, <a href="/wiki/Main_Page" title="Main Page">Main Page</a>!!! +</p> +!! end + +!! article +prefixed article +!! text +Some text +!! endarticle + +!! test +T45661: Piped links with identical prefixes +!! wikitext +[[prefixed article|prefixed articles with spaces]] + +[[prefixed article|prefixed articlesaoeu]] + +[[Main Page|Main Page test]] +!! html +<p><a href="/wiki/Prefixed_article" title="Prefixed article">prefixed articles with spaces</a> +</p><p><a href="/wiki/Prefixed_article" title="Prefixed article">prefixed articlesaoeu</a> +</p><p><a href="/wiki/Main_Page" title="Main Page">Main Page test</a> +</p> +!! end + + +!! test +Link with HTML entity in suffix / tail +!! wikitext +[[Main Page]]", [[Main Page]]a +!! html/php +<p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>", <a href="/wiki/Main_Page" title="Main Page">Main Page</a>a +</p> +!! html/parsoid +<p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a><span typeof="mw:Entity" data-parsoid='{"src":"&quot;","srcContent":"\""}'>"</span>, <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a><span typeof="mw:Entity" data-parsoid='{"src":"&#97;","srcContent":"a"}'>a</span></p> +!! end + +!! test +Link with 3 brackets +!! wikitext +[[[Main Page]]] +Foo [[[Main Page]]] +!! html +<p>[[[Main Page]]] +Foo [[[Main Page]]] +</p> +!! end + +!! test +Link with 4 brackets +!! wikitext +[[[[Main Page]]]] +!! html +<p>[[<a href="/wiki/Main_Page" title="Main Page">Main Page</a>]] +</p> +!! end + +!! test +Piped link with 3 brackets +!! wikitext +[[[main page|the main page]]] +!! html +<p>[[[main page|the main page]]] +</p> +!! end + +!! test +Piped link with extlink-like text +!! wikitext +[[Main Page|[bar]]] +[[Main Page|This is a [bar]]] +[[Main Page|[bar]] +!! html/php +<p><a href="/wiki/Main_Page" title="Main Page">[bar]</a> +<a href="/wiki/Main_Page" title="Main Page">This is a [bar]</a> +<a href="/wiki/Main_Page" title="Main Page">[bar</a> +</p> +!! html/parsoid +<p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"piped"}'>[bar]</a> +<a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"piped"}'>This is a [bar]</a> +<a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"piped"}'>[bar</a></p> +!! end + +!! test +Link with multiple pipes +!! wikitext +[[Main Page|The|Main|Page]] +!! html +<p><a href="/wiki/Main_Page" title="Main Page">The|Main|Page</a> +</p> +!! end + +!! test +Anchor containing a #. (T65430) +!! config +wgFragmentMode=[ 'html5', 'legacy' ] +!! wikitext +[[Main Page#And#Link]] +!! html/php +<p><a href="/wiki/Main_Page#And#Link" title="Main Page">Main Page#And#Link</a> +</p> +!! html/parsoid +<p><a rel="mw:WikiLink" href="./Main_Page#And#Link" title="Main Page" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#And#Link"},"sa":{"href":"Main Page#And#Link"}}'>Main Page#And#Link</a></p> +!! end + +!! test +Link to namespaces +!! wikitext +[[Talk:Parser testing]], [[Meta:Disclaimers]] +!! html +<p><a href="/index.php?title=Talk:Parser_testing&action=edit&redlink=1" class="new" title="Talk:Parser testing (page does not exist)">Talk:Parser testing</a>, <a href="/index.php?title=Meta:Disclaimers&action=edit&redlink=1" class="new" title="Meta:Disclaimers (page does not exist)">Meta:Disclaimers</a> +</p> +!! end + +!! test +Link with space in namespace +!! wikitext +[[User talk:Foo bar]] +!! html +<p><a href="/index.php?title=User_talk:Foo_bar&action=edit&redlink=1" class="new" title="User talk:Foo bar (page does not exist)">User talk:Foo bar</a> +</p> +!! end + +!! article +MemoryAlpha:AlphaTest +!! text +This is an article in the MemoryAlpha namespace +(which shadows the memoryalpha interwiki link). +!! endarticle + +!! test +Namespace takes precedence over interwiki link (T53680) +!! wikitext +[[MemoryAlpha:AlphaTest]] +!! html +<p><a href="/wiki/MemoryAlpha:AlphaTest" title="MemoryAlpha:AlphaTest">MemoryAlpha:AlphaTest</a> +</p> +!! end + +# The previous test doesn't work correctly in html2*, due to not recognizing the +# link as an internal one. This one checks for the correct behavior. +!! test +Link to namespace preferred over interwiki with correct rel attribute +!! options +parsoid=html2wt,html2html +!! html/parsoid +<p><a rel="mw:WikiLink" href="./MemoryAlpha:AlphaTest" title="MemoryAlpha:AlphaTest">MemoryAlpha:AlphaTest</a></p> +!! wikitext +[[MemoryAlpha:AlphaTest]] +!! end + +!! test +Piped link to namespace +!! wikitext +[[Meta:Disclaimers|The disclaimers]] +!! html +<p><a href="/index.php?title=Meta:Disclaimers&action=edit&redlink=1" class="new" title="Meta:Disclaimers (page does not exist)">The disclaimers</a> +</p> +!! end + +!! test +Link containing } +!! wikitext +[[Usually caused by a typo (oops}]] +!! html +<p>[[Usually caused by a typo (oops}]] +</p> +!! end + +!! article +7% Solution +!! text +Just a test of an article title containing a percent. +!! endarticle + +!! test +Link containing % (not as a hex sequence) +!! wikitext +[[7% Solution]] +[[7% Solution|7%25 Solution]] +!! html/php +<p><a href="/wiki/7%25_Solution" title="7% Solution">7% Solution</a> +<a href="/wiki/7%25_Solution" title="7% Solution">7%25 Solution</a> +</p> +!! html/parsoid +<p><a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7% Solution</a> +<a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7%25 Solution</a></p> +!! end + +# note that the parsoid HTML is identical to the previous test output, +# so the previous test ensures that the html2wt mode will generate the +# "not as a hex sequence" wikitext. +!! test +Link containing % as a single hex sequence interpreted to char +!! options +parsoid=wt2wt,wt2html,html2html +!! wikitext +[[7%25 Solution]] +[[7%25 Solution|7%25 Solution]] +!! html/php +<p><a href="/wiki/7%25_Solution" title="7% Solution">7% Solution</a> +<a href="/wiki/7%25_Solution" title="7% Solution">7%25 Solution</a> +</p> +!! html/parsoid +<p><a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7% Solution</a> +<a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7%25 Solution</a></p> +!!end + +!! test +Link containing % as a double hex sequence interpreted to hex sequence +!! wikitext +[[7%2525 Solution]] +!! html +<p>[[7%2525 Solution]] +</p> +!!end + +## Example for such a section: == < == +!! test +Link containing "#<" and "#>" % as a hex sequences- these are valid section anchors +!! config +wgFragmentMode=[ 'html5', 'legacy' ] +!! wikitext +[[%23%3c]][[%23%3e]] +!! html/php +<p><a href="#<">#<</a><a href="#>">#></a> +</p> +!! html/parsoid +<p><a rel="mw:WikiLink" href="./Main_Page#<" title="Main Page" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#<"},"sa":{"href":"%23%3c"}}'>#<</a><a rel="mw:WikiLink" href="./Main_Page#>" title="Main Page" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#>"},"sa":{"href":"%23%3e"}}'>#></a></p> +!! end + +## Example for such a section: == < == +!! test +Link containing "#<" and "#>" % as a hex sequences- these are valid section anchors (legacy) +!! config +wgFragmentMode=[ 'legacy' ] +!! wikitext +[[%23%3c]][[%23%3e]] +!! html/php +<p><a href="#.3C">#<</a><a href="#.3E">#></a> +</p> +!! end + +!! test +Link containing "<#" and ">#" as a hex sequences +!! wikitext +[[%3c%23]][[%3e%23]] +!! html +<p>[[%3c%23]][[%3e%23]] +</p> +!! end + +!! test +Link containing an equals sign +!! wikitext +[[Special:BookSources/isbn=4-00-026157-6]] +!! html/php +<p><a href="/wiki/Special:BookSources/isbn%3D4-00-026157-6" title="Special:BookSources/isbn=4-00-026157-6">Special:BookSources/isbn=4-00-026157-6</a> +</p> +!! html/parsoid +<p><a rel="mw:WikiLink" href="./Special:BookSources/isbn=4-00-026157-6" title="Special:BookSources/isbn=4-00-026157-6">Special:BookSources/isbn=4-00-026157-6</a></p> +!! end + +!! article +Foo~bar +!! text +Just a test of an article title containing a tilde. +!! endarticle + +# note that links containing signatures, like [[Foo~~~~]], are +# massaged by the pre-save transform (PST) and so the tildes are never +# seen by the parser. +!! test +Link containing a tilde +!! wikitext +[[Foo~bar]] +!! html/php +<p><a href="/wiki/Foo~bar" title="Foo~bar">Foo~bar</a> +</p> +!! html/parsoid +<p><a rel="mw:WikiLink" href="./Foo~bar" title="Foo~bar">Foo~bar</a></p> +!! end + +!! test +Link containing double-single-quotes '' (T6598) +!! wikitext +[[Lista d''e paise d''o munno]] +!! html/php +<p><a href="/index.php?title=Lista_d%27%27e_paise_d%27%27o_munno&action=edit&redlink=1" class="new" title="Lista d''e paise d''o munno (page does not exist)">Lista d''e paise d''o munno</a> +</p> +!! html/parsoid +<p><a rel="mw:WikiLink" href="./Lista_d''e_paise_d''o_munno" title="Lista d''e paise d''o munno">Lista d''e paise d''o munno</a></p> +!! end + +!! test +Link containing double quotes and spaces +!! wikitext +[[Cool "Gator"]] +!! html/php +<p><a href="/index.php?title=Cool_%22Gator%22&action=edit&redlink=1" class="new" title="Cool "Gator" (page does not exist)">Cool "Gator"</a> +</p> +!! html/parsoid +<p><a rel="mw:WikiLink" href='./Cool_"Gator"' title='Cool "Gator"'>Cool "Gator"</a></p> +!! end + +!! test +File containing double quotes and spaces +!! wikitext +[[File:Cool "Gator".png]] +!! html/parsoid +<p><figure-inline class="mw-default-size" typeof="mw:Error mw:Image" data-parsoid='{"optList":[]}' data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}]}'><a href="./File:Cool_%22Gator%22.png" data-parsoid='{"a":{"href":"./File:Cool_%22Gator%22.png"},"sa":{"href":"File:Cool \"Gator\".png"}}'><img resource='./File:Cool_"Gator".png' src="./Special:FilePath/Cool_%22Gator%22.png" height="220" width="220" data-parsoid='{"a":{"resource":"./File:Cool_\"Gator\".png","height":"220","width":"220","src":"./Special:FilePath/Cool_%22Gator%22.png"},"sa":{"resource":"File:Cool \"Gator\".png","src":"./Special:FilePath/Cool_\"Gator\".png"}}'/></a></figure-inline></p> +!! end + +!! test +Redirect containing double quotes and spaces +!! wikitext +#REDIRECT [[Cool "Gator"]] +!! html/parsoid +<link rel="mw:PageProp/redirect" href="./Cool_%22Gator%22" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./Cool_%22Gator%22"},"sa":{"href":"Cool \"Gator\""}}'/> +!! end + +!! test +Link containing double-single-quotes '' in text (T6598 sanity check) +!! wikitext +Some [[Link|pretty ''italics'' and stuff]]! +!! html/php +<p>Some <a href="/index.php?title=Link&action=edit&redlink=1" class="new" title="Link (page does not exist)">pretty <i>italics</i> and stuff</a>! +</p> +!! html/parsoid +<p>Some <a rel="mw:WikiLink" href="./Link" title="Link">pretty <i>italics</i> and stuff</a>!</p> +!! end + +!! test +Link containing double-single-quotes '' in text embedded in italics (T6598 sanity check) +!! wikitext +''Some [[Link|pretty ''italics'' and stuff]]!'' +!! html +<p><i>Some <a href="/index.php?title=Link&action=edit&redlink=1" class="new" title="Link (page does not exist)">pretty <i>italics</i> and stuff</a>!</i> +</p> +!! end + +!! test +Link with double quotes in title part (literal) and alternate part (interpreted) +!! wikitext +[[File:Denys_Savchenko_''Pentecoste''.jpg]] + +[[''Pentecoste'']] + +[[''Pentecoste''|Pentecoste]] + +[[''Pentecoste''|''Pentecoste'']] +!! html/php +<p><a href="/index.php?title=Special:Upload&wpDestFile=Denys_Savchenko_%27%27Pentecoste%27%27.jpg" class="new" title="File:Denys Savchenko ''Pentecoste''.jpg">File:Denys Savchenko <i>Pentecoste</i>.jpg</a> +</p><p><a href="/index.php?title=%27%27Pentecoste%27%27&action=edit&redlink=1" class="new" title="''Pentecoste'' (page does not exist)">''Pentecoste''</a> +</p><p><a href="/index.php?title=%27%27Pentecoste%27%27&action=edit&redlink=1" class="new" title="''Pentecoste'' (page does not exist)">Pentecoste</a> +</p><p><a href="/index.php?title=%27%27Pentecoste%27%27&action=edit&redlink=1" class="new" title="''Pentecoste'' (page does not exist)"><i>Pentecoste</i></a> +</p> +!! html/parsoid +<p><figure-inline class="mw-default-size" typeof="mw:Error mw:Image" data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}]}'><a href="./File:Denys_Savchenko_''Pentecoste''.jpg"><img resource="./File:Denys_Savchenko_''Pentecoste''.jpg" src="./Special:FilePath/Denys_Savchenko_''Pentecoste''.jpg" height="220" width="220"/></a></figure-inline></p> +<p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''">''Pentecoste''</a></p> +<p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''">Pentecoste</a></p> +<p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''"><i>Pentecoste</i></a></p> +!! end + +!! test +Broken image links with HTML captions (T41700) +!! wikitext +[[File:Nonexistent|<script></script>]] +[[File:Nonexistent|100x100px|<script></script>]] +[[File:Nonexistent|<]] +[[File:Nonexistent|a<i>b</i>c]] +!! html/php +<p><a href="/index.php?title=Special:Upload&wpDestFile=Nonexistent" class="new" title="File:Nonexistent"><script></script></a> +<a href="/index.php?title=Special:Upload&wpDestFile=Nonexistent" class="new" title="File:Nonexistent"><script></script></a> +<a href="/index.php?title=Special:Upload&wpDestFile=Nonexistent" class="new" title="File:Nonexistent"><</a> +<a href="/index.php?title=Special:Upload&wpDestFile=Nonexistent" class="new" title="File:Nonexistent">abc</a> +</p> +!! html/parsoid +<p><figure-inline class="mw-default-size" typeof="mw:Error mw:Image" data-parsoid='{"optList":[{"ck":"caption","ak":"<script></script>"}]}' data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}],"caption":"&lt;script>&lt;/script>"}'><a href="./File:Nonexistent" data-parsoid='{"a":{"href":"./File:Nonexistent"},"sa":{}}'><img resource="./File:Nonexistent" src="./Special:FilePath/Nonexistent" height="220" width="220" data-parsoid='{"a":{"resource":"./File:Nonexistent","height":"220","width":"220"},"sa":{"resource":"File:Nonexistent"}}'/></a></figure-inline> +<figure-inline typeof="mw:Error mw:Image" data-parsoid='{"optList":[{"ck":"width","ak":"100x100px"},{"ck":"caption","ak":"<script></script>"}]}' data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}],"caption":"&lt;script>&lt;/script>"}'><a href="./File:Nonexistent" data-parsoid='{"a":{"href":"./File:Nonexistent"},"sa":{}}'><img resource="./File:Nonexistent" src="./Special:FilePath/Nonexistent" height="100" width="100" data-parsoid='{"a":{"resource":"./File:Nonexistent","height":"100","width":"100"},"sa":{"resource":"File:Nonexistent"}}'/></a></figure-inline> +<figure-inline class="mw-default-size" typeof="mw:Error mw:Image" data-parsoid='{"optList":[{"ck":"caption","ak":"&lt;"}]}' data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}],"caption":"<span typeof=\"mw:Entity\" data-parsoid='{\"src\":\"&amp;lt;\",\"srcContent\":\"&lt;\",\"dsr\":[107,111,null,null]}'>&lt;</span>"}'><a href="./File:Nonexistent" data-parsoid='{"a":{"href":"./File:Nonexistent"},"sa":{}}'><img resource="./File:Nonexistent" src="./Special:FilePath/Nonexistent" height="220" width="220" data-parsoid='{"a":{"resource":"./File:Nonexistent","height":"220","width":"220"},"sa":{"resource":"File:Nonexistent"}}'/></a></figure-inline> +<figure-inline class="mw-default-size" typeof="mw:Error mw:Image" data-parsoid='{"optList":[{"ck":"caption","ak":"a<i>b</i>c"}]}' data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}],"caption":"a<i data-parsoid='{\"stx\":\"html\",\"dsr\":[134,142,3,4]}'>b</i>c"}'><a href="./File:Nonexistent" data-parsoid='{"a":{"href":"./File:Nonexistent"},"sa":{}}'><img resource="./File:Nonexistent" src="./Special:FilePath/Nonexistent" height="220" width="220" data-parsoid='{"a":{"resource":"./File:Nonexistent","height":"220","width":"220"},"sa":{"resource":"File:Nonexistent"}}'/></a></figure-inline></p> +!! end + +!! test +Plain link to URL +!! wikitext +[[http://www.example.com]] +!! html/php +<p>[<a rel="nofollow" class="external autonumber" href="http://www.example.com">[1]</a>] +</p> +!! html/parsoid +<p>[<a rel="mw:ExtLink" class="external autonumber" href="http://www.example.com"></a>]</p> +!! end + +!! test +Plain link to URL with link text +!! wikitext +[[http://www.example.com Link text]] +!! html +<p>[<a rel="nofollow" class="external text" href="http://www.example.com">Link text</a>] +</p> +!! end + +!! test +Plain link to protocol-relative URL +!! wikitext +[[//www.example.com]] +!! html/php +<p>[<a rel="nofollow" class="external autonumber" href="//www.example.com">[1]</a>] +</p> +!! html/parsoid +<p>[<a rel="mw:ExtLink" class="external autonumber" href="//www.example.com"></a>]</p> +!! end + +!! test +Plain link to protocol-relative URL with link text +!! wikitext +[[//www.example.com Link text]] +!! html +<p>[<a rel="nofollow" class="external text" href="//www.example.com">Link text</a>] +</p> +!! end + +!! test +Plain link to page with question mark in title +!! wikitext +[[A?b]] + +[[A?b|Baz]] +!! html +<p><a href="/wiki/A%3Fb" title="A?b">A?b</a> +</p><p><a href="/wiki/A%3Fb" title="A?b">Baz</a> +</p> +!! end + +# I'm fairly sure the expected result here is wrong. +# We want these to be URL links, not pseudo-pages with URLs for titles.... +# However the current output is also pretty screwy. +# +# ---- +# I'm changing it to match the current output--it arguably makes more +# sense in the light of the test above. Old expected result was: +#<p>Piped link to URL: <a href="/index.php?title=Http://www.example.com&action=edit" class="new">an example URL</a> +#</p> +# But I think this test is bordering on "garbage in, garbage out" anyway. +# -- wtm +!! test +Piped link to URL +!! wikitext +Piped link to URL: [[http://www.example.com|an example URL]] +!! html/php +<p>Piped link to URL: [<a rel="nofollow" class="external text" href="http://www.example.com%7Can">example URL</a>] +</p> +!! html/parsoid +<p>Piped link to URL: [<a rel="mw:ExtLink" class="external text" href="http://www.example.com%7Can" data-parsoid='{"a":{"href":"http://www.example.com%7Can"},"sa":{"href":"http://www.example.com|an"}}'>example URL</a>]</p> +!! end + +!! test +Plain link in template argument +!! options +parsoid=wt2html +!! wikitext +{{echo|[http://www.example.com |123]}} + +{{echo|[[http://www.example.com |123]]}} + +{{echo|[[http://www.example.com |123]}} + +{{echo|[http://www.example.com |123]]}} +!! html/php +<p>[<a rel="nofollow" class="external free" href="http://www.example.com">http://www.example.com</a> +</p><p>[<a rel="nofollow" class="external text" href="http://www.example.com">|123</a>] +</p><p>{{echo|[<a rel="nofollow" class="external text" href="http://www.example.com">|123</a>}} +</p><p>[<a rel="nofollow" class="external free" href="http://www.example.com">http://www.example.com</a> +</p> +!! html/parsoid +<p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[http://www.example.com "},"2":{"wt":"123]"}},"i":0}}]}'>[<a rel="mw:ExtLink" class="external free" href="http://www.example.com">http://www.example.com</a> </p> + +<p about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[http://www.example.com |123]]"}},"i":0}}]}'>[<a rel="mw:ExtLink" class="external text" href="http://www.example.com">|123</a>]</p> + +<p>{{echo|[<a rel="mw:ExtLink" class="external text" href="http://www.example.com" data-parsoid='{"targetOff":114,"contentOffsets":[114,118],"dsr":[90,119,24,1]}'>|123</a>}}</p> + +<p about="#mwt3" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[http://www.example.com "},"2":{"wt":"123]]"}},"i":0}}]}'>[<a rel="mw:ExtLink" class="external free" href="http://www.example.com">http://www.example.com</a> </p> +!! end + +!! test +T2002: [[page|http://url/]] should link to page, not http://url/ +!! wikitext +[[Main Page|http://url/]] +!! html/php +<p><a href="/wiki/Main_Page" title="Main Page">http://url/</a> +</p> +!! html/parsoid +<p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">http://url/</a></p> +!! end + +# Parsoid does not mark self-links, by design. +!! test +T2337: Escaped self-links should be bold +!! options +title=[[Bug462]] +!! wikitext +[[Bug462]] [[Bug462]] +!! html/php+tidy +<p><a class="mw-selflink selflink">Bug462</a> <a class="mw-selflink selflink">Bug462</a> +</p> +!! html/parsoid +<p><a rel="mw:WikiLink" href="./Bug462" title="Bug462">Bug462</a> <a rel="mw:WikiLink" href="./Bug462" title="Bug462">Bug462</a></p> +!! end + +!! test +Self-link to section should not be bold +!! options +title=[[Main Page]] +!! wikitext +[[Main Page#section]] +!! html +<p><a href="/wiki/Main_Page#section" title="Main Page">Main Page#section</a> +</p> +!! end + +!! article +00 +!! text +This is 00. +!! endarticle + +!!test +Self-link to numeric title +!!options +title=[[0]] +!! wikitext +[[0]] +!! html +<p><a class="mw-selflink selflink">0</a> +</p> +!!end + +!!test +Link to numeric-equivalent title +!!options +title=[[0]] +!! wikitext +[[00]] +!! html +<p><a href="/wiki/00" title="00">00</a> +</p> +!!end + +!! test +<nowiki> inside a link +!! wikitext +[[Main<nowiki> Page</nowiki>]] [[Main Page|the main page <nowiki>[it's not very good]</nowiki>]] +!! html +<p>[[Main Page]] <a href="/wiki/Main_Page" title="Main Page">the main page [it's not very good]</a> +</p> +!! end + +!! test +Non-breaking spaces in title +!! wikitext +[[ Main Page ]] +!! html +<p><a href="/wiki/Main_Page" title="Main Page">  Main   Page  </a> +</p> +!!end + +# Add new article for the test below so that it doesn't red-link +!! article +Foo bar baz +!! text +boo +!! endarticle + +!! test +Multiple spaces in titles should normalize to a single underscore +!! options +parsoid=wt2html,wt2wt +!! wikitext +[[Foo bar baz|x]] +[[Foo bar baz|x]] +[[Foo bar baz|x]] +!! html/php +<p><a href="/wiki/Foo_bar_baz" title="Foo bar baz">x</a> +<a href="/wiki/Foo_bar_baz" title="Foo bar baz">x</a> +<a href="/wiki/Foo_bar_baz" title="Foo bar baz">x</a> +</p> +!! html/parsoid +<p><a rel="mw:WikiLink" href="./Foo_bar_baz" title="Foo bar baz">x</a> +<a rel="mw:WikiLink" href="./Foo_bar_baz" title="Foo bar baz">x</a> +<a rel="mw:WikiLink" href="./Foo_bar_baz" title="Foo bar baz">x</a> +</p> +!! end + +!! test +Internal link with ca linktrail, surrounded by bold apostrophes (T29473 primary issue) +!! options +language=ca +!! wikitext +'''[[Main Page]]''' +!! html +<p><b><a href="/wiki/Main_Page" title="Main Page">Main Page</a></b> +</p> +!! end + +!! test +Internal link with ca linktrail, surrounded by italic apostrophes (T29473 primary issue) +!! options +language=ca +!! wikitext +''[[Main Page]]'' +!! html +<p><i><a href="/wiki/Main_Page" title="Main Page">Main Page</a></i> +</p> +!! end + +!! test +Internal link with en linktrail: no apostrophes (T29473) +!! options +language=en +!! wikitext +[[Something]]'nice +!! html +<p><a href="/index.php?title=Something&action=edit&redlink=1" class="new" title="Something (page does not exist)">Something</a>'nice +</p> +!! end + +!! test +Internal link with ca linktrail with apostrophes (T29473) +!! options +language=ca +!! wikitext +[[Something]]'nice +!! html +<p><a href="/index.php?title=Something&action=edit&redlink=1" class="new" title="Something (encara no existeix)">Something'nice</a> +</p> +!! end + +!! test +Internal link with kaa linktrail with apostrophes (T29473) +!! options +language=kaa +!! wikitext +[[Something]]'nice +!! html +<p><a href="/index.php?title=Something&action=edit&redlink=1" class="new" title="Something (bet ele jaratılmag'an)">Something'nice</a> +</p> +!! end + +!! test +Link with multiple ":" in a subpage-supporting namespace (T65636) +!! wikitext +[[User:Foo/Test/63636:Bar|Test]] +!! html/php +<p><a href="/index.php?title=User:Foo/Test/63636:Bar&action=edit&redlink=1" class="new" title="User:Foo/Test/63636:Bar (page does not exist)">Test</a> +</p> +!! html/parsoid +<p><a rel="mw:WikiLink" href="./User:Foo/Test/63636:Bar" title="User:Foo/Test/63636:Bar">Test</a></p> +!! end + +## Mainly a sanity check for Parsoid +!! test +Handle title parsing for subpages +!! options +title=[[/123123]] +subpage +!! wikitext +123 +!! html/php +<p>123 +</p> +!! html/parsoid +<p>123</p> +!! end + +!! article +User:Test/123 +!! text +test 123 +!! endarticle + +!! test +Link to a subpage from a namespace other than main +!! options +title=[[User:Test]] +subpage +!! wikitext +[[/123]] +!! html/php +<p><a href="/wiki/User:Test/123" title="User:Test/123">/123</a> +</p> +!! html/parsoid +<p><a rel="mw:WikiLink" href="./User:Test/123" title="User:Test/123" data-parsoid='{"stx":"simple","a":{"href":"./User:Test/123"},"sa":{"href":"/123"}}'>/123</a></p> +!! end + +!! test +Ensure that transclusion titles are not url-decoded +!! options +subpage title=[[Test]] +parsoid=wt2html +!! wikitext +{{Bar%C3%A9}} {{/Bar%C3%A9}} +!! html/php +<p>{{Bar%C3%A9}} {{/Bar%C3%A9}} +</p> +!! html/parsoid +<p>{{Bar%C3%A9}} {{/Bar%C3%A9}}</p> +!! end + +!! test +Purely hash wikilink +!! options +title=[[User:Test/123]] +subpage +!! wikitext +[[#a|b]] +!! html/php +<p><a href="#a">b</a> +</p> +!! html/parsoid +<p><a rel="mw:WikiLink" href="./User:Test/123#a" data-parsoid='{"stx":"piped","a":{"href":"./User:Test/123#a"},"sa":{"href":"#a"}}'>b</a></p> +!! end + +!! test +Serialization of purely hash wikilink +!! options +title=[[User:Test/123]] +subpage +parsoid=html2wt +!! html/parsoid +<p><a href="#a">[[</a></p> +!! wikitext +[[#a|<nowiki>[[</nowiki>]] +!! html/php +<p><a href="#a">[[</a> +</p> +!! end + +!! test +1. Interaction of linktrail and template encapsulation +!! wikitext +{{echo|[[Foo]]}}l +!! html/parsoid +<p><a rel="mw:WikiLink" href="./Foo" title="Foo" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[Foo]]"}},"i":0}},"l"]}'>Fool</a></p> +!! end + +!! test +2. Interaction of linktrail and template encapsulation +!! options +parsoid +!! wikitext +{{echo|Some [[Fool]]}}s +!! html +<p><span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"Some [[Fool]]"}},"i":0}},"s"]}' data-parsoid='{"pi":[[{"k":"1"}]]}'>Some </span><a rel="mw:WikiLink" href="./Fool" title="Fool" about="#mwt1" data-parsoid='{"stx":"simple","a":{"href":"./Fool"},"sa":{"href":"Fool"},"tail":"s"}'>Fools</a></p> +!! end + +!! test +3. Interaction of linktrail and template encapsulation +!! options +parsoid +!! wikitext +{{echo|Some [[Fool]]s are '''bold and foolish'''}} +!! html +<p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"Some [[Fool]]s are '''bold and foolish'''"}},"i":0}}]}' data-parsoid='{"pi":[[{"k":"1"}]]}'>Some <a rel="mw:WikiLink" href="./Fool" title="Fool" data-parsoid='{"stx":"simple","a":{"href":"./Fool"},"sa":{"href":"Fool"},"tail":"s"}'>Fools</a> are <b>bold and foolish</b></p> +!! end + +!! article +Söfnuður +!! text +Test. +!! endarticle + +!! test +Internal link with is link prefix +!! options +language=is +!! wikitext +Aðrir mótmælenda[[söfnuður|söfnuðir]] og +!! html +<p>Aðrir <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðir</a> og +</p> +!! end + +!! article +Mótmælendatrú +!! text +Test. +!! endarticle + +!! test +Internal link with is link trail and link prefix +!! options +language=is +!! wikitext +[[mótmælendatrú|xxx]]ar +[[mótmælendatrú]]ar +mótmælenda[[söfnuður]] +mótmælenda[[söfnuður|söfnuðir]] +mótmælenda[[söfnuður|söfnuðir]]xxx +!! html +<p><a href="/wiki/M%C3%B3tm%C3%A6lendatr%C3%BA" title="Mótmælendatrú">xxxar</a> +<a href="/wiki/M%C3%B3tm%C3%A6lendatr%C3%BA" title="Mótmælendatrú">mótmælendatrúar</a> +<a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuður</a> +<a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðir</a> +<a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðirxxx</a> +</p> +!! end + +!! test +Parsoid link trail escaping +!! options +parsoid=html2wt,html2html +!! html/parsoid +<p><a rel="mw:WikiLink" href="./Apple" title="Apple">apple</a>s</p> +!! wikitext +[[apple]]<nowiki/>s +!! end + +!! test +Parsoid link prefix escaping +!! options +language=is +parsoid=html2wt,html2html +!! html/parsoid +<p>Aðrir mótmælenda<a rel="mw:WikiLink" href="./Söfnuður" title="Söfnuður">söfnuður</a></p> +!! wikitext +Aðrir mótmælenda<nowiki/>[[söfnuður]] +!! end + +!! test +Parsoid link bracket escaping +!! options +parsoid=html2wt,html2html +!! html/parsoid +<p><a rel="mw:WikiLink" href="./Test" title="Test">Test</a></p> +<p>[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]</p> +<p>[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]</p> +<p>[[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]]</p> +<p>[[[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]]]</p> +<p>[[[[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]]]]</p> +!! wikitext +[[Test]] + +[<nowiki/>[[Test]]] + +[[[[Test]]]] + +[[[<nowiki/>[[Test]]]]] + +[[[[[[Test]]]]]] + +[[[[[<nowiki/>[[Test]]]]]]] +!! end + +!! test +Parsoid-centric test: Whitespace in ext- and wiki-links should be preserved +!! wikitext +[[Foo| bar]] + +[[Foo| ''bar'']] + +[http://wp.org foo] + +[http://wp.org ''foo''] +!! html +<p><a href="/wiki/Foo" title="Foo"> bar</a> +</p><p><a href="/wiki/Foo" title="Foo"> <i>bar</i></a> +</p><p><a rel="nofollow" class="external text" href="http://wp.org">foo</a> +</p><p><a rel="nofollow" class="external text" href="http://wp.org"><i>foo</i></a> +</p> +!! end + +!! test +Parsoid: Scoped parsing should handle mixed transclusions and plain text +!! wikitext +[[Foo|{{echo|a}} b {{echo|c}}]] +!! html/parsoid +<p><a rel="mw:WikiLink" href="./Foo" title="Foo"><span about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"a"}},"i":0}}]}'>a</span> b <span about="#mwt3" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"c"}},"i":0}}]}'>c</span></a></p> +!! end + +!! test +Link with angle bracket after anchor +!! config +wgFragmentMode=[ 'html5', 'legacy' ] +!! wikitext +[[Foo#<bar>]] +!! html/php +<p><a href="/wiki/Foo#<bar>" title="Foo">Foo#<bar></a> +</p> +!! html/parsoid +<p><a rel="mw:WikiLink" href="./Foo#<bar>" title="Foo" data-parsoid='{"stx":"simple","a":{"href":"./Foo#<bar>"},"sa":{"href":"Foo#<bar>"}}'>Foo#<bar></a></p> +!! end + +!! test +Link with angle bracket after anchor (legacy) +!! config +wgFragmentMode=[ 'legacy' ] +!! wikitext +[[Foo#<bar>]] +!! html/php +<p><a href="/wiki/Foo#.3Cbar.3E" title="Foo">Foo#<bar></a> +</p> +!! end + +### +### Interwiki links (see maintenance/interwiki.sql) +### + +!! test +Inline interwiki link +!! options +parsoid=wt2html,wt2wt,html2html +!! wikitext +[[MeatBall:SoftSecurity]] +!! html/php +<p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity" class="extiw" title="meatball:SoftSecurity">MeatBall:SoftSecurity</a> +</p> +!! html/parsoid +<p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity" title="meatball:SoftSecurity">MeatBall:SoftSecurity</a></p> +!! end + +!! test +Inline interwiki link with empty title (T4372) +!! options +parsoid=wt2html,wt2wt,html2html +!! wikitext +[[MeatBall:]] +!! html/php +<p><a href="http://www.usemod.com/cgi-bin/mb.pl" class="extiw" title="meatball:">MeatBall:</a> +</p> +!! html/parsoid +<p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?" title="meatball:">MeatBall:</a></p> +!! end + +## html2wt and html2html will fail because we will prefer the :en: interwiki prefix over wikipedia: +!! test +Interwiki link encoding conversion (T3636) +!! options +parsoid=wt2html,wt2wt +!! wikitext +*[[Wikipedia:ro:Olteniţa]] +*[[Wikipedia:ro:Olteniţa]] +!! html +<ul><li><a href="http://en.wikipedia.org/wiki/ro:Olteni%C5%A3a" class="extiw" title="wikipedia:ro:Olteniţa">Wikipedia:ro:Olteniţa</a></li> +<li><a href="http://en.wikipedia.org/wiki/ro:Olteni%C5%A3a" class="extiw" title="wikipedia:ro:Olteniţa">Wikipedia:ro:Olteniţa</a></li></ul> + +!! html/php+tidy +<ul> +<li><a href="http://en.wikipedia.org/wiki/ro:Olteni%C5%A3a" class="extiw" title="wikipedia:ro:Olteniţa">Wikipedia:ro:Olteniţa</a></li> +<li><a href="http://en.wikipedia.org/wiki/ro:Olteni%C5%A3a" class="extiw" title="wikipedia:ro:Olteniţa">Wikipedia:ro:Olteniţa</a></li> +</ul> +!! html/parsoid +<ul> +<li><a rel="mw:WikiLink/Interwiki" href="http://en.wikipedia.org/wiki/ro:Olteniţa" title="wikipedia:ro:Olteniţa">Wikipedia:ro:Olteniţa</a></li> +<li><a rel="mw:WikiLink/Interwiki" href="http://en.wikipedia.org/wiki/ro:Olteniţa" title="wikipedia:ro:Olteniţa">Wikipedia:ro:Olteniţa</a></li> +</ul> +!! end + +!! test +Interwiki link with fragment (T4130) +!! wikitext +[[MeatBall:SoftSecurity#foo]] +!! html +<p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity#foo" class="extiw" title="meatball:SoftSecurity">MeatBall:SoftSecurity#foo</a> +</p> +!! end + +!! test +Link scenarios with escaped fragments +!! config +wgFragmentMode=[ 'html5', 'legacy' ] +!! wikitext +[[#Is this great?]] +[[Foo#Is this great?]] +[[meatball:Foo#Is this great?]] +!! html/php +<p><a href="#Is_this_great?">#Is this great?</a> +<a href="/wiki/Foo#Is_this_great?" title="Foo">Foo#Is this great?</a> +<a href="http://www.usemod.com/cgi-bin/mb.pl?Foo#Is_this_great.3F" class="extiw" title="meatball:Foo">meatball:Foo#Is this great?</a> +</p> +!! html/parsoid +<p><a rel="mw:WikiLink" href="./Main_Page#Is_this_great?" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#Is_this_great?"},"sa":{"href":"#Is this great?"}}'>#Is this great?</a> +<a rel="mw:WikiLink" href="./Foo#Is_this_great?" title="Foo" data-parsoid='{"stx":"simple","a":{"href":"./Foo#Is_this_great?"},"sa":{"href":"Foo#Is this great?"}}'>Foo#Is this great?</a> +<a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?Foo#Is_this_great?" title="meatball:Foo" data-parsoid='{"stx":"simple","a":{"href":"http://www.usemod.com/cgi-bin/mb.pl?Foo#Is_this_great?"},"sa":{"href":"meatball:Foo#Is this great?"},"isIW":true}'>meatball:Foo#Is this great?</a></p> +!! end + +!! test +Link scenarios with escaped fragments (legacy) +!! config +wgFragmentMode=[ 'legacy' ] +!! wikitext +[[#Is this great?]] +[[Foo#Is this great?]] +[[meatball:Foo#Is this great?]] +!! html/php +<p><a href="#Is_this_great.3F">#Is this great?</a> +<a href="/wiki/Foo#Is_this_great.3F" title="Foo">Foo#Is this great?</a> +<a href="http://www.usemod.com/cgi-bin/mb.pl?Foo#Is_this_great.3F" class="extiw" title="meatball:Foo">meatball:Foo#Is this great?</a> +</p> +!! end + +# Ideally the wikipedia: prefix here should be proto-relative too +# [CSA]: this is kind of a bogus test, as the PHP parser test doesn't +# define the 'en' prefix, and originally the test used 'wikipedia', +# which isn't a localinterwiki prefix hence the links to the 'en:Foo' +# article. +!! test +Different interwiki prefixes mapping to the same URL +!! wikitext +[[:en:Foo]] + +[[:en:Foo|Foo]] + +[[wikipedia:Foo]] + +[[:wikipedia:Foo|Foo]] + +[[wikipedia:en:Foo]] + +[[:wikipedia:en:Foo]] + +[[ wikiPEdia :Foo]] +!! html/parsoid +<p><a rel="mw:WikiLink/Interwiki" href="//en.wikipedia.org/wiki/Foo" data-parsoid='{"stx":"simple","a":{"href":"//en.wikipedia.org/wiki/Foo"},"sa":{"href":":en:Foo"},"isIW":true}' title="en:Foo">en:Foo</a></p> + +<p><a rel="mw:WikiLink/Interwiki" href="//en.wikipedia.org/wiki/Foo" data-parsoid='{"stx":"piped","a":{"href":"//en.wikipedia.org/wiki/Foo"},"sa":{"href":":en:Foo"},"isIW":true}' title="en:Foo">Foo</a></p> + +<p><a rel="mw:WikiLink/Interwiki" href="http://en.wikipedia.org/wiki/Foo" data-parsoid='{"stx":"simple","a":{"href":"http://en.wikipedia.org/wiki/Foo"},"sa":{"href":"wikipedia:Foo"},"isIW":true}' title="wikipedia:Foo">wikipedia:Foo</a></p> + +<p><a rel="mw:WikiLink/Interwiki" href="http://en.wikipedia.org/wiki/Foo" data-parsoid='{"stx":"piped","a":{"href":"http://en.wikipedia.org/wiki/Foo"},"sa":{"href":":wikipedia:Foo"},"isIW":true}' title="wikipedia:Foo">Foo</a></p> + +<p><a rel="mw:WikiLink/Interwiki" href="http://en.wikipedia.org/wiki/en:Foo" data-parsoid='{"stx":"simple","a":{"href":"http://en.wikipedia.org/wiki/en:Foo"},"sa":{"href":"wikipedia:en:Foo"},"isIW":true}' title="wikipedia:en:Foo">wikipedia:en:Foo</a></p> + +<p><a rel="mw:WikiLink/Interwiki" href="http://en.wikipedia.org/wiki/en:Foo" data-parsoid='{"stx":"simple","a":{"href":"http://en.wikipedia.org/wiki/en:Foo"},"sa":{"href":":wikipedia:en:Foo"},"isIW":true}' title="wikipedia:en:Foo">wikipedia:en:Foo</a></p> + +<p><a rel="mw:WikiLink/Interwiki" href="http://en.wikipedia.org/wiki/Foo" data-parsoid='{"stx":"simple","a":{"href":"http://en.wikipedia.org/wiki/Foo"},"sa":{"href":" wikiPEdia :Foo"},"isIW":true}' title="wikipedia:Foo"> wikiPEdia :Foo</a></p> +!! end + +!! test +Interwiki links that cannot be represented in wiki syntax +!! wikitext +[[meatball:ok]] +[[meatball:ok#foo|ok with fragment]] +[[meatball:ok_as_well?|ok ending with ? mark]] +[http://de.wikipedia.org/wiki/Foo?action=history has query] +[http://de.wikipedia.org/wiki/#foo is just fragment] + +!! html/php +<p><a href="http://www.usemod.com/cgi-bin/mb.pl?ok" class="extiw" title="meatball:ok">meatball:ok</a> +<a href="http://www.usemod.com/cgi-bin/mb.pl?ok#foo" class="extiw" title="meatball:ok">ok with fragment</a> +<a href="http://www.usemod.com/cgi-bin/mb.pl?ok_as_well%3F" class="extiw" title="meatball:ok as well?">ok ending with ? mark</a> +<a rel="nofollow" class="external text" href="http://de.wikipedia.org/wiki/Foo?action=history">has query</a> +<a rel="nofollow" class="external text" href="http://de.wikipedia.org/wiki/#foo">is just fragment</a> +</p> +!! html/parsoid +<p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?ok" title="meatball:ok">meatball:ok</a> +<a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?ok#foo" title="meatball:ok">ok with fragment</a> +<a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?ok_as_well?" title="meatball:ok as well?">ok ending with ? mark</a> +<a rel="mw:ExtLink" class="external text" href="http://de.wikipedia.org/wiki/Foo?action=history">has query</a> +<a rel="mw:ExtLink" class="external text" href="http://de.wikipedia.org/wiki/#foo">is just fragment</a></p> +!! end + +!! test +Interwiki links: trail +!! wikitext +[[wikipedia:Foo|Ba]]r +!! html/php +<p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo">Bar</a> +</p> +!! html/parsoid +<p><a rel="mw:WikiLink/Interwiki" href="http://en.wikipedia.org/wiki/Foo" data-parsoid='{"stx":"piped","a":{"href":"http://en.wikipedia.org/wiki/Foo"},"sa":{"href":"wikipedia:Foo"},"isIW":true,"tail":"r"}' title="wikipedia:Foo">Bar</a></p> +!! end + +!! test +Local interwiki link +!! options +parsoid=wt2html,wt2wt,html2html +!! wikitext +[[local:Template:Foo]] +!! html/php +<p><a href="/wiki/Template:Foo" title="Template:Foo">local:Template:Foo</a> +</p> +!! html/parsoid +<p><a rel="mw:WikiLink" href="./Template:Foo" title="Template:Foo">local:Template:Foo</a></p> +!! end + +# Parsoid does not mark self-links, by design. +!! test +Local interwiki link: self-link to current page +!! options +title=[[Main Page]] +parsoid=wt2html,wt2wt,html2html +!! wikitext +[[local:Main Page]] +!! html/php +<p><a class="mw-selflink selflink">local:Main Page</a> +</p> +!! html/parsoid +<p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">local:Main Page</a></p> +!! end + +!! test +Local interwiki link: prefix only (T66167) +!! options +parsoid=wt2html,wt2wt,html2html +!! wikitext +[[local:]] +!! html/php +<p><a href="/wiki/Main_Page" title="Main Page">local:</a> +</p> +!! html/parsoid +<p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">local:</a></p> +!! end + +!! test +Local interwiki link: with additional interwiki prefix (T63357) +!! options +parsoid=wt2html,wt2wt,html2html +!! wikitext +[[local:meatball:Hello]] +!! html/php +<p><a href="http://www.usemod.com/cgi-bin/mb.pl?Hello" class="extiw" title="meatball:Hello">local:meatball:Hello</a> +</p> +!! html/parsoid +<p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?Hello" title="meatball:Hello">local:meatball:Hello</a></p> +!! end + +!! test +Multiple local interwiki link prefixes +!! wikitext +[[local:local:local:local:mi:local:Foo]] +!! options +parsoid=wt2html,wt2wt,html2html +!! html/php +<p><a href="/wiki/Foo" title="Foo">local:local:local:local:mi:local:Foo</a> +</p> +!! html/parsoid +<p><a rel="mw:WikiLink" href="./Foo" title="Foo">local:local:local:local:mi:local:Foo</a></p> +!! end + +### +### Interlanguage links +### Language links (so that searching for '### language' matches..) +### + +!! test +Interlanguage link +!! wikitext +Blah blah blah +[[zh:Chinese]] +!! html/php +<p>Blah blah blah +</p> +!! html/parsoid +<p>Blah blah blah</p> +<link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/> +!! end + +## parsoid html2wt will lose the space variations +!! test +Interlanguage link with spacing +!! options +parsoid=wt2html,wt2wt,html2html +!! wikitext +Blah blah blah +[[ zh : Chinese ]] +!! html/php +<p>Blah blah blah +</p> +!! html/parsoid +<p>Blah blah blah</p> +<link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/> +!! end + +!! test +Double interlanguage link +!! wikitext +Blah blah blah +[[es:Spanish]] +[[zh:Chinese]] +!! html/php +<p>Blah blah blah +</p> +!! html/parsoid +<p>Blah blah blah</p> +<link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Spanish"/> +<link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/> +!! end + +## parsoid html2wt will lose the space variations +!! test +Interlanguage link variations +!! options +parsoid=wt2html,wt2wt,html2html +!! wikitext +Blah blah blah +[[ es :Spanish]] +[[ ZH :Chinese]] +[[es:Foo_bar]] +!! html/php +<p>Blah blah blah +</p> +!! html/parsoid +<p>Blah blah blah</p> +<link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Spanish" /> +<link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese" /> +<link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo_bar" /> +!! end + +!! test +Escaping of interlanguage links (T129218, T156308) +!! wikitext +Blah blah blah +[[:es:Spanish]] +[[ : zh : Chinese ]] +!! html/php +<p>Blah blah blah +<a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">es:Spanish</a> +<a href="http://zh.wikipedia.org/wiki/Chinese" class="extiw" title="zh:Chinese"> zh : Chinese </a> +</p> +!! html/parsoid +<p>Blah blah blah +<a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">es:Spanish</a> +<a rel="mw:WikiLink/Interwiki" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese"> zh : Chinese </a></p> +!! end + +!! test +Multiple colons escaping interlanguage links +!! options +parsoid=wt2html +!! wikitext +[[:es:Spanish]] +[[::es:Spanish]] +[[:::es:Spanish]] +!! html/php +<p><a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">es:Spanish</a> +[[::es:Spanish]] +[[:::es:Spanish]] +</p> +!! html/parsoid +<p><a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">es:Spanish</a> +[[::es:Spanish]] +[[:::es:Spanish]]</p> +!! end + +## parsoid html2wt will normalize the space to _ +!! test +Space and question mark encoding in interlanguage links (T95473) +!! options +parsoid=wt2html,wt2wt,html2html +!! wikitext +Blah blah blah +[[es:Foo bar?]] +!! html/php +<p>Blah blah blah +</p> +!! html/parsoid +<p>Blah blah blah</p> +<link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo_bar%3F" /> +!! end + +!! test +Interlanguage link, with prefix links +!! options +language=ln +!! wikitext +Blah blah blah +[[zh:Chinese]] +!! html/php +<p>Blah blah blah +</p> +!! html/parsoid +<p>Blah blah blah</p> +<link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/> +!! end + +!! test +Double interlanguage link, with prefix links (T10897) +!! options +language=ln +!! wikitext +Blah blah blah +[[es:Spanish]] +[[zh:Chinese]] +!! html/php +<p>Blah blah blah +</p> +!! html/parsoid +<p>Blah blah blah</p> +<link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Spanish"/> +<link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/> +!! end + +!! test +"Extra" interlanguage links (T34189 / gerrit 111390) +!! wikitext +Blah blah blah +[[mul:Article]] +!! html/php +<p>Blah blah blah +</p> +!! html/parsoid +<p>Blah blah blah</p> +<link rel="mw:PageProp/Language" title="Multilingual" href="http://wikisource.org/wiki/Article"/> +!! end + +## PHP parser tests script needs an update +## Parsoid html2wt will normalize output to [[:zh:Chinese]] +!! test +Language links render as inline links if $wgInterwikiMagic=false +!! options +wgInterwikiMagic=false +parsoid=wt2html,wt2wt,html2html +!! wikitext +Blah blah blah +[[zh:Chinese]] +!! html/parsoid +<p>Blah blah blah <a rel="mw:WikiLink/Interwiki" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese">zh:Chinese</a></p> +!! end + +## PHP parser tests script needs an update +## Parsoid html2wt will normalize output to [[:zh:Chinese]] +!! test +Language links render as inline links in the Talk namespace +!! options +title=Talk:Foo +parsoid=wt2html,wt2wt,html2html +!! wikitext +Blah blah blah +[[zh:Chinese]] +!! html/parsoid +<p>Blah blah blah <a rel="mw:WikiLink/Interwiki" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese">zh:Chinese</a></p> +!! end + +!! test +Parsoid-specific test: Wikilinks with should RT properly +!! options +language=ln +!! wikitext +[[WW II]] +!! html +<p><a href="/index.php?title=WW_II&action=edit&redlink=1" class="new" title="WW II (lonkásá ezalí tɛ̂)">WW II</a> +</p> +!! end + +!! test +Parsoid T55221: Wikilinks should be properly entity-escaped +!! options +parsoid={ "modes": ["html2wt"], "suppressErrors": true } +!! html/parsoid +<p>He&nbsp;llo <a href="./Foo" rel="mw:WikiLink">He&nbsp;llo</a></p> +<p>He&nbsp;llo <a href="./He&nbsp;llo" rel="mw:WikiLink">He&nbsp;llo</a></p> +!! wikitext +He&nbsp;llo [[Foo|He&nbsp;llo]] + +He&nbsp;llo He&nbsp;llo +!! html/php +<p>He&nbsp;llo <a href="/wiki/Foo" title="Foo">He&nbsp;llo</a> +</p><p>He&nbsp;llo He&nbsp;llo +</p> +!! end + +# html2wt will fail because of title normalization without data-parsoid +!! test +Parsoid: handle constructor well +!! options +parsoid=wt2html,wt2wt +!! wikitext +[[constructor]] + +[[constructor:foo]] +!! html/php +<p><a href="/index.php?title=Constructor&action=edit&redlink=1" class="new" title="Constructor (page does not exist)">constructor</a> +</p><p><a href="/index.php?title=Constructor:foo&action=edit&redlink=1" class="new" title="Constructor:foo (page does not exist)">constructor:foo</a> +</p> +!! html/parsoid +<p><a rel="mw:WikiLink" href="./Constructor" title="Constructor" data-parsoid='{"stx":"simple","a":{"href":"./Constructor"},"sa":{"href":"constructor"}}'>constructor</a></p> + +<p><a rel="mw:WikiLink" href="./Constructor:foo" title="Constructor:foo" data-parsoid='{"stx":"simple","a":{"href":"./Constructor:foo"},"sa":{"href":"constructor:foo"}}'>constructor:foo</a></p> +!! end + +!! article +ko: +!! text +Test. +!! endarticle + +# Note that `ko` isn't a known interlanguage prefix +!! test +Parsoid: recognize interlanguage links without a target page +!! options +ill +!! wikitext +[[es:]] + +[[ko:]] +!! html/php +es: +!! html/parsoid +<link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/"/> + +<p><a rel="mw:WikiLink" href="./Ko:" title="Ko:">ko:</a></p> +!! end + +# Note that `ko` isn't a known interwiki prefix +!! test +Parsoid: recognize interwiki links without a target page +!! options +parsoid=wt2html,wt2wt,html2html +!! wikitext +[[:es:]] + +[[:ko:]] +!! html/php +<p><a href="http://es.wikipedia.org/wiki/" class="extiw" title="es:">es:</a> +</p><p><a href="/wiki/Ko:" title="Ko:">ko:</a> +</p> +!! html/parsoid +<p><a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/" title="es:">es:</a></p> +<p><a rel="mw:WikiLink" href="./Ko:" title="Ko:">ko:</a></p> +!! end + +!! test +Handle interwiki links pointing to the current wiki as plain wiki links (T47209) +!! wikitext +[[mi:Foo]] +!! html/php +<p><a href="/wiki/Foo" title="Foo">mi:Foo</a> +</p> +!! html/parsoid +<p><a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"simple","a":{"href":"./Foo"},"sa":{"href":"mi:Foo"}}'>mi:Foo</a></p> +!! end + +!! test +Interlanguage link with preceding local interwiki link (T70085) +!! options +parsoid=wt2html,wt2wt,html2html +!! wikitext +Blah blah blah +[[local:es:Spanish]] +!! html/php +<p>Blah blah blah +<a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">local:es:Spanish</a> +</p> +!! html/parsoid +<p>Blah blah blah +<a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">local:es:Spanish</a></p> +!! end + +!! test +Looks like an interlanguage link, but is actually a local interwiki +!! options +parsoid=wt2html,wt2wt,html2html +!! wikitext +Blah blah blah +[[mi:Template:Foo]] +!! html/php +<p>Blah blah blah +<a href="/wiki/Template:Foo" title="Template:Foo">mi:Template:Foo</a> +</p> +!! html/parsoid +<p>Blah blah blah +<a rel="mw:WikiLink" href="./Template:Foo" title="Template:Foo">mi:Template:Foo</a></p> +!! end + +### +### Redirects, Parsoid-only +### + +!! test +1. Simple redirect to page +!! wikitext +#REDIRECT [[Main Page]] +!! html/parsoid +<link rel="mw:PageProp/redirect" href="./Main_Page"/> +!! end + +!! test +2. Other redirect variants +!! wikitext +#REDIRECT [[Main_Page]] +!! html/parsoid +<link rel="mw:PageProp/redirect" href="./Main_Page" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./Main_Page"},"sa":{"href":"Main_Page"}}'/> +!! end + +# Not a valid redirect in PHP (although perhaps it was, once upon a time) +# This tests the Parsoid bail-out code. +!! test +3. Other redirect variants +!! options +parsoid=wt2html +!! wikitext +#REDIRECT [[<nowiki>[[Bar]]</nowiki>]] +!! html/parsoid +<ol><li>REDIRECT [[<span typeof="mw:Nowiki">[[Bar]]</span>]]</li></ol> +!! end + +!! test +4. Redirect to a templated destination +!! wikitext +#REDIRECT [[{{echo|Foo}}bar]] +!! html/parsoid +<link about="#mwt2" typeof="mw:ExpandedAttrs" rel="mw:PageProp/redirect" href="./Foobar" data-parsoid='{"a":{"href":"./Foobar"},"sa":{"href":"{{echo|Foo}}bar"}}' data-mw='{"attribs":[[{"txt":"href"},{"html":"<span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid='{\"pi\":[[{\"k\":\"1\"}]],\"dsr\":[12,24,null,null]}' data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"Foo\"}},\"i\":0}}]}'>Foo</span>bar"}]]}'/> +!! end + +!! test +Empty redirect +!! options +parsoid=wt2html,wt2wt +!! wikitext +#REDIRECT [[]] +!! html/parsoid +<ol> +<li>REDIRECT [[]]</li></ol> +!! end + +!! test +Optional colon in #REDIRECT +!! options +# the colon is archaic syntax. we support it for wt2html, but we +# don't care that it roundtrips back to the modern syntax. +parsoid=wt2html,html2html +!! wikitext +#REDIRECT:[[Main Page]] +!! html/parsoid +<link rel="mw:PageProp/redirect" href="./Main_Page"/> +!! end + +!! test +Whitespace in #REDIRECT with optional colon +!! options +# the colon and gratuitous whitespace is archaic syntax. we support +# it for wt2html, but we don't care that it roundtrips back to the +# modern syntax (without extra whitespace) +parsoid=wt2html,html2html +!! wikitext + + #REDIRECT +: +[[Main Page]] +!! html/parsoid +<link rel="mw:PageProp/redirect" href="./Main_Page"/> +!! end + +!! test +Piped link in #REDIRECT +!! options +# content after piped link is ignored. we support this syntax, +# but don't care that the piped link is lost when we roundtrip this. +parsoid=wt2html +!! wikitext +#REDIRECT [[Main Page|bar]] +!! html/parsoid +<link rel="mw:PageProp/redirect" href="./Main_Page"/> +!! end + +!! test +Redirect to category (T104502) +!! options +parsoid=wt2html,wt2wt +!! wikitext +#REDIRECT [[Category:Foo]] +!! html/parsoid +<link rel="mw:PageProp/redirect" href="./Category:Foo"/> +!! end + +!! test +Redirect to category with URL encoding (T104502) +!! options +parsoid=wt2html +!! wikitext +#REDIRECT [[Category%3AFoo]] +!! html/parsoid +<link rel="mw:PageProp/redirect" href="./Category:Foo"/> +!! end + +!! test +Redirect to category page +!! wikitext +#REDIRECT [[:Category:Foo]] +!! html/parsoid +<link rel="mw:PageProp/redirect" href="./Category:Foo"/> +!! end + +!! test +Redirect to image page (1) +!! wikitext +#REDIRECT [[File:Wiki.png]] +!! html/parsoid +<link rel="mw:PageProp/redirect" href="./File:Wiki.png"/> +!! end + +!! test +Redirect to image page (2) +!! wikitext +#REDIRECT [[Image:Wiki.png]] +!! html/parsoid +<link rel="mw:PageProp/redirect" href="./File:Wiki.png" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./File:Wiki.png"},"sa":{"href":"Image:Wiki.png"}}'/> +!! end + +# html2wt disabled because wts serializes as "#REDIRECT [[:en:File:Wiki.png]]" +# Next test confirms this. +!! test +Redirect to language (1) (T104918) +!! options +parsoid=wt2html,wt2wt,html2html +!! wikitext +#REDIRECT [[en:File:Wiki.png]] +!! html/parsoid +<link rel="mw:PageProp/redirect" href="//en.wikipedia.org/wiki/File:Wiki.png"/> +!! end + +!! test +Redirect to language (2) (T104918) +!! wikitext +#REDIRECT [[:en:File:Wiki.png]] +!! html/parsoid +<link rel="mw:PageProp/redirect" href="//en.wikipedia.org/wiki/File:Wiki.png"/> +!! end + +!! test +Redirect to interwiki (T104918) +!! wikitext +#REDIRECT [[meatball:File:Wiki.png]] +!! html/parsoid +<link rel="mw:PageProp/redirect" href="http://www.usemod.com/cgi-bin/mb.pl?File:Wiki.png"/> +!! end + +!! test +Non-English #REDIRECT +!! options +language=is +!! wikitext +#TILVÍSUN [[Main Page]] +!! html/parsoid +<link rel="mw:PageProp/redirect" href="./Main_Page" data-parsoid='{"src":"#TILVÍSUN ","a":{"href":"./Main_Page"},"sa":{"href":"Main Page"}}'/> +!! end + +!! test +Redirect syntax under text isn't considered a redirect +!! wikitext +some text + +#redirect [[Main Page]] +!! html/parsoid +<p>some text</p> +<ol data-parsoid='{}'><li data-parsoid='{}'>redirect <a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page"},"sa":{"href":"Main Page"}}'>Main Page</a></li></ol> +!! end + +!! test +New redirect +!! options +parsoid=html2wt +!! html/parsoid +<p>Foo<link rel="mw:PageProp/redirect" href="./Foo"/></p> +!! wikitext +#REDIRECT [[Foo]] +Foo +!! end + +!! test +Redirect followed by block on the same line +!! options +parsoid=wt2html +!! wikitext +#REDIRECT [[Main Page]]<!-- haha -->==hi== +!! html/parsoid +<link rel="mw:PageProp/redirect" href="./Main_Page"/><!-- haha --><h2 id="hi">hi</h2> +!! end + +!! test +Redirect followed by a newline +!! wikitext +#REDIRECT [[Main Page]] +A newline +!! html/parsoid +<link rel="mw:PageProp/redirect" href="./Main_Page"/> +<p>A newline</p> +!! end + +!! test +Redirect followed by multiple newlines +!! wikitext +#REDIRECT [[Main Page]] + + +A newline +!! html/parsoid +<link rel="mw:PageProp/redirect" href="./Main_Page"/> + +<p><br/> +A newline</p> +!! end + +!! test +Drop duplicate redirects +!! options +parsoid=html2wt +!! html/parsoid +<link rel="mw:PageProp/redirect" href="./Foo"/> +<link rel="mw:PageProp/redirect" href="./Bar"/> +<link rel="mw:PageProp/redirect" href="./Baz"/> +!! wikitext +#REDIRECT [[Foo]] +!! end + +## +## XHTML tidiness +### + +!! test +<br> to <br /> +!! wikitext +1<br>2<br />3 +!! html +<p>1<br />2<br />3 +</p> +!! end + +!! test +Broken br tag sanitization +!! wikitext +</br> +!! html/php +<p></br> +</p> +!! end + +# TODO: Fix html2html mode (T53055)! +!! test +Parsoid: Broken br tag recognition +!! options +parsoid=wt2html +!! wikitext +</br> + +<br/ > +!! html+tidy +<p><br /> +</p><p><br /> +</p> +!! end + +!! test +Incorrecly removing closing slashes from correctly formed XHTML +!! wikitext +<br style="clear:both;" /> +!! html +<p><br style="clear:both;" /> +</p> +!! end + +!! test +Failing to transform badly formed HTML into correct XHTML +!! wikitext +<br style="clear: left;"> +<br style="clear: right;"> +<br style="clear: both;"> +!! html +<p><br style="clear: left;" /> +<br style="clear: right;" /> +<br style="clear: both;" /> +</p> +!!end + +## FIXME: Is Parsoid's acceptance of self-closing html-tags +## a feature or a bug? See https://phabricator.wikimedia.org/T76962 +!! test +Handling html with a div self-closing tag +!! wikitext +<div title /> +<div title/> +<div title/ > +<div title=bar /> +<div title=bar/> +<div title=bar/ > +!! html/php +<p><div title /> +<div title/> +</p> +<div> +<p><div title=bar /> +<div title=bar/> +</p> +<div title="bar/"></div> +</div> + +!! html/parsoid +<div title="" data-parsoid='{"stx":"html","selfClose":true}'></div> +<div title="" data-parsoid='{"stx":"html","selfClose":true}'></div> +<div title="" data-parsoid='{"stx":"html","selfClose":true}'></div> +<div title="bar" data-parsoid='{"stx":"html","selfClose":true}'></div> +<div title="bar" data-parsoid='{"stx":"html","selfClose":true}'></div> +<div title="bar/" data-parsoid='{"stx":"html","autoInsertedEnd":true}'></div> +!! end + +!! test +Handling html with a br self-closing tag +!! wikitext +<br title /> +<br title/> +<br title/ > +<br title=bar /> +<br title=bar/> +<br title=bar/ > +!! html/php +<p><br title="" /> +<br title="" /> +<br /> +<br title="bar" /> +<br title="bar" /> +<br title="bar/" /> +</p> +!! html/parsoid +<p><br title="" /> +<br title="" /> +<br title="" /> +<br title="bar" /> +<br title="bar" /> +<br title="bar/" /> +</p> +!! end + +!! test +Horizontal ruler (should it add that extra space?) +!! wikitext +<hr> +<hr > +foo <hr +> bar +!! html+tidy +<hr /> +<hr /><p> +foo </p><hr /><p> bar +</p> +!! end + +!! test +Horizontal ruler -- 4+ dashes render hr +!! wikitext +---- +!! html +<hr /> + +!! end + +!! test +Horizontal ruler -- eats additional dashes on the same line +!! wikitext +--------- +!! html +<hr /> + +!! end + +!! test +Horizontal ruler -- does not collapse dashes on consecutive lines +!! wikitext +---- +---- +!! html +<hr /> +<hr /> + +!! end + +!! test +Horizontal ruler -- <4 dashes render as plain text +!! wikitext +--- +!! html +<p>--- +</p> +!! end + +!! test +Horizontal ruler -- Supports content following dashes on same line +!! wikitext +---- Foo +!! html +<hr /> Foo + +!! html+tidy +<hr /><p> Foo +</p> +!! end + +### +### Block-level elements +### +!! test +Common list +!! wikitext +*Common list +*item 2 +*item 3 +!! html +<ul><li>Common list</li> +<li>item 2</li> +<li>item 3</li></ul> + +!! end + +!! test +Numbered list +!! wikitext +#Numbered list +#item 2 +#item 3 +!! html +<ol><li>Numbered list</li> +<li>item 2</li> +<li>item 3</li></ol> + +!! end + +# the switch from level 3 to ordered should not introduce a newline between +!! test +Mixed list +!! wikitext +*Mixed list +*#with numbers +**and bullets +*#and numbers +*bullets again +**bullet level 2 +***bullet level 3 +***#Number on level 4 +**bullet level 2 +**#Number on level 3 +**#Number on level 3 +*#number level 2 +*Level 1 +***Level 3 +#**Level 3, but ordered +!! html +<ul><li>Mixed list +<ol><li>with numbers</li></ol> +<ul><li>and bullets</li></ul> +<ol><li>and numbers</li></ol></li> +<li>bullets again +<ul><li>bullet level 2 +<ul><li>bullet level 3 +<ol><li>Number on level 4</li></ol></li></ul></li> +<li>bullet level 2 +<ol><li>Number on level 3</li> +<li>Number on level 3</li></ol></li></ul> +<ol><li>number level 2</li></ol></li> +<li>Level 1 +<ul><li><ul><li>Level 3</li></ul></li></ul></li></ul> +<ol><li><ul><li><ul><li>Level 3, but ordered</li></ul></li></ul></li></ol> + +!! end + +!! test +1. Nested mixed wikitext and html list +!! wikitext +*hi +*<ul><li>ho</li></ul> +*hi +**ho +!! html/php +<ul><li>hi</li> +<li><ul><li>ho</li></ul></li> +<li>hi +<ul><li>ho</li></ul></li></ul> + +!! html/parsoid +<ul><li>hi</li> +<li><ul data-parsoid='{"stx":"html"}'><li data-parsoid='{"stx":"html"}'>ho</li></ul></li> +<li>hi +<ul><li>ho</li></ul></li></ul> +!! end + +!! test +2. Nested mixed wikitext and html list (incompatible) +!! wikitext +;hi +:{{echo|<li>ho</li>}} +!! html/php +<dl><dt>hi</dt> +<dd><li>ho</li></dd></dl> + +!! html/parsoid +<dl><dt>hi</dt> +<dd><li about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"stx":"html","pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"<li>ho</li>"}},"i":0}}]}'>ho</li></dd></dl> +!! end + +!! test +Nested lists 1 +!! wikitext +*foo +**bar +!! html +<ul><li>foo +<ul><li>bar</li></ul></li></ul> + +!! end + +!! test +Nested lists 2 +!! wikitext +**foo +*bar +!! html +<ul><li><ul><li>foo</li></ul></li> +<li>bar</li></ul> + +!! end + +!! test +Nested lists 3 (first element empty) +!! wikitext +* +**bar +!! html +<ul><li> +<ul><li>bar</li></ul></li></ul> + +!! end + +!! test +Nested lists 4 (first element empty) +!! wikitext +** +*bar +!! html +<ul><li><ul><li></li></ul></li> +<li>bar</li></ul> + +!! end + +!! test +Nested lists 5 (both elements empty) +!! wikitext +** +* +!! html +<ul><li><ul><li></li></ul></li> +<li></li></ul> + +!! end + +!! test +Nested lists 6 (both elements empty) +!! wikitext +* +** +!! html +<ul><li> +<ul><li></li></ul></li></ul> + +!! end + +!! test +Nested lists 7 (skip initial nesting levels) +!! wikitext +***foo +!! html +<ul><li><ul><li><ul><li>foo</li></ul></li></ul></li></ul> + +!! end + +!! test +Nested lists 8 (multiple nesting transitions) +!! wikitext +*foo +***bar +**baz +*boo +!! html +<ul><li>foo +<ul><li><ul><li>bar</li></ul></li> +<li>baz</li></ul></li> +<li>boo</li></ul> + +!! end + +!! test +Nested lists 9 (extension interaction) +!! options +parsoid +!! wikitext +*<references /> +!! html/parsoid +<ul><li data-parsoid='{}'><ol class="mw-references references" typeof="mw:Extension/references" about="#mwt2" data-parsoid='{}' data-mw='{"name":"references","attrs":{}}'></ol></li></ul> +!! end + +!! test +1. Lists with start-of-line-transparent tokens before bullets: Comments +!! wikitext +*foo +*<!--cmt-->bar +<!--cmt-->*baz +!! html +<ul><li>foo</li> +<li>bar</li> +<li>baz</li></ul> + +!! end + +!! test +2. Lists with start-of-line-transparent tokens before bullets: Template close +!! wikitext +*foo {{echo|bar +}}*baz +!! html +<ul><li>foo bar</li> +<li>baz</li></ul> + +!! end + +!! test +List items are not parsed correctly following a <pre> block (T2785) +!! wikitext +*<pre>foo</pre> +*<pre>bar</pre> +*zar +!! html/php +<ul><li><pre>foo</pre></li> +<li><pre>bar</pre></li> +<li>zar</li></ul> + +!! html/parsoid +<ul><li><pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo"}}'>foo</pre></li> +<li><pre typeof="mw:Extension/pre" about="#mwt4" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"bar"}}'>bar</pre></li> +<li>zar</li></ul> +!! end + +# FIXME: Might benefit from a html/parsoid since this has a template +!! test +List items from template +!! wikitext + +{{inner list}} +*item 2 + +*item 0 +{{inner list}} +*item 2 + +*item 0 +*notSOL{{inner list}} +*item 2 +!! html +<ul><li>item 1</li> +<li>item 2</li></ul> +<ul><li>item 0</li> +<li>item 1</li> +<li>item 2</li></ul> +<ul><li>item 0</li> +<li>notSOL</li> +<li>item 1</li> +<li>item 2</li></ul> + +!! end + +!! test +List interrupted by empty line or heading +!! wikitext +*foo + +**bar +==A heading== +*Another list item +!! html +<ul><li>foo</li></ul> +<ul><li><ul><li>bar</li></ul></li></ul> +<h2><span class="mw-headline" id="A_heading">A heading</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: A heading">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<ul><li>Another list item</li></ul> + +!!end + +!!test +Multiple list tags generated by templates +!! wikitext +{{echo|<li>}}a +{{echo|<li>}}b +{{echo|<li>}}c +!! html +<li>a +<li>b +<li>c</li> +</li> +</li> + +!! html+tidy +<li>a +</li><li>b +</li><li>c +</li> +!! html/parsoid +<li about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"stx":"html","autoInsertedEnd":true,"dsr":[0,44,null,null],"pi":[[{"k":"1"}],[{"k":"1"}],[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"<li>"}},"i":0}},"a\n",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"<li>"}},"i":1}},"b\n",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"<li>"}},"i":2}},"c"]}'>a +</li><li about="#mwt1">b +</li><li about="#mwt1" data-parsoid='{"stx":"html","autoInsertedEnd":true,"dsr":[null,44,null,0]}'>c</li> +!!end + +!!test +Single-comment whitespace lines dont break lists, and neither do multi-comment whitespace lines +!! wikitext +*a +<!--This line will NOT split the list--> +*b + <!--This line will NOT split the list either--> +*c + <!--foo--> <!----> <!--This line NOT split the list either--> +*d +!! html +<ul><li>a</li> +<li>b</li> +<li>c</li> +<li>d</li></ul> + +!!end + +!!test +Replacing whitespace with tabs still doesn't break the list (gerrit 78327) +!! wikitext +*a +<!--This line will NOT split the list--> +*b + <!--This line will NOT split the list either--> +*c + <!--foo--> <!----> <!--This line NOT split the list + either--> +*d +!! html +<ul><li>a</li> +<li>b</li> +<li>c</li> +<li>d</li></ul> + +!!end + +# FIXME: Parsoid has a dedicated DOM pass to mimic this Tidy-specific li-hack +# That pass could possibly be removed. +!!test +Test the li-hack (a hack from Tidy days, but doesn't work as advertised with Remex) +!!options +parsoid=wt2html,wt2wt +!! wikitext +*foo +*<li>li-hack +*{{echo|<li>templated li-hack}} +*<!--foo--><li> unsupported li-hack with preceding comments + +<ul> +<li><li>not a li-hack +</li> +</ul> +!! html+tidy +<ul><li>foo</li> +<li class="mw-empty-elt"></li><li>li-hack</li> +<li class="mw-empty-elt"></li><li>templated li-hack</li> +<li class="mw-empty-elt"></li><li> unsupported li-hack with preceding comments</li></ul> +<ul> +<li class="mw-empty-elt"></li><li>not a li-hack +</li> +</ul> +!! html/parsoid +<ul><li> foo</li> +<li data-parsoid='{"stx":"html","autoInsertedEnd":true,"liHackSrc":"*"}'>li-hack</li> +<li about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"stx":"html","autoInsertedEnd":true,,"pi":[[{"k":"1"}]]}' data-mw='{"parts":["*",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"<li>templated li-hack"}},"i":0}}]}'>templated li-hack</li> +<li data-parsoid='{"autoInsertedEnd":true}'><!--foo--></li><li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>unsupported li-hack with preceding comments</li></ul> + +<ul data-parsoid='{"stx":"html"}'> +<li class="mw-empty-elt" data-parsoid='{"stx":"html","autoInsertedEnd":true}'></li><li data-parsoid='{"stx":"html"}'>not a li-hack +</li> +</ul> + +!!end + +!! test +Parsoid: Make sure nested lists are serialized on their own line even if HTML contains no newlines +!! options +parsoid +!! wikitext +#foo +##bar + +*foo +**bar + +:foo +::bar +!! html +<ol> +<li>foo<ol> +<li>bar</li> +</ol></li> +</ol><ul> +<li>foo<ul> +<li>bar</li> +</ul></li> +</ul><dl> +<dd>foo<dl> +<dd>bar</dd> +</dl></dd> +</dl> +!! end + +!! test +Parsoid: Test of whitespace serialization with Templated bullets +!! options +parsoid +!! wikitext +* {{bullet}} +!! html/parsoid +<ul> +<li class="mw-empty-elt"> </li><li about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"bullet","href":"./Template:Bullet"},"params":{},"i":0}}]}'> Bar</li> +</ul> +!! end + +# ------------------------------------------------------------------------ +# The next set of tests are about Parsoid's ability to handle badly nested +# tags (parse, minimize scope of fixup, and roundtrip back) +# ------------------------------------------------------------------------ + +# Remex and Parsoid output stems from list handling diffs because Parsoid & PHP parser. +# Parsoid's list handling is more aware of block structure. +!! test +Unbalanced closing block tags break a list +!! wikitext +<div> +*a</div><div> +*b</div> +!! html+tidy +<div> +<ul><li>a</li></ul></div><div> +<li>b</li></div> +!! html/parsoid +<div><ul> +<li>a</li> +</ul></div> +<div><ul> +<li>b</li> +</ul></div> +!! end + +!! test +Unbalanced closing non-block tags don't break a list +!! wikitext +<span> +*a</span><span> +*b</span> +!! html/php+tidy +<p><span> +</span></p> +<ul><li>a<span></span></li> +<li>b</li></ul> +!! html/parsoid +<span> +<ul> +<li>a<span></span></li> +<li>b</li> +</ul> +</span> +!! end + +# Parsoid does some post-dom-building cleanup +# which is why its output differs from Remex. +!! test +Unclosed formatting tags that straddle lists are closed and reopened +!! options +parsoid=wt2html,wt2wt,html2html +!! wikitext +#<s> a +#b </s> +!! html/php+tidy +<ol><li><s> a</s></li><s> +</s><li><s>b </s></li></ol> +!! html/parsoid +<ol><li><s> a</s></li> +<li><s>b </s></li></ol> +!! end + +# Output is ugly because of all the misnested tag fixups. +# Remex is wrapping p-tags around empty elements. +# Parsoid has special-case handling of this pattern of +# wrapping lists in formatting tags. +# FIXME: Should we remove this code from Parsoid? Or add +# special support in Remex? If the latter, maybe just wait +# for Parsoid to become the default parser. +# See T70395. +!!test +1. List embedded in a formatting tag +!! wikitext +<small> +*foo +</small> +!! html/php+tidy +<p><small> +</small></p><small><ul><li>foo</li></ul></small><small></small><p><small></small> +</p> +!! html/parsoid +<small> +<ul> +<li>foo</li> +</ul> +</small> +!!end + +# Output is ugly because of all the misnested tag fixups +# Remex is wrapping p-tags around empty elements. +# Parsoid has code that strips useless p-tags. +!!test +2. List embedded in a formatting tag in a misnested way +!! wikitext +<small> +*a +*b</small> +!! html/php+tidy +<p><small> +</small></p><small></small><ul><small><li>a</li> +</small><li><small>b</small></li></ul> +!! html/parsoid +<small></small> +<ul><small> +<li>a</li> +</small> +<li><small>b</small></li> +</ul> +!!end + +!! test +Table with missing opening <tr> tag +!! options +parsoid=wt2html,wt2wt +!! wikitext +<table> +<td>foo</td> +</tr> +</table> +!! html+tidy +<table> +<tbody><tr><td>foo</td> +</tr> +</tbody></table> +!! end + +### +### Magic Words +### + +# Note that the current date is hard-coded as +# 1970-01-01T00:02:03Z (a Thursday) +# when running parser tests. The timezone is also fixed to GMT, so +# local date will be identical to current date. + +!! test +Magic Word: {{CURRENTDAY}} +!! wikitext +{{CURRENTDAY}} +!! html +<p>1 +</p> +!! end + +!! test +Magic Word: {{CURRENTDAY2}} +!! wikitext +{{CURRENTDAY2}} +!! html +<p>01 +</p> +!! end + +!! test +Magic Word: {{CURRENTDAYNAME}} +!! wikitext +{{CURRENTDAYNAME}} +!! html +<p>Thursday +</p> +!! end + +!! test +Magic Word: {{CURRENTDOW}} +!! wikitext +{{CURRENTDOW}} +!! html +<p>4 +</p> +!! end + +!! test +Magic Word: {{CURRENTMONTH}} +!! wikitext +{{CURRENTMONTH}} +!! html +<p>01 +</p> +!! end + +!! test +Magic Word: {{CURRENTMONTH1}} +!! wikitext +{{CURRENTMONTH1}} +!! html +<p>1 +</p> +!! end + +!! test +Magic Word: {{CURRENTMONTHABBREV}} +!! wikitext +{{CURRENTMONTHABBREV}} +!! html +<p>Jan +</p> +!! end + +!! test +Magic Word: {{CURRENTMONTHNAME}} +!! wikitext +{{CURRENTMONTHNAME}} +!! html +<p>January +</p> +!! end + +!! test +Magic Word: {{CURRENTMONTHNAMEGEN}} +!! wikitext +{{CURRENTMONTHNAMEGEN}} +!! html +<p>January +</p> +!! end + +!! test +Magic Word: {{CURRENTTIME}} +!! wikitext +{{CURRENTTIME}} +!! html +<p>00:02 +</p> +!! end + +!! test +Magic Word: {{CURRENTHOUR}} +!! wikitext +{{CURRENTHOUR}} +!! html +<p>00 +</p> +!! end + +!! test +Magic Word: {{CURRENTWEEK}} (T6594) +!! wikitext +{{CURRENTWEEK}} +!! html +<p>1 +</p> +!! end + +!! test +Magic Word: {{CURRENTYEAR}} +!! wikitext +{{CURRENTYEAR}} +!! html +<p>1970 +</p> +!! end + +!! test +Magic Word: {{CURRENTTIMESTAMP}} +!! wikitext +{{CURRENTTIMESTAMP}} +!! html +<p>19700101000203 +</p> +!! end + +!! test +Magic Words LOCAL (UTC) +!! wikitext +*{{LOCALMONTH}} +*{{LOCALMONTH1}} +*{{LOCALMONTHNAME}} +*{{LOCALMONTHNAMEGEN}} +*{{LOCALMONTHABBREV}} +*{{LOCALDAY}} +*{{LOCALDAY2}} +*{{LOCALDAYNAME}} +*{{LOCALYEAR}} +*{{LOCALTIME}} +*{{LOCALHOUR}} +*{{LOCALWEEK}} +*{{LOCALDOW}} +*{{LOCALTIMESTAMP}} +!! html +<ul><li>01</li> +<li>1</li> +<li>January</li> +<li>January</li> +<li>Jan</li> +<li>1</li> +<li>01</li> +<li>Thursday</li> +<li>1970</li> +<li>00:02</li> +<li>00</li> +<li>1</li> +<li>4</li> +<li>19700101000203</li></ul> + +!! end + +!! test +Magic Word: {{FULLPAGENAME}} +!! options +title=[[User:Ævar Arnfjörð Bjarmason]] +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } +!! wikitext +{{FULLPAGENAME}} +!! html/* +<p>User:Ævar Arnfjörð Bjarmason +</p> +!! end + +!! test +Magic Word: {{FULLPAGENAMEE}} +!! options +title=[[User:Ævar Arnfjörð Bjarmason]] +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } +!! wikitext +{{FULLPAGENAMEE}} +!! html/* +<p>User:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason +</p> +!! end + +!! test +Magic Word: {{TALKSPACE}} +!! options +title=[[User:Ævar Arnfjörð Bjarmason]] +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } +!! wikitext +{{TALKSPACE}} +!! html/* +<p>User talk +</p> +!! end + +!! test +Magic Word: {{TALKSPACE}}, same namespace +!! options +title=[[User talk:Ævar Arnfjörð Bjarmason]] +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } +!! wikitext +{{TALKSPACE}} +!! html/* +<p>User talk +</p> +!! end + +!! test +Magic Word: {{TALKSPACE}}, main namespace +!! options +title=[[Parser Test]] +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } +!! wikitext +{{TALKSPACE}} +!! html/* +<p>Talk +</p> +!! end + +!! test +Magic Word: {{TALKSPACEE}} +!! options +title=[[User:Ævar Arnfjörð Bjarmason]] +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } +!! wikitext +{{TALKSPACEE}} +!! html/* +<p>User_talk +</p> +!! end + +!! test +Magic Word: {{SUBJECTSPACE}} +!! options +title=[[User talk:Ævar Arnfjörð Bjarmason]] +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } +!! wikitext +{{SUBJECTSPACE}} +!! html/* +<p>User +</p> +!! end + +!! test +Magic Word: {{SUBJECTSPACE}}, same namespace +!! options +title=[[User:Ævar Arnfjörð Bjarmason]] +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } +!! wikitext +{{SUBJECTSPACE}} +!! html/* +<p>User +</p> +!! end + +!! test +Magic Word: {{SUBJECTSPACE}}, main namespace +!! options +title=[[Parser Test]] +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } +!! wikitext +{{SUBJECTSPACE}} +!! html/* + +!! end + +!! test +Magic Word: {{SUBJECTSPACEE}} +!! options +title=[[User talk:Ævar Arnfjörð Bjarmason]] +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } +!! wikitext +{{SUBJECTSPACEE}} +!! html/* +<p>User +</p> +!! end + +!! test +Magic Word: {{NAMESPACE}} +!! options +title=[[User:Ævar Arnfjörð Bjarmason]] +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } +!! wikitext +{{NAMESPACE}} +!! html/* +<p>User +</p> +!! end + +!! test +Magic Word: {{NAMESPACEE}} +!! options +title=[[User:Ævar Arnfjörð Bjarmason]] +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } +!! wikitext +{{NAMESPACEE}} +!! html/* +<p>User +</p> +!! end + +!! test +Magic Word: {{NAMESPACENUMBER}} +!! options +title=[[User:Ævar Arnfjörð Bjarmason]] +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } +!! wikitext +{{NAMESPACENUMBER}} +!! html/* +<p>2 +</p> +!! end + +!! test +Magic Word: {{SUBPAGENAME}} +!! options +title=[[Ævar Arnfjörð Bjarmason/sub ö]] subpage +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } +!! wikitext +{{SUBPAGENAME}} +!! html/* +<p>sub ö +</p> +!! end + +!! test +Magic Word: {{SUBPAGENAMEE}} +!! options +title=[[Ævar Arnfjörð Bjarmason/sub ö]] subpage +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } +!! wikitext +{{SUBPAGENAMEE}} +!! html/* +<p>sub_%C3%B6 +</p> +!! end + +!! test +Magic Word: {{ROOTPAGENAME}} +!! options +title=[[Ævar Arnfjörð Bjarmason/sub/sub2]] subpage +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } +!! wikitext +{{ROOTPAGENAME}} +!! html/* +<p>Ævar Arnfjörð Bjarmason +</p> +!! end + +!! test +Magic Word: {{ROOTPAGENAMEE}} +!! options +title=[[Ævar Arnfjörð Bjarmason/sub/sub2]] subpage +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } +!! wikitext +{{ROOTPAGENAMEE}} +!! html/* +<p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason +</p> +!! end + +!! test +Magic Word: {{BASEPAGENAME}} +!! options +title=[[Ævar Arnfjörð Bjarmason/sub]] subpage +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } +!! wikitext +{{BASEPAGENAME}} +!! html/* +<p>Ævar Arnfjörð Bjarmason +</p> +!! end + +!! test +Magic Word: {{BASEPAGENAMEE}} +!! options +title=[[Ævar Arnfjörð Bjarmason/sub]] subpage +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } +!! wikitext +{{BASEPAGENAMEE}} +!! html/* +<p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason +</p> +!! end + +!! test +Magic Word: {{TALKPAGENAME}} +!! options +title=[[User:Ævar Arnfjörð Bjarmason]] +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } +!! wikitext +{{TALKPAGENAME}} +!! html/* +<p>User talk:Ævar Arnfjörð Bjarmason +</p> +!! end + +!! test +Magic Word: {{TALKPAGENAMEE}} +!! options +title=[[User:Ævar Arnfjörð Bjarmason]] +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } +!! wikitext +{{TALKPAGENAMEE}} +!! html/* +<p>User_talk:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason +</p> +!! end + +!! test +Magic Word: {{SUBJECTPAGENAME}} +!! options +title=[[User talk:Ævar Arnfjörð Bjarmason]] +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } +!! wikitext +{{SUBJECTPAGENAME}} +!! html/* +<p>User:Ævar Arnfjörð Bjarmason +</p> +!! end + +!! test +Magic Word: {{SUBJECTPAGENAMEE}} +!! options +title=[[User talk:Ævar Arnfjörð Bjarmason]] +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } +!! wikitext +{{SUBJECTPAGENAMEE}} +!! html/* +<p>User:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason +</p> +!! end + +!! test +Magic Word: {{NUMBEROFFILES}} +!! options +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } +!! wikitext +{{NUMBEROFFILES}} +!! html/* +<p>7 +</p> +!! end + +!! test +Magic Word: {{PAGENAME}} +!! options +title=[[User:Ævar Arnfjörð Bjarmason]] +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } +!! wikitext +{{PAGENAME}} +!! html/* +<p>Ævar Arnfjörð Bjarmason +</p> +!! end + +!! test +Magic Word: {{PAGENAME}} with metacharacters +!! options +title=[['foo & bar = baz']] +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } +!! wikitext +''{{PAGENAME}}'' +!! html+tidy +<p><i>'foo & bar = baz'</i> +</p> +!! end + +!! test +Magic Word: {{PAGENAME}} with metacharacters (T28781) +!! options +title=[[*RFC 1234 http://example.com/]] +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } +!! wikitext +{{PAGENAME}} +!! html+tidy +<p>*RFC 1234 http://example.com/ +</p> +!! end + +!! test +Magic Word: {{PAGENAMEE}} +!! options +title=[[User:Ævar Arnfjörð Bjarmason]] +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } +!! wikitext +{{PAGENAMEE}} +!! html/* +<p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason +</p> +!! end + +!! test +Magic Word: {{PAGENAMEE}} with metacharacters (T28781) +!! options +title=[[*RFC 1234 http://example.com/]] +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } +!! wikitext +{{PAGENAMEE}} +!! html+tidy +<p>*RFC_1234_http://example.com/ +</p> +!! end + +!! test +Magic Word: {{REVISIONID}} +!! options +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } +showflags +!! wikitext +{{REVISIONID}} +!! html/* +<p>1337 +</p> +flags=vary-revision-id +!! end + +!! test +Magic Word: {{SCRIPTPATH}} +!! options +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } +!! wikitext +{{SCRIPTPATH}} +!! html/* + +!! end + +!! test +Magic Word: {{STYLEPATH}} +!! options +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } +!! wikitext +{{STYLEPATH}} +!! html/* +<p>/skins +</p> +!! end + +!! test +Magic Word: {{SERVER}} +!! options +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } +!! wikitext +{{SERVER}} +!! html/* +<p><a rel="nofollow" class="external free" href="http://example.org">http://example.org</a> +</p> +!! end + +!! test +Magic Word: {{SERVERNAME}} +!! options +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } +!! wikitext +{{SERVERNAME}} +!! html/* +<p>example.org +</p> +!! end + +!! test +Magic Word: {{SITENAME}} +!! options +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } +!! wikitext +{{SITENAME}} +!! html/* +<p>MediaWiki +</p> +!! end + +!! test +Magic Word: {{PAGELANGUAGE}} +!! options +language=fr +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } +!! wikitext +{{PAGELANGUAGE}} +!! html/* +<p>fr +</p> +!! end + +!! test +Magic Word: {{PAGELANGUAGE}} on a page with no explicitly set language +!! options +parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true } +!! wikitext +{{PAGELANGUAGE}} +!! html/* +<p>en +</p> +!! end + +!! test +Case-sensitive magic words, when cased differently, should just be template transclusions +!! wikitext +{{CurrentMonth}} +{{currentday}} +{{cURreNTweEK}} +{{currentHour}} +!! html +<p><a href="/index.php?title=Template:CurrentMonth&action=edit&redlink=1" class="new" title="Template:CurrentMonth (page does not exist)">Template:CurrentMonth</a> +<a href="/index.php?title=Template:Currentday&action=edit&redlink=1" class="new" title="Template:Currentday (page does not exist)">Template:Currentday</a> +<a href="/index.php?title=Template:CURreNTweEK&action=edit&redlink=1" class="new" title="Template:CURreNTweEK (page does not exist)">Template:CURreNTweEK</a> +<a href="/index.php?title=Template:CurrentHour&action=edit&redlink=1" class="new" title="Template:CurrentHour (page does not exist)">Template:CurrentHour</a> +</p> +!! end + +!! test +Case-insensitive magic words should still work with weird casing. +!! wikitext +{{sErVeRNaMe}} +{{LCFirst:AOEU}} +{{ucFIRST:aoeu}} +{{SERver}} +!! html +<p>example.org +aOEU +Aoeu +<a rel="nofollow" class="external free" href="http://example.org">http://example.org</a> +</p> +!! end + +# From plwiki:PLOS_ONE +!! test +Parsoid: Page property magic word with magic word contents +!! wikitext +{{DISPLAYTITLE:''{{PAGENAME}}''}} +!! html/parsoid +<meta property="mw:PageProp/displaytitle" content="Main Page" about="#mwt3" typeof="mw:ExpandedAttrs" data-parsoid='{"src":"{{DISPLAYTITLE:''{{PAGENAME}}''}}"}' data-mw='{"attribs":[[{"txt":"content"},{"html":"DISPLAYTITLE:<i data-parsoid='{\"dsr\":[15,31,2,2]}'><span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid='{\"pi\":[[]],\"dsr\":[17,29,null,null]}' data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"PAGENAME\",\"function\":\"pagename\"},\"params\":{},\"i\":0}}]}'>Main Page</span></i>"}]]}'/> +!! end + +# NOTE: mw:ExpandedAttrs is not the best typeof here. mw:Transclusion is better. +# But, this is a limitation of our representation and is documented in +# TemplateHandler.js in processSpecialMagicWord +!! test +Parsoid: Template-generated DISPLAYTITLE +!! wikitext +{{{{echo|DISPLAYTITLE}}:Foo}} +!! options +showtitle +!! config +wgAllowDisplayTitle=true +wgRestrictDisplayTitle=false +!! html/php +Foo + +!! html/parsoid +<meta property="mw:PageProp/displaytitle" content="Foo" about="#mwt1" typeof="mw:ExpandedAttrs" data-parsoid='{"pi":[[]]}' data-mw='{"attribs":[[{"txt":"content"},{"html":"<span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid='{\"pi\":[[{\"k\":\"1\"}]],\"dsr\":[2,23,null,null]}' data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"DISPLAYTITLE\"}},\"i\":0}}]}'>DISPLAYTITLE</span>:Foo"}]]}'/> +!! end + +!! test +Namespace 1 {{ns:1}} +!! wikitext +{{ns:1}} +!! html +<p>Talk +</p> +!! end + +!! test +Namespace 1 {{ns:01}} +!! wikitext +{{ns:01}} +!! html +<p>Talk +</p> +!! end + +!! test +Namespace 0 {{ns:0}} (T6783) +!! wikitext +{{ns:0}} +!! html + +!! end + +!! test +Namespace 0 {{ns:00}} (T6783) +!! wikitext +{{ns:00}} +!! html + +!! end + +!! test +Namespace -1 {{ns:-1}} +!! wikitext +{{ns:-1}} +!! html +<p>Special +</p> +!! end + +!! test +Namespace User {{ns:User}} +!! wikitext +{{ns:User}} +!! html +<p>User +</p> +!! end + +!! test +Namespace User talk {{ns:User_talk}} +!! wikitext +{{ns:User_talk}} +!! html +<p>User talk +</p> +!! end + +!! test +Namespace User talk {{ns:uSeR tAlK}} +!! wikitext +{{ns:uSeR tAlK}} +!! html +<p>User talk +</p> +!! end + +!! test +Namespace File {{ns:File}} +!! wikitext +{{ns:File}} +!! html +<p>File +</p> +!! end + +!! test +Namespace File {{ns:Image}} +!! wikitext +{{ns:Image}} +!! html +<p>File +</p> +!! end + +!! test +Namespace (lang=de) Benutzer {{ns:User}} +!! options +language=de +!! wikitext +{{ns:User}} +!! html +<p>Benutzer +</p> +!! end + +!! test +Namespace (lang=de) Benutzer Diskussion {{ns:3}} +!! options +language=de +!! wikitext +{{ns:3}} +!! html +<p>Benutzer Diskussion +</p> +!! end + +!! test +Urlencode +!! wikitext +{{urlencode:hi world?!}} +{{urlencode:hi world?!|WIKI}} +{{urlencode:hi world?!|PATH}} +{{urlencode:hi world?!|QUERY}} +!! html/php +<p>hi+world%3F%21 +hi_world%3F! +hi%20world%3F%21 +hi+world%3F%21 +</p> +!! end + +!! test +Magic Word: prioritize type info over data-parsoid +!! options +parsoid=html2wt +!! html/parsoid +<meta property="mw:PageProp/forcetoc" data-parsoid='{"magicSrc":"__NOTOC__"}'/> +!! wikitext +__FORCETOC__ +!! end + +!! test +Magic Word: serialize on separate line (parsoid) +!! options +parsoid=wt2wt,html2wt +!! wikitext +foo +__NOTOC__ +bar +!! html/parsoid +foo<meta property="mw:PageProp/notoc"/>bar +!! end + +!! test +Magic Word: rt non-english wikis +!! options +parsoid=wt2wt +language=de +!! wikitext +__NOEDITSECTION__ +!! html/parsoid +<meta property="mw:PageProp/noeditsection" data-parsoid='{"magicSrc":"__NOEDITSECTION__"}'/> +!! end + +!!test +__proto__ is treated as normal wikitext (T105997) +!!wikitext +__proto__ +!!html +<p>__proto__ +</p> +!!end + +### +### Magic links +### +!! test +Magic links: internal link to RFC (T2479) +!! wikitext +[[RFC 123]] +!! html/php +<p><a href="/index.php?title=RFC_123&action=edit&redlink=1" class="new" title="RFC 123 (page does not exist)">RFC 123</a> +</p> +!! html/parsoid +<p><a rel="mw:WikiLink" href="./RFC_123" title="RFC 123">RFC 123</a></p> +!! end + +!! test +Magic links: RFC (T2479) +!! wikitext +RFC 822 +!! html/php +<p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc822">RFC 822</a> +</p> +!! html/parsoid +<p><a href="https://tools.ietf.org/html/rfc822" rel="mw:ExtLink" class="external text">RFC 822</a></p> +!! end + +!! test +Magic links: RFC (T67278) +!! wikitext +This is RFC 822 but thisRFC 822 is not RFC 822linked. +!! html/php +<p>This is <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc822">RFC 822</a> but thisRFC 822 is not RFC 822linked. +</p> +!! html/parsoid +<p>This is <a href="https://tools.ietf.org/html/rfc822" rel="mw:ExtLink" class="external text">RFC 822</a> but thisRFC 822 is not RFC 822linked.</p> +!! end + +!! test +Magic links: RFC (w/ non-newline whitespace, T30950/T31025) +!! wikitext +RFC      822 +RFC +822 +!! html/php +<p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc822">RFC 822</a> +RFC +822 +</p> +!! html/parsoid +<p><a href="https://tools.ietf.org/html/rfc822" rel="mw:ExtLink" class="external text">RFC <span typeof="mw:Entity" data-parsoid='{"src":"&nbsp;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&#160;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&#0160;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&#xA0;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&#Xa0;","srcContent":" "}'> </span> 822</a> +RFC +822</p> +!! end + +!! test +Magic links: ISBN (T3937) +!! wikitext +ISBN 0-306-40615-2 +!! html/php +<p><a href="/wiki/Special:BookSources/0306406152" class="internal mw-magiclink-isbn">ISBN 0-306-40615-2</a> +</p> +!! html/parsoid +<p><a href="./Special:BookSources/0306406152" rel="mw:WikiLink">ISBN 0-306-40615-2</a></p> +!! end + +!! test +Magic links: ISBN (T67278) +!! wikitext +This is ISBN 978-0-316-09811-3 but thisISBN 978-0-316-09811-3 is not ISBN 978-0-316-09811-3linked. +!! html/php +<p>This is <a href="/wiki/Special:BookSources/9780316098113" class="internal mw-magiclink-isbn">ISBN 978-0-316-09811-3</a> but thisISBN 978-0-316-09811-3 is not ISBN 978-0-316-09811-3linked. +</p> +!! html/parsoid +<p>This is <a href="./Special:BookSources/9780316098113" rel="mw:WikiLink">ISBN 978-0-316-09811-3</a> but thisISBN 978-0-316-09811-3 is not ISBN 978-0-316-09811-3linked.</p> +!! end + +!! test +Magic links: ISBN (w/ non-newline whitespace, T30950/T31025) +!! wikitext +ISBN      978 0 316 09811 3 +ISBN +9780316098113 +ISBN 978 +0316098113 +!! html/php +<p><a href="/wiki/Special:BookSources/9780316098113" class="internal mw-magiclink-isbn">ISBN 978 0 316 09811 3</a> +ISBN +9780316098113 +ISBN 978 +0316098113 +</p> +!! html/parsoid +<p><a href="./Special:BookSources/9780316098113" rel="mw:WikiLink">ISBN <span typeof="mw:Entity" data-parsoid='{"src":"&nbsp;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&#160;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&#0160;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&#xA0;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&#Xa0;","srcContent":" "}'> </span> 978<span typeof="mw:Entity" data-parsoid='{"src":"&nbsp;","srcContent":" "}'> </span>0<span typeof="mw:Entity" data-parsoid='{"src":"&#160;","srcContent":" "}'> </span>316<span typeof="mw:Entity" data-parsoid='{"src":"&#0160;","srcContent":" "}'> </span>09811<span typeof="mw:Entity" data-parsoid='{"src":"&#xA0;","srcContent":" "}'> </span>3</a> +ISBN +9780316098113 +ISBN 978 +0316098113</p> +!! end + +!! test +Magic links: PMID incorrectly converts space to underscore +!! wikitext +PMID 1234 +!! html/php +<p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a> +</p> +!! html/parsoid +<p><a href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract" rel="mw:ExtLink" class="external text">PMID 1234</a></p> +!! end + +!! test +Magic links: PMID (T67278) +!! wikitext +This is PMID 1234 but thisPMID 1234 is not PMID 1234linked. +!! html/php +<p>This is <a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a> but thisPMID 1234 is not PMID 1234linked. +</p> +!! html/parsoid +<p>This is <a href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract" rel="mw:ExtLink" class="external text">PMID 1234</a> but thisPMID 1234 is not PMID 1234linked.</p> +!! end + +!! test +Magic links: PMID (w/ non-newline whitespace, T30950/T31025) +!! wikitext +PMID      1234 +PMID +1234 +!! html/php +<p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a> +PMID +1234 +</p> +!! html/parsoid +<p><a href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract" rel="mw:ExtLink" class="external text">PMID <span typeof="mw:Entity" data-parsoid='{"src":"&nbsp;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&#160;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&#0160;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&#xA0;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&#Xa0;","srcContent":" "}'> </span> 1234</a> +PMID +1234</p> +!! end + +# <nowiki> nodes shouldn't be inserted during html2wt by Parsoid, +# since these are ExtLinkText, not MagicLinkText +!! test +Magic links: use appropriate serialization for "almost" magic links. +!! wikitext +X[[Special:BookSources/0978739256|foo]] + +X[https://tools.ietf.org/html/rfc1234 foo] +!! html/php +<p>X<a href="/wiki/Special:BookSources/0978739256" title="Special:BookSources/0978739256">foo</a> +</p><p>X<a rel="nofollow" class="external text" href="https://tools.ietf.org/html/rfc1234">foo</a> +</p> +!! html/parsoid +<p>X<a rel="mw:WikiLink" href="./Special:BookSources/0978739256" title="Special:BookSources/0978739256">foo</a></p> +<p>X<a rel="mw:ExtLink" class="external text" href="https://tools.ietf.org/html/rfc1234">foo</a></p> +!! end + +!! test +Magic links: All disabled (T47942) +!! options +wgEnableMagicLinks={"ISBN":false, "PMID":false, "RFC":false} +!! wikitext +ISBN 0-306-40615-2 +PMID 1234 +RFC 4321 +!! html/php +<p>ISBN 0-306-40615-2 +PMID 1234 +RFC 4321 +</p> +!! end + +### +### Templates +#### + +!! test +Nonexistent template +!! wikitext +{{thistemplatedoesnotexist}} +!! html +<p><a href="/index.php?title=Template:Thistemplatedoesnotexist&action=edit&redlink=1" class="new" title="Template:Thistemplatedoesnotexist (page does not exist)">Template:Thistemplatedoesnotexist</a> +</p> +!! end + +!! test +Template with invalid target containing tags +!! wikitext +{{a<b>b</b>|{{echo|foo}}|{{echo|a}}={{echo|b}}|a = b}} +!! html +<p>{{a<b>b</b>|foo|a=b|a = b}} +</p> +!! end + +!! test +Template with invalid target containing unclosed tag +!! wikitext +{{a<b>|{{echo|foo}}|{{echo|a}}={{echo|b}}|a = b}} +!! html +<p>{{a<b>|foo|a=b|a = b}}</b> +</p> +!! end + +!! test +Template with invalid target containing wikilink +!! wikitext +{{[[Main Page]]}} +!! html/php +<p>{{<a href="/wiki/Main_Page" title="Main Page">Main Page</a>}} +</p> +!! html/parsoid +<p><span typeof="mw:Transclusion" about="#mwt1" data-mw='{"parts":[{"template":{"target":{"wt":"[[Main Page]]"},"params":{},"i":0}}]}'>{{</span><a rel="mw:WikiLink" href="./Main_Page" about="#mwt1">Main Page</a><span about="#mwt1">}}</span></p> +!! end + +!! test +Template with just whitespace in it, T70421 +!! wikitext +{{echo|{{ }}}} +!! html/parsoid +<p about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"{{ }}"}},"i":0}}]}'>{{ }}</p> +!! end + +!! article +Template:test +!! text +This is a test template +!! endarticle + +!! test +Simple template +!! wikitext +{{test}} +!! html +<p>This is a test template +</p> +!! end + +!! test +Template with explicit namespace +!! wikitext +{{Template:test}} +!! html +<p>This is a test template +</p> +!! end + + +!! article +Template:paramtest +!! text +This is a test template with parameter {{{param}}} +!! endarticle + +!! test +Template parameter +!! wikitext +{{paramtest|param=foo}} +!! html +<p>This is a test template with parameter foo +</p> +!! end + +!! article +Template:paramtestnum +!! text +[[{{{1}}}|{{{2}}}]] +!! endarticle + +!! test +Template unnamed parameter +!! wikitext +{{paramtestnum|Main Page|the main page}} +!! html +<p><a href="/wiki/Main_Page" title="Main Page">the main page</a> +</p> +!! end + +!! article +Template:templatesimple +!! text +(test) +!! endarticle + +!! article +Template:templateredirect +!! text +#redirect [[Template:templatesimple]] +!! endarticle + +!! article +Template:templateasargtestnum +!! text +{{{{{1}}}}} +!! endarticle + +!! article +Template:templateasargtest +!! text +{{template{{{templ}}}}} +!! endarticle + +!! article +Template:templateasargtest2 +!! text +{{{{{templ}}}}} +!! endarticle + +!! test +Template with template name as unnamed argument +!! wikitext +{{templateasargtestnum|templatesimple}} +!! html +<p>(test) +</p> +!! end + +!! test +Template with template name as argument +!! wikitext +{{templateasargtest|templ=simple}} +!! html +<p>(test) +</p> +!! end + +!! test +Template with template name as argument (2) +!! wikitext +{{templateasargtest2|templ=templatesimple}} +!! html +<p>(test) +</p> +!! end + +!! article +Template:templateasargtestdefault +!! text +{{{{{templ|templatesimple}}}}} +!! endarticle + +!! article +Template:templa +!! text +'''templ''' +!! endarticle + +!! test +Template with default value +!! wikitext +{{templateasargtestdefault}} +!! html +<p>(test) +</p> +!! end + +!! test +Template with default value (value set) +!! wikitext +{{templateasargtestdefault|templ=templa}} +!! html +<p><b>templ</b> +</p> +!! end + +!! test +Template redirect +!! wikitext +{{templateredirect}} +!! html/php +<p>(test) +</p> +!! html/parsoid +<link rel="mw:PageProp/redirect" href="./Template:Templatesimple" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"templateredirect","href":"./Template:Templateredirect"},"params":{},"i":0}}]}'/> +!! end + +!! test +Template with argument in separate line +!! wikitext +{{ templateasargtest | + templ = simple }} +!! html +<p>(test) +</p> +!! end + +!! test +Template with complex template as argument +!! wikitext +{{paramtest| + param ={{ templateasargtest | + templ = simple }}}} +!! html +<p>This is a test template with parameter (test) +</p> +!! end + +!! test +Templates with templated name +!! wikitext +{{{{echo|echo}}|foo}} +{{{{echo|inner list}} }} +!! html +<p>foo +</p> +<ul><li>item 1</li></ul> + +!! html/parsoid +<p about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"{{echo|echo}}","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</p> +<ul about="#mwt4" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"{{echo|inner list}} ","href":"./Template:Inner_list"},"params":{},"i":0}}]}'><li>item 1</li></ul> +!! end + +## Regression test; the output here isn't really that interesting. +!! test +Templates with templated name and top level template args +!! wikitext +{{1{{2{{{3}}}|4=5}}}} +!! html/parsoid +<p about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"1{{2{{{3}}}|4=5}}"},"params":{},"i":0}}]}'>{{1{{2{{{3}}}|4=5}}}}</p> +!! end + +# Parsoid markup is deliberate "broken". This is an edge case. +# See long comment in TemplateHandler.js:convertAttribsToString. +!! test +Templates with invalid templated targets +!! wikitext +{{echo +{{echo|foo}} +}} +!! html/php +<p>{{echo +foo +}} +</p> +!! html/parsoid +<p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo\n{{echo|foo}}\n"},"params":{},"i":0}}]}'>{{echo +foo }}</p> +!! end + +!! test +Template with thumb image (with link in description) +!! wikitext +{{paramtest|param=[[Image:noimage.png|thumb|[[no link|link]] [[no link|caption]]]]}} +!! html/php +This is a test template with parameter <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/index.php?title=Special:Upload&wpDestFile=Noimage.png" class="new" title="File:Noimage.png">File:Noimage.png</a> <div class="thumbcaption"><a href="/index.php?title=No_link&action=edit&redlink=1" class="new" title="No link (page does not exist)">link</a> <a href="/index.php?title=No_link&action=edit&redlink=1" class="new" title="No link (page does not exist)">caption</a></div></div></div> + +!! html+tidy +<p>This is a test template with parameter </p><div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/index.php?title=Special:Upload&wpDestFile=Noimage.png" class="new" title="File:Noimage.png">File:Noimage.png</a> <div class="thumbcaption"><a href="/index.php?title=No_link&action=edit&redlink=1" class="new" title="No link (page does not exist)">link</a> <a href="/index.php?title=No_link&action=edit&redlink=1" class="new" title="No link (page does not exist)">caption</a></div></div></div> +!! html/parsoid +<p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"paramtest","href":"./Template:Paramtest"},"params":{"param":{"wt":"[[Image:noimage.png|thumb|[[no link|link]] [[no link|caption]]]]"}},"i":0}}]}'>This is a test template with parameter </p><figure class="mw-default-size" typeof="mw:Error mw:Image/Thumb" about="#mwt1" data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}]}'><a href="./File:Noimage.png" ><img resource="./File:Noimage.png" src="./Special:FilePath/Noimage.png" height="220" width="220"/></a><figcaption><a rel="mw:WikiLink" href="./No_link" title="No link">link</a> <a rel="mw:WikiLink" href="./No_link" title="No link">caption</a></figcaption></figure> +!! end + +!! article +Template:complextemplate +!! text +{{{1}}} {{paramtest| + param ={{{param}}}}} +!! endarticle + +!! test +Template with complex arguments +!! wikitext +{{complextemplate| + param ={{ templateasargtest | + templ = simple }}|[[Template:complextemplate|link]]}} +!! html +<p><a href="/wiki/Template:Complextemplate" title="Template:Complextemplate">link</a> This is a test template with parameter (test) +</p> +!! end + +!! test +T2553: link with two variables in a piped link +!! wikitext +{| +|[[{{{1}}}|{{{2}}}]] +|} +!! html/php +<table> +<tr> +<td>[[{{{1}}}|{{{2}}}]] +</td></tr></table> + +!! html/parsoid +<table> +<tbody><tr><td>[[<span about="#mwt5" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"1"},"params":{},"i":0}}]}'>{{{1}}}</span>|<span about="#mwt2" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"2"},"params":{},"i":0}}]}'>{{{2}}}</span>]]</td></tr> +</tbody></table> +!! end + +# See: T2553 +!! test +Abort table cell attribute parsing on wikilink +!! wikitext +{| +|testing [[one|two]] |three||four +|testing one two |three||four +|testing="[[one|two]]" |three||four +|} +!! html/php +<table> +<tr> +<td>testing <a href="/index.php?title=One&action=edit&redlink=1" class="new" title="One (page does not exist)">two</a> |three</td> +<td>four +</td> +<td>three</td> +<td>four +</td> +<td>testing="<a href="/index.php?title=One&action=edit&redlink=1" class="new" title="One (page does not exist)">two</a>" |three</td> +<td>four +</td></tr></table> + +!! html/parsoid +<table> +<tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'>testing <a rel="mw:WikiLink" href="./One" title="One" data-parsoid='{"stx":"piped","a":{"href":"./One"},"sa":{"href":"one"}}'>two</a> |three</td><td data-parsoid='{"stx":"row","autoInsertedEnd":true}'>four</td> +<td data-parsoid='{"a":{"testing":null,"one":null,"two":null},"sa":{"testing":"","one":"","two":""},"autoInsertedEnd":true}'>three</td><td data-parsoid='{"stx":"row","autoInsertedEnd":true}'>four</td> +<td>testing="<a rel="mw:WikiLink" href="./One" title="One" data-parsoid='{"stx":"piped","a":{"href":"./One"},"sa":{"href":"one"}}'>two</a>" |three</td><td data-parsoid='{"stx":"row","autoInsertedEnd":true}'>four</td></tr> +</tbody></table> +!! end + +!! test +Don't abort table cell attribute parsing if wikilink is found in template arg +!! wikitext +{| +|Test {{#tag:ref|One two "[[three]]" four}} +|} +!! html/parsoid +<table> +<tbody><tr><td>Test <ref about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"#tag:ref","function":"tag"},"params":{"1":{"wt":"One two \"[[three]]\" four"}},"i":0}}]}'>One two "<a rel="mw:WikiLink" href="./Three" title="Three">three</a>" four</ref></td></tr> +</tbody></table> +!! end + +!! test +Magic variable as template parameter +!! wikitext +{{paramtest|param={{SITENAME}}}} +!! html +<p>This is a test template with parameter MediaWiki +</p> +!! end + +!! article +Template:linktest +!! text +[[{{{param}}}|link]] +!! endarticle + +!! test +Template parameter as link source +!! wikitext +{{linktest|param=Main Page}} +!! html +<p><a href="/wiki/Main_Page" title="Main Page">link</a> +</p> +!! end + +!!article +Template:paramtest2 +!! text +including another template, {{paramtest|param={{{arg}}}}} +!! endarticle + +!! test +Template passing argument to another template +!! wikitext +{{paramtest2|arg='hmm'}} +!! html +<p>including another template, This is a test template with parameter 'hmm' +</p> +!! end + +!! article +Template:Linktest2 +!! text +Main Page +!! endarticle + +!! test +Template as link source +!! wikitext +[[{{linktest2}}]] + +[[{{linktest2}}|Main Page]] + +[[{{linktest2}}]]Page +!! html +<p><a href="/wiki/Main_Page" title="Main Page">Main Page</a> +</p><p><a href="/wiki/Main_Page" title="Main Page">Main Page</a> +</p><p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>Page +</p> +!! end + + +!! article +Template:loop1 +!! text +{{loop2}} +!! endarticle + +!! article +Template:loop2 +!! text +{{loop1}} +!! endarticle + +!! test +Template infinite loop +!! wikitext +{{loop1}} +!! html +<p><span class="error">Template loop detected: <a href="/wiki/Template:Loop1" title="Template:Loop1">Template:Loop1</a></span> +</p> +!! end + +!! test +Template from main namespace +!! wikitext +{{:Main Page}} +!! html +<p>blah blah +</p> +!! end + +!! article +Template:table +!! text +{| +| 1 || 2 +|- +| 3 || 4 +|} +!! endarticle + +!! test +T2529: Template with table, not included at beginning of line +!! wikitext +foo {{table}} +!! html +<p>foo +</p> +<table> +<tr> +<td>1</td> +<td>2 +</td></tr> +<tr> +<td>3</td> +<td>4 +</td></tr></table> + +!! end + +!! test +T2523: Template shouldn't eat newline (or add an extra one before table) +!! wikitext +foo +{{table}} +!! html +<p>foo +</p> +<table> +<tr> +<td>1</td> +<td>2 +</td></tr> +<tr> +<td>3</td> +<td>4 +</td></tr></table> + +!! end + +!! test +T2041: Template parameters shown as broken links +!! wikitext +{{{parameter}}} +!! html +<p>{{{parameter}}} +</p> +!! end + +!! test +Template with targets containing wikilinks +!! options +parsoid=wt2html +!! wikitext +{{[[foo]]}} + +{{[[{{echo|foo}}]]}} + +{{{{echo|[[foo}}]]}} +!! html/php +<p>{{<a href="/wiki/Foo" title="Foo">foo</a>}} +</p><p>{{<a href="/wiki/Foo" title="Foo">foo</a>}} +</p><p>{{[[foo}}]] +</p> +!! html/parsoid +<p>{{<a rel="mw:WikiLink" href="./Foo" title="Foo">foo</a>}}</p> +<p>{{<a typeof="mw:ExpandedAttrs" rel="mw:WikiLink" href="./Foo" title="Foo" data-mw='{"attribs":[[{"txt":"href"},{"html":"<span about=\"#mwt3\" typeof=\"mw:Transclusion\" data-parsoid='{\"pi\":[[{\"k\":\"1\"}]],\"dsr\":[17,29,null,null]}' data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"foo\"}},\"i\":0}}]}'>foo</span>"}]]}'>foo</a>}}</p> +<p>{{<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[foo}}]]"}},"i":0}}]}'>[[foo}}]]</span></p> +!! end + +!! article +Template:'' +!! text +bar +!! endarticle + +!! test +Templates: Double quotes as template target +!! wikitext +foo {{''}} baz +!! html/php +<p>foo bar baz +</p> +!! html/parsoid +<p>foo <span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"''","href":"./Template:''"},"params":{},"i":0}}]}'>bar</span> baz +</p> +!! end + +## This test is about making sure Parsoid's data-mw is well formed in the +## face of multiple templates with intersecting and overlapping ranges. The +## wikitext itself is wretched. +!! test +Templates with intersecting and overlapping ranges +!! wikitext +{|{{echo| +<p>ha</p>}} +{|{{echo| +<p>ho</p>}} +{{echo|{{!}}hi}} +|} +!! html/php+tidy +<p>ha</p><table> + +</table><p>ho</p><table> + +<tbody><tr> +<td>hi +</td></tr></tbody></table> +!! html/parsoid +<p about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"stx":"html","autoInsertedEnd":true,"pi":[[{"k":"1"}],[{"k":"1"}],[{"k":"1"}]],"firstWikitextNode":"table"}' data-mw='{"parts":["{|",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"\n<p>ha</p>"}},"i":0}},"\n","{|",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"\n<p>ho</p>"}},"i":1}},"\n",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"{{!}}hi"}},"i":2}},"\n|}"]}'>ha</p><table about="#mwt1" typeof="mw:ExpandedAttrs" data-mw='{"attribs":[[{"txt":"","html":""},{"html":""}]]}'> + +</table><p about="#mwt1">ho</p><table about="#mwt1" typeof="mw:ExpandedAttrs" data-mw='{"attribs":[[{"txt":"","html":""},{"html":""}]]}'> + +<tbody><tr><td>hi</td></tr> +</tbody></table> +!! end + +!! article +Template:MSGNW test +!! text +''None'' of '''this''' should be +* interpreted + but rather passed unmodified +{{test}} +<gallery> +File:Foobar.jpg +</gallery> +<!-- comment --> +!! endarticle + +# hmm, fix this or just deprecate msgnw and document its behavior? +!! test +msgnw keyword +!! wikitext +{{msgnw:MSGNW test}} +!! html/php +<p>''None'' of '''this''' should be +* interpreted + but rather passed unmodified +{{test}} +<gallery> +File:Foobar.jpg +</gallery> +<!-- comment --> +</p> +!! end + +!! test +int keyword +!! wikitext +{{int:youhavenewmessages|lots of money|not!}} +!! html +<p>You have lots of money (not!). +</p> +!! end + +!! test +int keyword - non-existing message +!! wikitext +{{int:var}} +!! html +<p>⧼var⧽ +</p> +!! end + +!! article +Template:Includes +!! text +Foo<noinclude>zar</noinclude><includeonly>bar</includeonly> +!! endarticle + +!! test +<includeonly> and <noinclude> being included +!! wikitext +{{Includes}} +!! html +<p>Foobar +</p> +!! end + +!! article +Template:Includes2 +!! text +<onlyinclude>Foo</onlyinclude>bar +!! endarticle + +!! test +<onlyinclude> being included +!! wikitext +{{Includes2}} +!! html +<p>Foo +</p> +!! end + + +!! article +Template:Includes3 +!! text +<onlyinclude>Foo</onlyinclude>bar<includeonly>zar</includeonly> +!! endarticle + +!! test +<onlyinclude> and <includeonly> being included +!! wikitext +{{Includes3}} +!! html +<p>Foo +</p> +!! end + +!! test +<includeonly> and <noinclude> on a page +!! wikitext +Foo<noinclude>zar</noinclude><includeonly>bar</includeonly> +!! html +<p>Foozar +</p> +!! end + +!! test +Un-closed <noinclude> +!! wikitext +<noinclude> +!! html +!! end + +!! test +<onlyinclude> on a page +!! wikitext +<onlyinclude>Foo</onlyinclude>bar +!! html +<p>Foobar +</p> +!! end + +!! test +Un-closed <onlyinclude> +!! wikitext +<onlyinclude> +!! html +!! end + +!!test +Self-closed noinclude, includeonly, onlyinclude tags +!! wikitext +<noinclude /> +<includeonly /> +<onlyinclude /> +!! html +<p><br /> +</p> +!!end + +!!test +Unbalanced includeonly and noinclude tags +!! wikitext +{| +|a</noinclude> +|b</noinclude></noinclude> +|c</noinclude></includeonly> +|d</includeonly></includeonly> +|} +!! html +<table> +<tr> +<td>a +</td> +<td>b +</td> +<td>c</includeonly> +</td> +<td>d</includeonly></includeonly> +</td></tr></table> + +!!end + +!! article +Template:Includeonly section +!! text +<includeonly> +==Includeonly section== +</includeonly> +==Section T-1== +!!endarticle + +!! test +T8563: Edit link generation for section shown by <includeonly> +!! wikitext +{{includeonly section}} +!! html +<h2><span class="mw-headline" id="Includeonly_section">Includeonly section</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Template:Includeonly_section&action=edit&section=T-1" title="Template:Includeonly section">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h2><span class="mw-headline" id="Section_T-1">Section T-1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Template:Includeonly_section&action=edit&section=T-2" title="Template:Includeonly section">edit</a><span class="mw-editsection-bracket">]</span></span></h2> + +!! end + +# Uses same input as the contents of [[Template:Includeonly section]] +!! test +T8563: Section extraction for section shown by <includeonly> +!! options +section=T-2 +!! wikitext +<includeonly> +==Includeonly section== +</includeonly> +==Section T-2== +!! html +==Section T-2== +!! end + +!! test +T8563: Edit link generation for section suppressed by <includeonly> +!! wikitext +<includeonly> +==Includeonly section== +</includeonly> +==Section 1== +!! html +<h2><span class="mw-headline" id="Section_1">Section 1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: Section 1">edit</a><span class="mw-editsection-bracket">]</span></span></h2> + +!! end + +!! test +T8563: Section extraction for section suppressed by <includeonly> +!! options +section=1 +!! wikitext +<includeonly> +==Includeonly section== +</includeonly> +==Section 1== +!! html +==Section 1== +!! end + +!! test +Un-closed <includeonly> +!! wikitext +<includeonly> +!! html/php +!! html/parsoid +<meta typeof="mw:Includes/IncludeOnly" data-parsoid='{"src":"<includeonly>"}'/> +!! end + +## We used to, but no longer wt2wt this test since the default serializer +## will normalize the include directives to serialize on their own line. +## Selser will take care of preserving formatting in scenarios where they +## intermingled with other wikitext. +!! test +Includes and comments at SOL +!! options +parsoid=wt2html,html2html +!! wikitext +<!-- comment --><noinclude><!-- comment --></noinclude><!-- comment -->==hu== + +<noinclude> +some +</noinclude>*stuff +*here + +<includeonly>can have stuff</includeonly>===here=== + +!! html/php +<h2><span class="mw-headline" id="hu">hu</span></h2> +<p>some +</p> +<ul><li>stuff</li> +<li>here</li></ul> +<h3><span class="mw-headline" id="here">here</span></h3> + +!! html/parsoid +<!-- comment --><meta typeof="mw:Includes/NoInclude" data-parsoid='{"src":"<noinclude>"}'/><!-- comment --><meta typeof="mw:Includes/NoInclude/End" data-parsoid='{"src":"</noinclude>"}'/><!-- comment --><h2 id="hu">hu</h2> + +<meta typeof="mw:Includes/NoInclude" data-parsoid='{"src":"<noinclude>"}'/> +<p>some</p> +<meta typeof="mw:Includes/NoInclude/End" data-parsoid='{"src":"</noinclude>"}'/><ul><li>stuff</li> +<li>here</li></ul> + +<meta typeof="mw:Includes/IncludeOnly" data-parsoid='{"src":"<includeonly>can have stuff</includeonly>"}'/><meta typeof="mw:Includes/IncludeOnly/End" data-parsoid='{"src":""}'/><h3 id="here">here</h3> + +!! end + +# TODO: test with DOM fragment reuse! +!! test +Parsoid: DOM fragment reuse +!! options +parsoid=wt2wt,wt2html +!! wikitext +a{{echo|b<table></table>c}}d + +a{{echo|b +<table></table> +c}}d + +{{echo|a + +<table></table> + +b}} +!! html +<p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":["a",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"b<table></table>c"}},"i":0}},"d"]}' data-parsoid='{"pi":[[{"k":"1"}]]}'>ab</p><table about="#mwt1" data-parsoid='{"stx":"html"}'></table><p about="#mwt1">cd</p> + +<p about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":["a",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"b\n<table></table>\nc"}},"i":0}},"d"]}' data-parsoid='{"pi":[[{"k":"1"}]]}'>ab</p><span about="#mwt2"> +</span><table about="#mwt2" data-parsoid='{"stx":"html"}'></table><span about="#mwt2"> +</span><p about="#mwt2">cd</p> + +<p about="#mwt3" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"a\n\n<table></table>\n\nb"}},"i":0}}]}' data-parsoid='{"pi":[[{"k":"1"}]]}'>a</p><span about="#mwt3"> + +</span><table about="#mwt3" data-parsoid='{"stx":"html"}'></table><span about="#mwt3"> + +</span><p about="#mwt3">b</p> +!! end + +!! test +Parsoid: Merge double tds (T52603) +!! options +parsoid +!! wikitext +{| +|{{echo|{{!}} foo}} +|} +!! html +<table><tbody> +<tr><td about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":["|",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"{{!}} foo"}},"i":0}}]}'> foo</td></tr> +</tbody></table> +!! end + +!! test +Parsoid: Merge double tds in nested transclusion content (T52603) +!! options +parsoid +!! wikitext +{{echo|<div>}} +{| +|{{echo|{{!}} foo}} +|} +{{echo|</div>}} +!! html +<div about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"<div>"}},"i":0}},"\n{|\n|",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"{{!}} foo"}},"i":1}},"\n|}\n",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"</div>"}},"i":2}}]}'> +<table><tbody> +<tr><td data-mw='{"parts":["|"]}'> foo</td></tr> +</tbody></table> +</div> +!! end + +### +### <includeonly> and <noinclude> in attributes +### +!!test +0. includeonly around the entire attribute +!! wikitext +<span <includeonly>id="v1"</includeonly><noinclude>id="v2"</noinclude>>bar</span> +!! html +<p><span id="v2">bar</span> +</p> +!!end + +!!test +1. includeonly in html attr key +!! wikitext +<span <noinclude>id</noinclude><includeonly>about</includeonly>="foo">bar</span> +!! html +<p><span id="foo">bar</span> +</p> +!!end + +!!test +2. includeonly in html attr value +!! wikitext +<span id="<noinclude>v1</noinclude><includeonly>v2</includeonly>">bar</span> +<span id=<noinclude>"v1"</noinclude><includeonly>"v2"</includeonly>>bar</span> +!! html +<p><span id="v1">bar</span> +<span id="v1">bar</span> +</p> +!!end + +!!test +3. includeonly in part of an attr value +!! wikitext +<span style="color:<noinclude>red</noinclude><includeonly>blue</includeonly>;">bar</span> +!! html +<p><span style="color:red;">bar</span> +</p> +!!end + +!!test +4. includeonly in table attributes +!! wikitext +{| +|- <noinclude> +|- +|a +</noinclude> +|- <includeonly> +|- +|b +</includeonly> +|} +!! html +<table> + + +<tr> +<td>a +</td></tr> +</table> + +!!end + +### +### Preprocessor precedence tests +### See: https://www.mediawiki.org/wiki/Preprocessor_ABNF +### +##{{[[-{{{{{{[[Foo|bar}}]]}-}}}}}]] +!! test +Preprocessor precedence 1: link is rightmost opening +!! options +parsoid=wt2html +!! wikitext +{{[[Foo|bar}}]] + +But close-brace is not a valid character in a link title: +{{[[Foo}}|bar]] + +However, we can still tell this was handled as a link in the preprocessor: +{{echo|[[Foo}}|bar]]|bat}} +!! html/php +<p>{{<a href="/wiki/Foo" title="Foo">bar}}</a> +</p><p>But close-brace is not a valid character in a link title: +{{[[Foo}}|bar]] +</p><p>However, we can still tell this was handled as a link in the preprocessor: +[[Foo}}|bar]] +</p> +!! html/parsoid +<p>{{<a rel="mw:WikiLink" href="./Foo" title="Foo">bar}}</a></p> +<p>But close-brace is not a valid character in a link title: {{[[Foo}}|bar]]</p> +<p>However, we can still tell this was handled as a link in the preprocessor: <span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[Foo}}|bar]]"},"2":{"wt":"bat"}},"i":0}}]}'>[[Foo}}|bar]]</span></p> +!! end + +!! test +Preprocessor precedence 2: template is rightmost opening +!! options +language=zh +!! wikitext +-{{echo|foo}-}}- +!! html/php +<p>-foo}-- +</p> +!! html/parsoid +<p>-<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo}-"}},"i":0}}]}'>foo}-</span>-</p> +!! end + +!! test +Preprocessor precedence 3: language converter is rightmost opening +!! options +language=zh +parsoid=wt2html +!! wikitext +{{echo|hi}} + +{{-{R|echo|hi}}}- + +[[-{R|raw]]}- +!! html/php +<p>hi +</p><p>{{echo|hi}} +</p><p>[[raw]] +</p> +!! html/parsoid +<p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi"}},"i":0}}]}'>hi</p> +<p>{{<span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"echo|hi}}"}}'></span></p> +<p>[[<span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw]]"}}'></span></p> +!! end + +!! test +Preprocessor precedence 4: left-most angle bracket +!! options +language=zh +!! wikitext +<!--{raw}--> +!! html/php +!! html/parsoid +<!--{raw}--> +!! end + +!! article +Template:Precedence5 +!! text +{{{{{1}}}}} +!! endarticle + +!! test +Preprocessor precedence 5: tplarg takes precedence over template +!! wikitext +{{Precedence5|Bullet}} +!! html/php +<ul><li>Bar</li></ul> + +!! html/parsoid +<ul typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"Precedence5","href":"./Template:Precedence5"},"params":{"1":{"wt":"Bullet"}},"i":0}}]}'><li>Bar</li></ul> +!! end + +!! test +Preprocessor precedence 6: broken link is rightmost opening +!! options +parsoid=wt2html +!! wikitext +{{echo|[[Foo}} + +{{echo|[[Foo|bar|bat=baz}} +!! html/php +<p>{{echo|[[Foo}} +</p><p>{{echo|[[Foo|bar|bat=baz}} +</p> +!! html/parsoid +<p>{{echo|[[Foo}}</p> +<p>{{echo|[[Foo|bar|bat=baz}}</p> +!! end + +# This next test exposes a difference between PHP and Parsoid: +# Given [[Foo|{{echo|Bar]]x}}y]]z: +# 1) Both PHP and Parsoid ignore the `]]` inside the `echo` in the +# "preprocessor" stage. The `{{echo` extends until the `x}}`, and the +# outer `[[Foo` extends until the `y]]` +# 2a) But then the PHP preprocessor emits `[[Foo|Bar]]xy]]z` as an +# intermediate result (after template expansion), and link processing +# happens on this intermediate result, which moves the wikilink +# boundary leftward to `[[Foo|Bar]]` +# 2b) Parsoid works in a single step, so it's going to keep the +# wikilink as extending to the `y]]` +# 3a) Then PHP does linktrail processing which slurps up the trailing +# `xy` inside the link. +# 3b) Parsoid will do linktrail processing to slurp up the trailing +# `z` inside the link. +# This is "correct" behavior. Parsoid's basic worldview is that the +# `]]` inside the template shouldn't be allowed to leak out to affect +# the surrounding wikilink. PHP may match Parsoid (in the future) +# if you use {{#balance}} (T114445). + +!! test +Preprocessor precedence 7: broken template is rightmost opening +!! options +parsoid=wt2html +!! wikitext +[[Foo|{{echo|Bar]] + +[[Foo|{{echo|Bar]]-x}}-y]]-z + +Careful: linktrails can move the end of the wikilink: +[[Foo|{{echo|y']]a}}l]]l +!! html/php +<p><a href="/wiki/Foo" title="Foo">{{echo|Bar</a> +</p><p><a href="/wiki/Foo" title="Foo">Bar</a>-x-y]]-z +</p><p>Careful: linktrails can move the end of the wikilink: +<a href="/wiki/Foo" title="Foo">y'al</a>]]l +</p> +!! html/parsoid +<p>[[Foo|{{echo|Bar]]</p> +<p><a rel="mw:WikiLink" href="./Foo" title="Foo"><span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"Bar]]-x"}},"i":0}}]}'>Bar]]-x</span>-y</a>-z</p> +<p>Careful: linktrails can move the end of the wikilink: +<a rel="mw:WikiLink" href="./Foo" title="Foo"><span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"y']]a"}},"i":0}}]}'>y']]a</span>ll</a></p> +!! end + +!! test +Preprocessor precedence 8: broken language converter is rightmost opening +!! options +language=zh +!! wikitext +[[Foo-{R|raw]] +!! html +<p>[[Foo-{R|raw]] +</p> +!! end + +!! article +Template:Preprocessor_precedence_9 +!! text +;4: {{{{1}}}} +;5: {{{{{2}}}}} +;6: {{{{{{3}}}}}} +;7: {{{{{{{4}}}}}}} +!! endarticle + +!! test +Preprocessor precedence 9: groups of braces +!! wikitext +{{Preprocessor precedence 9|Four|Bullet|1|2}} +!! html/php +<dl><dt>4</dt> +<dd>{Four}</dd> +<dt>5</dt> +<dd></dd></dl> +<ul><li>Bar</li></ul> +<dl><dt>6</dt> +<dd>Four</dd> +<dt>7</dt> +<dd>{Bullet}</dd></dl> + +!! html/parsoid +<dl about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"Preprocessor precedence 9","href":"./Template:Preprocessor_precedence_9"},"params":{"1":{"wt":"Four"},"2":{"wt":"Bullet"},"3":{"wt":"1"},"4":{"wt":"2"}},"i":0}}]}'> +<dt>4</dt> +<dd>{Four}</dd> +<dt>5</dt> +<dd></dd> +</dl><ul about="#mwt1"> +<li>Bar</li> +</ul><span about="#mwt1"> </span><dl about="#mwt1"> +<dt>6</dt> +<dd>Four</dd> +<dt>7</dt> +<dd>{Bullet}</dd> +</dl> +!! end + +!! article +Template:Preprocessor_precedence_10 +!! text +;1: -{R|raw}- +;2: -{{Bullet}}- +;3: -{{{1}}}- +;4: -{{{{2}}}}- +;5: -{{{{{3}}}}}- +;6: -{{{{{{4}}}}}}- +;7: -{{{{{{{5}}}}}}}- +!! endarticle + +!! test +Preprocessor precedence 10: groups of braces with leading dash +!! options +language=zh +!! wikitext +{{Preprocessor precedence 10|Three|raw2|Bullet|1|2}} +!! html/php +<dl><dt>1</dt> +<dd>raw</dd> +<dt>2</dt> +<dd>-</dd></dl> +<ul><li>Bar-</li></ul> +<dl><dt>3</dt> +<dd>-Three-</dd> +<dt>4</dt> +<dd>raw2</dd> +<dt>5</dt> +<dd>-</dd></dl> +<ul><li>Bar-</li></ul> +<dl><dt>6</dt> +<dd>-Three-</dd> +<dt>7</dt> +<dd>raw2</dd></dl> + +!! html/parsoid +<dl about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"Preprocessor precedence 10","href":"./Template:Preprocessor_precedence_10"},"params":{"1":{"wt":"Three"},"2":{"wt":"raw2"},"3":{"wt":"Bullet"},"4":{"wt":"1"},"5":{"wt":"2"}},"i":0}}]}'> +<dt>1</dt> +<dd><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw"}}'></span></dd> +<dt>2</dt> +<dd>-</dd> +</dl><ul about="#mwt1"> +<li>Bar-</li> +</ul><span about="#mwt1"> </span><dl about="#mwt1"> +<dt>3</dt> +<dd>-Three-</dd> +<dt>4</dt> +<dd><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw2"}}'></span></dd> +<dt>5</dt> +<dd>-</dd> +</dl><ul about="#mwt1"> +<li>Bar-</li> +</ul><span about="#mwt1"> </span><dl about="#mwt1"> +<dt>6</dt> +<dd>-Three-</dd> +<dt>7</dt> +<dd><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw2"}}'></span></dd> +</dl> +!! end + +!! test +Preprocessor precedence 11: found during visual diff testing +!! wikitext +{{#tag:span|-{{#tag:span|-{{echo|x}}}}}} + +{{echo|-{{echo|-{{echo|x}}}}}} + +{{echo|-{{echo|x}}}} +!! html/php +<p><span>-<span>-x</span></span> +</p><p>--x +</p><p>-x +</p> +!! html/parsoid +<p><span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"#tag:span","function":"tag"},"params":{"1":{"wt":"-{{#tag:span|-{{echo|x}}}}"}},"i":0}}]}'>-<span>-x</span></span></p> + +<p about="#mwt4" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"-{{echo|-{{echo|x}}}}"}},"i":0}}]}'>--x</p> + +<p about="#mwt7" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"-{{echo|x}}"}},"i":0}}]}'>-x</p> +!! end + +!! test +Preprocessor precedence 12: broken language converter closed by brace. +!! options +parsoid=wt2html +!! wikitext +This form breaks the template, which is unfortunate: +*{{echo|foo-{bar}bat}} + +But if the broken language converter markup is inside an extension +tag, nothing bad happens: +*<nowiki>foo-{bar}bat</nowiki> +*{{echo|<nowiki>foo-{bar}bat</nowiki>}} +*<pre>foo-{bar}bat</pre> +*{{echo|<pre>foo-{bar}bat</pre>}} + +<tag>foo-{bar}bat</tag> +{{echo|<tag>foo-{bar}bat</tag>}} + +!! html/php+tidy +<p>This form breaks the template, which is unfortunate: +</p> +<ul><li>{{echo|foo-{bar}bat}}</li></ul> +<p>But if the broken language converter markup is inside an extension +tag, nothing bad happens: +</p> +<ul><li>foo-{bar}bat</li> +<li>foo-{bar}bat</li> +<li><pre>foo-{bar}bat</pre></li> +<li><pre>foo-{bar}bat</pre></li></ul> +<pre>'foo-{bar}bat' +array ( +) +</pre> +<pre>'foo-{bar}bat' +array ( +) +</pre> +!! html/parsoid +<p>This form breaks the template, which is unfortunate:</p> +<ul> +<li>{{echo|foo-{bar}bat}}</li> +</ul> +<p>But if the broken language converter markup is inside an extension tag, nothing bad happens:</p> +<ul> +<li><span typeof="mw:Nowiki">foo-{bar}bat</span></li> +<li><span typeof="mw:Transclusion mw:Nowiki" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"<nowiki>foo-{bar}bat</nowiki>"}},"i":0}}]}'>foo-{bar}bat</span></li> +<li><pre typeof="mw:Extension/pre" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo-{bar}bat"}}'>foo-{bar}bat</pre></li> +<li><pre typeof="mw:Transclusion mw:Extension/pre" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"<pre>foo-{bar}bat</pre>"}},"i":0}}]}'>foo-{bar}bat</pre></li> +</ul> +<pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"foo-{bar}bat"}}'></pre> <pre typeof="mw:Extension/tag mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"<tag>foo-{bar}bat</tag>"}},"i":0}}]}'></pre> +!! end + +!! test +Preprocessor precedence 13: broken language converter in external link +!! options +parsoid=wt2html +!! wikitext +*[http://example.com/-{foo Example in URL] +*[http://example.com Example in -{link} description] +*{{echo|[http://example.com/-{foo Breaks template, however]}} +!! html/php+tidy +<ul><li><a rel="nofollow" class="external text" href="http://example.com/-{foo">Example in URL</a></li> +<li><a rel="nofollow" class="external text" href="http://example.com">Example in -{link} description</a></li> +<li>{{echo|<a rel="nofollow" class="external text" href="http://example.com/-{foo">Breaks template, however</a>}}</li></ul> +!! html/parsoid +<ul> +<li><a rel="mw:ExtLink" class="external text" href="http://example.com/-{foo">Example in URL</a></li> +<li><a rel="mw:ExtLink" class="external text" href="http://example.com">Example in -{link} description</a></li> +<li>{{echo|<a rel="mw:ExtLink" class="external text" href="http://example.com/-{foo">Breaks template, however</a>}}</li> +</ul> +!! end + +!! test +Preprocessor precedence 14: broken language converter in comment +!! wikitext +*<!--{{foo}}-->...should be ok +*<!---{{foo}}-->...extra dashes +*{{echo|foo<!-- -{bar} -->bat}}...should be ok +!! html/php+tidy +<ul><li>...should be ok</li> +<li>...extra dashes</li> +<li>foobat...should be ok</li></ul> +!! html/parsoid +<ul> +<li><!--{{foo}}-->...should be ok</li> +<li><!---{{foo}}-->...extra dashes</li> +<li><span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo<!-- -{bar} -->bat"}},"i":0}}]}'>foo</span><span about="#mwt1"><!-- -{bar} --></span><span about="#mwt1">bat</span>...should be ok</li> +</ul> +!! end + +!! test +Preprocessor precedence 15: broken brace markup in headings +!! config +wgFragmentMode=[ 'html5', 'legacy' ] +!! options +parsoid=wt2html +!! wikitext +__NOTOC__ __NOEDITSECTION__ +===1 foo[bar 1=== +1 +===2 foo[[bar 2=== +2 +===3 foo{bar 3=== +3 +===4 foo{{bar 4=== +4 +===5 foo{{{bar 5=== +5 +===6 foo-{bar 6=== +6 +!! html/php+tidy +<h3><span id="1_foo.5Bbar_1"></span><span class="mw-headline" id="1_foo[bar_1">1 foo[bar 1</span></h3> +<p>1 +</p> +<h3><span id="2_foo.5B.5Bbar_2"></span><span class="mw-headline" id="2_foo[[bar_2">2 foo[[bar 2</span></h3> +<p>2 +</p> +<h3><span id="3_foo.7Bbar_3"></span><span class="mw-headline" id="3_foo{bar_3">3 foo{bar 3</span></h3> +<p>3 +</p> +<h3><span id="4_foo.7B.7Bbar_4"></span><span class="mw-headline" id="4_foo{{bar_4">4 foo{{bar 4</span></h3> +<p>4 +</p> +<h3><span id="5_foo.7B.7B.7Bbar_5"></span><span class="mw-headline" id="5_foo{{{bar_5">5 foo{{{bar 5</span></h3> +<p>5 +</p> +<h3><span id="6_foo-.7Bbar_6"></span><span class="mw-headline" id="6_foo-{bar_6">6 foo-{bar 6</span></h3> +<p>6 +</p> +!! html/parsoid +<meta property="mw:PageProp/notoc"/> <meta property="mw:PageProp/noeditsection"/> +<h3 id="1_foo[bar_1"><span id="1_foo.5Bbar_1" typeof="mw:FallbackId"></span>1 foo[bar 1</h3> +<p>1</p> +<h3 id="2_foo[[bar_2"><span id="2_foo.5B.5Bbar_2" typeof="mw:FallbackId"></span>2 foo[[bar 2</h3> +<p>2</p> +<h3 id="3_foo{bar_3"><span id="3_foo.7Bbar_3" typeof="mw:FallbackId"></span>3 foo{bar 3</h3> +<p>3</p> +<h3 id="4_foo{{bar_4"><span id="4_foo.7B.7Bbar_4" typeof="mw:FallbackId"></span>4 foo{{bar 4</h3> +<p>4</p> +<h3 id="5_foo{{{bar_5"><span id="5_foo.7B.7B.7Bbar_5" typeof="mw:FallbackId"></span>5 foo{{{bar 5</h3> +<p>5</p> +<h3 id="6_foo-{bar_6"><span id="6_foo-.7Bbar_6" typeof="mw:FallbackId"></span>6 foo-{bar 6</h3> +<p>6</p> +!! end + +!! test +Preprocessor precedence 16: matching closing braces to opening braces +!! options +language=zh +parsoid=wt2html +!! wikitext +-{{{echo|foo}}bar}- +!! html/php +<p>foobar +</p> +!! html/parsoid +<p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"<span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid='{\"pi\":[[{\"k\":\"1\"}]],\"dsr\":[2,14,null,null]}' data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"foo\"}},\"i\":0}}]}'>foo</span>bar"}}'></span></p> +!! end + +!! test +Preprocessor precedence 17: template w/o target shouldn't prevent closing +!! options +parsoid=wt2html +!! wikitext +{{echo|hi {{}}}} +!! html/php +<p>hi {{}} +</p> +!! html/parsoid +<p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi {{}}"}},"i":0}}]}'>hi {{}}</p> +!! end + +!! test +Preprocessor precedence 18: another rightmost wins scenario +!! options +parsoid=wt2html +!! wikitext +{{ -{{{{1|tplarg}}} }} }- +!! html/php +<p>{{ -{tplarg }} }- +</p> +!! html/parsoid +<p>{{ -{<span about="#mwt1" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"1"},"params":{"1":{"wt":"tplarg"}},"i":0}}]}'>tplarg</span> }} }-</p> +!! end + +!! test +Preprocessor precedence 19: break syntax +!! options +parsoid=wt2html +!! wikitext +-{{ +!! html/php +<p>-{{ +</p> +!! html/parsoid +<p>-{{</p> +!! end + +### +### Token Stream Patcher tests +### +### These tests won't always pass wt2wt and other modes because +### on serialization, the table will be output on a new line. +### For now, we are blacklisting them, and using this to test selser. +### + +!!test +1. Table tag in SOL posn. should get reparsed correctly with valid TSR +!!options +parsoid=wt2html,wt2wt +!!wikitext +{{echo|}}{| width = '100%' +|foo +|} +!!html/parsoid +<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":""}},"i":0}}]}'></span><table width="100%"> +<tbody><tr><td>foo</td></tr> +</tbody></table> +!!end + +## We used to, but no longer wt2wt this test since the default serializer +## will normalize the include directives to serialize on their own line. +## Selser will take care of preserving formatting in scenarios where they +## intermingled with other wikitext. +!!test +2. Table tag in SOL posn. should get reparsed correctly with valid TSR +!!options +parsoid=wt2html +!!wikitext +<includeonly>a</includeonly>{| {{{b}}} +|c +|} +!!html/parsoid +<meta typeof="mw:Includes/IncludeOnly" data-parsoid='{"src":"<includeonly>a</includeonly>"}'/><meta typeof="mw:Includes/IncludeOnly/End" data-parsoid='{"src":""}'/><table about="#mwt2" typeof="mw:ExpandedAttrs" data-parsoid='{"a":{"{{{b}}}":null},"sa":{"{{{b}}}":""}}' data-mw='{"attribs":[[{"txt":"{{{b}}}","html":"<span about=\"#mwt1\" typeof=\"mw:Param\" data-parsoid='{\"pi\":[[]],\"dsr\":[31,38,null,null]}' data-mw='{\"parts\":[{\"templatearg\":{\"target\":{\"wt\":\"b\"},\"params\":{},\"i\":0}}]}'>{{{b}}}</span>"},{"html":""}]]}'> +<tbody><tr><td>c</td></tr> +</tbody></table> +!!end + +!! test +Table wikitext syntax outside wiki-tables +!! wikitext +a +|+ not a caption +! not a table heading +|- not a table row +| not a table cell +| class="foo bar" | baz +b +|} +|- +c +!! html +<p>a +|+ not a caption +! not a table heading +|- not a table row +| not a table cell +| class="foo bar" | baz +b +|} +|- +c +</p> +!! end + +### +### Testing parsing of templates where a template arg +### has the same name as the template itself. +### + +!! article +Template:quote +!! text +{{{quote|{{{1}}}}}} +!! endarticle + +!!test +Templates: Template Name/Arg clash: 1. Use of positional param +!! wikitext +{{quote|foo}} +!! html +<p>foo +</p> +!!end + +!!test +Templates: Template Name/Arg clash: 2. Use of named param +!! wikitext +{{quote|quote=foo}} +!! html +<p>foo +</p> +!!end + +!!test +Templates: Template Name/Arg clash: 3. Use of named param with empty input +!! wikitext +{{quote|quote}} +!! html +<p>quote +</p> +!!end + +### +### Parsoid-centric tests to stress Parsoid's ability to RT them unchanged +### + +!!test +Templates: 1. Simple use +!! wikitext +{{echo|Foo}} +!! html +<p>Foo +</p> +!!end + +!!test +Templates: 2. Inside a block tag +!! wikitext +<div>{{echo|Foo}}</div> +<blockquote>{{echo|Foo}}</blockquote> +!! html +<div>Foo</div> +<blockquote>Foo</blockquote> + +!! html+tidy +<div>Foo</div> +<blockquote><p>Foo</p></blockquote> +!!end + +!!test +Templates: P-wrapping: 1a. Templates on consecutive lines +!! wikitext +{{echo|Foo}} +{{echo|bar}} +!! html +<p>Foo +bar +</p> +!!end + +!!test +Templates: P-wrapping: 1b. Templates on consecutive lines +!! wikitext +Foo + +{{echo|bar}} +{{echo|baz}} +!! html +<p>Foo +</p><p>bar +baz +</p> +!!end + +!!test +Templates: P-wrapping: 1c. Templates on consecutive lines +!! wikitext +{{echo|Foo}} +{{echo|bar}} <div>baz</div> +!! html +<p>Foo +</p> +bar <div>baz</div> + +!! html+tidy +<p>Foo +</p><p> +bar </p><div>baz</div> +!! end + +!!test +Templates: P-wrapping: 1d. Template preceded by comment-only line +!!options +parsoid +!! wikitext +<!-- foo --> +{{echo|Bar}} +!! html +<!-- foo --> + +<p about="#mwt223" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"Bar"}},"i":0}}]}'>Bar</p> +!!end + +!!test +Templates: Inline Text: 1. Multiple template uses +!! wikitext +{{echo|Foo}}bar{{echo|baz}} +!! html +<p>Foobarbaz +</p> +!!end + +!!test +Templates: Inline Text: 2. Back-to-back template uses +!! wikitext +{{echo|Foo}}{{echo|bar}} +!! html +<p>Foobar +</p> +!!end + +!!test +Templates: Block Tags: 1. Multiple template uses +!! wikitext +{{echo|<div>Foo</div>}}<div>bar</div>{{echo|<div>baz</div>}} +!! html +<div>Foo</div><div>bar</div><div>baz</div> + +!!end + +!!test +Templates: Block Tags: 2. Back-to-back template uses +!! wikitext +{{echo|<div>Foo</div>}}{{echo|<div>bar</div>}} +!! html +<div>Foo</div><div>bar</div> + +!!end + +# This is an edge case relating to paragraph wrapping. +!!test +Templates: Correctly encapsulate templates producing </p> tag without a corresponding <p> tag +!! wikitext +{{echo|a +b</p>}} +!! html/parsoid +<p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"a\nb</p>"}},"i":0}}]}'>a +b</p> +!!end + +!!test +Templates: Links: 1. Simple example +!! wikitext +{{echo|[[Foo|bar]]}} +!! html +<p><a href="/wiki/Foo" title="Foo">bar</a> +</p> +!!end + +!!test +Templates: Links: 2. Generation of link href +!! wikitext +[[{{echo|Foo}}|bar]] +!! html +<p><a href="/wiki/Foo" title="Foo">bar</a> +</p> +!!end + +!!test +Templates: Links: 3. Generation of part of a link href +!! wikitext +[[Fo{{echo|o}}|bar]] + +[[Foo{{echo|bar}}]] + +[[Foo{{echo|bar}}baz]] + +[[Foo{{echo|bar}}|bar]] + +[[:Foo{{echo|bar}}]] + +[[:Foo{{echo|bar}}|bar]] +!! html +<p><a href="/wiki/Foo" title="Foo">bar</a> +</p><p><a href="/index.php?title=Foobar&action=edit&redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a> +</p><p><a href="/index.php?title=Foobarbaz&action=edit&redlink=1" class="new" title="Foobarbaz (page does not exist)">Foobarbaz</a> +</p><p><a href="/index.php?title=Foobar&action=edit&redlink=1" class="new" title="Foobar (page does not exist)">bar</a> +</p><p><a href="/index.php?title=Foobar&action=edit&redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a> +</p><p><a href="/index.php?title=Foobar&action=edit&redlink=1" class="new" title="Foobar (page does not exist)">bar</a> +</p> +!!end + +!!test +Templates: Links: 4. Multiple templates generating link href +!! wikitext +[[{{echo|F}}{{echo|o}}ob{{echo|ar}}]] +!! html +<p><a href="/index.php?title=Foobar&action=edit&redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a> +</p> +!!end + +!!test +Templates: Links: 5. Generation of link text +!! wikitext +[[Foo|{{echo|bar}}]] +!! html +<p><a href="/wiki/Foo" title="Foo">bar</a> +</p> +!!end + +!!test +Templates: Links: 5. Nested templates (only outermost template should be marked) +!! wikitext +{{echo|[[{{echo|Foo}}|bar]]}} +!! html +<p><a href="/wiki/Foo" title="Foo">bar</a> +</p> +!!end + +!!test +Templates: HTML Tag: 1. Generation of HTML attr. key +!! wikitext +<div {{echo|style}}="color:red;">foo</div> +!! html +<div style="color:red;">foo</div> + +!!end + +!!test +Templates: HTML Tag: 2. Generation of HTML attr. value +!! wikitext +<div style={{echo|'color:red;'}}>foo</div> +!! html +<div style="color:red;">foo</div> + +!!end + +!!test +Templates: HTML Tag: 3. Generation of HTML attr key and value +!! wikitext +<div {{echo|style}}={{echo|'color:red;'}}>foo</div> +!! html +<div style="color:red;">foo</div> + +!!end + +!!test +Templates: HTML Tag: 4. Generation of starting piece of HTML attr value +!! wikitext +<div title="{{echo|This is a long title}} with just one piece templated">foo</div> +!! html +<div title="This is a long title with just one piece templated">foo</div> + +!!end + +!!test +Templates: HTML Tag: 5. Generation of middle piece of HTML attr value +!! wikitext +<div title="This is a long title with just {{echo|one piece}} templated">foo</div> +!! html +<div title="This is a long title with just one piece templated">foo</div> + +!!end + +!!test +Templates: HTML Tag: 6. Generation of end piece of HTML attr value +!! wikitext +<div title="This is a long title with just one piece {{echo|templated}}">foo</div> +!! html +<div title="This is a long title with just one piece templated">foo</div> + +!!end + +# SSS FIXME: While it is great we added support for all this, +# do we want to make this part of the spec? Maybe we want to +# deprecate this kind of usage in the future? +!!test +Templates: HTML Tag: 7. Generation of partial attribute key string +!! wikitext +<div st{{echo|yle}}="color:red;">foo</div> +!! html +<div style="color:red;">foo</div> + +!!end + +!! test +Templates: HTML Tag: 8. Template-generated attribute (k=v) +!! wikitext +<div {{echo|1=id="v1"}}>bar</div> +!! html +<div id="v1">bar</div> + +!!end + +!! test +Templates: HTML Tag: 9. Multiple template-generated attributes +!! wikitext +<div {{echo|1=id="v1" title="foo"}}>bar</div> +!! html +<div id="v1" title="foo">bar</div> + +!!end + +!! test +Templates: Support for templates generating attributes and content +!! wikitext +{| {{mixed_attr_content_template}} +|- +|bar +|} +!! html/php +<table style="color:red;" title="T48811"> + +<tr> +<td>foo +</td></tr> +<tr> +<td>bar +</td></tr></table> + +!! html/parsoid +<table style="color:red;" title="T48811" about="#mwt1" typeof="mw:Transclusion mw:ExpandedAttrs" data-mw='{"parts":["{| ",{"template":{"target":{"wt":"mixed_attr_content_template","href":"./Template:Mixed_attr_content_template"},"params":{},"i":0}},"\n|-\n|bar\n|}"]}'> +<tbody><tr> +<td>foo</td></tr> +<tr> +<td>bar</td></tr> +</tbody></table> +!!end + +!! test +1. Entities and nowikis inside templated attributes should be handled correctly +!! wikitext +<div {{echo|style{{=}}"background:#f9f9f9;"}}>foo</div> +!! html/php +<div style="background:#f9f9f9;">foo</div> + +!! html/parsoid +<div style="background:#f9f9f9;" about="#mwt3" typeof="mw:ExpandedAttrs" data-parsoid='{"stx":"html"}' data-mw='{"attribs":[[{"txt":"style","html":"<span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid='{\"pi\":[[{\"k\":\"1\"}]],\"dsr\":[5,49,null,null]}' data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"style{{=}}\\\"background:&amp;#35;f9f9f9;\\\"\"}},\"i\":0}}]}'>style</span><span typeof=\"mw:Nowiki\" about=\"#mwt1\" data-parsoid=\"{}\">=</span><span about=\"#mwt1\" data-parsoid=\"{}\">\"background:</span><span typeof=\"mw:Entity\" about=\"#mwt1\" data-parsoid='{\"src\":\"&amp;#35;\",\"srcContent\":\"#\"}'>#</span><span about=\"#mwt1\" data-parsoid=\"{}\">f9f9f9;\"</span>"},{"html":""}]]}'>foo</div> +!! end + +!! test +2. Entities and nowikis inside templated attributes should be handled correctly +!! wikitext +{| +|{{table_attribs_3}} +|} +!! html/php +<table> +<tr> +<td style="background:#f9f9f9;">Foo +</td></tr></table> + +!! html/parsoid +<table> +<tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td style="background:#f9f9f9;" typeof="mw:Transclusion" about="#mwt1" data-parsoid='{"autoInsertedEnd":true,"pi":[[]]}' data-mw='{"parts":["|",{"template":{"target":{"wt":"table_attribs_3","href":"./Template:Table_attribs_3"},"params":{},"i":0}}]}'>Foo</td></tr> +</tbody></table> +!! end + +!! test +3. Entities and nowikis inside templated attributes should be handled correctly inside templated tables +!! wikitext +{{tbl-start}} +|{{table_attribs_3}} +{{tbl-end}} +!! html/php +<table> +<tr> +<td style="background:#f9f9f9;">Foo +</td></tr></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|",{"template":{"target":{"wt":"table_attribs_3","href":"./Template:Table_attribs_3"},"params":{},"i":1}},"\n",{"template":{"target":{"wt":"tbl-end","href":"./Template:Tbl-end"},"params":{},"i":2}}]}'> +<tbody><tr><td style="background:#f9f9f9;">Foo</td></tr> +</tbody></table> +!! end + +# T107622 +!! test +4. Entities and nowikis inside templated attributes should be handled correctly inside templated tables +!! wikitext +{| +|{{table_attribs_6}} hi +|} +!! html/php +<table> +<tr> +<td style="background: red;">hi +</td></tr></table> + +!! html/parsoid +<table> +<tbody><tr><td style="background: red;" typeof="mw:Transclusion" about="#mwt1" data-parsoid='{"autoInsertedEnd":true,"pi":[[]]}' data-mw='{"parts":["|",{"template":{"target":{"wt":"table_attribs_6","href":"./Template:Table_attribs_6"},"params":{},"i":0}}," hi"]}'> hi</td></tr> +</tbody></table> +!! end + +!!test +Templates: HTML Tables: 1. Generating start of a HTML table +!! wikitext +{{echo|<table><tr><td>foo</td>}}</tr></table> +!! html +<table><tr><td>foo</td></tr></table> + +!!end + +!!test +Templates: HTML Tables: 2a. Generating middle of a HTML table +!! wikitext +<table><tr>{{echo|<td>foo</td>}}</tr></table> +!! html +<table><tr><td>foo</td></tr></table> + +!!end + +!!test +Templates: HTML Tables: 2b. Generating middle of a HTML table +!! wikitext +<table>{{echo|<tr><td>foo</td></tr>}}</table> +!! html +<table><tr><td>foo</td></tr></table> + +!!end + +!!test +Templates: HTML Tables: 3. Generating end of a HTML table +!! wikitext +<table><tr>{{echo|<td>foo</td></tr></table>}} +!! html +<table><tr><td>foo</td></tr></table> + +!!end + +!!test +Templates: HTML Tables: 4a. Generating a single tag of a HTML table +!! wikitext +{{echo|<table>}}<tr><td>foo</td></tr></table> +!! html +<table><tr><td>foo</td></tr></table> + +!!end + +!!test +Templates: HTML Tables: 4b. Generating a single tag of a HTML table +!! wikitext +<table>{{echo|<tr>}}<td>foo</td></tr></table> +!! html +<table><tr><td>foo</td></tr></table> + +!!end + +!!test +Templates: HTML Tables: 4c. Generating a single tag of a HTML table +!! wikitext +<table><tr>{{echo|<td>}}foo</td></tr></table> +!! html +<table><tr><td>foo</td></tr></table> + +!!end + +!!test +Templates: HTML Tables: 4d. Generating a single tag of a HTML table +!! wikitext +<table><tr><td>foo{{echo|</td>}}</tr></table> +!! html +<table><tr><td>foo</td></tr></table> + +!!end + +!!test +Templates: HTML Tables: 4e. Generating a single tag of a HTML table +!! wikitext +<table><tr><td>foo</td>{{echo|</tr>}}</table> +!! html +<table><tr><td>foo</td></tr></table> + +!!end + +!!test +Templates: HTML Tables: 4f. Generating a single tag of a HTML table +!! wikitext +<table><tr><td>foo</td></tr>{{echo|</table>}} +!! html +<table><tr><td>foo</td></tr></table> + +!!end + +!!test +Templates: HTML Tables: 5. Proper fostering of categories from inside +!!options +parsoid=wt2html,wt2wt +!! wikitext +<table>[[Category:foo1]]<tr><td>foo</td></tr></table> +<!--Two categories (T52330)--> +<table>[[Category:bar1]][[Category:bar2]]<tr><td>foo</td></tr></table> +!! html +<link rel="mw:PageProp/Category" href="./Category:Foo1"><table><tbody><tr><td>foo</td></tr></tbody></table> +<!--Two categories (T52330)--> +<link rel="mw:PageProp/Category" href="./Category:Bar1"><link rel="mw:PageProp/Category" href="./Category:Bar2"><table><tbody><tr><td>foo</td></tr></tbody></table> +!!end + +!!test +Templates: Wiki Tables: 1a. Fostering of entire template content +!! wikitext +{| +{{echo|a}} +|} +!! html +<table> +a +<tr><td></td></tr></table> + +!! html/php+tidy + +a +<table><tbody><tr><td></td></tr></tbody></table> +!! html/parsoid +<p about="#mwt2" typeof="mw:Transclusion" data-parsoid='{"fostered":true,"autoInsertedEnd":true,"firstWikitextNode":"TABLE","pi":[[{"k":"1"}]]}' data-mw='{"parts":["{|\n",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"a"}},"i":0}},"\n|}"]}'>a</p><table about="#mwt2"> + +</table> +!! end + +!!test +Templates: Wiki Tables: 1b. Fostering of entire template content +!! wikitext +{| +{{echo|<div>}} +foo +{{echo|</div>}} +|} +!! html +<table> +<div> +<p>foo +</p> +</div> +<tr><td></td></tr></table> + +!! html/php+tidy +<div> +<p>foo +</p> +</div><table> + +<tbody><tr><td></td></tr></tbody></table> +!! html/parsoid +<div about="#mwt3" typeof="mw:Transclusion" data-parsoid='{"stx":"html","fostered":true,"autoInsertedEnd":true,"firstWikitextNode":"TABLE","pi":[[{"k":"1"}],[{"k":"1"}]]}' data-mw='{"parts":["{|\n",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"<div>"}},"i":0}},"\nfoo\n",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"</div>"}},"i":1}},"\n|}"]}'> +<p>foo</p> +</div><table about="#mwt3"> + +</table> +!! end + +!!test +Templates: Wiki Tables: 2. Fostering of partial template content +!! wikitext +{| +{{echo|a +<div>b</div>}} +|} +!! html +<table> +a +<div>b</div> +<tr><td></td></tr></table> + +!! html/php+tidy + +a +<div>b</div><table> +<tbody><tr><td></td></tr></tbody></table> +!! html/parsoid +<p about="#mwt2" typeof="mw:Transclusion" data-parsoid='{"fostered":true,"autoInsertedEnd":true,"firstWikitextNode":"TABLE","pi":[[{"k":"1"}]]}' data-mw='{"parts":["{|\n",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"a\n<div>b</div>"}},"i":0}},"\n|}"]}'>a</p><div about="#mwt2">b</div><table about="#mwt2"> + + +</table> +!! end + +!!test +Templates: Wiki Tables: 3. td-content via multiple templates +!! wikitext +{| +{{echo|{{pipe}}a}}{{echo|b}} +|} +!! html +<table> +<tr> +<td>ab +</td></tr></table> + +!!end + +!!test +Templates: Wiki Tables: 4. Templated tags, no content +!! wikitext +{{tbl-start}} +{{tbl-end}} +!! html +<table> +<tr><td></td></tr></table> + +!!end + +!!test +Templates: Wiki Tables: 5. Templated tags, regular td-tags +!! wikitext +{{tbl-start}} +|foo +{{tbl-end}} +!! html +<table> +<tr> +<td>foo +</td></tr></table> + +!!end + +!!test +Templates: Wiki Tables: 6. Templated tags, templated td-tags +!! wikitext +{{tbl-start}} +{{!}}foo +{{tbl-end}} +!! html +<table> +<tr> +<td>foo +</td></tr></table> + +!!end + +## This test case is very specific to Parsoid's internals +## and is hence only tested for Parsoid's code. Parsoid uses +## a <meta> marker tag for <ref> tags and they are expanded +## much later. We are verifying that this <meta> tag usage +## doesn't prevent foster parenting. +!!test +Templates: Wiki Tables: 7. Fosterable <ref>s should get fostered +!!wikitext +{{PartialTable}}<ref>foo</ref> +|} + +<references /> +!!html/parsoid +<sup about="#mwt2" class="mw-ref" id="cite_ref-1" rel="dc:references" typeof="mw:Transclusion mw:Extension/ref" data-mw='{"parts":[{"template":{"target":{"wt":"PartialTable","href":"./Template:PartialTable"},"params":{},"i":0}},"<ref>foo</ref>\n|}"]}'><a href="./Main_Page#cite_note-1"><span class="mw-reflink-text">[1]</span></a></sup><table about="#mwt2"> +<tbody> +</tbody></table> + +<ol class="mw-references references" typeof="mw:Extension/references" about="#mwt4" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text">foo</span></li></ol> +!!end + +!! test +Templates: Wiki Tables: 8. Fosterable meta-tags should get fostered +!! wikitext +{{echo| +{{{!}} +{{!}}-}} +<onlyinclude> +|foo +</onlyinclude> +{{!}}} +!! html/parsoid +<span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"\n{{{!}}\n{{!}}-"}},"i":0}},"\n<onlyinclude>\n|foo\n</onlyinclude>\n{{!}}}"]}'> +</span><meta typeof="mw:Includes/OnlyInclude" about="#mwt1"/><table about="#mwt1"> +<tbody><tr> + +<td>foo +<meta typeof="mw:Includes/OnlyInclude/End"/></td></tr> +</tbody></table> +!! end + +!!test +Templates: Lists: Multi-line list-items via templates +!! wikitext +*{{echo|a {{nonexistent| +unused}}}} +*{{echo|b {{nonexistent| +unused}}}} +!! html +<ul><li>a <a href="/index.php?title=Template:Nonexistent&action=edit&redlink=1" class="new" title="Template:Nonexistent (page does not exist)">Template:Nonexistent</a></li> +<li>b <a href="/index.php?title=Template:Nonexistent&action=edit&redlink=1" class="new" title="Template:Nonexistent (page does not exist)">Template:Nonexistent</a></li></ul> + +!!end + +!!test +Templates: Ugly nesting: 1. Quotes opened/closed across templates (echo) +!! wikitext +{{echo|''a}}{{echo|b''c''d}}{{echo|''e}} +!! html +<p><i>ab</i>c<i>d</i>e +</p> +!!end + +!!test +Templates: Ugly nesting: 2. Quotes opened/closed across templates (echo_with_span) +(PHP parser generates misnested html) +!! wikitext +{{echo_with_span|''a}}{{echo_with_span|b''c''d}}{{echo_with_span|''e}} +!! html/parsoid +<p><span about="#mwt1" typeof="mw:Transclusion" data-mw="{"parts":[{"template":{"target":{"wt":"echo_with_span","href":"./Template:Echo_with_span"},"params":{"1":{"wt":"''a"}},"i":0}}]}"><i>a</i></span><i about="#mwt2" typeof="mw:Transclusion" data-mw="{"parts":[{"template":{"target":{"wt":"echo_with_span","href":"./Template:Echo_with_span"},"params":{"1":{"wt":"b''c''d"}},"i":0}},{"template":{"target":{"wt":"echo_with_span","href":"./Template:Echo_with_span"},"params":{"1":{"wt":"''e"}},"i":1}}]}"><span>b</span></i><span about="#mwt2">c</span><i about="#mwt2">d<span></span></i><span about="#mwt2">e</span></p> +!!end + +!!test +Templates: Ugly nesting: 3. Quotes opened/closed across templates (echo_with_div) +(PHP parser generates misnested html; Parsoid html2wt mode adds newlines between {{echo}}s) +!! options +parsoid=wt2html,wt2wt +!! wikitext +{{echo_with_div|''a}}{{echo_with_div|b''c''d}}{{echo_with_div|''e}} +!! html +<div about="#mwt1" typeof="mw:Transclusion" data-mw="{"parts":[{"template":{"target":{"wt":"echo_with_div","href":"./Template:Echo_with_div"},"params":{"1":{"wt":"''a"}},"i":0}}]}"><i>a</i></div> +<div about="#mwt2" typeof="mw:Transclusion" data-mw="{"parts":[{"template":{"target":{"wt":"echo_with_div","href":"./Template:Echo_with_div"},"params":{"1":{"wt":"b''c''d"}},"i":0}}]}"><i>b</i>c<i>d</i></div> +<div about="#mwt3" typeof="mw:Transclusion" data-mw="{"parts":[{"template":{"target":{"wt":"echo_with_div","href":"./Template:Echo_with_div"},"params":{"1":{"wt":"''e"}},"i":0}}]}">e</div> +!!end + +!!test +Templates: Ugly nesting: 4. Divs opened/closed across templates +!! wikitext +a<div>b{{echo|c</div>d}}e +!! html +a<div>bc</div>de + +!! html+tidy +<p>a</p><div>bc</div><p>de +</p> +!! end + +!! test +Templates: Ugly templates: 3. newline-only template parameter +!! wikitext +foo {{echo| +}} +!! html +<p>foo +</p> +!! end + +# This looks like a bug: a single newline triggers p/br for some reason. +!! test +Templates: Ugly templates: 4. newline-only template parameter inconsistency +!! wikitext +{{echo| +}} +!! html +<p><br /> +</p> +!! end + +# T66017 -- ugly wikitext with fostered content generates two template ranges that +# have a true overlap (T1-start - T2-start - T1-end - T2-end). +!! test +Templates: Ugly templates: 5. Template encapsulation test: Non-trivial overlap of template ranges is properly handled +!! wikitext +{{echo|<table>}} +{{echo|<div>foo}} +{{echo|</table>}} +!! html/parsoid +<div about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"<table>"}},"i":0}},"\n",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"<div>foo"}},"i":1}},"\n",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"</table>"}},"i":2}}]}' data-parsoid='{"stx":"html","autoInsertedEnd":true,"pi":[[{"k":"1"}],[{"k":"1"}],[{"k":"1"}]]}'>foo +</div><table about="#mwt1" data-parsoid='{"stx":"html"}'> +</table> +!! end + +# T66017 -- ugly wikitext with fostered content generates two template ranges +# that are "identical" and generate nesting cycles in the algorithm +!! test +Templates: Ugly templates: 6. Template encapsulation test: Cyclical nesting of template ranges is properly handled +!! wikitext +{{echo|<table><tr><td><table>}} +{{echo|<div>}} +{{echo|</div>}} +!! html/parsoid +<table about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"<table><tr><td><table>"}},"i":0}},"\n",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"<div>"}},"i":1}},"\n",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"</div>"}},"i":2}}]}' data-parsoid='{"stx":"html","autoInsertedEnd":true,"pi":[[{"k":"1"}],[{"k":"1"}],[{"k":"1"}]]}'><tbody><tr data-parsoid='{"stx":"html"}'><td data-parsoid='{"stx":"html"}'><div data-parsoid='{"stx":"html"}'> +</div><table about="#mwt1" data-parsoid='{"stx":"html"}'> +</table></td></tr></tbody></table> +!! end + +!! test +Templates: Parameters substituted at the top-level +!! wikitext +{{{foo|''who'' {{echo|me}}? '''never!'''}}} + +{{{foo|bar|baz}}} +!! html/php +<p><i>who</i> me? <b>never!</b> +</p><p>bar +</p> +!! html/parsoid +<p about="#mwt2" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"foo"},"params":{"1":{"wt":"''who'' {{echo|me}}? '''never!'''"}},"i":0}}]}'><i>who</i> me? <b>never!</b></p> + +<p about="#mwt3" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"foo"},"params":{"1":{"wt":"bar"},"2":{"wt":"baz"}},"i":0}}]}'>bar</p> +!! end + +!! test +Templates: Param with empty arg in the final position +!! wikitext +{{{hi|}}} +!! html/parsoid +<span about="#mwt1" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"hi"},"params":{"1":{"wt":""}},"i":0}}]}'></span> +!! end + +!!test +Parser Functions: 1. Simple example +!! wikitext +{{uc:foo}} +!! html +<p>FOO +</p> +!!end + +!!test +Parser Functions: 2. Nested use (only outermost should be marked up) +!! wikitext +{{uc:{{lc:FOO}}}} +!! html +<p>FOO +</p> +!!end + +### +### Pre-save transform tests +### +!! test +pre-save transform: subst: +!! options +pst +!! wikitext +{{subst:test}} +!! html/php +This is a test template +!! end + +!! test +pre-save transform: normal template +!! options +pst +!! wikitext +{{test}} +!! html/php +{{test}} +!! end + +!! test +pre-save transform: nonexistent template +!! options +pst +!! wikitext +{{thistemplatedoesnotexist}} +!! html/php +{{thistemplatedoesnotexist}} +!! end + +!! test +pre-save transform: subst magic variables +!! options +pst +!! wikitext +{{subst:SITENAME}} +!! html/php +MediaWiki +!! end + +# This is T2089, which I fixed. -- wtm +!! test +pre-save transform: subst: templates with parameters +!! options +pst +!! wikitext +{{subst:paramtest|param="something else"}} +!! html/php +This is a test template with parameter "something else" +!! end + +!! article +Template:nowikitest +!! text +<nowiki>'''not wiki'''</nowiki> +!! endarticle + +!! test +pre-save transform: nowiki in subst (T3188) +!! options +pst +!! wikitext +{{subst:nowikitest}} +!! html/php +<nowiki>'''not wiki'''</nowiki> +!! end + +!! article +Template:commenttest +!! text +This template has <!-- a comment --> in it. +!! endarticle + +!! test +pre-save transform: comment in subst (T3936) +!! options +pst +!! wikitext +{{subst:commenttest}} +!! html/php +This template has <!-- a comment --> in it. +!! end + +!! test +pre-save transform: unclosed tag +!! options +pst +!! wikitext +<nowiki>'''not wiki''' +!! html/php +<nowiki>'''not wiki''' +!! end + +!! test +pre-save transform: mixed tag case +!! options +pst +!! wikitext +<NOwiki>'''not wiki'''</noWIKI> +!! html/php +<NOwiki>'''not wiki'''</noWIKI> +!! end + +!! test +pre-save transform: unclosed comment in <nowiki> +!! options +pst +!! wikitext +wiki<nowiki>nowiki<!--nowiki</nowiki>wiki +!! html/php +wiki<nowiki>nowiki<!--nowiki</nowiki>wiki +!!end + +# Leading @ in this template definition works around a limitation +# in parsoid's parserTests which otherwise strips the <span> from the +# result (confusing it for a template wrapper) +!! article +Template:dangerous +!!text +@<span onmouseover="alert('crap')">Oh no</span> +!!endarticle + +!!test +(confirming safety of fix for subst T3936) +!! wikitext +{{Template:dangerous}} +!! html +<p>@<span>Oh no</span> +</p> +!! end + +!! test +pre-save transform: comment containing gallery (T7024) +!! options +pst +!! wikitext +<!-- <gallery>data</gallery> --> +!! html/php +<!-- <gallery>data</gallery> --> +!!end + +!! test +pre-save transform: comment containing extension +!! options +pst +!! wikitext +<!-- <tag>data</tag> --> +!! html/php +<!-- <tag>data</tag> --> +!!end + +!! test +pre-save transform: comment containing nowiki +!! options +pst +!! wikitext +<!-- <nowiki>data</nowiki> --> +!! html/php +<!-- <nowiki>data</nowiki> --> +!!end + +!! test +pre-save transform: <noinclude> in subst (T5298) +!! options +pst +!! wikitext +{{subst:Includes}} +!! html/php +Foobar +!! end + +!! test +pre-save transform: <onlyinclude> in subst (T5298) +!! options +pst +!! wikitext +{{subst:Includes2}} +!! html/php +Foo +!! end + +!! article +Template:SubstTest +!!text +{{<includeonly>subst:</includeonly>Includes}} +!! endarticle + +!! article +Template:SafeSubstTest +!! text +{{<includeonly>safesubst:</includeonly>Includes}} +!! endarticle + +!! test +T24297: safesubst: works during PST +!! options +pst +!! wikitext +{{subst:SafeSubstTest}}{{safesubst:SubstTest}} +!! html/php +FoobarFoobar +!! end + +!! test +T24297: safesubst: works during normal parse +!! wikitext +{{SafeSubstTest}} +!! html +<p>Foobar +</p> +!! end + +!! test +subst: does not work during normal parse +!! wikitext +{{SubstTest}} +!! html +<p>{{subst:Includes}} +</p> +!! end + +!! test +pre-save transform: context links ("pipe trick") +!! options +pst +!! wikitext +[[Article (context)|]] +[[Bar:Article|]] +[[:Bar:Article|]] +[[Bar:Article (context)|]] +[[:Bar:Article (context)|]] +[[|Article]] +[[|Article (context)]] +[[Bar:X (Y) Z|]] +[[:Bar:X (Y) Z|]] +!! html/php +[[Article (context)|Article]] +[[Bar:Article|Article]] +[[:Bar:Article|Article]] +[[Bar:Article (context)|Article]] +[[:Bar:Article (context)|Article]] +[[Article]] +[[Article (context)]] +[[Bar:X (Y) Z|X (Y) Z]] +[[:Bar:X (Y) Z|X (Y) Z]] +!! end + +!! test +pre-save transform: context links ("pipe trick") with interwiki prefix +!! options +pst +!! wikitext +[[interwiki:Article|]] +[[:interwiki:Article|]] +[[interwiki:Bar:Article|]] +[[:interwiki:Bar:Article|]] +!! html/php +[[interwiki:Article|Article]] +[[:interwiki:Article|Article]] +[[interwiki:Bar:Article|Bar:Article]] +[[:interwiki:Bar:Article|Bar:Article]] +!! end + +!! test +pre-save transform: context links ("pipe trick") with parens in title +!! options +pst title=[[Somearticle (context)]] +!! wikitext +[[|Article]] +!! html/php +[[Article (context)|Article]] +!! end + +!! test +pre-save transform: context links ("pipe trick") with comma in title +!! options +pst title=[[Someplace, Somewhere]] +!! wikitext +[[|Otherplace]] +[[Otherplace, Elsewhere|]] +[[Otherplace, Elsewhere, Anywhere|]] +!! html/php +[[Otherplace, Somewhere|Otherplace]] +[[Otherplace, Elsewhere|Otherplace]] +[[Otherplace, Elsewhere, Anywhere|Otherplace]] +!! end + +!! test +pre-save transform: context links ("pipe trick") with parens and comma +!! options +pst title=[[Someplace (IGNORED), Somewhere]] +!! wikitext +[[|Otherplace]] +[[Otherplace (place), Elsewhere|]] +!! html/php +[[Otherplace, Somewhere|Otherplace]] +[[Otherplace (place), Elsewhere|Otherplace]] +!! end + +!! test +pre-save transform: context links ("pipe trick") with comma and parens +!! options +pst title=[[Who, me? (context)]] +!! wikitext +[[|Yes, you.]] +[[Me, Myself, and I (1937 song)|]] +!! html/php +[[Yes, you. (context)|Yes, you.]] +[[Me, Myself, and I (1937 song)|Me, Myself, and I]] +!! end + +!! test +pre-save transform: context links ("pipe trick") with namespace +!! options +pst title=[[Ns:Somearticle]] +!! wikitext +[[|Article]] +!! html/php +[[Ns:Article|Article]] +!! end + +!! test +pre-save transform: context links ("pipe trick") with namespace and parens +!! options +pst title=[[Ns:Somearticle (context)]] +!! wikitext +[[|Article]] +!! html/php +[[Ns:Article (context)|Article]] +!! end + +!! test +pre-save transform: context links ("pipe trick") with namespace and comma +!! options +pst title=[[Ns:Somearticle, Context, Whatever]] +!! wikitext +[[|Article]] +!! html/php +[[Ns:Article, Context, Whatever|Article]] +!! end + +!! test +pre-save transform: context links ("pipe trick") with namespace, comma and parens +!! options +pst title=[[Ns:Somearticle, Context (context)]] +!! wikitext +[[|Article]] +!! html/php +[[Ns:Article (context)|Article]] +!! end + +!! test +pre-save transform: context links ("pipe trick") with namespace, parens and comma +!! options +pst title=[[Ns:Somearticle (IGNORED), Context]] +!! wikitext +[[|Article]] +!! html/php +[[Ns:Article, Context|Article]] +!! end + +!! test +pre-save transform: context links ("pipe trick") with full-width parens and no space (Japanese and Chinese style, T32149) +!! options +pst +!! wikitext +[[Article(context)|]] +[[Bar:Article(context)|]] +[[:Bar:Article(context)|]] +[[|Article(context)]] +[[Bar:X(Y)Z|]] +[[:Bar:X(Y)Z|]] +!! html/php +[[Article(context)|Article]] +[[Bar:Article(context)|Article]] +[[:Bar:Article(context)|Article]] +[[Article(context)]] +[[Bar:X(Y)Z|X(Y)Z]] +[[:Bar:X(Y)Z|X(Y)Z]] +!! end + +!! test +pre-save transform: context links ("pipe trick") with full-width parens and space (Japanese and Chinese style, T32149) +!! options +pst +!! wikitext +[[Article (context)|]] +[[Bar:Article (context)|]] +[[:Bar:Article (context)|]] +[[|Article (context)]] +[[Bar:X (Y) Z|]] +[[:Bar:X (Y) Z|]] +!! html/php +[[Article (context)|Article]] +[[Bar:Article (context)|Article]] +[[:Bar:Article (context)|Article]] +[[Article (context)]] +[[Bar:X (Y) Z|X (Y) Z]] +[[:Bar:X (Y) Z|X (Y) Z]] +!! end + +!! test +pre-save transform: context links ("pipe trick") with parens and no space (Korean style, T32149) +!! options +pst +!! wikitext +[[Article(context)|]] +[[Bar:Article(context)|]] +[[:Bar:Article(context)|]] +[[|Article(context)]] +[[Bar:X(Y)Z|]] +[[:Bar:X(Y)Z|]] +!! html/php +[[Article(context)|Article]] +[[Bar:Article(context)|Article]] +[[:Bar:Article(context)|Article]] +[[Article(context)]] +[[Bar:X(Y)Z|X(Y)Z]] +[[:Bar:X(Y)Z|X(Y)Z]] +!! end + +!! test +pre-save transform: context links ("pipe trick") with commas (T23660) +!! options +pst +!! wikitext +[[Article (context), context|]] +[[Article (context),context|]] +[[Bar:Article (context), context|]] +[[Bar:Article (context),context|]] +[[:Bar:Article (context), context|]] +[[:Bar:Article (context),context|]] +!! html/php +[[Article (context), context|Article]] +[[Article (context),context|Article]] +[[Bar:Article (context), context|Article]] +[[Bar:Article (context),context|Article]] +[[:Bar:Article (context), context|Article]] +[[:Bar:Article (context),context|Article]] +!! end + +!! test +Parsoid: backwards pipe trick +!! wikitext +[[|'''bar''']] +!! html/php +<p>[[|<b>bar</b>]] +</p> +!! html/parsoid +<p>[[|<b>bar</b>]]</p> +!! end + +!! test +pre-save transform: trim trailing empty lines +!! options +pst +!! wikitext +Empty lines are trimmed + + + + +!! html/php +Empty lines are trimmed +!! end + +!! test +pre-save transform: Signature expansion +!! options +pst +!! wikitext +* ~~~ +* ~~~~ +* ~~~~~ +* <noinclude>~~~</noinclude> +* <includeonly>~~~</includeonly> +* <onlyinclude>~~~</onlyinclude> +!! html/php +* [[Special:Contributions/127.0.0.1|127.0.0.1]] +* [[Special:Contributions/127.0.0.1|127.0.0.1]] 00:02, 1 January 1970 (UTC) +* 00:02, 1 January 1970 (UTC) +* <noinclude>[[Special:Contributions/127.0.0.1|127.0.0.1]]</noinclude> +* <includeonly>[[Special:Contributions/127.0.0.1|127.0.0.1]]</includeonly> +* <onlyinclude>[[Special:Contributions/127.0.0.1|127.0.0.1]]</onlyinclude> +!! end + + +!! test +ParserOutput flags from signature expansion (T84843) +!! options +pst +showflags +!! wikitext +~~~~ +!! html/php +[[Special:Contributions/127.0.0.1|127.0.0.1]] 00:02, 1 January 1970 (UTC) +flags=user-signature +!! end + + +!! test +pre-save transform: Signature expansion in nowiki tags (T2093) +!! options +pst disabled +!! wikitext +Shall not expand: + +<nowiki>~~~~</nowiki> + +<includeonly><nowiki>~~~~</nowiki></includeonly> + +<noinclude><nowiki>~~~~</nowiki></noinclude> + +<onlyinclude><nowiki>~~~~</nowiki></onlyinclude> + +{{subst:Foo}} shall be converted to FOO + +As well as inside noinclude/onlyinclude +<noinclude>{{subst:Foo}}</noinclude> +<onlyinclude>{{subst:Foo}}</onlyinclude> + +But not inside includeonly +<includeonly>{{subst:Foo}}</includeonly> +!! html/php +Shall not expand: + +<nowiki>~~~~</nowiki> + +<includeonly><nowiki>~~~~</nowiki></includeonly> + +<noinclude><nowiki>~~~~</nowiki></noinclude> + +<onlyinclude><nowiki>~~~~</nowiki></onlyinclude> + +FOO shall be converted to FOO + +As well as inside noinclude/onlyinclude +<noinclude>FOO</noinclude> +<onlyinclude>FOO</onlyinclude> + +But not inside includeonly +<includeonly>{{subst:Foo}}</includeonly> +!! end + +!! test +Parsoid: Recognize nowiki with trailing space in tags +!! options +parsoid=wt2html +!! wikitext +<nowiki ><div>[[foo]]</nowiki > + +a<nowiki / >b + +c<nowiki />d + +e<nowiki/ >f +!! html +<p><span typeof="mw:Nowiki"><div>[[foo]]</span></p> +<p>ab</p> +<p>cd</p> +<p>ef</p> +!! end + +!! test +Parsoid: Recognize nowiki with odd capitalization +!! options +parsoid=wt2html +!! wikitext +<noWikI ><div>[[foo]]</Nowiki > +!! html +<p><span typeof="mw:Nowiki"><div>[[foo]]</span></p> +!! end + + +!! test +Parsoid: Escape nowiki with trailing space in tags +!! options +parsoid=html2wt +!! html/parsoid +<p><nowiki > foo </nowiki ></p> +<p>a<nowiki />b</p> +<p>c<nowiki/ >d</p> +!! wikitext +<nowiki > foo </nowiki > + +a<nowiki />b + +c<nowiki/ >d +!! end + +!! test +Parsoid: Escape weird noWikI capitalizations +!! options +parsoid=html2wt +!! html/parsoid +<p><noWikI > foo </NoWikI ></p> +!! wikitext +<noWikI > foo </NoWikI > +!! end + +### +### Message transform tests +### +!! test +message transform: magic variables +!! options +msg +!! wikitext +{{SITENAME}} +!! html +MediaWiki +!! end + +!! test +message transform: should not transform wiki markup +!! options +msg +!! wikitext +''test'' +!! html +''test'' +!! end + +!! test +message transform: <noinclude> in transcluded template (T6926) +!! options +msg +!! wikitext +{{Includes}} +!! html +Foobar +!! end + +!! test +message transform: <onlyinclude> in transcluded template (T6926) +!! options +msg +!! wikitext +{{Includes2}} +!! html +Foo +!! end + +!! test +{{#special:}} page name, known +!! options +msg +!! wikitext +{{#special:Recentchanges}} +!! html +Special:RecentChanges +!! end + +!! test +{{#special:}} page name with subpage, known +!! options +msg +!! wikitext +{{#special:Recentchanges/param}} +!! html +Special:RecentChanges/param +!! end + +!! test +{{#special:}} page name, unknown +!! options +msg +!! wikitext +{{#special:foobar nonexistent}} +!! html +Special:Foobar nonexistent +!! end + +!! test +{{#speciale:}} page name, known +!! options +msg +!! wikitext +{{#speciale:Recentchanges}} +!! html +Special:RecentChanges +!! end + +!! test +{{#speciale:}} page name with subpage, known +!! options +msg +!! wikitext +{{#speciale:Recentchanges/param}} +!! html +Special:RecentChanges/param +!! end + +!! test +{{#speciale:}} page name, unknown +!! options +msg +!! wikitext +{{#speciale:foobar nonexistent}} +!! html +Special:Foobar_nonexistent +!! end + +### +### Images +### +### For Parsoid-specific tests, see +#### https://www.mediawiki.org/wiki/Parsoid/MediaWiki_DOM_spec#Images + +!! test +Simple image +!! options +parsoid=wt2html,wt2wt,html2html +!! wikitext +[[Image:foobar.jpg]] +!! html/php +<p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a> +</p> +!! html/parsoid +<p><figure-inline class="mw-default-size" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></figure-inline></p> +!! end + +!! test +Serialize simple image with span wrapper +!! options +parsoid=html2wt +!! html/parsoid +<p><span class="mw-default-size" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></span></p> +!! wikitext +[[File:Foobar.jpg]] +!! end + +!! test +Simple image (using File: namespace, now canonical) +!! wikitext +[[File:Foobar.jpg]] +!! html/php +<p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a> +</p> +!! html/parsoid +<p><figure-inline class="mw-default-size" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></figure-inline></p> +!! end + +!! test +Right-aligned image +!! wikitext +[[File:Foobar.jpg|right]] +!! html/php +<div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div> + +!! html/parsoid +<figure class="mw-default-size mw-halign-right" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></figure> +!! end + +!! test +Image with caption +!! wikitext +[[File:Foobar.jpg|right|Caption text]] +!! html/php +<div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image" title="Caption text"><img alt="Caption text" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div> + +!! html/parsoid +<figure class="mw-default-size mw-halign-right" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a><figcaption>Caption text</figcaption></figure> +!! end + +!! test +Image with caption, T55312 #1 +!! wikitext +[[File:Foobar.jpg|right|Caption page stuff]] +!! html/php +<div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image" title="Caption page stuff"><img alt="Caption page stuff" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div> + +!! html/parsoid +<figure class="mw-default-size mw-halign-right" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a><figcaption>Caption page stuff</figcaption></figure> +!! end + +!! test +Image with caption, T55312 #2 +!! wikitext +[[File:Foobar.jpg|right|Caption page=]] +!! html/php +<div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image" title="Caption page="><img alt="Caption page=" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div> + +!! html/parsoid +<figure class="mw-default-size mw-halign-right" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a><figcaption>Caption page=</figcaption></figure> +!! end + +!! test +Image with caption, T55312 #3 +!! wikitext +[[File:Foobar.jpg|right|Caption page=stuff]] +!! html/php +<div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image" title="Caption page=stuff"><img alt="Caption page=stuff" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div> + +!! html/parsoid +<figure class="mw-default-size mw-halign-right" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a><figcaption>Caption page=stuff</figcaption></figure> +!! end + +!! test +Image caption with pipe entity +!! wikitext +[[File:Foobar.jpg|thumb|one | two]] +[[File:Foobar.jpg|thumb|one ''two'' | three]] +!! html/php +<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>one | two</div></div></div> +<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>one <i>two</i> | three</div></div></div> + +!! html/parsoid +<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption>one <span typeof="mw:Entity">|</span> two</figcaption></figure> +<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption>one <i>two</i> <span typeof="mw:Entity">|</span> three</figcaption></figure> +!! end + +!! test +Allow empty links in image captions (T62753) +!! options +thumbsize=220 +!! wikitext +[[File:Foobar.jpg|thumb|Caption [[Link1]] +[[]] +[[Link2]] +]] +!! html/php +<div class="thumb tright"><div class="thumbinner" style="width:222px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" width="220" height="25" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>Caption <a href="/index.php?title=Link1&action=edit&redlink=1" class="new" title="Link1 (page does not exist)">Link1</a> [[]] <a href="/index.php?title=Link2&action=edit&redlink=1" class="new" title="Link2 (page does not exist)">Link2</a></div></div></div> + +!! html/parsoid +<figure class="mw-default-size" typeof="mw:Image/Thumb" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"},{"ck":"caption","ak":"Caption [[Link1]]\n[[]]\n[[Link2]]\n"}]}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"}}'><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"25","width":"220"},"sa":{"resource":"File:Foobar.jpg"}}'/></a><figcaption>Caption <a rel="mw:WikiLink" href="./Link1" title="Link1" data-parsoid='{"stx":"simple","a":{"href":"./Link1"},"sa":{"href":"Link1"}}'>Link1</a> +[[]] +<a rel="mw:WikiLink" href="./Link2" title="Link2" data-parsoid='{"stx":"simple","a":{"href":"./Link2"},"sa":{"href":"Link2"}}'>Link2</a> +</figcaption></figure> +!! end + +!! test +Titles in unlinked images (T23454) +!! wikitext +[[File:Foobar.jpg|link=|stuff]] +!! html/php +<p><img alt="stuff" src="http://example.com/images/3/3a/Foobar.jpg" title="stuff" width="1941" height="220" /> +</p> +!! html/parsoid +<p><figure-inline class="mw-default-size" typeof="mw:Image" data-mw='{"caption":"stuff"}'><span><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></span></figure-inline></p> +!! end + +!! test +Link with empty target +!! wikitext +[[]] +!! html +<p>[[]] +</p> +!! end + +!! test +Image with link trail +!! wikitext +Linktrails should not work for images: [[File:Foobar.jpg]]s +!! html/php +<p>Linktrails should not work for images: <a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>s +</p> +!! html/parsoid +<p>Linktrails should not work for images: <figure-inline class="mw-default-size" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></figure-inline>s</p> +!! end + +!! test +Image with empty attribute +!! options +parsoid=wt2html,wt2wt,html2html +!! wikitext +[[File:Foobar.jpg|right||Caption text]] +!! html/php +<div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image" title="Caption text"><img alt="Caption text" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div> + +!! html/parsoid +<figure class="mw-default-size mw-halign-right" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a><figcaption>Caption text</figcaption></figure> +!! end + +!! test +1. Block image with individual attributes from templates +!! wikitext +[[File:Foobar.jpg|thumb|{{echo|137px}}|This is a caption]] +!! html/php +<div class="thumb tright"><div class="thumbinner" style="width:139px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/137px-Foobar.jpg" width="137" height="16" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/206px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/274px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>This is a caption</div></div></div> + +!! html/parsoid +<figure typeof="mw:Image/Thumb mw:ExpandedAttrs" about="#mwt2" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"},{"ck":"width","ak":"{{echo|137px}}"},{"ck":"caption","ak":"This is a caption"}]}' data-mw='{"attribs":[["thumbnail",{"html":"thumb"}],["width",{"html":"<span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid='{\"pi\":[[{\"k\":\"1\"}]],\"dsr\":[24,38,null,null]}' data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"137px\"}},\"i\":0}}]}'>137px</span>"}]]}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{}}'><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/137px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="16" width="137" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"16","width":"137"},"sa":{"resource":"File:Foobar.jpg"}}'/></a><figcaption>This is a caption</figcaption></figure> +!! end + +!! test +2. Block Image with individual attributes from templates +!! wikitext +[[File:Foobar.jpg|{{echo|thumb}}|{{echo|137px}}|This is a caption]] +!! html/php +<div class="thumb tright"><div class="thumbinner" style="width:139px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/137px-Foobar.jpg" width="137" height="16" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/206px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/274px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>This is a caption</div></div></div> + +!! html/parsoid +<figure typeof="mw:Image/Thumb mw:ExpandedAttrs" about="#mwt3" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"{{echo|thumb}}"},{"ck":"width","ak":"{{echo|137px}}"},{"ck":"caption","ak":"This is a caption"}]}' data-mw='{"attribs":[["thumbnail",{"html":"<span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid='{\"pi\":[[{\"k\":\"1\"}]],\"dsr\":[18,32,null,null]}' data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"thumb\"}},\"i\":0}}]}'>thumb</span>"}],["width",{"html":"<span about=\"#mwt2\" typeof=\"mw:Transclusion\" data-parsoid='{\"pi\":[[{\"k\":\"1\"}]],\"dsr\":[33,47,null,null]}' data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"137px\"}},\"i\":0}}]}'>137px</span>"}]]}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{}}'><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/137px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="16" width="137" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"16","width":"137"},"sa":{"resource":"File:Foobar.jpg"}}'/></a><figcaption>This is a caption</figcaption></figure> +!! end + +!! test +3. Inline image with individual attributes from templates +!! wikitext +[[File:Foobar.jpg|{{echo|50px}}]] +!! html/php +<p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/50px-Foobar.jpg" width="50" height="6" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/75px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/100px-Foobar.jpg 2x" /></a> +</p> +!! html/parsoid +<p><figure-inline typeof="mw:Image mw:ExpandedAttrs" about="#mwt2" data-parsoid='{"optList":[{"ck":"width","ak":"{{echo|50px}}"}]}' data-mw='{"attribs":[["width",{"html":"<span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid='{\"pi\":[[{\"k\":\"1\"}]],\"dsr\":[18,31,null,null]}' data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"50px\"}},\"i\":0}}]}'>50px</span>"}]]}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{}}'><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/50px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="6" width="50" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"6","width":"50"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></figure-inline></p> +!! end + +## Parsoid does not provide editing support for images where templates produce multiple image attributes. +## To signal this, we add a 'mw:Placeholder' type to such images. This could change in the future. +!! test +Image with multiple attributes from the same template +!! wikitext +[[File:Foobar.jpg|{{image_attribs}}]] +!! html/php +<div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image" title="Caption text"><img alt="Caption text" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div> + +!! html/parsoid +<figure class="mw-default-size mw-halign-right" typeof="mw:Image mw:Placeholder"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a><figcaption>Caption text</figcaption></figure> +!! end + +!! test +Image with link tails +!! options +thumbsize=220 +!! wikitext +123[[File:Foobar.jpg]]456 +123[[File:Foobar.jpg|right]]456 +123[[File:Foobar.jpg|thumb]]456 +!! html/php +<p>123<a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>456 +</p> +123<div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div>456 +123<div class="thumb tright"><div class="thumbinner" style="width:222px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" width="220" height="25" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div></div></div></div>456 + +!! html/php+tidy +<p>123<a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>456 +</p><p> +123</p><div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div><p>456 +123</p><div class="thumb tright"><div class="thumbinner" style="width:222px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" width="220" height="25" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div></div></div></div><p>456 +</p> +!! html/parsoid +<p>123<figure-inline class="mw-default-size" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></figure-inline>456</p> +<p>123</p><figure class="mw-default-size mw-halign-right" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></figure><p>456</p> +<p>123</p><figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a></figure><p>456</p> +!! end + +!! test +Image with multiple captions -- only last one is accepted +!! wikitext +[[File:Foobar.jpg|right|Caption1 - ignored|[[Caption2]] - ignored|Caption3 - accepted]] +!! html/php +<div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image" title="Caption3 - accepted"><img alt="Caption3 - accepted" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div> + +!! html/parsoid +<figure class="mw-default-size mw-halign-right" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a><figcaption>Caption3 - accepted</figcaption></figure> +!! end + +!! test +Image with multiple widths -- use last +!! wikitext +[[File:Foobar.jpg|200px|300px|caption]] +!! html/php +<p><a href="/wiki/File:Foobar.jpg" class="image" title="caption"><img alt="caption" src="http://example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg" width="300" height="34" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/450px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/600px-Foobar.jpg 2x" /></a> +</p> +!! html/parsoid +<p><figure-inline typeof="mw:Image" data-mw='{"caption":"caption"}'><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="34" width="300"/></a></figure-inline></p> +!! end + +!! test +Image with multiple alignments -- use first (T50664) +!! options +thumbsize=220 +!! wikitext +[[File:Foobar.jpg|thumb|left|right|center|caption]] + +[[File:Foobar.jpg|middle|text-top|caption]] +!! html/php +<div class="thumb tleft"><div class="thumbinner" style="width:222px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" width="220" height="25" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>caption</div></div></div> +<p><a href="/wiki/File:Foobar.jpg" class="image" title="caption"><img alt="caption" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" style="vertical-align: middle" /></a> +</p> +!! html/parsoid +<figure class="mw-default-size mw-halign-left" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption>caption</figcaption></figure> +<p><figure-inline class="mw-default-size mw-valign-middle" typeof="mw:Image" data-mw='{"caption":"caption"}'><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></figure-inline></p> +!! end + +!! test +Image with width attribute at different positions +!! wikitext +[[File:Foobar.jpg|200px|right|Caption]] +[[File:Foobar.jpg|right|200px|Caption]] +[[File:Foobar.jpg|right|Caption|200px]] +!! html/php +<div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image" title="Caption"><img alt="Caption" src="http://example.com/images/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg" width="200" height="23" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/400px-Foobar.jpg 2x" /></a></div> +<div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image" title="Caption"><img alt="Caption" src="http://example.com/images/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg" width="200" height="23" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/400px-Foobar.jpg 2x" /></a></div> +<div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image" title="Caption"><img alt="Caption" src="http://example.com/images/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg" width="200" height="23" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/400px-Foobar.jpg 2x" /></a></div> + +!! html/parsoid +<figure class="mw-halign-right" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="23" width="200"/></a><figcaption>Caption</figcaption></figure> +<figure class="mw-halign-right" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="23" width="200"/></a><figcaption>Caption</figcaption></figure> +<figure class="mw-halign-right" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="23" width="200"/></a><figcaption>Caption</figcaption></figure> +!! end + +# a sad bit of backward-compatibility +!! test +Image with size specified with pxpx (T15500, T53628) +!! options +parsoid=wt2html,wt2wt,html2html +!! wikitext +[[File:Foobar.jpg|20pxpx]] +[[File:Foobar.jpg|200x20pxpx]] +!! html/php +<p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/20px-Foobar.jpg" width="20" height="2" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/30px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/40px-Foobar.jpg 2x" /></a> +<a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/177px-Foobar.jpg" width="177" height="20" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/265px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/353px-Foobar.jpg 2x" /></a> +</p> +!! html/parsoid +<p><figure-inline typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/20px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="2" width="20"/></a></figure-inline> <figure-inline typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/177px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="20" width="177"/></a></figure-inline></p> +!! end + +!! test +Image with link parameter, wiki target +!! wikitext +[[File:Foobar.jpg|link=Main Page]] +!! html/php +<p><a href="/wiki/Main_Page" title="Main Page"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a> +</p> +!! html/parsoid +<p><figure-inline class="mw-default-size" typeof="mw:Image"><a href="./Main_Page"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></figure-inline></p> +!! end + +# parsoid T51293 (part 1) +!! test +Image with link parameter, URL target +!! wikitext +[[File:Foobar.jpg|link=http://example.com/]] +!! html/php +<p><a href="http://example.com/" rel="nofollow"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a> +</p> +!! html/parsoid +<p><figure-inline class="mw-default-size" typeof="mw:Image"><a href="http://example.com/"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></figure-inline></p> +!! end + +# parsoid T51293 (part 2) +!! test +Image with link parameter, protocol-less URL target +!! wikitext +[[File:Foobar.jpg|link=//example.com/]] +!! html/php +<p><a href="//example.com/" rel="nofollow"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a> +</p> +!! html/parsoid +<p><figure-inline class="mw-default-size" typeof="mw:Image"><a href="//example.com/"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></figure-inline></p> +!! end + +!! test +Escaping non-block captions (T107435) +!! options +parsoid={ + "modes": ["wt2wt"], + "changes": [ + ["[typeof~='mw:Image']", "attr", "data-mw", "{\"caption\": \"|\"}"] + ] +} +!! wikitext +[[Image:Foobar.jpg|caption]] +!! wikitext/edited +[[Image:Foobar.jpg|<nowiki>|</nowiki>]] +!! end + +# wgExternalLinkTarget not supported by Parsoid +!! test +Image with link parameter, wgExternalLinkTarget +!! wikitext +[[Image:foobar.jpg|link=http://example.com/]] +!! config +wgExternalLinkTarget='foobar' +!! html/php +<p><a href="http://example.com/" target="foobar" rel="nofollow noreferrer noopener"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a> +</p> +!! end + +!! test +Image with link parameter, wgNoFollowLinks set to false +!! wikitext +[[Image:foobar.jpg|link=http://example.com/]] +!! config +wgNoFollowLinks=false +!! html/php +<p><a href="http://example.com/"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a> +</p> +!! end + +!! test +Image with link parameter, wgNoFollowDomainExceptions +!! wikitext +[[Image:foobar.jpg|link=http://example.com/]] +!! config +wgNoFollowDomainExceptions='example.com' +!! html/php +<p><a href="http://example.com/"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a> +</p> +!! end + +# wgExternalLinkTarget not supported by Parsoid +!! test +Image with link parameter, wgExternalLinkTarget, unnamed parameter +!! wikitext +[[Image:foobar.jpg|link=http://example.com/|Title]] +!! config +wgExternalLinkTarget='foobar' +!! html/php +<p><a href="http://example.com/" title="Title" target="foobar" rel="nofollow noreferrer noopener"><img alt="Title" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a> +</p> +!! end + +!! test +Image with empty link parameter +!! wikitext +[[File:Foobar.jpg|link=]] +!! html/php +<p><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /> +</p> +!! html/parsoid +<p><figure-inline class="mw-default-size" typeof="mw:Image"><span><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></span></figure-inline></p> +!! end + +!! test +Image with link parameter (wiki target) and unnamed parameter +!! wikitext +[[File:Foobar.jpg|link=Main_Page|Title]] +!! html/php +<p><a href="/wiki/Main_Page" title="Title"><img alt="Title" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a> +</p> +!! html/parsoid +<p><figure-inline class="mw-default-size" typeof="mw:Image" data-mw='{"caption":"Title"}'><a href="./Main_Page"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></figure-inline></p> +!! end + +!! test +Image with link parameter (URL target) and unnamed parameter +!! wikitext +[[File:Foobar.jpg|link=http://example.com/|Title]] +!! html/php +<p><a href="http://example.com/" title="Title" rel="nofollow"><img alt="Title" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a> +</p> +!! html/parsoid +<p><figure-inline class="mw-default-size" typeof="mw:Image" data-mw='{"caption":"Title"}'><a href="http://example.com/"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></figure-inline></p> +!! end + +!! test +Thumbnail image with link parameter +!! options +thumbsize=220 +parsoid=wt2html,wt2wt,html2html +!! wikitext +[[File:Foobar.jpg|thumb|link=http://example.com/|Title]] +!! html/php +<div class="thumb tright"><div class="thumbinner" style="width:222px;"><a href="http://example.com/"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" width="220" height="25" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>Title</div></div></div> + +!! html/parsoid +<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="http://example.com/"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption>Title</figcaption></figure> +!! end + +!! test +Manually-specified thumbnail image +!! options +thumbsize=220 +!! wikitext +[[File:Foobar.jpg|thumbnail=Thumb.png|Title]] +!! html/php +<div class="thumb tright"><div class="thumbinner" style="width:137px;"><a href="/wiki/File:Foobar.jpg"><img alt="" src="http://example.com/images/e/ea/Thumb.png" width="135" height="135" class="thumbimage" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>Title</div></div></div> + +!! html/parsoid +<figure class="mw-default-size" typeof="mw:Image/Thumb" data-mw='{"thumb":"Thumb.png"}'><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/e/ea/Thumb.png" data-file-width="135" data-file-height="135" data-file-type="bitmap" height="135" width="135"/></a><figcaption>Title</figcaption></figure> +!! end + +!! test +Manually-specified thumbnail image with explicit link to wiki page +!! options +thumbsize=220 +parsoid=wt2html,wt2wt,html2html +!! wikitext +[[File:Foobar.jpg|thumb=Thumb.png|link=Main_Page|Title]] +!! html/php +<div class="thumb tright"><div class="thumbinner" style="width:137px;"><a href="/wiki/Main_Page" title="Main Page"><img alt="" src="http://example.com/images/e/ea/Thumb.png" width="135" height="135" class="thumbimage" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>Title</div></div></div> + +!! html/parsoid +<figure class="mw-default-size" typeof="mw:Image/Thumb" data-mw='{"thumb":"Thumb.png"}'><a href="./Main_Page"><img resource="./File:Foobar.jpg" src="//example.com/images/e/ea/Thumb.png" data-file-width="135" data-file-height="135" data-file-type="bitmap" height="135" width="135"/></a><figcaption>Title</figcaption></figure> +!! end + +!! test +Manually-specified thumbnail image with explicit link to url +!! options +thumbsize=220 +parsoid=wt2html,wt2wt,html2html +!! wikitext +[[File:Foobar.jpg|thumb=Thumb.png|link=http://example.com|Title]] +!! html/php +<div class="thumb tright"><div class="thumbinner" style="width:137px;"><a href="http://example.com"><img alt="" src="http://example.com/images/e/ea/Thumb.png" width="135" height="135" class="thumbimage" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>Title</div></div></div> + +!! html/parsoid +<figure class="mw-default-size" typeof="mw:Image/Thumb" data-mw='{"thumb":"Thumb.png"}'><a href="http://example.com"><img resource="./File:Foobar.jpg" src="//example.com/images/e/ea/Thumb.png" data-file-width="135" data-file-height="135" data-file-type="bitmap" height="135" width="135"/></a><figcaption>Title</figcaption></figure> +!! end + +!! test +Manually-specified thumbnail image with explicit no link +!! options +thumbsize=220 +parsoid=wt2html,wt2wt,html2html +!! wikitext +[[File:Foobar.jpg|thumb=Thumb.png|link=|Title]] +!! html/php +<div class="thumb tright"><div class="thumbinner" style="width:137px;"><img alt="" src="http://example.com/images/e/ea/Thumb.png" width="135" height="135" class="thumbimage" /> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>Title</div></div></div> + +!! html/parsoid +<figure class="mw-default-size" typeof="mw:Image/Thumb" data-mw='{"thumb":"Thumb.png"}'><span><img resource="./File:Foobar.jpg" src="//example.com/images/e/ea/Thumb.png" data-file-width="135" data-file-height="135" data-file-type="bitmap" height="135" width="135"/></span><figcaption>Title</figcaption></figure> +!! end + +!! test +Manually-specified thumbnail image with explicit link and alt text +!! options +thumbsize=220 +parsoid=wt2html,wt2wt,html2html +!! wikitext +[[File:Foobar.jpg|thumb=Thumb.png|link=Main_Page|alt=alttext|Title]] +!! html/php +<div class="thumb tright"><div class="thumbinner" style="width:137px;"><a href="/wiki/Main_Page" title="Main Page"><img alt="alttext" src="http://example.com/images/e/ea/Thumb.png" width="135" height="135" class="thumbimage" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>Title</div></div></div> + +!! html/parsoid +<figure class="mw-default-size" typeof="mw:Image/Thumb" data-mw='{"thumb":"Thumb.png"}'><a href="./Main_Page"><img alt="alttext" resource="./File:Foobar.jpg" src="//example.com/images/e/ea/Thumb.png" data-file-width="135" data-file-height="135" data-file-type="bitmap" height="135" width="135"/></a><figcaption>Title</figcaption></figure> +!! end + +!! test +Image with frame and link +!! options +parsoid=wt2html,wt2wt,html2html +!! wikitext +[[File:Foobar.jpg|frame|left|This is a test image [[Main Page]]]] +!! html/php +<div class="thumb tleft"><div class="thumbinner" style="width:1943px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" class="thumbimage" /></a> <div class="thumbcaption">This is a test image <a href="/wiki/Main_Page" title="Main Page">Main Page</a></div></div></div> + +!! html/parsoid +<figure class="mw-default-size mw-halign-left" typeof="mw:Image/Frame"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a><figcaption>This is a test image <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></figcaption></figure> +!! end + +!! test +Image with frame and link and explicit alt +!! options +parsoid=wt2html,wt2wt,html2html +!! wikitext +[[Image:Foobar.jpg|frame|left|This is a test image [[Main Page]]|alt=Altitude]] +!! html/php +<div class="thumb tleft"><div class="thumbinner" style="width:1943px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Altitude" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" class="thumbimage" /></a> <div class="thumbcaption">This is a test image <a href="/wiki/Main_Page" title="Main Page">Main Page</a></div></div></div> + +!! html/parsoid +<figure class="mw-default-size mw-halign-left" typeof="mw:Image/Frame"><a href="./File:Foobar.jpg"><img alt="Altitude" resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a><figcaption>This is a test image <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></figcaption></figure> +!! end + +!! test +Image with wiki markup in implicit alt +!! wikitext +[[Image:Foobar.jpg|testing '''bold''' in alt]] + +[[Image:Foobar.jpg|alt=testing '''bold''' in alt]] +!! html/php +<p><a href="/wiki/File:Foobar.jpg" class="image" title="testing bold in alt"><img alt="testing bold in alt" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a> +</p><p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="testing bold in alt" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a> +</p> +!! html/parsoid +<p><figure-inline class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"caption","ak":"testing '''bold''' in alt"}]}' data-mw='{"caption":"testing <b data-parsoid='{\"dsr\":[27,37,3,3]}'>bold</b> in alt"}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{}}'><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"Image:Foobar.jpg"}}'/></a></figure-inline></p> + +<p><figure-inline class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"alt","ak":"alt=testing '''bold''' in alt"}]}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{}}'><img alt="testing bold in alt" resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"alt":"testing bold in alt","resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"alt":"alt=testing '''bold''' in alt","resource":"Image:Foobar.jpg"}}'/></a></figure-inline></p> +!! end + +!! test +Alt image option should handle most kinds of wikitext without barfing +!! wikitext +[[Image:Foobar.jpg|thumb|This is the image caption|alt=This is a [[link]] and a {{echo|''bold template''}}.]] +!! html/php +<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="This is a link and a bold template." src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>This is the image caption</div></div></div> + +!! html/parsoid +<figure class="mw-default-size" typeof="mw:Image/Thumb mw:ExpandedAttrs" about="#mwt2" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"},{"ck":"caption","ak":"This is the image caption"},{"ck":"alt","ak":"alt=This is a [[link]] and a {{echo|''bold template''}}."}]}' data-mw='{"attribs":[["thumbnail",{"html":"thumb"}],["alt",{"html":"alt=This is a <a rel=\"mw:WikiLink\" href=\"./Link\" title=\"Link\" data-parsoid='{\"stx\":\"simple\",\"a\":{\"href\":\"./Link\"},\"sa\":{\"href\":\"link\"},\"dsr\":[65,73,2,2]}'>link</a> and a <i about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid='{\"dsr\":[80,106,null,null],\"pi\":[[{\"k\":\"1\"}]]}' data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"&apos;&apos;bold template&apos;&apos;\"}},\"i\":0}}]}'>bold template</i>."}]]}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{}}'><img alt="This is a link and a bold template." resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220" data-parsoid='{"a":{"alt":"This is a link and a bold template.","resource":"./File:Foobar.jpg","height":"25","width":"220"},"sa":{"alt":"alt=This is a [[link]] and a {{echo|''bold template''}}.","resource":"Image:Foobar.jpg"}}'/></a><figcaption>This is the image caption</figcaption></figure> +!! end + +!! test +Image with table with attributes in caption +!! options +parsoid=wt2html,html2html +!! wikitext +[[File:Foobar.jpg|thumb| +{| class="123" | +|- class="456" | +| ha +|} +]] +!! html/parsoid +<figure class="mw-default-size" typeof="mw:Image/Thumb" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"},{"ck":"caption","ak":"\n{| class=\"123\" |\n|- class=\"456\" |\n| ha\n|}\n"}]}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{"href":"File:Foobar.jpg"}}'><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"25","width":"220"},"sa":{"resource":"File:Foobar.jpg"}}'/></a><figcaption> +<table class="123"> +<tbody><tr class="456" data-parsoid='{"startTagSrc":"|-"}'> +<td> ha</td></tr> +</tbody></table> +</figcaption></figure> +!! end + +!! test +Image with table with rows from templates in caption +!! wikitext +[[File:Foobar.jpg|thumb| +{| +{{echo|{{!}} hi}} +|} +]] +!! html/parsoid +<figure class="mw-default-size" typeof="mw:Image/Thumb" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"},{"ck":"caption","ak":"\n{|\n{{echo|{{!}} hi}}\n|}\n"}]}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{"href":"File:Foobar.jpg"}}'><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"25","width":"220"},"sa":{"resource":"File:Foobar.jpg"}}'/></a><figcaption> +<table> +<tbody about="#mwt4" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"{{!}} hi"}},"i":0}},"\n"]}'><tr><td> hi</td></tr> +</tbody></table> +</figcaption></figure> +!! end + +!! test +Image with nested tables in caption +!! wikitext +[[File:Foobar.jpg|thumb|Foo<br /> +{| +| +{| +|z +|} +|} +]] +!! html/parsoid +<figure class="mw-default-size" typeof="mw:Image/Thumb" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"},{"ck":"caption","ak":"Foo<br/>\n{|\n|\n{|\n|z\n|}\n|}\n"}]}'><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"25","width":"220"},"sa":{"resource":"File:Foobar.jpg"}}'/></a><figcaption data-parsoid='{"dsr":[null,50,null,null]}'>Foo<br data-parsoid='{"stx":"html","selfClose":true}'/> +<table> +<tbody><tr><td> +<table> +<tbody><tr><td>z</td></tr> +</tbody></table></td></tr> +</tbody></table> +</figcaption></figure> +!! end + +################### +# Conflicting image format options. +# First option specified should 'win'. +# All three cases in each test should be identical. + +!! test +Image with 'frameless' first. +!! options +parsoid=wt2html,wt2wt,html2html +!! wikitext +[[File:Foobar.jpg|frameless|caption]] + +[[File:Foobar.jpg|frameless|frame|caption]] + +[[File:Foobar.jpg|frameless|thumb|caption]] +!! html/php +<p><a href="/wiki/File:Foobar.jpg" class="image" title="caption"><img alt="caption" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> +</p><p><a href="/wiki/File:Foobar.jpg" class="image" title="caption"><img alt="caption" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> +</p><p><a href="/wiki/File:Foobar.jpg" class="image" title="caption"><img alt="caption" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> +</p> +!! html/parsoid +<p><figure-inline class="mw-default-size" typeof="mw:Image/Frameless" data-mw='{"caption":"caption"}'><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a></figure-inline></p> +<p><figure-inline class="mw-default-size" typeof="mw:Image/Frameless" data-mw='{"caption":"caption"}'><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a></figure-inline></p> +<p><figure-inline class="mw-default-size" typeof="mw:Image/Frameless" data-mw='{"caption":"caption"}'><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a></figure-inline></p> +!! end + +!! test +Image with 'frame' first. +!! options +parsoid=wt2html,wt2wt,html2html +!! wikitext +[[File:Foobar.jpg|frame|caption]] +[[File:Foobar.jpg|frame|frameless|caption]] +[[File:Foobar.jpg|frame|thumb|caption]] +!! html/php +<div class="thumb tright"><div class="thumbinner" style="width:1943px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" class="thumbimage" /></a> <div class="thumbcaption">caption</div></div></div> +<div class="thumb tright"><div class="thumbinner" style="width:1943px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" class="thumbimage" /></a> <div class="thumbcaption">caption</div></div></div> +<div class="thumb tright"><div class="thumbinner" style="width:1943px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" class="thumbimage" /></a> <div class="thumbcaption">caption</div></div></div> + +!! html/parsoid +<figure class="mw-default-size" typeof="mw:Image/Frame"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a><figcaption>caption</figcaption></figure> +<figure class="mw-default-size" typeof="mw:Image/Frame"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a><figcaption>caption</figcaption></figure> +<figure class="mw-default-size" typeof="mw:Image/Frame"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a><figcaption>caption</figcaption></figure> +!! end + +!! test +Image with 'thumb' first. +!! options +parsoid=wt2html,wt2wt,html2html +!! wikitext +[[File:Foobar.jpg|thumb|caption]] +[[File:Foobar.jpg|thumb|frameless|caption]] +[[File:Foobar.jpg|thumb|frame|caption]] +!! html/php +<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>caption</div></div></div> +<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>caption</div></div></div> +<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>caption</div></div></div> + +!! html/parsoid +<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption>caption</figcaption></figure> +<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption>caption</figcaption></figure> +<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption>caption</figcaption></figure> +!! end + +################### +# Image sizing. +# See https://www.mediawiki.org/wiki/Help:Images#Size_and_frame +# and https://phabricator.wikimedia.org/T64258 +# Foobar has actual size of 1941x220 +# 1. Thumbs & frameless always reduce, can't be enlarged unless it's +# a scalable format. +# 2. Framed images always ignore size options; always render at default size. +# 3. "Unspecified format" and border are the only types which can be +# enlarged. + +!! test +Image: unspecified format and border enlarge +!! options +parsoid=wt2html,wt2wt,html2html +!! wikitext +[[File:Foobar.jpg|2000px]] + +[[File:Foobar.jpg|border|2000px]] +!! html/php +<p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="2000" height="227" /></a> +</p><p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="2000" height="227" class="thumbborder" /></a> +</p> +!! html/parsoid +<p><figure-inline typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="227" width="2000"/></a></figure-inline></p> +<p><figure-inline class="mw-image-border" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="227" width="2000"/></a></figure-inline></p> +!! end + +!! test +Image: "unspecified format" and border reduce +!! options +parsoid=wt2html,wt2wt,html2html +!! wikitext +[[File:Foobar.jpg|1000px]] + +[[File:Foobar.jpg|border|1000px]] +!! html/php +<p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/1000px-Foobar.jpg" width="1000" height="113" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/1500px-Foobar.jpg 1.5x, http://example.com/images/3/3a/Foobar.jpg 2x" /></a> +</p><p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/1000px-Foobar.jpg" width="1000" height="113" class="thumbborder" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/1500px-Foobar.jpg 1.5x, http://example.com/images/3/3a/Foobar.jpg 2x" /></a> +</p> +!! html/parsoid +<p><figure-inline typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/1000px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="113" width="1000"/></a></figure-inline></p> +<p><figure-inline class="mw-image-border" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/1000px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="113" width="1000"/></a></figure-inline></p> +!! end + +!! test +Image: thumbs reduce +!! options +parsoid=wt2html,wt2wt,html2html +!! wikitext +[[File:Foobar.jpg|thumb|50px]] +!! html/php +<div class="thumb tright"><div class="thumbinner" style="width:52px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/50px-Foobar.jpg" width="50" height="6" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/75px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/100px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div></div></div></div> + +!! html/parsoid +<figure typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/50px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="6" width="50"/></a></figure> +!! end + +!! test +Image: bitmap thumbs can't be enlarged past original size, but vector can. +!! options +parsoid=wt2html,wt2wt,html2html +!! wikitext +[[File:Foobar.jpg|thumb|2000px]] + +[[File:Foobar.svg|thumb|2000px]] +!! html/php +<div class="thumb tright"><div class="thumbinner" style="width:1943px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" class="thumbimage" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div></div></div></div> +<div class="thumb tright"><div class="thumbinner" style="width:2002px;"><a href="/wiki/File:Foobar.svg" class="image"><img alt="Foobar.svg" src="http://example.com/images/thumb/f/ff/Foobar.svg/2000px-Foobar.svg.png" width="2000" height="1500" class="thumbimage" srcset="http://example.com/images/thumb/f/ff/Foobar.svg/3000px-Foobar.svg.png 1.5x, http://example.com/images/thumb/f/ff/Foobar.svg/4000px-Foobar.svg.png 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.svg" class="internal" title="Enlarge"></a></div></div></div></div> + +!! html/parsoid +<figure typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></figure> +<figure typeof="mw:Image/Thumb"><a href="./File:Foobar.svg"><img resource="./File:Foobar.svg" src="//example.com/images/thumb/f/ff/Foobar.svg/2000px-Foobar.svg.png" data-file-width="240" data-file-height="180" data-file-type="drawing" height="1500" width="2000"/></a></figure> +!! end + +!! test +Image: frameless can reduce in size +!! options +parsoid=wt2html,wt2wt,html2html +!! wikitext +[[File:Foobar.jpg|frameless|50px]] +!! html/php +<p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/50px-Foobar.jpg" width="50" height="6" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/75px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/100px-Foobar.jpg 2x" /></a> +</p> +!! html/parsoid +<p><figure-inline typeof="mw:Image/Frameless"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/50px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="6" width="50"/></a></figure-inline></p> +!! end + +!! test +Image: bitmap frameless can't be enlarged past original size, but vector can +!! options +parsoid=wt2html,wt2wt,html2html +!! wikitext +[[File:Foobar.jpg|frameless|2000px]] + +[[File:Foobar.svg|frameless|2000px]] +!! html/php +<p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a> +</p><p><a href="/wiki/File:Foobar.svg" class="image"><img alt="Foobar.svg" src="http://example.com/images/thumb/f/ff/Foobar.svg/2000px-Foobar.svg.png" width="2000" height="1500" srcset="http://example.com/images/thumb/f/ff/Foobar.svg/3000px-Foobar.svg.png 1.5x, http://example.com/images/thumb/f/ff/Foobar.svg/4000px-Foobar.svg.png 2x" /></a> +</p> +!! html/parsoid +<p><figure-inline typeof="mw:Image/Frameless"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></figure-inline></p> +<p><figure-inline typeof="mw:Image/Frameless"><a href="./File:Foobar.svg"><img resource="./File:Foobar.svg" src="//example.com/images/thumb/f/ff/Foobar.svg/2000px-Foobar.svg.png" data-file-width="240" data-file-height="180" data-file-type="drawing" height="1500" width="2000"/></a></figure-inline></p> +!! end + +!! test +Image: framed images are always unscaled. +!! options +parsoid=wt2html,wt2wt,html2html +!! wikitext +[[File:Foobar.jpg|frame]] + +[[File:Foobar.jpg|frame|50px]] + +[[File:Foobar.jpg|frame|50x50px]] + +[[File:Foobar.jpg|frame|2000px]] +!! html/php +<div class="thumb tright"><div class="thumbinner" style="width:1943px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" class="thumbimage" /></a> <div class="thumbcaption"></div></div></div> +<div class="thumb tright"><div class="thumbinner" style="width:1943px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" class="thumbimage" /></a> <div class="thumbcaption"></div></div></div> +<div class="thumb tright"><div class="thumbinner" style="width:1943px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" class="thumbimage" /></a> <div class="thumbcaption"></div></div></div> +<div class="thumb tright"><div class="thumbinner" style="width:1943px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" class="thumbimage" /></a> <div class="thumbcaption"></div></div></div> + +!! html/parsoid +<figure class="mw-default-size" typeof="mw:Image/Frame"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></figure> +<figure typeof="mw:Image/Frame"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></figure> +<figure typeof="mw:Image/Frame"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></figure> +<figure typeof="mw:Image/Frame"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></figure> +!! end + +################### + +!! test +Link to image page- image page normally doesn't exists, hence edit link +Add test with existing image page +#<p><a href="/wiki/File:Test" title="Image:Test">Image:test</a> +!! wikitext +[[:Image:test]] +!! html +<p><a href="/index.php?title=File:Test&action=edit&redlink=1" class="new" title="File:Test (page does not exist)">Image:test</a> +</p> +!! end + +!! test +T20784 Link to non-existent image page with caption should use caption as link text +!! wikitext +[[:Image:test|caption]] +!! html +<p><a href="/index.php?title=File:Test&action=edit&redlink=1" class="new" title="File:Test (page does not exist)">caption</a> +</p> +!! end + +!! test +Frameless image caption with a free URL +!! wikitext +[[File:Foobar.jpg|http://example.com]] +!! html/php +<p><a href="/wiki/File:Foobar.jpg" class="image" title="http://example.com"><img alt="http://example.com" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a> +</p> +!! html/parsoid +<p><figure-inline class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"caption","ak":"http://example.com"}]}' data-mw='{"caption":"<a rel=\"mw:ExtLink\" href=\"http://example.com\" data-parsoid='{\"stx\":\"url\",\"dsr\":[18,36,0,0]}'>http://example.com</a>"}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{}}'><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></figure-inline></p> +!! end + +!! test +Thumbnail image caption with a free URL +!! options +thumbsize=220 +!! wikitext +[[File:Foobar.jpg|thumb|http://example.com]] +!! html/php +<div class="thumb tright"><div class="thumbinner" style="width:222px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" width="220" height="25" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a></div></div></div> + +!! html/parsoid +<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption><a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a></figcaption></figure> +!! end + +!! test +Thumbnail image caption with a free URL and explicit alt +!! options +thumbsize=220 +parsoid=wt2html,wt2wt,html2html +!! wikitext +[[File:Foobar.jpg|thumb|http://example.com|alt=Alteration]] +!! html/php +<div class="thumb tright"><div class="thumbinner" style="width:222px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Alteration" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" width="220" height="25" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a></div></div></div> + +!! html/parsoid +<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img alt="Alteration" resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption><a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a></figcaption></figure> +!! end + +!! test +SVG thumbnails with no language set +!! options +!! wikitext +[[File:Foobar.svg|thumb|caption]] +!! html/php +<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.svg" class="image"><img alt="" src="http://example.com/images/thumb/f/ff/Foobar.svg/180px-Foobar.svg.png" width="180" height="135" class="thumbimage" srcset="http://example.com/images/thumb/f/ff/Foobar.svg/270px-Foobar.svg.png 1.5x, http://example.com/images/thumb/f/ff/Foobar.svg/360px-Foobar.svg.png 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.svg" class="internal" title="Enlarge"></a></div>caption</div></div></div> + +!! html/parsoid +<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.svg"><img resource="./File:Foobar.svg" src="//example.com/images/thumb/f/ff/Foobar.svg/220px-Foobar.svg.png" data-file-width="240" data-file-height="180" data-file-type="drawing" height="165" width="220"/></a><figcaption>caption</figcaption></figure> +!! end + +!! test +SVG thumbnails with language de +!! options +parsoid=wt2html,wt2wt,html2html +!! wikitext +[[File:Foobar.svg|thumb|caption|lang=de]] +!! html/php +<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/index.php?title=File:Foobar.svg&lang=de" class="image"><img alt="" src="http://example.com/images/thumb/f/ff/Foobar.svg/langde-180px-Foobar.svg.png" width="180" height="135" class="thumbimage" srcset="http://example.com/images/thumb/f/ff/Foobar.svg/langde-270px-Foobar.svg.png 1.5x, http://example.com/images/thumb/f/ff/Foobar.svg/langde-360px-Foobar.svg.png 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.svg" class="internal" title="Enlarge"></a></div>caption</div></div></div> + +!! html/parsoid +<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.svg"><img resource="./File:Foobar.svg" src="//example.com/images/thumb/f/ff/Foobar.svg/220px-Foobar.svg.png" lang="de" data-file-width="240" data-file-height="180" data-file-type="drawing" height="165" width="220"/></a><figcaption>caption</figcaption></figure> +!! end + +!! test +SVG thumbnails with invalid language code +!! options +parsoid=wt2html,wt2wt,html2html +!! wikitext +[[File:Foobar.svg|thumb|caption|lang=invalid:language:code]] +!! html/php +<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.svg" class="image"><img alt="" src="http://example.com/images/thumb/f/ff/Foobar.svg/180px-Foobar.svg.png" width="180" height="135" class="thumbimage" srcset="http://example.com/images/thumb/f/ff/Foobar.svg/270px-Foobar.svg.png 1.5x, http://example.com/images/thumb/f/ff/Foobar.svg/360px-Foobar.svg.png 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.svg" class="internal" title="Enlarge"></a></div>lang=invalid:language:code</div></div></div> + +!! html/parsoid +<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.svg"><img resource="./File:Foobar.svg" src="//example.com/images/thumb/f/ff/Foobar.svg/220px-Foobar.svg.png" data-file-width="240" data-file-height="180" data-file-type="drawing" height="165" width="220"/></a><figcaption>lang=invalid:language:code</figcaption></figure> +!! end + +!! test +T3887: A ISBN with a thumbnail +!! wikitext +[[File:Foobar.jpg|thumb|ISBN 1235467890]] +!! html/php +<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div><a href="/wiki/Special:BookSources/1235467890" class="internal mw-magiclink-isbn">ISBN 1235467890</a></div></div></div> + +!! html/parsoid +<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption><a href="./Special:BookSources/1235467890" rel="mw:WikiLink">ISBN 1235467890</a></figcaption></figure> +!! end + +!! test +T3887: A RFC with a thumbnail +!! wikitext +[[File:Foobar.jpg|thumb|This is RFC 12354]] +!! html/php +<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>This is <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc12354">RFC 12354</a></div></div></div> + +!! html/parsoid +<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption>This is <a href="https://tools.ietf.org/html/rfc12354" rel="mw:ExtLink" class="external text">RFC 12354</a></figcaption></figure> +!! end + +!! test +T3887: A mailto link with a thumbnail +!! wikitext +[[File:Foobar.jpg|thumb|Please mailto:nobody@example.com]] +!! html/php +<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>Please <a rel="nofollow" class="external free" href="mailto:nobody@example.com">mailto:nobody@example.com</a></div></div></div> + +!! html/parsoid +<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption>Please <a rel="mw:ExtLink" class="external free" href="mailto:nobody@example.com">mailto:nobody@example.com</a></figcaption></figure> +!! end + +# Pending resolution to T2368 +!! test +T2648: Frameless image caption with a link +!! wikitext +[[File:Foobar.jpg|text with a [[link]] in it]] +!! html/php +<p><a href="/wiki/File:Foobar.jpg" class="image" title="text with a link in it"><img alt="text with a link in it" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a> +</p> +!! html/parsoid +<p><figure-inline class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"caption","ak":"text with a [[link]] in it"}]}' data-mw='{"caption":"text with a <a rel=\"mw:WikiLink\" href=\"./Link\" title=\"Link\" data-parsoid='{\"stx\":\"simple\",\"a\":{\"href\":\"./Link\"},\"sa\":{\"href\":\"link\"},\"dsr\":[30,38,2,2]}'>link</a> in it"}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{}}'><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></figure-inline></p> +!! end + +!! test +T2648: Frameless image caption with a link (suffix) +!! wikitext +[[File:Foobar.jpg|text with a [[link]]foo in it]] +!! html/php +<p><a href="/wiki/File:Foobar.jpg" class="image" title="text with a linkfoo in it"><img alt="text with a linkfoo in it" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a> +</p> +!! html/parsoid +<p><figure-inline class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"caption","ak":"text with a [[link]]foo in it"}]}' data-mw='{"caption":"text with a <a rel=\"mw:WikiLink\" href=\"./Link\" title=\"Link\" data-parsoid='{\"stx\":\"simple\",\"a\":{\"href\":\"./Link\"},\"sa\":{\"href\":\"link\"},\"dsr\":[30,41,2,5],\"tail\":\"foo\"}'>linkfoo</a> in it"}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{}}'><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></figure-inline></p> +!! end + +!! test +T2648: Frameless image caption with an interwiki link +!! wikitext +[[File:Foobar.jpg|text with a [[MeatBall:Link]] in it]] +!! html/php +<p><a href="/wiki/File:Foobar.jpg" class="image" title="text with a MeatBall:Link in it"><img alt="text with a MeatBall:Link in it" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a> +</p> +!! html/parsoid +<p><figure-inline class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"caption","ak":"text with a [[MeatBall:Link]] in it"}]}' data-mw='{"caption":"text with a <a rel=\"mw:WikiLink/Interwiki\" href=\"http://www.usemod.com/cgi-bin/mb.pl?Link\" title=\"meatball:Link\" data-parsoid='{\"stx\":\"simple\",\"a\":{\"href\":\"http://www.usemod.com/cgi-bin/mb.pl?Link\"},\"sa\":{\"href\":\"MeatBall:Link\"},\"isIW\":true,\"dsr\":[30,47,2,2]}'>MeatBall:Link</a> in it"}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{}}'><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></figure-inline></p> +!! end + +!! test +T2648: Frameless image caption with a piped interwiki link +!! wikitext +[[File:Foobar.jpg|text with a [[MeatBall:Link|link]] in it]] +!! html/php +<p><a href="/wiki/File:Foobar.jpg" class="image" title="text with a link in it"><img alt="text with a link in it" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a> +</p> +!! html/parsoid +<p><figure-inline class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"caption","ak":"text with a [[MeatBall:Link|link]] in it"}]}' data-mw='{"caption":"text with a <a rel=\"mw:WikiLink/Interwiki\" href=\"http://www.usemod.com/cgi-bin/mb.pl?Link\" title=\"meatball:Link\" data-parsoid='{\"stx\":\"piped\",\"a\":{\"href\":\"http://www.usemod.com/cgi-bin/mb.pl?Link\"},\"sa\":{\"href\":\"MeatBall:Link\"},\"isIW\":true,\"dsr\":[30,52,16,2]}'>link</a> in it"}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{}}'><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></figure-inline></p> +!! end + +!! test +T107474: Frameless image caption with <nowiki> +!! wikitext +[[File:Foobar.jpg|<nowiki>text with a [[MeatBall:Link|link]] in it</nowiki>]] +!! html/parsoid +<p><figure-inline class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"caption","ak":"<nowiki>text with a [[MeatBall:Link|link]] in it</nowiki>"}]}' data-mw='{"caption":"<span typeof=\"mw:Nowiki\" data-parsoid='{\"dsr\":[18,75,8,9]}'>text with a [[MeatBall:Link|link]] in it</span>"}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{}}'><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></figure-inline></p> +!! end + +!! test +Escape HTML special chars in image alt text +!! wikitext +[[File:Foobar.jpg|& < > "]] +!! html/php +<p><a href="/wiki/File:Foobar.jpg" class="image" title="& < > ""><img alt="& < > "" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a> +</p> +!! html/parsoid +<p><figure-inline class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"caption","ak":"& < > \""}]}' data-mw='{"caption":"&amp; &lt; > \""}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{}}'><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></figure-inline></p> +!! end + +!! test +Escape HTML special chars in image alt text with LanguageConverter +!! options +language=zh +!! wikitext +[[File:Foobar.jpg|& < > "]] +!! html/php +<p><a href="/wiki/File:Foobar.jpg" class="image" title="& < > ""><img alt="& < > "" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a> +</p> +!! html/parsoid +<p><figure-inline class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"caption","ak":"& < > \""}]}' data-mw='{"caption":"&amp; &lt; > \""}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{}}'><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></figure-inline></p> +!! end + +!! test +Entities in file name and attributes +!! wikitext +[[File:7%25 solution.gif|manualthumb=7%25 solution.gif|link=7%25 solution|[[7%25 solution]]]] +!! html/php +<p><a href="/index.php?title=Special:Upload&wpDestFile=7%25_solution.gif" class="new" title="File:7% solution.gif">7% solution</a> +</p> +!! html/parsoid +<p><figure-inline class="mw-default-size" typeof="mw:Error mw:Image" data-parsoid='{"optList":[{"ck":"bogus","ak":"manualthumb=7%25 solution.gif"},{"ck":"link","ak":"link=7%25 solution"},{"ck":"caption","ak":"[[7%25 solution]]"}]}' data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}],"caption":"<a rel=\"mw:WikiLink\" href=\"./7%25_solution\" title=\"7% solution\" data-parsoid='{\"stx\":\"simple\",\"a\":{\"href\":\"./7%25_solution\"},\"sa\":{\"href\":\"7%25 solution\"},\"dsr\":[74,91,2,2]}'>7% solution</a>"}'><a href="./7%25_solution" data-parsoid='{"a":{"href":"./7%25_solution"},"sa":{"href":"link=7%25 solution"}}'><img resource="./File:7%25_solution.gif" src="./Special:FilePath/7%25_solution.gif" height="220" width="220" data-parsoid='{"a":{"resource":"./File:7%25_solution.gif","height":"220","width":"220"},"sa":{"resource":"File:7%25 solution.gif"}}'/></a></figure-inline></p> +!! end + +!! test +T2499: Alt text should have Ӓ, not &1234; +!! wikitext +[[File:Foobar.jpg|♀]] +!! html/php +<p><a href="/wiki/File:Foobar.jpg" class="image" title="♀"><img alt="♀" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a> +</p> +!! html/parsoid +<p><figure-inline class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"caption","ak":"&#9792;"}]}' data-mw='{"caption":"<span typeof=\"mw:Entity\" data-parsoid='{\"src\":\"&amp;#9792;\",\"srcContent\":\"♀\",\"dsr\":[18,25,null,null]}'>♀</span>"}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{}}'><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></figure-inline></p> +!! end + +!! test +Broken image caption with link +!! options +parsoid=wt2html,wt2wt,html2html +!! wikitext +[[Image:Foobar.jpg|thumb|This is a broken caption. But [[Main Page|this]] is just an ordinary link. +!! html/php +<p>[[Image:Foobar.jpg|thumb|This is a broken caption. But <a href="/wiki/Main_Page" title="Main Page">this</a> is just an ordinary link. +</p> +!! html/parsoid +<p>[[Image:Foobar.jpg|thumb|This is a broken caption. But <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">this</a> is just an ordinary link.</p> +!! end + +!! test +Image caption containing another image +!! wikitext +[[File:Foobar.jpg|thumb|This is a caption with another [[File:Thumb.png|image]] inside it!]] +!! html/php +<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>This is a caption with another <a href="/wiki/File:Thumb.png" class="image" title="image"><img alt="image" src="http://example.com/images/e/ea/Thumb.png" width="135" height="135" /></a> inside it!</div></div></div> + +!! html/parsoid +<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption>This is a caption with another <figure-inline class="mw-default-size" typeof="mw:Image" data-mw='{"caption":"image"}'><a href="./File:Thumb.png"><img resource="./File:Thumb.png" src="//example.com/images/e/ea/Thumb.png" data-file-width="135" data-file-height="135" data-file-type="bitmap" height="135" width="135"/></a></figure-inline> inside it!</figcaption></figure> +!! end + +!! test +Image: caption containing a newline +!! wikitext +[[File:Foobar.jpg|This +*is some text]] +!! html/php +<p><a href="/wiki/File:Foobar.jpg" class="image" title="This *is some text"><img alt="This *is some text" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a> +</p> +!! html/parsoid +<p><figure-inline class="mw-default-size" typeof="mw:Image" data-mw='{"caption":"This\n*is some text"}'><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></figure-inline></p> +!!end + +!!test +Image: caption containing leading space +(The leading space should not trigger nowiki escaping in wt2wt mode) +!! wikitext +[[File:Foobar.jpg|thumb| bar]] +!! html/php +<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>bar</div></div></div> + +!! html/parsoid +<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption> bar</figcaption></figure> +!!end + +# html/php output not have newlines after table, td, th, etc. because +# Linker::makeThumbLink2() replaces the newlines with spaces since +# the table is inside a caption. +# FIXME: Verify if that circa 2004 fix is still required. +!! test +Image: caption containing a table +!! options +parsoid=wt2html,wt2wt,html2html +!! wikitext +[[Image:Foobar.jpg|thumb|200px|This is an example image thumbnail caption with a table +{| +!Foo!!Bar +|- +|Foo1||Bar1 +|} +and some more text.]] +!! html/php +<div class="thumb tright"><div class="thumbinner" style="width:202px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg" width="200" height="23" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/400px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>This is an example image thumbnail caption with a table <table> <tr> <th>Foo</th> <th>Bar </th></tr> <tr> <td>Foo1</td> <td>Bar1 </td></tr></table> and some more text.</div></div></div> + +!! html/parsoid +<figure typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="23" width="200"/></a><figcaption>This is an example image thumbnail caption with a table +<table> +<tbody> +<tr><th>Foo</th><th>Bar</th></tr> +<tr> +<td>Foo1</td> +<td>Bar1</td></tr></tbody></table>and some more text.</figcaption></figure> +!! end + +!! test +T5090: External links other than http: in image captions +!! wikitext +[[File:Foobar.jpg|thumb|200x200px|This caption has [irc://example.net irc] and [https://example.com Secure] ext links in it.]] +!! html/php +<div class="thumb tright"><div class="thumbinner" style="width:202px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg" width="200" height="23" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/400px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>This caption has <a rel="nofollow" class="external text" href="irc://example.net">irc</a> and <a rel="nofollow" class="external text" href="https://example.com">Secure</a> ext links in it.</div></div></div> + +!! html/parsoid +<figure typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="23" width="200"/></a><figcaption>This caption has <a rel="mw:ExtLink" class="external text" href="irc://example.net">irc</a> and <a rel="mw:ExtLink" class="external text" href="https://example.com">Secure</a> ext links in it.</figcaption></figure> +!! end + +!! test +Custom class +!! options +parsoid=wt2html,wt2wt,html2html +!! wikitext +[[Image:foobar.jpg|a|class=b]] +!! html/php +<p><a href="/wiki/File:Foobar.jpg" class="image" title="a"><img alt="a" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" class="b" /></a> +</p> +!! html/parsoid +<p><figure-inline class="mw-default-size b" typeof="mw:Image" data-mw='{"caption":"a"}'><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></figure-inline></p> +!! end + +!! test +Localized image handling (1). +!! options +parsoid=wt2html,wt2wt,html2html +language=es +!! wikitext +[[Archivo:Foobar.jpg|izquierda|enlace=foo|caption]] +!! html/php +<div class="floatleft"><a href="/wiki/Foo" title="caption"><img alt="caption" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div> + +!! html/parsoid +<figure class="mw-default-size mw-halign-left" typeof="mw:Image"><a href="./Foo"><img resource="./Archivo:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a><figcaption>caption</figcaption></figure> +!! end + +!! test +Localized image handling (2). +!! options +thumbsize=220 +parsoid=wt2html,wt2wt,html2html +language=es +!! wikitext +[[Archivo:Foobar.jpg|miniatura|izquierda|enlace=foo|caption]] +!! html/php +<div class="thumb tleft"><div class="thumbinner" style="width:222px;"><a href="/wiki/Foo" title="Foo"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" width="220" height="25" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/Archivo:Foobar.jpg" class="internal" title="Aumentar"></a></div>caption</div></div></div> + +!! html/parsoid +<figure class="mw-default-size mw-halign-left" typeof="mw:Image/Thumb"><a href="./Foo"><img resource="./Archivo:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption>caption</figcaption></figure> +!! end + +!! test +Localized image handling (3). +!! options +language=fa +parsoid=html2wt +!! html/parsoid +<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a></figure> +!! wikitext +[[File:Foobar.jpg|بندانگشتی]] +!! end + +!! test +"border", "frameless" and "class" attributes on an image. +!! options +thumbsize=220 +parsoid=wt2html,wt2wt,html2html +!! wikitext +[[File:Foobar.jpg|frameless|border|class=extra|caption]] +!! html/php +<p><a href="/wiki/File:Foobar.jpg" class="image" title="caption"><img alt="caption" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" width="220" height="25" class="extra thumbborder" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a> +</p> +!! html/parsoid +<p><figure-inline class="mw-default-size mw-image-border extra" typeof="mw:Image/Frameless" data-mw='{"caption":"caption"}'><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a></figure-inline></p> +!! end + +# Note that 'right' is the default alignment, despite the misspelled 'righ' below +!! test +Invalid image attributes (T64500) +!! options +thumbsize=220 +parsoid=wt2html,wt2wt,html2html +!! wikitext +[[File:Foobar.jpg|thumb|float|left|caption]] + +[[File:Foobar.jpg|thumb|righ|caption]] + +[[File:Foobar.jpg|bogus1|thumb|bogus2|left|bogus3|caption]] +!! html/php +<div class="thumb tleft"><div class="thumbinner" style="width:222px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" width="220" height="25" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>caption</div></div></div> +<div class="thumb tright"><div class="thumbinner" style="width:222px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" width="220" height="25" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>caption</div></div></div> +<div class="thumb tleft"><div class="thumbinner" style="width:222px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" width="220" height="25" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>caption</div></div></div> + +!! html/parsoid +<figure class="mw-default-size mw-halign-left" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption>caption</figcaption></figure> +<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption>caption</figcaption></figure> +<figure class="mw-default-size mw-halign-left" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption>caption</figcaption></figure> +!! end + +!! article +File:Barfoo.jpg +!! text +#REDIRECT [[File:Barfoo.jpg]] +!! endarticle + +# FIXME: Parsoid should run this test -- but we'd need to teach the +# mockAPI about the redirected Barfoo.jpg image. +!! test +Redirected image +!! wikitext +[[Image:Barfoo.jpg]] +!! html/php +<p><a href="/wiki/File:Barfoo.jpg" class="mw-redirect" title="File:Barfoo.jpg">File:Barfoo.jpg</a> +</p> +!! end + +!! test +Missing image with uploads disabled +!! options +wgEnableUploads=0 +!! wikitext +[[File:Foobaz.jpg]] +!! html/php +<p><a href="/wiki/File:Foobaz.jpg" title="File:Foobaz.jpg">File:Foobaz.jpg</a> +</p> +!! html/parsoid +<p><figure-inline class="mw-default-size" typeof="mw:Error mw:Image" data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}]}'><a href="./File:Foobaz.jpg"><img resource="./File:Foobaz.jpg" src="./Special:FilePath/Foobaz.jpg" height="220" width="220"/></a></figure-inline></p> +!! end + +# Parsoid-specific testing for images +# https://www.mediawiki.org/wiki/Parsoid/MediaWiki_DOM_spec#Images +# Currently imperfect due to a flaw in the Parsoid testrunner +# Work in progress +# THESE TESTS SHOULD BE MOVED UP and merged with the php-specific +# image tests. + +!! test +Parsoid-specific image handling - simple image with size and middle alignment +!! wikitext +[[File:Foobar.jpg|middle|50px]] +!! html/parsoid +<p><figure-inline class="mw-valign-middle" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/50px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="6" width="50"/></a></figure-inline></p> +!! end + +!! test +Parsoid-specific image handling - simple image with size, middle alignment, +non-standard namespace alias +!! options +parsoid=wt2wt,wt2html,html2html +!! wikitext +[[Image:Foobar.jpg|middle|50px]] +!! html/parsoid +<p><figure-inline class="mw-valign-middle" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/50px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="6" width="50"/></a></figure-inline></p> +!! end + +!! test +Parsoid-specific image handling - simple image with size and middle alignment +(existing content) +!! wikitext +[[File:Foobar.jpg|50px|middle]] +!! html/parsoid +<p><figure-inline class="mw-valign-middle" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"width","ak":"50px"},{"ck":"middle","ak":"middle"}]}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"}}'><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/50px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="6" width="50" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"6","width":"50"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></figure-inline></p> +!! end + +!! test +Parsoid-specific image handling - simple image with size and middle alignment +and non-standard namespace name +!! options +parsoid=wt2html,wt2wt,html2html +!! wikitext +[[Image:Foobar.jpg|50px|middle]] +!! html/parsoid +<p><figure-inline class="mw-valign-middle" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/50px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="6" width="50"/></a></figure-inline></p> +!! end + +!! test +Parsoid-specific image handling - simple image with both sizes, a baseline alignment, and a caption +!! wikitext +[[File:Foobar.jpg|500x10px|baseline|caption]] +!! html/parsoid +<p><figure-inline class="mw-valign-baseline" typeof="mw:Image" data-mw='{"caption":"caption"}' data-parsoid='{"optList":[{"ck":"width","ak":"500x10px"},{"ck":"baseline","ak":"baseline"},{"ck":"caption","ak":"caption"}],"size":"500x10"}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"}}'><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/89px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="10" width="89" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"10","width":"89"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></figure-inline></p> +!! end + +!! test +Parsoid-specific image handling - simple image with border and size spec +!! wikitext +[[File:Foobar.jpg|50px|border|caption]] +!! html/parsoid +<p><figure-inline class="mw-image-border" typeof="mw:Image" data-mw='{"caption":"caption"}' data-parsoid='{"optList":[{"ck":"width","ak":"50px"},{"ck":"border","ak":"border"},{"ck":"caption","ak":"caption"}]}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"}}'><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/50px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="6" width="50" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"6","width":"50"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></figure-inline></p> +!! end + +!! test +Parsoid-specific image handling - thumbnail with halign, valign, and caption +!! wikitext +[[File:Foobar.jpg|left|baseline|thumb|caption content]] +!! html/parsoid +<figure class="mw-default-size mw-halign-left mw-valign-baseline" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption>caption content</figcaption></figure> +!! end + +!! test +Parsoid-specific image handling - thumbnail with halign, valign, and caption +(existing content) +!! wikitext +[[File:Foobar.jpg|thumb|left|baseline|caption content]] +!! html/parsoid +<figure class="mw-default-size mw-halign-left mw-valign-baseline" typeof="mw:Image/Thumb" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"},{"ck":"left","ak":"left"},{"ck":"baseline","ak":"baseline"},{"ck":"caption","ak":"caption content"}]}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"}}'><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"25","width":"220"},"sa":{"resource":"File:Foobar.jpg"}}'/></a><figcaption>caption content</figcaption></figure> +!! end + +!! test +Parsoid-specific image handling - thumbnail with specific size, halign, valign, and caption +!! wikitext +[[Image:Foobar.jpg|right|middle|thumb|50x50px|caption]] +!! html/parsoid +<figure class="mw-halign-right mw-valign-middle" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/50px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="6" width="50"/></a><figcaption>caption</figcaption></figure> +!! end + +!! test +Parsoid-specific image handling - thumbnail with specific size, halign, +valign, and caption (existing content) +!! wikitext +[[File:Foobar.jpg|thumb|50x50px|right|middle|caption]] +!! html/parsoid +<figure class="mw-halign-right mw-valign-middle" typeof="mw:Image/Thumb" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"},{"ck":"width","ak":"50x50px"},{"ck":"right","ak":"right"},{"ck":"middle","ak":"middle"},{"ck":"caption","ak":"caption"}],"size":"50x50"}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"}}'><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/50px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="6" width="50" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"6","width":"50"},"sa":{"resource":"File:Foobar.jpg"}}'/></a><figcaption>caption</figcaption></figure> +!! end + +!! test +Parsoid-specific image handling - framed image with specific size and caption +(size is ignored) +!! options +parsoid=wt2html,wt2wt,html2html +!! wikitext +[[File:Foobar.jpg|frame|500x50px|caption]] +!! html/parsoid +<figure typeof="mw:Image/Frame"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a><figcaption>caption</figcaption></figure> +!! end + +!! test +Parsoid-specific image handling - framed image with specific size, halign, valign, and caption +(size is ignored) +!! options +parsoid=wt2html,wt2wt,html2html +!! wikitext +[[File:Foobar.jpg|left|baseline|frame|500x50px|caption]] +!! html/parsoid +<figure class="mw-halign-left mw-valign-baseline" typeof="mw:Image/Frame"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a><figcaption>caption</figcaption></figure> +!! end + +!! test +Parsoid-specific image handling - frameless image with specific size, border, and caption +!! wikitext +[[File:Foobar.jpg|frameless|442x50px|border|caption]] +!! html/parsoid +<p><figure-inline class="mw-image-border" typeof="mw:Image/Frameless" data-mw='{"caption":"caption"}' data-parsoid='{"optList":[{"ck":"frameless","ak":"frameless"},{"ck":"width","ak":"442x50px"},{"ck":"border","ak":"border"},{"ck":"caption","ak":"caption"}],"size":"442x50"}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"}}'><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/442px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="50" width="442" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"50","width":"442"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></figure-inline></p> +!! end + +!! test +Parsoid-specific image handling - simple image with a formatted caption +!! wikitext +[[File:Foobar.jpg|<table><tr><td>a</td><td>b</td></tr><tr><td>c</td></tr></table>]] +!! html/parsoid +<p><figure-inline class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"caption","ak":"<table><tr><td>a</td><td>b</td></tr><tr><td>c</td></tr></table>"}]}' data-mw='{"caption":"<table data-parsoid='{\"stx\":\"html\",\"dsr\":[18,81,7,8]}'><tbody data-parsoid='{\"dsr\":[25,73,0,0]}'><tr data-parsoid='{\"stx\":\"html\",\"dsr\":[25,54,4,5]}'><td data-parsoid='{\"stx\":\"html\",\"dsr\":[29,39,4,5]}'>a</td><td data-parsoid='{\"stx\":\"html\",\"dsr\":[39,49,4,5]}'>b</td></tr><tr data-parsoid='{\"stx\":\"html\",\"dsr\":[54,73,4,5]}'><td data-parsoid='{\"stx\":\"html\",\"dsr\":[58,68,4,5]}'>c</td></tr></tbody></table>"}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{}}'><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></figure-inline></p> +!! end + +!! test +Parsoid-specific image handling - caption with a template in it +!! wikitext +[[File:Foobar.jpg|thumb|200x23px|This caption has a {{echo|transclusion}} in it.]] +!! html/parsoid +<figure typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="23" width="200"></a><figcaption>This caption has a <span about="#mwt1" typeof="mw:Transclusion" data-mw="{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"transclusion"}},"i":0}}]}">transclusion</span> in it.</figcaption></figure> +!! end + +!! test +Parsoid-specific image handling - caption with unbalanced tags in it +!! options +parsoid=wt2html,wt2wt,html2html +!! wikitext +foo +[[File:Foobar.jpg|thumb|200x200px|This caption has a <center>unbalanced tag in it.]] +bar +!! html/parsoid +<p>foo</p> +<figure typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="23" width="200"/></a><figcaption>This caption has a <center>unbalanced tag in it.</center></figcaption></figure> +<p>bar</p> +!! end + +!! test +Parsoid-specific image handling - empty caption (1) +!! options +parsoid=wt2html,wt2wt +!! wikitext +[[File:Foobar.jpg|thumb|]] +!! html/parsoid +<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption></figcaption></figure> +!! end + +# empty captions don't get serialized unless we're in the "round trip" case +!! test +Parsoid-specific image handling - empty caption (2) +!! options +parsoid=html2wt +!! html/parsoid +<figure class="mw-default-size" typeof="mw:Image/Thumb"> + <a href="./File:Foobar.jpg"> + <img resource="./File:Foobar.jpg" + src="//example.com/images/3/3a/Foobar.jpg" + data-file-width="1941" data-file-height="220" data-file-type="bitmap" + height="25" width="220"/> + </a> + <figcaption></figcaption> +</figure> +!! wikitext +[[File:Foobar.jpg|thumb]] +!! end + +!! test +Parsoid-specific image handling - whitespace caption +!! wikitext +[[File:Foobar.jpg|thumb| ]] +!! html/parsoid +<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption> </figcaption></figure> +!! end + +!! test +Parsoid-specific image handling - lang option +!! wikitext +foo +[[File:Foobar.svg|lang=de|caption]] +bar +!! html/parsoid +<p>foo +<figure-inline class="mw-default-size" typeof="mw:Image" data-mw='{"caption":"caption"}'><a href="./File:Foobar.svg"><img resource="./File:Foobar.svg" src="//example.com/images/f/ff/Foobar.svg" lang="de" data-file-width="240" data-file-height="180" data-file-type="drawing" height="180" width="240"/></a></figure-inline> +bar</p> +!! end + +## Edge case bugs in Parsoid from T93580 +!! test +T93580: 1. Templated <ref> inside block images +!! wikitext +[[File:Foobar.jpg|thumb|Caption with templated ref: {{echo|<ref>foo</ref>}}]] + +<references /> +!! html/parsoid +<figure class="mw-default-size" typeof="mw:Image/Thumb" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"},{"ck":"caption","ak":"Caption with templated ref: {{echo|<ref>foo</ref>}}"}]}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{}}'><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"25","width":"220"},"sa":{"resource":"File:Foobar.jpg"}}'/></a><figcaption>Caption with templated ref: <sup about="#mwt5" class="mw-ref" id="cite_ref-1" rel="dc:references" typeof="mw:Transclusion mw:Extension/ref" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"<ref>foo</ref>"}},"i":0}}]}'><a href="./Main_Page#cite_note-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></sup></figcaption></figure> + +<ol class="mw-references references" typeof="mw:Extension/references" about="#mwt6" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text" data-parsoid="{}">foo</span></li></ol> +!! end + +!! test +T93580: 2. <ref> inside inline images +!! wikitext +[[File:Foobar.jpg|Undisplayed caption in inline image with ref: <ref>foo</ref>]] + +<references /> +!! html/parsoid +<p><figure-inline class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"caption","ak":"Undisplayed caption in inline image with ref: <ref>foo</ref>"}]}' data-mw='{"caption":"Undisplayed caption in inline image with ref: <sup about=\"#mwt2\" class=\"mw-ref\" id=\"cite_ref-1\" rel=\"dc:references\" typeof=\"mw:Extension/ref\" data-parsoid='{\"dsr\":[64,78,5,6]}' data-mw='{\"name\":\"ref\",\"body\":{\"id\":\"mw-reference-text-cite_note-1\"},\"attrs\":{}}'><a href=\"./Main_Page#cite_note-1\" style=\"counter-reset: mw-Ref 1;\" data-parsoid=\"{}\"><span class=\"mw-reflink-text\" data-parsoid=\"{}\">[1]</span></a></sup>"}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{"href":"File:Foobar.jpg"}}'><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></figure-inline></p> + +<ol class="mw-references references" typeof="mw:Extension/references" about="#mwt4" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text">foo</span></li></ol> +!! end + +!! test +T93580: 3. Templated <ref> inside inline images +!! wikitext +[[File:Foobar.jpg|Undisplayed caption in inline image with ref: {{echo|<ref>{{echo|foo}}</ref>}}]] + +<references /> +!! html/parsoid +<p><figure-inline class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"caption","ak":"Undisplayed caption in inline image with ref: {{echo|<ref>{{echo|foo}}</ref>}}"}]}' data-mw='{"caption":"Undisplayed caption in inline image with ref: <sup about=\"#mwt2\" class=\"mw-ref\" id=\"cite_ref-1\" rel=\"dc:references\" typeof=\"mw:Transclusion mw:Extension/ref\" data-parsoid='{\"dsr\":[64,96,null,null],\"pi\":[[{\"k\":\"1\"}]]}' data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"&lt;ref>{{echo|foo}}&lt;/ref>\"}},\"i\":0}}]}'><a href=\"./Main_Page#cite_note-1\" style=\"counter-reset: mw-Ref 1;\" data-parsoid=\"{}\"><span class=\"mw-reflink-text\" data-parsoid=\"{}\">[1]</span></a></sup>"}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{"href":"File:Foobar.jpg"}}'><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></figure-inline></p> + +<ol class="mw-references references" typeof="mw:Extension/references" about="#mwt6" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text">foo</span></li></ol> +!! end + +### +### Subpages +### +!! article +Subpage test/subpage +!! text +foo +!! endarticle + +!! test +Subpage link +!! options +subpage title=[[Subpage test]] +!! wikitext +[[/subpage]] +!! html +<p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a> +</p> +!! end + +!! test +Subpage noslash link +!! options +subpage title=[[Subpage test]] +!! wikitext +[[/subpage/]] +!! html +<p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">subpage</a> +</p> +!! end + +!! article +Subpage test/1/2/subpage +!! text +blah +!! endarticle + +!! test +Relative subpage noslash link +!! options +parsoid=wt2wt,wt2html,html2html +subpage title=[[Subpage test/1/2/3/4]] +!! wikitext +[[../../subpage/]] + +[[../../subpage]] +!! html/php +<p><a href="/wiki/Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">subpage</a> +</p><p><a href="/wiki/Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">Subpage test/1/2/subpage</a> +</p> +!! html/parsoid +<p><a rel="mw:WikiLink" href="./Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">subpage</a></p> +<p><a rel="mw:WikiLink" href="./Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">Subpage_test/1/2/subpage</a></p> +!! end + +!! test +Parsoid: dot-slash prefixed wikilinks +!! wikitext +[[./foo]] + +[[././bar]] + +[[././baz/]] +!! html/php +<p>[[./foo]] +</p><p>[[././bar]] +</p><p>[[././baz/]] +</p> +!! html/parsoid +<p>[[./foo]] +</p><p>[[././bar]] +</p><p>[[././baz/]] +</p> +!! end + +!! test +Render invalid page names as plain text (T53090) +!! wikitext +[[./../foo|bar]] +[[foo�|bar]] +[[foo/.|bar]] +[[foo/..|bar]] +[[foo~~~bar]] +[[foo>bar]] +[[foo[bar]] +[[.]] +[[..]] +[[foo././bar]] +[[foo[http://example.com]xyz]] + +[[{{echo|./../foo}}|bar]] +[[{{echo|foo/.}}|bar]] +[[{{echo|foo/..}}|bar]] +[[{{echo|foo~~~~bar}}]] +[[{{echo|foo>bar}}]] +[[{{echo|foo././bar}}]] +[[{{echo|foo{bar}}]] +[[{{echo|foo}bar}}]] +[[{{echo|foo[bar}}]] +[[{{echo|foo]bar}}]] +[[{{echo|foo<bar}}]] +!!html/php +<p>[[./../foo|bar]] +[[foo�|bar]] +[[foo/.|bar]] +[[foo/..|bar]] +[[foo~~~bar]] +[[foo>bar]] +[[foo[bar]] +[[.]] +[[..]] +[[foo././bar]] +[[foo<a rel="nofollow" class="external autonumber" href="http://example.com">[1]</a>xyz]] +</p><p>[[./../foo|bar]] +[[foo/.|bar]] +[[foo/..|bar]] +[[foo~~~~bar]] +[[foo>bar]] +[[foo././bar]] +[[foo{bar]] +[[foo}bar]] +[[foo[bar]] +[[foo]bar]] +[[foo<bar]] +</p> +!!html/parsoid +<p>[[./../foo|bar]] +[[foo�|bar]] +[[foo/.|bar]] +[[foo/..|bar]] +[[foo~~~bar]] +[[foo>bar]] +[[foo[bar]] +[[.]] +[[..]] +[[foo././bar]] +[[foo<a rel="mw:ExtLink" class="external autonumber" href="http://example.com"></a>xyz]]</p> + +<p>[[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"./../foo"}},"i":0}}]}'>./../foo</span>|bar]] +[[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo/."}},"i":0}}]}'>foo/.</span>|bar]] +[[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo/.."}},"i":0}}]}'>foo/..</span>|bar]] +[[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo~~~~bar"}},"i":0}}]}'>foo~~~~bar</span>]] +[[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo>bar"}},"i":0}}]}'>foo>bar</span>]] +[[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo././bar"}},"i":0}}]}'>foo././bar</span>]] +[[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo{bar"}},"i":0}}]}'>foo{bar</span>]] +[[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo}bar"}},"i":0}}]}'>foo}bar</span>]] +[[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo[bar"}},"i":0}}]}'>foo[bar</span>]] +[[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo]bar"}},"i":0}}]}'>foo]bar</span>]] +[[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo<bar"}},"i":0}}]}'>foo<bar</span>]]</p> +!!end + +!! test +Disabled subpages +!! wikitext +[[/subpage]] +!! html +<p><a href="/index.php?title=/subpage&action=edit&redlink=1" class="new" title="/subpage (page does not exist)">/subpage</a> +</p> +!! end + +!! test +T2561: {{/Subpage}} +!! options +subpage title=[[Page]] +!! wikitext +{{/Subpage}} +!! html +<p><a href="/index.php?title=Page/Subpage&action=edit&redlink=1" class="new" title="Page/Subpage (page does not exist)">Page/Subpage</a> +</p> +!! end + +### +### Categories +### +!! article +Category:MediaWiki User's Guide +!! text +blah +!! endarticle + +!! test +Link to category +!! wikitext +[[:Category:MediaWiki User's Guide]] +!! html +<p><a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User's Guide">Category:MediaWiki User's Guide</a> +</p> +!! end + +!! test +Simple category +!! options +cat +!! wikitext +[[Category:MediaWiki User's Guide]] +!! html/php +cat=MediaWiki_User's_Guide sort= +!! html/parsoid +<link rel="mw:PageProp/Category" href="./Category:MediaWiki_User's_Guide" data-parsoid='{"stx":"simple","a":{"href":"./Category:MediaWiki_User's_Guide"},"sa":{"href":"Category:MediaWiki User's Guide"}}'/> +!! end + +!! test +PAGESINCATEGORY invalid title fatal (r33546 fix) +!! wikitext +{{PAGESINCATEGORY:<bogus>}} +!! html +<p>0 +</p> +!! end + +!! test +Category with different sort key +!! options +cat +!! wikitext +[[Category:MediaWiki User's Guide|Foo]] +!! html/php +cat=MediaWiki_User's_Guide sort=Foo +!! html/parsoid +<link rel="mw:PageProp/Category" href="./Category:MediaWiki_User's_Guide#Foo" data-parsoid='{"stx":"piped","a":{"href":"./Category:MediaWiki_User's_Guide"},"sa":{"href":"Category:MediaWiki User's Guide"}}'/> +!! end + +!! test +Category with identical sort key +!! options +cat +!! wikitext +[[Category:MediaWiki User's Guide|MediaWiki User's Guide]] +!! html/php +cat=MediaWiki_User's_Guide sort=MediaWiki User's Guide +!! html/parsoid +<link rel="mw:PageProp/Category" href="./Category:MediaWiki_User's_Guide#MediaWiki%20User's%20Guide" data-parsoid='{"stx":"piped","a":{"href":"./Category:MediaWiki_User's_Guide"},"sa":{"href":"Category:MediaWiki User's Guide"}}'/> +!! end + +!! test +Category with empty sort key +!! options +cat +pst +!! wikitext +[[Category:MediaWiki User's Guide|]] +!! html/php +[[Category:MediaWiki User's Guide|MediaWiki User's Guide]] +!! end + +!! test +Category with empty sort key and parentheses +!! options +cat +pst +!! wikitext +[[Category:Foo (bar)|]] +!! html/php +[[Category:Foo (bar)|Foo]] +!! end + +!! test +Category with link tail +!! options +cat +pst +!! wikitext +123[[Category:Foo]]456 +!! html/php +123[[Category:Foo]]456 +!! end + +!! test +Category with template +!! options +cat +pst +!! wikitext +[[Category:{{echo|Foo}}]] +!! html/php +[[Category:{{echo|Foo}}]] +!! end + +!! test +Category with template in sort key +!! options +cat +pst +!! wikitext +[[Category:Foo|{{echo|Bar}}]] +!! html/php +[[Category:Foo|{{echo|Bar}}]] +!! end + +!! test +Category with template in sort key and title +!! options +cat +pst +!! wikitext +[[Category:{{echo|Foo}}|{{echo|Bar}}]] +!! html/php +[[Category:{{echo|Foo}}|{{echo|Bar}}]] +!! end + +## We used to, but no longer wt2wt this test since the default serializer +## will normalize all categories to serialize on their own line. +## This wikitext usage is going to be fairly uncommon in production and +## selser will take care of preserving formatting in those scenarios. +!! test +Category / paragraph interactions +!! options +parsoid=wt2html +!! wikitext +Foo [[Category:Baz]] Bar + +Foo [[Category:Baz]] +Bar + +Foo +[[Category:Baz]] +Bar + +Foo +[[Category:Baz]] Bar + +Foo +[[Category:Baz]] + [[Category:Baz]] +[[Category:Baz]] +Bar + +[[Category:Baz]] + [[Category:Baz]] +[[Category:Baz]] + +[[Category:Baz]] + {{echo|[[Category:Baz]]}} +[[Category:Baz]] +!! html/php +<p>Foo Bar +</p><p>Foo +Bar +</p><p>Foo +Bar +</p><p>Foo Bar +</p><p>Foo +Bar +</p> +!! html/parsoid +<p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p> +<p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p> +<p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p> +<p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p> +<p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> <link rel="mw:PageProp/Category" href="./Category:Baz"/> <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p> +<link rel="mw:PageProp/Category" href="./Category:Baz"/> <link rel="mw:PageProp/Category" href="./Category:Baz"/> <link rel="mw:PageProp/Category" href="./Category:Baz"/> <link rel="mw:PageProp/Category" href="./Category:Baz"/> <link rel="mw:PageProp/Category" href="./Category:Baz" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[Category:Baz]]"}},"i":0}}]}'/> +<link rel="mw:PageProp/Category" href="./Category:Baz"/> +!! end + +## We used to, but no longer wt2wt this test since the default serializer +## will normalize all categories to serialize on their own line. +## This wikitext usage is going to be fairly uncommon in production and +## selser will take care of preserving formatting in those scenarios. +## +## The whitespace on the empty line is part of the test. Please do not delete +!! test +1. Categories and newlines: All preceding newlines should be suppressed (courtesy T2087) +!! options +parsoid=wt2html +!! wikitext +This + +[[Category:Foo]] and this should be part of same paragraph (not an indent-pre) + +{{echo|[[Category:Foo]] and so should this!}} +!! html/php +<p>This and this should be part of same paragraph (not an indent-pre) and so should this! +</p> +!! html/parsoid +<p>This + +<link rel="mw:PageProp/Category" href="./Category:Foo"/> and this should be part of same paragraph (not an indent-pre) + +<link rel="mw:PageProp/Category" href="./Category:Foo" about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[Category:Foo]] and so should this!"}},"i":0}}]}'/><span about="#mwt1"> and so should this!</span></p> +!! end + +## Parsoid will not try to wt2wt this while preserving newlines because +## it suppresses excess newlines within list items -- and we don't want to +## introduce a special case just for categories, which is, in reality somewhat +## odd behavior -- categories are unlikely to be used in list items like this +## in top-level pages and are only likely to show up in template-generated +## list items where this RT-ing is a non-issue. +## +## The whitespace on the empty line is part of the test. Please do not delete +!! test +2. Categories and newlines: All preceding newlines should be suppressed (courtesy T2087) +!! options +parsoid=wt2html +!! wikitext +* This + +[[Category:Foo]] and this should be part of the same list item +* So should this + +{{echo|[[Category:Foo]] and this should be part of the same list item}} +!! html +<ul><li>This and this should be part of the same list item</li> +<li>So should this and this should be part of the same list item</li></ul> +!! html/parsoid +<ul> +<li>This <link rel="mw:PageProp/Category" href="./Category:Foo"/> and this should be part of the same list item</li> +<li>So should this <link rel="mw:PageProp/Category" href="./Category:Foo" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[Category:Foo]] and this should be part of the same list item"}},"i":0}}]}'/><span> and this should be part of the same list item</span></li> +</ul> +!! end + +## Newlines and categories that follow the last item of a list +## are treated differently because this (list followed by categories) +## is an extremely common pattern on wikis. +!! test +3. Categories and newlines: newline suppression for last list item should RT properly +!! wikitext +* a +* b + +[[Category:Foo]] + +[[Category:Bar]] +[[Category:Baz]] +!! html/parsoid +<ul><li> a</li> +<li> b</li></ul> + +<link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/> + +<link rel="mw:PageProp/Category" href="./Category:Bar" data-parsoid='{"stx":"simple","a":{"href":"./Category:Bar"},"sa":{"href":"Category:Bar"}}'/> +<link rel="mw:PageProp/Category" href="./Category:Baz" data-parsoid='{"stx":"simple","a":{"href":"./Category:Baz"},"sa":{"href":"Category:Baz"}}'/> +!! end + +!! test +4. Categories and newlines: newline suppression for last list item should RT properly +!! wikitext +* a +**** b + +[[Category:Foo]] +!! html/parsoid +<ul><li> a +<ul><li><ul><li><ul><li> b</li></ul></li></ul></li></ul></li></ul> + +<link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/> +!! end + +## only wt2html for this to make sure the algo only applies to the rightmost path +!! test +5. Categories and newlines: migrateTrailingCategories dom pass should only run on the rightmost path of nested lists +!! options +parsoid=wt2html +!! wikitext +* a +** b +[[Category:Foo]] +* c +** d +[[Category:Foo]] +!! html/parsoid +<ul><li> a +<ul><li> b +<link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/></li></ul></li> +<li> c +<ul><li> d</li></ul></li></ul> +<link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/> +!! end + +## We used to, but no longer wt2wt this test since the default serializer +## will normalize all categories to serialize on their own line. +## This wikitext usage is going to be fairly uncommon in production and +## selser will take care of preserving formatting in those scenarios. +!! test +6. Categories and newlines: migrateTrailingCategories dom pass should not migrate categories not preceded by newlines +!! options +parsoid=wt2html +!! wikitext +* a [[Category:Foo]] +!! html/parsoid +<ul><li>a <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/></li></ul> +!! end + +# This test also demonstrates because of newline+category tunneling +# through the list hander, template wrapping doesn't expand to the +# containing list when the list item swallows the category. +!! test +7. Categories and newlines: migrateTrailingCategories dom pass should leave template content alone +!! wikitext +* {{echo|a +[[Category:Foo]]}} +!! html/parsoid +<ul><li> <span about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"a\n[[Category:Foo]]"}},"i":0}}]}'>a +</span><link rel="mw:PageProp/Category" href="./Category:Foo" about="#mwt1" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/></li></ul> +!! end + +!! test +8. Categories and newlines: migrateTrailingCategories dom pass should not get tripped by intervening templates +!! wikitext +* a + +{{echo|[[Category:Foo]] +[[Category:Bar]]}} +[[Category:Baz]] +!! html/parsoid +<ul><li> a</li></ul> + +<link rel="mw:PageProp/Category" href="./Category:Foo" about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"},"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[Category:Foo]]\n[[Category:Bar]]"}},"i":0}}]}'/><span about="#mwt1"> +</span><link rel="mw:PageProp/Category" href="./Category:Bar" about="#mwt1" data-parsoid='{"stx":"simple","a":{"href":"./Category:Bar"},"sa":{"href":"Category:Bar"}}'/> +<link rel="mw:PageProp/Category" href="./Category:Baz" data-parsoid='{"stx":"simple","a":{"href":"./Category:Baz"},"sa":{"href":"Category:Baz"}}'/> +!! end + +!! test +9. Categories and newlines: should behave properly with linkprefix (T87753) +!! options +language=ar +!! wikitext +foo bar +foo bar +[[تصنيف:Foo]] +[[تصنيف:Bar]] +!! html/php +<p>foo bar +foo bar +</p> +!! html/parsoid +<p>foo bar +foo bar</p> +<link rel="mw:PageProp/Category" href="./تصنيف:Foo"/> +<link rel="mw:PageProp/Category" href="./تصنيف:Bar"/> +!! end + +!! test +10. No regressions on internal links following category (T174639) +!! options +parsoid=wt2html,html2html +!! wikitext +[[Category:Foo]]<div>a + +[[Foo]]</div> +!! html/php +<div>a +<a href="/wiki/Foo" title="Foo">Foo</a></div> + +!! html/parsoid +<link rel="mw:PageProp/Category" href="./Category:Foo"/><div>a + +<a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></div> +!! end + +# Note that Parsoid differs slightly from PHP due to T175421 +!! test +11. Special case where only newlines separate links (T175416) +!! options +parsoid=wt2html,html2html +!! wikitext +[[Category:Foo]] + +[[Foo]][[es:Alimento]] + +[[Foo]] +!! html/php +<p><br /> +<a href="/wiki/Foo" title="Foo">Foo</a> +</p><p><a href="/wiki/Foo" title="Foo">Foo</a> +</p> +!! html/parsoid +<link rel="mw:PageProp/Category" href="./Category:Foo"/> + +<p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></p><link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Alimento"/> + +<p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></p> +!! end + +!! test +Category links with multiple namespaces +!! wikitext +[[Category:Project:Foo]] +!! html/parsoid +<link rel="mw:PageProp/Category" href="./Category:Project:Foo" /> +!! end + +!! test +Parsoid: Serialize link to category page with colon escape +!! options +parsoid +!! wikitext + +[[:Category:Foo]] +[[:Category:Foo|Bar]] +!! html +<p> +<a rel="mw:WikiLink" href="./Category:Foo" title="Category:Foo">Category:Foo</a> +<a rel="mw:WikiLink" href="./Category:Foo" title="Category:Foo">Bar</a> +</p> +!! end + +# We used to, but no longer wt2wt this test since the default serializer +# will normalize all categories to serialize on their own line. +# This wikitext usage is going to be fairly uncommon in production and +# selser will take care of preventing whitespace insertion if this +# occurs in an article. +# +# html2html disabled for the same reason (whitespace insertion between +# x and y). +# +# html2wt disabled because it localizes the "Category" namespace. +!! test +Link prefix/suffixes aren't applied to category links +!! options +parsoid=wt2html +language=is +!! wikitext +x[[Category:Foo]]y +!! html/php +<p>xy +</p> +!! html/parsoid +<p>x<link rel="mw:PageProp/Category" href="./Flokkur:Foo" data-parsoid=""/>y</p> +!! end + +!! test +Link prefix/suffixes aren't applied to language links +!! options +parsoid=wt2html +language=is +!! wikitext +x[[es:Foo]]y +!! html/php +<p>xy +</p> +!! html/parsoid +<p>x<link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo" data-parsoid=""/>y</p> +!! end + +!! test +Parsoid: Serialize link to file page with colon escape +!! options +parsoid +!! wikitext + +[[:File:Foo.png]] +[[:File:Foo.png|Bar]] +!! html +<p> +<a rel="mw:WikiLink" href="./File:Foo.png" title="File:Foo.png">File:Foo.png</a> +<a rel="mw:WikiLink" href="./File:Foo.png" title="File:Foo.png">Bar</a> +</p> +!! end + +!! test +Parsoid: Serialize a genuine category link without colon escape +!! options +parsoid +!! wikitext +[[Category:Foo]] +[[Category:Foo|Bar]] +!! html +<link rel="mw:PageProp/Category" href="./Category:Foo"> +<link rel="mw:PageProp/Category" href="./Category:Foo#Bar"> +!! end + +!! test +Normalize hrefs properly before testing for invalid link targets (T72894) +!! options +parsoid=html2wt +!! html/parsoid +<link rel="mw:PageProp/Category" href="./Category:Toxine_bactérienne"/> +!! wikitext +[[Category:Toxine bactérienne]] +!! end + +!! test +Parsoid: Defaultsort +!! wikitext +{{DEFAULTSORT:Foo}} +!! html/parsoid +<meta property="mw:PageProp/categorydefaultsort" content="Foo"/> +!! end + +# NOTE: mw:ExpandedAttrs is not the best typeof here. mw:Transclusion is better. +# But, this is a limitation of our representation and is documented in +# TemplateHandler.js in processSpecialMagicWord +!! test +Parsoid: Defaultsort (template-generated) +!! wikitext +{{{{echo|DEFAULTSORT}}:Foo}} +!! html/parsoid +<meta property="mw:PageProp/categorydefaultsort" content="Foo" about="#mwt3" typeof="mw:ExpandedAttrs" data-parsoid='{"src":"{{{{echo|DEFAULTSORT}}:Foo}}","dsr":[0,26,null,null]}' data-mw='{"attribs":[[{"txt":"content"},{"html":"<span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid='{\"pi\":[[{\"k\":\"1\"}]],\"dsr\":[2,22,null,null]}' data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"DEFAULTSORT\"}},\"i\":0}}]}'>DEFAULTSORT</span>:Foo"}]]}'/> +!! end + +### +### Inter-language links +### +!! test +Interlanguage links +!! options +ill +!! wikitext +[[es:Alimento]] +[[fr:Nourriture]] +[[zh:食品]] +!! html/php +es:Alimento fr:Nourriture zh:食品 +!! html/parsoid +<link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Alimento"/> +<link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/Nourriture"/> +<link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/食品"/> +!! end + +!! test +Duplicate interlanguage links (T26502) +!! options +ill +!! wikitext +[[es:1]] +[[es:2]] +[[fr:1]] +[[fr:2]] +!! html/php +es:1 fr:1 +!! html/parsoid +<link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/1"/> +<link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/2"/> +<link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/1"/> +<link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/2"/> +!! end + +### +### Sections +### +!! test +Basic section headings +!! wikitext +==Headline 1== +Some text + +==Headline 2== +More +===Smaller headline=== +Blah blah +!! html +<h2><span class="mw-headline" id="Headline_1">Headline 1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: Headline 1">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<p>Some text +</p> +<h2><span class="mw-headline" id="Headline_2">Headline 2</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: Headline 2">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<p>More +</p> +<h3><span class="mw-headline" id="Smaller_headline">Smaller headline</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=3" title="Edit section: Smaller headline">edit</a><span class="mw-editsection-bracket">]</span></span></h3> +<p>Blah blah +</p> +!! end + +!! test +Section headings with TOC +!! wikitext +==Headline 1== +===Subheadline 1=== +=====Skipping a level===== +======Skipping a level====== + +==Headline 2== +Some text +===Another headline=== +!! html +<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div> +<ul> +<li class="toclevel-1 tocsection-1"><a href="#Headline_1"><span class="tocnumber">1</span> <span class="toctext">Headline 1</span></a> +<ul> +<li class="toclevel-2 tocsection-2"><a href="#Subheadline_1"><span class="tocnumber">1.1</span> <span class="toctext">Subheadline 1</span></a> +<ul> +<li class="toclevel-3 tocsection-3"><a href="#Skipping_a_level"><span class="tocnumber">1.1.1</span> <span class="toctext">Skipping a level</span></a> +<ul> +<li class="toclevel-4 tocsection-4"><a href="#Skipping_a_level_2"><span class="tocnumber">1.1.1.1</span> <span class="toctext">Skipping a level</span></a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +<li class="toclevel-1 tocsection-5"><a href="#Headline_2"><span class="tocnumber">2</span> <span class="toctext">Headline 2</span></a> +<ul> +<li class="toclevel-2 tocsection-6"><a href="#Another_headline"><span class="tocnumber">2.1</span> <span class="toctext">Another headline</span></a></li> +</ul> +</li> +</ul> +</div> + +<h2><span class="mw-headline" id="Headline_1">Headline 1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: Headline 1">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h3><span class="mw-headline" id="Subheadline_1">Subheadline 1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: Subheadline 1">edit</a><span class="mw-editsection-bracket">]</span></span></h3> +<h5><span class="mw-headline" id="Skipping_a_level">Skipping a level</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=3" title="Edit section: Skipping a level">edit</a><span class="mw-editsection-bracket">]</span></span></h5> +<h6><span class="mw-headline" id="Skipping_a_level_2">Skipping a level</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=4" title="Edit section: Skipping a level">edit</a><span class="mw-editsection-bracket">]</span></span></h6> +<h2><span class="mw-headline" id="Headline_2">Headline 2</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=5" title="Edit section: Headline 2">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<p>Some text +</p> +<h3><span class="mw-headline" id="Another_headline">Another headline</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=6" title="Edit section: Another headline">edit</a><span class="mw-editsection-bracket">]</span></span></h3> + +!! end + +!! test +TOC anchors don't collide +!! wikitext +__FORCETOC__ +==Headline 2== +==Headline== +==Headline 2== +==Headline== +!! html/php +<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div> +<ul> +<li class="toclevel-1 tocsection-1"><a href="#Headline_2"><span class="tocnumber">1</span> <span class="toctext">Headline 2</span></a></li> +<li class="toclevel-1 tocsection-2"><a href="#Headline"><span class="tocnumber">2</span> <span class="toctext">Headline</span></a></li> +<li class="toclevel-1 tocsection-3"><a href="#Headline_2_2"><span class="tocnumber">3</span> <span class="toctext">Headline 2</span></a></li> +<li class="toclevel-1 tocsection-4"><a href="#Headline_3"><span class="tocnumber">4</span> <span class="toctext">Headline</span></a></li> +</ul> +</div> + +<h2><span class="mw-headline" id="Headline_2">Headline 2</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: Headline 2">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h2><span class="mw-headline" id="Headline">Headline</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: Headline">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h2><span class="mw-headline" id="Headline_2_2">Headline 2</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=3" title="Edit section: Headline 2">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h2><span class="mw-headline" id="Headline_3">Headline</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=4" title="Edit section: Headline">edit</a><span class="mw-editsection-bracket">]</span></span></h2> + +!! end + +# perl -e 'print "="x$_," Level $_ heading","="x$_,"\n" for 1..10' +# Parsoid html2wt direction adds <nowiki> for level 7 and up. +!! test +Handling of sections up to level 6 and beyond +!! options +parsoid=wt2html +!! wikitext +=Level 1 Heading= +==Level 2 Heading== +===Level 3 Heading=== +====Level 4 Heading==== +=====Level 5 Heading===== +======Level 6 Heading====== +=======Level 7 Heading======= +========Level 8 Heading======== +=========Level 9 Heading========= +==========Level 10 Heading========== +!! html/php +<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div> +<ul> +<li class="toclevel-1 tocsection-1"><a href="#Level_1_Heading"><span class="tocnumber">1</span> <span class="toctext">Level 1 Heading</span></a> +<ul> +<li class="toclevel-2 tocsection-2"><a href="#Level_2_Heading"><span class="tocnumber">1.1</span> <span class="toctext">Level 2 Heading</span></a> +<ul> +<li class="toclevel-3 tocsection-3"><a href="#Level_3_Heading"><span class="tocnumber">1.1.1</span> <span class="toctext">Level 3 Heading</span></a> +<ul> +<li class="toclevel-4 tocsection-4"><a href="#Level_4_Heading"><span class="tocnumber">1.1.1.1</span> <span class="toctext">Level 4 Heading</span></a> +<ul> +<li class="toclevel-5 tocsection-5"><a href="#Level_5_Heading"><span class="tocnumber">1.1.1.1.1</span> <span class="toctext">Level 5 Heading</span></a> +<ul> +<li class="toclevel-6 tocsection-6"><a href="#Level_6_Heading"><span class="tocnumber">1.1.1.1.1.1</span> <span class="toctext">Level 6 Heading</span></a></li> +<li class="toclevel-6 tocsection-7"><a href="#.3DLevel_7_Heading.3D"><span class="tocnumber">1.1.1.1.1.2</span> <span class="toctext">=Level 7 Heading=</span></a></li> +<li class="toclevel-6 tocsection-8"><a href="#.3D.3DLevel_8_Heading.3D.3D"><span class="tocnumber">1.1.1.1.1.3</span> <span class="toctext">==Level 8 Heading==</span></a></li> +<li class="toclevel-6 tocsection-9"><a href="#.3D.3D.3DLevel_9_Heading.3D.3D.3D"><span class="tocnumber">1.1.1.1.1.4</span> <span class="toctext">===Level 9 Heading===</span></a></li> +<li class="toclevel-6 tocsection-10"><a href="#.3D.3D.3D.3DLevel_10_Heading.3D.3D.3D.3D"><span class="tocnumber">1.1.1.1.1.5</span> <span class="toctext">====Level 10 Heading====</span></a></li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +</ul> +</li> +</ul> +</div> + +<h1><span class="mw-headline" id="Level_1_Heading">Level 1 Heading</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: Level 1 Heading">edit</a><span class="mw-editsection-bracket">]</span></span></h1> +<h2><span class="mw-headline" id="Level_2_Heading">Level 2 Heading</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: Level 2 Heading">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h3><span class="mw-headline" id="Level_3_Heading">Level 3 Heading</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=3" title="Edit section: Level 3 Heading">edit</a><span class="mw-editsection-bracket">]</span></span></h3> +<h4><span class="mw-headline" id="Level_4_Heading">Level 4 Heading</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=4" title="Edit section: Level 4 Heading">edit</a><span class="mw-editsection-bracket">]</span></span></h4> +<h5><span class="mw-headline" id="Level_5_Heading">Level 5 Heading</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=5" title="Edit section: Level 5 Heading">edit</a><span class="mw-editsection-bracket">]</span></span></h5> +<h6><span class="mw-headline" id="Level_6_Heading">Level 6 Heading</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=6" title="Edit section: Level 6 Heading">edit</a><span class="mw-editsection-bracket">]</span></span></h6> +<h6><span class="mw-headline" id=".3DLevel_7_Heading.3D">=Level 7 Heading=</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=7" title="Edit section: =Level 7 Heading=">edit</a><span class="mw-editsection-bracket">]</span></span></h6> +<h6><span class="mw-headline" id=".3D.3DLevel_8_Heading.3D.3D">==Level 8 Heading==</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=8" title="Edit section: ==Level 8 Heading==">edit</a><span class="mw-editsection-bracket">]</span></span></h6> +<h6><span class="mw-headline" id=".3D.3D.3DLevel_9_Heading.3D.3D.3D">===Level 9 Heading===</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=9" title="Edit section: ===Level 9 Heading===">edit</a><span class="mw-editsection-bracket">]</span></span></h6> +<h6><span class="mw-headline" id=".3D.3D.3D.3DLevel_10_Heading.3D.3D.3D.3D">====Level 10 Heading====</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=10" title="Edit section: ====Level 10 Heading====">edit</a><span class="mw-editsection-bracket">]</span></span></h6> + +!! html/parsoid +<h1 id="Level_1_Heading" data-parsoid='{}'>Level 1 Heading</h1> +<h2 id="Level_2_Heading" data-parsoid='{}'>Level 2 Heading</h2> +<h3 id="Level_3_Heading" data-parsoid='{}'>Level 3 Heading</h3> +<h4 id="Level_4_Heading" data-parsoid='{}'>Level 4 Heading</h4> +<h5 id="Level_5_Heading" data-parsoid='{}'>Level 5 Heading</h5> +<h6 id="Level_6_Heading" data-parsoid='{}'>Level 6 Heading</h6> +<h6 id="=Level_7_Heading=" data-parsoid='{}'><span id=".3DLevel_7_Heading.3D" typeof="mw:FallbackId"></span>=Level 7 Heading=</h6> +<h6 id="==Level_8_Heading==" data-parsoid='{}'><span id=".3D.3DLevel_8_Heading.3D.3D" typeof="mw:FallbackId"></span>==Level 8 Heading==</h6> +<h6 id="===Level_9_Heading===" data-parsoid='{}'><span id=".3D.3D.3DLevel_9_Heading.3D.3D.3D" typeof="mw:FallbackId"></span>===Level 9 Heading===</h6> +<h6 id="====Level_10_Heading====" data-parsoid='{}'><span id=".3D.3D.3D.3DLevel_10_Heading.3D.3D.3D.3D" typeof="mw:FallbackId"></span>====Level 10 Heading====</h6> +!! end + +!! test +TOC regression (T11764) +!! wikitext +==title 1== +===title 1.1=== +====title 1.1.1==== +===title 1.2=== +==title 2== +===title 2.1=== +!! html +<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div> +<ul> +<li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a> +<ul> +<li class="toclevel-2 tocsection-2"><a href="#title_1.1"><span class="tocnumber">1.1</span> <span class="toctext">title 1.1</span></a> +<ul> +<li class="toclevel-3 tocsection-3"><a href="#title_1.1.1"><span class="tocnumber">1.1.1</span> <span class="toctext">title 1.1.1</span></a></li> +</ul> +</li> +<li class="toclevel-2 tocsection-4"><a href="#title_1.2"><span class="tocnumber">1.2</span> <span class="toctext">title 1.2</span></a></li> +</ul> +</li> +<li class="toclevel-1 tocsection-5"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a> +<ul> +<li class="toclevel-2 tocsection-6"><a href="#title_2.1"><span class="tocnumber">2.1</span> <span class="toctext">title 2.1</span></a></li> +</ul> +</li> +</ul> +</div> + +<h2><span class="mw-headline" id="title_1">title 1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: title 1">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h3><span class="mw-headline" id="title_1.1">title 1.1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: title 1.1">edit</a><span class="mw-editsection-bracket">]</span></span></h3> +<h4><span class="mw-headline" id="title_1.1.1">title 1.1.1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=3" title="Edit section: title 1.1.1">edit</a><span class="mw-editsection-bracket">]</span></span></h4> +<h3><span class="mw-headline" id="title_1.2">title 1.2</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=4" title="Edit section: title 1.2">edit</a><span class="mw-editsection-bracket">]</span></span></h3> +<h2><span class="mw-headline" id="title_2">title 2</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=5" title="Edit section: title 2">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h3><span class="mw-headline" id="title_2.1">title 2.1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=6" title="Edit section: title 2.1">edit</a><span class="mw-editsection-bracket">]</span></span></h3> + +!! end + +!! test +TOC for heading containing <span id="..."></span> (T96153) +!! wikitext +__FORCETOC__ +==<span id="old-anchor"></span>New title== +!! html/php +<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div> +<ul> +<li class="toclevel-1 tocsection-1"><a href="#New_title"><span class="tocnumber">1</span> <span class="toctext">New title</span></a></li> +</ul> +</div> + +<h2><span class="mw-headline" id="New_title"><span id="old-anchor"></span>New title</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: New title">edit</a><span class="mw-editsection-bracket">]</span></span></h2> + +!! end + +!! test +TOC with wgMaxTocLevel=3 (T8204) +!! options +wgMaxTocLevel=3 +!! wikitext +==title 1== +===title 1.1=== +====title 1.1.1==== +===title 1.2=== +==title 2== +===title 2.1=== +!! html +<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div> +<ul> +<li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a> +<ul> +<li class="toclevel-2 tocsection-2"><a href="#title_1.1"><span class="tocnumber">1.1</span> <span class="toctext">title 1.1</span></a></li> +<li class="toclevel-2 tocsection-4"><a href="#title_1.2"><span class="tocnumber">1.2</span> <span class="toctext">title 1.2</span></a></li> +</ul> +</li> +<li class="toclevel-1 tocsection-5"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a> +<ul> +<li class="toclevel-2 tocsection-6"><a href="#title_2.1"><span class="tocnumber">2.1</span> <span class="toctext">title 2.1</span></a></li> +</ul> +</li> +</ul> +</div> + +<h2><span class="mw-headline" id="title_1">title 1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: title 1">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h3><span class="mw-headline" id="title_1.1">title 1.1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: title 1.1">edit</a><span class="mw-editsection-bracket">]</span></span></h3> +<h4><span class="mw-headline" id="title_1.1.1">title 1.1.1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=3" title="Edit section: title 1.1.1">edit</a><span class="mw-editsection-bracket">]</span></span></h4> +<h3><span class="mw-headline" id="title_1.2">title 1.2</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=4" title="Edit section: title 1.2">edit</a><span class="mw-editsection-bracket">]</span></span></h3> +<h2><span class="mw-headline" id="title_2">title 2</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=5" title="Edit section: title 2">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h3><span class="mw-headline" id="title_2.1">title 2.1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=6" title="Edit section: title 2.1">edit</a><span class="mw-editsection-bracket">]</span></span></h3> + +!! end + +!! test +TOC with wgMaxTocLevel=3 and two level four headings (T8204) +!! options +wgMaxTocLevel=3 +!! wikitext +==Section 1== +===Section 1.1=== +====Section 1.1.1==== +====Section 1.1.1.1==== +==Section 2== +!! html +<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div> +<ul> +<li class="toclevel-1 tocsection-1"><a href="#Section_1"><span class="tocnumber">1</span> <span class="toctext">Section 1</span></a> +<ul> +<li class="toclevel-2 tocsection-2"><a href="#Section_1.1"><span class="tocnumber">1.1</span> <span class="toctext">Section 1.1</span></a></li> +</ul> +</li> +<li class="toclevel-1 tocsection-5"><a href="#Section_2"><span class="tocnumber">2</span> <span class="toctext">Section 2</span></a></li> +</ul> +</div> + +<h2><span class="mw-headline" id="Section_1">Section 1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: Section 1">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h3><span class="mw-headline" id="Section_1.1">Section 1.1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: Section 1.1">edit</a><span class="mw-editsection-bracket">]</span></span></h3> +<h4><span class="mw-headline" id="Section_1.1.1">Section 1.1.1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=3" title="Edit section: Section 1.1.1">edit</a><span class="mw-editsection-bracket">]</span></span></h4> +<h4><span class="mw-headline" id="Section_1.1.1.1">Section 1.1.1.1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=4" title="Edit section: Section 1.1.1.1">edit</a><span class="mw-editsection-bracket">]</span></span></h4> +<h2><span class="mw-headline" id="Section_2">Section 2</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=5" title="Edit section: Section 2">edit</a><span class="mw-editsection-bracket">]</span></span></h2> + +!! end + + +!! test +Resolving duplicate section names +!! wikitext +==Foo bar== +==Foo bar== +!! html +<h2><span class="mw-headline" id="Foo_bar">Foo bar</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: Foo bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h2><span class="mw-headline" id="Foo_bar_2">Foo bar</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: Foo bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2> + +!! end + +!! test +Resolving duplicate section names with differing case (T12721) +!! wikitext +==Foo bar== +==Foo Bar== +!! html +<h2><span class="mw-headline" id="Foo_bar">Foo bar</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: Foo bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h2><span class="mw-headline" id="Foo_Bar_2">Foo Bar</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: Foo Bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2> + +!! end + +!! article +Template:sections +!! text +===Section 1=== +==Section 2== +!! endarticle + +!! test +Template with sections, __NOTOC__ +!! wikitext +__NOTOC__ +==Section 0== +{{sections}} +==Section 4== +!! html +<h2><span class="mw-headline" id="Section_0">Section 0</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: Section 0">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h3><span class="mw-headline" id="Section_1">Section 1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Template:Sections&action=edit&section=T-1" title="Template:Sections">edit</a><span class="mw-editsection-bracket">]</span></span></h3> +<h2><span class="mw-headline" id="Section_2">Section 2</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Template:Sections&action=edit&section=T-2" title="Template:Sections">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h2><span class="mw-headline" id="Section_4">Section 4</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: Section 4">edit</a><span class="mw-editsection-bracket">]</span></span></h2> + +!! end + +!! test +__NOEDITSECTION__ keyword +!! wikitext +__NOEDITSECTION__ +==Section 1== +==Section 2== +!! html +<h2><span class="mw-headline" id="Section_1">Section 1</span></h2> +<h2><span class="mw-headline" id="Section_2">Section 2</span></h2> + +!! end + +!! test +Link inside a section heading +!! wikitext +==Section with a [[Main Page|link]] in it== +!! html +<h2><span class="mw-headline" id="Section_with_a_link_in_it">Section with a <a href="/wiki/Main_Page" title="Main Page">link</a> in it</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: Section with a link in it">edit</a><span class="mw-editsection-bracket">]</span></span></h2> + +!! end + +!! test +TOC regression (T14077) +!! wikitext +__TOC__ +==title 1== +===title 1.1=== +==title 2== +!! html +<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div> +<ul> +<li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a> +<ul> +<li class="toclevel-2 tocsection-2"><a href="#title_1.1"><span class="tocnumber">1.1</span> <span class="toctext">title 1.1</span></a></li> +</ul> +</li> +<li class="toclevel-1 tocsection-3"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a></li> +</ul> +</div> + +<h2><span class="mw-headline" id="title_1">title 1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: title 1">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h3><span class="mw-headline" id="title_1.1">title 1.1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: title 1.1">edit</a><span class="mw-editsection-bracket">]</span></span></h3> +<h2><span class="mw-headline" id="title_2">title 2</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=3" title="Edit section: title 2">edit</a><span class="mw-editsection-bracket">]</span></span></h2> + +!! end + +!! test +T3219 URL next to image (good) +!! wikitext +http://example.com [[File:Foobar.jpg]] +!! html/php +<p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> <a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a> +</p> +!! html/parsoid +<p><a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a> <figure-inline class="mw-default-size" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></figure-inline></p> +!!end + +# Parsoid doesn't wt2wt this cleanly because it adds <nowiki>s. +!! test +Short headings with trailing space should match behavior of Parser::doHeadings (T21910) +!! options +parsoid=wt2html,html2html +!! wikitext +=== +The line above must have a trailing space! +=== <!-- +--> <!-- --> +But just in case it doesn't... +!! html/php +<h1><span class="mw-headline" id=".3D">=</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: =">edit</a><span class="mw-editsection-bracket">]</span></span></h1> +<p>The line above must have a trailing space! +</p> +<h1><span class="mw-headline" id=".3D_2">=</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: =">edit</a><span class="mw-editsection-bracket">]</span></span></h1> +<p>But just in case it doesn't... +</p> +!! html/parsoid +<h1 id="="><span id=".3D" typeof="mw:FallbackId"></span>=</h1> +<p>The line above must have a trailing space!</p> +<h1 id="=_2"><span id=".3D_2" typeof="mw:FallbackId"></span>=</h1> <!-- +--> <!-- --> +<p>But just in case it doesn't...</p> +!! end + +!! test +Header with special characters (T27462) +!! wikitext +The tooltips shall not show entities to the user (ie. be double escaped) + +==text > text== +section 1 + +==text < text== +section 2 + +==text & text== +section 3 + +==text ' text== +section 4 + +==text " text== +section 5 +!! html/php +<p>The tooltips shall not show entities to the user (ie. be double escaped) +</p> +<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div> +<ul> +<li class="toclevel-1 tocsection-1"><a href="#text_.3E_text"><span class="tocnumber">1</span> <span class="toctext">text > text</span></a></li> +<li class="toclevel-1 tocsection-2"><a href="#text_.3C_text"><span class="tocnumber">2</span> <span class="toctext">text < text</span></a></li> +<li class="toclevel-1 tocsection-3"><a href="#text_.26_text"><span class="tocnumber">3</span> <span class="toctext">text & text</span></a></li> +<li class="toclevel-1 tocsection-4"><a href="#text_.27_text"><span class="tocnumber">4</span> <span class="toctext">text ' text</span></a></li> +<li class="toclevel-1 tocsection-5"><a href="#text_.22_text"><span class="tocnumber">5</span> <span class="toctext">text " text</span></a></li> +</ul> +</div> + +<h2><span class="mw-headline" id="text_.3E_text">text > text</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: text > text">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<p>section 1 +</p> +<h2><span class="mw-headline" id="text_.3C_text">text < text</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: text < text">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<p>section 2 +</p> +<h2><span class="mw-headline" id="text_.26_text">text & text</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=3" title="Edit section: text & text">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<p>section 3 +</p> +<h2><span class="mw-headline" id="text_.27_text">text ' text</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=4" title="Edit section: text ' text">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<p>section 4 +</p> +<h2><span class="mw-headline" id="text_.22_text">text " text</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=5" title="Edit section: text " text">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<p>section 5 +</p> +!! html/parsoid +<p>The tooltips shall not show entities to the user (ie. be double escaped)</p> + +<h2 id="text_>_text"><span id="text_.3E_text" typeof="mw:FallbackId"></span>text > text</h2> +<p>section 1</p> + +<h2 id="text_<_text"><span id="text_.3C_text" typeof="mw:FallbackId"></span>text < text</h2> +<p>section 2</p> + +<h2 id="text_&_text"><span id="text_.26_text" typeof="mw:FallbackId"></span>text & text</h2> +<p>section 3</p> + +<h2 id="text_'_text"><span id="text_.27_text" typeof="mw:FallbackId"></span>text ' text</h2> +<p>section 4</p> + +<h2 id='text_"_text'><span id="text_.22_text" typeof="mw:FallbackId"></span>text " text</h2> +<p>section 5</p> +!! end + +!! test +Header with space, plus and underscore as entity +!! wikitext +Id should not contain + for spaces + +==Space between Text== +section 1 + +==Space-Entity between Text== +section 2 + +==Plus+between+Text== +section 3 + +==Plus-Entity+between+Text== +section 4 + +==Underscore_between_Text== +section 5 + +==Underscore-Entity_between_Text== +section 6 + +[[#Space between Text]] +[[#Space-Entity between Text]] +[[#Plus+between+Text]] +[[#Plus-Entity+between+Text]] +[[#Underscore_between_Text]] +[[#Underscore-Entity_between_Text]] +!! html/php +<p>Id should not contain + for spaces +</p> +<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div> +<ul> +<li class="toclevel-1 tocsection-1"><a href="#Space_between_Text"><span class="tocnumber">1</span> <span class="toctext">Space between Text</span></a></li> +<li class="toclevel-1 tocsection-2"><a href="#Space-Entity_between_Text"><span class="tocnumber">2</span> <span class="toctext">Space-Entity between Text</span></a></li> +<li class="toclevel-1 tocsection-3"><a href="#Plus.2Bbetween.2BText"><span class="tocnumber">3</span> <span class="toctext">Plus+between+Text</span></a></li> +<li class="toclevel-1 tocsection-4"><a href="#Plus-Entity.2Bbetween.2BText"><span class="tocnumber">4</span> <span class="toctext">Plus-Entity+between+Text</span></a></li> +<li class="toclevel-1 tocsection-5"><a href="#Underscore_between_Text"><span class="tocnumber">5</span> <span class="toctext">Underscore_between_Text</span></a></li> +<li class="toclevel-1 tocsection-6"><a href="#Underscore-Entity_between_Text"><span class="tocnumber">6</span> <span class="toctext">Underscore-Entity_between_Text</span></a></li> +</ul> +</div> + +<h2><span class="mw-headline" id="Space_between_Text">Space between Text</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: Space between Text">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<p>section 1 +</p> +<h2><span class="mw-headline" id="Space-Entity_between_Text">Space-Entity between Text</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: Space-Entity between Text">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<p>section 2 +</p> +<h2><span class="mw-headline" id="Plus.2Bbetween.2BText">Plus+between+Text</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=3" title="Edit section: Plus+between+Text">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<p>section 3 +</p> +<h2><span class="mw-headline" id="Plus-Entity.2Bbetween.2BText">Plus-Entity+between+Text</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=4" title="Edit section: Plus-Entity+between+Text">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<p>section 4 +</p> +<h2><span class="mw-headline" id="Underscore_between_Text">Underscore_between_Text</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=5" title="Edit section: Underscore between Text">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<p>section 5 +</p> +<h2><span class="mw-headline" id="Underscore-Entity_between_Text">Underscore-Entity_between_Text</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=6" title="Edit section: Underscore-Entity_between_Text">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<p>section 6 +</p><p><a href="#Space_between_Text">#Space between Text</a> +<a href="#Space-Entity_between_Text">#Space-Entity between Text</a> +<a href="#Plus.2Bbetween.2BText">#Plus+between+Text</a> +<a href="#Plus-Entity.2Bbetween.2BText">#Plus-Entity+between+Text</a> +<a href="#Underscore_between_Text">#Underscore_between_Text</a> +<a href="#Underscore-Entity_between_Text">#Underscore-Entity_between_Text</a> +</p> +!! html/parsoid +<p>Id should not contain + for spaces</p> + +<h2 id="Space_between_Text">Space between Text</h2> +<p>section 1</p> + +<h2 id="Space-Entity_between_Text">Space-Entity<span typeof="mw:Entity" data-parsoid='{"src":"&#32;","srcContent":" "}'> </span>between<span typeof="mw:Entity" data-parsoid='{"src":"&#32;","srcContent":" "}'> </span>Text</h2> +<p>section 2</p> + +<h2 id="Plus+between+Text"><span id="Plus.2Bbetween.2BText" typeof="mw:FallbackId"></span>Plus+between+Text</h2> +<p>section 3</p> + +<h2 id="Plus-Entity+between+Text"><span id="Plus-Entity.2Bbetween.2BText" typeof="mw:FallbackId"></span>Plus-Entity<span typeof="mw:Entity" data-parsoid='{"src":"&#43;","srcContent":"+"}'>+</span>between<span typeof="mw:Entity" data-parsoid='{"src":"&#43;","srcContent":"+"}'>+</span>Text</h2> +<p>section 4</p> + +<h2 id="Underscore_between_Text">Underscore_between_Text</h2> +<p>section 5</p> + +<h2 id="Underscore-Entity_between_Text">Underscore-Entity<span typeof="mw:Entity" data-parsoid='{"src":"&#95;","srcContent":"_"}'>_</span>between<span typeof="mw:Entity" data-parsoid='{"src":"&#95;","srcContent":"_"}'>_</span>Text</h2> +<p>section 6</p> + +<p><a rel="mw:WikiLink" href="./Main_Page#Space_between_Text" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#Space_between_Text"},"sa":{"href":"#Space between Text"}}'>#Space between Text</a> +<a rel="mw:WikiLink" href="./Main_Page#Space-Entity_between_Text" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#Space-Entity_between_Text"},"sa":{"href":"#Space-Entity&#32;between&#32;Text"}}'>#Space-Entity between Text</a> +<a rel="mw:WikiLink" href="./Main_Page#Plus+between+Text" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#Plus+between+Text"},"sa":{"href":"#Plus+between+Text"}}'>#Plus+between+Text</a> +<a rel="mw:WikiLink" href="./Main_Page#Plus-Entity+between+Text" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#Plus-Entity+between+Text"},"sa":{"href":"#Plus-Entity&#43;between&#43;Text"}}'>#Plus-Entity+between+Text</a> +<a rel="mw:WikiLink" href="./Main_Page#Underscore_between_Text" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#Underscore_between_Text"},"sa":{"href":"#Underscore_between_Text"}}'>#Underscore_between_Text</a> +<a rel="mw:WikiLink" href="./Main_Page#Underscore-Entity_between_Text" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#Underscore-Entity_between_Text"},"sa":{"href":"#Underscore-Entity&#95;between&#95;Text"}}'>#Underscore-Entity_between_Text</a></p> +!! end + +# Parsoid html2wt disabled because it adds padding spaces around = +!! test +Headers with excess '=' characters +(Are similar tests necessary beyond the 1st level?) +!! options +parsoid=wt2html,wt2wt,html2html +!! wikitext +=foo== +==foo= +=''italic'' heading== +==''italic'' heading= +!! html/php +<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div> +<ul> +<li class="toclevel-1 tocsection-1"><a href="#foo.3D"><span class="tocnumber">1</span> <span class="toctext">foo=</span></a></li> +<li class="toclevel-1 tocsection-2"><a href="#.3Dfoo"><span class="tocnumber">2</span> <span class="toctext">=foo</span></a></li> +<li class="toclevel-1 tocsection-3"><a href="#italic_heading.3D"><span class="tocnumber">3</span> <span class="toctext"><i>italic</i> heading=</span></a></li> +<li class="toclevel-1 tocsection-4"><a href="#.3Ditalic_heading"><span class="tocnumber">4</span> <span class="toctext">=<i>italic</i> heading</span></a></li> +</ul> +</div> + +<h1><span class="mw-headline" id="foo.3D">foo=</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: foo=">edit</a><span class="mw-editsection-bracket">]</span></span></h1> +<h1><span class="mw-headline" id=".3Dfoo">=foo</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: =foo">edit</a><span class="mw-editsection-bracket">]</span></span></h1> +<h1><span class="mw-headline" id="italic_heading.3D"><i>italic</i> heading=</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=3" title="Edit section: italic heading=">edit</a><span class="mw-editsection-bracket">]</span></span></h1> +<h1><span class="mw-headline" id=".3Ditalic_heading">=<i>italic</i> heading</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=4" title="Edit section: =italic heading">edit</a><span class="mw-editsection-bracket">]</span></span></h1> + +!! html/parsoid +<h1 id="foo="><span id="foo.3D" typeof="mw:FallbackId"></span>foo=</h1> +<h1 id="=foo"><span id=".3Dfoo" typeof="mw:FallbackId"></span>=foo</h1> +<h1 id="italic_heading="><span id="italic_heading.3D" typeof="mw:FallbackId"></span><i>italic</i> heading=</h1> +<h1 id="=italic_heading"><span id=".3Ditalic_heading" typeof="mw:FallbackId"></span>=<i>italic</i> heading</h1> +!! end + +!! test +HTML headers vs TOC (T25393) +(__NOEDITSECTION__ for clearer output, doesn't matter here) +!! wikitext +<h1>Header 1</h1> +==Header 1.1== +==Header 1.2== + +<h1>Header 2 +</h1> +==Header 2.1== +==Header 2.2== +__NOEDITSECTION__ +!! html/php +<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div> +<ul> +<li class="toclevel-1"><a href="#Header_1"><span class="tocnumber">1</span> <span class="toctext">Header 1</span></a> +<ul> +<li class="toclevel-2 tocsection-1"><a href="#Header_1.1"><span class="tocnumber">1.1</span> <span class="toctext">Header 1.1</span></a></li> +<li class="toclevel-2 tocsection-2"><a href="#Header_1.2"><span class="tocnumber">1.2</span> <span class="toctext">Header 1.2</span></a></li> +</ul> +</li> +<li class="toclevel-1"><a href="#Header_2"><span class="tocnumber">2</span> <span class="toctext">Header 2</span></a> +<ul> +<li class="toclevel-2 tocsection-3"><a href="#Header_2.1"><span class="tocnumber">2.1</span> <span class="toctext">Header 2.1</span></a></li> +<li class="toclevel-2 tocsection-4"><a href="#Header_2.2"><span class="tocnumber">2.2</span> <span class="toctext">Header 2.2</span></a></li> +</ul> +</li> +</ul> +</div> + +<h1><span class="mw-headline" id="Header_1">Header 1</span></h1> +<h2><span class="mw-headline" id="Header_1.1">Header 1.1</span></h2> +<h2><span class="mw-headline" id="Header_1.2">Header 1.2</span></h2> +<h1><span class="mw-headline" id="Header_2">Header 2 +</span></h1> +<h2><span class="mw-headline" id="Header_2.1">Header 2.1</span></h2> +<h2><span class="mw-headline" id="Header_2.2">Header 2.2</span></h2> + +!! html/parsoid +<h1 id="Header_1" data-parsoid='{"stx":"html"}'>Header 1</h1> +<h2 id="Header_1.1" data-parsoid='{}'>Header 1.1</h2> +<h2 id="Header_1.2" data-parsoid='{}'>Header 1.2</h2> + +<h1 id="Header_2" data-parsoid='{"stx":"html"}'>Header 2 +</h1> +<h2 id="Header_2.1" data-parsoid='{}'>Header 2.1</h2> +<h2 id="Header_2.2" data-parsoid='{}'>Header 2.2</h2> +<meta property="mw:PageProp/noeditsection"/> +!! end + +!! test +Single-line or multiline-comments can follow headings +!! options +parsoid=wt2html,wt2wt +!! wikitext +==foo==<!----> +==bar==<!--c1--> +==baz==<!-- +c2 +c3--> +!! html/php +<h2><span class="mw-headline" id="foo">foo</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: foo">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h2><span class="mw-headline" id="bar">bar</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h2><span class="mw-headline" id="baz">baz</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=3" title="Edit section: baz">edit</a><span class="mw-editsection-bracket">]</span></span></h2> + +!! html/parsoid +<h2 id="foo">foo</h2><!----> +<h2 id="bar">bar</h2><!--c1--> +<h2 id="baz">baz</h2><!-- +c2 +c3--> +!! end + +!! test +T3219 URL next to image (broken) +!! wikitext +http://example.com[[File:Foobar.jpg]] +!! html/php +<p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a> +</p> +!! html/parsoid +<p><a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a><figure-inline class="mw-default-size" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></figure-inline></p> +!!end + +!! test +T3186 news: in the middle of text +!! wikitext +http://en.wikinews.org/wiki/Wikinews:Workplace +!! html +<p><a rel="nofollow" class="external free" href="http://en.wikinews.org/wiki/Wikinews:Workplace">http://en.wikinews.org/wiki/Wikinews:Workplace</a> +</p> +!!end + + +!! test +Namespaced link must have a title +!! wikitext +[[Project:]] +!! html +<p>[[Project:]] +</p> +!!end + +!! test +Namespaced link must have a title (bad fragment version) +!! wikitext +[[Project:#fragment]] +!! html +<p>[[Project:#fragment]] +</p> +!!end + + +### +### HTML tags and HTML attributes +### + +!! test +div with no attributes +!! wikitext +<div>HTML rocks</div> +!! html +<div>HTML rocks</div> + +!! end + +!! test +div with double-quoted attribute +!! wikitext +<div id="rock">HTML rocks</div> +!! html +<div id="rock">HTML rocks</div> + +!! end + +!! test +div with single-quoted attribute +!! wikitext +<div id='rock'>HTML rocks</div> +!! html +<div id="rock">HTML rocks</div> + +!! end + +!! test +div with unquoted attribute +!! wikitext +<div id=rock>HTML rocks</div> +!! html +<div id="rock">HTML rocks</div> + +!! end + +!! test +div with illegal double attributes +!! wikitext +<div id="a" id="b">HTML rocks</div> +!! html +<div id="b">HTML rocks</div> + +!!end + +!! test +div with empty attribute value, space before equals +!! options +parsoid=wt2html,html2html +!! wikitext +<div class =>HTML rocks</div> +!! html/php +<div class="">HTML rocks</div> + +!! html/parsoid +<div class="" data-parsoid='{"stx":"html"}'>HTML rocks</div> +!! end + +!! test +div with multiple empty attribute values +!! config +wgFragmentMode=[ 'html5', 'legacy' ] +!! options +parsoid=wt2html,html2html +!! wikitext +<div id= title=>HTML rocks</div> +!! html/php +<div id="title=">HTML rocks</div> + +!! html/parsoid +<div id="title=" data-parsoid='{"stx":"html"}'>HTML rocks</div> +!! end + +# FIXME Parsoid doesn't actually match PHP here. +# Probably we should use the synthetic <foo /> or <indicator> +# extensions for this test, which are enabled when running parser tests. +!! test +Extension tag in attribute value +!! wikitext +<span title="<translate>123</translate>">ok</span> +!! html/php+disabled +<p><span title="<translate>123</translate>">ok</span> +</p> +!! html/parsoid +<p><span title="123" about="#mwt4" typeof="mw:ExpandedAttrs" data-parsoid='{"stx":"html","a":{"title":"123"},"sa":{"title":"<translate>123</translate>"}}' data-mw='{"attribs":[[{"txt":"title"},{"html":"<translate typeof=\"mw:Extension/translate\" about=\"#mwt3\" data-parsoid='{\"dsr\":[13,39,2,2]}' data-mw='{\"name\":\"translate\",\"attrs\":{},\"body\":{\"extsrc\":\"123\"}}'>123</translate>"}]]}'>ok</span></p> +!! end + +!! test +table with multiple empty attribute values +!! options +parsoid=wt2html,html2html +!! wikitext +{| title= id= +|hi +|} +!! html/php +<table title="id="> +<tr> +<td>hi +</td></tr></table> + +!! html/parsoid +<table title="id="> +<tbody><tr><td>hi</td></tr> +</tbody></table> +!! end + +!! test +div with braces in attribute value +!! wikitext +<div title="{}">Foo</div> +!! html/php +<div title="{}">Foo</div> + +!! html/parsoid +<div title="{}">Foo</div> +!! end + +!! test +div with empty attribute value, no space before equals +!! options +parsoid=wt2html,html2html +!! wikitext +<div class=>HTML rocks</div> +!! html/php +<div class="">HTML rocks</div> + +!! html/parsoid +<div class="">HTML rocks</div> +!! end + +!! test +HTML multiple attributes correction +!! wikitext +<p class="error" class="awesome">Awesome!</p> +!! html +<p class="awesome">Awesome!</p> + +!!end + +!! test +Table multiple attributes correction +!! wikitext +{| +!+ class="error" class="awesome"|status +|} +!! html +<table> +<tr> +<th class="awesome">status +</th></tr></table> + +!!end + +!! test +DIV IN UPPERCASE +!! wikitext +<DIV ID="x">HTML ROCKS</DIV> +!! html +<div id="x">HTML ROCKS</div> + +!!end + +!! test +Non-ASCII pseudo-tags are rendered as text +!! wikitext +<khyô> +!! html +<p><khyô> +</p> +!! end + +!! test +Pseudo-tag with URL 'name' renders as url link +!! wikitext +<http://example.com/> +!! html +<p><<a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a>> +</p> +!! end + +!! test +text with amp in the middle of nowhere +!! wikitext +Remember AT&T? +!! html +<p>Remember AT&T? +</p> +!! end + +!! test +text with character entity: eacute +!! wikitext +I always thought é was a cute letter. +!! html+tidy +<p>I always thought é was a cute letter. +</p> +!! end + +!! test +text with entity-escaped character entity-like string: eacute +!! wikitext +I always thought &eacute; was a cute letter. +!! html +<p>I always thought &eacute; was a cute letter. +</p> +!! end + +!! test +text with undefined character entity: xacute +!! wikitext +I always thought &xacute; was a cute letter. +!! html +<p>I always thought &xacute; was a cute letter. +</p> +!! end + +!! test +HTML5 tags +!! wikitext +<data value="5">five</data> +<time datetime="2000-01-01T00:00Z">The new millenium started</time> +<mark>This highlighted text</mark> +!! html +<p><data value="5">five</data> +<time datetime="2000-01-01T00:00Z">The new millenium started</time> +<mark>This highlighted text</mark> +</p> +!! end + +!! test +HTML tag with leading space is parsed as text +!! wikitext +< div>foo< /div> +!! html +<p>< div>foo< /div> +</p> +!! end + +## Don't expect Parsoid and PHP to match, since PHP isn't exactly following +## the HTML5 parsing spec. +!! test +Element with broken attribute syntax +!! options +parsoid=wt2html +!! wikitext +<div style=" style="123">hi</div> +<div =>ho</div> +!! html/php +<div style="123">hi</div> +<div>ho</div> + +!! html/parsoid +<div style=" style=" data-parsoid='{"stx":"html","a":{"123\"":null},"sa":{"123\"":""}}'>hi</div> +<div data-parsoid='{"stx":"html","a":{"=":null},"sa":{"=":""}}'>ho</div> +!! end + +### +### Nesting tests (see T43545, T52604, T53081) +### + +# This test case is fixed in Parsoid by domino 1.0.12. (T52604) +# Note that html2wt is considerably more difficult if we use <b> in +# the test case, instead of <small> +!! test +Ensure that HTML adoption agency algorithm is properly implemented. +!! wikitext +<small>X<small>Y</small>Z</small> +!! html +<p><small>X<small>Y</small>Z</small> +</p> +!! end + +# This was T43545 in the PHP parser. +!! test +Nesting of <kbd> +!! wikitext +<kbd>X<kbd>Y</kbd>Z</kbd> +!! html+tidy +<p><kbd>X<kbd>Y</kbd>Z</kbd> +</p> +!! end + +# The following cases were T53081 in the PHP parser. +# Note that there are some other nestable tags (b, i, etc) which are +# not covered; see T53081 for discussion. + +!! test +Nesting of <em> +!! wikitext +<em>X<em>Y</em>Z</em> +!! html+tidy +<p><em>X<em>Y</em>Z</em> +</p> +!! end + +!! test +Nesting of <strong> +!! wikitext +<strong>X<strong>Y</strong>Z</strong> +!! html+tidy +<p><strong>X<strong>Y</strong>Z</strong> +</p> +!! end + +!! test +Nesting of <q> +!! wikitext +<q>X<q>Y</q>Z</q> +!! html+tidy +<p><q>X<q>Y</q>Z</q> +</p> +!! end + +!! test +Nesting of <ruby> +!! wikitext +<ruby>X<ruby>Y</ruby>Z</ruby> +!! html +<p><ruby>X<ruby>Y</ruby>Z</ruby> +</p> +!! end + +!! test +Nesting of <bdo> +!! wikitext +<bdo>X<bdo>Y</bdo>Z</bdo> +!! html +<p><bdo>X<bdo>Y</bdo>Z</bdo> +</p> +!! end + + +### +### Media links +### + +!! test +Media link +!! wikitext +[[Media:Foobar.jpg]] +[[Media:Video.ogv]] +[[:Media:Video.ogv]] +!! html/php +<p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Media:Foobar.jpg</a> +<a href="http://example.com/images/0/00/Video.ogv" class="internal" title="Video.ogv">Media:Video.ogv</a> +<a href="http://example.com/images/0/00/Video.ogv" class="internal" title="Video.ogv">Media:Video.ogv</a> +</p> +!! html/parsoid +<p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg">Media:Foobar.jpg</a> +<a rel="mw:MediaLink" href="//example.com/images/0/00/Video.ogv" title="Video.ogv">Media:Video.ogv</a> +<a rel="mw:MediaLink" href="//example.com/images/0/00/Video.ogv" title="Video.ogv" data-parsoid='{"a":{"namespace":"Media"},"sa":{"namespace":":Media"}}'>Media:Video.ogv</a></p> +!! end + +!! test +Media link with text +!! wikitext +[[Media:Foobar.jpg|A neat file to look at]] +!! html/php +<p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">A neat file to look at</a> +</p> +!! html/parsoid +<p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg">A neat file to look at</a></p> +!! end + +# FIXME: this is still bad HTML tag nesting +# FIXME: doBlockLevels won't wrap this in a paragraph because it contains a div +# Parsoid & Remex fix the p-wrapping since they operate on the DOM. +!! test +Media link with nasty text +!! wikitext +[[Media:Foobar.jpg|Safe Link<div style=display:none>" onmouseover="alert(document.cookie)" onfoo="</div>]] +!! html/php +<a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Safe Link<div style="display:none">" onmouseover="alert(document.cookie)" onfoo="</div></a> + +!! html/php+tidy +<p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Safe Link</a></p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg"><div style="display:none">" onmouseover="alert(document.cookie)" onfoo="</div></a> +!! html/parsoid +<p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg" data-parsoid='{"autoInsertedEnd":true}'>Safe Link</a></p><div style="display:none" data-parsoid='{"stx":"html"}'><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg" data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'>" onmouseover="alert(document.cookie)" onfoo="</a></div> + +!! end + +!! test +Media link to nonexistent file (T3702) +!! wikitext +[[Media:No such.jpg]] +[[Media:No_such file.jpg]] +!! html/php +<p><a href="/index.php?title=Special:Upload&wpDestFile=No_such.jpg" class="new" title="No such.jpg">Media:No such.jpg</a> +<a href="/index.php?title=Special:Upload&wpDestFile=No_such_file.jpg" class="new" title="No such file.jpg">Media:No_such file.jpg</a> +</p> +!! html/parsoid +<p><a rel="mw:MediaLink" href="./Special:FilePath/No_such.jpg" title="No such.jpg" typeof="mw:Error" data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}]}' data-parsoid='{"a":{"fileName":"No_such.jpg"},"sa":{"fileName":"No such.jpg"}}'>Media:No such.jpg</a> +<a rel="mw:MediaLink" href="./Special:FilePath/No_such_file.jpg" title="No such file.jpg" typeof="mw:Error" data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}]}' data-parsoid='{"a":{"fileName":"No_such_file.jpg"},"sa":{"fileName":"No_such file.jpg"}}'>Media:No_such file.jpg</a></p> +!! end + +!! test +Image link to nonexistent file (T3850 - good) +!! wikitext +[[File:No_such.jpg]] +!! html/php +<p><a href="/index.php?title=Special:Upload&wpDestFile=No_such.jpg" class="new" title="File:No such.jpg">File:No such.jpg</a> +</p> +!! html/parsoid +<p><figure-inline class="mw-default-size" typeof="mw:Error mw:Image" data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}]}'><a href="./File:No_such.jpg"><img resource="./File:No_such.jpg" src="./Special:FilePath/No_such.jpg" height="220" width="220"/></a></figure-inline></p> +!! end + +!! test +:Image link to nonexistent file (T3850 - bad) +!! wikitext +[[:Image:No such.jpg]] +!! html/php +<p><a href="/index.php?title=File:No_such.jpg&action=edit&redlink=1" class="new" title="File:No such.jpg (page does not exist)">Image:No such.jpg</a> +</p> +!! html/parsoid +<p><a rel="mw:WikiLink" href="./File:No_such.jpg" title="File:No such.jpg">Image:No such.jpg</a></p> +!! end + +!! test +Character reference normalization in link text (T3938) +!! wikitext +[[Main Page|this&that]] +!! html +<p><a href="/wiki/Main_Page" title="Main Page">this&that</a> +</p> +!!end + +!! article +אַ +!! text +Test for unicode normalization + +The page's name is U+05d0 U+05b7, with non-canonical form U+FB2E +!! endarticle + +!! test +(T21451) Links should refer to the normalized form. +!! wikitext +[[אַ]] +[[אַ]] +[[אַ]] +[[אַ]] +[[אַ]] +!! html +<p><a href="/wiki/%D7%90%D6%B7" title="אַ">אַ</a> +<a href="/wiki/%D7%90%D6%B7" title="אַ">אַ</a> +<a href="/wiki/%D7%90%D6%B7" title="אַ">אַ</a> +<a href="/wiki/%D7%90%D6%B7" title="אַ">אַ</a> +<a href="/wiki/%D7%90%D6%B7" title="אַ">אַ</a> +</p> +!! end + +!! test +Empty attribute crash test (T4067) +!! wikitext +<font color="">foo</font> +!! html +<p><font color="">foo</font> +</p> +!! end + +!! test +Empty attribute crash test single-quotes (T4067) +!! wikitext +<font color=''>foo</font> +!! html +<p><font color="">foo</font> +</p> +!! end + +!! test +Attribute test: equals, then nothing +!! options +parsoid=wt2html,html2html +!! wikitext +<font color=>foo</font> +!! html/php +<p><font color="">foo</font> +</p> +!! html/parsoid +<p><font color="" data-parsoid='{"stx":"html"}'>foo</font></p> +!! end + +!! test +Attribute test: unquoted value +!! options +parsoid=wt2html,html2html +!! wikitext +<font color=x>foo</font> +!! html/php +<p><font color="x">foo</font> +</p> +!! html/parsoid +<p><font color="x" data-parsoid='{"stx":"html"}'>foo</font></p> +!! end + +!! test +Attribute test: unquoted but illegal value (hash) +!! wikitext +<font color=#x>foo</font> +!! html +<p><font color="#x">foo</font> +</p> +!! end + +# Parsoid does not serialize to empty attribute syntax, +# so wt2wt and html2wt cases are skipped +!! test +Attribute test: no value (T54330) +!! options +parsoid=wt2html,html2html +!! wikitext +<font color>foo</font> +!! html/php +<p><font color="">foo</font> +</p> +!! html/parsoid +<p><font color="">foo</font></p> +!! end + +!! test +T4095: link with three closing brackets +!! wikitext +[[Main Page]]] +!! html/php +<p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>] +</p> +!! html/parsoid +<p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a>]</p> +!! end + +!! test +T4095: link with pipe and three closing brackets +!! wikitext +[[Main Page|link]]] +!! html/php +<p><a href="/wiki/Main_Page" title="Main Page">link</a>] +</p> +!! html/parsoid +<p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">link</a>]</p> +!! end + +!! test +T4095: link with pipe and three closing brackets, version 2 +!! wikitext +[[Main Page|[http://example.com/]]] +!! html/php +<p><a href="/wiki/Main_Page" title="Main Page">[http://example.com/]</a> +</p> +!! html/parsoid +<p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">[http://example.com/]</a></p> +!! end + + +### +### Safety +### + +!! article +Template:Dangerous attribute +!! text +" onmouseover="alert(document.cookie) +!! endarticle + +!! article +Template:Dangerous style attribute +!! text +border-size: expression(alert(document.cookie)) +!! endarticle + +!! article +Template:Div style +!! text +<div style="float: right; {{{1}}}">Magic div</div> +!! endarticle + +!! test +T4304: HTML attribute safety (safe template; regression T4309) +!! wikitext +<div title="{{test}}"></div> +!! html/php +<div title="This is a test template"></div> + +!! html/parsoid +<div title="This is a test template" about="#mwt2" typeof="mw:ExpandedAttrs" data-parsoid='{"stx":"html","a":{"title":"This is a test template"},"sa":{"title":"{{test}}"}}' data-mw='{"attribs":[[{"txt":"title"},{"html":"<span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid='{\"pi\":[[]],\"dsr\":[12,20,null,null]}' data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"test\",\"href\":\"./Template:Test\"},\"params\":{},\"i\":0}}]}'>This is a test template</span>"}]]}'></div> +!! end + +# Parsoid has enough context to handle this case +!! test +T4304: HTML attribute safety (dangerous template; 2309) +!! wikitext +<div title="{{dangerous attribute}}"></div> +!! html/php +<div title=""></div> + +!! html/parsoid +<div title='" onmouseover="alert(document.cookie)' about="#mwt2" typeof="mw:ExpandedAttrs" data-parsoid='{"stx":"html","a":{"title":"\" onmouseover=\"alert(document.cookie)"},"sa":{"title":"{{dangerous attribute}}"}}' data-mw='{"attribs":[[{"txt":"title"},{"html":"<span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid='{\"pi\":[[]],\"dsr\":[12,35,null,null]}' data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"dangerous attribute\",\"href\":\"./Template:Dangerous_attribute\"},\"params\":{},\"i\":0}}]}'>\" onmouseover=\"alert(document.cookie)</span>"}]]}'></div> +!! end + +!! test +T4304: HTML attribute safety (dangerous style template; 2309) +!! wikitext +<div style="{{dangerous style attribute}}"></div> +!! html/php +<div style="/* insecure input */"></div> + +!! html/parsoid +<div style="/* insecure input */" about="#mwt2" typeof="mw:ExpandedAttrs" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"{{dangerous style attribute}}"}}' data-mw='{"attribs":[[{"txt":"style"},{"html":"<span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid='{\"pi\":[[]],\"dsr\":[12,41,null,null]}' data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"dangerous style attribute\",\"href\":\"./Template:Dangerous_style_attribute\"},\"params\":{},\"i\":0}}]}'>border-size: expression(alert(document.cookie))</span>"}]]}'></div> +!! end + +!! test +T4304: HTML attribute safety (safe parameter; 2309) +!! wikitext +{{div style|width: 200px}} +!! html/php +<div style="float: right; width: 200px">Magic div</div> + +!! html/parsoid +<div style="float: right; width: 200px" about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"stx":"html","a":{"style":"float: right; width: 200px"},"sa":{"style":"float: right; {{{1}}}"},"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"div style","href":"./Template:Div_style"},"params":{"1":{"wt":"width: 200px"}},"i":0}}]}'>Magic div</div> +!! end + +!! test +T4304: HTML attribute safety (unsafe parameter; 2309) +!! wikitext +{{div style|width: expression(alert(document.cookie))}} +!! html/php +<div style="/* insecure input */">Magic div</div> + +!! html/parsoid +<div style="/* insecure input */" about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"float: right; {{{1}}}"},"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"div style","href":"./Template:Div_style"},"params":{"1":{"wt":"width: expression(alert(document.cookie))"}},"i":0}}]}'>Magic div</div> +!! end + +## Parsoid output here differs; needs investigation. +!! test +T4304: HTML attribute safety (unsafe breakout parameter; 2309) +!! wikitext +{{div style|"><script>alert(document.cookie)</script>}} +!! html +<div style="float: right;"><script>alert(document.cookie)</script>">Magic div</div> + +!! end + +## Parsoid output here differs; needs investigation. +!! test +T4304: HTML attribute safety (unsafe breakout parameter 2; 2309) +!! wikitext +{{div style|" ><script>alert(document.cookie)</script>}} +!! html +<div style="float: right;"><script>alert(document.cookie)</script>">Magic div</div> + +!! end + +!! test +T4304: HTML attribute safety (link) +!! wikitext +<div title="[[Main Page]]"></div> +!! html/php +<div title="[[Main Page]]"></div> + +!! html/parsoid +<div title="[[Main Page]]"></div> +!! end + +!! test +T4304: HTML attribute safety (italics) +!! wikitext +<div title="''foobar''"></div> +!! html +<div title="''foobar''"></div> + +!! end + +!! test +T4304: HTML attribute safety (bold) +!! wikitext +<div title="'''foobar'''"></div> +!! html +<div title="'''foobar'''"></div> + +!! end + +!! test +T4304: HTML attribute safety (ISBN) +!! wikitext +<div title="ISBN 1234567890"></div> +!! html +<div title="ISBN 1234567890"></div> + +!! end + +!! test +T4304: HTML attribute safety (RFC) +!! wikitext +<div title="RFC 1234"></div> +!! html +<div title="RFC 1234"></div> + +!! end + +!! test +T4304: HTML attribute safety (PMID) +!! wikitext +<div title="PMID 1234567890"></div> +!! html +<div title="PMID 1234567890"></div> + +!! end + +!! test +T4304: HTML attribute safety (web link) +!! wikitext +<div title="http://example.com/"></div> +!! html +<div title="http://example.com/"></div> + +!! end + +!! test +T4304: HTML attribute safety (named web link) +!! wikitext +<div title="[http://example.com/ link]"></div> +!! html/php +<div title="[http://example.com/ link]"></div> + +!! html/parsoid +<div title="[http://example.com/ link]"></div> +!! end + +!! test +T5244: HTML attribute safety (extension; safe) +!! wikitext +<div style="<nowiki>background:blue</nowiki>"></div> +!! html/php +<div style="background:blue"></div> + +!! html/parsoid +<div style="background:blue" data-parsoid='{"stx":"html","a":{"style":"background:blue"},"sa":{"style":"<nowiki>background:blue</nowiki>"}}'></div> +!! end + +!! test +T5244: HTML attribute safety (extension; unsafe) +!! wikitext +<div style="<nowiki>border-left:expression(alert(document.cookie))</nowiki>"></div> +!! html/php +<div style="/* insecure input */"></div> + +!! html/parsoid +<div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"<nowiki>border-left:expression(alert(document.cookie))</nowiki>"}}'></div> +!! end + +# More MSIE fun discovered by Tom Gilder + +!! test +MSIE CSS safety test: spurious slash +!! wikitext +<div style="background-image:u\rl(javascript:alert('boo'))">evil</div> +!! html/php +<div style="/* insecure input */">evil</div> + +!! html/parsoid +<div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:u\\rl(javascript:alert('boo'))"}}'>evil</div> +!! end + +!! test +MSIE CSS safety test: hex code +!! wikitext +<div style="background-image:u\72l(javascript:alert('boo'))">evil</div> +!! html/php +<div style="/* insecure input */">evil</div> + +!! html/parsoid +<div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:u\\72l(javascript:alert('boo'))"}}'>evil</div> +!! end + +!! test +MSIE CSS safety test: comment in url +!! wikitext +<div style="background-image:u/**/rl(javascript:alert('boo'))">evil</div> +!! html/php +<div style="background-image:u rl(javascript:alert('boo'))">evil</div> + +!! html/parsoid +<div style="background-image:u rl(javascript:alert('boo'))" data-parsoid='{"stx":"html","a":{"style":"background-image:u rl(javascript:alert('boo'))"},"sa":{"style":"background-image:u/**/rl(javascript:alert('boo'))"}}'>evil</div> +!! end + +!! test +MSIE CSS safety test: comment in expression +!! wikitext +<div style="background-image:expres/**/sion(alert('boo4'))">evil4</div> +!! html/php +<div style="background-image:expres sion(alert('boo4'))">evil4</div> + +!! html/parsoid +<div style="background-image:expres sion(alert('boo4'))" data-parsoid='{"stx":"html","a":{"style":"background-image:expres sion(alert('boo4'))"},"sa":{"style":"background-image:expres/**/sion(alert('boo4'))"}}'>evil4</div> +!! end + +!! test +CSS safety test (all browsers): vertical tab (T57332 / CVE-2013-4567) +!! wikitext +<p style="font-size: 100px; background-image:url\b(https://www.google.com/images/srpr/logo6w.png)">A</p> +!! html/php +<p style="/* invalid control char */">A</p> + +!! html/parsoid +<p style="/* invalid control char */" data-parsoid='{"stx":"html","a":{"style":"/* invalid control char */"},"sa":{"style":"font-size: 100px; background-image:url\\b(https://www.google.com/images/srpr/logo6w.png)"}}'>A</p> +!! end + +!! test +MSIE 6 CSS safety test: Fullwidth (T57332) +!! wikitext +<p style="font-size: 100px; color: expression((title='XSSed'),'red')">A</p> +<div style="top:EXPRESSION(alert())">B</div> +!! html/php +<p style="/* insecure input */">A</p> +<div style="/* insecure input */">B</div> + +!! html/parsoid +<p style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"font-size: 100px; color: expression((title='XSSed'),'red')"}}'>A</p> +<div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"top:EXPRESSION(alert())"}}'>B</div> +!! end + +!! test +MSIE 6 CSS safety test: IPA extensions (T57332) +!! wikitext +<div style="background-image:uʀʟ(javascript:alert())">A</div> +<p style="font-size: 100px; color: expʀessɪoɴ((title='XSSed'),'red')">B</p> +!! html/php +<div style="/* insecure input */">A</div> +<p style="/* insecure input */">B</p> + +!! html/parsoid +<div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:uʀʟ(javascript:alert())"}}'>A</div> +<p style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"font-size: 100px; color: expʀessɪoɴ((title='XSSed'),'red')"}}'>B</p> +!! end + +!! test +MSIE 6 CSS safety test: sup/sub script (T57332) +!! wikitext +<div style="background-image:url⁽javascript:alert())">A</div> +<div style="background-image:url₍javascript:alert())">B</div> +<p style="font-size: 100px; color: expressioⁿ((title='XSSed'),'red')">C</p> +!! html/php +<div style="/* insecure input */">A</div> +<div style="/* insecure input */">B</div> +<p style="/* insecure input */">C</p> + +!! html/parsoid +<div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:url⁽javascript:alert())"}}'>A</div> +<div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:url₍javascript:alert())"}}'>B</div> +<p style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"font-size: 100px; color: expressioⁿ((title='XSSed'),'red')"}}'>C</p> +!! end + +!! test +Opera -o-link CSS +!! options +parsoid=wt2html,html2html +!! wikitext +<div +title="data:text/html,<img src=1 onerror=alert(1)>" +style="-o-link:attr(title);-o-link-source:current">X</div> +!! html/php +<div title="data:text/html,<img src=1 onerror=alert(1)>" style="/* insecure input */">X</div> + +!! html/parsoid +<div title="data:text/html,<img src=1 onerror=alert(1)>" style="/* insecure input */" data-parsoid='{"stx":"html","a":{"title":"data:text/html,<img src=1 onerror=alert(1)>","style":"/* insecure input */"},"sa":{"title":"&#100;&#97;&#116;&#97;&#58;&#116;&#101;&#120;&#116;&#47;&#104;&#116;&#109;&#108;&#44;&#60;&#105;&#109;&#103;&#32;&#115;&#114;&#99;&#61;&#49;&#32;&#111;&#110;&#101;&#114;&#114;&#111;&#114;&#61;&#97;&#108;&#101;&#114;&#116;&#40;&#49;&#41;&#62;","style":"-o-link:attr(title);-o-link-source:current"}}'>X</div> +!! end + +!! test +MSIE 6 CSS safety test: Repetition markers (T57332) +!! wikitext +<p style="font-size: 100px; color: expres〱ion((title='XSSed'),'red')">A</p> +<p style="font-size: 100px; color: expresゝion((title='XSSed'),'red')">B</p> +<p style="font-size: 100px; color: expresーion((title='XSSed'),'red')">C</p> +<p style="font-size: 100px; color: expresヽion((title='XSSed'),'red')">D</p> +<p style="font-size: 100px; color: expresﹽion((title='XSSed'),'red')">E</p> +<p style="font-size: 100px; color: expresﹼion((title='XSSed'),'red')">F</p> +<p style="font-size: 100px; color: expresーion((title='XSSed'),'red')">G</p> +!! html/php +<p style="/* insecure input */">A</p> +<p style="/* insecure input */">B</p> +<p style="/* insecure input */">C</p> +<p style="/* insecure input */">D</p> +<p style="/* insecure input */">E</p> +<p style="/* insecure input */">F</p> +<p style="/* insecure input */">G</p> + +!! html/parsoid +<p style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"font-size: 100px; color: expres〱ion((title='XSSed'),'red')"}}'>A</p> +<p style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"font-size: 100px; color: expresゝion((title='XSSed'),'red')"}}'>B</p> +<p style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"font-size: 100px; color: expresーion((title='XSSed'),'red')"}}'>C</p> +<p style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"font-size: 100px; color: expresヽion((title='XSSed'),'red')"}}'>D</p> +<p style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"font-size: 100px; color: expresﹽion((title='XSSed'),'red')"}}'>E</p> +<p style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"font-size: 100px; color: expresﹼion((title='XSSed'),'red')"}}'>F</p> +<p style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"font-size: 100px; color: expresーion((title='XSSed'),'red')"}}'>G</p> +!! end + +!! test +Table attribute legitimate extension +!! wikitext +{| +!+ style="<nowiki>color:blue</nowiki>"|status +|} +!! html +<table> +<tr> +<th style="color:blue">status +</th></tr></table> + +!!end + +!! test +Table attribute safety +!! wikitext +{| +!+ style="<nowiki>border-width:expression(0+alert(document.cookie))</nowiki>"|status +|} +!! html +<table> +<tr> +<th style="/* insecure input */">status +</th></tr></table> + +!! end + +!! test +CSS line continuation 1 +!! wikitext +<div style="background-image: u\ rl(test.jpg);"></div> +!! html +<div style="/* insecure input */"></div> + +!! end + +!! test +CSS line continuation 2 +!! wikitext +<div style="background-image: u\ rl(test.jpg); "></div> +!! html +<div style="/* invalid control char */"></div> + +!! end + +!! article +Template:Identity +!! text +{{{1}}} +!! endarticle + +!! test +Expansion of multi-line templates in attribute values (T8255) +!! wikitext +<div style="background: {{identity|#00FF00}}">-</div> +!! html +<div style="background: #00FF00">-</div> + +!! end + +!! test +Expansion of multi-line templates in attribute values (T8255 sanity check) +!! wikitext +<div style="background: +#00FF00">-</div> +!! html/php +<div style="background: #00FF00">-</div> + +!! html/parsoid +<div style="background: +#00FF00">-</div> +!! end + +!! test +Expansion of multi-line templates in attribute values (T8255 sanity check 2) +!! wikitext +<div style="background: #00FF00">-</div> +!! html +<div style="background: #00FF00">-</div> + +!! end + +!! test +Tags which are hidden from tidiers cannot pass through the Sanitizer +!! wikitext +<mw:toc><script>alert();</script></mw:toc> +!! html+tidy +<p><mw:toc><script>alert();</script></mw:toc> +</p> +!! end + +### +### Parser hooks (see tests/parser/parserTestsParserHook.php for the <tag> extension) +### + +!! test +Parser hook: empty input +!! wikitext +<tag></tag> +!! html/php +<pre> +'' +array ( +) +</pre> + +!! html/parsoid +<pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre> +!! end + +## Don't expect parsoid to rt this form. +!! test +Parser hook: empty input using terminated empty elements +!! options +parsoid=wt2html,html2html +!! wikitext +<tag/> +!! html/php +<pre> +NULL +array ( +) +</pre> + +!! html/parsoid +<pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":null}' data-parsoid='{}' about="#mwt2"></pre> +!! end + +!! test +Parser hook: empty input using terminated empty elements (space before) +!! wikitext +<tag /> +!! html/php +<pre> +NULL +array ( +) +</pre> + +!! html/parsoid +<pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":null}' data-parsoid='{}' about="#mwt2"></pre> +!! end + +!! test +Parser hook: basic input +!! wikitext +<tag>input</tag> +!! html/php +<pre> +'input' +array ( +) +</pre> + +!! html/parsoid +<pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre> +!! end + +## Don't expect parsoid to rt this form. +!! test +Parser hook: case insensitive +!! options +parsoid=wt2html,html2html +!! wikitext +<TAG>input</TAG> +!! html/php +<pre> +'input' +array ( +) +</pre> + +!! html/parsoid +<pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre> +!! end + +## Don't expect parsoid to rt this form. +!! test +Parser hook: case insensitive, redux +!! options +parsoid=wt2html,html2html +!! wikitext +<TaG>input</TAg> +!! html/php +<pre> +'input' +array ( +) +</pre> + +!! html/parsoid +<pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre> +!! end + +!! test +Parser hook: nested tags +!! wikitext +<tag><tag></tag></tag> +!! html/php +<pre> +'<tag>' +array ( +) +</pre></tag> + +!! html/parsoid +<pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"<tag>"}}' data-parsoid='{}' about="#mwt2"></pre></tag> +!! end + +!! test +Parser hook: basic arguments +!! wikitext +<tag width="200" height="100" depth="50" square=""></tag> +!! html/php +<pre> +'' +array ( + 'width' => '200', + 'height' => '100', + 'depth' => '50', + 'square' => '', +) +</pre> + +!! html/parsoid +<pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre> +!! end + +## Don't expect parsoid to rt this form. +!! test +Parser hook: basic arguments, variations +!! options +parsoid=wt2html,html2html +!! wikitext +<tag width=200 height = "100" depth = '50' square></tag> +!! html/php +<pre> +'' +array ( + 'width' => '200', + 'height' => '100', + 'depth' => '50', + 'square' => '', +) +</pre> + +!! html/parsoid +<pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre> +!! end + +!! test +Parser hook: argument containing a forward slash (T7344) +!! wikitext +<tag filename="/tmp/bla"></tag> +!! html/php +<pre> +'' +array ( + 'filename' => '/tmp/bla', +) +</pre> + +!! html/parsoid +<pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"filename":"/tmp/bla"},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre> +!! end + +## Don't expect parsoid to rt this form. +!! test +Parser hook: empty input using terminated empty elements (T4374) +!! options +parsoid=wt2html,html2html +!! wikitext +<tag foo=bar/>text +!! html/php +<pre> +NULL +array ( + 'foo' => 'bar', +) +</pre>text + +!! html/parsoid +<pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"foo":"bar"},"body":null}' data-parsoid='{}' about="#mwt2"></pre>text +!! end + +## </tag> should be output literally since there is no matching tag that begins it +## Don't expect parsoid to rt this form. +!! test +Parser hook: basic arguments using terminated empty elements (T4374) +!! options +parsoid=wt2html +!! wikitext +<tag width=200 height = "100" depth = '50' square/> +other stuff +</tag> +!! html/php +<pre> +NULL +array ( + 'width' => '200', + 'height' => '100', + 'depth' => '50', + 'square' => '', +) +</pre> +<p>other stuff +</tag> +</p> +!! html/parsoid +<pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""},"body":null}' about="#mwt2"></pre><p>other stuff +</tag></p> +!! end + +## Don't expect parsoid to rt this form. +!! test +Parser hook: Don't allow unclosed extension tags +!! options +parsoid=wt2html +!! wikitext +test <tag>123 + +this is a '''test''' +!! html/php +<p>test <tag>123 +</p><p>this is a <b>test</b> +</p> +!! html/parsoid +<p>test <tag>123</p> + +<p>this is a <b>test</b></p> +!! end + +!! test +Parser hook: horizontal rule inside extension tag that outputs <pre> +!! wikitext +<tag> +Hello +<hr/> +Goodbye +</tag> +!! html/php +<pre> +' +Hello +<hr/> +Goodbye +' +array ( +) +</pre> + +!! end + +### +### (see tests/parser/parserTestsParserHook.php for the <statictag> extension) +### + +!! test +Parser hook: static parser hook not inside a comment +!! wikitext +<statictag>hello, world</statictag> + +<statictag action="flush" /> +!! html/php +<p><br /> +hello, world +</p> +!! html/parsoid +<p><span typeof="mw:Extension/statictag" data-mw='{"name":"statictag","attrs":{},"body":{"extsrc":"hello, world"}}' data-parsoid='{}' about="#mwt2"></span></p> +<p typeof="mw:Extension/statictag" data-mw='{"name":"statictag","attrs":{"action":"flush"},"body":null}' data-parsoid='{}' about="#mwt4">hello, world</p> +!! end + +!! test +Parser hook: static parser hook inside a comment +!! wikitext +<!-- <statictag>hello, world</statictag> --> +<statictag action="flush" /> +!! html/php +<p><br /> +</p> +!! html/parsoid +<!-- <statictag>hello, world</statictag> --> +<p typeof='mw:Extension/statictag' data-mw='{"name":"statictag","attrs":{"action":"flush"},"body":null}' data-parsoid='{}' about='#mwt2'></p> +!! end + +# Nested template calls; this case was broken by Parser.php rev 1.506, +# since reverted. + +!! article +Template:One-parameter +!! text +(My parameter is: {{{1}}}) +!! endarticle + +!! article +Template:Map-one-parameter +!! text +{{{{{1}}}|{{{2}}}}} +!! endarticle + +!! test +Nested template calls +!! wikitext +{{Map-one-parameter|One-parameter|param}} +!! html +<p>(My parameter is: param) +</p> +!! end + + +### +### Sanitizer +### + +# Remex wraps empty tag runs with p-tags. +# Parsoid strips them out during p-wrapping. +!! test +Sanitizer: Closing of open tags +!! wikitext +<s></s><table></table> +!! html/php+tidy +<p><s></s></p><table></table> +!! html/parsoid +<s></s><table></table> +!! end + +!! test +Sanitizer: Closing of open but not closed tags +!! wikitext +<s>foo +!! html +<p><s>foo</s> +</p> +!! end + +!! test +Sanitizer: Closing of closed but not open tags +!! options +parsoid=wt2html +!! wikitext +</s> +!! html/php+tidy +<p class="mw-empty-elt"> +</p> +!! html/parsoid +!! end + +!! test +Sanitizer: Closing of closed but not open table tags +!! options +parsoid=wt2html +!! wikitext +Table not started</td></tr></table> +!! html+tidy +<p>Table not started +</p> +!! end + +!! test +Sanitizer: Escaping of spaces, multibyte characters, colons & other stuff in id="" +!! config +wgFragmentMode=[ 'html5', 'legacy' ] +!! wikitext +<span id="æ: v">byte</span>[[#æ: v|backlink]] +!! html/php +<p><span id="æ:_v">byte</span><a href="#æ:_v">backlink</a> +</p> +!! html/parsoid +<p><span id="æ:_v" data-parsoid='{"stx":"html","a":{"id":"æ:_v"},"sa":{"id":"æ: v"}}'>byte</span><a rel="mw:WikiLink" href="./Main_Page#æ:_v" data-parsoid='{"stx":"piped","a":{"href":"./Main_Page#æ:_v"},"sa":{"href":"#æ: v"}}'>backlink</a></p> +!! end + +!! test +Sanitizer: Escaping of spaces, multibyte characters, colons & other stuff in id="" (legacy) +!! config +wgFragmentMode=[ 'legacy' ] +!! wikitext +<span id="æ: v">byte</span>[[#æ: v|backlink]] +!! html/php +<p><span id=".C3.A6:_v">byte</span><a href="#.C3.A6:_v">backlink</a> +</p> +!! end + +# In HTML5, the restrictions are that id must contain at least one character, +# and must not contain any space characters. +!! test +Sanitizer: Validating the contents of the id attribute (T6515) +!! options +disabled +!! wikitext +<br id="" /><br id="a space" /> +!! html +Something ... +!! end + +# In HTML5, id must be unique amongst all the ids in the element's home subtree. +!! test +Sanitizer: Validating id attribute uniqueness (T6515, T8301) +!! options +disabled +!! wikitext +<br id="foo" /><br id="foo" /> +!! html +Something need to be done. foo-2 ? +!! end + +!! test +Sanitizer: Validating that <meta> and <link> work, but only for Microdata +!! wikitext +<div itemscope> + <meta itemprop="hello" content="world"> + <meta http-equiv="refresh" content="5"> + <meta itemprop="hello" http-equiv="refresh" content="5"> + <link itemprop="hello" href="{{SERVER}}"> + <link rel="stylesheet" href="{{SERVER}}"> + <link rel="stylesheet" itemprop="hello" href="{{SERVER}}"> +</div> +!! html +<div itemscope=""> +<p> <meta itemprop="hello" content="world" /> + <meta http-equiv="refresh" content="5"> + <meta itemprop="hello" content="5" /> + <link itemprop="hello" href="http://example.org" /> + <link rel="stylesheet" href="<a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>"> + <link itemprop="hello" href="http://example.org" /> +</p> +</div> + +!! end + +!! test +Sanitizer: Strip comments from CSS attributes +!! options +parsoid=wt2html,wt2wt +!! wikitext +<span style="margin:/*negate mbox-text padding */-0.125em -0.45em; /*rainbow*/rgba(255, 0, 0, 0.3)">2013</span> +!! html/php +<p><span style="margin: -0.125em -0.45em; rgba(255, 0, 0, 0.3)">2013</span> +</p> +!! html/parsoid +<p><span style="margin: -0.125em -0.45em; rgba(255, 0, 0, 0.3)">2013</span></p> +!! end + +!! test +Sanitizer: Avoid unnecessary percent encoded characters in interwiki links +!! wikitext +[[meatball:Soft"Security]] +!! html/php +<p><a href="http://www.usemod.com/cgi-bin/mb.pl?Soft%22Security" class="extiw" title="meatball:Soft"Security">meatball:Soft"Security</a> +</p> +!! html/parsoid +<p><a rel="mw:WikiLink/Interwiki" href='http://www.usemod.com/cgi-bin/mb.pl?Soft"Security' title='meatball:Soft"Security'>meatball:Soft"Security</a></p> +!! end + +!! test +Sanitizer: angle brackets are invalid, even in interwiki links (T182338) +!! wikitext +[[meatball:Foo<Bar]] +[[meatball:Foo>Bar]] +[[meatball:Foo<bar]] +[[meatball:Foo>bar]] +!! html/php +<p>[[meatball:Foo<Bar]] +[[meatball:Foo>Bar]] +[[meatball:Foo<bar]] +[[meatball:Foo>bar]] +</p> +!! html/parsoid +<p>[[meatball:Foo<Bar]] +[[meatball:Foo>Bar]] +[[meatball:Foo<span typeof="mw:Entity" data-parsoid='{"src":"&lt;","srcContent":"<"}'><</span>bar]] +[[meatball:Foo<span typeof="mw:Entity" data-parsoid='{"src":"&gt;","srcContent":">"}'>></span>bar]]</p> +!! end + +!! test +Language converter: output gets cut off unexpectedly (T7757) +!! options +language=zh +!! wikitext +this bit is safe: }- + +but if we add a conversion instance: -{zh-cn:xxx;zh-tw:yyy}- + +then we get cut off here: }- + +all additional text is vanished +!! html/php +<p>this bit is safe: }- +</p><p>but if we add a conversion instance: xxx +</p><p>then we get cut off here: }- +</p><p>all additional text is vanished +</p> +!! html/parsoid +<p>this bit is safe: }-</p> +<p>but if we add a conversion instance: <span typeof="mw:LanguageVariant" data-parsoid='{"tSp":[6]}' data-mw-variant='{"twoway":[{"l":"zh-cn","t":"xxx"},{"l":"zh-tw","t":"yyy"}]}'></span></p> +<p>then we get cut off here: }-</p> +<p>all additional text is vanished</p> +!! end + +!! test +Language converter glossary rules inside attributes (T119158) +!! options +language=sr variant=sr-el +!! wikitext +-{H|foAjrjvi=>sr-el:" onload="alert(1)" data-foo="}- + +[[File:Foobar.jpg|alt=-{}-foAjrjvi-{}-]] +!! html/php +<p> +</p><p><a href="/wiki/%D0%94%D0%B0%D1%82%D0%BE%D1%82%D0%B5%D0%BA%D0%B0:Foobar.jpg" class="image"><img alt="" onload="alert(1)" data-foo="" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a> +</p> +!! html/parsoid +<p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"foAjrjvi","l":"sr-el","t":"\" onload=\"alert(1)\" data-foo=\""}]}'/></p> + +<p><figure-inline class="mw-default-size" typeof="mw:Image"><a href="./Датотека:Foobar.jpg"><img alt="foAjrjvi" resource="./Датотека:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"alt":"foAjrjvi","resource":"./Датотека:Foobar.jpg","height":"220","width":"1941"},"sa":{"alt":"alt=-{}-foAjrjvi-{}-","resource":"File:Foobar.jpg"}}'/></a></figure-inline></p> +!! end + +!! test +Self closed html pairs (T7487) +!! wikitext +<center><font id="bug" />Centered text</center> +<div><font id="bug2" />In div text</div> +!! html+tidy +<center><font id="bug"></font>Centered text</center> +<div><font id="bug2"></font>In div text</div> +!! end + +!! test +Punctuation: nbsp before exclamation +!! wikitext +C'est grave ! +!! html +<p>C'est grave ! +</p> +!! end + +!! test +Punctuation: CSS !important (T13874) +!! wikitext +<div style="width:50% !important">important</div> +!! html +<div style="width:50% !important">important</div> + +!!end + +!! test +Punctuation: CSS ! important (T13874; with space after) +!! wikitext +<div style="width:50% ! important">important</div> +!! html +<div style="width:50% ! important">important</div> + +!!end + +!! test +HTML bullet list, closed tags (T7497) +!! wikitext +<ul> +<li>One</li> +<li>Two</li> +</ul> +!! html/php +<ul> +<li>One</li> +<li>Two</li> +</ul> + +!! html/parsoid +<ul data-parsoid='{"stx":"html"}'> +<li data-parsoid='{"stx":"html"}'>One</li> +<li data-parsoid='{"stx":"html"}'>Two</li> +</ul> + +!! end + +!! test +HTML bullet list, unclosed tags (T7497) +!! wikitext +<ul> +<li>One +<li>Two +</ul> +!! html/php+tidy +<ul> +<li>One +</li><li>Two +</li></ul> +!! html/parsoid +<ul data-parsoid='{"stx":"html"}'> +<li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>One</li> +<li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>Two</li> +</ul> + +!! end + +!! test +HTML ordered list, closed tags (T7497) +!! wikitext +<ol> +<li>One</li> +<li>Two</li> +</ol> +!! html/php +<ol> +<li>One</li> +<li>Two</li> +</ol> + +!! html/parsoid +<ol data-parsoid='{"stx":"html"}'> +<li data-parsoid='{"stx":"html"}'>One</li> +<li data-parsoid='{"stx":"html"}'>Two</li> +</ol> + +!! end + +!! test +HTML ordered list, unclosed tags (T7497) +!! options +!! wikitext +<ol> +<li>One +<li>Two +</ol> +!! html/php+tidy +<ol> +<li>One +</li><li>Two +</li></ol> +!! html/parsoid +<ol data-parsoid='{"stx":"html"}'> +<li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>One</li> +<li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>Two</li> +</ol> + +!! end + +!! test +HTML nested bullet list, closed tags (T7497) +!! wikitext +<ul> +<li>One</li> +<li>Two: +<ul> +<li>Sub-one</li> +<li>Sub-two</li> +</ul> +</li> +</ul> +!! html/php +<ul> +<li>One</li> +<li>Two: +<ul> +<li>Sub-one</li> +<li>Sub-two</li> +</ul> +</li> +</ul> + +!! html/parsoid +<ul data-parsoid='{"stx":"html"}'> +<li data-parsoid='{"stx":"html"}'>One</li> +<li data-parsoid='{"stx":"html"}'>Two: +<ul data-parsoid='{"stx":"html"}'> +<li data-parsoid='{"stx":"html"}'>Sub-one</li> +<li data-parsoid='{"stx":"html"}'>Sub-two</li> +</ul> +</li> +</ul> +!! end + +!! test +HTML nested bullet list, open tags (T7497) +!! wikitext +<ul> +<li>One +<li>Two: +<ul> +<li>Sub-one +<li>Sub-two +</ul> +</ul> +!! html+tidy +<ul> +<li>One +</li><li>Two: +<ul> +<li>Sub-one +</li><li>Sub-two +</li></ul> +</li></ul> +!! end + +!! test +HTML nested ordered list, closed tags (T7497) +!! wikitext +<ol> +<li>One</li> +<li>Two: +<ol> +<li>Sub-one</li> +<li>Sub-two</li> +</ol> +</li> +</ol> +!! html +<ol> +<li>One</li> +<li>Two: +<ol> +<li>Sub-one</li> +<li>Sub-two</li> +</ol> +</li> +</ol> + +!! end + +!! test +HTML nested ordered list, open tags (T7497) +!! wikitext +<ol> +<li>One +<li>Two: +<ol> +<li>Sub-one +<li>Sub-two +</ol> +</ol> +!! html/php +<ol> +<li>One +<li>Two: +<ol> +<li>Sub-one +<li>Sub-two +</ol> +</ol> + +!! html/parsoid +<ol> +<li>One +</li> +<li>Two: +<ol> +<li>Sub-one +</li> +<li>Sub-two +</li> +</ol> +</li> +</ol> + +!! end + +!! test +HTML ordered list item with parameters oddity +!! wikitext +<ol><li id="fragment">One</li> +</ol> +!! html +<ol><li id="fragment">One</li> +</ol> + +!! end + +# parsoid doesn't explicitly mark autonumbered links, see T55505 +!!test +T7918: autonumbering +!! wikitext +[http://first/] [http://second] [ftp://ftp] + +ftp://inlineftp + +[mailto:enclosed@mail.tld With target] + +[mailto:enclosed@mail.tld] + +mailto:inline@mail.tld +!! html/php +<p><a rel="nofollow" class="external autonumber" href="http://first/">[1]</a> <a rel="nofollow" class="external autonumber" href="http://second">[2]</a> <a rel="nofollow" class="external autonumber" href="ftp://ftp">[3]</a> +</p><p><a rel="nofollow" class="external free" href="ftp://inlineftp">ftp://inlineftp</a> +</p><p><a rel="nofollow" class="external text" href="mailto:enclosed@mail.tld">With target</a> +</p><p><a rel="nofollow" class="external autonumber" href="mailto:enclosed@mail.tld">[4]</a> +</p><p><a rel="nofollow" class="external free" href="mailto:inline@mail.tld">mailto:inline@mail.tld</a> +</p> +!! html/parsoid +<p><a rel="mw:ExtLink" class="external autonumber" href="http://first/"></a> <a rel="mw:ExtLink" class="external autonumber" href="http://second"></a> <a rel="mw:ExtLink" class="external autonumber" href="ftp://ftp"></a></p> +<p><a rel="mw:ExtLink" class="external free" href="ftp://inlineftp">ftp://inlineftp</a></p> +<p><a rel="mw:ExtLink" class="external text" href="mailto:enclosed@mail.tld">With target</a></p> +<p><a rel="mw:ExtLink" class="external autonumber" href="mailto:enclosed@mail.tld"></a></p> +<p><a rel="mw:ExtLink" class="external free" href="mailto:inline@mail.tld">mailto:inline@mail.tld</a></p> +!! end + + +# +# Security and HTML correctness +# From Nick Jenkins' fuzz testing +# + +!! test +Fuzz testing: Parser13 +!! wikitext +{| +| http://a| +!! html +<table> +<tr> +<td> +</td> +</tr> +</table> + +!! end + +# Note that Parsoid output differs from the PHP parser here: the PHP +# parser breaks the URL for the magic word, while in Parsoid the URL +# production takes precedence. +!! test +Fuzz testing: Parser14 +!! wikitext +==onmouseover=== +http://__TOC__ +!! html/php +<h2><span class="mw-headline" id="onmouseover.3D">onmouseover=</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: onmouseover=">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +http://<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div> +<ul> +<li class="toclevel-1 tocsection-1"><a href="#onmouseover.3D"><span class="tocnumber">1</span> <span class="toctext">onmouseover=</span></a></li> +</ul> +</div> + + +!! html/php+tidy +<h2><span class="mw-headline" id="onmouseover.3D">onmouseover=</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: onmouseover=">edit</a><span class="mw-editsection-bracket">]</span></span></h2><p> +http://</p><div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div> +<ul> +<li class="toclevel-1 tocsection-1"><a href="#onmouseover.3D"><span class="tocnumber">1</span> <span class="toctext">onmouseover=</span></a></li> +</ul> +</div> +!! html/parsoid +<h2 id="onmouseover="><span id="onmouseover.3D" typeof="mw:FallbackId"></span>onmouseover=</h2> +<p><a rel="mw:ExtLink" class="external free" href="http://__TOC__" data-parsoid='{"stx":"url"}'>http://__TOC__</a></p> +!! end + +!! test +Fuzz testing: Parser14-table +!! options +parsoid=wt2html,html2html +!! wikitext +==a== +{| STYLE=__TOC__ +!! html +<h2><span class="mw-headline" id="a">a</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: a">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<table style="__TOC__"> +<tr><td></td></tr> +</table> + +!! html+tidy +<h2><span class="mw-headline" id="a">a</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: a">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<table style="__TOC__"> +<tr> +<td></td> +</tr> +</table> +!! html/parsoid +<h2 id="a">a</h2> +<table style="__TOC__"></table> +!! end + +# Known to produce bogus xml (extra </td>) +# Don't add the html/php section since it generates broken HTML +!! test +Fuzz testing: Parser16 +!! wikitext +{| +!https://|||||| +!! html+tidy +<table> +<tbody><tr> +<th>https://</th> +<th></th> +<th></th> +<th> + +</th></tr> +</tbody></table> +!! end + +!! test +Fuzz testing: Parser21 +!! wikitext +{| +!irc://{{ftp://a" onmouseover="alert('hello world');" +| +!! html +<table> +<tr> +<th><a rel="nofollow" class="external free" href="irc://{{ftp://a">irc://{{ftp://a</a>" onmouseover="alert('hello world');" +</th> +<td> +</td> +</tr> +</table> + +!! end + +!! test +Fuzz testing: Parser22 +!! wikitext +http://===r:::https://b + +{| +!! html +<p><a rel="nofollow" class="external free" href="http://===r:::https://b">http://===r:::https://b</a> +</p> +<table> +<tr><td></td></tr> +</table> + +!! end + +# Known to produce bad XML for now +!! test +Fuzz testing: Parser24 +!! options +parsoid=wt2html +!! wikitext +{| +{{{| +<u CLASS= +| {{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx--><noinclude>}}}} > +<br style="onmouseover='alert(document.cookie);' " /> + +MOVE YOUR MOUSE CURSOR OVER THIS TEXT +| +!! html/php +<table> +{{{| +<u class="|">}}}} > +<br style="onmouseover='alert(document.cookie);'" /> + +MOVE YOUR MOUSE CURSOR OVER THIS TEXT +<tr> +<td></u> +</td> +</tr> +</table> + +!! html/parsoid +<p data-parsoid='{"fostered":true,"autoInsertedEnd":true}'>{{{| +<u class="|" data-parsoid='{"stx":"html","a":{"{{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx--":null},"sa":{"{{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx--":""},"autoInsertedEnd":true}'><meta typeof="mw:Includes/NoInclude" data-parsoid='{"src":"<noinclude>"}'/>}}}} > +<br style="onmouseover='alert(document.cookie);' " data-parsoid='{"stx":"html","selfClose":true}'/></u></p><p data-parsoid='{"fostered":true,"autoInsertedEnd":true}'><u class="|" data-parsoid='{"stx":"html","a":{"{{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx--":null},"sa":{"{{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx--":""},"autoInsertedEnd":true,"autoInsertedStart":true}'>MOVE YOUR MOUSE CURSOR OVER THIS TEXT</u></p><table data-parsoid='{"autoInsertedEnd":true}'> + + + +<tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'></td></tr></tbody></table> +!! end + +# Note: the current result listed for this is not what the original one was, +# but the original bug was JavaScript injection, which is fixed in any case. +# It's not clear that the original result listed was any more correct than the +# current one. Original result: +# <p>{{{| +# </p> +# <li class="||"> +# }}}blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b> +!!test +Fuzz testing: Parser25 (T8055) +!! wikitext +{{{ +| +<LI CLASS=|| + > +}}}blah" onmouseover="alert('hello world');" align="left"'''MOVE MOUSE CURSOR OVER HERE +!! html/php +<p><LI CLASS=blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b> +</p> +!! html/parsoid +<span about="#mwt1" typeof="mw:Param" data-parsoid='{"pi":[[{"k":"1"},{"k":"2"},{"k":"3"}]]}' data-mw='{"parts":[{"templatearg":{"target":{"wt":"\n"},"params":{"1":{"wt":" \n<LI CLASS="},"2":{"wt":""},"3":{"wt":"\n >\n"}},"i":0}},"blah\" onmouseover=\"alert('hello world');\" align=\"left\"'''MOVE MOUSE CURSOR OVER HERE"]}'> +</span><p about="#mwt1"><LI CLASS=blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b></p> +!! end + +!!test +Fuzz testing: URL adjacent extension (with space, clean) +!! wikitext +http://example.com <nowiki>junk</nowiki> +!! html/php +<p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> junk +</p> +!! html/parsoid +<p><a rel="mw:ExtLink" class="external free" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a> <span typeof="mw:Nowiki">junk</span></p> +!! end + +!!test +Fuzz testing: URL adjacent extension (no space, dirty; nowiki) +!! wikitext +http://example.com<nowiki>junk</nowiki> +!! html/php +<p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>junk +</p> +!! html/parsoid +<p><a rel="mw:ExtLink" class="external free" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a><span typeof="mw:Nowiki">junk</span></p> +!! end + +!! test +Fuzz testing: URL adjacent extension (no space, dirty; pre) +!! wikitext +http://example.com<pre>junk</pre> +!! html/php +<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a><pre>junk</pre> + +!! html/php+tidy +<p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a></p><pre>junk</pre> +!! html/parsoid +<p><a rel="mw:ExtLink" class="external free" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a></p><pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"junk"}}'>junk</pre> +!! end + +!! test +Fuzz testing: image with bogus manual thumbnail +!! wikitext +[[Image:foobar.jpg|thumbnail= ]] +!! html/php +<div class="thumb tright"><div class="thumbinner" style="width:182px;">Error creating thumbnail: <div class="thumbcaption"></div></div></div> + +!! html/parsoid +<figure class="mw-default-size" typeof="mw:Error mw:Image/Thumb" data-parsoid='{"optList":[{"ck":"manualthumb","ak":"thumbnail= "}]}' data-mw='{"errors":[{"key":"apierror-invalidtitle","message":"Invalid thumbnail title.","params":{"name":""}}],"thumb":""}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{"href":"Image:foobar.jpg"}}'><img resource="./File:Foobar.jpg" src="./Special:FilePath/Foobar.jpg" height="220" width="220" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"220"},"sa":{"resource":"Image:foobar.jpg"}}'/></a></figure> +!! end + +# Parsoid will emit the newline literally in wt2wt; see next test case. +!! test +Fuzz testing: encoded newline in generated HTML replacements (T8577) +!! options +parsoid=wt2html +!! wikitext +<pre dir=" "></pre> +!! html/php +<pre dir=" "></pre> + +!! html/parsoid +<pre typeof="mw:Extension/pre" about="#mwt2" dir=" +" data-mw='{"name":"pre","attrs":{"dir":"\n"},"body":{"extsrc":""}}'></pre> +!! end + +!! test +Fuzz testing: encoded newline in generated HTML replacements, html2wt (T8577) +!! options +parsoid=html2wt +!! html/parsoid +<pre typeof="mw:Extension/pre" about="#mwt2" dir=" +" data-mw='{"name":"pre","attrs":{"dir":"\n"},"body":{"extsrc":""}}'></pre> +!! wikitext +<pre dir=" +"></pre> +!! html/php +<pre dir=""></pre> + +!! end + +!! test +Templates in extension attributes are not expanded +!! wikitext +<pre dir="{{echo|ltr}}"></pre> +!! html/php +<pre dir="{{echo|ltr}}"></pre> + +!! html/parsoid +<pre typeof="mw:Extension/pre" about="#mwt2" dir="{{echo|ltr}}" data-mw='{"name":"pre","attrs":{"dir":"{{echo|ltr}}"},"body":{"extsrc":""}}'></pre> +!! end + +!! test +Parsing optional HTML elements (T8171) +!! options +!! wikitext +<table> + <tr> + <td> Some tabular data</td> + <td> More tabular data ... + <td> And yet som tabular data</td> + </tr> +</table> +!! html +<table> + <tr> + <td> Some tabular data</td> + <td> More tabular data ... + </td><td> And yet som tabular data</td> + </tr> +</table> + +!! end + +!! test +Correct handling of <td>, <tr> (T8171) +!! options +!! wikitext +<table> + <tr> + <td> Some tabular data</td> + <td> More tabular data ...</td> + <td> And yet som tabular data</td> + </tr> +</table> +!! html +<table> + <tr> + <td> Some tabular data</td> + <td> More tabular data ...</td> + <td> And yet som tabular data</td> + </tr> +</table> + +!! end + + +!! test +Parsing crashing regression (fr:JavaScript) +!! wikitext +</body></x> +!! html +<p></body></x> +</p> +!! end + +!! test +Inline wiki vs wiki block nesting +!! wikitext +'''Bold paragraph + +New wiki paragraph +!! html +<p><b>Bold paragraph</b> +</p><p>New wiki paragraph +</p> +!! end + +# FIXME: The current php output is documented +# and desired output is the parsoid target. +!! test +Inline HTML vs wiki block nesting +!! wikitext +<b>Bold paragraph + +New wiki paragraph +!! html/php +<p><b>Bold paragraph +</p><p>New wiki paragraph</b> +</p> +!! html/parsoid +<p><b>Bold paragraph</b> +</p><p>New wiki paragraph +</p> +!! end + +# Original result was this: +# <p><b>bold</b><b>bold<i>bolditalics</i></b> +# </p> +# While that might be marginally more intuitive, maybe, the six-apostrophe +# construct is clearly pathological and the result stated here (which is what +# the parser actually does) is about as reasonable as anything. +!!test +Mixing markup for italics and bold +!! options +!! wikitext +'''bold''''''bold''bolditalics''''' +!! html +<p>'<i>bold'</i><b>bold<i>bolditalics</i></b> +</p> +!! end + + +!! article +Xyzzyx +!! text +Article for special page transclusion test +!! endarticle + +!! test +Special page transclusion +!! options +!! wikitext +{{Special:Prefixindex/Xyzzyx}} +!! html +<ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li> +</ul> + +!! end + +!! test +Special page transclusion twice (T7021) +!! options +!! wikitext +{{Special:Prefixindex/Xyzzyx}} +{{Special:Prefixindex/Xyzzyx}} +!! html +<ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li> +</ul> +<ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li> +</ul> + +!! end + +!! test +Transclusion of default MediaWiki message +!! wikitext +{{MediaWiki:Mainpage}} +!! html +<p>Main Page +</p> +!! end + +!! test +Transclusion of nonexistent MediaWiki message +!! wikitext +{{MediaWiki:Mainpagexxx}} +!! html +<p><a href="/index.php?title=MediaWiki:Mainpagexxx&action=edit&redlink=1" class="new" title="MediaWiki:Mainpagexxx (page does not exist)">MediaWiki:Mainpagexxx</a> +</p> +!! end + +!! test +Transclusion of MediaWiki message with underscore +!! wikitext +{{MediaWiki:history_short}} +!! html +<p>History +</p> +!! end + +!! test +Transclusion of MediaWiki message with space +!! wikitext +{{MediaWiki:history short}} +!! html +<p>History +</p> +!! end + +!! test +Invalid header with following text +!! wikitext += x = y +!! html +<p>= x = y +</p> +!! end + + +!! test +Section extraction test (section 0) +!! options +section=0 +!! wikitext +start +==a== +===aa=== +====aaa==== +==b== +===ba=== +===bb=== +====bba==== +===bc=== +==c== +===ca=== +!! html/php +start +!! end + +!! test +Section extraction test (section 1) +!! options +section=1 +!! wikitext +start +==a== +===aa=== +====aaa==== +==b== +===ba=== +===bb=== +====bba==== +===bc=== +==c== +===ca=== +!! html/php +==a== +===aa=== +====aaa==== +!! end + +!! test +Section extraction test (section 2) +!! options +section=2 +!! wikitext +start +==a== +===aa=== +====aaa==== +==b== +===ba=== +===bb=== +====bba==== +===bc=== +==c== +===ca=== +!! html/php +===aa=== +====aaa==== +!! end + +!! test +Section extraction test (section 3) +!! options +section=3 +!! wikitext +start +==a== +===aa=== +====aaa==== +==b== +===ba=== +===bb=== +====bba==== +===bc=== +==c== +===ca=== +!! html/php +====aaa==== +!! end + +!! test +Section extraction test (section 4) +!! options +section=4 +!! wikitext +start +==a== +===aa=== +====aaa==== +==b== +===ba=== +===bb=== +====bba==== +===bc=== +==c== +===ca=== +!! html/php +==b== +===ba=== +===bb=== +====bba==== +===bc=== +!! end + +!! test +Section extraction test (section 5) +!! options +section=5 +!! wikitext +start +==a== +===aa=== +====aaa==== +==b== +===ba=== +===bb=== +====bba==== +===bc=== +==c== +===ca=== +!! html/php +===ba=== +!! end + +!! test +Section extraction test (section 6) +!! options +section=6 +!! wikitext +start +==a== +===aa=== +====aaa==== +==b== +===ba=== +===bb=== +====bba==== +===bc=== +==c== +===ca=== +!! html/php +===bb=== +====bba==== +!! end + +!! test +Section extraction test (section 7) +!! options +section=7 +!! wikitext +start +==a== +===aa=== +====aaa==== +==b== +===ba=== +===bb=== +====bba==== +===bc=== +==c== +===ca=== +!! html/php +====bba==== +!! end + +!! test +Section extraction test (section 8) +!! options +section=8 +!! wikitext +start +==a== +===aa=== +====aaa==== +==b== +===ba=== +===bb=== +====bba==== +===bc=== +==c== +===ca=== +!! html/php +===bc=== +!! end + +!! test +Section extraction test (section 9) +!! options +section=9 +!! wikitext +start +==a== +===aa=== +====aaa==== +==b== +===ba=== +===bb=== +====bba==== +===bc=== +==c== +===ca=== +!! html/php +==c== +===ca=== +!! end + +!! test +Section extraction test (section 10) +!! options +section=10 +!! wikitext +start +==a== +===aa=== +====aaa==== +==b== +===ba=== +===bb=== +====bba==== +===bc=== +==c== +===ca=== +!! html/php +===ca=== +!! end + +!! test +Section extraction test (nonexistent section 11) +!! options +section=11 +!! wikitext +start +==a== +===aa=== +====aaa==== +==b== +===ba=== +===bb=== +====bba==== +===bc=== +==c== +===ca=== +!! html/php +!! end + +!! test +Section extraction test with bogus heading (section 1) +!! options +section=1 +!! wikitext +==a== +==bogus== not a legal section +==b== +!! html/php +==a== +==bogus== not a legal section +!! end + +!! test +Section extraction test with bogus heading (section 2) +!! options +section=2 +!! wikitext +==a== +==bogus== not a legal section +==b== +!! html/php +==b== +!! end + +!! test +Section extraction test with comment after heading (section 1) +!! options +section=1 +!! wikitext +==a== +==b== <!-- --> +==c== +!! html/php +==a== +!! end + +!! test +Section extraction test with comment after heading (section 2) +!! options +section=2 +!! wikitext +==a== +==b== <!-- --> +==c== +!! html/php +==b== <!-- --> +!! end + +!! test +Section extraction test with bogus <nowiki> heading (section 1) +!! options +section=1 +!! wikitext +==a== +==bogus== <nowiki>not a legal section</nowiki> +==b== +!! html/php +==a== +==bogus== <nowiki>not a legal section</nowiki> +!! end + +!! test +Section extraction test with bogus <nowiki> heading (section 2) +!! options +section=2 +!! wikitext +==a== +==bogus== <nowiki>not a legal section</nowiki> +==b== +!! html/php +==b== +!! end + +# Formerly testing for T4587, now resolved by the use of unmarked sections +# instead of respecting commented sections +!! test +Section extraction prefixed by comment (section 1) +!! options +section=1 +!! wikitext +<!-- -->==sec1== +==sec2== +!! html/php +==sec2== +!!end + +!! test +Section extraction prefixed by comment (section 2) +!! options +section=2 +!! wikitext +<!-- -->==sec1== +==sec2== +!! html/php + +!!end + +# Formerly testing for T4607, now resolved by the use of unmarked sections +# instead of respecting HTML-style headings +!! test +Section extraction, mixed wiki and html (section 1) +!! options +section=1 +!! wikitext +<h2>unmarked</h2> +unmarked +==1== +one +==2== +two +!! html/php +==1== +one +!! end + +!! test +Section extraction, mixed wiki and html (section 2) +!! options +section=2 +!! wikitext +<h2>unmarked</h2> +unmarked +==1== +one +==2== +two +!! html/php +==2== +two +!! end + + +# Formerly testing for T5342 +!! test +Section extraction, heading surrounded by <noinclude> +!! options +section=1 +!! wikitext +<noinclude>==unmarked==</noinclude> +==marked== +!! html/php +==marked== +!!end + +# Test behavior of T21910 +!! test +Sectiion with all-equals +!! options +section=2 +!! wikitext +=== +The line above must have a trailing space +=== <!-- +--> <!-- --> +But just in case it doesn't... +!! html/php +=== <!-- +--> <!-- --> +But just in case it doesn't... +!! end + +!! test +Section replacement test (section 0) +!! options +replace=0,"xxx" +!! wikitext +start +==a== +===aa=== +====aaa==== +==b== +===ba=== +===bb=== +====bba==== +===bc=== +==c== +===ca=== +!! html/php +xxx + +==a== +===aa=== +====aaa==== +==b== +===ba=== +===bb=== +====bba==== +===bc=== +==c== +===ca=== +!! end + +!! test +Section replacement test (section 1) +!! options +replace=1,"xxx" +!! wikitext +start +==a== +===aa=== +====aaa==== +==b== +===ba=== +===bb=== +====bba==== +===bc=== +==c== +===ca=== +!! html/php +start +xxx + +==b== +===ba=== +===bb=== +====bba==== +===bc=== +==c== +===ca=== +!! end + +!! test +Section replacement test (section 2) +!! options +replace=2,"xxx" +!! wikitext +start +==a== +===aa=== +====aaa==== +==b== +===ba=== +===bb=== +====bba==== +===bc=== +==c== +===ca=== +!! html/php +start +==a== +xxx + +==b== +===ba=== +===bb=== +====bba==== +===bc=== +==c== +===ca=== +!! end + +!! test +Section replacement test (section 3) +!! options +replace=3,"xxx" +!! wikitext +start +==a== +===aa=== +====aaa==== +==b== +===ba=== +===bb=== +====bba==== +===bc=== +==c== +===ca=== +!! html/php +start +==a== +===aa=== +xxx + +==b== +===ba=== +===bb=== +====bba==== +===bc=== +==c== +===ca=== +!! end + +!! test +Section replacement test (section 4) +!! options +replace=4,"xxx" +!! wikitext +start +==a== +===aa=== +====aaa==== +==b== +===ba=== +===bb=== +====bba==== +===bc=== +==c== +===ca=== +!! html/php +start +==a== +===aa=== +====aaa==== +xxx + +==c== +===ca=== +!! end + +!! test +Section replacement test (section 5) +!! options +replace=5,"xxx" +!! wikitext +start +==a== +===aa=== +====aaa==== +==b== +===ba=== +===bb=== +====bba==== +===bc=== +==c== +===ca=== +!! html/php +start +==a== +===aa=== +====aaa==== +==b== +xxx + +===bb=== +====bba==== +===bc=== +==c== +===ca=== +!! end + +!! test +Section replacement test (section 6) +!! options +replace=6,"xxx" +!! wikitext +start +==a== +===aa=== +====aaa==== +==b== +===ba=== +===bb=== +====bba==== +===bc=== +==c== +===ca=== +!! html/php +start +==a== +===aa=== +====aaa==== +==b== +===ba=== +xxx + +===bc=== +==c== +===ca=== +!! end + +!! test +Section replacement test (section 7) +!! options +replace=7,"xxx" +!! wikitext +start +==a== +===aa=== +====aaa==== +==b== +===ba=== +===bb=== +====bba==== +===bc=== +==c== +===ca=== +!! html/php +start +==a== +===aa=== +====aaa==== +==b== +===ba=== +===bb=== +xxx + +===bc=== +==c== +===ca=== +!! end + +!! test +Section replacement test (section 8) +!! options +replace=8,"xxx" +!! wikitext +start +==a== +===aa=== +====aaa==== +==b== +===ba=== +===bb=== +====bba==== +===bc=== +==c== +===ca=== +!! html/php +start +==a== +===aa=== +====aaa==== +==b== +===ba=== +===bb=== +====bba==== +xxx + +==c== +===ca=== +!!end + +!! test +Section replacement test (section 9) +!! options +replace=9,"xxx" +!! wikitext +start +==a== +===aa=== +====aaa==== +==b== +===ba=== +===bb=== +====bba==== +===bc=== +==c== +===ca=== +!! html/php +start +==a== +===aa=== +====aaa==== +==b== +===ba=== +===bb=== +====bba==== +===bc=== +xxx +!! end + +!! test +Section replacement test (section 10) +!! options +replace=10,"xxx" +!! wikitext +start +==a== +===aa=== +====aaa==== +==b== +===ba=== +===bb=== +====bba==== +===bc=== +==c== +===ca=== +!! html/php +start +==a== +===aa=== +====aaa==== +==b== +===ba=== +===bb=== +====bba==== +===bc=== +==c== +xxx +!! end + +!! test +Section replacement test with initial whitespace (T15728) +!! options +replace=2,"xxx" +!! wikitext + Preformatted initial line +==a== +===a=== +!! html/php + Preformatted initial line +==a== +xxx +!! end + + +!! test +Section extraction, heading followed by pre with 20 spaces (T8398) +!! options +section=1 +!! wikitext +==a== + a +!! html/php +==a== + a +!! end + +!! test +Section extraction, heading followed by pre with 19 spaces (T8398 sanity check) +!! options +section=1 +!! wikitext +==a== + a +!! html/php +==a== + a +!! end + + +!! test +Section extraction, <pre> around bogus header (T12309) +!! options +section=2 +!! wikitext +== Section One == +<pre> +======= +</pre> + +== Section Two == +stuff +!! html/php +== Section Two == +stuff +!! end + +!! test +Section replacement, <pre> around bogus header (T12309) +!! options +replace=2,"xxx" +!! wikitext +== Section One == +<pre> +======= +</pre> + +== Section Two == +stuff +!! html/php +== Section One == +<pre> +======= +</pre> + +xxx +!! end + +!! test +Handling of 
 in URLs +!! wikitext +*irc://
a +!! html/php +<ul><li><a rel="nofollow" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul> + +!! html/parsoid +<ul><li><a rel="mw:ExtLink" class="external free" href="irc://%0Aa" data-parsoid='{"stx":"url","a":{"href":"irc://%0Aa"},"sa":{"href":"irc://&#x0A;a"}}'>irc://%0Aa</a></li></ul> +!! end + +!! test +Handling of %0A in URLs +!! wikitext +*irc://%0Aa +!! html/php +<ul><li><a rel="nofollow" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul> + +!! html/parsoid +<ul><li><a rel="mw:ExtLink" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul> +!! end + +# The PHP parser strips the empty tags out for giggles; parsoid doesn't. +!! test +5 quotes, code coverage +1 line +!! options +parsoid=wt2html +!! wikitext +''''' +!! html/php +!! html/parsoid +<b><i></i></b> +!! end + +# same html as previous, but wikitext adjusted to match parsoid html2wt +# note that wt2html and html2html will put the <i> before the <b> +!! test +5 quotes, code coverage +1 line w/ nowiki (1) +!! options +parsoid=wt2wt,html2wt +!! wikitext +'''''<nowiki/>''''' +!! html/php +<p><i></i> +</p> +!! html/parsoid +<p><b><i></i></b></p> +!! end + +# same as previous, just swapping the <i> and <b> +!! test +5 quotes, code coverage +1 line w/ nowiki (2) +!! wikitext +'''''<nowiki/>''''' +!! html/php +<p><i></i> +</p> +!! html/parsoid +<p><i><b></b></i></p> +!! end + +!! test +Special:Search page linking. +!! wikitext +{{Special:search}} +!! html +<p><a href="/wiki/Special:Search" title="Special:Search">Special:Search</a> +</p> +!! end + +!! test +{{!}} is a magic word +!! wikitext +{{!}} is a magic word there and {{!}} is still a magic word here +| is not a magic word here but {{!}} is still a magic word here +!! html/php +<p>| is a magic word there and | is still a magic word here +| is not a magic word here but | is still a magic word here +</p> +!! html/parsoid +<p><span about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[]]}' data-mw='{"parts":[{"template":{"target":{"wt":"!","function":"!"},"params":{},"i":0}}]}'>|</span> is a magic word there and <span about="#mwt2" typeof="mw:Transclusion" data-parsoid='{"pi":[[]]}' data-mw='{"parts":[{"template":{"target":{"wt":"!","function":"!"},"params":{},"i":0}}]}'>|</span> is still a magic word here +| is not a magic word here but <span about="#mwt3" typeof="mw:Transclusion" data-parsoid='{"pi":[[]]}' data-mw='{"parts":[{"template":{"target":{"wt":"!","function":"!"},"params":{},"i":0}}]}'>|</span> is still a magic word here</p> +!! end + +!! test +Say the magic word +!! options +title=[[Parser test]] +!! wikitext +*{{PAGENAME}} +*{{PAGENAMEE}} +*{{FULLPAGENAME}} +*{{FULLPAGENAMEE}} +*{{BASEPAGENAME}} +*{{BASEPAGENAMEE}} +*{{SUBPAGENAME}} +*{{SUBPAGENAMEE}} +*{{ROOTPAGENAME}} +*{{ROOTPAGENAMEE}} +*{{TALKPAGENAME}} +*{{TALKPAGENAMEE}} +*{{SUBJECTPAGENAME}} +*{{SUBJECTPAGENAMEE}} +*{{NAMESPACEE}} +*{{NAMESPACE}} +*{{NAMESPACENUMBER}} +*{{TALKSPACE}} +*{{TALKSPACEE}} +*{{SUBJECTSPACE}} +*{{SUBJECTSPACEE}} +*{{Dynamic|{{NUMBEROFUSERS}}|{{NUMBEROFPAGES}}|{{CURRENTVERSION}}|{{CONTENTLANGUAGE}}|{{DIRECTIONMARK}}|{{CURRENTTIMESTAMP}}|{{NUMBEROFARTICLES}}}} +!! html +<ul><li>Parser test</li> +<li>Parser_test</li> +<li>Parser test</li> +<li>Parser_test</li> +<li>Parser test</li> +<li>Parser_test</li> +<li>Parser test</li> +<li>Parser_test</li> +<li>Parser test</li> +<li>Parser_test</li> +<li>Talk:Parser test</li> +<li>Talk:Parser_test</li> +<li>Parser test</li> +<li>Parser_test</li> +<li></li> +<li></li> +<li>0</li> +<li>Talk</li> +<li>Talk</li> +<li></li> +<li></li> +<li><a href="/index.php?title=Template:Dynamic&action=edit&redlink=1" class="new" title="Template:Dynamic (page does not exist)">Template:Dynamic</a></li></ul> + +!! end +### Note: Above tests excludes the "{{NUMBEROFADMINS}}" magic word because it generates a MySQL error when included. + +!! test +Gallery with valid attributes +!! wikitext +<gallery type="123" summary="345"> +File:File:Foobar.jpg +</gallery> +!! html/php +<ul class="gallery mw-gallery-traditional" type="123"> + <li class="gallerybox" style="width: 155px"><div style="width: 155px"> + <div class="thumb" style="height: 150px;">File:Foobar.jpg</div> + <div class="gallerytext"> + </div> + </div></li> +</ul> + +!! html/parsoid +<ul class="gallery mw-gallery-traditional" type="123" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{"type":"123","summary":"345"},"body":{"extsrc":"\nFile:File:Foobar.jpg\n"}}'> +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline typeof="mw:Error mw:Image"><a href="./File:File:Foobar.jpg"><img resource="./File:File:Foobar.jpg" src="./Special:FilePath/File:Foobar.jpg" height="120" width="120"/></a></figure-inline></div><div class="gallerytext"></div></li> +</ul> +!! end + +## Parsoid thinks the "centre" here is a property, not a caption. +!! test +Gallery +!! options +parsoid={ + "modes": ["wt2html"], + "nativeGallery": true +} +!! wikitext +<gallery> +image1.png | +image2.gif||||| + +image3| +image4 |300px| centre + image5.svg| http:///////// +[[x|xx]]]] +* image6 +</gallery> +!! html/php +<ul class="gallery mw-gallery-traditional"> + <li class="gallerybox" style="width: 155px"><div style="width: 155px"> + <div class="thumb" style="height: 150px;">Image1.png</div> + <div class="gallerytext"> + </div> + </div></li> + <li class="gallerybox" style="width: 155px"><div style="width: 155px"> + <div class="thumb" style="height: 150px;">Image2.gif</div> + <div class="gallerytext"> + </div> + </div></li> + <li class="gallerybox" style="width: 155px"><div style="width: 155px"> + <div class="thumb" style="height: 150px;">Image3</div> + <div class="gallerytext"> + </div> + </div></li> + <li class="gallerybox" style="width: 155px"><div style="width: 155px"> + <div class="thumb" style="height: 150px;">Image4</div> + <div class="gallerytext"> +<pre>centre +</pre> + </div> + </div></li> + <li class="gallerybox" style="width: 155px"><div style="width: 155px"> + <div class="thumb" style="height: 150px;">Image5.svg</div> + <div class="gallerytext"> +<p><a rel="nofollow" class="external free" href="http://///////">http://///////</a> +</p> + </div> + </div></li> + <li class="gallerybox" style="width: 155px"><div style="width: 155px"> + <div class="thumb" style="height: 150px;">* image6</div> + <div class="gallerytext"> + </div> + </div></li> +</ul> + +!! html/parsoid +<ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{},"body":{}}'> +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline typeof="mw:Error mw:Image"><a href="./File:Image1.png"><img resource="./File:Image1.png" src="./Special:FilePath/Image1.png" height="120" width="120"/></a></figure-inline></div><div class="gallerytext"></div></li> +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline typeof="mw:Error mw:Image"><a href="./File:Image2.gif"><img resource="./File:Image2.gif" src="./Special:FilePath/Image2.gif" height="120" width="120"/></a></figure-inline></div><div class="gallerytext"></div></li> +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline typeof="mw:Error mw:Image"><a href="./File:Image3"><img resource="./File:Image3" src="./Special:FilePath/Image3" height="120" width="120"/></a></figure-inline></div><div class="gallerytext"></div></li> +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline typeof="mw:Error mw:Image"><a href="./File:Image4"><img resource="./File:Image4" src="./Special:FilePath/Image4" height="300" width="300"/></a></figure-inline></div><div class="gallerytext"></div></li> +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline typeof="mw:Error mw:Image"><a href="./File:Image5.svg"><img resource="./File:Image5.svg" src="./Special:FilePath/Image5.svg" height="120" width="120"/></a></figure-inline></div><div class="gallerytext"> <a rel="mw:ExtLink" class="external free" href="http://///////">http://///////</a></div></li> +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline typeof="mw:Error mw:Image"><a href="./File:*_image6"><img resource="./File:*_image6" src="./Special:FilePath/*_image6" height="120" width="120"/></a></figure-inline></div><div class="gallerytext"></div></li> +</ul> +!! end + +!! test +Gallery (with options, html) +!! options +parsoid={ + "modes": ["wt2html", "html2html"], + "nativeGallery": true +} +!! wikitext +<gallery widths="70px" heights="40px" perrow="2" caption="Foo [[Main Page]]"> +File:Nonexistent.jpg|caption +File:Nonexistent.jpg +image:foobar.jpg|some '''caption''' [[Main Page]] +image:foobar.jpg +image:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla. +</gallery> +!! html/php +<ul class="gallery mw-gallery-traditional" style="max-width: 226px;_width: 226px;"> + <li class='gallerycaption'>Foo <a href="/wiki/Main_Page" title="Main Page">Main Page</a></li> + <li class="gallerybox" style="width: 105px"><div style="width: 105px"> + <div class="thumb" style="height: 70px;">Nonexistent.jpg</div> + <div class="gallerytext"> +<p>caption +</p> + </div> + </div></li> + <li class="gallerybox" style="width: 105px"><div style="width: 105px"> + <div class="thumb" style="height: 70px;">Nonexistent.jpg</div> + <div class="gallerytext"> + </div> + </div></li> + <li class="gallerybox" style="width: 105px"><div style="width: 105px"> + <div class="thumb" style="width: 100px;"><div style="margin:31px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/70px-Foobar.jpg" width="70" height="8" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/105px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/140px-Foobar.jpg 2x" /></a></div></div> + <div class="gallerytext"> +<p>some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a> +</p> + </div> + </div></li> + <li class="gallerybox" style="width: 105px"><div style="width: 105px"> + <div class="thumb" style="width: 100px;"><div style="margin:31px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/70px-Foobar.jpg" width="70" height="8" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/105px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/140px-Foobar.jpg 2x" /></a></div></div> + <div class="gallerytext"> + </div> + </div></li> + <li class="gallerybox" style="width: 105px"><div style="width: 105px"> + <div class="thumb" style="width: 100px;"><div style="margin:31px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="This is a foo-bar." src="http://example.com/images/thumb/3/3a/Foobar.jpg/70px-Foobar.jpg" width="70" height="8" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/105px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/140px-Foobar.jpg 2x" /></a></div></div> + <div class="gallerytext"> +<p>blabla. +</p> + </div> + </div></li> +</ul> + +!! html/parsoid +<ul class="gallery mw-gallery-traditional" style="max-width: 226px; _width: 226px;" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{"widths":"70px","heights":"40px","perrow":"2"},"body":{}}'> +<li class="gallerycaption">Foo <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></li> +<li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><figure-inline typeof="mw:Error mw:Image"><a href="./File:Nonexistent.jpg"><img resource="./File:Nonexistent.jpg" src="./Special:FilePath/Nonexistent.jpg" height="40" width="70"/></a></figure-inline></div><div class="gallerytext">caption</div></li> +<li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><figure-inline typeof="mw:Error mw:Image"><a href="./File:Nonexistent.jpg"><img resource="./File:Nonexistent.jpg" src="./Special:FilePath/Nonexistent.jpg" height="40" width="70"/></a></figure-inline></div><div class="gallerytext"></div></li> +<li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><figure-inline typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/70px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="8" width="70"/></a></figure-inline></div><div class="gallerytext">some <b>caption</b> <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></div></li> +<li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><figure-inline typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/70px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="8" width="70"/></a></figure-inline></div><div class="gallerytext"></div></li> +<li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><figure-inline typeof="mw:Image"><a href="./File:Foobar.jpg"><img alt="This is a foo-bar." resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/70px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="8" width="70"/></a></figure-inline></div><div class="gallerytext">blabla.</div></li> +</ul> +!! end + +!! test +Gallery (with options, extsrc) +!! options +parsoid={ + "nativeGallery": false +} +!! wikitext +<gallery widths="70px" heights="40px" perrow="2" caption="Foo [[Main Page]]"> +File:Nonexistent.jpg|caption +File:Nonexistent.jpg +image:foobar.jpg|some '''caption''' [[Main Page]] +image:foobar.jpg +image:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla. +</gallery> +!! html/php +<ul class="gallery mw-gallery-traditional" style="max-width: 226px;_width: 226px;"> + <li class='gallerycaption'>Foo <a href="/wiki/Main_Page" title="Main Page">Main Page</a></li> + <li class="gallerybox" style="width: 105px"><div style="width: 105px"> + <div class="thumb" style="height: 70px;">Nonexistent.jpg</div> + <div class="gallerytext"> +<p>caption +</p> + </div> + </div></li> + <li class="gallerybox" style="width: 105px"><div style="width: 105px"> + <div class="thumb" style="height: 70px;">Nonexistent.jpg</div> + <div class="gallerytext"> + </div> + </div></li> + <li class="gallerybox" style="width: 105px"><div style="width: 105px"> + <div class="thumb" style="width: 100px;"><div style="margin:31px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/70px-Foobar.jpg" width="70" height="8" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/105px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/140px-Foobar.jpg 2x" /></a></div></div> + <div class="gallerytext"> +<p>some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a> +</p> + </div> + </div></li> + <li class="gallerybox" style="width: 105px"><div style="width: 105px"> + <div class="thumb" style="width: 100px;"><div style="margin:31px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/70px-Foobar.jpg" width="70" height="8" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/105px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/140px-Foobar.jpg 2x" /></a></div></div> + <div class="gallerytext"> + </div> + </div></li> + <li class="gallerybox" style="width: 105px"><div style="width: 105px"> + <div class="thumb" style="width: 100px;"><div style="margin:31px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="This is a foo-bar." src="http://example.com/images/thumb/3/3a/Foobar.jpg/70px-Foobar.jpg" width="70" height="8" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/105px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/140px-Foobar.jpg 2x" /></a></div></div> + <div class="gallerytext"> +<p>blabla. +</p> + </div> + </div></li> +</ul> + +!! html/parsoid +<ul class="gallery mw-gallery-traditional" style="max-width: 226px; _width: 226px;" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{"widths":"70px","heights":"40px","perrow":"2","caption":"Foo [[Main Page]]"},"body":{"extsrc":"\nFile:Nonexistent.jpg|caption\nFile:Nonexistent.jpg\nimage:foobar.jpg|some '''caption''' [[Main Page]]\nimage:foobar.jpg\nimage:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla.\n"}}'> +<li class="gallerycaption">Foo <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></li> +<li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><figure-inline typeof="mw:Error mw:Image"><a href="./File:Nonexistent.jpg"><img resource="./File:Nonexistent.jpg" src="./Special:FilePath/Nonexistent.jpg" height="40" width="70"/></a></figure-inline></div><div class="gallerytext">caption</div></li> +<li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><figure-inline typeof="mw:Error mw:Image"><a href="./File:Nonexistent.jpg"><img resource="./File:Nonexistent.jpg" src="./Special:FilePath/Nonexistent.jpg" height="40" width="70"/></a></figure-inline></div><div class="gallerytext"></div></li> +<li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><figure-inline typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/70px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="8" width="70"/></a></figure-inline></div><div class="gallerytext">some <b>caption</b> <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></div></li> +<li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><figure-inline typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/70px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="8" width="70"/></a></figure-inline></div><div class="gallerytext"></div></li> +<li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><figure-inline typeof="mw:Image"><a href="./File:Foobar.jpg"><img alt="This is a foo-bar." resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/70px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="8" width="70"/></a></figure-inline></div><div class="gallerytext">blabla.</div></li> +</ul> +!! end + +!! test +Gallery (without px units) +!! wikitext +<gallery widths="70" heights="40"> +File:Foobar.jpg +</gallery> +!! html/php +<ul class="gallery mw-gallery-traditional"> + <li class="gallerybox" style="width: 105px"><div style="width: 105px"> + <div class="thumb" style="width: 100px;"><div style="margin:31px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/70px-Foobar.jpg" width="70" height="8" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/105px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/140px-Foobar.jpg 2x" /></a></div></div> + <div class="gallerytext"> + </div> + </div></li> +</ul> + +!! html/parsoid +<ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{"widths":"70","heights":"40"},"body":{"extsrc":"\nFile:Foobar.jpg\n"}}'> +<li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><figure-inline typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/70px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="8" width="70"/></a></figure-inline></div><div class="gallerytext"></div></li> +</ul> +!! end + +!! test +Gallery (with invalid units) +!! wikitext +<gallery widths="70em" heights="40em"> +File:Foobar.jpg +</gallery> +!! html/php +<ul class="gallery mw-gallery-traditional"> + <li class="gallerybox" style="width: 155px"><div style="width: 155px"> + <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div> + <div class="gallerytext"> + </div> + </div></li> +</ul> + +!! html/parsoid +<ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{"widths":"70em","heights":"40em"},"body":{"extsrc":"\nFile:Foobar.jpg\n"}}'> +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></figure-inline></div><div class="gallerytext"></div></li> +</ul> +!! end + +!! test +Gallery with link that has fragment +!! options +parsoid={ + "modes": ["wt2html", "html2html"], + "nativeGallery": true +} +!! wikitext +<gallery> +image:foobar.jpg|link=Main_Page +image:foobar.jpg|link=Main_Page#section +image:foobar.jpg|link=Main Page#section|caption +</gallery> +!! html/php +<ul class="gallery mw-gallery-traditional"> + <li class="gallerybox" style="width: 155px"><div style="width: 155px"> + <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/Main_Page"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div> + <div class="gallerytext"> + </div> + </div></li> + <li class="gallerybox" style="width: 155px"><div style="width: 155px"> + <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/Main_Page#section"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div> + <div class="gallerytext"> + </div> + </div></li> + <li class="gallerybox" style="width: 155px"><div style="width: 155px"> + <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/Main_Page#section"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div> + <div class="gallerytext"> +<p>caption +</p> + </div> + </div></li> +</ul> + +!! html/parsoid +<ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'> +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline typeof="mw:Image"><a href="./Main_Page"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></figure-inline></div><div class="gallerytext"></div></li> +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline typeof="mw:Image"><a href="./Main_Page#section"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></figure-inline></div><div class="gallerytext"></div></li> +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline typeof="mw:Image"><a href="./Main_Page#section"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></figure-inline></div><div class="gallerytext">caption</div></li> +</ul> +!! end + +## Whoops, Parsoid shouldn't be parsing templates in the attribute caption! +!! test +Gallery with template inside caption +!! options +parsoid={ + "nativeGallery": true +} +!! wikitext +<gallery caption="{{echo|hi}}"> +File:Foobar.jpg|{{echo|ho}} +</gallery> +!! html/php +<ul class="gallery mw-gallery-traditional"> + <li class='gallerycaption'>{{echo|hi}}</li> + <li class="gallerybox" style="width: 155px"><div style="width: 155px"> + <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div> + <div class="gallerytext"> +<p>ho +</p> + </div> + </div></li> +</ul> + +!! html/parsoid +<ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt6" data-mw='{"name":"gallery","attrs":{},"body":{}}'> +<li class="gallerycaption"><span about="#mwt3" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi"}},"i":0}}]}'>hi</span></li> +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></figure-inline></div><div class="gallerytext"><span about="#mwt5" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"ho"}},"i":0}}]}'>ho</span></div></li> +</ul> +!! end + +!! test +Gallery with wikitext inside caption +!! options +parsoid={ + "nativeGallery": true +} +!! wikitext +<gallery> +File:Foobar.jpg|alt=galleryalt|[[File:Foobar.jpg|alt=inneralt|20x20px|desc]] +File:Foobar.jpg|alt=galleryalt|{{Test|unamedParam|alt=param}} +</gallery> +!! html/php +<ul class="gallery mw-gallery-traditional"> + <li class="gallerybox" style="width: 155px"><div style="width: 155px"> + <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="galleryalt" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div> + <div class="gallerytext"> +<p><a href="/wiki/File:Foobar.jpg" class="image" title="desc"><img alt="inneralt" src="http://example.com/images/thumb/3/3a/Foobar.jpg/20px-Foobar.jpg" width="20" height="2" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/30px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/40px-Foobar.jpg 2x" /></a> +</p> + </div> + </div></li> + <li class="gallerybox" style="width: 155px"><div style="width: 155px"> + <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="galleryalt" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div> + <div class="gallerytext"> +<p>This is a test template +</p> + </div> + </div></li> +</ul> + +!! html/parsoid +<ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt6" data-mw='{"name":"gallery","attrs":{},"body":{}}'> +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline typeof="mw:Image"><a href="./File:Foobar.jpg"><img alt="galleryalt" resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></figure-inline></div><div class="gallerytext"><figure-inline typeof="mw:Image" data-mw='{"caption":"desc"}'><a href="./File:Foobar.jpg"><img alt="inneralt" resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/20px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="2" width="20"/></a></figure-inline></div></li> +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline typeof="mw:Image"><a href="./File:Foobar.jpg"><img alt="galleryalt" resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></figure-inline></div><div class="gallerytext"><span about="#mwt4" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"Test","href":"./Template:Test"},"params":{"1":{"wt":"unamedParam"},"alt":{"wt":"param"}},"i":0}}]}'>This is a test template</span></div></li> +</ul> +!! end + +!! test +Gallery (with showfilename option) +!! options +parsoid={ + "nativeGallery": true +} +!! wikitext +<gallery showfilename=""> +File:Nonexistent.jpg|caption +File:Nonexistent.jpg +File:Foobar.jpg|some '''caption''' [[Main Page]] +File:Foobar.jpg +</gallery> +!! html/php +<ul class="gallery mw-gallery-traditional"> + <li class="gallerybox" style="width: 155px"><div style="width: 155px"> + <div class="thumb" style="height: 150px;">Nonexistent.jpg</div> + <div class="gallerytext"> +<p><a href="/wiki/File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">Nonexistent.jpg</a> +caption +</p> + </div> + </div></li> + <li class="gallerybox" style="width: 155px"><div style="width: 155px"> + <div class="thumb" style="height: 150px;">Nonexistent.jpg</div> + <div class="gallerytext"> +<p><a href="/wiki/File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">Nonexistent.jpg</a> +</p> + </div> + </div></li> + <li class="gallerybox" style="width: 155px"><div style="width: 155px"> + <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div> + <div class="gallerytext"> +<p><a href="/wiki/File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">Foobar.jpg</a> +some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a> +</p> + </div> + </div></li> + <li class="gallerybox" style="width: 155px"><div style="width: 155px"> + <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div> + <div class="gallerytext"> +<p><a href="/wiki/File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">Foobar.jpg</a> +</p> + </div> + </div></li> +</ul> + +!! html/parsoid +<ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{"showfilename":""},"body":{}}'> +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline typeof="mw:Error mw:Image"><a href="./File:Nonexistent.jpg"><img resource="./File:Nonexistent.jpg" src="./Special:FilePath/Nonexistent.jpg" height="120" width="120"/></a></figure-inline></div><div class="gallerytext"><a href="./File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">File:Nonexistent.jpg</a>caption</div></li> +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline typeof="mw:Error mw:Image"><a href="./File:Nonexistent.jpg"><img resource="./File:Nonexistent.jpg" src="./Special:FilePath/Nonexistent.jpg" height="120" width="120"/></a></figure-inline></div><div class="gallerytext"><a href="./File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">File:Nonexistent.jpg</a></div></li> +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></figure-inline></div><div class="gallerytext"><a href="./File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">File:Foobar.jpg</a>some <b>caption</b> <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></div></li> +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></figure-inline></div><div class="gallerytext"><a href="./File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">File:Foobar.jpg</a></div></li> +</ul> +!! end + +## Should Parsoid be preserving these variations? See T151367 +!! test +Gallery (with namespace-less filenames) +!! options +parsoid={ + "modes": ["wt2html", "html2html"], + "nativeGallery": true +} +!! wikitext +<gallery> +File:Nonexistent.jpg +Nonexistent.jpg +image:foobar.jpg +foobar.jpg +</gallery> +!! html/php +<ul class="gallery mw-gallery-traditional"> + <li class="gallerybox" style="width: 155px"><div style="width: 155px"> + <div class="thumb" style="height: 150px;">Nonexistent.jpg</div> + <div class="gallerytext"> + </div> + </div></li> + <li class="gallerybox" style="width: 155px"><div style="width: 155px"> + <div class="thumb" style="height: 150px;">Nonexistent.jpg</div> + <div class="gallerytext"> + </div> + </div></li> + <li class="gallerybox" style="width: 155px"><div style="width: 155px"> + <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div> + <div class="gallerytext"> + </div> + </div></li> + <li class="gallerybox" style="width: 155px"><div style="width: 155px"> + <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div> + <div class="gallerytext"> + </div> + </div></li> +</ul> + +!! html/parsoid +<ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'> +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline typeof="mw:Error mw:Image"><a href="./File:Nonexistent.jpg"><img resource="./File:Nonexistent.jpg" src="./Special:FilePath/Nonexistent.jpg" height="120" width="120"/></a></figure-inline></div><div class="gallerytext"></div></li> +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline typeof="mw:Error mw:Image"><a href="./File:Nonexistent.jpg"><img resource="./File:Nonexistent.jpg" src="./Special:FilePath/Nonexistent.jpg" height="120" width="120"/></a></figure-inline></div><div class="gallerytext"></div></li> +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></figure-inline></div><div class="gallerytext"></div></li> +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></figure-inline></div><div class="gallerytext"></div></li> +</ul> +!! end + +!! test +Gallery override link with wikilink (T36852) +!! options +parsoid={ + "nativeGallery": true +} +!! wikitext +<gallery> +File:Foobar.jpg|alt=galleryalt|link=Wikilink +</gallery> +!! html/php +<ul class="gallery mw-gallery-traditional"> + <li class="gallerybox" style="width: 155px"><div style="width: 155px"> + <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/Wikilink"><img alt="galleryalt" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div> + <div class="gallerytext"> + </div> + </div></li> +</ul> + +!! html/parsoid +<ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'> +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline typeof="mw:Image"><a href="./Wikilink"><img alt="galleryalt" resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></figure-inline></div><div class="gallerytext"></div></li> +</ul> +!! end + +!! test +Gallery override link with absolute external link (T36852) +!! options +parsoid={ + "nativeGallery": true +} +!! wikitext +<gallery> +File:Foobar.jpg|alt=galleryalt|link=http://www.example.org +</gallery> +!! html/php +<ul class="gallery mw-gallery-traditional"> + <li class="gallerybox" style="width: 155px"><div style="width: 155px"> + <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="http://www.example.org"><img alt="galleryalt" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div> + <div class="gallerytext"> + </div> + </div></li> +</ul> + +!! html/parsoid +<ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'> +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline typeof="mw:Image"><a href="http://www.example.org"><img alt="galleryalt" resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></figure-inline></div><div class="gallerytext"></div></li> +</ul> +!! end + +!! test +Gallery override link with absolute external link with LanguageConverter +!! options +language=zh +!! wikitext +<gallery> +File:foobar.jpg|caption|alt=galleryalt|link=http://www.example.org +</gallery> +!! html/php +<ul class="gallery mw-gallery-traditional"> + <li class="gallerybox" style="width: 155px"><div style="width: 155px"> + <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="http://www.example.org"><img alt="galleryalt" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div> + <div class="gallerytext"> +<p>caption +</p> + </div> + </div></li> +</ul> + +!! html/parsoid +<ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{"extsrc":"\nFile:foobar.jpg|caption|alt=galleryalt|link=http://www.example.org\n"}}'> +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline typeof="mw:Image"><a href="http://www.example.org"><img alt="galleryalt" resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></figure-inline></div><div class="gallerytext">caption</div></li> +</ul> +!! end + +!! test +Gallery override link with malicious javascript (T36852) +!! options +parsoid={ + "modes": ["wt2html", "html2html"], + "nativeGallery": true +} +!! wikitext +<gallery> +File:Foobar.jpg|alt=galleryalt|link=" onclick="alert('malicious javascript code!'); +</gallery> +!! html/php +<ul class="gallery mw-gallery-traditional"> + <li class="gallerybox" style="width: 155px"><div style="width: 155px"> + <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/%22_onclick%3D%22alert(%27malicious_javascript_code!%27);"><img alt="galleryalt" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div> + <div class="gallerytext"> + </div> + </div></li> +</ul> + +!! html/parsoid +<ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'> +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline typeof="mw:Image"><a href="./%22_onclick=%22alert('malicious_javascript_code!');"><img alt="galleryalt" resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></figure-inline></div><div class="gallerytext"></div></li> +</ul> +!! end + +# Note that parsoid uses the invalid link as a caption, PHP does not. +!! test +Gallery with invalid title as link (T45964) +!! options +parsoid={ + "modes": ["wt2html", "html2html"], + "nativeGallery": true +} +!! wikitext +<gallery> +File:Foobar.jpg|link=< +</gallery> +!! html/php +<ul class="gallery mw-gallery-traditional"> + <li class="gallerybox" style="width: 155px"><div style="width: 155px"> + <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div> + <div class="gallerytext"> + </div> + </div></li> +</ul> + +!! html/parsoid +<ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'> +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></figure-inline></div><div class="gallerytext">link=<</div></li> +</ul> +!! end + +!! test +Serialize gallery without attrs in data-mw +!! options +parsoid={ + "modes": ["html2wt"], + "nativeGallery": true +} +!! html/parsoid +<ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","body":{}}'> +<li class="gallerycaption">123</li> +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span>File:Test.png</span></div><div class="gallerytext"></div></li> +</ul> +!! wikitext +<gallery caption="123"> +File:Test.png +</gallery> +!! end + +!! test +Gallery with class and style attributes +!! options +parsoid={ + "nativeGallery": true +} +!! wikitext +<gallery class="center" style="text-align: center;"> +File:Foobar.jpg +</gallery> +!! html/php +<ul class="gallery mw-gallery-traditional center" style="text-align: center;"> + <li class="gallerybox" style="width: 155px"><div style="width: 155px"> + <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div> + <div class="gallerytext"> + </div> + </div></li> +</ul> + +!! html/parsoid +<ul class="gallery mw-gallery-traditional center" style="text-align: center;" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{"class":"center","style":"text-align: center;"},"body":{}}'> +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></figure-inline></div><div class="gallerytext"></div></li> +</ul> +!! end + +!! test +Gallery in slideshow mode +!! options +parsoid={ + "nativeGallery": true +} +!! wikitext +<gallery mode="slideshow" showthumbnails=""> +File:Foobar.jpg +</gallery> +!! html/php +<ul class="gallery mw-gallery-slideshow" data-showthumbnails="1"> + <li class="gallerybox" style="width: 155px"><div style="width: 155px"> + <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div> + <div class="gallerytext"> + </div> + </div></li> +</ul> + +!! html/parsoid +<ul class="gallery mw-gallery-slideshow" data-showthumbnails="1" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{"mode":"slideshow","showthumbnails":""},"body":{}}'> +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px;"><figure-inline typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></figure-inline></div><div class="gallerytext"></div></li> +</ul> +!! end + +!! test +HTML Hex character encoding (spells the word "JavaScript") +!! options +parsoid=wt2html,wt2wt,html2html +!! wikitext +JavaScript +!! html/php +<p>JavaScript +</p> +!! html/parsoid +<p><span typeof="mw:Entity">J</span><span typeof="mw:Entity">a</span><span typeof="mw:Entity">v</span><span typeof="mw:Entity">a</span><span typeof="mw:Entity">S</span><span typeof="mw:Entity">c</span><span typeof="mw:Entity">r</span><span typeof="mw:Entity">i</span><span typeof="mw:Entity">p</span><span typeof="mw:Entity">t</span></p> +!! end + +!! test +HTML Hex character encoding bogus encoding (T28437 regression check) +!! wikitext +&#xsee;&#XSEE; +!! html +<p>&#xsee;&#XSEE; +</p> +!! end + +!! test +HTML Hex character encoding mixed case +!! options +parsoid=wt2html,wt2wt,html2html +!! wikitext +îî +!! html/php +<p>îî +</p> +!! html/parsoid +<p><span typeof="mw:Entity">î</span><span typeof="mw:Entity">î</span></p> +!! end + +# See: https://www.w3.org/TR/html5/syntax.html#character-references +# Note that U+000C (form feed) is not a valid XML character, so +# it is banned even though allowed in HTML5. +!! test +Illegal character references (T106578) +!! wikitext +; Null: � +; FF:  +; CR: 
 +; Control (low):  +; Control (high):  Ÿ +; Surrogate: �� +; This is an okay astral character: 💩 +!! html+tidy +<dl><dt>Null</dt> +<dd>&#00;</dd> +<dt>FF</dt> +<dd>&#xC;</dd> +<dt>CR</dt> +<dd>&#xD;</dd> +<dt>Control (low)</dt> +<dd>&#8;</dd> +<dt>Control (high)</dt> +<dd>&#x7F; &#x9F;</dd> +<dt>Surrogate</dt> +<dd>&#xD83D;&#xDCA9;</dd> +<dt>This is an okay astral character</dt> +<dd>💩</dd></dl> +!! end + +!! test +__FORCETOC__ override +!! wikitext +__NEWSECTIONLINK__ +__FORCETOC__ +!! html/php +<p><br /> +</p> +!! end + +!! test +ISBN code coverage +!! wikitext +ISBN 978-0-1234-56 789 +!! html/php +<p><a href="/wiki/Special:BookSources/9780123456" class="internal mw-magiclink-isbn">ISBN 978-0-1234-56</a> 789 +</p> +!! html/parsoid +<p><a href="./Special:BookSources/9780123456" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978-0-1234-56</a><span typeof="mw:Entity" data-parsoid='{"src":"&#x20;","srcContent":" "}'> </span>789</p> +!! end + +!! test +ISBN followed by 5 spaces +!! wikitext +ISBN +!! html +<p>ISBN +</p> +!! end + +!! test +Double ISBN +!! wikitext +ISBN ISBN 1234567890 +!! html/php +<p>ISBN <a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a> +</p> +!! html/parsoid +<p>ISBN <a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a></p> +!! end + +# Uppercase X and lowercase x as well +!! test +ISBN with an X +!! wikitext +ISBN 3-462-04561-X +ISBN 3-462-04561-x +ISBN 080442957X +ISBN 080442957x +ISBN 978080442957X +ISBN 978080442957x +!! html/php +<p><a href="/wiki/Special:BookSources/346204561X" class="internal mw-magiclink-isbn">ISBN 3-462-04561-X</a> +<a href="/wiki/Special:BookSources/346204561X" class="internal mw-magiclink-isbn">ISBN 3-462-04561-x</a> +<a href="/wiki/Special:BookSources/080442957X" class="internal mw-magiclink-isbn">ISBN 080442957X</a> +<a href="/wiki/Special:BookSources/080442957X" class="internal mw-magiclink-isbn">ISBN 080442957x</a> +<a href="/wiki/Special:BookSources/978080442957X" class="internal mw-magiclink-isbn">ISBN 978080442957X</a> +<a href="/wiki/Special:BookSources/978080442957X" class="internal mw-magiclink-isbn">ISBN 978080442957x</a> +</p> +!! html/parsoid +<p><a href="./Special:BookSources/346204561X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 3-462-04561-X</a> +<a href="./Special:BookSources/346204561X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 3-462-04561-x</a> +<a href="./Special:BookSources/080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 080442957X</a> +<a href="./Special:BookSources/080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 080442957x</a> +<a href="./Special:BookSources/978080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978080442957X</a> +<a href="./Special:BookSources/978080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978080442957x</a></p> +!! end + +!! test +ISBN with empty prefix (parsoid test) +!! wikitext +ISBN 1234567890 +!! html/php +<p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a> +</p> +!! html/parsoid +<p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink">ISBN 1234567890</a></p> +!! end + +!! test +T24905: <abbr> followed by ISBN followed by </a> +!! wikitext +<abbr>(fr)</abbr> ISBN 2753300917 [http://www.example.com example.com] +!! html/php +<p><abbr>(fr)</abbr> <a href="/wiki/Special:BookSources/2753300917" class="internal mw-magiclink-isbn">ISBN 2753300917</a> <a rel="nofollow" class="external text" href="http://www.example.com">example.com</a> +</p> +!! html/parsoid +<p><abbr data-parsoid='{"stx":"html"}'>(fr)</abbr> <a href="./Special:BookSources/2753300917" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 2753300917</a> <a rel="mw:ExtLink" class="external text" href="http://www.example.com">example.com</a></p> +!! end + +!! test +Double RFC +!! wikitext +RFC RFC 1234 +!! html +<p>RFC <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc1234">RFC 1234</a> +</p> +!! end + +!! test +Double RFC with a wiki link +!! wikitext +RFC [[RFC 1234]] +!! html +<p>RFC <a href="/index.php?title=RFC_1234&action=edit&redlink=1" class="new" title="RFC 1234 (page does not exist)">RFC 1234</a> +</p> +!! end + +!! test +RFC code coverage +!! wikitext +RFC 983 987 +!! html/php +<p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc983">RFC 983</a> 987 +</p> +!! html/parsoid +<p><a href="https://tools.ietf.org/html/rfc983" rel="mw:ExtLink" class="external text" data-parsoid='{"stx":"magiclink"}'>RFC 983</a><span typeof="mw:Entity" data-parsoid='{"src":"&#x20;","srcContent":" "}'> </span>987</p> +!! end + +!! test +Centre-aligned image +!! wikitext +[[Image:foobar.jpg|centre]] +!! html/php +<div class="center"><div class="floatnone"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div></div> + +!! html/parsoid +<figure class="mw-default-size mw-halign-center" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"center","ak":"centre"}]}'><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"Image:foobar.jpg"}}'/></a></figure> +!! end + +!! test +None-aligned image +!! wikitext +[[Image:foobar.jpg|none]] +!! html/php +<div class="floatnone"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div> + +!! html/parsoid +<figure class="mw-default-size mw-halign-none" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"Image:foobar.jpg"}}'/></a></figure> +!! end + +!! test +Width + Height sized image (using px) (height is ignored) +!! wikitext +[[Image:foobar.jpg|640x480px]] +!! html/php +<p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/640px-Foobar.jpg" width="640" height="73" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/960px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/1280px-Foobar.jpg 2x" /></a> +</p> +!! html/parsoid +<p><figure-inline typeof="mw:Image" data-parsoid='{"optList":[{"ck":"width","ak":"640x480px"}]}'><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/640px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="73" width="640" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"73","width":"640"},"sa":{"resource":"Image:foobar.jpg"}}'/></a></figure-inline></p> +!! end + +!! test +Width-sized image (using px, no following whitespace) +!! wikitext +[[Image:foobar.jpg|640px]] +!! html/php +<p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/640px-Foobar.jpg" width="640" height="73" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/960px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/1280px-Foobar.jpg 2x" /></a> +</p> +!! html/parsoid +<p><figure-inline typeof="mw:Image" data-parsoid='{"optList":[{"ck":"width","ak":"640px"}]}'><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/640px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="73" width="640" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"73","width":"640"},"sa":{"resource":"Image:foobar.jpg"}}'/></a></figure-inline></p> +!! end + +!! test +Width-sized image (using px, with following whitespace - test regression from r39467) +!! wikitext +[[Image:foobar.jpg|640px ]] +!! html/php +<p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/640px-Foobar.jpg" width="640" height="73" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/960px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/1280px-Foobar.jpg 2x" /></a> +</p> +!! html/parsoid +<p><figure-inline typeof="mw:Image" data-parsoid='{"optList":[{"ck":"width","ak":"640px "}]}'><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/640px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="73" width="640" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"73","width":"640"},"sa":{"resource":"Image:foobar.jpg"}}'/></a></figure-inline></p> +!!end + +!! test +Width-sized image (using px, with preceding whitespace - test regression from r39467) +!! wikitext +[[Image:foobar.jpg| 640px]] +!! html/php +<p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/640px-Foobar.jpg" width="640" height="73" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/960px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/1280px-Foobar.jpg 2x" /></a> +</p> +!! html/parsoid +<p><figure-inline typeof="mw:Image" data-parsoid='{"optList":[{"ck":"width","ak":" 640px"}]}'><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/640px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="73" width="640" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"73","width":"640"},"sa":{"resource":"Image:foobar.jpg"}}'/></a></figure-inline></p> +!! end + +!! test +Image with page parameter +!! options +djvu +!! wikitext +[[File:LoremIpsum.djvu|page=2]] +!! html/php +<p><a href="/index.php?title=File:LoremIpsum.djvu&page=2" class="image"><img alt="LoremIpsum.djvu" src="http://example.com/images/thumb/5/5f/LoremIpsum.djvu/page2-2480px-LoremIpsum.djvu.jpg" width="2480" height="3508" srcset="http://example.com/images/thumb/5/5f/LoremIpsum.djvu/page2-3720px-LoremIpsum.djvu.jpg 1.5x, http://example.com/images/thumb/5/5f/LoremIpsum.djvu/page2-4960px-LoremIpsum.djvu.jpg 2x" /></a> +</p> +!! html/parsoid +<p><figure-inline class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"page","ak":"page=2"}]}' data-mw='{"page":"2"}'><a href="./File:LoremIpsum.djvu" data-parsoid='{"a":{"href":"./File:LoremIpsum.djvu"},"sa":{"href":"File:LoremIpsum.djvu"}}'><img resource="./File:LoremIpsum.djvu" src="//example.com/images/5/5f/LoremIpsum.djvu" data-file-width="2480" data-file-height="3508" data-file-type="bitmap" height="3508" width="2480" data-parsoid='{"a":{"resource":"./File:LoremIpsum.djvu","height":"3508","width":"2480"},"sa":{"resource":"File:LoremIpsum.djvu"}}'/></a></figure-inline></p> +!! end + +!! test +Another italics / bold test +!! wikitext + ''' ''x' +!! html +<pre>'<i> </i>x' +</pre> +!!end + +# FIXME: The php output seems broken. It's interleaving some open/close tags. +!! test +dt/dd/dl test +!! wikitext +:;;;:: +!! html/php +<dl><dd><dl><dt><dl><dt><dl><dt><dl><dd><dl><dd></dt></dl></dd></dl></dd></dl></dd></dl></dd></dl></dd></dl> + +!! html/parsoid +<dl><dd><dl><dt><dl><dt><dl><dt><dl><dd><dl><dd></dd></dl></dd></dl></dt></dl></dt></dl></dt></dl></dd></dl> + +!!end + +# Images with the "|" character in external URLs in comment tags; Eats half the comment, leaves unmatched "</a>" tag. +!! test +Images with the "|" character in the comment +!! wikitext +[[File:Foobar.jpg|thumb|An [http://test/?param1=|left|¶m2=|x external] URL]] +!! html/php +<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>An <a rel="nofollow" class="external text" href="http://test/?param1=%7Cleft%7C&param2=%7Cx">external</a> URL</div></div></div> + +!! html/parsoid +<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption>An <a rel="mw:ExtLink" class="external text" href="http://test/?param1=%7Cleft%7C&param2=%7Cx" data-parsoid='{"a":{"href":"http://test/?param1=%7Cleft%7C&param2=%7Cx"},"sa":{"href":"http://test/?param1=|left|&param2=|x"}}'>external</a> URL</figcaption></figure> +!! end + +!! test +[Before] HTML without raw HTML enabled ($wgRawHtml==false) +!! wikitext +<html><script>alert(1);</script></html> +!! html +<p><html><script>alert(1);</script></html> +</p> +!! end + +!! test +HTML with raw HTML ($wgRawHtml==true) +!! options +wgRawHtml=1 +!! wikitext +<html><script>alert(1);</script></html> +!! html/php +<p><script>alert(1);</script> +</p> +!! end + +!! test +Parents of subpages, one level up +!! options +subpage title=[[Subpage test/L1/L2/L3]] +!! wikitext +[[../|L2]] +!! html +<p><a href="/index.php?title=Subpage_test/L1/L2&action=edit&redlink=1" class="new" title="Subpage test/L1/L2 (page does not exist)">L2</a> +</p> +!! end + + +!! test +Parents of subpages, one level up, not named +!! options +subpage title=[[Subpage test/L1/L2/L3]] +!! wikitext +[[../]] +!! html +<p><a href="/index.php?title=Subpage_test/L1/L2&action=edit&redlink=1" class="new" title="Subpage test/L1/L2 (page does not exist)">Subpage test/L1/L2</a> +</p> +!! end + + + +!! test +Parents of subpages, two levels up +!! options +subpage title=[[Subpage test/L1/L2/L3]] +!! wikitext +[[../../|L1]]2 + +[[../../|L1]]l +!! html +<p><a href="/index.php?title=Subpage_test/L1&action=edit&redlink=1" class="new" title="Subpage test/L1 (page does not exist)">L1</a>2 +</p><p><a href="/index.php?title=Subpage_test/L1&action=edit&redlink=1" class="new" title="Subpage test/L1 (page does not exist)">L1l</a> +</p> +!! end + +!! test +Parents of subpages, two levels up, without trailing slash or name. +!! options +subpage title=[[Subpage test/L1/L2/L3]] +!! wikitext +[[../..]] +!! html +<p>[[../..]] +</p> +!! end + +!! test +Parents of subpages, two levels up, with lots of extra trailing slashes. +!! options +subpage title=[[Subpage test/L1/L2/L3]] +!! wikitext +[[../../////]] +!! html +<p><a href="/index.php?title=Subpage_test/L1&action=edit&redlink=1" class="new" title="Subpage test/L1 (page does not exist)">Subpage test/L1</a> +</p> +!! end + +!! article +Subpage test/L1/L2/L3Sibling +!! text +Sibling article +!! endarticle + +!! test +Transclusion of a sibling page (one level up) +!! options +subpage title=[[Subpage test/L1/L2/L3]] +!! wikitext +{{../L3Sibling}} +!! html +<p>Sibling article +</p> +!! end + +!! test +Transclusion of a child page +!! options +subpage title=[[Subpage test/L1/L2]] +!! wikitext +{{/L3Sibling}} +!! html +<p>Sibling article +</p> +!! end + +# This is wt2html only in Parsoid because we add <nowiki> +# because of {{..}} and we don't expect to fix that to +# eliminate the nowikis selective for {{..}} markup. +!! test +Non-transclusion because of too many up levels +!! options +subpage title=[[Subpage test/L1/L2/L3]] +parsoid=wt2html +!! wikitext +{{../../../../More than parent}} +!! html/php +<p>{{../../../../More than parent}} +</p> +!! html/parsoid +<p>{{../../../../More than parent}}</p> +!! end + +!! test +Definition list code coverage +!! wikitext +;title : def +;title : def +;title: def +!! html/php +<dl><dt>title  </dt> +<dd>def</dd> +<dt>title </dt> +<dd>def</dd> +<dt>title</dt> +<dd>def</dd></dl> + +!! html/parsoid +<dl><dt>title <span typeof="mw:Placeholder"> </span></dt><dd> def</dd> +<dt>title<span typeof="mw:Placeholder"> </span></dt><dd> def</dd> +<dt>title</dt><dd> def</dd></dl> +!! end + +!! test +Don't fall for the self-closing div +!! wikitext +<div>hello world</div/> +!! html +<div>hello world</div> + +!! end + +!! test +MSGNW magic word +!! wikitext +{{MSGNW:msg}} +!! html/php +<p>[[:Template:Msg]] +</p> +!! end + +!! test +RAW magic word +!! wikitext +{{RAW:QUERTY}} +!! html +<p><a href="/index.php?title=Template:QUERTY&action=edit&redlink=1" class="new" title="Template:QUERTY (page does not exist)">Template:QUERTY</a> +</p> +!! end + +# This isn't needed for XHTML conformance, but would be handy as a fallback security measure +!! test +Always escape literal '>' in output, not just after '<' +!! wikitext +><> +!! html +<p>><> +</p> +!! end + +!! test +Template caching +!! wikitext +{{Test}} +{{Test}} +!! html +<p>This is a test template +This is a test template +</p> +!! end + + +!! article +MediaWiki:Fake +!! text +==header== +!! endarticle + +!! test +Inclusion of !userCanEdit() content +!! wikitext +{{MediaWiki:Fake}} +!! html +<h2><span class="mw-headline" id="header">header</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=MediaWiki:Fake&action=edit&section=T-1" title="MediaWiki:Fake">edit</a><span class="mw-editsection-bracket">]</span></span></h2> + +!! end + + +!! test +Out-of-order TOC heading levels +!! wikitext +==2== +======6====== +===3=== +=1= +=====5===== +==2== +!! html +<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div> +<ul> +<li class="toclevel-1 tocsection-1"><a href="#2"><span class="tocnumber">1</span> <span class="toctext">2</span></a> +<ul> +<li class="toclevel-2 tocsection-2"><a href="#6"><span class="tocnumber">1.1</span> <span class="toctext">6</span></a></li> +<li class="toclevel-2 tocsection-3"><a href="#3"><span class="tocnumber">1.2</span> <span class="toctext">3</span></a></li> +</ul> +</li> +<li class="toclevel-1 tocsection-4"><a href="#1"><span class="tocnumber">2</span> <span class="toctext">1</span></a> +<ul> +<li class="toclevel-2 tocsection-5"><a href="#5"><span class="tocnumber">2.1</span> <span class="toctext">5</span></a></li> +<li class="toclevel-2 tocsection-6"><a href="#2_2"><span class="tocnumber">2.2</span> <span class="toctext">2</span></a></li> +</ul> +</li> +</ul> +</div> + +<h2><span class="mw-headline" id="2">2</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: 2">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h6><span class="mw-headline" id="6">6</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: 6">edit</a><span class="mw-editsection-bracket">]</span></span></h6> +<h3><span class="mw-headline" id="3">3</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=3" title="Edit section: 3">edit</a><span class="mw-editsection-bracket">]</span></span></h3> +<h1><span class="mw-headline" id="1">1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=4" title="Edit section: 1">edit</a><span class="mw-editsection-bracket">]</span></span></h1> +<h5><span class="mw-headline" id="5">5</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=5" title="Edit section: 5">edit</a><span class="mw-editsection-bracket">]</span></span></h5> +<h2><span class="mw-headline" id="2_2">2</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=6" title="Edit section: 2">edit</a><span class="mw-editsection-bracket">]</span></span></h2> + +!! end + + +!! test +ISBN with a dummy number +!! wikitext +ISBN --- +!! html +<p>ISBN --- +</p> +!! end + + +!! test +ISBN with space-delimited number +!! wikitext +ISBN 92 9017 032 8 +!! html/php +<p><a href="/wiki/Special:BookSources/9290170328" class="internal mw-magiclink-isbn">ISBN 92 9017 032 8</a> +</p> +!! html/parsoid +<p data-parsoid='{"dsr":[0,18,0,0]}'><a href="./Special:BookSources/9290170328" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink","dsr":[0,18,2,2]}'>ISBN 92 9017 032 8</a></p> +!! end + + +!! test +ISBN with multiple spaces, no number +!! wikitext +ISBN foo +!! html +<p>ISBN foo +</p> +!! end + + +!! test +ISBN length +!! wikitext +ISBN 123456789 + +ISBN 1234567890 + +ISBN 12345678901 +!! html/php +<p>ISBN 123456789 +</p><p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a> +</p><p>ISBN 12345678901 +</p> +!! html/parsoid +<p>ISBN 123456789</p> + +<p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a></p> + +<p>ISBN 12345678901</p> +!! end + + +!! test +ISBN with trailing year (T9110) +!! wikitext +ISBN 1-234-56789-0 - 2006 + +ISBN 1 234 56789 0 - 2006 +!! html/php +<p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1-234-56789-0</a> - 2006 +</p><p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1 234 56789 0</a> - 2006 +</p> +!! html/parsoid +<p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1-234-56789-0</a> - 2006</p> + +<p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1 234 56789 0</a> - 2006</p> +!! end + + +!! test +anchorencode +!! config +wgFragmentMode=[ 'html5', 'legacy' ] +!! wikitext +{{anchorencode:foo bar©#%n}} +!! html/php +<p>foo_bar©#%n +</p> +!! html/parsoid +<p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode:foo bar©#%n","function":"anchorencode"},"params":{},"i":0}}]}'>foo_bar©#%n</p> +!! end + +!! test +anchorencode (legacy) +!! config +wgFragmentMode=[ 'legacy' ] +!! wikitext +{{anchorencode:foo bar©#%n}} +!! html/php +<p>foo_bar.C2.A9.23.25n +</p> +!! end + +!! test +anchorencode trims spaces +!! config +wgFragmentMode=[ 'html5', 'legacy' ] +!! wikitext +{{anchorencode: __pretty__please__}} +!! html/php +<p>pretty_please +</p> +!! html/parsoid +<p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: __pretty__please__","function":"anchorencode"},"params":{},"i":0}}]}'>pretty_please</p> +!! end + +!! test +anchorencode deals with links +!! config +wgFragmentMode=[ 'html5', 'legacy' ] +!! wikitext +{{anchorencode: [[hello|world]] [[hi]]}} +!! html/php +<p>world_hi +</p> +!! html/parsoid +<p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: [[hello|world]] [[hi]]","function":"anchorencode"},"params":{},"i":0}}]}'>world_hi</p> +!! end + +!! test +anchorencode deals with templates +!! config +wgFragmentMode=[ 'html5', 'legacy' ] +!! wikitext +{{anchorencode: {{Foo}} x}} +!! html/php +<p>FOO_x +</p> +!! html/parsoid +<p about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: {{Foo}} x","function":"anchorencode"},"params":{},"i":0}}]}'>FOO_x</p> +!! end + +!! test +anchorencode encodes like the TOC generator: (T20431) +!! config +wgFragmentMode=[ 'html5', 'legacy' ] +!! wikitext +===_ +:.3A%3A _ &&]] x=== +{{anchorencode: _ +:.3A%3A _ &&]] x}} +__NOEDITSECTION__ +!! html/php +<h3><span id=".2B:.3A.253A_.26.26.5D.5D_x"></span><span class="mw-headline" id="+:.3A%3A_&&]]_x">_ +:.3A%3A _ &&]] x</span></h3> +<p>+:.3A%3A_&&]]_x +</p> +!! html/parsoid +<h3 id="+:.3A%3A_&&]]_x"><span id=".2B:.3A.253A_.26.26.5D.5D_x" typeof="mw:FallbackId"></span>_ +:.3A%3A _ &<span typeof="mw:Entity" data-parsoid='{"src":"&amp;","srcContent":"&","dsr":[18,23,null,null]}'>&</span>]] x</h3> +<p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: _ +:.3A%3A _ &&amp;]] x","function":"anchorencode"},"params":{},"i":0}}]}'>+:.3A%3A_&&<span typeof="mw:Entity">]</span><span typeof="mw:Entity">]</span>_x</p> +<meta property="mw:PageProp/noeditsection"/> +!! end + +!! test +anchorencode encodes like the TOC generator: (T20431) (legacy) +!! config +wgFragmentMode=[ 'legacy' ] +!! wikitext +===_ +:.3A%3A&&]]=== +{{anchorencode: _ +:.3A%3A&&]] }} +__NOEDITSECTION__ +!! html/php +<h3><span class="mw-headline" id=".2B:.3A.253A.26.26.5D.5D">_ +:.3A%3A&&]]</span></h3> +<p>.2B:.3A.253A.26.26.5D.5D +</p> +!! end + +!! test +T8200: blockquotes and paragraph formatting +!! wikitext +<blockquote> +foo +</blockquote> + +bar + + baz +!! html +<blockquote> +<p>foo +</p> +</blockquote> +<p>bar +</p> +<pre>baz +</pre> +!! end + +!! test +T10293: Use of center tag ruins paragraph formatting +!! wikitext +<center> +foo +</center> + +bar + + baz +!! html +<center> +<p>foo +</p> +</center> +<p>bar +</p> +<pre>baz +</pre> +!! end + +!!test +Parsing of overlapping (improperly nested) inline html tags +!! wikitext +<span><s>x</span></s> +!! html/php +<p><span><s>x</span></s></span> +</p> +!! html/parsoid +<p><span><s>x</s></span> +</p> +!!end + +### +### Language variants related tests +### + +# Parsoid does not mark self-links. +# Parsoid does not convert links; PHP will do any necessary redirects. + +!! test +Self-link in language variants +!! options +title=[[Dunav]] language=sr +!! wikitext +Both [[Dunav]] and [[Дунав]] are names for this river. +!! html/php +<p>Both <a class="mw-selflink selflink">Dunav</a> and <a class="mw-selflink selflink">Дунав</a> are names for this river. +</p> +!! html/parsoid +<p>Both <a rel="mw:WikiLink" href="./Dunav" title="Dunav">Dunav</a> and <a rel="mw:WikiLink" href="./Дунав" title="Дунав">Дунав</a> are names for this river.</p> +!! end + +!! article +Дуна +!! text +content +!! endarticle + +!! test +Link to another existing title shouldn't be parsed as self-link even if it's a variant of this title +!! options +title=[[Duna]] language=sr +!! wikitext +[[Дуна]] is not a self-link while [[Duna]] and [[Dуна]] are still self-links. +!! html/php +<p><a href="/wiki/%D0%94%D1%83%D0%BD%D0%B0" title="Дуна">Дуна</a> is not a self-link while <a class="mw-selflink selflink">Duna</a> and <a class="mw-selflink selflink">Dуна</a> are still self-links. +</p> +!! html/parsoid +<p><a rel="mw:WikiLink" href="./Дуна" title="Дуна">Дуна</a> is not a self-link while <a rel="mw:WikiLink" href="./Duna" title="Duna">Duna</a> and <a rel="mw:WikiLink" href="./Dуна" title="Dуна">Dуна</a> are still self-links.</p> +!! end + +!! test +Link to a section of a variant of this title shouldn't be parsed as self-link +!! options +title=[[Duna]] language=sr +!! wikitext +[[Dуна]] is a self-link while [[Dunа#Foo]] and [[Dуна#Foo]] are not self-links. +!! html/php +<p><a class="mw-selflink selflink">Dуна</a> is a self-link while <a href="/wiki/%D0%94%D1%83%D0%BD%D0%B0" title="Дуна">Dunа#Foo</a> and <a href="/wiki/%D0%94%D1%83%D0%BD%D0%B0" title="Дуна">Dуна#Foo</a> are not self-links. +</p> +!! html/parsoid +<p><a rel="mw:WikiLink" href="./Dуна" title="Dуна">Dуна</a> is a self-link while <a rel="mw:WikiLink" href="./Dunа#Foo" title="Dunа">Dunа#Foo</a> and <a rel="mw:WikiLink" href="./Dуна#Foo" title="Dуна">Dуна#Foo</a> are not self-links.</p> +!! end + +!! test +Link to pages in language variants +!! options +language=sr +!! wikitext +Main Page can be written as [[Маин Паге]] +!! html/php +<p>Main Page can be written as <a href="/wiki/Main_Page" title="Main Page">Маин Паге</a> +</p> +!! html/parsoid +<p>Main Page can be written as <a rel="mw:WikiLink" href="./Маин_Паге" title="Маин Паге">Маин Паге</a></p> +!! end + + +!! test +Multiple links to pages in language variants +!! options +language=sr +!! wikitext +[[Main Page]] can be written as [[Маин Паге]] same as [[Маин Паге]]. +!! html/php +<p><a href="/wiki/Main_Page" title="Main Page">Main Page</a> can be written as <a href="/wiki/Main_Page" title="Main Page">Маин Паге</a> same as <a href="/wiki/Main_Page" title="Main Page">Маин Паге</a>. +</p> +!! html/parsoid +<p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a> can be written as <a rel="mw:WikiLink" href="./Маин_Паге" title="Маин Паге">Маин Паге</a> same as <a rel="mw:WikiLink" href="./Маин_Паге" title="Маин Паге">Маин Паге</a>.</p> +!! end + + +!! test +Simple template in language variants +!! options +language=sr +!! wikitext +{{тест}} +!! html/php +<p>This is a test template +</p> +!! end + + +!! test +Template with explicit namespace in language variants +!! options +language=sr +!! wikitext +{{Template:тест}} +!! html/php +<p>This is a test template +</p> +!! end + + +!! test +Basic test for template parameter in language variants +!! options +language=sr +!! wikitext +{{парамтест|param=foo}} +!! html/php +<p>This is a test template with parameter foo +</p> +!! end + +!! test +Simple category in language variants +!! options +language=sr cat +!! wikitext +[[Category:МедиаWики Усер'с Гуиде]] +!! html/php +cat=МедиаWики_Усер'с_Гуиде sort= +!! html/parsoid +<link rel="mw:PageProp/Category" href="./Категорија:МедиаWики_Усер'с_Гуиде" data-parsoid='{"stx":"simple","a":{"href":"./Категорија:МедиаWики_Усер'с_Гуиде"},"sa":{"href":"Category:МедиаWики Усер'с Гуиде"}}'/> +!! end + +!! article +Category:分类 +!! text +blah +!! endarticle + +!! article +Category:分類 +!! text +blah +!! endarticle + +## We used to, but no longer wt2wt this test since the default serializer +## will normalize all categories to serialize on their own line. +## This wikitext usage is going to be fairly uncommon in production and +## selser will take care of preserving formatting in those scenarios. +!! test +Don't convert blue categorylinks to another variant (T35210) +!! options +cat +language=zh +parsoid=wt2html +!! wikitext +[[A]][[Category:分类]] +!! html/php +cat=分类 sort= +!! html/parsoid +<p><a rel="mw:WikiLink" href="./A" title="A">A</a></p> +<link rel="mw:PageProp/Category" href="./Category:分类"/> +!! end + +!! test +Stripping -{}- tags (language variants) +!! options +language=sr +!! wikitext +Latin proverb: -{Ne nuntium necare}- +!! html/php +<p>Latin proverb: Ne nuntium necare +</p> +!! html/parsoid +<p>Latin proverb: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p> +!! end + + +!! test +Prevent conversion with -{}- tags (language variants) +!! options +language=sr variant=sr-ec +!! wikitext +Latinski: -{Ne nuntium necare}- +!! html/php +<p>Латински: Ne nuntium necare +</p> +!! html/parsoid +<p>Latinski: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p> +!! end + + +!! test +Prevent conversion of text with -{}- tags (language variants) +!! options +language=sr variant=sr-ec +!! wikitext +Latinski: -{Ne nuntium necare}- +!! html/php +<p>Латински: Ne nuntium necare +</p> +!! html/parsoid +<p>Latinski: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p> +!! end + + +!! test +Prevent conversion of links with -{}- tags (language variants) +!! options +language=sr variant=sr-ec +!! wikitext +-{[[Main Page]]}- +!! html/php +<p><a href="/wiki/Main_Page" title="Main Page">Main Page</a> +</p> +!! html/parsoid +<p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"<a rel=\"mw:WikiLink\" href=\"./Main_Page\" title=\"Main Page\" data-parsoid='{\"stx\":\"simple\",\"a\":{\"href\":\"./Main_Page\"},\"sa\":{\"href\":\"Main Page\"},\"dsr\":[2,15,2,2]}'>Main Page</a>"}}'></span></p> +!! end + + +!! test +-{}- tags within headlines (within html for parserConvert()) +!! config +wgFragmentMode=[ 'html5', 'legacy' ] +!! options +language=sr variant=sr-ec +!! wikitext +==-{Naslov}-== + +Note that even an unprotected headline ID is not affected by language +conversion: + +==Latinski== +!! html/php +<h2><span id="-.7BNaslov.7D-"></span><span class="mw-headline" id="-{Naslov}-">Naslov</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Уреди одељак „Naslov“">уреди</a><span class="mw-editsection-bracket">]</span></span></h2> +<p>Ноте тхат евен ан унпротецтед хеадлине ИД ис нот аффецтед бy лангуаге +цонверсион: +</p> +<h2><span class="mw-headline" id="Latinski">Латински</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=2" title="Уреди одељак „Латински“">уреди</a><span class="mw-editsection-bracket">]</span></span></h2> + +!! html/parsoid +<h2 id="-{Naslov}-"><span id="-.7BNaslov.7D-" typeof="mw:FallbackId"></span><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Naslov"}}'></span></h2> + +<p>Note that even an unprotected headline ID is not affected by language +conversion:</p> + +<h2 id="Latinski">Latinski</h2> +!! end + +!! test +Explicit definition of language variant alternatives +!! options +language=zh variant=zh-tw +!! wikitext +-{zh:China;zh-tw:Taiwan}-, not China +!! html/php +<p>Taiwan, not China +</p> +!! html/parsoid +<p><span typeof="mw:LanguageVariant" data-parsoid='{"tSp":[6]}' data-mw-variant='{"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'></span>, not China</p> +!! end + +!! test +Filter syntax for language variants +!! options +language=zh variant=zh-tw +!! wikitext +foo-{zh;zh-hans;zh-hant|blog, WEBJOURNAL, WEBLOG}-quux +!! html/php +<p>fooblog, WEBJOURNAL, WEBLOGquux +</p> +!! html/parsoid +<p>foo<span typeof="mw:LanguageVariant" data-mw-variant='{"filter":{"l":["zh","zh-hans","zh-hant"],"t":"blog, WEBJOURNAL, WEBLOG"}}'></span>quux</p> +!! end + +# Note that Parsoid post-processing for language variants needs to +# update the `title` attribute here, based on the mw:ExpandedAttrs property +!! test +Conversion around HTML tags +!! options +language=sr variant=sr-ec +!! wikitext +-{H|span=>sr-ec:script;title=>sr-ec:src}- +<span title="La-{sr-el:L;sr-ec:C}-tin">ski</span> +!! html/php +<p> +<span title="ЛаCтин">ски</span> +</p> +!! html/parsoid +<p><meta typeof="mw:LanguageVariant" data-parsoid='{"tSp":[8]}' data-mw-variant='{"add":true,"oneway":[{"f":"span","l":"sr-ec","t":"script"},{"f":"title","l":"sr-ec","t":"src"}]}'/> +<span title="Latin" typeof="mw:ExpandedAttrs" data-mw='{"attribs":[[{"txt":"title"},{"html":"La<span typeof=\"mw:LanguageVariant\" data-mw-variant='{\"twoway\":[{\"l\":\"sr-el\",\"t\":\"L\"},{\"l\":\"sr-ec\",\"t\":\"C\"}]}' data-parsoid='{\"fl\":[],\"tSp\":[6],\"dsr\":[57,76,null,2]}'></span>tin"}]]}'>ski</span></p> +!! end + +!! test +Explicit session-wise two-way language variant mapping (A flag and - flag) +!! options +language=zh variant=zh-tw +!! wikitext +This is -{zh:China; zh-tw:Taiwan}-, but we'll forget that now. + +Taiwan is not China. + +But -{A|zh:China; zh-tw:Taiwan}- is China, + +(This-{-|zh:China; zh-tw:Taiwan}- should be stripped!) + +and -{China}- is China. +!! html/php +<p>This is Taiwan, but we'll forget that now. +</p><p>Taiwan is not China. +</p><p>But Taiwan is Taiwan, +</p><p>(This should be stripped!) +</p><p>and China is China. +</p> +!! html/parsoid +<p>This is <span typeof="mw:LanguageVariant" data-mw-variant='{"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'></span>, but we'll forget that now.</p> +<p>Taiwan is not China.</p> +<p>But <span typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'></span> is China,</p> +<p>(This<meta typeof="mw:LanguageVariant" data-mw-variant='{"remove":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/> should be stripped!)</p> +<p>and <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"China"}}'></span> is China.</p> +!! end + +!! test +Explicit session-wise one-way language variant mapping (A flag and - flag) +!! options +language=zh variant=zh-tw +!! wikitext +This is -{COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}-, but we'll forget that now. + +COUNTRY is China or Taiwan. + +But -{A|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- is COUNTRY, + +(This-{-|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- should be stripped!) + +and -{COUNTRY}- is COUNTRY. +!! html/php +<p>This is Taiwan, but we'll forget that now. +</p><p>COUNTRY is China or Taiwan. +</p><p>But Taiwan is Taiwan, +</p><p>(This should be stripped!) +</p><p>and COUNTRY is COUNTRY. +</p> +!! html/parsoid +<p>This is <span typeof="mw:LanguageVariant" data-mw-variant='{"oneway":[{"f":"COUNTRY","l":"zh","t":"China"},{"f":"COUNTRY","l":"zh-tw","t":"Taiwan"}]}'></span>, but we'll forget that now.</p> +<p>COUNTRY is China or Taiwan.</p> +<p>But <span typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"COUNTRY","l":"zh","t":"China"},{"f":"COUNTRY","l":"zh-tw","t":"Taiwan"}]}'></span> is COUNTRY,</p> +<p>(This<meta typeof="mw:LanguageVariant" data-mw-variant='{"oneway":[{"f":"COUNTRY","l":"zh","t":"China"},{"f":"COUNTRY","l":"zh-tw","t":"Taiwan"}],"remove":true}'/> should be stripped!)</p> +<p>and <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"COUNTRY"}}'></span> is COUNTRY.</p> +!! end + +!! test +Explicit session-wise two-way language variant mapping (H flag for hide) +!! options +language=zh variant=zh-tw +!! wikitext +(This-{H|zh:China;zh-tw:Taiwan}- should be stripped!) + +Taiwan is China. +!! html/php +<p>(This should be stripped!) +</p><p>Taiwan is Taiwan. +</p> +!! html/parsoid +<p>(This<meta typeof="mw:LanguageVariant" data-parsoid='{"tSp":[6]}' data-mw-variant='{"add":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/> should be stripped!)</p> +<p>Taiwan is China.</p> +!! end + +!! test +Explicit session-wise one-way language variant mapping (H flag for hide) +!! options +language=zh variant=zh-tw +!! wikitext +(This-{H|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- should be stripped!) + +COUNTRY is Taiwan or China. +!! html/php +<p>(This should be stripped!) +</p><p>Taiwan is Taiwan or China. +</p> +!! html/parsoid +<p>(This<meta typeof="mw:LanguageVariant" data-parsoid='{"tSp":[8]}' data-mw-variant='{"add":true,"oneway":[{"f":"COUNTRY","l":"zh","t":"China"},{"f":"COUNTRY","l":"zh-tw","t":"Taiwan"}]}'/> should be stripped!)</p> +<p>COUNTRY is Taiwan or China.</p> +!! end + +## Note that parsoid test runner does not support 'showtitle' option. +!! test +Adding explicit conversion rule for title (T flag) +!! options +language=zh variant=zh-tw showtitle +!! wikitext +Should be stripped-{T|zh:China;zh-tw:Taiwan}-! + +Taiwan is China. +!! html/php +Taiwan +<p>Should be stripped! +</p><p>Taiwan is China. +</p> +!! html/parsoid +<p>Should be stripped<meta typeof="mw:LanguageVariant" data-parsoid='{"tSp":[6]}' data-mw-variant='{"title":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>!</p> +<p>Taiwan is China.</p> +!! end + +!! test +Code coverage: T combined with H flag +!! options +language=zh variant=zh-tw showtitle +!! wikitext +Should be stripped-{T;H|zh:China; zh-tw:Taiwan}-! + +Taiwan is China. +!! html/php +Taiwan +<p>Should be stripped! +</p><p>Taiwan is Taiwan. +</p> +!! html/parsoid +<p>Should be stripped<meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"title":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>!</p> +<p>Taiwan is China.</p> +!! end + +!! test +Code coverage: T with no variants +!! options +language=zh variant=zh-tw showtitle +!! wikitext +-{H|zh:China; zh-tw:Taiwan}- +Taiwan is China.-{T|Taiwan is China}- +!! html/php +Taiwan is China +<p> +Taiwan is Taiwan. +</p> +!! html/parsoid +<p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/> +Taiwan is China.<meta typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Taiwan is China"},"title":true}'/></p> +!! end + +!! test +Code coverage: rules with no variants +!! options +language=zh variant=zh-tw +!! wikitext +-{H|zh:China; zh-tw:Taiwan}- +Taiwan is China. +-{H|China}- +Taiwan is China. +!! html/php +<p> +Taiwan is Taiwan. + +Taiwan is China. +</p> +!! html/parsoid +<p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/> +Taiwan is China. +<meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"*","t":"China"}]}'/> +Taiwan is China.</p> +!! end + + +!! test +Code coverage: D flag for conversion rule +!! options +language=zh variant=zh-tw +!! wikitext +-{D|zh-cn:XA; zh-tw:YA}- +-{A;D|zh-cn:XB; zh-tw:YB}- +-{D;H|zh-cn:XC; zh-tw:YC}- + +-{D;H|FOO=>zh-tw:BAR;FOO=>zh-cn:BAT}- + +-{D|0=>zh-tw:1}- +-{A;D|2=>zh-tw:3}- +-{D;H|4=>zh-tw:5}- + +XA XB XC YA YB YC FOO BAR BAT 012345 +!! html/php +<p>大陆:XA;台灣:YA; + +大陆:XC;台灣:YC; +</p><p>FOO⇒台灣:BAR;FOO⇒大陆:BAT; +</p><p>0⇒台灣:1; + +4⇒台灣:5; +</p><p>XA YB YC YA YB YC BAR BAR BAT 013355 +</p> +!! html/parsoid +<p><span typeof="mw:LanguageVariant" data-mw-variant='{"describe":true,"twoway":[{"l":"zh-cn","t":"XA"},{"l":"zh-tw","t":"YA"}]}'></span> +<meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"twoway":[{"l":"zh-cn","t":"XB"},{"l":"zh-tw","t":"YB"}]}'/> +<span typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"twoway":[{"l":"zh-cn","t":"XC"},{"l":"zh-tw","t":"YC"}]}'></span></p> +<p><span typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"oneway":[{"f":"FOO","l":"zh-tw","t":"BAR"},{"f":"FOO","l":"zh-cn","t":"BAT"}]}'></span></p> +<p><span typeof="mw:LanguageVariant" data-mw-variant='{"describe":true,"oneway":[{"f":"0","l":"zh-tw","t":"1"}]}'></span> +<meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"oneway":[{"f":"2","l":"zh-tw","t":"3"}]}'/> +<span typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"oneway":[{"f":"4","l":"zh-tw","t":"5"}]}'></span></p> +<p>XA XB XC YA YB YC FOO BAR BAT 012345</p> +!! end + +!! test +Code coverage: N flag for conversion rule +!! options +language=zh variant=zh-cn +!! wikitext +-{N|zh-cn}- + +-{N|zh-tw}- + +-{N|sr-ec}- +!! html/php +<p>大陆 +</p><p>台灣 +</p><p>српски (ћирилица) +</p> +!! html/parsoid +<p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"zh-cn"}}'></span></p> +<p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"zh-tw"}}'></span></p> +<p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"sr-ec"}}'></span></p> +!! end + +# html2wt suppresses the bogus 'D' flag, so this is wt2html only +!! test +Code coverage: N flag for conversion rule (wt2html only) +!! options +language=zh variant=zh-cn +parsoid=wt2html,html2html +!! wikitext +-{D;N|en}- +!! html/php +<p>English +</p> +!! html/parsoid +<p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"en"}}' data-parsoid='{"fl":["D","N"]}'></span></p> +!! end + +!! test +Testing that changing the language variant here in the tests actually works +!! options +language=zh variant=zh showtitle +!! wikitext +Should be stripped-{T|zh:China; zh-tw:Taiwan}-! +!! html/php +China +<p>Should be stripped! +</p> +!! html/parsoid +<p>Should be stripped<meta typeof="mw:LanguageVariant" data-mw-variant='{"title":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>!</p> +!! end + +!! test +Recursive conversion of alt and title attrs shouldn't clear converter state +!! options +language=zh variant=zh-cn +showtitle +!! wikitext +-{H|zh-cn:Exclamation; zh-tw:exclamation}- +Should be stripped-{T|zh-cn:China; zh-tw:Taiwan}-<span title="exclamation">!</span> +!! html/php +China +<p> +Should be stripped<span title="Exclamation">!</span> +</p> +!! html/parsoid +<p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh-cn","t":"Exclamation"},{"l":"zh-tw","t":"exclamation"}]}'/> +Should be stripped<meta typeof="mw:LanguageVariant" data-mw-variant='{"title":true,"twoway":[{"l":"zh-cn","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/><span title="exclamation">!</span></p> +!! end + +!! test +T26072: more test on conversion rule for title +!! options +language=zh variant=zh-tw showtitle +!! wikitext +This should be stripped-{T|zh:China; zh-tw:Taiwan}-! + +This won't take interferes with the title rule-{H|zh:Beijing; zh-tw:Taipei}-. +!! html/php +Taiwan +<p>This should be stripped! +</p><p>This won't take interferes with the title rule. +</p> +!! html/parsoid +<p>This should be stripped<meta typeof="mw:LanguageVariant" data-mw-variant='{"title":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>!</p> +<p>This won't take interferes with the title rule<meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh","t":"Beijing"},{"l":"zh-tw","t":"Taipei"}]}'/>.</p> +!! end + +!! test +Partly disable title conversion if variant == main language code +!! options +language=zh variant=zh title=[[ZH]] showtitle +!! wikitext +-{T|zh-cn:CN;zh-tw:TW}- +!! html/php +ZH +<p> +</p> +!! html/parsoid +<p><meta typeof="mw:LanguageVariant" data-parsoid='{"tSp":[6]}' data-mw-variant='{"title":true,"twoway":[{"l":"zh-cn","t":"CN"},{"l":"zh-tw","t":"TW"}]}'/></p> +!! end + +!! test +Partly disable title conversion if variant == main language code, more +!! options +language=zh variant=zh title=[[ZH]] showtitle +!! wikitext +-{T|TW}- +!! html/php +ZH +<p> +</p> +!! html/parsoid +<p><meta typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"TW"},"title":true}'/></p> +!! end + +!! test +Raw output of variant escape tags (R flag) +!! options +language=zh variant=zh-tw +!! wikitext +Raw: -{R|zh:China;zh-tw:Taiwan}- +!! html/php +<p>Raw: zh:China;zh-tw:Taiwan +</p> +!! html/parsoid +<p>Raw: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"zh:China;zh-tw:Taiwan"}}'></span></p> +!! end + +# html2wt suppresses the bogus 'D' flags, so this is wt2html only +!! test +Raw output of variant escape tags (R flag) (wt2html only) +!! options +language=zh variant=zh-tw +parsoid=wt2html,html2html +!! wikitext +-{Variant}- -{D|syntax}- -{D;R|options}- +!! html/php +<p>Variant syntax options +</p> +!! html/parsoid +<p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Variant"}}'></span> <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"syntax"}}'></span> <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"options"}}'></span></p> +!! end + +!! test +Nested markup inside raw output of variant escape tags (R flag) +!! options +language=zh variant=zh-tw +!! wikitext +Nested raw: -{R|nested -{zh:China;zh-tw:Taiwan}- nested}- +!! html/php +<p>Nested raw: nested Taiwan nested +</p> +!! html/parsoid +<p>Nested raw: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"nested <span typeof=\"mw:LanguageVariant\" data-mw-variant='{\"twoway\":[{\"l\":\"zh\",\"t\":\"China\"},{\"l\":\"zh-tw\",\"t\":\"Taiwan\"}]}' data-parsoid='{\"fl\":[],\"tSp\":[6],\"dsr\":[23,48,null,2]}'></span> nested"}}'></span></p> +!! end + +!! test +Nested markup and spaces inside raw output of variant escape tags (R flag) +!! options +language=zh variant=zh-tw +!! wikitext +X-{ outer -{ inner }- outer }-X +!! html/php +<p>X outer inner outer X +</p> +!! html/parsoid +<p>X<span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":" outer <span typeof=\"mw:LanguageVariant\" data-mw-variant='{\"disabled\":{\"t\":\" inner \"}}' data-parsoid='{\"fl\":[],\"dsr\":[10,21,null,2]}'></span> outer "}}'></span>X</p> +!! end + +!! test +Templates inside raw output of variant escape tags (R flag) +!! options +language=zh variant=zh-tw +!! wikitext +Nested raw: -{R|nested {{echo|hi}} templates}- +!! html/php +<p>Nested raw: nested hi templates +</p> +!! html/parsoid +<p>Nested raw: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"nested <span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid='{\"pi\":[[{\"k\":\"1\"}]],\"dsr\":[23,34,null,null]}' data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"hi\"}},\"i\":0}}]}'>hi</span> templates"}}'></span></p> +!! end + +!! test +Strings evaluating false shouldn't be ignored by Language converter (T51072) +!! options +language=zh variant=zh-cn +!! wikitext +-{zh-cn:0;zh-sg:1;zh-tw:2;zh-hk:3}- +!! html/php +<p>0 +</p> +!! html/parsoid +<p><span typeof="mw:LanguageVariant" data-parsoid='{"tSp":[12]}' data-mw-variant='{"twoway":[{"l":"zh-cn","t":"0"},{"l":"zh-sg","t":"1"},{"l":"zh-tw","t":"2"},{"l":"zh-hk","t":"3"}]}'></span></p> +!! end + +!! test +Conversion rules from [numeric-only string] to [something else] (T48634) +!! options +language=zh variant=zh-cn +!! wikitext +-{H|0=>zh-cn:B}--{H|0=>zh-cn:C;0=>zh-cn:D}--{H|0=>zh-hans:A}-012345-{A|zh-tw:0;zh-cn:E;}-012345 +!! html/php +<p>D12345EE12345 +</p> +!! html/parsoid +<p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"0","l":"zh-cn","t":"B"}]}'/><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"0","l":"zh-cn","t":"C"},{"f":"0","l":"zh-cn","t":"D"}]}'/><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"0","l":"zh-hans","t":"A"}]}'/>012345<span typeof="mw:LanguageVariant" data-parsoid='{"fl":["A"],"tSp":[7]}' data-mw-variant='{"add":true,"twoway":[{"l":"zh-tw","t":"0"},{"l":"zh-cn","t":"E"}]}'></span>012345</p> +!! end + +!! test +Two-way converter rule entries with an empty value should be ignored (T53551) +!! options +language=zh variant=zh-cn +!! wikitext +-{H|zh-cn:foo;zh-tw:;}-foobar +!! html/php +<p>foobar +</p> +!! html/parsoid +<p><meta typeof="mw:LanguageVariant" data-parsoid='{"tSp":[7]}' data-mw-variant='{"add":true,"twoway":[{"l":"zh-cn","t":"foo"},{"l":"zh-tw","t":""}]}'/>foobar</p> +!! end + +!! test +One-way converter rule entries with an empty "from" string should be ignored (T53551) +!! options +language=zh variant=zh-cn +!! wikitext +-{H|=>zh-cn:foo;}-foobar +!! html/php +<p>foobar +</p> +!! html/parsoid +<p><meta typeof="mw:LanguageVariant" data-parsoid='{"tSp":[5]}' data-mw-variant='{"add":true,"oneway":[{"f":"","l":"zh-cn","t":"foo"}]}'/>foobar</p> +!! end + +!! test +Empty converter rule entries shouldn't be inserted into the conversion table (T53551) +!! options +language=zh variant=zh-cn +!! wikitext +-{H|}-foobar +!! html/php +<p>foobar +</p> +!! html/parsoid +<p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"*","t":""}]}'/>foobar</p> +!! end + +!! test +Nested using of manual convert syntax +!! options +language=zh variant=zh-hk +!! wikitext +Nested: -{zh-hans:Hi -{zh-cn:China;zh-sg:Singapore;}-;zh-hant:Hello -{zh-tw:Taiwan;zh-hk:H-{ong}- K-{}-ong;}-;}-! +!! html/php +<p>Nested: Hello Hong Kong! +</p> +!! html/parsoid +<p>Nested: <span typeof="mw:LanguageVariant" data-parsoid='{"tSp":[7]}' data-mw-variant='{"twoway":[{"l":"zh-hans","t":"Hi <span typeof=\"mw:LanguageVariant\" data-mw-variant='{\"twoway\":[{\"l\":\"zh-cn\",\"t\":\"China\"},{\"l\":\"zh-sg\",\"t\":\"Singapore\"}]}' data-parsoid='{\"fl\":[],\"tSp\":[7],\"dsr\":[21,53,null,2]}'></span>"},{"l":"zh-hant","t":"Hello <span typeof=\"mw:LanguageVariant\" data-mw-variant='{\"twoway\":[{\"l\":\"zh-tw\",\"t\":\"Taiwan\"},{\"l\":\"zh-hk\",\"t\":\"H&lt;span typeof=\\\"mw:LanguageVariant\\\" data-mw-variant=&apos;{\\\"disabled\\\":{\\\"t\\\":\\\"ong\\\"}}&apos; data-parsoid=&apos;{\\\"fl\\\":[],\\\"dsr\\\":[90,97,null,2]}&apos;>&lt;/span> K&lt;span typeof=\\\"mw:LanguageVariant\\\" data-mw-variant=&apos;{\\\"disabled\\\":{\\\"t\\\":\\\"\\\"}}&apos; data-parsoid=&apos;{\\\"fl\\\":[],\\\"dsr\\\":[99,103,null,2]}&apos;>&lt;/span>ong\"}]}' data-parsoid='{\"fl\":[],\"tSp\":[7],\"dsr\":[68,109,null,2]}'></span>"}]}'></span>!</p> +!! end + +!! test +HTML markups with conversion syntax in attribs, nested in other conversion blocks +!! options +language=zh variant=zh-cn +!! wikitext +-{zh;zh-hans;zh-hant|<span title="-{X}-">A</span>}- +!! html/php +<p><span title="X">A</span> +</p> +!! html/parsoid +<p><span typeof="mw:LanguageVariant" data-mw-variant='{"filter":{"l":["zh","zh-hans","zh-hant"],"t":"<span title=\"\" about=\"#mwt1\" typeof=\"mw:ExpandedAttrs\" data-parsoid='{\"stx\":\"html\",\"a\":{\"title\":\"\"},\"sa\":{\"title\":\"-{X}-\"},\"dsr\":[21,49,20,7]}' data-mw='{\"attribs\":[[{\"txt\":\"title\"},{\"html\":\"&lt;span typeof=\\\"mw:LanguageVariant\\\" data-mw-variant=&apos;{\\\"disabled\\\":{\\\"t\\\":\\\"X\\\"}}&apos; data-parsoid=&apos;{\\\"fl\\\":[],\\\"dsr\\\":[34,39,null,2]}&apos;>&lt;/span>\"}]]}'>A</span>"}}'></span></p> +!! end + +!! test +HTML markups with conversion syntax in attribs, nested in other conversion blocks (not working yet in PHP parser) +!! options +language=zh variant=zh-cn +!! wikitext +-{<span title="-{X}-">A</span>}- +!! html/php+disabled +<p><span title="X">A</span> +</p> +!! html/parsoid +<p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"<span title=\"\" about=\"#mwt1\" typeof=\"mw:ExpandedAttrs\" data-parsoid='{\"stx\":\"html\",\"a\":{\"title\":\"\"},\"sa\":{\"title\":\"-{X}-\"},\"dsr\":[2,30,20,7]}' data-mw='{\"attribs\":[[{\"txt\":\"title\"},{\"html\":\"&lt;span typeof=\\\"mw:LanguageVariant\\\" data-mw-variant=&apos;{\\\"disabled\\\":{\\\"t\\\":\\\"X\\\"}}&apos; data-parsoid=&apos;{\\\"fl\\\":[],\\\"dsr\\\":[15,20,null,2]}&apos;>&lt;/span>\"}]]}'>A</span>"}}'></span></p> +!! end + +# Parsoid and PHP disagree on how to parse this example: Parsoid +# insists that the content of a language converter element be a valid +# DOM fragment or attribute string +!! test +Language converter markup with block content +!! options +language=zh variant=zh-cn +!! wikitext +<span>a-{b<div>c}-d + +<span>a-{zh;zh-hans;zh-hant|b<div>c}-d + +<span>a-{H|0=>zh-cn:x<span>y;0=>zh-tw:b<div>c}-d +!! html/php+tidy +<span>ab<div>cd +<span>ab<div>cd +<span>ad +</span></div></span></div></span> +!! html/parsoid +<p><span data-parsoid='{"stx":"html","autoInsertedEnd":true}'>a</span></p><div typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"b<div data-parsoid='{\"stx\":\"html\",\"autoInsertedEnd\":true,\"dsr\":[10,16,5,0]}'>c</div>"}}'></div><p>d</p> + +<p><span data-parsoid='{"stx":"html","autoInsertedEnd":true}'>a</span></p><div typeof="mw:LanguageVariant" data-mw-variant='{"filter":{"l":["zh","zh-hans","zh-hant"],"t":"b<div data-parsoid='{\"stx\":\"html\",\"autoInsertedEnd\":true,\"dsr\":[50,56,5,0]}'>c</div>"}}'></div><p>d</p> + +<p><span data-parsoid='{"stx":"html","autoInsertedEnd":true}'>a<meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"0","l":"zh-cn","t":"x<span data-parsoid='{\"stx\":\"html\",\"autoInsertedEnd\":true,\"dsr\":[82,89,6,0]}'>y</span>"},{"f":"0","l":"zh-tw","t":"b<div data-parsoid='{\"stx\":\"html\",\"autoInsertedEnd\":true,\"dsr\":[100,106,5,0]}'>c</div>"}]}'/>d</span></p> +!! end + +!! test +LanguageConverter selser (1) +!! options +language=zh variant=zh-cn +parsoid={ + "modes": ["wt2wt", "selser"], + "changes": [ + ["span[typeof]", "attr", "data-mw-variant", "{\"disabled\":{\"t\":\"edited\"}}"] + ] +} +!! wikitext +-{raw}- +!! wikitext/edited +-{edited}- +!! end + +!! test +LanguageConverter selser (2) +!! options +language=zh variant=zh-cn +parsoid={ + "modes": ["wt2wt", "selser"], + "changes": [ + ["span[class='x']", "contents", "text", "-{foo}-"], + ["a", "contents", "text", "-{"], + ["span[typeof]", "attr", "data-mw", "{\"parts\":[{\"template\":{\"target\":{\"wt\":\"1x\",\"href\":\"./Template:1x\"},\"params\":{\"1\":{\"wt\":\"-{\"}},\"i\":0}}]}"] + ] +} +!! wikitext +<span class="x">TEXT1</span> +[http://example.com TEXT2] +[[Foo|TEXT3]] +{{echo|TEXT4}} +!! wikitext/edited +<span class="x"><nowiki>-{foo}-</nowiki></span> +[http://example.com -{] +[[Foo|<nowiki>-{</nowiki>]] +{{1x|<nowiki>-{</nowiki>}} +!! end + +# Tests LanguageVariantText in ConstrainedText +!! test +LanguageConverter selser (3) +!! options +language=zh variant=zh-cn +parsoid={ + "modes": ["wt2wt", "selser"], + "changes": [ + ["td > span", "attr", "typeof", "mw:LanguageVariant"], + ["td > span", "attr", "data-mw-variant", "{\"disabled\":{\"t\":\"edited\"}}"] + ] +} +!! wikitext +{| +|- +|<span>Foo</span> +|} +!! wikitext/edited +{| +|- +|<nowiki/>-{edited}- +|} +!! end + +# Tests LanguageVariantText._fromSelSer +!! test +LanguageConverter selser (4) +!! options +language=zh variant=zh-cn +parsoid={ + "modes": ["wt2wt", "selser"], + "changes": [ + ["td > span.x", "remove"] + ] +} +!! wikitext +{| +|- +|<span class="x">Foo</span>-{Bar}- +||<span class="x">Foo</span>-{Bar}- +|} +!! wikitext/edited +{| +|- +|<nowiki/>-{Bar}- +||-{Bar}- +|} +!! end + +# Since Parsoid is starting to emit canonical wikitext for links, +# [http://example.com http://example.com] will not RT back to that +# form anymore. +# Parsoid does not language-convert links (it is done in a +# post-processing step) +!! test +Proper conversion of text in external links +!! options +language=sr variant=sr-ec +parsoid=wt2html +!! wikitext +http://www.google.com +gopher://www.google.com +[http://www.google.com http://www.google.com] +[gopher://www.google.com gopher://www.google.com] +[https://www.google.com irc://www.google.com] +[ftp://www.google.com www.google.com/ftp://dir] +[//www.google.com www.google.com] +!! html/php +<p><a rel="nofollow" class="external free" href="http://www.google.com">http://www.google.com</a> +<a rel="nofollow" class="external free" href="gopher://www.google.com">gopher://www.google.com</a> +<a rel="nofollow" class="external text" href="http://www.google.com">http://www.google.com</a> +<a rel="nofollow" class="external text" href="gopher://www.google.com">gopher://www.google.com</a> +<a rel="nofollow" class="external text" href="https://www.google.com">irc://www.google.com</a> +<a rel="nofollow" class="external text" href="ftp://www.google.com">www.гоогле.цом/фтп://дир</a> +<a rel="nofollow" class="external text" href="//www.google.com">www.гоогле.цом</a> +</p> +!! html/parsoid +<p><a rel="mw:ExtLink" class="external free" href="http://www.google.com">http://www.google.com</a> +<a rel="mw:ExtLink" class="external free" href="gopher://www.google.com">gopher://www.google.com</a> +<a rel="mw:ExtLink" class="external free" href="http://www.google.com">http://www.google.com</a> +<a rel="mw:ExtLink" class="external free" href="gopher://www.google.com">gopher://www.google.com</a> +<a rel="mw:ExtLink" class="external text" href="https://www.google.com">irc://www.google.com</a> +<a rel="mw:ExtLink" class="external text" href="ftp://www.google.com">www.google.com/ftp://dir</a> +<a rel="mw:ExtLink" class="external text" href="//www.google.com">www.google.com</a></p> +!! end + +!! test +Do not convert roman numbers to language variants +!! options +language=sr variant=sr-ec +!! wikitext +Fridrih IV je car. +!! html/php +<p>Фридрих IV је цар. +</p> +!! html/parsoid +<p>Fridrih IV je car.</p> +!! end + +!! test +Unclosed language converter markup "-{" +!! options +language=sr +!! wikitext +-{T|hello +!! html +<p>-{T|hello +</p> +!! end + +!! test +Don't convert raw rule "-{R|=>}-" to "=>" +!! options +language=sr +!! wikitext +-{R|=>}- +!! html/php +<p>=> +</p> +!! html/parsoid +<p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"=<span typeof=\"mw:Entity\" data-parsoid='{\"src\":\"&amp;gt;\",\"srcContent\":\">\",\"dsr\":[5,9,null,null]}'>></span>"}}'></span></p> +!!end + +!! test +Don't break link parsing if language converter markup is in the caption. +!! options +language=sr variant=sr-ec +!! wikitext +[[Main Page|-{R|main page}-]] +!! html/php +<p><a href="/wiki/Main_Page" title="Маин Паге">main page</a> +</p> +!! html/parsoid +<p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page"><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"main page"}}' data-parsoid='{"fl":["R"]}'></span></a></p> +!! end + +!! test +T146304: Don't break template parsing if language converter markup is in the parameter. +!! options +language=sr variant=sr-ec +!! wikitext +{{echo|-{R|foo}-}} +!! html/php +<p>foo +</p> +!! html/parsoid +<p><span typeof="mw:Transclusion mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"foo"}}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Шаблон:Echo"},"params":{"1":{"wt":"-{R|foo}-"}},"i":0}}]}'></span></p> +!! end + +!! test +T146305: Don't break image parsing if language converter markup is in the caption. +!! options +language=sr +!! wikitext +[[Датотека:Foobar.jpg|thumb|-{R|caption:}-]] +!! html/php +<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/%D0%94%D0%B0%D1%82%D0%BE%D1%82%D0%B5%D0%BA%D0%B0:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/%D0%94%D0%B0%D1%82%D0%BE%D1%82%D0%B5%D0%BA%D0%B0:Foobar.jpg" class="internal" title="Повећај"></a></div>caption:</div></div></div> + +!! html/parsoid +<figure class="mw-default-size" typeof="mw:Image/Thumb" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"}]}'><a href="./Датотека:Foobar.jpg"><img resource="./Датотека:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"caption:"}}' data-parsoid='{"fl":["R"]}'></span></figcaption></figure> +!! end + +!! test +T146305: Don't break image parsing if nested language converter markup is in the caption. +!! options +language=zh variant=zh-cn +!! wikitext +[[File:Foobar.jpg|thumb|-{|zh-cn:blog (hk: -{zh-hans|WEBJOURNAL}-, tw: -{zh-hans|WEBLOG}-)}-]] +!! html/php +<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="放大"></a></div>blog (hk: WEBJOURNAL, tw: WEBLOG)</div></div></div> + +!! html/parsoid +<figure class="mw-default-size" typeof="mw:Image/Thumb" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"}]}'><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption><span typeof="mw:LanguageVariant" data-mw-variant='{"twoway":[{"l":"zh-cn","t":"blog (hk: <span typeof=\"mw:LanguageVariant\" data-mw-variant='{\"filter\":{\"l\":[\"zh-hans\"],\"t\":\"WEBJOURNAL\"}}' data-parsoid='{\"fl\":[\"zh-hans\"],\"dsr\":[43,65,null,2]}'></span>, tw: <span typeof=\"mw:LanguageVariant\" data-mw-variant='{\"filter\":{\"l\":[\"zh-hans\"],\"t\":\"WEBLOG\"}}' data-parsoid='{\"fl\":[\"zh-hans\"],\"dsr\":[71,89,null,2]}'></span>)"}]}'></span></figcaption></figure> +!! end + +# XXX html2wt disabled because rich markup in alt is not preserved. +!! test +Don't break gallery if language converter markup is inside. +!! options +language=zh +!! wikitext +<gallery> +File:foobar.jpg|[[File:foobar.jpg|20px|desc|alt=-{R|foo}-|-{R|bar}-]]|alt=-{R|bat}- +File:foobar.jpg|{{Test|unamedParam|alt=-{R|param}-}}|alt=galleryalt +</gallery> +!! html/php +<ul class="gallery mw-gallery-traditional"> + <li class="gallerybox" style="width: 155px"><div style="width: 155px"> + <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="bat" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div> + <div class="gallerytext"> +<p><a href="/wiki/File:Foobar.jpg" class="image" title="bar"><img alt="foo" src="http://example.com/images/thumb/3/3a/Foobar.jpg/20px-Foobar.jpg" width="20" height="2" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/30px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/40px-Foobar.jpg 2x" /></a> +</p> + </div> + </div></li> + <li class="gallerybox" style="width: 155px"><div style="width: 155px"> + <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="galleryalt" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div> + <div class="gallerytext"> +<p>This is a test template +</p> + </div> + </div></li> +</ul> + +!! html/parsoid +<ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt6" data-mw='{"name":"gallery","attrs":{},"body":{"extsrc":"\nFile:foobar.jpg|[[File:foobar.jpg|20px|desc|alt=-{R|foo}-|-{R|bar}-]]|alt=-{R|bat}-\nFile:foobar.jpg|{{Test|unamedParam|alt=-{R|param}-}}|alt=galleryalt\n"}}'> +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline typeof="mw:Image"><a href="./File:Foobar.jpg"><img alt="" resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></figure-inline></div><div class="gallerytext"><figure-inline typeof="mw:Image" data-mw='{"caption":"<span typeof=\"mw:LanguageVariant\" data-mw-variant='{\"disabled\":{\"t\":\"bar\"}}' data-parsoid='{\"fl\":[\"R\"],\"dsr\":[68,77,null,2]}'></span>"}'><a href="./File:Foobar.jpg"><img alt="" resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/20px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="2" width="20"/></a></figure-inline></div></li> +<li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline typeof="mw:Image"><a href="./File:Foobar.jpg"><img alt="galleryalt" resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></figure-inline></div><div class="gallerytext"><span about="#mwt4" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"Test","href":"./Template:Test"},"params":{"1":{"wt":"unamedParam"},"alt":{"wt":"-{R|param}-"}},"i":0}}]}'>This is a test template</span></div></li> +</ul> +!! end + +!! test +T153135: Don't break list handling if language converter markup is in the item. +!! options +language=zh variant=zh-cn +!! wikitext +;-{zh-cn:AAA;zh-tw:BBB}- +;-{R|foo:bar}- +!! html/php +<dl><dt>AAA</dt> +<dt>foo:bar</dt></dl> + +!! html/parsoid +<dl><dt data-parsoid='{"dsr":[0,24,1,0]}'><span typeof="mw:LanguageVariant" data-parsoid='{"tSp":[6]}' data-mw-variant='{"twoway":[{"l":"zh-cn","t":"AAA"},{"l":"zh-tw","t":"BBB"}]}'></span></dt> +<dt data-parsoid='{"dsr":[25,39,1,0]}'><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"foo:bar"}}'></span></dt> +</dl> +!! end + +// Note that parsoid does not protect colons unless language converter +// markup is properly nested, because it is a backtracking parser. +!! test +T153135: Unclosed markup in definition list (code coverage) +!! options +language=zh variant=zh-cn +!! wikitext +;<b>foo:bar +;-{zh-cn:AAA +!! html/php+tidy +<dl><dt><b>foo:bar</b></dt><b> +<dt>-{zh-cn:AAA</dt></b></dl><p><b> +</b></p> +!! html/parsoid +<dl><dt data-parsoid='{"dsr":[0,11,1,0]}'><b data-parsoid='{"stx":"html","autoInsertedEnd":true}'>foo:bar</b></dt><b data-parsoid='{"stx":"html","autoInsertedEnd":true,"autoInsertedStart":true}'> +<dt data-parsoid='{"dsr":[12,20,1,0]}'>-{zh-cn</dt> +<dd data-parsoid='{"stx":"row","dsr":[20,24,1,0]}'>AAA</dd> +</b></dl> +!! end + +!! test +T153135: Nested language converter markup in definition list (code coverage) +!! options +language=zh variant=zh-cn +!! wikitext +;-{|zh-cn:AAA -{zh-hans|foo:bar}- -{R|bat:baz}-}-:def +!! html/php +<dl><dt>AAA foo:bar bat:baz</dt> +<dd>def</dd></dl> + +!! html/parsoid +<dl><dt data-parsoid='{"dsr":[0,49,1,0]}'><span typeof="mw:LanguageVariant" data-mw-variant='{"twoway":[{"l":"zh-cn","t":"AAA <span typeof=\"mw:LanguageVariant\" data-mw-variant='{\"filter\":{\"l\":[\"zh-hans\"],\"t\":\"foo:bar\"}}' data-parsoid='{\"fl\":[\"zh-hans\"],\"dsr\":[14,33,null,2]}'></span> <span typeof=\"mw:LanguageVariant\" data-mw-variant='{\"disabled\":{\"t\":\"bat:baz\"}}' data-parsoid='{\"fl\":[\"R\"],\"dsr\":[34,47,null,2]}'></span>"}]}'></span></dt> +<dd data-parsoid='{"stx":"row","dsr":[49,53,1,0]}'>def</dd> +</dl> +!! end + +# html2wt mode disabled due to <nowiki> insertion. +!! test +T153140: Don't break table handling if language converter markup is in the cell. +!! options +language=sr variant=sr-ec +parsoid=wt2html,wt2wt,html2html +!! wikitext +{| +|- +| -{R|B}- +|} +!! html/php +<table> + +<tr> +<td>B +</td></tr></table> + +!! html/parsoid +<table> +<tbody> +<tr> +<td><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"B"}}'></span></td> +</tr> +</tbody> +</table> +!! end + +!! test +Language converter tricky html2wt cases (1) +!! options +language=sr +parsoid=html2wt,wt2wt +!! html/parsoid +<p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"}-"}}'></span></p> +!! wikitext +-{<nowiki>}-</nowiki>}- +!! html/php +<p>}- +</p> +!! end + +!! test +Language converter tricky html2wt cases (2) +!! options +language=sr +parsoid=html2wt,wt2wt +!! html/parsoid +<p>-{foo}-</p> +!! wikitext +<nowiki>-{foo}-</nowiki> +!! html/php +<p>-{foo}- +</p> +!! end + +!! test +Language converter tricky html2wt cases (3) +!! options +language=sr +parsoid=html2wt,wt2wt +!! html/parsoid +<p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"|"}}'></span></p> +<p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"R|raw"}}'></span></p> +<p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"-{foo}-"}}'></span></p> +!! wikitext +-{R||}- + +-{R|R|raw}- + +-{<nowiki>-{foo}-</nowiki>}- +!! html/php +<p>| +</p><p>R|raw +</p><p>-{foo}- +</p> +!! end + +!! test +Language converter tricky html2wt cases (4) +!! options +language=sr +parsoid=html2wt,wt2wt +!! html/parsoid +<p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"<span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid='{\"pi\":[[{\"k\":\"1\"}]],\"dsr\":[2,14,null,null]}' data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"hey\"}},\"i\":0}}]}'>hey</span>"}}'></span></p> +!! wikitext +-{R|{{echo|hey}}}- +!! html/php +<p>hey +</p> +!! end + +# Note that the <nowiki> escaping added by parsoid for source text, +# destination text, and language names only works on the PHP side +# for *destination text*. (HTML entity escaping wouldn't work +# any better.) This is probably a bug, at least for source texts. +# (For language names PHP uses a precise regexp based on the languages +# it currently knows have variants, which is fragile since this set +# can grow/shrink over time.) +!! test +Language converter tricky html2wt cases (5) +!! options +language=zh variant=zh-cn +!! html/parsoid +<p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"a:b=>c","l":"zh-cn","t":"x;foo=>zh-cn:boo"},{"f":"bar","l":"zh-cn","t":"bat;xyz=>zh-cn:abc"}]}'/>foobar</p> +<p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"A","l":"bo:g;us","t":"B"}]}'/></p> +<p><span typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh-tw","t":"xyz"},{"l":"zh-cn","t":"0;zh-tw:bar"}]}'></span></p> +<p><span typeof="mw:LanguageVariant" data-mw-variant='{"twoway":[{"l":"bo:g;us","t":"xyz"},{"l":"zh-cn","t":"abc"}]}'></span></p> +<p>a:b=>c xyz</p> +!! wikitext +-{H|<nowiki>a:b=>c</nowiki>=>zh-cn:<nowiki>x;foo=>zh-cn:boo</nowiki>;bar=>zh-cn:<nowiki>bat;xyz=>zh-cn:abc</nowiki>}-foobar + +-{H|A=><nowiki>bo:g;us</nowiki>:B}- + +-{A|zh-tw:xyz; zh-cn:<nowiki>0;zh-tw:bar</nowiki>}- + +-{<nowiki>bo:g;us</nowiki>:xyz; zh-cn:abc}- + +a:b=>c xyz +!! html/php+disabled +<p>foobat;xyz=>zh-cn:abc +</p><p>A +</p><p>0;zh-tw:bar +</p><p>abc +</p><p>a:b=>c 0;zh-tw:bar +</p> +!! end + +!! test +T179579: Nowiki and lc interaction +!! options +parsoid=wt2html +language=sr +!! wikitext +-{</nowiki>123}- + +-{123<nowiki>|</nowiki>456}- +!! html/parsoid +<p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"&lt;/nowiki>123"}}' data-parsoid='{"fl":[],"src":"-{</nowiki>123}-"}'></span></p> + +<p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"123<span typeof=\"mw:Nowiki\" data-parsoid='{\"dsr\":[23,41,8,9]}'>|</span>456"}}' data-parsoid='{"fl":[],"src":"-{123<nowiki>|</nowiki>456}-"}'></span></p> +!! end + +!! test +T2529: Uncovered bullet +!! wikitext +*Foo {{bullet}} +!! html +<ul><li>Foo</li> +<li>Bar</li></ul> + +!! end + +!! test +T2529: Uncovered bullet in a deeply nested list +!! wikitext +*******Foo {{bullet}} +!! html +<ul><li><ul><li><ul><li><ul><li><ul><li><ul><li><ul><li>Foo</li></ul></li></ul></li></ul></li></ul></li></ul></li></ul></li> +<li>Bar</li></ul> + +!! end + +!! test +T2529: Uncovered table already at line-start +!! wikitext +x + +{{table}} +y +!! html +<p>x +</p> +<table> +<tr> +<td>1</td> +<td>2 +</td></tr> +<tr> +<td>3</td> +<td>4 +</td></tr></table> +<p>y +</p> +!! end + +!! test +T2529: Uncovered bullet in parser function result +!! wikitext +*Foo {{lc:{{bullet}} }} +!! html +<ul><li>Foo</li> +<li>bar</li></ul> + +!! end + +!! test +T7678: Double-parsed template argument +!! wikitext +{{lc:{{{1}}}|hello}} +!! html +<p>{{{1}}} +</p> +!! end + +!! test +T7678: Double-parsed template invocation +!! wikitext +{{lc:{{paramtest {{!}} param = hello }} }} +!! html +<p>{{paramtest | param = hello }} +</p> +!! end + +!! test +Case insensitivity of parser functions for non-ASCII characters (T10143) +!! options +language=cs +title=[[Main Page]] +!! wikitext +{{PRVNÍVELKÉ:ěščř}} +{{prvnívelké:ěščř}} +{{PRVNÍMALÉ:ěščř}} +{{prvnímalé:ěščř}} +{{MALÁ:ěščř}} +{{malá:ěščř}} +{{VELKÁ:ěščř}} +{{velká:ěščř}} +!! html +<p>Ěščř +Ěščř +ěščř +ěščř +ěščř +ěščř +ĚŠČŘ +ĚŠČŘ +</p> +!! end + +!! test +Morwen/13: Unclosed link followed by heading +!! wikitext +[[link +==heading== +!! html +<p>[[link +</p> +<h2><span class="mw-headline" id="heading">heading</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: heading">edit</a><span class="mw-editsection-bracket">]</span></span></h2> + +!! end + +!! test +HHP2.1: Heuristics for headings in preprocessor parenthetical structures +!! wikitext +{{foo| +=heading= +!! html +<p>{{foo| +</p> +<h1><span class="mw-headline" id="heading">heading</span></h1> + +!! end + +!! test +HHP2.2: Heuristics for headings in preprocessor parenthetical structures +!! wikitext +{{foo| +==heading== +!! html +<p>{{foo| +</p> +<h2><span class="mw-headline" id="heading">heading</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: heading">edit</a><span class="mw-editsection-bracket">]</span></span></h2> + +!! end + +!! test +Tildes in comments +!! options +pst +!! wikitext +<!-- ~~~~ --> +!! html/php +<!-- ~~~~ --> +!! end + +!! test +Paragraphs inside divs (no extra line breaks) +!! wikitext +<div>Line one + +Line two</div> +!! html +<div>Line one +Line two</div> + +!! end + +!! test +Paragraphs inside divs (extra line break on open) +!! wikitext +<div> +Line one + +Line two</div> +!! html +<div> +<p>Line one +</p> +Line two</div> + +!! end + +!! test +Paragraphs inside divs (extra line break on close) +!! wikitext +<div>Line one + +Line two +</div> +!! html +<div>Line one +<p>Line two +</p> +</div> + +!! end + +!! test +Paragraphs inside divs (extra line break on open and close) +!! wikitext +<div> +Line one + +Line two +</div> +!! html +<div> +<p>Line one +</p><p>Line two +</p> +</div> + +!! end + +# doBlockLevels screws up this output and Remex cleans up as much as it can. +# Parsoid seems to do a better job here since its p-wrapper is probably smarter. +!! test +Nesting tags, paragraphs on lines which begin with <div> +!! wikitext +<div></div><strong>A +B</strong> +!! html/php+tidy +<div></div><p><strong>A +</strong></p><strong></strong><p><strong>B</strong> +</p> +!! html/parsoid +<div></div> +<p><strong>A +B</strong> +</p> +!! end + +# T8200: <blockquote> should behave like <div> with respect to line breaks +!! test +T8200: paragraphs inside blockquotes (no extra line breaks) +!! wikitext +<blockquote>Line one + +Line two</blockquote> +!! html +<blockquote>Line one +Line two</blockquote> + +!! html+tidy +<blockquote><p>Line one +Line two</p></blockquote> +!! end + +!! test +T8200: paragraphs inside blockquotes (extra line break on open) +!! wikitext +<blockquote> +Line one + +Line two</blockquote> +!! html +<blockquote> +<p>Line one +</p> +Line two</blockquote> + +!! html+tidy +<blockquote> +<p>Line one +</p><p> +Line two</p></blockquote> +!! end + +# Parsoid's output is broken on this because of Tidy-compatibility cruft +!! test +T8200: paragraphs inside blockquotes (extra line break on close) +!! wikitext +<blockquote>Line one + +Line two +</blockquote> +!! html +<blockquote>Line one +<p>Line two +</p> +</blockquote> + +!! html+tidy +<blockquote><p>Line one +</p><p>Line two +</p> +</blockquote> +!! end + +!! test +T8200: paragraphs inside blockquotes (extra line break on open and close) +!! wikitext +<blockquote> +Line one + +Line two +</blockquote> +!! html +<blockquote> +<p>Line one +</p><p>Line two +</p> +</blockquote> + +!! end + +# FIXME: Why does/should the blockquote+div combo suppress p-wrapping here? +!! test +Paragraphs inside blockquotes/divs (no extra line breaks) +!! wikitext +<blockquote><div>Line one + +Line two</div></blockquote> +!! html +<blockquote><div>Line one +Line two</div></blockquote> + +!! end + +!! test +Paragraphs inside blockquotes/divs (extra line break on open) +!! wikitext +<blockquote><div> +Line one + +Line two</div></blockquote> +!! html +<blockquote><div> +<p>Line one +</p> +Line two</div></blockquote> + +!! end + +!! test +Paragraphs inside blockquotes/divs (extra line break on close) +!! wikitext +<blockquote><div>Line one + +Line two +</div></blockquote> +!! html +<blockquote><div>Line one +<p>Line two +</p> +</div></blockquote> + +!! end + +!! test +Paragraphs inside blockquotes/divs (extra line break on open and close) +!! wikitext +<blockquote><div> +Line one + +Line two +</div></blockquote> +!! html +<blockquote><div> +<p>Line one +</p><p>Line two +</p> +</div></blockquote> + +!! end + +!! test +Interwiki links trounced by replaceExternalLinks after early LinkHolderArray expansion +!! options +wgLinkHolderBatchSize=0 +!! wikitext +[[meatball:1]] +[[meatball:2]] +[[meatball:3]] +!! html +<p><a href="http://www.usemod.com/cgi-bin/mb.pl?1" class="extiw" title="meatball:1">meatball:1</a> +<a href="http://www.usemod.com/cgi-bin/mb.pl?2" class="extiw" title="meatball:2">meatball:2</a> +<a href="http://www.usemod.com/cgi-bin/mb.pl?3" class="extiw" title="meatball:3">meatball:3</a> +</p> +!! end + +!! test +Free external link invading image caption +!! wikitext +[[Image:Foobar.jpg|thumb|http://x|hello]] +!! html/php +<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>hello</div></div></div> + +!! html/parsoid +<figure class="mw-default-size" typeof="mw:Image/Thumb" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"},{"ck":"bogus","ak":"http://x"},{"ck":"caption","ak":"hello"}]}'><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"25","width":"220"},"sa":{"resource":"Image:Foobar.jpg"}}'/></a><figcaption>hello</figcaption></figure> +!! end + +!! test +T17196: localised external link numbers +!! options +language=fa +!! wikitext +[http://en.wikipedia.org/] +!! html/php +<p><a rel="nofollow" class="external autonumber" href="http://en.wikipedia.org/">[۱]</a> +</p> +!! html/parsoid +<p><a rel="mw:ExtLink" class="external autonumber" href="http://en.wikipedia.org/"></a></p> +!! end + +!! test +Multibyte character in padleft +!! wikitext +{{padleft:-Hello|7|Æ}} +!! html/php +<p>Æ-Hello +</p> +!! html/parsoid +<p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padleft:-Hello","function":"padleft"},"params":{"1":{"wt":"7"},"2":{"wt":"Æ"}},"i":0}}]}'>Æ-Hello</p> +!! end + +!! test +Multibyte character in padright +!! wikitext +{{padright:Hello-|7|Æ}} +!! html/php +<p>Hello-Æ +</p> +!! html/parsoid +<p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padright:Hello-","function":"padright"},"params":{"1":{"wt":"7"},"2":{"wt":"Æ"}},"i":0}}]}'>Hello-Æ</p> +!! end + +!!test +formatdate parser function +!! wikitext +{{#formatdate:2009-03-24}} +!! html +<p><span class="mw-formatted-date" title="2009-03-24">2009-03-24</span> +</p> +!! end + +!!test +formatdate parser function, with default format +!! wikitext +{{#formatdate:2009-03-24|mdy}} +!! html +<p><span class="mw-formatted-date" title="2009-03-24">March 24, 2009</span> +</p> +!! end + +!! test +Spacing of numbers in formatted dates +!! wikitext +{{#formatdate:January 15}} +!! html +<p><span class="mw-formatted-date" title="01-15">January 15</span> +</p> +!! end + +!! test +formatdate parser function, with default format and on a page of which the content language is always English and different from the wiki content language +!! options +language=nl title=[[MediaWiki:Common.css]] +!! wikitext +{{#formatdate:2009-03-24|dmy}} +!! html +<p><span class="mw-formatted-date" title="2009-03-24">24 March 2009</span> +</p> +!! end + +# +# +# + +# +# Edit comments +# + +!! test +Edit comment with link +!! options +comment +!! wikitext +I like the [[Main Page]] a lot +!! html/php +I like the <a href="/wiki/Main_Page" title="Main Page">Main Page</a> a lot +!!end + +!! test +Edit comment with link and link text +!! options +comment +!! wikitext +I like the [[Main Page|best pages]] a lot +!! html/php +I like the <a href="/wiki/Main_Page" title="Main Page">best pages</a> a lot +!!end + +!! test +Edit comment with link and link text with suffix +!! options +comment +!! wikitext +I like the [[Main Page|best page]]s a lot +!! html/php +I like the <a href="/wiki/Main_Page" title="Main Page">best pages</a> a lot +!!end + +!! test +Edit comment with section link (non-local, eg in history list) +!! options +comment title=[[Main Page]] +!! wikitext +/* External links */ removed bogus entries +!! html/php +<a href="/wiki/Main_Page#External_links" title="Main Page">→</a><span dir="auto"><span class="autocomment">External links: </span> removed bogus entries</span> +!!end + +!! test +Edit comment with section link and text before it (non-local, eg in history list) +!! options +comment title=[[Main Page]] +!! wikitext +pre-comment text /* External links */ removed bogus entries +!! html/php +pre-comment text <a href="/wiki/Main_Page#External_links" title="Main Page">→</a><span dir="auto"><span class="autocomment">External links: </span> removed bogus entries</span> +!!end + +!! test +Edit comment with section link (local, eg in diff view) +!! options +comment local title=[[Main Page]] +!! wikitext +/* External links */ removed bogus entries +!! html/php +<a href="#External_links">→</a><span dir="auto"><span class="autocomment">External links: </span> removed bogus entries</span> +!!end + +!! test +Edit comment with subpage link (T16080) +!! options +comment +subpage +title=[[Subpage test]] +!! wikitext +Poked at a [[/subpage]] here... +!! html/php +Poked at a <a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a> here... +!!end + +!! test +Edit comment with subpage link and link text (T16080) +!! options +comment +subpage +title=[[Subpage test]] +!! wikitext +Poked at a [[/subpage|neat little page]] here... +!! html/php +Poked at a <a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">neat little page</a> here... +!!end + +!! test +Edit comment with bogus subpage link in non-subpage NS (T16080) +!! options +comment +title=[[Subpage test]] +!! wikitext +Poked at a [[/subpage]] here... +!! html/php +Poked at a <a href="/index.php?title=/subpage&action=edit&redlink=1" class="new" title="/subpage (page does not exist)">/subpage</a> here... +!!end + +!! test +Edit comment with bare anchor link (local, as on diff) +!! options +comment +local +title=[[Main Page]] +!! wikitext +[[#section]] +!! html/php +<a href="#section">#section</a> +!! end + +!! test +Edit comment with bare anchor link (non-local, as on history) +!! options +comment +title=[[Main Page]] +!! wikitext +[[#section]] +!! html/php +<a href="/wiki/Main_Page#section" title="Main Page">#section</a> +!! end + +!! test +Anchor starting with underscore +!! options +title=[[Foo]] +!! wikitext +[[#_ref|One]] +!! html/php +<p><a href="#_ref">One</a> +</p> +!! html/parsoid +<p><a rel="mw:WikiLink" href="./Foo#_ref" data-parsoid='{"stx":"piped","a":{"href":"./Foo#_ref"},"sa":{"href":"#_ref"}}'>One</a></p> +!! end + +!! test +Id starting with underscore +!! wikitext +<div id="_ref"></div> +!! html/* +<div id="_ref"></div> + +!! end + +!! test +Edit comment with link with more than one pipe (T99346) +!! options +comment +!! wikitext +[[Main Page|Many|pipes]] +!! html/php +<a href="/wiki/Main_Page" title="Main Page">Many|pipes</a> +!! end + +!! test +Complex edit comment with link with more than one pipe (T99346) +!! options +comment +!! wikitext +Created page with "<noinclude>[[Category:Requests for permissions/Bot|{{subst:#titleparts:{{subst:PAGENAME}}|1|3}}]]</noinclude> === [[User:MineoBot|]] 8=== {{Request for permissions/links|Mineo..." +!! html/php +Created page with "<noinclude><a href="/index.php?title=Category:Requests_for_permissions/Bot&action=edit&redlink=1" class="new" title="Category:Requests for permissions/Bot (page does not exist)">{{subst:#titleparts:{{subst:PAGENAME}}|1|3}}</a></noinclude> === <a href="/index.php?title=User:MineoBot&action=edit&redlink=1" class="new" title="User:MineoBot (page does not exist)">User:MineoBot</a> 8=== {{Request for permissions/links|Mineo..." +!! end + +!! test +Space normalisation on autocomment (T24784) +!! options +comment +title=[[Main Page]] +!! wikitext +/* __hello__world__ */ +!! html/php +<a href="/wiki/Main_Page#hello_world" title="Main Page">→</a><span dir="auto"><span class="autocomment">__hello__world__</span></span> +!! end + +!! test +percent-encoding and + signs in comments (T28410) +!! options +comment +!! wikitext +[[ABC%33D% ++]] [[ABC%33D% ++|+%20]] +!! html/php +<a href="/index.php?title=ABC3D%25_%2B%2B&action=edit&redlink=1" class="new" title="ABC3D% ++ (page does not exist)">ABC3D% ++</a> <a href="/index.php?title=ABC3D%25_%2B%2B&action=edit&redlink=1" class="new" title="ABC3D% ++ (page does not exist)">+%20</a> +!! end + +# Parsoid doesn't support this yet: see T75581 +# but it *should* omit the 'src' attribute if the image is bad. +# PHP side of tests was disabled in +# mediawiki/core:6bd31e7d95161a6e88fa86df60871051da997c3c +# because of issues in the PHP parserTests infrastructure +# (but the output below is indeed what the PHP side emits) +!! test +Bad images - basic functionality +!! wikitext +[[File:Bad.jpg]] +!! html/php+disabled +!! html/parsoid +<p><span class="mw-default-size" typeof="mw:Error mw:Image" data-mw='{"errors":[{"key":"bad-image","message":"This image is blacklisted in this context."}]}'><a href="./File:Bad.jpg"><img resource="./File:Bad.jpg" height="220" width="220"/></a></span></p> +!! end + +!! test +Bad images - T18039: text after bad image disappears +!! wikitext +Foo bar +[[File:Bad.jpg]] +Bar foo +!! html/php+disabled +<p>Foo bar +</p><p>Bar foo +</p> +!! html/parsoid +<p>Foo bar +<span class="mw-default-size" typeof="mw:Error mw:Image" data-mw='{"errors":[{"key":"bad-image","message":"This image is blacklisted in this context."}]}'><a href="./File:Bad.jpg"><img resource="./File:Bad.jpg" height="220" width="220"/></a></span> +Bar foo</p> +!! end + +!! test +Verify that displaytitle works (T24501) no displaytitle +!! options +showtitle +!! config +wgAllowDisplayTitle=true +wgRestrictDisplayTitle=false +!! wikitext +this is not the the title +!! html/php +Parser test +<p>this is not the the title +</p> +!! end + +!! test +Verify that displaytitle works (T24501) RestrictDisplayTitle=false +!! options +showtitle +title=[[Screen]] +!! config +wgAllowDisplayTitle=true +wgRestrictDisplayTitle=false +!! wikitext +this is not the the title +{{DISPLAYTITLE:whatever}} +!! html/php +whatever +<p>this is not the the title +</p> +!! end + +!! test +Verify that displaytitle works (T24501) RestrictDisplayTitle=true mismatch +!! options +showtitle +title=[[Screen]] +!! config +wgAllowDisplayTitle=true +wgRestrictDisplayTitle=true +!! wikitext +this is not the the title +{{DISPLAYTITLE:whatever}} +!! html/php +Screen +<p>this is not the the title +</p> +!! end + +!! test +Verify that displaytitle works (T24501) RestrictDisplayTitle=true matching +!! options +showtitle +title=[[Screen]] +!! config +wgAllowDisplayTitle=true +wgRestrictDisplayTitle=true +!! wikitext +this is not the the title +{{DISPLAYTITLE:screen}} +!! html/php +screen +<p>this is not the the title +</p> +!! end + +!! test +Verify that displaytitle works (T24501) AllowDisplayTitle=false +!! options +showtitle +title=[[Screen]] +!! config +wgAllowDisplayTitle=false +!! wikitext +this is not the the title +{{DISPLAYTITLE:screen}} +!! html/php +Screen +<p>this is not the the title +<a href="/index.php?title=Template:DISPLAYTITLE:screen&action=edit&redlink=1" class="new" title="Template:DISPLAYTITLE:screen (page does not exist)">Template:DISPLAYTITLE:screen</a> +</p> +!! end + +!! test +Verify that displaytitle works (T24501) AllowDisplayTitle=false no DISPLAYTITLE +!! options +showtitle +title=[[Screen]] +!! config +wgAllowDisplayTitle=false +!! wikitext +this is not the the title +!! html/php +Screen +<p>this is not the the title +</p> +!! end + +!! test +Verify that displaytitle handles inline CSS styles (T28547) - rejected value +!! options +showtitle +title=[[Screen]] +!! config +wgAllowDisplayTitle=true +wgRestrictDisplayTitle=true +!! wikitext +this is not the the title +{{DISPLAYTITLE:<span style="display: none;">s</span>creen}} +!! html/php +<span style="/* attempt to bypass $wgRestrictDisplayTitle */">s</span>creen +<p>this is not the the title +</p> +!! end + +!! test +Verify that displaytitle handles inline CSS styles (T28547) - accepted value +!! options +showtitle +title=[[Screen]] +!! config +wgAllowDisplayTitle=true +wgRestrictDisplayTitle=true +!! wikitext +this is not the the title +{{DISPLAYTITLE:<span style="color: red;">s</span>creen}} +!! html/php +<span style="color: red;">s</span>creen +<p>this is not the the title +</p> +!! end + +!! test +Page status indicators: Empty name is invalid +!! options +showindicators +!! wikitext +<indicator name=" "></indicator> +<indicator></indicator> +!! html/php +<p><span class="error"><strong>Error:</strong> Page status indicators' <code>name</code> attribute must not be empty.</span> +<span class="error"><strong>Error:</strong> Page status indicators' <code>name</code> attribute must not be empty.</span> +</p> +!! end + +!! test +Page status indicators: Weird syntaxes that are okay +!! options +showindicators +!! wikitext +<indicator name="empty" /> +<indicator name="name"></indicator> +!! html/php +empty= +name= +<p><br /> +</p> +!! end + +!! test +Page status indicators: Torture test +!! options +showindicators +!! wikitext +<indicator name="01">hello world</indicator> +<indicator name="02">[[Main Page]]</indicator> +<indicator name="03">[[File:Foobar.jpg|25px|link=]]</indicator> +<indicator name="04">[[File:Foobar.jpg|25px]]</indicator> +<indicator name="05">*foo +*bar</indicator> +<indicator name="06"><nowiki>foo</nowiki></indicator> +<indicator name="07"> Preformatted</indicator> +<indicator name="08"><div>Broken tag</indicator> +<indicator name="09">{| class=wikitable +|cell +|}</indicator> +<indicator name="10">Two + +paragraphs</indicator> +!! html/php +01=hello world +02=<a href="/wiki/Main_Page" title="Main Page">Main Page</a> +03=<img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/25px-Foobar.jpg" width="25" height="3" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/38px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/50px-Foobar.jpg 2x" /> +04=<a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/25px-Foobar.jpg" width="25" height="3" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/38px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/50px-Foobar.jpg 2x" /></a> +05=<ul><li>foo</li> +<li>bar</li></ul> + +06=foo +07=<pre>Preformatted +</pre> +08=<div>Broken tag</div> + +09=<table class="wikitable"> +<tr> +<td>cell +</td></tr></table> + +10=<p>Two +</p><p>paragraphs +</p> +<p><br /> +</p><p><br /> +</p><p><br /> +</p><p><br /> +</p><p><br /> +</p> +!! end + +!! test +preload: check <noinclude> and <includeonly> +!! options +preload +!! wikitext +Hello <noinclude>cruel</noinclude><includeonly>kind</includeonly> world. +!! html/php +Hello kind world. +!! end + +!! test +preload: check <onlyinclude> +!! options +preload +!! wikitext +Goodbye <onlyinclude>Hello world</onlyinclude> +!! html/php +Hello world +!! end + +!! test +preload: can pass tags through if we want to +!! options +preload +!! wikitext +<includeonly><</includeonly>includeonly>Hello world<includeonly><</includeonly>/includeonly> +!! html/php +<includeonly>Hello world</includeonly> +!! end + +!! test +preload: check that it doesn't try to do tricks +!! options +preload +!! wikitext +* <!-- Hello --> ''{{world}}'' {{<includeonly>subst:</includeonly>How are you}}{{ {{{|safesubst:}}} #if:1|2|3}} +!! html/php +* <!-- Hello --> ''{{world}}'' {{subst:How are you}}{{ {{{|safesubst:}}} #if:1|2|3}} +!! end + +!! test +Play a bit with r67090 and T5158 +!! wikitext +<div style="width:50% !important"> </div> +<div style="width:50% !important"> </div> +<div style="width:50% !important"> </div> +<div style="border : solid;"> </div> +!! html/php +<div style="width:50% !important"> </div> +<div style="width:50% !important"> </div> +<div style="width:50% !important"> </div> +<div style="border : solid;"> </div> + +!! html/parsoid +<div style="width:50% !important" data-parsoid='{"stx":"html"}'><span typeof="mw:Entity" data-parsoid='{"srcContent":" "}'> </span></div> +<div style="width:50% !important" data-parsoid='{"stx":"html","a":{"style":"width:50% !important"},"sa":{"style":"width:50%&nbsp;!important"}}'><span typeof="mw:Entity" data-parsoid='{"srcContent":" "}'> </span></div> +<div style="width:50% !important" data-parsoid='{"stx":"html","a":{"style":"width:50% !important"},"sa":{"style":"width:50%&#160;!important"}}'><span typeof="mw:Entity" data-parsoid='{"srcContent":" "}'> </span></div> +<div style="border : solid;" data-parsoid='{"stx":"html"}'><span typeof="mw:Entity" data-parsoid='{"srcContent":" "}'> </span></div> + +!! end + +!! test +HTML5 data attributes +!! wikitext +<span data-foo="bar">Baz</span> +<p data-abc-def_hij="">Quuz</p> +!! html/php +<p><span data-foo="bar">Baz</span> +</p> +<p data-abc-def_hij="">Quuz</p> + +!! html/parsoid +<p><span data-foo="bar" data-parsoid='{"stx":"html"}'>Baz</span></p> +<p data-abc-def_hij="" data-parsoid='{"stx":"html"}'>Quuz</p> +!! end + +!! test +Strip reserved data attributes +!! wikitext +<div data-mw="foo" data-parsoid="bar" data-mw-someext="baz" data-ok="fred" data-ooui="xyzzy" data-bad:ns="ns">d</div> +!! html/php +<div data-ok="fred">d</div> + +!! html/parsoid +<div data-x-data-mw="foo" data-x-data-parsoid="bar" data-x-data-mw-someext="baz" data-ok="fred" data-parsoid='{"stx":"html","a":{"data-ooui":null,"data-bad:ns":null},"sa":{"data-ooui":"xyzzy","data-bad:ns":"ns"}}'>d</div> +!! end + +!! test +percent-encoding and + signs in internal links (T28410) +!! wikitext +[[User:+%]] [[Page+title%]] +[[%+]] [[%+|%20]] [[%+ ]] [[%+r]] +[[%]] [[+]] [[File:%+abc%39|foo|[[bar]]]] +[[%33%45]] [[%33%45+]] +!! html/php +<p><a href="/index.php?title=User:%2B%25&action=edit&redlink=1" class="new" title="User:+% (page does not exist)">User:+%</a> <a href="/index.php?title=Page%2Btitle%25&action=edit&redlink=1" class="new" title="Page+title% (page does not exist)">Page+title%</a> +<a href="/index.php?title=%25%2B&action=edit&redlink=1" class="new" title="%+ (page does not exist)">%+</a> <a href="/index.php?title=%25%2B&action=edit&redlink=1" class="new" title="%+ (page does not exist)">%20</a> <a href="/index.php?title=%25%2B&action=edit&redlink=1" class="new" title="%+ (page does not exist)">%+ </a> <a href="/index.php?title=%25%2Br&action=edit&redlink=1" class="new" title="%+r (page does not exist)">%+r</a> +<a href="/index.php?title=%25&action=edit&redlink=1" class="new" title="% (page does not exist)">%</a> <a href="/index.php?title=%2B&action=edit&redlink=1" class="new" title="+ (page does not exist)">+</a> <a href="/index.php?title=Special:Upload&wpDestFile=%25%2Babc9" class="new" title="File:%+abc9">bar</a> +<a href="/index.php?title=3E&action=edit&redlink=1" class="new" title="3E (page does not exist)">3E</a> <a href="/index.php?title=3E%2B&action=edit&redlink=1" class="new" title="3E+ (page does not exist)">3E+</a> +</p> +!! html/parsoid +<p><a rel="mw:WikiLink" href="./User:+%25" title="User:+%" data-parsoid='{"stx":"simple","a":{"href":"./User:+%25"},"sa":{"href":"User:+%"}}'>User:+%</a> <a rel="mw:WikiLink" href="./Page+title%25" title="Page+title%" data-parsoid='{"stx":"simple","a":{"href":"./Page+title%25"},"sa":{"href":"Page+title%"}}'>Page+title%</a> +<a rel="mw:WikiLink" href="./%25+" title="%+" data-parsoid='{"stx":"simple","a":{"href":"./%25+"},"sa":{"href":"%+"}}'>%+</a> <a rel="mw:WikiLink" href="./%25+" title="%+" data-parsoid='{"stx":"piped","a":{"href":"./%25+"},"sa":{"href":"%+"}}'>%20</a> <a rel="mw:WikiLink" href="./%25+" title="%+" data-parsoid='{"stx":"simple","a":{"href":"./%25+"},"sa":{"href":"%+ "}}'>%+ </a> <a rel="mw:WikiLink" href="./%25+r" title="%+r" data-parsoid='{"stx":"simple","a":{"href":"./%25+r"},"sa":{"href":"%+r"}}'>%+r</a> +<a rel="mw:WikiLink" href="./%25" title="%" data-parsoid='{"stx":"simple","a":{"href":"./%25"},"sa":{"href":"%"}}'>%</a> <a rel="mw:WikiLink" href="./+" title="+" data-parsoid='{"stx":"simple","a":{"href":"./+"},"sa":{"href":"+"}}'>+</a> <figure-inline class="mw-default-size" typeof="mw:Error mw:Image" data-parsoid='{"optList":[{"ck":"bogus","ak":"foo"},{"ck":"caption","ak":"[[bar]]"}]}' data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}],"caption":"<a rel=\"mw:WikiLink\" href=\"./Bar\" title=\"Bar\" data-parsoid='{\"stx\":\"simple\",\"a\":{\"href\":\"./Bar\"},\"sa\":{\"href\":\"bar\"},\"dsr\":[94,101,2,2]}'>bar</a>"}'><a href="./File:%25+abc9" data-parsoid='{"a":{"href":"./File:%25+abc9"},"sa":{}}'><img resource="./File:%25+abc9" src="./Special:FilePath/%25+abc9" height="220" width="220" data-parsoid='{"a":{"resource":"./File:%25+abc9","height":"220","width":"220"},"sa":{"resource":"File:%+abc%39"}}'/></a></figure-inline> +<a rel="mw:WikiLink" href="./3E" title="3E" data-parsoid='{"stx":"simple","a":{"href":"./3E"},"sa":{"href":"%33%45"}}'>3E</a> <a rel="mw:WikiLink" href="./3E+" title="3E+" data-parsoid='{"stx":"simple","a":{"href":"./3E+"},"sa":{"href":"%33%45+"}}'>3E+</a></p> +!! end + +!! test +Special characters in embedded file links (T29679) +!! wikitext +[[File:Contains & ampersand.jpg]] +[[File:Does not exist.jpg|Title with & ampersand]] +!! html/php +<p><a href="/index.php?title=Special:Upload&wpDestFile=Contains_%26_ampersand.jpg" class="new" title="File:Contains & ampersand.jpg">File:Contains & ampersand.jpg</a> +<a href="/index.php?title=Special:Upload&wpDestFile=Does_not_exist.jpg" class="new" title="File:Does not exist.jpg">Title with & ampersand</a> +</p> +!! html/parsoid +<p><figure-inline class="mw-default-size" typeof="mw:Error mw:Image" data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}]}'><a href="./File:Contains_&_ampersand.jpg"><img resource="./File:Contains_&_ampersand.jpg" src="./Special:FilePath/Contains_&_ampersand.jpg" height="220" width="220"/></a></figure-inline> +<figure-inline class="mw-default-size" typeof="mw:Error mw:Image" data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}],"caption":"Title with &amp; ampersand"}'><a href="./File:Does_not_exist.jpg"><img resource="./File:Does_not_exist.jpg" src="./Special:FilePath/Does_not_exist.jpg" height="220" width="220"/></a></figure-inline></p> +!! end + +!! test +Confirm that 'apos' named character reference doesn't make it to output (not legal in HTML 4) +!! wikitext +Text's been normalized? +!! html +<p>Text's been normalized? +</p> +!! end + +!! test +T21052 U+3000 IDEOGRAPHIC SPACE should terminate free external links +!! wikitext +http://www.example.org/ <-- U+3000 (vim: ^Vu3000) +!! html +<p><a rel="nofollow" class="external free" href="http://www.example.org/">http://www.example.org/</a> <-- U+3000 (vim: ^Vu3000) +</p> +!! end + +!! test +T21052 U+3000 IDEOGRAPHIC SPACE should terminate bracketed external links +!! wikitext +[http://www.example.org/ ideograms] +!! html +<p><a rel="nofollow" class="external text" href="http://www.example.org/">ideograms</a> +</p> +!! end + +!! test +T21052 U+3000 IDEOGRAPHIC SPACE should terminate external images links +!! wikitext +http://www.example.org/pic.png <-- U+3000 (vim: ^Vu3000) +!! html +<p><img src="http://www.example.org/pic.png" alt="pic.png"/> <-- U+3000 (vim: ^Vu3000) +</p> +!! end + +!! article +Mediawiki:loop1 +!! text +{{Identical|A}} +!! endarticle + +!! article +Mediawiki:loop2 +!! text +{{Identical|B}} +!! endarticle + +!! article +Template:Identical +!! text +{{int:loop1}} +{{int:loop2}} +!! endarticle + +!! test +T33098 Template which includes system messages which includes the template +!! wikitext +{{Identical}} +!! html +<p><span class="error">Template loop detected: <a href="/wiki/Template:Identical" title="Template:Identical">Template:Identical</a></span> +<span class="error">Template loop detected: <a href="/wiki/Template:Identical" title="Template:Identical">Template:Identical</a></span> +</p> +!! end + +!! test +T33490 Turkish: ucfirst 'blah' +!! options +language=tr +!! wikitext +{{ucfirst:blah}} +!! html +<p>Blah +</p> +!! end + +!! test +T33490 Turkish: ucfirst 'ix' +!! options +language=tr +!! wikitext +{{ucfirst:ix}} +!! html +<p>İx +</p> +!! end + +!! test +T33490 Turkish: lcfirst 'BLAH' +!! options +language=tr +!! wikitext +{{lcfirst:BLAH}} +!! html +<p>bLAH +</p> +!! end + +!! test +T33490 Turkish: ucfırst (with a dotless i) +!! options +language=tr +!! wikitext +{{ucfırst:blah}} +!! html +<p><a href="/index.php?title=%C5%9Eablon:Ucf%C4%B1rst:blah&action=edit&redlink=1" class="new" title="Şablon:Ucfırst:blah (sayfa mevcut değil)">Şablon:Ucfırst:blah</a> +</p> +!! end + +!! test +T33490 ucfırst (with a dotless i) with English language +!! options +language=en +!! wikitext +{{ucfırst:blah}} +!! html +<p><a href="/index.php?title=Template:Ucf%C4%B1rst:blah&action=edit&redlink=1" class="new" title="Template:Ucfırst:blah (page does not exist)">Template:Ucfırst:blah</a> +</p> +!! end + +# Note that Parsoid doesn't emit an explicit TOC. +# Note also that the html2wt direction tends to emit an extra newline +# between the __TOC__ magicword and the first heading unless *both* +# the <meta> and the <h2> have a data-parsoid attribute set (even if +# it's "{}"). + +!! test +T28375: TOC with italics +!! options +title=[[Main Page]] +!! wikitext +__TOC__ +==''Lost'' episodes== +!! html/php +<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div> +<ul> +<li class="toclevel-1 tocsection-1"><a href="#Lost_episodes"><span class="tocnumber">1</span> <span class="toctext"><i>Lost</i> episodes</span></a></li> +</ul> +</div> + +<h2><span class="mw-headline" id="Lost_episodes"><i>Lost</i> episodes</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Main_Page&action=edit&section=1" title="Edit section: Lost episodes">edit</a><span class="mw-editsection-bracket">]</span></span></h2> + +!! html/parsoid +<meta property="mw:PageProp/toc" data-parsoid='{}'/> +<h2 id="Lost_episodes" data-parsoid='{}'><i>Lost</i> episodes</h2> +!! end + +!! test +T28375: TOC with bold +!! options +title=[[Main Page]] +!! wikitext +__TOC__ +=='''should be bold''' then normal text== +!! html/php +<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div> +<ul> +<li class="toclevel-1 tocsection-1"><a href="#should_be_bold_then_normal_text"><span class="tocnumber">1</span> <span class="toctext"><b>should be bold</b> then normal text</span></a></li> +</ul> +</div> + +<h2><span class="mw-headline" id="should_be_bold_then_normal_text"><b>should be bold</b> then normal text</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Main_Page&action=edit&section=1" title="Edit section: should be bold then normal text">edit</a><span class="mw-editsection-bracket">]</span></span></h2> + +!! html/parsoid +<meta property="mw:PageProp/toc" data-parsoid='{}'/> +<h2 id="should_be_bold_then_normal_text" data-parsoid='{}'><b>should be bold</b> then normal text</h2> +!! end + +!! test +T35845: Headings become cursive in TOC when they contain an image +!! options +title=[[Main Page]] +!! wikitext +__TOC__ +==Image [[Image:foobar.jpg]]== +!! html/php +<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div> +<ul> +<li class="toclevel-1 tocsection-1"><a href="#Image"><span class="tocnumber">1</span> <span class="toctext">Image</span></a></li> +</ul> +</div> + +<h2><span class="mw-headline" id="Image">Image <a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Main_Page&action=edit&section=1" title="Edit section: Image">edit</a><span class="mw-editsection-bracket">]</span></span></h2> + +!! html/parsoid +<meta property="mw:PageProp/toc" data-parsoid='{}'/> +<h2 id="Image" data-parsoid='{}'>Image <figure-inline class="mw-default-size" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"Image:foobar.jpg"}}'/></a></figure-inline></h2> +!! end + +!! test +T35845 (2): Headings become bold in TOC when they contain a blockquote +!! options +title=[[Main Page]] +!! wikitext +__TOC__ +==<blockquote>Quote</blockquote>== +!! html/php +<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div> +<ul> +<li class="toclevel-1 tocsection-1"><a href="#Quote"><span class="tocnumber">1</span> <span class="toctext">Quote</span></a></li> +</ul> +</div> + +<h2><span class="mw-headline" id="Quote"><blockquote>Quote</blockquote></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Main_Page&action=edit&section=1" title="Edit section: Quote">edit</a><span class="mw-editsection-bracket">]</span></span></h2> + +!! html/php+tidy +<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div> +<ul> +<li class="toclevel-1 tocsection-1"><a href="#Quote"><span class="tocnumber">1</span> <span class="toctext">Quote</span></a></li> +</ul> +</div> + +<h2><span class="mw-headline" id="Quote"><blockquote><p>Quote</p></blockquote></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Main_Page&action=edit&section=1" title="Edit section: Quote">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +!! html/parsoid +<meta property="mw:PageProp/toc" data-parsoid='{}'/> +<h2 id="Quote" data-parsoid='{}'><blockquote>Quote</blockquote></h2> +!! end + +!! test +Unclosed tags in TOC +!! config +wgFragmentMode=[ 'html5', 'legacy' ] +!! options +title=[[Main Page]] +!! wikitext +__TOC__ +==Proof: 2 < 3== +<small>Hanc marginis exiguitas non caperet.</small> +QED +!! html/php +<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div> +<ul> +<li class="toclevel-1 tocsection-1"><a href="#Proof:_2_<_3"><span class="tocnumber">1</span> <span class="toctext">Proof: 2 < 3</span></a></li> +</ul> +</div> + +<h2><span id="Proof:_2_.3C_3"></span><span class="mw-headline" id="Proof:_2_<_3">Proof: 2 < 3</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Main_Page&action=edit&section=1" title="Edit section: Proof: 2 < 3">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<p><small>Hanc marginis exiguitas non caperet.</small> +QED +</p> +!! html/parsoid +<meta property="mw:PageProp/toc" data-parsoid='{}'/> +<h2 id="Proof:_2_<_3" data-parsoid='{}'><span id="Proof:_2_.3C_3" typeof="mw:FallbackId"></span>Proof: 2 < 3</h2> +<p><small>Hanc marginis exiguitas non caperet.</small> +QED</p> +!! end + +!! test +Multiple tags in TOC +!! wikitext +__TOC__ +==<i>Foo</i> <b>Bar</b>== + +==<i>Foo</i> <blockquote>Bar</blockquote>== +!! html/php +<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div> +<ul> +<li class="toclevel-1 tocsection-1"><a href="#Foo_Bar"><span class="tocnumber">1</span> <span class="toctext"><i>Foo</i> <b>Bar</b></span></a></li> +<li class="toclevel-1 tocsection-2"><a href="#Foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext"><i>Foo</i> Bar</span></a></li> +</ul> +</div> + +<h2><span class="mw-headline" id="Foo_Bar"><i>Foo</i> <b>Bar</b></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: Foo Bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h2><span class="mw-headline" id="Foo_Bar_2"><i>Foo</i> <blockquote>Bar</blockquote></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: Foo Bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2> + +!! html/php+tidy +<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div> +<ul> +<li class="toclevel-1 tocsection-1"><a href="#Foo_Bar"><span class="tocnumber">1</span> <span class="toctext"><i>Foo</i> <b>Bar</b></span></a></li> +<li class="toclevel-1 tocsection-2"><a href="#Foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext"><i>Foo</i> Bar</span></a></li> +</ul> +</div> + +<h2><span class="mw-headline" id="Foo_Bar"><i>Foo</i> <b>Bar</b></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: Foo Bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h2><span class="mw-headline" id="Foo_Bar_2"><i>Foo</i> <blockquote><p>Bar</p></blockquote></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: Foo Bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +!! html/parsoid +<meta property="mw:PageProp/toc" data-parsoid='{}'/> +<h2 id="Foo_Bar" data-parsoid='{}'><i data-parsoid='{"stx":"html"}'>Foo</i> <b data-parsoid='{"stx":"html"}'>Bar</b></h2> + +<h2 id="Foo_Bar_2" data-parsoid='{}'><i data-parsoid='{"stx":"html"}'>Foo</i> <blockquote>Bar</blockquote></h2> +!! end + +# Don't expect Parsoid to roundtrip this until the php parser comes closer to +# html5 tag parsing. +!! test +Tags with parameters in TOC +!! options +parsoid=wt2html +!! wikitext +__TOC__ +==<sup class="in-h2">Hello</sup>== + +==<sup class="a > b">Evilbye</sup>== +!! html/php +<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div> +<ul> +<li class="toclevel-1 tocsection-1"><a href="#Hello"><span class="tocnumber">1</span> <span class="toctext"><sup>Hello</sup></span></a></li> +<li class="toclevel-1 tocsection-2"><a href="#b.22.3EEvilbye"><span class="tocnumber">2</span> <span class="toctext"><sup> b">Evilbye</sup></span></a></li> +</ul> +</div> + +<h2><span class="mw-headline" id="Hello"><sup class="in-h2">Hello</sup></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: Hello">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h2><span class="mw-headline" id="b.22.3EEvilbye"><sup class="a"> b">Evilbye</sup></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: b">Evilbye">edit</a><span class="mw-editsection-bracket">]</span></span></h2> + +!! html/parsoid +<meta property="mw:PageProp/toc" /> +<h2 id="Hello"><sup class="in-h2" data-parsoid='{"stx":"html"}'>Hello</sup></h2> + +<h2 id='b">Evilbye'><span id="b.22.3EEvilbye" typeof="mw:FallbackId"></span><sup class="a " data-parsoid='{"stx":"html"}'> b">Evilbye</sup></h2> +!! end + +!! test +span tags with directionality in TOC +!! wikitext +__TOC__ +==<span dir="ltr">C++</span>== + +==<span dir="rtl">זבנג!</span>== + +==<span style="font-style: italic">The attributes on these span tags must be deleted from the TOC</span>== + +==<span style="font-style: italic" dir="ltr">All attributes on these span tags must be deleted from the TOC</span>== + +==<span dir="ltr" style="font-style: italic">Attributes after dir on these span tags must be deleted from the TOC</span>== +!! html/php +<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div> +<ul> +<li class="toclevel-1 tocsection-1"><a href="#C.2B.2B"><span class="tocnumber">1</span> <span class="toctext"><span dir="ltr">C++</span></span></a></li> +<li class="toclevel-1 tocsection-2"><a href="#.D7.96.D7.91.D7.A0.D7.92.21"><span class="tocnumber">2</span> <span class="toctext"><span dir="rtl">זבנג!</span></span></a></li> +<li class="toclevel-1 tocsection-3"><a href="#The_attributes_on_these_span_tags_must_be_deleted_from_the_TOC"><span class="tocnumber">3</span> <span class="toctext"><span>The attributes on these span tags must be deleted from the TOC</span></span></a></li> +<li class="toclevel-1 tocsection-4"><a href="#All_attributes_on_these_span_tags_must_be_deleted_from_the_TOC"><span class="tocnumber">4</span> <span class="toctext"><span>All attributes on these span tags must be deleted from the TOC</span></span></a></li> +<li class="toclevel-1 tocsection-5"><a href="#Attributes_after_dir_on_these_span_tags_must_be_deleted_from_the_TOC"><span class="tocnumber">5</span> <span class="toctext"><span dir="ltr">Attributes after dir on these span tags must be deleted from the TOC</span></span></a></li> +</ul> +</div> + +<h2><span class="mw-headline" id="C.2B.2B"><span dir="ltr">C++</span></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: C++">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h2><span class="mw-headline" id=".D7.96.D7.91.D7.A0.D7.92.21"><span dir="rtl">זבנג!</span></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: זבנג!">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h2><span class="mw-headline" id="The_attributes_on_these_span_tags_must_be_deleted_from_the_TOC"><span style="font-style: italic">The attributes on these span tags must be deleted from the TOC</span></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=3" title="Edit section: The attributes on these span tags must be deleted from the TOC">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h2><span class="mw-headline" id="All_attributes_on_these_span_tags_must_be_deleted_from_the_TOC"><span style="font-style: italic" dir="ltr">All attributes on these span tags must be deleted from the TOC</span></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=4" title="Edit section: All attributes on these span tags must be deleted from the TOC">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h2><span class="mw-headline" id="Attributes_after_dir_on_these_span_tags_must_be_deleted_from_the_TOC"><span dir="ltr" style="font-style: italic">Attributes after dir on these span tags must be deleted from the TOC</span></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=5" title="Edit section: Attributes after dir on these span tags must be deleted from the TOC">edit</a><span class="mw-editsection-bracket">]</span></span></h2> + +!! html/parsoid +<meta property="mw:PageProp/toc" data-parsoid='{}'/> +<h2 id="C++" data-parsoid='{}'><span id="C.2B.2B" typeof="mw:FallbackId"></span><span dir="ltr">C++</span></h2> +<h2 id="זבנג!"><span id=".D7.96.D7.91.D7.A0.D7.92.21" typeof="mw:FallbackId"></span><span dir="rtl">זבנג!</span></h2> +<h2 id="The_attributes_on_these_span_tags_must_be_deleted_from_the_TOC"><span style="font-style: italic">The attributes on these span tags must be deleted from the TOC</span></h2> +<h2 id="All_attributes_on_these_span_tags_must_be_deleted_from_the_TOC"><span style="font-style: italic" dir="ltr">All attributes on these span tags must be deleted from the TOC</span></h2> +<h2 id="Attributes_after_dir_on_these_span_tags_must_be_deleted_from_the_TOC"><span dir="ltr" style="font-style: italic">Attributes after dir on these span tags must be deleted from the TOC</span></h2> +!! end + +!! test +T74884: bdi element in ToC +!! wikitext +__TOC__ +==<bdi>test</bdi>== +!! html/php +<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div> +<ul> +<li class="toclevel-1 tocsection-1"><a href="#test"><span class="tocnumber">1</span> <span class="toctext"><bdi>test</bdi></span></a></li> +</ul> +</div> + +<h2><span class="mw-headline" id="test"><bdi>test</bdi></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: test">edit</a><span class="mw-editsection-bracket">]</span></span></h2> + +!! html/parsoid +<meta property="mw:PageProp/toc" data-parsoid='{}'/> +<h2 id="test" data-parsoid='{}'><bdi>test</bdi></h2> +!! end + +!! test +T35715: s/strike element in ToC +!! wikitext +__TOC__ +==<s>test</s> test <strike>test</strike>== +!! html/php +<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div> +<ul> +<li class="toclevel-1 tocsection-1"><a href="#test_test_test"><span class="tocnumber">1</span> <span class="toctext"><s>test</s> test <strike>test</strike></span></a></li> +</ul> +</div> + +<h2><span class="mw-headline" id="test_test_test"><s>test</s> test <strike>test</strike></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: test test test">edit</a><span class="mw-editsection-bracket">]</span></span></h2> + +!! html/parsoid +<meta property="mw:PageProp/toc" data-parsoid='{}'/> +<h2 id="test_test_test" data-parsoid='{}'><s>test</s> test <strike>test</strike></h2> +!! end + +!! test +Empty <p> tag in TOC, removed by Sanitizer (T92892) +!! wikitext +__TOC__ +==x== +!! html/php +<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div> +<ul> +<li class="toclevel-1 tocsection-1"><a href="#x"><span class="tocnumber">1</span> <span class="toctext">x</span></a></li> +</ul> +</div> + +<h2><span class="mw-headline" id="x">x</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: x">edit</a><span class="mw-editsection-bracket">]</span></span></h2> + +!! html/parsoid +<meta property="mw:PageProp/toc" data-parsoid='{}'/> +<h2 id="x" data-parsoid='{}'>x</h2> +!! end + +!! article +MediaWiki:T34057 +!! text +== {{int:headline_sample}} == +!! endarticle + +!! test +T34057: Title needed when expanding <h> nodes. +!! options +title=[[Main Page]] +!! wikitext +{{int:T34057}} +!! html +<h2><span class="mw-headline" id="Headline_text">Headline text</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Main_Page&action=edit&section=1" title="Edit section: Headline text">edit</a><span class="mw-editsection-bracket">]</span></span></h2> + +!! end + +!! test +Strip marker in urlencode +!! wikitext +{{urlencode:x<nowiki/>y}} +{{urlencode:x<nowiki/>y|wiki}} +{{urlencode:x<nowiki/>y|path}} +{{urlencode:x<pre id="one">two</pre>y}} +!! html/php +<p>xy +xy +xy +xy +</p> +!! end + +!! test +Strip marker in lc +!! wikitext +{{lc:x<nowiki/>y}} +!! html +<p>xy +</p> +!! end + +!! test +Strip marker in uc +!! wikitext +{{uc:x<nowiki/>y}} +!! html +<p>XY +</p> +!! end + +!! test +Strip marker in formatNum +!! wikitext +{{formatnum:1<nowiki/>2}} +{{formatnum:1<nowiki/>2|R}} +!! html +<p>12 +12 +</p> +!! end + +!! test +Check noCommafy in formatNum +!! options +language=be-tarask +!! wikitext +{{formatnum:123456.78}} +{{formatnum:123456.78|NOSEP}} +!! html +<p>123 456,78 +123456.78 +</p> +!! end + +!! test +Wrong option for formatNum (T58199) +!! wikitext +{{formatnum:1,234.56|Random}} +{{formatnum:1,234.56|EVERYTHING}} +{{formatnum:1234.56|any argument that has the string 'NOSEP'}} +!! html +<p>1,234.56 +1,234.56 +1,234.56 +</p> +!! end + +!! test +Strip marker in grammar +!! options +language=fi +!! wikitext +{{grammar:elative|foo<nowiki/>bar}} +!! html +<p>foobarista +</p> +!! end + +!! test +Strip marker in padleft +!! wikitext +{{padleft:|2|x<nowiki/>y}} +!! html +<p>xy +</p> +!! end + +!! test +Strip marker in padright +!! wikitext +{{padright:|2|x<nowiki/>y}} +!! html +<p>xy +</p> +!! end + +!! test +Strip marker in anchorencode +!! wikitext +{{anchorencode:x<nowiki/>y}} +!! html/php +<p>xy +</p> +!! html/parsoid +<p about="#mwt2" typeof="mw:Transclusion" data-parsoid='{"pi":[[]]}' data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode:x<nowiki/>y","function":"anchorencode"},"params":{},"i":0}}]}'>xy</p> +!! end + +!! test +nowiki inside link inside heading (T20295) +!! wikitext +==[[foo|x<nowiki>y</nowiki>z]]== +!! html +<h2><span class="mw-headline" id="xyz"><a href="/wiki/Foo" title="Foo">xyz</a></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: xyz">edit</a><span class="mw-editsection-bracket">]</span></span></h2> + +!! end + +!! test +new support for bdi element (T33817) +!! wikitext +<p dir="rtl" lang="he">ולדימיר לנין (ברוסית: <bdi lang="ru">Владимир Ленин</bdi>, 24 באפריל 1870–22 בינואר 1924) הוא מנהיג פוליטי קומוניסטי רוסי.</p> +!! html +<p dir="rtl" lang="he">ולדימיר לנין (ברוסית: <bdi lang="ru">Владимир Ленин</bdi>, 24 באפריל 1870–22 בינואר 1924) הוא מנהיג פוליטי קומוניסטי רוסי.</p> + +!!end + +!! test +Ignore pipe between table row attributes +!! wikitext +{| +|quux +|- id=foo | style='color: red' +|bar +|} +!! html +<table> +<tr> +<td>quux +</td></tr> +<tr id="foo" style="color: red"> +<td>bar +</td></tr></table> + +!! end + +!!test +Language parser function +!! wikitext +{{#language:ar}} +!! html +<p>العربية +</p> +!! end + +!!test +Padleft and padright (default 0-padding) +!! wikitext +{{padleft:xyz|5}} +{{padright:xyz|5}} +!! html/php +<p>00xyz +xyz00 +</p> +!! html/parsoid +<p><span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padleft:xyz","function":"padleft"},"params":{"1":{"wt":"5"}},"i":0}}]}'>00xyz</span> +<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padright:xyz","function":"padright"},"params":{"1":{"wt":"5"}},"i":0}}]}'>xyz00</span></p> +!! end + +!!test +Padleft and padright (partial fill) +!! wikitext +{{padleft:xyz|6|ab}} +{{padright:xyz|6|ab}} +!! html/php +<p>abaxyz +xyzaba +</p> +!! html/parsoid +<p><span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padleft:xyz","function":"padleft"},"params":{"1":{"wt":"6"},"2":{"wt":"ab"}},"i":0}}]}'>abaxyz</span> +<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padright:xyz","function":"padright"},"params":{"1":{"wt":"6"},"2":{"wt":"ab"}},"i":0}}]}'>xyzaba</span></p> +!! end + +!!test +Padleft and padright as substr +!! wikitext +{{padleft:|3|abcde}} +{{padright:|3|abcde}} +!! html/php +<p>abc +abc +</p> +!! html/parsoid +<p><span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padleft:","function":"padleft"},"params":{"1":{"wt":"3"},"2":{"wt":"abcde"}},"i":0}}]}'>abc</span> +<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padright:","function":"padright"},"params":{"1":{"wt":"3"},"2":{"wt":"abcde"}},"i":0}}]}'>abc</span></p> +!! end + +!! test +Padleft and padright with non-numerical length (T180403) +!! wikitext +{{padleft:abcdef|junk}} +{{padright:abcdef|junk}} +!! html/php +<p>abcdef +abcdef +</p> +!! end + +!!test +Special parser function +!! wikitext +{{#special:RandomPage}} +{{#special:BaDtItLe}} +{{#special:Foobar}} +!! html +<p>Special:Random +Special:Badtitle +Special:Foobar +</p> +!! end + +!!test +T36939 - Case insensitive link parsing ([HttP://]) +!! wikitext +[HttP://MediaWiki.Org/] +!! html/php +<p><a rel="nofollow" class="external autonumber" href="HttP://MediaWiki.Org/">[1]</a> +</p> +!! html/parsoid +<p><a rel="mw:ExtLink" class="external autonumber" href="HttP://MediaWiki.Org/"></a></p> +!! end + +!!test +T36939 - Case insensitive link parsing ([HttP:// title]) +!! wikitext +[HttP://MediaWiki.Org/ MediaWiki] +!! html +<p><a rel="nofollow" class="external text" href="HttP://MediaWiki.Org/">MediaWiki</a> +</p> +!! end + +!!test +T36939 - Case insensitive link parsing (HttP://) +!! wikitext +HttP://MediaWiki.Org/ +!! html/php +<p><a rel="nofollow" class="external free" href="HttP://MediaWiki.Org/">HttP://MediaWiki.Org/</a> +</p> +!! html/parsoid +<p><a rel="mw:ExtLink" class="external free" href="HttP://MediaWiki.Org/">HttP://MediaWiki.Org/</a></p> +!! end + +!!test +Disable TOC +!! options +notoc +!! wikitext +Lead +==Section 1== +==Section 2== +==Section 3== +==Section 4== +==Section 5== +!! html +<p>Lead +</p> + +<h2><span class="mw-headline" id="Section_1">Section 1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: Section 1">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h2><span class="mw-headline" id="Section_2">Section 2</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: Section 2">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h2><span class="mw-headline" id="Section_3">Section 3</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=3" title="Edit section: Section 3">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h2><span class="mw-headline" id="Section_4">Section 4</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=4" title="Edit section: Section 4">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h2><span class="mw-headline" id="Section_5">Section 5</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=5" title="Edit section: Section 5">edit</a><span class="mw-editsection-bracket">]</span></span></h2> + +!! end + + +### +### Parsoid-specific tests +### Parsoid-PHP parser incompatibilities +### +!!test +1. SOL-sensitive wikitext tokens as template-args +!!options +parsoid=wt2html,wt2wt +!! wikitext +{{echo|*a}} +{{echo|#a}} +{{echo|:a}} +!! html +<span about="#mwt1" typeof="mw:Transclusion"> +</span><ul about="#mwt1"><li>a</li> +</ul> +<span about="#mwt2" typeof="mw:Transclusion"> +</span><ol about="#mwt2"><li>a</li> +</ol> +<span about="#mwt3" typeof="mw:Transclusion"> +</span><dl about="#mwt3"><dd>a</dd> +</dl> +!!end + +#### ----------------------------------------------------------------- +#### Parsoid-specific functionality tests +#### ----------------------------------------------------------------- + +# T65642/T68749: Formatting elt fixup around images is cleaned up. +# We know wt2wt will fail, but we expect selser to pass. +# Due to the nature of our testing, wt2wt and selser tests will enter the +# blacklist and we'll catch selser regressions based on changes to the +# blacklist entries for selser tests. +!! test +1. Bad treebuilder fixup of formatting elt is cleaned up +!! options +parsoid=wt2html,wt2wt +!! wikitext +{| +| +<small> +[[Image:Foobar.jpg|right|Test]] +</small> +|} +!! html/parsoid +<table> +<tbody><tr><td> +<small> +<figure class="mw-default-size mw-halign-right" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a><figcaption>Test</figcaption></figure> +</small> +</td></tr> +</tbody></table> +!! end + +!! test +2. Bad treebuilder fixup of formatting elt is cleaned up +!! options +parsoid=wt2html,wt2wt +!! wikitext +'''foo[[File:Foobar.jpg|thumb|caption]]bar''' + +<small>[[Image:Foobar.jpg|right|300px]]</small> +!! html/parsoid + +<p><b>foo</b></p> +<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption><b>caption</b></figcaption></figure> +<p><b>bar</b></p> +<small><figure class="mw-halign-right" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="34" width="300"/></a></figure></small> +!! end + +!! test +3. Bad treebuilder fixup of formatting elt is cleaned up +!! options +parsoid=wt2html,wt2wt +!! wikitext +<small>'''foo[[File:Foobar.jpg|thumb|caption]]bar'''</small> +!! html/parsoid +<p><small><b>foo</b></small></p> +<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption><small><b>caption</b></small></figcaption></figure> +<p><small><b>bar</b></small></p> +!! end + +!! test +4. Bad treebuilder fixup of formatting elt is cleaned up: formatting tags around captionless images are ignored +!! options +parsoid=wt2html,wt2wt +!! wikitext +'''<small>[[Image:Foobar.jpg|right|300px]]</small>''' +!! html/parsoid +<b><small><figure class="mw-halign-right" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="34" width="300"/></a></figure></small></b> +!! end + +#### ---------------------------------------------------------------- +#### Parsoid-only testing of Parsoid's impl of LST +#### Not implemented yet, see +#### https://www.mediawiki.org/wiki/Parsoid/HTML_based_LST +#### ---------------------------------------------------------------- + +## We still need to support serializing the older format while content is stored. +!! test +LST Sections: Backwards compatibility +!! options +parsoid={ + "suppressErrors": true, + "modes": ["html2wt"] +} +!! wikitext +<section begin="2011-05-16" /> +<section end="2014-04-10 (MW 1.23wmf22)" /> +!! html/parsoid +<p><meta typeof="mw:Extension/LabeledSectionTransclusion/begin" content="2011-05-16"/> +<meta typeof="mw:Extension/LabeledSectionTransclusion/end" content="2014-04-10 (MW 1.23wmf22)"/></p> +!! end + +!! test +LST Sections: Newfangled approach +!! wikitext +<section begin="2011-05-16" /> +<section end="2014-04-10 (MW 1.23wmf22)" /> +!! html/parsoid +<p><span typeof="mw:Extension/section" about="#mwt4" data-mw='{"name":"section","attrs":{"begin":"2011-05-16"},"body":null}'> +</span> +<span typeof="mw:Extension/section" about="#mwt6" data-mw='{"name":"section","attrs":{"end":"2014-04-10 (MW 1.23wmf22)"},"body":null}'> +</span></p> +!! end + +#--------- Test stripping of empty nodes in template content ---------- + +!! test +Empty LI and TR nodes should be stripped from template content +!! wikitext +{{EmptyLITest}} +{{EmptyTRTest}} +!! html/parsoid +<ul about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyLITest","href":"./Template:EmptyLITest"},"params":{},"i":0}}]}'> +<li>a</li> +<li>b</li> +</ul> +<table about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyTRTest","href":"./Template:EmptyTRTest"},"params":{},"i":0}}]}'> +<tbody> +<tr> +<td>foo</td> +</tr> +<tr> +<td>bar</td> +</tr> +</tbody> +</table> +!! end + +!! test +Empty LI and TR nodes should not be stripped from top-level content +!! wikitext +* a +* +* b + +{| +|- +|- +|foo +|} +!! html/parsoid +<ul> +<li> a</li> +<li class='mw-empty-elt'></li> +<li> b</li> +</ul> +<table> +<tbody> +<tr class='mw-empty-elt'></tr> +<tr> +<td>foo</td> +</tr> +</tbody> +</table> +!! end + +!! test +Empty TR nodes should not be stripped if they have any attributes set +!! wikitext +{{EmptyTRWithHTMLAttrTest}} +!! html/parsoid +<table about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyTRWithHTMLAttrTest","href":"./Template:EmptyTRWithHTMLAttrTest"},"params":{},"i":0}}]}'> +<tr align='center'></tr> +<tr><td>foo</td></tr> +<tr align='center'></tr> +<tr><td>bar</td></tr> +</table> +!! end + +#### ---------------------------------------------------------------- +#### The following section of tests are primarily to test +#### wikitext escaping capabilities of Parsoid. Given that +#### escaping can be done any number of ways, the wikitext (input) +#### is always adjusted to reflect how Parsoid adds nowiki +#### escape tags. +#### +#### We are marking several tests as parsoid-only since the +#### HTML in the result section is different from what the +#### PHP parser generates for it. +#### ---------------------------------------------------------------- + + +#### --------------- Headings --------------- +#### 0. Unnested +#### 1. Nested inside html <h1>=foo=</h1> +#### 2. Outside heading nest on a single line <h1>foo</h1>*bar +#### 3. Nested inside html with wikitext split by html tags +#### 4. No escape needed +#### 5. Empty headings <h1></h1> +#### 6. Heading chars in SOL context +#### ---------------------------------------- +!! test +Headings: 0. Unnested +!! options +parsoid=html2wt +!! html/parsoid +<p>=foo=</p> + +<p> =foo= +<!--cmt--> +=foo=</p> + +<p>=foo<i>a</i>=</p> +!! wikitext +<nowiki>=foo=</nowiki> + +<nowiki> </nowiki>=foo= +<!--cmt--> +<nowiki>=foo=</nowiki> + +=foo''a''<nowiki>=</nowiki> +!!end + +# New headings and existing headings are handled differently +!! test +Headings: 1. Nested inside html +!! options +parsoid=html2wt +!! html/parsoid +<h1>=foo=</h1> +<h2>=foo=</h2> +<h3>=foo=</h3> + +<h1 data-parsoid=''>=foo=</h1> +<h2 data-parsoid=''>=foo=</h2> +<h3 data-parsoid=''>=foo=</h3> +<h4 data-parsoid=''>=foo=</h4> +<h5 data-parsoid=''>=foo=</h5> +<h6 data-parsoid=''>=foo=</h6> +!! wikitext += =foo= = + +== =foo= == + +=== =foo= === + +=<nowiki>=foo=</nowiki>= +==<nowiki>=foo=</nowiki>== +===<nowiki>=foo=</nowiki>=== +====<nowiki>=foo=</nowiki>==== +=====<nowiki>=foo=</nowiki>===== +======<nowiki>=foo=</nowiki>====== + +!!end + +!! test +Headings: 2. Outside heading nest on a single line <h1>foo</h1>*bar +!! options +parsoid=html2wt +!! html/parsoid +<h1>foo</h1>*bar +<h1>foo</h1>=bar +<h1>foo</h1>=bar= +!! wikitext += foo = +<nowiki>*</nowiki>bar + += foo = +=bar + += foo = +<nowiki>=bar=</nowiki> +!!end + +!! test +Headings: 3. Nested inside html with wikitext split by html tags +!! options +parsoid=html2wt +!! html/parsoid +<h1>=<b>bold</b>foo=</h1> +!! wikitext += ='''bold'''foo= = +!!end + +!! test +Headings: 4a. No escaping needed (testing just h1 and h2) +!! options +parsoid=html2wt +!! html/parsoid +<h1>=foo</h1> +<h1>foo=</h1> +<h1> =foo= </h1> +<h1>=foo= bar</h1> +<h2>=foo</h2> +<h2>foo=</h2> +<h1>=</h1> +<h1><i>=</i>foo=</h1> +!! wikitext += =foo = + += foo= = + += =foo= = + += =foo= bar = + +== =foo == + +== foo= == + += = = + += ''=''foo= = +!!end + +!! test +Headings: 4b. No escaping needed (inside p-tags) +!! options +parsoid=html2wt +!! html/parsoid +<p>=foo= x +=foo= <s></s> +</p> +!! wikitext +=foo= x +=foo= <s></s> +!! html/php +<p>=foo= x +=foo= <s></s> +</p> +!!end + +!! test +Headings: 4c. Short headings (1) +!! options +parsoid=html2wt +!! html/parsoid +<p>=== +</p> +!! wikitext +<nowiki>===</nowiki> +!! html/php +<p>=== +</p> +!! end + +# in the html2wt direction we emit '= = =' or '=<nowiki>=</nowiki>=' +!! test +Headings: 4d. Short headings (2) +!! options +parsoid=wt2html,html2html +!! wikitext += +== +=== +==== +===== +!! html/php +<p>= +== +</p> +<h1><span class="mw-headline" id=".3D">=</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: =">edit</a><span class="mw-editsection-bracket">]</span></span></h1> +<h1><span class="mw-headline" id=".3D.3D">==</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: ==">edit</a><span class="mw-editsection-bracket">]</span></span></h1> +<h2><span class="mw-headline" id=".3D_2">=</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=3" title="Edit section: =">edit</a><span class="mw-editsection-bracket">]</span></span></h2> + +!! html/parsoid +<p>= +==</p> +<h1 id="="><span id=".3D" typeof="mw:FallbackId"></span>=</h1> +<h1 id="=="><span id=".3D.3D" typeof="mw:FallbackId"></span>==</h1> +<h2 id="=_2"><span id=".3D_2" typeof="mw:FallbackId"></span>=</h2> +!! end + +!! test +Headings: 5. Empty headings +!! options +parsoid=html2wt +!! html/parsoid +<h1 data-parsoid='{}'></h1> + +<h2 data-parsoid='{}'></h2> + +<h3 data-parsoid='{}'></h3> + +<h4 data-parsoid='{}'></h4> + +<h5 data-parsoid='{}'></h5> + +<h6 data-parsoid='{}'></h6> +!! wikitext +=<nowiki/>= + +==<nowiki/>== + +===<nowiki/>=== + +====<nowiki/>==== + +=====<nowiki/>===== + +======<nowiki/>====== +!!end + +!! test +Headings: 6a. Heading chars in SOL context (with trailing spaces) +!! options +parsoid=html2wt +!! html/parsoid +<p>=a=</p> + +<p>=a=</p> + +<p>=a=</p> +!! wikitext +<nowiki>=a=</nowiki> + +<nowiki>=a=</nowiki> + +<nowiki>=a=</nowiki> +!!end + +!! test +Headings: 6b. Heading chars in SOL context (with trailing newlines) +!! options +parsoid=html2wt +!! html/parsoid +<p>=a= +b</p> + +<p>=a= +b</p> + +<p>=a= +b</p> +!! wikitext +<nowiki>=a=</nowiki> +b + +<nowiki>=a=</nowiki> +b + +<nowiki>=a=</nowiki> +b +!!end + +!! test +Headings: 6c. Heading chars in SOL context (leading newline break) +!! options +parsoid=html2wt +!! html/parsoid +<p>a +=b=</p> +!! wikitext +a +<nowiki>=b=</nowiki> +!!end + +!! test +Headings: 6d. Heading chars in SOL context (with interspersed comments) +!! options +parsoid=html2wt +!! html/parsoid +<!--c0--><p>=a=</p> + +<!--c1--><p>=a=</p> <!--c2--> <!--c3--> +!! wikitext +<!--c0--><nowiki>=a=</nowiki> + +<!--c1--><nowiki>=a=</nowiki> <!--c2--> <!--c3--> +!!end + +!! test +Headings: 6d. Heading chars in SOL context (No escaping needed) +!! options +parsoid=html2wt +!! html/parsoid +=a=<div>b</div> +!! wikitext +=a=<div>b</div> +!!end + +!! test +Headings: 7. Insert a newline between new content and headings +!! options +parsoid=html2wt +!! html/parsoid +<h2>NEW</h2> +<p>new</p> +<h2 data-parsoid='{}'>A</h2> +<p data-parsoid='{}'>a</p> +!! wikitext +== NEW == +new + +==A== +a + +!! end + +!! test +Headings: Used as horizontal rule +!! config +wgFragmentMode=[ 'html5', 'legacy' ] +!! options +parsoid=wt2html +!! wikitext +=============== +!! html/php +<h6><span id=".3D.3D.3D"></span><span class="mw-headline" id="===">===</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: ===">edit</a><span class="mw-editsection-bracket">]</span></span></h6> + +!! html/parsoid +<h6 id="==="><span id=".3D.3D.3D" typeof="mw:FallbackId"></span>===</h6> +!! end + +#### --------------- Lists --------------- +#### 0. Outside nests (*foo, etc.) +#### 1. Nested inside html <ul><li>*foo</li></ul> +#### 2. Inside definition lists +#### 3. Only bullets at start should be escaped +#### 4. No escapes needed +#### 5. No unnecessary escapes +#### 6. Escape bullets in SOL position +#### 7. Escape bullets in a multi-line context +#### ---------------------------------------- + +!! test +Lists: 0. Outside nests +!! options +parsoid=html2wt +!! html/parsoid +<p>*foo</p> + +<p>#foo</p> + +<p>;Foo:bar</p> +!! wikitext +<nowiki>*</nowiki>foo + +<nowiki>#</nowiki>foo + +<nowiki>;</nowiki>Foo<nowiki>:</nowiki>bar +!!end + +## Making these next 3 tests Parsoid-only since they are html2wt tests +## to test wikitext escaping, and insignificant whitespace diffs +## cause PHP parser tests to barf +!! test +Lists: 1. Nested inside html (No unnecessary escapes) +!! options +parsoid=html2wt +!! html/parsoid +<ul> +<li>*foo</li> +<li>#foo</li> +<li>:foo</li> +<li>;foo</li> +<li data-parsoid='{}'>*foo</li> +<li data-parsoid='{}'>#foo</li> +<li data-parsoid='{}'>:foo</li> +<li data-parsoid='{}'>;foo</li> +</ul> + +<ol> +<li>*foo</li> +<li>#foo</li> +<li>:foo</li> +<li>;foo</li> +<li data-parsoid='{}'>*foo</li> +<li data-parsoid='{}'>#foo</li> +<li data-parsoid='{}'>:foo</li> +<li data-parsoid='{}'>;foo</li> +</ol> +!! wikitext +* *foo +* #foo +* :foo +* ;foo +*<nowiki>*foo</nowiki> +*<nowiki>#foo</nowiki> +*<nowiki>:foo</nowiki> +*<nowiki>;foo</nowiki> + +# *foo +# #foo +# :foo +# ;foo +#<nowiki>*foo</nowiki> +#<nowiki>#foo</nowiki> +#<nowiki>:foo</nowiki> +#<nowiki>;foo</nowiki> +!!end + +!! test +Lists: 2. Inside definition lists +!! options +parsoid=html2wt +!! html/parsoid +<dl><dt>;foo</dt></dl> +<dl><dt>:foo</dt></dl> +<dl><dt>:foo</dt> +<dd>bar</dd></dl> +<dl><dd>:foo</dd></dl> +!! wikitext +; ;foo + +; <nowiki>:foo</nowiki> + +; <nowiki>:foo</nowiki> +: bar + +: :foo +!!end + +!! test +Lists: 3. Only bullets at start of text in wikitext-generated HTML should be escaped +!! options +parsoid=html2wt +!! html/parsoid +<ul> +<li>*foo*bar</li> +<li data-parsoid='{}'>*foo<i>it</i>*bar</li> +</ul> +!! wikitext +* *foo*bar +*<nowiki>*foo</nowiki>''it''*bar +!!end + +!! test +Lists: 4. No escapes needed +!! options +parsoid=html2wt +!! html/parsoid +<ul> +<li>foo*bar +</li> +</ul> +<ul> +<li><i>foo</i>*bar +</li> +</ul> +<ul> +<li><a rel="mw:WikiLink" href="Foo" title="Foo">Foo</a>: bar +</li> +</ul> +<ul> +<li><a rel="mw:WikiLink" href="Foo" title="Foo">Foo</a>*bar +</li> +</ul> +!! wikitext +*foo*bar + +*''foo''*bar + +*[[Foo]]: bar + +*[[Foo]]*bar +!!end + +!! test +Lists: 5. No unnecessary escapes +!! options +parsoid=html2wt +!! html/parsoid +<ul><li> bar <span>[[foo]]</span></li></ul> +<ul><li> =bar <span>[[foo]]</span></li></ul> +<ul><li> [[bar <span>[[foo]]</span></li></ul> +<ul><li> ]]bar <span>[[foo]]</span></li></ul> +<ul><li> =bar <span>foo]]</span>=</li></ul> +<ul><li> <s></s>: a</li></ul> +<ul><li> <i>* foo</i></li></ul> + +!! wikitext +* bar <span><nowiki>[[foo]]</nowiki></span> + +* =bar <span><nowiki>[[foo]]</nowiki></span> + +* [[bar <span><nowiki>[[foo]]</nowiki></span> + +* ]]bar <span><nowiki>[[foo]]</nowiki></span> + +* =bar <span>foo]]</span>= + +* <s></s>: a + +* ''* foo'' +!!end + +!! test +Lists: 6. Escape bullets in SOL position +!! options +parsoid=html2wt +!! html/parsoid +<p><!--cmt-->*foo</p> +!! wikitext +<!--cmt--><nowiki>*</nowiki>foo +!!end + +!! test +Lists: 7. Escape bullets in a multi-line context +!! options +parsoid=html2wt +!! html/parsoid +<p>a +*b +</p> +!! wikitext +a +<nowiki>*</nowiki>b +!!end + +!! test +Lists: 8. Escape colons only if not present in tags +!! options +parsoid=html2wt +!! html/parsoid +<dl><dt>a:b<i>c:d</i></dt></dl> +!! wikitext +; <nowiki>a:b</nowiki>''c:d'' +!! end + +#### --------------- HRs --------------- +#### 1. Single line +#### ----------------------------------- + +!! test +HRs: 1. Single line +!! options +parsoid=html2wt +!! html/parsoid +<hr />---- +<hr />=foo= +<hr />*foo +!! wikitext +----<nowiki>----</nowiki> +----=foo= +----*foo +!! end + +#### --------------- Tables --------------- +#### 1a. Simple example +#### 1b. No escaping needed (!foo) +#### 1c. No escaping needed (|foo) +#### 1d. No escaping needed (|}foo) +#### +#### 2a. Nested in td (<td>foo|bar</td>) +#### 2b. Nested in td (<td>foo||bar</td>) +#### 2c. Nested in td -- no escaping needed(<td>foo!!bar</td>) +#### +#### 3a. Nested in th (<th>foo!bar</th>) +#### 3b. Nested in th (<th>foo!!bar</th>) +#### 3c. Nested in th -- no escaping needed(<th>foo||bar</th>) +#### +#### 4a. Escape - +#### 4b. Escape + +#### 4c. No escaping needed +#### -------------------------------------- + +!! test +Tables: 1a. Simple example +!! options +parsoid=html2wt +!! html/parsoid +<p>{| +|} +</p> +!! wikitext +<nowiki>{|</nowiki> +|} +!! end + +!! test +Tables: 1b. No escaping needed +!! options +parsoid=html2wt +!! html/parsoid +<p>!foo +</p> +!! wikitext +!foo +!! end + +!! test +Tables: 1c. No escaping needed +!! options +parsoid=html2wt +!! html/parsoid +<p>|foo +</p> +!! wikitext +|foo +!! end + +!! test +Tables: 1d. No escaping needed +!! options +parsoid=html2wt +!! html/parsoid +<p>|}foo +</p> +!! wikitext +|}foo +!! end + +!! test +Tables: 2a. Nested in td +!! options +parsoid=html2wt +!! html/parsoid +<table><tbody><tr> +<td>foo|bar</td></tr> +<tr><td>x<div>a|b</div></td> +</tbody></table> +!! wikitext +{| +|<nowiki>foo|bar</nowiki> +|- +|x<div><nowiki>a|b</nowiki></div> +|} +!! html/php+tidy +<table> +<tbody><tr> +<td>foo|bar +</td></tr> +<tr> +<td>x<div>a|b</div> +</td></tr></tbody></table> +!! end + +!! test +Tables: 2b. Nested in td +!! options +parsoid=html2wt +!! html/parsoid +<table><tbody><tr> +<td>foo||bar</td> +<td>a<i>b||c</i></td> +<td>a<i><div>b||c</div></i></td> +</tr></tbody></table> +!! wikitext +{| +|<nowiki>foo||bar</nowiki> +|a''<nowiki>b||c</nowiki>'' +|a''<div><nowiki>b||c</nowiki></div>'' +|} +!! html/php +<table> +<tr> +<td>foo||bar +</td> +<td>a<i>b||c</i> +</td> +<td>a<i><div>b||c</div></i> +</td></tr></table> + +!! end + +!! test +Tables: 2c. Nested in td -- no escaping needed +!! options +parsoid=html2wt +!! html/* +<table> +<tr> +<td>foo!!bar +</td></tr></table> + +!! wikitext +{| +|foo!!bar +|} +!! end + +!! test +Tables: 3a. Nested in th +!! options +parsoid=html2wt +!! html/* +<table> +<tr> +<th>foo!bar +</th></tr></table> + +!! wikitext +{| +!foo!bar +|} +!! end + +!! test +Tables: 3b. Nested in th +!! options +parsoid=html2wt +!! html/parsoid +<table><tbody> +<tr><th>foo!!bar</th> +<th><i>foo|bar</i></th> +<th><i>foo!!bar</i></th> +<th><i><span>foo!!bar</span></i></th> +</tr></tbody></table> +!! wikitext +{| +!<nowiki>foo!!bar</nowiki> +!''<nowiki>foo|bar</nowiki>'' +!''<nowiki>foo!!bar</nowiki>'' +!''<span><nowiki>foo!!bar</nowiki></span>'' +|} +!! html/php +<table> +<tr> +<th>foo!!bar +</th> +<th><i>foo|bar</i> +</th> +<th><i>foo!!bar</i> +</th> +<th><i><span>foo!!bar</span></i> +</th></tr></table> + +!! end + +!! test +Tables: 3c. Nested in th +!! options +parsoid=html2wt +!! html/parsoid +<table><tbody> +<tr><th>foo||bar</th> +<th><span typeof="mw:Nowiki">foo||bar</span></th> +</tr></tbody></table> +!! wikitext +{| +!<nowiki>foo||bar</nowiki> +!<nowiki>foo||bar</nowiki> +|} +!! html/php +<table> +<tr> +<th>foo||bar +</th> +<th>foo||bar +</th></tr></table> + +!! end + +!! test +Tables: 4a. Escape - +!! options +parsoid=html2wt +!! html/* +<table> +<tr> +<th>-bar +</th></tr> +<tr> +<td>-bar +</td></tr></table> + +!! wikitext +{| +!-bar +|- +|<nowiki>-bar</nowiki> +|} +!! end + +!! test +Tables: 4b. Escape + +!! options +parsoid=html2wt +!! html/* +<table> +<tr> +<th>+bar +</th></tr> +<tr> +<td>+bar +</td></tr></table> + +!! wikitext +{| +!+bar +|- +|<nowiki>+bar</nowiki> +|} +!! end + +!! test +Tables: 4c. No escaping needed +!! options +parsoid=html2wt +!! html/parsoid +<table><tbody> +<tr><td>foo-bar</td><td>foo+bar</td></tr> +<tr><td><i>foo</i>-bar</td><td><i>foo</i>+bar</td></tr> +<tr><td>foo +<p>bar|baz ++bar +-bar</p></td></tr> +<tr><td>x +<div>a|b</div></td> +</tbody></table> +!! wikitext +{| +|foo-bar +|foo+bar +|- +|''foo''-bar +|''foo''+bar +|- +|foo +bar|baz ++bar +-bar +|- +|x +<div>a|b</div> +|} +!! html/php +<table> +<tr> +<td>foo-bar +</td> +<td>foo+bar +</td></tr> +<tr> +<td><i>foo</i>-bar +</td> +<td><i>foo</i>+bar +</td></tr> +<tr> +<td>foo +<p>bar|baz ++bar +-bar +</p> +</td></tr> +<tr> +<td>x +<div>a|b</div> +</td></tr></table> + +!! end + +!! test +Tables: 4d. No escaping needed +!! options +parsoid=html2wt +!! html/parsoid +<table> +<tbody><tr><td><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a>-bar</td> +<td data-parsoid='{"startTagSrc":"|","attrSepSrc":"|"}'>+1</td> +<td data-parsoid='{"startTagSrc":"|","attrSepSrc":"|"}'>-2</td></tr> +</tbody></table> +!! wikitext +{| +|[[Foo]]-bar +||+1 +||-2 +|} +!! html/php +<table> +<tr> +<td><a href="/wiki/Foo" title="Foo">Foo</a>-bar +</td> +<td>+1 +</td> +<td>-2 +</td></tr></table> + +!! end + +!! test +T97430: Don't emit empty nowiki pairs around marker meta tags +!! options +parsoid=html2wt +!! html/parsoid +<p>*This is a long sentence here that will make the nowiki algo split up the nowikis into multiple pairs +|** Make this another long long long sentence forcing the nowiki algo to split up the nowikis.</p> +!! wikitext +<nowiki>*</nowiki>This is a long sentence here that will make the nowiki algo split up the nowikis into multiple pairs +|** Make this another long long long sentence forcing the nowiki algo to split up the nowikis. +!! end + +!! test +Unclosed xmlish element in table line shouldn't eat end delimiters +!! options +parsoid=html2wt +!! html/parsoid +<table> +<tbody><tr><td> <foo</td> +<td> bar></td></tr> +</tbody></table> +!! wikitext +{| +| <foo +| bar> +|} +!! html/php +<table> +<tr> +<td><foo +</td> +<td>bar> +</td></tr></table> + +!! end + +#### --------------- Links ---------------- +#### 1. Quote marks in link text +#### 2. Wikilinks: Escapes needed +#### 3. Wikilinks: No escapes needed +#### 4. Extlinks: Escapes needed +#### 5. Extlinks: No escapes needed +#### -------------------------------------- +!! test +Links 1. WikiLinks: No escapes needed +!! options +parsoid=html2wt +!! html/parsoid +<p><a rel="mw:WikiLink" href="Foo" title="Foo">Foo<i>boo</i></a> +<a rel="mw:WikiLink" href="Foo" title="Foo">[Foobar]</a> +<a rel="mw:WikiLink" href="Foo" title="Foo">x [Foobar] x</a></p> +!! wikitext +[[Foo|Foo''boo'']] +[[Foo|[Foobar]]] +[[Foo|x [Foobar] x]] +!! html/php +<p><a href="/wiki/Foo" title="Foo">Foo<i>boo</i></a> +<a href="/wiki/Foo" title="Foo">[Foobar]</a> +<a href="/wiki/Foo" title="Foo">x [Foobar] x</a> +</p> +!! end + +!! test +Links 2. WikiLinks: Escapes needed +!! options +parsoid=html2wt +!! html/parsoid +<a href="Foo" rel="mw:WikiLink">Foobar]</a> +<a href="Foo" rel="mw:WikiLink">x [http://google.com g] x</a> +<a href="Foo" rel="mw:WikiLink">[[Bar]]</a> +<a href="Foo" rel="mw:WikiLink">x [[Bar]] x</a> +<a href="Foo" rel="mw:WikiLink">|Bar</a> +<a href="Foo" rel="mw:WikiLink">]]bar</a> +<a href="Foo" rel="mw:WikiLink">[[bar</a> +<a href="Foo" rel="mw:WikiLink">x [[ y</a> +<a href="Foo" rel="mw:WikiLink">x ]] y</a> +<a href="Foo" rel="mw:WikiLink">x ]] y [[ z</a> +!! wikitext +[[Foo|<nowiki>Foobar]</nowiki>]] +[[Foo|x <nowiki>[http://google.com g]</nowiki> x]] +[[Foo|<nowiki>[[Bar]]</nowiki>]] +[[Foo|<nowiki>x [[Bar]] x</nowiki>]] +[[Foo|<nowiki>|Bar</nowiki>]] +[[Foo|<nowiki>]]bar</nowiki>]] +[[Foo|<nowiki>[[bar</nowiki>]] +[[Foo|<nowiki>x [[ y</nowiki>]] +[[Foo|<nowiki>x ]] y</nowiki>]] +[[Foo|<nowiki>x ]] y [[ z</nowiki>]] +!! html/php +<p><a href="/wiki/Foo" title="Foo">Foobar]</a> +<a href="/wiki/Foo" title="Foo">x [http://google.com g] x</a> +<a href="/wiki/Foo" title="Foo">[[Bar]]</a> +<a href="/wiki/Foo" title="Foo">x [[Bar]] x</a> +<a href="/wiki/Foo" title="Foo">|Bar</a> +<a href="/wiki/Foo" title="Foo">]]bar</a> +<a href="/wiki/Foo" title="Foo">[[bar</a> +<a href="/wiki/Foo" title="Foo">x [[ y</a> +<a href="/wiki/Foo" title="Foo">x ]] y</a> +<a href="/wiki/Foo" title="Foo">x ]] y [[ z</a> +</p> +!! end + +!! test +Links 3. WikiLinks: No escapes needed +!! options +parsoid=html2wt +!! html/parsoid +<p><a rel="mw:WikiLink" href="Foo">[Foobar</a> +<a rel="mw:WikiLink" href="Foo" title="Foo">foo|bar</a></p> +!! wikitext +[[Foo|[Foobar]] +[[Foo|foo|bar]] +!! html/php +<p><a href="/wiki/Foo" title="Foo">[Foobar</a> +<a href="/wiki/Foo" title="Foo">foo|bar</a> +</p> +!! end + +!! test +Links 4. ExtLinks: Escapes needed +!! options +parsoid=html2wt +!! html/parsoid +<p><a rel="mw:ExtLink" href="http://google.com">[google]</a> +<a rel="mw:ExtLink" href="http://google.com">google]</a> +<a rel="mw:ExtLink" href="http://google.com">goog] le</a></p> +<p>[http://google.com]</p> +<p>[http://google.com google]</p> +<p>[<a rel="mw:ExtLink" href="http://google.com">http://google.com</a>]</p> +<p>[<a rel="mw:ExtLink" href="http://google.com" about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"http://google.com"}},"i":0}}]}'>http://google.com</a>]</p> +!! wikitext +[http://google.com <nowiki>[google]</nowiki>] +[http://google.com <nowiki>google]</nowiki>] +[http://google.com <nowiki>goog] le</nowiki>] + +<nowiki>[http://google.com]</nowiki> + +<nowiki>[http://google.com google]</nowiki> + +[http://google.com<nowiki>]</nowiki> + +[{{echo|http://google.com}}<nowiki>]</nowiki> +!! html/php +<p><a rel="nofollow" class="external text" href="http://google.com">[google]</a> +<a rel="nofollow" class="external text" href="http://google.com">google]</a> +<a rel="nofollow" class="external text" href="http://google.com">goog] le</a> +</p><p>[http://google.com] +</p><p>[http://google.com google] +</p><p>[<a rel="nofollow" class="external free" href="http://google.com">http://google.com</a>] +</p><p>[<a rel="nofollow" class="external free" href="http://google.com">http://google.com</a>] +</p> +!! end + +!! test +Links 5. ExtLinks: No escapes needed +!! options +parsoid=html2wt +!! html/parsoid +<p><a rel="mw:ExtLink" href="http://google.com">[google</a></p> +<p>[<a ref="mw:ExtLink" href="http://google.com"></a>]</p> +!! wikitext +[http://google.com [google] + +[[http://google.com]] +!! html/php +<p><a rel="nofollow" class="external text" href="http://google.com">[google</a> +</p><p>[<a rel="nofollow" class="external autonumber" href="http://google.com">[1]</a>] +</p> +!! end + +!! test +Links 6. Add <nowiki/>s between text-nodes and url-links when required (T66300) +!! options +parsoid=html2wt +!! html/parsoid +<p>x<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>y +<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>?x +<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>&x +<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>'x +<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>,x +<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>.x +<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>;x +<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>:x +<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>;x +<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>!x +<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>=x +<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>(x) +<a rel="mw:ExtLink" href="http://example.com(x" data-parsoid='{"stx":"url"}'>http://example.com(x</a>) +</p> +!! wikitext +x<nowiki/>http://example.com<nowiki/>y +http://example.com<nowiki/>?x +http://example.com<nowiki/>&x +http://example.com<nowiki/>'x +http://example.com<nowiki/>,x +http://example.com<nowiki/>.x +http://example.com<nowiki/>;x +http://example.com<nowiki/>:x +http://example.com<nowiki/>;x +http://example.com<nowiki/>!x +http://example.com<nowiki/>=x +http://example.com<nowiki/>(x) +http://example.com(x<nowiki/>) +!! end + +!! test +Links 7a. Don't add spurious <nowiki/>s between text-nodes and url-links (T66300) +!! options +parsoid=html2wt +!! html/parsoid +<p>x +<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a> +y +"<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>" +(<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>) +(<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>) foo +<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>, +<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>, foo +</p> +!! wikitext +x +http://example.com +y +"http://example.com" +(http://example.com) +(http://example.com) foo +http://example.com, +http://example.com, foo +!! html/php +<p>x +<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> +y +"<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>" +(<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>) +(<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>) foo +<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>, +<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>, foo +</p> +!! end + +!! test +Links 7b. Don't add spurious <nowiki/>s between text-nodes and url-links (T66300) +!! options +parsoid=html2wt +!! html/parsoid +<p><a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>.,;:!?\ +-<a rel="mw:ExtLink" href="http://example.com">http://example.com</a>:</p> +!! wikitext +http://example.com.,;:!?\ +-http://example.com: +!! html/php +<p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>.,;:!?\ +-<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>: +</p> +!! end + +!! test +Links 8. Add <nowiki/>s between text-nodes and RFC-links when required (T66300) +!! options +parsoid=html2wt +!! html/parsoid +<p><a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>4 +<a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y +X<a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y</p> +!! wikitext +RFC 123<nowiki/>4 +RFC 123<nowiki/>y +X<nowiki/>RFC 123<nowiki/>y +!! end + +!! test +Links 9. Don't add spurious <nowiki/>s between text-nodes and RFC-links (T66300) +!! options +parsoid=html2wt +!! html/parsoid +<p><a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>?foo +<a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>&foo +-<a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>- +</p> +!! wikitext +RFC 123?foo +RFC 123&foo +-RFC 123- +!! html/php +<p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>?foo +<a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>&foo +-<a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>- +</p> +!! end + +!! test +Links 10. Add <nowiki/>s between text-nodes and PMID-links when required (T66300) +!! options +parsoid=html2wt +!! html/parsoid +<p><a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>4 +<a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>y +X<a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>y +!! wikitext +PMID 123<nowiki/>4 +PMID 123<nowiki/>y +X<nowiki/>PMID 123<nowiki/>y +!! end + +!! test +Links 11. Don't add spurious <nowiki/>s between text-nodes and PMID-links (T66300) +!! options +parsoid=html2wt +!! html/parsoid +<p><a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>?foo +<a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>&foo +-<a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>- +</p> +!! wikitext +PMID 123?foo +PMID 123&foo +-PMID 123- +!! html/php +<p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>?foo +<a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>&foo +-<a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>- +</p> +!! end + +!! test +Links 12. Add <nowiki/>s between text-nodes and ISBN-links when required (T66300) +!! options +parsoid=html2wt +!! html/parsoid +<p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>1 +<a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>x +a<a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>b +</p> +!! wikitext +ISBN 1234567890<nowiki/>1 +ISBN 1234567890<nowiki/>x +a<nowiki/>ISBN 1234567890<nowiki/>b +!! end + +!! test +Links 13. Don't add spurious <nowiki/>s between text-nodes and ISBN-links (T66300) +!! options +parsoid=html2wt +!! html/parsoid +<p>-<a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>'s +!! wikitext +-ISBN 1234567890's +!! html/php +<p>-<a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>'s +</p> +!! end + +!! test +Links 14. Protect link-like plain text. (Parsoid bug T78425) +!! options +parsoid=html2wt +!! html/* +<p>this is not a link: http://example.com +</p> +!! wikitext +this is not a link: <nowiki>http://example.com</nowiki> +!! end + +!! test +Links 15. Link trails can't become link prefixes. +!! options +language=is +parsoid=html2wt +!! html/parsoid +<p><a rel="mw:WikiLink" href="Söfnuður" title="Söfnuður" data-parsoid='{"stx":"simple","tail":"-"}'>Söfnuður-</a><a rel="mw:WikiLink" href="00" title="00">00</a></p> +!! wikitext +[[Söfnuður]]-[[00]] +!! html/php +<p><a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">Söfnuður-</a><a href="/wiki/00" title="00">00</a> +</p> +!! end + +#### --------------- Quotes --------------- +#### 1. Quotes inside <b> and <i> +#### 2. Link fragments separated by <i> and <b> tags +#### 3. Link fragments inside <i> and <b> +#### 4. No escaping needed +#### -------------------------------------- +!! test +1a. Quotes inside <b> and <i> +!! options +parsoid=html2wt +!! html/* +<p><i>'foo'</i> +<i>''foo''</i> +<i>'''foo'''</i> +<i>foo</i>'s +<b>'foo'</b> +<b>''foo''</b> +<b>'''foo'''</b> +<b>foo'<i>bar'</i>baz</b> +<b>foo</b>'s +'<i>foo</i> +<i>foo</i>' +<i>foo'</i>' +'<i>foo</i>' +'<b>foo</b> +<b>foo</b>' +'<b>foo</b>' +<i>fools'<span> errand</span></i> +<i><span>fool</span>'s errand</i> +'<i>foo</i> bar '<i>baz</i> +a|!*#-:;+-~[]{}b'<i>x</i> +</p> +!! wikitext +''<nowiki/>'foo''' +''<nowiki>''foo''</nowiki>'' +''<nowiki>'''foo'''</nowiki>'' +''foo''<nowiki/>'s +'''<nowiki/>'foo'''' +'''<nowiki>''foo''</nowiki>''' +'''<nowiki>'''foo'''</nowiki>''' +'''foo'<nowiki/>''bar'<nowiki/>''baz''' +'''foo'''<nowiki/>'s +'''foo'' +''foo''<nowiki/>' +''foo'''<nowiki/>' +'''foo''<nowiki/>' +''''foo''' +'''foo'''<nowiki/>' +''''foo'''<nowiki/>' +''fools'<span> errand</span>'' +''<span>fool</span>'s errand'' +'<nowiki/>''foo'' bar '''baz'' +a|!*#-:;+-~[]{}b'''x'' +!! end + +!! test +1b. Quotes inside <b> and <i> with other tags on same line +!! options +parsoid=html2wt +!! html/parsoid +'<i>a</i> foo <i><a rel="mw:WikiLink" href="Bar" title="Bar">bar</a></i> +<i>a'</i> foo <i><a rel="mw:WikiLink" href="Bar" title="Bar">bar</a></i> +<i>a'</i> foo <b><a rel="mw:WikiLink" href="Bar" title="Bar" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[bar]]"}},"i":0}}]}'>bar</a></b> +<a rel="mw:WikiLink" href="Foo" title="Foo">foo</a> x'<i><a href="Bar" rel="mw:WikiLink" title="Bar">bar</a></i> +'<i>foo</i> <span class="mw-ref" id="cite_ref-1-0" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","body":{"id":"mw-reference-text-cite_note-1"},"attrs":{}}'><a href="./Main_Page#cite_note-1"><span class="mw-reflink-text">[1]</span></a></span> +'<i>foo</i> <div title="name">test</div> +'<i>foo</i> and <br data-parsoid='{"stx":"html","noClose":true}'/> bar +<ol class="mw-references references" typeof="mw:Extension/references" about="#mwt5" data-mw='{"name":"references","attrs":{}}'> +<li about="#cite_note-1" id="cite_note-1"><span rel="mw:referencedBy"><a href="./Main_Page#cite_ref-1">↑</a></span> <span id="mw-reference-text-cite_note-1" class="mw-reference-text" data-parsoid="{}">test</span></li> +</ol> +!! wikitext +'''a'' foo ''[[bar]]'' +''a''' foo ''[[bar]]'' +''a''' foo '''{{echo|[[bar]]}}''' +[[foo]] x'''[[bar]]'' +'''foo'' <ref>test</ref> +'''foo'' <div title="name">test</div> +'''foo'' and <br> bar +<references /> +!! end + +!! test +2. Link fragments separated by <i> and <b> tags +!! options +parsoid=html2wt +!! html/parsoid +<p>[[<i>foo</i>hello]]</p> +<p>[[<b>foo</b>hello]]</p> +!! wikitext +[[''foo''<nowiki>hello]]</nowiki> + +[['''foo'''<nowiki>hello]]</nowiki> +!! end + +# FIXME: Escaping one or both of [[ and ]] is also acceptable -- +# this is one of the shortcomings of this format +!! test +3. Link fragments inside <i> and <b> +!! options +parsoid=html2wt +!! html/parsoid +<p><i>[[foo</i>]]</p> +<p><b>[[foo</b>]]</p> +!! wikitext +''[[foo''<nowiki>]]</nowiki> + +'''[[foo'''<nowiki>]]</nowiki> +!! end + +!! test +4. No escaping needed +!! options +parsoid=html2wt +!! html/parsoid +<p>'<span><i>bar</i></span>' +'<span><b>bar</b></span>' +'a:b'foo +</p> +!! wikitext +'<span>''bar''</span>' +'<span>'''bar'''</span>' +'a:b'foo +!! end + +#### ----------- Paragraphs --------------- +#### 1. No unnecessary escapes +#### -------------------------------------- + +!! test +1. No unnecessary escapes +!! options +parsoid=html2wt +!! html/parsoid +<p>bar <span>[[foo]]</span> +</p><p>=bar <span>[[foo]]</span> +</p><p>[[bar <span>[[foo]]</span> +</p><p>]]bar <span>[[foo]]</span> +</p><p>=bar <span>foo]]</span>= +</p> +!! wikitext +bar <span><nowiki>[[foo]]</nowiki></span> + +=bar <span><nowiki>[[foo]]</nowiki></span> + +[[bar <span><nowiki>[[foo]]</nowiki></span> + +]]bar <span><nowiki>[[foo]]</nowiki></span> + +=bar <span>foo]]</span><nowiki>=</nowiki> +!!end + +#### ----------------------- PRE -------------------------- +#### 1. Leading whitespace in SOL context should be escaped +#### ------------------------------------------------------ +!! test +1. Leading whitespace in SOL context should be escaped +!! options +parsoid=html2wt +!! html/parsoid +<p> a</p> + +<p> a</p> + +<p> a(tab)</p> + +<p> a +<!--cmt--> + a</p> + +<p>a + b</p> + +<p>a + b</p> + +<p>a + b</p> +!! wikitext +<nowiki> </nowiki>a + +<nowiki> </nowiki> a + + a(tab) + +<nowiki> </nowiki> a +<!--cmt--> +<nowiki> </nowiki>a + +a +<nowiki> </nowiki>b + +a + b + +a + b +!! html/php +<p> a +</p><p> a +</p><p> a(tab) +</p><p> a + a +</p><p>a + b +</p><p>a + b +</p><p>a + b +</p> +!! end + +!! test +2. Leading whitespace in non-indent-pre contexts should not be escaped +!! options +parsoid=html2wt +!! html/parsoid +<p>foo <span about="#mwt2" class="mw-ref" id="cite_ref-1" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","body":{"id":"mw-reference-text-cite_note-1"},"attrs":{}}'><a href="./Main_Page#cite_note-1"><span class="mw-reflink-text">[1]</span></a></span></p> +<ol class="mw-references references" typeof="mw:Extension/references" about="#mwt4" data-mw='{"name":"references","attrs":{}}'> +<li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text"><i>a</i> + b</span></li> +</ol> +!! wikitext +foo <ref>''a'' + b</ref> +<references /> +!! end + +!! test +3. Leading whitespace in indent-pre suppressing contexts should not be escaped +!! options +parsoid=html2wt +!! html/parsoid +<blockquote> +<p> + a + <span>b</span> + c</p> +</blockquote> +!! wikitext +<blockquote> + a + <span>b</span> + c +</blockquote> +!! end + +!! test +4. Leading whitespace in indent-pre suppressing contexts should not be escaped +!! options +parsoid=html2wt +!! html/parsoid + <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption>caption</figcaption></figure> +!! wikitext + [[File:Foobar.jpg|thumb|caption]] +!! end + +!! test +5. Nowiki escaping should account for indent-pres +!! options +parsoid=html2wt +!! html/parsoid +<pre>==foo==</pre> +!! wikitext + ==foo== +!! end + +!!test +T95794: nowiki escaping should account for leading space at start-of-line in an indent-pre block +!! options +parsoid=html2wt +!! html/parsoid +<pre> +* foo +* bar +</pre> +!! wikitext + * foo + * bar +!! end + +#### --------------- Behavior Switches -------------------- + +!! test +1. Valid behavior switches should be escaped +!! options +parsoid=html2wt +!! html/parsoid +__TOC__ +<i>__TOC__</i> +!! wikitext +<nowiki>__TOC__</nowiki> +''<nowiki>__TOC__</nowiki>'' +!! end + +!! test +2. Invalid behavior switches should not be escaped +!! options +parsoid=html2wt +!! html/parsoid +__TOO__ +__|__ +!! wikitext +__TOO__ +__|__ +!! end + +# We use indent-pre as an indirect way to test for sol-transparent behavior. +!! test +Behavior switches should be SOL-transparent +!! options +parsoid=html2wt +!! html/parsoid + <meta property="mw:PageProp/toc" /> + + <!-- this one's bogus --> +<pre>__TOO__</pre> + +<pre data-parsoid='{}'><meta property="mw:PageProp/toc" data-parsoid='{"src":"__TOC__","magicSrc":"__TOC__"}'/> foo</pre> + +<meta property="mw:PageProp/toc" data-parsoid='{"src":"__TOC__","magicSrc":"__TOC__"}'/><pre data-parsoid='{}'>bar</pre> +!! wikitext + __TOC__ + + <!-- this one's bogus --> + __TOO__ + + __TOC__ foo + +__TOC__ + bar +!! end + +#### --------------- HTML tags --------------- +#### 1. a tags +#### 2. other tags +#### 3. multi-line html tag +#### 4. extension tags +#### ----------------------------------------- +!! test +1. a tags +!! options +parsoid=html2wt +!! html/parsoid +<a href="http://google.com">google</a> +!! wikitext +<a href="http://google.com">google</a> +!! end + +!! test +2. other tags +!! options +parsoid=html2wt +!! html/parsoid +<ul><li> <div>foo</div></li> +<li> <div style="color:red">foo</div></li> +<li> <td></li></ul> + +!! wikitext +* <nowiki><div>foo</div></nowiki> +* <nowiki><div style="color:red">foo</div></nowiki> +* <nowiki><td></nowiki> +!! end + +!! test +3. multi-line html tag +!! options +parsoid=html2wt +!! html/parsoid +<p><div +>foo</div +> +</p> +!! wikitext +<nowiki><div +>foo</div +></nowiki> +!! end + +!! test +4. extension tags +!! options +parsoid=html2wt +!! html/parsoid +<p><ref>foo</ref> +</p><p><ref>bar +</p><p>baz</ref> +</p> +!! wikitext +<nowiki><ref>foo</ref></nowiki> + +<nowiki><ref>bar</nowiki> + +baz<nowiki></ref></nowiki> +!! end + +#### --------------- Others --------------- +!! test +Escaping nowikis +!! options +parsoid=html2wt +!! html/parsoid +<p><nowiki>foo</nowiki> +</p> +!! wikitext +<nowiki>foo</nowiki> +!! end + +## The quote-char in the input is necessary for triggering the bug +!! test +(T54035) Nowiki-escaping should not get tripped by " :" in text +!! options +parsoid=html2wt +!! html/parsoid +<p>foo's bar :</p> +!! wikitext +foo's bar : +!! end + +#----------- End of wikitext escaping tests -------------- + +!! test + +Tag-like HTML structures are passed through as text +!! wikitext +<x y> + +<x.y> + +<x-y> + +1>2 + +x<y + +a>b + +1<d e>f +!! html +<p><x y> +</p><p><x.y> +</p><p><x-y> +</p><p>1>2 +</p><p>x<y +</p><p>a>b +</p><p>1<d e>f +</p> +!! end + +!! test +HTML tag with necessary entities in attributes +!! wikitext +<span title="&amp;">foo</span> +!! html +<p><span title="&amp;">foo</span> +</p> +!! end + +!! test +HTML tag with 'unnecessary' entity encoding in attributes +!! wikitext +<span title="&">foo</span> +!! html +<p><span title="&">foo</span> +</p> +!! end + +!! test +HTML tag with broken attribute value quoting +!! options +parsoid=wt2html,html2html +!! wikitext +<span title="Hello world>Foo</span> +!! html/php +<p><span title="Hello world">Foo</span> +</p> +!! html/parsoid +<p><span title="Hello world">Foo</span></p> +!! end + +!! test +Self-closed tag with broken attribute value quoting +!! options +parsoid=wt2html,html2html +!! wikitext +<div title="Hello world />Foo +!! html/php+tidy +<div title="Hello world"></div><p>Foo +</p> +!! html/parsoid +<div title="Hello world " data-parsoid='{"stx":"html","selfClose":true}'></div><p>Foo</p> +!! end + +!! test +Table with broken attribute value quoting +!! options +parsoid=wt2html,html2html +!! wikitext +{| +| title="Hello world|Foo +|} +!! html/php +<table> +<tr> +<td title="Hello world">Foo +</td></tr></table> + +!! html/parsoid +<table> +<tr> +<td title="Hello world">Foo +</td></tr></table> + +!! end + +!! test +Table with broken attribute value quoting on consecutive lines +!! options +parsoid=wt2html,html2html +!! wikitext +{| +| title="Hello world|Foo +| style="color:red|Bar +|} +!! html/php +<table> +<tr> +<td title="Hello world">Foo +</td> +<td style="color:red">Bar +</td></tr></table> + +!! html/parsoid +<table><tbody> +<tr> +<td title="Hello world">Foo +</td><td style="color: red">Bar +</td></tr></tbody></table> + +!! end + +!!test +Accept empty td cell attribute +!! wikitext +{| +| align="center" |foo|| | +|} +!! html +<table> +<tr> +<td align="center">foo</td> +<td> +</td></tr></table> + +!!end + +!!test +Non-empty attributes in th-cells +!! wikitext +{| +!Foo!! style="color: red" |Bar +|} +!! html +<table> +<tr> +<th>Foo</th> +<th style="color: red">Bar +</th></tr></table> + +!!end + +!!test +Accept empty attributes in th-cells +!! wikitext +{| +!|foo!!|bar +|} +!! html +<table> +<tr> +<th>foo</th> +<th>bar +</th></tr></table> + +!!end + +!!test +Empty table rows go away +!! wikitext +{| +|Hello +|there +|- class="foo" +|- +|} +!! html +<table> +<tr> +<td>Hello +</td> +<td>there +</td></tr> + +</table> + +!! end + +### +### Parsoid-centric tests for testing RTing of inter-element separators +### Edge cases not tested by existing parser tests and specific to +### Parsoid-specific serialization strategies. +### + +!!test +RT-ed inter-element separators should be valid separators +!! wikitext +{| +|- [[foo]] +|} +!! html/php +<table> + +</table> + +!! html/parsoid +<table> +<tbody><tr class='mw-empty-elt' data-parsoid='{"startTagSrc":"|-","a":{"[[foo]]":null},"sa":{"[[foo]]":""},"autoInsertedEnd":true}'></tr> +</tbody></table> +!!end + +# Parsoid-only test of a DOM pass +!!test +Trailing newlines in a deep dom-subtree that ends a wikitext line should be migrated out +!! wikitext +{| +|<small>foo +bar +|} + +{| +|<small>foo<small> +|} +!! html/parsoid +<table> +<tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'><small data-parsoid='{"stx":"html","autoInsertedEnd":true}'>foo +<p>bar</p></small></td></tr> +</tbody></table> + +<table> +<tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'><small data-parsoid='{"stx":"html","autoInsertedEnd":true}'>foo<small data-parsoid='{"stx":"html","autoInsertedEnd":true}'></small></small></td></tr> +</tbody></table> +!!end + +# Note that the "style" attribute is really a template parameter here. +# The = would have to be {{=}} if you wanted the literal. +!!test +Empty TD followed by TD with tpl-generated attribute +!! wikitext +{| +|- +| +|{{echo|style='color:red'}}|foo +|} +!! html +<table> + +<tr> +<td> +</td> +<td>foo +</td></tr></table> + +!!end + +!!test +Indented table with an empty td +!! wikitext + {| + |- + | + |foo + |} +!! html +<table> + +<tr> +<td> +</td> +<td>foo +</td></tr></table> + +!!end + +## We have some newline diffs RT-ing this edge case +## and it is not important enough -- we seem to be emitting +## at most 2 newlines after a </tr> and this is unrelated to +## the issue from T85627 that this is testing. +!!test +Indented table with blank lines in between (T85627) +!! options +parsoid=wt2html +!! wikitext + {| + |foo + + + |} +!! html +<table> + +<tr> +<td>foo +</td></tr></table> + +!!end + +!!test +Indented block & table +!! wikitext + <div>foo</div> + {| + |foo + |} +!! html/php + <div>foo</div> +<table> +<tr> +<td>foo +</td></tr></table> + +!! html/parsoid + <div data-parsoid='{"stx":"html"}'>foo</div> + <table><tbody> + <tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'>foo</td></tr> + </tbody></table> +!!end + +!! test +Indent and comment before table row +!! wikitext +{| + <!--hi-->|- + |there +|} +!! html/php +<table> + +<tr> +<td>there +</td></tr></table> + +!! html/parsoid +<table> + <!--hi--><tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'> + <td data-parsoid='{"autoInsertedEnd":true}'> there</td></tr> +</tbody></table> +!! end + +# Parsoid-specific since PHP parser doesn't handle this mixed tbl-wikitext +!!test +Empty TR followed by a template-generated TR +!!options +parsoid +!! wikitext +{| +|- +{{echo|<tr><td>foo</td></tr>}} +|} +!! html +<table> +<tbody> +<tr class='mw-empty-elt'></tr> +<tr about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"<tr><td>foo</td></tr>"}},"i":0}}]}'> +<td>foo</td></tr> +</tbody></table> +!!end + +## PHP and parsoid output differ for this, and since this is primarily +## for testing Parsoid's serializer, marking this Parsoid only +!!test +Empty TR followed by mixed-ws-comment line should RT correctly +!!options +parsoid +!! wikitext +{| +|- + <!--c--> +|- +<!--c--> <!--d--> +|} +!! html +<table> +<tbody> +<tr class='mw-empty-elt'></tr> + <!--c--> +<tr> +<!--c--> </tr><!--d--> +</tbody></table> + +!!end + +!!test +Multi-line image caption generated by templates with/without trailing newlines +!! wikitext +[[File:Foobar.jpg|thumb|300x300px|foo\n{{echo|A}}\n{{echo|B}}\n{{echo|C}}]] +[[File:Foobar.jpg|thumb|300x300px|foo\n{{echo|A}}\n{{echo|B}}\n{{echo|C}}\n\n]] +!! html/parsoid +<figure typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="34" width="300"/></a><figcaption>foo\n<span about="#mwt9" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"A"}},"i":0}}]}'>A</span>\n<span about="#mwt10" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"B"}},"i":0}}]}'>B</span>\n<span about="#mwt11" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"C"}},"i":0}}]}'>C</span></figcaption></figure> +<figure typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="34" width="300"/></a><figcaption>foo\n<span about="#mwt12" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"A"}},"i":0}}]}'>A</span>\n<span about="#mwt13" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"B"}},"i":0}}]}'>B</span>\n<span about="#mwt14" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"C"}},"i":0}}]}'>C</span>\n\n</figcaption></figure> +!!end + +!! test +New element inserted (without intervening newlines) after an old sol-transparent node should serialize correctly +!! options +parsoid=html2wt +!! html/parsoid +<meta typeof="mw:Includes/IncludeOnly" data-parsoid='{"src":"<includeonly>foo</includeonly>"}'/><meta typeof="mw:Includes/IncludeOnly/End" data-parsoid='{"src":""}'/><p>new para</p> + +<link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{}'/><h1>new heading</h1> +!! wikitext +<includeonly>foo</includeonly> +new para + +[[Category:Foo]] + += new heading = +!! end + +## PHP emits broken html for this, and since this is primarily +## a Parsoid serializer test, marking this Parsoid only +!!test +Improperly nested inline or quotes tags with whitespace in between +!! wikitext +<span> <s>x</span> </s> +''' ''x''' '' +!! html/parsoid +<p><span> <s>x</s></span><s> </s> +<b> <i>x</i></b><i> </i> +</p> +!!end + +!!test +Encapsulate protected attributes from wt +!! wikitext +<div typeof="mw:placeholder stuff" data-mw="whoo" data-parsoid="weird" data-parsoid-other="no" about="time" rel="mw:true">foo</div> + +{| typeof="mw:placeholder stuff" data-mw="whoo" data-parsoid="weird" data-parsoid-other="no" about="time" rel="mw:true" +| ok +|} +!! html/parsoid +<div data-x-typeof="mw:placeholder stuff" data-x-data-mw="whoo" data-x-data-parsoid="weird" data-x-data-parsoid-other="no" data-x-about="time" data-x-rel="mw:true">foo</div> + +<table data-x-typeof="mw:placeholder stuff" data-x-data-mw="whoo" data-x-data-parsoid="weird" data-x-data-parsoid-other="no" data-x-about="time" data-x-rel="mw:true"> +<tbody><tr><td data-parsoid='{"autoInsertedEnd":true}'> ok</td></tr> +</tbody></table> +!!end + +## Currently the p-wrapper is fragile in how it adds / removes transformations. +## Having nested or stray pre tags results in the attempt to add duplicates, +## causing an assertion fail. This test tries to prevent that situation. +!!test +Ensure ParagraphWrapper can deal with stray closing pre tags +!!options +parsoid=wt2html +!! wikitext +plain text</pre> +!! html/parsoid +plain text +!!end + +!!test +1. Ensure fostered text content is wrapped in element nodes +!!options +parsoid=wt2html +!! wikitext +<table>hi</table><table>ho</table> +!! html/parsoid +<p>hi</p> +<table></table> +<p>ho</p> +<table></table> +!!end + +!!test +2. Ensure fostered text content is wrapped in element nodes (traps regressions around fostered marker on the element getting lost) +!!options +parsoid=wt2html,wt2wt +!! wikitext +<table> +<tr> || || +<td> a +</table> +!! html/parsoid +<p> || || +</p><table> +<tbody><tr><td> a</td></tr> +</tbody></table> +!!end + +!!test +Encapsulation properly handles null DSR information from foster box +!!options +parsoid=wt2html,wt2wt +!! wikitext +{{echo|<table>foo<tr><td>bar</td></tr></table>}} +!! html/parsoid +<span typeof="mw:Transclusion" data-mw="{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"<table>foo<tr><td>bar</td></tr></table>"}},"i":0}}]}">foo</span><table><tbody><tr><td>bar</td></tr></tbody></table> +!!end + +!!test +1. Encapsulate foster-parented transclusion content +!!options +parsoid=wt2wt,wt2html +!! wikitext +<table>{{echo|foo<tr><td>bar</td></tr>}}</table> +!! html/parsoid +<p typeof="mw:Transclusion" data-mw="{"parts":["<table>",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo<tr><td>bar</td></tr>"}},"i":0}},"</table>"]}">foo</p><table> +<tbody> +<tr> +<td>bar</td> +</tr> +</tbody> +</table> +!!end + +!!test +2. Encapsulate foster-parented transclusion content +!!options +parsoid=wt2wt,wt2html +!! wikitext +<table><div>{{echo|foo}}</div><tr><td>bar</td></tr></table> +!! html/parsoid +<div typeof="mw:Transclusion" data-mw="{"parts":["<table><div>",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}},"</div><tr><td>bar</td></tr></table>"]}">foo</div> +<table> +<tbody> +<tr> +<td>bar</td> +</tr> +</tbody> +</table> +!!end + +!!test +3. Encapsulate foster-parented transclusion content +!!options +parsoid=wt2wt,wt2html +!! wikitext +<table><div><p>{{echo|foo</p></div><tr><td>}}bar</td></tr></table> +!! html/parsoid +<div typeof="mw:Transclusion" data-mw="{"parts":["<table><div><p>",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo</p></div><tr><td>"}},"i":0}},"bar</td></tr></table>"]}"> +<p>foo</p> +</div> +<table> +<tbody> +<tr> +<td>bar</td> +</tr> +</tbody> +</table> +!!end + +!!test +4. Encapsulate foster-parented transclusion content +!!options +parsoid=wt2wt,wt2html +!! wikitext +<table><div><p>{{echo|foo</p></div><tr><td>}}bar</td></tr></table> +!! html/parsoid +<div typeof="mw:Transclusion" data-mw="{"parts":["<table><div><p>",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo</p></div><tr><td>"}},"i":0}},"bar</td></tr></table>"]}"> +<p>foo</p> +</div> +<table> +<tbody> +<tr> +<td>bar</td> +</tr> +</tbody> +</table> +!!end + +!!test +5. Encapsulate foster-parented transclusion content +!!options +parsoid=wt2wt,wt2html +!! wikitext +<table><tr><td><div><p>{{echo|foo</p></div></td>foo}}</tr></table> +!! html/parsoid +<p typeof="mw:Transclusion" data-mw="{"parts":["<table><tr><td><div><p>",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo</p></div></td>foo"}},"i":0}},"</tr></table>"]}">foo</p> +<table> +<tbody> +<tr> +<td> +<div> +<p>foo</p> +</div> +</td> +</tr> +</tbody> +</table> +!!end + +!!test +6. Encapsulate foster-parented transclusion content +!!options +parsoid=wt2wt,wt2html +!! wikitext +<table><tr><td><div><p>{{echo|foo</p></div></td>foo</tr></table>}}<p>ok</p> +!! html/parsoid +<p typeof="mw:Transclusion" data-mw="{"parts":["<table><tr><td><div><p>",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo</p></div></td>foo</tr></table>"}},"i":0}}]}">foo</p> +<table> +<tbody> +<tr> +<td> +<div> +<p>foo</p> +</div> +</td> +</tr> +</tbody> +</table> +<p>ok</p> +!!end + +!!test +7. Encapsulate foster-parented transclusion content +!!options +parsoid=wt2wt,wt2html +!! wikitext +<table>{{echo|<p>foo</p>}}<td>bar</td></table> +!! html/parsoid +<p typeof="mw:Transclusion" data-mw="{"parts":["<table>",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"<p>foo</p>"}},"i":0}},"<td>bar</td></table>"]}">foo</p> +<table> +<tbody> +<tr> +<td>bar</td> +</tr> +</tbody> +</table> +!!end + +# Note that the wt is broken on purpose: the = should be {{=}} if you +# don't want it to be a template parameter key. +!!test +8. Encapsulate foster-parented transclusion content +!!options +parsoid=wt2wt,wt2html +!! wikitext +{{echo|a +}}{|{{echo|style='color:red'}} +|- +|b +|} +!! html/parsoid +<p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"a\n"}},"i":0}}]}'>a</p> +<span> </span> +<p typeof="mw:Transclusion" data-mw='{"parts":["{|",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"style":{"wt":"'color:red'"}},"i":0}},"\n|-\n|b\n|}"]}'>{{{1}}}</p> +<table> +<tbody> +<tr> +<td>b</td> +</tr> +</tbody> +</table> +!!end + +!!test +9. Encapsulate foster-parented transclusion content +!!options +parsoid=wt2wt,wt2html +!! wikitext +<table>{{echo|hi</table>hello}} +!! html/parsoid +<p about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":["<table>",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi</table>hello"}},"i":0}}]}' data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true,"pi":[[{"k":"1"}]]}'>hi</p><table about="#mwt2" data-parsoid='{"stx":"html"}'></table><p about="#mwt2">hello</p> +!!end + +!!test +Table in fosterable position +!!options +parsoid=wt2html +!! wikitext +{{OpenTable}} +<div> +{| +|} +</div> +|} +!! html/parsoid +<div about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"OpenTable","href":"./Template:OpenTable"},"params":{},"i":0}},"\n<div>\n"]}' data-parsoid='{"stx":"html","autoInsertedEnd":true,"pi":[[]]}'></div><span about="#mwt1"> +</span> +<table about="#mwt1" data-parsoid='{"autoInsertedEnd":true}'></table> + +<table> +</table> +!!end + +# Parsoid only for T66747 +!! test +Properly encapsulate empty-content transclusions in fosterable positions +!! wikitext +<table> +{{#if:| +<td>foo</td> +}} +</table> +!! html/parsoid +<table about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":["<table>\n",{"template":{"target":{"wt":"#if:","function":"if"},"params":{"1":{"wt":"\n<td>foo</td>\n"}},"i":0}},"\n</table>"]}' data-parsoid='{"stx":"html","pi":[[{"k":"1"}]]}'> + +</table> +!! end + +!! test +Always encapsulate foster box when template range is expanded to table +!! options +parsoid=wt2wt +!! wikitext +{| +hello +{{OpenTable}} +|} +!! html/parsoid + +!! end + +!! test +T115289: Unclosed table +!! wikitext +{{echo|<table>}}<!--c-->[[Category:Two]] +!! html/parsoid +<link rel="mw:PageProp/Category" href="./Category:Two" about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"stx":"simple","a":{"href":"./Category:Two"},"sa":{"href":"Category:Two"},"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"<table>"}},"i":0}},"<!--c-->[[Category:Two]]"]}'/><table about="#mwt1" data-parsoid='{"stx":"html","autoInsertedEnd":true}'><!--c--></table> +!! end + +!! test +T115289: Don't migrate newlines out of tables with fostered content +!! wikitext +<table><td></td>{{echo|<tr>[[Category:One]]}}<!--c-->[[Category:Two]] +!! html/parsoid +<link rel="mw:PageProp/Category" href="./Category:One" about="#mwt2" typeof="mw:Transclusion" data-parsoid='{"stx":"simple","a":{"href":"./Category:One"},"sa":{"href":"Category:One"},"fostered":true,"pi":[[{"k":"1"}]]}' data-mw='{"parts":["<table><td></td>",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"<tr>[[Category:One]]"}},"i":0}},"<!--c-->[[Category:Two]]"]}'/><link rel="mw:PageProp/Category" href="./Category:Two" about="#mwt2"/><table about="#mwt2" data-parsoid='{"stx":"html","autoInsertedEnd":true}'><tbody><tr><td></td></tr><tr><!--c--></tr></tbody></table> +!! end + +!! test +T73074: More fostering fun +!! wikitext +<table><td></td>{{echo|<tr>}}<!--c-->[[Category:Two]] +!! html/parsoid +<link rel="mw:PageProp/Category" href="./Category:Two" data-parsoid='{"stx":"simple","a":{"href":"./Category:Two"},"sa":{"href":"Category:Two"},"fostered":true}'/><table data-parsoid='{"stx":"html","autoInsertedEnd":true}'><tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"stx":"html"}'></td></tr><tr about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"stx":"html","autoInsertedEnd":true,"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"<tr>"}},"i":0}},"<!--c-->[[Category:Two]]"]}'><!--c--></tr></tbody></table> +!! end + +!!test +Support <object> element with .data attribute +!!options +parsoid=html2wt +!! html/parsoid +<object data="test.swf"></object> +!! wikitext +<object data="test.swf"></object> +!!end + +!! test +Don't block XML namespace declaration +!! wikitext +<span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">MediaWiki</span> +!! html/php +<p><span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">MediaWiki</span> +</p> +!! html/parsoid +<p><span xmlns:dct="http://purl.org/dc/terms/" data-x-property="dct:title" data-parsoid='{"stx":"html"}'>MediaWiki</span></p> +!! end + +# ----------------------------------------------------------------- +# The following section of tests are primarily to spec requirements +# around Parsoid's serialization (old, new, edited content) +# +# All these tests are marked Parsoid html2wt and html2html only +# ---------------------------------------------------------------- + +!! test +Ignore rel attribute in a-tags during serialization to url-links +!! options +parsoid=html2wt +!! html/parsoid +<a href='http://en.wikipedia.org/wiki/Foobar'>http://en.wikipedia.org/wiki/Foobar</a> +<a href='http://en.wikipedia.org/wiki/Foobar' rel='mw:ExtLink'>http://en.wikipedia.org/wiki/Foobar</a> +<a href='http://en.wikipedia.org/wiki/Foobar' rel='mw:WikiLink'>http://en.wikipedia.org/wiki/Foobar</a> +!! wikitext +http://en.wikipedia.org/wiki/Foobar +http://en.wikipedia.org/wiki/Foobar +http://en.wikipedia.org/wiki/Foobar +!! end + +# 'mi' is a localinterwiki prefix as well as a language +!! test +Serialize interwiki links pointing to the current wiki as plain wiki links (T67869) +!! options +parsoid=html2wt +!! html/parsoid +<p><a rel="mw:ExtLink" href="http://mi.wikipedia.org/wiki/Foo">Foo</a></p> +!! wikitext +[[Foo]] +!! end + +!! test +Parsoid should accept interwiki shortcuts +!! options +parsoid=html2wt +!! html/parsoid +<p><a rel='mw:WikiLink' href='./fr:Foo'>Foo</a> +<a rel='mw:ExtLink' href='./fr:Foo'>Foo</a> +<a href='./fr:Foo'>Foo</a></p> +<p><a rel='mw:WikiLink' href='fr%3AFoo'>Foo</a> +<a rel='mw:ExtLink' href='fr%3AFoo'>Foo</a> +<a href='fr%3AFoo'>Foo</a></p> +<p><a href='FR%3AFoo'>Foo</a> +<a href='./FR:Foo'>Foo</a></p> +!! wikitext +[[:fr:Foo|Foo]] +[[:fr:Foo|Foo]] +[[:fr:Foo|Foo]] + +[[:fr:Foo|Foo]] +[[:fr:Foo|Foo]] +[[:fr:Foo|Foo]] + +[[:fr:Foo|Foo]] +[[:fr:Foo|Foo]] +!! end + +!! test +Parsoid should not accept invalid interwiki shortcuts +!! options +parsoid=html2wt +!! html/parsoid +<p><a rel='mw:WikiLink' href='news:Foo'>Foo</a> +<a rel='mw:ExtLink' href='news:Foo'>Foo</a> +<a href='news:Foo'>Foo</a></p> +!! wikitext +[news:Foo Foo] +[news:Foo Foo] +[news:Foo Foo] +!! end + +# See T93839 +!! test +New wikilinks should be serialized properly +!! options +parsoid=html2wt +!! html/parsoid +<a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{}'>Foo</a> +<a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a> +<a href="//en.wikipedia.org/wiki/Foo">//en.wikipedia.org/wiki/Foo</a> +<a href="http://en.wikipedia.org/wiki/Foo">http://en.wikipedia.org/wiki/Foo</a> +<a href="//en.wikipedia.org/wiki/Foo_bar">//en.wikipedia.org/wiki/Foo bar</a> +!! wikitext +[[Foo]] +[[Foo]] +[[:en:Foo|//en.wikipedia.org/wiki/Foo]] +http://en.wikipedia.org/wiki/Foo +[[:en:Foo_bar|//en.wikipedia.org/wiki/Foo bar]] +!! end + +!! test +New wiki links (href variations) +!! options +parsoid=html2wt +!! html/parsoid +<a rel="mw:WikiLink" href="./Foo_bar">Foo_bar</a> +<a rel="mw:WikiLink" href="Foo_bar">Foo_bar</a> +<a rel="mw:WikiLink" href="Foo bar">Foo_bar</a> +<a rel="mw:WikiLink" href="./Toxine_bact%C3%A9rienne">Toxine bactérienne</a> +!! wikitext +[[Foo_bar]] +[[Foo_bar]] +[[Foo_bar]] +[[Toxine bactérienne]] +!! end + +!! test +New wiki links (content string variations) +!! options +parsoid=html2wt +!! html/parsoid +<a rel="mw:WikiLink" href="./Foo_bar">Foo_bar</a> +<a rel="mw:WikiLink" href="./Foo_bar">Foo bar</a> +<a rel="mw:WikiLink" href="./Foo_bar">./Foo_bar</a> +!! wikitext +[[Foo_bar]] +[[Foo bar]] +[[Foo_bar|./Foo_bar]] +!! end + +!! test +New category links (href variations) +!! options +parsoid=html2wt +!! html/parsoid +<link rel="mw:PageProp/Category" href="./Category:Toxine_bactérienne" /> +<link rel="mw:PageProp/Category" href="./Category:Toxine_bact%C3%A9rienne" /> +<link rel="mw:PageProp/Category" href="Category:Toxine_bact%C3%A9rienne" /> +!! wikitext +[[Category:Toxine bactérienne]] +[[Category:Toxine bactérienne]] +[[Category:Toxine bactérienne]] +!! end + +!! test +New sol transparent links don't need indent-pre nowiki protection +!! options +parsoid=html2wt +language=de +!! html/parsoid + <link rel="mw:PageProp/redirect" href="./Main_Page"> +<!-- this is good --> <link rel="mw:PageProp/Category" href="./Category:Good" /> +<!-- this is great --> <link rel="mw:PageProp/Category" href="./Kategorie:Great" /> +!! wikitext + #WEITERLEITUNG [[Main Page]] +<!-- this is good --> [[Category:Good]] +<!-- this is great --> [[Kategorie:Great]] +!! end + +!! test +New interlanguage links (href variations) +!! options +parsoid=html2wt +!! html/parsoid +<link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine bactérienne" /> +<link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine_bactérienne" /> +<link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine_bact%C3%A9rienne" /> +!! wikitext +[[es:Toxine bactérienne]] +[[es:Toxine_bactérienne]] +[[es:Toxine_bactérienne]] +!! end + +!! test +Image: Modifying size of an image (1) +!! options +parsoid={ + "modes": ["wt2wt"], + "changes": [ + ["img[height]", "attr", "height", "22"], + ["img[width]", "attr", "width", "200"] + ] +} +!! wikitext +[[Image:Foobar.jpg|230x230px]] +!! wikitext/edited +[[Image:Foobar.jpg|200x200px]] +!!end + +!! test +Image: Modifying size of an image (2) +!! options +parsoid={ + "modes": ["wt2wt"], + "changes": [ + ["img[height]", "attr", "height", "100"], + ["img[width]", "attr", "width", "500"] + ] +} +!! wikitext +[[Image:Foobar.jpg|230x230px]] +!! wikitext/edited +[[Image:Foobar.jpg|500x500px]] +!!end + +# Change in size is ignored so long as class='mw-default-size' +!! test +Image: Modifying size of an image (3) +!! options +parsoid={ + "modes": ["wt2wt"], + "changes": [ + ["figure[class]", "removeClass", "mw-default-size"], + ["figure img", "attr", "height", "19"], + ["figure img", "attr", "width", "170"] + ] +} +!! wikitext +[[Image:Foobar.jpg|thumb]] +!! wikitext/edited +[[Image:Foobar.jpg|thumb|170x170px]] +!!end + +!! test +Image: Modifying alignment of an image (T50665) +!! options +parsoid={ + "modes": ["wt2wt"], + "changes": [ + ["figure[class]", "removeClass", "mw-halign-right"], + ["figure[class]", "addClass", "mw-halign-left"] + ] +} +!! wikitext +[[Image:Foobar.jpg|thumb|caption|right]] +!! wikitext/edited +[[Image:Foobar.jpg|thumb|caption|left]] +!! end + +!! test +Image: Modifying mw-default-size of an frameless image (T64805) +!! options +parsoid={ + "modes": ["wt2wt"], + "changes": [ + ["figure.mw-default-size", "removeClass", "mw-default-size"] + ] +} +!! wikitext +[[Image:Foobar.jpg|frameless|right]] +!! wikitext/edited +[[Image:Foobar.jpg|frameless|right|220x220px]] +!! end + +!! test +Image: Modifying valign of an image (T51221) +!! options +parsoid={ + "modes": ["wt2wt"], + "changes": [ + ["*[typeof=\"mw:Image\"]", "removeClass", "mw-valign-middle"], + ["*[typeof=\"mw:Image\"]", "addClass", "mw-valign-text-top"] + ] +} +!! wikitext +[[File:Foobar.jpg|20px|middle]] +!! wikitext/edited +[[File:Foobar.jpg|20px|text-top]] +!! end + +!! test +Image: Modifying alt attribute of an image (T58400) +!! options +parsoid={ + "modes": ["wt2wt"], + "changes": [ + ["img[alt]", "attr", "alt", "some alternate edited text"] + ] +} +!! wikitext +[[File:Foobar.jpg|thumb|some caption|alt=some alternate text]] +!! wikitext/edited +[[File:Foobar.jpg|thumb|some caption|alt=some alternate edited text]] +!!end + +!! test +Image: Modifying caption of an image +!! options +parsoid={ + "modes": ["wt2wt"], + "changes": [ + ["figcaption", "text", "new caption"] + ] +} +!! wikitext +[[Image:Foobar.jpg|thumb|original caption]] +!! wikitext/edited +[[Image:Foobar.jpg|thumb|new caption]] +!!end + +!! test +Image: empty alt attribute (T50924) +!! options +parsoid +!! wikitext +[[File:Foobar.jpg|thumb|alt=|bar]] +!! html +<figure class="mw-default-size" typeof="mw:Image/Thumb" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"},{"ck":"alt","ak":"alt="},{"ck":"caption","ak":"bar"}]}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"}}'><img alt="" resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220" data-parsoid='{"a":{"alt":"","resource":"./File:Foobar.jpg","height":"25","width":"220"},"sa":{"alt":"alt=","resource":"File:Foobar.jpg"}}'/></a><figcaption>bar</figcaption></figure> +!! end + +!! test +Image: new attributes should be serialized in wiki's language for RTL languages (T53852) +!! options +parsoid=html2wt +language=ar +disabled +!! html/parsoid +<figure class="mw-default-size mw-halign-right" typeof="mw:Image/Thumb"><a href="./Imagen:Foobar.jpg"><img resource="./Imagen:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="20" width="180"/></a></figure> +!! wikitext +[[Imagen:Foobar.jpg|derecha|miniaturadeimagen]] +!! end + +!! test +Image: Block level image should have \n before and after +!! wikitext +123 +[[File:Foobar.jpg|right|thumb|150x150px]] +456 +!! html/parsoid +<p>123</p> +<figure class="mw-halign-right" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/150px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="17" width="150"/></a></figure> +<p>456</p> +!! end + +!! test +Image: New block level image should have \n before and after (existing content) +!! wikitext +123 +[[File:Foobar.jpg|right|thumb|150x150px]] +456 +!! html/parsoid +<p>123</p> +<figure class="mw-halign-right" typeof="mw:Image/Thumb" data-parsoid='{"optList":[{"ck":"right","ak":"right"},{"ck":"thumbnail","ak":"thumb"},{"ck":"width","ak":"150x150px"}]}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"}}'><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/150px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="17" width="150" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"17","width":"150"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></figure> +<p>456</p> +!! end + +!! test +Image: upright option (parsoid) +!! wikitext +[[File:Foobar.jpg|thumb|upright|caption]] +[[File:Foobar.jpg|thumb|upright=0.5|caption]] +[[File:Foobar.jpg|thumb|500x500px|upright=0.5|caption]] +!! html/parsoid +<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/170px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="19" width="170"/></a><figcaption>caption</figcaption></figure> +<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/110px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="12" width="110"/></a><figcaption>caption</figcaption></figure> +<figure typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/500px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="57" width="500"/></a><figcaption>caption</figcaption></figure> +!! end + +!! test +Image: upright option is ignored on inline and frame images (parsoid) +!! wikitext +[[File:Foobar.jpg|500x500px|upright=0.5|caption]] +!! html/parsoid +<p><figure-inline typeof="mw:Image" data-mw='{"caption":"caption"}'><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/500px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="57" width="500"/></a></figure-inline></p> +!! end + +!! test +Image: in template parameter with empty parameter +!! wikitext +{{echo|[[File:Foobar.jpg|link=]]}} +!! html/parsoid +<p><figure-inline class="mw-default-size" typeof="mw:Transclusion mw:Image" about="#mwt1" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[File:Foobar.jpg|link=]]"}},"i":0}}]}'><span><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></span></figure-inline></p> +!! end + +!! test +Image: from basic HTML (1) +!! options +parsoid=html2wt +!! html/parsoid +<span typeof="mw:Image"> + <img src="./File:Foobar.jpg" width=100 height=100 alt="Alt"> +</span> +!! wikitext +[[File:Foobar.jpg|link=|alt=Alt|100x100px]] +!! end + +!! test +Image: from basic HTML (2) +!! options +parsoid=html2wt +!! html/parsoid +<img src="./File:Foobar.jpg" width=100 height=100 alt="Alt"> +!! wikitext +[[File:Foobar.jpg|link=|alt=Alt|100x100px]] +!! end + +!! test +Image: from basic HTML (3) +!! options +parsoid=html2wt +!! html/parsoid +<a href="Main"><img src="./File:Foobar.jpg" width=100 height=100 alt="Alt"></a> +!! wikitext +[[File:Foobar.jpg|link=Main|alt=Alt|100x100px]] +!! end + +!! test +Image: from basic HTML (4) +!! options +parsoid=html2wt +!! html/parsoid +<img src="./File:Foobar.jpg"> +!! wikitext +[[File:Foobar.jpg|link=]] +!! end + +!! test +Image: Invalid title as link +!! wikitext +[[File:Foobar.jpg|link=<]] +!! html/php +<p><a href="/wiki/File:Foobar.jpg" class="image" title="link=<"><img alt="link=<" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a> +</p> +!! html/parsoid +<p><figure-inline class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"link","ak":"link=<"}]}' data-mw='{"caption":"link=&lt;"}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{}}'><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></figure-inline></p> +!! end + +!! test +Lists: Serialize correctly even when list content is wrapped in p-tags (like VE does) +!! options +parsoid=html2wt +!! html/parsoid +<ul> +<li><p>foo</p></li> +</ul> +!! wikitext +* foo +!! end + +!! test +Lists: Serialize correctly even when list tags has unneeded whitespace between tags +!! options +parsoid=html2wt +!! html/parsoid +<ul> <li>foo</li></ul> +!! wikitext +* foo +!! end + +!! test +Don't strip leading whitespace when handling indent-pre suppressing tags +!! options +parsoid=html2wt +!! html/parsoid +<table> + <tr><td> indented row</td></tr> +</table> +<blockquote><p> + <b>This is very bold of you!</b> +</p> +<table><tr><td> + indented cell (no pre-wrapping!) +</td></tr></table> +</blockquote> +<p>foo</p> + <div>bar</div> +!! wikitext +{| + | indented row +|} +<blockquote> + '''This is very bold of you!''' + +{| +| + indented cell (no pre-wrapping!) +|} +</blockquote> +foo + <div>bar</div> +!! end + +!! test +Nowiki-wrap leading whitespace when handling indent-pre inducing tags +!! options +parsoid=html2wt +!! html/parsoid +<p>foo</p> + <span>bar</span> + +<span>foo2 + </span>bar2 + +<div>foo</div> + <span>bar</span> + +<div> + <span>foo</span> +</div> +!! wikitext +foo + +<span>bar</span> + +<span>foo2 +<nowiki> </nowiki></span>bar2 + +<div>foo</div> +<nowiki> </nowiki><span>bar</span> + +<div> +<nowiki> </nowiki><span>foo</span> +</div> +!! end + +!! test +Lists: Dont insert newlines in a serialized list item. +!! options +parsoid=html2wt +!! html/parsoid +<ul><li>a<br>b</li><li>c</li></ul> +!! wikitext +* a<br />b +* c +!! end + +!! test +1. Headings: Force sol-transparent links and behavior switches to serialize before/after +!! options +parsoid={ + "modes": ["html2wt"], + "scrubWikitext": false +} +!! html/parsoid +<h2>hello there<link href="./Category:A1" rel="mw:PageProp/Category" /></h2> +<h2><link href="./Category:A2" rel="mw:PageProp/Category" />hi pal</h2> + +<h2><!--foo--> <link href="./Category:A3" rel="mw:PageProp/Category" /> how goes it</h2> +<h2>it goes well <link href="./Category:A4" rel="mw:PageProp/Category" /> <!--bar--></h2> + +<h2 data-parsoid='{}'>howdy<link href="./Category:A5" rel="mw:PageProp/Category" /></h2> + +<h2><meta property="mw:PageProp/toc" /> ok</h2> +!! wikitext +== hello there [[Category:A1]] == + +== [[Category:A2]] hi pal == + +== <!--foo--> [[Category:A3]] how goes it == + +== it goes well [[Category:A4]] <!--bar--> == + +==howdy [[Category:A5]]== + +== __TOC__ ok == +!! end + +!! test +2. Headings: Force sol-transparent links and behavior switches to serialize before/after +!! options +parsoid={ + "modes": ["html2wt"], + "scrubWikitext": true +} +!! html/parsoid +<h2>hello there<link href="./Category:A1" rel="mw:PageProp/Category" /></h2> +<h2><link href="./Category:A2" rel="mw:PageProp/Category" />hi pal</h2> + +<h2><!--foo--> <link href="./Category:A3" rel="mw:PageProp/Category" /> how goes it</h2> +<h2>it goes well <link href="./Category:A4" rel="mw:PageProp/Category" /> <!--bar--></h2> + +<h2><meta property="mw:PageProp/toc" /> ok</h2> +!! wikitext +== hello there == +[[Category:A1]] +[[Category:A2]] + +== hi pal == + +<!--foo--> [[Category:A3]] + +== how goes it == + +== it goes well == +[[Category:A4]] <!--bar--> + +__TOC__ + +== ok == +!! end + +!! test +Headings: Don't hoist metas that come from templates +!! options +parsoid={ + "modes": ["html2wt"], + "scrubWikitext": true +} +!! html/parsoid +<h2><span about="#mwt1" typeof="mw:Transclusion" data-parsoid="{}" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo [[Category:Foo]]"}},"i":0}}]}'>foo </span><link rel="mw:PageProp/Category" href="./Category:Foo" about="#mwt1" data-parsoid="{}" /></h2> +!! wikitext +== {{echo|foo [[Category:Foo]]}} == +!! end + +!! test +Headings: Category in ref isn't hoisted +!! options +parsoid={ + "modes": ["html2wt"], + "scrubWikitext": true +} +!! html/parsoid +<h2> foo <span about="#mwt2" class="mw-ref" id="cite_ref-1" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","body":{"id":"mw-reference-text-cite_note-1"},"attrs":{}}'><a href="./Main_Page#cite_note-1"><span class="mw-reflink-text">[1]</span></a></span> </h2> + +<ol class="references" typeof="mw:Extension/references" about="#mwt3" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><span rel="mw:referencedBy"><a href="./Main_Page#cite_ref-1">↑</a></span> <span id="mw-reference-text-cite_note-1" class="mw-reference-text">bar <link rel="mw:PageProp/Category" href="./Category:Baz" /> </span></li></ol> +!! wikitext +== foo <ref>bar +[[Category:Baz]] </ref> == + +<references /> +!! end + +!! test +Parsoid: Serialize positional parameters with = in them as named parameter +!! options +parsoid=html2wt +!! html/parsoid +<p about="#mwt1" typeof="mw:Transclusion" +data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"f=oo"}},"i":0}}]}'>foo</p> + +<p about="#mwt1" typeof="mw:Transclusion" +data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"f=oo"}, "2":{"wt":"bar"}},"i":0}}]}'>foo</p> + +<!--Orig params with data-parsoid has heuristics for handling = chars--> +<!--FIXME: But maybe the heuristic needs fixing to apply to new params as well--> +<p data-parsoid='{"pi":[[{"k":"1"},{"k":"2"}]]}' about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"f=oo"},"2":{"wt":"bar"}},"i":0}}]}'>foo</p> +!! wikitext +{{echo|1=f=oo}} + +{{echo|1=f=oo|2=bar}} + +<!--Orig params with data-parsoid has heuristics for handling = chars--> +<!--FIXME: But maybe the heuristic needs fixing to apply to new params as well--> +{{echo|<nowiki>f=oo</nowiki>|bar}} +!! end + +!! test +Parsoid: Serialize positional parameters with = in extlink as named parameter +!! options +parsoid=html2wt +!! html/parsoid +<p><a rel="mw:ExtLink" href="http://stuff?is=ok" about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"http://stuff?is=ok"}},"i":0}}]}'>http://stuff?is=ok</a></p> +!! wikitext +{{echo|1=http://stuff?is=ok}} +!! end + +!! test +Parsoid: Correctly serialize block-node children when they are a combination of text and p-nodes +!! options +parsoid=html2wt +!! html/parsoid +<div>a<p>b</p></div> +<div>a +<p>b</p></div> +<div> +a +<p>b</p></div> +!! wikitext +<div>a +b +</div> +<div>a +b +</div> +<div> +a + +b +</div> +!! end + +!! test +Substrings resembling wikitext in hrefs should not get nowiki escapes +!! options +parsoid=html2wt +!! html/parsoid +<a rel="mw:WikiLink" href="./Foo''bar''baz">Foo''bar''baz</a> +!! wikitext +[[Foo''bar''baz]] +!! end + +!! test +Enforce single-line context in the serializer +!! options +parsoid=html2wt +!! html/parsoid +<h2>testing +123</h2> + +<h2> hi <span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"bogus","href":"./Template:Bogus"},"params":{"1":{"wt":"there\nyou"}},"i":0}}]}'>there</span><span about="#mwt1"> +</span><span about="#mwt1">you</span> </h2> + +<h2> foo <span about="#mwt2" class="mw-ref" id="cite_ref-1" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","body":{"id":"mw-reference-text-cite_note-1"},"attrs":{}}'><a href="./Main_Page#cite_note-1"><span class="mw-reflink-text">[1]</span></a></span> </h2> + +<ol class="references" typeof="mw:Extension/references" about="#mwt3" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><span rel="mw:referencedBy"><a href="./Main_Page#cite_ref-1">↑</a></span> <span id="mw-reference-text-cite_note-1" class="mw-reference-text" data-parsoid="{}">hello +there</span></li></ol> + +<ul><li>asd +sdf</li></ul> + +<ul><li>foo +bar +baz</li> +<li>foo <b>bar</b> +baz</li></ul> + +<dl><dt>hi +ho </dt><dd data-parsoid='{"stx":"row"}'> hi +ho</dd></dl> + +<dl><dd> <table> +<tbody><tr><td> ha +ha +ha</td></tr> +</tbody></table></dd></dl> +!! wikitext +== testing 123 == + +== hi {{bogus|there +you}} == + +== foo <ref>hello +there</ref> == + +<references /> + +* asd sdf + +* foo bar baz +* foo '''bar''' baz + +; hi ho : hi ho + +: {| +| ha +ha +ha +|} +!! end + +!! test +Serialize new placeholder space without spans +!! options +parsoid=html2wt +!! html/parsoid +<p>foo<span typeof="mw:Placeholder"> </span>: bar</p> + +<p>foo<span typeof="mw:DisplaySpace mw:Placeholder" data-parsoid='{"src":" ","isDisplayHack":true}'> </span>: bar</p> + +<span typeof="mw:Extension/ref" data-mw="{"name":"ref","body":{"html":"foo<span typeof=\"mw:Placeholder\">&nbsp;</span>: bar"}}"><sup>[1]</sup></span>ok</p> +!! wikitext +foo : bar + +foo : bar + +<ref>foo : bar</ref>ok +!! end + + +#----------------------- +# Tag minimization tests +#----------------------- + +!! test +1. I/B quote minimization: wikitext-only tags should be combined +!! options +parsoid=html2wt +!! html/parsoid +<p><i>A</i><i>B</i></p> +<p><b>A</b><b>B</b></p> +<p><i>A</i><b><i>B</i></b></p> +<p><b>A</b><i><b>B</b></i></p> +<p><b>A</b><i><b>B</b><b>C</b></i><b>D</b></p> +<p><i><b>A</b></i><i><b>B</b></i></p> +<p><i><b>A</b></i><b><i>B</i></b></p> +<p><b><i>A</i></b><i><b>B</b></i></p> +!! wikitext +''AB'' + +'''AB''' + +''A'''B''''' + +'''A''B''''' + +'''A''BC''D''' + +'''''AB''''' + +'''''AB''''' + +'''''AB''''' +!! end + +!! test +2. I/B quote minimization: wikitext and html tags should not be combined +!! options +parsoid=html2wt +!! html/parsoid +<p><i>A</i><i data-parsoid='{"stx":"html"}'>B</i></p> +<p><i>A</i><b><i data-parsoid='{"stx":"html"}'>B</i></b></p> +!! wikitext +''A''<i>B</i> + +''A''<nowiki/>'''<i>B</i>''' +!! end + +!! test +3. I/B quote minimization: templated content stops minimization +!! options +parsoid=html2wt +!! html/parsoid +<p><i>A</i><i about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"''B''"}},"i":0}}]}'>B</i> +<p><i>A</i><b about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"'''''B'''''"}},"i":0}}]}'><i>B</i></b> +!! wikitext +''A''{{echo|''B''}} + +''A''{{echo|'''''B'''''}} +!! end + +!! test +4. I/B quote minimization: new content should be mimimized with adjacent old content +!! options +parsoid=html2wt +!! html/parsoid +<p><i>A</i><i>B</i></p> +<p><b>A</b><b>B</b></p> +<p><i>A</i><b><i>B</i></b></p> +!! wikitext +''AB'' + +'''AB''' + +''A'''B''''' +!! end + +!! test +5a. Merge adjacent quote nodes if they've been edited +!! options +parsoid={ + "modes": ["wt2wt", "selser"], + "changes": [ + ["p", "contents", "remove", ":contains('b')"] + ] +} +!! wikitext +''a''b''c'' +!! wikitext/edited +''ac'' +!! end + +!! test +5b. Merge adjacent quote nodes if they've been edited +!! options +parsoid={ + "modes": ["wt2wt", "selser"], + "changes": [ + ["#x", "remove"] + ] +} +!! wikitext +''a''<span id="x">b</span>''c'' +!! wikitext/edited +''ac'' +!! end + +!! test +1. Merge adjacent link nodes as long as at least one element is new +!! options +parsoid={ + "modes": ["html2wt"], + "scrubWikitext": true +} +!! html/parsoid +<a rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a> +<a data-parsoid="{}" rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a> +<a data-parsoid="{}" rel="mw:WikiLink" href="./Football">Foot</a><a data-parsoid="{}" rel="mw:WikiLink" href="./Football">ball</a> +!! wikitext +[[Football]] +[[Football]] +[[Football|Foot]][[Football|ball]] +!! end + +!! test +2. Merge adjacent link nodes and enable additional normalizations +!! options +parsoid={ + "modes": ["html2wt"], + "scrubWikitext": true +} +!! html/parsoid +<a rel="mw:WikiLink" href="./Football"><i>Foot</i></a><a rel="mw:WikiLink" href="./Football"><i>ball</i></a> +!! wikitext +[[Football|''Football'']] +!! end + +!! test +3. Don't merge adjacent link nodes if scrubWikitext is false +!! options +parsoid={ + "modes": ["html2wt"], + "scrubWikitext": false +} +!! html/parsoid +<a rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a> +!! wikitext +[[Football|Foot]][[Football|ball]] +!! end + +#------------------------------ +# End of tag minimization tests +#------------------------------ + +!!test +T56262: New entities +!! options +parsoid=html2wt +!! html/parsoid +<span typeof="mw:Entity"> </span> +!! wikitext + +!! end + +## Note that there is no wikitext output for 'unknownproperty' ## +## Unknown magic words are silently dropped ## + +!! test +Magic words +!! options +parsoid=html2wt +!! html/parsoid +<meta property='mw:PageProp/toc' /> +<meta property='mw:PageProp/notoc' /> +<meta property='mw:PageProp/forcetoc' /> +<meta property='mw:PageProp/index' /> +<meta property='mw:PageProp/noindex' /> +<meta property='mw:PageProp/nogallery' /> +<meta property='mw:PageProp/noeditsection' /> +<meta property='mw:PageProp/notitleconvert' /> +<meta property='mw:PageProp/nocontentconvert' /> +<meta property='mw:PageProp/unknownproperty' /> +!! wikitext +__TOC__ +__NOTOC__ +__FORCETOC__ +__INDEX__ +__NOINDEX__ +__NOGALLERY__ +__NOEDITSECTION__ +__NOTITLECONVERT__ +__NOCONTENTCONVERT__ +!! end + +!! test +Consecutive <pre>s should not get merged +!! options +parsoid=html2wt,html2html +!! html/parsoid +<pre>a</pre><pre>b</pre> + +<pre>c +</pre><pre> +d</pre> + +<pre>e + +</pre><pre> + +f</pre> +!! wikitext + a + + b + + c + + d + + e + + + + f +!! end + +!! test +Edited ISBN links not serializable as ISBN links should serialize as wikilinks +!! options +parsoid=html2wt +!! html/parsoid +<a href="./Special:BookSources/1234567890" rel="mw:ExtLink">ISBN 1234567895</a> +!! wikitext +[[Special:BookSources/1234567890|ISBN 1234567895]] +!! end + +!! test +Edited RFC links not serializable as RFC links should serialize as extlinks +!! options +parsoid=html2wt +!! html/parsoid +<a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink">New RFC</a> +!! wikitext +[https://tools.ietf.org/html/rfc123 New RFC] +!! end + +!! test +Edited PMID links not serializable as PMID links should serialize as extlinks +!! options +parsoid=html2wt +!! html/parsoid +<a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink">New PMID</a> +!! wikitext +[//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract New PMID] +!! end + +!! test +WTS of autolinks with trailing/surrounding context +!! options +parsoid=html2wt +!! html/parsoid +<p><a href="http://cscott.net">http://cscott.net</a><b>foo</b></p> +<p><a href="http://cscott.net">http://cscott.net</a><b data-parsoid='{"stx":"html"}'>foo</b></p> +<p><b><a href="http://cscott.net">http://cscott.net</a></b></p> +<p><b><a href="http://cscott.net">http://cscott.net</a> </b></p> +<p><b><a href="http://cscott.net">http://cscott.net</a>x</b></p> +<p><a href="http://cscott.net">http://cscott.net</a>x</p> +!! wikitext +http://cscott.net'''foo''' + +http://cscott.net<b>foo</b> + +'''http://cscott.net''' + +'''http://cscott.net ''' + +'''http://cscott.net<nowiki/>x''' + +http://cscott.net<nowiki/>x +!! end + +!! test +WTS of autolinks with nowikis (round-trip) +!! wikitext +x<nowiki/>http://cscott.net<nowiki/>x +!! html/parsoid +<p>x<a rel="mw:ExtLink" class="external free" href="http://cscott.net">http://cscott.net</a>x</p> +!! end + +# this is the "easy" test because it leaves in place all the +# data-parsoid information indicating this is an autolink +!! test +WTS of autolinks with escapes (editing) +!! options +parsoid={ + "modes": ["wt2wt"], + "changes": [ + [ "span", "remove" ] + ] +} +!! wikitext +x<nowiki/>http://cscott.net<nowiki/>x +!! wikitext/edited +x<nowiki/>http://cscott.net<nowiki/>x +!! end + +!! test +WTS of edited autolink-like text (T103364) +!! options +parsoid={ + "modes": ["wt2wt"], + "changes": [ + [ "span[typeof]", "removeAttr", "typeof" ] + ] +} +!! wikitext +Not a link: <nowiki>http://example.com</nowiki>. +!! wikitext/edited +Not a link: <span><nowiki>http://example.com</nowiki></span>. +!! end + +!! test +WTS of newly-authored autolink-like text (T103364) +!! options +parsoid=html2wt +!! html/parsoid +<p>http://example.com is not a link.</p> +!! wikitext +<nowiki>http://example.com</nowiki> is not a link. +!! end + +!! test +WTS of autolink-like text after an autolink (T108563) +!! options +parsoid=html2wt +!! html/parsoid +<p><a rel="mw:ExtLink" href="http://example.com">http://example.com</a> http://example.com is not a link.</p> +!! wikitext +http://example.com <nowiki>http://example.com</nowiki> is not a link. +!! end + +!! test +Magic links inside links (not autolinked) +!! wikitext +[[Foo|http://example.com]] +[[Foo|RFC 1234]] +[[Foo|PMID 1234]] +[[Foo|ISBN 123456789x]] + +[http://foo.com http://example.com] +[http://foo.com RFC 1234] +[http://foo.com PMID 1234] +[http://foo.com ISBN 123456789x] +!! html+tidy +<p><a href="/wiki/Foo" title="Foo">http://example.com</a> +<a href="/wiki/Foo" title="Foo">RFC 1234</a> +<a href="/wiki/Foo" title="Foo">PMID 1234</a> +<a href="/wiki/Foo" title="Foo">ISBN 123456789x</a> +</p><p><a rel="nofollow" class="external text" href="http://foo.com">http://example.com</a> +<a rel="nofollow" class="external text" href="http://foo.com">RFC 1234</a> +<a rel="nofollow" class="external text" href="http://foo.com">PMID 1234</a> +<a rel="nofollow" class="external text" href="http://foo.com">ISBN 123456789x</a> +</p> +!! html/parsoid +<p><a rel="mw:WikiLink" href="./Foo" title="Foo">http://example.com</a> +<a rel="mw:WikiLink" href="./Foo" title="Foo">RFC 1234</a> +<a rel="mw:WikiLink" href="./Foo" title="Foo">PMID 1234</a> +<a rel="mw:WikiLink" href="./Foo" title="Foo">ISBN 123456789x</a></p> + +<p><a rel="mw:ExtLink" class="external text" href="http://foo.com">http://example.com</a> +<a rel="mw:ExtLink" class="external text" href="http://foo.com">RFC 1234</a> +<a rel="mw:ExtLink" class="external text" href="http://foo.com">PMID 1234</a> +<a rel="mw:ExtLink" class="external text" href="http://foo.com">ISBN 123456789x</a></p> +!! end + +!! test +Magic links inside image captions (autolinked) +!! wikitext +[[File:Foobar.jpg|thumb|http://example.com]] +[[File:Foobar.jpg|thumb|RFC 1234]] +[[File:Foobar.jpg|thumb|PMID 1234]] +[[File:Foobar.jpg|thumb|ISBN 123456789x]] +!! html+tidy +<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a></div></div></div> +<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc1234">RFC 1234</a></div></div></div> +<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a></div></div></div> +<div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div><a href="/wiki/Special:BookSources/123456789X" class="internal mw-magiclink-isbn">ISBN 123456789x</a></div></div></div> +!! html/parsoid +<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption><a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a></figcaption></figure> +<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption><a href="https://tools.ietf.org/html/rfc1234" rel="mw:ExtLink" class="external text">RFC 1234</a></figcaption></figure> +<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption><a href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract" rel="mw:ExtLink" class="external text">PMID 1234</a></figcaption></figure> +<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption><a href="./Special:BookSources/123456789X" rel="mw:WikiLink">ISBN 123456789x</a></figcaption></figure> +!! end + +!! test +WTS of magic word text (T109371) +!! options +parsoid=html2wt +!! html/parsoid +<p>RFC 1234</p> +<p><a href="http://foo.com" rel="mw:ExtLink">RFC 1234</a></p> +<p><a href="./Foo" rel="mw:WikiLink">RFC 1234</a></p> +!! wikitext +<nowiki>RFC 1234</nowiki> + +[http://foo.com RFC 1234] + +[[Foo|RFC 1234]] +!! end + +!! test +Edited Redirect link should emit a non-piped wikitext link +!! options +parsoid=html2wt +!! html/parsoid +<link rel="mw:PageProp/redirect" href="Bar" data-parsoid='{"a":{"href":"./Foo"},"sa":{"href":"Foo"}}'> +!! wikitext +#REDIRECT [[Bar]] +!! end + +!! test +T75121: Infer extension name from typeOf if data-mw is not present +!! options +parsoid={ "modes": ["html2wt"], "suppressErrors": true } +!! html/parsoid +<div typeOf="mw:Extension/foo"></div> +!! wikitext +<foo /> +!! end + +# Note that the <p> wrapping isn't present in PHP parser output +# The important thing for this test is that P-wrapping doesn't +# interfere with the <nowiki> protection for leading - in <td> +# (which isn't necessary for <th>). +!! test +T88318: p-wrapped dash in table. +!! options +parsoid=html2wt,wt2wt +!! html/parsoid +<table><tbody> +<tr><th><p>-</p></th><th><p>- </p></th></tr> +<tr><td><p>-</p></td><td><p>- </p></td></tr> +<tr><td><small>-</small></td><td><br/><p>-</p></td><td><br/>-</td></tr> +</tbody></table> +!! wikitext +{| +!- +!- +|- +|<nowiki>-</nowiki> +|<nowiki>- </nowiki> +|- +|<small>-</small> +|<br /> +- +|<br /> +- +|} +!! html/php+tidy +<table> +<tbody><tr> +<th>- +</th> +<th>- +</th></tr> +<tr> +<td>- +</td> +<td>- +</td></tr> +<tr> +<td><small>-</small> +</td> +<td><br /> +<p>- +</p> +</td> +<td><br /> +<p>- +</p> +</td></tr></tbody></table> +!! end + +!! test +T149209: WTS: Handle newlines in table cells properly +!! options +parsoid=html2wt +!! html/parsoid +<table> +<tbody> +<tr><td>a +b +</td><td data-parsoid='{"stx":"row"}'>c</td></tr> +<tr><td><p>x</p> +</td><td data-parsoid='{"stx":"row", "startTagSrc": "{{!}}{{!}}"}'>y</td></tr> +</tbody></table> +<table> +<tbody> +<tr><th>a +b +</th><th data-parsoid='{"stx":"row"}'>c</th></tr> +<tr><th><p>x</h> +</th><th data-parsoid='{"stx":"row"}'>y</th></tr> +</tbody></table> +!! wikitext +{| +|a +b +|c +|- +|x +{{!}}y +|} +{| +!a +b +!c +|- +!x +!y +|} +!! end + +!! test +T149209: Selser: Handle newlines in table cells properly +!! options +parsoid={ + "modes": ["selser"], + "changes": [ + [ "#h1", "html", "a\nb\n" ], + [ "#h2", "html", "a\nb\n" ], + [ "#c1", "html", "a\nb\n" ], + [ "#c2", "html", "<p>a</p>" ], + [ "#c3", "html", "<p>a</p>" ], + [ "#c4", "html", "edit-me<p>a</p>" ] + ] +} +!! wikitext +{| +! id="h1" |edit-me!!1 +|- +! id="h2" |edit-me||2 +|- +| id="c1" |edit-me||3 +|- +| id="c2" |edit-me||4 +|- +| id="c3" |edit-me||p||q||r +|- +| id="c4" |edit-me||p||q||r +|} +!! wikitext/edited +{| +! id="h1" |a +b +!1 +|- +! id="h2" |a +b +!2 +|- +| id="c1" |a +b +|3 +|- +| id="c2" |a +|4 +|- +| id="c3" |a +|p||q||r +|- +| id="c4" |edit-me +a +|p||q||r +|} +!! end + +!! test +HTML id attribute with Parsoid-like element ids should not be serialized to wikitext +!! options +parsoid=html2wt +!! html/parsoid +<table id='mwAb'> +<td id='mwAc'>foo</td> +<td id='serialize-this'>bar</td> +</table> +!! wikitext +{| +|foo +| id="serialize-this" |bar +|} +!! end + +!! test +Parsoid-like element ids should not be serialized to wikitext unless shadowed +!! options +parsoid=html2wt +!! html/parsoid +<div id="mwAQ" data-parsoid='{"stx":"html","a":{"id":"mwAQ"},"sa":{"id":"hello"}}'>ok</div> +!! wikitext +<div id="hello">ok</div> +!! end + +!! test +WTS change modes +!! options +parsoid={ + "modes": ["wt2wt"], + "changes": [ + [ "#xyz", "before", "<b>before</b> stuff " ], + [ "#xyz", "after", " stuff <i>after</i>" ], + [ "#xyz", "html", "x <b>y</b> z" ] + ] +} +!! wikitext +<span id="xyz">hello</span> +!! wikitext/edited +'''before''' stuff <span id="xyz">x '''y''' z</span> stuff ''after'' +!! end + +!! test +Never serialize a-tag as html, regardless of what data-parsoid has to say +!! options +parsoid={ "modes": ["html2wt"], "suppressErrors": true } +!! html/parsoid +<a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"html"}'>Foo</a> +!! wikitext +[[Foo]] +!! end + +## SSS FIXME: This is broken output nevertheless. +## What might be a reasonable non-broken output for this? +## This is an edge case unlikely to be seen in production +## that I am not wasting more time on this right now. +!! test +Never serialize a-tag as html, no matter what attributes it has +!! options +parsoid={ "modes": ["html2wt"], "suppressErrors": true } +!! html/parsoid +<a bad='true' href='http://boo.org'><img src='http://boohoo.org' /></a> +!! wikitext +[http://boo.org http://boohoo.org] +!! end + +# Misnested is an indication that selser can reuse the source but these have +# shown to sneak through on occasion. See T101768. +# The original wikitext here is: [http://test.com [[one]] two three] +!! test +Strip span tags added to mark misnested links +!! options +parsoid=html2wt +!! html/parsoid +<p data-parsoid='{}'><a rel="mw:ExtLink" href="http://test.com" data-parsoid='{"targetOff":17,"contentOffsets":[17,34]}'></a><a rel="mw:WikiLink" href="./One" title="One" data-parsoid='{"stx":"simple","a":{"href":"./One"},"sa":{"href":"one"},"misnested":true}'>one</a><span data-parsoid='{"misnested":true}'> two three</span></p> +!! wikitext +[http://test.com][[one]] two three +!! end + +!! test +Catch regression when unpacking misnested links +!! options +parsoid=wt2html +!! wikitext +{{echo|hi}}[http://example.com [[ho]]] +!! html/parsoid +<p><span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi"}},"i":0}}]}'>hi</span><a rel="mw:ExtLink" class="external autonumber" href="http://example.com"></a><a rel="mw:WikiLink" href="./Ho" title="Ho" data-parsoid='{"misnested":true}'>ho</a></p> +!! end + +!! test +Catch regression when unpacking with trailing content +!! wikitext +{{echo|Foo <references/> bar}} +!! html/parsoid +<p about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"Foo <references/> bar"}},"i":0}}]}'>Foo </p><ol class="mw-references references" typeof="mw:Extension/references" about="#mwt2" data-mw='{"name":"references","attrs":{}}'></ol><p about="#mwt2"> bar</p> +!! end + +!! test +Use data-parsoid.firstWikitextNode to compute newline constraints for template content +!! options +parsoid=html2wt +!! html/parsoid +<span about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"a"}},"i":0}}]}'>a</span><table about="#mwt2" typeof="mw:Transclusion mw:ExpandedAttrs" data-parsoid='{"a":{"{{echo|c\n{{!}}d\n}}":null},"sa":{"{{echo|c\n{{!}}d\n}}":""},"firstWikitextNode":"table","pi":[[{"k":"1"}]]}' data-mw='{"parts":["{|",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"c\n{{!}}d\n"}},"i":0}},"\n|}"]}'> +<tbody><tr><td>d +</td></tr> +</tbody></table> +!! wikitext +{{echo|a}} +{|{{echo|c +{{!}}d +}} +|} +!! end + +## This test verifies the presence and computation of this attribute indirectly +## by making an edit and ensuring that the serialization is correct (which it would be +## only if firstWikitextNode is properly set). +!! test +data-parsoid.firstWikitextNode should be computed properly in the presence of fostered content +!! options +parsoid= { + "modes": ["wt2wt"], + "changes": [ + [ "div#x", "remove" ], + [ "div", "before", "<div>new</div>" ] + ] +} +!! wikitext +<div id="x">foo</div> +{| +{{echo|<div>boo</div> +{{!}}b}} +|c +|} +!! wikitext/edited + +<div>new</div> +{| +{{echo|<div>boo</div> +{{!}}b}} +|c +|} +!! end + +# -------------------------------------------- +# Tests spec'ing wikitext serialization norms | +# -------------------------------------------- + +!! test +Serialize multi-line indent-pre starting with wikitext syntax +!! options +parsoid=html2wt +!! html/parsoid +<pre>* 1 +** 2 +* 3</pre> +!! wikitext + * 1 + ** 2 + * 3 +!! end + +!! test +1. Categories should always be serialized on their own line +!! options +parsoid=html2wt +!! html/parsoid +foo<link rel="mw:PageProp/Category" href="./Category:Foo">bar +!! wikitext +foo +[[Category:Foo]] +bar +!! end + +!! test +2. Categories that are part of templates should not introduce a line break +!! wikitext +foo {{echo|<span>bar</span> [[Category:baz]]}} bar +!! html/parsoid +<p>foo <span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"<span>bar</span> [[Category:baz]]"}},"i":0}}]}'>bar</span><span about="#mwt1"> </span><link rel="mw:PageProp/Category" href="./Category:Baz" about="#mwt1" data-parsoid='{"stx":"simple","a":{"href":"./Category:Baz"},"sa":{"href":"Category:baz"}}'/> bar</p> +!! end + +# Careful while editing these next 2 tests. There are \u200f characters +# before and after the <link> tags in the HTML and following some +# of the categories in wikitext +# Do not remove these characters in edits. +# +# As part of the serialization, these bidi characters will get stripped. +!! test +RTL (\u200f) and LTR (\u200e) markers around category tags should be stripped +!! options +parsoid={ + "modes": ["html2wt"], + "scrubWikitext": true +} +!! html/parsoid +<p><link rel="mw:PageProp/Category" href="./קטגוריה:טקסים" /> +<link rel="mw:PageProp/Category" href="./קטגוריה:_שיטות_משפט" /></p> +!! wikitext +[[קטגוריה:טקסים]] +[[קטגוריה: שיטות משפט]] +!! end + +!! test +RTL (\u200f) and LTR (\u200e) markers should not be stripped if followed by a text node +!! options +parsoid={ + "modes": ["html2wt"], + "scrubWikitext": true +} +!! html/parsoid +<p><link rel="mw:PageProp/Category" href="./קטגוריה:טקסים" />y</p> +!! wikitext +[[קטגוריה:טקסים]] +y +!! end + +!! test +Lists: Add space after bullets +!! options +parsoid=html2wt +!! html/parsoid +<ul> +<li>foo</li> +<li> bar</li> +<li><span> baz</span></li> +</ul> +!! wikitext +* foo +* bar +* <span> baz</span> +!! end + +!! test +1. Headings: Add space before/after == (T53744) +!! options +parsoid=html2wt +!! html/parsoid +<h2>foo</h2> +<h2> bar</h2> +<h2>baz </h2> +<h2><span> baz</span></h2> +!! wikitext +== foo == + +== bar == + +== baz == + +== <span> baz</span> == +!! end + +!! test +2. Headings: Add space before/after == even after hoisted content +!! options +parsoid={ + "modes": ["html2wt"], + "scrubWikitext": true +} +!! html/parsoid +<h2> <link href="./Category:A2" rel="mw:PageProp/Category" />ok</h2> +!! wikitext + [[Category:A2]] + +== ok == +!! end + +!! test +1. Headings: suppress newly created empty headings +!! options +parsoid={ + "modes": ["html2wt"], + "scrubWikitext": true +} +!! html/parsoid +<h2></h2> +!! wikitext +!! end + +!! test +2. Headings: don't suppress empty headings if scrubWikitext is false +!! options +parsoid=html2wt +!! html/parsoid +<h2></h2> +!! wikitext +==<nowiki/>== +!! end + +!! test +3. Headings: suppress empty headings on edits +!! options +parsoid={ + "modes": ["selser"], + "scrubWikitext": true, + "changes": [ + [ "#x", "remove"] + ] +} +!! wikitext +==<span id="x">foo</span>== +!! wikitext/edited +!! end + +!! test +Headings: Replace <br/> with a single whitespace char (when scrubWikitext = true) +!! options +parsoid={ + "modes": ["html2wt"], + "scrubWikitext": true +} +!! html/parsoid +<h2>foo<br/>bar</h2> +<h2>foo <span><br/>bar</span> baz</h2> +!! wikitext +== foo bar == + +== foo <span> bar</span> baz == +!! end + +!! test +Headings: Replace <br/> with a single whitespace char (when scrubWikitext = false) +!! options +parsoid={ + "modes": ["html2wt"], + "scrubWikitext": false +} +!! html/parsoid +<h2>foo<br/>bar</h2> +!! wikitext +== foo<br /> bar == +!! end + +!! test +1. WT Quote Tags: suppress newly created empty style tags +!! options +parsoid={ + "modes": ["html2wt"], + "scrubWikitext": true +} +!! html/parsoid +<i></i><b></b> +!! wikitext +!! end + +!! test +2. WT Quote Tags: don't suppress empty style tags if scrubWikitext is false +!! options +parsoid=html2wt +!! html/parsoid +<i></i><b></b> +!! wikitext +''<nowiki/>'''''<nowiki/>''' +!! end + +!! test +3. WT Quote Tags: suppress empty style tags on edits +!! options +parsoid={ + "modes": ["selser"], + "scrubWikitext": true, + "changes": [ + [ "#x", "remove"] + ] +} +!! wikitext +'''<span id="x">foo</span>''' +!! wikitext/edited +!! end + +!! test +1. Anchors: suppress newly created empty anchors +!! options +parsoid={ + "modes": ["html2wt"], + "scrubWikitext": true +} +!! html/parsoid +<a rel="mw:WikiLink" href="./Test" title="Test"></a> +!! wikitext +!! end + +!! test +2. Anchors: don't suppress empty anchors if scrubWikitext is false +!! options +parsoid={ + "modes": ["html2wt"], + "scrubWikitext": false +} +!! html/parsoid +<a rel="mw:WikiLink" href="./Test" title="Test"></a> +!! wikitext +[[Test|<nowiki/>]] +!! end + +!! test +3. Anchors: suppress empty anchors on edits +!! options +parsoid={ + "modes": ["selser"], + "scrubWikitext": true, + "changes": [ + [ "#x", "remove"] + ] +} +!! wikitext +[[Test|<span id="x">foo</span>]] +!! wikitext/edited +!! end + +!! test +3a. Anchors: do not suppress numbered extlinks +!! options +parsoid={ + "modes": ["wt2wt"], + "scrubWikitext": true +} +!! wikitext +[http://foo.com] +!! html/parsoid +<a rel="mw:ExtLink" href="http://foo.com"></a> +!! end + +!! test +3b. Anchors: do not suppress numbered extlinks +!! options +parsoid={ + "modes": ["wt2wt"], + "scrubWikitext": true, + "changes": [ + [ "#x", "remove"] + ] +} +!! wikitext +[http://foo.com <span id="x">foo</span>] +!! wikitext/edited +[http://foo.com] +!! end + +!!test +Normalizations should be restricted to edited content +!!options +parsoid={ + "modes": ["selser"], + "scrubWikitext": true, + "changes": [ + [ "h1", "before", "<i></i>"] + ] +} +!!wikitext +a += = +b +!!wikitext/edited +a += = +b +!!end + +!! test +1. Multiple normalizations (html2wt) +!! options +parsoid={ + "modes": ["html2wt"], + "scrubWikitext": true +} +!! html +<h2><i></i></h2> +<p><a href='Foo' rel='mw:WikiLink'>foo<i></i> + </a><b><i></i></b>x</p> +!! wikitext + +[[foo]] +x + +!! end + +!! test +2. Multiple normalizations (selser) +!! options +parsoid={ + "modes": ["selser"], + "scrubWikitext": true, + "changes": [ + [ "#x", "after", "<h1><i></i></h1>\n<p> x<b></b></p>"] + ] +} +!! wikitext +<span id="x">foo</span> +!! wikitext/edited +<span id="x">foo</span> + +x +!! end + +!! test +1. Indent Pre Nowiki: suppress whitespace at the start of new paragraph +!! options +parsoid={ + "modes": ["html2wt"], + "scrubWikitext": true +} +!! html/parsoid +<p> hi</p> +<p> hello</p> +!! wikitext +hi + +hello +!! end + +!! test +2. Indent Pre Nowiki: don't suppress whitespace at the start of new paragraph if scrubWikitext is false +!! options +parsoid=html2wt +!! html/parsoid +<p> hi</p> +<p> hello</p> +!! wikitext +<nowiki> </nowiki>hi + +<nowiki> </nowiki> hello +!! end + +!! test +3. Indent Pre Nowiki: suppress whitespace after newlines in new paragraph or table cell +!! options +parsoid={ + "modes": ["html2wt"], + "scrubWikitext": true +} +!! html/parsoid +<p>Foo + bar +baz</p> + +<table><tr><td>Foo + bar + baz bang</td></tr></table> + +<p><!--boo--> foo + bar</p> + +<p> foo + bar<span>boo</span></p> +!! wikitext +Foo +bar +baz + +{| +|Foo +bar +baz bang +|} + +<!--boo-->foo +bar + +foo +bar<span>boo</span> +!! end + +!! test +4. Indent Pre Nowiki: suppress leading whitespace in edited paragraphs +!! options +parsoid={ + "modes": ["selser"], + "scrubWikitext": true, + "changes": [ + [ "p", "html", " a\n b" ] + ] +} +!! wikitext +xyz +!! wikitext/edited +a +b +!! end + +!! test +1. New links that end in spaces +!! options +parsoid={ + "modes": ["html2wt"], + "scrubWikitext": false +} +!! html/parsoid +<p><a rel="mw:WikiLink" href="./Berlin" title="Berlin">Berlin </a>is the capital of Germany.</p> +<p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo </a><b>bar</b></p> +<p><a rel="mw:WikiLink" href="./Boston" title="Boston">Boston </a> is a city.</p> +!! wikitext +[[Berlin ]]<nowiki/>is the capital of Germany. + +[[Foo ]]'''bar''' + +[[Boston ]] is a city. +!! end + +!! test +2. New links that end in spaces +!! options +parsoid={ + "modes": ["html2wt"], + "scrubWikitext": true +} +!! html/parsoid +<p><a rel="mw:WikiLink" href="./Berlin" title="Berlin">Berlin </a>is the capital of Germany.</p> +<p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo </a><b>bar</b></p> +<p><a rel="mw:WikiLink" href="./Boston" title="Boston">Boston </a> is a city.</p> +!! wikitext +[[Berlin]] is the capital of Germany. + +[[Foo]] '''bar''' + +[[Boston]] is a city. +!! end + +!! test +1. Table cells with escapable prefixes +!! options +parsoid={ + "modes": ["html2wt"], + "scrubWikitext": false +} +!! html +<table> +<tr><td>a</td></tr> +<tr><td>-</td></tr> +<tr><td>+</td></tr> +</table> +!! wikitext +{| +|a +|- +|<nowiki>-</nowiki> +|- +|<nowiki>+</nowiki> +|} +!! end + +!! test +2. Table cells with escapable prefixes +!! options +parsoid={ + "modes": ["html2wt"], + "scrubWikitext": true +} +!! html +<table> +<tr><td>a</td></tr> +<tr><td>-</td></tr> +<tr><td>+</td></tr> +</table> +!! wikitext +{| +|a +|- +| - +|- +| + +|} +!! end + +!! test +3a. Table cells with escapable prefixes after edits +!! options +parsoid={ + "modes": ["selser"], + "scrubWikitext": true, + "changes": [ + [ "table tbody tr:first-child td:first-child", "remove"] + ] +} +!! wikitext +{| +|a||- +|} +!! wikitext/edited +{| +| - +|} +!! end + +!! test +3b. Table cells with escapable prefixes after edits +!! options +parsoid={ + "modes": ["selser"], + "scrubWikitext": true, + "changes": [ + [ "table tbody tr:first-child td:first-child", "html", "-" ], + [ "#x", "remove" ] + ] +} +!! wikitext +{| +|pqr +|<span id="x">foo</span>+ +|} +!! wikitext/edited +{| +| - +| + +|} +!! end + +# FIXME: This test will fail because +# normalization doesn't realize that the id attribute +# will eliminate the escapable scenario +!! test +4a. Table cells without escapable prefixes after edits +!! options +parsoid={ + "modes": ["selser"], + "scrubWikitext": true, + "changes": [ + [ "#x", "html", "-" ] + ] +} +!! wikitext +{| +| id="x" |abcd +|} +!! wikitext/edited +{| +| id="x" |- +|} +!! end + +## This tests normalizer's ability to discriminate between +## cells having identical content. +!! test +4b. Table cells without escapable prefixes after edits +!! options +parsoid={ + "modes": ["selser"], + "scrubWikitext": true, + "changes": [ + [ "td", "html", "-" ] + ] +} +!! wikitext +{| +|a||b +|} +!! wikitext/edited +{| +| -||- +|} +!! end + +## This tests normalizer's ability to not be tripped by +## comments (and whitespace) +!! test +4c. Table cells without escapable prefixes after edits +!! options +parsoid={ + "modes": ["selser"], + "scrubWikitext": true, + "changes": [ + [ "table tbody tr td:first-child", "remove" ] + ] +} +!! wikitext +{| +|- +<!--foo--> |a||- +|} +!! wikitext/edited +{| +|- +<!--foo--> | - +|} +!! end + +## This tests normalizer's ability to handle HTML cells +!! test +4d. Table cells without escapable prefixes after edits +!! options +parsoid={ + "modes": ["selser"], + "scrubWikitext": true, + "changes": [ + [ "td", "html", "-" ] + ] +} +!! wikitext +<table> +<tr><td>a</td></tr> +</table> +!! wikitext/edited +<table> +<tr><td>-</td></tr> +</table> +!! end + +## T111151 Remove font elements without attributes +!! test +5a. font tags without attributes should be dropped in scrubWikitext mode +!! options +parsoid={ + "modes": ["html2wt"], + "scrubWikitext": true +} +!! html +<font>foo</font> +<font><font>bar</font></font> +<font class="x">boo</font> +!! wikitext +foo +bar +<font class="x">boo</font> +!! end + +!! test +5b. font tags should not be dropped without scrubWikitext being enabled +!! options +parsoid={ + "modes": ["html2wt"], + "scrubWikitext": false +} +!! html +<font>foo</font> +!! wikitext +<font>foo</font> +!! end + +!! test +Escape nowiki DOM elements +!! options +parsoid=html2wt +!! html/parsoid +<nowiki><i>foo</i></nowiki> +!! wikitext +<nowiki>''foo''</nowiki> +!! end + +# This is meant to be an interim fix while we go about figuring out +# how to not introduce these trailing <nowiki/>s in the first place. +!! test +T115717: Strip trailing <nowiki/>s (without affecting valid uses) +!! options +parsoid=html2wt +!! html/parsoid +<p>x<meta typeof="mw:Placeholder" data-parsoid='{"src":"<nowiki/>"}'/><meta typeof="mw:Placeholder" data-parsoid='{"src":"<nowiki/>"}'/> +y</p> +<p><span about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1","named":true,"spc":["\n"," "," ",""]}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"<nowiki/>"}},"i":0}}]}'></span></p> +<p><span about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1","named":true,"spc":["\n"," "," ","\n"]}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"<nowiki/>"}},"i":0}}]}'></span></p> +!! wikitext +x +y + +{{echo| +1 = <nowiki/>}} + +{{echo| +1 = <nowiki/> +}} +!! end + +!! test +New list is serialized on newlines +!! options +parsoid=html2wt +!! html/parsoid +<p>The quick brown fox jumps over the lazy dog.</p><ul> +<li>Yesterday</li> +<li>Today</li> +<li>Tomorrow</li> +</ul><p>The quick onyx goblin jumps over the lazy dwarf.</p> +!! wikitext +The quick brown fox jumps over the lazy dog. + +* Yesterday +* Today +* Tomorrow + +The quick onyx goblin jumps over the lazy dwarf. +!! end + +!! test +New lists in formatting elements serialized w/o newlines +!! options +parsoid=html2wt +!! html/parsoid +<small> + +<ul> +<li>123</li> +</ul> + +</small> + +<small><ul><li>hi</li></ul></small> +!! wikitext +<small> +* 123 +</small> + +<small> +* hi +</small> +!! end + +!! test +New list in table doesn't need newlines +!! options +parsoid=html2wt +!! html/parsoid +<table><tr><td><ul><li>test</li><li>123</li></td></tr></table> +!! wikitext +{| +| +* test +* 123 +|} +!! end + +# --------------------------------------------------- +# End of tests spec'ing wikitext serialization norms | +# --------------------------------------------------- + +# T104032 +!! test +Bare inline nodes not wrapped inside p-tags should be treated as p-wrapped +!! options +parsoid=html2wt +!! html/parsoid +a<p>b</p> +<b>c</b><p>d</p> +<table><tr> +<td>a<p>b</p></td> +<td><b>c</b><p>d</p></td> +</tr></table> +!! wikitext +a + +b + +'''c''' + +d +{| +|a +b +|'''c''' +d +|} +!! end + +!! test +Anchor without href scenarios +!! options +parsoid={ "modes": ["html2wt"], "suppressErrors": true } +!! html/parsoid +<a class="bc"></a> +<a class="no">dice</a> +<a name="foo"></a> +!! wikitext + +dice +<span name="foo"></span> +!! end + +!! test +New transclusion added after a list should be serialized after the list +!! options +parsoid=html2wt +!! html/parsoid +<ul><li>a</li></ul><span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</span> +!! wikitext +* a +{{echo|foo}} +!! end + +# ----------------------------------------------------------------- +# End of section for Parsoid-only html2wt tests for serialization +# of new content +# ----------------------------------------------------------------- + +# ----------------------------------------------------------------- +# The following section of tests are primarily to spec behavior of +# the selective serializer. All these tests have manual selser +# changes. The automated selser changes for all tests handle the +# wide variation of changes, but these tests here capture specs +# deterministically. +# ---------------------------------------------------------------- + +## T90517 +!! test +Selser: New comments should not be lost +!! options +parsoid={ + "modes": ["selser"], + "changes": [ + [ "#a", "after", "<!--c1-->" ], + [ "#b", "before", "<!--c2-->" ] + ] +} +!! wikitext +<span id="a">a</span> + +<span id="b">b</span> +!! wikitext/edited +<span id="a">a</span><!--c1--> + +<!--c2--><span id="b">b</span> +!! end + +## T89383 +!! test +Selser: Check for validity of DSR before using it +!! options +parsoid={ + "modes": ["selser"], + "changes": [ + [ "#a", "before", "<meta property='mw:PageProp/displaytitle' content='foo'>" ] + ] +} +!! wikitext +<span id="a">a</span> +!! wikitext/edited +{{DISPLAYTITLE:foo}} +<span id="a">a</span> +!! end + +!! test +1. DOMDiff: Changes to <ref> content should be looked up using id +!! options +parsoid={ + "modes": ["selser"], + "changes": [ + ["#X", "after", "bar"], + ["#Y", "after", "baz"] + ] +} +!! wikitext +X <ref><span id="X">foo</span></ref> +Y <ref name="a" /> +<references> +<ref name="a"><span id="Y">foo</span></ref> +</references> +!! wikitext/edited +X <ref><span id="X">foo</span>bar</ref> +Y <ref name="a" /> +<references> +<ref name="a"><span id="Y">foo</span>baz</ref> +</references> +!! end + +!! test +2. DOMDiff: Changes to <ref> content should be looked up using id +!! options +parsoid={ + "modes": ["selser"], + "changes": [ + ["#Z", "after", "bar"] + ] +} +!! wikitext +A <ref>foo bar for a</ref> +B <ref group="X" name="b" /> + +<references /> + +<references group="X"> +<ref name="b"><span id="Z">foo</span></ref> +</references> +!! wikitext/edited +A <ref>foo bar for a</ref> +B <ref group="X" name="b" /> + +<references /> + +<references group="X"> +<ref name="b"><span id="Z">foo</span>bar</ref> +</references> +!! end + +!! test +DOMDiff: Edits to content nested in elements with templated attributes should not be lost (T139388) +!! options +parsoid={ + "modes": ["selser"], + "changes": [ + [ "div:first-child", "text", "bar" ] + ] +} +!! wikitext +<div style="{{1x|color:red;}}%">foo</div> +!! wikitext/edited +<div style="{{1x|color:red;}}%">bar</div> +!! end + +!! test +Empty LI (T49673) +!! wikitext +*a +* +* +*b +!! html+tidy +<ul><li>a</li> +<li class="mw-empty-elt"></li> +<li class="mw-empty-elt"></li> +<li>b</li></ul> +!! end + +!! test +Thumbnail output +!! wikitext +[[File:Thumb.png|thumb]] +!! html/php+tidy +<div class="thumb tright"><div class="thumbinner" style="width:137px;"><a href="/wiki/File:Thumb.png" class="image"><img alt="Thumb.png" src="http://example.com/images/e/ea/Thumb.png" width="135" height="135" class="thumbimage" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Thumb.png" class="internal" title="Enlarge"></a></div></div></div></div> +!! html/parsoid +<figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Thumb.png"><img resource="./File:Thumb.png" src="//example.com/images/e/ea/Thumb.png" data-file-width="135" data-file-height="135" data-file-type="bitmap" height="135" width="135"/></a></figure> +!! end + +!! test +unclosed internal link XSS (T137264) +!! wikitext +[[#%3Cscript%3Ealert(1)%3C/script%3E| +!! html/php +<p>[[#<script>alert(1)</script>| +</p> +!! html/parsoid +<p>[[#%3Cscript%3Ealert(1)%3C/script%3E|</p> +!! end + +!! test +Validating that <style> isn't eaten by tidy (T167349) +!! options +styletag=1 +!! wikitext +<div class="foo"> +<style>.foo::before { content: "<foo>"; }</style> +<style data-mw-foobar="baz">.foo::after { content: "<bar>"; }</style> +</div> +!! html/php+tidy +<div class="foo"> +<style>.foo::before { content: "<foo>"; }</style> +<style data-mw-foobar="baz">.foo::after { content: "<bar>"; }</style> +</div> +!! end + +!! test +Validating that <style> isn't wrapped in a paragraph (T186965) +!! options +styletag=1 +!! wikitext +A style tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph + +<style>.foo::before { content: "<foo>"; }</style> + +<style>.foo::before { content: "<foo>"; }</style> <link rel="foo" href="bar"/><style>.foo::before { content: "<foo>"; }</style> + +But if it's on a line with other content, let it be wrapped. + +<style>.foo::before { content: "<foo>"; }</style> bar + +foo <style>.foo::before { content: "<foo>"; }</style> + +foo <style>.foo::before { content: "<foo>"; }</style> bar + +And the same if we have non-paragraph-breaking whitespace + +foo +<style>.foo::before { content: "<foo>"; }</style> +bar +!! html/php +<p>A style tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph +</p> +<style>.foo::before { content: "<foo>"; }</style> +<style>.foo::before { content: "<foo>"; }</style> <link rel="foo" href="bar"/><style>.foo::before { content: "<foo>"; }</style> +<p>But if it's on a line with other content, let it be wrapped. +</p><p><style>.foo::before { content: "<foo>"; }</style> bar +</p><p>foo <style>.foo::before { content: "<foo>"; }</style> +</p><p>foo <style>.foo::before { content: "<foo>"; }</style> bar +</p><p>And the same if we have non-paragraph-breaking whitespace +</p><p>foo +<style>.foo::before { content: "<foo>"; }</style> +bar +</p> +!! end + +!! test +Validating that <link> isn't wrapped in a paragraph (T186965) +!! options +styletag=1 +!! wikitext +A link tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph + +<link rel="foo" href="bar"/> + +<link rel="foo" href="bar"/> <style>.foo::before { content: "<foo>"; }</style><link rel="foo" href="bar"/> + +But if it's on a line with other content, let it be wrapped. + +<link rel="foo" href="bar"/> bar + +foo <link rel="foo" href="bar"/> + +foo <link rel="foo" href="bar"/> bar + +And the same if we have non-paragraph-breaking whitespace + +foo +<link rel="foo" href="bar"/> +bar +!! html/php +<p>A link tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph +</p> +<link rel="foo" href="bar"/> +<link rel="foo" href="bar"/> <style>.foo::before { content: "<foo>"; }</style><link rel="foo" href="bar"/> +<p>But if it's on a line with other content, let it be wrapped. +</p><p><link rel="foo" href="bar"/> bar +</p><p>foo <link rel="foo" href="bar"/> +</p><p>foo <link rel="foo" href="bar"/> bar +</p><p>And the same if we have non-paragraph-breaking whitespace +</p><p>foo +<link rel="foo" href="bar"/> +bar +</p> +!! end + +!! test +Decoding of HTML entities in headings and links for IDs and link fragments (T103714) +!! config +wgFragmentMode=[ 'html5', 'legacy' ] +!! wikitext +==A&B&C&amp;D&amp;amp;E== +[[#A&B&C&amp;D&amp;amp;E]] +!! html/php +<h2><span id="A.26B.26C.26amp.3BD.26amp.3Bamp.3BE"></span><span class="mw-headline" id="A&B&C&amp;D&amp;amp;E">A&B&C&amp;D&amp;amp;E</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: A&B&C&amp;D&amp;amp;E">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<p><a href="#A&B&C&amp;D&amp;amp;E">#A&B&C&amp;D&amp;amp;E</a> +</p> +!! html/parsoid +<h2 id="A&B&C&amp;D&amp;amp;E"><span id="A.26B.26C.26amp.3BD.26amp.3Bamp.3BE" typeof="mw:FallbackId" data-parsoid="{}"></span>A&B<span typeof="mw:Entity" data-parsoid='{"src":"&amp;","srcContent":"&"}'>&</span>C<span typeof="mw:Entity" data-parsoid='{"src":"&amp;","srcContent":"&"}'>&</span>amp;D<span typeof="mw:Entity" data-parsoid='{"src":"&amp;","srcContent":"&"}'>&</span>amp;amp;E</h2> +<p><a rel="mw:WikiLink" href="./Main_Page#A&B&C&amp;D&amp;amp;E" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#A&B&C&amp;D&amp;amp;E"},"sa":{"href":"#A&B&amp;C&amp;amp;D&amp;amp;amp;E"}}'>#A&B&C&amp;D&amp;amp;E</a></p> +!! end + +!! test +Decoding of HTML entities in headings and links for IDs and link fragments (T103714) (legacy) +!! config +wgFragmentMode=[ 'legacy' ] +!! wikitext +==A&B&C&amp;D&amp;amp;E== +[[#A&B&C&amp;D&amp;amp;E]] +!! html/php +<h2><span class="mw-headline" id="A.26B.26C.26amp.3BD.26amp.3Bamp.3BE">A&B&C&amp;D&amp;amp;E</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: A&B&C&amp;D&amp;amp;E">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<p><a href="#A.26B.26C.26amp.3BD.26amp.3Bamp.3BE">#A&B&C&amp;D&amp;amp;E</a> +</p> +!! end + +!! test +Decoding of HTML entities in embedded HTML tags +!! wikitext +<table class="1&2&3&amp;4&amp;amp;5"><tr><td>x</td></tr></table> +!! html/php +<table class="1&2&3&amp;4&amp;amp;5"><tr><td>x</td></tr></table> + +!! html/parsoid +<table class="1&2&3&amp;4&amp;amp;5" data-parsoid='{"stx":"html","a":{"class":"1&2&3&amp;4&amp;amp;5"},"sa":{"class":"1&2&amp;3&amp;amp;4&amp;amp;amp;5"}}'><tbody><tr data-parsoid='{"stx":"html"}'><td data-parsoid='{"stx":"html"}'>x</td></tr></tbody></table> +!! end + +!! test +Decoding of HTML entities in indicator names for IDs (T104196) +!! options +parsoid=wt2html,html2html +showindicators +!! wikitext +<indicator name="1&2&3&amp;4&amp;amp;5">Indicator</indicator> +!! html/php +1&2&3&4&amp;5=Indicator + +!! html/parsoid +<p><span typeof="mw:Extension/indicator" about="#mwt3" data-mw='{"name":"indicator","attrs":{"name":"1&2&3&amp;4&amp;amp;5"},"body":{"extsrc":"Indicator"}}'></span></p> +!! end + +# this version of the test strips out the ambiguity so Parsoid rts cleanly +!! test +Decoding of HTML entities in indicator names for IDs (unambiguous) (T104196) +!! options +showindicators +!! wikitext +<indicator name="1&2&3&amp;4&amp;amp;5">Indicator</indicator> +!! html/php +1&2&3&4&amp;5=Indicator + +!! html/parsoid +<p><span typeof="mw:Extension/indicator" about="#mwt3" data-mw='{"name":"indicator","attrs":{"name":"1&2&3&amp;4&amp;amp;5"},"body":{"extsrc":"Indicator"}}'></span></p> +!! end + +# This fragment mode is what Parsoid supports. +!! test +HTML5 ids: fallback to legacy +!! config +wgFragmentMode=[ 'html5', 'legacy' ] +!! wikitext +==Foo bar== + +==foo Bar== + +==Тест== + +==Тест== + +==тест== + +==Hey < # " > % : '== +[[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']] + +{{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span> + +<!-- These two links should produce identical HTML --> +[[#啤酒]] [[#%E5%95%A4%E9%85%92]] + +!! html/php +<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div> +<ul> +<li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li> +<li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li> +<li class="toclevel-1 tocsection-3"><a href="#Тест"><span class="tocnumber">3</span> <span class="toctext">Тест</span></a></li> +<li class="toclevel-1 tocsection-4"><a href="#Тест_2"><span class="tocnumber">4</span> <span class="toctext">Тест</span></a></li> +<li class="toclevel-1 tocsection-5"><a href="#тест"><span class="tocnumber">5</span> <span class="toctext">тест</span></a></li> +<li class="toclevel-1 tocsection-6"><a href="#Hey_<_#_"_>_%_:_'"><span class="tocnumber">6</span> <span class="toctext">Hey < # " > % : '</span></a></li> +</ul> +</div> + +<h2><span class="mw-headline" id="Foo_bar">Foo bar</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: Foo bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h2><span class="mw-headline" id="foo_Bar_2">foo Bar</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: foo Bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h2><span id=".D0.A2.D0.B5.D1.81.D1.82"></span><span class="mw-headline" id="Тест">Тест</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=3" title="Edit section: Тест">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h2><span id=".D0.A2.D0.B5.D1.81.D1.82_2"></span><span class="mw-headline" id="Тест_2">Тест</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=4" title="Edit section: Тест">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h2><span id=".D1.82.D0.B5.D1.81.D1.82"></span><span class="mw-headline" id="тест">тест</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=5" title="Edit section: тест">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h2><span id="Hey_.3C_.23_.22_.3E_.25_:_.27"></span><span class="mw-headline" id="Hey_<_#_"_>_%_:_'">Hey < # " > % : '</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=6" title="Edit section: Hey < # " > % : '">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<p><a href="#Foo_bar">#Foo bar</a> <a href="#foo_Bar">#foo Bar</a> <a href="#Тест">#Тест</a> <a href="#тест">#тест</a> <a href="#Hey_<_#_"_>_%_:_'">#Hey < # " > % : '</a> +</p><p>💩 <span id="💩"></span> +</p><p><a href="#啤酒">#啤酒</a> <a href="#啤酒">#啤酒</a> +</p> +!! html/parsoid +<h2 id="Foo_bar">Foo bar</h2> + +<h2 id="foo_Bar_2">foo Bar</h2> + +<h2 id="Тест"><span id=".D0.A2.D0.B5.D1.81.D1.82" typeof="mw:FallbackId"></span>Тест</h2> + +<h2 id="Тест_2"><span id=".D0.A2.D0.B5.D1.81.D1.82_2" typeof="mw:FallbackId"></span>Тест</h2> + +<h2 id="тест"><span id=".D1.82.D0.B5.D1.81.D1.82" typeof="mw:FallbackId"></span>тест</h2> + +<h2 id="Hey_<_#_"_>_%_:_'"><span id="Hey_.3C_.23_.22_.3E_.25_:_.27" typeof="mw:FallbackId"></span>Hey < # " > %<span typeof="mw:DisplaySpace mw:Placeholder" data-parsoid='{"src":" ","isDisplayHack":true}'> </span>: '</h2> +<p><a rel="mw:WikiLink" href="./Main_Page#Foo_bar">#Foo bar</a> <a rel="mw:WikiLink" href="./Main_Page#foo_Bar">#foo Bar</a> <a rel="mw:WikiLink" href="./Main_Page#Тест">#Тест</a> <a rel="mw:WikiLink" href="./Main_Page#тест">#тест</a> <a rel="mw:WikiLink" href="./Main_Page#Hey_<_#_"_>_%_:_'" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#Hey_<_#_\"_>_%_:_'"},"sa":{"href":"#Hey < # \" > % : '"}}'>#Hey < # " > % : '</a></p> + +<p><span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode:💩","function":"anchorencode"},"params":{},"i":0}}]}'>💩</span> <span id="💩" about="#mwt3" typeof="mw:ExpandedAttrs" data-mw='{"attribs":[[{"txt":"id"},{"html":"<span about=\"#mwt2\" typeof=\"mw:Transclusion\" data-parsoid='{\"pi\":[[]],\"dsr\":[178,197,null,null]}' data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"anchorencode:💩\",\"function\":\"anchorencode\"},\"params\":{},\"i\":0}}]}'>💩</span>"}]]}'></span></p> + +<!-- These two links should produce identical HTML --> +<p><a rel="mw:WikiLink" href="./Main_Page#啤酒">#啤酒</a> <a rel="mw:WikiLink" href="./Main_Page#啤酒" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#啤酒"},"sa":{"href":"#%E5%95%A4%E9%85%92"}}'>#啤酒</a></p> +!! end + +# Parsoid doesn't support this mode +!! test +HTML5 ids: legacy with a fallback to modern +!! config +wgFragmentMode=[ 'legacy', 'html5' ] +!! wikitext +==Foo bar== + +==foo Bar== + +==Тест== + +==Тест== + +==тест== + +==Hey < # " > % : '== +[[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']] + +{{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span> + +<!-- These two links should produce identical HTML --> +[[#啤酒]] [[#%E5%95%A4%E9%85%92]] + +!! html/php +<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div> +<ul> +<li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li> +<li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li> +<li class="toclevel-1 tocsection-3"><a href="#.D0.A2.D0.B5.D1.81.D1.82"><span class="tocnumber">3</span> <span class="toctext">Тест</span></a></li> +<li class="toclevel-1 tocsection-4"><a href="#.D0.A2.D0.B5.D1.81.D1.82_2"><span class="tocnumber">4</span> <span class="toctext">Тест</span></a></li> +<li class="toclevel-1 tocsection-5"><a href="#.D1.82.D0.B5.D1.81.D1.82"><span class="tocnumber">5</span> <span class="toctext">тест</span></a></li> +<li class="toclevel-1 tocsection-6"><a href="#Hey_.3C_.23_.22_.3E_.25_:_.27"><span class="tocnumber">6</span> <span class="toctext">Hey < # " > % : '</span></a></li> +</ul> +</div> + +<h2><span class="mw-headline" id="Foo_bar">Foo bar</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: Foo bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h2><span class="mw-headline" id="foo_Bar_2">foo Bar</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: foo Bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h2><span id="Тест"></span><span class="mw-headline" id=".D0.A2.D0.B5.D1.81.D1.82">Тест</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=3" title="Edit section: Тест">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h2><span id="Тест_2"></span><span class="mw-headline" id=".D0.A2.D0.B5.D1.81.D1.82_2">Тест</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=4" title="Edit section: Тест">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h2><span id="тест"></span><span class="mw-headline" id=".D1.82.D0.B5.D1.81.D1.82">тест</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=5" title="Edit section: тест">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h2><span id="Hey_<_#_"_>_%_:_'"></span><span class="mw-headline" id="Hey_.3C_.23_.22_.3E_.25_:_.27">Hey < # " > % : '</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=6" title="Edit section: Hey < # " > % : '">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<p><a href="#Foo_bar">#Foo bar</a> <a href="#foo_Bar">#foo Bar</a> <a href="#.D0.A2.D0.B5.D1.81.D1.82">#Тест</a> <a href="#.D1.82.D0.B5.D1.81.D1.82">#тест</a> <a href="#Hey_.3C_.23_.22_.3E_.25_:_.27">#Hey < # " > % : '</a> +</p><p>.F0.9F.92.A9 <span id=".F0.9F.92.A9"></span> +</p><p><a href="#.E5.95.A4.E9.85.92">#啤酒</a> <a href="#.E5.95.A4.E9.85.92">#啤酒</a> +</p> +!! end + +# Parsoid doesn't support this mode. +!! test +HTML5 ids: no legacy +!! config +wgFragmentMode=[ 'html5' ] +!! wikitext +==Foo bar== + +==foo Bar== + +==Тест== + +==Тест== + +==тест== + +==Hey < # " > % : '== +[[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']] + +{{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span> + +<!-- These two links should produce identical HTML --> +[[#啤酒]] [[#%E5%95%A4%E9%85%92]] + +!! html/php +<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div> +<ul> +<li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li> +<li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li> +<li class="toclevel-1 tocsection-3"><a href="#Тест"><span class="tocnumber">3</span> <span class="toctext">Тест</span></a></li> +<li class="toclevel-1 tocsection-4"><a href="#Тест_2"><span class="tocnumber">4</span> <span class="toctext">Тест</span></a></li> +<li class="toclevel-1 tocsection-5"><a href="#тест"><span class="tocnumber">5</span> <span class="toctext">тест</span></a></li> +<li class="toclevel-1 tocsection-6"><a href="#Hey_<_#_"_>_%_:_'"><span class="tocnumber">6</span> <span class="toctext">Hey < # " > % : '</span></a></li> +</ul> +</div> + +<h2><span class="mw-headline" id="Foo_bar">Foo bar</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: Foo bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h2><span class="mw-headline" id="foo_Bar_2">foo Bar</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: foo Bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h2><span class="mw-headline" id="Тест">Тест</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=3" title="Edit section: Тест">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h2><span class="mw-headline" id="Тест_2">Тест</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=4" title="Edit section: Тест">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h2><span class="mw-headline" id="тест">тест</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=5" title="Edit section: тест">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h2><span class="mw-headline" id="Hey_<_#_"_>_%_:_'">Hey < # " > % : '</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=6" title="Edit section: Hey < # " > % : '">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<p><a href="#Foo_bar">#Foo bar</a> <a href="#foo_Bar">#foo Bar</a> <a href="#Тест">#Тест</a> <a href="#тест">#тест</a> <a href="#Hey_<_#_"_>_%_:_'">#Hey < # " > % : '</a> +</p><p>💩 <span id="💩"></span> +</p><p><a href="#啤酒">#啤酒</a> <a href="#啤酒">#啤酒</a> +</p> +!! end + +!! test +T90902: Normalize weird characters in section IDs +!! config +wgFragmentMode=[ 'html5', 'legacy' ] +!! wikitext +==Foo bar== +[[#Foo bar]] + +!! html/php +<h2><span class="mw-headline" id="Foo_bar">Foo bar</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: Foo bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<p><a href="#Foo_bar">#Foo bar</a> +</p> +!! html/parsoid +<h2 id="Foo_bar"> Foo<span typeof="mw:Entity" data-parsoid='{"src":"&nbsp;","srcContent":" "}'> </span>bar </h2> +<p><a rel="mw:WikiLink" href="./Main_Page#Foo_bar" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#Foo_bar"},"sa":{"href":"#Foo&nbsp;bar"}}'>#Foo bar</a></p> +!! end + +!! test +T51672: Test for brackets in attributes of elements in external link texts +!! wikitext +[http://example.com/ link <span title="title with [brackets]">span</span>] +[http://example.com/ link <span title="title with [brackets]">span</span>] + +!! html/php +<p><a rel="nofollow" class="external text" href="http://example.com/">link <span title="title with [brackets]">span</span></a> +<a rel="nofollow" class="external text" href="http://example.com/">link <span title="title with [brackets]">span</span></a> +</p> +!! html/parsoid +<p><a rel="mw:ExtLink" class="external text" href="http://example.com/">link <span title="title with [brackets]">span</span></a> +<a rel="mw:ExtLink" class="external text" href="http://example.com/">link <span title="title with [brackets]" data-parsoid='{"stx":"html","a":{"title":"title with [brackets]"},"sa":{"title":"title with &#91;brackets&#93;"}}'>span</span></a></p> +!! end + +!! test +T72875: Test for brackets in attributes of elements in internal link texts +!! wikitext +[[Foo|link <span title="title with [[double brackets]]">span</span>]] +[[Foo|link <span title="title with [[double brackets]]">span</span>]] + +!! html/php +<p><a href="/wiki/Foo" title="Foo">link <span title="title with [[double brackets]]">span</span></a> +<a href="/wiki/Foo" title="Foo">link <span title="title with [[double brackets]]">span</span></a> +</p> +!! html/parsoid +<p><a rel="mw:WikiLink" href="./Foo" title="Foo">link <span title="title with [[double brackets]]">span</span></a> +<a rel="mw:WikiLink" href="./Foo" title="Foo">link <span title="title with [[double brackets]]" data-parsoid='{"stx":"html","a":{"title":"title with [[double brackets]]"},"sa":{"title":"title with &#91;&#91;double brackets&#93;&#93;"}}'>span</span></a></p> +!! end + +!! test +T179544: {{anchorencode:}} output should be always usable in links +!! config +wgFragmentMode=[ 'html5' ] +!! wikitext +<span id="{{anchorencode:[foo]}}"></span>[[#{{anchorencode:[foo]}}]] +!! html/php +<p><span id="[foo]"></span><a href="#[foo]">#[foo]</a> +</p> +!! html/parsoid +<p><span id="[foo]" about="#mwt3" typeof="mw:ExpandedAttrs" data-parsoid='{"stx":"html","a":{"id":"[foo]"},"sa":{"id":"{{anchorencode:[foo]}}"}}' data-mw='{"attribs":[[{"txt":"id"},{"html":"<span typeof=\"mw:Transclusion mw:Entity\" about=\"#mwt1\" data-parsoid='{\"srcContent\":\"[\",\"dsr\":[10,32,null,null],\"pi\":[[]]}' data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"anchorencode:[foo]\",\"function\":\"anchorencode\"},\"params\":{},\"i\":0}}]}'>[</span><span about=\"#mwt1\" data-parsoid=\"{}\">foo</span><span typeof=\"mw:Entity\" about=\"#mwt1\" data-parsoid='{\"src\":\"&amp;#x5D;\",\"srcContent\":\"]\"}'>]</span>"}]]}'></span><a typeof="mw:ExpandedAttrs" about="#mwt4" rel="mw:WikiLink" href="./Main_Page#[foo]" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#[foo]"},"sa":{"href":"#{{anchorencode:[foo]}}"}}' data-mw='{"attribs":[[{"txt":"href"},{"html":"#<span typeof=\"mw:Transclusion mw:Entity\" about=\"#mwt2\" data-parsoid='{\"srcContent\":\"[\",\"dsr\":[44,66,null,null],\"pi\":[[]]}' data-mw='{\"parts\":[{\"template\":{\"target\":{\"wt\":\"anchorencode:[foo]\",\"function\":\"anchorencode\"},\"params\":{},\"i\":0}}]}'>[</span><span about=\"#mwt2\" data-parsoid=\"{}\">foo</span><span typeof=\"mw:Entity\" about=\"#mwt2\" data-parsoid='{\"src\":\"&amp;#x5D;\",\"srcContent\":\"]\"}'>]</span>"}]]}'>#[foo]</a></p> +!! end + +## ------------------------------ +## Parsoid section-wrapping tests +## ------------------------------ +!! test +Section wrapping for well-nested sections (no leading content) +!! options +parsoid={ + "wrapSections": true +} +!! wikitext +=1= +a + +=2= +b + +==2.1== +c + +==2.2== +d + +===2.2.1=== +e + +=3= +f +!! html/parsoid +<section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1> +<p>a</p> + +</section><section data-mw-section-id="2"><h1 id="2">2</h1> +<p>b</p> + +<section data-mw-section-id="3"><h2 id="2.1">2.1</h2> +<p>c</p> + +</section><section data-mw-section-id="4"><h2 id="2.2">2.2</h2> +<p>d</p> + +<section data-mw-section-id="5"><h3 id="2.2.1">2.2.1</h3> +<p>e</p> + +</section></section></section><section data-mw-section-id="6"><h1 id="3">3</h1> +<p>f</p> + +</section> +!! end + +!! test +Section wrapping for well-nested sections (with leading content) +!! options +parsoid={ + "wrapSections": true +} +!! wikitext +Para 1. + +Para 2 with a <div>nested in it</div> + +Para 3. + +=1= +a + +=2= +b + +==2.1== +c +!! html/parsoid +<section data-mw-section-id="0"><p>Para 1.</p> + +<p>Para 2 with a </p><div>nested in it</div> + +<p>Para 3.</p> + +</section><section data-mw-section-id="1"><h1 id="1">1</h1> +<p>a</p> + +</section><section data-mw-section-id="2"><h1 id="2">2</h1> +<p>b</p> + +<section data-mw-section-id="3"><h2 id="2.1">2.1</h2> +<p>c</p> + +</section></section> +!! end + +!! test +Section wrapping with template-generated sections (good nesting 1) +!! options +parsoid={ + "wrapSections": true +} +!! wikitext +=1= +a + +{{echo|1= +==1.1== +b +}} + +==1.2== +c + +=2= +d +!! html/parsoid +<section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1> +<p>a</p> + +<section data-mw-section-id="-1"><h2 about="#mwt1" typeof="mw:Transclusion" id="1.1" data-parsoid='{"dsr":[9,33,null,null],"pi":[[{"k":"1","named":true,"spc":["","","\n","\n"]}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"==1.1==\nb"}},"i":0}}]}'>1.1</h2><span about="#mwt1"> +</span><p about="#mwt1">b</p> +</section><section data-mw-section-id="3"><h2 id="1.2">1.2</h2> +<p>c</p> + +</section></section><section data-mw-section-id="4"><h1 id="2">2</h1> +<p>d</p></section> +!! end + +# In this example, the template scope is mildly expanded to incorporate the +# trailing newline after the transclusion since that is part of section 1.1.1 +!! test +Section wrapping with template-generated sections (good nesting 2) +!! options +parsoid={ + "wrapSections": true, + "modes": ["wt2html", "wt2wt"] +} +!! wikitext +=1= +a + +{{echo|1= +==1.1== +b +===1.1.1=== +d +}} +=2= +e +!! html/parsoid +<section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1> +<p>a</p> + +<section data-mw-section-id="-1"><h2 about="#mwt1" typeof="mw:Transclusion" id="1.1" data-parsoid='{"dsr":[9,50,null,null],"pi":[[{"k":"1","named":true,"spc":["","","\n","\n"]}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"==1.1==\nb\n===1.1.1===\nd"}},"i":0}},"\n"]}'>1.1</h2><span about="#mwt1"> +</span><p about="#mwt1">b</p><span about="#mwt1"> +</span><section data-mw-section-id="-1" about="#mwt1"><h3 about="#mwt1" id="1.1.1">1.1.1</h3><span about="#mwt1"> +</span><p about="#mwt1">d</p><span about="#mwt1"> +</span></section></section></section><section data-mw-section-id="4" data-parsoid="{}"><h1 id="2">2</h1> +<p>e</p></section> +!! end + +# In this example, the template scope is mildly expanded to incorporate the +# trailing newline after the transclusion since that is part of section 1.2.1 +!! test +Section wrapping with template-generated sections (good nesting 3) +!! options +parsoid={ + "wrapSections": true, + "modes": ["wt2html", "wt2wt"] +} +!! wikitext +=1= +a + +{{echo|1= +x +==1.1== +b +==1.2== +c +===1.2.1=== +d +}} +=2= +e +!! html/parsoid +<section data-mw-section-id="0"></section><section data-mw-section-id="1" data-parsoid="{}"><h1 id="1"> 1 </h1> +<p>a</p> + +<p about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"dsr":[9,60,0,0],"pi":[[{"k":"1","named":true,"spc":["","","\n","\n"]}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"x\n==1.1==\nb\n==1.2==\nc\n===1.2.1===\nd"}},"i":0}},"\n"]}'>x</p><span about="#mwt1"> +</span><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="1.1">1.1</h2><span about="#mwt1"> +</span><p about="#mwt1">b</p><span about="#mwt1"> +</span></section><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="1.2">1.2</h2><span about="#mwt1"> +</span><p about="#mwt1">c</p><span about="#mwt1"> +</span><section data-mw-section-id="-1" about="#mwt1"><h3 about="#mwt1" id="1.2.1">1.2.1</h3><span about="#mwt1"> +</span><p about="#mwt1">d</p><span about="#mwt1"> +</span></section></section></section><section data-mw-section-id="5"><h1 id="2">2</h1> +<p>e</p></section> +!! end + +# Because of section-wrapping and template-wrapping interactions, +# the scope of the template is expanded so that the template markup +# is valid in the presence of <section> tags. +# This exercises the s1 is null scenario in the wrapSections code +!! test +Section wrapping with template-generated sections (bad nesting 1) +!! options +parsoid={ + "wrapSections": true +} +!! wikitext +<div> +a + +{{echo| +=1= +b +}} + +c +</div> +!! html/parsoid +<section data-mw-section-id="-1"></section><section data-mw-section-id="-2"><div data-parsoid='{"stx":"html"}'> +<p>a</p> + +<span about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"\n=1=\nb\n"}},"i":0}},"\n\nc\n"]}'> +</span><section data-mw-section-id="-1" about="#mwt1"><h1 about="#mwt1" id="1">1</h1><span about="#mwt1"> +</span><p about="#mwt1">b +</p><span about="#mwt1"> + +</span><p about="#mwt1">c</p><span about="#mwt1"> +</span></section></div></section> +!! end + +# Because of section-wrapping and template-wrapping interactions, +# the scope of the template is expanded so that the template markup +# is valid in the presence of <section> tags. +# This exercises the s1 is ancestor of s2 scenario in the wrapSections code +!! test +Section wrapping with template-generated sections (bad nesting 2) +!! options +parsoid={ + "wrapSections": true +} +!! wikitext +=1= +a + +{{echo|1= +=2= +b +==2.1== +c +}} + +d + +=3= +e +!! html/parsoid +<section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1> +<p>a</p> + +</section><section data-mw-section-id="-1"><h1 about="#mwt1" typeof="mw:Transclusion" id="2" data-parsoid='{"dsr":[9,45,null,null],"pi":[[{"k":"1","named":true,"spc":["","","\n","\n"]}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"=2=\nb\n==2.1==\nc"}},"i":0}},"\n\nd\n\n"]}'>2</h1><span about="#mwt1"> +</span><p about="#mwt1">b</p><span about="#mwt1"> +</span><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="2.1">2.1</h2><span about="#mwt1"> +</span><p about="#mwt1">c</p><span about="#mwt1"> + +</span><p about="#mwt1">d</p><span about="#mwt1"> + +</span></section></section><section data-mw-section-id="4"><h1 id="3">3</h1> +<p>e</p></section> +!! end + +# Because of section-wrapping and template-wrapping interactions, +# additional template wrappers are added to <section> tags +# so that template wrapping semantics are valid whether section +# tags are retained or stripped. But, the template scope can expand +# greatly when accounting for section tags. +# This exercises the s1 and s2 are in different subtrees scenario +!! test +Section wrapping with template-generated sections (bad nesting 3) +!! options +parsoid={ + "wrapSections": true, + "modes": ["wt2html", "wt2wt"] +} +!! wikitext +=1= +a + +{{echo|1= +==1.2== +b +=2= +c +}} + +d + +=3= +e +!! html/parsoid +<section data-mw-section-id="0"></section><section data-mw-section-id="1" about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":["=1=\na\n\n",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"==1.2==\nb\n=2=\nc"}},"i":0}},"\n\nd\n\n"]}'><h1 id="1">1</h1> +<p>a</p> + +<section data-mw-section-id="-1"><h2 about="#mwt1" typeof="mw:Transclusion" id="1.2" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"==1.2==\nb\n=2=\nc"}},"i":0}}]}'>1.2</h2><span about="#mwt1"> +</span><p about="#mwt1">b</p><span about="#mwt1"> +</span></section></section><section data-mw-section-id="-1" about="#mwt1"><h1 about="#mwt1" id="2">2</h1><span about="#mwt1"> +</span><p about="#mwt1">c</p> + +<p>d</p> +</section><section data-mw-section-id="4" data-parsoid="{}"><h1 id="3">3</h1> +<p>e</p></section> +!! end + +!! test +Section wrapping with uneditable lead section + div wrapping multiple sections +!! options +parsoid={ + "wrapSections": true +} +!! wikitext +foo + +<div style="border:1px solid red;"> +=1= +a + +==1.1== +b + +=2= +c +</div> + +=3= +d + +==3.1== +e +!! html/parsoid +<section data-mw-section-id="-1"><p>foo</p> + +</section><section data-mw-section-id="-2"><div style="border:1px solid red;"> +<section data-mw-section-id="1"><h1 id="1">1</h1> +<p>a</p> + +<section data-mw-section-id="2"><h2 id="1.1">1.1</h2> +<p>b</p> + +</section></section><section data-mw-section-id="-1"><h1 id="2">2</h1> +<p>c</p> +</section></div> + +</section><section data-mw-section-id="4"><h1 id="3">3</h1> +<p>d</p> + +<section data-mw-section-id="5"><h2 id="3.1">3.1</h2> +<p>e</p> +</section></section> +!! end + +!! test +Section wrapping with editable lead section + div overlapping multiple sections +!! options +parsoid={ + "wrapSections": true +} +!! wikitext +foo + +=1= +a +<div style="border:1px solid red;"> +b + +==1.1== +c + +=2= +d +</div> +e + +=3= +f + +==3.1== +g +!! html/parsoid +<section data-mw-section-id="0"><p>foo</p> + +</section><section data-mw-section-id="-1"><h1 id="1">1</h1> +<p>a</p> +</section><section data-mw-section-id="-2"><div style="border:1px solid red;"> +<p>b</p> + +<section data-mw-section-id="2"><h2 id="1.1">1.1</h2> +<p>c</p> + +</section><section data-mw-section-id="-1"><h1 id="2">2</h1> +<p>d</p> +</section></div> +<p>e</p> + +</section><section data-mw-section-id="4"><h1 id="3">3</h1> +<p>f</p> + +<section data-mw-section-id="5"><h2 id="3.1">3.1</h2> +<p>g</p> +</section></section> +!! end + +!! test +HTML header tags should not be wrapped in section tags +!! options +parsoid={ + "wrapSections": true +} +!! wikitext +foo + +<h1>a</h1> + +=b= + +<h1>c</h1> + +=d= +!! html/parsoid +<section data-mw-section-id="0"><p>foo</p> + +<h1 id="a" data-parsoid='{"stx":"html"}'>a</h1> + +</section><section data-mw-section-id="1"><h1 id="b">b</h1> + +<h1 id="c" data-parsoid='{"stx":"html"}'>c</h1> + +</section><section data-mw-section-id="2"><h1 id="d">d</h1></section> +!! end + +!! test +Lead section containing only whitespace and comments. +!! options +parsoid={ + "wrapSections": true +} +!! wikitext + +<!-- this is a comment, presumably significant to editors --> +=1= +a + +=2= +b +!! html/parsoid +<section data-mw-section-id="0" data-parsoid="{}"> +<!-- this is a comment, presumably significant to editors --> +</section><section data-mw-section-id="1"><h1 id="1">1</h1> +<p>a</p> + +</section><section data-mw-section-id="2"><h1 id="2">2</h1> +<p>b</p></section> +!! end + +!! test +Pseudo-sections emitted by templates should have id -2 +!! options +parsoid={ + "wrapSections": true +} +!! wikitext +foo +{{echo|<div> +==a== +==b== +</div> +}} +!! html/parsoid +<section data-mw-section-id="-1"><p>foo</p> +</section><section data-mw-section-id="-2"><div about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"stx":"html","pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"<div>\n==a==\n==b==\n</div>\n"}},"i":0}}]}'> +<section data-mw-section-id="-1"><h2 id="a">a</h2> +</section><section data-mw-section-id="-1"><h2 id="b">b</h2> +</section></div><span about="#mwt1"> +</span></section> +!! end + +########################################################################## +Tests demonstrating white-space insensitivity in input wikitext +for wikitext headings, wikitext list items, and wikitext table captions, +headings, and cells. HTML versions of the same should preserve whitespace. +########################################################################## +!! test +Trim whitespace in wikitext headings, list items, table captions, headings, and cells +!! wikitext +__NOTOC__ +== <!--c1--> <!--c2--> Spaces <!--c3--> <!--c4--> == +== <!--c2--> <!--c2--> Tabs <!--c3--><!--c4--> == +* <!--c1--> <!--c2--> List item <!--c3--> <!--c4--> +; <!--term to define--> term : <!--term's definition--> definition +{| +|+ <!--c1--> <!--c2--> Table Caption <!--c3--> <!--c4--> +|- +! <!--c1--> <!--c2--> Table Heading 1 <!--c3--> <!--c4--> !! Table Heading 2 <!--c5--> +|- +| <!--c1--> <!--c2--> Table Cell 1 <!--c3--> <!--c4--> || Table Cell 2 <!--c5--> +|- +| class="foo" || <!--c1--> <!--c2--> Table Cell 3 <!--c3--> <!--c4--> +|- +| <!--c1--> testing [[one|two]] <!--c2--> | <!--c3--> some content +|} +: {| + | <!--c1--> <!--c2--> Table Cell 1 <!--c3--> <!--c4--> || Table Cell 2 <!--c5--> + |} foo <!--c1--> +!! html/php+tidy +<h2><span class="mw-headline" id="Spaces">Spaces</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: Spaces">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<h2><span class="mw-headline" id="Tabs">Tabs</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: Tabs">edit</a><span class="mw-editsection-bracket">]</span></span></h2> +<ul><li>List item</li></ul> +<dl><dt>term </dt> +<dd>definition</dd></dl> +<table> +<caption>Table Caption +</caption> +<tbody><tr> +<th>Table Heading 1</th> +<th>Table Heading 2 +</th></tr> +<tr> +<td>Table Cell 1</td> +<td>Table Cell 2 +</td></tr> +<tr> +<td>class="foo"</td> +<td>Table Cell 3 +</td></tr> +<tr> +<td>testing <a href="/index.php?title=One&action=edit&redlink=1" class="new" title="One (page does not exist)">two</a> | some content +</td></tr></tbody></table> +<dl><dd><table> +<tbody><tr> +<td>Table Cell 1</td> +<td>Table Cell 2 +</td></tr></tbody></table> foo</dd></dl> +!! end + +# Looks like <caption> is not accepted in HTML +!! test +Do not trim whitespace in HTML headings, list items, table captions, headings, and cells +!! wikitext +__NOTOC__ +<h2> <!--c1--> <!--c2--> Heading <!--c3--> <!--c4--> </h2> +<ul><li> <!--c1--> <!--c2--> List item <!--c3--> <!--c4--> </li></ul> +<table> +<tr><th> <!--c1--> <!--c2--> Table Heading <!--c3--> <!--c4--> <th></tr> +<tr><td> <!--c1--> <!--c2--> Table Cell <!--c3--> <!--c4--> <th></tr> +</table> +!! html/php+tidy +<h2><span class="mw-headline" id="Heading"> Heading </span></h2> +<ul><li> List item </li></ul> +<table> +<tbody><tr><th> Table Heading </th><th></th></tr> +<tr><td> Table Cell </td><th></th></tr> +</tbody></table> +!! end + +!! test +Do not trim whitespace in links and quotes +!! wikitext +foo '' <!--c1--> italic <!--c2--> '' and ''' <!--c3--> bold <!--c4--> ''' +[[Foo| some text ]] +!! html/php+tidy +<p>foo <i> italic </i> and <b> bold </b> +<a href="/wiki/Foo" title="Foo"> some text </a> +</p> +!! end + +!! test +Remove p tags surrounding a single element in a figcaption +!! options +parsoid=html2wt +!! wikitext +[[File:Foobar.jpg|right|200x200px|Caption]] +!! html/parsoid +<figure class="mw-halign-right" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="23" width="200"/></a><figcaption><p>Caption</p></figcaption></figure> +!! end + +!! test +Selser preserves lack of newline before list and allows newline after the list +!! options +parsoid={ + "modes": ["selser"], + "scrubWikitext": true, + "changes": [ + [ "ul", "after", "<p>footer</p>" ] + ] +} +!! wikitext +header +*foo +*bar +!! wikitext/edited +header +*foo +*bar + +footer +!! end + + +!! test +Selser does not introduce newlines between unedited paragraph preceding the list +!! options +parsoid={ + "modes": ["selser"], + "changes": [ + [ "table tbody tr td p:last-child", "empty" ] + ] +} +!! wikitext +{| +| +header +*foo +*bar +footer +|} +!! wikitext/edited +{| +| +header +*foo +*bar + +|} +!! end + +!! test +Selser does not introduce newlines between unedited paragraph following the list +!! options +parsoid={ + "modes": ["selser"], + "changes": [ + [ "table tbody tr td p:first-child", "empty" ] + ] +} +!! wikitext +{| +| +header +*foo +*bar +footer +|} +!! wikitext/edited +{| +| + +*foo +*bar +footer +|} +!! end + +!! test +Remove a list item but do not insert newline above list +!! options +parsoid={ + "modes": ["selser"], + "changes": [ + [ "ul li:last-child", "remove" ] + ] +} +!! wikitext +header +*foo +*bar +footer +!! wikitext/edited +header +*foo +footer +!! end |