]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blob - maintenance/parserTests.txt
MediaWiki 1.5.8 (initial commit)
[autoinstallsdev/mediawiki.git] / maintenance / parserTests.txt
1 # MediaWiki Parser test cases
2 # Some taken from http://meta.wikimedia.org/wiki/Parser_testing
3 # All (C) their respective authors and released under the GPL
4 #
5 # The syntax should be fairly self-explanatory.
6 #
7 # Currently supported test options:
8 #       One of the following three:
9 #
10 #       (default)       generate HTML output
11 #       pst             apply pre-save transform
12 #       msg             apply message transform
13 #
14 #       Plus any combination of these:
15 #
16 #       cat             add category links
17 #       ill             add inter-language links
18 #       subpage         enable subpages (disabled by default)
19 #       title=[[XXX]]   run test using article title XXX
20 #       disabled        do not run test
21 #
22 # For testing purposes, temporary articles can created:
23 # !!article / NAMESPACE:TITLE / !!text / ARTICLE TEXT / !!endarticle
24 # where '/' denotes a newline.
25
26 # This is the standard article assumed to exist.
27 !! article
28 Main Page
29 !! text
30 blah blah
31 !! endarticle
32
33 ###
34 ### Basic tests
35 ###
36 !! test
37 Blank input
38 !! input
39 !! result
40 !! end
41
42
43 !! test
44 Simple paragraph
45 !! input
46 This is a simple paragraph.
47 !! result
48 <p>This is a simple paragraph.
49 </p>
50 !! end
51
52 !! test
53 Simple list
54 !! input
55 * Item 1
56 * Item 2
57 !! result
58 <ul><li> Item 1
59 </li><li> Item 2
60 </li></ul>
61
62 !! end
63
64 !! test
65 Italics and bold
66 !! input
67 * plain
68 * plain''italic''plain
69 * plain''italic''plain''italic''plain
70 * plain'''bold'''plain
71 * plain'''bold'''plain'''bold'''plain
72 * plain''italic''plain'''bold'''plain
73 * plain'''bold'''plain''italic''plain
74 * plain''italic'''bold-italic'''italic''plain
75 * plain'''bold''bold-italic''bold'''plain
76 * plain'''''bold-italic'''italic''plain
77 * plain'''''bold-italic''bold'''plain
78 * plain''italic'''bold-italic'''''plain
79 * plain'''bold''bold-italic'''''plain
80 * plain l'''italic''plain
81 !! result
82 <ul><li> plain
83 </li><li> plain<i>italic</i>plain
84 </li><li> plain<i>italic</i>plain<i>italic</i>plain
85 </li><li> plain<b>bold</b>plain
86 </li><li> plain<b>bold</b>plain<b>bold</b>plain
87 </li><li> plain<i>italic</i>plain<b>bold</b>plain
88 </li><li> plain<b>bold</b>plain<i>italic</i>plain
89 </li><li> plain<i>italic<b>bold-italic</b>italic</i>plain
90 </li><li> plain<b>bold<i>bold-italic</i>bold</b>plain
91 </li><li> plain<i><b>bold-italic</b>italic</i>plain
92 </li><li> plain<b><i>bold-italic</i>bold</b>plain
93 </li><li> plain<i>italic<b>bold-italic</b></i>plain
94 </li><li> plain<b>bold<i>bold-italic</i></b>plain
95 </li><li> plain l'<i>italic</i>plain
96 </li></ul>
97
98 !! end
99
100 ###
101 ### <nowiki> test cases
102 ###
103
104 !! test
105 <nowiki> unordered list
106 !! input
107 <nowiki>* This is not an unordered list item.</nowiki>
108 !! result
109 <p>* This is not an unordered list item.
110 </p>
111 !! end
112
113 !! test
114 <nowiki> spacing
115 !! input
116 <nowiki>Lorem ipsum dolor
117
118 sed abit.
119   sed nullum.
120
121 :and a colon
122 </nowiki>
123 !! result
124 <p>Lorem ipsum dolor
125
126 sed abit.
127   sed nullum.
128
129 :and a colon
130
131 </p>
132 !! end
133
134 !! test
135 nowiki 3
136 !! input
137 :There is not nowiki.
138 :There is <nowiki>nowiki</nowiki>.
139
140 #There is not nowiki.
141 #There is <nowiki>nowiki</nowiki>.
142
143 *There is not nowiki.
144 *There is <nowiki>nowiki</nowiki>.
145 !! result
146 <dl><dd>There is not nowiki.
147 </dd><dd>There is nowiki.
148 </dd></dl>
149 <ol><li>There is not nowiki.
150 </li><li>There is nowiki.
151 </li></ol>
152 <ul><li>There is not nowiki.
153 </li><li>There is nowiki.
154 </li></ul>
155
156 !! end
157
158 ###
159 ### Comments
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 lists
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 free' title="http://example.com/" rel="nofollow">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 text' title="http://www.google.com/" rel="nofollow">Google</a></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 ; [[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>
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 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>
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 free' title="news:alt.wikipedia.rox" rel="nofollow">news:alt.wikipedia.rox</a> -- don't crash or enter an infinite loop
321 </dt></dl>
322
323 !! end
324
325 !! test
326 Definition lists: colon in external link text
327 !! input
328 ; [http://www.wikipedia2.org/ Wikipedia : The Next Generation]: OK, I made that up
329 !! result
330 <dl><dt> <a href="http://www.wikipedia2.org/" class='external text' title="http://www.wikipedia2.org/" rel="nofollow">Wikipedia&nbsp;: The Next Generation</a></dt><dd> OK, I made that up
331 </dd></dl>
332
333 !! end
334
335
336 ###
337 ### External links
338 ###
339 !! test
340 External links: non-bracketed
341 !! input
342 Non-bracketed: http://example.com
343 !! result
344 <p>Non-bracketed: <a href="http://example.com" class='external free' title="http://example.com" rel="nofollow">http://example.com</a>
345 </p>
346 !! end
347
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
360
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
369
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
378
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
387
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
396
397 !! test
398 External image
399 !! input
400 External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
401 !! result
402 <p>External image: <img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png" />
403 </p>
404 !! end
405
406 !! test
407 External image from https
408 !! input
409 External image from https: https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
410 !! result
411 <p>External image from https: <img src="https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png" />
412 </p>
413 !! end
414
415 !! test
416 Link to non-http image, no img tag
417 !! input
418 Link to non-http image, no img tag: ftp://example.com/test.jpg
419 !! result
420 <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>
421 </p>
422 !! end
423
424 !! test
425 External links: terminating separator
426 !! input
427 Terminating separator: http://example.com/thing,
428 !! result
429 <p>Terminating separator: <a href="http://example.com/thing" class='external free' title="http://example.com/thing" rel="nofollow">http://example.com/thing</a>,
430 </p>
431 !! end
432
433 !! test
434 External links: intervening separator
435 !! input
436 Intervening separator: http://example.com/1,2,3
437 !! result
438 <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>
439 </p>
440 !! end
441
442 !! test
443 External links: old bug with URL in query
444 !! input
445 Old bug with URL in query: [http://example.com/thing?url=http://example.com link]
446 !! result
447 <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>
448 </p>
449 !! end
450
451 !! test
452 External links: old URL-in-URL bug, mixed protocols
453 !! input
454 And again with mixed protocols: [ftp://example.com?url=http://example.com link]
455 !! result
456 <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>
457 </p>
458 !!end
459
460 !! test
461 External links: URL in text
462 !! input
463 URL in text: [http://example.com http://example.com]
464 !! result
465 <p>URL in text: <a href="http://example.com" class='external free' title="http://example.com" rel="nofollow">http://example.com</a>
466 </p>
467 !! end
468
469 !! test
470 External links: Clickable images
471 !! input
472 ja-style clickable images: [http://example.com http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png]
473 !! result
474 <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>
475 </p>
476 !!end
477
478 !! test
479 External links: raw ampersand
480 !! input
481 Old &amp; use: http://x&y
482 !! result
483 <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>
484 </p>
485 !! end
486
487 !! test
488 External links: encoded ampersand
489 !! input
490 Old &amp; use: http://x&amp;y
491 !! result
492 <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>
493 </p>
494 !! end
495
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 autonumber' title="http://x&amp;y" rel="nofollow">[1]</a>
502 </p>
503 !! end
504
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 autonumber' title="http://x&amp;y" rel="nofollow">[1]</a>
511 </p>
512 !! end
513
514 !! test
515 External links: www.jpeg.org (bug 554)
516 !! input
517 http://www.jpeg.org
518 !!result
519 <p><a href="http://www.jpeg.org" class='external free' title="http://www.jpeg.org" rel="nofollow">http://www.jpeg.org</a>
520 </p>
521 !! end
522
523 !! test
524 External links: URL within URL (original bug 2)
525 !! input
526 [http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp]
527 !! result
528 <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>
529 </p>
530 !! end
531
532 !! test
533 BUG 361: URL inside bracketed URL
534 !! input
535 [http://www.example.com/foo http://www.example.com/bar]
536 !! result
537 <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>
538 </p>
539 !! end
540
541 !! test
542 BUG 361: URL within URL, not bracketed
543 !! input
544 http://www.example.com/foo?=http://www.example.com/bar
545 !! result
546 <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>
547 </p>
548 !! end
549
550 !! test
551 BUG 289: ">"-token in URL-tail
552 !! input
553 http://www.example.com/<hello>
554 !! result
555 <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;
556 </p>
557 !!end
558
559 !! test
560 BUG 289: literal ">"-token in URL-tail
561 !! input
562 http://www.example.com/<b>html</b>
563 !! result
564 <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>
565 </p>
566 !!end
567
568 !! test
569 BUG 289: ">"-token in bracketed URL
570 !! input
571 [http://www.example.com/<hello> stuff]
572 !! result
573 <p><a href="http://www.example.com/" class='external text' title="http://www.example.com/" rel="nofollow">&lt;hello&gt; stuff</a>
574 </p>
575 !!end
576
577 !! test
578 BUG 289: literal ">"-token in bracketed URL
579 !! input
580 [http://www.example.com/<b>html</b> stuff]
581 !! result
582 <p><a href="http://www.example.com/" class='external text' title="http://www.example.com/" rel="nofollow"><b>html</b> stuff</a>
583 </p>
584 !!end
585
586 !! test
587 BUG 289: literal double quote at end of URL
588 !! input
589 http://www.example.com/"hello"
590 !! result
591 <p><a href="http://www.example.com/" class='external free' title="http://www.example.com/" rel="nofollow">http://www.example.com/</a>"hello"
592 </p>
593 !!end
594
595 !! test
596 BUG 289: literal double quote in bracketed URL
597 !! input
598 [http://www.example.com/"hello" stuff]
599 !! result
600 <p><a href="http://www.example.com/" class='external text' title="http://www.example.com/" rel="nofollow">"hello" stuff</a>
601 </p>
602 !!end
603
604 !! test
605 External links: invalid character
606 !! input
607 [http://www.example.com\0 test]
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>\0 test]
610 </p>
611 !! end
612
613 !! test
614 BUG 787: Links with one slash after the url protocol are invalid
615 !! input
616 http:/example.com
617
618 [http:/example.com title]
619 !! result
620 <p>http:/example.com
621 </p><p>[http:/example.com title]
622 </p>
623 !! end
624
625 !! test
626 Bug 2702: Mismatched <i> and <a> tags are invalid
627 !! input
628 ''[http://example.com text'']
629 !! result
630 <p><i><a href="http://example.com" class='external text' title="http://example.com" rel="nofollow">text</a></i>
631 </p>
632 !! end
633
634 ###
635 ### Quotes
636 ###
637
638 !! test
639 Quotes
640 !! input
641 Normal text. '''Bold text.''' Normal text. ''Italic text.''
642
643 Normal text. '''''Bold italic text.''''' Normal text.
644 !!result
645 <p>Normal text. <b>Bold text.</b> Normal text. <i>Italic text.</i>
646 </p><p>Normal text. <i><b>Bold italic text.</b></i> Normal text.
647 </p>
648 !! end
649
650
651 !! test
652 Unclosed and unmatched quotes
653 !! input
654 '''''Bold italic text '''with bold deactivated''' in between.'''''
655
656 '''''Bold italic text ''with italic deactivated'' in between.'''''
657
658 '''Bold text..
659
660 ..spanning two paragraphs (should not work).'''
661
662 '''Bold tag left open
663
664 ''Italic tag left open
665
666 Normal text.
667
668 <!-- Unmatching number of opening, closing tags: -->
669 '''This year''''s election ''should'' beat '''last year''''s.
670
671 ''Tom'''s car is bigger than ''Susan'''s.
672 !! result
673 <p><i><b>Bold italic text </b>with bold deactivated<b> in between.</b></i>
674 </p><p><b><i>Bold italic text </i>with italic deactivated<i> in between.</i></b>
675 </p><p><b>Bold text..</b>
676 </p><p>..spanning two paragraphs (should not work).<b></b>
677 </p><p><b>Bold tag left open</b>
678 </p><p><i>Italic tag left open</i>
679 </p><p>Normal text.
680 </p><p><b>This year'</b>s election <i>should</i> beat <b>last year'</b>s.
681 </p><p><i>Tom<b>s car is bigger than </b></i><b>Susan</b>s.
682 </p>
683 !! end
684
685 ###
686 ### Tables
687 ###
688 ### some content taken from http://meta.wikimedia.org/wiki/MediaWiki_User%27s_Guide:_Using_tables
689 ###
690
691 # This should not produce <table></table> as <table><tr><td></td></tr></table>
692 # is the bare minimun required by the spec, see:
693 # http://www.w3.org/TR/xhtml-modularization/dtd_module_defs.html#a_module_Basic_Tables
694 !! test
695 A table with no data.
696 !! input
697 {||}
698 !! result
699 !! end
700
701 # A table with nothing but a caption is invalid XHTML, we might want to render
702 # this as <p>caption</p>
703 !! test
704 A table with nothing but a caption
705 !! input 
706 {|
707 |+ caption
708 |}
709 !! result
710 <table>
711 <caption> caption
712 </caption>
713 <tr>
714 <td>
715 </td></tr></table>
716 !! end
717
718 !! test
719 Simple table
720 !! input
721 {| 
722 | 1 || 2
723 |- 
724 | 3 || 4
725 |}
726 !! result
727 <table>
728 <tr>
729 <td> 1 </td><td> 2
730 </td></tr>
731 <tr>
732 <td> 3 </td><td> 4
733 </td></tr></table>
734
735 !! end
736
737 !! test
738 Multiplication table
739 !! input
740 {| border="1" cellpadding="2"
741 |+Multiplication table
742 |-
743 ! &times; !! 1 !! 2 !! 3
744 |-
745 ! 1
746 | 1 || 2 || 3
747 |-
748 ! 2
749 | 2 || 4 || 6
750 |-
751 ! 3
752 | 3 || 6 || 9
753 |-
754 ! 4
755 | 4 || 8 || 12
756 |-
757 ! 5
758 | 5 || 10 || 15
759 |}
760 !! result
761 <table border="1" cellpadding="2">
762 <caption>Multiplication table
763 </caption>
764 <tr>
765 <th> &times; </th><th> 1 </th><th> 2 </th><th> 3
766 </th></tr>
767 <tr>
768 <th> 1
769 </th><td> 1 </td><td> 2 </td><td> 3
770 </td></tr>
771 <tr>
772 <th> 2
773 </th><td> 2 </td><td> 4 </td><td> 6
774 </td></tr>
775 <tr>
776 <th> 3
777 </th><td> 3 </td><td> 6 </td><td> 9
778 </td></tr>
779 <tr>
780 <th> 4
781 </th><td> 4 </td><td> 8 </td><td> 12
782 </td></tr>
783 <tr>
784 <th> 5
785 </th><td> 5 </td><td> 10 </td><td> 15
786 </td></tr></table>
787
788 !! end
789
790 !! test
791 Table rowspan
792 !! input
793 {| align=right border=1
794 | Cell 1, row 1 
795 |rowspan=2| Cell 2, row 1 (and 2) 
796 | Cell 3, row 1 
797 |- 
798 | Cell 1, row 2 
799 | Cell 3, row 2 
800 |}
801 !! result
802 <table align="right" border="1">
803 <tr>
804 <td> Cell 1, row 1
805 </td><td rowspan="2"> Cell 2, row 1 (and 2)
806 </td><td> Cell 3, row 1
807 </td></tr>
808 <tr>
809 <td> Cell 1, row 2
810 </td><td> Cell 3, row 2
811 </td></tr></table>
812
813 !! end
814
815 !! test
816 Nested table
817 !! input
818 {| border=1
819 | &alpha;
820 |
821 {| bgcolor=#ABCDEF border=2
822 |nested
823 |-
824 |table
825 |}
826 |the original table again
827 |}
828 !! result
829 <table border="1">
830 <tr>
831 <td> &alpha;
832 </td><td>
833 <table bgcolor="#ABCDEF" border="2">
834 <tr>
835 <td>nested
836 </td></tr>
837 <tr>
838 <td>table
839 </td></tr></table>
840 </td><td>the original table again
841 </td></tr></table>
842
843 !! end
844
845 !! test
846 Invalid attributes in table cell (bug 1830)
847 !! input
848 {|
849 |Cell:|broken
850 |}
851 !! result
852 <table>
853 <tr>
854 <td>broken
855 </td></tr></table>
856
857 !! end
858
859
860 ###
861 ### Internal links
862 ###
863 !! test
864 Plain link, capitalized
865 !! input
866 [[Main Page]]
867 !! result
868 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
869 </p>
870 !! end
871
872 !! test
873 Plain link, uncapitalized
874 !! input
875 [[main Page]]
876 !! result
877 <p><a href="/wiki/Main_Page" title="Main Page">main Page</a>
878 </p>
879 !! end
880
881 !! test
882 Piped link
883 !! input
884 [[Main Page|The Main Page]]
885 !! result
886 <p><a href="/wiki/Main_Page" title="Main Page">The Main Page</a>
887 </p>
888 !! end
889
890 !! test
891 Broken link
892 !! input
893 [[Zigzagzogzagzig]]
894 !! result
895 <p><a href="/index.php?title=Zigzagzogzagzig&amp;action=edit" class="new" title="Zigzagzogzagzig">Zigzagzogzagzig</a>
896 </p>
897 !! end
898
899 !! test
900 Link with prefix
901 !! input
902 xxx[[main Page]], xxx[[Main Page]], Xxx[[main Page]] XXX[[main Page]], XXX[[Main Page]]
903 !! result
904 <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>
905 </p>
906 !! end
907
908 !! test
909 Link with suffix
910 !! input
911 [[Main Page]]xxx, [[Main Page]]XXX
912 !! result
913 <p><a href="/wiki/Main_Page" title="Main Page">Main Pagexxx</a>, <a href="/wiki/Main_Page" title="Main Page">Main Page</a>XXX
914 </p>
915 !! end
916
917 !! test
918 Link with 3 brackets
919 !! input
920 [[[main page]]]
921 !! result
922 <p>[[[main page]]]
923 </p>
924 !! end
925
926 !! test
927 Piped link with 3 brackets
928 !! input
929 [[[main page|the main page]]]
930 !! result
931 <p>[[[main page|the main page]]]
932 </p>
933 !! end
934
935 !! test
936 Link with multiple pipes
937 !! input
938 [[Main Page|The|Main|Page]]
939 !! result
940 <p><a href="/wiki/Main_Page" title="Main Page">The|Main|Page</a>
941 </p>
942 !! end
943
944 !! test
945 Link to namespaces
946 !! input
947 [[Talk:Parser testing]], [[Meta:Disclaimers]]
948 !! result
949 <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>
950 </p>
951 !! end
952
953 !! test
954 Piped link to namespace
955 !! input
956 [[Meta:Disclaimers|The disclaimers]]
957 !! result
958 <p><a href="/index.php?title=Meta:Disclaimers&amp;action=edit" class="new" title="Meta:Disclaimers">The disclaimers</a>
959 </p>
960 !! end
961
962 !! test
963 Link containing }
964 !! input
965 [[Usually caused by a typo (oops}]]
966 !! result
967 <p>[[Usually caused by a typo (oops}]]
968 </p>
969 !! end
970
971 !! test
972 Link containing % (not as a hex sequence)
973 !! input
974 [[7% Solution]]
975 !! result
976 <p><a href="/index.php?title=7%25_Solution&amp;action=edit" class="new" title="7% Solution">7% Solution</a>
977 </p>
978 !! end
979
980 !! test
981 Link containing % as a single hex sequence interpreted to char
982 !! input
983 [[7%25 Solution]]
984 !! result
985 <p><a href="/index.php?title=7%25_Solution&amp;action=edit" class="new" title="7% Solution">7% Solution</a>
986 </p>
987 !!end
988
989 !! test
990 Link containing % as a double hex sequence interpreted to hex sequence
991 !! input
992 [[7%2525 Solution]]
993 !! result
994 <p>[[7%2525 Solution]]
995 </p>
996 !!end
997
998 !! test
999 Plain link to URL
1000 !! input
1001 [[http://www.example.org]]
1002 !! result
1003 <p>[<a href="http://www.example.org" class='external autonumber' title="http://www.example.org" rel="nofollow">[1]</a>]
1004 </p>
1005 !! end
1006
1007 # I'm fairly sure the expected result here is wrong.
1008 # We want these to be URL links, not pseudo-pages with URLs for titles....
1009 # However the current output is also pretty screwy.
1010 #
1011 # ----
1012 # I'm changing it to match the current output--it arguably makes more
1013 # sense in the light of the test above. Old expected result was:
1014 #<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>
1015 #</p>
1016 # But I think this test is bordering on "garbage in, garbage out" anyway.
1017 # -- wtm
1018 !! test
1019 Piped link to URL
1020 !! input
1021 Piped link to URL: [[http://www.example.org|an example URL]]
1022 !! result
1023 <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>]
1024 </p>
1025 !! end
1026
1027 !! test
1028 BUG 2: [[page|http://url/]] should link to page, not http://url/
1029 !! input
1030 [[Main Page|http://url/]]
1031 !! result
1032 <p><a href="/wiki/Main_Page" title="Main Page">http://url/</a>
1033 </p>
1034 !! end
1035
1036 !! test
1037 BUG 337: Escaped self-links should be bold
1038 !! options
1039 title=[[Bug462]]
1040 !! input
1041 [[Bu&#103;462]] [[Bug462]]
1042 !! result
1043 <p><strong>Bu&#103;462</strong> <strong>Bug462</strong>
1044 </p>
1045 !! end
1046
1047 !! test
1048 Self-link to section should not be bold
1049 !! options
1050 title=[[Main Page]]
1051 !! input
1052 [[Main Page#section]]
1053 !! result
1054 <p><a href="/wiki/Main_Page#section" title="Main Page">Main Page#section</a>
1055 </p>
1056 !! end
1057
1058 !! test
1059 <nowiki> inside a link
1060 !! input
1061 [[Main<nowiki> Page</nowiki>]] [[Main Page|the main page <nowiki>[it's not very good]</nowiki>]]
1062 !! result
1063 <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>
1064 </p>
1065 !! end
1066
1067 ###
1068 ### Interwiki links (see maintenance/interwiki.sql)
1069 ###
1070
1071 !! test
1072 Inline interwiki link
1073 !! input
1074 [[MeatBall:SoftSecurity]]
1075 !! result
1076 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity" class='extiw' title="MeatBall:SoftSecurity">MeatBall:SoftSecurity</a>
1077 </p>
1078 !! end
1079
1080 !! test
1081 Inline interwiki link with empty title (bug 2372)
1082 !! input
1083 [[MeatBall:]]
1084 !! result
1085 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?" class='extiw' title="MeatBall:">MeatBall:</a>
1086 </p>
1087 !! end
1088
1089 !! test
1090 Interwiki link encoding conversion (bug 1636)
1091 !! input
1092 *[[Wikipedia:ro:Olteni&#0355;a]]
1093 *[[Wikipedia:ro:Olteni&#355;a]]
1094 !! result
1095 <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>
1096 </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>
1097 </li></ul>
1098
1099 !! end
1100
1101 !! test
1102 Interwiki link with fragment (bug 2130)
1103 !! input
1104 [[MeatBall:SoftSecurity#foo]]
1105 !! result
1106 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity#foo" class='extiw' title="MeatBall:SoftSecurity">MeatBall:SoftSecurity#foo</a>
1107 </p>
1108 !! end
1109
1110 ##
1111 ## XHTML tidiness
1112 ###
1113
1114 !! test
1115 <br> to <br />
1116 !! input
1117 1<br>2<br />3
1118 !! result
1119 <p>1<br />2<br />3
1120 </p>
1121 !! end
1122
1123 !! test
1124 Incorrecly removing closing slashes from correctly formed XHTML
1125 !! input
1126 <br style="clear:both;" />
1127 !! result
1128 <p><br style="clear:both;" />
1129 </p>
1130 !! end
1131
1132 !! test 
1133 Failing to transform badly formed HTML into correct XHTML
1134 !! input
1135 <br clear=left>
1136 <br clear=right>
1137 <br clear=all>
1138 !! result
1139 <p><br style="clear:left;" />
1140 <br style="clear:right;" />
1141 <br style="clear:both;" />
1142 </p>
1143 !!end
1144
1145 !! test 
1146 Horizontal ruler (should it add that extra space?)
1147 !! input 
1148 <hr>
1149 <hr >
1150 foo <hr
1151 > bar
1152 !! result 
1153 <hr />
1154 <hr />
1155 foo <hr /> bar
1156 !! end
1157
1158 ###
1159 ### Block-level elements
1160 ###
1161 !! test
1162 Common list
1163 !! input
1164 *Common list
1165 * item 2
1166 *item 3
1167 !! result
1168 <ul><li>Common list
1169 </li><li> item 2
1170 </li><li>item 3
1171 </li></ul>
1172
1173 !! end
1174
1175 !! test
1176 Numbered list
1177 !! input
1178 #Numbered list
1179 #item 2
1180 # item 3
1181 !! result
1182 <ol><li>Numbered list
1183 </li><li>item 2
1184 </li><li> item 3
1185 </li></ol>
1186
1187 !! end
1188
1189 !! test
1190 Mixed list
1191 !! input
1192 *Mixed list
1193 *# with numbers
1194 ** and bullets
1195 *# and numbers
1196 *bullets again
1197 **bullet level 2
1198 ***bullet level 3
1199 ***#Number on level 4
1200 **bullet level 2
1201 **#Number on level 3
1202 **#Number on level 3
1203 *#number level 2
1204 *Level 1
1205 !! result
1206 <ul><li>Mixed list
1207 <ol><li> with numbers
1208 </li></ol>
1209 <ul><li> and bullets
1210 </li></ul>
1211 <ol><li> and numbers
1212 </li></ol>
1213 </li><li>bullets again
1214 <ul><li>bullet level 2
1215 <ul><li>bullet level 3
1216 <ol><li>Number on level 4
1217 </li></ol>
1218 </li></ul>
1219 </li><li>bullet level 2
1220 <ol><li>Number on level 3
1221 </li><li>Number on level 3
1222 </li></ol>
1223 </li></ul>
1224 <ol><li>number level 2
1225 </li></ol>
1226 </li><li>Level 1
1227 </li></ul>
1228
1229 !! end
1230
1231 !! test
1232 List items are not parsed correctly following a <pre> block (bug 785)
1233 !! input
1234 * <pre>foo</pre>
1235 * <pre>bar</pre>
1236 * zar
1237 !! result
1238 <ul><li> <pre>foo</pre>
1239 </li><li> <pre>bar</pre>
1240 </li><li> zar
1241 </li></ul>
1242
1243 !! end
1244
1245 ###
1246 ### Magic variables
1247 ###
1248 !! test
1249 Magic variables
1250 !! input
1251 {{SITENAME}}
1252 !! result
1253 <p>MediaWiki
1254 </p>
1255 !! end
1256
1257 ###
1258 ### Magic links
1259 ###
1260 !! test
1261 Magic links: internal link to RFC (bug 479)
1262 !! input
1263 [[RFC 123]]
1264 !! result
1265 <p><a href="/index.php?title=RFC_123&amp;action=edit" class="new" title="RFC 123">RFC 123</a>
1266 </p>
1267 !! end
1268
1269 !! test
1270 Magic links: RFC (bug 479)
1271 !! input
1272 RFC 822
1273 !! result
1274 <p><a href='http://www.ietf.org/rfc/rfc822.txt' class='external' title="http://www.ietf.org/rfc/rfc822.txt">RFC 822</a>
1275 </p>
1276 !! end
1277
1278 !! test
1279 Magic links: ISBN (bug 1937)
1280 !! input
1281 ISBN 0-306-40615-2
1282 !! result
1283 <p><a href="/index.php?title=Special:Booksources&amp;isbn=0306406152" class="internal">ISBN 0-306-40615-2</a>
1284 </p>
1285 !! end
1286
1287 !! test
1288 Magic links: PMID incorrectly converts space to underscore
1289 !! input
1290 PMID 1234
1291 !! result
1292 <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>
1293 </p>
1294 !! end
1295
1296 ###
1297 ### Templates
1298 ####
1299
1300 !! test
1301 Nonexistant template
1302 !! input
1303 {{thistemplatedoesnotexist}}
1304 !! result
1305 <p><a href="/index.php?title=Template:Thistemplatedoesnotexist&amp;action=edit" class="new" title="Template:Thistemplatedoesnotexist">Template:Thistemplatedoesnotexist</a>
1306 </p>
1307 !! end
1308
1309 !! article
1310 Template:test
1311 !! text
1312 This is a test template
1313 !! endarticle
1314
1315 !! test
1316 Simple template
1317 !! input
1318 {{test}}
1319 !! result
1320 <p>This is a test template
1321 </p>
1322 !! end
1323
1324 !! test
1325 Template with explicit namespace
1326 !! input
1327 {{Template:test}}
1328 !! result
1329 <p>This is a test template
1330 </p>
1331 !! end
1332
1333
1334 !! article
1335 Template:paramtest
1336 !! text
1337 This is a test template with parameter {{{param}}}
1338 !! endarticle
1339
1340 !! test
1341 Template parameter
1342 !! input
1343 {{paramtest|param=foo}}
1344 !! result
1345 <p>This is a test template with parameter foo
1346 </p>
1347 !! end
1348
1349 !! article
1350 Template:paramtestnum
1351 !! text
1352 [[{{{1}}}|{{{2}}}]]
1353 !! endarticle
1354
1355 !! test
1356 Template unnamed parameter
1357 !! input
1358 {{paramtestnum|Main Page|the main page}}
1359 !! result
1360 <p><a href="/wiki/Main_Page" title="Main Page">the main page</a>
1361 </p>
1362 !! end
1363
1364 !! test
1365 BUG 553: link with two variables in a piped link
1366 !! input
1367 {| 
1368 |[[{{{1}}}|{{{2}}}]]
1369 |}
1370 !! result
1371 <table>
1372 <tr>
1373 <td>[[{{{1}}}|{{{2}}}]]
1374 </td></tr></table>
1375
1376 !! end
1377
1378 !! test
1379 Magic variable as template parameter
1380 !! input
1381 {{paramtest|param={{SITENAME}}}}
1382 !! result
1383 <p>This is a test template with parameter MediaWiki
1384 </p>
1385 !! end
1386
1387 !! article
1388 Template:linktest
1389 !! text
1390 [[{{{param}}}|link]]
1391 !! endarticle
1392
1393 !! test
1394 Template parameter as link source
1395 !! input
1396 {{linktest|param=Main Page}}
1397 !! result
1398 <p><a href="/wiki/Main_Page" title="Main Page">link</a>
1399 </p>
1400 !! end
1401
1402
1403 !!article
1404 Template:paramtest2
1405 !! text
1406 including another template, {{paramtest|param={{{arg}}}}}
1407 !! endarticle
1408
1409 !! test
1410 Template passing argument to another template
1411 !! input
1412 {{paramtest2|arg='hmm'}}
1413 !! result
1414 <p>including another template, This is a test template with parameter 'hmm'
1415 </p>
1416 !! end
1417
1418 !! article
1419 Template:Linktest2
1420 !! text
1421 Main Page
1422 !! endarticle
1423
1424 !! test
1425 Template as link source
1426 !! input
1427 [[{{linktest2}}]]
1428 !! result
1429 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
1430 </p>
1431 !! end
1432
1433
1434 !! article
1435 Template:loop1
1436 !! text
1437 {{loop2}}
1438 !! endarticle
1439
1440 !! article
1441 Template:loop2
1442 !! text
1443 {{loop1}}
1444 !! endarticle
1445
1446 !! test
1447 Template infinite loop
1448 !! input
1449 {{loop1}}
1450 !! result
1451 <p>{{loop1}}<!-- WARNING: template loop detected -->
1452 </p>
1453 !! end
1454
1455 !! test
1456 Template from main namespace
1457 !! input
1458 {{:Main Page}}
1459 !! result
1460 <p>blah blah
1461 </p>
1462 !! end
1463
1464 !! article
1465 Template:table
1466 !! text
1467 {| 
1468 | 1 || 2
1469 |- 
1470 | 3 || 4
1471 |}
1472 !! endarticle
1473
1474 !! test
1475 BUG 529: Template with table, not included at beginning of line
1476 !! input
1477 foo {{table}}
1478 !! result
1479 <p>foo 
1480 </p>
1481 <table>
1482 <tr>
1483 <td> 1 </td><td> 2
1484 </td></tr>
1485 <tr>
1486 <td> 3 </td><td> 4
1487 </td></tr></table>
1488
1489 !! end
1490
1491 !! test
1492 BUG 523: Template shouldn't eat newline (or add an extra one before table)
1493 !! input
1494 foo
1495 {{table}}
1496 !! result
1497 <p>foo
1498 </p>
1499 <table>
1500 <tr>
1501 <td> 1 </td><td> 2
1502 </td></tr>
1503 <tr>
1504 <td> 3 </td><td> 4
1505 </td></tr></table>
1506
1507 !! end
1508
1509 !! test
1510 BUG 41: Template parameters shown as broken links
1511 !! input
1512 {{{parameter}}}
1513 !! result
1514 <p>{{{parameter}}}
1515 </p>
1516 !! end
1517
1518
1519 !! article
1520 Template:MSGNW test
1521 !! text
1522 ''None'' of '''this''' should be 
1523 * interepreted
1524  but rather passed unmodified
1525 {{test}}
1526 !! endarticle
1527
1528 # hmm, fix this or just deprecate msgnw and document its behavior?
1529 !! test
1530 msgnw keyword
1531 !! options
1532 disabled
1533 !! input
1534 {{msgnw:MSGNW test}}
1535 !! result
1536 <p>''None'' of '''this''' should be 
1537 * interepreted
1538  but rather passed unmodified
1539 {{test}}
1540 </p>
1541 !! end
1542
1543 !! test
1544 int keyword
1545 !! input
1546 {{int:newmessages|lots of money}}
1547 !! result
1548 <p>You have lots of money.
1549 </p>
1550 !! end
1551
1552 ###
1553 ### Pre-save transform tests
1554 ###
1555 !! test
1556 pre-save transform: subst:
1557 !! options
1558 PST
1559 !! input
1560 {{subst:test}}
1561 !! result
1562 This is a test template
1563 !! end
1564
1565 !! test
1566 pre-save transform: normal template
1567 !! options
1568 PST
1569 !! input
1570 {{test}}
1571 !! result
1572 {{test}}
1573 !! end
1574
1575 !! test
1576 pre-save transform: nonexistant template
1577 !! options
1578 PST
1579 !! input
1580 {{thistemplatedoesnotexist}}
1581 !! result
1582 {{thistemplatedoesnotexist}}
1583 !! end
1584
1585
1586 !! test
1587 pre-save transform: subst magic variables
1588 !! options
1589 PST
1590 !! input
1591 {{subst:SITENAME}}
1592 !! result
1593 MediaWiki
1594 !! end
1595
1596 # This is bug 89, which I fixed. -- wtm
1597 !! test
1598 pre-save transform: subst: templates with parameters
1599 !! options
1600 pst
1601 !! input
1602 {{subst:paramtest|param="something else"}}
1603 !! result
1604 This is a test template with parameter "something else"
1605 !! end
1606
1607
1608 !! article
1609 Template:nowikitest
1610 !! text
1611 <nowiki>'''not wiki'''</nowiki>
1612 !! endarticle
1613
1614 !! test
1615 pre-save transform: nowiki in subst (bug 1188)
1616 !! options
1617 pst
1618 !! input
1619 {{subst:nowikitest}}
1620 !! result
1621 <nowiki>'''not wiki'''</nowiki>
1622 !! end
1623
1624
1625 !! article
1626 Template:commenttest
1627 !! text
1628 This template has <!-- a comment --> in it.
1629 !! endarticle
1630
1631 !! test
1632 pre-save transform: comment in subst (bug 1936)
1633 !! options
1634 pst
1635 !! input
1636 {{subst:commenttest}}
1637 !! result
1638 This template has <!-- a comment --> in it.
1639 !! end
1640
1641
1642 !! article
1643 Template:dangerous
1644 !!text
1645 <span onmouseover="alert('crap')">Oh no</span>
1646 !!endarticle
1647
1648 !!test
1649 (confirming safety of fix for subst bug 1936)
1650 !! input
1651 {{Template:dangerous}}
1652 !! result
1653 <p><span>Oh no</span>
1654 </p>
1655 !! end
1656
1657
1658 ###
1659 ### Message transform tests
1660 ###
1661 !! test
1662 message transform: magic variables
1663 !! options
1664 msg
1665 !! input
1666 {{SITENAME}}
1667 !! result
1668 MediaWiki
1669 !! end
1670
1671 !! test
1672 message transform: should not transform wiki markup
1673 !! options
1674 msg
1675 !! input
1676 ''test''
1677 !! result
1678 ''test''
1679 !! end
1680
1681 ###
1682 ### Images
1683 ###
1684 !! test
1685 Simple image
1686 !! input
1687 [[Image:foobar.jpg]]
1688 !! result
1689 <p><a href="/wiki/Image:Foobar.jpg" class="image" title="Image:foobar.jpg"><img src="/images/3/3a/Foobar.jpg" alt="Image:foobar.jpg" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a>
1690 </p>
1691 !! end
1692
1693 !! test
1694 Right-aligned image
1695 !! input
1696 [[Image:foobar.jpg|right]]
1697 !! result
1698 <div class="floatright"><span><a href="/wiki/Image:Foobar.jpg" class="image" title=""><img src="/images/3/3a/Foobar.jpg" alt="" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a></span></div>
1699
1700 !! end
1701
1702 !! test
1703 Image with caption
1704 !! input
1705 [[Image:foobar.jpg|right|Caption text]]
1706 !! result
1707 <div class="floatright"><span><a href="/wiki/Image:Foobar.jpg" class="image" title="Caption text"><img src="/images/3/3a/Foobar.jpg" alt="Caption text" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a></span></div>
1708
1709 !! end
1710
1711 !! test
1712 Image with frame and link
1713 !! input
1714 [[Image:Foobar.jpg|frame|left|This is a test image [[Main Page]]]]
1715 !! result
1716 <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="/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>
1717
1718 !! end
1719
1720 !! test
1721 Link to image page
1722 !! input
1723 [[:Image:test]]
1724 !! result
1725 <p><a href="/wiki/Image:Test" title="Image:Test">Image:test</a>
1726 </p>
1727 !! end
1728
1729 !! test
1730 Frameless image caption with a free URL
1731 !! input
1732 [[Image:foobar.jpg|http://example.com]]
1733 !! result
1734 <p><a href="/wiki/Image:Foobar.jpg" class="image" title="http://example.com"><img src="/images/3/3a/Foobar.jpg" alt="http://example.com" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a>
1735 </p>
1736 !! end
1737
1738 !! test
1739 Thumbnail image caption with a free URL
1740 !! input
1741 [[Image:foobar.jpg|thumb|http://example.com]]
1742 !! result
1743 <div class="thumb tright"><div style="width:182px;"><a href="/wiki/Image:Foobar.jpg" class="internal" title="http://example.com"><img src="/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>
1744
1745 !! end
1746
1747 !! test
1748 BUG 1887: A ISBN with a thumbnail
1749 !! input
1750 [[Image:foobar.jpg|thumb|ISBN 12354]]
1751 !! result
1752 <div class="thumb tright"><div style="width:182px;"><a href="/wiki/Image:Foobar.jpg" class="internal" title="ISBN 12354"><img src="/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>
1753 !! end
1754
1755 !! test
1756 BUG 1887: A <math> with a thumbnail
1757 !! input
1758 [[Image:foobar.jpg|thumb|<math>2+2</math>]]
1759 !! result
1760 <div class="thumb tright"><div style="width:182px;"><a href="/wiki/Image:Foobar.jpg" class="internal" title="2+2"><img src="/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>
1761 !! end
1762
1763 # Pending resolution to bug 368
1764 !! test
1765 BUG 648: Frameless image caption with a link
1766 !! input
1767 [[Image:foobar.jpg|text with a [[link]] in it]]
1768 !! result
1769 <p><a href="/wiki/Image:Foobar.jpg" class="image" title="text with a link in it"><img src="/images/3/3a/Foobar.jpg" alt="text with a link in it" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a>
1770 </p>
1771 !! end
1772
1773 !! test
1774 BUG 648: Frameless image caption with a link (suffix)
1775 !! input
1776 [[Image:foobar.jpg|text with a [[link]]foo in it]]
1777 !! result
1778 <p><a href="/wiki/Image:Foobar.jpg" class="image" title="text with a linkfoo in it"><img src="/images/3/3a/Foobar.jpg" alt="text with a linkfoo in it" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a>
1779 </p>
1780 !! end
1781
1782 !! test
1783 BUG 648: Frameless image caption with an interwiki link
1784 !! input
1785 [[Image:foobar.jpg|text with a [[MeatBall:Link]] in it]]
1786 !! result
1787 <p><a href="/wiki/Image:Foobar.jpg" class="image" title="text with a MeatBall:Link in it"><img src="/images/3/3a/Foobar.jpg" alt="text with a MeatBall:Link in it" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a>
1788 </p>
1789 !! end
1790
1791 !! test
1792 BUG 648: Frameless image caption with a piped interwiki link
1793 !! input
1794 [[Image:foobar.jpg|text with a [[MeatBall:Link|link]] in it]]
1795 !! result
1796 <p><a href="/wiki/Image:Foobar.jpg" class="image" title="text with a link in it"><img src="/images/3/3a/Foobar.jpg" alt="text with a link in it" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a>
1797 </p>
1798 !! end
1799
1800 !! test
1801 Escape HTML special chars in image alt text
1802 !! input
1803 [[Image:foobar.jpg|& < > "]]
1804 !! result
1805 <p><a href="/wiki/Image:Foobar.jpg" class="image" title="&amp; &lt; &gt; &quot;"><img src="/images/3/3a/Foobar.jpg" alt="&amp; &lt; &gt; &quot;" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a>
1806 </p>
1807 !! end
1808
1809 !! test
1810 BUG 499: Alt text should have &#1234;, not &amp;1234;
1811 !! input
1812 [[Image:foobar.jpg|&#9792;]]
1813 !! result
1814 <p><a href="/wiki/Image:Foobar.jpg" class="image" title="&#9792;"><img src="/images/3/3a/Foobar.jpg" alt="&#9792;" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a>
1815 </p>
1816 !! end
1817
1818 !! test
1819 Broken image caption with link
1820 !! input
1821 [[Image:Foobar.jpg|thumb|This is a broken caption. But [[Main Page|this]] is just an ordinary link.
1822 !! result
1823 <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.
1824 </p>
1825 !! end
1826
1827 !! test
1828 Image caption containing another image
1829 !! input
1830 [[Image:Foobar.jpg|thumb|This is a caption with another [[Image:icon.png|image]] inside it!]]
1831 !! result
1832 <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="/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>
1833
1834 !! end
1835
1836 !! test
1837 Image caption containing a newline
1838 !! input
1839 [[Image:Foobar.jpg|This
1840 *is some text]]
1841 !! result
1842 <p><a href="/wiki/Image:Foobar.jpg" class="image" title="This *is some text"><img src="/images/3/3a/Foobar.jpg" alt="This *is some text" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a>
1843 </p>
1844 !!end
1845
1846
1847 !! test
1848 Bug 3090: External links other than http: in image captions
1849 !! input
1850 [[Image:Foobar.jpg|thumb|200px|This caption has [irc://example.net irc] and [https://example.com Secure] ext links in it.]]
1851 !! result
1852 <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="/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>
1853
1854 !! end
1855
1856
1857 ###
1858 ### Subpages
1859 ###
1860 !! article
1861 Subpage test/subpage
1862 !! text
1863 foo
1864 !! endarticle
1865
1866 !! test
1867 Subpage link
1868 !! options
1869 subpage title=[[Subpage test]]
1870 !! input
1871 [[/subpage]]
1872 !! result
1873 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a>
1874 </p>
1875 !! end
1876
1877 !! test
1878 Subpage noslash link
1879 !! options
1880 subpage title=[[Subpage test]]
1881 !!input
1882 [[/subpage/]]
1883 !! result
1884 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">subpage</a>
1885 </p>
1886 !! end
1887
1888 !! test
1889 Disabled subpages
1890 !! input
1891 [[/subpage]]
1892 !! result
1893 <p><a href="/index.php?title=/subpage&amp;action=edit" class="new" title="/subpage">/subpage</a>
1894 </p>
1895 !! end
1896
1897 !! test
1898 BUG 561: {{/Subpage}}
1899 !! options
1900 subpage title=[[Page]]
1901 !! input
1902 {{/Subpage}}
1903 !! result
1904 <p><a href="/index.php?title=Page/Subpage&amp;action=edit" class="new" title="Page/Subpage">Page/Subpage</a>
1905 </p>
1906 !! end
1907
1908 ###
1909 ### Categories
1910 ###
1911 !! article
1912 Category:MediaWiki User's Guide
1913 !! text
1914 blah
1915 !! endarticle
1916
1917 !! test
1918 Link to category
1919 !! input
1920 [[:Category:MediaWiki User's Guide]]
1921 !! result
1922 <p><a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User's Guide">Category:MediaWiki User's Guide</a>
1923 </p>
1924 !! end
1925
1926 !! test
1927 Simple category
1928 !! options
1929 cat
1930 !! input
1931 [[Category: MediaWiki User's Guide]]
1932 !! result
1933 <a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User's Guide">MediaWiki User's Guide</a>
1934 !! end
1935
1936 ###
1937 ### Inter-language links
1938 ###
1939 !! test
1940 Inter-language links
1941 !! options
1942 ill
1943 !! input
1944 [[es:Alimento]]
1945 [[fr:Nourriture]]
1946 [[zh:&#39135;&#21697;]]
1947 !! result
1948 es:Alimento fr:Nourriture zh:食品
1949 !! end
1950
1951 ###
1952 ### Sections
1953 ###
1954 !! test
1955 Basic section headings
1956 !! options
1957 title=[[Parser test script]]
1958 !! input
1959 == Headline 1 ==
1960 Some text
1961
1962 ==Headline 2==
1963 More
1964 ===Smaller headline===
1965 Blah blah
1966 !! result
1967 <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>
1968 <p>Some text
1969 </p>
1970 <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>
1971 <p>More
1972 </p>
1973 <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>
1974 <p>Blah blah
1975 </p>
1976 !! end
1977
1978 !! test
1979 Section headings with TOC
1980 !! options
1981 title=[[Parser test script]]
1982 !! input
1983 == Headline 1 ==
1984 === Subheadline 1 ===
1985 ===== Skipping a level =====
1986 ====== Skipping a level ======
1987
1988 == Headline 2 ==
1989 Some text
1990 ===Another headline===
1991 !! result
1992 <table id='toc' class='toc'><tr><td><div id='toctitle'><h2>Contents</h2></div>
1993 <ul>
1994 <li class='toclevel-1'><a href="#Headline_1"><span class="tocnumber">1</span> <span class="toctext">Headline 1</span></a>
1995 <ul>
1996 <li class='toclevel-2'><a href="#Subheadline_1"><span class="tocnumber">1.1</span> <span class="toctext">Subheadline 1</span></a>
1997 <ul>
1998 <li class='toclevel-3'><a href="#Skipping_a_level"><span class="tocnumber">1.1.1</span> <span class="toctext">Skipping a level</span></a>
1999 <ul>
2000 <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>
2001 </ul>
2002 </li>
2003 </ul>
2004 </li>
2005 </ul>
2006 </li>
2007 <li class='toclevel-1'><a href="#Headline_2"><span class="tocnumber">2</span> <span class="toctext">Headline 2</span></a>
2008 <ul>
2009 <li class='toclevel-2'><a href="#Another_headline"><span class="tocnumber">2.1</span> <span class="toctext">Another headline</span></a></li>
2010 </ul>
2011 </li>
2012 </ul>
2013 </td></tr></table>
2014 <script type="text/javascript"> if (window.showTocToggle) { var tocShowText = "show"; var tocHideText = "hide"; showTocToggle(); } </script>
2015 <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>
2016 <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>
2017 <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>
2018 <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>
2019 <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>
2020 <p>Some text
2021 </p>
2022 <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>
2023
2024 !! end
2025
2026 # perl -e 'print "="x$_," Level $_ heading","="x$_,"\n" for 1..10'
2027 !! test
2028 Handling of sections up to level 6 and beyond
2029 !! input 
2030 = Level 1 Heading=
2031 == Level 2 Heading==
2032 === Level 3 Heading===
2033 ==== Level 4 Heading====
2034 ===== Level 5 Heading=====
2035 ====== Level 6 Heading======
2036 ======= Level 7 Heading=======
2037 ======== Level 8 Heading========
2038 ========= Level 9 Heading=========
2039 ========== Level 10 Heading==========
2040 !! result
2041 <table id='toc' class='toc'><tr><td><div id='toctitle'><h2>Contents</h2></div>
2042 <ul>
2043 <li class='toclevel-1'><a href="#Level_1_Heading"><span class="tocnumber">1</span> <span class="toctext">Level 1 Heading</span></a>
2044 <ul>
2045 <li class='toclevel-2'><a href="#Level_2_Heading"><span class="tocnumber">1.1</span> <span class="toctext">Level 2 Heading</span></a>
2046 <ul>
2047 <li class='toclevel-3'><a href="#Level_3_Heading"><span class="tocnumber">1.1.1</span> <span class="toctext">Level 3 Heading</span></a>
2048 <ul>
2049 <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>
2050 <ul>
2051 <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>
2052 <ul>
2053 <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>
2054 <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>
2055 <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>
2056 <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>
2057 <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>
2058 </ul>
2059 </li>
2060 </ul>
2061 </li>
2062 </ul>
2063 </li>
2064 </ul>
2065 </li>
2066 </ul>
2067 </li>
2068 </ul>
2069 </td></tr></table>
2070 <p><script type="text/javascript"> if (window.showTocToggle) { var tocShowText = "show"; var tocHideText = "hide"; showTocToggle(); } </script>
2071 </p>
2072 <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>
2073 <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>
2074 <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>
2075 <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>
2076 <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>
2077 <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>
2078 <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>
2079 <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>
2080 <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>
2081 <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>
2082
2083 !! end
2084
2085 !! test
2086 Resolving duplicate section names
2087 !! options
2088 title=[[Parser test script]]
2089 !! input
2090 == Foo bar ==
2091 == Foo bar ==
2092 !! result
2093 <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>
2094 <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>
2095
2096 !! end
2097
2098 !! article
2099 Template:sections
2100 !! text
2101 ===Section 1===
2102 ==Section 2==
2103 !! endarticle
2104
2105 !! test
2106 Template with sections, __NOTOC__
2107 !! options
2108 title=[[Parser test script]]
2109 !! input
2110 __NOTOC__
2111 ==Section 0==
2112 {{sections}}
2113 ==Section 4==
2114 !! result
2115 <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>
2116 <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>
2117 <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>
2118 <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>
2119
2120 !! end
2121
2122 !! test
2123 __NOEDITSECTION__ keyword
2124 !! input
2125 __NOEDITSECTION__
2126 ==Section 1==
2127 ==Section 2==
2128 !! result
2129 <a name="Section_1"></a><h2>Section 1</h2>
2130 <a name="Section_2"></a><h2>Section 2</h2>
2131
2132 !! end
2133
2134 !! test
2135 Link inside a section heading
2136 !! options
2137 title=[[Parser test script]]
2138 !! input
2139 ==Section with a [[Main Page|link]] in it==
2140 !! result
2141 <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>
2142
2143 !! end
2144
2145
2146 !! test
2147 BUG 1219 URL next to image (good)
2148 !! input
2149 http://example.com [[Image:foobar.jpg]]
2150 !! result
2151 <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="/images/3/3a/Foobar.jpg" alt="Image:foobar.jpg" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a>
2152 </p>
2153 !!end
2154
2155 !! test
2156 BUG 1219 URL next to image (broken)
2157 !! input
2158 http://example.com[[Image:foobar.jpg]]
2159 !! result
2160 <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="/images/3/3a/Foobar.jpg" alt="Image:foobar.jpg" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a>
2161 </p>
2162 !!end
2163
2164 !! test
2165 Bug 1186 news: in the middle of text
2166 !! input
2167 http://en.wikinews.org/wiki/Wikinews:Workplace
2168 !! result
2169 <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>
2170 </p>
2171 !!end
2172
2173
2174 !! test
2175 Namespaced link must have a title
2176 !! input
2177 [[Project:]]
2178 !! result
2179 <p>[[Project:]]
2180 </p>
2181 !!end
2182
2183 !! test
2184 Namespaced link must have a title (bad fragment version)
2185 !! input
2186 [[Project:#fragment]]
2187 !! result
2188 <p>[[Project:#fragment]]
2189 </p>
2190 !!end
2191
2192
2193 !! test
2194 div with no attributes
2195 !! input
2196 <div>HTML rocks</div>
2197 !! result
2198 <div>HTML rocks</div>
2199
2200 !! end
2201
2202 !! test
2203 div with double-quoted attribute
2204 !! input
2205 <div id="rock">HTML rocks</div>
2206 !! result
2207 <div id="rock">HTML rocks</div>
2208
2209 !! end
2210
2211 !! test
2212 div with single-quoted attribute
2213 !! input
2214 <div id='rock'>HTML rocks</div>
2215 !! result
2216 <div id="rock">HTML rocks</div>
2217
2218 !! end
2219
2220 !! test
2221 div with unquoted attribute
2222 !! input
2223 <div id=rock>HTML rocks</div>
2224 !! result
2225 <div id="rock">HTML rocks</div>
2226
2227 !! end
2228
2229 !! test
2230 div with illegal double attributes
2231 !! input
2232 <div align="center" align="right">HTML rocks</div>
2233 !! result
2234 <div align="right">HTML rocks</div>
2235
2236 !!end
2237
2238 !! test
2239 HTML multiple attributes correction
2240 !! input
2241 <p class="error" class="awesome">Awesome!</p>
2242 !! result
2243 <p class="awesome">Awesome!</p>
2244
2245 !!end
2246
2247 !! test
2248 Table multiple attributes correction
2249 !! input
2250 {|
2251 !+ class="error" class="awesome"| status
2252 |}
2253 !! result
2254 <table>
2255 <tr>
2256 <th class="awesome">status</th>
2257 </tr>
2258 </table>
2259
2260 !!end
2261
2262 !! test
2263 DIV IN UPPERCASE
2264 !! input
2265 <DIV ALIGN="center">HTML ROCKS</DIV>
2266 !! result
2267 <div align="center">HTML ROCKS</div>
2268
2269 !!end
2270
2271
2272 !! test
2273 text with amp in the middle of nowhere
2274 !! input
2275 Remember AT&T?
2276 !!result
2277 <p>Remember AT&amp;T?
2278 </p>
2279 !! end
2280
2281 !! test
2282 text with character entity: eacute
2283 !! input
2284 I always thought &eacute; was a cute letter.
2285 !! result
2286 <p>I always thought &eacute; was a cute letter.
2287 </p>
2288 !! end
2289
2290 !! test
2291 text with undefined character entity: xacute
2292 !! input
2293 I always thought &xacute; was a cute letter.
2294 !! result
2295 <p>I always thought &amp;xacute; was a cute letter.
2296 </p>
2297 !! end
2298
2299
2300 ###
2301 ### Media links
2302 ###
2303
2304 !! test
2305 Media link
2306 !! input
2307 [[Media:Foobar.jpg]]
2308 !! result
2309 <p><a href="/images/3/3a/Foobar.jpg" class='internal' title="Foobar.jpg">Media:Foobar.jpg</a>
2310 </p>
2311 !! end
2312
2313 !! test
2314 Media link with text
2315 !! input
2316 [[Media:Foobar.jpg|A neat file to look at]]
2317 !! result
2318 <p><a href="/images/3/3a/Foobar.jpg" class='internal' title="Foobar.jpg">A neat file to look at</a>
2319 </p>
2320 !! end
2321
2322 # FIXME: this is still bad HTML tag nesting
2323 !! test
2324 Media link with nasty text
2325 !! input
2326 [[Media:Foobar.jpg|Safe Link<div style=display:none>" onmouseover="alert(document.cookie)" onfoo="</div>]]
2327 !! result
2328 <p><a href="/images/3/3a/Foobar.jpg" class='internal' title="Foobar.jpg">Safe Link<div style="display:none">" onmouseover="alert(document.cookie) onfoo="</div></a>
2329 </p>
2330 !! end
2331
2332 !! test
2333 Media link to nonexistent file (bug 1702)
2334 !! input
2335 [[Media:No such.jpg]]
2336 !! result
2337 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=No_such.jpg" class='new' title="No such.jpg">Media:No such.jpg</a>
2338 </p>
2339 !! end
2340
2341
2342
2343 !! test
2344 Character reference normalization in link text (bug 1938)
2345 !! input
2346 [[Main Page|this&that]]
2347 !! result
2348 <p><a href="/wiki/Main_Page" title="Main Page">this&amp;that</a>
2349 </p>
2350 !!end
2351
2352 !! test
2353 Empty attribute crash test (bug 2067)
2354 !! input
2355 <font color="">foo</font>
2356 !! result
2357 <p><font color="">foo</font>
2358 </p>
2359 !! end
2360
2361 !! test
2362 Empty attribute crash test single-quotes (bug 2067)
2363 !! input
2364 <font color=''>foo</font>
2365 !! result
2366 <p><font color="">foo</font>
2367 </p>
2368 !! end
2369
2370 !! test
2371 Attribute test: equals, then nothing
2372 !! input
2373 <font color=>foo</font>
2374 !! result
2375 <p><font>foo</font>
2376 </p>
2377 !! end
2378
2379 !! test
2380 Attribute test: unquoted value
2381 !! input
2382 <font color=x>foo</font>
2383 !! result
2384 <p><font color="x">foo</font>
2385 </p>
2386 !! end
2387
2388 !! test
2389 Attribute test: unquoted but illegal value (hash)
2390 !! input
2391 <font color=#x>foo</font>
2392 !! result
2393 <p><font color="#x">foo</font>
2394 </p>
2395 !! end
2396
2397 !! test
2398 Attribute test: no value
2399 !! input
2400 <font color>foo</font>
2401 !! result
2402 <p><font color="color">foo</font>
2403 </p>
2404 !! end
2405
2406 !! test
2407 Bug 2095: link with three closing brackets
2408 !! input
2409 [[Main Page]]]
2410 !! result
2411 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>]
2412 </p>
2413 !! end
2414
2415 !! test
2416 Bug 2095: link with pipe and three closing brackets
2417 !! input
2418 [[Main Page|link]]]
2419 !! result
2420 <p><a href="/wiki/Main_Page" title="Main Page">link</a>]
2421 </p>
2422 !! end
2423
2424
2425 ###
2426 ### Safety
2427 ###
2428
2429 !! article
2430 Template:Dangerous attribute
2431 !! text
2432 " onmouseover="alert(document.cookie)
2433 !! endarticle
2434
2435 !! article
2436 Template:Dangerous style attribute
2437 !! text
2438 border-size: expression(alert(document.cookie))
2439 !! endarticle
2440
2441 !! article
2442 Template:Div style
2443 !! text
2444 <div style="float: right; {{{1}}}">Magic div</div>
2445 !! endarticle
2446
2447 !! test
2448 Bug 2304: HTML attribute safety (safe template; regression bug 2309)
2449 !! input
2450 <div title="{{test}}"></div>
2451 !! result
2452 <div title="This is a test template"></div>
2453
2454 !! end
2455
2456 !! test
2457 Bug 2304: HTML attribute safety (dangerous template; 2309)
2458 !! input
2459 <div title="{{dangerous attribute}}"></div>
2460 !! result
2461 <div title=""></div>
2462
2463 !! end
2464
2465 !! test
2466 Bug 2304: HTML attribute safety (dangerous style template; 2309)
2467 !! input
2468 <div style="{{dangerous style attribute}}"></div>
2469 !! result
2470 <div></div>
2471
2472 !! end
2473
2474 !! test
2475 Bug 2304: HTML attribute safety (safe parameter; 2309)
2476 !! input
2477 {{div style|width: 200px}}
2478 !! result
2479 <div style="float: right; width: 200px">Magic div</div>
2480
2481 !! end
2482
2483 !! test
2484 Bug 2304: HTML attribute safety (unsafe parameter; 2309)
2485 !! input
2486 {{div style|width: expression(alert(document.cookie))}}
2487 !! result
2488 <div>Magic div</div>
2489
2490 !! end
2491
2492 !! test
2493 Bug 2304: HTML attribute safety (unsafe breakout parameter; 2309)
2494 !! input
2495 {{div style|"><script>alert(document.cookie)</script>}}
2496 !! result
2497 <div>Magic div</div>
2498
2499 !! end
2500
2501 !! test
2502 Bug 2304: HTML attribute safety (unsafe breakout parameter 2; 2309)
2503 !! input
2504 {{div style|" ><script>alert(document.cookie)</script>}}
2505 !! result
2506 <div style="float: right; ">Magic div</div>
2507
2508 !! end
2509
2510 !! test
2511 Bug 2304: HTML attribute safety (link)
2512 !! input
2513 <div title="[[Main Page]]"></div>
2514 !! result
2515 <div title="&#91;&#91;Main Page]]"></div>
2516
2517 !! end
2518
2519 !! test
2520 Bug 2304: HTML attribute safety (italics)
2521 !! input
2522 <div title="''foobar''"></div>
2523 !! result
2524 <div title="&#39;&#39;foobar&#39;&#39;"></div>
2525
2526 !! end
2527
2528 !! test
2529 Bug 2304: HTML attribute safety (bold)
2530 !! input
2531 <div title="'''foobar'''"></div>
2532 !! result
2533 <div title="&#39;&#39;'foobar&#39;&#39;'"></div>
2534
2535 !! end
2536
2537 !! test
2538 Bug 2304: HTML attribute safety (ISBN)
2539 !! input
2540 <div title="ISBN 1234567890"></div>
2541 !! result
2542 <div title="&#73;SBN 1234567890"></div>
2543
2544 !! end
2545
2546 !! test
2547 Bug 2304: HTML attribute safety (RFC)
2548 !! input
2549 <div title="RFC 1234"></div>
2550 !! result
2551 <div title="&#82;FC 1234"></div>
2552
2553 !! end
2554
2555 !! test
2556 Bug 2304: HTML attribute safety (PMID)
2557 !! input
2558 <div title="PMID 1234567890"></div>
2559 !! result
2560 <div title="&#80;MID 1234567890"></div>
2561
2562 !! end
2563
2564 !! test
2565 Bug 2304: HTML attribute safety (web link)
2566 !! input
2567 <div title="http://example.com/"></div>
2568 !! result
2569 <div title="http&#58;//example.com/"></div>
2570
2571 !! end
2572
2573 !! test
2574 Bug 2304: HTML attribute safety (named web link)
2575 !! input
2576 <div title="[http://example.com/ link]"></div>
2577 !! result
2578 <div title="&#91;http&#58;//example.com/ link]"></div>
2579
2580 !! end
2581
2582 !! test
2583 Bug 3244: HTML attribute safety (extension; safe)
2584 !! input
2585 <div style="<nowiki>background:blue</nowiki>"></div>
2586 !! result
2587 <div style="background:blue"></div>
2588
2589 !! end
2590
2591 !! test
2592 Bug 3244: HTML attribute safety (extension; unsafe)
2593 !! input
2594 <div style="<nowiki>border-left:expression(alert(document.cookie))</nowiki>"></div>
2595 !! result
2596 <div></div>
2597
2598 !! end
2599
2600
2601 !! test
2602 Math section safety when disabled
2603 !! input
2604 <math><script>alert(document.cookies);</script></math>
2605 !! result
2606 <p>&lt;math&gt;&lt;script&gt;alert(document.cookies);&lt;/script&gt;&lt;/math&gt;
2607 </p>
2608 !! end
2609
2610
2611 !! test
2612 Table attribute legitimate extension
2613 !! input
2614 {|
2615 !+ style="<nowiki>color:blue</nowiki>"| status
2616 |}
2617 !! result
2618 <table>
2619 <tr>
2620 <th style="color:blue"> status
2621 </th></tr></table>
2622
2623 !!end
2624
2625 !! test
2626 Table attribute safety
2627 !! input
2628 {|
2629 !+ style="<nowiki>border-width:expression(0+alert(document.cookie))</nowiki>"| status
2630 |}
2631 !! result
2632 <table>
2633 <tr>
2634 <th> status
2635 </th></tr></table>
2636
2637 !! end
2638
2639
2640 # More MSIE fun discovered by Tom Gilder
2641
2642 !! test
2643 MSIE CSS safety test: spurious slash
2644 !! input
2645 <div style="background-image:u\rl(javascript:alert('boo'))">evil</div>
2646 !! result
2647 <div>evil</div>
2648
2649 !! end
2650
2651 !! test
2652 MSIE CSS safety test: hex code
2653 !! input
2654 <div style="background-image:u\72l(javascript:alert('boo'))">evil</div>
2655 !! result
2656 <div>evil</div>
2657
2658 !! end
2659
2660 !! test
2661 MSIE CSS safety test: comment in url
2662 !! input
2663 <div style="background-image:u/**/rl(javascript:alert('boo'))">evil</div>
2664 !! result
2665 <div style="background-image:u rl(javascript:alert('boo'))">evil</div>
2666
2667 !! end
2668
2669 !! test
2670 MSIE CSS safety test: comment in expression
2671 !! input
2672 <div style="background-image:expres/**/sion(alert('boo4'))">evil4</div>
2673 !! result
2674 <div style="background-image:expres sion(alert('boo4'))">evil4</div>
2675
2676 !! end
2677
2678
2679 TODO:
2680 more images
2681 more tables
2682 math
2683 character entities
2684 and much more