fixed bug
[mediawiki.git] / maintenance / parserTests.txt
blob792902ac3f5c3be9ac868070842f9a2ad063e274
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 ### Comments
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 lists
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 free' title="http://example.com/" rel="nofollow">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 text' title="http://www.google.com/" rel="nofollow">Google</a></dt><dd>Number one search engine
290 </dd></dl>
292 !! end
294 !! test
295 Definition list with wikilink containing colon
296 !! input
297 ; [[Help:FAQ]]: The least-read page on Wikipedia
298 !! result
299 <dl><dt> <a href="/index.php?title=Help:FAQ&amp;action=edit" class="new" title="Help:FAQ">Help: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 free' title="news:alt.wikipedia.rox" rel="nofollow">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 free' title="news:alt.wikipedia.rox" rel="nofollow">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 text' title="http://www.wikipedia2.org/" rel="nofollow">Wikipedia&nbsp;: The Next Generation</a></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 free' title="http://example.com" rel="nofollow">http://example.com</a>
345 </p>
346 !! end
348 !! test
349 External links: numbered
350 !! input
351 Numbered: [http://example.com]
352 Numbered: [http://example.net]
353 Numbered: [http://example.org]
354 !! result
355 <p>Numbered: <a href="http://example.com" class='external autonumber' title="http://example.com" rel="nofollow">[1]</a>
356 Numbered: <a href="http://example.net" class='external autonumber' title="http://example.net" rel="nofollow">[2]</a>
357 Numbered: <a href="http://example.org" class='external autonumber' title="http://example.org" rel="nofollow">[3]</a>
358 </p>
359 !!end
361 !! test
362 External links: specified text
363 !! input
364 Specified text: [http://example.com link]
365 !! result
366 <p>Specified text: <a href="http://example.com" class='external text' title="http://example.com" rel="nofollow">link</a>
367 </p>
368 !!end
370 !! test
371 External links: trail
372 !! input
373 Linktrails should not work for external links: [http://example.com link]s
374 !! result
375 <p>Linktrails should not work for external links: <a href="http://example.com" class='external text' title="http://example.com" rel="nofollow">link</a>s
376 </p>
377 !! end
379 !! test
380 External links: dollar sign in URL
381 !! input
382 http://example.com/1$2345
383 !! result
384 <p><a href="http://example.com/1$2345" class='external free' title="http://example.com/1$2345" rel="nofollow">http://example.com/1$2345</a>
385 </p>
386 !! end
388 !! test
389 External links: dollar sign in URL (named)
390 !! input
391 [http://example.com/1$2345]
392 !! result
393 <p><a href="http://example.com/1$2345" class='external autonumber' title="http://example.com/1$2345" rel="nofollow">[1]</a>
394 </p>
395 !!end
397 !! test
398 External links: open square bracket forbidden in URL (bug 4377)
399 !! input
400 http://example.com/1[2345
401 !! result
402 <p><a href="http://example.com/1" class='external free' title="http://example.com/1" rel="nofollow">http://example.com/1</a>[2345
403 </p>
404 !! end
406 !! test
407 External links: open square bracket forbidden in URL (named) (bug 4377)
408 !! input
409 [http://example.com/1[2345]
410 !! result
411 <p><a href="http://example.com/1" class='external text' title="http://example.com/1" rel="nofollow">[2345</a>
412 </p>
413 !!end
415 !! test
416 External image
417 !! input
418 External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
419 !! result
420 <p>External image: <img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png" />
421 </p>
422 !! end
424 !! test
425 External image from https
426 !! input
427 External image from https: https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
428 !! result
429 <p>External image from https: <img src="https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png" />
430 </p>
431 !! end
433 !! test
434 Link to non-http image, no img tag
435 !! input
436 Link to non-http image, no img tag: ftp://example.com/test.jpg
437 !! result
438 <p>Link to non-http image, no img tag: <a href="ftp://example.com/test.jpg" class='external free' title="ftp://example.com/test.jpg" rel="nofollow">ftp://example.com/test.jpg</a>
439 </p>
440 !! end
442 !! test
443 External links: terminating separator
444 !! input
445 Terminating separator: http://example.com/thing,
446 !! result
447 <p>Terminating separator: <a href="http://example.com/thing" class='external free' title="http://example.com/thing" rel="nofollow">http://example.com/thing</a>,
448 </p>
449 !! end
451 !! test
452 External links: intervening separator
453 !! input
454 Intervening separator: http://example.com/1,2,3
455 !! result
456 <p>Intervening separator: <a href="http://example.com/1,2,3" class='external free' title="http://example.com/1,2,3" rel="nofollow">http://example.com/1,2,3</a>
457 </p>
458 !! end
460 !! test
461 External links: old bug with URL in query
462 !! input
463 Old bug with URL in query: [http://example.com/thing?url=http://example.com link]
464 !! result
465 <p>Old bug with URL in query: <a href="http://example.com/thing?url=http://example.com" class='external text' title="http://example.com/thing?url=http://example.com" rel="nofollow">link</a>
466 </p>
467 !! end
469 !! test
470 External links: old URL-in-URL bug, mixed protocols
471 !! input
472 And again with mixed protocols: [ftp://example.com?url=http://example.com link]
473 !! result
474 <p>And again with mixed protocols: <a href="ftp://example.com?url=http://example.com" class='external text' title="ftp://example.com?url=http://example.com" rel="nofollow">link</a>
475 </p>
476 !!end
478 !! test
479 External links: URL in text
480 !! input
481 URL in text: [http://example.com http://example.com]
482 !! result
483 <p>URL in text: <a href="http://example.com" class='external free' title="http://example.com" rel="nofollow">http://example.com</a>
484 </p>
485 !! end
487 !! test
488 External links: Clickable images
489 !! input
490 ja-style clickable images: [http://example.com http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png]
491 !! result
492 <p>ja-style clickable images: <a href="http://example.com" class='external text' title="http://example.com" rel="nofollow"><img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png" /></a>
493 </p>
494 !!end
496 !! test
497 External links: raw ampersand
498 !! input
499 Old &amp; use: http://x&y
500 !! result
501 <p>Old &amp; use: <a href="http://x&amp;y" class='external free' title="http://x&amp;y" rel="nofollow">http://x&amp;y</a>
502 </p>
503 !! end
505 !! test
506 External links: encoded ampersand
507 !! input
508 Old &amp; use: http://x&amp;y
509 !! result
510 <p>Old &amp; use: <a href="http://x&amp;y" class='external free' title="http://x&amp;y" rel="nofollow">http://x&amp;y</a>
511 </p>
512 !! end
514 !! test
515 External links: [raw ampersand]
516 !! input
517 Old &amp; use: [http://x&y]
518 !! result
519 <p>Old &amp; use: <a href="http://x&amp;y" class='external autonumber' title="http://x&amp;y" rel="nofollow">[1]</a>
520 </p>
521 !! end
523 !! test
524 External links: [encoded ampersand]
525 !! input
526 Old &amp; use: [http://x&amp;y]
527 !! result
528 <p>Old &amp; use: <a href="http://x&amp;y" class='external autonumber' title="http://x&amp;y" rel="nofollow">[1]</a>
529 </p>
530 !! end
532 !! test
533 External links: www.jpeg.org (bug 554)
534 !! input
535 http://www.jpeg.org
536 !!result
537 <p><a href="http://www.jpeg.org" class='external free' title="http://www.jpeg.org" rel="nofollow">http://www.jpeg.org</a>
538 </p>
539 !! end
541 !! test
542 External links: URL within URL (original bug 2)
543 !! input
544 [http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp]
545 !! result
546 <p><a href="http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp" class='external autonumber' title="http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp" rel="nofollow">[1]</a>
547 </p>
548 !! end
550 !! test
551 BUG 361: URL inside bracketed URL
552 !! input
553 [http://www.example.com/foo http://www.example.com/bar]
554 !! result
555 <p><a href="http://www.example.com/foo" class='external text' title="http://www.example.com/foo" rel="nofollow">http://www.example.com/bar</a>
556 </p>
557 !! end
559 !! test
560 BUG 361: URL within URL, not bracketed
561 !! input
562 http://www.example.com/foo?=http://www.example.com/bar
563 !! result
564 <p><a href="http://www.example.com/foo?=http://www.example.com/bar" class='external free' title="http://www.example.com/foo?=http://www.example.com/bar" rel="nofollow">http://www.example.com/foo?=http://www.example.com/bar</a>
565 </p>
566 !! end
568 !! test
569 BUG 289: ">"-token in URL-tail
570 !! input
571 http://www.example.com/<hello>
572 !! result
573 <p><a href="http://www.example.com/" class='external free' title="http://www.example.com/" rel="nofollow">http://www.example.com/</a>&lt;hello&gt;
574 </p>
575 !!end
577 !! test
578 BUG 289: literal ">"-token in URL-tail
579 !! input
580 http://www.example.com/<b>html</b>
581 !! result
582 <p><a href="http://www.example.com/" class='external free' title="http://www.example.com/" rel="nofollow">http://www.example.com/</a><b>html</b>
583 </p>
584 !!end
586 !! test
587 BUG 289: ">"-token in bracketed URL
588 !! input
589 [http://www.example.com/<hello> stuff]
590 !! result
591 <p><a href="http://www.example.com/" class='external text' title="http://www.example.com/" rel="nofollow">&lt;hello&gt; stuff</a>
592 </p>
593 !!end
595 !! test
596 BUG 289: literal ">"-token in bracketed URL
597 !! input
598 [http://www.example.com/<b>html</b> stuff]
599 !! result
600 <p><a href="http://www.example.com/" class='external text' title="http://www.example.com/" rel="nofollow"><b>html</b> stuff</a>
601 </p>
602 !!end
604 !! test
605 BUG 289: literal double quote at end of URL
606 !! input
607 http://www.example.com/"hello"
608 !! result
609 <p><a href="http://www.example.com/" class='external free' title="http://www.example.com/" rel="nofollow">http://www.example.com/</a>"hello"
610 </p>
611 !!end
613 !! test
614 BUG 289: literal double quote in bracketed URL
615 !! input
616 [http://www.example.com/"hello" stuff]
617 !! result
618 <p><a href="http://www.example.com/" class='external text' title="http://www.example.com/" rel="nofollow">"hello" stuff</a>
619 </p>
620 !!end
622 !! test
623 External links: invalid character
624 !! input
625 [http://www.example.com\0 test]
626 !! result
627 <p>[<a href="http://www.example.com" class='external free' title="http://www.example.com" rel="nofollow">http://www.example.com</a>\0 test]
628 </p>
629 !! end
631 !! test
632 BUG 787: Links with one slash after the url protocol are invalid
633 !! input
634 http:/example.com
636 [http:/example.com title]
637 !! result
638 <p>http:/example.com
639 </p><p>[http:/example.com title]
640 </p>
641 !! end
643 !! test
644 Bug 2702: Mismatched <i> and <a> tags are invalid
645 !! input
646 ''[http://example.com text'']
647 !! result
648 <p><i><a href="http://example.com" class='external text' title="http://example.com" rel="nofollow">text</a></i>
649 </p>
650 !! end
653 ### Quotes
656 !! test
657 Quotes
658 !! input
659 Normal text. '''Bold text.''' Normal text. ''Italic text.''
661 Normal text. '''''Bold italic text.''''' Normal text.
662 !!result
663 <p>Normal text. <b>Bold text.</b> Normal text. <i>Italic text.</i>
664 </p><p>Normal text. <i><b>Bold italic text.</b></i> Normal text.
665 </p>
666 !! end
669 !! test
670 Unclosed and unmatched quotes
671 !! input
672 '''''Bold italic text '''with bold deactivated''' in between.'''''
674 '''''Bold italic text ''with italic deactivated'' in between.'''''
676 '''Bold text..
678 ..spanning two paragraphs (should not work).'''
680 '''Bold tag left open
682 ''Italic tag left open
684 Normal text.
686 <!-- Unmatching number of opening, closing tags: -->
687 '''This year''''s election ''should'' beat '''last year''''s.
689 ''Tom'''s car is bigger than ''Susan'''s.
690 !! result
691 <p><i><b>Bold italic text </b>with bold deactivated<b> in between.</b></i>
692 </p><p><b><i>Bold italic text </i>with italic deactivated<i> in between.</i></b>
693 </p><p><b>Bold text..</b>
694 </p><p>..spanning two paragraphs (should not work).<b></b>
695 </p><p><b>Bold tag left open</b>
696 </p><p><i>Italic tag left open</i>
697 </p><p>Normal text.
698 </p><p><b>This year'</b>s election <i>should</i> beat <b>last year'</b>s.
699 </p><p><i>Tom<b>s car is bigger than </b></i><b>Susan</b>s.
700 </p>
701 !! end
704 ### Tables
706 ### some content taken from http://meta.wikimedia.org/wiki/MediaWiki_User%27s_Guide:_Using_tables
709 # This should not produce <table></table> as <table><tr><td></td></tr></table>
710 # is the bare minimun required by the spec, see:
711 # http://www.w3.org/TR/xhtml-modularization/dtd_module_defs.html#a_module_Basic_Tables
712 !! test
713 A table with no data.
714 !! input
715 {||}
716 !! result
717 !! end
719 # A table with nothing but a caption is invalid XHTML, we might want to render
720 # this as <p>caption</p>
721 !! test
722 A table with nothing but a caption
723 !! input 
725 |+ caption
727 !! result
728 <table>
729 <caption> caption
730 </caption>
731 <tr>
732 <td>
733 </td></tr></table>
734 !! end
736 !! test
737 Simple table
738 !! input
739 {| 
740 | 1 || 2
741 |- 
742 | 3 || 4
744 !! result
745 <table>
746 <tr>
747 <td> 1 </td><td> 2
748 </td></tr>
749 <tr>
750 <td> 3 </td><td> 4
751 </td></tr></table>
753 !! end
755 !! test
756 Multiplication table
757 !! input
758 {| border="1" cellpadding="2"
759 |+Multiplication table
761 ! &times; !! 1 !! 2 !! 3
763 ! 1
764 | 1 || 2 || 3
766 ! 2
767 | 2 || 4 || 6
769 ! 3
770 | 3 || 6 || 9
772 ! 4
773 | 4 || 8 || 12
775 ! 5
776 | 5 || 10 || 15
778 !! result
779 <table border="1" cellpadding="2">
780 <caption>Multiplication table
781 </caption>
782 <tr>
783 <th> &times; </th><th> 1 </th><th> 2 </th><th> 3
784 </th></tr>
785 <tr>
786 <th> 1
787 </th><td> 1 </td><td> 2 </td><td> 3
788 </td></tr>
789 <tr>
790 <th> 2
791 </th><td> 2 </td><td> 4 </td><td> 6
792 </td></tr>
793 <tr>
794 <th> 3
795 </th><td> 3 </td><td> 6 </td><td> 9
796 </td></tr>
797 <tr>
798 <th> 4
799 </th><td> 4 </td><td> 8 </td><td> 12
800 </td></tr>
801 <tr>
802 <th> 5
803 </th><td> 5 </td><td> 10 </td><td> 15
804 </td></tr></table>
806 !! end
808 !! test
809 Table rowspan
810 !! input
811 {| align=right border=1
812 | Cell 1, row 1 
813 |rowspan=2| Cell 2, row 1 (and 2) 
814 | Cell 3, row 1 
815 |- 
816 | Cell 1, row 2 
817 | Cell 3, row 2 
819 !! result
820 <table align="right" border="1">
821 <tr>
822 <td> Cell 1, row 1
823 </td><td rowspan="2"> Cell 2, row 1 (and 2)
824 </td><td> Cell 3, row 1
825 </td></tr>
826 <tr>
827 <td> Cell 1, row 2
828 </td><td> Cell 3, row 2
829 </td></tr></table>
831 !! end
833 !! test
834 Nested table
835 !! input
836 {| border=1
837 | &alpha;
839 {| bgcolor=#ABCDEF border=2
840 |nested
842 |table
844 |the original table again
846 !! result
847 <table border="1">
848 <tr>
849 <td> &alpha;
850 </td><td>
851 <table bgcolor="#ABCDEF" border="2">
852 <tr>
853 <td>nested
854 </td></tr>
855 <tr>
856 <td>table
857 </td></tr></table>
858 </td><td>the original table again
859 </td></tr></table>
861 !! end
863 !! test
864 Invalid attributes in table cell (bug 1830)
865 !! input
867 |Cell:|broken
869 !! result
870 <table>
871 <tr>
872 <td>broken
873 </td></tr></table>
875 !! end
879 ### Internal links
881 !! test
882 Plain link, capitalized
883 !! input
884 [[Main Page]]
885 !! result
886 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
887 </p>
888 !! end
890 !! test
891 Plain link, uncapitalized
892 !! input
893 [[main Page]]
894 !! result
895 <p><a href="/wiki/Main_Page" title="Main Page">main Page</a>
896 </p>
897 !! end
899 !! test
900 Piped link
901 !! input
902 [[Main Page|The Main Page]]
903 !! result
904 <p><a href="/wiki/Main_Page" title="Main Page">The Main Page</a>
905 </p>
906 !! end
908 !! test
909 Broken link
910 !! input
911 [[Zigzagzogzagzig]]
912 !! result
913 <p><a href="/index.php?title=Zigzagzogzagzig&amp;action=edit" class="new" title="Zigzagzogzagzig">Zigzagzogzagzig</a>
914 </p>
915 !! end
917 !! test
918 Link with prefix
919 !! input
920 xxx[[main Page]], xxx[[Main Page]], Xxx[[main Page]] XXX[[main Page]], XXX[[Main Page]]
921 !! result
922 <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>
923 </p>
924 !! end
926 !! test
927 Link with suffix
928 !! input
929 [[Main Page]]xxx, [[Main Page]]XXX
930 !! result
931 <p><a href="/wiki/Main_Page" title="Main Page">Main Pagexxx</a>, <a href="/wiki/Main_Page" title="Main Page">Main Page</a>XXX
932 </p>
933 !! end
935 !! test
936 Link with 3 brackets
937 !! input
938 [[[main page]]]
939 !! result
940 <p>[[[main page]]]
941 </p>
942 !! end
944 !! test
945 Piped link with 3 brackets
946 !! input
947 [[[main page|the main page]]]
948 !! result
949 <p>[[[main page|the main page]]]
950 </p>
951 !! end
953 !! test
954 Link with multiple pipes
955 !! input
956 [[Main Page|The|Main|Page]]
957 !! result
958 <p><a href="/wiki/Main_Page" title="Main Page">The|Main|Page</a>
959 </p>
960 !! end
962 !! test
963 Link to namespaces
964 !! input
965 [[Talk:Parser testing]], [[Meta:Disclaimers]]
966 !! result
967 <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>
968 </p>
969 !! end
971 !! test
972 Piped link to namespace
973 !! input
974 [[Meta:Disclaimers|The disclaimers]]
975 !! result
976 <p><a href="/index.php?title=Meta:Disclaimers&amp;action=edit" class="new" title="Meta:Disclaimers">The disclaimers</a>
977 </p>
978 !! end
980 !! test
981 Link containing }
982 !! input
983 [[Usually caused by a typo (oops}]]
984 !! result
985 <p>[[Usually caused by a typo (oops}]]
986 </p>
987 !! end
989 !! test
990 Link containing % (not as a hex sequence)
991 !! input
992 [[7% Solution]]
993 !! result
994 <p><a href="/index.php?title=7%25_Solution&amp;action=edit" class="new" title="7% Solution">7% Solution</a>
995 </p>
996 !! end
998 !! test
999 Link containing % as a single hex sequence interpreted to char
1000 !! input
1001 [[7%25 Solution]]
1002 !! result
1003 <p><a href="/index.php?title=7%25_Solution&amp;action=edit" class="new" title="7% Solution">7% Solution</a>
1004 </p>
1005 !!end
1007 !! test
1008 Link containing % as a double hex sequence interpreted to hex sequence
1009 !! input
1010 [[7%2525 Solution]]
1011 !! result
1012 <p>[[7%2525 Solution]]
1013 </p>
1014 !!end
1016 !! test
1017 Plain link to URL
1018 !! input
1019 [[http://www.example.org]]
1020 !! result
1021 <p>[<a href="http://www.example.org" class='external autonumber' title="http://www.example.org" rel="nofollow">[1]</a>]
1022 </p>
1023 !! end
1025 # I'm fairly sure the expected result here is wrong.
1026 # We want these to be URL links, not pseudo-pages with URLs for titles....
1027 # However the current output is also pretty screwy.
1029 # ----
1030 # I'm changing it to match the current output--it arguably makes more
1031 # sense in the light of the test above. Old expected result was:
1032 #<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>
1033 #</p>
1034 # But I think this test is bordering on "garbage in, garbage out" anyway.
1035 # -- wtm
1036 !! test
1037 Piped link to URL
1038 !! input
1039 Piped link to URL: [[http://www.example.org|an example URL]]
1040 !! result
1041 <p>Piped link to URL: [<a href="http://www.example.org|an" class='external text' title="http://www.example.org|an" rel="nofollow">example URL</a>]
1042 </p>
1043 !! end
1045 !! test
1046 BUG 2: [[page|http://url/]] should link to page, not http://url/
1047 !! input
1048 [[Main Page|http://url/]]
1049 !! result
1050 <p><a href="/wiki/Main_Page" title="Main Page">http://url/</a>
1051 </p>
1052 !! end
1054 !! test
1055 BUG 337: Escaped self-links should be bold
1056 !! options
1057 title=[[Bug462]]
1058 !! input
1059 [[Bu&#103;462]] [[Bug462]]
1060 !! result
1061 <p><strong>Bu&#103;462</strong> <strong>Bug462</strong>
1062 </p>
1063 !! end
1065 !! test
1066 Self-link to section should not be bold
1067 !! options
1068 title=[[Main Page]]
1069 !! input
1070 [[Main Page#section]]
1071 !! result
1072 <p><a href="/wiki/Main_Page#section" title="Main Page">Main Page#section</a>
1073 </p>
1074 !! end
1076 !! test
1077 <nowiki> inside a link
1078 !! input
1079 [[Main<nowiki> Page</nowiki>]] [[Main Page|the main page <nowiki>[it's not very good]</nowiki>]]
1080 !! result
1081 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a> <a href="/wiki/Main_Page" title="Main Page">the main page [it's not very good]</a>
1082 </p>
1083 !! end
1086 ### Interwiki links (see maintenance/interwiki.sql)
1089 !! test
1090 Inline interwiki link
1091 !! input
1092 [[MeatBall:SoftSecurity]]
1093 !! result
1094 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity" class='extiw' title="meatball:SoftSecurity">MeatBall:SoftSecurity</a>
1095 </p>
1096 !! end
1098 !! test
1099 Inline interwiki link with empty title (bug 2372)
1100 !! input
1101 [[MeatBall:]]
1102 !! result
1103 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?" class='extiw' title="meatball:">MeatBall:</a>
1104 </p>
1105 !! end
1107 !! test
1108 Interwiki link encoding conversion (bug 1636)
1109 !! input
1110 *[[Wikipedia:ro:Olteni&#0355;a]]
1111 *[[Wikipedia:ro:Olteni&#355;a]]
1112 !! result
1113 <ul><li><a href="http://en.wikipedia.org/wiki/ro:Olteni%C5%A3a" class='extiw' title="wikipedia:ro:Olteniţa">Wikipedia:ro:Olteni&#355;a</a>
1114 </li><li><a href="http://en.wikipedia.org/wiki/ro:Olteni%C5%A3a" class='extiw' title="wikipedia:ro:Olteniţa">Wikipedia:ro:Olteni&#355;a</a>
1115 </li></ul>
1117 !! end
1119 !! test
1120 Interwiki link with fragment (bug 2130)
1121 !! input
1122 [[MeatBall:SoftSecurity#foo]]
1123 !! result
1124 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity#foo" class='extiw' title="meatball:SoftSecurity">MeatBall:SoftSecurity#foo</a>
1125 </p>
1126 !! end
1129 ## XHTML tidiness
1132 !! test
1133 <br> to <br />
1134 !! input
1135 1<br>2<br />3
1136 !! result
1137 <p>1<br />2<br />3
1138 </p>
1139 !! end
1141 !! test
1142 Incorrecly removing closing slashes from correctly formed XHTML
1143 !! input
1144 <br style="clear:both;" />
1145 !! result
1146 <p><br style="clear:both;" />
1147 </p>
1148 !! end
1150 !! test 
1151 Failing to transform badly formed HTML into correct XHTML
1152 !! input
1153 <br clear=left>
1154 <br clear=right>
1155 <br clear=all>
1156 !! result
1157 <p><br style="clear:left;" />
1158 <br style="clear:right;" />
1159 <br style="clear:both;" />
1160 </p>
1161 !!end
1163 !! test 
1164 Horizontal ruler (should it add that extra space?)
1165 !! input 
1166 <hr>
1167 <hr >
1168 foo <hr
1169 > bar
1170 !! result 
1171 <hr />
1172 <hr />
1173 foo <hr /> bar
1174 !! end
1177 ### Block-level elements
1179 !! test
1180 Common list
1181 !! input
1182 *Common list
1183 * item 2
1184 *item 3
1185 !! result
1186 <ul><li>Common list
1187 </li><li> item 2
1188 </li><li>item 3
1189 </li></ul>
1191 !! end
1193 !! test
1194 Numbered list
1195 !! input
1196 #Numbered list
1197 #item 2
1198 # item 3
1199 !! result
1200 <ol><li>Numbered list
1201 </li><li>item 2
1202 </li><li> item 3
1203 </li></ol>
1205 !! end
1207 !! test
1208 Mixed list
1209 !! input
1210 *Mixed list
1211 *# with numbers
1212 ** and bullets
1213 *# and numbers
1214 *bullets again
1215 **bullet level 2
1216 ***bullet level 3
1217 ***#Number on level 4
1218 **bullet level 2
1219 **#Number on level 3
1220 **#Number on level 3
1221 *#number level 2
1222 *Level 1
1223 !! result
1224 <ul><li>Mixed list
1225 <ol><li> with numbers
1226 </li></ol>
1227 <ul><li> and bullets
1228 </li></ul>
1229 <ol><li> and numbers
1230 </li></ol>
1231 </li><li>bullets again
1232 <ul><li>bullet level 2
1233 <ul><li>bullet level 3
1234 <ol><li>Number on level 4
1235 </li></ol>
1236 </li></ul>
1237 </li><li>bullet level 2
1238 <ol><li>Number on level 3
1239 </li><li>Number on level 3
1240 </li></ol>
1241 </li></ul>
1242 <ol><li>number level 2
1243 </li></ol>
1244 </li><li>Level 1
1245 </li></ul>
1247 !! end
1249 !! test
1250 List items are not parsed correctly following a <pre> block (bug 785)
1251 !! input
1252 * <pre>foo</pre>
1253 * <pre>bar</pre>
1254 * zar
1255 !! result
1256 <ul><li> <pre>foo</pre>
1257 </li><li> <pre>bar</pre>
1258 </li><li> zar
1259 </li></ul>
1261 !! end
1264 ### Magic variables
1266 !! test
1267 Magic variables
1268 !! input
1269 {{SITENAME}}
1270 !! result
1271 <p>MediaWiki
1272 </p>
1273 !! end
1276 ### Magic links
1278 !! test
1279 Magic links: internal link to RFC (bug 479)
1280 !! input
1281 [[RFC 123]]
1282 !! result
1283 <p><a href="/index.php?title=RFC_123&amp;action=edit" class="new" title="RFC 123">RFC 123</a>
1284 </p>
1285 !! end
1287 !! test
1288 Magic links: RFC (bug 479)
1289 !! input
1290 RFC 822
1291 !! result
1292 <p><a href='http://www.ietf.org/rfc/rfc822.txt' class='external' title="http://www.ietf.org/rfc/rfc822.txt">RFC 822</a>
1293 </p>
1294 !! end
1296 !! test
1297 Magic links: ISBN (bug 1937)
1298 !! input
1299 ISBN 0-306-40615-2
1300 !! result
1301 <p><a href="/index.php?title=Special:Booksources&amp;isbn=0306406152" class="internal">ISBN 0-306-40615-2</a>
1302 </p>
1303 !! end
1305 !! test
1306 Magic links: PMID incorrectly converts space to underscore
1307 !! input
1308 PMID 1234
1309 !! result
1310 <p><a href='http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&amp;db=pubmed&amp;dopt=Abstract&amp;list_uids=1234' class='external' title="http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&amp;db=pubmed&amp;dopt=Abstract&amp;list_uids=1234">PMID 1234</a>
1311 </p>
1312 !! end
1315 ### Templates
1316 ####
1318 !! test
1319 Nonexistant template
1320 !! input
1321 {{thistemplatedoesnotexist}}
1322 !! result
1323 <p><a href="/index.php?title=Template:Thistemplatedoesnotexist&amp;action=edit" class="new" title="Template:Thistemplatedoesnotexist">Template:Thistemplatedoesnotexist</a>
1324 </p>
1325 !! end
1327 !! article
1328 Template:test
1329 !! text
1330 This is a test template
1331 !! endarticle
1333 !! test
1334 Simple template
1335 !! input
1336 {{test}}
1337 !! result
1338 <p>This is a test template
1339 </p>
1340 !! end
1342 !! test
1343 Template with explicit namespace
1344 !! input
1345 {{Template:test}}
1346 !! result
1347 <p>This is a test template
1348 </p>
1349 !! end
1352 !! article
1353 Template:paramtest
1354 !! text
1355 This is a test template with parameter {{{param}}}
1356 !! endarticle
1358 !! test
1359 Template parameter
1360 !! input
1361 {{paramtest|param=foo}}
1362 !! result
1363 <p>This is a test template with parameter foo
1364 </p>
1365 !! end
1367 !! article
1368 Template:paramtestnum
1369 !! text
1370 [[{{{1}}}|{{{2}}}]]
1371 !! endarticle
1373 !! test
1374 Template unnamed parameter
1375 !! input
1376 {{paramtestnum|Main Page|the main page}}
1377 !! result
1378 <p><a href="/wiki/Main_Page" title="Main Page">the main page</a>
1379 </p>
1380 !! end
1382 !! article
1383 Template:templatesimple
1384 !! text
1385 (test)
1386 !! endarticle
1388 !! article
1389 Template:templateredirect
1390 !! text
1391 #redirect [[Template:templatesimple]]
1392 !! endarticle
1394 !! article
1395 Template:templateasargtestnum
1396 !! text
1397 {{{{{1}}}}}
1398 !! endarticle
1400 !! article
1401 Template:templateasargtest
1402 !! text
1403 {{template{{{templ}}}}}
1404 !! endarticle
1406 !! article
1407 Template:templateasargtest2
1408 !! text
1409 {{{{{templ}}}}}
1410 !! endarticle
1412 !! test
1413 Template with template name as unnamed argument
1414 !! input
1415 {{templateasargtestnum|templatesimple}}
1416 !! result
1417 <p>(test)
1418 </p>
1419 !! end
1421 !! test
1422 Template with template name as argument
1423 !! input
1424 {{templateasargtest|templ=simple}}
1425 !! result
1426 <p>(test)
1427 </p>
1428 !! end
1430 !! test
1431 Template with template name as argument (2)
1432 !! input
1433 {{templateasargtest2|templ=templatesimple}}
1434 !! result
1435 <p>(test)
1436 </p>
1437 !! end
1439 !! article
1440 Template:templateasargtestdefault
1441 !! text
1442 {{{{{templ|templatesimple}}}}}
1443 !! endarticle
1445 !! article
1446 Template:templa
1447 !! text
1448 '''templ'''
1449 !! endarticle
1451 !! test
1452 Template with default value
1453 !! input
1454 {{templateasargtestdefault}}
1455 !! result
1456 <p>(test)
1457 </p>
1458 !! end
1460 !! test
1461 Template with default value (value set)
1462 !! input
1463 {{templateasargtestdefault|templ=templa}}
1464 !! result
1465 <p><b>templ</b>
1466 </p>
1467 !! end
1469 !! test
1470 Template redirect
1471 !! input
1472 {{templateredirect}}
1473 !! result
1474 <p>(test)
1475 </p>
1476 !! end
1478 !! test
1479 Template with argument in separate line
1480 !! input
1481 {{ templateasargtest  |
1482  templ = simple }}
1483 !! result
1484 <p>(test)
1485 </p>
1486 !! end
1488 !! test
1489 Template with complex template as argument
1490 !! input
1491 {{paramtest|
1492   param ={{ templateasargtest  |
1493  templ = simple }}}}
1494 !! result
1495 <p>This is a test template with parameter (test)
1496 </p>
1497 !! end
1499 !! test
1500 Template with thumb image (wiht link in description)
1501 !! input
1502 {{paramtest|
1503   param =[[Image:noimage.png|thumb|[[no link|link]] [[no link|caption]]]]}}
1504 !! result
1505 This is a test template with parameter <div class="thumb tright"><div style="width:182px;"><a href="/index.php?title=Special:Upload&amp;wpDestFile=Noimage.png" class="new" title="Image:Noimage.png">Image:Noimage.png</a>  <div class="thumbcaption" ><a href="/index.php?title=No_link&amp;action=edit" class="new" title="No link">link</a> <a href="/index.php?title=No_link&amp;action=edit" class="new" title="No link">caption</a></div></div></div>
1507 !! end
1509 !! article
1510 Template:complextemplate
1511 !! text
1512 {{{1}}} {{paramtest|
1513   param ={{{param}}}}}
1514 !! endarticle
1516 !! test
1517 Template with complex arguments
1518 !! input
1519 {{complextemplate|
1520   param ={{ templateasargtest  |
1521  templ = simple }}|[[Template:complextemplate|link]]}}
1522 !! result
1523 <p><a href="/wiki/Template:Complextemplate" title="Template:Complextemplate">link</a> This is a test template with parameter (test)
1524 </p>
1525 !! end
1527 !! test
1528 BUG 553: link with two variables in a piped link
1529 !! input
1530 {| 
1531 |[[{{{1}}}|{{{2}}}]]
1533 !! result
1534 <table>
1535 <tr>
1536 <td>[[{{{1}}}|{{{2}}}]]
1537 </td></tr></table>
1539 !! end
1541 !! test
1542 Magic variable as template parameter
1543 !! input
1544 {{paramtest|param={{SITENAME}}}}
1545 !! result
1546 <p>This is a test template with parameter MediaWiki
1547 </p>
1548 !! end
1550 !! article
1551 Template:linktest
1552 !! text
1553 [[{{{param}}}|link]]
1554 !! endarticle
1556 !! test
1557 Template parameter as link source
1558 !! input
1559 {{linktest|param=Main Page}}
1560 !! result
1561 <p><a href="/wiki/Main_Page" title="Main Page">link</a>
1562 </p>
1563 !! end
1566 !!article
1567 Template:paramtest2
1568 !! text
1569 including another template, {{paramtest|param={{{arg}}}}}
1570 !! endarticle
1572 !! test
1573 Template passing argument to another template
1574 !! input
1575 {{paramtest2|arg='hmm'}}
1576 !! result
1577 <p>including another template, This is a test template with parameter 'hmm'
1578 </p>
1579 !! end
1581 !! article
1582 Template:Linktest2
1583 !! text
1584 Main Page
1585 !! endarticle
1587 !! test
1588 Template as link source
1589 !! input
1590 [[{{linktest2}}]]
1591 !! result
1592 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
1593 </p>
1594 !! end
1597 !! article
1598 Template:loop1
1599 !! text
1600 {{loop2}}
1601 !! endarticle
1603 !! article
1604 Template:loop2
1605 !! text
1606 {{loop1}}
1607 !! endarticle
1609 !! test
1610 Template infinite loop
1611 !! input
1612 {{loop1}}
1613 !! result
1614 <p>{{loop1}}<!-- WARNING: template loop detected -->
1615 </p>
1616 !! end
1618 !! test
1619 Template from main namespace
1620 !! input
1621 {{:Main Page}}
1622 !! result
1623 <p>blah blah
1624 </p>
1625 !! end
1627 !! article
1628 Template:table
1629 !! text
1630 {| 
1631 | 1 || 2
1632 |- 
1633 | 3 || 4
1635 !! endarticle
1637 !! test
1638 BUG 529: Template with table, not included at beginning of line
1639 !! input
1640 foo {{table}}
1641 !! result
1642 <p>foo 
1643 </p>
1644 <table>
1645 <tr>
1646 <td> 1 </td><td> 2
1647 </td></tr>
1648 <tr>
1649 <td> 3 </td><td> 4
1650 </td></tr></table>
1652 !! end
1654 !! test
1655 BUG 523: Template shouldn't eat newline (or add an extra one before table)
1656 !! input
1658 {{table}}
1659 !! result
1660 <p>foo
1661 </p>
1662 <table>
1663 <tr>
1664 <td> 1 </td><td> 2
1665 </td></tr>
1666 <tr>
1667 <td> 3 </td><td> 4
1668 </td></tr></table>
1670 !! end
1672 !! test
1673 BUG 41: Template parameters shown as broken links
1674 !! input
1675 {{{parameter}}}
1676 !! result
1677 <p>{{{parameter}}}
1678 </p>
1679 !! end
1682 !! article
1683 Template:MSGNW test
1684 !! text
1685 ''None'' of '''this''' should be 
1686 * interepreted
1687  but rather passed unmodified
1688 {{test}}
1689 !! endarticle
1691 # hmm, fix this or just deprecate msgnw and document its behavior?
1692 !! test
1693 msgnw keyword
1694 !! options
1695 disabled
1696 !! input
1697 {{msgnw:MSGNW test}}
1698 !! result
1699 <p>''None'' of '''this''' should be 
1700 * interepreted
1701  but rather passed unmodified
1702 {{test}}
1703 </p>
1704 !! end
1706 !! test
1707 int keyword
1708 !! input
1709 {{int:newmessages|lots of money}}
1710 !! result
1711 <p>You have lots of money.
1712 </p>
1713 !! end
1715 !! article
1716 Template:Includes
1717 !! text
1718 Foo<noinclude>zar</noinclude><includeonly>bar</includeonly>
1719 !! endarticle
1721 !! test
1722 <includeonly> and <noinclude> being included
1723 !! input
1724 {{Includes}}
1725 !! result
1726 <p>Foobar
1727 </p>
1728 !! end
1730 !! article
1731 Template:Includes2
1732 !! text
1733 <onlyinclude>Foo</onlyinclude>bar
1734 !! endarticle
1736 !! test
1737 <onlyinclude> being included
1738 !! input
1739 {{Includes2}}
1740 !! result
1741 <p>Foo
1742 </p>
1743 !! end
1746 !! article
1747 Template:Includes3
1748 !! text
1749 <onlyinclude>Foo</onlyinclude>bar<includeonly>zar</includeonly>
1750 !! endarticle
1752 !! test
1753 <onlyinclude> and <includeonly> being included
1754 !! input
1755 {{Includes3}}
1756 !! result
1757 <p>Foo
1758 </p>
1759 !! end
1761 !! test
1762 <includeonly> and <noinclude> on a page
1763 !! input
1764 Foo<noinclude>zar</noinclude><includeonly>bar</includeonly>
1765 !! result
1766 <p>Foozar
1767 </p>
1768 !! end
1770 !! test
1771 <onlyinclude> on a page
1772 !! input
1773 <onlyinclude>Foo</onlyinclude>bar
1774 !! result
1775 <p>Foobar
1776 </p>
1777 !! end
1780 ### Pre-save transform tests
1782 !! test
1783 pre-save transform: subst:
1784 !! options
1786 !! input
1787 {{subst:test}}
1788 !! result
1789 This is a test template
1790 !! end
1792 !! test
1793 pre-save transform: normal template
1794 !! options
1796 !! input
1797 {{test}}
1798 !! result
1799 {{test}}
1800 !! end
1802 !! test
1803 pre-save transform: nonexistant template
1804 !! options
1806 !! input
1807 {{thistemplatedoesnotexist}}
1808 !! result
1809 {{thistemplatedoesnotexist}}
1810 !! end
1813 !! test
1814 pre-save transform: subst magic variables
1815 !! options
1817 !! input
1818 {{subst:SITENAME}}
1819 !! result
1820 MediaWiki
1821 !! end
1823 # This is bug 89, which I fixed. -- wtm
1824 !! test
1825 pre-save transform: subst: templates with parameters
1826 !! options
1828 !! input
1829 {{subst:paramtest|param="something else"}}
1830 !! result
1831 This is a test template with parameter "something else"
1832 !! end
1835 !! article
1836 Template:nowikitest
1837 !! text
1838 <nowiki>'''not wiki'''</nowiki>
1839 !! endarticle
1841 !! test
1842 pre-save transform: nowiki in subst (bug 1188)
1843 !! options
1845 !! input
1846 {{subst:nowikitest}}
1847 !! result
1848 <nowiki>'''not wiki'''</nowiki>
1849 !! end
1852 !! article
1853 Template:commenttest
1854 !! text
1855 This template has <!-- a comment --> in it.
1856 !! endarticle
1858 !! test
1859 pre-save transform: comment in subst (bug 1936)
1860 !! options
1862 !! input
1863 {{subst:commenttest}}
1864 !! result
1865 This template has <!-- a comment --> in it.
1866 !! end
1869 !! article
1870 Template:dangerous
1871 !!text
1872 <span onmouseover="alert('crap')">Oh no</span>
1873 !!endarticle
1875 !!test
1876 (confirming safety of fix for subst bug 1936)
1877 !! input
1878 {{Template:dangerous}}
1879 !! result
1880 <p><span>Oh no</span>
1881 </p>
1882 !! end
1886 ### Message transform tests
1888 !! test
1889 message transform: magic variables
1890 !! options
1892 !! input
1893 {{SITENAME}}
1894 !! result
1895 MediaWiki
1896 !! end
1898 !! test
1899 message transform: should not transform wiki markup
1900 !! options
1902 !! input
1903 ''test''
1904 !! result
1905 ''test''
1906 !! end
1909 ### Images
1911 !! test
1912 Simple image
1913 !! input
1914 [[Image:foobar.jpg]]
1915 !! result
1916 <p><a href="/wiki/Image:Foobar.jpg" class="image" title="Image:foobar.jpg"><img src="http://example.com/images/3/3a/Foobar.jpg" alt="Image:foobar.jpg" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a>
1917 </p>
1918 !! end
1920 !! test
1921 Right-aligned image
1922 !! input
1923 [[Image:foobar.jpg|right]]
1924 !! result
1925 <div class="floatright"><span><a href="/wiki/Image:Foobar.jpg" class="image" title=""><img src="http://example.com/images/3/3a/Foobar.jpg" alt="" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a></span></div>
1927 !! end
1929 !! test
1930 Image with caption
1931 !! input
1932 [[Image:foobar.jpg|right|Caption text]]
1933 !! result
1934 <div class="floatright"><span><a href="/wiki/Image:Foobar.jpg" class="image" title="Caption text"><img src="http://example.com/images/3/3a/Foobar.jpg" alt="Caption text" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a></span></div>
1936 !! end
1938 !! test
1939 Image with frame and link
1940 !! input
1941 [[Image:Foobar.jpg|frame|left|This is a test image [[Main Page]]]]
1942 !! result
1943 <div class="thumb tleft"><div style="width:1943px;"><a href="/wiki/Image:Foobar.jpg" class="internal" title="This is a test image Main Page"><img src="http://example.com/images/3/3a/Foobar.jpg" alt="This is a test image Main Page" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a>  <div class="thumbcaption" >This is a test image <a href="/wiki/Main_Page" title="Main Page">Main Page</a></div></div></div>
1945 !! end
1947 !! test
1948 Link to image page
1949 !! input
1950 [[:Image:test]]
1951 !! result
1952 <p><a href="/wiki/Image:Test" title="Image:Test">Image:test</a>
1953 </p>
1954 !! end
1956 !! test
1957 Frameless image caption with a free URL
1958 !! input
1959 [[Image:foobar.jpg|http://example.com]]
1960 !! result
1961 <p><a href="/wiki/Image:Foobar.jpg" class="image" title="http://example.com"><img src="http://example.com/images/3/3a/Foobar.jpg" alt="http://example.com" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a>
1962 </p>
1963 !! end
1965 !! test
1966 Thumbnail image caption with a free URL
1967 !! input
1968 [[Image:foobar.jpg|thumb|http://example.com]]
1969 !! result
1970 <div class="thumb tright"><div style="width:182px;"><a href="/wiki/Image:Foobar.jpg" class="internal" title="http://example.com"><img src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" alt="http://example.com" width="180" height="20" longdesc="/wiki/Image:Foobar.jpg" /></a>  <div class="thumbcaption" ><div class="magnify" style="float:right"><a href="/wiki/Image:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="Enlarge" /></a></div><a href="http://example.com" class='external free' title="http://example.com" rel="nofollow">http://example.com</a></div></div></div>
1972 !! end
1974 !! test
1975 BUG 1887: A ISBN with a thumbnail
1976 !! input
1977 [[Image:foobar.jpg|thumb|ISBN 12354]]
1978 !! result
1979 <div class="thumb tright"><div style="width:182px;"><a href="/wiki/Image:Foobar.jpg" class="internal" title="ISBN 12354"><img src="http://example.com/images/3/3a/Foobar.jpg" alt="ISBN 12354" longdesc="/wiki/Image:Foobar.jpg" height="180" width="180"></a>  <div class="thumbcaption"><div class="magnify" style="float:right;"><a href="/wiki/Image:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="Enlarge"></a></div><a href="index.php?title=Special:Booksources&amp;isbn=12354" class="internal">ISBN 12354</a></div></div></div>
1980 !! end
1982 !! test
1983 BUG 1887: A <math> with a thumbnail
1984 !! input
1985 [[Image:foobar.jpg|thumb|<math>2+2</math>]]
1986 !! result
1987 <div class="thumb tright"><div style="width:182px;"><a href="/wiki/Image:Foobar.jpg" class="internal" title="2+2"><img src="http://example.com/images/3/3a/Foobar.jpg" alt="2+2" longdesc="/wiki/Image:Foobar.jpg" height="180" width="180"></a>  <div class="thumbcaption"><div class="magnify" style="float:right;"><a href="/wiki/Image:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="Enlarge"></a></div>&lt;math&gt;2+2&lt;math&gt;</div></div></div>
1988 !! end
1990 # Pending resolution to bug 368
1991 !! test
1992 BUG 648: Frameless image caption with a link
1993 !! input
1994 [[Image:foobar.jpg|text with a [[link]] in it]]
1995 !! result
1996 <p><a href="/wiki/Image:Foobar.jpg" class="image" title="text with a link in it"><img src="http://example.com/images/3/3a/Foobar.jpg" alt="text with a link in it" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a>
1997 </p>
1998 !! end
2000 !! test
2001 BUG 648: Frameless image caption with a link (suffix)
2002 !! input
2003 [[Image:foobar.jpg|text with a [[link]]foo in it]]
2004 !! result
2005 <p><a href="/wiki/Image:Foobar.jpg" class="image" title="text with a linkfoo in it"><img src="http://example.com/images/3/3a/Foobar.jpg" alt="text with a linkfoo in it" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a>
2006 </p>
2007 !! end
2009 !! test
2010 BUG 648: Frameless image caption with an interwiki link
2011 !! input
2012 [[Image:foobar.jpg|text with a [[MeatBall:Link]] in it]]
2013 !! result
2014 <p><a href="/wiki/Image:Foobar.jpg" class="image" title="text with a MeatBall:Link in it"><img src="http://example.com/images/3/3a/Foobar.jpg" alt="text with a MeatBall:Link in it" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a>
2015 </p>
2016 !! end
2018 !! test
2019 BUG 648: Frameless image caption with a piped interwiki link
2020 !! input
2021 [[Image:foobar.jpg|text with a [[MeatBall:Link|link]] in it]]
2022 !! result
2023 <p><a href="/wiki/Image:Foobar.jpg" class="image" title="text with a link in it"><img src="http://example.com/images/3/3a/Foobar.jpg" alt="text with a link in it" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a>
2024 </p>
2025 !! end
2027 !! test
2028 Escape HTML special chars in image alt text
2029 !! input
2030 [[Image:foobar.jpg|& < > "]]
2031 !! result
2032 <p><a href="/wiki/Image:Foobar.jpg" class="image" title="&amp; &lt; &gt; &quot;"><img src="http://example.com/images/3/3a/Foobar.jpg" alt="&amp; &lt; &gt; &quot;" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a>
2033 </p>
2034 !! end
2036 !! test
2037 BUG 499: Alt text should have &#1234;, not &amp;1234;
2038 !! input
2039 [[Image:foobar.jpg|&#9792;]]
2040 !! result
2041 <p><a href="/wiki/Image:Foobar.jpg" class="image" title="&#9792;"><img src="http://example.com/images/3/3a/Foobar.jpg" alt="&#9792;" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a>
2042 </p>
2043 !! end
2045 !! test
2046 Broken image caption with link
2047 !! input
2048 [[Image:Foobar.jpg|thumb|This is a broken caption. But [[Main Page|this]] is just an ordinary link.
2049 !! result
2050 <p>[[Image:Foobar.jpg|thumb|This is a broken caption. But <a href="/wiki/Main_Page" title="Main Page">this</a> is just an ordinary link.
2051 </p>
2052 !! end
2054 !! test
2055 Image caption containing another image
2056 !! input
2057 [[Image:Foobar.jpg|thumb|This is a caption with another [[Image:icon.png|image]] inside it!]]
2058 !! result
2059 <div class="thumb tright"><div style="width:182px;"><a href="/wiki/Image:Foobar.jpg" class="internal" title="This is a caption with another Image:Icon.png inside it!"><img src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" alt="This is a caption with another Image:Icon.png inside it!" width="180" height="20" longdesc="/wiki/Image:Foobar.jpg" /></a>  <div class="thumbcaption" ><div class="magnify" style="float:right"><a href="/wiki/Image:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="Enlarge" /></a></div>This is a caption with another <a href="/index.php?title=Special:Upload&amp;wpDestFile=Icon.png" class="new" title="Image:Icon.png">Image:Icon.png</a> inside it!</div></div></div>
2061 !! end
2063 !! test
2064 Image caption containing a newline
2065 !! input
2066 [[Image:Foobar.jpg|This
2067 *is some text]]
2068 !! result
2069 <p><a href="/wiki/Image:Foobar.jpg" class="image" title="This *is some text"><img src="http://example.com/images/3/3a/Foobar.jpg" alt="This *is some text" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a>
2070 </p>
2071 !!end
2074 !! test
2075 Bug 3090: External links other than http: in image captions
2076 !! input
2077 [[Image:Foobar.jpg|thumb|200px|This caption has [irc://example.net irc] and [https://example.com Secure] ext links in it.]]
2078 !! result
2079 <div class="thumb tright"><div style="width:202px;"><a href="/wiki/Image:Foobar.jpg" class="internal" title="This caption has irc and Secure ext links in it."><img src="http://example.com/images/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg" alt="This caption has irc and Secure ext links in it." width="200" height="23" longdesc="/wiki/Image:Foobar.jpg" /></a>  <div class="thumbcaption" ><div class="magnify" style="float:right"><a href="/wiki/Image:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="Enlarge" /></a></div>This caption has <a href="irc://example.net" class='external text' title="irc://example.net" rel="nofollow">irc</a> and <a href="https://example.com" class='external text' title="https://example.com" rel="nofollow">Secure</a> ext links in it.</div></div></div>
2081 !! end
2085 ### Subpages
2087 !! article
2088 Subpage test/subpage
2089 !! text
2091 !! endarticle
2093 !! test
2094 Subpage link
2095 !! options
2096 subpage title=[[Subpage test]]
2097 !! input
2098 [[/subpage]]
2099 !! result
2100 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a>
2101 </p>
2102 !! end
2104 !! test
2105 Subpage noslash link
2106 !! options
2107 subpage title=[[Subpage test]]
2108 !!input
2109 [[/subpage/]]
2110 !! result
2111 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">subpage</a>
2112 </p>
2113 !! end
2115 !! test
2116 Disabled subpages
2117 !! input
2118 [[/subpage]]
2119 !! result
2120 <p><a href="/index.php?title=/subpage&amp;action=edit" class="new" title="/subpage">/subpage</a>
2121 </p>
2122 !! end
2124 !! test
2125 BUG 561: {{/Subpage}}
2126 !! options
2127 subpage title=[[Page]]
2128 !! input
2129 {{/Subpage}}
2130 !! result
2131 <p><a href="/index.php?title=Page/Subpage&amp;action=edit" class="new" title="Page/Subpage">Page/Subpage</a>
2132 </p>
2133 !! end
2136 ### Categories
2138 !! article
2139 Category:MediaWiki User's Guide
2140 !! text
2141 blah
2142 !! endarticle
2144 !! test
2145 Link to category
2146 !! input
2147 [[:Category:MediaWiki User's Guide]]
2148 !! result
2149 <p><a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User's Guide">Category:MediaWiki User's Guide</a>
2150 </p>
2151 !! end
2153 !! test
2154 Simple category
2155 !! options
2157 !! input
2158 [[Category: MediaWiki User's Guide]]
2159 !! result
2160 <a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User's Guide">MediaWiki User's Guide</a>
2161 !! end
2164 ### Inter-language links
2166 !! test
2167 Inter-language links
2168 !! options
2170 !! input
2171 [[es:Alimento]]
2172 [[fr:Nourriture]]
2173 [[zh:&#39135;&#21697;]]
2174 !! result
2175 es:Alimento fr:Nourriture zh:食品
2176 !! end
2179 ### Sections
2181 !! test
2182 Basic section headings
2183 !! options
2184 title=[[Parser test script]]
2185 !! input
2186 == Headline 1 ==
2187 Some text
2189 ==Headline 2==
2190 More
2191 ===Smaller headline===
2192 Blah blah
2193 !! result
2194 <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>
2195 <p>Some text
2196 </p>
2197 <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>
2198 <p>More
2199 </p>
2200 <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>
2201 <p>Blah blah
2202 </p>
2203 !! end
2205 !! test
2206 Section headings with TOC
2207 !! options
2208 title=[[Parser test script]]
2209 !! input
2210 == Headline 1 ==
2211 === Subheadline 1 ===
2212 ===== Skipping a level =====
2213 ====== Skipping a level ======
2215 == Headline 2 ==
2216 Some text
2217 ===Another headline===
2218 !! result
2219 <table id='toc' class='toc'><tr><td><div id='toctitle'><h2>Contents</h2></div>
2220 <ul>
2221 <li class='toclevel-1'><a href="#Headline_1"><span class="tocnumber">1</span> <span class="toctext">Headline 1</span></a>
2222 <ul>
2223 <li class='toclevel-2'><a href="#Subheadline_1"><span class="tocnumber">1.1</span> <span class="toctext">Subheadline 1</span></a>
2224 <ul>
2225 <li class='toclevel-3'><a href="#Skipping_a_level"><span class="tocnumber">1.1.1</span> <span class="toctext">Skipping a level</span></a>
2226 <ul>
2227 <li class='toclevel-4'><a href="#Skipping_a_level_2"><span class="tocnumber">1.1.1.1</span> <span class="toctext">Skipping a level</span></a></li>
2228 </ul>
2229 </li>
2230 </ul>
2231 </li>
2232 </ul>
2233 </li>
2234 <li class='toclevel-1'><a href="#Headline_2"><span class="tocnumber">2</span> <span class="toctext">Headline 2</span></a>
2235 <ul>
2236 <li class='toclevel-2'><a href="#Another_headline"><span class="tocnumber">2.1</span> <span class="toctext">Another headline</span></a></li>
2237 </ul>
2238 </li>
2239 </ul>
2240 </td></tr></table>
2241 <script type="text/javascript"> if (window.showTocToggle) { var tocShowText = "show"; var tocHideText = "hide"; showTocToggle(); } </script>
2242 <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>
2243 <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>
2244 <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>
2245 <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>
2246 <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>
2247 <p>Some text
2248 </p>
2249 <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>
2251 !! end
2253 # perl -e 'print "="x$_," Level $_ heading","="x$_,"\n" for 1..10'
2254 !! test
2255 Handling of sections up to level 6 and beyond
2256 !! input 
2257 = Level 1 Heading=
2258 == Level 2 Heading==
2259 === Level 3 Heading===
2260 ==== Level 4 Heading====
2261 ===== Level 5 Heading=====
2262 ====== Level 6 Heading======
2263 ======= Level 7 Heading=======
2264 ======== Level 8 Heading========
2265 ========= Level 9 Heading=========
2266 ========== Level 10 Heading==========
2267 !! result
2268 <table id='toc' class='toc'><tr><td><div id='toctitle'><h2>Contents</h2></div>
2269 <ul>
2270 <li class='toclevel-1'><a href="#Level_1_Heading"><span class="tocnumber">1</span> <span class="toctext">Level 1 Heading</span></a>
2271 <ul>
2272 <li class='toclevel-2'><a href="#Level_2_Heading"><span class="tocnumber">1.1</span> <span class="toctext">Level 2 Heading</span></a>
2273 <ul>
2274 <li class='toclevel-3'><a href="#Level_3_Heading"><span class="tocnumber">1.1.1</span> <span class="toctext">Level 3 Heading</span></a>
2275 <ul>
2276 <li class='toclevel-4'><a href="#Level_4_Heading"><span class="tocnumber">1.1.1.1</span> <span class="toctext">Level 4 Heading</span></a>
2277 <ul>
2278 <li class='toclevel-5'><a href="#Level_5_Heading"><span class="tocnumber">1.1.1.1.1</span> <span class="toctext">Level 5 Heading</span></a>
2279 <ul>
2280 <li class='toclevel-6'><a href="#Level_6_Heading"><span class="tocnumber">1.1.1.1.1.1</span> <span class="toctext">Level 6 Heading</span></a></li>
2281 <li class='toclevel-6'><a href="#.3D_Level_7_Heading.3D"><span class="tocnumber">1.1.1.1.1.2</span> <span class="toctext">= Level 7 Heading=</span></a></li>
2282 <li class='toclevel-6'><a href="#.3D.3D_Level_8_Heading.3D.3D"><span class="tocnumber">1.1.1.1.1.3</span> <span class="toctext">== Level 8 Heading==</span></a></li>
2283 <li class='toclevel-6'><a href="#.3D.3D.3D_Level_9_Heading.3D.3D.3D"><span class="tocnumber">1.1.1.1.1.4</span> <span class="toctext">=== Level 9 Heading===</span></a></li>
2284 <li class='toclevel-6'><a href="#.3D.3D.3D.3D_Level_10_Heading.3D.3D.3D.3D"><span class="tocnumber">1.1.1.1.1.5</span> <span class="toctext">==== Level 10 Heading====</span></a></li>
2285 </ul>
2286 </li>
2287 </ul>
2288 </li>
2289 </ul>
2290 </li>
2291 </ul>
2292 </li>
2293 </ul>
2294 </li>
2295 </ul>
2296 </td></tr></table>
2297 <p><script type="text/javascript"> if (window.showTocToggle) { var tocShowText = "show"; var tocHideText = "hide"; showTocToggle(); } </script>
2298 </p>
2299 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Parser test">edit</a>]</div><a name="Level_1_Heading"></a><h1> Level 1 Heading</h1>
2300 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Parser test">edit</a>]</div><a name="Level_2_Heading"></a><h2> Level 2 Heading</h2>
2301 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=3" title="Parser test">edit</a>]</div><a name="Level_3_Heading"></a><h3> Level 3 Heading</h3>
2302 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=4" title="Parser test">edit</a>]</div><a name="Level_4_Heading"></a><h4> Level 4 Heading</h4>
2303 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=5" title="Parser test">edit</a>]</div><a name="Level_5_Heading"></a><h5> Level 5 Heading</h5>
2304 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=6" title="Parser test">edit</a>]</div><a name="Level_6_Heading"></a><h6> Level 6 Heading</h6>
2305 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=7" title="Parser test">edit</a>]</div><a name=".3D_Level_7_Heading.3D"></a><h6>= Level 7 Heading=</h6>
2306 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=8" title="Parser test">edit</a>]</div><a name=".3D.3D_Level_8_Heading.3D.3D"></a><h6>== Level 8 Heading==</h6>
2307 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=9" title="Parser test">edit</a>]</div><a name=".3D.3D.3D_Level_9_Heading.3D.3D.3D"></a><h6>=== Level 9 Heading===</h6>
2308 <div class="editsection" style="float:right;margin-left:5px;">[<a href="/index.php?title=Parser_test&amp;action=edit&amp;section=10" title="Parser test">edit</a>]</div><a name=".3D.3D.3D.3D_Level_10_Heading.3D.3D.3D.3D"></a><h6>==== Level 10 Heading====</h6>
2310 !! end
2312 !! test
2313 Resolving duplicate section names
2314 !! options
2315 title=[[Parser test script]]
2316 !! input
2317 == Foo bar ==
2318 == Foo bar ==
2319 !! result
2320 <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>
2321 <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>
2323 !! end
2325 !! article
2326 Template:sections
2327 !! text
2328 ===Section 1===
2329 ==Section 2==
2330 !! endarticle
2332 !! test
2333 Template with sections, __NOTOC__
2334 !! options
2335 title=[[Parser test script]]
2336 !! input
2337 __NOTOC__
2338 ==Section 0==
2339 {{sections}}
2340 ==Section 4==
2341 !! result
2342 <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>
2343 <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>
2344 <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>
2345 <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>
2347 !! end
2349 !! test
2350 __NOEDITSECTION__ keyword
2351 !! input
2352 __NOEDITSECTION__
2353 ==Section 1==
2354 ==Section 2==
2355 !! result
2356 <a name="Section_1"></a><h2>Section 1</h2>
2357 <a name="Section_2"></a><h2>Section 2</h2>
2359 !! end
2361 !! test
2362 Link inside a section heading
2363 !! options
2364 title=[[Parser test script]]
2365 !! input
2366 ==Section with a [[Main Page|link]] in it==
2367 !! result
2368 <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_with_a_link_in_it"></a><h2>Section with a <a href="/wiki/Main_Page" title="Main Page">link</a> in it</h2>
2370 !! end
2373 !! test
2374 BUG 1219 URL next to image (good)
2375 !! input
2376 http://example.com [[Image:foobar.jpg]]
2377 !! result
2378 <p><a href="http://example.com" class='external free' title="http://example.com" rel="nofollow">http://example.com</a> <a href="/wiki/Image:Foobar.jpg" class="image" title="Image:foobar.jpg"><img src="http://example.com/images/3/3a/Foobar.jpg" alt="Image:foobar.jpg" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a>
2379 </p>
2380 !!end
2382 !! test
2383 BUG 1219 URL next to image (broken)
2384 !! input
2385 http://example.com[[Image:foobar.jpg]]
2386 !! result
2387 <p><a href="http://example.com" class='external free' title="http://example.com" rel="nofollow">http://example.com</a><a href="/wiki/Image:Foobar.jpg" class="image" title="Image:foobar.jpg"><img src="http://example.com/images/3/3a/Foobar.jpg" alt="Image:foobar.jpg" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a>
2388 </p>
2389 !!end
2391 !! test
2392 Bug 1186 news: in the middle of text
2393 !! input
2394 http://en.wikinews.org/wiki/Wikinews:Workplace
2395 !! result
2396 <p><a href="http://en.wikinews.org/wiki/Wikinews:Workplace" class='external free' title="http://en.wikinews.org/wiki/Wikinews:Workplace" rel="nofollow">http://en.wikinews.org/wiki/Wikinews:Workplace</a>
2397 </p>
2398 !!end
2401 !! test
2402 Namespaced link must have a title
2403 !! input
2404 [[Project:]]
2405 !! result
2406 <p>[[Project:]]
2407 </p>
2408 !!end
2410 !! test
2411 Namespaced link must have a title (bad fragment version)
2412 !! input
2413 [[Project:#fragment]]
2414 !! result
2415 <p>[[Project:#fragment]]
2416 </p>
2417 !!end
2420 !! test
2421 div with no attributes
2422 !! input
2423 <div>HTML rocks</div>
2424 !! result
2425 <div>HTML rocks</div>
2427 !! end
2429 !! test
2430 div with double-quoted attribute
2431 !! input
2432 <div id="rock">HTML rocks</div>
2433 !! result
2434 <div id="rock">HTML rocks</div>
2436 !! end
2438 !! test
2439 div with single-quoted attribute
2440 !! input
2441 <div id='rock'>HTML rocks</div>
2442 !! result
2443 <div id="rock">HTML rocks</div>
2445 !! end
2447 !! test
2448 div with unquoted attribute
2449 !! input
2450 <div id=rock>HTML rocks</div>
2451 !! result
2452 <div id="rock">HTML rocks</div>
2454 !! end
2456 !! test
2457 div with illegal double attributes
2458 !! input
2459 <div align="center" align="right">HTML rocks</div>
2460 !! result
2461 <div align="right">HTML rocks</div>
2463 !!end
2465 !! test
2466 HTML multiple attributes correction
2467 !! input
2468 <p class="error" class="awesome">Awesome!</p>
2469 !! result
2470 <p class="awesome">Awesome!</p>
2472 !!end
2474 !! test
2475 Table multiple attributes correction
2476 !! input
2478 !+ class="error" class="awesome"| status
2480 !! result
2481 <table>
2482 <tr>
2483 <th class="awesome"> status
2484 </th></tr></table>
2486 !!end
2488 !! test
2489 DIV IN UPPERCASE
2490 !! input
2491 <DIV ALIGN="center">HTML ROCKS</DIV>
2492 !! result
2493 <div align="center">HTML ROCKS</div>
2495 !!end
2498 !! test
2499 text with amp in the middle of nowhere
2500 !! input
2501 Remember AT&T?
2502 !!result
2503 <p>Remember AT&amp;T?
2504 </p>
2505 !! end
2507 !! test
2508 text with character entity: eacute
2509 !! input
2510 I always thought &eacute; was a cute letter.
2511 !! result
2512 <p>I always thought &eacute; was a cute letter.
2513 </p>
2514 !! end
2516 !! test
2517 text with undefined character entity: xacute
2518 !! input
2519 I always thought &xacute; was a cute letter.
2520 !! result
2521 <p>I always thought &amp;xacute; was a cute letter.
2522 </p>
2523 !! end
2527 ### Media links
2530 !! test
2531 Media link
2532 !! input
2533 [[Media:Foobar.jpg]]
2534 !! result
2535 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class='internal' title="Foobar.jpg">Media:Foobar.jpg</a>
2536 </p>
2537 !! end
2539 !! test
2540 Media link with text
2541 !! input
2542 [[Media:Foobar.jpg|A neat file to look at]]
2543 !! result
2544 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class='internal' title="Foobar.jpg">A neat file to look at</a>
2545 </p>
2546 !! end
2548 # FIXME: this is still bad HTML tag nesting
2549 !! test
2550 Media link with nasty text
2551 !! input
2552 [[Media:Foobar.jpg|Safe Link<div style=display:none>" onmouseover="alert(document.cookie)" onfoo="</div>]]
2553 !! result
2554 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class='internal' title="Foobar.jpg">Safe Link<div style="display:none">" onmouseover="alert(document.cookie) onfoo="</div></a>
2555 </p>
2556 !! end
2558 !! test
2559 Media link to nonexistent file (bug 1702)
2560 !! input
2561 [[Media:No such.jpg]]
2562 !! result
2563 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=No_such.jpg" class='new' title="No such.jpg">Media:No such.jpg</a>
2564 </p>
2565 !! end
2567 !! test
2568 Image link to nonexistent file (bug 1850 - good)
2569 !! input
2570 [[Image:No such.jpg]]
2571 !! result
2572 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=No_such.jpg" class="new" title="Image:No such.jpg">Image:No such.jpg</a>
2573 </p>
2574 !! end
2576 !! test
2577 :Image link to nonexistent file (bug 1850 - bad)
2578 !! input
2579 [[:Image:No such.jpg]]
2580 !! result
2581 <p><a href="/index.php?title=Image:No_such.jpg&amp;action=edit" class="new" title="Image:No such.jpg">Image:No such.jpg</a>
2582 </p>
2583 !! end
2587 !! test
2588 Character reference normalization in link text (bug 1938)
2589 !! input
2590 [[Main Page|this&that]]
2591 !! result
2592 <p><a href="/wiki/Main_Page" title="Main Page">this&amp;that</a>
2593 </p>
2594 !!end
2596 !! test
2597 Empty attribute crash test (bug 2067)
2598 !! input
2599 <font color="">foo</font>
2600 !! result
2601 <p><font color="">foo</font>
2602 </p>
2603 !! end
2605 !! test
2606 Empty attribute crash test single-quotes (bug 2067)
2607 !! input
2608 <font color=''>foo</font>
2609 !! result
2610 <p><font color="">foo</font>
2611 </p>
2612 !! end
2614 !! test
2615 Attribute test: equals, then nothing
2616 !! input
2617 <font color=>foo</font>
2618 !! result
2619 <p><font>foo</font>
2620 </p>
2621 !! end
2623 !! test
2624 Attribute test: unquoted value
2625 !! input
2626 <font color=x>foo</font>
2627 !! result
2628 <p><font color="x">foo</font>
2629 </p>
2630 !! end
2632 !! test
2633 Attribute test: unquoted but illegal value (hash)
2634 !! input
2635 <font color=#x>foo</font>
2636 !! result
2637 <p><font color="#x">foo</font>
2638 </p>
2639 !! end
2641 !! test
2642 Attribute test: no value
2643 !! input
2644 <font color>foo</font>
2645 !! result
2646 <p><font color="color">foo</font>
2647 </p>
2648 !! end
2650 !! test
2651 Bug 2095: link with three closing brackets
2652 !! input
2653 [[Main Page]]]
2654 !! result
2655 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>]
2656 </p>
2657 !! end
2659 !! test
2660 Bug 2095: link with pipe and three closing brackets
2661 !! input
2662 [[Main Page|link]]]
2663 !! result
2664 <p><a href="/wiki/Main_Page" title="Main Page">link</a>]
2665 </p>
2666 !! end
2670 ### Safety
2673 !! article
2674 Template:Dangerous attribute
2675 !! text
2676 " onmouseover="alert(document.cookie)
2677 !! endarticle
2679 !! article
2680 Template:Dangerous style attribute
2681 !! text
2682 border-size: expression(alert(document.cookie))
2683 !! endarticle
2685 !! article
2686 Template:Div style
2687 !! text
2688 <div style="float: right; {{{1}}}">Magic div</div>
2689 !! endarticle
2691 !! test
2692 Bug 2304: HTML attribute safety (safe template; regression bug 2309)
2693 !! input
2694 <div title="{{test}}"></div>
2695 !! result
2696 <div title="This is a test template"></div>
2698 !! end
2700 !! test
2701 Bug 2304: HTML attribute safety (dangerous template; 2309)
2702 !! input
2703 <div title="{{dangerous attribute}}"></div>
2704 !! result
2705 <div title=""></div>
2707 !! end
2709 !! test
2710 Bug 2304: HTML attribute safety (dangerous style template; 2309)
2711 !! input
2712 <div style="{{dangerous style attribute}}"></div>
2713 !! result
2714 <div></div>
2716 !! end
2718 !! test
2719 Bug 2304: HTML attribute safety (safe parameter; 2309)
2720 !! input
2721 {{div style|width: 200px}}
2722 !! result
2723 <div style="float: right; width: 200px">Magic div</div>
2725 !! end
2727 !! test
2728 Bug 2304: HTML attribute safety (unsafe parameter; 2309)
2729 !! input
2730 {{div style|width: expression(alert(document.cookie))}}
2731 !! result
2732 <div>Magic div</div>
2734 !! end
2736 !! test
2737 Bug 2304: HTML attribute safety (unsafe breakout parameter; 2309)
2738 !! input
2739 {{div style|"><script>alert(document.cookie)</script>}}
2740 !! result
2741 <div>Magic div</div>
2743 !! end
2745 !! test
2746 Bug 2304: HTML attribute safety (unsafe breakout parameter 2; 2309)
2747 !! input
2748 {{div style|" ><script>alert(document.cookie)</script>}}
2749 !! result
2750 <div style="float: right; ">Magic div</div>
2752 !! end
2754 !! test
2755 Bug 2304: HTML attribute safety (link)
2756 !! input
2757 <div title="[[Main Page]]"></div>
2758 !! result
2759 <div title="&#91;&#91;Main Page]]"></div>
2761 !! end
2763 !! test
2764 Bug 2304: HTML attribute safety (italics)
2765 !! input
2766 <div title="''foobar''"></div>
2767 !! result
2768 <div title="&#39;&#39;foobar&#39;&#39;"></div>
2770 !! end
2772 !! test
2773 Bug 2304: HTML attribute safety (bold)
2774 !! input
2775 <div title="'''foobar'''"></div>
2776 !! result
2777 <div title="&#39;&#39;'foobar&#39;&#39;'"></div>
2779 !! end
2781 !! test
2782 Bug 2304: HTML attribute safety (ISBN)
2783 !! input
2784 <div title="ISBN 1234567890"></div>
2785 !! result
2786 <div title="&#73;SBN 1234567890"></div>
2788 !! end
2790 !! test
2791 Bug 2304: HTML attribute safety (RFC)
2792 !! input
2793 <div title="RFC 1234"></div>
2794 !! result
2795 <div title="&#82;FC 1234"></div>
2797 !! end
2799 !! test
2800 Bug 2304: HTML attribute safety (PMID)
2801 !! input
2802 <div title="PMID 1234567890"></div>
2803 !! result
2804 <div title="&#80;MID 1234567890"></div>
2806 !! end
2808 !! test
2809 Bug 2304: HTML attribute safety (web link)
2810 !! input
2811 <div title="http://example.com/"></div>
2812 !! result
2813 <div title="http&#58;//example.com/"></div>
2815 !! end
2817 !! test
2818 Bug 2304: HTML attribute safety (named web link)
2819 !! input
2820 <div title="[http://example.com/ link]"></div>
2821 !! result
2822 <div title="&#91;http&#58;//example.com/ link]"></div>
2824 !! end
2826 !! test
2827 Bug 3244: HTML attribute safety (extension; safe)
2828 !! input
2829 <div style="<nowiki>background:blue</nowiki>"></div>
2830 !! result
2831 <div style="background:blue"></div>
2833 !! end
2835 !! test
2836 Bug 3244: HTML attribute safety (extension; unsafe)
2837 !! input
2838 <div style="<nowiki>border-left:expression(alert(document.cookie))</nowiki>"></div>
2839 !! result
2840 <div></div>
2842 !! end
2845 !! test
2846 Math section safety when disabled
2847 !! input
2848 <math><script>alert(document.cookies);</script></math>
2849 !! result
2850 <p>&lt;math&gt;&lt;script&gt;alert(document.cookies);&lt;/script&gt;&lt;/math&gt;
2851 </p>
2852 !! end
2855 !! test
2856 Table attribute legitimate extension
2857 !! input
2859 !+ style="<nowiki>color:blue</nowiki>"| status
2861 !! result
2862 <table>
2863 <tr>
2864 <th style="color:blue"> status
2865 </th></tr></table>
2867 !!end
2869 !! test
2870 Table attribute safety
2871 !! input
2873 !+ style="<nowiki>border-width:expression(0+alert(document.cookie))</nowiki>"| status
2875 !! result
2876 <table>
2877 <tr>
2878 <th> status
2879 </th></tr></table>
2881 !! end
2884 ### Parser hooks
2886 !! test
2887 Parser hook: empty input
2888 !! input
2889 <tag></tag>
2890 !! result
2891 !! end
2893 !! test
2894 Parser hook: basic input
2895 !! input
2896 <tag>input</tag>
2897 !! result
2898 <p>input
2899 </p>
2900 !! end
2902 !! test
2903 Parser hook: case insensetive
2904 !! input
2905 <TaG>input</TAg>
2906 !! result
2907 <p>input
2908 </p>
2909 !! end
2911 !! test
2912 Parser hook: basic arguments
2913 !! input
2914 <tag width=200 height = "100" depth = '50' square></tag>
2915 !! result
2916 <pre>
2917 Array
2919     [width] => 200
2920     [height] => 100
2921     [depth] => 50
2922     [square] => square
2924 </pre>
2926 !! end
2928 !! test
2929 Parser hook: empty input using terminated empty elements (bug 2374)
2930 !! input
2931 <tag foo=bar/>text
2932 !! result
2933 <pre>
2934 Array
2936     [foo] => bar
2938 </pre>
2939 text
2940 !! end
2942 # </tag> should be output literally since there is no matching tag that begins it
2943 !! test
2944 Parser hook: basic arguments using terminated empty elements (bug 2374)
2945 !! input
2946 <tag width=200 height = "100" depth = '50' square/>
2947 other stuff
2948 </tag>
2949 !! result
2950 <pre>
2951 Array
2953     [width] => 200
2954     [height] => 100
2955     [depth] => 50
2956     [square] => square
2958 </pre>
2959 other stuff
2960 </tag>
2962 !! end
2965 # Nested template calls; this case was broken by Parser.php rev 1.506,
2966 # since reverted.
2968 !! article
2969 Template:One-parameter
2970 !! text
2971 (My parameter is: {{{1}}})
2972 !! endarticle
2974 !! article
2975 Template:Map-one-parameter
2976 !! text
2977 {{{{{1}}}|{{{2}}}}}
2978 !! endarticle
2980 !! test
2981 Nested template calls
2982 !! input
2983 {{Map-one-parameter|One-parameter|param}}
2984 !! result
2985 <p>(My parameter is: param)
2986 </p>
2987 !! end
2990 # More MSIE fun discovered by Tom Gilder
2992 !! test
2993 MSIE CSS safety test: spurious slash
2994 !! input
2995 <div style="background-image:u\rl(javascript:alert('boo'))">evil</div>
2996 !! result
2997 <div>evil</div>
2999 !! end
3001 !! test
3002 MSIE CSS safety test: hex code
3003 !! input
3004 <div style="background-image:u\72l(javascript:alert('boo'))">evil</div>
3005 !! result
3006 <div>evil</div>
3008 !! end
3010 !! test
3011 MSIE CSS safety test: comment in url
3012 !! input
3013 <div style="background-image:u/**/rl(javascript:alert('boo'))">evil</div>
3014 !! result
3015 <div style="background-image:u rl(javascript:alert('boo'))">evil</div>
3017 !! end
3019 !! test
3020 MSIE CSS safety test: comment in expression
3021 !! input
3022 <div style="background-image:expres/**/sion(alert('boo4'))">evil4</div>
3023 !! result
3024 <div style="background-image:expres sion(alert('boo4'))">evil4</div>
3026 !! end
3029 TODO:
3030 more images
3031 more tables
3032 math
3033 character entities
3034 and much more