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