Make user functions more generalised so other maintenance scripts can use them
[lhc/web/wiklou.git] / maintenance / parserTests.txt
1 # MediaWiki Parser test cases
2 # Some taken from http://meta.wikimedia.org/wiki/Parser_testing
3 # All (C) their respective authors and released under the GPL
4 #
5 # The syntax should be fairly self-explanatory.
6 #
7 # Currently supported test options:
8 # One of the following three:
9 #
10 # (default) generate HTML output
11 # pst apply pre-save transform
12 # msg apply message transform
13 #
14 # Plus any combination of these:
15 #
16 # cat add category links
17 # ill add inter-language links
18 # subpage enable subpages (disabled by default)
19 # noxml don't check for XML well formdness
20 # title=[[XXX]] run test using article title XXX
21 # disabled do not run test
22 #
23 # For testing purposes, temporary articles can created:
24 # !!article / NAMESPACE:TITLE / !!text / ARTICLE TEXT / !!endarticle
25 # where '/' denotes a newline.
26
27 # This is the standard article assumed to exist.
28 !! article
29 Main Page
30 !! text
31 blah blah
32 !! endarticle
33
34 ###
35 ### Basic tests
36 ###
37 !! test
38 Blank input
39 !! input
40 !! result
41 !! end
42
43
44 !! test
45 Simple paragraph
46 !! input
47 This is a simple paragraph.
48 !! result
49 <p>This is a simple paragraph.
50 </p>
51 !! end
52
53 !! test
54 Simple list
55 !! input
56 * Item 1
57 * Item 2
58 !! result
59 <ul><li> Item 1
60 </li><li> Item 2
61 </li></ul>
62
63 !! end
64
65 !! test
66 Italics and bold
67 !! input
68 * plain
69 * plain''italic''plain
70 * plain''italic''plain''italic''plain
71 * plain'''bold'''plain
72 * plain'''bold'''plain'''bold'''plain
73 * plain''italic''plain'''bold'''plain
74 * plain'''bold'''plain''italic''plain
75 * plain''italic'''bold-italic'''italic''plain
76 * plain'''bold''bold-italic''bold'''plain
77 * plain'''''bold-italic'''italic''plain
78 * plain'''''bold-italic''bold'''plain
79 * plain''italic'''bold-italic'''''plain
80 * plain'''bold''bold-italic'''''plain
81 * plain l'''italic''plain
82 !! result
83 <ul><li> plain
84 </li><li> plain<i>italic</i>plain
85 </li><li> plain<i>italic</i>plain<i>italic</i>plain
86 </li><li> plain<b>bold</b>plain
87 </li><li> plain<b>bold</b>plain<b>bold</b>plain
88 </li><li> plain<i>italic</i>plain<b>bold</b>plain
89 </li><li> plain<b>bold</b>plain<i>italic</i>plain
90 </li><li> plain<i>italic<b>bold-italic</b>italic</i>plain
91 </li><li> plain<b>bold<i>bold-italic</i>bold</b>plain
92 </li><li> plain<i><b>bold-italic</b>italic</i>plain
93 </li><li> plain<b><i>bold-italic</i>bold</b>plain
94 </li><li> plain<i>italic<b>bold-italic</b></i>plain
95 </li><li> plain<b>bold<i>bold-italic</i></b>plain
96 </li><li> plain l'<i>italic</i>plain
97 </li></ul>
98
99 !! end
100
101 ###
102 ### <nowiki> test cases
103 ###
104
105 !! test
106 <nowiki> unordered list
107 !! input
108 <nowiki>* This is not an unordered list item.</nowiki>
109 !! result
110 <p>* This is not an unordered list item.
111 </p>
112 !! end
113
114 !! test
115 <nowiki> spacing
116 !! input
117 <nowiki>Lorem ipsum dolor
118
119 sed abit.
120 sed nullum.
121
122 :and a colon
123 </nowiki>
124 !! result
125 <p>Lorem ipsum dolor
126
127 sed abit.
128 sed nullum.
129
130 :and a colon
131
132 </p>
133 !! end
134
135 !! test
136 nowiki 3
137 !! input
138 :There is not nowiki.
139 :There is <nowiki>nowiki</nowiki>.
140
141 #There is not nowiki.
142 #There is <nowiki>nowiki</nowiki>.
143
144 *There is not nowiki.
145 *There is <nowiki>nowiki</nowiki>.
146 !! result
147 <dl><dd>There is not nowiki.
148 </dd><dd>There is nowiki.
149 </dd></dl>
150 <ol><li>There is not nowiki.
151 </li><li>There is nowiki.
152 </li></ol>
153 <ul><li>There is not nowiki.
154 </li><li>There is nowiki.
155 </li></ul>
156
157 !! end
158
159 ###
160 ### Comments
161 ###
162 !! test
163 Comment test 1
164 !! input
165 <!-- comment 1 --> asdf
166 <!-- comment 2 -->
167 !! result
168 <pre>asdf
169 </pre>
170
171 !! end
172
173 !! test
174 Comment test 2
175 !! input
176 asdf
177 <!-- comment 1 -->
178 jkl
179 !! result
180 <p>asdf
181 jkl
182 </p>
183 !! end
184
185 !! test
186 Comment test 3
187 !! input
188 asdf
189 <!-- comment 1 -->
190 <!-- comment 2 -->
191 jkl
192 !! result
193 <p>asdf
194 jkl
195 </p>
196 !! end
197
198 !! test
199 Comment test 4
200 !! input
201 asdf<!-- comment 1 -->jkl
202 !! result
203 <p>asdfjkl
204 </p>
205 !! end
206
207 !! test
208 Comment spacing
209 !! input
210 a
211 <!-- foo --> b <!-- bar -->
212 c
213 !! result
214 <p>a
215 </p>
216 <pre> b
217 </pre>
218 <p>c
219 </p>
220 !! end
221
222 !! test
223 Comment whitespace
224 !! input
225 <!-- returns a single newline, not nothing, since the newline after > is not stripped -->
226 !! result
227
228 !! end
229
230 !! test
231 Comment semantics and delimiters
232 !! input
233 <!-- --><!----><!-----><!------>
234 !! result
235
236 !! end
237
238 !! test
239 Comment semantics and delimiters, redux
240 !! input
241 <!-- In SGML every "foo" here would actually show up in the text -- foo -- bar
242 -- foo -- funky huh? ... -->
243 !! result
244
245 !! end
246
247 !! test
248 Comment semantics and delimiters: directors cut
249 !! input
250 <!-- ... However we like to keep things simple and somewhat XML-ish so we eat
251 everything starting with < followed by !-- until the first -- and > we see,
252 that wouldn't be valid XML however, since in XML -- has to terminate a comment
253 -->-->
254 !! result
255 <p>-->
256 </p>
257 !! end
258
259 !! test
260 Comment semantics: nesting
261 !! input
262 <!--<!-- no, we're not going to do anything fancy here -->-->
263 !! result
264 <p>-->
265 </p>
266 !! end
267
268
269 ###
270 ### Preformatted text
271 ###
272 !! test
273 Preformatted text
274 !! input
275 This is some
276 Preformatted text
277 With ''italic''
278 And '''bold'''
279 And a [[Main Page|link]]
280 !! result
281 <pre>This is some
282 Preformatted text
283 With <i>italic</i>
284 And <b>bold</b>
285 And a <a href="/wiki/Main_Page" title="Main Page">link</a>
286 </pre>
287 !! end
288
289 ###
290 ### Definition lists
291 ###
292 !! test
293 Simple definition
294 !! input
295 ; name : Definition
296 !! result
297 <dl><dt> name&nbsp;</dt><dd> Definition
298 </dd></dl>
299
300 !! end
301
302 !! test
303 Simple definition
304 !! input
305 : Indented text
306 !! result
307 <dl><dd> Indented text
308 </dd></dl>
309
310 !! end
311
312 !! test
313 Definition list with no space
314 !! input
315 ;name:Definition
316 !! result
317 <dl><dt>name</dt><dd>Definition
318 </dd></dl>
319
320 !!end
321
322 !! test
323 Definition list with URL link
324 !! input
325 ; http://example.com/ : definition
326 !! result
327 <dl><dt> <a href="http://example.com/" class='external free' title="http://example.com/" rel="nofollow">http://example.com/</a>&nbsp;</dt><dd> definition
328 </dd></dl>
329
330 !! end
331
332 !! test
333 Definition list with bracketed URL link
334 !! input
335 ;[http://www.google.com/ Google]:Number one search engine
336 !! result
337 <dl><dt><a href="http://www.google.com/" class='external text' title="http://www.google.com/" rel="nofollow">Google</a></dt><dd>Number one search engine
338 </dd></dl>
339
340 !! end
341
342 !! test
343 Definition list with wikilink containing colon
344 !! input
345 ; [[Help:FAQ]]: The least-read page on Wikipedia
346 !! result
347 <dl><dt> <a href="/index.php?title=Help:FAQ&amp;action=edit" class="new" title="Help:FAQ">Help:FAQ</a></dt><dd> The least-read page on Wikipedia
348 </dd></dl>
349
350 !! end
351
352 # At Brion's and JeLuF's insistence... :)
353 !! test
354 Definition list with wikilink containing colon
355 !! input
356 ; news:alt.wikipedia.rox: This isn't even a real newsgroup!
357 !! result
358 <dl><dt> <a href="news:alt.wikipedia.rox" class='external free' title="news:alt.wikipedia.rox" rel="nofollow">news:alt.wikipedia.rox</a></dt><dd> This isn't even a real newsgroup!
359 </dd></dl>
360
361 !! end
362
363 !! test
364 Malformed definition list with colon
365 !! input
366 ; news:alt.wikipedia.rox -- don't crash or enter an infinite loop
367 !! result
368 <dl><dt> <a href="news:alt.wikipedia.rox" class='external free' title="news:alt.wikipedia.rox" rel="nofollow">news:alt.wikipedia.rox</a> -- don't crash or enter an infinite loop
369 </dt></dl>
370
371 !! end
372
373 !! test
374 Definition lists: colon in external link text
375 !! input
376 ; [http://www.wikipedia2.org/ Wikipedia : The Next Generation]: OK, I made that up
377 !! result
378 <dl><dt> <a href="http://www.wikipedia2.org/" class='external text' title="http://www.wikipedia2.org/" rel="nofollow">Wikipedia&nbsp;: The Next Generation</a></dt><dd> OK, I made that up
379 </dd></dl>
380
381 !! end
382
383
384 ###
385 ### External links
386 ###
387 !! test
388 External links: non-bracketed
389 !! input
390 Non-bracketed: http://example.com
391 !! result
392 <p>Non-bracketed: <a href="http://example.com" class='external free' title="http://example.com" rel="nofollow">http://example.com</a>
393 </p>
394 !! end
395
396 !! test
397 External links: numbered
398 !! input
399 Numbered: [http://example.com]
400 Numbered: [http://example.net]
401 Numbered: [http://example.org]
402 !! result
403 <p>Numbered: <a href="http://example.com" class='external autonumber' title="http://example.com" rel="nofollow">[1]</a>
404 Numbered: <a href="http://example.net" class='external autonumber' title="http://example.net" rel="nofollow">[2]</a>
405 Numbered: <a href="http://example.org" class='external autonumber' title="http://example.org" rel="nofollow">[3]</a>
406 </p>
407 !!end
408
409 !! test
410 External links: specified text
411 !! input
412 Specified text: [http://example.com link]
413 !! result
414 <p>Specified text: <a href="http://example.com" class='external text' title="http://example.com" rel="nofollow">link</a>
415 </p>
416 !!end
417
418 !! test
419 External links: trail
420 !! input
421 Linktrails should not work for external links: [http://example.com link]s
422 !! result
423 <p>Linktrails should not work for external links: <a href="http://example.com" class='external text' title="http://example.com" rel="nofollow">link</a>s
424 </p>
425 !! end
426
427 !! test
428 External links: dollar sign in URL
429 !! input
430 http://example.com/1$2345
431 !! result
432 <p><a href="http://example.com/1$2345" class='external free' title="http://example.com/1$2345" rel="nofollow">http://example.com/1$2345</a>
433 </p>
434 !! end
435
436 !! test
437 External links: dollar sign in URL (named)
438 !! input
439 [http://example.com/1$2345]
440 !! result
441 <p><a href="http://example.com/1$2345" class='external autonumber' title="http://example.com/1$2345" rel="nofollow">[1]</a>
442 </p>
443 !!end
444
445 !! test
446 External links: open square bracket forbidden in URL (bug 4377)
447 !! input
448 http://example.com/1[2345
449 !! result
450 <p><a href="http://example.com/1" class='external free' title="http://example.com/1" rel="nofollow">http://example.com/1</a>[2345
451 </p>
452 !! end
453
454 !! test
455 External links: open square bracket forbidden in URL (named) (bug 4377)
456 !! input
457 [http://example.com/1[2345]
458 !! result
459 <p><a href="http://example.com/1" class='external text' title="http://example.com/1" rel="nofollow">[2345</a>
460 </p>
461 !!end
462
463 !! test
464 External image
465 !! input
466 External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
467 !! result
468 <p>External image: <img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png" />
469 </p>
470 !! end
471
472 !! test
473 External image from https
474 !! input
475 External image from https: https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
476 !! result
477 <p>External image from https: <img src="https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png" />
478 </p>
479 !! end
480
481 !! test
482 Link to non-http image, no img tag
483 !! input
484 Link to non-http image, no img tag: ftp://example.com/test.jpg
485 !! result
486 <p>Link to non-http image, no img tag: <a href="ftp://example.com/test.jpg" class='external free' title="ftp://example.com/test.jpg" rel="nofollow">ftp://example.com/test.jpg</a>
487 </p>
488 !! end
489
490 !! test
491 External links: terminating separator
492 !! input
493 Terminating separator: http://example.com/thing,
494 !! result
495 <p>Terminating separator: <a href="http://example.com/thing" class='external free' title="http://example.com/thing" rel="nofollow">http://example.com/thing</a>,
496 </p>
497 !! end
498
499 !! test
500 External links: intervening separator
501 !! input
502 Intervening separator: http://example.com/1,2,3
503 !! result
504 <p>Intervening separator: <a href="http://example.com/1,2,3" class='external free' title="http://example.com/1,2,3" rel="nofollow">http://example.com/1,2,3</a>
505 </p>
506 !! end
507
508 !! test
509 External links: old bug with URL in query
510 !! input
511 Old bug with URL in query: [http://example.com/thing?url=http://example.com link]
512 !! result
513 <p>Old bug with URL in query: <a href="http://example.com/thing?url=http://example.com" class='external text' title="http://example.com/thing?url=http://example.com" rel="nofollow">link</a>
514 </p>
515 !! end
516
517 !! test
518 External links: old URL-in-URL bug, mixed protocols
519 !! input
520 And again with mixed protocols: [ftp://example.com?url=http://example.com link]
521 !! result
522 <p>And again with mixed protocols: <a href="ftp://example.com?url=http://example.com" class='external text' title="ftp://example.com?url=http://example.com" rel="nofollow">link</a>
523 </p>
524 !!end
525
526 !! test
527 External links: URL in text
528 !! input
529 URL in text: [http://example.com http://example.com]
530 !! result
531 <p>URL in text: <a href="http://example.com" class='external free' title="http://example.com" rel="nofollow">http://example.com</a>
532 </p>
533 !! end
534
535 !! test
536 External links: Clickable images
537 !! input
538 ja-style clickable images: [http://example.com http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png]
539 !! result
540 <p>ja-style clickable images: <a href="http://example.com" class='external text' title="http://example.com" rel="nofollow"><img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png" /></a>
541 </p>
542 !!end
543
544 !! test
545 External links: raw ampersand
546 !! input
547 Old &amp; use: http://x&y
548 !! result
549 <p>Old &amp; use: <a href="http://x&amp;y" class='external free' title="http://x&amp;y" rel="nofollow">http://x&amp;y</a>
550 </p>
551 !! end
552
553 !! test
554 External links: encoded ampersand
555 !! input
556 Old &amp; use: http://x&amp;y
557 !! result
558 <p>Old &amp; use: <a href="http://x&amp;y" class='external free' title="http://x&amp;y" rel="nofollow">http://x&amp;y</a>
559 </p>
560 !! end
561
562 !! test
563 External links: [raw ampersand]
564 !! input
565 Old &amp; use: [http://x&y]
566 !! result
567 <p>Old &amp; use: <a href="http://x&amp;y" class='external autonumber' title="http://x&amp;y" rel="nofollow">[1]</a>
568 </p>
569 !! end
570
571 !! test
572 External links: [encoded ampersand]
573 !! input
574 Old &amp; use: [http://x&amp;y]
575 !! result
576 <p>Old &amp; use: <a href="http://x&amp;y" class='external autonumber' title="http://x&amp;y" rel="nofollow">[1]</a>
577 </p>
578 !! end
579
580 !! test
581 External links: www.jpeg.org (bug 554)
582 !! input
583 http://www.jpeg.org
584 !!result
585 <p><a href="http://www.jpeg.org" class='external free' title="http://www.jpeg.org" rel="nofollow">http://www.jpeg.org</a>
586 </p>
587 !! end
588
589 !! test
590 External links: URL within URL (original bug 2)
591 !! input
592 [http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp]
593 !! result
594 <p><a href="http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp" class='external autonumber' title="http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp" rel="nofollow">[1]</a>
595 </p>
596 !! end
597
598 !! test
599 BUG 361: URL inside bracketed URL
600 !! input
601 [http://www.example.com/foo http://www.example.com/bar]
602 !! result
603 <p><a href="http://www.example.com/foo" class='external text' title="http://www.example.com/foo" rel="nofollow">http://www.example.com/bar</a>
604 </p>
605 !! end
606
607 !! test
608 BUG 361: URL within URL, not bracketed
609 !! input
610 http://www.example.com/foo?=http://www.example.com/bar
611 !! result
612 <p><a href="http://www.example.com/foo?=http://www.example.com/bar" class='external free' title="http://www.example.com/foo?=http://www.example.com/bar" rel="nofollow">http://www.example.com/foo?=http://www.example.com/bar</a>
613 </p>
614 !! end
615
616 !! test
617 BUG 289: ">"-token in URL-tail
618 !! input
619 http://www.example.com/<hello>
620 !! result
621 <p><a href="http://www.example.com/" class='external free' title="http://www.example.com/" rel="nofollow">http://www.example.com/</a>&lt;hello&gt;
622 </p>
623 !!end
624
625 !! test
626 BUG 289: literal ">"-token in URL-tail
627 !! input
628 http://www.example.com/<b>html</b>
629 !! result
630 <p><a href="http://www.example.com/" class='external free' title="http://www.example.com/" rel="nofollow">http://www.example.com/</a><b>html</b>
631 </p>
632 !!end
633
634 !! test
635 BUG 289: ">"-token in bracketed URL
636 !! input
637 [http://www.example.com/<hello> stuff]
638 !! result
639 <p><a href="http://www.example.com/" class='external text' title="http://www.example.com/" rel="nofollow">&lt;hello&gt; stuff</a>
640 </p>
641 !!end
642
643 !! test
644 BUG 289: literal ">"-token in bracketed URL
645 !! input
646 [http://www.example.com/<b>html</b> stuff]
647 !! result
648 <p><a href="http://www.example.com/" class='external text' title="http://www.example.com/" rel="nofollow"><b>html</b> stuff</a>
649 </p>
650 !!end
651
652 !! test
653 BUG 289: literal double quote at end of URL
654 !! input
655 http://www.example.com/"hello"
656 !! result
657 <p><a href="http://www.example.com/" class='external free' title="http://www.example.com/" rel="nofollow">http://www.example.com/</a>"hello"
658 </p>
659 !!end
660
661 !! test
662 BUG 289: literal double quote in bracketed URL
663 !! input
664 [http://www.example.com/"hello" stuff]
665 !! result
666 <p><a href="http://www.example.com/" class='external text' title="http://www.example.com/" rel="nofollow">"hello" stuff</a>
667 </p>
668 !!end
669
670 !! test
671 External links: invalid character
672 !! input
673 [http://www.example.com