# MediaWiki Parser test cases
-# see also http://meta.wikimedia.org/wiki/Parser_testing
+# Some taken from http://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:
+# (default) generate HTML output
+# pst apply pre-save transform
+# msg apply message transform
+#
+# Tests can be disabled with the '!!disabled' flag.
+#
+# For testing purposes, temporary articles can created:
+# !!article / NAMESPACE:TITLE / !!text / ARTICLE TEXT / !!endarticle
+# where '/' denotes a newline.
+###
+### Basic tests
+###
!! test
Blank input
!! input
<ul><li> Item 1
</li><li> Item 2
</li></ul>
+
!! end
!! test
</li><li> plain<b>bold<i>bold-italic</i></b>plain
</li><li> plain l'<i>italic</i>plain
</li></ul>
+
!! end
###
<ul><li>There is not nowiki.
</li><li>There is nowiki.
</li></ul>
+
!! end
###
!! result
<pre>asdf
</pre>
+
!! end
!! test
</p>
!! end
+###
+### Tables
+###
+### content taken from http://meta.wikimedia.org/wiki/MediaWiki_User%27s_Guide:_Using_tables
+###
+!! test
+Simple table
+!! input
+{|
+| 1 || 2
+|-
+| 3 || 4
+|}
+!! result
+<table >
+<tr >
+<td> 1 </td><td> 2
+</td></tr>
+<tr >
+<td> 3 </td><td> 4
+</td></tr></table>
+
+!! end
+
+!! test
+Multiplication table
+!! input
+{| 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
+|}
+!! result
+<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
+Table rowspan
+!! input
+{| align=right 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
+|}
+!! result
+<table align=right 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
+!! input
+{| border=1
+| α
+|
+{| bgcolor=#ABCDEF border=2
+|nested
+|-
+|table
+|}
+|the original table again
+|}
+!! result
+<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
+
###
### Internal links
###
</li><li> item 2
</li><li>item 3
</li></ul>
+
!! end
!! test
</li><li>item 2
</li><li> item 3
</li></ol>
+
!! end
!! test
</li></ol>
</li><li>Level 1
</li></ul>
+
!! end
###
!! article
Template:linktest
!! text
-[[{{{param}}}|foo]]
+[[{{{param}}}|link]]
!! endarticle
-XXX this works outside of parser testing
!! test
-!! disabled
Template parameter as link source
!! input
{{linktest|param=Main Page}}
!! result
+<p><a href="/wiki/Main_Page" title="Main Page">link</a>
+</p>
+!! end
+
+
+!! article
+Template:Linktest2
+!! text
+Main Page
+!! endarticle
+
+!! test
+Template as link source
+!! input
+[[{{linktest2}}]]
+!! result
<p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
</p>
!! end
+!! article
+Template:loop1
+!! text
+{{loop2}}
+!! endarticle
+
+!! article
+Template:loop2
+!! text
+{{loop1}}
+!! endarticle
+
+!! test
+Template infinite loop
+!! input
+{{loop1}}
+!! result
+<p>{{loop2}}<!-- WARNING: template loop detected -->
+</p>
+!! end
+
+
###
### Pre-save transform tests
###
{{test}}
!! end
+!! test
+pre-save transform: nonexistant template
+!! options
+PST
+!! input
+{{thistemplatedoesnotexist}}
+!! result
+{{thistemplatedoesnotexist}}
+!! end
+
!! test
pre-save transform: subst magic variables
!! options
-pst
+PST
!! input
{{subst:SITENAME}}
!! result
!! end
!! test
-message transform: should transform wiki markup
+message transform: should not transform wiki markup
!! options
msg
!! input
tables
images
subpages
-pre-save transform and message transform checking
+character entities
and much more