Update git submodules
[mediawiki.git] / tests / parser / pst.txt
blob8e23be63022f7391f4d4c48ccccc91f9bdcb6e32
1 # The parsoid-compatible option below is only relevant when we are running
2 # parser tests in integrated mode with Parsoid. This option is ignored
3 # when this test file is run with Parsoid in standalone mode.
4 !! options
5 parsoid-compatible=wt2html,wt2wt
6 version=2
7 !! end
9 !! article
10 Template:test
11 !! text
12 This is a test template
13 !! endarticle
15 !! article
16 Template:paramtest
17 !! text
18 This is a test template with parameter {{{param}}}
19 !! endarticle
21 !! article
22 Template:Includes
23 !! text
24 Foo<noinclude>zar</noinclude><includeonly>bar</includeonly>
25 !! endarticle
27 !! article
28 Template:Includes2
29 !! text
30 <onlyinclude>Foo</onlyinclude>bar
31 !! endarticle
33 !! test
34 pre-save transform: subst:
35 !! options
36 pst
37 !! wikitext
38 {{subst:test}}
39 !! html/php
40 This is a test template
41 !! end
43 !! test
44 pre-save transform: normal template
45 !! options
46 pst
47 !! wikitext
48 {{test}}
49 !! html/php
50 {{test}}
51 !! end
53 !! test
54 pre-save transform: nonexistent template
55 !! options
56 pst
57 !! wikitext
58 {{thistemplatedoesnotexist}}
59 !! html/php
60 {{thistemplatedoesnotexist}}
61 !! end
63 !! test
64 pre-save transform: subst magic variables
65 !! options
66 pst
67 !! wikitext
68 {{subst:SITENAME}}
69 !! html/php
70 MediaWiki
71 !! end
73 # This is T2089, which I fixed. -- wtm
74 !! test
75 pre-save transform: subst: templates with parameters
76 !! options
77 pst
78 !! wikitext
79 {{subst:paramtest|param="something else"}}
80 !! html/php
81 This is a test template with parameter "something else"
82 !! end
84 !! article
85 Template:nowikitest
86 !! text
87 <nowiki>'''not wiki'''</nowiki>
88 !! endarticle
90 !! test
91 pre-save transform: nowiki in subst (T3188)
92 !! options
93 pst
94 !! wikitext
95 {{subst:nowikitest}}
96 !! html/php
97 <nowiki>'''not wiki'''</nowiki>
98 !! end
100 !! article
101 Template:commenttest
102 !! text
103 This template has <!-- a comment --> in it.
104 !! endarticle
106 !! test
107 pre-save transform: comment in subst (T3936)
108 !! options
110 !! wikitext
111 {{subst:commenttest}}
112 !! html/php
113 This template has <!-- a comment --> in it.
114 !! end
116 !! test
117 pre-save transform: unclosed tag
118 !! options
120 !! wikitext
121 <nowiki>'''not wiki'''
122 !! html/php
123 <nowiki>'''not wiki'''
124 !! end
126 !! test
127 pre-save transform: mixed tag case
128 !! options
130 !! wikitext
131 <NOwiki>'''not wiki'''</noWIKI>
132 !! html/php
133 <NOwiki>'''not wiki'''</noWIKI>
134 !! end
136 !! test
137 pre-save transform: unclosed comment in <nowiki>
138 !! options
140 !! wikitext
141 wiki<nowiki>nowiki<!--nowiki</nowiki>wiki
142 !! html/php
143 wiki<nowiki>nowiki<!--nowiki</nowiki>wiki
144 !!end
146 # Leading @ in this template definition works around a limitation
147 # in parsoid's parserTests which otherwise strips the <span> from the
148 # result (confusing it for a template wrapper)
149 !! article
150 Template:dangerous
151 !!text
152 @<span onmouseover="alert('crap')">Oh no</span>
153 !!endarticle
155 !!test
156 (confirming safety of fix for subst T3936)
157 !! wikitext
158 {{Template:dangerous}}
159 !! html
160 <p>@<span>Oh no</span>
161 </p>
162 !! end
164 !! test
165 pre-save transform: comment containing gallery (T7024)
166 !! options
168 !! wikitext
169 <!-- <gallery>data</gallery> -->
170 !! html/php
171 <!-- <gallery>data</gallery> -->
172 !!end
174 !! test
175 pre-save transform: comment containing extension
176 !! options
178 !! wikitext
179 <!-- <tag>data</tag> -->
180 !! html/php
181 <!-- <tag>data</tag> -->
182 !!end
184 !! test
185 pre-save transform: comment containing nowiki
186 !! options
188 !! wikitext
189 <!-- <nowiki>data</nowiki> -->
190 !! html/php
191 <!-- <nowiki>data</nowiki> -->
192 !!end
194 !! test
195 pre-save transform: <noinclude> in subst (T5298)
196 !! options
198 !! wikitext
199 {{subst:Includes}}
200 !! html/php
201 Foobar
202 !! end
204 !! test
205 pre-save transform: <onlyinclude> in subst (T5298)
206 !! options
208 !! wikitext
209 {{subst:Includes2}}
210 !! html/php
212 !! end
214 !! article
215 Template:SubstTest
216 !!text
217 {{<includeonly>subst:</includeonly>Includes}}
218 !! endarticle
220 !! article
221 Template:SafeSubstTest
222 !! text
223 {{<includeonly>safesubst:</includeonly>Includes}}
224 !! endarticle
226 !! article
227 Template:SafeSubstSelfTest
228 !! text
229 {{safesubst:SafeSubstSelfTest}}
230 !! endarticle
232 !! article
233 Template:safesubst
234 !! text
235 {{{1}}}
236 !! endarticle
238 !! article
239 Template:ROOTPAGENAME
240 !! text
241 NotTheVariable
242 !! endarticle
244 !! test
245 T24297: safesubst: works during PST
246 !! options
248 !! wikitext
249 {{subst:SafeSubstTest}}{{safesubst:SubstTest}}
250 !! html/php
251 FoobarFoobar
252 !! end
254 !! test
255 T24297: safesubst: works during normal parse
256 !! wikitext
257 {{SafeSubstTest}}
258 !! html
259 <p>Foobar
260 </p>
261 !! end
263 !! test
264 subst: does not work during normal parse
265 !! wikitext
266 {{SubstTest}}
267 !! html
268 <p>{{subst:Includes}}
269 </p>
270 !! html/parsoid+integrated
271 <p><span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"SubstTest","href":"./Template:SubstTest"},"params":{},"i":0}}]}'>{{subst:Includes}}</span></p>
272 !! end
274 !! test
275 safesubst self: does not work during normal parse - T276476
276 !! options
277 pst title=[[Template:SafeSubstSelfTest]]
278 !! wikitext
279 {{SafeSubstSelfTest}}
280 !! html/php
281 {{SafeSubstSelfTest}}
282 !! end
284 ## Non-PST test
285 !! test
286 Template named safesubst - T309405
287 !! wikitext
288 {{safesubst|123}}
289 !! html/php
290 <p>123
291 </p>
292 !! html/parsoid
293 <p><span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"safesubst","href":"./Template:Safesubst"},"params":{"1":{"wt":"123"}},"i":0}}]}'>123</span></p>
294 !! end
296 !! test
297 subst: with whitespace - variable vs. template
298 !! options
299 pst title=[[TestSubstVariable]]
300 !! wikitext
301 Variable: {{subst: ROOTPAGENAME}}
302 Variable: {{subst:ROOTPAGENAME}}
303 Template: {{subst: ROOTPAGENAME|template}}
304 Template: {{subst:ROOTPAGENAME|template}}
305 !! html/php
306 Variable: TestSubstVariable
307 Variable: TestSubstVariable
308 Template: NotTheVariable
309 Template: NotTheVariable
310 !! end
312 !! test
313 pre-save transform: context links ("pipe trick")
314 !! options
316 !! wikitext
317 [[Article (context)|]]
318 [[Bar:Article|]]
319 [[:Bar:Article|]]
320 [[Bar:Article (context)|]]
321 [[:Bar:Article (context)|]]
322 [[|Article]]
323 [[|Article (context)]]
324 [[Bar:X (Y) Z|]]
325 [[:Bar:X (Y) Z|]]
326 !! html/php
327 [[Article (context)|Article]]
328 [[Bar:Article|Article]]
329 [[:Bar:Article|Article]]
330 [[Bar:Article (context)|Article]]
331 [[:Bar:Article (context)|Article]]
332 [[Article]]
333 [[Article (context)]]
334 [[Bar:X (Y) Z|X (Y) Z]]
335 [[:Bar:X (Y) Z|X (Y) Z]]
336 !! end
338 !! test
339 pre-save transform: context links ("pipe trick") with interwiki prefix
340 !! options
342 !! wikitext
343 [[interwiki:Article|]]
344 [[:interwiki:Article|]]
345 [[interwiki:Bar:Article|]]
346 [[:interwiki:Bar:Article|]]
347 !! html/php
348 [[interwiki:Article|Article]]
349 [[:interwiki:Article|Article]]
350 [[interwiki:Bar:Article|Bar:Article]]
351 [[:interwiki:Bar:Article|Bar:Article]]
352 !! end
354 !! test
355 pre-save transform: context links ("pipe trick") with parens in title
356 !! options
357 pst title=[[Somearticle (context)]]
358 !! wikitext
359 [[|Article]]
360 !! html/php
361 [[Article (context)|Article]]
362 !! end
364 !! test
365 pre-save transform: context links ("pipe trick") with single, double-width and Arabic comma in title
366 !! options
367 pst title=[[Someplace, Somewhere]]
368 !! wikitext
369 [[|Otherplace]]
370 [[Otherplace, Elsewhere|]]
371 [[Otherplace, Elsewhere, Anywhere|]]
372 [[Otherplace,Elsewhere|]]
373 [[Otherplace، Elsewhere|]]
374 !! html/php
375 [[Otherplace, Somewhere|Otherplace]]
376 [[Otherplace, Elsewhere|Otherplace]]
377 [[Otherplace, Elsewhere, Anywhere|Otherplace]]
378 [[Otherplace,Elsewhere|Otherplace]]
379 [[Otherplace، Elsewhere|Otherplace]]
380 !! end
382 !! test
383 pre-save transform: context links ("pipe trick") with parens and comma
384 !! options
385 pst title=[[Someplace (IGNORED), Somewhere]]
386 !! wikitext
387 [[|Otherplace]]
388 [[Otherplace (place), Elsewhere|]]
389 !! html/php
390 [[Otherplace, Somewhere|Otherplace]]
391 [[Otherplace (place), Elsewhere|Otherplace]]
392 !! end
394 !! test
395 pre-save transform: context links ("pipe trick") with comma and parens
396 !! options
397 pst title=[[Who, me? (context)]]
398 !! wikitext
399 [[|Yes, you.]]
400 [[Me, Myself, and I (1937 song)|]]
401 !! html/php
402 [[Yes, you. (context)|Yes, you.]]
403 [[Me, Myself, and I (1937 song)|Me, Myself, and I]]
404 !! end
406 !! test
407 pre-save transform: context links ("pipe trick") with namespace
408 !! options
409 pst title=[[Ns:Somearticle]]
410 !! wikitext
411 [[|Article]]
412 !! html/php
413 [[Ns:Article|Article]]
414 !! end
416 !! test
417 pre-save transform: context links ("pipe trick") with namespace and parens
418 !! options
419 pst title=[[Ns:Somearticle (context)]]
420 !! wikitext
421 [[|Article]]
422 !! html/php
423 [[Ns:Article (context)|Article]]
424 !! end
426 !! test
427 pre-save transform: context links ("pipe trick") with namespace and comma
428 !! options
429 pst title=[[Ns:Somearticle, Context, Whatever]]
430 !! wikitext
431 [[|Article]]
432 !! html/php
433 [[Ns:Article, Context, Whatever|Article]]
434 !! end
436 !! test
437 pre-save transform: context links ("pipe trick") with namespace, comma and parens
438 !! options
439 pst title=[[Ns:Somearticle, Context (context)]]
440 !! wikitext
441 [[|Article]]
442 !! html/php
443 [[Ns:Article (context)|Article]]
444 !! end
446 !! test
447 pre-save transform: context links ("pipe trick") with namespace, parens and comma
448 !! options
449 pst title=[[Ns:Somearticle (IGNORED), Context]]
450 !! wikitext
451 [[|Article]]
452 !! html/php
453 [[Ns:Article, Context|Article]]
454 !! end
456 !! test
457 pre-save transform: context links ("pipe trick") with full-width parens and no space (Japanese and Chinese style, T32149)
458 !! options
460 !! wikitext
461 [[Article(context)|]]
462 [[Bar:Article(context)|]]
463 [[:Bar:Article(context)|]]
464 [[|Article(context)]]
465 [[Bar:X(Y)Z|]]
466 [[:Bar:X(Y)Z|]]
467 !! html/php
468 [[Article(context)|Article]]
469 [[Bar:Article(context)|Article]]
470 [[:Bar:Article(context)|Article]]
471 [[Article(context)]]
472 [[Bar:X(Y)Z|X(Y)Z]]
473 [[:Bar:X(Y)Z|X(Y)Z]]
474 !! end
476 !! test
477 pre-save transform: context links ("pipe trick") with full-width parens and space (Japanese and Chinese style, T32149)
478 !! options
480 !! wikitext
481 [[Article (context)|]]
482 [[Bar:Article (context)|]]
483 [[:Bar:Article (context)|]]
484 [[|Article (context)]]
485 [[Bar:X (Y) Z|]]
486 [[:Bar:X (Y) Z|]]
487 !! html/php
488 [[Article (context)|Article]]
489 [[Bar:Article (context)|Article]]
490 [[:Bar:Article (context)|Article]]
491 [[Article (context)]]
492 [[Bar:X (Y) Z|X (Y) Z]]
493 [[:Bar:X (Y) Z|X (Y) Z]]
494 !! end
496 !! test
497 pre-save transform: context links ("pipe trick") with parens and no space (Korean style, T32149)
498 !! options
500 !! wikitext
501 [[Article(context)|]]
502 [[Bar:Article(context)|]]
503 [[:Bar:Article(context)|]]
504 [[|Article(context)]]
505 [[Bar:X(Y)Z|]]
506 [[:Bar:X(Y)Z|]]
507 !! html/php
508 [[Article(context)|Article]]
509 [[Bar:Article(context)|Article]]
510 [[:Bar:Article(context)|Article]]
511 [[Article(context)]]
512 [[Bar:X(Y)Z|X(Y)Z]]
513 [[:Bar:X(Y)Z|X(Y)Z]]
514 !! end
516 !! test
517 pre-save transform: context links ("pipe trick") with commas (T23660)
518 !! options
520 !! wikitext
521 [[Article (context), context|]]
522 [[Article (context),context|]]
523 [[Bar:Article (context), context|]]
524 [[Bar:Article (context),context|]]
525 [[:Bar:Article (context), context|]]
526 [[:Bar:Article (context),context|]]
527 !! html/php
528 [[Article (context), context|Article]]
529 [[Article (context),context|Article]]
530 [[Bar:Article (context), context|Article]]
531 [[Bar:Article (context),context|Article]]
532 [[:Bar:Article (context), context|Article]]
533 [[:Bar:Article (context),context|Article]]
534 !! end
536 !! test
537 Parsoid: backwards pipe trick
538 !! wikitext
539 [[|'''bar''']]
540 !! html/php
541 <p>[[|<b>bar</b>]]
542 </p>
543 !! html/parsoid
544 <p>[[|<b>bar</b>]]</p>
545 !! end
547 !! test
548 pre-save transform: trim trailing empty lines
549 !! options
551 !! wikitext
552 Empty lines are trimmed
557 !! html/php
558 Empty lines are trimmed
559 !! end
561 !! test
562 pre-save transform: Signature expansion
563 !! options
565 !! wikitext
566 * ~~~
567 * ~~~~
568 * ~~~~~
569 * <noinclude>~~~</noinclude>
570 * <includeonly>~~~</includeonly>
571 * <onlyinclude>~~~</onlyinclude>
572 !! html/php
573 * [[Special:Contributions/127.0.0.1|127.0.0.1]]
574 * [[Special:Contributions/127.0.0.1|127.0.0.1]] 00:02, 1 January 1970 (UTC)
575 * 00:02, 1 January 1970 (UTC)
576 * <noinclude>[[Special:Contributions/127.0.0.1|127.0.0.1]]</noinclude>
577 * <includeonly>[[Special:Contributions/127.0.0.1|127.0.0.1]]</includeonly>
578 * <onlyinclude>[[Special:Contributions/127.0.0.1|127.0.0.1]]</onlyinclude>
579 !! end
582 !! test
583 ParserOutput flags from signature expansion (T84843)
584 !! options
586 showflags
587 !! wikitext
588 ~~~~
589 !! metadata
590 flags=user-signature
591 !! html/php
592 [[Special:Contributions/127.0.0.1|127.0.0.1]] 00:02, 1 January 1970 (UTC)
593 !! end
595 !! test
596 pre-save transform: Signature expansion in nowiki tags (T2093)
597 !! options
598 pst disabled
599 !! wikitext
600 Shall not expand:
602 <nowiki>~~~~</nowiki>
604 <includeonly><nowiki>~~~~</nowiki></includeonly>
606 <noinclude><nowiki>~~~~</nowiki></noinclude>
608 <onlyinclude><nowiki>~~~~</nowiki></onlyinclude>
610 {{subst:Foo}} shall be converted to FOO
612 As well as inside noinclude/onlyinclude
613 <noinclude>{{subst:Foo}}</noinclude>
614 <onlyinclude>{{subst:Foo}}</onlyinclude>
616 But not inside includeonly
617 <includeonly>{{subst:Foo}}</includeonly>
618 !! html/php
619 Shall not expand:
621 <nowiki>~~~~</nowiki>
623 <includeonly><nowiki>~~~~</nowiki></includeonly>
625 <noinclude><nowiki>~~~~</nowiki></noinclude>
627 <onlyinclude><nowiki>~~~~</nowiki></onlyinclude>
629 FOO shall be converted to FOO
631 As well as inside noinclude/onlyinclude
632 <noinclude>FOO</noinclude>
633 <onlyinclude>FOO</onlyinclude>
635 But not inside includeonly
636 <includeonly>{{subst:Foo}}</includeonly>
637 !! end
639 !! test
640 Parsoid: Recognize nowiki with trailing space in tags
641 !! options
642 parsoid=wt2html
643 !! wikitext
644 <nowiki ><div>[[foo]]</nowiki >
646 a<nowiki / >b
648 c<nowiki />d
650 e<nowiki/ >f
651 !! html/php
652 <p>&lt;div&gt;[[foo]]
653 </p><p>a&lt;nowiki / &gt;b
654 </p><p>cd
655 </p><p>e&lt;nowiki/ &gt;f
656 </p>
657 !! html/parsoid
658 <p><span typeof="mw:Nowiki">&lt;div>[[foo]]</span></p>
660 <p>a&lt;nowiki / >b</p>
662 <p>c<span typeof="mw:Nowiki"></span>d</p>
664 <p>e&lt;nowiki/ >f</p>
665 !! end
667 !! test
668 Category with empty sort key
669 !! options
672 !! wikitext
673 [[Category:MediaWiki User's Guide|]]
674 !! html/php
675 [[Category:MediaWiki User's Guide|MediaWiki User's Guide]]
676 !! end
678 !! test
679 Category with empty sort key and parentheses
680 !! options
683 !! wikitext
684 [[Category:Foo (bar)|]]
685 !! html/php
686 [[Category:Foo (bar)|Foo]]
687 !! end
689 !! test
690 Category with link tail
691 !! options
694 !! wikitext
695 123[[Category:Foo]]456
696 !! html/php
697 123[[Category:Foo]]456
698 !! end
700 !! test
701 Category with template
702 !! options
705 !! wikitext
706 [[Category:{{1x|Foo}}]]
707 !! html/php
708 [[Category:{{1x|Foo}}]]
709 !! end
711 !! test
712 Category with template in sort key
713 !! options
716 !! wikitext
717 [[Category:Foo|{{1x|Bar}}]]
718 !! html/php
719 [[Category:Foo|{{1x|Bar}}]]
720 !! end
722 !! test
723 Category with template in sort key and title
724 !! options
727 !! wikitext
728 [[Category:{{1x|Foo}}|{{1x|Bar}}]]
729 !! html/php
730 [[Category:{{1x|Foo}}|{{1x|Bar}}]]
731 !! end
733 !! test
734 Tildes in comments
735 !! options
737 !! wikitext
738 <!-- ~~~~ -->
739 !! html/php
740 <!-- ~~~~ -->
741 !! end