blah blah
!! endarticle
-!!article
+!!article
Template:Foo
!!text
FOO
!!endarticle
-!! article
+!! article
Template:Blank
!! text
!! endarticle
* item 1
!! endarticle
+!! article
+Template:echo
+!! text
+{{{1}}}
+!! endarticle
+
###
### Basic tests
###
### Comments
###
!! test
-Comment test 1
+Comments and Pre
!! input
+<!-- comment 1 --> asdf
+
<!-- comment 1 --> asdf
<!-- comment 2 -->
+
+<!-- comment 1 --> asdf
+<!-- comment 2 -->xyz
+
+<!-- comment 1 --> asdf
+<!-- comment 2 --> xyz
!! result
<pre>asdf
</pre>
-
+<pre>asdf
+</pre>
+<pre>asdf
+</pre>
+<p>xyz
+</p>
+<pre>asdf
+xyz
+</pre>
!! end
!! test
</p>
!! end
+!!test
+Templates: Pre: 1a. Templates that break a line should suppress <pre>
+!!input
+ {{echo|}}
+!!result
+
+!!end
+
+!!test
+Templates: Pre: 1b. Templates that break a line should suppress <pre>
+!!input
+ {{echo|
+foo}}
+!!result
+<p>foo
+</p>
+!!end
+
+!! test
+Templates: Pre: 1c: Wrapping should be based on expanded content
+!! input
+ {{echo|a
+b}}
+!!result
+<pre>a
+</pre>
+<p>b
+</p>
+!!end
+
+!! test
+Templates: Pre: 1d: Wrapping should be based on expanded content
+!! input
+ {{echo|a
+b
+c
+ d
+e
+}}
+!!result
+<pre>a
+</pre>
+<p>b
+c
+</p>
+<pre>d
+</pre>
+<p>e
+</p>
+!!end
+
+!!test
+Templates: Pre: 1e. Wrapping should be based on expanded content
+!!input
+{{echo| foo}}
+
+{{echo| foo}}
+{{echo| bar}}
+
+{{echo|<!--cmt--> foo}}
+
+<!--cmt-->{{echo| foo}}
+
+{{echo|{{echo| }}bar}}
+!!result
+<pre>foo
+</pre>
+<pre>foo
+bar
+</pre>
+<pre>foo
+</pre>
+<pre>foo
+</pre>
+<pre>bar
+</pre>
+!!end
+
+###
+### Parsoid-centric tests for testing RT edge cases
+### around comments and white-space inside pre blocks
+###
+
+!!test
+1a. Pre and Comments
+!!input
+ a
+<!--a-->
+c
+!!result
+<pre>a
+</pre>
+<p>c
+</p>
+!!end
+
+!!test
+1b. Pre and Comments
+!!input
+ a
+ <!--a-->
+c
+!!result
+<pre>a
+</pre>
+<p>c
+</p>
+!!end
+
+!!test
+1c. Pre and Comments
+!!input
+<!--a--> a
+
+ <!--a--> a
+!!result
+<pre> a
+</pre>
+<pre> a
+</pre>
+!!end
###
### Definition lists
##
## All Parsoid only definition list tests have this difference.
##
-## See also: https://bugzilla.wikimedia.org/show_bug.cgi?id=6569
+## See also: https://bugzilla.wikimedia.org/show_bug.cgi?id=6569
## and http://lists.wikimedia.org/pipermail/wikitext-l/2011-November/000483.html
!! test
</p>
!!end
+!! test
+External links: Pipe char between url and text
+!! input
+[http://example.com | link]
+!! result
+<p><a rel="nofollow" class="external text" href="http://example.com">| link</a>
+</p>
+!!end
+
!! test
External links: protocol-relative URL in brackets
!! input
# this as <p>caption</p>
!! test
A table with nothing but a caption
-!! input
+!! input
{|
|+ caption
|}
</p>
!! end
+!! test
+Parsoid-specific test: Wikilinks with should RT properly
+!! options
+language=ln
+!! input
+[[WW II]]
+!!result
+<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
##
## XHTML tidiness
</p>
!! end
-!! test
+!! test
Failing to transform badly formed HTML into correct XHTML
!! input
<br style="clear: left;">
</p>
!!end
+!! test
+Handling html with a div self-closing tag
+!! input
+<div title />
+<div title/>
+<div title/ >
+<div title=bar />
+<div title=bar/>
+<div title=bar/ >
+!! result
+<p><div title />
+<div title/>
+</p>
+<div>
+<p><div title=bar />
+<div title=bar/>
+</p>
+<div title="bar/"></div>
+</div>
+
+!! end
+
+!! test
+Handling html with a br self-closing tag
+!! input
+<br title />
+<br title/>
+<br title/ >
+<br title=bar />
+<br title=bar/>
+<br title=bar/ >
+!! result
+<p><br title="title" />
+<br title="title" />
+<br />
+<br title="bar" />
+<br title="bar" />
+<br title="bar/" />
+</p>
+!! end
+
!! test
Horizontal ruler (should it add that extra space?)
!! input
!! end
###
-### Parsoid-centric tests to stress Parsoid's ability to RT them unchanged
+### <includeonly> and <noinclude> in attributes
###
+!!test
+1. includeonly around the entire attribute
+!!input
+<span <includeonly>id="v1"</includeonly><noinclude>id="v2"</noinclude>>bar</span>
+!!result
+<p><span id="v2">bar</span>
+</p>
+!!end
+
+!!test
+2. includeonly in html attr key
+!!input
+<span <noinclude>id</noinclude><includeonly>about</includeonly>="foo">bar</span>
+!!result
+<p><span id="foo">bar</span>
+</p>
+!!end
+
+!!test
+3. includeonly in html attr value
+!!input
+<span id="<noinclude>v1</noinclude><includeonly>v2</includeonly>">bar</span>
+<span id=<noinclude>"v1"</noinclude><includeonly>"v2"</includeonly>>bar</span>
+!!result
+<p><span id="v1">bar</span>
+<span id="v1">bar</span>
+</p>
+!!end
+
+!!test
+4. includeonly in part of an attr value
+!!input
+<span style="color:<noinclude>red</noinclude><includeonly>blue</includeonly>;">bar</span>
+!!result
+<p><span style="color:red;">bar</span>
+</p>
+!!end
+
+###
+### Testing parsing of templates where a template arg
+### has the same name as the template itself.
+###
+
!! article
-Template:echo
+Template:quote
!! text
-{{{1}}}
+{{{quote|{{{1}}}}}}
!! endarticle
+!!test
+Templates: Template Name/Arg clash: 1. Use of positional param
+!!input
+{{quote|foo}}
+!!result
+<p>foo
+</p>
+!!end
+
+!!test
+Templates: Template Name/Arg clash: 2. Use of named param
+!!input
+{{quote|quote=foo}}
+!!result
+<p>foo
+</p>
+!!end
+
+!!test
+Templates: Template Name/Arg clash: 3. Use of named param with empty input
+!!input
+{{quote|quote}}
+!!result
+<p>quote
+</p>
+!!end
+
+###
+### Parsoid-centric tests to stress Parsoid's ability to RT them unchanged
+###
+
!!test
Templates: 1. Simple use
!!input
!!end
!!test
-Templates: HTML Tag: 5. Generation of middle piece of HTML attr value
+Templates: HTML Tag: 5. Generation of middle piece of HTML attr value
!!input
<div title="This is a long title with just {{echo|one piece}} templated">foo</div>
!!result
!!end
!!test
-Templates: HTML Tag: 6. Generation of end piece of HTML attr value
+Templates: HTML Tag: 6. Generation of end piece of HTML attr value
!!input
<div title="This is a long title with just one piece {{echo|templated}}">foo</div>
!!result
!!end
-!!test
-Templates: Pre: 1a. Templates that break a line should suppress <pre>
-!!input
- {{echo|}}
-!!result
-
-!!end
-
-!!test
-Templates: Pre: 1b. Templates that break a line should suppress <pre>
-!!input
- {{echo|
-foo}}
-!!result
-<p>foo
-</p>
-!!end
-
!!test
Parser Functions: 1. Simple example
!!input
</p>
!! end
-!! article
+!! article
File:Barfoo.jpg
!! text
#REDIRECT [[File:Barfoo.jpg]]
</p>
!! end
+!! test
+Category with different sort key
+!! options
+cat
+!! input
+[[Category:MediaWiki User's Guide|Foo]]
+!! result
+<a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User's Guide">MediaWiki User's Guide</a>
+!! end
+
+!! test
+Category with identical sort key
+!! options
+cat
+!! input
+[[Category:MediaWiki User's Guide|MediaWiki User's Guide]]
+!! result
+<a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User's Guide">MediaWiki User's Guide</a>
+!! end
+
+!! test
+Category with empty sort key
+!! options
+cat
+pst
+!! input
+[[Category:MediaWiki User's Guide|]]
+!! result
+[[Category:MediaWiki User's Guide|MediaWiki User's Guide]]
+!! end
+
+!! test
+Category with empty sort key and parentheses
+!! options
+cat
+pst
+!! input
+[[Category:Foo (bar)|]]
+!! result
+[[Category:Foo (bar)|Foo]]
+!! end
+
###
### Inter-language links
###
# perl -e 'print "="x$_," Level $_ heading","="x$_,"\n" for 1..10'
!! test
Handling of sections up to level 6 and beyond
-!! input
+!! input
= Level 1 Heading=
== Level 2 Heading==
=== Level 3 Heading===
!! end
-# Formerly testing for bug 2587, now resolved by the use of unmarked sections
+# Formerly testing for bug 2587, now resolved by the use of unmarked sections
# instead of respecting commented sections
!! test
Section extraction prefixed by comment (section 1)
!!end
-# Formerly testing for bug 2607, now resolved by the use of unmarked sections
+# Formerly testing for bug 2607, now resolved by the use of unmarked sections
# instead of respecting HTML-style headings
!! test
Section extraction, mixed wiki and html (section 1)
!! test
__FORCETOC__ override
-!! input
+!! input
__NEWSECTIONLINK__
__FORCETOC__
!! result
!! end
!! test
-Double RFC with a wiki link
+Double RFC with a wiki link
!! input
RFC [[RFC 1234]]
!! result
!! test
Unclosed language converter markup "-{"
-!! options
+!! options
language=sr
!! input
-{T|hello
language=sr
!! input
-{R|=>}-
-!! result
+!! result
<p>=>
</p>
!!end
-!!article
+!!article
Template:Bullet
!!text
* Bar
<p>this is not the the title
</p>
!! end
-
+
!! test
preload: check <noinclude> and <includeonly>
!! options
!! result
Hello kind world.
!! end
-
+
!! test
preload: check <onlyinclude>
!! options
!! end
!! test
-Play a bit with r67090 and bug 3158
+Play a bit with r67090 and bug 3158
!! options
disabled
!! input
!! end
!! test
-Bug 26375: TOC with bold
+Bug 26375: TOC with bold
!! options
title=[[Main Page]]
!! input
!! end
+!! test
+span tags with directionality in TOC
+!! input
+__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> ==
+!! result
+<table id="toc" class="toc"><tr><td><div id="toctitle"><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>
+</td></tr></table>
+<h2><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=1" title="Edit section: C++">edit</a>]</span> <span class="mw-headline" id="C.2B.2B"> <span dir="ltr">C++</span> </span></h2>
+<h2><span class="editsection">[<a href="/index.php?title=Parser_test&action=edit&section=2" title="Edit section: זבנג!">edit</a>]</span> <span class="mw-headline" id=".D7.96.D7.91.D7.A0.D7.92.21"> <span dir="rtl">זבנג!</span> </span></h2>
+<h2><span class="editsection">[<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> <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></h2>
+<h2><span class="editsection">[<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> <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></h2>
+<h2><span class="editsection">[<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> <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></h2>
+
+!! end
+
!! article
MediaWiki:Bug32057
!! text