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