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