7c74f6a012cd5f0d416691baa9dc4a659921e363
[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 !! test
265 Definition list with no space
266 !! input
267 ;name:Definition
268 !! result
269 <dl><dt>name</dt><dd>Definition
270 </dd></dl>
271
272 !!end
273
274 !! test
275 Definition list with URL link
276 !! input
277 ; http://example.com/ : definition
278 !! result
279 <dl><dt> <a href="http://example.com/" class='external'>http://example.com/</a></dt><dd> definition
280 </dd></dl>
281
282 !! end
283
284 ###
285 ### External links
286 ###
287 !! test
288 External links: non-bracketed
289 !! input
290 Non-bracketed: http://example.com
291 !! result
292 <p>Non-bracketed: <a href="http://example.com" class='external'>http://example.com</a>
293 </p>
294 !! end
295
296 !! test
297 External links: numbered
298 !! input
299 Numbered: [http://example.com]
300 !! result
301 <p>Numbered: <a href="http://example.com" class='external' title="http://example.com">[1]</a><span class='urlexpansion'> (<i>http://example.com</i>)</span>
302 </p>
303 !!end
304
305 !! test
306 External links: specified text
307 !! input
308 Specified text: [http://example.com link]
309 !! result
310 <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>
311 </p>
312 !!end
313
314 !! test
315 External links: trail
316 !! input
317 Trail (not sure if this is meant to work): [http://example.com link]s
318 !! result
319 <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>
320 </p>
321 !! end
322
323 !! test
324 External links: dollar sign in URL
325 !! input
326 http://example.com/1$2345
327 !! result
328 <p><a href="http://example.com/1$2345" class='external'>http://example.com/1$2345</a>
329 </p>
330 !! end
331
332 !! test
333 External links: dollar sign in URL (named)
334 !! input
335 [http://example.com/1$2345]
336 !! result
337 <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>
338 </p>
339 !!end
340
341 !! test
342 External image
343 !! input
344 External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
345 !! result
346 <p>External image: <img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png" />
347 </p>
348 !! end
349
350 !! test
351 External image from https
352 !! input
353 External image from https: https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
354 !! result
355 <p>External image from https: <img src="https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png" />
356 </p>
357 !! end
358
359 !! test
360 Link to non-http image, no img tag
361 !! input
362 Link to non-http image, no img tag: ftp://example.com/test.jpg
363 !! result
364 <p>Link to non-http image, no img tag: <a href="ftp://example.com/test.jpg" class='external'>ftp://example.com/test.jpg</a>
365 </p>
366 !! end
367
368 !! test
369 External links: terminating separator
370 !! input
371 Terminating separator: http://example.com/thing,
372 !! result
373 <p>Terminating separator: <a href="http://example.com/thing" class='external'>http://example.com/thing</a>,
374 </p>
375 !! end
376
377 !! test
378 External links: intervening separator
379 !! input
380 Intervening separator: http://example.com/1,2,3
381 !! result
382 <p>Intervening separator: <a href="http://example.com/1,2,3" class='external'>http://example.com/1,2,3</a>
383 </p>
384 !! end
385
386 !! test
387 External links: old bug with URL in query
388 !! input
389 Old bug with URL in query: [http://example.com/thing?url=http://example.com link]
390 !! result
391 <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>
392 </p>
393 !! end
394
395 !! test
396 External links: old URL-in-URL bug, mixed protocols
397 !! input
398 And again with mixed protocols: [ftp://example.com?url=http://example.com link]
399 !! result
400 <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>
401 </p>
402 !!end
403
404 !! test
405 External links: URL in text
406 !! input
407 URL in text: [http://example.com http://example.com]
408 !! result
409 <p>URL in text: <a href="http://example.com" class='external'>http://example.com</a>
410 </p>
411 !! end
412
413 !! test
414 External links: Clickable images
415 !! input
416 ja-style clickable images: [http://example.com http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png]
417 !! result
418 <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>
419 </p>
420 !!end
421
422 !! test
423 External links: raw ampersand
424 !! input
425 Old &amp; use: http://x&y
426 !! result
427 <p>Old &amp; use: <a href="http://x&amp;y" class='external'>http://x&amp;y</a>
428 </p>
429 !! end
430
431 !! test
432 External links: www.jpeg.org (bug 554)
433 !! input
434 http://www.jpeg.org
435 !!result
436 <p><a href="http://www.jpeg.org" class='external'>http://www.jpeg.org</a>
437 </p>
438 !! end
439
440 !! test
441 External links: URL within URL (original bug 2)
442 !! input
443 [http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp]
444 !! result
445 <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>
446 </p>
447 !! end
448
449 ###
450 ### Quotes
451 ###
452
453 !! test
454 Quotes
455 !! input
456 Normal text. '''Bold text.''' Normal text. ''Italic text.''
457
458 Normal text. '''''Bold italic text.''''' Normal text.
459 !!result
460 <p>Normal text. <b>Bold text.</b> Normal text. <i>Italic text.</i>
461 </p><p>Normal text. <i><b>Bold italic text.</b></i> Normal text.
462 </p>
463 !! end
464
465
466 !! test
467 Unclosed and unmatched quotes
468 !! input
469 '''''Bold italic text '''with bold deactivated''' in between.'''''
470
471 '''''Bold italic text ''with italic deactivated'' in between.'''''
472
473 '''Bold text..
474
475 ..spanning two paragraphs (should not work).'''
476
477 '''Bold tag left open
478
479 ''Italic tag left open
480
481 Normal text.
482
483 <!-- Unmatching number of opening, closing tags: -->
484 '''This year''''s election ''should'' beat '''last year''''s.
485
486 ''Tom'''s car is bigger than ''Susan'''s.
487 !! result
488 <p><i><b>Bold italic text </b>with bold deactivated<b> in between.</b></i>
489 </p><p><b><i>Bold italic text </i>with italic deactivated<i> in between.</i></b>
490 </p><p><b>Bold text..</b>
491 </p><p>..spanning two paragraphs (should not work).<b></b>
492 </p><p><b>Bold tag left open</b>
493 </p><p><i>Italic tag left open</i>
494 </p><p>Normal text.
495 </p><p><b>This year'</b>s election <i>should</i> beat <b>last year'</b>s.
496 </p><p><i>Tom<b>s car is bigger than </b></i><b>Susan</b>s.
497 </p>
498 !! end
499
500 ###
501 ### Tables
502 ###
503 ### content taken from http://meta.wikimedia.org/wiki/MediaWiki_User%27s_Guide:_Using_tables
504 ###
505 !! test
506 Simple table
507 !! input
508 {|
509 | 1 || 2
510 |-
511 | 3 || 4
512 |}
513 !! result
514 <table >
515 <tr >
516 <td> 1 </td><td> 2
517 </td></tr>
518 <tr >
519 <td> 3 </td><td> 4
520 </td></tr></table>
521
522 !! end
523
524 !! test
525 Multiplication table
526 !! input
527 {| border="1" cellpadding="2"
528 |+Multiplication table
529 |-
530 ! &times; !! 1 !! 2 !! 3
531 |-
532 ! 1
533 | 1 || 2 || 3
534 |-
535 ! 2
536 | 2 || 4 || 6
537 |-
538 ! 3
539 | 3 || 6 || 9
540 |-
541 ! 4
542 | 4 || 8 || 12
543 |-
544 ! 5
545 | 5 || 10 || 15
546 |}
547 !! result
548 <table border="1" cellpadding="2">
549 <caption>Multiplication table
550 </caption>
551 <tr >
552 <th> &times; </th><th> 1 </th><th> 2 </th><th> 3
553 </th></tr>
554 <tr >
555 <th> 1
556 </th><td> 1 </td><td> 2 </td><td> 3
557 </td></tr>
558 <tr >
559 <th> 2
560 </th><td> 2 </td><td> 4 </td><td> 6
561 </td></tr>
562 <tr >
563 <th> 3
564 </th><td> 3 </td><td> 6 </td><td> 9
565 </td></tr>
566 <tr >
567 <th> 4
568 </th><td> 4 </td><td> 8 </td><td> 12
569 </td></tr>
570 <tr >
571 <th> 5
572 </th><td> 5 </td><td> 10 </td><td> 15
573 </td></tr></table>
574
575 !! end
576
577 !! test
578 Table rowspan
579 !! input
580 {| align=right border=1
581 | Cell 1, row 1
582 |rowspan=2| Cell 2, row 1 (and 2)
583 | Cell 3, row 1
584 |-
585 | Cell 1, row 2
586 | Cell 3, row 2
587 |}
588 !! result
589 <table align=right border=1>
590 <tr >
591 <td> Cell 1, row 1
592 </td><td rowspan=2> Cell 2, row 1 (and 2)
593 </td><td> Cell 3, row 1
594 </td></tr>
595 <tr >
596 <td> Cell 1, row 2
597 </td><td> Cell 3, row 2
598 </td></tr></table>
599
600 !! end
601
602 !! test
603 Nested table
604 !! input
605 {| border=1
606 | &alpha;
607 |
608 {| bgcolor=#ABCDEF border=2
609 |nested
610 |-
611 |table
612 |}
613 |the original table again
614 |}
615 !! result
616 <table border=1>
617 <tr >
618 <td> &alpha;
619 </td><td>
620 <table bgcolor=#ABCDEF border=2>
621 <tr >
622 <td>nested
623 </td></tr>
624 <tr >
625 <td>table
626 </td></tr></table>
627 </td><td>the original table again
628 </td></tr></table>
629
630 !! end
631
632 ###
633 ### Internal links
634 ###
635 !! test
636 Plain link, capitalized
637 !! input
638 [[Main Page]]
639 !! result
640 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
641 </p>
642 !! end
643
644 !! test
645 Plain link, uncapitalized
646 !! input
647 [[main Page]]
648 !! result
649 <p><a href="/wiki/Main_Page" title="Main Page">main Page</a>
650 </p>
651 !! end
652
653 !! test
654 Piped link
655 !! input
656 [[Main Page|The Main Page]]
657 !! result
658 <p><a href="/wiki/Main_Page" title="Main Page">The Main Page</a>
659 </p>
660 !! end
661
662 !! test
663 Broken link
664 !! input
665 [[Zigzagzogzagzig]]
666 !! result
667 <p><a href="/index.php?title=Zigzagzogzagzig&amp;action=edit" class="new" title="Zigzagzogzagzig">Zigzagzogzagzig</a>
668 </p>
669 !! end
670
671 !! test
672 Link with prefix
673 !! input
674 xxx[[main Page]], xxx[[Main Page]], Xxx[[main Page]] XXX[[main Page]], XXX[[Main Page]]
675 !! result
676 <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>
677 </p>
678 !! end
679
680 !! test
681 Link with suffix
682 !! input
683 [[Main Page]]xxx, [[Main Page]]XXX
684 !! result
685 <p><a href="/wiki/Main_Page" title="Main Page">Main Pagexxx</a>, <a href="/wiki/Main_Page" title="Main Page">Main Page</a>XXX
686 </p>
687 !! end
688
689 !! test
690 Link with 3 brackets
691 !! input
692 [[[main page]]]
693 !! result
694 <p>[[[main page]]]
695 </p>
696 !! end
697
698 !! test
699 Piped link with 3 brackets
700 !! input
701 [[[main page|the main page]]]
702 !! result
703 <p>[[[main page|the main page]]]
704 </p>
705 !! end
706
707 !! test
708 Link to namespaces
709 !! input
710 [[Talk:Parser testing]], [[Meta:Disclaimers]]
711 !! result
712 <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>
713 </p>
714 !! end
715
716 !! test
717 Piped link to namespace
718 !! input
719 [[Meta:Disclaimers|The disclaimers]]
720 !! result
721 <p><a href="/index.php?title=Meta:Disclaimers&amp;action=edit" class="new" title="Meta:Disclaimers">The disclaimers</a>
722 </p>
723 !! end
724
725 !! test
726 Link containing }
727 !! input
728 [[Usually caused by a typo (oops}]]
729 !! result
730 <p>[[Usually caused by a typo (oops}]]
731 </p>
732 !! end
733
734
735 !! test
736 Plain link to URL
737 !! input
738 [[http://www.example.org]]
739 !! result
740 <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>]
741 </p>
742 !! end
743
744 # I'm fairly sure the expected result here is wrong.
745 # We want these to be URL links, not pseudo-pages with URLs for titles....
746 # However the current output is also pretty screwy.
747 #
748 # ----
749 # I'm changing it to match the current output--it arguably makes more
750 # sense in the light of the test above. Old expected result was:
751 #<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>
752 #</p>
753 # But I think this test is bordering on "garbage in, garbage out" anyway.
754 # -- wtm
755 !! test
756 Piped link to URL
757 !! input
758 Piped link to URL: [[http://www.example.org|an example URL]]
759 !! result
760 <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>]
761 </p>
762 !! end
763
764 !! test
765 BUG 2: [[page|http://url/]] should link to page, not http://url/
766 !! input
767 [[Main Page|http://url/]]
768 !! result
769 <p><a href="/wiki/Main_Page" title="Main Page">http://url/</a>
770 </p>
771 !! end
772
773
774 ###
775 ### Interwiki links
776 ###
777
778 !! test
779 Inline interwiki link
780 !! input
781 [[MeatBall:SoftSecurity]]
782 !! result
783 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity" class='extiw'>MeatBall:SoftSecurity</a>
784 </p>
785 !! end
786
787 ###
788 ### Images
789 ###
790
791 !! test
792 [[
793
794
795 ##
796 ## XHTML tidiness
797 ###
798
799 !! test
800 <br> to <br />
801 !! input
802 1<br>2<br />3
803 !! result
804 <p>1<br />2<br />3
805 </p>
806 !! end
807
808 ###
809 ### Block-level elements
810 ###
811 !! test
812 Common list
813 !! input
814 *Common list
815 * item 2
816 *item 3
817 !! result
818 <ul><li>Common list
819 </li><li> item 2
820 </li><li>item 3
821 </li></ul>
822
823 !! end
824
825 !! test
826 Numbered list
827 !! input
828 #Numbered list
829 #item 2
830 # item 3
831 !! result
832 <ol><li>Numbered list
833 </li><li>item 2
834 </li><li> item 3
835 </li></ol>
836
837 !! end
838
839 !! test
840 Mixed list
841 !! input
842 *Mixed list
843 *# with numbers
844 ** and bullets
845 *# and numbers
846 *bullets again
847 **bullet level 2
848 ***bullet level 3
849 ***#Number on level 4
850 **bullet level 2
851 **#Number on level 3
852 **#Number on level 3
853 *#number level 2
854 *Level 1
855 !! result
856 <ul><li>Mixed list
857 <ol><li> with numbers
858 </li></ol>
859 <ul><li> and bullets
860 </li></ul>
861 <ol><li> and numbers
862 </li></ol>
863 </li><li>bullets again
864 <ul><li>bullet level 2
865 <ul><li>bullet level 3
866 <ol><li>Number on level 4
867 </li></ol>
868 </li></ul>
869 </li><li>bullet level 2
870 <ol><li>Number on level 3
871 </li><li>Number on level 3
872 </li></ol>
873 </li></ul>
874 <ol><li>number level 2
875 </li></ol>
876 </li><li>Level 1
877 </li></ul>
878
879 !! end
880
881 ###
882 ### Magic variables
883 ###
884 !! test
885 Magic variables
886 !! input
887 {{SITENAME}}
888 !! result
889 <p>MediaWiki
890 </p>
891 !! end
892
893 ###
894 ### Magic links
895 ###
896 !! test
897 Magic links: internal link to RFC
898 !! input
899 [[RFC 123]]
900 !! result
901 <p><a href="/index.php?title=RFC_123&amp;action=edit" class="new" title="RFC 123">RFC 123</a>
902 </p>
903 !! end
904
905 !! test
906 Magic links: ISBN
907 !! input
908 ISBN 0-306-40615-2
909 !! result
910 <p><a href="/index.php?title=Special:Booksources&amp;isbn=0306406152" class="internal">ISBN 0-306-40615-2</a>
911 </p>
912 !! end
913
914 ###
915 ### Templates
916 ####
917
918 !! test
919 Nonexistant template
920 !! input
921 {{thistemplatedoesnotexist}}
922 !! result
923 <p><a href="/index.php?title=Template:Thistemplatedoesnotexist&amp;action=edit" class="new" title="Template:Thistemplatedoesnotexist">Template:Thistemplatedoesnotexist</a>
924 </p>
925 !! end
926
927 !! article
928 Template:test
929 !! text
930 This is a test template
931 !! endarticle
932
933 !! test
934 Simple template
935 !! input
936 {{test}}
937 !! result
938 <p>This is a test template
939 </p>
940 !! end
941
942 !! test
943 Template with explicit namespace
944 !! input
945 {{Template:test}}
946 !! result
947 <p>This is a test template
948 </p>
949 !! end
950
951
952 !! article
953 Template:paramtest
954 !! text
955 This is a test template with parameter {{{param}}}
956 !! endarticle
957
958 !! test
959 Template parameter
960 !! input
961 {{paramtest|param=foo}}
962 !! result
963 <p>This is a test template with parameter foo
964 </p>
965 !! end
966
967 !! test
968 Magic variable as template parameter
969 !! input
970 {{paramtest|param={{SITENAME}}}}
971 !! result
972 <p>This is a test template with parameter MediaWiki
973 </p>
974 !! end
975
976 !! article
977 Template:linktest
978 !! text
979 [[{{{param}}}|link]]
980 !! endarticle
981
982 !! test
983 Template parameter as link source
984 !! input
985 {{linktest|param=Main Page}}
986 !! result
987 <p><a href="/wiki/Main_Page" title="Main Page">link</a>
988 </p>
989 !! end
990
991
992 !!article
993 Template:paramtest2
994 !! text
995 including another template, {{paramtest|param={{{arg}}}}}
996 !! endarticle
997
998 !! test
999 Template passing argument to another template
1000 !! input
1001 {{paramtest2|arg='hmm'}}
1002 !! result
1003 <p>including another template, This is a test template with parameter 'hmm'
1004 </p>
1005 !! end
1006
1007 !! article
1008 Template:Linktest2
1009 !! text
1010 Main Page
1011 !! endarticle
1012
1013 !! test
1014 Template as link source
1015 !! input
1016 [[{{linktest2}}]]
1017 !! result
1018 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
1019 </p>
1020 !! end
1021
1022
1023 !! article
1024 Template:loop1
1025 !! text
1026 {{loop2}}
1027 !! endarticle
1028
1029 !! article
1030 Template:loop2
1031 !! text
1032 {{loop1}}
1033 !! endarticle
1034
1035 !! test
1036 Template infinite loop
1037 !! input
1038 {{loop1}}
1039 !! result
1040 <p>{{loop2}}<!-- WARNING: template loop detected -->
1041 </p>
1042 !! end
1043
1044 !! test
1045 Template from main namespace
1046 !! input
1047 {{:Main Page}}
1048 !! result
1049 <p>blah blah
1050 </p>
1051 !! end
1052
1053 !! article
1054 Template:table
1055 !! text
1056 {|
1057 | 1 || 2
1058 |-
1059 | 3 || 4
1060 |}
1061 !! endarticle
1062
1063 !! test
1064 BUG 529: Template with table, not included at beginning of line
1065 !! input
1066 foo {{table}}
1067 !! result
1068 <p>foo
1069 </p>
1070 <table >
1071 <tr >
1072 <td> 1 </td><td> 2
1073 </td></tr>
1074 <tr >
1075 <td> 3 </td><td> 4
1076 </td></tr></table>
1077
1078 !! end
1079
1080 !! test
1081 BUG 523: Template shouldn't eat newline (or add an extra one before table)
1082 !! input
1083 foo
1084 {{table}}
1085 !! result
1086 <p>foo
1087 </p>
1088 <table >
1089 <tr >
1090 <td> 1 </td><td> 2
1091 </td></tr>
1092 <tr >
1093 <td> 3 </td><td> 4
1094 </td></tr></table>
1095
1096 !! end
1097
1098 !! test
1099 BUG 41: Template parameters shown as broken links
1100 !! input
1101 {{{parameter}}}
1102 !! result
1103 <p>{{{parameter}}}
1104 </p>
1105 !! end
1106
1107
1108 !! article
1109 Template:MSGNW test
1110 !! text
1111 ''None'' of '''this''' should be
1112 * interepreted
1113 but rather passed unmodified
1114 {{test}}
1115 !! endarticle
1116
1117 # hmm, fix this or just disable/deprecate msgnw?
1118 !! test
1119 msgnw keyword
1120 !! input
1121 {{msgnw:MSGNW test}}
1122 !! result
1123 <p>''None'' of '''this''' should be
1124 * interepreted
1125 but rather passed unmodified
1126 {{test}}
1127 </p>
1128 !! end
1129
1130 !! test
1131 int keyword
1132 !! input
1133 {{int:newmessages|lots of money}}
1134 !! result
1135 <p>You have lots of money.
1136 </p>
1137 !! end
1138
1139 ###
1140 ### Pre-save transform tests
1141 ###
1142 !! test
1143 pre-save transform: subst:
1144 !! options
1145 PST
1146 !! input
1147 {{subst:test}}
1148 !! result
1149 This is a test template
1150 !! end
1151
1152 !! test
1153 pre-save transform: normal template
1154 !! options
1155 PST
1156 !! input
1157 {{test}}
1158 !! result
1159 {{test}}
1160 !! end
1161
1162 !! test
1163 pre-save transform: nonexistant template
1164 !! options
1165 PST
1166 !! input
1167 {{thistemplatedoesnotexist}}
1168 !! result
1169 {{thistemplatedoesnotexist}}
1170 !! end
1171
1172
1173 !! test
1174 pre-save transform: subst magic variables
1175 !! options
1176 PST
1177 !! input
1178 {{subst:SITENAME}}
1179 !! result
1180 MediaWiki
1181 !! end
1182
1183 # This is bug 89, which I fixed. -- wtm
1184 !! test
1185 pre-save transform: subst: templates with parameters
1186 !! options
1187 pst
1188 !! input
1189 {{subst:paramtest|param="something else"}}
1190 !! result
1191 This is a test template with parameter "something else"
1192 !! end
1193
1194 ###
1195 ### Message transform tests
1196 ###
1197 !! test
1198 message transform: magic variables
1199 !! options
1200 msg
1201 !! input
1202 {{SITENAME}}
1203 !! result
1204 MediaWiki
1205 !! end
1206
1207 !! test
1208 message transform: should not transform wiki markup
1209 !! options
1210 msg
1211 !! input
1212 ''test''
1213 !! result
1214 ''test''
1215 !! end
1216
1217 ###
1218 ### Images
1219 ###
1220 !! test
1221 Simple image
1222 !! input
1223 [[Image: test]]
1224 !! result
1225 <p><a href="/wiki/Image:Test" class="image" title="Image: test"><img src="/images/0/0c/Test" alt="Image: test" /></a>
1226 </p>
1227 !! end
1228
1229 !! test
1230 Right-aligned image
1231 !! input
1232 [[Image:test|right]]
1233 !! result
1234 <div class="floatright"><span><a href="/wiki/Image:Test" class="image" title="right"><img src="/images/0/0c/Test" alt="right" /></a></span></div>
1235
1236 !! end
1237
1238 !! test
1239 Image with caption
1240 !! input
1241 [[Image:test|right|Caption text]]
1242 !! result
1243 <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>
1244
1245 !! end
1246
1247 !! test
1248 Image with frame and link
1249 !! input
1250 [[Image:Foobar.jpg|frame|left|This is a test image [[Main Page]]]]
1251 !! result
1252 <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>
1253
1254 !! end
1255
1256 !! test
1257 Link to image page
1258 !! input
1259 [[:Image:test]]
1260 !! result
1261 <p><a href="/wiki/Image:Test" title="Image:Test">Image:test</a>
1262 </p>
1263 !! end
1264
1265 ###
1266 ### Subpages
1267 ###
1268 !! article
1269 Subpage test/subpage
1270 !! text
1271 foo
1272 !! endarticle
1273
1274 !! test
1275 Subpage link
1276 !! options
1277 subpage title=[[Subpage test]]
1278 !! input
1279 [[/subpage]]
1280 !! result
1281 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a>
1282 </p>
1283 !! end
1284
1285 !! test
1286 Subpage noslash link
1287 !! options
1288 subpage title=[[Subpage test]]
1289 !!input
1290 [[/subpage/]]
1291 !! result
1292 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">subpage</a>
1293 </p>
1294 !! end
1295
1296 !! test
1297 Disabled subpages
1298 !! input
1299 [[/subpage]]
1300 !! result
1301 <p><a href="/index.php?title=/subpage&amp;action=edit" class="new" title="/subpage">/subpage</a>
1302 </p>
1303 !! end
1304
1305 !! test
1306 BUG 561: {{/Subpage}}
1307 !! options
1308 subpage title=[[Page]]
1309 !! input
1310 {{/Subpage}}
1311 !! result
1312 <p><a href="/index.php?title=Page/Subpage&amp;action=edit" class="new" title="Page/Subpage">Page/Subpage</a>
1313 </p>
1314 !! end
1315
1316 ###
1317 ### Categories
1318 ###
1319 !! article
1320 Category:MediaWiki User's Guide
1321 !! text
1322 blah
1323 !! endarticle
1324
1325 !! test
1326 Link to category
1327 !! input
1328 [[:Category:MediaWiki User's Guide]]
1329 !! result
1330 <p><a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User's Guide">Category:MediaWiki User's Guide</a>
1331 </p>
1332 !! end
1333
1334 !! test
1335 Simple category
1336 !! options
1337 cat
1338 !! input
1339 [[Category: MediaWiki User's Guide]]
1340 !! result
1341 <a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User's Guide">MediaWiki User's Guide</a>
1342 !! end
1343
1344 ###
1345 ### Inter-language links
1346 ###
1347 !! test
1348 Inter-language links
1349 !! options
1350 ill
1351 !! input
1352 [[es:Alimento]]
1353 [[fr:Nourriture]]
1354 [[zh:&#39135;&#21697;]]
1355 !! result
1356 es:Alimento fr:Nourriture zh:食品
1357 !! end
1358
1359 ###
1360 ### Sections
1361 ###
1362 !! test
1363 Basic section headings
1364 !! input
1365 == Headline 1 ==
1366 Some text
1367
1368 ==Headline 2==
1369 More
1370 ===Smaller headline===
1371 Blah blah
1372 !! result
1373 <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>
1374 <p>Some text
1375 </p>
1376 <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>
1377 <p>More
1378 </p>
1379 <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>
1380 <p>Blah blah
1381 </p>
1382 !! end
1383
1384 !! test
1385 Section headings with TOC
1386 !! input
1387 == Headline 1 ==
1388 === Subheadline 1 ===
1389 ===== Skipping a level =====
1390 ====== Skipping a level ======
1391
1392 == Headline 2 ==
1393 Some text
1394 ===Another headline===
1395 !! result
1396 <table border="0" id="toc"><tr id="toctitle"><td align="center">
1397 <b>Table of contents</b> <script type="text/javascript">showTocToggle("show","hide")</script></td></tr><tr id="tocinside"><td>
1398 <div class="tocline"><a href="#Headline_1">1 Headline 1</a><br /></div>
1399 <div class="tocindent">
1400 <p><a href="#Subheadline_1">1.1 Subheadline 1</a><br />
1401 </p>
1402 <div class="tocindent">
1403 <div class="tocindent">
1404 <p><a href="#Skipping_a_level">1.1.1 Skipping a level</a><br />
1405 </p>
1406 <div class="tocindent">
1407 <p><a href="#Skipping_a_level_2">1.1.1.1 Skipping a level</a><br />
1408 </p>
1409 </div>
1410 </div>
1411 </div>
1412 </div>
1413 <div class="tocline"><a href="#Headline_2">2 Headline 2</a><br /></div>
1414 <div class="tocindent">
1415 <p><a href="#Another_headline">2.1 Another headline</a><br />
1416 </p>
1417 </div>
1418 </td></tr></table>
1419 <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>
1420 <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>
1421 <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>
1422 <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>
1423 <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>
1424 <p>Some text
1425 </p>
1426 <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>
1427
1428 !! end
1429
1430 !! test
1431 Resolving duplicate section names
1432 !! input
1433 == Foo bar ==
1434 ==Foo bar==
1435 !! result
1436 <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>
1437 <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>
1438
1439 !! end
1440
1441 !! article
1442 Template:sections
1443 !! text
1444 ===Section 1===
1445 ==Section 2==
1446 !! endarticle
1447
1448 !! test
1449 Template with sections, __NOTOC__
1450 !! options title=[[Parser test script]]
1451 !! input
1452 __NOTOC__
1453 ==Section 0==
1454 {{sections}}
1455 ==Section 4==
1456 !! result
1457 <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>
1458 <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>
1459 <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>
1460 <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>
1461
1462 !! end
1463
1464 !! test
1465 __NOEDITSECTION__ keyword
1466 !! input
1467 __NOEDITSECTION__
1468 ==Section 1==
1469 ==Section 2==
1470 !! result
1471 <a name="Section_1"></a><h2>Section 1</h2>
1472 <a name="Section_2"></a><h2>Section 2</h2>
1473
1474 !! end
1475
1476 TODO:
1477 more images
1478 more tables
1479 math
1480 character entities
1481 and much more
1482