Handle urls as external-url args
[lhc/web/wiklou.git] / maintenance / parserTests.txt
1 # MediaWiki Parser test cases
2 # Some taken from http://meta.wikimedia.org/wiki/Parser_testing
3 # All (C) their respective authors and released under the GPL
4 #
5 # The syntax should be fairly self-explanatory.
6 #
7 # Currently supported test options:
8 # One of the following three:
9 #
10 # (default) generate HTML output
11 # pst apply pre-save transform
12 # msg apply message transform
13 #
14 # Plus any combination of these:
15 #
16 # cat add category links
17 # ill add inter-language links
18 # subpage enable subpages (disabled by default)
19 # noxml don't check for XML well formdness
20 # title=[[XXX]] run test using article title XXX
21 # disabled do not run test
22 #
23 # For testing purposes, temporary articles can created:
24 # !!article / NAMESPACE:TITLE / !!text / ARTICLE TEXT / !!endarticle
25 # where '/' denotes a newline.
26
27 # This is the standard article assumed to exist.
28 !! article
29 Main Page
30 !! text
31 blah blah
32 !! endarticle
33
34 ###
35 ### Basic tests
36 ###
37 !! test
38 Blank input
39 !! input
40 !! result
41 !! end
42
43
44 !! test
45 Simple paragraph
46 !! input
47 This is a simple paragraph.
48 !! result
49 <p>This is a simple paragraph.
50 </p>
51 !! end
52
53 !! test
54 Simple list
55 !! input
56 * Item 1
57 * Item 2
58 !! result
59 <ul><li> Item 1
60 </li><li> Item 2
61 </li></ul>
62
63 !! end
64
65 !! test
66 Italics and bold
67 !! input
68 * plain
69 * plain''italic''plain
70 * plain''italic''plain''italic''plain
71 * plain'''bold'''plain
72 * plain'''bold'''plain'''bold'''plain
73 * plain''italic''plain'''bold'''plain
74 * plain'''bold'''plain''italic''plain
75 * plain''italic'''bold-italic'''italic''plain
76 * plain'''bold''bold-italic''bold'''plain
77 * plain'''''bold-italic'''italic''plain
78 * plain'''''bold-italic''bold'''plain
79 * plain''italic'''bold-italic'''''plain
80 * plain'''bold''bold-italic'''''plain
81 * plain l'''italic''plain
82 !! result
83 <ul><li> plain
84 </li><li> plain<i>italic</i>plain
85 </li><li> plain<i>italic</i>plain<i>italic</i>plain
86 </li><li> plain<b>bold</b>plain
87 </li><li> plain<b>bold</b>plain<b>bold</b>plain
88 </li><li> plain<i>italic</i>plain<b>bold</b>plain
89 </li><li> plain<b>bold</b>plain<i>italic</i>plain
90 </li><li> plain<i>italic<b>bold-italic</b>italic</i>plain
91 </li><li> plain<b>bold<i>bold-italic</i>bold</b>plain
92 </li><li> plain<i><b>bold-italic</b>italic</i>plain
93 </li><li> plain<b><i>bold-italic</i>bold</b>plain
94 </li><li> plain<i>italic<b>bold-italic</b></i>plain
95 </li><li> plain<b>bold<i>bold-italic</i></b>plain
96 </li><li> plain l'<i>italic</i>plain
97 </li></ul>
98
99 !! end
100
101 ###
102 ### <nowiki> test cases
103 ###
104
105 !! test
106 <nowiki> unordered list
107 !! input
108 <nowiki>* This is not an unordered list item.</nowiki>
109 !! result
110 <p>* This is not an unordered list item.
111 </p>
112 !! end
113
114 !! test
115 <nowiki> spacing
116 !! input
117 <nowiki>Lorem ipsum dolor
118
119 sed abit.
120 sed nullum.
121
122 :and a colon
123 </nowiki>
124 !! result
125 <p>Lorem ipsum dolor
126
127 sed abit.
128 sed nullum.
129
130 :and a colon
131
132 </p>
133 !! end
134
135 !! test
136 nowiki 3
137 !! input
138 :There is not nowiki.
139 :There is <nowiki>nowiki</nowiki>.
140
141 #There is not nowiki.
142 #There is <nowiki>nowiki</nowiki>.
143
144 *There is not nowiki.
145 *There is <nowiki>nowiki</nowiki>.
146 !! result
147 <dl><dd>There is not nowiki.
148 </dd><dd>There is nowiki.
149 </dd></dl>
150 <ol><li>There is not nowiki.
151 </li><li>There is nowiki.
152 </li></ol>
153 <ul><li>There is not nowiki.
154 </li><li>There is nowiki.
155 </li></ul>
156
157 !! end
158
159 ###
160 ### Comments
161 ###
162 !! test
163 Comment test 1
164 !! input
165 <!-- comment 1 --> asdf
166 <!-- comment 2 -->
167 !! result
168 <pre>asdf
169 </pre>
170
171 !! end
172
173 !! test
174 Comment test 2
175 !! input
176 asdf
177 <!-- comment 1 -->
178 jkl
179 !! result
180 <p>asdf
181 jkl
182 </p>
183 !! end
184
185 !! test
186 Comment test 3
187 !! input
188 asdf
189 <!-- comment 1 -->
190 <!-- comment 2 -->
191 jkl
192 !! result
193 <p>asdf
194 jkl
195 </p>
196 !! end
197
198 !! test
199 Comment test 4
200 !! input
201 asdf<!-- comment 1 -->jkl
202 !! result
203 <p>asdfjkl
204 </p>
205 !! end
206
207 !! test
208 Comment spacing
209 !! input
210 a
211 <!-- foo --> b <!-- bar -->
212 c
213 !! result
214 <p>a
215 </p>
216 <pre> b
217 </pre>
218 <p>c
219 </p>
220 !! end
221
222 !! test
223 Comment whitespace
224 !! input
225 <!-- returns a single newline, not nothing, since the newline after > is not stripped -->
226 !! result
227
228 !! end
229
230 !! test
231 Comment semantics and delimiters
232 !! input
233 <!-- --><!----><!-----><!------>
234 !! result
235
236 !! end
237
238 !! test
239 Comment semantics and delimiters, redux
240 !! input
241 <!-- In SGML every "foo" here would actually show up in the text -- foo -- bar
242 -- foo -- funky huh? ... -->
243 !! result
244
245 !! end
246
247 !! test
248 Comment semantics and delimiters: directors cut
249 !! input
250 <!-- ... However we like to keep things simple and somewhat XML-ish so we eat
251 everything starting with < followed by !-- until the first -- and > we see,
252 that wouldn't be valid XML however, since in XML -- has to terminate a comment
253 -->-->
254 !! result
255 <p>-->
256 </p>
257 !! end
258
259 !! test
260 Comment semantics: nesting
261 !! input
262 <!--<!-- no, we're not going to do anything fancy here -->-->
263 !! result
264 <p>-->
265 </p>
266 !! end
267
268
269 ###
270 ### Preformatted text
271 ###
272 !! test
273 Preformatted text
274 !! input
275 This is some
276 Preformatted text
277 With ''italic''
278 And '''bold'''
279 And a [[Main Page|link]]
280 !! result
281 <pre>This is some
282 Preformatted text
283 With <i>italic</i>
284 And <b>bold</b>
285 And a <a href="/wiki/Main_Page" title="Main Page">link</a>
286 </pre>
287 !! end
288
289 ###
290 ### Definition lists
291 ###
292 !! test
293 Simple definition
294 !! input
295 ; name : Definition
296 !! result
297 <dl><dt> name&nbsp;</dt><dd> Definition
298 </dd></dl>
299
300 !! end
301
302 !! test
303 Simple definition
304 !! input
305 : Indented text
306 !! result
307 <dl><dd> Indented text
308 </dd></dl>
309
310 !! end
311
312 !! test
313 Definition list with no space
314 !! input
315 ;name:Definition
316 !! result
317 <dl><dt>name</dt><dd>Definition
318 </dd></dl>
319
320 !!end
321
322 !! test
323 Definition list with URL link
324 !! input
325 ; http://example.com/ : definition
326 !! result
327 <dl><dt> <a href="http://example.com/" class='external free' title="http://example.com/" rel="nofollow">http://example.com/</a>&nbsp;</dt><dd> definition
328 </dd></dl>
329
330 !! end
331
332 !! test
333 Definition list with bracketed URL link
334 !! input
335 ;[http://www.google.com/ Google]:Number one search engine
336 !! result
337 <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
338 </dd></dl>
339
340 !! end
341
342 !! test
343 Definition list with wikilink containing colon
344 !! input
345 ; [[Help:FAQ]]: The least-read page on Wikipedia
346 !! result
347 <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
348 </dd></dl>
349
350 !! end
351
352 # At Brion's and JeLuF's insistence... :)
353 !! test
354 Definition list with wikilink containing colon
355 !! input
356 ; news:alt.wikipedia.rox: This isn't even a real newsgroup!
357 !! result
358 <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!
359 </dd></dl>
360
361 !! end
362
363 !! test
364 Malformed definition list with colon
365 !! input
366 ; news:alt.wikipedia.rox -- don't crash or enter an infinite loop
367 !! result
368 <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
369 </dt></dl>
370
371 !! end
372
373 !! test
374 Definition lists: colon in external link text
375 !! input
376 ; [http://www.wikipedia2.org/ Wikipedia : The Next Generation]: OK, I made that up
377 !! result
378 <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
379 </dd></dl>
380
381 !! end
382
383
384 ###
385 ### External links
386 ###
387 !! test
388 External links: non-bracketed
389 !! input
390 Non-bracketed: http://example.com
391 !! result
392 <p>Non-bracketed: <a href="http://example.com" class='external free' title="http://example.com" rel="nofollow">http://example.com</a>
393 </p>
394 !! end
395
396 !! test
397 External links: numbered
398 !! input
399 Numbered: [http://example.com]
400 Numbered: [http://example.net]
401 Numbered: [http://example.org]
402 !! result
403 <p>Numbered: <a href="http://example.com" class='external autonumber' title="http://example.com" rel="nofollow">[1]</a>
404 Numbered: <a href="http://example.net" class='external autonumber' title="http://example.net" rel="nofollow">[2]</a>
405 Numbered: <a href="http://example.org" class='external autonumber' title="http://example.org" rel="nofollow">[3]</a>
406 </p>
407 !!end
408
409 !! test
410 External links: specified text
411 !! input
412 Specified text: [http://example.com link]
413 !! result
414 <p>Specified text: <a href="http://example.com" class='external text' title="http://example.com" rel="nofollow">link</a>
415 </p>
416 !!end
417
418 !! test
419 External links: trail
420 !! input
421 Linktrails should not work for external links: [http://example.com link]s
422 !! result
423 <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
424 </p>
425 !! end
426
427 !! test
428 External links: dollar sign in URL
429 !! input
430 http://example.com/1$2345
431 !! result
432 <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>
433 </p>
434 !! end
435
436 !! test
437 External links: dollar sign in URL (named)
438 !! input
439 [http://example.com/1$2345]
440 !! result
441 <p><a href="http://example.com/1$2345" class='external autonumber' title="http://example.com/1$2345" rel="nofollow">[1]</a>
442 </p>
443 !!end
444
445 !! test
446 External links: open square bracket forbidden in URL (bug 4377)
447 !! input
448 http://example.com/1[2345
449 !! result
450 <p><a href="http://example.com/1" class='external free' title="http://example.com/1" rel="nofollow">http://example.com/1</a>[2345
451 </p>
452 !! end
453
454 !! test
455 External links: open square bracket forbidden in URL (named) (bug 4377)
456 !! input
457 [http://example.com/1[2345]
458 !! result
459 <p><a href="http://example.com/1" class='external text' title="http://example.com/1" rel="nofollow">[2345</a>
460 </p>
461 !!end
462
463 !! test
464 External image
465 !! input
466 External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
467 !! result
468 <p>External image: <img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png" />
469 </p>
470 !! end
471
472 !! test
473 External image from https
474 !! input
475 External image from https: https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
476 !! result
477 <p>External image from https: <img src="https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png" />
478 </p>
479 !! end
480
481 !! test
482 Link to non-http image, no img tag
483 !! input
484 Link to non-http image, no img tag: ftp://example.com/test.jpg
485 !! result
486 <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>
487 </p>
488 !! end
489
490 !! test
491 External links: terminating separator
492 !! input
493 Terminating separator: http://example.com/thing,
494 !! result
495 <p>Terminating separator: <a href="http://example.com/thing" class='external free' title="http://example.com/thing" rel="nofollow">http://example.com/thing</a>,
496 </p>
497 !! end
498
499 !! test
500 External links: intervening separator
501 !! input
502 Intervening separator: http://example.com/1,2,3
503 !! result
504 <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>
505 </p>
506 !! end
507
508 !! test
509 External links: old bug with URL in query
510 !! input
511 Old bug with URL in query: [http://example.com/thing?url=http://example.com link]
512 !! result
513 <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>
514 </p>
515 !! end
516
517 !! test
518 External links: old URL-in-URL bug, mixed protocols
519 !! input
520 And again with mixed protocols: [ftp://example.com?url=http://example.com link]
521 !! result
522 <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>
523 </p>
524 !!end
525
526 !! test
527 External links: URL in text
528 !! input
529 URL in text: [http://example.com http://example.com]
530 !! result
531 <p>URL in text: <a href="http://example.com" class='external free' title="http://example.com" rel="nofollow">http://example.com</a>
532 </p>
533 !! end
534
535 !! test
536 External links: Clickable images
537 !! input
538 ja-style clickable images: [http://example.com http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png]
539 !! result
540 <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>
541 </p>
542 !!end
543
544 !! test
545 External links: raw ampersand
546 !! input
547 Old &amp; use: http://x&y
548 !! result
549 <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>
550 </p>
551 !! end
552
553 !! test
554 External links: encoded ampersand
555 !! input
556 Old &amp; use: http://x&amp;y
557 !! result
558 <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>
559 </p>
560 !! end
561
562 !! test
563 External links: [raw ampersand]
564 !! input
565 Old &amp; use: [http://x&y]
566 !! result
567 <p>Old &amp; use: <a href="http://x&amp;y" class='external autonumber' title="http://x&amp;y" rel="nofollow">[1]</a>
568 </p>
569 !! end
570
571 !! test
572 External links: [encoded ampersand]
573 !! input
574 Old &amp; use: [http://x&amp;y]
575 !! result
576 <p>Old &amp; use: <a href="http://x&amp;y" class='external autonumber' title="http://x&amp;y" rel="nofollow">[1]</a>
577 </p>
578 !! end
579
580 !! test
581 External links: www.jpeg.org (bug 554)
582 !! input
583 http://www.jpeg.org
584 !!result
585 <p><a href="http://www.jpeg.org" class='external free' title="http://www.jpeg.org" rel="nofollow">http://www.jpeg.org</a>
586 </p>
587 !! end
588
589 !! test
590 External links: URL within URL (original bug 2)
591 !! input
592 [http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp]
593 !! result
594 <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>
595 </p>
596 !! end
597
598 !! test
599 BUG 361: URL inside bracketed URL
600 !! input
601 [http://www.example.com/foo http://www.example.com/bar]
602 !! result
603 <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>
604 </p>
605 !! end
606
607 !! test
608 BUG 361: URL within URL, not bracketed
609 !! input
610 http://www.example.com/foo?=http://www.example.com/bar
611 !! result
612 <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>
613 </p>
614 !! end
615
616 !! test
617 BUG 289: ">"-token in URL-tail
618 !! input
619 http://www.example.com/<hello>
620 !! result
621 <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;
622 </p>
623 !!end
624
625 !! test
626 BUG 289: literal ">"-token in URL-tail
627 !! input
628 http://www.example.com/<b>html</b>
629 !! result
630 <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>
631 </p>
632 !!end
633
634 !! test
635 BUG 289: ">"-token in bracketed URL
636 !! input
637 [http://www.example.com/<hello> stuff]
638 !! result
639 <p><a href="http://www.example.com/" class='external text' title="http://www.example.com/" rel="nofollow">&lt;hello&gt; stuff</a>
640 </p>
641 !!end
642
643 !! test
644 BUG 289: literal ">"-token in bracketed URL
645 !! input
646 [http://www.example.com/<b>html</b> stuff]
647 !! result
648 <p><a href="http://www.example.com/" class='external text' title="http://www.example.com/" rel="nofollow"><b>html</b> stuff</a>
649 </p>
650 !!end
651
652 !! test
653 BUG 289: literal double quote at end of URL
654 !! input
655 http://www.example.com/"hello"
656 !! result
657 <p><a href="http://www.example.com/" class='external free' title="http://www.example.com/" rel="nofollow">http://www.example.com/</a>"hello"
658 </p>
659 !!end
660
661 !! test
662 BUG 289: literal double quote in bracketed URL
663 !! input
664 [http://www.example.com/"hello" stuff]
665 !! result
666 <p><a href="http://www.example.com/" class='external text' title="http://www.example.com/" rel="nofollow">"hello" stuff</a>
667 </p>
668 !!end
669
670 !! test
671 External links: invalid character
672 !! input
673 [http://www.example.com test]
674 !! result
675 <p>[<a href="http://www.example.com" class='external free' title="http://www.example.com" rel="nofollow">http://www.example.com</a> test]
676 </p>
677 !! end
678
679 !! test
680 External links: multiple legal whitespace is fine, Magnus. Don't break it please. (bug 5081)
681 !! input
682 [http://www.example.com test]
683 !! result
684 <p><a href="http://www.example.com" class='external text' title="http://www.example.com" rel="nofollow">test</a>
685 </p>
686 !! end
687
688 !! test
689 BUG 787: Links with one slash after the url protocol are invalid
690 !! input
691 http:/example.com
692
693 [http:/example.com title]
694 !! result
695 <p>http:/example.com
696 </p><p>[http:/example.com title]
697 </p>
698 !! end
699
700 !! test
701 Bug 2702: Mismatched <i> and <a> tags are invalid
702 !! input
703 ''[http://example.com text'']
704 !! result
705 <p><i><a href="http://example.com" class='external text' title="http://example.com" rel="nofollow">text</a></i>
706 </p>
707 !! end
708
709
710 !! test
711 Bug 4781: %26 in URL
712 !! input
713 http://www.example.com/?title=AT%26T
714 !! result
715 <p><a href="http://www.example.com/?title=AT%26T" class='external free' title="http://www.example.com/?title=AT%26T" rel="nofollow">http://www.example.com/?title=AT%26T</a>
716 </p>
717 !! end
718
719 !! test
720 Bug 4781, 5267: %26 in URL
721 !! input
722 http://www.example.com/?title=100%25_Bran
723 !! result
724 <p><a href="http://www.example.com/?title=100%25_Bran" class='external free' title="http://www.example.com/?title=100%25_Bran" rel="nofollow">http://www.example.com/?title=100%25_Bran</a>
725 </p>
726 !! end
727
728 !! test
729 Bug 4781, 5267: %28, %29 in URL
730 !! input
731 http://www.example.com/?title=Ben-Hur_%281959_film%29
732 !! result
733 <p><a href="http://www.example.com/?title=Ben-Hur_%281959_film%29" class='external free' title="http://www.example.com/?title=Ben-Hur_%281959_film%29" rel="nofollow">http://www.example.com/?title=Ben-Hur_%281959_film%29</a>
734 </p>
735 !! end
736
737
738 !! test
739 Bug 4781: %26 in autonumber URL
740 !! input
741 [http://www.example.com/?title=AT%26T]
742 !! result
743 <p><a href="http://www.example.com/?title=AT%26T" class='external autonumber' title="http://www.example.com/?title=AT%26T" rel="nofollow">[1]</a>
744 </p>
745 !! end
746
747 !! test
748 Bug 4781, 5267: %26 in autonumber URL
749 !! input
750 [http://www.example.com/?title=100%25_Bran]
751 !! result
752 <p><a href="http://www.example.com/?title=100%25_Bran" class='external autonumber' title="http://www.example.com/?title=100%25_Bran" rel="nofollow">[1]</a>
753 </p>
754 !! end
755
756 !! test
757 Bug 4781, 5267: %28, %29 in autonumber URL
758 !! input
759 [http://www.example.com/?title=Ben-Hur_%281959_film%29]
760 !! result
761 <p><a href="http://www.example.com/?title=Ben-Hur_%281959_film%29" class='external autonumber' title="http://www.example.com/?title=Ben-Hur_%281959_film%29" rel="nofollow">[1]</a>
762 </p>
763 !! end
764
765
766 !! test
767 Bug 4781: %26 in bracketed URL
768 !! input
769 [http://www.example.com/?title=AT%26T link]
770 !! result
771 <p><a href="http://www.example.com/?title=AT%26T" class='external text' title="http://www.example.com/?title=AT%26T" rel="nofollow">link</a>
772 </p>
773 !! end
774
775 !! test
776 Bug 4781, 5267: %26 in bracketed URL
777 !! input
778 [http://www.example.com/?title=100%25_Bran link]
779 !! result
780 <p><a href="http://www.example.com/?title=100%25_Bran" class='external text' title="http://www.example.com/?title=100%25_Bran" rel="nofollow">link</a>
781 </p>
782 !! end
783
784 !! test
785 Bug 4781, 5267: %28, %29 in bracketed URL
786 !! input
787 [http://www.example.com/?title=Ben-Hur_%281959_film%29 link]
788 !! result
789 <p><a href="http://www.example.com/?title=Ben-Hur_%281959_film%29" class='external text' title="http://www.example.com/?title=Ben-Hur_%281959_film%29" rel="nofollow">link</a>
790 </p>
791 !! end
792
793
794 ###
795 ### Quotes
796 ###
797
798 !! test
799 Quotes
800 !! input
801 Normal text. '''Bold text.''' Normal text. ''Italic text.''
802
803 Normal text. '''''Bold italic text.''''' Normal text.
804 !!result
805 <p>Normal text. <b>Bold text.</b> Normal text. <i>Italic text.</i>
806 </p><p>Normal text. <i><b>Bold italic text.</b></i> Normal text.
807 </p>
808 !! end
809
810
811 !! test
812 Unclosed and unmatched quotes
813 !! input
814 '''''Bold italic text '''with bold deactivated''' in between.'''''
815
816 '''''Bold italic text ''with italic deactivated'' in between.'''''
817
818 '''Bold text..
819
820 ..spanning two paragraphs (should not work).'''
821
822 '''Bold tag left open
823
824 ''Italic tag left open
825
826 Normal text.
827
828 <!-- Unmatching number of opening, closing tags: -->
829 '''This year''''s election ''should'' beat '''last year''''s.
830
831 ''Tom'''s car is bigger than ''Susan'''s.
832 !! result
833 <p><i><b>Bold italic text </b>with bold deactivated<b> in between.</b></i>
834 </p><p><b><i>Bold italic text </i>with italic deactivated<i> in between.</i></b>
835 </p><p><b>Bold text..</b>
836 </p><p>..spanning two paragraphs (should not work).<b></b>
837 </p><p><b>Bold tag left open</b>
838 </p><p><i>Italic tag left open</i>
839 </p><p>Normal text.
840 </p><p><b>This year'</b>s election <i>should</i> beat <b>last year'</b>s.
841 </p><p><i>Tom<b>s car is bigger than </b></i><b>Susan</b>s.
842 </p>
843 !! end
844
845 ###
846 ### Tables
847 ###
848 ### some content taken from http://meta.wikimedia.org/wiki/MediaWiki_User%27s_Guide:_Using_tables
849 ###
850
851 # This should not produce <table></table> as <table><tr><td></td></tr></table>
852 # is the bare minimun required by the spec, see:
853 # http://www.w3.org/TR/xhtml-modularization/dtd_module_defs.html#a_module_Basic_Tables
854 !! test
855 A table with no data.
856 !! input
857 {||}
858 !! result
859 !! end
860
861 # A table with nothing but a caption is invalid XHTML, we might want to render
862 # this as <p>caption</p>
863 !! test
864 A table with nothing but a caption
865 !! input
866 {|
867 |+ caption
868 |}
869 !! result
870 <table>
871 <caption> caption
872 </caption>
873 <tr>
874 <td>
875 </td></tr></table>
876 !! end
877
878 !! test
879 Simple table
880 !! input
881 {|
882 | 1 || 2
883 |-
884 | 3 || 4
885 |}
886 !! result
887 <table>
888 <tr>
889 <td> 1 </td><td> 2
890 </td></tr>
891 <tr>
892 <td> 3 </td><td> 4
893 </td></tr></table>
894
895 !! end
896
897 !! test
898 Multiplication table
899 !! input
900 {| border="1" cellpadding="2"
901 |+Multiplication table
902 |-
903 ! &times; !! 1 !! 2 !! 3
904 |-
905 ! 1
906 | 1 || 2 || 3
907 |-
908 ! 2
909 | 2 || 4 || 6
910 |-
911 ! 3
912 | 3 || 6 || 9
913 |-
914 ! 4
915 | 4 || 8 || 12
916 |-
917 ! 5
918 | 5 || 10 || 15
919 |}
920 !! result
921 <table border="1" cellpadding="2">
922 <caption>Multiplication table
923 </caption>
924 <tr>
925 <th> &times; </th><th> 1 </th><th> 2 </th><th> 3
926 </th></tr>
927 <tr>
928 <th> 1
929 </th><td> 1 </td><td> 2 </td><td> 3
930 </td></tr>
931 <tr>
932 <th> 2
933 </th><td> 2 </td><td> 4 </td><td> 6
934 </td></tr>
935 <tr>
936 <th> 3
937 </th><td> 3 </td><td> 6 </td><td> 9
938 </td></tr>
939 <tr>
940 <th> 4
941 </th><td> 4 </td><td> 8 </td><td> 12
942 </td></tr>
943 <tr>
944 <th> 5
945 </th><td> 5 </td><td> 10 </td><td> 15
946 </td></tr></table>
947
948 !! end
949
950 !! test
951 Table rowspan
952 !! input
953 {| align=right border=1
954 | Cell 1, row 1
955 |rowspan=2| Cell 2, row 1 (and 2)
956 | Cell 3, row 1
957 |-
958 | Cell 1, row 2
959 | Cell 3, row 2
960 |}
961 !! result
962 <table align="right" border="1">
963 <tr>
964 <td> Cell 1, row 1
965 </td><td rowspan="2"> Cell 2, row 1 (and 2)
966 </td><td> Cell 3, row 1
967 </td></tr>
968 <tr>
969 <td> Cell 1, row 2
970 </td><td> Cell 3, row 2
971 </td></tr></table>
972
973 !! end
974
975 !! test
976 Nested table
977 !! input
978 {| border=1
979 | &alpha;
980 |
981 {| bgcolor=#ABCDEF border=2
982 |nested
983 |-
984 |table
985 |}
986 |the original table again
987 |}
988 !! result
989 <table border="1">
990 <tr>
991 <td> &alpha;
992 </td><td>
993 <table bgcolor="#ABCDEF" border="2">
994 <tr>
995 <td>nested
996 </td></tr>
997 <tr>
998 <td>table
999 </td></tr></table>
1000 </td><td>the original table again
1001 </td></tr></table>
1002
1003 !! end
1004
1005 !! test
1006 Invalid attributes in table cell (bug 1830)
1007 !! input
1008 {|
1009 |Cell:|broken
1010 |}
1011 !! result
1012 <table>
1013 <tr>
1014 <td>broken
1015 </td></tr></table>
1016
1017 !! end
1018
1019
1020 ###
1021 ### Internal links
1022 ###
1023 !! test
1024 Plain link, capitalized
1025 !! input
1026 [[Main Page]]
1027 !! result
1028 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
1029 </p>
1030 !! end
1031
1032 !! test
1033 Plain link, uncapitalized
1034 !! input
1035 [[main Page]]
1036 !! result
1037 <p><a href="/wiki/Main_Page" title="Main Page">main Page</a>
1038 </p>
1039 !! end
1040
1041 !! test
1042 Piped link
1043 !! input
1044 [[Main Page|The Main Page]]
1045 !! result
1046 <p><a href="/wiki/Main_Page" title="Main Page">The Main Page</a>
1047 </p>
1048 !! end
1049
1050 !! test
1051 Broken link
1052 !! input
1053 [[Zigzagzogzagzig]]
1054 !! result
1055 <p><a href="/index.php?title=Zigzagzogzagzig&amp;action=edit" class="new" title="Zigzagzogzagzig">Zigzagzogzagzig</a>
1056 </p>
1057 !! end
1058
1059 !! test
1060 Link with prefix
1061 !! input
1062 xxx[[main Page]], xxx[[Main Page]], Xxx[[main Page]] XXX[[main Page]], XXX[[Main Page]]
1063 !! result
1064 <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>
1065 </p>
1066 !! end
1067
1068 !! test
1069 Link with suffix
1070 !! input
1071 [[Main Page]]xxx, [[Main Page]]XXX
1072 !! result
1073 <p><a href="/wiki/Main_Page" title="Main Page">Main Pagexxx</a>, <a href="/wiki/Main_Page" title="Main Page">Main Page</a>XXX
1074 </p>
1075 !! end
1076
1077 !! test
1078 Link with 3 brackets
1079 !! input
1080 [[[main page]]]
1081 !! result
1082 <p>[[[main page]]]
1083 </p>
1084 !! end
1085
1086 !! test
1087 Piped link with 3 brackets
1088 !! input
1089 [[[main page|the main page]]]
1090 !! result
1091 <p>[[[main page|the main page]]]
1092 </p>
1093 !! end
1094
1095 !! test
1096 Link with multiple pipes
1097 !! input
1098 [[Main Page|The|Main|Page]]
1099 !! result
1100 <p><a href="/wiki/Main_Page" title="Main Page">The|Main|Page</a>
1101 </p>
1102 !! end
1103
1104 !! test
1105 Link to namespaces
1106 !! input
1107 [[Talk:Parser testing]], [[Meta:Disclaimers]]
1108 !! result
1109 <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>
1110 </p>
1111 !! end
1112
1113 !! test
1114 Piped link to namespace
1115 !! input
1116 [[Meta:Disclaimers|The disclaimers]]
1117 !! result
1118 <p><a href="/index.php?title=Meta:Disclaimers&amp;action=edit" class="new" title="Meta:Disclaimers">The disclaimers</a>
1119 </p>
1120 !! end
1121
1122 !! test
1123 Link containing }
1124 !! input
1125 [[Usually caused by a typo (oops}]]
1126 !! result
1127 <p>[[Usually caused by a typo (oops}]]
1128 </p>
1129 !! end
1130
1131 !! test
1132 Link containing % (not as a hex sequence)
1133 !! input
1134 [[7% Solution]]
1135 !! result
1136 <p><a href="/index.php?title=7%25_Solution&amp;action=edit" class="new" title="7% Solution">7% Solution</a>
1137 </p>
1138 !! end
1139
1140 !! test
1141 Link containing % as a single hex sequence interpreted to char
1142 !! input
1143 [[7%25 Solution]]
1144 !! result
1145 <p><a href="/index.php?title=7%25_Solution&amp;action=edit" class="new" title="7% Solution">7% Solution</a>
1146 </p>
1147 !!end
1148
1149 !! test
1150 Link containing % as a double hex sequence interpreted to hex sequence
1151 !! input
1152 [[7%2525 Solution]]
1153 !! result
1154 <p>[[7%2525 Solution]]
1155 </p>
1156 !!end
1157
1158 !! test
1159 Link containing "#<" and "#>" % as a hex sequences
1160 !! input
1161 [[%23%3c]]<!-- Render this as "[[#%3c]]" maybe.. ? -->[[%23%3e]]<!-- ..."[[#%3e]]" ? -->
1162 !! result
1163 <p>[[%23%3c]][[%23%3e]]
1164 </p>
1165 !! end
1166
1167 !! test
1168 Link containing "<#" and ">#" as a hex sequences
1169 !! input
1170 [[%3c%23]][[%3e%23]]
1171 !! result
1172 <p>[[%3c%23]][[%3e%23]]
1173 </p>
1174 !! end
1175
1176 !! test
1177 Plain link to URL
1178 !! input
1179 [[http://www.example.org]]
1180 !! result
1181 <p>[<a href="http://www.example.org" class='external autonumber' title="http://www.example.org" rel="nofollow">[1]</a>]
1182 </p>
1183 !! end
1184
1185 # I'm fairly sure the expected result here is wrong.
1186 # We want these to be URL links, not pseudo-pages with URLs for titles....
1187 # However the current output is also pretty screwy.
1188 #
1189 # ----
1190 # I'm changing it to match the current output--it arguably makes more
1191 # sense in the light of the test above. Old expected result was:
1192 #<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>
1193 #</p>
1194 # But I think this test is bordering on "garbage in, garbage out" anyway.
1195 # -- wtm
1196 !! test
1197 Piped link to URL
1198 !! input
1199 Piped link to URL: [[http://www.example.org|an example URL]]
1200 !! result
1201 <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>]
1202 </p>
1203 !! end
1204
1205 !! test
1206 BUG 2: [[page|http://url/]] should link to page, not http://url/
1207 !! input
1208 [[Main Page|http://url/]]
1209 !! result
1210 <p><a href="/wiki/Main_Page" title="Main Page">http://url/</a>
1211 </p>
1212 !! end
1213
1214 !! test
1215 BUG 337: Escaped self-links should be bold
1216 !! options
1217 title=[[Bug462]]
1218 !! input
1219 [[Bu&#103;462]] [[Bug462]]
1220 !! result
1221 <p><strong>Bu&#103;462</strong> <strong>Bug462</strong>
1222 </p>
1223 !! end
1224
1225 !! test
1226 Self-link to section should not be bold
1227 !! options
1228 title=[[Main Page]]
1229 !! input
1230 [[Main Page#section]]
1231 !! result
1232 <p><a href="/wiki/Main_Page#section" title="Main Page">Main Page#section</a>
1233 </p>
1234 !! end
1235
1236 !! test
1237 <nowiki> inside a link
1238 !! input
1239 [[Main<nowiki> Page</nowiki>]] [[Main Page|the main page <nowiki>[it's not very good]</nowiki>]]
1240 !! result
1241 <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>
1242 </p>
1243 !! end
1244
1245 ###
1246 ### Interwiki links (see maintenance/interwiki.sql)
1247 ###
1248
1249 !! test
1250 Inline interwiki link
1251 !! input
1252 [[MeatBall:SoftSecurity]]
1253 !! result
1254 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity" class='extiw' title="meatball:SoftSecurity">MeatBall:SoftSecurity</a>
1255 </p>
1256 !! end
1257
1258 !! test
1259 Inline interwiki link with empty title (bug 2372)
1260 !! input
1261 [[MeatBall:]]
1262 !! result
1263 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?" class='extiw' title="meatball:">MeatBall:</a>
1264 </p>
1265 !! end
1266
1267 !! test
1268 Interwiki link encoding conversion (bug 1636)
1269 !! input
1270 *[[Wikipedia:ro:Olteni&#0355;a]]
1271 *[[Wikipedia:ro:Olteni&#355;a]]
1272 !! result
1273 <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>
1274 </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>
1275 </li></ul>
1276
1277 !! end
1278
1279 !! test
1280 Interwiki link with fragment (bug 2130)
1281 !! input
1282 [[MeatBall:SoftSecurity#foo]]
1283 !! result
1284 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity#foo" class='extiw' title="meatball:SoftSecurity">MeatBall:SoftSecurity#foo</a>
1285 </p>
1286 !! end
1287
1288 ##
1289 ## XHTML tidiness
1290 ###
1291
1292 !! test
1293 <br> to <br />
1294 !! input
1295 1<br>2<br />3
1296 !! result
1297 <p>1<br />2<br />3
1298 </p>
1299 !! end
1300
1301 !! test
1302 Incorrecly removing closing slashes from correctly formed XHTML
1303 !! input
1304 <br style="clear:both;" />
1305 !! result
1306 <p><br style="clear:both;" />
1307 </p>
1308 !! end
1309
1310 !! test
1311 Failing to transform badly formed HTML into correct XHTML
1312 !! input
1313 <br clear=left>
1314 <br clear=right>
1315 <br clear=all>
1316 !! result
1317 <p><br clear="left" />
1318 <br clear="right" />
1319 <br clear="all" />
1320 </p>
1321 !!end
1322
1323 !! test
1324 Horizontal ruler (should it add that extra space?)
1325 !! input
1326 <hr>
1327 <hr >
1328 foo <hr
1329 > bar
1330 !! result
1331 <hr />
1332 <hr />
1333 foo <hr /> bar
1334
1335 !! end
1336
1337 ###
1338 ### Block-level elements
1339 ###
1340 !! test
1341 Common list
1342 !! input
1343 *Common list
1344 * item 2
1345 *item 3
1346 !! result
1347 <ul><li>Common list
1348 </li><li> item 2
1349 </li><li>item 3
1350 </li></ul>
1351
1352 !! end
1353
1354 !! test
1355 Numbered list
1356 !! input
1357 #Numbered list
1358 #item 2
1359 # item 3
1360 !! result
1361 <ol><li>Numbered list
1362 </li><li>item 2
1363 </li><li> item 3
1364 </li></ol>
1365
1366 !! end
1367
1368 !! test
1369 Mixed list
1370 !! input
1371 *Mixed list
1372 *# with numbers
1373 ** and bullets
1374 *# and numbers
1375 *bullets again
1376 **bullet level 2
1377 ***bullet level 3
1378 ***#Number on level 4
1379 **bullet level 2
1380 **#Number on level 3
1381 **#Number on level 3
1382 *#number level 2
1383 *Level 1
1384 !! result
1385 <ul><li>Mixed list
1386 <ol><li> with numbers
1387 </li></ol>
1388 <ul><li> and bullets
1389 </li></ul>
1390 <ol><li> and numbers
1391 </li></ol>
1392 </li><li>bullets again
1393 <ul><li>bullet level 2
1394 <ul><li>bullet level 3
1395 <ol><li>Number on level 4
1396 </li></ol>
1397 </li></ul>
1398 </li><li>bullet level 2
1399 <ol><li>Number on level 3
1400 </li><li>Number on level 3
1401 </li></ol>
1402 </li></ul>
1403 <ol><li>number level 2
1404 </li></ol>
1405 </li><li>Level 1
1406 </li></ul>
1407
1408 !! end
1409
1410 !! test
1411 List items are not parsed correctly following a <pre> block (bug 785)
1412 !! input
1413 * <pre>foo</pre>
1414 * <pre>bar</pre>
1415 * zar
1416 !! result
1417 <ul><li> <pre>foo</pre>
1418 </li><li> <pre>bar</pre>
1419 </li><li> zar
1420 </li></ul>
1421
1422 !! end
1423
1424 ###
1425 ### Magic Words
1426 ###
1427
1428 !! test
1429 Magic Word: {{CURRENTDAY}}
1430 !! input
1431 {{CURRENTDAY}}
1432 !! result
1433 <p>1
1434 </p>
1435 !! end
1436
1437 !! test
1438 Magic Word: {{CURRENTDAY2}}
1439 !! input
1440 {{CURRENTDAY2}}
1441 !! result
1442 <p>01
1443 </p>
1444 !! end
1445
1446 !! test
1447 Magic Word: {{CURRENTDAYNAME}}
1448 !! input
1449 {{CURRENTDAYNAME}}
1450 !! result
1451 <p>Thursday
1452 </p>
1453 !! end
1454
1455 !! test
1456 Magic Word: {{CURRENTDOW}}
1457 !! input
1458 {{CURRENTDOW}}
1459 !! result
1460 <p>4
1461 </p>
1462 !! end
1463
1464 !! test
1465 Magic Word: {{CURRENTMONTH}}
1466 !! input
1467 {{CURRENTMONTH}}
1468 !! result
1469 <p>01
1470 </p>
1471 !! end
1472
1473 !! test
1474 Magic Word: {{CURRENTMONTHABBREV}}
1475 !! input
1476 {{CURRENTMONTHABBREV}}
1477 !! result
1478 <p>Jan
1479 </p>
1480 !! end
1481
1482 !! test
1483 Magic Word: {{CURRENTMONTHNAME}}
1484 !! input
1485 {{CURRENTMONTHNAME}}
1486 !! result
1487 <p>January
1488 </p>
1489 !! end
1490
1491 !! test
1492 Magic Word: {{CURRENTMONTHNAMEGEN}}
1493 !! input
1494 {{CURRENTMONTHNAMEGEN}}
1495 !! result
1496 <p>January
1497 </p>
1498 !! end
1499
1500 !! test
1501 Magic Word: {{CURRENTTIME}}
1502 !! input
1503 {{CURRENTTIME}}
1504 !! result
1505 <p>00:02
1506 </p>
1507 !! end
1508
1509 !! test
1510 Magic Word: {{CURRENTWEEK}} (@bug 4594)
1511 !! input
1512 {{CURRENTWEEK}}
1513 !! result
1514 <p>1
1515 </p>
1516 !! end
1517
1518 !! test
1519 Magic Word: {{CURRENTYEAR}}
1520 !! input
1521 {{CURRENTYEAR}}
1522 !! result
1523 <p>1970
1524 </p>
1525 !! end
1526
1527 !! test
1528 Magic Word: {{FULLPAGENAME}}
1529 !! options
1530 title=[[User:Ævar Arnfjörð Bjarmason]]
1531 !! input
1532 {{FULLPAGENAME}}
1533 !! result
1534 <p>User:Ævar Arnfjörð Bjarmason
1535 </p>
1536 !! end
1537
1538 !! test
1539 Magic Word: {{FULLPAGENAMEE}}
1540 !! options
1541 title=[[User:Ævar Arnfjörð Bjarmason]]
1542 !! input
1543 {{FULLPAGENAMEE}}
1544 !! result
1545 <p>User:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
1546 </p>
1547 !! end
1548
1549 !! test
1550 Magic Word: {{NAMESPACE}}
1551 !! options
1552 title=[[User:Ævar Arnfjörð Bjarmason]]
1553 disabled # FIXME
1554 !! input
1555 {{NAMESPACE}}
1556 !! result
1557 <p>User
1558 </p>
1559 !! end
1560
1561 !! test
1562 Magic Word: {{NAMESPACEE}}
1563 !! options
1564 title=[[User:Ævar Arnfjörð Bjarmason]]
1565 disabled # FIXME
1566 !! input
1567 {{NAMESPACEE}}
1568 !! result
1569 <p>User
1570 </p>
1571 !! end
1572
1573 !! test
1574 Magic Word: {{NUMBEROFARTICLES}}
1575 !! input
1576 {{NUMBEROFARTICLES}}
1577 !! result
1578 <p>-1
1579 </p>
1580 !! end
1581
1582 !! test
1583 Magic Word: {{NUMBEROFFILES}}
1584 !! input
1585 {{NUMBEROFFILES}}
1586 !! result
1587 <p>1
1588 </p>
1589 !! end
1590
1591 !! test
1592 Magic Word: {{PAGENAME}}
1593 !! options
1594 title=[[User:Ævar Arnfjörð Bjarmason]]
1595 disabled # FIXME
1596 !! input
1597 {{PAGENAME}}
1598 !! result
1599 <p>Ævar Arnfjörð Bjarmason
1600 </p>
1601 !! end
1602
1603 !! test
1604 Magic Word: {{PAGENAMEE}}
1605 !! options
1606 title=[[User:Ævar Arnfjörð Bjarmason]]
1607 !! input
1608 {{PAGENAMEE}}
1609 !! result
1610 <p>User:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
1611 </p>
1612 !! end
1613
1614 !! test
1615 Magic Word: {{REVISIONID}}
1616 !! input
1617 {{REVISIONID}}
1618 !! result
1619 <p>1337
1620 </p>
1621 !! end
1622
1623 !! test
1624 Magic Word: {{SCRIPTPATH}}
1625 !! input
1626 {{SCRIPTPATH}}
1627 !! result
1628 <p>/
1629 </p>
1630 !! end
1631
1632 !! test
1633 Magic Word: {{SERVER}}
1634 !! input
1635 {{SERVER}}
1636 !! result
1637 <p><a href="http://localhost" class='external free' title="http://localhost" rel="nofollow">http://localhost</a>
1638 </p>
1639 !! end
1640
1641 !! test
1642 Magic Word: {{SERVERNAME}}
1643 !! input
1644 {{SERVERNAME}}
1645 !! result
1646 <p>Britney Spears
1647 </p>
1648 !! end
1649
1650 !! test
1651 Magic Word: {{SITENAME}}
1652 !! input
1653 {{SITENAME}}
1654 !! result
1655 <p>MediaWiki
1656 </p>
1657 !! end
1658
1659 !! test
1660 Namespace 1 {{ns:1}}
1661 !! input
1662 {{ns:1}}
1663 !! result
1664 <p>Talk
1665 </p>
1666 !! end
1667
1668 !! test
1669 Namespace 1 {{ns:01}}
1670 !! input
1671 {{ns:01}}
1672 !! result
1673 <p>Talk
1674 </p>
1675 !! end
1676
1677 !! test
1678 Namespace 0 {{ns:0}} (bug 4783)
1679 !! input
1680 {{ns:0}}
1681 !! result
1682
1683 !! end
1684
1685 !! test
1686 Namespace 0 {{ns:00}} (bug 4783)
1687 !! input
1688 {{ns:00}}
1689 !! result
1690
1691 !! end
1692
1693 !! test
1694 Namespace -1 {{ns:-1}}
1695 !! input
1696 {{ns:-1}}
1697 !! result
1698 <p>Special
1699 </p>
1700 !! end
1701
1702 !! test
1703 Namespace Project {{ns:User}}
1704 !! input
1705 {{ns:User}}
1706 !! result
1707 <p>User
1708 </p>
1709 !! end
1710
1711
1712 ###
1713 ### Magic links
1714 ###
1715 !! test
1716 Magic links: internal link to RFC (bug 479)
1717 !! input
1718 [[RFC 123]]
1719 !! result
1720 <p><a href="/index.php?title=RFC_123&amp;action=edit" class="new" title="RFC 123">RFC 123</a>
1721 </p>
1722 !! end
1723
1724 !! test
1725 Magic links: RFC (bug 479)
1726 !! input
1727 RFC 822
1728 !! result
1729 <p><a href='http://www.ietf.org/rfc/rfc822.txt' class='external' title="http://www.ietf.org/rfc/rfc822.txt">RFC 822</a>
1730 </p>
1731 !! end
1732
1733 !! test
1734 Magic links: ISBN (bug 1937)
1735 !! input
1736 ISBN 0-306-40615-2
1737 !! result
1738 <p><a href="/index.php?title=Special:Booksources&amp;isbn=0306406152" class="internal">ISBN 0-306-40615-2</a>
1739 </p>
1740 !! end
1741
1742 !! test
1743 Magic links: PMID incorrectly converts space to underscore
1744 !! input
1745 PMID 1234
1746 !! result
1747 <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>
1748 </p>
1749 !! end
1750
1751 ###
1752 ### Templates
1753 ####
1754
1755 !! test
1756 Nonexistant template
1757 !! input
1758 {{thistemplatedoesnotexist}}
1759 !! result
1760 <p><a href="/index.php?title=Template:Thistemplatedoesnotexist&amp;action=edit" class="new" title="Template:Thistemplatedoesnotexist">Template:Thistemplatedoesnotexist</a>
1761 </p>
1762 !! end
1763
1764 !! article
1765 Template:test
1766 !! text
1767 This is a test template
1768 !! endarticle
1769
1770 !! test
1771 Simple template
1772 !! input
1773 {{test}}
1774 !! result
1775 <p>This is a test template
1776 </p>
1777 !! end
1778
1779 !! test
1780 Template with explicit namespace
1781 !! input
1782 {{Template:test}}
1783 !! result
1784 <p>This is a test template
1785 </p>
1786 !! end
1787
1788
1789 !! article
1790 Template:paramtest
1791 !! text
1792 This is a test template with parameter {{{param}}}
1793 !! endarticle
1794
1795 !! test
1796 Template parameter
1797 !! input
1798 {{paramtest|param=foo}}
1799 !! result
1800 <p>This is a test template with parameter foo
1801 </p>
1802 !! end
1803
1804 !! article
1805 Template:paramtestnum
1806 !! text
1807 [[{{{1}}}|{{{2}}}]]
1808 !! endarticle
1809
1810 !! test
1811 Template unnamed parameter
1812 !! input
1813 {{paramtestnum|Main Page|the main page}}
1814 !! result
1815 <p><a href="/wiki/Main_Page" title="Main Page">the main page</a>
1816 </p>
1817 !! end
1818
1819 !! article
1820 Template:templatesimple
1821 !! text
1822 (test)
1823 !! endarticle
1824
1825 !! article
1826 Template:templateredirect
1827 !! text
1828 #redirect [[Template:templatesimple]]
1829 !! endarticle
1830
1831 !! article
1832 Template:templateasargtestnum
1833 !! text
1834 {{{{{1}}}}}
1835 !! endarticle
1836
1837 !! article
1838 Template:templateasargtest
1839 !! text
1840 {{template{{{templ}}}}}
1841 !! endarticle
1842
1843 !! article
1844 Template:templateasargtest2
1845 !! text
1846 {{{{{templ}}}}}
1847 !! endarticle
1848
1849 !! test
1850 Template with template name as unnamed argument
1851 !! input
1852 {{templateasargtestnum|templatesimple}}
1853 !! result
1854 <p>(test)
1855 </p>
1856 !! end
1857
1858 !! test
1859 Template with template name as argument
1860 !! input
1861 {{templateasargtest|templ=simple}}
1862 !! result
1863 <p>(test)
1864 </p>
1865 !! end
1866
1867 !! test
1868 Template with template name as argument (2)
1869 !! input
1870 {{templateasargtest2|templ=templatesimple}}
1871 !! result
1872 <p>(test)
1873 </p>
1874 !! end
1875
1876 !! article
1877 Template:templateasargtestdefault
1878 !! text
1879 {{{{{templ|templatesimple}}}}}
1880 !! endarticle
1881
1882 !! article
1883 Template:templa
1884 !! text
1885 '''templ'''
1886 !! endarticle
1887
1888 !! test
1889 Template with default value
1890 !! input
1891 {{templateasargtestdefault}}
1892 !! result
1893 <p>(test)
1894 </p>
1895 !! end
1896
1897 !! test
1898 Template with default value (value set)
1899 !! input
1900 {{templateasargtestdefault|templ=templa}}
1901 !! result
1902 <p><b>templ</b>
1903 </p>
1904 !! end
1905
1906 !! test
1907 Template redirect
1908 !! input
1909 {{templateredirect}}
1910 !! result
1911 <p>(test)
1912 </p>
1913 !! end
1914
1915 !! test
1916 Template with argument in separate line
1917 !! input
1918 {{ templateasargtest |
1919 templ = simple }}
1920 !! result
1921 <p>(test)
1922 </p>
1923 !! end
1924
1925 !! test
1926 Template with complex template as argument
1927 !! input
1928 {{paramtest|
1929 param ={{ templateasargtest |
1930 templ = simple }}}}
1931 !! result
1932 <p>This is a test template with parameter (test)
1933 </p>
1934 !! end
1935
1936 !! test
1937 Template with thumb image (wiht link in description)
1938 !! input
1939 {{paramtest|
1940 param =[[Image:noimage.png|thumb|[[no link|link]] [[no link|caption]]]]}}
1941 !! result
1942 This is a test template with parameter <div class="thumb tright"><div style="width:182px;"><a href="/index.php?title=Special:Upload&amp;wpDestFile=Noimage.png" class="new" title="Image:Noimage.png">Image:Noimage.png</a> <div class="thumbcaption" ><a href="/index.php?title=No_link&amp;action=edit" class="new" title="No link">link</a> <a href="/index.php?title=No_link&amp;action=edit" class="new" title="No link">caption</a></div></div></div>
1943
1944 !! end
1945
1946 !! article
1947 Template:complextemplate
1948 !! text
1949 {{{1}}} {{paramtest|
1950 param ={{{param}}}}}
1951 !! endarticle
1952
1953 !! test
1954 Template with complex arguments
1955 !! input
1956 {{complextemplate|
1957 param ={{ templateasargtest |
1958 templ = simple }}|[[Template:complextemplate|link]]}}
1959 !! result
1960 <p><a href="/wiki/Template:Complextemplate" title="Template:Complextemplate">link</a> This is a test template with parameter (test)
1961 </p>
1962 !! end
1963
1964 !! test
1965 BUG 553: link with two variables in a piped link
1966 !! input
1967 {|
1968 |[[{{{1}}}|{{{2}}}]]
1969 |}
1970 !! result
1971 <table>
1972 <tr>
1973 <td>[[{{{1}}}|{{{2}}}]]
1974 </td></tr></table>
1975
1976 !! end
1977
1978 !! test
1979 Magic variable as template parameter
1980 !! input
1981 {{paramtest|param={{SITENAME}}}}
1982 !! result
1983 <p>This is a test template with parameter MediaWiki
1984 </p>
1985 !! end
1986
1987 !! article
1988 Template:linktest
1989 !! text
1990 [[{{{param}}}|link]]
1991 !! endarticle
1992
1993 !! test
1994 Template parameter as link source
1995 !! input
1996 {{linktest|param=Main Page}}
1997 !! result
1998 <p><a href="/wiki/Main_Page" title="Main Page">link</a>
1999 </p>
2000 !! end
2001
2002
2003 !!article
2004 Template:paramtest2
2005 !! text
2006 including another template, {{paramtest|param={{{arg}}}}}
2007 !! endarticle
2008
2009 !! test
2010 Template passing argument to another template
2011 !! input
2012 {{paramtest2|arg='hmm'}}
2013 !! result
2014 <p>including another template, This is a test template with parameter 'hmm'
2015 </p>
2016 !! end
2017
2018 !! article
2019 Template:Linktest2
2020 !! text
2021 Main Page
2022 !! endarticle
2023
2024 !! test
2025 Template as link source
2026 !! input
2027 [[{{linktest2}}]]
2028 !! result
2029 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
2030 </p>
2031 !! end
2032
2033
2034 !! article
2035 Template:loop1
2036 !! text
2037 {{loop2}}
2038 !! endarticle
2039
2040 !! article
2041 Template:loop2
2042 !! text
2043 {{loop1}}
2044 !! endarticle
2045
2046 !! test
2047 Template infinite loop
2048 !! input
2049 {{loop1}}
2050 !! result
2051 <p>{{loop1}}<!-- WARNING: template loop detected -->
2052 </p>
2053 !! end
2054
2055 !! test
2056 Template from main namespace
2057 !! input
2058 {{:Main Page}}
2059 !! result
2060 <p>blah blah
2061 </p>
2062 !! end
2063
2064 !! article
2065 Template:table
2066 !! text
2067 {|
2068 | 1 || 2
2069 |-
2070 | 3 || 4
2071 |}
2072 !! endarticle
2073
2074 !! test
2075 BUG 529: Template with table, not included at beginning of line
2076 !! input
2077 foo {{table}}
2078 !! result
2079 <p>foo
2080 </p>
2081 <table>
2082 <tr>
2083 <td> 1 </td><td> 2
2084 </td></tr>
2085 <tr>
2086 <td> 3 </td><td> 4
2087 </td></tr></table>
2088
2089 !! end
2090
2091 !! test
2092 BUG 523: Template shouldn't eat newline (or add an extra one before table)
2093 !! input
2094 foo
2095 {{table}}
2096 !! result
2097 <p>foo
2098 </p>
2099 <table>
2100 <tr>
2101 <td> 1 </td><td> 2
2102 </td></tr>
2103 <tr>
2104 <td> 3 </td><td> 4
2105 </td></tr></table>
2106
2107 !! end
2108
2109 !! test
2110 BUG 41: Template parameters shown as broken links
2111 !! input
2112 {{{parameter}}}
2113 !! result
2114 <p>{{{parameter}}}
2115 </p>
2116 !! end
2117
2118
2119 !! article
2120 Template:MSGNW test
2121 !! text
2122 ''None'' of '''this''' should be
2123 * interepreted
2124 but rather passed unmodified
2125 {{test}}
2126 !! endarticle
2127
2128 # hmm, fix this or just deprecate msgnw and document its behavior?
2129 !! test
2130 msgnw keyword
2131 !! options
2132 disabled
2133 !! input
2134 {{msgnw:MSGNW test}}
2135 !! result
2136 <p>''None'' of '''this''' should be
2137 * interepreted
2138 but rather passed unmodified
2139 {{test}}
2140 </p>
2141 !! end
2142
2143 !! test
2144 int keyword
2145 !! input
2146 {{int:youhavenewmessages|lots of money|not!}}
2147 !! result
2148 <p>You have lots of money (not!).
2149 </p>
2150 !! end
2151
2152 !! article
2153 Template:Includes
2154 !! text
2155 Foo<noinclude>zar</noinclude><includeonly>bar</includeonly>
2156 !! endarticle
2157
2158 !! test
2159 <includeonly> and <noinclude> being included
2160 !! input
2161 {{Includes}}
2162 !! result
2163 <p>Foobar
2164 </p>
2165 !! end
2166
2167 !! article
2168 Template:Includes2
2169 !! text
2170 <onlyinclude>Foo</onlyinclude>bar
2171 !! endarticle
2172
2173 !! test
2174 <onlyinclude> being included
2175 !! input
2176 {{Includes2}}
2177 !! result
2178 <p>Foo
2179 </p>
2180 !! end
2181
2182
2183 !! article
2184 Template:Includes3
2185 !! text
2186 <onlyinclude>Foo</onlyinclude>bar<includeonly>zar</includeonly>
2187 !! endarticle
2188
2189 !! test
2190 <onlyinclude> and <includeonly> being included
2191 !! input
2192 {{Includes3}}
2193 !! result
2194 <p>Foo
2195 </p>
2196 !! end
2197
2198 !! test
2199 <includeonly> and <noinclude> on a page
2200 !! input
2201 Foo<noinclude>zar</noinclude><includeonly>bar</includeonly>
2202 !! result
2203 <p>Foozar
2204 </p>
2205 !! end
2206
2207 !! test
2208 <onlyinclude> on a page
2209 !! input
2210 <onlyinclude>Foo</onlyinclude>bar
2211 !! result
2212 <p>Foobar
2213 </p>
2214 !! end
2215
2216 ###
2217 ### Pre-save transform tests
2218 ###
2219 !! test
2220 pre-save transform: subst:
2221 !! options
2222 PST
2223 !! input
2224 {{subst:test}}
2225 !! result
2226 This is a test template
2227 !! end
2228
2229 !! test
2230 pre-save transform: normal template
2231 !! options
2232 PST
2233 !! input
2234 {{test}}
2235 !! result
2236 {{test}}
2237 !! end
2238
2239 !! test
2240 pre-save transform: nonexistant template
2241 !! options
2242 PST
2243 !! input
2244 {{thistemplatedoesnotexist}}
2245 !! result
2246 {{thistemplatedoesnotexist}}
2247 !! end
2248
2249
2250 !! test
2251 pre-save transform: subst magic variables
2252 !! options
2253 PST
2254 !! input
2255 {{subst:SITENAME}}
2256 !! result
2257 MediaWiki
2258 !! end
2259
2260 # This is bug 89, which I fixed. -- wtm
2261 !! test
2262 pre-save transform: subst: templates with parameters
2263 !! options
2264 pst
2265 !! input
2266 {{subst:paramtest|param="something else"}}
2267 !! result
2268 This is a test template with parameter "something else"
2269 !! end
2270
2271 !! article
2272 Template:nowikitest
2273 !! text
2274 <nowiki>'''not wiki'''</nowiki>
2275 !! endarticle
2276
2277 !! test
2278 pre-save transform: nowiki in subst (bug 1188)
2279 !! options
2280 pst
2281 !! input
2282 {{subst:nowikitest}}
2283 !! result
2284 <nowiki>'''not wiki'''</nowiki>
2285 !! end
2286
2287
2288 !! article
2289 Template:commenttest
2290 !! text
2291 This template has <!-- a comment --> in it.
2292 !! endarticle
2293
2294 !! test
2295 pre-save transform: comment in subst (bug 1936)
2296 !! options
2297 pst
2298 !! input
2299 {{subst:commenttest}}
2300 !! result
2301 This template has <!-- a comment --> in it.
2302 !! end
2303
2304
2305 !! article
2306 Template:dangerous
2307 !!text
2308 <span onmouseover="alert('crap')">Oh no</span>
2309 !!endarticle
2310
2311 !!test
2312 (confirming safety of fix for subst bug 1936)
2313 !! input
2314 {{Template:dangerous}}
2315 !! result
2316 <p><span>Oh no</span>
2317 </p>
2318 !! end
2319
2320 !! test
2321 pre-save transform: comment containing gallery (bug 5024)
2322 !! options
2323 pst
2324 !! input
2325 <!-- <gallery>data</gallery> -->
2326 !!result
2327 <!-- <gallery>data</gallery> -->
2328 !!end
2329
2330 !! test
2331 pre-save transform: comment containing extension
2332 !! options
2333 pst
2334 !! input
2335 <!-- <tag>data</tag> -->
2336 !!result
2337 <!-- <tag>data</tag> -->
2338 !!end
2339
2340 !! test
2341 pre-save transform: comment containing nowiki
2342 !! options
2343 pst
2344 !! input
2345 <!-- <nowiki>data</nowiki> -->
2346 !!result
2347 <!-- <nowiki>data</nowiki> -->
2348 !!end
2349
2350 !! test
2351 pre-save transform: comment containing math
2352 !! options
2353 pst
2354 !! input
2355 <!-- <math>data</math> -->
2356 !!result
2357 <!-- <math>data</math> -->
2358 !!end
2359
2360
2361 ###
2362 ### Message transform tests
2363 ###
2364 !! test
2365 message transform: magic variables
2366 !! options
2367 msg
2368 !! input
2369 {{SITENAME}}
2370 !! result
2371 MediaWiki
2372 !! end
2373
2374 !! test
2375 message transform: should not transform wiki markup
2376 !! options
2377 msg
2378 !! input
2379 ''test''
2380 !! result
2381 ''test''
2382 !! end
2383
2384 ###
2385 ### Images
2386 ###
2387 !! test
2388 Simple image
2389 !! input
2390 [[Image:foobar.jpg]]
2391 !! result
2392 <p><a href="/wiki/Image:Foobar.jpg" class="image" title="Image:foobar.jpg"><img src="http://example.com/images/3/3a/Foobar.jpg" alt="Image:foobar.jpg" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a>
2393 </p>
2394 !! end
2395
2396 !! test
2397 Right-aligned image
2398 !! input
2399 [[Image:foobar.jpg|right]]
2400 !! result
2401 <div class="floatright"><span><a href="/wiki/Image:Foobar.jpg" class="image" title=""><img src="http://example.com/images/3/3a/Foobar.jpg" alt="" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a></span></div>
2402
2403 !! end
2404
2405 !! test
2406 Image with caption
2407 !! input
2408 [[Image:foobar.jpg|right|Caption text]]
2409 !! result
2410 <div class="floatright"><span><a href="/wiki/Image:Foobar.jpg" class="image" title="Caption text"><img src="http://example.com/images/3/3a/Foobar.jpg" alt="Caption text" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a></span></div>
2411
2412 !! end
2413
2414 !! test
2415 Image with frame and link
2416 !! input
2417 [[Image:Foobar.jpg|frame|left|This is a test image [[Main Page]]]]
2418 !! result
2419 <div class="thumb tleft"><div style="width:1943px;"><a href="/wiki/Image:Foobar.jpg" class="internal" title="This is a test image Main Page"><img src="http://example.com/images/3/3a/Foobar.jpg" alt="This is a test image Main Page" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a> <div class="thumbcaption" >This is a test image <a href="/wiki/Main_Page" title="Main Page">Main Page</a></div></div></div>
2420
2421 !! end
2422
2423 !! test
2424 Link to image page
2425 !! input
2426 [[:Image:test]]
2427 !! result
2428 <p><a href="/wiki/Image:Test" title="Image:Test">Image:test</a>
2429 </p>
2430 !! end
2431
2432 !! test
2433 Frameless image caption with a free URL
2434 !! input
2435 [[Image:foobar.jpg|http://example.com]]
2436 !! result
2437 <p><a href="/wiki/Image:Foobar.jpg" class="image" title="http://example.com"><img src="http://example.com/images/3/3a/Foobar.jpg" alt="http://example.com" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a>
2438 </p>
2439 !! end
2440
2441 !! test
2442 Thumbnail image caption with a free URL
2443 !! input
2444 [[Image:foobar.jpg|thumb|http://example.com]]
2445 !! result
2446 <div class="thumb tright"><div style="width:182px;"><a href="/wiki/Image:Foobar.jpg" class="internal" title="http://example.com"><img src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" alt="http://example.com" width="180" height="20" longdesc="/wiki/Image:Foobar.jpg" /></a> <div class="thumbcaption" ><div class="magnify" style="float:right"><a href="/wiki/Image:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="Enlarge" /></a></div><a href="http://example.com" class='external free' title="http://example.com" rel="nofollow">http://example.com</a></div></div></div>
2447
2448 !! end
2449
2450 !! test
2451 BUG 1887: A ISBN with a thumbnail
2452 !! input
2453 [[Image:foobar.jpg|thumb|ISBN 12354]]
2454 !! result
2455 <div class="thumb tright"><div style="width:182px;"><a href="/wiki/Image:Foobar.jpg" class="internal" title="ISBN 12354"><img src="http://example.com/images/3/3a/Foobar.jpg" alt="ISBN 12354" longdesc="/wiki/Image:Foobar.jpg" height="180" width="180"></a> <div class="thumbcaption"><div class="magnify" style="float:right;"><a href="/wiki/Image:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="Enlarge"></a></div><a href="index.php?title=Special:Booksources&amp;isbn=12354" class="internal">ISBN 12354</a></div></div></div>
2456 !! end
2457
2458 !! test
2459 BUG 1887: A <math> with a thumbnail
2460 !! input
2461 [[Image:foobar.jpg|thumb|<math>2+2</math>]]
2462 !! result
2463 <div class="thumb tright"><div style="width:182px;"><a href="/wiki/Image:Foobar.jpg" class="internal" title="2+2"><img src="http://example.com/images/3/3a/Foobar.jpg" alt="2+2" longdesc="/wiki/Image:Foobar.jpg" height="180" width="180"></a> <div class="thumbcaption"><div class="magnify" style="float:right;"><a href="/wiki/Image:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="Enlarge"></a></div>&lt;math&gt;2+2&lt;math&gt;</div></div></div>
2464 !! end
2465
2466 # Pending resolution to bug 368
2467 !! test
2468 BUG 648: Frameless image caption with a link
2469 !! input
2470 [[Image:foobar.jpg|text with a [[link]] in it]]
2471 !! result
2472 <p><a href="/wiki/Image:Foobar.jpg" class="image" title="text with a link in it"><img src="http://example.com/images/3/3a/Foobar.jpg" alt="text with a link in it" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a>
2473 </p>
2474 !! end
2475
2476 !! test
2477 BUG 648: Frameless image caption with a link (suffix)
2478 !! input
2479 [[Image:foobar.jpg|text with a [[link]]foo in it]]
2480 !! result
2481 <p><a href="/wiki/Image:Foobar.jpg" class="image" title="text with a linkfoo in it"><img src="http://example.com/images/3/3a/Foobar.jpg" alt="text with a linkfoo in it" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a>
2482 </p>
2483 !! end
2484
2485 !! test
2486 BUG 648: Frameless image caption with an interwiki link
2487 !! input
2488 [[Image:foobar.jpg|text with a [[MeatBall:Link]] in it]]
2489 !! result
2490 <p><a href="/wiki/Image:Foobar.jpg" class="image" title="text with a MeatBall:Link in it"><img src="http://example.com/images/3/3a/Foobar.jpg" alt="text with a MeatBall:Link in it" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a>
2491 </p>
2492 !! end
2493
2494 !! test
2495 BUG 648: Frameless image caption with a piped interwiki link
2496 !! input
2497 [[Image:foobar.jpg|text with a [[MeatBall:Link|link]] in it]]
2498 !! result
2499 <p><a href="/wiki/Image:Foobar.jpg" class="image" title="text with a link in it"><img src="http://example.com/images/3/3a/Foobar.jpg" alt="text with a link in it" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a>
2500 </p>
2501 !! end
2502
2503 !! test
2504 Escape HTML special chars in image alt text
2505 !! input
2506 [[Image:foobar.jpg|& < > "]]
2507 !! result
2508 <p><a href="/wiki/Image:Foobar.jpg" class="image" title="&amp; &lt; &gt; &quot;"><img src="http://example.com/images/3/3a/Foobar.jpg" alt="&amp; &lt; &gt; &quot;" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a>
2509 </p>
2510 !! end
2511
2512 !! test
2513 BUG 499: Alt text should have &#1234;, not &amp;1234;
2514 !! input
2515 [[Image:foobar.jpg|&#9792;]]
2516 !! result
2517 <p><a href="/wiki/Image:Foobar.jpg" class="image" title="&#9792;"><img src="http://example.com/images/3/3a/Foobar.jpg" alt="&#9792;" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a>
2518 </p>
2519 !! end
2520
2521 !! test
2522 Broken image caption with link
2523 !! input
2524 [[Image:Foobar.jpg|thumb|This is a broken caption. But [[Main Page|this]] is just an ordinary link.
2525 !! result
2526 <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.
2527 </p>
2528 !! end
2529
2530 !! test
2531 Image caption containing another image
2532 !! input
2533 [[Image:Foobar.jpg|thumb|This is a caption with another [[Image:icon.png|image]] inside it!]]
2534 !! result
2535 <div class="thumb tright"><div style="width:182px;"><a href="/wiki/Image:Foobar.jpg" class="internal" title="This is a caption with another Image:Icon.png inside it!"><img src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" alt="This is a caption with another Image:Icon.png inside it!" width="180" height="20" longdesc="/wiki/Image:Foobar.jpg" /></a> <div class="thumbcaption" ><div class="magnify" style="float:right"><a href="/wiki/Image:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="Enlarge" /></a></div>This is a caption with another <a href="/index.php?title=Special:Upload&amp;wpDestFile=Icon.png" class="new" title="Image:Icon.png">Image:Icon.png</a> inside it!</div></div></div>
2536
2537 !! end
2538
2539 !! test
2540 Image caption containing a newline
2541 !! input
2542 [[Image:Foobar.jpg|This
2543 *is some text]]
2544 !! result
2545 <p><a href="/wiki/Image:Foobar.jpg" class="image" title="This *is some text"><img src="http://example.com/images/3/3a/Foobar.jpg" alt="This *is some text" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a>
2546 </p>
2547 !!end
2548
2549
2550 !! test
2551 Bug 3090: External links other than http: in image captions
2552 !! input
2553 [[Image:Foobar.jpg|thumb|200px|This caption has [irc://example.net irc] and [https://example.com Secure] ext links in it.]]
2554 !! result
2555 <div class="thumb tright"><div style="width:202px;"><a href="/wiki/Image:Foobar.jpg" class="internal" title="This caption has irc and Secure ext links in it."><img src="http://example.com/images/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg" alt="This caption has irc and Secure ext links in it." width="200" height="23" longdesc="/wiki/Image:Foobar.jpg" /></a> <div class="thumbcaption" ><div class="magnify" style="float:right"><a href="/wiki/Image:Foobar.jpg" class="internal" title="Enlarge"><img src="/skins/common/images/magnify-clip.png" width="15" height="11" alt="Enlarge" /></a></div>This caption has <a href="irc://example.net" class='external text' title="irc://example.net" rel="nofollow">irc</a> and <a href="https://example.com" class='external text' title="https://example.com" rel="nofollow">Secure</a> ext links in it.</div></div></div>
2556
2557 !! end
2558
2559
2560 ###
2561 ### Subpages
2562 ###
2563 !! article
2564 Subpage test/subpage
2565 !! text
2566 foo
2567 !! endarticle
2568
2569 !! test
2570 Subpage link
2571 !! options
2572 subpage title=[[Subpage test]]
2573 !! input
2574 [[/subpage]]
2575 !! result
2576 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a>
2577 </p>
2578 !! end
2579
2580 !! test
2581 Subpage noslash link
2582 !! options
2583 subpage title=[[Subpage test]]
2584 !!input
2585 [[/subpage/]]
2586 !! result
2587 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">subpage</a>
2588 </p>
2589 !! end
2590
2591 !! test
2592 Disabled subpages
2593 !! input
2594 [[/subpage]]
2595 !! result
2596 <p><a href="/index.php?title=/subpage&amp;action=edit" class="new" title="/subpage">/subpage</a>
2597 </p>
2598 !! end
2599
2600 !! test
2601 BUG 561: {{/Subpage}}
2602 !! options
2603 subpage title=[[Page]]
2604 !! input
2605 {{/Subpage}}
2606 !! result
2607 <p><a href="/index.php?title=Page/Subpage&amp;action=edit" class="new" title="Page/Subpage">Page/Subpage</a>
2608 </p>
2609 !! end
2610
2611 ###
2612 ### Categories
2613 ###
2614 !! article
2615 Category:MediaWiki User's Guide
2616 !! text
2617 blah
2618 !! endarticle
2619
2620 !! test
2621 Link to category
2622 !! input
2623 [[:Category:MediaWiki User's Guide]]
2624 !! result
2625 <p><a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User's Guide">Category:MediaWiki User's Guide</a>
2626 </p>
2627 !! end
2628
2629 !! test
2630 Simple category
2631 !! options
2632 cat
2633 !! input
2634 [[Category: MediaWiki User's Guide]]
2635 !! result
2636 <a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User's Guide">MediaWiki User's Guide</a>
2637 !! end
2638
2639 ###
2640 ### Inter-language links
2641 ###
2642 !! test
2643 Inter-language links
2644 !! options
2645 ill
2646 !! input
2647 [[es:Alimento]]
2648 [[fr:Nourriture]]
2649 [[zh:&#39135;&#21697;]]
2650 !! result
2651 es:Alimento fr:Nourriture zh:食品
2652 !! end
2653
2654 ###
2655 ### Sections
2656 ###
2657 !! test
2658 Basic section headings
2659 !! options
2660 title=[[Parser test script]]
2661 !! input
2662 == Headline 1 ==
2663 Some text
2664
2665 ==Headline 2==
2666 More
2667 ===Smaller headline===
2668 Blah blah
2669 !! result
2670 <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>
2671 <p>Some text
2672 </p>
2673 <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>
2674 <p>More
2675 </p>
2676 <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>
2677 <p>Blah blah
2678 </p>
2679 !! end
2680
2681 !! test
2682 Section headings with TOC
2683 !! options
2684 title=[[Parser test script]]
2685 !! input
2686 == Headline 1 ==
2687 === Subheadline 1 ===
2688 ===== Skipping a level =====
2689 ====== Skipping a level ======
2690
2691 == Headline 2 ==
2692 Some text
2693 ===Another headline===
2694 !! result
2695 <table id="toc" class="toc" summary="Contents"><tr><td><div id="toctitle"><h2>Contents</h2></div>
2696 <ul>
2697 <li class='toclevel-1'><a href="#Headline_1"><span class="tocnumber">1</span> <span class="toctext">Headline 1</span></a>
2698 <ul>
2699 <li class='toclevel-2'><a href="#Subheadline_1"><span class="tocnumber">1.1</span> <span class="toctext">Subheadline 1</span></a>
2700 <ul>
2701 <li class='toclevel-3'><a href="#Skipping_a_level"><span class="tocnumber">1.1.1</span> <span class="toctext">Skipping a level</span></a>
2702 <ul>
2703 <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>
2704 </ul>
2705 </li>
2706 </ul>
2707 </li>
2708 </ul>
2709 </li>
2710 <li class='toclevel-1'><a href="#Headline_2"><span class="tocnumber">2</span> <span class="toctext">Headline 2</span></a>
2711 <ul>
2712 <li class='toclevel-2'><a href="#Another_headline"><span class="tocnumber">2.1</span> <span class="toctext">Another headline</span></a></li>
2713 </ul>
2714 </li>
2715 </ul>
2716 </td></tr></table>
2717 <script type="text/javascript"> if (window.showTocToggle) { var tocShowText = "show"; var tocHideText = "hide"; showTocToggle(); } </script>
2718 <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>
2719 <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>
2720 <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>
2721 <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>
2722 <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>
2723 <p>Some text
2724 </p>
2725 <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>
2726
2727 !! end
2728
2729 # perl -e 'print "="x$_," Level $_ heading","="x$_,"\n" for 1..10'
2730 !! test
2731 Handling of sections up to level 6 and beyond
2732 !! input
2733 = Level 1 Heading=
2734 == Level 2 Heading==
2735 === Level 3 Heading===
2736 ==== Level 4 Heading====
2737 ===== Level 5 Heading=====
2738 ====== Level 6 Heading======
2739 ======= Level 7 Heading=======
2740 ======== Level 8 Heading========
2741 ========= Level 9 Heading=========
2742 ========== Level 10 Heading==========
2743 !! result
2744 <table id="toc" class="toc" summary="Contents"><tr><td><div id="toctitle"><h2>Contents</h2></div>
2745 <ul>
2746 <li class='toclevel-1'><a href="#Level_1_Heading"><span class="tocnumber">1</span> <span class="toctext">Level 1 Heading</span></a>
2747 <ul>
2748 <li class='toclevel-2'><a href="#Level_2_Heading"><span class="tocnumber">1.1</span> <span class="toctext">Level 2 Heading</span></a>
2749 <ul>
2750 <li class='toclevel-3'><a href="#Level_3_Heading"><span class="tocnumber">1.1.1</span> <span class="toctext">Level 3 Heading</span></a>
2751 <ul>
2752 <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>
2753 <ul>
2754 <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>
2755 <ul>
2756 <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>
2757 <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>
2758 <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>
2759 <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>
2760 <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>
2761 </ul>
2762 </li>
2763 </ul>
2764 </li>
2765 </ul>
2766 </li>
2767 </ul>
2768 </li>
2769 </ul>
2770 </li>
2771 </ul>
2772 </td></tr></table>
2773 <p><script type="text/javascript"> if (window.showTocToggle) { var tocShowText = "show"; var tocHideText = "hide"; showTocToggle(); } </script>
2774 </p>
2775 <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>
2776 <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>
2777 <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>
2778 <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>
2779 <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>
2780 <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>
2781 <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>
2782 <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>
2783 <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>
2784 <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>
2785
2786 !! end
2787
2788 !! test
2789 Resolving duplicate section names
2790 !! options
2791 title=[[Parser test script]]
2792 !! input
2793 == Foo bar ==
2794 == Foo bar ==
2795 !! result
2796 <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>
2797 <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>
2798
2799 !! end
2800
2801 !! article
2802 Template:sections
2803 !! text
2804 ===Section 1===
2805 ==Section 2==
2806 !! endarticle
2807
2808 !! test
2809 Template with sections, __NOTOC__
2810 !! options
2811 title=[[Parser test script]]
2812 !! input
2813 __NOTOC__
2814 ==Section 0==
2815 {{sections}}
2816 ==Section 4==
2817 !! result
2818 <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>
2819 <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>
2820 <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>
2821 <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>
2822
2823 !! end
2824
2825 !! test
2826 __NOEDITSECTION__ keyword
2827 !! input
2828 __NOEDITSECTION__
2829 ==Section 1==
2830 ==Section 2==
2831 !! result
2832 <a name="Section_1"></a><h2>Section 1</h2>
2833 <a name="Section_2"></a><h2>Section 2</h2>
2834
2835 !! end
2836
2837 !! test
2838 Link inside a section heading
2839 !! options
2840 title=[[Parser test script]]
2841 !! input
2842 ==Section with a [[Main Page|link]] in it==
2843 !! result
2844 <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>
2845
2846 !! end
2847
2848
2849 !! test
2850 BUG 1219 URL next to image (good)
2851 !! input
2852 http://example.com [[Image:foobar.jpg]]
2853 !! result
2854 <p><a href="http://example.com" class='external free' title="http://example.com" rel="nofollow">http://example.com</a> <a href="/wiki/Image:Foobar.jpg" class="image" title="Image:foobar.jpg"><img src="http://example.com/images/3/3a/Foobar.jpg" alt="Image:foobar.jpg" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a>
2855 </p>
2856 !!end
2857
2858 !! test
2859 BUG 1219 URL next to image (broken)
2860 !! input
2861 http://example.com[[Image:foobar.jpg]]
2862 !! result
2863 <p><a href="http://example.com" class='external free' title="http://example.com" rel="nofollow">http://example.com</a><a href="/wiki/Image:Foobar.jpg" class="image" title="Image:foobar.jpg"><img src="http://example.com/images/3/3a/Foobar.jpg" alt="Image:foobar.jpg" width="1941" height="220" longdesc="/wiki/Image:Foobar.jpg" /></a>
2864 </p>
2865 !!end
2866
2867 !! test
2868 Bug 1186 news: in the middle of text
2869 !! input
2870 http://en.wikinews.org/wiki/Wikinews:Workplace
2871 !! result
2872 <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>
2873 </p>
2874 !!end
2875
2876
2877 !! test
2878 Namespaced link must have a title
2879 !! input
2880 [[Project:]]
2881 !! result
2882 <p>[[Project:]]
2883 </p>
2884 !!end
2885
2886 !! test
2887 Namespaced link must have a title (bad fragment version)
2888 !! input
2889 [[Project:#fragment]]
2890 !! result
2891 <p>[[Project:#fragment]]
2892 </p>
2893 !!end
2894
2895
2896 !! test
2897 div with no attributes
2898 !! input
2899 <div>HTML rocks</div>
2900 !! result
2901 <div>HTML rocks</div>
2902
2903 !! end
2904
2905 !! test
2906 div with double-quoted attribute
2907 !! input
2908 <div id="rock">HTML rocks</div>
2909 !! result
2910 <div id="rock">HTML rocks</div>
2911
2912 !! end
2913
2914 !! test
2915 div with single-quoted attribute
2916 !! input
2917 <div id='rock'>HTML rocks</div>
2918 !! result
2919 <div id="rock">HTML rocks</div>
2920
2921 !! end
2922
2923 !! test
2924 div with unquoted attribute
2925 !! input
2926 <div id=rock>HTML rocks</div>
2927 !! result
2928 <div id="rock">HTML rocks</div>
2929
2930 !! end
2931
2932 !! test
2933 div with illegal double attributes
2934 !! input
2935 <div align="center" align="right">HTML rocks</div>
2936 !! result
2937 <div align="right">HTML rocks</div>
2938
2939 !!end
2940
2941 !! test
2942 HTML multiple attributes correction
2943 !! input
2944 <p class="error" class="awesome">Awesome!</p>
2945 !! result
2946 <p class="awesome">Awesome!</p>
2947
2948 !!end
2949
2950 !! test
2951 Table multiple attributes correction
2952 !! input
2953 {|
2954 !+ class="error" class="awesome"| status
2955 |}
2956 !! result
2957 <table>
2958 <tr>
2959 <th class="awesome"> status
2960 </th></tr></table>
2961
2962 !!end
2963
2964 !! test
2965 DIV IN UPPERCASE
2966 !! input
2967 <DIV ALIGN="center">HTML ROCKS</DIV>
2968 !! result
2969 <div align="center">HTML ROCKS</div>
2970
2971 !!end
2972
2973
2974 !! test
2975 text with amp in the middle of nowhere
2976 !! input
2977 Remember AT&T?
2978 !!result
2979 <p>Remember AT&amp;T?
2980 </p>
2981 !! end
2982
2983 !! test
2984 text with character entity: eacute
2985 !! input
2986 I always thought &eacute; was a cute letter.
2987 !! result
2988 <p>I always thought &eacute; was a cute letter.
2989 </p>
2990 !! end
2991
2992 !! test
2993 text with undefined character entity: xacute
2994 !! input
2995 I always thought &xacute; was a cute letter.
2996 !! result
2997 <p>I always thought &amp;xacute; was a cute letter.
2998 </p>
2999 !! end
3000
3001
3002 ###
3003 ### Media links
3004 ###
3005
3006 !! test
3007 Media link
3008 !! input
3009 [[Media:Foobar.jpg]]
3010 !! result
3011 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class='internal' title="Foobar.jpg">Media:Foobar.jpg</a>
3012 </p>
3013 !! end
3014
3015 !! test
3016 Media link with text
3017 !! input
3018 [[Media:Foobar.jpg|A neat file to look at]]
3019 !! result
3020 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class='internal' title="Foobar.jpg">A neat file to look at</a>
3021 </p>
3022 !! end
3023
3024 # FIXME: this is still bad HTML tag nesting
3025 !! test
3026 Media link with nasty text
3027 !! input
3028 [[Media:Foobar.jpg|Safe Link<div style=display:none>" onmouseover="alert(document.cookie)" onfoo="</div>]]
3029 !! result
3030 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class='internal' title="Foobar.jpg">Safe Link<div style="display:none">" onmouseover="alert(document.cookie) onfoo="</div></a>
3031 </p>
3032 !! end
3033
3034 !! test
3035 Media link to nonexistent file (bug 1702)
3036 !! input
3037 [[Media:No such.jpg]]
3038 !! result
3039 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=No_such.jpg" class='new' title="No such.jpg">Media:No such.jpg</a>
3040 </p>
3041 !! end
3042
3043 !! test
3044 Image link to nonexistent file (bug 1850 - good)
3045 !! input
3046 [[Image:No such.jpg]]
3047 !! result
3048 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=No_such.jpg" class="new" title="Image:No such.jpg">Image:No such.jpg</a>
3049 </p>
3050 !! end
3051
3052 !! test
3053 :Image link to nonexistent file (bug 1850 - bad)
3054 !! input
3055 [[:Image:No such.jpg]]
3056 !! result
3057 <p><a href="/index.php?title=Image:No_such.jpg&amp;action=edit" class="new" title="Image:No such.jpg">Image:No such.jpg</a>
3058 </p>
3059 !! end
3060
3061
3062
3063 !! test
3064 Character reference normalization in link text (bug 1938)
3065 !! input
3066 [[Main Page|this&that]]
3067 !! result
3068 <p><a href="/wiki/Main_Page" title="Main Page">this&amp;that</a>
3069 </p>
3070 !!end
3071
3072 !! test
3073 Empty attribute crash test (bug 2067)
3074 !! input
3075 <font color="">foo</font>
3076 !! result
3077 <p><font color="">foo</font>
3078 </p>
3079 !! end
3080
3081 !! test
3082 Empty attribute crash test single-quotes (bug 2067)
3083 !! input
3084 <font color=''>foo</font>
3085 !! result
3086 <p><font color="">foo</font>
3087 </p>
3088 !! end
3089
3090 !! test
3091 Attribute test: equals, then nothing
3092 !! input
3093 <font color=>foo</font>
3094 !! result
3095 <p><font>foo</font>
3096 </p>
3097 !! end
3098
3099 !! test
3100 Attribute test: unquoted value
3101 !! input
3102 <font color=x>foo</font>
3103 !! result
3104 <p><font color="x">foo</font>
3105 </p>
3106 !! end
3107
3108 !! test
3109 Attribute test: unquoted but illegal value (hash)
3110 !! input
3111 <font color=#x>foo</font>
3112 !! result
3113 <p><font color="#x">foo</font>
3114 </p>
3115 !! end
3116
3117 !! test
3118 Attribute test: no value
3119 !! input
3120 <font color>foo</font>
3121 !! result
3122 <p><font color="color">foo</font>
3123 </p>
3124 !! end
3125
3126 !! test
3127 Bug 2095: link with three closing brackets
3128 !! input
3129 [[Main Page]]]
3130 !! result
3131 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>]
3132 </p>
3133 !! end
3134
3135 !! test
3136 Bug 2095: link with pipe and three closing brackets
3137 !! input
3138 [[Main Page|link]]]
3139 !! result
3140 <p><a href="/wiki/Main_Page" title="Main Page">link</a>]
3141 </p>
3142 !! end
3143
3144
3145 ###
3146 ### Safety
3147 ###
3148
3149 !! article
3150 Template:Dangerous attribute
3151 !! text
3152 " onmouseover="alert(document.cookie)
3153 !! endarticle
3154
3155 !! article
3156 Template:Dangerous style attribute
3157 !! text
3158 border-size: expression(alert(document.cookie))
3159 !! endarticle
3160
3161 !! article
3162 Template:Div style
3163 !! text
3164 <div style="float: right; {{{1}}}">Magic div</div>
3165 !! endarticle
3166
3167 !! test
3168 Bug 2304: HTML attribute safety (safe template; regression bug 2309)
3169 !! input
3170 <div title="{{test}}"></div>
3171 !! result
3172 <div title="This is a test template"></div>
3173
3174 !! end
3175
3176 !! test
3177 Bug 2304: HTML attribute safety (dangerous template; 2309)
3178 !! input
3179 <div title="{{dangerous attribute}}"></div>
3180 !! result
3181 <div title=""></div>
3182
3183 !! end
3184
3185 !! test
3186 Bug 2304: HTML attribute safety (dangerous style template; 2309)
3187 !! input
3188 <div style="{{dangerous style attribute}}"></div>
3189 !! result
3190 <div></div>
3191
3192 !! end
3193
3194 !! test
3195 Bug 2304: HTML attribute safety (safe parameter; 2309)
3196 !! input
3197 {{div style|width: 200px}}
3198 !! result
3199 <div style="float: right; width: 200px">Magic div</div>
3200
3201 !! end
3202
3203 !! test
3204 Bug 2304: HTML attribute safety (unsafe parameter; 2309)
3205 !! input
3206 {{div style|width: expression(alert(document.cookie))}}
3207 !! result
3208 <div>Magic div</div>
3209
3210 !! end
3211
3212 !! test
3213 Bug 2304: HTML attribute safety (unsafe breakout parameter; 2309)
3214 !! input
3215 {{div style|"><script>alert(document.cookie)</script>}}
3216 !! result
3217 <div>Magic div</div>
3218
3219 !! end
3220
3221 !! test
3222 Bug 2304: HTML attribute safety (unsafe breakout parameter 2; 2309)
3223 !! input
3224 {{div style|" ><script>alert(document.cookie)</script>}}
3225 !! result
3226 <div style="float: right; ">Magic div</div>
3227
3228 !! end
3229
3230 !! test
3231 Bug 2304: HTML attribute safety (link)
3232 !! input
3233 <div title="[[Main Page]]"></div>
3234 !! result
3235 <div title="&#91;&#91;Main Page]]"></div>
3236
3237 !! end
3238
3239 !! test
3240 Bug 2304: HTML attribute safety (italics)
3241 !! input
3242 <div title="''foobar''"></div>
3243 !! result
3244 <div title="&#39;&#39;foobar&#39;&#39;"></div>
3245
3246 !! end
3247
3248 !! test
3249 Bug 2304: HTML attribute safety (bold)
3250 !! input
3251 <div title="'''foobar'''"></div>
3252 !! result
3253 <div title="&#39;&#39;'foobar&#39;&#39;'"></div>
3254
3255 !! end
3256
3257
3258 !! test
3259 Bug 2304: HTML attribute safety (ISBN)
3260 !! input
3261 <div title="ISBN 1234567890"></div>
3262 !! result
3263 <div title="&#73;SBN 1234567890"></div>
3264
3265 !! end
3266
3267 !! test
3268 Bug 2304: HTML attribute safety (RFC)
3269 !! input
3270 <div title="RFC 1234"></div>
3271 !! result
3272 <div title="&#82;FC 1234"></div>
3273
3274 !! end
3275
3276 !! test
3277 Bug 2304: HTML attribute safety (PMID)
3278 !! input
3279 <div title="PMID 1234567890"></div>
3280 !! result
3281 <div title="&#80;MID 1234567890"></div>
3282
3283 !! end
3284
3285 !! test
3286 Bug 2304: HTML attribute safety (web link)
3287 !! input
3288 <div title="http://example.com/"></div>
3289 !! result
3290 <div title="http&#58;//example.com/"></div>
3291
3292 !! end
3293
3294 !! test
3295 Bug 2304: HTML attribute safety (named web link)
3296 !! input
3297 <div title="[http://example.com/ link]"></div>
3298 !! result
3299 <div title="&#91;http&#58;//example.com/ link]"></div>
3300
3301 !! end
3302
3303 !! test
3304 Bug 3244: HTML attribute safety (extension; safe)
3305 !! input
3306 <div style="<nowiki>background:blue</nowiki>"></div>
3307 !! result
3308 <div style="background:blue"></div>
3309
3310 !! end
3311
3312 !! test
3313 Bug 3244: HTML attribute safety (extension; unsafe)
3314 !! input
3315 <div style="<nowiki>border-left:expression(alert(document.cookie))</nowiki>"></div>
3316 !! result
3317 <div></div>
3318
3319 !! end
3320
3321 !! test
3322 Math section safety when disabled
3323 !! input
3324 <math><script>alert(document.cookies);</script></math>
3325 !! result
3326 <p>&lt;math&gt;&lt;script&gt;alert(document.cookies);&lt;/script&gt;&lt;/math&gt;
3327 </p>
3328 !! end
3329
3330 # More MSIE fun discovered by Tom Gilder
3331
3332 !! test
3333 MSIE CSS safety test: spurious slash
3334 !! input
3335 <div style="background-image:u\rl(javascript:alert('boo'))">evil</div>
3336 !! result
3337 <div>evil</div>
3338
3339 !! end
3340
3341 !! test
3342 MSIE CSS safety test: hex code
3343 !! input
3344 <div style="background-image:u\72l(javascript:alert('boo'))">evil</div>
3345 !! result
3346 <div>evil</div>
3347
3348 !! end
3349
3350 !! test
3351 MSIE CSS safety test: comment in url
3352 !! input
3353 <div style="background-image:u/**/rl(javascript:alert('boo'))">evil</div>
3354 !! result
3355 <div style="background-image:u rl(javascript:alert('boo'))">evil</div>
3356
3357 !! end
3358
3359 !! test
3360 MSIE CSS safety test: comment in expression
3361 !! input
3362 <div style="background-image:expres/**/sion(alert('boo4'))">evil4</div>
3363 !! result
3364 <div style="background-image:expres sion(alert('boo4'))">evil4</div>
3365
3366 !! end
3367
3368
3369 !! test
3370 Table attribute legitimate extension
3371 !! input
3372 {|
3373 !+ style="<nowiki>color:blue</nowiki>"| status
3374 |}
3375 !! result
3376 <table>
3377 <tr>
3378 <th style="color:blue"> status
3379 </th></tr></table>
3380
3381 !!end
3382
3383 !! test
3384 Table attribute safety
3385 !! input
3386 {|
3387 !+ style="<nowiki>border-width:expression(0+alert(document.cookie))</nowiki>"| status
3388 |}
3389 !! result
3390 <table>
3391 <tr>
3392 <th> status
3393 </th></tr></table>
3394
3395 !! end
3396
3397 ###
3398 ### Parser hooks (see maintenance/parserTestsParserHook.php for the <tag> extension)
3399 ###
3400 !! test
3401 Parser hook: empty input
3402 !! input
3403 <tag></tag>
3404 !! result
3405 <pre>
3406 string(0) ""
3407 array(0) {
3408 }
3409 </pre>
3410
3411 !! end
3412
3413 !! test
3414 Parser hook: empty input using terminated empty elements
3415 !! input
3416 <tag/>
3417 !! result
3418 <pre>
3419 NULL
3420 array(0) {
3421 }
3422 </pre>
3423
3424 !! end
3425
3426 !! test
3427 Parser hook: basic input
3428 !! input
3429 <tag>input</tag>
3430 !! result
3431 <pre>
3432 string(5) "input"
3433 array(0) {
3434 }
3435 </pre>
3436
3437 !! end
3438
3439
3440 !! test
3441 Parser hook: case insensetive
3442 !! input
3443 <TAG>input</TAG>
3444 !! result
3445 <pre>
3446 string(5) "input"
3447 array(0) {
3448 }
3449 </pre>
3450
3451 !! end
3452
3453
3454 !! test
3455 Parser hook: case insensetive, redux
3456 !! input
3457 <TaG>input</TAg>
3458 !! result
3459 <pre>
3460 string(5) "input"
3461 array(0) {
3462 }
3463 </pre>
3464
3465 !! end
3466
3467 !! test
3468 Parser hook: nested tags
3469 !! options
3470 noxml
3471 !! input
3472 <tag><tag></tag></tag>
3473 !! result
3474 <pre>
3475 string(5) "<tag>"
3476 array(0) {
3477 }
3478 </pre>&lt;/tag&gt;
3479
3480 !! end
3481
3482 !! test
3483 Parser hook: basic arguments
3484 !! input
3485 <tag width=200 height = "100" depth = '50' square></tag>
3486 !! result
3487 <pre>
3488 string(0) ""
3489 array(4) {
3490 ["width"]=>
3491 string(3) "200"
3492 ["height"]=>
3493 string(3) "100"
3494 ["depth"]=>
3495 string(2) "50"
3496 ["square"]=>
3497 string(6) "square"
3498 }
3499 </pre>
3500
3501 !! end
3502
3503 !! test
3504 Parser hook: empty input using terminated empty elements (bug 2374)
3505 !! input
3506 <tag foo=bar/>text
3507 !! result
3508 <pre>
3509 NULL
3510 array(1) {
3511 ["foo"]=>
3512 string(3) "bar"
3513 }
3514 </pre>text
3515
3516 !! end
3517
3518 # </tag> should be output literally since there is no matching tag that begins it
3519 !! test
3520 Parser hook: basic arguments using terminated empty elements (bug 2374)
3521 !! input
3522 <tag width=200 height = "100" depth = '50' square/>
3523 other stuff
3524 </tag>
3525 !! result
3526 <pre>
3527 NULL
3528 array(4) {
3529 ["width"]=>
3530 string(3) "200"
3531 ["height"]=>
3532 string(3) "100"
3533 ["depth"]=>
3534 string(2) "50"
3535 ["square"]=>
3536 string(6) "square"
3537 }
3538 </pre>
3539 <p>other stuff
3540 &lt;/tag&gt;
3541 </p>
3542 !! end
3543
3544 ###
3545 ### (see maintenance/parserTestsStaticParserHook.php for the <statictag> extension)
3546 ###
3547
3548 !! test
3549 Parser hook: static parser hook not inside a comment
3550 !! input
3551 <statictag>hello, world</statictag>
3552 <statictag action=flush/>
3553 !! result
3554 <p>hello, world
3555 </p>
3556 !! end
3557
3558
3559 !! test
3560 Parser hook: static parser hook inside a comment
3561 !! input
3562 <!-- <statictag>hello, world</statictag> -->
3563 <statictag action=flush/>
3564 !! result
3565 <p><br />
3566 </p>
3567 !! end
3568
3569 # Nested template calls; this case was broken by Parser.php rev 1.506,
3570 # since reverted.
3571
3572 !! article
3573 Template:One-parameter
3574 !! text
3575 (My parameter is: {{{1}}})
3576 !! endarticle
3577
3578 !! article
3579 Template:Map-one-parameter
3580 !! text
3581 {{{{{1}}}|{{{2}}}}}
3582 !! endarticle
3583
3584 !! test
3585 Nested template calls
3586 !! input
3587 {{Map-one-parameter|One-parameter|param}}
3588 !! result
3589 <p>(My parameter is: param)
3590 </p>
3591 !! end
3592
3593
3594 ###
3595 ### Sanitizer
3596 ###
3597 !! test
3598 Sanitizer: Closing of open tags
3599 !! input
3600 <s></s><table></table>
3601 !! result
3602 <s></s><table></table>
3603
3604 !! end
3605
3606 !! test
3607 Sanitizer: Closing of open but not closed tags
3608 !! input
3609 <s>foo
3610 !! result
3611 <p><s>foo</s>
3612 </p>
3613 !! end
3614
3615 !! test
3616 Sanitizer: Closing of closed but not open tags
3617 !! input
3618 </s>
3619 !! result
3620 <p>&lt;/s&gt;
3621 </p>
3622 !! end
3623
3624 !! test
3625 Sanitizer: Closing of closed but not open table tags
3626 !! input
3627 Table not started</td></tr></table>
3628 !! result
3629 <p>Table not started&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
3630 </p>
3631 !! end
3632
3633 !! test
3634 Sanitizer: Escaping of spaces, multibyte characters, colons & other stuff in id=""
3635 !! input
3636 <span id="æ: v">byte</span>[[#æ: v|backlink]]
3637 !! result
3638 <p><span id=".C3.A6:_v">byte</span><a href="#.C3.A6:_v" title="">backlink</a>
3639 </p>
3640 !! end
3641
3642 !! test
3643 Sanitizer: Validating the contents of the id attribute (bug 4515)
3644 !! input
3645 <br id=9 />
3646 !! result
3647 Something, but defenetly not <br id="9" />...
3648 !! end
3649
3650 TODO:
3651 more images
3652 more tables
3653 math
3654 character entities
3655 and much more