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