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