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