bf2d8c49ab8629b6176b98e4264781390a3d88a6
[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're purely an XML shop you see, so we eat everything
251 starting with < followed by !-- until the first -- and > we see, observe: -->-->
252 !! result
253 <p>--&gt;
254 </p>
255 !! end
256
257 !! test
258 Comment semantics: nesting
259 !! input
260 <!--<!-- no, we're not going to do anything fancy here -->-->
261 !! result
262 <p>--&gt;
263 </p>
264 !! end
265
266
267 ###
268 ### Preformatted text
269 ###
270 !! test
271 Preformatted text
272 !! input
273 This is some
274 Preformatted text
275 With ''italic''
276 And '''bold'''
277 And a [[Main Page|link]]
278 !! result
279 <pre>This is some
280 Preformatted text
281 With <i>italic</i>
282 And <b>bold</b>
283 And a <a href="/wiki/Main_Page" title="Main Page">link</a>
284 </pre>
285 !! end
286
287 ###
288 ### Definition lists
289 ###
290 !! test
291 Simple definition
292 !! input
293 ; name : Definition
294 !! result
295 <dl><dt> name&nbsp;</dt><dd> Definition
296 </dd></dl>
297
298 !! end
299
300 !! test
301 Simple definition
302 !! input
303 : Indented text
304 !! result
305 <dl><dd> Indented text
306 </dd></dl>
307
308 !! end
309
310 !! test
311 Definition list with no space
312 !! input
313 ;name:Definition
314 !! result
315 <dl><dt>name</dt><dd>Definition
316 </dd></dl>
317
318 !!end
319
320 !! test
321 Definition list with URL link
322 !! input
323 ; http://example.com/ : definition
324 !! result
325 <dl><dt> <a href="http://example.com/" class='external free' title="http://example.com/" rel="nofollow">http://example.com/</a>&nbsp;</dt><dd> definition
326 </dd></dl>
327
328 !! end
329
330 !! test
331 Definition list with bracketed URL link
332 !! input
333 ;[http://www.google.com/ Google]:Number one search engine
334 !! result
335 <dl><dt><a href="http://www.google.com/" class='external text' title="http://www.google.com/" rel="nofollow">Google</a></dt><dd>Number one search engine
336 </dd></dl>
337
338 !! end
339
340 !! test
341 Definition list with wikilink containing colon
342 !! input
343 ; [[Help:FAQ]]: The least-read page on Wikipedia
344 !! result
345 <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
346 </dd></dl>
347
348 !! end
349
350 # At Brion's and JeLuF's insistence... :)
351 !! test
352 Definition list with wikilink containing colon
353 !! input
354 ; news:alt.wikipedia.rox: This isn't even a real newsgroup!
355 !! result
356 <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!
357 </dd></dl>
358
359 !! end
360
361 !! test
362 Malformed definition list with colon
363 !! input
364 ; news:alt.wikipedia.rox -- don't crash or enter an infinite loop
365 !! result
366 <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
367 </dt></dl>
368
369 !! end
370
371 !! test
372 Definition lists: colon in external link text
373 !! input
374 ; [http://www.wikipedia2.org/ Wikipedia : The Next Generation]: OK, I made that up
375 !! result
376 <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
377 </dd></dl>
378
379 !! end
380
381
382 ###
383 ### External links
384 ###
385 !! test
386 External links: non-bracketed
387 !! input
388 Non-bracketed: http://example.com
389 !! result
390 <p>Non-bracketed: <a href="http://example.com" class='external free' title="http://example.com" rel="nofollow">http://example.com</a>
391 </p>
392 !! end
393
394 !! test
395 External links: numbered
396 !! input
397 Numbered: [http://example.com]
398 Numbered: [http://example.net]
399 Numbered: [http://example.org]
400 !! result
401 <p>Numbered: <a href="http://example.com" class='external autonumber' title="http://example.com" rel="nofollow">[1]</a>
402 Numbered: <a href="http://example.net" class='external autonumber' title="http://example.net" rel="nofollow">[2]</a>
403 Numbered: <a href="http://example.org" class='external autonumber' title="http://example.org" rel="nofollow">[3]</a>
404 </p>
405 !!end
406
407 !! test
408 External links: specified text
409 !! input
410 Specified text: [http://example.com link]
411 !! result
412 <p>Specified text: <a href="http://example.com" class='external text' title="http://example.com" rel="nofollow">link</a>
413 </p>
414 !!end
415
416 !! test
417 External links: trail
418 !! input
419 Linktrails should not work for external links: [http://example.com link]s
420 !! result
421 <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
422 </p>
423 !! end
424
425 !! test
426 External links: dollar sign in URL
427 !! input
428 http://example.com/1$2345
429 !! result
430 <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>
431 </p>
432 !! end
433
434 !! test
435 External links: dollar sign in URL (named)
436 !! input
437 [http://example.com/1$2345]
438 !! result
439 <p><a href="http://example.com/1$2345" class='external autonumber' title="http://example.com/1$2345" rel="nofollow">[1]</a>
440 </p>
441 !!end
442
443 !! test
444 External links: open square bracket forbidden in URL (bug 4377)
445 !! input
446 http://example.com/1[2345
447 !! result
448 <p><a href="http://example.com/1" class='external free' title="http://example.com/1" rel="nofollow">http://example.com/1</a>[2345
449 </p>
450 !! end
451
452 !! test
453 External links: open square bracket forbidden in URL (named) (bug 4377)
454 !! input
455 [http://example.com/1[2345]
456 !! result
457 <p><a href="http://example.com/1" class='external text' title="http://example.com/1" rel="nofollow">[2345</a>
458 </p>
459 !!end
460
461 !! test
462 External image
463 !! input
464 External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
465 !! result
466 <p>External image: <img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png" />
467 </p>
468 !! end
469
470 !! test
471 External image from https
472 !! input
473 External image from https: https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
474 !! result
475 <p>External image from https: <img src="https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png" />
476 </p>
477 !! end
478
479 !! test
480 Link to non-http image, no img tag
481 !! input
482 Link to non-http image, no img tag: ftp://example.com/test.jpg
483 !! result
484 <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>
485 </p>
486 !! end
487
488 !! test
489 External links: terminating separator
490 !! input
491 Terminating separator: http://example.com/thing,
492 !! result
493 <p>Terminating separator: <a href="http://example.com/thing" class='external free' title="http://example.com/thing" rel="nofollow">http://example.com/thing</a>,
494 </p>
495 !! end
496
497 !! test
498 External links: intervening separator
499 !! input
500 Intervening separator: http://example.com/1,2,3
501 !! result
502 <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>
503 </p>
504 !! end
505
506 !! test
507 External links: old bug with URL in query
508 !! input
509 Old bug with URL in query: [http://example.com/thing?url=http://example.com link]
510 !! result
511 <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>
512 </p>
513 !! end
514
515 !! test
516 External links: old URL-in-URL bug, mixed protocols
517 !! input
518 And again with mixed protocols: [ftp://example.com?url=http://example.com link]
519 !! result
520 <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>
521 </p>
522 !!end
523
524 !! test
525 External links: URL in text
526 !! input
527 URL in text: [http://example.com http://example.com]
528 !! result
529 <p>URL in text: <a href="http://example.com" class='external free' title="http://example.com" rel="nofollow">http://example.com</a>
530 </p>
531 !! end
532
533 !! test
534 External links: Clickable images
535 !! input
536 ja-style clickable images: [http://example.com http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png]
537 !! result
538 <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>
539 </p>
540 !!end
541
542 !! test
543 External links: raw ampersand
544 !! input
545 Old &amp; use: http://x&y
546 !! result
547 <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>
548 </p>
549 !! end
550
551 !! test
552 External links: encoded ampersand
553 !! input
554 Old &amp; use: http://x&amp;y
555 !! result
556 <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>
557 </p>
558 !! end
559
560 !! test
561 External links: [raw ampersand]
562 !! input
563 Old &amp; use: [http://x&y]
564 !! result
565 <p>Old &amp; use: <a href="http://x&amp;y" class='external autonumber' title="http://x&amp;y" rel="nofollow">[1]</a>
566 </p>
567 !! end
568
569 !! test
570 External links: [encoded ampersand]
571 !! input
572 Old &amp; use: [http://x&amp;y]
573 !! result
574 <p>Old &amp; use: <a href="http://x&amp;y" class='external autonumber' title="http://x&amp;y" rel="nofollow">[1]</a>
575 </p>
576 !! end
577
578 !! test
579 External links: www.jpeg.org (bug 554)
580 !! input
581 http://www.jpeg.org
582 !!result
583 <p><a href="http://www.jpeg.org" class='external free' title="http://www.jpeg.org" rel="nofollow">http://www.jpeg.org</a>
584 </p>
585 !! end
586
587 !! test
588 External links: URL within URL (original bug 2)
589 !! input
590 [http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp]
591 !! result
592 <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>
593 </p>
594 !! end
595
596 !! test
597 BUG 361: URL inside bracketed URL
598 !! input
599 [http://www.example.com/foo http://www.example.com/bar]
600 !! result
601 <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>
602 </p>
603 !! end
604
605 !! test
606 BUG 361: URL within URL, not bracketed
607 !! input
608 http://www.example.com/foo?=http://www.example.com/bar
609 !! result
610 <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>
611 </p>
612 !! end
613
614 !! test
615 BUG 289: ">"-token in URL-tail
616 !! input
617 http://www.example.com/<hello>
618 !! result
619 <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;
620 </p>
621 !!end
622
623 !! test
624 BUG 289: literal ">"-token in URL-tail
625 !! input
626 http://www.example.com/<b>html</b>
627 !! result
628 <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>
629 </p>
630 !!end
631
632 !! test
633 BUG 289: ">"-token in bracketed URL
634 !! input
635 [http://www.example.com/<hello> stuff]
636 !! result
637 <p><a href="http://www.example.com/" class='external text' title="http://www.example.com/" rel="nofollow">&lt;hello&gt; stuff</a>
638 </p>
639 !!end
640
641 !! test
642 BUG 289: literal ">"-token in bracketed URL
643 !! input
644 [http://www.example.com/<b>html</b> stuff]
645 !! result
646 <p><a href="http://www.example.com/" class='external text' title="http://www.example.com/" rel="nofollow"><b>html</b> stuff</a>
647 </p>
648 !!end
649
650 !! test
651 BUG 289: literal double quote at end of URL
652 !! input
653 http://www.example.com/"hello"
654 !! result
655 <p><a href="http://www.example.com/" class='external free' title="http://www.example.com/" rel="nofollow">http://www.example.com/</a>"hello"
656 </p>
657 !!end
658
659 !! test
660 BUG 289: literal double quote in bracketed URL
661 !! input
662 [http://www.example.com/"hello" stuff]
663 !! result
664 <p><a href="http://www.example.com/" class='external text' title="http://www.example.com/" rel="nofollow">"hello" stuff</a>
665 </p>
666 !!end
667
668 !! test
669 External links: invalid character
670 !! input
671 [http://www.example.com