Use OutputPage to replace link placeholders; add links, quotes tests
[lhc/web/wiklou.git] / maintenance / parserTests.txt
1 # MediaWiki Parser test cases
2 # see also http://meta.wikimedia.org/wiki/Parser_testing
3
4 # At present these assume that $wgUseTidy is false and may break
5 # if it is enabled.
6
7 !! test
8 Blank input
9 !! input
10 !! result
11 !! end
12
13 !! test
14 Simple paragraph
15 !! input
16 This is a simple paragraph.
17 !! result
18 <p>This is a simple paragraph.
19 </p>
20 !! end
21
22 !! test
23 Simple list
24 !! input
25 * Item 1
26 * Item 2
27 !! result
28 <ul><li> Item 1
29 </li><li> Item 2
30 </li></ul>
31 !! end
32
33 !! test
34 Italics and bold
35 !! input
36 * plain
37 * plain''italic''plain
38 * plain''italic''plain''italic''plain
39 * plain'''bold'''plain
40 * plain'''bold'''plain'''bold'''plain
41 * plain''italic''plain'''bold'''plain
42 * plain'''bold'''plain''italic''plain
43 * plain''italic'''bold-italic'''italic''plain
44 * plain'''bold''bold-italic''bold'''plain
45 * plain'''''bold-italic'''italic''plain
46 * plain'''''bold-italic''bold'''plain
47 * plain''italic'''bold-italic'''''plain
48 * plain'''bold''bold-italic'''''plain
49 * plain l'''italic''plain
50 !! result
51 <ul><li> plain
52 </li><li> plain<i>italic</i>plain
53 </li><li> plain<i>italic</i>plain<i>italic</i>plain
54 </li><li> plain<b>bold</b>plain
55 </li><li> plain<b>bold</b>plain<b>bold</b>plain
56 </li><li> plain<i>italic</i>plain<b>bold</b>plain
57 </li><li> plain<b>bold</b>plain<i>italic</i>plain
58 </li><li> plain<i>italic<b>bold-italic</b>italic</i>plain
59 </li><li> plain<b>bold<i>bold-italic</i>bold</b>plain
60 </li><li> plain<i><b>bold-italic</b>italic</i>plain
61 </li><li> plain<b><i>bold-italic</i>bold</b>plain
62 </li><li> plain<i>italic<b>bold-italic</b></i>plain
63 </li><li> plain<b>bold<i>bold-italic</i></b>plain
64 </li><li> plain l'<i>italic</i>plain
65 </li></ul>
66 !! end
67
68 ###
69 ### <nowiki> test cases
70 ###
71
72 !! test
73 <nowiki> unordered list
74 !! input
75 <nowiki>* This is not an unordered list item.</nowiki>
76 !! result
77 <p>* This is not an unordered list item.
78 </p>
79 !! end
80
81 !! test
82 <nowiki> spacing
83 !! input
84 <nowiki>Lorem ipsum dolor
85
86 sed abit.
87 sed nullum.
88
89 :and a colon
90 </nowiki>
91 !! result
92 <p>Lorem ipsum dolor sed abit. sed nullum. :and a colon</p>
93 !! end
94
95 !! test
96 nowiki 3
97 !! input
98 :There is not nowiki.
99 :There is <nowiki>nowiki</nowiki>.
100
101 #There is not nowiki.
102 #There is <nowiki>nowiki</nowiki>.
103
104 *There is not nowiki.
105 *There is <nowiki>nowiki</nowiki>.
106 !! result
107 <dl><dd>There is not nowiki.
108 </dd><dd>There is nowiki.
109 </dd></dl>
110 <ol><li>There is not nowiki.
111 </li><li>There is nowiki.
112 </li></ol>
113 <ul><li>There is not nowiki.
114 </li><li>There is nowiki.
115 </li></ul>
116 !! end
117
118 ###
119 ### comment test cases
120 ###
121 !! test
122 comment test 1
123 !! input
124 <!-- comment 1 --> asdf
125 <!-- comment 2 -->
126 !! result
127 <pre>asdf
128 </pre>
129 !! end
130
131 !! test
132 !! disabled
133 comment test 2
134 !! input
135 asdf
136 <!-- comment 1 -->
137 jkl
138 !! result
139 <p>asdf jkl
140 </p>
141 !! end
142
143 !! test
144 comment test 3
145 !! disabled
146 !! input
147 asdf
148 <!-- comment 1 -->
149 <!-- comment 2 -->
150 jkl
151 !! result
152 <p>asdf jkl
153 </p>
154 !! end
155
156 !! test
157 comment test 4
158 !! input
159 asdf<!-- comment 1 -->jkl
160 !! result
161 <p>asdfjkl
162 </p>
163 !! end
164
165 ###
166 ### External links
167 ###
168 !! test
169 External links 1-4
170 !! input
171 Non-bracketed: http://example.com
172
173 Numbered: [http://example.com]
174
175 Specified text: [http://example.com link]
176
177 Trail (not sure if this is meant to work): [http://example.com link]s
178 !! result
179 <p>Non-bracketed: <a href="http://example.com" class='external' title="http://example.com">http://example.com</a>
180 </p><p>Numbered: <a href="http://example.com" class='external' title="http://example.com">[1]</a><span class='urlexpansion'> (<i>http://example.com</i>)</span>
181 </p><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>
182 </p><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>
183 </p>
184 !! end
185
186 # todo: enable these
187 !! test
188 !! disabled
189 External links
190 !! input
191 Unrecognised characters (for no good reason): http://example.com/1$2345 [http://example.com/1$2345]
192 External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
193 External image from https: https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
194 Link to non-http image, no img tag: ftp://example.com/test.jpg
195 Terminating separator: http://example.com/thing,
196 Intervening separator: http://example.com/1,2,3
197 Old bug with URL in query: [http://example.com/thing?url=http://example.com link]
198 And again with mixed protocols: [ftp://example.com?url=http://example.com link]
199 URL in text: [http://example.com http://example.com]
200 ja-style clickable images: [http://example.com http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png]
201 Old &amp; use: http://x&y
202 Escaping without &amp;: http://x&y
203 !! result
204 <p>Unrecognised characters (for no good reason): <a href="http://example.com/1" class='external'>http://example.com/1</a>$2345
205 [http://example.com/1$2345]</p>
206 <p>External image: <img src="http://example.com/test.jpg" alt="test.jpg" /></p>
207 <p>External image from https: <img src="https://example.com/test.jpg" alt="test.jpg" /></p>
208 <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>
209 <p>Terminating separator: <a href="http://example.com/thing" class='external'>http://example.com/thing</a>,</p>
210 <p>Intervening separator: <a href="http://example.com/1,2,3" class='external'>http://example.com/1,2,3</a></p>
211 <p>Old bug with URL in query: [http://example.com/thing?url=<a href="http://example.com" class='external'>http://example.com</a>
212 link]</p>
213 <p>And again with mixed protocols: [ftp://example.com?url=<a href="http://example.com" class='external'>http://example.com</a>
214 link]</p>
215 <p>URL in text: <a href='http://example.com' class='external'></a><a href="http://example.com" class=
216 'external'>http://example.com</a> <span class='urlexpansion'>(<i>http://example.com</i>)</span></p>
217 <p>ja-style clickable images: <a href='http://example.com' class='external'><img src=
218 "http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png" /></a> <span class=
219 'urlexpansion'>(<i>http://example.com</i>)</span></p>
220 <p>Old &amp; use: <a href="http://x&y" class='external'>http://x&y</a></p>
221 <p>Escaping without &amp;: <a href="http://x&y" class='external'>http://x&y</a></p>
222 !! end
223
224 ###
225 ### Quotes
226 ###
227
228 !! test
229 Quotes
230 !! input
231 Normal text. '''Bold text.''' Normal text. ''Italic text.''
232
233 '''Bold text..
234
235 ..spanning two paragraphs (should not work).'''
236
237 Normal text. '''''Bold italic text.''''' Normal text.
238
239 '''''Bold italic text '''with bold deactivated''' in between.'''''
240
241 '''''Bold italic text ''with italic deactivated'' in between.'''''
242
243 '''Bold tag left open
244
245 ''Italic tag left open
246
247 Normal text.
248
249 <!-- Unmatching number of opening, closing tags: -->
250 '''This year''''s election ''should'' beat '''last year''''s.
251
252 ''Tom'''s car is bigger than ''Susan'''s.
253 !! result
254 <p>Normal text. <b>Bold text.</b> Normal text. <i>Italic text.</i>
255 </p><p><b>Bold text..</b>
256 </p><p>..spanning two paragraphs (should not work).
257 </p><p>Normal text. <i><b>Bold italic text.</b></i> Normal text.
258 </p><p><i><b>Bold italic text</b> with bold deactivated <b>in between.</b></i>
259 </p><p><b><i>Bold italic text</i> with italic deactivated <i>in between.</i></b>
260 </p><p><b>Bold tag left open</b>
261 </p><p><i>Italic tag left open</i>
262 </p><p>Normal text.
263 </p><p><b>This year</b>'s election <i>should</i> beat <b>last year</b>'s.
264 </p><p><i>Tom<b>s car is bigger than</b></i> <b>Susan</b>s.
265 </p>
266 !! end
267
268 ###
269 ### Internal links
270 ###
271 !! test
272 Internal links
273 !! input
274 Plain link, capitalized: [[Main Page]]
275 !! result
276 <p>Plain link, capitalized: <a href="/wiki/Main_Page" title ="Main Page">Main Page</a>
277 !! end
278
279 !! test
280 Internal links 2
281 !! disabled
282 !!input
283 Plain link, uncapitalized: [[main Page]]
284
285 Piped link: [[Main Page|The Main Page]]
286
287 Broken link: [[Zigzagzogzagzig]]
288
289 Link with prefix: XXX[[main Page]], XXX[[Main Page]]
290
291 Link with suffix: [[Main Page]]XXX
292
293 Link with 3 brackets: [[[main page]]]
294
295 Piped link with 3 brackets: [[[main page|the main page]]]
296
297 Link to namespaces: [[Talk:Parser testing]], [[Meta:Disclaimers]]
298
299 Piped link to namespace: [[Meta:Disclaimers|The disclaimers]]
300
301 Link to category: [[:Category:MediaWiki User's Guide]]
302
303 Link to image page: [[:Image:Ncwikicol.png]]
304
305 Plain link to URL: [[http://www.example.org]]
306
307 Piped link to URL: [[http://www.example.org|an example URL]]
308 !! result
309 </p><p>Plain link, uncapitalized: <a href="/wiki/Main_Page">main Page</a>
310 </p><p>Piped link: <a href="/wiki/Main_Page">The Main Page</a></p>
311 <p>Broken link: <a href="/w/wiki.phtml?title=Zigzagzogzagzig&action=edit" class="new">Zigzagzogzagzig</a></p>
312 <p>Link with prefix: xxx<a href="/wiki/Main_Page">main Page</a>, xxx<a href="/wiki/Main_Page">Main Page</a>, Xxx<a href=
313 "/wiki/Main_Page">main Page</a> XXX<a href="/wiki/Main_Page">main Page</a>, XXX<a href="/wiki/Main_Page">Main Page</a></p>
314 <p>Link with suffix: <a href="/wiki/Main_Page">Main Pagexxx</a>, <a href="/wiki/Main_Page">Main Page</a>XXX</p>
315 <p>Link with 3 brackets: [[[main page]]]</p>
316 <p>Piped link with 3 brackets: [[[main page|the main page]]]</p>
317 <p>Link to namespaces: <a href="/w/wiki.phtml?title=Talk:Parser_testing&action=edit" class="new">Talk:Parser testing</a>,
318 <a href="/w/wiki.phtml?title=Meta:Disclaimers&action=edit" class="new">Meta:Disclaimers</a></p>
319 <p>Piped link to namespace: <a href="/w/wiki.phtml?title=Meta:Disclaimers&action=edit" class="new">The disclaimers</a></p>
320 <p>Link to category: <a href="/wiki/Category:MediaWiki_User%27s_Guide">Category:MediaWiki User's Guide</a></p>
321 <p>Link to image page: <a href="/wiki/Image:Ncwikicol.png">Image:Ncwikicol.png</a></p>
322 <p>Plain link to URL: [<a href='http://www.example.org' class='external'>[1]</a> <span class=
323 'urlexpansion'>(<i>http://www.example.org</i>)</span>]</p>
324 <p>Piped link to URL: <a href="/w/wiki.phtml?title=Http://www.example.org&action=edit" class="new">an example URL</a></p>
325 !! end