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