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