1776 lines
38 KiB
Text
1776 lines
38 KiB
Text
# MediaWiki Parser test cases
|
||
# Some taken from http://meta.wikimedia.org/wiki/Parser_testing
|
||
# All (C) their respective authors and released under the GPL
|
||
# $Id$
|
||
#
|
||
# 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
|
||
# ill add inter-language links
|
||
# subpage enable subpages (disabled by default)
|
||
# title=[[XXX]] run test using article title XXX
|
||
# disabled do not run test
|
||
#
|
||
# 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
|
||
|
||
###
|
||
### Basic tests
|
||
###
|
||
!! test
|
||
Blank input
|
||
!! input
|
||
!! result
|
||
!! end
|
||
|
||
|
||
!! test
|
||
Simple paragraph
|
||
!! input
|
||
This is a simple paragraph.
|
||
!! result
|
||
<p>This is a simple paragraph.
|
||
</p>
|
||
!! end
|
||
|
||
!! test
|
||
Simple list
|
||
!! input
|
||
* Item 1
|
||
* Item 2
|
||
!! result
|
||
<ul><li> Item 1
|
||
</li><li> Item 2
|
||
</li></ul>
|
||
|
||
!! end
|
||
|
||
!! test
|
||
Italics and bold
|
||
!! input
|
||
* 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
|
||
!! result
|
||
<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></ul>
|
||
|
||
!! end
|
||
|
||
###
|
||
### <nowiki> test cases
|
||
###
|
||
|
||
!! test
|
||
<nowiki> unordered list
|
||
!! input
|
||
<nowiki>* This is not an unordered list item.</nowiki>
|
||
!! result
|
||
<p>* This is not an unordered list item.
|
||
</p>
|
||
!! end
|
||
|
||
!! test
|
||
<nowiki> spacing
|
||
!! input
|
||
<nowiki>Lorem ipsum dolor
|
||
|
||
sed abit.
|
||
sed nullum.
|
||
|
||
:and a colon
|
||
</nowiki>
|
||
!! result
|
||
<p>Lorem ipsum dolor
|
||
|
||
sed abit.
|
||
sed nullum.
|
||
|
||
:and a colon
|
||
|
||
</p>
|
||
!! end
|
||
|
||
!! test
|
||
nowiki 3
|
||
!! input
|
||
: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>.
|
||
!! result
|
||
<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>
|
||
|
||
!! end
|
||
|
||
###
|
||
### comment test cases
|
||
###
|
||
!! test
|
||
Comment test 1
|
||
!! input
|
||
<!-- comment 1 --> asdf
|
||
<!-- comment 2 -->
|
||
!! result
|
||
<pre>asdf
|
||
</pre>
|
||
|
||
!! end
|
||
|
||
!! test
|
||
Comment test 2
|
||
!! input
|
||
asdf
|
||
<!-- comment 1 -->
|
||
jkl
|
||
!! result
|
||
<p>asdf
|
||
jkl
|
||
</p>
|
||
!! end
|
||
|
||
!! test
|
||
Comment test 3
|
||
!! input
|
||
asdf
|
||
<!-- comment 1 -->
|
||
<!-- comment 2 -->
|
||
jkl
|
||
!! result
|
||
<p>asdf
|
||
jkl
|
||
</p>
|
||
!! end
|
||
|
||
!! test
|
||
Comment test 4
|
||
!! input
|
||
asdf<!-- comment 1 -->jkl
|
||
!! result
|
||
<p>asdfjkl
|
||
</p>
|
||
!! end
|
||
|
||
!! test
|
||
Comment spacing
|
||
!! input
|
||
a
|
||
<!-- foo --> b <!-- bar -->
|
||
c
|
||
!! result
|
||
<p>a
|
||
</p>
|
||
<pre> b
|
||
</pre>
|
||
<p>c
|
||
</p>
|
||
!! end
|
||
|
||
###
|
||
### Preformatted text
|
||
###
|
||
!! test
|
||
Preformatted text
|
||
!! input
|
||
This is some
|
||
Preformatted text
|
||
With ''italic''
|
||
And '''bold'''
|
||
And a [[Main Page|link]]
|
||
!! result
|
||
<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
|
||
|
||
###
|
||
### Definition list
|
||
###
|
||
!! test
|
||
Simple definition
|
||
!! input
|
||
; name : Definition
|
||
!! result
|
||
<dl><dt> name </dt><dd> Definition
|
||
</dd></dl>
|
||
|
||
!! end
|
||
|
||
!! test
|
||
Simple definition
|
||
!! input
|
||
: Indented text
|
||
!! result
|
||
<dl><dd> Indented text
|
||
</dd></dl>
|
||
|
||
!! end
|
||
|
||
!! test
|
||
Definition list with no space
|
||
!! input
|
||
;name:Definition
|
||
!! result
|
||
<dl><dt>name</dt><dd>Definition
|
||
</dd></dl>
|
||
|
||
!!end
|
||
|
||
!! test
|
||
Definition list with URL link
|
||
!! input
|
||
; http://example.com/ : definition
|
||
!! result
|
||
<dl><dt> <a href="http://example.com/" class='external'>http://example.com/</a> </dt><dd> definition
|
||
</dd></dl>
|
||
|
||
!! end
|
||
|
||
!! test
|
||
Definition list with bracketed URL link
|
||
!! input
|
||
;[http://www.google.com/ Google]:Number one search engine
|
||
!! result
|
||
<dl><dt><a href="http://www.google.com/" class='external' title="http://www.google.com/">Google</a><span class='urlexpansion'> (<i>http://www.google.com/</i>)</span></dt><dd>Number one search engine
|
||
</dd></dl>
|
||
|
||
!! end
|
||
|
||
!! test
|
||
Definition list with wikilink containing colon
|
||
!! input
|
||
; [[Wikipedia:FAQ]]: The least-read page on Wikipedia
|
||
!! result
|
||
<dl><dt> <a href="http://en.wikipedia.org/wiki/FAQ" class='extiw'>Wikipedia:FAQ</a></dt><dd> The least-read page on Wikipedia
|
||
</dd></dl>
|
||
|
||
!! end
|
||
|
||
# At Brion's and JeLuF's insistence... :)
|
||
!! test
|
||
Definition list with wikilink containing colon
|
||
!! input
|
||
; news:alt.wikipedia.rox: This isn't even a real newsgroup!
|
||
!! result
|
||
<dl><dt> <a href="news:alt.wikipedia.rox" class='external'>news:alt.wikipedia.rox</a></dt><dd> This isn't even a real newsgroup!
|
||
</dd></dl>
|
||
|
||
!! end
|
||
|
||
!! test
|
||
Malformed definition list with colon
|
||
!! input
|
||
; news:alt.wikipedia.rox -- don't crash or enter an infinite loop
|
||
!! result
|
||
<dl><dt> <a href="news:alt.wikipedia.rox" class='external'>news:alt.wikipedia.rox</a> -- don't crash or enter an infinite loop
|
||
</dt></dl>
|
||
|
||
!! end
|
||
|
||
!! test
|
||
Definition lists: colon in external link text
|
||
!! input
|
||
; [http://www.wikipedia2.org/ Wikipedia : The Next Generation]: OK, I made that up
|
||
!! result
|
||
<dl><dt> <a href="http://www.wikipedia2.org/" class='external' title="http://www.wikipedia2.org/">Wikipedia : The Next Generation</a><span class='urlexpansion'> (<i>http://www.wikipedia2.org/</i>)</span></dt><dd> OK, I made that up
|
||
</dd></dl>
|
||
|
||
!! end
|
||
|
||
|
||
###
|
||
### External links
|
||
###
|
||
!! test
|
||
External links: non-bracketed
|
||
!! input
|
||
Non-bracketed: http://example.com
|
||
!! result
|
||
<p>Non-bracketed: <a href="http://example.com" class='external'>http://example.com</a>
|
||
</p>
|
||
!! end
|
||
|
||
!! test
|
||
External links: numbered
|
||
!! input
|
||
Numbered: [http://example.com]
|
||
!! result
|
||
<p>Numbered: <a href="http://example.com" class='external' title="http://example.com">[1]</a><span class='urlexpansion'> (<i>http://example.com</i>)</span>
|
||
</p>
|
||
!!end
|
||
|
||
!! test
|
||
External links: specified text
|
||
!! input
|
||
Specified text: [http://example.com link]
|
||
!! result
|
||
<p>Specified text: <a href="http://example.com" class='external' title="http://example.com">link</a><span class='urlexpansion'> (<i>http://example.com</i>)</span>
|
||
</p>
|
||
!!end
|
||
|
||
!! test
|
||
External links: trail
|
||
!! input
|
||
Trail (not sure if this is meant to work): [http://example.com link]s
|
||
!! result
|
||
<p>Trail (not sure if this is meant to work): <a href="http://example.com" class='external' title="http://example.com">link</a>s<span class='urlexpansion'> (<i>http://example.com</i>)</span>
|
||
</p>
|
||
!! end
|
||
|
||
!! test
|
||
External links: dollar sign in URL
|
||
!! input
|
||
http://example.com/1$2345
|
||
!! result
|
||
<p><a href="http://example.com/1$2345" class='external'>http://example.com/1$2345</a>
|
||
</p>
|
||
!! end
|
||
|
||
!! test
|
||
External links: dollar sign in URL (named)
|
||
!! input
|
||
[http://example.com/1$2345]
|
||
!! result
|
||
<p><a href="http://example.com/1$2345" class='external' title="http://example.com/1$2345">[1]</a><span class='urlexpansion'> (<i>http://example.com/1$2345</i>)</span>
|
||
</p>
|
||
!!end
|
||
|
||
!! test
|
||
External image
|
||
!! input
|
||
External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
|
||
!! result
|
||
<p>External image: <img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png" />
|
||
</p>
|
||
!! end
|
||
|
||
!! test
|
||
External image from https
|
||
!! input
|
||
External image from https: https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
|
||
!! result
|
||
<p>External image from https: <img src="https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png" />
|
||
</p>
|
||
!! end
|
||
|
||
!! test
|
||
Link to non-http image, no img tag
|
||
!! input
|
||
Link to non-http image, no img tag: ftp://example.com/test.jpg
|
||
!! result
|
||
<p>Link to non-http image, no img tag: <a href="ftp://example.com/test.jpg" class='external'>ftp://example.com/test.jpg</a>
|
||
</p>
|
||
!! end
|
||
|
||
!! test
|
||
External links: terminating separator
|
||
!! input
|
||
Terminating separator: http://example.com/thing,
|
||
!! result
|
||
<p>Terminating separator: <a href="http://example.com/thing" class='external'>http://example.com/thing</a>,
|
||
</p>
|
||
!! end
|
||
|
||
!! test
|
||
External links: intervening separator
|
||
!! input
|
||
Intervening separator: http://example.com/1,2,3
|
||
!! result
|
||
<p>Intervening separator: <a href="http://example.com/1,2,3" class='external'>http://example.com/1,2,3</a>
|
||
</p>
|
||
!! end
|
||
|
||
!! test
|
||
External links: old bug with URL in query
|
||
!! input
|
||
Old bug with URL in query: [http://example.com/thing?url=http://example.com link]
|
||
!! result
|
||
<p>Old bug with URL in query: <a href="http://example.com/thing?url=http://example.com" class='external' title="http://example.com/thing?url=http://example.com">link</a><span class='urlexpansion'> (<i>http://example.com/thing?url=http://example.com</i>)</span>
|
||
</p>
|
||
!! end
|
||
|
||
!! test
|
||
External links: old URL-in-URL bug, mixed protocols
|
||
!! input
|
||
And again with mixed protocols: [ftp://example.com?url=http://example.com link]
|
||
!! result
|
||
<p>And again with mixed protocols: <a href="ftp://example.com?url=http://example.com" class='external' title="ftp://example.com?url=http://example.com">link</a><span class='urlexpansion'> (<i>ftp://example.com?url=http://example.com</i>)</span>
|
||
</p>
|
||
!!end
|
||
|
||
!! test
|
||
External links: URL in text
|
||
!! input
|
||
URL in text: [http://example.com http://example.com]
|
||
!! result
|
||
<p>URL in text: <a href="http://example.com" class='external'>http://example.com</a>
|
||
</p>
|
||
!! end
|
||
|
||
!! test
|
||
External links: Clickable images
|
||
!! input
|
||
ja-style clickable images: [http://example.com http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png]
|
||
!! result
|
||
<p>ja-style clickable images: <a href="http://example.com" class='external' title="http://example.com"><img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png" /></a><span class='urlexpansion'> (<i>http://example.com</i>)</span>
|
||
</p>
|
||
!!end
|
||
|
||
!! test
|
||
External links: raw ampersand
|
||
!! input
|
||
Old & use: http://x&y
|
||
!! result
|
||
<p>Old & use: <a href="http://x&y" class='external'>http://x&y</a>
|
||
</p>
|
||
!! end
|
||
|
||
!! test
|
||
External links: www.jpeg.org (bug 554)
|
||
!! input
|
||
http://www.jpeg.org
|
||
!!result
|
||
<p><a href="http://www.jpeg.org" class='external'>http://www.jpeg.org</a>
|
||
</p>
|
||
!! end
|
||
|
||
!! test
|
||
External links: URL within URL (original bug 2)
|
||
!! input
|
||
[http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp]
|
||
!! result
|
||
<p><a href="http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp" class='external' title="http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp">[1]</a><span class='urlexpansion'> (<i>http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp</i>)</span>
|
||
</p>
|
||
!! end
|
||
|
||
!! test
|
||
BUG 361: URL inside bracketed URL
|
||
!! input
|
||
[http://www.example.com/foo http://www.example.com/bar]
|
||
!! result
|
||
<p><a href="http://www.example.com/foo" class='external' title="http://www.example.com/foo">http://www.example.com/bar</a><span class='urlexpansion'> (<i>http://www.example.com/foo</i>)</span>
|
||
</p>
|
||
!! end
|
||
|
||
!! test
|
||
BUG 289: ">"-token in URL-tail
|
||
!! input
|
||
http://www.example.com/<hello>
|
||
!! result
|
||
<p><a href="http://www.example.com/" class='external'>http://www.example.com/</a><hello>
|
||
</p>
|
||
!!end
|
||
|
||
!! test
|
||
BUG 289: literal ">"-token in URL-tail
|
||
!! input
|
||
http://www.example.com/<b>html</b>
|
||
!! result
|
||
<p><a href="http://www.example.com/" class='external'>http://www.example.com/</a><b >html</b >
|
||
</p>
|
||
!!end
|
||
|
||
!! test
|
||
BUG 289: ">"-token in bracketed URL
|
||
!! input
|
||
[http://www.example.com/<hello> stuff]
|
||
!! result
|
||
<p><a href="http://www.example.com/" class='external' title="http://www.example.com/"><hello> stuff</a><span class='urlexpansion'> (<i>http://www.example.com/</i>)</span>
|
||
</p>
|
||
!!end
|
||
|
||
!! test
|
||
BUG 289: literal ">"-token in bracketed URL
|
||
!! input
|
||
[http://www.example.com/<b>html</b> stuff]
|
||
!! result
|
||
<p><a href="http://www.example.com/" class='external' title="http://www.example.com/"><b >html</b > stuff</a><span class='urlexpansion'> (<i>http://www.example.com/</i>)</span>
|
||
</p>
|
||
!!end
|
||
|
||
!! test
|
||
BUG 289: literal double quote at end of URL
|
||
!! input
|
||
http://www.example.com/"hello"
|
||
!! result
|
||
<p><a href="http://www.example.com/" class='external'>http://www.example.com/</a>"hello"
|
||
</p>
|
||
!!end
|
||
|
||
!! test
|
||
BUG 289: literal double quote in bracketed URL
|
||
!! input
|
||
[http://www.example.com/"hello" stuff]
|
||
!! result
|
||
<p><a href="http://www.example.com/" class='external' title="http://www.example.com/">"hello" stuff</a><span class='urlexpansion'> (<i>http://www.example.com/</i>)</span>
|
||
</p>
|
||
!!end
|
||
|
||
!! test
|
||
External links: invalid character
|
||
!! input
|
||
[http://www.example.com |