* Adding a tool to find duplicate translations
[mediawiki.git] / maintenance / parserTests.txt
blob9794cff3c0b2e01b255bd87606d0c9e6ad899a7c
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 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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
613 !! test
614 BUG 787: Links with one slash after the url protocol are invalid
615 !! input
616 http:/example.com
618 [http:/example.com title]
619 !! result
620 <p>http:/example.com
621 </p><p>[http:/example.com title]
622 </p>
623 !! end
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
635 ### Quotes
638 !! test
639 Quotes
640 !! input
641 Normal text. '''Bold text.''' Normal text. ''Italic text.''
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
651 !! test
652 Unclosed and unmatched quotes
653 !! input
654 '''''Bold italic text '''with bold deactivated''' in between.'''''
656 '''''Bold italic text ''with italic deactivated'' in between.'''''
658 '''Bold text..
660 ..spanning two paragraphs (should not work).'''
662 '''Bold tag left open
664 ''Italic tag left open
666 Normal text.
668 <!-- Unmatching number of opening, closing tags: -->
669 '''This year''''s election ''should'' beat '''last year''''s.
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
686 ### Tables
688 ### some content taken from http://meta.wikimedia.org/wiki/MediaWiki_User%27s_Guide:_Using_tables
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
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 
707 |+ caption
709 !! result
710 <table>
711 <caption> caption
712 </caption>
713 <tr>
714 <td>
715 </td></tr></table>
716 !! end
718 !! test
719 Simple table
720 !! input
721 {| 
722 | 1 || 2
723 |- 
724 | 3 || 4
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>
735 !! end
737 !! test
738 Multiplication table
739 !! input
740 {| border="1" cellpadding="2"
741 |+Multiplication table
743 ! &times; !! 1 !! 2 !! 3
745 ! 1
746 | 1 || 2 || 3
748 ! 2
749 | 2 || 4 || 6
751 ! 3
752 | 3 || 6 || 9
754 ! 4
755 | 4 || 8 || 12
757 ! 5
758 | 5 || 10 || 15
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>
788 !! end
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 
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>
813 !! end
815 !! test
816 Nested table
817 !! input
818 {| border=1
819 | &alpha;
821 {| bgcolor=#ABCDEF border=2
822 |nested
824 |table
826 |the original table again
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>
843 !! end
845 !! test
846 Invalid attributes in table cell (bug 1830)
847 !! input
849 |Cell:|broken
851 !! result
852 <table>
853 <tr>
854 <td>broken
855 </td></tr></table>
857 !! end
861 ### Internal links
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
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
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
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
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
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
917 !! test
918 Link with 3 brackets
919 !! input
920 [[[main page]]]
921 !! result
922 <p>[[[main page]]]
923 </p>
924 !! end
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
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
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
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
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
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
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
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
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
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.
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
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
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
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
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
1068 ### Interwiki links (see maintenance/interwiki.sql)
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
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
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>
1099 !! end
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
1111 ## XHTML tidiness
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
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
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
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
1159 ### Block-level elements
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>
1173 !! end
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>
1187 !! end
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>
1229 !! end
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>
1243 !! end
1246 ### Magic variables
1248 !! test
1249 Magic variables
1250 !! input
1251 {{SITENAME}}
1252 !! result
1253 <p>MediaWiki
1254 </p>
1255 !! end
1258 ### Magic links
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
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
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
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
1297 ### Templates
1298 ####
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
1309 !! article
1310 Template:test
1311 !! text
1312 This is a test template
1313 !! endarticle
1315 !! test
1316 Simple template
1317 !! input
1318 {{test}}
1319 !! result
1320 <p>This is a test template
1321 </p>
1322 !! end
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
1334 !! article
1335 Template:paramtest
1336 !! text
1337 This is a test template with parameter {{{param}}}
1338 !! endarticle
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
1349 !! article
1350 Template:paramtestnum
1351 !! text
1352 [[{{{1}}}|{{{2}}}]]
1353 !! endarticle
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
1364 !! test
1365 BUG 553: link with two variables in a piped link
1366 !! input
1367 {| 
1368 |[[{{{1}}}|{{{2}}}]]
1370 !! result
1371 <table>
1372 <tr>
1373 <td>[[{{{1}}}|{{{2}}}]]
1374 </td></tr></table>
1376 !! end
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
1387 !! article
1388 Template:linktest
1389 !! text
1390 [[{{{param}}}|link]]
1391 !! endarticle
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
1403 !!article
1404 Template:paramtest2
1405 !! text
1406 including another template, {{paramtest|param={{{arg}}}}}
1407 !! endarticle
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
1418 !! article
1419 Template:Linktest2
1420 !! text
1421 Main Page
1422 !! endarticle
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
1434 !! article
1435 Template:loop1
1436 !! text
1437 {{loop2}}
1438 !! endarticle
1440 !! article
1441 Template:loop2
1442 !! text
1443 {{loop1}}
1444 !! endarticle
1446 !! test
1447 Template infinite loop
1448 !! input
1449 {{loop1}}
1450 !! result
1451 <p>{{loop1}}<!-- WARNING: template loop detected -->
1452 </p>
1453 !! end
1455 !! test
1456 Template from main namespace
1457 !! input
1458 {{:Main Page}}
1459 !! result
1460 <p>blah blah
1461 </p>
1462 !! end
1464 !! article
1465 Template:table
1466 !! text
1467 {| 
1468 | 1 || 2
1469 |- 
1470 | 3 || 4
1472 !! endarticle
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>
1489 !! end
1491 !! test
1492 BUG 523: Template shouldn't eat newline (or add an extra one before table)
1493 !! input
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>
1507 !! end
1509 !! test
1510 BUG 41: Template parameters shown as broken links
1511 !! input
1512 {{{parameter}}}
1513 !! result
1514 <p>{{{parameter}}}
1515 </p>
1516 !! end
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
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
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
1553 ### Pre-save transform tests
1555 !! test
1556 pre-save transform: subst:
1557 !! options
1559 !! input
1560 {{subst:test}}
1561 !! result
1562 This is a test template
1563 !! end
1565 !! test
1566 pre-save transform: normal template
1567 !! options
1569 !! input
1570 {{test}}
1571 !! result
1572 {{test}}
1573 !! end
1575 !! test
1576 pre-save transform: nonexistant template
1577 !! options
1579 !! input
1580 {{thistemplatedoesnotexist}}
1581 !! result
1582 {{thistemplatedoesnotexist}}
1583 !! end
1586 !! test
1587 pre-save transform: subst magic variables
1588 !! options
1590 !! input
1591 {{subst:SITENAME}}
1592 !! result
1593 MediaWiki
1594 !! end
1596 # This is bug 89, which I fixed. -- wtm
1597 !! test
1598 pre-save transform: subst: templates with parameters
1599 !! options
1601 !! input
1602 {{subst:paramtest|param="something else"}}
1603 !! result
1604 This is a test template with parameter "something else"
1605 !! end
1608 !! article
1609 Template:nowikitest
1610 !! text
1611 <nowiki>'''not wiki'''</nowiki>
1612 !! endarticle
1614 !! test
1615 pre-save transform: nowiki in subst (bug 1188)
1616 !! options
1618 !! input
1619 {{subst:nowikitest}}
1620 !! result
1621 <nowiki>'''not wiki'''</nowiki>
1622 !! end
1625 !! article
1626 Template:commenttest
1627 !! text
1628 This template has <!-- a comment --> in it.
1629 !! endarticle
1631 !! test
1632 pre-save transform: comment in subst (bug 1936)
1633 !! options
1635 !! input
1636 {{subst:commenttest}}
1637 !! result
1638 This template has <!-- a comment --> in it.
1639 !! end
1642 !! article
1643 Template:dangerous
1644 !!text
1645 <span onmouseover="alert('crap')">Oh no</span>
1646 !!endarticle
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
1659 ### Message transform tests
1661 !! test
1662 message transform: magic variables
1663 !! options
1665 !! input
1666 {{SITENAME}}
1667 !! result
1668 MediaWiki
1669 !! end
1671 !! test
1672 message transform: should not transform wiki markup
1673 !! options
1675 !! input
1676 ''test''
1677 !! result
1678 ''test''
1679 !! end
1682 ### Images
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
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>
1700 !! end
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>
1709 !! end
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>
1718 !! end
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
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
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>
1745 !! end
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
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
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
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
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
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
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
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
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
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>
1834 !! end
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
1849 ### Subpages
1851 !! article
1852 Subpage test/subpage
1853 !! text
1855 !! endarticle
1857 !! test
1858 Subpage link
1859 !! options
1860 subpage title=[[Subpage test]]
1861 !! input
1862 [[/subpage]]
1863 !! result
1864 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a>
1865 </p>
1866 !! end
1868 !! test
1869 Subpage noslash link
1870 !! options
1871 subpage title=[[Subpage test]]
1872 !!input
1873 [[/subpage/]]
1874 !! result
1875 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">subpage</a>
1876 </p>
1877 !! end
1879 !! test
1880 Disabled subpages
1881 !! input
1882 [[/subpage]]
1883 !! result
1884 <p><a href="/index.php?title=/subpage&amp;action=edit" class="new" title="/subpage">/subpage</a>
1885 </p>
1886 !! end
1888 !! test
1889 BUG 561: {{/Subpage}}
1890 !! options
1891 subpage title=[[Page]]
1892 !! input
1893 {{/Subpage}}
1894 !! result
1895 <p><a href="/index.php?title=Page/Subpage&amp;action=edit" class="new" title="Page/Subpage">Page/Subpage</a>
1896 </p>
1897 !! end
1900 ### Categories
1902 !! article
1903 Category:MediaWiki User's Guide
1904 !! text
1905 blah
1906 !! endarticle
1908 !! test
1909 Link to category
1910 !! input
1911 [[:Category:MediaWiki User's Guide]]
1912 !! result
1913 <p><a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User's Guide">Category:MediaWiki User's Guide</a>
1914 </p>
1915 !! end
1917 !! test
1918 Simple category
1919 !! options
1921 !! input
1922 [[Category: MediaWiki User's Guide]]
1923 !! result
1924 <a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User's Guide">MediaWiki User's Guide</a>
1925 !! end
1928 ### Inter-language links
1930 !! test
1931 Inter-language links
1932 !! options
1934 !! input
1935 [[es:Alimento]]
1936 [[fr:Nourriture]]
1937 [[zh:&#39135;&#21697;]]
1938 !! result
1939 es:Alimento fr:Nourriture zh:食品
1940 !! end
1943 ### Sections
1945 !! test
1946 Basic section headings
1947 !! options
1948 title=[[Parser test script]]
1949 !! input
1950 == Headline 1 ==
1951 Some text
1953 ==Headline 2==
1954 More
1955 ===Smaller headline===
1956 Blah blah
1957 !! result
1958 <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>
1959 <p>Some text
1960 </p>
1961 <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>
1962 <p>More
1963 </p>
1964 <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>
1965 <p>Blah blah
1966 </p>
1967 !! end
1969 !! test
1970 Section headings with TOC
1971 !! options
1972 title=[[Parser test script]]
1973 !! input
1974 == Headline 1 ==
1975 === Subheadline 1 ===
1976 ===== Skipping a level =====
1977 ====== Skipping a level ======
1979 == Headline 2 ==
1980 Some text
1981 ===Another headline===
1982 !! result
1983 <table id='toc' class='toc'><tr><td><div id='toctitle'><h2>Contents</h2></div>
1984 <ul>
1985 <li class='toclevel-1'><a href="#Headline_1"><span class="tocnumber">1</span> <span class="toctext">Headline 1</span></a>
1986 <ul>
1987 <li class='toclevel-2'><a href="#Subheadline_1"><span class="tocnumber">1.1</span> <span class="toctext">Subheadline 1</span></a>
1988 <ul>
1989 <li class='toclevel-3'><a href="#Skipping_a_level"><span class="tocnumber">1.1.1</span> <span class="toctext">Skipping a level</span></a>
1990 <ul>
1991 <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>
1992 </ul>
1993 </li>
1994 </ul>
1995 </li>
1996 </ul>
1997 </li>
1998 <li class='toclevel-1'><a href="#Headline_2"><span class="tocnumber">2</span> <span class="toctext">Headline 2</span></a>
1999 <ul>
2000 <li class='toclevel-2'><a href="#Another_headline"><span class="tocnumber">2.1</span> <span class="toctext">Another headline</span></a></li>
2001 </ul>
2002 </li>
2003 </ul>
2004 </td></tr></table>
2005 <script type="text/javascript"> if (window.showTocToggle) { var tocShowText = "show"; var tocHideText = "hide"; showTocToggle(); } </script>
2006 <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>
2007 <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>
2008 <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>
2009 <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>
2010 <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>
2011 <p>Some text
2012 </p>
2013 <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>
2015 !! end
2017 # perl -e 'print "="x$_," Level $_ heading","="x$_,"\n" for 1..10'
2018 !! test
2019 Handling of sections up to level 6 and beyond
2020 !! input 
2021 = Level 1 Heading=
2022 == Level 2 Heading==
2023 === Level 3 Heading===
2024 ==== Level 4 Heading====
2025 ===== Level 5 Heading=====
2026 ====== Level 6 Heading======
2027 ======= Level 7 Heading=======
2028 ======== Level 8 Heading========
2029 ========= Level 9 Heading=========
2030 ========== Level 10 Heading==========
2031 !! result
2032 <table id='toc' class='toc'><tr><td><div id='toctitle'><h2>Contents</h2></div>
2033 <ul>
2034 <li class='toclevel-1'><a href="#Level_1_Heading"><span class="tocnumber">1</span> <span class="toctext">Level 1 Heading</span></a>
2035 <ul>
2036 <li class='toclevel-2'><a href="#Level_2_Heading"><span class="tocnumber">1.1</span> <span class="toctext">Level 2 Heading</span></a>
2037 <ul>
2038 <li class='toclevel-3'><a href="#Level_3_Heading"><span class="tocnumber">1.1.1</span> <span class="toctext">Level 3 Heading</span></a>
2039 <ul>
2040 <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>
2041 <ul>
2042 <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>
2043 <ul>
2044 <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>
2045 <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>
2046 <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>
2047 <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>
2048 <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>
2049 </ul>
2050 </li>
2051 </ul>
2052 </li>
2053 </ul>
2054 </li>
2055 </ul>
2056 </li>
2057 </ul>
2058 </li>
2059 </ul>
2060 </td></tr></table>
2061 <p><script type="text/javascript"> if (window.showTocToggle) { var tocShowText = "show"; var tocHideText = "hide"; showTocToggle(); } </script>
2062 </p>
2063 <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>
2064 <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>
2065 <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>
2066 <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>
2067 <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>
2068 <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>
2069 <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>
2070 <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>
2071 <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>
2072 <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>
2074 !! end
2076 !! test
2077 Resolving duplicate section names
2078 !! options
2079 title=[[Parser test script]]
2080 !! input
2081 == Foo bar ==
2082 == Foo bar ==
2083 !! result
2084 <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>
2085 <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>
2087 !! end
2089 !! article
2090 Template:sections
2091 !! text
2092 ===Section 1===
2093 ==Section 2==
2094 !! endarticle
2096 !! test
2097 Template with sections, __NOTOC__
2098 !! options
2099 title=[[Parser test script]]
2100 !! input
2101 __NOTOC__
2102 ==Section 0==
2103 {{sections}}
2104 ==Section 4==
2105 !! result
2106 <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>
2107 <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>
2108 <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>
2109 <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>
2111 !! end
2113 !! test
2114 __NOEDITSECTION__ keyword
2115 !! input
2116 __NOEDITSECTION__
2117 ==Section 1==
2118 ==Section 2==
2119 !! result
2120 <a name="Section_1"></a><h2>Section 1</h2>
2121 <a name="Section_2"></a><h2>Section 2</h2>
2123 !! end
2125 !! test
2126 Link inside a section heading
2127 !! options
2128 title=[[Parser test script]]
2129 !! input
2130 ==Section with a [[Main Page|link]] in it==
2131 !! result
2132 <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>
2134 !! end
2137 !! test
2138 BUG 1219 URL next to image (good)
2139 !! input
2140 http://example.com [[Image:foobar.jpg]]
2141 !! result
2142 <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>
2143 </p>
2144 !!end
2146 !! test
2147 BUG 1219 URL next to image (broken)
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
2155 !! test
2156 Bug 1186 news: in the middle of text
2157 !! input
2158 http://en.wikinews.org/wiki/Wikinews:Workplace
2159 !! result
2160 <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>
2161 </p>
2162 !!end
2165 !! test
2166 Namespaced link must have a title
2167 !! input
2168 [[Project:]]
2169 !! result
2170 <p>[[Project:]]
2171 </p>
2172 !!end
2174 !! test
2175 Namespaced link must have a title (bad fragment version)
2176 !! input
2177 [[Project:#fragment]]
2178 !! result
2179 <p>[[Project:#fragment]]
2180 </p>
2181 !!end
2184 !! test
2185 div with no attributes
2186 !! input
2187 <div>HTML rocks</div>
2188 !! result
2189 <div>HTML rocks</div>
2191 !! end
2193 !! test
2194 div with double-quoted attribute
2195 !! input
2196 <div id="rock">HTML rocks</div>
2197 !! result
2198 <div id="rock">HTML rocks</div>
2200 !! end
2202 !! test
2203 div with single-quoted attribute
2204 !! input
2205 <div id='rock'>HTML rocks</div>
2206 !! result
2207 <div id="rock">HTML rocks</div>
2209 !! end
2211 !! test
2212 div with unquoted attribute
2213 !! input
2214 <div id=rock>HTML rocks</div>
2215 !! result
2216 <div id="rock">HTML rocks</div>
2218 !! end
2220 !! test
2221 div with illegal double attributes
2222 !! input
2223 <div align="center" align="right">HTML rocks</div>
2224 !! result
2225 <div align="right">HTML rocks</div>
2227 !!end
2229 !! test
2230 HTML multiple attributes correction
2231 !! input
2232 <p class="error" class="awesome">Awesome!</p>
2233 !! result
2234 <p class="awesome">Awesome!</p>
2236 !!end
2238 !! test
2239 Table multiple attributes correction
2240 !! input
2242 !+ class="error" class="awesome"| status
2244 !! result
2245 <table>
2246 <tr>
2247 <th class="awesome">status</th>
2248 </tr>
2249 </table>
2251 !!end
2253 !! test
2254 DIV IN UPPERCASE
2255 !! input
2256 <DIV ALIGN="center">HTML ROCKS</DIV>
2257 !! result
2258 <div align="center">HTML ROCKS</div>
2260 !!end
2263 !! test
2264 text with amp in the middle of nowhere
2265 !! input
2266 Remember AT&T?
2267 !!result
2268 <p>Remember AT&amp;T?
2269 </p>
2270 !! end
2272 !! test
2273 text with character entity: eacute
2274 !! input
2275 I always thought &eacute; was a cute letter.
2276 !! result
2277 <p>I always thought &eacute; was a cute letter.
2278 </p>
2279 !! end
2281 !! test
2282 text with undefined character entity: xacute
2283 !! input
2284 I always thought &xacute; was a cute letter.
2285 !! result
2286 <p>I always thought &amp;xacute; was a cute letter.
2287 </p>
2288 !! end
2292 ### Media links
2295 !! test
2296 Media link
2297 !! input
2298 [[Media:Foobar.jpg]]
2299 !! result
2300 <p><a href="/images/3/3a/Foobar.jpg" class='internal' title="Foobar.jpg">Media:Foobar.jpg</a>
2301 </p>
2302 !! end
2304 !! test
2305 Media link with text
2306 !! input
2307 [[Media:Foobar.jpg|A neat file to look at]]
2308 !! result
2309 <p><a href="/images/3/3a/Foobar.jpg" class='internal' title="Foobar.jpg">A neat file to look at</a>
2310 </p>
2311 !! end
2313 # FIXME: this is still bad HTML tag nesting
2314 !! test
2315 Media link with nasty text
2316 !! input
2317 [[Media:Foobar.jpg|Safe Link<div style=display:none>" onmouseover="alert(document.cookie)" onfoo="</div>]]
2318 !! result
2319 <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>
2320 </p>
2321 !! end
2323 !! test
2324 Media link to nonexistent file (bug 1702)
2325 !! input
2326 [[Media:No such.jpg]]
2327 !! result
2328 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=No_such.jpg" class='new' title="No such.jpg">Media:No such.jpg</a>
2329 </p>
2330 !! end
2334 !! test
2335 Character reference normalization in link text (bug 1938)
2336 !! input
2337 [[Main Page|this&that]]
2338 !! result
2339 <p><a href="/wiki/Main_Page" title="Main Page">this&amp;that</a>
2340 </p>
2341 !!end
2343 !! test
2344 Empty attribute crash test (bug 2067)
2345 !! input
2346 <font color="">foo</font>
2347 !! result
2348 <p><font color="">foo</font>
2349 </p>
2350 !! end
2352 !! test
2353 Empty attribute crash test single-quotes (bug 2067)
2354 !! input
2355 <font color=''>foo</font>
2356 !! result
2357 <p><font color="">foo</font>
2358 </p>
2359 !! end
2361 !! test
2362 Attribute test: equals, then nothing
2363 !! input
2364 <font color=>foo</font>
2365 !! result
2366 <p><font>foo</font>
2367 </p>
2368 !! end
2370 !! test
2371 Attribute test: unquoted value
2372 !! input
2373 <font color=x>foo</font>
2374 !! result
2375 <p><font color="x">foo</font>
2376 </p>
2377 !! end
2379 !! test
2380 Attribute test: unquoted but illegal value (hash)
2381 !! input
2382 <font color=#x>foo</font>
2383 !! result
2384 <p><font color="#x">foo</font>
2385 </p>
2386 !! end
2388 !! test
2389 Attribute test: no value
2390 !! input
2391 <font color>foo</font>
2392 !! result
2393 <p><font color="color">foo</font>
2394 </p>
2395 !! end
2397 !! test
2398 Bug 2095: link with three closing brackets
2399 !! input
2400 [[Main Page]]]
2401 !! result
2402 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>]
2403 </p>
2404 !! end
2406 !! test
2407 Bug 2095: link with pipe and three closing brackets
2408 !! input
2409 [[Main Page|link]]]
2410 !! result
2411 <p><a href="/wiki/Main_Page" title="Main Page">link</a>]
2412 </p>
2413 !! end
2417 ### Safety
2420 !! article
2421 Template:Dangerous attribute
2422 !! text
2423 " onmouseover="alert(document.cookie)
2424 !! endarticle
2426 !! article
2427 Template:Dangerous style attribute
2428 !! text
2429 border-size: expression(alert(document.cookie))
2430 !! endarticle
2432 !! article
2433 Template:Div style
2434 !! text
2435 <div style="float: right; {{{1}}}">Magic div</div>
2436 !! endarticle
2438 !! test
2439 Bug 2304: HTML attribute safety (safe template; regression bug 2309)
2440 !! input
2441 <div title="{{test}}"></div>
2442 !! result
2443 <div title="This is a test template"></div>
2445 !! end
2447 !! test
2448 Bug 2304: HTML attribute safety (dangerous template; 2309)
2449 !! input
2450 <div title="{{dangerous attribute}}"></div>
2451 !! result
2452 <div title=""></div>
2454 !! end
2456 !! test
2457 Bug 2304: HTML attribute safety (dangerous style template; 2309)
2458 !! input
2459 <div style="{{dangerous style attribute}}"></div>
2460 !! result
2461 <div></div>
2463 !! end
2465 !! test
2466 Bug 2304: HTML attribute safety (safe parameter; 2309)
2467 !! input
2468 {{div style|width: 200px}}
2469 !! result
2470 <div style="float: right; width: 200px">Magic div</div>
2472 !! end
2474 !! test
2475 Bug 2304: HTML attribute safety (unsafe parameter; 2309)
2476 !! input
2477 {{div style|width: expression(alert(document.cookie))}}
2478 !! result
2479 <div>Magic div</div>
2481 !! end
2483 !! test
2484 Bug 2304: HTML attribute safety (unsafe breakout parameter; 2309)
2485 !! input
2486 {{div style|"><script>alert(document.cookie)</script>}}
2487 !! result
2488 <div>Magic div</div>
2490 !! end
2492 !! test
2493 Bug 2304: HTML attribute safety (unsafe breakout parameter 2; 2309)
2494 !! input
2495 {{div style|" ><script>alert(document.cookie)</script>}}
2496 !! result
2497 <div style="float: right; ">Magic div</div>
2499 !! end
2501 !! test
2502 Bug 2304: HTML attribute safety (link)
2503 !! input
2504 <div title="[[Main Page]]"></div>
2505 !! result
2506 <div title="&#91;&#91;Main Page]]"></div>
2508 !! end
2510 !! test
2511 Bug 2304: HTML attribute safety (italics)
2512 !! input
2513 <div title="''foobar''"></div>
2514 !! result
2515 <div title="&#39;&#39;foobar&#39;&#39;"></div>
2517 !! end
2519 !! test
2520 Bug 2304: HTML attribute safety (bold)
2521 !! input
2522 <div title="'''foobar'''"></div>
2523 !! result
2524 <div title="&#39;&#39;'foobar&#39;&#39;'"></div>
2526 !! end
2528 !! test
2529 Bug 2304: HTML attribute safety (ISBN)
2530 !! input
2531 <div title="ISBN 1234567890"></div>
2532 !! result
2533 <div title="&#73;SBN 1234567890"></div>
2535 !! end
2537 !! test
2538 Bug 2304: HTML attribute safety (RFC)
2539 !! input
2540 <div title="RFC 1234"></div>
2541 !! result
2542 <div title="&#82;FC 1234"></div>
2544 !! end
2546 !! test
2547 Bug 2304: HTML attribute safety (PMID)
2548 !! input
2549 <div title="PMID 1234567890"></div>
2550 !! result
2551 <div title="&#80;MID 1234567890"></div>
2553 !! end
2555 !! test
2556 Bug 2304: HTML attribute safety (web link)
2557 !! input
2558 <div title="http://example.com/"></div>
2559 !! result
2560 <div title="http&#58;//example.com/"></div>
2562 !! end
2564 !! test
2565 Bug 2304: HTML attribute safety (named web link)
2566 !! input
2567 <div title="[http://example.com/ link]"></div>
2568 !! result
2569 <div title="&#91;http&#58;//example.com/ link]"></div>
2571 !! end
2574 TODO:
2575 more images
2576 more tables
2577 math
2578 character entities
2579 and much more