Set wgUploadPath for tests so we don't all have to be using Wil's filesystem layout. ;)
[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 # (default) generate HTML output
9 # pst apply pre-save transform
10 # msg apply message transform
11 # cat add category links
12 # ill add inter-language links
13 # subpage enable subpages (disabled by default)
14 # title=[[XXX]] run test using article title XXX
15 # disabled do not run test
16 #
17 # For testing purposes, temporary articles can created:
18 # !!article / NAMESPACE:TITLE / !!text / ARTICLE TEXT / !!endarticle
19 # where '/' denotes a newline.
20
21 # This is the standard article assumed to exist.
22 !! article
23 Main Page
24 !! text
25 blah blah
26 !! endarticle
27
28
29 ###
30 ### Basic tests
31 ###
32 !! test
33 Blank input
34 !! input
35 !! result
36 !! end
37
38 !! test
39 Simple paragraph
40 !! input
41 This is a simple paragraph.
42 !! result
43 <p>This is a simple paragraph.
44 </p>
45 !! end
46
47 !! test
48 Simple list
49 !! input
50 * Item 1
51 * Item 2
52 !! result
53 <ul><li> Item 1
54 </li><li> Item 2
55 </li></ul>
56
57 !! end
58
59 !! test
60 Italics and bold
61 !! input
62 * plain
63 * plain''italic''plain
64 * plain''italic''plain''italic''plain
65 * plain'''bold'''plain
66 * plain'''bold'''plain'''bold'''plain
67 * plain''italic''plain'''bold'''plain
68 * plain'''bold'''plain''italic''plain
69 * plain''italic'''bold-italic'''italic''plain
70 * plain'''bold''bold-italic''bold'''plain
71 * plain'''''bold-italic'''italic''plain
72 * plain'''''bold-italic''bold'''plain
73 * plain''italic'''bold-italic'''''plain
74 * plain'''bold''bold-italic'''''plain
75 * plain l'''italic''plain
76 !! result
77 <ul><li> plain
78 </li><li> plain<i>italic</i>plain
79 </li><li> plain<i>italic</i>plain<i>italic</i>plain
80 </li><li> plain<b>bold</b>plain
81 </li><li> plain<b>bold</b>plain<b>bold</b>plain
82 </li><li> plain<i>italic</i>plain<b>bold</b>plain
83 </li><li> plain<b>bold</b>plain<i>italic</i>plain
84 </li><li> plain<i>italic<b>bold-italic</b>italic</i>plain
85 </li><li> plain<b>bold<i>bold-italic</i>bold</b>plain
86 </li><li> plain<i><b>bold-italic</b>italic</i>plain
87 </li><li> plain<b><i>bold-italic</i>bold</b>plain
88 </li><li> plain<i>italic<b>bold-italic</b></i>plain
89 </li><li> plain<b>bold<i>bold-italic</i></b>plain
90 </li><li> plain l'<i>italic</i>plain
91 </li></ul>
92
93 !! end
94
95 ###
96 ### <nowiki> test cases
97 ###
98
99 !! test
100 <nowiki> unordered list
101 !! input
102 <nowiki>* This is not an unordered list item.</nowiki>
103 !! result
104 <p>* This is not an unordered list item.
105 </p>
106 !! end
107
108 !! test
109 <nowiki> spacing
110 !! input
111 <nowiki>Lorem ipsum dolor
112
113 sed abit.
114 sed nullum.
115
116 :and a colon
117 </nowiki>
118 !! result
119 <p>Lorem ipsum dolor
120
121 sed abit.
122 sed nullum.
123
124 :and a colon
125
126 </p>
127 !! end
128
129 !! test
130 nowiki 3
131 !! input
132 :There is not nowiki.
133 :There is <nowiki>nowiki</nowiki>.
134
135 #There is not nowiki.
136 #There is <nowiki>nowiki</nowiki>.
137
138 *There is not nowiki.
139 *There is <nowiki>nowiki</nowiki>.
140 !! result
141 <dl><dd>There is not nowiki.
142 </dd><dd>There is nowiki.
143 </dd></dl>
144 <ol><li>There is not nowiki.
145 </li><li>There is nowiki.
146 </li></ol>
147 <ul><li>There is not nowiki.
148 </li><li>There is nowiki.
149 </li></ul>
150
151 !! end
152
153 ###
154 ### comment test cases
155 ###
156 !! test
157 Comment test 1
158 !! input
159 <!-- comment 1 --> asdf
160 <!-- comment 2 -->
161 !! result
162 <pre>asdf
163 </pre>
164
165 !! end
166
167 !! test
168 Comment test 2
169 !! input
170 asdf
171 <!-- comment 1 -->
172 jkl
173 !! result
174 <p>asdf
175 jkl
176 </p>
177 !! end
178
179 !! test
180 Comment test 3
181 !! input
182 asdf
183 <!-- comment 1 -->
184 <!-- comment 2 -->
185 jkl
186 !! result
187 <p>asdf
188 jkl
189 </p>
190 !! end
191
192 !! test
193 Comment test 4
194 !! input
195 asdf<!-- comment 1 -->jkl
196 !! result
197 <p>asdfjkl
198 </p>
199 !! end
200
201 !! test
202 Comment spacing
203 !! input
204 a
205 <!-- foo --> b <!-- bar -->
206 c
207 !! result
208 <p>a
209 </p>
210 <pre> b
211 </pre>
212 <p>c
213 </p>
214 !! end
215
216 ###
217 ### Preformatted text
218 ###
219 !! test
220 Preformatted text
221 !! input
222 This is some
223 Preformatted text
224 With ''italic''
225 And '''bold'''
226 And a [[Main Page|link]]
227 !! result
228 <pre>This is some
229 Preformatted text
230 With <i>italic</i>
231 And <b>bold</b>
232 And a <a href="/wiki/Main_Page" title="Main Page">link</a>
233 </pre>
234 !! end
235
236 ###
237 ### Definition list
238 ###
239 !! test
240 Simple definition
241 !! input
242 ; name : Definition
243 !! result
244 <dl><dt> name&nbsp;</dt><dd> Definition
245 </dd></dl>
246
247 !! end
248
249 !! test
250 Simple definition
251 !! input
252 : Indented text
253 !! result
254 <dl><dd> Indented text
255 </dd></dl>
256
257 !! end
258
259 ###
260 ### External links
261 ###
262 !! test
263 External links: non-bracketed
264 !! input
265 Non-bracketed: http://example.com
266 !! result
267 <p>Non-bracketed: <a href="http://example.com" class='external'>http://example.com</a>
268 </p>
269 !! end
270
271 !! test
272 External links: numbered
273 !! input
274 Numbered: [http://example.com]
275 !! result
276 <p>Numbered: <a href="http://example.com" class='external' title="http://example.com">[1]</a><span class='urlexpansion'> (<i>http://example.com</i>)</span>
277 </p>
278 !!end
279
280 !! test
281 External links: specified text
282 !! input
283 Specified text: [http://example.com link]
284 !! result
285 <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>
286 </p>
287 !!end
288
289 !! test
290 External links: trail
291 !! input
292 Trail (not sure if this is meant to work): [http://example.com link]s
293 !! result
294 <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>
295 </p>
296 !! end
297
298 !! test
299 External links: dollar sign in URL
300 !! input
301 http://example.com/1$2345
302 !! result
303 <p><a href="http://example.com/1$2345" class='external'>http://example.com/1$2345</a>
304 </p>
305 !! end
306
307 !! test
308 External links: dollar sign in URL (named)
309 !! input
310 [http://example.com/1$2345]
311 !! result
312 <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>
313 </p>
314 !!end
315
316 !! test
317 External image
318 !! input
319 External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
320 !! result
321 <p>External image: <img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png" />
322 </p>
323 !! end
324
325 !! test
326 External image from https
327 !! input
328 External image from https: https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
329 !! result
330 <p>External image from https: <img src="https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png" />
331 </p>
332 !! end
333
334 !! test
335 Link to non-http image, no img tag
336 !! input
337 Link to non-http image, no img tag: ftp://example.com/test.jpg
338 !! result
339 <p>Link to non-http image, no img tag: <a href="ftp://example.com/test.jpg" class='external'>ftp://example.com/test.jpg</a>
340 </p>
341 !! end
342
343 !! test
344 External links: terminating separator
345 !! input
346 Terminating separator: http://example.com/thing,
347 !! result
348 <p>Terminating separator: <a href="http://example.com/thing" class='external'>http://example.com/thing</a>,
349 </p>
350 !! end
351
352 !! test
353 External links: intervening separator
354 !! input
355 Intervening separator: http://example.com/1,2,3
356 !! result
357 <p>Intervening separator: <a href="http://example.com/1,2,3" class='external'>http://example.com/1,2,3</a>
358 </p>
359 !! end
360
361 !! test
362 External links: old bug with URL in query
363 !! input
364 Old bug with URL in query: [http://example.com/thing?url=http://example.com link]
365 !! result
366 <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>
367 </p>
368 !! end
369
370 !! test
371 External links: old URL-in-URL bug, mixed protocols
372 !! input
373 And again with mixed protocols: [ftp://example.com?url=http://example.com link]
374 !! result
375 <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>
376 </p>
377 !!end
378
379 !! test
380 External links: URL in text
381 !! input
382 URL in text: [http://example.com http://example.com]
383 !! result
384 <p>URL in text: <a href="http://example.com" class='external'>http://example.com</a>
385 </p>
386 !! end
387
388 !! test
389 External links: Clickable images
390 !! input
391 ja-style clickable images: [http://example.com http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png]
392 !! result
393 <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>
394 </p>
395 !!end
396
397 !! test
398 External links: raw ampersand
399 !! input
400 Old &amp; use: http://x&y
401 !! result
402 <p>Old &amp; use: <a href="http://x&amp;y" class='external'>http://x&amp;y</a>
403 </p>
404 !! end
405
406 !! test
407 External links: www.jpeg.org (bug 554)
408 !! input
409 http://www.jpeg.org
410 !!result
411 <p><a href="http://www.jpeg.org" class='external'>http://www.jpeg.org</a>
412 </p>
413 !! end
414
415 !! test
416 External links: URL within URL (original bug 2)
417 !! input
418 [http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp]
419 !! result
420 <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>
421 </p>
422 !! end
423
424 ###
425 ### Quotes
426 ###
427
428 !! test
429 Quotes
430 !! input
431 Normal text. '''Bold text.''' Normal text. ''Italic text.''
432
433 Normal text. '''''Bold italic text.''''' Normal text.
434 !!result
435 <p>Normal text. <b>Bold text.</b> Normal text. <i>Italic text.</i>
436 </p><p>Normal text. <i><b>Bold italic text.</b></i> Normal text.
437 </p>
438 !! end
439
440
441 !! test
442 Unclosed and unmatched quotes
443 !! input
444 '''''Bold italic text '''with bold deactivated''' in between.'''''
445
446 '''''Bold italic text ''with italic deactivated'' in between.'''''
447
448 '''Bold text..
449
450 ..spanning two paragraphs (should not work).'''
451
452 '''Bold tag left open
453
454 ''Italic tag left open
455
456 Normal text.
457
458 <!-- Unmatching number of opening, closing tags: -->
459 '''This year''''s election ''should'' beat '''last year''''s.
460
461 ''Tom'''s car is bigger than ''Susan'''s.
462 !! result
463 <p><i><b>Bold italic text </b>with bold deactivated<b> in between.</b></i>
464 </p><p><b><i>Bold italic text </i>with italic deactivated<i> in between.</i></b>
465 </p><p><b>Bold text..</b>
466 </p><p>..spanning two paragraphs (should not work).<b></b>
467 </p><p><b>Bold tag left open</b>
468 </p><p><i>Italic tag left open</i>
469 </p><p>Normal text.
470 </p><p><b>This year'</b>s election <i>should</i> beat <b>last year'</b>s.
471 </p><p><i>Tom<b>s car is bigger than </b></i><b>Susan</b>s.
472 </p>
473 !! end
474
475 ###
476 ### Tables
477 ###
478 ### content taken from http://meta.wikimedia.org/wiki/MediaWiki_User%27s_Guide:_Using_tables
479 ###
480 !! test
481 Simple table
482 !! input
483 {|
484 | 1 || 2
485 |-
486 | 3 || 4
487 |}
488 !! result
489 <table >
490 <tr >
491 <td> 1 </td><td> 2
492 </td></tr>
493 <tr >
494 <td> 3 </td><td> 4
495 </td></tr></table>
496
497 !! end
498
499 !! test
500 Multiplication table
501 !! input
502 {| border="1" cellpadding="2"
503 |+Multiplication table
504 |-
505 ! &times; !! 1 !! 2 !! 3
506 |-
507 ! 1
508 | 1 || 2 || 3
509 |-
510 ! 2
511 | 2 || 4 || 6
512 |-
513 ! 3
514 | 3 || 6 || 9
515 |-
516 ! 4
517 | 4 || 8 || 12
518 |-
519 ! 5
520 | 5 || 10 || 15
521 |}
522 !! result
523 <table border="1" cellpadding="2">
524 <caption>Multiplication table
525 </caption>
526 <tr >
527 <th> &times; </th><th> 1 </th><th> 2 </th><th> 3
528 </th></tr>
529 <tr >
530 <th> 1
531 </th><td> 1 </td><td> 2 </td><td> 3
532 </td></tr>
533 <tr >
534 <th> 2
535 </th><td> 2 </td><td> 4 </td><td> 6
536 </td></tr>
537 <tr >
538 <th> 3
539 </th><td> 3 </td><td> 6 </td><td> 9
540 </td></tr>
541 <tr >
542 <th> 4
543 </th><td> 4 </td><td> 8 </td><td> 12
544 </td></tr>
545 <tr >
546 <th> 5
547 </th><td> 5 </td><td> 10 </td><td> 15
548 </td></tr></table>
549
550 !! end
551
552 !! test
553 Table rowspan
554 !! input
555 {| align=right border=1
556 | Cell 1, row 1
557 |rowspan=2| Cell 2, row 1 (and 2)
558 | Cell 3, row 1
559 |-
560 | Cell 1, row 2
561 | Cell 3, row 2
562 |}
563 !! result
564 <table align=right border=1>
565 <tr >
566 <td> Cell 1, row 1
567 </td><td rowspan=2> Cell 2, row 1 (and 2)
568 </td><td> Cell 3, row 1
569 </td></tr>
570 <tr >
571 <td> Cell 1, row 2
572 </td><td> Cell 3, row 2
573 </td></tr></table>
574
575 !! end
576
577 !! test
578 Nested table
579 !! input
580 {| border=1
581 | &alpha;
582 |
583 {| bgcolor=#ABCDEF border=2
584 |nested
585 |-
586 |table
587 |}
588 |the original table again
589 |}
590 !! result
591 <table border=1>
592 <tr >
593 <td> &alpha;
594 </td><td>
595 <table bgcolor=#ABCDEF border=2>
596 <tr >
597 <td>nested
598 </td></tr>
599 <tr >
600 <td>table
601 </td></tr></table>
602 </td><td>the original table again
603 </td></tr></table>
604
605 !! end
606
607 ###
608 ### Internal links
609 ###
610 !! test
611 Plain link, capitalized
612 !! input
613 [[Main Page]]
614 !! result
615 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
616 </p>
617 !! end
618
619 !! test
620 Plain link, uncapitalized
621 !! input
622 [[main Page]]
623 !! result
624 <p><a href="/wiki/Main_Page" title="Main Page">main Page</a>
625 </p>
626 !! end
627
628 !! test
629 Piped link
630 !! input
631 [[Main Page|The Main Page]]
632 !! result
633 <p><a href="/wiki/Main_Page" title="Main Page">The Main Page</a>
634 </p>
635 !! end
636
637 !! test
638 Broken link
639 !! input
640 [[Zigzagzogzagzig]]
641 !! result
642 <p><a href="/index.php?title=Zigzagzogzagzig&amp;action=edit" class="new" title="Zigzagzogzagzig">Zigzagzogzagzig</a>
643 </p>
644 !! end
645
646 !! test
647 Link with prefix
648 !! input
649 xxx[[main Page]], xxx[[Main Page]], Xxx[[main Page]] XXX[[main Page]], XXX[[Main Page]]
650 !! result
651 <p>xxx<a href="/wiki/Main_Page" title="Main Page">main Page</a>, xxx<a href="/wiki/Main_Page" title="Main Page">Main Page</a>, Xxx<a href="/wiki/Main_Page" title="Main Page">main Page</a> XXX<a href="/wiki/Main_Page" title="Main Page">main Page</a>, XXX<a href="/wiki/Main_Page" title="Main Page">Main Page</a>
652 </p>
653 !! end
654
655 !! test
656 Link with suffix
657 !! input
658 [[Main Page]]xxx, [[Main Page]]XXX
659 !! result
660 <p><a href="/wiki/Main_Page" title="Main Page">Main Pagexxx</a>, <a href="/wiki/Main_Page" title="Main Page">Main Page</a>XXX
661 </p>
662 !! end
663
664 !! test
665 Link with 3 brackets
666 !! input
667 [[[main page]]]
668 !! result
669 <p>[[[main page]]]
670 </p>
671 !! end
672
673 !! test
674 Piped link with 3 brackets
675 !! input
676 [[[main page|the main page]]]
677 !! result
678 <p>[[[main page|the main page]]]
679 </p>
680 !! end
681
682 !! test
683 Link to namespaces
684 !! input
685 [[Talk:Parser testing]], [[Meta:Disclaimers]]
686 !! result
687 <p><a href="/index.php?title=Talk:Parser_testing&amp;action=edit" class="new" title="Talk:Parser testing">Talk:Parser testing</a>, <a href="/index.php?title=Meta:Disclaimers&amp;action=edit" class="new" title="Meta:Disclaimers">Meta:Disclaimers</a>
688 </p>
689 !! end
690
691 !! test
692 Piped link to namespace
693 !! input
694 [[Meta:Disclaimers|The disclaimers]]
695 !! result
696 <p><a href="/index.php?title=Meta:Disclaimers&amp;action=edit" class="new" title="Meta:Disclaimers">The disclaimers</a>
697 </p>
698 !! end
699
700 !! test
701 Link containing }
702 !! input
703 [[Usually caused by a typo (oops}]]
704 !! result
705 <p>[[Usually caused by a typo (oops}]]
706 </p>
707 !! end
708
709
710 !! test
711 Plain link to URL
712 !! input
713 [[http://www.example.org]]
714 !! result
715 <p>[<a href="http://www.example.org" class='external' title="http://www.example.org">[1]</a><span class='urlexpansion'> (<i>http://www.example.org</i>)</span>]
716 </p>
717 !! end
718
719 # I'm fairly sure the expected result here is wrong.
720 # We want these to be URL links, not pseudo-pages with URLs for titles....
721 # However the current output is also pretty screwy.
722 #
723 # ----
724 # I'm changing it to match the current output--it arguably makes more
725 # sense in the light of the test above. Old expected result was:
726 #<p>Piped link to URL: <a href="/index.php?title=Http://www.example.org&amp;action=edit" class="new" title="Http://www.example.org">an example URL</a>
727 #</p>
728 # But I think this test is bordering on "garbage in, garbage out" anyway.
729 # -- wtm
730 !! test
731 Piped link to URL
732 !! input
733 Piped link to URL: [[http://www.example.org|an example URL]]
734 !! result
735 <p>Piped link to URL: [<a href="http://www.example.org|an" class='external' title="http://www.example.org|an">example URL</a><span class='urlexpansion'> (<i>http://www.example.org|an</i>)</span>]
736 </p>
737 !! end
738
739 !! test
740 BUG 2: [[page|http://url/]] should link to page, not http://url/
741 !! input
742 [[Main Page|http://url/]]
743 !! result
744 <p><a href="/wiki/Main_Page" title="Main Page">http://url/</a>
745 </p>
746 !! end
747
748
749 ###
750 ### Interwiki links
751 ###
752
753 !! test
754 Inline interwiki link
755 !! input
756 [[MeatBall:SoftSecurity]]
757 !! result
758 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity" class='extiw'>MeatBall:SoftSecurity</a>
759 </p>
760 !! end
761
762 ###
763 ### Images
764 ###
765
766 !! test
767 [[
768
769
770 ##
771 ## XHTML tidiness
772 ###
773
774 !! test
775 <br> to <br />
776 !! input
777 1<br>2<br />3
778 !! result
779 <p>1<br />2<br />3
780 </p>
781 !! end
782
783 ###
784 ### Block-level elements
785 ###
786 !! test
787 Common list
788 !! input
789 *Common list
790 * item 2
791 *item 3
792 !! result
793 <ul><li>Common list
794 </li><li> item 2
795 </li><li>item 3
796 </li></ul>
797
798 !! end
799
800 !! test
801 Numbered list
802 !! input
803 #Numbered list
804 #item 2
805 # item 3
806 !! result
807 <ol><li>Numbered list
808 </li><li>item 2
809 </li><li> item 3
810 </li></ol>
811
812 !! end
813
814 !! test
815 Mixed list
816 !! input
817 *Mixed list
818 *# with numbers
819 ** and bullets
820 *# and numbers
821 *bullets again
822 **bullet level 2
823 ***bullet level 3
824 ***#Number on level 4
825 **bullet level 2
826 **#Number on level 3
827 **#Number on level 3
828 *#number level 2
829 *Level 1
830 !! result
831 <ul><li>Mixed list
832 <ol><li> with numbers
833 </li></ol>
834 <ul><li> and bullets
835 </li></ul>
836 <ol><li> and numbers
837 </li></ol>
838 </li><li>bullets again
839 <ul><li>bullet level 2
840 <ul><li>bullet level 3
841 <ol><li>Number on level 4
842 </li></ol>
843 </li></ul>
844 </li><li>bullet level 2
845 <ol><li>Number on level 3
846 </li><li>Number on level 3
847 </li></ol>
848 </li></ul>
849 <ol><li>number level 2
850 </li></ol>
851 </li><li>Level 1
852 </li></ul>
853
854 !! end
855
856 ###
857 ### Magic variables
858 ###
859 !! test
860 Magic variables
861 !! input
862 {{SITENAME}}
863 !! result
864 <p>MediaWiki
865 </p>
866 !! end
867
868 ###
869 ### Magic links
870 ###
871 !! test
872 Magic links: internal link to RFC
873 !! input
874 [[RFC 123]]
875 !! result
876 <p><a href="/index.php?title=RFC_123&amp;action=edit" class="new" title="RFC 123">RFC 123</a>
877 </p>
878 !! end
879
880 !! test
881 Magic links: ISBN
882 !! input
883 ISBN 0-306-40615-2
884 !! result
885 <p><a href="/index.php?title=Special:Booksources&amp;isbn=0306406152" class="internal">ISBN 0-306-40615-2</a>
886 </p>
887 !! end
888
889 ###
890 ### Templates
891 ####
892
893 !! test
894 Nonexistant template
895 !! input
896 {{thistemplatedoesnotexist}}
897 !! result
898 <p><a href="/index.php?title=Template:Thistemplatedoesnotexist&amp;action=edit" class="new" title="Template:Thistemplatedoesnotexist">Template:Thistemplatedoesnotexist</a>
899 </p>
900 !! end
901
902 !! article
903 Template:test
904 !! text
905 This is a test template
906 !! endarticle
907
908 !! test
909 Simple template
910 !! input
911 {{test}}
912 !! result
913 <p>This is a test template
914 </p>
915 !! end
916
917 !! test
918 Template with explicit namespace
919 !! input
920 {{Template:test}}
921 !! result
922 <p>This is a test template
923 </p>
924 !! end
925
926
927 !! article
928 Template:paramtest
929 !! text
930 This is a test template with parameter {{{param}}}
931 !! endarticle
932
933 !! test
934 Template parameter
935 !! input
936 {{paramtest|param=foo}}
937 !! result
938 <p>This is a test template with parameter foo
939 </p>
940 !! end
941
942 !! test
943 Magic variable as template parameter
944 !! input
945 {{paramtest|param={{SITENAME}}}}
946 !! result
947 <p>This is a test template with parameter MediaWiki
948 </p>
949 !! end
950
951 !! article
952 Template:linktest
953 !! text
954 [[{{{param}}}|link]]
955 !! endarticle
956
957 !! test
958 Template parameter as link source
959 !! input
960 {{linktest|param=Main Page}}
961 !! result
962 <p><a href="/wiki/Main_Page" title="Main Page">link</a>
963 </p>
964 !! end
965
966
967 !!article
968 Template:paramtest2
969 !! text
970 including another template, {{paramtest|param={{{arg}}}}}
971 !! endarticle
972
973 !! test
974 Template passing argument to another template
975 !! input
976 {{paramtest2|arg='hmm'}}
977 !! result
978 <p>including another template, This is a test template with parameter 'hmm'
979 </p>
980 !! end
981
982 !! article
983 Template:Linktest2
984 !! text
985 Main Page
986 !! endarticle
987
988 !! test
989 Template as link source
990 !! input
991 [[{{linktest2}}]]
992 !! result
993 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
994 </p>
995 !! end
996
997
998 !! article
999 Template:loop1
1000 !! text
1001 {{loop2}}
1002 !! endarticle
1003
1004 !! article
1005 Template:loop2
1006 !! text
1007 {{loop1}}
1008 !! endarticle
1009
1010 !! test
1011 Template infinite loop
1012 !! input
1013 {{loop1}}
1014 !! result
1015 <p>{{loop2}}<!-- WARNING: template loop detected -->
1016 </p>
1017 !! end
1018
1019
1020 !! article
1021 Template:table
1022 !! text
1023 {|
1024 | 1 || 2
1025 |-
1026 | 3 || 4
1027 |}
1028 !! endarticle
1029
1030 !! test
1031 BUG 529: Template with table, not included at beginning of line
1032 !! input
1033 foo {{table}}
1034 !! result
1035 <p>foo
1036 </p>
1037 <table >
1038 <tr >
1039 <td> 1 </td><td> 2
1040 </td></tr>
1041 <tr >
1042 <td> 3 </td><td> 4
1043 </td></tr></table>
1044
1045 !! end
1046
1047 !! test
1048 BUG 523: Template shouldn't eat newline (or add an extra one before table)
1049 !! input
1050 foo
1051 {{table}}
1052 !! result
1053 <p>foo
1054 </p>
1055 <table >
1056 <tr >
1057 <td> 1 </td><td> 2
1058 </td></tr>
1059 <tr >
1060 <td> 3 </td><td> 4
1061 </td></tr></table>
1062
1063 !! end
1064
1065 !! test
1066 BUG 41: Template parameters shown as broken links
1067 !! input
1068 {{{parameter}}}
1069 !! result
1070 <p>{{{parameter}}}
1071 </p>
1072 !! end
1073
1074 ###
1075 ### Pre-save transform tests
1076 ###
1077 !! test
1078 pre-save transform: subst:
1079 !! options
1080 PST
1081 !! input
1082 {{subst:test}}
1083 !! result
1084 This is a test template
1085 !! end
1086
1087 !! test
1088 pre-save transform: normal template
1089 !! options
1090 PST
1091 !! input
1092 {{test}}
1093 !! result
1094 {{test}}
1095 !! end
1096
1097 !! test
1098 pre-save transform: nonexistant template
1099 !! options
1100 PST
1101 !! input
1102 {{thistemplatedoesnotexist}}
1103 !! result
1104 {{thistemplatedoesnotexist}}
1105 !! end
1106
1107
1108 !! test
1109 pre-save transform: subst magic variables
1110 !! options
1111 PST
1112 !! input
1113 {{subst:SITENAME}}
1114 !! result
1115 MediaWiki
1116 !! end
1117
1118 # This is bug 89, which I fixed. -- wtm
1119 !! test
1120 pre-save transform: subst: templates with parameters
1121 !! options
1122 pst
1123 !! input
1124 {{subst:paramtest|param="something else"}}
1125 !! result
1126 This is a test template with parameter "something else"
1127 !! end
1128
1129 ###
1130 ### Message transform tests
1131 ###
1132 !! test
1133 message transform: magic variables
1134 !! options
1135 msg
1136 !! input
1137 {{SITENAME}}
1138 !! result
1139 MediaWiki
1140 !! end
1141
1142 !! test
1143 message transform: should not transform wiki markup
1144 !! options
1145 msg
1146 !! input
1147 ''test''
1148 !! result
1149 ''test''
1150 !! end
1151
1152 ###
1153 ### Images
1154 ###
1155 !! test
1156 Simple image
1157 !! input
1158 [[Image: test]]
1159 !! result
1160 <p><a href="/wiki/Image:Test" class="image" title="Image: test"><img src="/images/0/0c/Test" alt="Image: test" /></a>
1161 </p>
1162 !! end
1163
1164 !! test
1165 Right-aligned image
1166 !! input
1167 [[Image:test|right]]
1168 !! result
1169 <div class="floatright"><span><a href="/wiki/Image:Test" class="image" title="right"><img src="/images/0/0c/Test" alt="right" /></a></span></div>
1170
1171 !! end
1172
1173 !! test
1174 Image with caption
1175 !! input
1176 [[Image:test|right|Caption text]]
1177 !! result
1178 <div class="floatright"><span><a href="/wiki/Image:Test" class="image" title="Caption text"><img src="/images/0/0c/Test" alt="Caption text" /></a></span></div>
1179
1180 !! end
1181
1182 !! test
1183 Image with frame and link
1184 !! input
1185 [[Image:Foobar.jpg|frame|left|This is a test image [[Main Page]]]]
1186 !! result
1187 <div class="thumb tleft"><div style="width:202px;"><a href="/wiki/Image:Foobar.jpg" class="internal" title="This is a test image "><img src="/images/3/3a/Foobar.jpg" alt="This is a test image " width="200" height="200" /></a> <div class="thumbcaption" >This is a test image <a href="/wiki/Main_Page" title="Main Page">Main Page</a></div></div></div>
1188
1189 !! end
1190
1191 !! test
1192 Link to image page
1193 !! input
1194 [[:Image:test]]
1195 !! result
1196 <p><a href="/wiki/Image:Test" title="Image:Test">Image:test</a>
1197 </p>
1198 !! end
1199
1200 ###
1201 ### Subpages
1202 ###
1203 !! article
1204 Subpage test/subpage
1205 !! text
1206 foo
1207 !! endarticle
1208
1209 !! test
1210 Subpage link
1211 !! options
1212 subpage title=[[Subpage test]]
1213 !! input
1214 [[/subpage]]
1215 !! result
1216 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a>
1217 </p>
1218 !! end
1219
1220 !! test
1221 Subpage noslash link
1222 !! options
1223 subpage title=[[Subpage test]]
1224 !!input
1225 [[/subpage/]]
1226 !! result
1227 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">subpage</a>
1228 </p>
1229 !! end
1230
1231 # bug 561: it would be nice if this linked to /subpage -- wtm
1232 !! test
1233 Disabled subpages
1234 !! input
1235 [[/subpage]]
1236 !! result
1237 <p><a href="/index.php?title=Subpage&amp;action=edit" class="new" title="Subpage">subpage</a>
1238 </p>
1239 !! end
1240
1241 !! test
1242 BUG 561: {{/Subpage}}
1243 !! options
1244 title=[[Page]]
1245 !! input
1246 {{/Subpage}}
1247 !! result
1248 <p><a href="/index.php?title=Page/Subpage&amp;action=edit" class="new" title="Page/Subpage">Page/Subpage</a>
1249 </p>
1250 !! end
1251
1252 ###
1253 ### Categories
1254 ###
1255 !! article
1256 Category:MediaWiki User's Guide
1257 !! text
1258 blah
1259 !! endarticle
1260
1261 !! test
1262 Link to category
1263 !! input
1264 [[:Category:MediaWiki User's Guide]]
1265 !! result
1266 <p><a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User's Guide">Category:MediaWiki User's Guide</a>
1267 </p>
1268 !! end
1269
1270 !! test
1271 Simple category
1272 !! options
1273 cat
1274 !! input
1275 [[Category: MediaWiki User's Guide]]
1276 !! result
1277 <a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User's Guide">MediaWiki User's Guide</a>
1278 !! end
1279
1280 ###
1281 ### Inter-language links
1282 ###
1283 !! test
1284 Inter-language links
1285 !! options
1286 ill
1287 !! input
1288 [[es:Alimento]]
1289 [[fr:Nourriture]]
1290 [[zh:&#39135;&#21697;]]
1291 !! result
1292 es:Alimento fr:Nourriture zh:食品
1293 !! end
1294
1295 ###
1296 ### Sections
1297 ###
1298 !! test
1299 Basic section headings
1300 !! input
1301 == Headline 1 ==
1302 Some text
1303
1304 ==Headline 2==
1305 More
1306 ===Smaller headline===
1307 Blah blah
1308 !! result
1309 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test_script&amp;action=edit&amp;section=1" title="Parser test script">edit</a>]</div><a name="Headline_1"></a><h2> Headline 1 </h2>
1310 <p>Some text
1311 </p>
1312 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test_script&amp;action=edit&amp;section=2" title="Parser test script">edit</a>]</div><a name="Headline_2"></a><h2>Headline 2</h2>
1313 <p>More
1314 </p>
1315 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test_script&amp;action=edit&amp;section=3" title="Parser test script">edit</a>]</div><a name="Smaller_headline"></a><h3>Smaller headline</h3>
1316 <p>Blah blah
1317 </p>
1318 !! end
1319
1320 !! test
1321 Section headings with TOC
1322 !! input
1323 == Headline 1 ==
1324 === Subheadline 1 ===
1325 ===== Skipping a level =====
1326 ====== Skipping a level ======
1327
1328 == Headline 2 ==
1329 Some text
1330 ===Another headline===
1331 !! result
1332 <table border="0" id="toc"><tr id="toctitle"><td align="center">
1333 <b>Table of contents</b> <script type="text/javascript">showTocToggle("show","hide")</script></td></tr><tr id="tocinside"><td>
1334 <div class="tocline"><a href="#Headline_1">1 Headline 1</a><br /></div>
1335 <div class="tocindent">
1336 <p><a href="#Subheadline_1">1.1 Subheadline 1</a><br />
1337 </p>
1338 <div class="tocindent">
1339 <div class="tocindent">
1340 <p><a href="#Skipping_a_level">1.1.1 Skipping a level</a><br />
1341 </p>
1342 <div class="tocindent">
1343 <p><a href="#Skipping_a_level_2">1.1.1.1 Skipping a level</a><br />
1344 </p>
1345 </div>
1346 </div>
1347 </div>
1348 </div>
1349 <div class="tocline"><a href="#Headline_2">2 Headline 2</a><br /></div>
1350 <div class="tocindent">
1351 <p><a href="#Another_headline">2.1 Another headline</a><br />
1352 </p>
1353 </div>
1354 </td></tr></table>
1355 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test_script&amp;action=edit&amp;section=1" title="Parser test script">edit</a>]</div><a name="Headline_1"></a><h2> Headline 1 </h2>
1356 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test_script&amp;action=edit&amp;section=2" title="Parser test script">edit</a>]</div><a name="Subheadline_1"></a><h3> Subheadline 1 </h3>
1357 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test_script&amp;action=edit&amp;section=3" title="Parser test script">edit</a>]</div><a name="Skipping_a_level"></a><h5> Skipping a level </h5>
1358 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test_script&amp;action=edit&amp;section=4" title="Parser test script">edit</a>]</div><a name="Skipping_a_level_2"></a><h6> Skipping a level </h6>
1359 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test_script&amp;action=edit&amp;section=5" title="Parser test script">edit</a>]</div><a name="Headline_2"></a><h2> Headline 2 </h2>
1360 <p>Some text
1361 </p>
1362 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test_script&amp;action=edit&amp;section=6" title="Parser test script">edit</a>]</div><a name="Another_headline"></a><h3>Another headline</h3>
1363
1364 !! end
1365
1366 !! test
1367 Resolving duplicate section names
1368 !! input
1369 == Foo bar ==
1370 ==Foo bar==
1371 !! result
1372 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test_script&amp;action=edit&amp;section=1" title="Parser test script">edit</a>]</div><a name="Foo_bar"></a><h2> Foo bar </h2>
1373 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test_script&amp;action=edit&amp;section=2" title="Parser test script">edit</a>]</div><a name="Foo_bar_2"></a><h2>Foo bar</h2>
1374
1375 !! end
1376
1377 TODO:
1378 more images
1379 more tables
1380 math
1381 character entities
1382 and much more
1383