When deleting images / old image revisions, don't fail out if the file
[mediawiki.git] / maintenance / parserTests.txt
blob00d1ef8900d7203f357874865082b2650bc54f07
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
5 # The syntax should be fairly self-explanatory.
7 # Currently supported test options:
8 #       One of the following three:
10 #       (default)       generate HTML output
11 #       pst             apply pre-save transform
12 #       msg             apply message transform
14 #       Plus any combination of these:
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
22 # For testing purposes, temporary articles can created:
23 # !!article / NAMESPACE:TITLE / !!text / ARTICLE TEXT / !!endarticle
24 # where '/' denotes a newline.
26 # This is the standard article assumed to exist.
27 !! article
28 Main Page
29 !! text
30 blah blah
31 !! endarticle
33 ###
34 ### Basic tests
35 ###
36 !! test
37 Blank input
38 !! input
39 !! result
40 !! end
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
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>
62 !! end
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>
98 !! end
101 ### <nowiki> test cases
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
113 !! test
114 <nowiki> spacing
115 !! input
116 <nowiki>Lorem ipsum dolor
118 sed abit.
119   sed nullum.
121 :and a colon
122 </nowiki>
123 !! result
124 <p>Lorem ipsum dolor
126 sed abit.
127   sed nullum.
129 :and a colon
131 </p>
132 !! end
134 !! test
135 nowiki 3
136 !! input
137 :There is not nowiki.
138 :There is <nowiki>nowiki</nowiki>.
140 #There is not nowiki.
141 #There is <nowiki>nowiki</nowiki>.
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>
156 !! end
159 ### comment test cases
161 !! test
162 Comment test 1
163 !! input
164 <!-- comment 1 --> asdf
165 <!-- comment 2 -->
166 !! result
167 <pre>asdf
168 </pre>
170 !! end
172 !! test
173 Comment test 2
174 !! input
175 asdf
176 <!-- comment 1 -->
178 !! result
179 <p>asdf
181 </p>
182 !! end
184 !! test
185 Comment test 3
186 !! input
187 asdf
188 <!-- comment 1 -->
189 <!-- comment 2 -->
191 !! result
192 <p>asdf
194 </p>
195 !! end
197 !! test
198 Comment test 4
199 !! input
200 asdf<!-- comment 1 -->jkl
201 !! result
202 <p>asdfjkl
203 </p>
204 !! end
206 !! test
207 Comment spacing
208 !! input
210  <!-- foo --> b <!-- bar -->
212 !! result
213 <p>a
214 </p>
215 <pre> b 
216 </pre>
217 <p>c
218 </p>
219 !! end
222 ### Preformatted text
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
242 ### Definition list
244 !! test
245 Simple definition
246 !! input
247 ; name : Definition
248 !! result
249 <dl><dt> name&nbsp;</dt><dd> Definition
250 </dd></dl>
252 !! end
254 !! test
255 Simple definition
256 !! input
257 : Indented text
258 !! result
259 <dl><dd> Indented text
260 </dd></dl>
262 !! end
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>
272 !!end
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>
282 !! end
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>
292 !! end
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="http://en.wikipedia.org/wiki/FAQ" class='extiw'>Wikipedia:FAQ</a></dt><dd> The least-read page on Wikipedia
300 </dd></dl>
302 !! end
304 # At Brion's and JeLuF's insistence... :)
305 !! test
306 Definition list with wikilink containing colon
307 !! input
308 ;  news:alt.wikipedia.rox: This isn't even a real newsgroup!
309 !! result
310 <dl><dt>  <a href="news:alt.wikipedia.rox" class='external'>news:alt.wikipedia.rox</a></dt><dd> This isn't even a real newsgroup!
311 </dd></dl>
313 !! end
315 !! test
316 Malformed definition list with colon
317 !! input
318 ;  news:alt.wikipedia.rox -- don't crash or enter an infinite loop
319 !! result
320 <dl><dt>  <a href="news:alt.wikipedia.rox" class='external'>news:alt.wikipedia.rox</a> -- don't crash or enter an infinite loop
321 </dt></dl>
323 !! end
325 !! test
326 Definition lists: colon in external link text
327 !! input
328 ; [http://www.wikipedia2.org/ Wikipedia : The Next Generation]: OK, I made that up
329 !! result
330 <dl><dt> <a href="http://www.wikipedia2.org/" class='external' title="http://www.wikipedia2.org/">Wikipedia&nbsp;: The Next Generation</a><span class='urlexpansion'> (<i>http://www.wikipedia2.org/</i>)</span></dt><dd> OK, I made that up
331 </dd></dl>
333 !! end
337 ### External links
339 !! test
340 External links: non-bracketed
341 !! input
342 Non-bracketed: http://example.com
343 !! result
344 <p>Non-bracketed: <a href="http://example.com" class='external'>http://example.com</a>
345 </p>
346 !! end
348 !! test
349 External links: numbered
350 !! input
351 Numbered: [http://example.com]
352 !! result
353 <p>Numbered: <a href="http://example.com" class='external' title="http://example.com">[1]</a><span class='urlexpansion'> (<i>http://example.com</i>)</span>
354 </p>
355 !!end
357 !! test
358 External links: specified text
359 !! input
360 Specified text: [http://example.com link]
361 !! result
362 <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>
363 </p>
364 !!end
366 !! test
367 External links: trail
368 !! input
369 Trail (not sure if this is meant to work): [http://example.com link]s
370 !! result
371 <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>
372 </p>
373 !! end
375 !! test
376 External links: dollar sign in URL
377 !! input
378 http://example.com/1$2345
379 !! result
380 <p><a href="http://example.com/1$2345" class='external'>http://example.com/1$2345</a>
381 </p>
382 !! end
384 !! test
385 External links: dollar sign in URL (named)
386 !! input
387 [http://example.com/1$2345]
388 !! result
389 <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>
390 </p>
391 !!end
393 !! test
394 External image
395 !! input
396 External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
397 !! result
398 <p>External image: <img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png" />
399 </p>
400 !! end
402 !! test
403 External image from https
404 !! input
405 External image from https: https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
406 !! result
407 <p>External image from https: <img src="https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png" />
408 </p>
409 !! end
411 !! test
412 Link to non-http image, no img tag
413 !! input
414 Link to non-http image, no img tag: ftp://example.com/test.jpg
415 !! result
416 <p>Link to non-http image, no img tag: <a href="ftp://example.com/test.jpg" class='external'>ftp://example.com/test.jpg</a>
417 </p>
418 !! end
420 !! test
421 External links: terminating separator
422 !! input
423 Terminating separator: http://example.com/thing,
424 !! result
425 <p>Terminating separator: <a href="http://example.com/thing" class='external'>http://example.com/thing</a>,
426 </p>
427 !! end
429 !! test
430 External links: intervening separator
431 !! input
432 Intervening separator: http://example.com/1,2,3
433 !! result
434 <p>Intervening separator: <a href="http://example.com/1,2,3" class='external'>http://example.com/1,2,3</a>
435 </p>
436 !! end
438 !! test
439 External links: old bug with URL in query
440 !! input
441 Old bug with URL in query: [http://example.com/thing?url=http://example.com link]
442 !! result
443 <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>
444 </p>
445 !! end
447 !! test
448 External links: old URL-in-URL bug, mixed protocols
449 !! input
450 And again with mixed protocols: [ftp://example.com?url=http://example.com link]
451 !! result
452 <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>
453 </p>
454 !!end
456 !! test
457 External links: URL in text
458 !! input
459 URL in text: [http://example.com http://example.com]
460 !! result
461 <p>URL in text: <a href="http://example.com" class='external'>http://example.com</a>
462 </p>
463 !! end
465 !! test
466 External links: Clickable images
467 !! input
468 ja-style clickable images: [http://example.com http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png]
469 !! result
470 <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>
471 </p>
472 !!end
474 !! test
475 External links: raw ampersand
476 !! input
477 Old &amp; use: http://x&y
478 !! result
479 <p>Old &amp; use: <a href="http://x&amp;y" class='external'>http://x&amp;y</a>
480 </p>
481 !! end
483 !! test
484 External links: www.jpeg.org (bug 554)
485 !! input
486 http://www.jpeg.org
487 !!result
488 <p><a href="http://www.jpeg.org" class='external'>http://www.jpeg.org</a>
489 </p>
490 !! end
492 !! test
493 External links: URL within URL (original bug 2)
494 !! input
495 [http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp]
496 !! result
497 <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>
498 </p>
499 !! end
501 !! test
502 BUG 361: URL inside bracketed URL
503 !! input
504 [http://www.example.com/foo http://www.example.com/bar]
505 !! result
506 <p><a href="http://www.example.com/foo" class='external' title="http://www.example.com/foo">http://www.example.com/bar</a><span class='urlexpansion'> (<i>http://www.example.com/foo</i>)</span>
507 </p>
508 !! end
510 !! test
511 BUG 289: ">"-token in URL-tail
512 !! input
513 http://www.example.com/<hello>
514 !! result
515 <p><a href="http://www.example.com/" class='external'>http://www.example.com/</a>&lt;hello&gt;
516 </p>
517 !!end
520 ### Quotes
523 !! test
524 Quotes
525 !! input
526 Normal text. '''Bold text.''' Normal text. ''Italic text.''
528 Normal text. '''''Bold italic text.''''' Normal text.
529 !!result
530 <p>Normal text. <b>Bold text.</b> Normal text. <i>Italic text.</i>
531 </p><p>Normal text. <i><b>Bold italic text.</b></i> Normal text.
532 </p>
533 !! end
536 !! test
537 Unclosed and unmatched quotes
538 !! input
539 '''''Bold italic text '''with bold deactivated''' in between.'''''
541 '''''Bold italic text ''with italic deactivated'' in between.'''''
543 '''Bold text..
545 ..spanning two paragraphs (should not work).'''
547 '''Bold tag left open
549 ''Italic tag left open
551 Normal text.
553 <!-- Unmatching number of opening, closing tags: -->
554 '''This year''''s election ''should'' beat '''last year''''s.
556 ''Tom'''s car is bigger than ''Susan'''s.
557 !! result
558 <p><i><b>Bold italic text </b>with bold deactivated<b> in between.</b></i>
559 </p><p><b><i>Bold italic text </i>with italic deactivated<i> in between.</i></b>
560 </p><p><b>Bold text..</b>
561 </p><p>..spanning two paragraphs (should not work).<b></b>
562 </p><p><b>Bold tag left open</b>
563 </p><p><i>Italic tag left open</i>
564 </p><p>Normal text.
565 </p><p><b>This year'</b>s election <i>should</i> beat <b>last year'</b>s.
566 </p><p><i>Tom<b>s car is bigger than </b></i><b>Susan</b>s.
567 </p>
568 !! end
571 ### Tables
573 ### content taken from http://meta.wikimedia.org/wiki/MediaWiki_User%27s_Guide:_Using_tables
575 !! test
576 Simple table
577 !! input
578 {| 
579 | 1 || 2
580 |- 
581 | 3 || 4
583 !! result
584 <table >
585 <tr >
586 <td> 1 </td><td> 2
587 </td></tr>
588 <tr >
589 <td> 3 </td><td> 4
590 </td></tr></table>
592 !! end
594 !! test
595 Multiplication table
596 !! input
597 {| border="1" cellpadding="2"
598 |+Multiplication table
600 ! &times; !! 1 !! 2 !! 3
602 ! 1
603 | 1 || 2 || 3
605 ! 2
606 | 2 || 4 || 6
608 ! 3
609 | 3 || 6 || 9
611 ! 4
612 | 4 || 8 || 12
614 ! 5
615 | 5 || 10 || 15
617 !! result
618 <table border="1" cellpadding="2">
619 <caption>Multiplication table
620 </caption>
621 <tr >
622 <th> &times; </th><th> 1 </th><th> 2 </th><th> 3
623 </th></tr>
624 <tr >
625 <th> 1
626 </th><td> 1 </td><td> 2 </td><td> 3
627 </td></tr>
628 <tr >
629 <th> 2
630 </th><td> 2 </td><td> 4 </td><td> 6
631 </td></tr>
632 <tr >
633 <th> 3
634 </th><td> 3 </td><td> 6 </td><td> 9
635 </td></tr>
636 <tr >
637 <th> 4
638 </th><td> 4 </td><td> 8 </td><td> 12
639 </td></tr>
640 <tr >
641 <th> 5
642 </th><td> 5 </td><td> 10 </td><td> 15
643 </td></tr></table>
645 !! end
647 !! test
648 Table rowspan
649 !! input
650 {| align=right border=1
651 | Cell 1, row 1 
652 |rowspan=2| Cell 2, row 1 (and 2) 
653 | Cell 3, row 1 
654 |- 
655 | Cell 1, row 2 
656 | Cell 3, row 2 
658 !! result
659 <table align=right border=1>
660 <tr >
661 <td> Cell 1, row 1
662 </td><td rowspan=2> Cell 2, row 1 (and 2)
663 </td><td> Cell 3, row 1
664 </td></tr>
665 <tr >
666 <td> Cell 1, row 2
667 </td><td> Cell 3, row 2
668 </td></tr></table>
670 !! end
672 !! test
673 Nested table
674 !! input
675 {| border=1
676 | &alpha;
678 {| bgcolor=#ABCDEF border=2
679 |nested
681 |table
683 |the original table again
685 !! result
686 <table border=1>
687 <tr >
688 <td> &alpha;
689 </td><td>
690 <table bgcolor=#ABCDEF border=2>
691 <tr >
692 <td>nested
693 </td></tr>
694 <tr >
695 <td>table
696 </td></tr></table>
697 </td><td>the original table again
698 </td></tr></table>
700 !! end
703 ### Internal links
705 !! test
706 Plain link, capitalized
707 !! input
708 [[Main Page]]
709 !! result
710 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
711 </p>
712 !! end
714 !! test
715 Plain link, uncapitalized
716 !! input
717 [[main Page]]
718 !! result
719 <p><a href="/wiki/Main_Page" title="Main Page">main Page</a>
720 </p>
721 !! end
723 !! test
724 Piped link
725 !! input
726 [[Main Page|The Main Page]]
727 !! result
728 <p><a href="/wiki/Main_Page" title="Main Page">The Main Page</a>
729 </p>
730 !! end
732 !! test
733 Broken link
734 !! input
735 [[Zigzagzogzagzig]]
736 !! result
737 <p><a href="/index.php?title=Zigzagzogzagzig&amp;action=edit" class="new" title="Zigzagzogzagzig">Zigzagzogzagzig</a>
738 </p>
739 !! end
741 !! test
742 Link with prefix
743 !! input
744 xxx[[main Page]], xxx[[Main Page]], Xxx[[main Page]] XXX[[main Page]], XXX[[Main Page]]
745 !! result
746 <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>
747 </p>
748 !! end
750 !! test
751 Link with suffix
752 !! input
753 [[Main Page]]xxx, [[Main Page]]XXX
754 !! result
755 <p><a href="/wiki/Main_Page" title="Main Page">Main Pagexxx</a>, <a href="/wiki/Main_Page" title="Main Page">Main Page</a>XXX
756 </p>
757 !! end
759 !! test
760 Link with 3 brackets
761 !! input
762 [[[main page]]]
763 !! result
764 <p>[[[main page]]]
765 </p>
766 !! end
768 !! test
769 Piped link with 3 brackets
770 !! input
771 [[[main page|the main page]]]
772 !! result
773 <p>[[[main page|the main page]]]
774 </p>
775 !! end
777 !! test
778 Link to namespaces
779 !! input
780 [[Talk:Parser testing]], [[Meta:Disclaimers]]
781 !! result
782 <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>
783 </p>
784 !! end
786 !! test
787 Piped link to namespace
788 !! input
789 [[Meta:Disclaimers|The disclaimers]]
790 !! result
791 <p><a href="/index.php?title=Meta:Disclaimers&amp;action=edit" class="new" title="Meta:Disclaimers">The disclaimers</a>
792 </p>
793 !! end
795 !! test
796 Link containing }
797 !! input
798 [[Usually caused by a typo (oops}]]
799 !! result
800 <p>[[Usually caused by a typo (oops}]]
801 </p>
802 !! end
805 !! test
806 Plain link to URL
807 !! input
808 [[http://www.example.org]]
809 !! result
810 <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>]
811 </p>
812 !! end
814 # I'm fairly sure the expected result here is wrong.
815 # We want these to be URL links, not pseudo-pages with URLs for titles....
816 # However the current output is also pretty screwy.
818 # ----
819 # I'm changing it to match the current output--it arguably makes more
820 # sense in the light of the test above. Old expected result was:
821 #<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>
822 #</p>
823 # But I think this test is bordering on "garbage in, garbage out" anyway.
824 # -- wtm
825 !! test
826 Piped link to URL
827 !! input
828 Piped link to URL: [[http://www.example.org|an example URL]]
829 !! result
830 <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>]
831 </p>
832 !! end
834 !! test
835 BUG 2: [[page|http://url/]] should link to page, not http://url/
836 !! input
837 [[Main Page|http://url/]]
838 !! result
839 <p><a href="/wiki/Main_Page" title="Main Page">http://url/</a>
840 </p>
841 !! end
845 ### Interwiki links
848 !! test
849 Inline interwiki link
850 !! input
851 [[MeatBall:SoftSecurity]]
852 !! result
853 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity" class='extiw'>MeatBall:SoftSecurity</a>
854 </p>
855 !! end
858 ## XHTML tidiness
861 !! test
862 <br> to <br />
863 !! input
864 1<br>2<br />3
865 !! result
866 <p>1<br />2<br />3
867 </p>
868 !! end
871 ### Block-level elements
873 !! test
874 Common list
875 !! input
876 *Common list
877 * item 2
878 *item 3
879 !! result
880 <ul><li>Common list
881 </li><li> item 2
882 </li><li>item 3
883 </li></ul>
885 !! end
887 !! test
888 Numbered list
889 !! input
890 #Numbered list
891 #item 2
892 # item 3
893 !! result
894 <ol><li>Numbered list
895 </li><li>item 2
896 </li><li> item 3
897 </li></ol>
899 !! end
901 !! test
902 Mixed list
903 !! input
904 *Mixed list
905 *# with numbers
906 ** and bullets
907 *# and numbers
908 *bullets again
909 **bullet level 2
910 ***bullet level 3
911 ***#Number on level 4
912 **bullet level 2
913 **#Number on level 3
914 **#Number on level 3
915 *#number level 2
916 *Level 1
917 !! result
918 <ul><li>Mixed list
919 <ol><li> with numbers
920 </li></ol>
921 <ul><li> and bullets
922 </li></ul>
923 <ol><li> and numbers
924 </li></ol>
925 </li><li>bullets again
926 <ul><li>bullet level 2
927 <ul><li>bullet level 3
928 <ol><li>Number on level 4
929 </li></ol>
930 </li></ul>
931 </li><li>bullet level 2
932 <ol><li>Number on level 3
933 </li><li>Number on level 3
934 </li></ol>
935 </li></ul>
936 <ol><li>number level 2
937 </li></ol>
938 </li><li>Level 1
939 </li></ul>
941 !! end
944 ### Magic variables
946 !! test
947 Magic variables
948 !! input
949 {{SITENAME}}
950 !! result
951 <p>MediaWiki
952 </p>
953 !! end
956 ### Magic links
958 !! test
959 Magic links: internal link to RFC
960 !! input
961 [[RFC 123]]
962 !! result
963 <p><a href="/index.php?title=RFC_123&amp;action=edit" class="new" title="RFC 123">RFC 123</a>
964 </p>
965 !! end
967 !! test
968 Magic links: RFC
969 !! input
970 RFC 822
971 !! result
972 <p><a href='http://www.faqs.org/rfcs/rfc822.html' class='external' title="http://www.faqs.org/rfcs/rfc822.html">RFC 822</a>
973 </p>
974 !! end
976 !! test
977 Magic links: ISBN
978 !! input
979 ISBN 0-306-40615-2
980 !! result
981 <p><a href="/index.php?title=Special:Booksources&amp;isbn=0306406152" class="internal">ISBN 0-306-40615-2</a>
982 </p>
983 !! end
986 ### Templates
987 ####
989 !! test
990 Nonexistant template
991 !! input
992 {{thistemplatedoesnotexist}}
993 !! result
994 <p><a href="/index.php?title=Template:Thistemplatedoesnotexist&amp;action=edit" class="new" title="Template:Thistemplatedoesnotexist">Template:Thistemplatedoesnotexist</a>
995 </p>
996 !! end
998 !! article
999 Template:test
1000 !! text
1001 This is a test template
1002 !! endarticle
1004 !! test
1005 Simple template
1006 !! input
1007 {{test}}
1008 !! result
1009 <p>This is a test template
1010 </p>
1011 !! end
1013 !! test
1014 Template with explicit namespace
1015 !! input
1016 {{Template:test}}
1017 !! result
1018 <p>This is a test template
1019 </p>
1020 !! end
1023 !! article
1024 Template:paramtest
1025 !! text
1026 This is a test template with parameter {{{param}}}
1027 !! endarticle
1029 !! test
1030 Template parameter
1031 !! input
1032 {{paramtest|param=foo}}
1033 !! result
1034 <p>This is a test template with parameter foo
1035 </p>
1036 !! end
1038 !! article
1039 Template:paramtestnum
1040 !! text
1041 [[{{{1}}}|{{{2}}}]]
1042 !! endarticle
1044 !! test
1045 Template unnamed parameter
1046 !! input
1047 {{paramtestnum|Main Page|the main page}}
1048 !! result
1049 <p><a href="/wiki/Main_Page" title="Main Page">the main page</a>
1050 </p>
1051 !! end
1053 !! test
1054 BUG 553: link with two variables in a piped link
1055 !! input
1056 {| 
1057 |[[{{{1}}}|{{{2}}}]]
1059 !! result
1060 <table >
1061 <tr >
1062 <td>[[{{{1}}}|{{{2}}}]]
1063 </td></tr></table>
1065 !! end
1067 !! test
1068 Magic variable as template parameter
1069 !! input
1070 {{paramtest|param={{SITENAME}}}}
1071 !! result
1072 <p>This is a test template with parameter MediaWiki
1073 </p>
1074 !! end
1076 !! article
1077 Template:linktest
1078 !! text
1079 [[{{{param}}}|link]]
1080 !! endarticle
1082 !! test
1083 Template parameter as link source
1084 !! input
1085 {{linktest|param=Main Page}}
1086 !! result
1087 <p><a href="/wiki/Main_Page" title="Main Page">link</a>
1088 </p>
1089 !! end
1092 !!article
1093 Template:paramtest2
1094 !! text
1095 including another template, {{paramtest|param={{{arg}}}}}
1096 !! endarticle
1098 !! test
1099 Template passing argument to another template
1100 !! input
1101 {{paramtest2|arg='hmm'}}
1102 !! result
1103 <p>including another template, This is a test template with parameter 'hmm'
1104 </p>
1105 !! end
1107 !! article
1108 Template:Linktest2
1109 !! text
1110 Main Page
1111 !! endarticle
1113 !! test
1114 Template as link source
1115 !! input
1116 [[{{linktest2}}]]
1117 !! result
1118 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
1119 </p>
1120 !! end
1123 !! article
1124 Template:loop1
1125 !! text
1126 {{loop2}}
1127 !! endarticle
1129 !! article
1130 Template:loop2
1131 !! text
1132 {{loop1}}
1133 !! endarticle
1135 !! test
1136 Template infinite loop
1137 !! input
1138 {{loop1}}
1139 !! result
1140 <p>{{loop2}}<!-- WARNING: template loop detected -->
1141 </p>
1142 !! end
1144 !! test
1145 Template from main namespace
1146 !! input
1147 {{:Main Page}}
1148 !! result
1149 <p>blah blah
1150 </p>
1151 !! end
1153 !! article
1154 Template:table
1155 !! text
1156 {| 
1157 | 1 || 2
1158 |- 
1159 | 3 || 4
1161 !! endarticle
1163 !! test
1164 BUG 529: Template with table, not included at beginning of line
1165 !! input
1166 foo {{table}}
1167 !! result
1168 <p>foo 
1169 </p>
1170 <table >
1171 <tr >
1172 <td> 1 </td><td> 2
1173 </td></tr>
1174 <tr >
1175 <td> 3 </td><td> 4
1176 </td></tr></table>
1178 !! end
1180 !! test
1181 BUG 523: Template shouldn't eat newline (or add an extra one before table)
1182 !! input
1184 {{table}}
1185 !! result
1186 <p>foo
1187 </p>
1188 <table >
1189 <tr >
1190 <td> 1 </td><td> 2
1191 </td></tr>
1192 <tr >
1193 <td> 3 </td><td> 4
1194 </td></tr></table>
1196 !! end
1198 !! test
1199 BUG 41: Template parameters shown as broken links
1200 !! input
1201 {{{parameter}}}
1202 !! result
1203 <p>{{{parameter}}}
1204 </p>
1205 !! end
1208 !! article
1209 Template:MSGNW test
1210 !! text
1211 ''None'' of '''this''' should be 
1212 * interepreted
1213  but rather passed unmodified
1214 {{test}}
1215 !! endarticle
1217 # hmm, fix this or just deprecate msgnw and document its behavior?
1218 !! test
1219 msgnw keyword
1220 !! options
1221 disabled
1222 !! input
1223 {{msgnw:MSGNW test}}
1224 !! result
1225 <p>''None'' of '''this''' should be 
1226 * interepreted
1227  but rather passed unmodified
1228 {{test}}
1229 </p>
1230 !! end
1232 !! test
1233 int keyword
1234 !! input
1235 {{int:newmessages|lots of money}}
1236 !! result
1237 <p>You have lots of money.
1238 </p>
1239 !! end
1242 ### Pre-save transform tests
1244 !! test
1245 pre-save transform: subst:
1246 !! options
1248 !! input
1249 {{subst:test}}
1250 !! result
1251 This is a test template
1252 !! end
1254 !! test
1255 pre-save transform: normal template
1256 !! options
1258 !! input
1259 {{test}}
1260 !! result
1261 {{test}}
1262 !! end
1264 !! test
1265 pre-save transform: nonexistant template
1266 !! options
1268 !! input
1269 {{thistemplatedoesnotexist}}
1270 !! result
1271 {{thistemplatedoesnotexist}}
1272 !! end
1275 !! test
1276 pre-save transform: subst magic variables
1277 !! options
1279 !! input
1280 {{subst:SITENAME}}
1281 !! result
1282 MediaWiki
1283 !! end
1285 # This is bug 89, which I fixed. -- wtm
1286 !! test
1287 pre-save transform: subst: templates with parameters
1288 !! options
1290 !! input
1291 {{subst:paramtest|param="something else"}}
1292 !! result
1293 This is a test template with parameter "something else"
1294 !! end
1297 ### Message transform tests
1299 !! test
1300 message transform: magic variables
1301 !! options
1303 !! input
1304 {{SITENAME}}
1305 !! result
1306 MediaWiki
1307 !! end
1309 !! test
1310 message transform: should not transform wiki markup
1311 !! options
1313 !! input
1314 ''test''
1315 !! result
1316 ''test''
1317 !! end
1320 ### Images
1322 !! test
1323 Simple image
1324 !! input
1325 [[Image: test]]
1326 !! result
1327 <p><a href="/wiki/Image:Test" class="image" title="Image: test"><img src="/images/0/0c/Test" alt="Image: test" /></a>
1328 </p>
1329 !! end
1331 !! test
1332 Right-aligned image
1333 !! input
1334 [[Image:test|right]]
1335 !! result
1336 <div class="floatright"><span><a href="/wiki/Image:Test" class="image" title="right"><img src="/images/0/0c/Test" alt="right" /></a></span></div>
1338 !! end
1340 !! test
1341 Image with caption
1342 !! input
1343 [[Image:test|right|Caption text]]
1344 !! result
1345 <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>
1347 !! end
1349 !! test
1350 Image with frame and link
1351 !! input
1352 [[Image:Foobar.jpg|frame|left|This is a test image [[Main Page]]]]
1353 !! result
1354 <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>
1356 !! end
1358 !! test
1359 Link to image page
1360 !! input
1361 [[:Image:test]]
1362 !! result
1363 <p><a href="/wiki/Image:Test" title="Image:Test">Image:test</a>
1364 </p>
1365 !! end
1367 !! test
1368 Frameless image caption with a free URL
1369 !! input
1370 [[Image:foo|http://example.com]]
1371 !! result
1372 <p><a href="/wiki/Image:Foo" class="image" title="http://example.com"><img src="/images/1/13/Foo" alt="http://example.com" /></a>
1373 </p>
1374 !! end
1376 !! test
1377 Thumbnail image caption with a free URL
1378 !! input
1379 [[Image:foo|thumb|http://example.com]]
1380 !! result
1381 <div class="thumb tright"><div style="width:182px;"><b>Missing image</b><br /><i>Foo</i>   <div class="thumbcaption" ><a href="http://example.com" class='external'>http://example.com</a></div></div></div>
1383 !! end
1385 # Pending resolution to bug 368
1386 !! test
1387 BUG 648: Frameless image caption with a link
1388 !! input
1389 [[Image:foo|text with a [[link]] in it]]
1390 !! result
1391 <p><a href="/wiki/Image:Foo" class="image" title="text with a link in it"><img src="/images/1/13/Foo" alt="text with a link in it" /></a>
1392 </p>
1393 !! end
1395 !! test
1396 Escape HTML special chars in image alt text
1397 !! input
1398 [[Image:example.jpg|& < > "]]
1399 !! result
1400 <p><a href="/wiki/Image:Example.jpg" class="image" title="&amp; &lt; &gt; &quot;"><img src="/images/a/a9/Example.jpg" alt="&amp; &lt; &gt; &quot;" /></a>
1401 </p>
1402 !! end
1404 !! test
1405 BUG 499: Alt text should have &#1234;, not &amp;1234;
1406 !! input
1407 [[Image:image.jpg|&#9792;]]
1408 !! result
1409 <p><a href="/wiki/Image:Image.jpg" class="image" title="&#9792;"><img src="/images/7/78/Image.jpg" alt="&#9792;" /></a>
1410 </p>
1411 !! end
1413 !! test
1414 Broken image caption with link
1415 !! input
1416 [[Image:Rowan.jpeg|thumb|This is a broken caption. But [[Main Page|this]] is just an ordinary link.
1417 !! result
1418 <p>[[Image:Rowan.jpeg|thumb|This is a broken caption. But <a href="/wiki/Main_Page" title="Main Page">this</a> is just an ordinary link.
1419 </p>
1420 !! end
1422 !! test
1423 Image caption containing another image
1424 !! input
1425 [[Image:Bar.jpeg|thumb|This is a caption with another [[Image:icon.png|image]] inside it!]]
1426 !! result
1427 <div class="thumb tright"><div style="width:182px;"><b>Missing image</b><br /><i>Bar.jpeg</i>   <div class="thumbcaption" >This is a caption with another <a href="/wiki/Image:Icon.png" class="image" title="image"><img src="/images/9/96/Icon.png" alt="image" /></a> inside it!</div></div></div>
1429 !! end
1432 ### Subpages
1434 !! article
1435 Subpage test/subpage
1436 !! text
1438 !! endarticle
1440 !! test
1441 Subpage link
1442 !! options
1443 subpage title=[[Subpage test]]
1444 !! input
1445 [[/subpage]]
1446 !! result
1447 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a>
1448 </p>
1449 !! end
1451 !! test
1452 Subpage noslash link
1453 !! options
1454 subpage title=[[Subpage test]]
1455 !!input
1456 [[/subpage/]]
1457 !! result
1458 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">subpage</a>
1459 </p>
1460 !! end
1462 !! test
1463 Disabled subpages
1464 !! input
1465 [[/subpage]]
1466 !! result
1467 <p><a href="/index.php?title=/subpage&amp;action=edit" class="new" title="/subpage">/subpage</a>
1468 </p>
1469 !! end
1471 !! test
1472 BUG 561: {{/Subpage}}
1473 !! options
1474 subpage title=[[Page]]
1475 !! input
1476 {{/Subpage}}
1477 !! result
1478 <p><a href="/index.php?title=Page/Subpage&amp;action=edit" class="new" title="Page/Subpage">Page/Subpage</a>
1479 </p>
1480 !! end
1483 ### Categories
1485 !! article
1486 Category:MediaWiki User's Guide
1487 !! text
1488 blah
1489 !! endarticle
1491 !! test
1492 Link to category
1493 !! input
1494 [[:Category:MediaWiki User's Guide]]
1495 !! result
1496 <p><a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User's Guide">Category:MediaWiki User's Guide</a>
1497 </p>
1498 !! end
1500 !! test
1501 Simple category
1502 !! options
1504 !! input
1505 [[Category: MediaWiki User's Guide]]
1506 !! result
1507 <a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User's Guide">MediaWiki User's Guide</a>
1508 !! end
1511 ### Inter-language links
1513 !! test
1514 Inter-language links
1515 !! options
1517 !! input
1518 [[es:Alimento]]
1519 [[fr:Nourriture]]
1520 [[zh:&#39135;&#21697;]]
1521 !! result
1522 es:Alimento fr:Nourriture zh:食品
1523 !! end
1526 ### Sections
1528 !! test
1529 Basic section headings
1530 !! input
1531 == Headline 1 ==
1532 Some text
1534 ==Headline 2==
1535 More
1536 ===Smaller headline===
1537 Blah blah
1538 !! result
1539 <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>
1540 <p>Some text
1541 </p>
1542 <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>
1543 <p>More
1544 </p>
1545 <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>
1546 <p>Blah blah
1547 </p>
1548 !! end
1550 !! test
1551 Section headings with TOC
1552 !! input
1553 == Headline 1 ==
1554 === Subheadline 1 ===
1555 ===== Skipping a level =====
1556 ====== Skipping a level ======
1558 == Headline 2 ==
1559 Some text
1560 ===Another headline===
1561 !! result
1562 <table border="0" id="toc"><tr id="toctitle"><td align="center">
1563 <b>Table of contents</b> <script type="text/javascript">showTocToggle("show","hide")</script></td></tr><tr id="tocinside"><td>
1564 <div class="tocline"><a href="#Headline_1">1 Headline 1</a><br /></div>
1565 <div class="tocindent">
1566 <p><a href="#Subheadline_1">1.1 Subheadline 1</a><br />
1567 </p>
1568 <div class="tocindent">
1569 <div class="tocindent">
1570 <p><a href="#Skipping_a_level">1.1.1 Skipping a level</a><br />
1571 </p>
1572 <div class="tocindent">
1573 <p><a href="#Skipping_a_level_2">1.1.1.1 Skipping a level</a><br />
1574 </p>
1575 </div>
1576 </div>
1577 </div>
1578 </div>
1579 <div class="tocline"><a href="#Headline_2">2 Headline 2</a><br /></div>
1580 <div class="tocindent">
1581 <p><a href="#Another_headline">2.1 Another headline</a><br />
1582 </p>
1583 </div>
1584 </td></tr></table>
1585 <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>
1586 <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>
1587 <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>
1588 <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>
1589 <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>
1590 <p>Some text
1591 </p>
1592 <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>
1594 !! end
1596 !! test
1597 Resolving duplicate section names
1598 !! input
1599 == Foo bar ==
1600 ==Foo bar==
1601 !! result
1602 <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>
1603 <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>
1605 !! end
1607 !! article
1608 Template:sections
1609 !! text
1610 ===Section 1===
1611 ==Section 2==
1612 !! endarticle
1614 !! test
1615 Template with sections, __NOTOC__
1616 !! options title=[[Parser test script]]
1617 !! input
1618 __NOTOC__
1619 ==Section 0==
1620 {{sections}}
1621 ==Section 4==
1622 !! result
1623 <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>
1624 <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>
1625 <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>
1626 <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>
1628 !! end
1630 !! test
1631 __NOEDITSECTION__ keyword
1632 !! input
1633 __NOEDITSECTION__
1634 ==Section 1==
1635 ==Section 2==
1636 !! result
1637 <a name="Section_1"></a><h2>Section 1</h2>
1638 <a name="Section_2"></a><h2>Section 2</h2>
1640 !! end
1642 TODO:
1643 more images
1644 more tables
1645 math
1646 character entities
1647 and much more