Fix link prefix/suffixes around Category and Language links (take 2).
[lhc/web/wiklou.git] / tests / parser / parserTests.txt
1 # MediaWiki Parser test cases
2 # Some taken from https://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 # (ignored by Parsoid, since it emits <link>s)
18 # ill add inter-language links
19 # (ignored by Parsoid, since it emits <link>s)
20 # subpage enable subpages (disabled by default)
21 # title=[[XXX]] run test using article title XXX
22 # language=XXX set content language to XXX for this test
23 # variant=XXX set the variant of language for this test (eg zh-tw)
24 # disabled do not run test
25 # parsoid parsoid-specific options (not run by PHP parser unless
26 # the test includes an html/php section)
27 # php php-only test (not run by the parsoid parser unless
28 # the test includes an html/parsoid section)
29 # showtitle make the first line the title
30 # showindicators make the first lines the page status indicators
31 # comment run through Linker::formatComment() instead of main parser
32 # local format section links in edit comment text as local links
33 # notoc disable table of contents
34 # thumbsize=NNN set the default thumb size to NNNpx for this test
35 # wrap include the normal wrapper <div class="mw-parser-output"> (since 1.30)
36 #
37 # You can also set the following parser properties via test options:
38 # wgEnableUploads, wgAllowExternalImages, wgMaxTocLevel,
39 # wgLinkHolderBatchSize, wgRawHtml, wgInterwikiMagic,
40 # wgEnableMagicLinks
41 #
42 # For testing purposes, temporary articles can created:
43 # !!article / NAMESPACE:TITLE / !!text / ARTICLE TEXT / !!endarticle
44 # where '/' denotes a newline.
45
46 # This is the standard article assumed to exist.
47 !! article
48 Main Page
49 !! text
50 blah blah
51 !! endarticle
52
53 !!article
54 Foo
55 !!text
56 FOO
57 !!endarticle
58
59 !!article
60 Template:Foo
61 !!text
62 FOO
63 !!endarticle
64
65 !! article
66 Template:Blank
67 !! text
68 !! endarticle
69
70 !! article
71 Template:pipe
72 !! text
73 |
74 !! endarticle
75
76 !! article
77 Template:=
78 !! text
79 <nowiki>=</nowiki>
80 !! endarticle
81
82 !!article
83 MediaWiki:bad image list
84 !!text
85 * [[File:Bad.jpg]] except [[Nasty page]]
86 !!endarticle
87
88 !! article
89 Template:inner list
90 !! text
91 * item 1
92 !! endarticle
93
94 !! article
95 Template:tbl-start
96 !! text
97 {|
98 !! endarticle
99
100 !! article
101 Template:tbl-end
102 !! text
103 |}
104 !! endarticle
105
106 !! article
107 Template:echo
108 !! text
109 {{{1}}}
110 !! endarticle
111
112 // For Serbian; localize Template namespace
113 !! article
114 Шаблон:Echo
115 !! text
116 {{{1}}}
117 !! endarticle
118
119 !! article
120 Template:echo_with_span
121 !! text
122 <span>{{{1}}}</span>
123 !! endarticle
124
125 !! article
126 Template:echo_with_div
127 !! text
128 <div>{{{1}}}</div>
129 !! endarticle
130
131 !! article
132 Template:blank_param
133 !! text
134 {{{1}}}
135 {{{}}}
136 !! endarticle
137
138 !! article
139 Template:table_attribs
140 !! text
141 <noinclude>
142 |</noinclude>style="color:red;"|Foo
143 !! endarticle
144
145 !! article
146 Template:table_attribs_2
147 !! text
148 <noinclude>
149 |</noinclude>style="color:red;"|Foo
150 |Bar||Baz
151 !! endarticle
152
153 !! article
154 Template:table_attribs_3
155 !! text
156 <noinclude>
157 |</noinclude>style{{=}}"background:&#35;f9f9f9;"|Foo
158 !! endarticle
159
160 !! article
161 Template:table_attribs_4
162 !! text
163 | style="background-color:#DC241f;" width="10px" |
164 !! endarticle
165
166 !! article
167 Template:table_attribs_5
168 !! text
169 <noinclude>
170 |</noinclude>style="color:red;"||Bar
171 !! endarticle
172
173 !! article
174 Template:table_attribs_6
175 !! text
176 style="background: <nowiki>
177
178
179 red;</nowiki>" |
180 !! endarticle
181
182 !! article
183 Template:table_attribs_7
184 !! text
185 <noinclude>
186 |</noinclude>style{{=}}"background:&#35;f9f9f9;"|Foo<ref>foo</ref>
187 !! endarticle
188
189 !! article
190 Template:table_header_cells
191 !! text
192 {{table_attribs}}!!style='color:red;'|''Bar''||style='color:brown;'|''Foo'' and Baz
193 !! endarticle
194
195 !! article
196 Template:table_cells
197 !! text
198 {{table_attribs}}||style='color:red;'|''Bar''||style='color:brown;'|''Foo'' and Baz
199 !! endarticle
200
201 !! article
202 Template:PartialTable
203 !! text
204 {|
205 |-
206 !! endarticle
207
208 !! article
209 Template:image_attribs
210 !! text
211 <noinclude>
212 [[File:foobar.jpg|</noinclude>right|Caption text<noinclude>]]</noinclude>
213 !! endarticle
214
215 ## See T48811 for details
216 !! article
217 Template:mixed_attr_content_template
218 !! text
219 style="color:red;" title="T48811"
220 |-
221 |foo
222 !! endarticle
223
224 !! article
225 Template:definition_list
226 !! text
227 one
228 ::two
229 !! endarticle
230
231 !! article
232 A?b
233 !! text
234 Weirdo titles!
235 !! endarticle
236
237 !!article
238 Template:Bullet
239 !!text
240 * Bar
241 !!endarticle
242
243 !!article
244 Template:OpenTable
245 !!text
246 {|
247 !!endarticle
248
249 !!article
250 Template:EmptyLITest
251 !!text
252 *a
253 *
254 *
255 *b
256 !!endarticle
257
258 !!article
259 Template:EmptyTRTest
260 !!text
261 {|
262 |-
263 |-
264 |foo
265 |-
266 |-
267 |bar
268 |}
269 !!endarticle
270
271 !!article
272 Template:EmptyTRWithHTMLAttrTest
273 !!text
274 <table>
275 <tr align="center"></tr>
276 <tr><td>foo</td></tr>
277 <tr align="center"></tr>
278 <tr><td>bar</td></tr>
279 </table>
280 !!endarticle
281
282 !! article
283 Template:CircularRef
284 !! text
285 <ref>{{CircularRef}}</ref>
286 !! endarticle
287
288 !! article
289 Template:With: Colon
290 !! text
291 Template with colon
292 !! endarticle
293
294 ###
295 ### Basic tests
296 ###
297 !! test
298 Blank input
299 !! wikitext
300 !! html
301 !! end
302
303 !! test
304 CircularRef
305 !! wikitext
306 {{CircularRef}}
307 <references />
308 !! html/parsoid
309 <p><span about="#mwt1" class="mw-ref" id="cite_ref-1" rel="dc:references" typeof="mw:Transclusion mw:Extension/ref" data-parsoid='{"pi":[[]]}' data-mw='{"parts":[{"template":{"target":{"wt":"CircularRef","href":"./Template:CircularRef"},"params":{},"i":0}}]}'><a href="./Main_Page#cite_note-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></span></p>
310 <ol class="mw-references" typeof="mw:Extension/references" about="#mwt6" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text" data-parsoid="{}">Error: Expansion loop detected at <a data-parsoid='{"a":{"href":null},"sa":{"href":"Template:CircularRef"}}'>Template:CircularRef</a></span></li></ol>
311 !! end
312
313 !! test
314 Simple paragraph
315 !! wikitext
316 This is a simple paragraph.
317 !! html
318 <p>This is a simple paragraph.
319 </p>
320 !! end
321
322 !! test
323 Paragraphs with extra newline spacing
324 !! wikitext
325 foo
326
327 bar
328
329
330 baz
331
332
333
334 booz
335 !! html
336 <p>foo
337 </p><p>bar
338 </p><p><br />
339 baz
340 </p><p><br />
341 </p><p>booz
342 </p>
343 !! end
344
345 !! test
346 Paragraphs with newline spacing with comment lines in between
347 !! wikitext
348 ----
349 a
350 <!--foo-->
351 b
352 ----
353 a
354 <!--foo--><!--More than 1 comment, still stripped-->
355 b
356 ----
357 a
358 <!--foo--> <!----> <!-- bar -->
359 b
360 ----
361 a
362 <!--foo-->
363
364 b
365 ----
366 a
367
368 <!--foo-->
369 b
370 ----
371 a
372 <!--foo-->
373
374
375 b
376 ----
377 a
378
379
380 <!--foo-->
381 b
382 ----
383 !! html
384 <hr />
385 <p>a
386 b
387 </p>
388 <hr />
389 <p>a
390 b
391 </p>
392 <hr />
393 <p>a
394 b
395 </p>
396 <hr />
397 <p>a
398 </p><p>b
399 </p>
400 <hr />
401 <p>a
402 </p><p>b
403 </p>
404 <hr />
405 <p>a
406 </p><p><br />
407 b
408 </p>
409 <hr />
410 <p>a
411 </p><p><br />
412 b
413 </p>
414 <hr />
415
416 !! end
417
418 !! test
419 Paragraphs with newline spacing with non-empty white-space lines in between
420 !! wikitext
421 ----
422 a
423
424 b
425 ----
426 a
427
428
429 b
430 ----
431 !! html
432 <hr />
433 <p>a
434 </p><p>b
435 </p>
436 <hr />
437 <p>a
438 </p><p><br />
439 b
440 </p>
441 <hr />
442
443 !! end
444
445 !! test
446 Paragraphs with newline spacing with non-empty mixed comment and white-space lines in between
447 !! wikitext
448 ----
449 a
450 <!--foo-->
451 b
452 ----
453 a
454 <!--foo--><!--More than 1 comment doesn't disable stripping of this line!-->
455 b
456 ----
457 a
458
459 <!--foo-->
460 <!--bar-->
461 b
462 ----
463 a
464
465 <!--foo-->
466 <!--bar-->
467
468 b
469 ----
470 !! html
471 <hr />
472 <p>a
473 b
474 </p>
475 <hr />
476 <p>a
477 b
478 </p>
479 <hr />
480 <p>a
481 </p><p>b
482 </p>
483 <hr />
484 <p>a
485 </p><p><br />
486 b
487 </p>
488 <hr />
489
490 !! end
491
492 !! test
493 Extra newlines: More paragraphs with indented comment
494 !! wikitext
495 a
496
497 <!--boo-->
498
499 b
500 !! html
501 <p>a
502 </p><p><br />
503 b
504 </p>
505 !!end
506
507 !! test
508 Extra newlines followed by heading
509 !! wikitext
510 a
511
512
513
514 =b=
515 [[a]]
516
517
518 =b=
519 !! html
520 <p>a
521 </p><p><br />
522 </p>
523 <h1><span class="mw-headline" id="b">b</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: b">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
524 <p><a href="/index.php?title=A&amp;action=edit&amp;redlink=1" class="new" title="A (page does not exist)">a</a>
525 </p><p><br />
526 </p>
527 <h1><span class="mw-headline" id="b_2">b</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: b">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
528
529 !! end
530
531 !! test
532 Extra newlines between heading and content are swallowed
533 !! wikitext
534 =b=
535
536
537
538 [[a]]
539 !! html
540 <h1><span class="mw-headline" id="b">b</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: b">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
541 <p><a href="/index.php?title=A&amp;action=edit&amp;redlink=1" class="new" title="A (page does not exist)">a</a>
542 </p>
543 !! end
544
545 !! test
546 Heading with line break in nowiki
547 !! options
548 parsoid=wt2html
549 !! wikitext
550 == A <nowiki>B
551 C</nowiki> ==
552 !! html
553 <h2><span class="mw-headline" id="A_B.0AC">A B
554 C</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: A B&#10;C">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
555
556 !! html/parsoid
557 <h2 id="A_B.0AC">A <span typeof="mw:Nowiki">B
558 C</span> </h2>
559 !! end
560
561 !! test
562 Parsing an URL
563 !! wikitext
564 http://fr.wikipedia.org/wiki/🍺
565 <!-- EasterEgg we love beer, better be able be able to link to it -->
566 !! html
567 <p><a rel="nofollow" class="external free" href="http://fr.wikipedia.org/wiki/🍺">http://fr.wikipedia.org/wiki/🍺</a>
568 </p>
569 !! end
570
571 # Note that the html+tidy output removes the spaces after the <li>,
572 # which is a bug (https://sourceforge.net/p/tidy/bugs/945/, etc).
573 # This is an issue for all tests with lists. We intentionally do
574 # *not* add html+tidy clauses for these, as we don't want to
575 # document/test the broken behavior. (Parsoid matches the non-tidy
576 # output in these cases.)
577
578 !! test
579 Simple list
580 !! wikitext
581 * Item 1
582 * Item 2
583 !! html
584 <ul><li> Item 1</li>
585 <li> Item 2</li></ul>
586
587 !! end
588
589 !! test
590 Italics and bold
591 !! wikitext
592 * plain
593 * plain''italic''plain
594 * plain''italic''plain''italic''plain
595 * plain'''bold'''plain
596 * plain'''bold'''plain'''bold'''plain
597 * plain''italic''plain'''bold'''plain
598 * plain'''bold'''plain''italic''plain
599 * plain''italic'''bold-italic'''italic''plain
600 * plain'''bold''bold-italic''bold'''plain
601 * plain'''''bold-italic'''italic''plain
602 * plain'''''bold-italic''bold'''plain
603 * plain''italic'''bold-italic'''''plain
604 * plain'''bold''bold-italic'''''plain
605 * plain l'''italic''plain
606 * plain l''''bold''' plain
607 !! html
608 <ul><li> plain</li>
609 <li> plain<i>italic</i>plain</li>
610 <li> plain<i>italic</i>plain<i>italic</i>plain</li>
611 <li> plain<b>bold</b>plain</li>
612 <li> plain<b>bold</b>plain<b>bold</b>plain</li>
613 <li> plain<i>italic</i>plain<b>bold</b>plain</li>
614 <li> plain<b>bold</b>plain<i>italic</i>plain</li>
615 <li> plain<i>italic<b>bold-italic</b>italic</i>plain</li>
616 <li> plain<b>bold<i>bold-italic</i>bold</b>plain</li>
617 <li> plain<i><b>bold-italic</b>italic</i>plain</li>
618 <li> plain<b><i>bold-italic</i>bold</b>plain</li>
619 <li> plain<i>italic<b>bold-italic</b></i>plain</li>
620 <li> plain<b>bold<i>bold-italic</i></b>plain</li>
621 <li> plain l'<i>italic</i>plain</li>
622 <li> plain l'<b>bold</b> plain</li></ul>
623
624 !! end
625
626 # this example taken from the [[simple:Moon]] article (T49326)
627 !! test
628 Italics and possessives (1)
629 !! wikitext
630 obtained by ''[[Lunar Prospector]]'''s gamma-ray spectrometer
631 !! html
632 <p>obtained by <i><a href="/index.php?title=Lunar_Prospector&amp;action=edit&amp;redlink=1" class="new" title="Lunar Prospector (page does not exist)">Lunar Prospector</a>'</i>s gamma-ray spectrometer
633 </p>
634 !! end
635
636 # this example taken from [[en:Flaming Pie]] (T51926)
637 !! test
638 Italics and possessives (2)
639 !! wikitext
640 '''''Flaming Pie''''' is ... released in 1997. In ''Flaming Pie'''s liner notes
641 !! html
642 <p><i><b>Flaming Pie</b></i> is ... released in 1997. In <i>Flaming Pie'</i>s liner notes
643 </p>
644 !! end
645
646 # this example taken from [[en:Dictionary]] (T51926)
647 !! test
648 Italics and possessives (3)
649 !! wikitext
650 The first monolingual dictionary written in a Romance language was ''Sebastián Covarrubias''' ''Tesoro de la lengua castellana o española'', published in 1611 in Madrid. In 1612 the first edition of the ''Vocabolario dell'[[Accademia della Crusca]]'', for Italian, was published. In 1690 in Rotterdam was published, posthumously, the ''Dictionnaire Universel''.
651 !! html
652 <p>The first monolingual dictionary written in a Romance language was <i>Sebastián Covarrubias'</i> <i>Tesoro de la lengua castellana o española</i>, published in 1611 in Madrid. In 1612 the first edition of the <i>Vocabolario dell'<a href="/index.php?title=Accademia_della_Crusca&amp;action=edit&amp;redlink=1" class="new" title="Accademia della Crusca (page does not exist)">Accademia della Crusca</a></i>, for Italian, was published. In 1690 in Rotterdam was published, posthumously, the <i>Dictionnaire Universel</i>.
653 </p>
654 !! end
655
656
657 ###
658 ### 2-quote opening sequence tests
659 ###
660 !! test
661 Italics and bold: 2-quote opening sequence: (2,2)
662 !! wikitext
663 ''foo''
664 !! html
665 <p><i>foo</i>
666 </p>
667 !!end
668
669 !! test
670 Italics and bold: 2-quote opening sequence: (2,3)
671 !! wikitext
672 ''foo'''
673 !! html/*
674 <p><i>foo'</i>
675 </p>
676 !!end
677
678 !! test
679 Italics and bold: 2-quote opening sequence: (2,4)
680 !! options
681 parsoid=wt2html
682 !! wikitext
683 ''foo''''
684 !! html/*
685 <p><i>foo''</i>
686 </p>
687 !!end
688
689 # same html as previous, but wikitext adjusted to match parsoid html2wt
690 !! test
691 Italics and bold: 2-quote opening sequence: (2,4) w/ nowiki
692 !! wikitext
693 ''foo<nowiki>''</nowiki>''
694 !! html
695 <p><i>foo''</i>
696 </p>
697 !! end
698
699 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
700 !! test
701 Italics and bold: 2-quote opening sequence: (2,5)
702 !! options
703 parsoid=wt2html
704 !! wikitext
705 ''foo'''''
706 !! html/php
707 <p><i>foo</i>
708 </p>
709 !! html/parsoid
710 <p><i>foo</i><b></b>
711 </p>
712 !!end
713
714 # same html as previous, but wikitext adjusted to match parsoid html2wt
715 !! test
716 Italics and bold: 2-quote opening sequence: (2,5+3) w/ nowiki
717 !! wikitext
718 ''foo'''''<nowiki/>'''
719 !! html/php
720 <p><i>foo</i>
721 </p>
722 !! html/parsoid
723 <p><i>foo</i><b></b>
724 </p>
725 !! end
726
727
728 ###
729 ### 3-quote opening sequence tests
730 ###
731
732 !! test
733 Italics and bold: 3-quote opening sequence: (3,2)
734 !! wikitext
735 '''foo''
736 !! html/*
737 <p>'<i>foo</i>
738 </p>
739 !!end
740
741 !! test
742 Italics and bold: 3-quote opening sequence: (3,3)
743 !! wikitext
744 '''foo'''
745 !! html
746 <p><b>foo</b>
747 </p>
748 !!end
749
750 !! test
751 Italics and bold: 3-quote opening sequence: (3,4)
752 !! wikitext
753 '''foo''''
754 !! html/*
755 <p><b>foo'</b>
756 </p>
757 !!end
758
759 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
760 !! test
761 Italics and bold: 3-quote opening sequence: (3,5)
762 !! options
763 parsoid=wt2html
764 !! wikitext
765 '''foo'''''
766 !! html/php
767 <p><b>foo</b>
768 </p>
769 !! html/parsoid
770 <p><b>foo</b><i></i>
771 </p>
772 !!end
773
774 # same html as previous, but wikitext adjusted to match parsoid html2wt
775 !! test
776 Italics and bold: 3-quote opening sequence: (3,5+2) w/ nowiki
777 !! wikitext
778 '''foo'''''<nowiki/>''
779 !! html/php
780 <p><b>foo</b>
781 </p>
782 !! html/parsoid
783 <p><b>foo</b><i></i>
784 </p>
785 !! end
786
787
788 ###
789 ### 4-quote opening sequence tests
790 ###
791
792 !! test
793 Italics and bold: 4-quote opening sequence: (4,2)
794 !! options
795 parsoid=wt2html
796 !! wikitext
797 ''''foo''
798 !! html/*
799 <p>''<i>foo</i>
800 </p>
801 !!end
802
803 # same html as previous, but wikitext adjusted to match parsoid html2wt
804 !! test
805 Italics and bold: 4-quote opening sequence: (4,2) w/ nowiki
806 !! wikitext
807 <nowiki>''</nowiki>''foo''
808 !! html
809 <p>''<i>foo</i>
810 </p>
811 !! end
812
813 !! test
814 Italics and bold: 4-quote opening sequence: (4,3)
815 !! wikitext
816 ''''foo'''
817 !! html/*
818 <p>'<b>foo</b>
819 </p>
820 !!end
821
822 !! test
823 Italics and bold: 4-quote opening sequence: (4,4)
824 !! options
825 parsoid=wt2html
826 !! wikitext
827 ''''foo''''
828 !! html/*
829 <p>'<b>foo'</b>
830 </p>
831 !!end
832
833 # same html as previous, but wikitext adjusted to match parsoid html2wt
834 !! test
835 Italics and bold: 4-quote opening sequence: (4,4) w/ nowiki
836 !! wikitext
837 '<nowiki/>'''foo''''
838 !! html
839 <p>'<b>foo'</b>
840 </p>
841 !! end
842
843 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
844 !! test
845 Italics and bold: 4-quote opening sequence: (4,5)
846 !! options
847 parsoid=wt2html
848 !! wikitext
849 ''''foo'''''
850 !! html/php
851 <p>'<b>foo</b>
852 </p>
853 !! html/parsoid
854 <p>'<b>foo</b><i></i>
855 </p>
856 !!end
857
858 # same html as previous, but wikitext adjusted to match parsoid html2wt
859 !! test
860 Italics and bold: 4-quote opening sequence: (4,5+2) w/ nowiki
861 !! wikitext
862 '<nowiki/>'''foo'''''<nowiki/>''
863 !! html/php
864 <p>'<b>foo</b>
865 </p>
866 !! html/parsoid
867 <p>'<b>foo</b><i></i>
868 </p>
869 !! end
870
871
872 ###
873 ### 5-quote opening sequence tests
874 ###
875
876 !! test
877 Italics and bold: 5-quote opening sequence: (5,2)
878 !! options
879 parsoid=wt2html
880 !! wikitext
881 '''''foo''
882 !! html/*
883 <p><b><i>foo</i></b>
884 </p>
885 !!end
886
887 # same html as previous, but wikitext adjusted to match parsoid html2wt
888 !! test
889 Italics and bold: 5-quote opening sequence: (5,2+3)
890 !! wikitext
891 '''''foo'''''
892 !! html/*
893 <p><i><b>foo</b></i>
894 </p>
895 !! end
896
897 !! test
898 Italics and bold: 5-quote opening sequence: (5,3)
899 !! options
900 parsoid=wt2html
901 !! wikitext
902 '''''foo'''
903 !! html/*
904 <p><i><b>foo</b></i>
905 </p>
906 !!end
907
908 # same html as previous, but wikitext adjusted to match parsoid html2wt
909 !! test
910 Italics and bold: 5-quote opening sequence: (5,3+2)
911 !! wikitext
912 '''''foo'''''
913 !! html
914 <p><i><b>foo</b></i>
915 </p>
916 !! end
917
918 !! test
919 Italics and bold: 5-quote opening sequence: (5,4)
920 !! options
921 parsoid=wt2html
922 !! wikitext
923 '''''foo''''
924 !! html/*
925 <p><i><b>foo'</b></i>
926 </p>
927 !!end
928
929 !! test
930 Italics and bold: 5-quote opening sequence: (5,5)
931 !! wikitext
932 '''''foo'''''
933 !! html
934 <p><i><b>foo</b></i>
935 </p>
936 !!end
937
938 !! test
939 Italics and bold: 5-quote opening sequence: (5,6)
940 !! wikitext
941 '''''foo''''''
942 !! html/*
943 <p><i><b>foo'</b></i>
944 </p>
945 !! end
946
947 ###
948 ### multiple quote sequences in a line
949 ###
950
951 !! test
952 Italics and bold: multiple quote sequences: (2,4,2)
953 !! options
954 parsoid=wt2html
955 !! wikitext
956 ''foo''''bar''
957 !! html/*
958 <p><i>foo'<b>bar</b></i>
959 </p>
960 !! end
961
962 # same html as previous, but wikitext adjusted to match parsoid html2wt
963 !! test
964 Italics and bold: multiple quote sequences: (2,4,2+3) w/ nowiki
965 !! wikitext
966 ''foo'<nowiki/>'''bar'''''
967 !! html
968 <p><i>foo'<b>bar</b></i>
969 </p>
970 !! end
971
972 !! test
973 Italics and bold: multiple quote sequences: (2,4,3)
974 !! options
975 parsoid=wt2html
976 !! wikitext
977 ''foo''''bar'''
978 !! html/*
979 <p><i>foo'<b>bar</b></i>
980 </p>
981 !! end
982
983 # same html as previous, but wikitext adjusted to match parsoid html2wt
984 !! test
985 Italics and bold: multiple quote sequences: (2,4,3+2) w/ nowiki
986 !! wikitext
987 ''foo'<nowiki/>'''bar'''''
988 !! html
989 <p><i>foo'<b>bar</b></i>
990 </p>
991 !! end
992
993 !! test
994 Italics and bold: multiple quote sequences: (2,4,4)
995 !! options
996 parsoid=wt2html
997 !! wikitext
998 ''foo''''bar''''
999 !! html/*
1000 <p><i>foo'<b>bar'</b></i>
1001 </p>
1002 !! end
1003
1004 # same html as previous, but wikitext adjusted to match parsoid html2wt
1005 !! test
1006 Italics and bold: multiple quote sequences: (2,4,4+2) w/ nowiki
1007 !! wikitext
1008 ''foo'<nowiki/>'''bar'<nowiki/>'''''
1009 !! html
1010 <p><i>foo'<b>bar'</b></i>
1011 </p>
1012 !! end
1013
1014 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
1015 !! test
1016 Italics and bold: multiple quote sequences: (3,4,2)
1017 !! options
1018 parsoid=wt2html
1019 !! wikitext
1020 '''foo''''bar''
1021 !! html/php
1022 <p><b>foo'</b>bar
1023 </p>
1024 !! html/parsoid
1025 <p><b>foo'</b>bar<i></i>
1026 </p>
1027 !! end
1028
1029 # same html as previous, but wikitext adjusted to match parsoid html2wt
1030 !! test
1031 Italics and bold: multiple quote sequences: (3,4,2+2) w/ nowiki
1032 !! wikitext
1033 '''foo''''bar''<nowiki/>''
1034 !! html/php
1035 <p><b>foo'</b>bar
1036 </p>
1037 !! html/parsoid
1038 <p><b>foo'</b>bar<i></i>
1039 </p>
1040 !! end
1041
1042 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
1043 !! test
1044 Italics and bold: multiple quote sequences: (3,4,3)
1045 !! options
1046 parsoid=wt2html
1047 !! wikitext
1048 '''foo''''bar'''
1049 !! html/php
1050 <p><b>foo'</b>bar
1051 </p>
1052 !! html/parsoid
1053 <p><b>foo'</b>bar<b></b>
1054 </p>
1055 !! end
1056
1057 # same html as previous, but wikitext adjusted to match parsoid html2wt
1058 !! test
1059 Italics and bold: multiple quote sequences: (3,4,3+3) w/ nowiki
1060 !! wikitext
1061 '''foo''''bar'''<nowiki/>'''
1062 !! html/php
1063 <p><b>foo'</b>bar
1064 </p>
1065 !! html/parsoid
1066 <p><b>foo'</b>bar<b></b>
1067 </p>
1068 !! end
1069
1070 ###
1071 ### other quote tests
1072 ###
1073 !! test
1074 Italics and bold: other quote tests: (2,3,5)
1075 !! wikitext
1076 ''this is about '''foo's family'''''
1077 !! html
1078 <p><i>this is about <b>foo's family</b></i>
1079 </p>
1080 !!end
1081
1082
1083 !! test
1084 Italics and bold: other quote tests: (2,(3,3),2)
1085 !! wikitext
1086 ''this is about '''foo's''' family''
1087 !! html
1088 <p><i>this is about <b>foo's</b> family</i>
1089 </p>
1090 !!end
1091
1092
1093 !! test
1094 Italics and bold: other quote tests: (3,2,3,2)
1095 !! options
1096 parsoid=wt2html
1097 !! wikitext
1098 '''this is about ''foo'''s family''
1099 !! html/*
1100 <p><b>this is about <i>foo</i></b><i>s family</i>
1101 </p>
1102 !!end
1103
1104
1105 # same html as previous, but wikitext adjusted to match parsoid html2wt
1106 !! test
1107 Italics and bold: other quote tests: (3,2,3+2+2,2)
1108 !! wikitext
1109 '''this is about ''foo'''''<nowiki/>''s family''
1110 !! html
1111 <p><b>this is about <i>foo</i></b><i>s family</i>
1112 </p>
1113 !! end
1114
1115
1116 !! test
1117 Italics and bold: other quote tests: (3,2,3,3)
1118 !! wikitext
1119 '''this is about ''foo'''s family'''
1120 !! html/*
1121 <p>'<i>this is about </i>foo<b>s family</b>
1122 </p>
1123 !!end
1124
1125
1126 !! test
1127 Italics and bold: other quote tests: (3,(2,2),3)
1128 !! wikitext
1129 '''this is about ''foo's'' family'''
1130 !! html
1131 <p><b>this is about <i>foo's</i> family</b>
1132 </p>
1133 !!end
1134
1135
1136 !! test
1137 Italicized possessive
1138 !! wikitext
1139 The ''[[Main Page]]'''s talk page.
1140 !! html/php
1141 <p>The <i><a href="/wiki/Main_Page" title="Main Page">Main Page</a>'</i>s talk page.
1142 </p>
1143 !! html/parsoid
1144 <p>The <i><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a>'</i>s talk page.</p>
1145 !! end
1146
1147 !! test
1148 Parsoid only: Quote balancing context should be restricted to td/th cells on the same wikitext line
1149 (Requires tidy for PHP parser output to be fixed up)
1150 !! options
1151 parsoid=wt2html,wt2wt
1152 !! wikitext
1153 {|
1154 !''a!!''b
1155 |''a||''b
1156 |}
1157 !! html/php+tidy
1158 <table>
1159 <tr>
1160 <th><i>a</i></th>
1161 <th><i>b</i></th>
1162 <td><i>a</i></td>
1163 <td><i>b</i></td>
1164 </tr>
1165 </table>
1166 !! html/parsoid
1167 <table>
1168 <tbody><tr><th><i>a</i></th><th><i>b</i></th>
1169 <td><i>a</i></td><td><i>b</i></td></tr>
1170 </tbody></table>
1171 !! end
1172
1173 ###
1174 ### Non-html5 tags
1175 ###
1176
1177 !! test
1178 Non-html5 tags should be accepted
1179 !! wikitext
1180 <center>''foo''</center>
1181 <big>''foo''</big>
1182 <font>''foo''</font>
1183 <strike>''foo''</strike>
1184 <tt>''foo''</tt>
1185 !! html
1186 <center><i>foo</i></center>
1187 <p><big><i>foo</i></big>
1188 <font><i>foo</i></font>
1189 <strike><i>foo</i></strike>
1190 <tt><i>foo</i></tt>
1191 </p>
1192 !! end
1193
1194 !! test
1195 <wbr> is valid wikitext (T54468)
1196 !! wikitext
1197 <wbr>
1198 !! html
1199 <p><wbr />
1200 </p>
1201 !! end
1202
1203 # <strike> is HTML4, <s> is HTML4/5.
1204 !! test
1205 <s> or <strike> for strikethrough
1206 !! wikitext
1207 <strike>strike</strike>
1208
1209 <s>s</s>
1210 !! html
1211 <p><strike>strike</strike>
1212 </p><p><s>s</s>
1213 </p>
1214 !! end
1215
1216 ## a not permitted
1217 ## i,b,br omitted
1218 !! test
1219 Text-level semantic html elements in wikitext
1220 !! wikitext
1221 <em>text</em>
1222 <strong>text</strong>
1223 <small>text</small>
1224 <s>text</s>
1225 <cite>text</cite>
1226 <q>text</q>
1227 <dfn>text</dfn>
1228 <abbr>text</abbr>
1229 <data>text</data>
1230 <time>text</time>
1231 <code>text</code>
1232 <var>text</var>
1233 <samp>text</samp>
1234 <kbd>text</kbd>
1235 <sub>text</sub>
1236 <u>text</u>
1237 <mark>text</mark>
1238 <ruby><rb>明日</rb><rp>(</rp><rt>Ashita</rt><rp> </rp><rtc>あした</rtc><rp>)</rp></ruby>
1239 <bdi>text</bdi>
1240 <bdo>text</bdo>
1241 <span>text</span>
1242 <wbr />
1243 !! html
1244 <p><em>text</em>
1245 <strong>text</strong>
1246 <small>text</small>
1247 <s>text</s>
1248 <cite>text</cite>
1249 <q>text</q>
1250 <dfn>text</dfn>
1251 <abbr>text</abbr>
1252 <data>text</data>
1253 <time>text</time>
1254 <code>text</code>
1255 <var>text</var>
1256 <samp>text</samp>
1257 <kbd>text</kbd>
1258 <sub>text</sub>
1259 <u>text</u>
1260 <mark>text</mark>
1261 <ruby><rb>明日</rb><rp>(</rp><rt>Ashita</rt><rp> </rp><rtc>あした</rtc><rp>)</rp></ruby>
1262 <bdi>text</bdi>
1263 <bdo>text</bdo>
1264 <span>text</span>
1265 <wbr />
1266 </p>
1267 !! end
1268
1269 # test cases taken from
1270 # https://www.w3.org/TR/html5/text-level-semantics.html#the-ruby-element
1271 !! test
1272 Ruby markup (W3C-style)
1273 !! wikitext
1274 ; Mono-ruby for individual base characters
1275 : <ruby>日<rt>に</rt>本<rt>ほん</rt>語<rt>ご</rt></ruby>
1276 ; Group ruby
1277 : <ruby>今日<rt>きょう</rt></ruby>
1278 ; Jukugo ruby
1279 : <ruby>法<rb>華</rb><rb>経</rb><rt>ほ</rt><rt>け</rt><rt>きょう</rt></ruby>
1280 ; Inline ruby
1281 : <ruby>東<rb>京</rb><rp>(</rp><rt>とう</rt><rt>きょう</rt><rp>)</rp></ruby>
1282 ; Double-sided ruby
1283 : <ruby><rb>旧</rb><rb>金</rb><rb>山</rb><rt>jiù</rt><rt>jīn</rt><rt>shān</rt><rtc>San Francisco</rtc></ruby>
1284 <ruby>
1285 <rb>♥</rb><rtc><rt>Heart</rt></rtc><rtc lang="fr"><rt>Cœur</rt></rtc>
1286 <rb>☘</rb><rtc><rt>Shamrock</rt></rtc><rtc lang="fr"><rt>Trèfle</rt></rtc>
1287 <rb>✶</rb><rtc><rt>Star</rt></rtc><rtc lang="fr"><rt>Étoile</rt></rtc>
1288 </ruby>
1289 !! html
1290 <dl><dt> Mono-ruby for individual base characters</dt>
1291 <dd> <ruby>日<rt>に</rt>本<rt>ほん</rt>語<rt>ご</rt></ruby></dd>
1292 <dt> Group ruby</dt>
1293 <dd> <ruby>今日<rt>きょう</rt></ruby></dd>
1294 <dt> Jukugo ruby</dt>
1295 <dd> <ruby>法<rb>華</rb><rb>経</rb><rt>ほ</rt><rt>け</rt><rt>きょう</rt></ruby></dd>
1296 <dt> Inline ruby</dt>
1297 <dd> <ruby>東<rb>京</rb><rp>(</rp><rt>とう</rt><rt>きょう</rt><rp>)</rp></ruby></dd>
1298 <dt> Double-sided ruby</dt>
1299 <dd> <ruby><rb>旧</rb><rb>金</rb><rb>山</rb><rt>jiù</rt><rt>jīn</rt><rt>shān</rt><rtc>San Francisco</rtc></ruby></dd></dl>
1300 <p><ruby>
1301 <rb>♥</rb><rtc><rt>Heart</rt></rtc><rtc lang="fr"><rt>Cœur</rt></rtc>
1302 <rb>☘</rb><rtc><rt>Shamrock</rt></rtc><rtc lang="fr"><rt>Trèfle</rt></rtc>
1303 <rb>✶</rb><rtc><rt>Star</rt></rtc><rtc lang="fr"><rt>Étoile</rt></rtc>
1304 </ruby>
1305 </p>
1306 !! end
1307
1308 # The next two test different paths in the sanitizer.
1309 !! test
1310 Non-word characters don't terminate tag names (T19663, T42670, T54022)
1311 !! wikitext
1312 <blockquote|>a</blockquote>
1313
1314 <b→> doesn't terminate </b→>
1315
1316 <bä> doesn't terminate </bä>
1317
1318 <boo> doesn't terminate </boo>
1319
1320 <s.foo> doesn't terminate </s.foo>
1321
1322 <sub-ID#1>
1323 !! html
1324 <p>&lt;blockquote|&gt;a&lt;/blockquote&gt;
1325 </p><p>&lt;b→&gt; doesn't terminate &lt;/b→&gt;
1326 </p><p>&lt;bä&gt; doesn't terminate &lt;/bä&gt;
1327 </p><p>&lt;boo&gt; doesn't terminate &lt;/boo&gt;
1328 </p><p>&lt;s.foo&gt; doesn't terminate &lt;/s.foo&gt;
1329 </p><p>&lt;sub-ID#1&gt;
1330 </p>
1331 !! end
1332
1333 # There is a tidy bug here: https://sourceforge.net/p/tidy/bugs/946/
1334 # If the non-word-character tag made it through the sanitizer, tidy
1335 # would munge it up.
1336 !! test
1337 Non-word characters don't terminate tag names + tidy
1338 !! wikitext
1339 <blockquote|>a</blockquote>
1340
1341 <b→> doesn't terminate </b→>
1342
1343 <bä> doesn't terminate </bä>
1344
1345 <boo> doesn't terminate </boo>
1346
1347 <s.foo> doesn't terminate </s.foo>
1348
1349 <sub-ID#1>
1350 !! html+tidy
1351 <p>&lt;blockquote|&gt;a</p>
1352 <p>&lt;b→&gt; doesn't terminate &lt;/b→&gt;</p>
1353 <p>&lt;bä&gt; doesn't terminate &lt;/bä&gt;</p>
1354 <p>&lt;boo&gt; doesn't terminate &lt;/boo&gt;</p>
1355 <p>&lt;s.foo&gt; doesn't terminate &lt;/s.foo&gt;</p>
1356 <p>&lt;sub-ID#1&gt;</p>
1357 !! end
1358
1359 ###
1360 ### See tests/parser/parserTestsParserHook.php for the <tåg> extension)
1361 ### This checks that HTML5 tags (with non-word characters in the tag
1362 ### name) make it safely through the parser -- the Sanitizer will
1363 ### munge them later, as it should.
1364 ###
1365 !! test
1366 Non-word characters are valid in extension tags (T19663)
1367 !! wikitext
1368 <tåg>tåg</tåg>
1369 !! html/php
1370 <pre>
1371 'tåg'
1372 array (
1373 )
1374 </pre>
1375
1376 !! html/parsoid
1377 <pre typeof="mw:Extension/tåg" data-mw='{"name":"tåg","attrs":{},"body":{"extsrc":"tåg"}}' data-parsoid='{}' about="#mwt2"></pre>
1378 !! end
1379
1380 !! test
1381 Isolated close tags should be treated as literal text (T54760)
1382 !! options
1383 parsoid=wt2html
1384 !! wikitext
1385 </b>
1386
1387 <s.foo>s</s>
1388 !! html/php+tidy
1389 <p>&lt;s.foo&gt;s</p>
1390 !! html/parsoid
1391 <p>&lt;s.foo&gt;s</p>
1392 !! end
1393
1394 ###
1395 ### Special characters
1396 ###
1397
1398 !! test
1399 Bare pipe character (T54363)
1400 !! wikitext
1401 |
1402 !! html
1403 <p>|
1404 </p>
1405 !! end
1406
1407 !! test
1408 Bare pipe character from a template (T54363)
1409 !! wikitext
1410 {{pipe}}
1411 !! html
1412 <p>|
1413 </p>
1414 !! end
1415
1416 ###
1417 ### <nowiki> test cases
1418 ###
1419
1420 !! test
1421 <nowiki> unordered list
1422 !! wikitext
1423 <nowiki>* This is not an unordered list item.</nowiki>
1424 !! html/php
1425 <p>* This is not an unordered list item.
1426 </p>
1427 !! html/parsoid
1428 <p><span typeof="mw:Nowiki">* This is not an unordered list item.</span></p>
1429 !! end
1430
1431 !! test
1432 <nowiki> spacing
1433 !! wikitext
1434 <nowiki>Lorem ipsum dolor
1435
1436 sed abit.
1437 sed nullum.
1438
1439 :and a colon
1440 </nowiki>
1441 !! html/php
1442 <p>Lorem ipsum dolor
1443
1444 sed abit.
1445 sed nullum.
1446
1447 :and a colon
1448
1449 </p>
1450 !! html/parsoid
1451 <p><span typeof="mw:Nowiki">Lorem ipsum dolor
1452
1453 sed abit.
1454 sed nullum.
1455
1456 :and a colon
1457 </span></p>
1458 !! end
1459
1460 !! test
1461 Don't parse <nowiki><span class="error"></nowiki> (T149622)
1462 !! wikitext
1463 <nowiki><span class="error"></nowiki>
1464 !! html/php
1465 <p>&lt;span class="error"&gt;
1466 </p>
1467 !! html/parsoid
1468 <p><span typeof="mw:Nowiki">&lt;span class="error"></span></p>
1469 !! end
1470
1471 !! test
1472 nowiki 3
1473 !! wikitext
1474 :There is not nowiki.
1475 :There is <nowiki>nowiki</nowiki>.
1476
1477 #There is not nowiki.
1478 #There is <nowiki>nowiki</nowiki>.
1479
1480 *There is not nowiki.
1481 *There is <nowiki>nowiki</nowiki>.
1482 !! html/php
1483 <dl><dd>There is not nowiki.</dd>
1484 <dd>There is nowiki.</dd></dl>
1485 <ol><li>There is not nowiki.</li>
1486 <li>There is nowiki.</li></ol>
1487 <ul><li>There is not nowiki.</li>
1488 <li>There is nowiki.</li></ul>
1489
1490 !! html/parsoid
1491 <dl><dd data-parsoid='{}'>There is not nowiki.</dd>
1492 <dd data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</dd></dl>
1493
1494 <ol><li data-parsoid='{}'>There is not nowiki.</li>
1495 <li data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</li></ol>
1496
1497 <ul><li data-parsoid='{}'>There is not nowiki.</li>
1498 <li data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</li></ul>
1499 !! end
1500
1501 !! test
1502 Entities inside <nowiki>
1503 !! wikitext
1504 <nowiki>&lt;</nowiki>
1505 !! html/php
1506 <p>&lt;
1507 </p>
1508 !! html/parsoid
1509 <p><span typeof="mw:Nowiki"><span typeof="mw:Entity" data-parsoid='{"src":"&amp;lt;","srcContent":"&lt;"}'>&lt;</span></span></p>
1510 !! end
1511
1512 !! test
1513 Entities inside template parameters
1514 !! wikitext
1515 {{echo|&ndash;}}
1516 !! html/php+tidy
1517 <p>–</p>
1518 !! html/parsoid
1519 <p><span typeof="mw:Transclusion mw:Entity" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&amp;ndash;"}},"i":0}}]}'>&ndash;</span></p>
1520 !! end
1521
1522 !! test
1523 Properly escape nowiki when combined with other wiki markup
1524 !! options
1525 parsoid=html2wt
1526 !! html/parsoid
1527 <p>* &lt;/nowiki&gt; tag</p>
1528 !! wikitext
1529 <nowiki>*</nowiki> <nowiki>&lt;/nowiki&gt;</nowiki> tag
1530 !! end
1531
1532 !! test
1533 T93824: Put escaped HTML tags inside nowiki
1534 !! options
1535 parsoid=html2wt
1536 !! html/parsoid
1537 <p>&lt;h2&gt;foo&lt;/h2&gt;</p>
1538 !! wikitext
1539 <nowiki><h2>foo</h2></nowiki>
1540 !! end
1541
1542 !! test
1543 T71950: 1. Put nowiki as close to cause as possible, even with non-quote escapable chars
1544 !! options
1545 parsoid=html2wt
1546 !! html/parsoid
1547 <p>This text: L'<a rel="mw:WikiLink" href="./Foo">Foo</a>
1548 This text: L''<a rel="mw:WikiLink" href="./Foo">Foo</a>
1549 This text: L'''<a rel="mw:WikiLink" href="./Foo">Foo</a>''</p>
1550 !! wikitext
1551 This text: L'[[Foo]]
1552 This text: L<nowiki>''</nowiki>[[Foo]]
1553 This text: L<nowiki>'''</nowiki>[[Foo]]<nowiki>''</nowiki>
1554 !! end
1555
1556 # This test fails because wikitext whitespace is not normalized before comparing.
1557 !! test
1558 T71950: 2. Put nowiki as close to cause as possible, after ' :'
1559 !! options
1560 parsoid=html2wt
1561 !! html/parsoid
1562 <p>This text : L''<a rel="mw:WikiLink" href="./Foo">Foo</a>
1563 </p>
1564 !! wikitext
1565 This text : L<nowiki>''</nowiki>[[Foo]]
1566 !! end
1567
1568 # This test and the next one are html2wt only as they test that incorrect wikitext
1569 # passed in template arguments gets escaped or wrapped in nowikis where required.
1570 !! test
1571 T71482: Use {{!}} instead of nowiki for single pipe in template argument
1572 !! options
1573 parsoid=html2wt
1574 !! html/parsoid
1575 <p><span typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;foo|bar&quot;}},&quot;i&quot;:0}}]}" about="#mwt1"></span>
1576 <span typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;foo|bar |[[&quot;}},&quot;i&quot;:0}}]}" about="#mwt2"></p>
1577 !! wikitext
1578 {{echo|foo{{!}}bar}}
1579 {{echo|<nowiki>foo|bar |[[</nowiki>}}
1580 !! end
1581
1582 !! test
1583 T53961: Output correct nowikis in template arguments
1584 !! options
1585 parsoid=html2wt
1586 !! html/parsoid
1587 <p><span typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;a [ b&quot;}},&quot;i&quot;:0}}]}" about="#mwt1"></span>
1588 <span typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;a }} b&quot;}},&quot;i&quot;:0}}]}" about="#mwt2"></span>
1589 <span typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;a [[ b&quot;}},&quot;i&quot;:0}}]}" about="#mwt3"></span>
1590 <span typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;a | {{ ]]&quot;}},&quot;i&quot;:0}}]}" about="#mwt4"></span>
1591 <span typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;a }&quot;}},&quot;i&quot;:0}}]}" about="#mwt5"></span></p>
1592 !! wikitext
1593 {{echo|a [ b}}
1594 {{echo|<nowiki>a }} b</nowiki>}}
1595 {{echo|<nowiki>a [[ b</nowiki>}}
1596 {{echo|<nowiki>a | {{ ]]</nowiki>}}
1597 {{echo|a <nowiki>}</nowiki>}}
1598 !! end
1599
1600 !! test
1601 Cases where "!!" needs nowiki protection
1602 !! options
1603 parsoid=html2wt
1604 !! html/parsoid
1605 <table>
1606 <tr><th>this needs protection !! here</th></tr>
1607 </table>
1608
1609 <table>
1610 <tr><th>this does not need
1611 protection !! here</th></tr>
1612 </table>
1613 !! wikitext
1614 {|
1615 !<nowiki>this needs protection !! here</nowiki>
1616 |}
1617
1618 {|
1619 !this does not need
1620 protection !! here
1621 |}
1622 !! end
1623
1624 ###
1625 ### Comments
1626 ###
1627 !! test
1628 Comments and Indent-Pre
1629 !! wikitext
1630 <!-- comment 1 --> asdf
1631
1632 <!-- comment 1 --> asdf
1633 <!-- comment 2 -->
1634
1635 <!-- comment 1 --> asdf
1636 <!-- comment 2 -->xyz
1637
1638 <!-- comment 1 --> asdf
1639 <!-- comment 2 --> xyz
1640 !! html
1641 <pre>asdf
1642 </pre>
1643 <pre>asdf
1644 </pre>
1645 <pre>asdf
1646 </pre>
1647 <p>xyz
1648 </p>
1649 <pre>asdf
1650 xyz
1651 </pre>
1652 !! end
1653
1654 !! test
1655 Comment test 2a
1656 !! wikitext
1657 asdf
1658 <!-- comment 1 -->
1659 jkl
1660 !! html
1661 <p>asdf
1662 jkl
1663 </p>
1664 !! end
1665
1666 !! test
1667 Comment test 2b
1668 !! wikitext
1669 asdf
1670 <!-- comment 1 -->
1671
1672 jkl
1673 !! html
1674 <p>asdf
1675 </p><p>jkl
1676 </p>
1677 !! end
1678
1679 !! test
1680 Comment test 3
1681 !! wikitext
1682 asdf
1683 <!-- comment 1 -->
1684 <!-- comment 2 -->
1685 jkl
1686 !! html
1687 <p>asdf
1688 jkl
1689 </p>
1690 !! end
1691
1692 !! test
1693 Comment test 4
1694 !! wikitext
1695 asdf<!-- comment 1 -->jkl
1696 !! html
1697 <p>asdfjkl
1698 </p>
1699 !! end
1700
1701 !! test
1702 Comment spacing
1703 !! wikitext
1704 a
1705 <!-- foo --> b <!-- bar -->
1706 c
1707 !! html
1708 <p>a
1709 </p>
1710 <pre> b
1711 </pre>
1712 <p>c
1713 </p>
1714 !! end
1715
1716 !! test
1717 Comment whitespace
1718 !! wikitext
1719 <!-- returns a single newline, not nothing, since the newline after > is not stripped -->
1720 !! html
1721
1722 !! end
1723
1724 !! test
1725 Comment semantics and delimiters
1726 !! wikitext
1727 <!-- --><!----><!-----><!------>
1728 !! html/php
1729
1730 !! html/parsoid
1731 <!-- --><!----><!--&#x2D;--><!--&#x2D;&#x2D;-->
1732 !! end
1733
1734 !! test
1735 Comment semantics and delimiters, redux
1736 !! wikitext
1737 <!-- In SGML every "foo" here would actually show up in the text -- foo -- bar
1738 -- foo -- funky huh? ... -->
1739 !! html/php
1740
1741 !! html/parsoid
1742 <!-- In SGML every "foo" here would actually show up in the text &#x2D;&#x2D; foo &#x2D;&#x2D; bar
1743 &#x2D;&#x2D; foo &#x2D;&#x2D; funky huh? ... -->
1744 !! end
1745
1746 !! test
1747 Comment semantics and delimiters: directors cut
1748 !! wikitext
1749 <!-- ... However we like to keep things simple and somewhat XML-ish so we eat
1750 everything starting with < followed by !-- until the first -- and > we see,
1751 that wouldn't be valid XML however, since in XML -- has to terminate a comment
1752 -->-->
1753 !! html/php
1754 <p>--&gt;
1755 </p>
1756 !! html/parsoid
1757 <!-- ... However we like to keep things simple and somewhat XML&#x2D;ish so we eat
1758 everything starting with < followed by !&#x2D;&#x2D; until the first &#x2D;&#x2D; and &#x3E; we see,
1759 that wouldn't be valid XML however, since in XML &#x2D;&#x2D; has to terminate a comment
1760 --><p>--></p>
1761 !! end
1762
1763 !! test
1764 Comment semantics: nesting
1765 !! wikitext
1766 <!--<!-- no, we're not going to do anything fancy here -->-->
1767 !! html/php
1768 <p>--&gt;
1769 </p>
1770 !! html/parsoid
1771 <!--<!&#x2D;&#x2D; no, we're not going to do anything fancy here --><p>--></p>
1772 !! end
1773
1774 # Parsoid closes the unclosed comment, even if it means a slight
1775 # round-trip diff.
1776 !! test
1777 Comment semantics: unclosed comment at end
1778 !! options
1779 parsoid=wt2html,html2html
1780 !! wikitext
1781 <!--This comment will run out to the end of the document
1782 !! html/php
1783
1784 !! html/parsoid
1785 <!--This comment will run out to the end of the document-->
1786 !! end
1787
1788 !! test
1789 Comment semantics: normalize comments to play nice with XML and browsers
1790 !! wikitext
1791 <!-- Browsers --!> think this is closed -->
1792 <!--> This would normally be text -->
1793 <!---> As would this -->
1794 <!-- XML doesn't like trailing dashes -------->
1795 <!-- Nor doubled hyphens -- anywhere in the data -->
1796 But this is not a comment.
1797 !! html/php
1798 <p>But this is not a comment.
1799 </p>
1800 !! html/parsoid
1801 <!-- Browsers &#x2D;&#x2D;!&#x3E; think this is closed -->
1802 <!--&#x3E; This would normally be text -->
1803 <!--&#x2D;&#x3E; As would this -->
1804 <!-- XML doesn't like trailing dashes &#x2D;&#x2D;&#x2D;&#x2D;&#x2D;&#x2D;-->
1805 <!-- Nor doubled hyphens &#x2D;&#x2D; anywhere in the data -->
1806 <p>But this is not a comment.</p>
1807 !! end
1808
1809 !! test
1810 Comment semantics: round-trip even text which contains encoded -->
1811 !! wikitext
1812 <!-- hello & goodbye - > --&gt; --&amp;gt; --&xx -->
1813 !! html/parsoid
1814 <!-- hello &#x26; goodbye &#x2D; &#x3E; &#x2D;&#x2D;&#x3E; &#x2D;&#x2D;&#x26;gt; &#x2D;&#x2D;&#x26;xx -->
1815 !! end
1816
1817 !! test
1818 Comment in template title
1819 !! wikitext
1820 {{f<!---->oo}}
1821 !! html
1822 <p>FOO
1823 </p>
1824 !! end
1825
1826 !! test
1827 Comment on its own line post-expand
1828 !! wikitext
1829 a
1830 {{blank}}<!---->
1831 b
1832 !! html
1833 <p>a
1834 </p><p>b
1835 </p>
1836 !! end
1837
1838 !! test
1839 Comment on its own line post-expand with non-significant whitespace
1840 !! wikitext
1841 a
1842 {{blank}} <!---->
1843 b
1844 !! html
1845 <p>a
1846 </p><p>b
1847 </p>
1848 !! end
1849
1850 !! test
1851 Multiple comments should still parse as SOL-transparent
1852 !! options
1853 parsoid=wt2html,wt2wt
1854 !! wikitext
1855 <!--c1-->*a
1856 <!--c2--><!--c3--><!--c4-->*b
1857 !! html/php
1858 <ul><li>a</li>
1859 <li>b</li></ul>
1860
1861 !! html/parsoid
1862 <!--c1--><ul>
1863 <li>a
1864 </li>
1865 <!--c2--><!--c3--><!--c4-->
1866 <li>b
1867 </li>
1868 </ul>
1869 !! end
1870
1871 ## Make sure ">" gets escaped in comments to avoid XSS
1872 !! test
1873 IE conditional comments
1874 !! wikitext
1875 <!--[if lt IE 9]>
1876 <script>alert('hi');</script>
1877 <![endif]-->
1878 !! html/parsoid
1879 <!--[if lt IE 9]&#x3E;
1880 <script&#x3E;alert('hi');</script&#x3E;
1881 <![endif]-->
1882 !! end
1883
1884 ###
1885 ### paragraph wrapping tests
1886 ###
1887 !! test
1888 No block tags
1889 !! wikitext
1890 a
1891
1892 b
1893 !! html
1894 <p>a
1895 </p><p>b
1896 </p>
1897 !! end
1898
1899 !! test
1900 Block tag on one line (<div>)
1901 !! wikitext
1902 a <div>foo</div>
1903
1904 b
1905 !! html
1906 a <div>foo</div>
1907 <p>b
1908 </p>
1909 !! html+tidy
1910 <p>a</p>
1911 <div>foo</div>
1912 <p>b</p>
1913 !! end
1914
1915 !! test
1916 Block tag on one line (<blockquote>)
1917 !! wikitext
1918 a <blockquote>foo</blockquote>
1919
1920 b
1921 !! html
1922 a <blockquote>foo</blockquote>
1923 <p>b
1924 </p>
1925 !! html+tidy
1926 <p>a</p>
1927 <blockquote>
1928 <p>foo</p>
1929 </blockquote>
1930 <p>b</p>
1931 !! end
1932
1933 !! test
1934 Block tag on both lines (<div>)
1935 !! wikitext
1936 a <div>foo</div>
1937
1938 b <div>foo</div>
1939 !! html
1940 a <div>foo</div>
1941 b <div>foo</div>
1942
1943 !! html+tidy
1944 <p>a</p>
1945 <div>foo</div>
1946 <p>b</p>
1947 <div>foo</div>
1948 !! end
1949
1950 !! test
1951 Block tag on both lines (<blockquote>)
1952 !! wikitext
1953 a <blockquote>foo</blockquote>
1954
1955 b <blockquote>foo</blockquote>
1956 !! html
1957 a <blockquote>foo</blockquote>
1958 b <blockquote>foo</blockquote>
1959
1960 !! html+tidy
1961 <p>a</p>
1962 <blockquote>
1963 <p>foo</p>
1964 </blockquote>
1965 <p>b</p>
1966 <blockquote>
1967 <p>foo</p>
1968 </blockquote>
1969 !! end
1970
1971 !! test
1972 Multiple lines without block tags
1973 !! wikitext
1974 <div>foo</div> a
1975 b
1976 c
1977 d<!--foo--> e
1978 x <div>foo</div> z
1979 !! html
1980 <div>foo</div> a
1981 <p>b
1982 c
1983 d e
1984 </p>
1985 x <div>foo</div> z
1986
1987 !! html+tidy
1988 <div>foo</div>
1989 <p>a</p>
1990 <p>b c d e</p>
1991 <p>x</p>
1992 <div>foo</div>
1993 <p>z</p>
1994 !! end
1995
1996 # Tidy strips out the empty <div> tags. Parsoid doesn't.
1997 # So, we have a separate section for Parsoid. We don't want
1998 # to mimic this stripping behavior in Parsoid. It affects
1999 # editing experience and also requires us to maintain additional
2000 # info for RT-ing.
2001 !! test
2002 Empty lines between lines with block tags
2003 !! wikitext
2004 <div></div>
2005
2006
2007 <div></div>a
2008
2009 b
2010 <div>a</div>b
2011
2012 <div>b</div>d
2013
2014
2015 <div>e</div>
2016 !! html
2017 <div></div>
2018 <p><br />
2019 </p>
2020 <div></div>a
2021 <p>b
2022 </p>
2023 <div>a</div>b
2024 <div>b</div>d
2025 <p><br />
2026 </p>
2027 <div>e</div>
2028
2029 !! html+tidy
2030 <p><br /></p>
2031 <p>a</p>
2032 <p>b</p>
2033 <div>a</div>
2034 <p>b</p>
2035 <div>b</div>
2036 <p>d</p>
2037 <p><br /></p>
2038 <div>e</div>
2039 !! html/parsoid
2040 <div data-parsoid='{"stx":"html"}'></div>
2041
2042 <p><br /></p>
2043 <div data-parsoid='{"stx":"html"}'></div><p>a</p>
2044
2045 <p>b</p>
2046 <div data-parsoid='{"stx":"html"}'>a</div><p>b</p>
2047
2048 <div data-parsoid='{"stx":"html"}'>b</div><p>d</p>
2049
2050 <p><br /></p>
2051 <div data-parsoid='{"stx":"html"}'>e</div>
2052 !! end
2053
2054 ## PHP parser emits output which is broken
2055 !! test
2056 Unclosed HTML p-tags should be handled properly
2057 !! wikitext
2058 <div><p>foo</div>
2059 a
2060
2061 b
2062 !! html/php+tidy
2063 <div>
2064 <p>foo</p>
2065 </div>
2066 <p>a</p>
2067 <p>b</p>
2068 !! html/parsoid
2069 <div data-parsoid='{"stx":"html"}'><p data-parsoid='{"stx":"html", "autoInsertedEnd":true}'>foo</p></div>
2070 <p>a</p>
2071 <p>b</p>
2072 !! end
2073
2074 ## SSS FIXME: I can come up with other scenarios where this doesn't work because
2075 ## of eager output of buffered tokens in the p-wrapper. But, I'm going to ignore
2076 ## them for now.
2077 !! test
2078 1. P-wrapping should leave sol-transparent tags outside p-tags where possible
2079 !! options
2080 parsoid=wt2html
2081 !! wikitext
2082 a [[Category:A1]] [[Category:A2]]
2083 [[Category:A3]]
2084 [[Category:A4]]
2085 !! html/parsoid
2086 <p>a</p>
2087 <link rel="mw:PageProp/Category" href="./Category:A1"/> <link rel="mw:PageProp/Category" href="./Category:A2"/> <link rel="mw:PageProp/Category" href="./Category:A3"/> <link rel="mw:PageProp/Category" href="./Category:A4"/>
2088 !! end
2089
2090 !! test
2091 2. P-wrapping should leave sol-transparent tags outside p-tags where possible
2092 !! options
2093 parsoid=wt2html
2094 !! wikitext
2095 [[Category:A1]]a
2096 !! html/parsoid
2097 <link rel="mw:PageProp/Category" href="./Category:A1"/><p>a</p>
2098 !! end
2099
2100 ###
2101 ### Preformatted text
2102 ###
2103 !! test
2104 Preformatted text
2105 !! wikitext
2106 This is some
2107 Preformatted text
2108 With ''italic''
2109 And '''bold'''
2110 And a [[Main Page|link]]
2111 !! html
2112 <pre>This is some
2113 Preformatted text
2114 With <i>italic</i>
2115 And <b>bold</b>
2116 And a <a href="/wiki/Main_Page" title="Main Page">link</a>
2117 </pre>
2118 !! end
2119
2120 !! test
2121 Tabs don't trigger preformatted text
2122 !! wikitext
2123 This is not
2124 preformatted text.
2125 This is preformatted text.
2126 So is this.
2127 !! html/php
2128 <p> This is not
2129 preformatted text.
2130 </p>
2131 <pre>This is preformatted text.
2132 So is this.
2133 </pre>
2134 !! html/parsoid
2135 <p> This is not
2136 preformatted text.</p>
2137 <pre>This is preformatted text.
2138 So is this.</pre>
2139 !! end
2140
2141 !! test
2142 Space before tab needs nowiki pre protection
2143 !! options
2144 parsoid=html2wt
2145 !! html/parsoid
2146 <p> a</p>
2147 !! wikitext
2148 <nowiki> </nowiki> a
2149 !! end
2150
2151 !! test
2152 Ident preformatting with inline content
2153 !! wikitext
2154 a
2155 ''b''
2156 !! html
2157 <pre>a
2158 <i>b</i>
2159 </pre>
2160 !! end
2161
2162 !! test
2163 <pre> with <nowiki> inside (compatibility with 1.6 and earlier)
2164 !! wikitext
2165 <pre><nowiki>
2166 <b>
2167 <cite>
2168 <em>
2169 </nowiki></pre>
2170 !! html
2171 <pre>
2172 &lt;b&gt;
2173 &lt;cite&gt;
2174 &lt;em&gt;
2175 </pre>
2176
2177 !! end
2178
2179 !! test
2180 Regression with preformatted in <center>
2181 !! wikitext
2182 <center>
2183 Blah
2184 </center>
2185 !! html
2186 <center>
2187 <pre>Blah
2188 </pre>
2189 </center>
2190
2191 !! end
2192
2193 !! test
2194 T54763: Preformatted in <blockquote>
2195 !! wikitext
2196 <blockquote>
2197 Blah
2198 {|
2199 |
2200 indented cell (no pre-wrapping!)
2201 |}
2202 </blockquote>
2203 !! html
2204 <blockquote>
2205 <p> Blah
2206 </p>
2207 <table>
2208 <tr>
2209 <td>
2210 <p> indented cell (no pre-wrapping!)
2211 </p>
2212 </td></tr></table>
2213 </blockquote>
2214
2215 !! end
2216
2217 !! test
2218 T53086: Double newlines in blockquotes should be turned into paragraphs
2219 !! wikitext
2220 <blockquote>
2221 Foo
2222
2223 Bar
2224 </blockquote>
2225 !! html
2226 <blockquote>
2227 <p>Foo
2228 </p><p>Bar
2229 </p>
2230 </blockquote>
2231
2232 !! end
2233
2234 !! test
2235 T17491: <ins>/<del> in blockquote
2236 !! wikitext
2237 <blockquote>
2238 Foo <del>bar</del> <ins>baz</ins> quux
2239 </blockquote>
2240 !! html
2241 <blockquote>
2242 <p>Foo <del>bar</del> <ins>baz</ins> quux
2243 </p>
2244 </blockquote>
2245
2246 !! end
2247
2248 # Note that the p-wrapping is newline sensitive, which could be
2249 # considered a bug: tidy will wrap only the 'Foo' in the example
2250 # below in a <p> tag. (see comment 23-25 of T8200)
2251 !! test
2252 T17491: <ins>/<del> in blockquote (2)
2253 !! wikitext
2254 <blockquote>Foo <del>bar</del> <ins>baz</ins> quux
2255 </blockquote>
2256 !! html
2257 <blockquote>Foo <del>bar</del> <ins>baz</ins> quux
2258 </blockquote>
2259
2260 !! html+tidy
2261 <blockquote>
2262 <p>Foo</p>
2263 <del>bar</del> <ins>baz</ins> quux</blockquote>
2264 !! end
2265
2266 !! test
2267 <pre> with attributes (T5202)
2268 !! wikitext
2269 <pre style="background: blue; color:white">Bluescreen of WikiDeath</pre>
2270 !! html
2271 <pre style="background: blue; color:white">Bluescreen of WikiDeath</pre>
2272
2273 !! end
2274
2275 !! test
2276 <pre> with width attribute (T5202)
2277 !! wikitext
2278 <pre width="8">Narrow screen goodies</pre>
2279 !! html
2280 <pre width="8">Narrow screen goodies</pre>
2281
2282 !! end
2283
2284 !! test
2285 <pre> with forbidden attribute (T5202)
2286 !! wikitext
2287 <pre width="8" onmouseover="alert(document.cookie)">Narrow screen goodies</pre>
2288 !! html
2289 <pre width="8">Narrow screen goodies</pre>
2290
2291 !! end
2292
2293 !! test
2294 Entities inside <pre>
2295 !! wikitext
2296 <pre>&lt;</pre>
2297 !! html
2298 <pre>&lt;</pre>
2299
2300 !! end
2301
2302 !! test
2303 <pre> with forbidden attribute values (T5202)
2304 !! wikitext
2305 <pre width="8" style="border-width: expression(alert(document.cookie))">Narrow screen goodies</pre>
2306 !! html
2307 <pre width="8" style="/* insecure input */">Narrow screen goodies</pre>
2308
2309 !! end
2310
2311 !! test
2312 <nowiki> inside <pre> (T15238)
2313 !! wikitext
2314 <pre>
2315 <nowiki>
2316 </pre>
2317 <pre>
2318 <nowiki></nowiki>
2319 </pre>
2320 <pre><nowiki><nowiki></nowiki>Foo<nowiki></nowiki></nowiki></pre>
2321 !! html
2322 <pre>
2323 &lt;nowiki&gt;
2324 </pre>
2325 <pre>
2326
2327 </pre>
2328 <pre>&lt;nowiki&gt;Foo&lt;/nowiki&gt;</pre>
2329
2330 !! end
2331
2332 !! test
2333 <nowiki> inside of #tag:pre
2334 !! wikitext
2335 {{#tag:pre|Foo <nowiki>&rarr;bar</nowiki>}}
2336 !! html/php
2337 <pre>Foo &#8594;bar</pre>
2338
2339 !! html/parsoid
2340 <pre about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"#tag:pre","function":"tag"},"params":{"1":{"wt":"Foo &lt;nowiki>&amp;rarr;bar&lt;/nowiki>"}},"i":0}}]}'>Foo <span typeof="mw:Entity">→</span>bar</pre>
2341 !! end
2342
2343 ## Don't expect this to rt, Parsoid drops the unmatched closing pre tags that
2344 ## aren't enclosed in nowikis.
2345 !! test
2346 <nowiki> and <pre> preference (first one wins)
2347 !! options
2348 parsoid=wt2html
2349 !! wikitext
2350 <pre>
2351 <nowiki>
2352 </pre>
2353 </nowiki>
2354 </pre>
2355
2356 <nowiki>
2357 <pre>
2358 <nowiki>
2359 </pre>
2360 </nowiki>
2361 </pre>
2362
2363 !! html/php
2364 <pre>
2365 &lt;nowiki&gt;
2366 </pre>
2367 <p>&lt;/nowiki&gt;
2368 &lt;/pre&gt;
2369 </p><p>
2370 &lt;pre&gt;
2371 &lt;nowiki&gt;
2372 &lt;/pre&gt;
2373
2374 &lt;/pre&gt;
2375 </p>
2376 !! html/parsoid
2377 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n&lt;nowiki>\n"}}'>&lt;nowiki>
2378 </pre>
2379 <p>&lt;/nowiki></p>
2380
2381
2382 <p><span typeof="mw:Nowiki">
2383 &lt;pre>
2384 &lt;nowiki>
2385 &lt;/pre>
2386 </span></p>
2387 !! end
2388
2389 !! test
2390 </pre> inside nowiki
2391 !! wikitext
2392 <nowiki></pre></nowiki>
2393 !! html
2394 <p>&lt;/pre&gt;
2395 </p>
2396 !! end
2397
2398 # Parsoid doesn't strip empty tags, like Tidy does.
2399 !! test
2400 Empty pre; pre inside other HTML tags (T56946)
2401 !! wikitext
2402 a
2403
2404 <div><pre>
2405 foo
2406 </pre></div>
2407 <pre></pre>
2408 !! html/php
2409 <p>a
2410 </p>
2411 <div><pre>
2412 foo
2413 </pre></div>
2414 <pre></pre>
2415
2416 !! html/php+tidy
2417 <p>a</p>
2418 <div>
2419 <pre>
2420 foo
2421 </pre></div>
2422 !! html/parsoid
2423 <p>a</p>
2424
2425 <div data-parsoid='{"stx":"html"}'><pre typeof="mw:Extension/pre" about="#mwt2" data-parsoid='{"stx":"html"}' data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\nfoo\n"}}'>foo
2426 </pre></div>
2427 <pre typeof="mw:Extension/pre" about="#mwt4" data-parsoid='{"stx":"html"}' data-mw='{"name":"pre","attrs":{},"body":{"extsrc":""}}'></pre>
2428 !! end
2429
2430 !! test
2431 HTML pre followed by indent-pre
2432 !! wikitext
2433 <pre>foo</pre>
2434 bar
2435 !! html
2436 <pre>foo</pre>
2437 <pre>bar
2438 </pre>
2439 !! end
2440
2441 # Note that tidy removes the empty <p> tags from the start and end.
2442 # Parsoid does not, by design.
2443 !! test
2444 Block tag pre
2445 !! wikitext
2446 <p><pre>foo</pre></p>
2447 !! html/php+tidy
2448 <pre>
2449 foo
2450 </pre>
2451 !! html/parsoid
2452 <p data-parsoid='{"stx":"html","autoInsertedEnd":true}'></p><pre typeof="mw:Extension/pre" about="#mwt2" data-parsoid='{"stx":"html"}' data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo"}}'>foo</pre><p data-parsoid='{"autoInsertedStart":true,"stx":"html"}'></p>
2453 !! end
2454
2455 !!test
2456 Templates: Indent-Pre: 1a. Templates that break a line should suppress <pre>
2457 !! wikitext
2458 {{echo|}}
2459 !! html
2460
2461 !!end
2462
2463 !!test
2464 Templates: Indent-Pre: 1b. Templates that break a line should suppress <pre>
2465 !! wikitext
2466 {{echo|
2467 foo}}
2468 !! html
2469 <p>foo
2470 </p>
2471 !!end
2472
2473 !! test
2474 Templates: Indent-Pre: 1c: Wrapping should be based on expanded content
2475 !! wikitext
2476 {{echo|a
2477 b}}
2478 !! html
2479 <pre>a
2480 </pre>
2481 <p>b
2482 </p>
2483 !!end
2484
2485 !! test
2486 Templates: Indent-Pre: 1d: Wrapping should be based on expanded content
2487 !! wikitext
2488 {{echo|a
2489 b
2490 c
2491 d
2492 e
2493 }}
2494 !! html
2495 <pre>a
2496 </pre>
2497 <p>b
2498 c
2499 </p>
2500 <pre>d
2501 </pre>
2502 <p>e
2503 </p>
2504 !!end
2505
2506 !!test
2507 Templates: Indent-Pre: 1e. Wrapping should be based on expanded content
2508 !! wikitext
2509 {{echo| foo}}
2510
2511 {{echo| foo}}{{echo| bar}}
2512
2513 {{echo| foo}}
2514 {{echo| bar}}
2515
2516 {{echo|<!--cmt--> foo}}
2517
2518 <!--cmt-->{{echo| foo}}
2519
2520 {{echo|{{echo| }}bar}}
2521 !! html
2522 <pre>foo
2523 </pre>
2524 <pre>foo bar
2525 </pre>
2526 <pre>foo
2527 bar
2528 </pre>
2529 <pre>foo
2530 </pre>
2531 <pre>foo
2532 </pre>
2533 <pre>bar
2534 </pre>
2535 !!end
2536
2537 !! test
2538 Templates: Indent-Pre: 1f: Wrapping should be based on expanded content
2539 !! wikitext
2540 {{echo| }}a
2541
2542 {{echo|
2543 }}a
2544
2545 {{echo|
2546 b}}
2547
2548 {{echo|a
2549 }}b
2550
2551 {{echo|a
2552 }} b
2553 !! html
2554 <pre>a
2555 </pre>
2556 <p><br />
2557 </p>
2558 <pre>a
2559 </pre>
2560 <p><br />
2561 </p>
2562 <pre>b
2563 </pre>
2564 <p>a
2565 </p>
2566 <pre>b
2567 </pre>
2568 <p>a
2569 </p>
2570 <pre>b
2571 </pre>
2572 !!end
2573
2574 ## Hmm, should Parsoid rt this?
2575 !! test
2576 Pres with newline attributes
2577 !! options
2578 parsoid=wt2html,html2html
2579 !! wikitext
2580 <pre class="one
2581 two">hi</pre>
2582 !! html/php
2583 <pre class="one two">hi</pre>
2584
2585 !! html/parsoid
2586 <pre typeof="mw:Extension/pre" about="#mwt2" class="one two" data-mw='{"name":"pre","attrs":{"class":"one two"},"body":{"extsrc":"hi"}}'>hi</pre>
2587 !! end
2588
2589 !! test
2590 Things that look like <pre> tags aren't treated as such
2591 !! wikitext
2592 Barack Obama <President> of the United States
2593 <President></President>
2594 !! html
2595 <p>Barack Obama &lt;President&gt; of the United States
2596 &lt;President&gt;&lt;/President&gt;
2597 </p>
2598 !! end
2599
2600 !! test
2601 Handle broken pre-like tags (T66025)
2602 !! options
2603 parsoid=wt2html
2604 !! wikitext
2605 {{echo|<pre <pre>x</pre>}}
2606
2607 <table><pre </table>
2608 !! html/php
2609 <pre>x</pre>
2610 <table>&lt;pre </table>
2611
2612 !! html/php+tidy
2613 <pre>
2614 x
2615 </pre>
2616 <p>&lt;pre</p>
2617 !! html/parsoid
2618 <pre about="#mwt1" typeof="mw:Transclusion mw:Extension/pre" data-parsoid='{"a":{"&lt;pre":null},"sa":{"&lt;pre":""},"stx":"html","pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;pre &lt;pre>x&lt;/pre>"}},"i":0}}]}'>x</pre>
2619
2620
2621 <p>&lt;pre </p>
2622
2623 <table></table>
2624 !! end
2625
2626 !! test
2627 Parsoid: handle pre with space after attribute
2628 !! options
2629 parsoid=wt2html
2630 !! wikitext
2631 <pre style="width:50%;" >{{echo|foo}}</pre>
2632 !! html/php
2633 <pre style="width:50%;">{{echo|foo}}</pre>
2634
2635 !! html/parsoid
2636 <pre typeof="mw:Extension/pre" about="#mwt2" style="width:50%;" data-mw='{"name":"pre","attrs":{"style":"width:50%;"},"body":{"extsrc":"{{echo|foo}}"}}'>{{echo|foo}}</pre>
2637 !! end
2638
2639 # TODO / maybe: fix wt2wt for this
2640 !! test
2641 Parsoid: Don't paragraph-wrap fosterable content
2642 !! options
2643 parsoid=wt2html
2644 !! wikitext
2645 {|
2646 <td></td>
2647 <td></td>
2648
2649
2650
2651 |}
2652 !! html
2653 <table>
2654
2655 <tbody>
2656 <tr>
2657 <td></td>
2658
2659 <td></td></tr>
2660
2661
2662
2663 </tbody></table>
2664 !! end
2665
2666 !! test
2667 Parsoid: Don't paragraph-wrap fosterable content even if table syntax is unbalanced
2668 !! options
2669 parsoid=wt2html
2670 !! wikitext
2671 {|
2672 <td>
2673 <td>
2674 </td>
2675
2676
2677
2678 |}
2679 !! html
2680 <table>
2681
2682 <tbody>
2683 <tr>
2684 <td></td>
2685
2686 <td>
2687 </td></tr>
2688
2689
2690
2691 </tbody></table>
2692 !! end
2693
2694
2695 #--------------------------------------------------------------------
2696 # Transclusion parameter whitespace stripping tests
2697 # Behavior is different for positional and named parameters
2698 #--------------------------------------------------------------------
2699 !! test
2700 Templates: Strip leading and trailing whitespace from named-param values
2701 !! wikitext
2702 {{echo|1= a }}
2703
2704 {{echo|1= {{echo|b}} }}
2705
2706 {{echo| 1 =
2707 c }}
2708
2709 {{echo| 1 =
2710 * d
2711 }}
2712 !! html
2713 <p>a
2714 </p><p>b
2715 </p><p>c
2716 </p>
2717 <ul><li> d</li></ul>
2718
2719 !! end
2720
2721 !! test
2722 Templates: Don't strip whitespace from positional-param values
2723 !! wikitext
2724 {{echo|a }}
2725
2726 {{echo|{{echo|b}} }}
2727
2728 {{echo| c
2729 }}
2730
2731 {{echo| {{echo|d}}
2732 }}
2733
2734 {{echo|
2735 e}}
2736
2737 {{echo|
2738 * f}}
2739
2740 {{echo|
2741 }}g
2742 !! html
2743 <p>a
2744 </p><p>b
2745 </p>
2746 <pre>c
2747 </pre>
2748 <p><br />
2749 </p>
2750 <pre>d
2751 </pre>
2752 <p><br />
2753 </p>
2754 <pre>e
2755 </pre>
2756 <p><br />
2757 </p>
2758 <ul><li> f</li></ul>
2759 <p><br />
2760 </p>
2761 <pre>g
2762 </pre>
2763 !! end
2764
2765 !! test
2766 Templates: Don't recognize targets split by newlines
2767 !! options
2768 parsoid=wt2html
2769 !! wikitext
2770 {{ech
2771 o|foo}}
2772 !! html/php
2773 <p>{{ech
2774 o|foo}}
2775 </p>
2776 !! html/parsoid
2777 <p>{{ech
2778 o|foo}}</p>
2779 !! end
2780
2781 !! test
2782 Templates: Recognize targets when newlines and comments don't split the target
2783 !! options
2784 parsoid=wt2html
2785 !! wikitext
2786 {{
2787 <!--X--> ech<!--X-->o<!--X-->
2788 <!--X--> <!--X-->
2789
2790 |foo}}
2791 !! html/php
2792 <p>foo
2793 </p>
2794 !! html/parsoid
2795 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"ech&lt;!--X-->o&lt;!--X--> \n &lt;!--X--> &lt;!--X-->\n\n ","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</p>
2796 !! end
2797
2798 !! test
2799 Templates: Handle empty comment-and-ws-only lines correctly
2800 !! wikitext
2801 {{echo|foo
2802 <!--should be ignored-->
2803 <!--should be ignored as well-->
2804 bar}}
2805 !! html/php
2806 <p>foo
2807 bar
2808 </p>
2809 !! html/parsoid
2810 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo\n&lt;!--should be ignored-->\n &lt;!--should be ignored as well-->\nbar"}},"i":0}}]}'>foo <!--should be ignored--> <!--should be ignored as well--> bar</p>
2811 !! end
2812
2813 !! test
2814 Templates: Handle comments in the target
2815 !! wikitext
2816 {{echo
2817 <!-- should be ignored -->
2818 |foo}}
2819
2820 {{echo
2821 <!-- should be ignored and spaces on next line should not trip us up (T147742) -->
2822 |foo}}
2823
2824 {{echo<!-- should be ignored -->
2825 |foo}}
2826
2827 {{echo<!-- should be ignored -->|foo}}
2828
2829 {{<!-- should be ignored -->echo|foo}}
2830 !! html/php
2831 <p>foo
2832 </p><p>foo
2833 </p><p>foo
2834 </p><p>foo
2835 </p><p>foo
2836 </p>
2837 !! html/parsoid
2838 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo\n&lt;!-- should be ignored -->\n","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</p>
2839
2840 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo\n&lt;!-- should be ignored and spaces on next line should not trip us up (T147742) -->\n ","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</p>
2841
2842 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo&lt;!-- should be ignored -->\n","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</p>
2843
2844 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo&lt;!-- should be ignored -->","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</p>
2845
2846 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</p>
2847 !! end
2848
2849 !! test
2850 Templates: Handle comments in parameter names (T69657)
2851 !! wikitext
2852 {{echo|1
2853 <!-- should be ignored -->
2854 =foo}}
2855
2856 {{echo|
2857 <!-- should be ignored -->
2858 1 = foo}}
2859
2860 {{echo|1<!-- should be ignored -->=foo}}
2861
2862 {{echo|<!-- should be ignored -->1=foo}}
2863 !! html/php
2864 <p>foo
2865 </p><p>foo
2866 </p><p>foo
2867 </p><p>foo
2868 </p>
2869 !! html/parsoid
2870 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo","key":{"wt":"1\n&lt;!-- should be ignored -->"}}},"i":0}}]}'>foo</p>
2871
2872 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo","key":{"wt":"&lt;!-- should be ignored -->\n1"}}},"i":0}}]}'>foo</p>
2873
2874 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo","key":{"wt":"1&lt;!-- should be ignored -->"}}},"i":0}}]}'>foo</p>
2875
2876 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo","key":{"wt":"&lt;!-- should be ignored -->1"}}},"i":0}}]}'>foo</p>
2877 !! end
2878
2879 !! test
2880 Templates: Other wikitext in parameter names (T69657)
2881 !! wikitext
2882 {{echo|''1''=foo}}
2883 !! html/php
2884 <p>{{{1}}}
2885 </p>
2886 !! html/parsoid
2887 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"&#39;&#39;1&#39;&#39;":{"wt":"foo"}},"i":0}}]}'>{{{1}}}</p>
2888 !! end
2889
2890 !! test
2891 Templates: With colons
2892 !! wikitext
2893 {{With: Colon}}
2894 !! html/php
2895 <p>Template with colon
2896 </p>
2897 !! html/parsoid
2898 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"With: Colon","href":"./Template:With:_Colon"},"params":{},"i":0}}]}'>Template with colon</p>
2899 !! end
2900
2901 #--------------------------------------------------------------------
2902 # Transclusion parameter escaping tests
2903 #--------------------------------------------------------------------
2904
2905 !! test
2906 Templates: Parsoid parameter escaping test 1
2907 !! wikitext
2908 {{echo|[foo]|{{echo|[bar]}}}}
2909 !! html/php+tidy
2910 <p>[foo]</p>
2911 !! html/parsoid
2912 <p about="#mwt1" typeof="mw:Transclusion"
2913 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[foo]"},"2":{"wt":"{{echo|[bar]}}"}},"i":0}}]}'>[foo]</p>
2914 !! end
2915
2916 !! test
2917 Parsoid: Pipes in external links in template parameter
2918 !! wikitext
2919 {{echo|[{{echo|http://example.com}} link]}}
2920 !! html/php+tidy
2921 <p><a rel="nofollow" class="external text" href="http://example.com">link</a></p>
2922 !! html/parsoid
2923 <p><a rel="mw:ExtLink" href="http://example.com" about="#mwt31" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[{{echo|http://example.com}} link]"}},"i":0}}]}'>link</a></p>
2924 !! end
2925
2926 !! test
2927 Parsoid: pipe in transclusion parameter
2928 !! wikitext
2929 {{echo|http://foo.com/a&#124;b}}
2930 !! html/php+tidy
2931 <p><a rel="nofollow" class="external free" href="http://foo.com/a%7Cb">http://foo.com/a%7Cb</a></p>
2932 !! html/parsoid
2933 <p><a rel="mw:ExtLink" href="http://foo.com/a%7Cb" about="#mwt1"
2934 typeof="mw:Transclusion"
2935 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"http://foo.com/a&amp;#124;b"}},"i":0}}]}'>http://foo.com/a%7Cb</a></p>
2936 !! end
2937
2938 !! test
2939 Parsoid: Pipe in external link target and content in template parameter
2940 !! options
2941 parsoid=html2wt,wt2wt
2942 !! wikitext
2943 {{echo|[http://foo.com/a&#124;b a&#124;b]}}
2944 !! html/php+tidy
2945 <p><a rel="nofollow" class="external text" href="http://foo.com/a%7Cb">a|b</a></p>
2946 !! html/parsoid
2947 <p><a rel="mw:ExtLink" href="http://foo.com/a|b" about="#mwt1"
2948 typeof="mw:Transclusion"
2949 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},
2950 "params":{"1":{"wt":"[http://foo.com/a|b a|b]"}},"i":0}}]}'>a|b</a></p>
2951 !! end
2952
2953 !! test
2954 Parsoid: Pipe in template with nested template in external link target in template parameter (seriously)
2955 !! options
2956 parsoid
2957 !! wikitext
2958 {{echo|[{{fullurl:{{FULLPAGENAME}}|action=edit}} bar]}}
2959 !! html
2960 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[{{fullurl:{{FULLPAGENAME}}|action=edit}} bar]"}},"i":0}}]}'>[Main Page bar]</p>
2961 !! end
2962
2963 !! test
2964 Templates: Don't escape already nowiki-escaped text in template parameters
2965 !! options
2966 parsoid=html2wt,wt2wt
2967 !! wikitext
2968 {{echo|foo<nowiki>|</nowiki>bar}}
2969 {{echo|<nowiki>&lt;div&gt;</nowiki>}}
2970 {{echo|<nowiki></nowiki>}}
2971 !! html/php+tidy
2972 <p>foo|bar &lt;div&gt;</p>
2973 !! html/parsoid
2974 <p><span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo<nowiki>|</nowiki>bar"}},"i":0}}]}'}'>foo</span><span typeof="mw:Nowiki" about="#mwt1">|</span><span about="#mwt1">bar</span>
2975 <span typeof="mw:Transclusion mw:Nowiki" about="#mwt2" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"<nowiki>&amp;lt;div&amp;gt;</nowiki>"}},"i":0}}]}'><span typeof="mw:Entity">&lt;</span>div<span typeof="mw:Entity">&gt;</span></span>
2976 <span typeof="mw:Transclusion mw:Nowiki" about="#mwt3" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"<nowiki></nowiki>"}},"i":0}}]}'></span>
2977 </p>
2978 !! end
2979
2980 ## T54824
2981 !! test
2982 Templates: '=' char in nested transclusions should not trigger nowiki escapes or conversion to named param
2983 !! options
2984 parsoid=html2wt,wt2wt
2985 !! wikitext
2986 {{echo|{{echo|1=bar}}}}
2987 !! html/php+tidy
2988 <p>bar</p>
2989 !! html/parsoid
2990 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"{{echo|1=bar}}"}},"i":0}}]}'>bar</p>
2991 !! end
2992
2993 ## T58733
2994 !! test
2995 Templates parameters with special tokenizing behavior dont get modified because of arg escaping
2996 !! wikitext
2997 {{echo|a : b}}
2998 !! html/php+tidy
2999 <p>a&#160;: b</p>
3000 !! html/parsoid
3001 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"a : b"}},"i":0}}]}'>a<span typeof="mw:DisplaySpace mw:Placeholder" data-parsoid='{"isDisplayHack":true}'> </span>: b</p>
3002 !! end
3003
3004 ## T73412
3005 !! test
3006 Templates: Preserve blank parameter names
3007 !! wikitext
3008 {{echo|=foo}}
3009 !! html/php+tidy
3010 <p>{{{1}}}</p>
3011 !! html/parsoid
3012 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"":{"wt":"foo"}},"i":0}}]}'>{{{1}}}</p>
3013 !! end
3014
3015 !! test
3016 Templates: Preserve blank parameter names in other positions
3017 !! wikitext
3018 {{blank_param|bar|=foo}}
3019 !! html/php+tidy
3020 <p>bar foo</p>
3021 !! html/parsoid
3022 <p about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1"},{"k":"","named":true}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"blank_param","href":"./Template:Blank_param"},"params":{"1":{"wt":"bar"},"":{"wt":"foo"}},"i":0}}]}'>bar
3023 foo</p>
3024 !! end
3025
3026 ###
3027 ### Parsoid-centric tests for testing RT edge cases for pre
3028 ###
3029
3030 !!test
3031 1a. Indent-Pre and Comments
3032 !! wikitext
3033 a
3034 <!--a-->
3035 c
3036 !! html
3037 <pre>a
3038 </pre>
3039 <p>c
3040 </p>
3041 !!end
3042
3043 !!test
3044 1b. Indent-Pre and Comments
3045 !! wikitext
3046 a
3047 <!--a-->
3048 c
3049 !! html
3050 <pre>a
3051 </pre>
3052 <p>c
3053 </p>
3054 !!end
3055
3056 !!test
3057 1c. Indent-Pre and Comments
3058 !! wikitext
3059 <!--a--> a
3060
3061 <!--a--> a
3062 !! html
3063 <pre> a
3064 </pre>
3065 <pre> a
3066 </pre>
3067 !!end
3068
3069 !!test
3070 1d. Indent-Pre and Comments
3071 (Pre-handler currently cannot distinguish between comment/ws order and normalizes them to [comment,ws] order)
3072 !! wikitext
3073 <!--a--> a
3074
3075 <!--b-->b
3076 !! html
3077 <pre>a
3078 </pre>
3079 <pre>b
3080 </pre>
3081 !!end
3082
3083 !!test
3084 2a. Indent-Pre and tables
3085 !! wikitext
3086 {|
3087 |-
3088 !h1!!h2
3089 |foo||bar
3090 |}
3091 !! html
3092 <table>
3093
3094 <tr>
3095 <th>h1</th>
3096 <th>h2
3097 </th>
3098 <td>foo</td>
3099 <td>bar
3100 </td></tr></table>
3101
3102 !!end
3103
3104 !!test
3105 2b. Indent-Pre and tables
3106 !! wikitext
3107 {|
3108 |-
3109 |foo
3110 |}
3111 !! html
3112 <table>
3113
3114 <tr>
3115 <td>foo
3116 </td></tr></table>
3117
3118 !!end
3119
3120 !!test
3121 2c. Indent-Pre and tables (T44252)
3122 !! wikitext
3123 {|
3124 |+ foo
3125 ! | bar
3126 |}
3127 !! html
3128 <table>
3129 <caption> foo
3130 </caption>
3131 <tr>
3132 <th> bar
3133 </th></tr></table>
3134
3135 !!end
3136
3137 !!test
3138 2d. Indent-Pre and tables
3139 !! wikitext
3140 a
3141 {|
3142 | b
3143 |}
3144 !! html/php
3145 <pre>a
3146 </pre>
3147 <table>
3148 <tr>
3149 <td> b
3150 </td></tr></table>
3151
3152 !! html/parsoid
3153 <pre>a</pre>
3154 <table>
3155 <tbody><tr><td> b</td></tr>
3156 </tbody></table>
3157 !!end
3158
3159 !!test
3160 2e. Indent-Pre and table-line syntax
3161 !! wikitext
3162 a
3163 | b
3164 | c
3165 !! html/php
3166 <pre>a
3167 | b
3168 | c
3169 </pre>
3170 !!end
3171
3172 !!test
3173 2f. Indent-pre started by table-line syntax
3174 !! wikitext
3175 a
3176 | b
3177 | c
3178 !! html/php
3179 <p>a
3180 </p>
3181 <pre>| b
3182 | c
3183 </pre>
3184 !! html/parsoid
3185 <p>a</p>
3186 <pre>
3187 | b
3188 | c</pre>
3189 !!end
3190
3191 !! test
3192 2g. Indented table markup mixed with indented pre content (proposed in T8200)
3193 !! wikitext
3194 <table>
3195 <tr>
3196 <td>
3197 Text that should be rendered preformatted
3198 </td>
3199 </tr>
3200 </table>
3201 !! html
3202 <table>
3203 <tr>
3204 <td>
3205 <pre>Text that should be rendered preformatted
3206 </pre>
3207 </td>
3208 </tr>
3209 </table>
3210
3211 !! end
3212
3213 !!test
3214 3a. Indent-Pre and block tags (single-line html)
3215 !! wikitext
3216 a <p> foo </p>
3217 b <div> foo </div>
3218 c <blockquote> foo </blockquote>
3219 <span> foo </span>
3220 !! html
3221 a <p> foo </p>
3222 b <div> foo </div>
3223 c <blockquote> foo </blockquote>
3224 <pre><span> foo </span>
3225 </pre>
3226 !! html/parsoid
3227 <p>a </p><p data-parsoid='{"stx":"html"}'> foo </p>
3228 <p>b </p><div data-parsoid='{"stx":"html"}'> foo </div>
3229 <p>c </p><blockquote data-parsoid='{"stx":"html"}'> foo </blockquote>
3230 <pre><span> foo </span>
3231 </pre>
3232 !! html+tidy
3233 <p>a</p>
3234 <p>foo</p>
3235 <p>b</p>
3236 <div>foo</div>
3237 <p>c</p>
3238 <blockquote>
3239 <p>foo</p>
3240 </blockquote>
3241 <pre>
3242 <span> foo </span>
3243 </pre>
3244 !! end
3245
3246 !!test
3247 3b. Indent-Pre and block tags (multi-line html)
3248 !! wikitext
3249 a <span>foo</span>
3250 b <div> foo </div>
3251 !! html
3252 <pre>a <span>foo</span>
3253 </pre>
3254 b <div> foo </div>
3255
3256 !! html/parsoid
3257 <pre>a <span data-parsoid='{"stx":"html"}'>foo</span></pre>
3258 b <div data-parsoid='{"stx":"html"}'> foo </div>
3259 !! html+tidy
3260 <pre>
3261 a <span>foo</span>
3262 </pre>
3263 <p>b</p>
3264 <div>foo</div>
3265 !!end
3266
3267 !!test
3268 3c. Indent-Pre and block tags (pre-content on separate line)
3269 !! wikitext
3270 <p>
3271 foo
3272 </p>
3273
3274 <div>
3275 foo
3276 </div>
3277
3278 <center>
3279 foo
3280 </center>
3281
3282 <blockquote>
3283 foo
3284 </blockquote>
3285
3286 <blockquote>
3287 <pre>
3288 foo
3289 </pre>
3290 </blockquote>
3291
3292 <table><tr><td>
3293 foo
3294 </td></tr></table>
3295
3296 <ul><li>
3297 foo
3298 </li></ul>
3299
3300 !! html
3301 <p>
3302 foo
3303 </p>
3304 <div>
3305 <pre>foo
3306 </pre>
3307 </div>
3308 <center>
3309 <pre>foo
3310 </pre>
3311 </center>
3312 <blockquote>
3313 <p> foo
3314 </p>
3315 </blockquote>
3316 <blockquote>
3317 <pre>
3318 foo
3319 </pre>
3320 </blockquote>
3321 <table><tr><td>
3322 <pre>foo
3323 </pre>
3324 </td></tr></table>
3325 <ul><li>
3326 foo
3327 </li></ul>
3328
3329 !!end
3330
3331 !! test
3332 4. Indent-Pre and extension tags
3333 !! wikitext
3334 a <tag />
3335 !! html/php
3336 a <pre>
3337 NULL
3338 array (
3339 )
3340 </pre>
3341
3342 !! html/parsoid
3343 a <pre typeof="mw:Extension/tag" about="#mwt2" data-parsoid='{}' data-mw='{"name":"tag","attrs":{},"body":null}'></pre>
3344 !! end
3345
3346 !! test
3347 5. Indent-Pre and html pre
3348 !! wikitext
3349 <pre class="123">hi</pre>
3350 !! html/php
3351 <pre class="123">hi</pre>
3352
3353 !! html/parsoid
3354 <pre typeof="mw:Extension/pre" about="#mwt2" class="123" data-mw='{"name":"pre","attrs":{"class":"123"},"body":{"extsrc":"hi"}}'>hi</pre>
3355 !! end
3356
3357 !!test
3358 Render paragraphs when indent-pre is suppressed in blocklevels
3359 !! wikitext
3360 <blockquote>
3361 foo
3362
3363 bar
3364 </blockquote>
3365 !! html
3366 <blockquote>
3367 <p> foo
3368 </p><p> bar
3369 </p>
3370 </blockquote>
3371
3372 !!end
3373
3374 !!test
3375 4. Multiple spaces at start-of-line
3376 !! wikitext
3377 <p> foo </p>
3378 foo
3379 {|
3380 |foo
3381 |}
3382 !! html
3383 <p> foo </p>
3384 <pre> foo
3385 </pre>
3386 <table>
3387 <tr>
3388 <td>foo
3389 </td></tr></table>
3390
3391 !!end
3392
3393 ## NOTE: the leading white-space chars on empty line are significant
3394 !! test
3395 5a. White-space in indent-pre
3396 !! wikitext
3397 a<br />
3398
3399 b
3400 !! html
3401 <pre>a<br />
3402
3403 b
3404 </pre>
3405 !! end
3406
3407 ## NOTE: the leading white-space chars on empty line are significant
3408 !! test
3409 5b. White-space in indent-pre
3410 !! wikitext
3411 a
3412
3413 b
3414
3415
3416 c
3417 !! html
3418 <pre>a
3419
3420 b
3421
3422
3423 c
3424 </pre>
3425 !! end
3426
3427 !! test
3428 5c. White-space in indent-pre
3429 !! wikitext
3430 ''a''
3431 ''b''
3432 ''c''
3433 !! html
3434 <pre><i>a</i>
3435 <i>b</i>
3436 <i>c</i>
3437 </pre>
3438 !! end
3439
3440 !! test
3441 6. Pre-blocks should extend across lines with leading WS even when there is no wrappable content
3442 !! wikitext
3443 a
3444
3445 <!-- continue -->
3446 b
3447
3448 c
3449
3450 d
3451 !! html
3452 <pre>a
3453
3454 b
3455 </pre>
3456 <pre>c
3457
3458 </pre>
3459 <p>d
3460 </p>
3461 !! end
3462
3463 !! test
3464 7a. Indent-pre and category links
3465 !! options
3466 parsoid=wt2html,wt2wt
3467 !! wikitext
3468 [[Category:foo]] <!-- No pre-wrapping -->
3469 {{echo| [[Category:foo]]}} <!-- No pre-wrapping -->
3470 !! html/php+tidy
3471 !! html/parsoid
3472 <link rel="mw:PageProp/Category" href="./Category:Foo"> <!-- No pre&#x2D;wrapping -->
3473 <span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":" [[Category:foo]]"}},"i":0}}]}'> </span><link rel="mw:PageProp/Category" href="./Category:Foo" about="#mwt1"> <!-- No pre&#x2D;wrapping -->
3474 !! end
3475
3476 ## We used to, but no longer wt2wt this test since the default serializer
3477 ## will normalize all categories to serialize on their own line.
3478 ## This wikitext usage is going to be fairly uncommon in production and
3479 ## selser will take care of preserving formatting in those scenarios.
3480 !! test
3481 7b. Indent-pre and category links
3482 !! options
3483 parsoid=wt2html
3484 !! wikitext
3485 [[Category:foo]] a
3486 [[Category:foo]] {{echo|b}}
3487 !! html/parsoid
3488 <pre><link rel="mw:PageProp/Category" href="./Category:Foo"> a
3489 <link rel="mw:PageProp/Category" href="./Category:Foo"> <span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"b"}},"i":0}}]}'>b</span></pre>
3490 !! end
3491
3492 !! test
3493 Indent-Pre: Newlines in comments shouldn't affect sol state
3494 !! wikitext
3495 a <!--
3496 foo
3497 --> b
3498 !! html/php+tidy
3499 <p>a b</p>
3500 !! html/parsoid
3501 <p>a <!--
3502 foo
3503 --> b</p>
3504 !! end
3505
3506 ###
3507 ### HTML-pre (some to spec PHP parser behavior and some Parsoid-RT-centric)
3508 ###
3509
3510 !!test
3511 HTML-pre: 1. embedded newlines
3512 !! wikitext
3513 <pre>foo</pre>
3514
3515 <pre>
3516 foo
3517 </pre>
3518
3519 <pre>
3520
3521 foo
3522 </pre>
3523
3524 <pre>
3525
3526
3527 foo
3528 </pre>
3529 !! html/php+tidy
3530 <pre>
3531 foo
3532 </pre>
3533 <pre>
3534 foo
3535 </pre>
3536 <pre>
3537
3538 foo
3539 </pre>
3540 <pre>
3541
3542
3543 foo
3544 </pre>
3545 !! html/parsoid
3546 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo"}}'>foo</pre>
3547
3548 <pre typeof="mw:Extension/pre" about="#mwt4" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\nfoo\n"}}'>foo
3549 </pre>
3550
3551 <pre typeof="mw:Extension/pre" about="#mwt6" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n\nfoo\n"}}'>
3552
3553 foo
3554 </pre>
3555
3556 <pre typeof="mw:Extension/pre" about="#mwt8" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n\n\nfoo\n"}}'>
3557
3558
3559 foo
3560 </pre>
3561 !!end
3562
3563 !! test
3564 HTML-pre: big spaces
3565 !! wikitext
3566 <pre>
3567
3568
3569
3570
3571 haha
3572
3573
3574
3575
3576 haha
3577
3578
3579
3580
3581 </pre>
3582 !! html/php+tidy
3583 <pre>
3584
3585
3586
3587
3588 haha
3589
3590
3591
3592
3593 haha
3594
3595
3596
3597
3598 </pre>
3599 !! html/parsoid
3600 <pre typeof="mw:Extension/pre" about="#mwt2" data-parsoid='{"stx":"html"}' data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n\n\n\n\nhaha\n\n\n\n\nhaha\n\n\n\n\n"}}'>
3601
3602
3603
3604
3605 haha
3606
3607
3608
3609
3610 haha
3611
3612
3613
3614
3615 </pre>
3616 !! end
3617
3618 !!test
3619 HTML-pre: 2: indented text
3620 !! wikitext
3621 <pre>
3622 foo
3623 </pre>
3624 !! html
3625 <pre>
3626 foo
3627 </pre>
3628
3629 !!end
3630
3631 !!test
3632 HTML-pre: 3: other wikitext
3633 !! wikitext
3634 <pre>
3635 * foo
3636 # bar
3637 = no-h =
3638 '' no-italic ''
3639 [[ NoLink ]]
3640 </pre>
3641 !! html/php
3642 <pre>
3643 * foo
3644 # bar
3645 = no-h =
3646 '' no-italic ''
3647 [[ NoLink ]]
3648 </pre>
3649
3650 !! html/parsoid
3651 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n* foo\n# bar\n= no-h =\n&#39;&#39; no-italic &#39;&#39;\n[[ NoLink ]]\n"}}'>* foo
3652 # bar
3653 = no-h =
3654 '' no-italic ''
3655 [[ NoLink ]]
3656 </pre>
3657 !!end
3658
3659 ###
3660 ### Definition lists
3661 ###
3662 !! test
3663 Simple definition
3664 !! wikitext
3665 ; name : Definition
3666 !! html
3667 <dl><dt> name&#160;</dt>
3668 <dd> Definition</dd></dl>
3669
3670 !! end
3671
3672 !! test
3673 Definition list for indentation only
3674 !! wikitext
3675 : Indented text
3676 !! html
3677 <dl><dd> Indented text</dd></dl>
3678
3679 !! end
3680
3681 !! test
3682 Definition list with no space
3683 !! wikitext
3684 ;name:Definition
3685 !! html
3686 <dl><dt>name</dt>
3687 <dd>Definition</dd></dl>
3688
3689 !!end
3690
3691 !! test
3692 Definition list with URL link
3693 !! wikitext
3694 ; http://example.com/ : definition
3695 !! html
3696 <dl><dt> <a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a>&#160;</dt>
3697 <dd> definition</dd></dl>
3698
3699 !! end
3700
3701 !! test
3702 Definition list with bracketed URL link
3703 !! wikitext
3704 ;[http://www.example.com/ Example]:Something about it
3705 !! html
3706 <dl><dt><a rel="nofollow" class="external text" href="http://www.example.com/">Example</a></dt>
3707 <dd>Something about it</dd></dl>
3708
3709 !! end
3710
3711 !! test
3712 Definition list with wikilink containing colon
3713 !! wikitext
3714 ; [[Help:FAQ]]: The least-read page on Wikipedia
3715 !! html
3716 <dl><dt> <a href="/index.php?title=Help:FAQ&amp;action=edit&amp;redlink=1" class="new" title="Help:FAQ (page does not exist)">Help:FAQ</a></dt>
3717 <dd> The least-read page on Wikipedia</dd></dl>
3718
3719 !! end
3720
3721 # At Brion's and JeLuF's insistence... :)
3722 !! test
3723 Definition list with news link containing colon
3724 !! wikitext
3725 ; news:alt.wikipedia.rox: This isn't even a real newsgroup!
3726 !! html/php
3727 <dl><dt> <a rel="nofollow" class="external free" href="news:alt.wikipedia.rox">news:alt.wikipedia.rox</a></dt>
3728 <dd> This isn't even a real newsgroup!</dd></dl>
3729
3730 !! html/parsoid
3731 <dl><dt> <a rel="mw:ExtLink" href="news:alt.wikipedia.rox" data-parsoid='{"stx":"url"}'>news:alt.wikipedia.rox</a></dt><dd data-parsoid='{"stx":"row"}'> This isn't even a real newsgroup!</dd></dl>
3732 !! end
3733
3734 !! test
3735 Malformed definition list with colon
3736 !! wikitext
3737 ; news:alt.wikipedia.rox -- don't crash or enter an infinite loop
3738 !! html
3739 <dl><dt> <a rel="nofollow" class="external free" href="news:alt.wikipedia.rox">news:alt.wikipedia.rox</a> -- don't crash or enter an infinite loop</dt></dl>
3740
3741 !! end
3742
3743 !! test
3744 Definition lists: colon in external link text
3745 !! wikitext
3746 ; [http://www.wikipedia2.org/ Wikipedia : The Next Generation]: OK, I made that up
3747 !! html
3748 <dl><dt> <a rel="nofollow" class="external text" href="http://www.wikipedia2.org/">Wikipedia&#160;: The Next Generation</a></dt>
3749 <dd> OK, I made that up</dd></dl>
3750
3751 !! end
3752
3753 !! test
3754 Definition lists: colon in HTML attribute
3755 !! wikitext
3756 ;<b style="display: inline">bold</b>
3757 !! html
3758 <dl><dt><b style="display: inline">bold</b></dt></dl>
3759
3760 !! end
3761
3762 !! test
3763 Definition lists: self-closed tag
3764 !! wikitext
3765 ;one<br/>two : two-line fun
3766 !! html
3767 <dl><dt>one<br />two&#160;</dt>
3768 <dd> two-line fun</dd></dl>
3769
3770 !! end
3771
3772 !! test
3773 Definition lists: ignore colons inside tags
3774 !! wikitext
3775 ;one <b>two : tag <i>fun:</i>:</b>: def
3776 !! html
3777 <dl><dt>one <b>two&#160;: tag <i>fun:</i>:</b></dt>
3778 <dd> def</dd></dl>
3779
3780 !! end
3781
3782 !! test
3783 Definition lists: excess closed tags
3784 !! wikitext
3785 ;one</b>two : bad tag fun
3786 !! html/php+tidy
3787 <dl>
3788 <dt>onetwo&#160;</dt>
3789 <dd>bad tag fun</dd>
3790 </dl>
3791 !! html/parsoid
3792 <dl>
3793 <dt>onetwo</dt>
3794 <dd>bad tag fun</dd>
3795 </dl>
3796 !! end
3797
3798 !! test
3799 T13748: Literal closing tags
3800 !! wikitext
3801 <dl>
3802 <dt>test 1</dt>
3803 <dd>test test test test test</dd>
3804 <dt>test 2</dt>
3805 <dd>test test test test test</dd>
3806 </dl>
3807 !! html
3808 <dl>
3809 <dt>test 1</dt>
3810 <dd>test test test test test</dd>
3811 <dt>test 2</dt>
3812 <dd>test test test test test</dd>
3813 </dl>
3814
3815 !! end
3816
3817 !! test
3818 Definition and unordered list using wiki syntax nested in unordered list using html tags.
3819 !! wikitext
3820 <ul><li>
3821 ; term : description
3822 * unordered
3823 </li></ul>
3824 !! html
3825 <ul><li>
3826 <dl><dt> term&#160;</dt>
3827 <dd> description</dd></dl>
3828 <ul><li> unordered</li></ul>
3829 </li></ul>
3830
3831 !! end
3832
3833 !! test
3834 Definition list with empty definition and following paragraph
3835 !! wikitext
3836 ; term:
3837 Paragraph text
3838 !! html
3839 <dl><dt> term</dt>
3840 <dd></dd></dl>
3841 <p>Paragraph text
3842 </p>
3843 !! end
3844
3845 !! test
3846 Nested definition lists using html syntax
3847 !! wikitext
3848 <dl><dt>x</dt>
3849 <dd>a</dd>
3850 <dd>b</dd></dl>
3851 !! html
3852 <dl><dt>x</dt>
3853 <dd>a</dd>
3854 <dd>b</dd></dl>
3855
3856 !! end
3857
3858 !! test
3859 Definition Lists: No nesting: Multiple dd's
3860 !! wikitext
3861 ;x
3862 :a
3863 :b
3864 !! html
3865 <dl><dt>x</dt>
3866 <dd>a</dd>
3867 <dd>b</dd></dl>
3868
3869 !! end
3870
3871 !! test
3872 Definition Lists: Indentation: Regular
3873 !! wikitext
3874 :i1
3875 ::i2
3876 :::i3
3877 !! html
3878 <dl><dd>i1
3879 <dl><dd>i2
3880 <dl><dd>i3</dd></dl></dd></dl></dd></dl>
3881
3882 !! end
3883
3884 !! test
3885 Definition Lists: Indentation: Missing 1st level
3886 !! wikitext
3887 ::i2
3888 :::i3
3889 !! html
3890 <dl><dd><dl><dd>i2
3891 <dl><dd>i3</dd></dl></dd></dl></dd></dl>
3892
3893 !! end
3894
3895 !! test
3896 Definition Lists: Indentation: Multi-level indent
3897 !! wikitext
3898 :::i3
3899 !! html
3900 <dl><dd><dl><dd><dl><dd>i3</dd></dl></dd></dl></dd></dl>
3901
3902 !! end
3903
3904 !! test
3905 Definition Lists: Hacky use to indent tables
3906 !! wikitext
3907 ::{|
3908 |foo
3909 |bar
3910 |}
3911 this text
3912 should be left alone
3913 !! html
3914 <dl><dd><dl><dd><table>
3915 <tr>
3916 <td>foo
3917 </td>
3918 <td>bar
3919 </td></tr></table></dd></dl></dd></dl>
3920 <p>this text
3921 should be left alone
3922 </p>
3923 !! end
3924
3925 !! test
3926 Definition Lists: Hacky use to indent tables, with comments (T65979)
3927 !! wikitext
3928 <!-- foo -->
3929 ::{|
3930 |foo
3931 |bar
3932 |}<!-- bar -->
3933 this text
3934 should be left alone
3935 !! html/parsoid
3936 <!-- foo -->
3937 <dl><dd><dl><dd><table><tr>
3938 <td>foo</td>
3939 <td>bar</td>
3940 </tr></table><!-- bar --></dd></dl></dd></dl>
3941 <p>this text
3942 should be left alone</p>
3943 !! end
3944
3945 !! test
3946 Definition Lists: Hacky use to indent tables, with comment before table
3947 !! wikitext
3948 ::<!-- foo -->{|
3949 |foo
3950 |}
3951 !! html/parsoid
3952 <dl><dd><dl><dd><!-- foo --><table><tr>
3953 <td>foo</td>
3954 </tr></table></dd></dl></dd></dl>
3955 !! end
3956
3957 # The trailing whitespace in this test is to catch a regression in
3958 # Parsoid after T54473.
3959 !! test
3960 Definition Lists: Hacky use to indent tables (WS-insensitive)
3961 !! wikitext
3962 : {|
3963 |a
3964 |}
3965 !! html/php
3966 <dl><dd><table>
3967 <tr>
3968 <td>a
3969 </td></tr></table></dd></dl>
3970
3971 !! html/parsoid
3972 <dl><dd> <table>
3973 <tbody><tr><td>a</td></tr>
3974 </tbody></table> </dd></dl>
3975 !! end
3976
3977 ## The PHP parser treats : items (dd) without a corresponding ; item (dt)
3978 ## as an empty dt item. It also ignores all but the last ";" when followed
3979 ## by ":" later on. So, ";" are not ignored in ";;;t3" but are ignored in
3980 ## ";;;t3 :d1". So, PHP parser behavior is a little inconsistent wrt multiple
3981 ## ";"s.
3982 ##
3983 ## Ex: ";;t2 ::d2" is transformed into:
3984 ##
3985 ## <dl>
3986 ## <dt>t2 </dt>
3987 ## <dd>
3988 ## <dl>
3989 ## <dt></dt>
3990 ## <dd>d2</dd>
3991 ## </dl>
3992 ## </dd>
3993 ## </dl>
3994 ##
3995 ## But, Parsoid treats "; :" as a tight atomic unit and excess ":" as plain text
3996 ## So, the same wikitext above (;;t2 ::d2) is transformed into:
3997 ##
3998 ## <dl>
3999 ## <dt>
4000 ## <dl>
4001 ## <dt>t2 </dt>
4002 ## <dd>:d2</dd>
4003 ## </dl>
4004 ## </dt>
4005 ## </dl>
4006 ##
4007 ## All Parsoid only definition list tests have this difference.
4008 ##
4009 ## See also: https://phabricator.wikimedia.org/T8569
4010 ## and https://lists.wikimedia.org/pipermail/wikitext-l/2011-November/000483.html
4011
4012 !! test
4013 Table / list interaction: indented table with lists in table contents
4014 !! wikitext
4015 :{|
4016 |-
4017 | a
4018 * b
4019 |-
4020 | c
4021 * d
4022 |}
4023 !! html
4024 <dl><dd><table>
4025
4026 <tr>
4027 <td> a
4028 <ul><li> b</li></ul>
4029 </td></tr>
4030 <tr>
4031 <td> c
4032 <ul><li> d</li></ul>
4033 </td></tr></table></dd></dl>
4034
4035 !! end
4036
4037 !!test
4038 Table / list interaction: lists nested in tables nested in indented lists
4039 !! wikitext
4040 :{|
4041 |
4042 :a
4043 :b
4044 |
4045 *c
4046 *d
4047 |}
4048
4049 *e
4050 *f
4051 !! html
4052 <dl><dd><table>
4053 <tr>
4054 <td>
4055 <dl><dd>a</dd>
4056 <dd>b</dd></dl>
4057 </td>
4058 <td>
4059 <ul><li>c</li>
4060 <li>d</li></ul>
4061 </td></tr></table></dd></dl>
4062 <ul><li>e</li>
4063 <li>f</li></ul>
4064
4065 !!end
4066
4067 !! test
4068 Definition Lists: Nesting: Multi-level (Parsoid only)
4069 !! options
4070 parsoid
4071 !! wikitext
4072 ;t1 :d1
4073 ;;t2 ::d2
4074 ;;;t3 :::d3
4075 !! html
4076 <dl>
4077 <dt>t1 </dt>
4078 <dd>d1</dd>
4079 <dt>
4080 <dl>
4081 <dt>t2 </dt>
4082 <dd>:d2</dd>
4083 <dt>
4084 <dl>
4085 <dt>t3 </dt>
4086 <dd>::d3</dd>
4087 </dl>
4088 </dt>
4089 </dl>
4090 </dt>
4091 </dl>
4092
4093
4094 !! end
4095
4096
4097 !! test
4098 Definition Lists: Nesting: Test 2 (Parsoid only)
4099 !! wikitext
4100 ;t1
4101 ::d2
4102 !! html/php+tidy
4103 <dl>
4104 <dt>t1</dt>
4105 <dd>
4106 <dl>
4107 <dd>d2</dd>
4108 </dl>
4109 </dd>
4110 </dl>
4111 !! html/parsoid
4112 <dl>
4113 <dt>t1</dt>
4114 <dd>
4115 <dl>
4116 <dd>d2</dd>
4117 </dl>
4118 </dd>
4119 </dl>
4120
4121 !! end
4122
4123
4124 !! test
4125 Definition Lists: Nesting: Test 3 (Parsoid only)
4126 !! wikitext
4127 :;t1
4128 ::::d2
4129 !! html/php+tidy
4130 <dl>
4131 <dd>
4132 <dl>
4133 <dt>t1</dt>
4134 <dd>
4135 <dl>
4136 <dd>
4137 <dl>
4138 <dd>d2</dd>
4139 </dl>
4140 </dd>
4141 </dl>
4142 </dd>
4143 </dl>
4144 </dd>
4145 </dl>
4146 !! html/parsoid
4147 <dl>
4148 <dd>
4149 <dl>
4150 <dt>t1</dt>
4151 <dd>
4152 <dl>
4153 <dd>
4154 <dl>
4155 <dd>d2</dd>
4156 </dl>
4157 </dd>
4158 </dl>
4159 </dd>
4160 </dl>
4161 </dd>
4162 </dl>
4163
4164 !! end
4165
4166
4167 !! test
4168 Definition Lists: Nesting: Test 4
4169 !! wikitext
4170 ::;t3
4171 :::d3
4172 !! html
4173 <dl><dd><dl><dd><dl><dt>t3</dt>
4174 <dd>d3</dd></dl></dd></dl></dd></dl>
4175
4176 !! end
4177
4178
4179 ## The Parsoid team believes the following three test exposes a
4180 ## bug in the PHP parser. (Parsoid team thinks the PHP parser is
4181 ## wrong to close the <dl> after the <dt> containing the <ul>.)
4182 ## It also exposes a "misfeature" in tidy, which doesn't like
4183 ## <dl> tags with a single <dt> child; it converts the <dt> into
4184 ## a <dd> in that case. (Parsoid leaves the <dt> alone!)
4185 !! test
4186 Definition Lists: Mixed Lists: Test 1
4187 !! wikitext
4188 :;* foo
4189 ::* bar
4190 :; baz
4191 !! html/php
4192 <dl><dd><dl><dt><ul><li> foo</li>
4193 <li> bar</li></ul></dt></dl>
4194 <dl><dt> baz</dt></dl></dd></dl>
4195
4196 !! html/php+tidy
4197 <dl>
4198 <dd>
4199 <dl>
4200 <dd>
4201 <ul>
4202 <li>foo</li>
4203 <li>bar</li>
4204 </ul>
4205 </dd>
4206 </dl>
4207 <dl>
4208 <dt>baz</dt>
4209 </dl>
4210 </dd>
4211 </dl>
4212 !! html/parsoid
4213 <dl>
4214 <dd><dl>
4215 <dt><ul>
4216 <li> foo
4217 </li>
4218 </ul></dt>
4219 <dd><ul>
4220 <li> bar
4221 </li>
4222 </ul></dd>
4223 <dt> baz</dt>
4224 </dl></dd>
4225 </dl>
4226 !! end
4227
4228 !! test
4229 Definition Lists: Mixed Lists: Test 2
4230 !! wikitext
4231 *: d1
4232 *: d2
4233 !! html
4234 <ul><li><dl><dd> d1</dd>
4235 <dd> d2</dd></dl></li></ul>
4236
4237 !! end
4238
4239
4240 !! test
4241 Definition Lists: Mixed Lists: Test 3
4242 !! wikitext
4243 *::: d1
4244 *::: d2
4245 !! html
4246 <ul><li><dl><dd><dl><dd><dl><dd> d1</dd>
4247 <dd> d2</dd></dl></dd></dl></dd></dl></li></ul>
4248
4249 !! end
4250
4251
4252 !! test
4253 Definition Lists: Mixed Lists: Test 4
4254 !! wikitext
4255 *;d1 :d2
4256 *;d3 :d4
4257 !! html
4258 <ul><li><dl><dt>d1&#160;</dt>
4259 <dd>d2</dd>
4260 <dt>d3&#160;</dt>
4261 <dd>d4</dd></dl></li></ul>
4262
4263 !! end
4264
4265
4266 !! test
4267 Definition Lists: Mixed Lists: Test 5
4268 !! wikitext
4269 *:d1
4270 *:: d2
4271 !! html
4272 <ul><li><dl><dd>d1
4273 <dl><dd> d2</dd></dl></dd></dl></li></ul>
4274
4275 !! end
4276
4277
4278 !! test
4279 Definition Lists: Mixed Lists: Test 6
4280 !! wikitext
4281 #*:d1
4282 #*::: d3
4283 !! html
4284 <ol><li><ul><li><dl><dd>d1
4285 <dl><dd><dl><dd> d3</dd></dl></dd></dl></dd></dl></li></ul></li></ol>
4286
4287 !! end
4288
4289
4290 !! test
4291 Definition Lists: Mixed Lists: Test 7
4292 !! wikitext
4293 :* d1
4294 :* d2
4295 !! html
4296 <dl><dd><ul><li> d1</li>
4297 <li> d2</li></ul></dd></dl>
4298
4299 !! end
4300
4301
4302 !! test
4303 Definition Lists: Mixed Lists: Test 8
4304 !! wikitext
4305 :* d1
4306 ::* d2
4307 !! html
4308 <dl><dd><ul><li> d1</li></ul>
4309 <dl><dd><ul><li> d2</li></ul></dd></dl></dd></dl>
4310
4311 !! end
4312
4313
4314 !! test
4315 Definition Lists: Mixed Lists: Test 9
4316 !! wikitext
4317 *;foo :bar
4318 !! html
4319 <ul><li><dl><dt>foo&#160;</dt>
4320 <dd>bar</dd></dl></li></ul>
4321
4322 !! end
4323
4324
4325 !! test
4326 Definition Lists: Mixed Lists: Test 10
4327 !! wikitext
4328 *#;foo :bar
4329 !! html
4330 <ul><li><ol><li><dl><dt>foo&#160;</dt>
4331 <dd>bar</dd></dl></li></ol></li></ul>
4332
4333 !! end
4334
4335 # The Parsoid team disagrees with the PHP parser's seemingly-random
4336 # rules regarding dd/dt on the next two tests. Parsoid is more
4337 # consistent, and recognizes the shared nesting and keeps the
4338 # still-open tags around until the nesting is complete.
4339 # (And tidy again converts <dt> to <dd> before 'bar'.)
4340
4341 !! test
4342 Definition Lists: Mixed Lists: Test 11
4343 !! wikitext
4344 *#*#;*;;foo :bar
4345 *#*#;boo :baz
4346 !! html/php
4347 <ul><li><ol><li><ul><li><ol><li><dl><dt>foo&#160;</dt>
4348 <dd><ul><li><dl><dt><dl><dt>bar</dt></dl></dd></dl></li></ul></dd></dl>
4349 <dl><dt>boo&#160;</dt>
4350 <dd>baz</dd></dl></li></ol></li></ul></li></ol></li></ul>
4351
4352 !! html/php+tidy
4353 <ul>
4354 <li>
4355 <ol>
4356 <li>
4357 <ul>
4358 <li>
4359 <ol>
4360 <li>
4361 <dl>
4362 <dt>foo&#160;</dt>
4363 <dd>
4364 <ul>
4365 <li>
4366 <dl>
4367 <dd>
4368 <dl>
4369 <dt>bar</dt>
4370 </dl>
4371 </dd>
4372 </dl>
4373 </li>
4374 </ul>
4375 </dd>
4376 </dl>
4377 <dl>
4378 <dt>boo&#160;</dt>
4379 <dd>baz</dd>
4380 </dl>
4381 </li>
4382 </ol>
4383 </li>
4384 </ul>
4385 </li>
4386 </ol>
4387 </li>
4388 </ul>
4389 !! html/parsoid
4390 <ul>
4391 <li>
4392 <ol>
4393 <li>
4394 <ul>
4395 <li>
4396 <ol>
4397 <li>
4398 <dl>
4399 <dt>
4400 <ul>
4401 <li>
4402 <dl>
4403 <dt>
4404 <dl>
4405 <dt>foo<span typeof="mw:Placeholder" data-parsoid='{"src":" "}'>&nbsp;</span></dt>
4406 <dd data-parsoid='{"stx":"row"}'>bar</dd>
4407 </dl></dt>
4408 </dl></li>
4409 </ul></dt>
4410 <dt>boo<span typeof="mw:Placeholder" data-parsoid='{"src":" "}'>&nbsp;</span></dt>
4411 <dd data-parsoid='{"stx":"row"}'>baz</dd>
4412 </dl></li>
4413 </ol></li>
4414 </ul></li>
4415 </ol></li>
4416 </ul>
4417 !! end
4418
4419
4420 # Another case where tidy converts a <dt> to a <dd> (but Parsoid doesn't).
4421 # From whitelist:
4422 # * The test is wrong, there are two colons where there should be :;
4423 # * The PHP parser is wrong to close the <dl> after the <dt> containing the <ul>.
4424 !! test
4425 Definition Lists: Weird Ones: Test 1
4426 !! wikitext
4427 *#;*::;; foo : bar (who uses this?)
4428 !! html/php
4429 <ul><li><ol><li><dl><dt> foo&#160;</dt>
4430 <dd><ul><li><dl><dd><dl><dd><dl><dt><dl><dt> bar (who uses this?)</dt></dl></dd></dl></dd></dl></dd></dl></li></ul></dd></dl></li></ol></li></ul>
4431
4432 !! html/php+tidy
4433 <ul>
4434 <li>
4435 <ol>
4436 <li>
4437 <dl>
4438 <dt>foo&#160;</dt>
4439 <dd>
4440 <ul>
4441 <li>
4442 <dl>
4443 <dd>
4444 <dl>
4445 <dd>
4446 <dl>
4447 <dd>
4448 <dl>
4449 <dt>bar (who uses this?)</dt>
4450 </dl>
4451 </dd>
4452 </dl>
4453 </dd>
4454 </dl>
4455 </dd>
4456 </dl>
4457 </li>
4458 </ul>
4459 </dd>
4460 </dl>
4461 </li>
4462 </ol>
4463 </li>
4464 </ul>
4465 !! html/parsoid
4466 <ul>
4467 <li>
4468 <ol>
4469 <li>
4470 <dl>
4471 <dt>
4472 <ul>
4473 <li>
4474 <dl>
4475 <dd>
4476 <dl>
4477 <dd>
4478 <dl>
4479 <dt>
4480 <dl>
4481 <dt> foo<span typeof="mw:DisplaySpace mw:Placeholder" data-parsoid='{"src":" ","isDisplayHack":true}'> </span></dt>
4482 <dd data-parsoid='{"stx":"row"}'> bar (who uses this?)</dd>
4483 </dl></dt>
4484 </dl></dd>
4485 </dl></dd>
4486 </dl></li>
4487 </ul></dt>
4488 </dl></li>
4489 </ol></li>
4490 </ul>
4491 !! end
4492
4493 !! test
4494 Definition Lists: colons occurring in tags
4495 !! wikitext
4496 ;a:b
4497 ;'''a:b'''
4498 ;<i>a:b</i>
4499 ;<span>a:b</span>
4500 ;<div>a:b</div>
4501 ;<div>a
4502 :b</div>
4503 ;{{echo|a:b}}
4504 ;{{echo|''a:b''}}
4505 ;;;''a:b''
4506 !! html+tidy
4507 <dl>
4508 <dt>a</dt>
4509 <dd>b</dd>
4510 <dt><b>a:b</b></dt>
4511 <dt><i>a:b</i></dt>
4512 <dt><span>a:b</span></dt>
4513 <dd>
4514 <div>a:b</div>
4515 </dd>
4516 <dd>
4517 <div>a
4518 <dl>
4519 <dd>b</dd>
4520 </dl>
4521 </div>
4522 </dd>
4523 <dt>a</dt>
4524 <dd>b</dd>
4525 <dt><i>a:b</i></dt>
4526 </dl>
4527 <dl>
4528 <dd>
4529 <dl>
4530 <dd>
4531 <dl>
4532 <dt><i>a:b</i></dt>
4533 </dl>
4534 </dd>
4535 </dl>
4536 </dd>
4537 </dl>
4538 !! html/parsoid
4539 <dl><dt>a</dt><dd data-parsoid='{"stx":"row"}'>b</dd>
4540 <dt><b>a:b</b></dt>
4541 <dt><i data-parsoid='{"stx":"html"}'>a:b</i></dt>
4542 <dt><span data-parsoid='{"stx":"html"}'>a:b</span></dt>
4543 <dt><div data-parsoid='{"stx":"html"}'>a:b</div></dt>
4544 <dt><div data-parsoid='{"stx":"html","autoInsertedEnd":true}'>a</div></dt>
4545 <dd>b</dd>
4546 <dt><span about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"a:b"}},"i":0}}]}'>a:b</span></dt>
4547 <dt><i about="#mwt2" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&#39;&#39;a:b&#39;&#39;"}},"i":0}}]}'>a:b</i>
4548 <dl><dt><dl><dt><i>a:b</i></dt></dl></dt></dl></dt></dl>
4549 !! end
4550
4551 !! test
4552 Definition Lists: colons and tables 1
4553 !! wikitext
4554 :{|
4555 | x
4556 |}
4557 :{|
4558 | y
4559 |}
4560 !! html
4561 <dl><dd><table>
4562 <tr>
4563 <td> x
4564 </td></tr></table></dd></dl>
4565 <dl><dd><table>
4566 <tr>
4567 <td> y
4568 </td></tr></table></dd></dl>
4569
4570 !! end
4571
4572 # Parsoid's output (as documented below) differs from php's in this case.
4573 # This is probably a bug. If we fixup parsoid to match php's output, the
4574 # above test should pass and the below test case can be removed. It is
4575 # unclear which output is more desirable.
4576
4577 !! test
4578 Definition Lists: colons and tables 2
4579 !! wikitext
4580 :{|
4581 | x
4582 |}
4583 :{|
4584 | y
4585 |}
4586 !! html/parsoid
4587 <dl><dd><table>
4588 <tr>
4589 <td> x
4590 </td></tr></table></dd>
4591 <dd><table>
4592 <tr>
4593 <td> y
4594 </td></tr></table></dd></dl>
4595 !! end
4596
4597 !! test
4598 Definition Lists: template interaction
4599 !! wikitext
4600 ::{{definition_list}}
4601
4602 :one
4603 ::{{definition_list}}
4604 :::two
4605 :::three
4606 ::four
4607 !! html/parsoid
4608 <dl><dd><dl data-parsoid='{}'><dd about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[]]}' data-mw='{"parts":[":",{"template":{"target":{"wt":"definition_list","href":"./Template:Definition_list"},"params":{},"i":0}}]}'>one</dd><span about="#mwt1">
4609 </span><dd about="#mwt1">two</dd></dl></dd></dl>
4610
4611 <dl><dd data-parsoid='{}'>one
4612 <dl><dd about="#mwt2" typeof="mw:Transclusion" data-parsoid='{"pi":[[]]}' data-mw='{"parts":["::",{"template":{"target":{"wt":"definition_list","href":"./Template:Definition_list"},"params":{},"i":0}},"\n:::two\n:::three"]}'>one</dd><span about="#mwt2">
4613 </span><dd about="#mwt2">two
4614 <dl><dd>two</dd>
4615 <dd>three</dd></dl></dd>
4616 <dd data-parsoid='{}'>four</dd></dl></dd></dl>
4617 !! end
4618
4619
4620 ###
4621 ### External links
4622 ###
4623 !! test
4624 External links: non-bracketed
4625 !! wikitext
4626 Non-bracketed: http://example.com
4627 !! html
4628 <p>Non-bracketed: <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
4629 </p>
4630 !! end
4631
4632 # parsoid doesn't explicitly mark autonumbered links, see T55505
4633 !! test
4634 External links: numbered
4635 !! wikitext
4636 Numbered: [http://example.com]
4637 Numbered: [http://example.net]
4638 Numbered: [http://example.com]
4639 !! html/php
4640 <p>Numbered: <a rel="nofollow" class="external autonumber" href="http://example.com">[1]</a>
4641 Numbered: <a rel="nofollow" class="external autonumber" href="http://example.net">[2]</a>
4642 Numbered: <a rel="nofollow" class="external autonumber" href="http://example.com">[3]</a>
4643 </p>
4644 !! html/parsoid
4645 <p>Numbered: <a rel="mw:ExtLink" href="http://example.com"></a>
4646 Numbered: <a rel="mw:ExtLink" href="http://example.net"></a>
4647 Numbered: <a rel="mw:ExtLink" href="http://example.com"></a></p>
4648 !!end
4649
4650 !! test
4651 External links: specified text
4652 !! wikitext
4653 Specified text: [http://example.com link]
4654 !! html
4655 <p>Specified text: <a rel="nofollow" class="external text" href="http://example.com">link</a>
4656 </p>
4657 !!end
4658
4659 !! test
4660 External links: trail
4661 !! wikitext
4662 Linktrails should not work for external links: [http://example.com link]s
4663 !! html
4664 <p>Linktrails should not work for external links: <a rel="nofollow" class="external text" href="http://example.com">link</a>s
4665 </p>
4666 !! end
4667
4668 !! test
4669 External links: dollar sign in URL
4670 !! wikitext
4671 http://example.com/1$2345
4672 !! html
4673 <p><a rel="nofollow" class="external free" href="http://example.com/1$2345">http://example.com/1$2345</a>
4674 </p>
4675 !! end
4676
4677 # parsoid doesn't explicitly mark autonumbered links, see T55505
4678 !! test
4679 External links: dollar sign in URL (autonumber)
4680 !! wikitext
4681 [http://example.com/1$2345]
4682 !! html/php
4683 <p><a rel="nofollow" class="external autonumber" href="http://example.com/1$2345">[1]</a>
4684 </p>
4685 !! html/parsoid
4686 <p><a rel="mw:ExtLink" href="http://example.com/1$2345"></a></p>
4687 !!end
4688
4689 !! test
4690 External links: open square bracket forbidden in URL (T6377)
4691 !! options
4692 parsoid=wt2html,wt2wt,html2html
4693 !! wikitext
4694 http://example.com/1[2345
4695 !! html/php
4696 <p><a rel="nofollow" class="external free" href="http://example.com/1">http://example.com/1</a>[2345
4697 </p>
4698 !! html/parsoid
4699 <p><a rel="mw:ExtLink" href="http://example.com/1">http://example.com/1</a>[2345</p>
4700 !! end
4701
4702 !! test
4703 External links: open square bracket forbidden in URL (named) (T6377)
4704 !! options
4705 parsoid=wt2html,html2html
4706 !! wikitext
4707 [http://example.com/1[2345]
4708 !! html/php
4709 <p><a rel="nofollow" class="external text" href="http://example.com/1">[2345</a>
4710 </p>
4711 !! html/parsoid
4712 <p><a rel="mw:ExtLink" href="http://example.com/1">[2345</a></p>
4713 !!end
4714
4715 # parsoid adds a space before the link name
4716 !! test
4717 External links: open square bracket forbidden in URL (named) (T6377)
4718 Parsoid variant.
4719 !! wikitext
4720 [http://example.com/1 [2345]
4721 !! html
4722 <p><a rel="nofollow" class="external text" href="http://example.com/1">[2345</a>
4723 </p>
4724 !!end
4725
4726 !! test
4727 External links: nowiki in URL link text (T8230)
4728 !! wikitext
4729 [http://example.com/ <nowiki>''example site''</nowiki>]
4730 !! html
4731 <p><a rel="nofollow" class="external text" href="http://example.com/">''example site''</a>
4732 </p>
4733 !! end
4734
4735 !! test
4736 External links: newline forbidden in text (T8230 regression check)
4737 !! wikitext
4738 [http://example.com/ first
4739 second]
4740 !! html
4741 <p>[<a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a> first
4742 second]
4743 </p>
4744 !!end
4745
4746 !! test
4747 External links: Pipe char between url and text
4748 !! wikitext
4749 [http://example.com | link]
4750 !! html
4751 <p><a rel="nofollow" class="external text" href="http://example.com">| link</a>
4752 </p>
4753 !!end
4754
4755 !! test
4756 External links: protocol-relative URL in brackets
4757 !! wikitext
4758 [//example.com/ Test]
4759 !! html
4760 <p><a rel="nofollow" class="external text" href="//example.com/">Test</a>
4761 </p>
4762 !! end
4763
4764 # parsoid doesn't explicitly mark autonumbered links, see T55505
4765 !! test
4766 External links: protocol-relative URL in brackets without text
4767 !! wikitext
4768 [//example.com]
4769 !! html/php
4770 <p><a rel="nofollow" class="external autonumber" href="//example.com">[1]</a>
4771 </p>
4772 !! html/parsoid
4773 <p><a rel="mw:ExtLink" href="//example.com"></a></p>
4774 !! end
4775
4776 !! test
4777 External links: protocol-relative URL in free text is left alone
4778 !! wikitext
4779 //example.com/Foo
4780 !! html
4781 <p>//example.com/Foo
4782 </p>
4783 !!end
4784
4785 !! test
4786 External links: protocol-relative URL in the middle of a word is left alone (T32269)
4787 !! wikitext
4788 foo//example.com/Foo
4789 !! html
4790 <p>foo//example.com/Foo
4791 </p>
4792 !! end
4793
4794 !! test
4795 External links: with no contents
4796 !! wikitext
4797 [http://en.wikipedia.org/wiki/Foo]
4798
4799 [[wikipedia:Foo|Bar]]
4800
4801 [[wikipedia:Foo|<span>Bar</span>]]
4802 !! html/php
4803 <p><a rel="nofollow" class="external autonumber" href="http://en.wikipedia.org/wiki/Foo">[1]</a>
4804 </p><p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo">Bar</a>
4805 </p><p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo"><span>Bar</span></a>
4806 </p>
4807 !! html/parsoid
4808 <p><a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/Foo"></a></p>
4809 <p><a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/Foo" title="wikipedia:Foo">Bar</a></p>
4810 <p><a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/Foo" title="wikipedia:Foo"><span>Bar</span></a></p>
4811 !! end
4812
4813 !! test
4814 External links: Free with trailing punctuation
4815 !! wikitext
4816 http://example.com,
4817 http://example.com;
4818 http://example.com\
4819 http://example.com.
4820 http://example.com:
4821 http://example.com!
4822 http://example.com?
4823 http://example.com)
4824 http://example.com/url_with_(brackets)
4825 (http://example.com/url_without_brackets)
4826 http://example.com/url_with_entity&amp;
4827 http://example.com/url_with_entity&#x26;
4828 http://example.com/url_with_entity&#038;
4829 http://example.com/url_with_entity&nbsp;
4830 http://example.com/url_with_entity&#xA0;
4831 http://example.com/url_with_entity&#160;
4832 http://example.com/url_with_entity&lt;
4833 http://example.com/url_with_entity&#x3C;
4834 http://example.com/url_with_entity&#60;
4835 !! html/php
4836 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>,
4837 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>;
4838 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>\
4839 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>.
4840 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>:
4841 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>!
4842 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>?
4843 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
4844 <a rel="nofollow" class="external free" href="http://example.com/url_with_(brackets)">http://example.com/url_with_(brackets)</a>
4845 (<a rel="nofollow" class="external free" href="http://example.com/url_without_brackets">http://example.com/url_without_brackets</a>)
4846 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4847 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4848 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4849 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#160;
4850 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#xa0;
4851 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#160;
4852 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&lt;
4853 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#x3c;
4854 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#60;
4855 </p>
4856 !! html/parsoid
4857 <p><a rel="mw:ExtLink" href="http://example.com">http://example.com</a>,
4858 <a rel="mw:ExtLink" href="http://example.com">http://example.com</a>;
4859 <a rel="mw:ExtLink" href="http://example.com">http://example.com</a>\
4860 <a rel="mw:ExtLink" href="http://example.com">http://example.com</a>.
4861 <a rel="mw:ExtLink" href="http://example.com">http://example.com</a>:
4862 <a rel="mw:ExtLink" href="http://example.com">http://example.com</a>!
4863 <a rel="mw:ExtLink" href="http://example.com">http://example.com</a>?
4864 <a rel="mw:ExtLink" href="http://example.com">http://example.com</a>)
4865 <a rel="mw:ExtLink" href="http://example.com/url_with_(brackets)">http://example.com/url_with_(brackets)</a>
4866 (<a rel="mw:ExtLink" href="http://example.com/url_without_brackets">http://example.com/url_without_brackets</a>)
4867 <a rel="mw:ExtLink" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4868 <a rel="mw:ExtLink" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4869 <a rel="mw:ExtLink" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4870 <a rel="mw:ExtLink" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a><span typeof="mw:Entity" data-parsoid='{"src":"&amp;nbsp;","srcContent":" "}'> </span>
4871 <a rel="mw:ExtLink" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#xA0;","srcContent":" "}'> </span>
4872 <a rel="mw:ExtLink" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#160;","srcContent":" "}'> </span>
4873 <a rel="mw:ExtLink" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a><span typeof="mw:Entity" data-parsoid='{"src":"&amp;lt;","srcContent":"&lt;"}'>&lt;</span>
4874 <a rel="mw:ExtLink" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#x3C;","srcContent":"&lt;"}'>&lt;</span>
4875 <a rel="mw:ExtLink" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#60;","srcContent":"&lt;"}'>&lt;</span></p>
4876 !! end
4877
4878 !! test
4879 External links: tricky Parsoid html2html case
4880 !! options
4881 parsoid=wt2html,wt2wt,html2html
4882 !! wikitext
4883 http://example.com/url_with_entity&amp;amp;
4884 !! html/php
4885 <p><a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;amp">http://example.com/url_with_entity&amp;amp</a>;
4886 </p>
4887 !! html/parsoid
4888 <p><a rel="mw:ExtLink" href="http://example.com/url_with_entity&amp;amp">http://example.com/url_with_entity&amp;amp</a>;</p>
4889 !! end
4890
4891 !! test
4892 External links: Free with trailing quotes (T113666)
4893 !! wikitext
4894 '''News:''' Stuff here
4895
4896 news:'a'b''c''d e
4897 !! html/php
4898 <p><b>News:</b> Stuff here
4899 </p><p><a rel="nofollow" class="external free" href="news:'a'b">news:'a'b</a><i>c</i>d e
4900 </p>
4901 !! html/parsoid
4902 <p><b>News:</b> Stuff here</p>
4903 <p><a rel="mw:ExtLink" href="news:'a'b">news:'a'b</a><i>c</i>d e</p>
4904 !! end
4905
4906 !! test
4907 External links: with entity
4908 !! wikitext
4909 [http://&#x20;www.librarieswithoutborders.org Libraries without borders]
4910 !! html/php
4911 <p><a rel="nofollow" class="external text" href="http://+www.librarieswithoutborders.org">Libraries without borders</a>
4912 </p>
4913 !! html/parsoid
4914 <p><a rel="mw:ExtLink" href="http://+www.librarieswithoutborders.org" data-parsoid='{"a":{"href":"http://+www.librarieswithoutborders.org"},"sa":{"href":"http://&amp;#x20;www.librarieswithoutborders.org"}}'>Libraries without borders</a></p>
4915 !! end
4916
4917 !! test
4918 External links: Lone protocols are never linked (T105697)
4919 !! wikitext
4920 http://
4921 http://;
4922 (http://)
4923 bitcoin:
4924 bitcoin:;
4925 (bitcoin:)
4926 !! html
4927 <p>http://
4928 http://;
4929 (http://)
4930 bitcoin:
4931 bitcoin:;
4932 (bitcoin:)
4933 </p>
4934 !! end
4935
4936 !! test
4937 External links: No preceding word characters allowed (T67278)
4938 !! wikitext
4939 NOPEhttp://example.com
4940 N0http://example.com
4941 ok:http://example.com
4942 ok-http://example.com
4943 !! html
4944 <p>NOPEhttp://example.com
4945 N0http://example.com
4946 ok:<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
4947 ok-<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
4948 </p>
4949 !! end
4950
4951 !! test
4952 External links: nofollow domain exception
4953 !! wikitext
4954 A [https://no-nofollow.org/foobar link], and another [https://example.org link].
4955 !! html
4956 <p>A <a class="external text" href="https://no-nofollow.org/foobar">link</a>, and another <a rel="nofollow" class="external text" href="https://example.org">link</a>.
4957 </p>
4958 !!end
4959
4960 !! test
4961 External image
4962 !! wikitext
4963 External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
4964 !! html
4965 <p>External image: <img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png"/>
4966 </p>
4967 !! end
4968
4969 !! test
4970 External image from https
4971 !! wikitext
4972 External image from https: https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
4973 !! html
4974 <p>External image from https: <img src="https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png"/>
4975 </p>
4976 !! end
4977
4978 !! test
4979 External image (when not allowed)
4980 !! options
4981 wgAllowExternalImages=0
4982 !! wikitext
4983 External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
4984 !! html
4985 <p>External image: <a rel="nofollow" class="external free" href="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png">http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png</a>
4986 </p>
4987 !! end
4988
4989 !! test
4990 Link to non-http image, no img tag
4991 !! wikitext
4992 Link to non-http image, no img tag: ftp://example.com/test.jpg
4993 !! html
4994 <p>Link to non-http image, no img tag: <a rel="nofollow" class="external free" href="ftp://example.com/test.jpg">ftp://example.com/test.jpg</a>
4995 </p>
4996 !! end
4997
4998 !! test
4999 External links: terminating separator
5000 !! wikitext
5001 Terminating separator: http://example.com/thing,
5002 !! html
5003 <p>Terminating separator: <a rel="nofollow" class="external free" href="http://example.com/thing">http://example.com/thing</a>,
5004 </p>
5005 !! end
5006
5007 !! test
5008 External links: intervening separator
5009 !! wikitext
5010 Intervening separator: http://example.com/1,2,3
5011 !! html
5012 <p>Intervening separator: <a rel="nofollow" class="external free" href="http://example.com/1,2,3">http://example.com/1,2,3</a>
5013 </p>
5014 !! end
5015
5016 !! test
5017 External links: old bug with URL in query
5018 !! wikitext
5019 Old bug with URL in query: [http://example.com/thing?url=http://example.com link]
5020 !! html
5021 <p>Old bug with URL in query: <a rel="nofollow" class="external text" href="http://example.com/thing?url=http://example.com">link</a>
5022 </p>
5023 !! end
5024
5025 !! test
5026 External links: old URL-in-URL bug, mixed protocols
5027 !! wikitext
5028 And again with mixed protocols: [ftp://example.com?url=http://example.com link]
5029 !! html
5030 <p>And again with mixed protocols: <a rel="nofollow" class="external text" href="ftp://example.com?url=http://example.com">link</a>
5031 </p>
5032 !!end
5033
5034 # Since Parsoid is starting to emit canonical wikitext for links,
5035 # [http://example.com http://example.com] will not RT back to that
5036 # form anymore.
5037 !! test
5038 External links: URL in text
5039 !! options
5040 parsoid=wt2html
5041 !! wikitext
5042 URL in text: [http://example.com http://example.com]
5043 !! html/php
5044 <p>URL in text: <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
5045 </p>
5046 !! html/parsoid
5047 <p>URL in text: <a rel="mw:ExtLink" href="http://example.com">http://example.com</a></p>
5048 !! end
5049
5050 !! test
5051 External links: Clickable images
5052 !! wikitext
5053 ja-style clickable images: [http://example.com http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png]
5054 !! html/php
5055 <p>ja-style clickable images: <a rel="nofollow" class="external text" href="http://example.com"><img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png"/></a>
5056 </p>
5057 !! html/parsoid
5058 <p>ja-style clickable images: <a rel="mw:ExtLink" href="http://example.com"><img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png" data-parsoid='{"type":"extlink"}'/></a></p>
5059 !! end
5060
5061 !! test
5062 External links: raw ampersand
5063 !! wikitext
5064 Old &amp; use: http://x&y
5065 !! html
5066 <p>Old &amp; use: <a rel="nofollow" class="external free" href="http://x&amp;y">http://x&amp;y</a>
5067 </p>
5068 !! end
5069
5070 !! test
5071 External links: encoded ampersand
5072 !! wikitext
5073 Old &amp; use: http://x&amp;y
5074 !! html/php
5075 <p>Old &amp; use: <a rel="nofollow" class="external free" href="http://x&amp;y">http://x&amp;y</a>
5076 </p>
5077 !! html/parsoid
5078 <p>Old <span typeof="mw:Entity">&amp;</span> use: <a rel="mw:ExtLink" href="http://x&amp;y">http://x&amp;y</a></p>
5079 !! end
5080
5081 !! test
5082 External links: encoded equals (T8102)
5083 !! wikitext
5084 http://example.com/?foo&#61;bar
5085 !! html/php
5086 <p><a rel="nofollow" class="external free" href="http://example.com/?foo=bar">http://example.com/?foo=bar</a>
5087 </p>
5088 !! html/parsoid
5089 <p><a rel="mw:ExtLink" href="http://example.com/?foo=bar">http://example.com/?foo=bar</a></p>
5090 !! end
5091
5092 ##
5093 ## Note that parsoid doesn't explicit mark autonumbered links, nor
5094 ## does it number them. As discussed in T55505, we can identify
5095 ## autonumbered links via CSS.
5096 ##
5097
5098 !! test
5099 External links: [raw ampersand]
5100 !! wikitext
5101 Old &amp; use: [http://x&y]
5102 !! html/php
5103 <p>Old &amp; use: <a rel="nofollow" class="external autonumber" href="http://x&amp;y">[1]</a>
5104 </p>
5105 !! html/parsoid
5106 <p>Old <span typeof="mw:Entity">&amp;</span> use: <a rel="mw:ExtLink" href="http://x&amp;y"></a></p>
5107 !! end
5108
5109 # note that parsoid html is identical to [raw ampersand] case; so html2wt
5110 # mode will return the [raw ampersand] wikitext
5111 !! test
5112 External links: [encoded ampersand]
5113 !! options
5114 parsoid=wt2html,wt2wt,html2html
5115 !! wikitext
5116 Old &amp; use: [http://x&amp;y]
5117 !! html/php
5118 <p>Old &amp; use: <a rel="nofollow" class="external autonumber" href="http://x&amp;y">[1]</a>
5119 </p>
5120 !! html/parsoid
5121 <p>Old <span typeof="mw:Entity">&amp;</span> use: <a rel="mw:ExtLink" href="http://x&amp;y"></a></p>
5122 !! end
5123
5124 !! test
5125 External links: [raw equals]
5126 !! wikitext
5127 [http://example.com/?foo=bar]
5128 !! html/php
5129 <p><a rel="nofollow" class="external autonumber" href="http://example.com/?foo=bar">[1]</a>
5130 </p>
5131 !! html/parsoid
5132 <p><a rel="mw:ExtLink" href="http://example.com/?foo=bar"></a></p>
5133 !! end
5134
5135 # note that parsoid html is identical to [raw equals] case; so html2wt
5136 # mode will return the [raw equals] wikitext
5137 !! test
5138 External links: [encoded equals] (T8102)
5139 !! options
5140 parsoid=wt2html,wt2wt,html2html
5141 !! wikitext
5142 [http://example.com/?foo&#61;bar]
5143 !! html/php
5144 <p><a rel="nofollow" class="external autonumber" href="http://example.com/?foo=bar">[1]</a>
5145 </p>
5146 !! html/parsoid
5147 <p><a rel="mw:ExtLink" href="http://example.com/?foo=bar"></a></p>
5148 !! end
5149
5150 # xxx parsoid strips the IDN character, so the round-trip tests will
5151 # obviously fail and are disabled. --cscott
5152 !! test
5153 External links: [IDN ignored character reference in hostname; strip it right off]
5154 !! options
5155 parsoid=wt2html,wt2wt,html2html
5156 !! wikitext
5157 [http://e&zwnj;xample.com/]
5158 !! html/php
5159 <p><a rel="nofollow" class="external autonumber" href="http://example.com/">[1]</a>
5160 </p>
5161 !! html/parsoid
5162 <p><a rel="mw:ExtLink" href="http://example.com/"></a></p>
5163 !! end
5164
5165 # FIXME: This test (the IDN characters in the text of a link) is an inconsistency.
5166 # Where an external link could easily circumvent the sanitization of the text of
5167 # a link like this (where an IDN-ignore character is in the URL somewhere), this
5168 # test demands a higher standard. That's a bit strange.
5169 #
5170 # Example:
5171 #
5172 # http://e‌xample.com -> [http://example.com|http://example.com]
5173 # [http://example.com|http://e‌xample.com] -> [http://example.com|http://e‌xample.com]
5174 #
5175 # The first example is sanitized, but the second is not. Any security benefits
5176 # from this production are trivial to circumvent. Either remove this test and
5177 # let the parser(s) do their thing unaccosted, or fix the inconsistency and change
5178 # the test accordingly.
5179 #
5180 # All our love,
5181 # The Parsoid team.
5182 # xxx parsoid strips the IDN character, so the round-trip tests will
5183 # obviously fail and are disabled. --cscott
5184 !! test
5185 External links: IDN ignored character reference in hostname; strip it right off
5186 !! options
5187 parsoid=wt2html,html2html
5188 !! wikitext
5189 http://e&zwnj;xample.com/
5190 !! html/php
5191 <p><a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a>
5192 </p>
5193 !! html/parsoid
5194 <p><a rel="mw:ExtLink" href="http://example.com/">http://example.com/</a></p>
5195 !! end
5196
5197 !! test
5198 External links: www.jpeg.org (T2554)
5199 !! wikitext
5200 http://www.jpeg.org
5201 !! html
5202 <p><a rel="nofollow" class="external free" href="http://www.jpeg.org">http://www.jpeg.org</a>
5203 </p>
5204 !! end
5205
5206 # parsoid doesn't explicitly mark autonumbered links, see T55505
5207 !! test
5208 External links: URL within URL (T2002)
5209 !! wikitext
5210 [http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp]
5211 !! html/php
5212 <p><a rel="nofollow" class="external autonumber" href="http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp">[1]</a>
5213 </p>
5214 !! html/parsoid
5215 <p><a rel="mw:ExtLink" href="http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp"></a></p>
5216 !! end
5217
5218 !! test
5219 T2361: URL inside bracketed URL
5220 !! wikitext
5221 [http://www.example.com/foo http://www.example.com/bar]
5222 !! html
5223 <p><a rel="nofollow" class="external text" href="http://www.example.com/foo">http://www.example.com/bar</a>
5224 </p>
5225 !! end
5226
5227 !! test
5228 T2361: URL within URL, not bracketed
5229 !! wikitext
5230 http://www.example.com/foo?=http://www.example.com/bar
5231 !! html
5232 <p><a rel="nofollow" class="external free" href="http://www.example.com/foo?=http://www.example.com/bar">http://www.example.com/foo?=http://www.example.com/bar</a>
5233 </p>
5234 !! end
5235
5236 !! test
5237 T2289: ">"-token in URL-tail
5238 !! wikitext
5239 http://www.example.com/<hello>
5240 !! html
5241 <p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a>&lt;hello&gt;
5242 </p>
5243 !!end
5244
5245 !! test
5246 T2289: literal ">"-token in URL-tail
5247 !! wikitext
5248 http://www.example.com/<b>html</b>
5249 !! html/php
5250 <p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a><b>html</b>
5251 </p>
5252 !! html/parsoid
5253 <p><a rel="mw:ExtLink" href="http://www.example.com/" data-parsoid='{"stx":"url"}'>http://www.example.com/</a><b data-parsoid='{"stx":"html"}'>html</b></p>
5254 !! end
5255
5256 !! test
5257 T2289: ">"-token in bracketed URL
5258 !! wikitext
5259 [http://www.example.com/<hello> stuff]
5260 !! html
5261 <p><a rel="nofollow" class="external text" href="http://www.example.com/">&lt;hello&gt; stuff</a>
5262 </p>
5263 !!end
5264
5265 !! test
5266 T2289: literal ">"-token in bracketed URL
5267 !! wikitext
5268 [http://www.example.com/<b>html</b> stuff]
5269 !! html
5270 <p><a rel="nofollow" class="external text" href="http://www.example.com/"><b>html</b> stuff</a>
5271 </p>
5272 !!end
5273
5274 !! test
5275 T2289: literal double quote at end of URL
5276 !! wikitext
5277 http://www.example.com/"hello"
5278 !! html
5279 <p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a>"hello"
5280 </p>
5281 !!end
5282
5283 !! test
5284 T2289: literal double quote in bracketed URL
5285 !! wikitext
5286 [http://www.example.com/"hello" stuff]
5287 !! html
5288 <p><a rel="nofollow" class="external text" href="http://www.example.com/">"hello" stuff</a>
5289 </p>
5290 !!end
5291
5292 !! test
5293 External links: multiple legal whitespace is fine, Magnus. Don't break it please. (T7081)
5294 !! wikitext
5295 [http://www.example.com test]
5296 !! html
5297 <p><a rel="nofollow" class="external text" href="http://www.example.com">test</a>
5298 </p>
5299 !! end
5300
5301 !! test
5302 External links: link text with spaces
5303 !! wikitext
5304 [http://www.example.com a b c]
5305 [http://www.example.com ''a'' ''b'']
5306 !! html
5307 <p><a rel="nofollow" class="external text" href="http://www.example.com">a b c</a>
5308 <a rel="nofollow" class="external text" href="http://www.example.com"><i>a</i> <i>b</i></a>
5309 </p>
5310 !! end
5311
5312 !! test
5313 External links: wiki links within external link (T5695)
5314 !! options
5315 parsoid=wt2html,html2html
5316 !! wikitext
5317 [http://example.com [[wikilink]] embedded in ext link]
5318 !! html/php
5319 <p><a rel="nofollow" class="external text" href="http://example.com"></a><a href="/index.php?title=Wikilink&amp;action=edit&amp;redlink=1" class="new" title="Wikilink (page does not exist)">wikilink</a><a rel="nofollow" class="external text" href="http://example.com"> embedded in ext link</a>
5320 </p>
5321 !! html/parsoid
5322 <p><a rel="mw:ExtLink" href="http://example.com"></a><a rel="mw:WikiLink" href="./Wikilink" title="Wikilink">wikilink</a><span> embedded in ext link</span></p>
5323 !! end
5324
5325 !! test
5326 T2787: Links with one slash after the url protocol are invalid
5327 !! wikitext
5328 http:/example.com
5329
5330 [http:/example.com title]
5331 !! html
5332 <p>http:/example.com
5333 </p><p>[http:/example.com title]
5334 </p>
5335 !! end
5336
5337 !! test
5338 Bracketed external links with template-generated invalid target
5339 !! wikitext
5340 [{{echo|http:/example.com}} title]
5341 !! html
5342 <p>[http:/example.com title]
5343 </p>
5344 !! end
5345
5346 # wt2html only because Parsoid would want to add <nowiki>s coming from html
5347 !! test
5348 Broken wikilinks (but not external links) prevent templates from closing
5349 !! options
5350 parsoid=wt2html
5351 !! wikitext
5352 [http://example.com x
5353
5354 {{echo|[http://example.com x}}
5355
5356 [[Foo
5357
5358 {{echo|[[Foo}}
5359 !! html/php
5360 <p>[<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> x
5361 </p><p>[<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> x
5362 </p><p>[[Foo
5363 </p><p>{{echo|[[Foo}}
5364 </p>
5365 !! html/parsoid
5366 <p>[<a rel="mw:ExtLink" href="http://example.com">http://example.com</a> x</p>
5367 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[http://example.com x"}},"i":0}}]}'>[<a rel="mw:ExtLink" href="http://example.com">http://example.com</a> x</p>
5368 <p>[[Foo</p>
5369 <p>{{echo|[[Foo}}</p>
5370 !! end
5371
5372 !! test
5373 Wikilinks with embedded newlines are not broken
5374 !! wikitext
5375 {{echo|[[ Foo
5376 B
5377 C]]}}
5378 !! html/php
5379 <p>[[ Foo
5380 B
5381 C]]
5382 </p>
5383 !! html/parsoid
5384 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[ Foo\nB\nC]]"}},"i":0}}]}'>[[ Foo B C]]</p>
5385 !! end
5386
5387 !! test
5388 Broken templates
5389 !! options
5390 parsoid=wt2html
5391 !! wikitext
5392 {{echo|[[Foo|}}]]
5393
5394 [[Foo|{{echo|]]}}
5395 !! html/php
5396 <p>{{echo|<a href="/wiki/Foo" title="Foo">}}</a>
5397 </p><p>[[Foo|]]
5398 </p>
5399 !! html/parsoid
5400 <p>{{echo|<a rel="mw:WikiLink" href="./Foo" title="Foo">}}</a></p>
5401 <p>[[Foo|<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"]]"}},"i":0}}]}'>]]</span></p>
5402 !! end
5403
5404 !! test
5405 T4702: Mismatched <i>, <b> and <a> tags are invalid
5406 !! wikitext
5407 ''[http://example.com text'']
5408 [http://example.com '''text]'''
5409 ''Something [http://example.com in italic'']
5410 ''Something [http://example.com mixed''''', even bold]'''
5411 '''''Now [http://example.com both''''']
5412 !! html
5413 <p><a rel="nofollow" class="external text" href="http://example.com"><i>text</i></a>
5414 <a rel="nofollow" class="external text" href="http://example.com"><b>text</b></a>
5415 <i>Something </i><a rel="nofollow" class="external text" href="http://example.com"><i>in italic</i></a>
5416 <i>Something </i><a rel="nofollow" class="external text" href="http://example.com"><i>mixed</i><b>, even bold</b></a>
5417 <i><b>Now </b></i><a rel="nofollow" class="external text" href="http://example.com"><i><b>both</b></i></a>
5418 </p>
5419 !! end
5420
5421
5422 !! test
5423 T6781: %26 in URL
5424 !! wikitext
5425 http://www.example.com/?title=AT%26T
5426 !! html/php
5427 <p><a rel="nofollow" class="external free" href="http://www.example.com/?title=AT%26T">http://www.example.com/?title=AT%26T</a>
5428 </p>
5429 !! html/parsoid
5430 <p><a rel="mw:ExtLink" href="http://www.example.com/?title=AT%26T">http://www.example.com/?title=AT%26T</a></p>
5431 !! end
5432
5433 # According to https://www.w3.org/TR/2011/WD-html5-20110525/Overview.html#parsing-urls a plain
5434 # % is actually legal in HTML5. Any change in output would need testing though.
5435 !! test
5436 T6781, T7267: %25 in URL
5437 !! wikitext
5438 http://www.example.com/?title=100%25_Bran
5439 !! html/php
5440 <p><a rel="nofollow" class="external free" href="http://www.example.com/?title=100%25_Bran">http://www.example.com/?title=100%25_Bran</a>
5441 </p>
5442 !! html/parsoid
5443 <p><a rel="mw:ExtLink" href="http://www.example.com/?title=100%25_Bran">http://www.example.com/?title=100%25_Bran</a></p>
5444 !! end
5445
5446 !! test
5447 T6781, T7267: %28, %29 in URL
5448 !! wikitext
5449 http://www.example.com/?title=Ben-Hur_%281959_film%29
5450 !! html/php
5451 <p><a rel="nofollow" class="external free" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">http://www.example.com/?title=Ben-Hur_%281959_film%29</a>
5452 </p>
5453 !! html/parsoid
5454 <p><a rel="mw:ExtLink" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">http://www.example.com/?title=Ben-Hur_%281959_film%29</a></p>
5455 !! end
5456
5457
5458 !! test
5459 T6781: %26 in autonumber URL
5460 !! wikitext
5461 [http://www.example.com/?title=AT%26T]
5462 !! html/php
5463 <p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=AT%26T">[1]</a>
5464 </p>
5465 !! html/parsoid
5466 <p><a rel="mw:ExtLink" href="http://www.example.com/?title=AT%26T"></a></p>
5467 !! end
5468
5469 !! test
5470 T6781, T7267: %26 in autonumber URL
5471 !! wikitext
5472 [http://www.example.com/?title=100%25_Bran]
5473 !! html/php
5474 <p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=100%25_Bran">[1]</a>
5475 </p>
5476 !! html/parsoid
5477 <p><a rel="mw:ExtLink" href="http://www.example.com/?title=100%25_Bran"></a></p>
5478 !! end
5479
5480 !! test
5481 T6781, T7267: %28, %29 in autonumber URL
5482 !! wikitext
5483 [http://www.example.com/?title=Ben-Hur_%281959_film%29]
5484 !! html/php
5485 <p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">[1]</a>
5486 </p>
5487 !! html/parsoid
5488 <p><a rel="mw:ExtLink" href="http://www.example.com/?title=Ben-Hur_%281959_film%29"></a></p>
5489 !! end
5490
5491
5492 !! test
5493 T6781: %26 in bracketed URL
5494 !! wikitext
5495 [http://www.example.com/?title=AT%26T link]
5496 !! html/php
5497 <p><a rel="nofollow" class="external text" href="http://www.example.com/?title=AT%26T">link</a>
5498 </p>
5499 !! html/parsoid
5500 <p><a rel="mw:ExtLink" href="http://www.example.com/?title=AT%26T">link</a></p>
5501 !! end
5502
5503 !! test
5504 T6781, T7267: %25 in bracketed URL
5505 !! wikitext
5506 [http://www.example.com/?title=100%25_Bran link]
5507 !! html
5508 <p><a rel="nofollow" class="external text" href="http://www.example.com/?title=100%25_Bran">link</a>
5509 </p>
5510 !! end
5511
5512 !! test
5513 T6781, T7267: %28, %29 in bracketed URL
5514 !! wikitext
5515 [http://www.example.com/?title=Ben-Hur_%281959_film%29 link]
5516 !! html/php
5517 <p><a rel="nofollow" class="external text" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">link</a>
5518 </p>
5519 !! html/parsoid
5520 <p><a rel="mw:ExtLink" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">link</a></p>
5521 !! end
5522
5523 !! test
5524 External link containing a period in the anchor. (T65947)
5525 !! wikitext
5526 [//foo.org/bar#baz. bang]
5527
5528 [//foo.org/bar. bang]
5529 !! html/php
5530 <p><a rel="nofollow" class="external text" href="//foo.org/bar#baz.">bang</a>
5531 </p><p><a rel="nofollow" class="external text" href="//foo.org/bar.">bang</a>
5532 </p>
5533 !! html/parsoid
5534 <p><a rel="mw:ExtLink" href="//foo.org/bar#baz.">bang</a></p>
5535 <p><a rel="mw:ExtLink" href="//foo.org/bar.">bang</a></p>
5536 !! end
5537
5538 !! test
5539 External link containing a single quote. (T65947)
5540 !! wikitext
5541 [//foo.org/bar'baz]
5542
5543 [//foo.org/bar'baz bang]
5544 !! html/php
5545 <p><a rel="nofollow" class="external autonumber" href="//foo.org/bar'baz">[1]</a>
5546 </p><p><a rel="nofollow" class="external text" href="//foo.org/bar'baz">bang</a>
5547 </p>
5548 !! html/parsoid
5549 <p><a rel="mw:ExtLink" href="//foo.org/bar'baz"></a></p>
5550 <p><a rel="mw:ExtLink" href="//foo.org/bar'baz">bang</a></p>
5551 !! end
5552
5553 !! test
5554 External link containing double-single-quotes in text '' (T6598 sanity check)
5555 !! wikitext
5556 Some [http://example.com/ pretty ''italics'' and stuff]!
5557 !! html
5558 <p>Some <a rel="nofollow" class="external text" href="http://example.com/">pretty <i>italics</i> and stuff</a>!
5559 </p>
5560 !! end
5561
5562 !! test
5563 External link containing double-single-quotes in text embedded in italics (T6598 sanity check)
5564 !! wikitext
5565 ''Some [http://example.com/ pretty ''italics'' and stuff]!''
5566 !! html
5567 <p><i>Some </i><a rel="nofollow" class="external text" href="http://example.com/"><i>pretty </i>italics<i> and stuff</i></a><i>!</i>
5568 </p>
5569 !! end
5570
5571 !! test
5572 External link containing double-single-quotes with no space separating the url from text in italics
5573 !! wikitext
5574 [http://www.musee-picasso.fr/pages/page_id18528_u1l2.htm''La muerte de Casagemas'' (1901) en el sitio de [[Museo Picasso (París)|Museo Picasso]].]
5575 !! html/php
5576 <p><a rel="nofollow" class="external text" href="http://www.musee-picasso.fr/pages/page_id18528_u1l2.htm"><i>La muerte de Casagemas</i> (1901) en el sitio de <a href="/index.php?title=Museo_Picasso_(Par%C3%ADs)&amp;action=edit&amp;redlink=1" class="new" title="Museo Picasso (París) (page does not exist)">Museo Picasso</a>.</a>
5577 </p>
5578 !! html/php+tidy
5579 <p><a rel="nofollow" class="external text" href="http://www.musee-picasso.fr/pages/page_id18528_u1l2.htm"><i>La muerte de Casagemas</i> (1901) en el sitio de</a> <a href="/index.php?title=Museo_Picasso_(Par%C3%ADs)&amp;action=edit&amp;redlink=1" class="new" title="Museo Picasso (París) (page does not exist)">Museo Picasso</a>.</p>
5580 !! html/parsoid
5581 <p><a rel="mw:ExtLink" href="http://www.musee-picasso.fr/pages/page_id18528_u1l2.htm"><i>La muerte de Casagemas</i> (1901) en el sitio de </a><a rel="mw:WikiLink" href="./Museo_Picasso_(París)" title="Museo Picasso (París)">Museo Picasso</a><span>.</span></p>
5582 !! end
5583
5584 !! test
5585 External link with comments in link text
5586 !! wikitext
5587 [http://www.google.com Google <!-- comment -->]
5588 !! html/php
5589 <p><a rel="nofollow" class="external text" href="http://www.google.com">Google </a>
5590 </p>
5591 !! html/parsoid
5592 <p><a rel="mw:ExtLink" href="http://www.google.com">Google <!-- comment --></a></p>
5593 !! end
5594
5595 !! test
5596 External link to bare IPv4 address
5597 !! wikitext
5598 [http://192.168.0.1 Link]
5599 !! html/php
5600 <p><a rel="nofollow" class="external text" href="http://192.168.0.1">Link</a>
5601 </p>
5602 !! html/parsoid
5603 <p><a rel="mw:ExtLink" href="http://192.168.0.1">Link</a></p>
5604 !! end
5605
5606 !! test
5607 URL-encoding in URL functions (single parameter)
5608 !! wikitext
5609 {{localurl:Some page|amp=&}}
5610 !! html
5611 <p>/index.php?title=Some_page&amp;amp=&amp;
5612 </p>
5613 !! end
5614
5615 !! test
5616 URL-encoding in URL functions (multiple parameters)
5617 !! wikitext
5618 {{localurl:Some page|q=?&amp=&}}
5619 !! html
5620 <p>/index.php?title=Some_page&amp;q=?&amp;amp=&amp;
5621 </p>
5622 !! end
5623
5624 !! test
5625 Brackets in urls
5626 !! wikitext
5627 http://example.com/index.php?foozoid%5B%5D=bar
5628
5629 http://example.com/index.php?foozoid&#x5B;&#x5D;=bar
5630 !! html/php
5631 <p><a rel="nofollow" class="external free" href="http://example.com/index.php?foozoid%5B%5D=bar">http://example.com/index.php?foozoid%5B%5D=bar</a>
5632 </p><p><a rel="nofollow" class="external free" href="http://example.com/index.php?foozoid%5B%5D=bar">http://example.com/index.php?foozoid%5B%5D=bar</a>
5633 </p>
5634 !! html/parsoid
5635 <p><a rel="mw:ExtLink" href="http://example.com/index.php?foozoid%5B%5D=bar">http://example.com/index.php?foozoid%5B%5D=bar</a></p>
5636
5637 <p><a rel="mw:ExtLink" href="http://example.com/index.php?foozoid%5B%5D=bar" data-parsoid='{"stx":"url","a":{"href":"http://example.com/index.php?foozoid%5B%5D=bar"},"sa":{"href":"http://example.com/index.php?foozoid&amp;#x5B;&amp;#x5D;=bar"}}'>http://example.com/index.php?foozoid%5B%5D=bar</a></p>
5638 !! end
5639
5640 !! test
5641 IPv6 urls, autolink format (T23261)
5642 !! wikitext
5643 http://[2404:130:0:1000::187:2]/index.php
5644
5645 Examples from RFC 2373, section 2.2:
5646 * http://[1080::8:800:200C:417A]/unicast
5647 * http://[FF01::101]/multicast
5648 * http://[::1]/loopback
5649 * http://[::]/unspecified
5650 * http://[::13.1.68.3]/ipv4compat
5651 * http://[::FFFF:129.144.52.38]/ipv4compat
5652
5653 Examples from RFC 2732, section 2:
5654 * http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html
5655 * http://[1080:0:0:0:8:800:200C:417A]/index.html
5656 * http://[3ffe:2a00:100:7031::1]
5657 * http://[1080::8:800:200C:417A]/foo
5658 * http://[::192.9.5.5]/ipng
5659 * http://[::FFFF:129.144.52.38]:80/index.html
5660 * http://[2010:836B:4179::836B:4179]
5661
5662 !! html/php
5663 <p><a rel="nofollow" class="external free" href="http://[2404:130:0:1000::187:2]/index.php">http://[2404:130:0:1000::187:2]/index.php</a>
5664 </p><p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc2373">RFC 2373</a>, section 2.2:
5665 </p>
5666 <ul><li> <a rel="nofollow" class="external free" href="http://[1080::8:800:200C:417A]/unicast">http://[1080::8:800:200C:417A]/unicast</a></li>
5667 <li> <a rel="nofollow" class="external free" href="http://[FF01::101]/multicast">http://[FF01::101]/multicast</a></li>
5668 <li> <a rel="nofollow" class="external free" href="http://[::1]/loopback">http://[::1]/loopback</a></li>
5669 <li> <a rel="nofollow" class="external free" href="http://[::]/unspecified">http://[::]/unspecified</a></li>
5670 <li> <a rel="nofollow" class="external free" href="http://[::13.1.68.3]/ipv4compat">http://[::13.1.68.3]/ipv4compat</a></li>
5671 <li> <a rel="nofollow" class="external free" href="http://[::FFFF:129.144.52.38]/ipv4compat">http://[::FFFF:129.144.52.38]/ipv4compat</a></li></ul>
5672 <p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc2732">RFC 2732</a>, section 2:
5673 </p>
5674 <ul><li> <a rel="nofollow" class="external free" href="http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html">http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html</a></li>
5675 <li> <a rel="nofollow" class="external free" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">http://[1080:0:0:0:8:800:200C:417A]/index.html</a></li>
5676 <li> <a rel="nofollow" class="external free" href="http://[3ffe:2a00:100:7031::1]">http://[3ffe:2a00:100:7031::1]</a></li>
5677 <li> <a rel="nofollow" class="external free" href="http://[1080::8:800:200C:417A]/foo">http://[1080::8:800:200C:417A]/foo</a></li>
5678 <li> <a rel="nofollow" class="external free" href="http://[::192.9.5.5]/ipng">http://[::192.9.5.5]/ipng</a></li>
5679 <li> <a rel="nofollow" class="external free" href="http://[::FFFF:129.144.52.38]:80/index.html">http://[::FFFF:129.144.52.38]:80/index.html</a></li>
5680 <li> <a rel="nofollow" class="external free" href="http://[2010:836B:4179::836B:4179]">http://[2010:836B:4179::836B:4179]</a></li></ul>
5681
5682 !! html/parsoid
5683 <p><a rel="mw:ExtLink" href="http://[2404:130:0:1000::187:2]/index.php">http://[2404:130:0:1000::187:2]/index.php</a></p>
5684
5685 <p>Examples from <a href="//tools.ietf.org/html/rfc2373" rel="mw:ExtLink">RFC 2373</a>, section 2.2:</p>
5686 <ul><li> <a rel="mw:ExtLink" href="http://[1080::8:800:200C:417A]/unicast">http://[1080::8:800:200C:417A]/unicast</a></li>
5687 <li> <a rel="mw:ExtLink" href="http://[FF01::101]/multicast">http://[FF01::101]/multicast</a></li>
5688 <li> <a rel="mw:ExtLink" href="http://[::1]/loopback">http://[::1]/loopback</a></li>
5689 <li> <a rel="mw:ExtLink" href="http://[::]/unspecified">http://[::]/unspecified</a></li>
5690 <li> <a rel="mw:ExtLink" href="http://[::13.1.68.3]/ipv4compat">http://[::13.1.68.3]/ipv4compat</a></li>
5691 <li> <a rel="mw:ExtLink" href="http://[::FFFF:129.144.52.38]/ipv4compat">http://[::FFFF:129.144.52.38]/ipv4compat</a></li></ul>
5692
5693 <p>Examples from <a href="//tools.ietf.org/html/rfc2732" rel="mw:ExtLink">RFC 2732</a>, section 2:</p>
5694 <ul><li> <a rel="mw:ExtLink" href="http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html">http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html</a></li>
5695 <li> <a rel="mw:ExtLink" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">http://[1080:0:0:0:8:800:200C:417A]/index.html</a></li>
5696 <li> <a rel="mw:ExtLink" href="http://[3ffe:2a00:100:7031::1]">http://[3ffe:2a00:100:7031::1]</a></li>
5697 <li> <a rel="mw:ExtLink" href="http://[1080::8:800:200C:417A]/foo">http://[1080::8:800:200C:417A]/foo</a></li>
5698 <li> <a rel="mw:ExtLink" href="http://[::192.9.5.5]/ipng">http://[::192.9.5.5]/ipng</a></li>
5699 <li> <a rel="mw:ExtLink" href="http://[::FFFF:129.144.52.38]:80/index.html">http://[::FFFF:129.144.52.38]:80/index.html</a></li>
5700 <li> <a rel="mw:ExtLink" href="http://[2010:836B:4179::836B:4179]">http://[2010:836B:4179::836B:4179]</a></li></ul>
5701 !! end
5702
5703 !! test
5704 IPv6 urls, bracketed format (T23261)
5705 !! wikitext
5706 [http://[2404:130:0:1000::187:2]/index.php test]
5707
5708 Examples from RFC 2373, section 2.2:
5709 * [http://[1080::8:800:200C:417A] unicast]
5710 * [http://[FF01::101] multicast]
5711 * [http://[::1]/ loopback]
5712 * [http://[::] unspecified]
5713 * [http://[::13.1.68.3] ipv4compat]
5714 * [http://[::FFFF:129.144.52.38] ipv4compat]
5715
5716 Examples from RFC 2732, section 2:
5717 * [http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html 1]
5718 * [http://[1080:0:0:0:8:800:200C:417A]/index.html 2]
5719 * [http://[3ffe:2a00:100:7031::1] 3]
5720 * [http://[1080::8:800:200C:417A]/foo 4]
5721 * [http://[::192.9.5.5]/ipng 5]
5722 * [http://[::FFFF:129.144.52.38]:80/index.html 6]
5723 * [http://[2010:836B:4179::836B:4179] 7]
5724
5725 !! html/php
5726 <p><a rel="nofollow" class="external text" href="http://[2404:130:0:1000::187:2]/index.php">test</a>
5727 </p><p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc2373">RFC 2373</a>, section 2.2:
5728 </p>
5729 <ul><li> <a rel="nofollow" class="external text" href="http://[1080::8:800:200C:417A]">unicast</a></li>
5730 <li> <a rel="nofollow" class="external text" href="http://[FF01::101]">multicast</a></li>
5731 <li> <a rel="nofollow" class="external text" href="http://[::1]/">loopback</a></li>
5732 <li> <a rel="nofollow" class="external text" href="http://[::]">unspecified</a></li>
5733 <li> <a rel="nofollow" class="external text" href="http://[::13.1.68.3]">ipv4compat</a></li>
5734 <li> <a rel="nofollow" class="external text" href="http://[::FFFF:129.144.52.38]">ipv4compat</a></li></ul>
5735 <p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc2732">RFC 2732</a>, section 2:
5736 </p>
5737 <ul><li> <a rel="nofollow" class="external text" href="http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html">1</a></li>
5738 <li> <a rel="nofollow" class="external text" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">2</a></li>
5739 <li> <a rel="nofollow" class="external text" href="http://[3ffe:2a00:100:7031::1]">3</a></li>
5740 <li> <a rel="nofollow" class="external text" href="http://[1080::8:800:200C:417A]/foo">4</a></li>
5741 <li> <a rel="nofollow" class="external text" href="http://[::192.9.5.5]/ipng">5</a></li>
5742 <li> <a rel="nofollow" class="external text" href="http://[::FFFF:129.144.52.38]:80/index.html">6</a></li>
5743 <li> <a rel="nofollow" class="external text" href="http://[2010:836B:4179::836B:4179]">7</a></li></ul>
5744
5745 !! html/parsoid
5746 <p><a rel="mw:ExtLink" href="http://[2404:130:0:1000::187:2]/index.php">test</a></p>
5747
5748 <p>Examples from <a href="//tools.ietf.org/html/rfc2373" rel="mw:ExtLink">RFC 2373</a>, section 2.2:</p>
5749 <ul><li> <a rel="mw:ExtLink" href="http://[1080::8:800:200C:417A]">unicast</a></li>
5750 <li> <a rel="mw:ExtLink" href="http://[FF01::101]">multicast</a></li>
5751 <li> <a rel="mw:ExtLink" href="http://[::1]/">loopback</a></li>
5752 <li> <a rel="mw:ExtLink" href="http://[::]">unspecified</a></li>
5753 <li> <a rel="mw:ExtLink" href="http://[::13.1.68.3]">ipv4compat</a></li>
5754 <li> <a rel="mw:ExtLink" href="http://[::FFFF:129.144.52.38]">ipv4compat</a></li></ul>
5755
5756 <p>Examples from <a href="//tools.ietf.org/html/rfc2732" rel="mw:ExtLink">RFC 2732</a>, section 2:</p>
5757 <ul><li> <a rel="mw:ExtLink" href="http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html">1</a></li>
5758 <li> <a rel="mw:ExtLink" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">2</a></li>
5759 <li> <a rel="mw:ExtLink" href="http://[3ffe:2a00:100:7031::1]">3</a></li>
5760 <li> <a rel="mw:ExtLink" href="http://[1080::8:800:200C:417A]/foo">4</a></li>
5761 <li> <a rel="mw:ExtLink" href="http://[::192.9.5.5]/ipng">5</a></li>
5762 <li> <a rel="mw:ExtLink" href="http://[::FFFF:129.144.52.38]:80/index.html">6</a></li>
5763 <li> <a rel="mw:ExtLink" href="http://[2010:836B:4179::836B:4179]">7</a></li></ul>
5764 !! end
5765
5766 !! test
5767 Non-extlinks in brackets
5768 !! wikitext
5769 [foo]
5770 [foo bar]
5771 [foo ''bar'']
5772 [fool's] errand
5773 [fool's errand]
5774 [{{echo|foo}}]
5775 [{{echo|foo}} bar]
5776 [{{echo|foo}} ''bar'']
5777 [{{echo|foo}}l's] errand
5778 [{{echo|foo}}l's errand]
5779 [url={{echo|foo}}]
5780 [url=http://example.com]
5781 [http:// bare protocols don't count]
5782 !! html/php
5783 <p>[foo]
5784 [foo bar]
5785 [foo <i>bar</i>]
5786 [fool's] errand
5787 [fool's errand]
5788 [foo]
5789 [foo bar]
5790 [foo <i>bar</i>]
5791 [fool's] errand
5792 [fool's errand]
5793 [url=foo]
5794 [url=<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>]
5795 [http:// bare protocols don't count]
5796 </p>
5797 !! html/parsoid
5798 <p>[foo]
5799 [foo bar]
5800 [foo <i>bar</i>]
5801 [fool's] errand
5802 [fool's errand]
5803 [<span typeof="mw:Placeholder" data-parsoid='{"src":"{{echo|foo}}"}'>foo</span>]
5804 [<span typeof="mw:Placeholder" data-parsoid='{"src":"{{echo|foo}}"}'>foo</span> bar]
5805 [<span typeof="mw:Placeholder" data-parsoid='{"src":"{{echo|foo}}"}'>foo</span> <i>bar</i>]
5806 [<span typeof="mw:Placeholder" data-parsoid='{"src":"{{echo|foo}}l&#39;s"}'>fool's</span>] errand
5807 [<span typeof="mw:Placeholder" data-parsoid='{"src":"{{echo|foo}}l&#39;s"}'>fool's</span> errand]
5808 [<span typeof="mw:Placeholder" data-parsoid='{"src":"url={{echo|foo}}"}'>url=foo</span>]
5809 [url=<a rel="mw:ExtLink" href="http://example.com">http://example.com</a>]
5810 [http:// bare protocols don't count]</p>
5811 !! end
5812
5813 !! test
5814 Percent encoding in external links
5815 !! wikitext
5816 [https://github.com/search?l=&q=ResourceLoader+%40wikimedia Search]
5817 !! html/php
5818 <p><a rel="nofollow" class="external text" href="https://github.com/search?l=&amp;q=ResourceLoader+%40wikimedia">Search</a>
5819 </p>
5820 !! html/parsoid
5821 <p><a rel="mw:ExtLink"
5822 href="https://github.com/search?l=&amp;q=ResourceLoader+%40wikimedia">Search</a></p>
5823 !! end
5824
5825 !! test
5826 Use url link syntax for links where the content is equal the link target
5827 !! wikitext
5828 http://example.com
5829 !! html/php
5830 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
5831 </p>
5832 !! html/parsoid
5833 <p><a rel="mw:ExtLink" href="http://example.com">http://example.com</a></p>
5834 !! end
5835
5836 !! test
5837 Parenthesis in external links, especially URL links
5838 !! wikitext
5839 http://example.com)
5840
5841 http://example.com/test)
5842
5843 http://example.com/(test)
5844
5845 http://example.com/((test)
5846
5847 (http://example.com/(test))
5848
5849 (http://example.com/(test)))))
5850
5851 http://example.com/a)b
5852
5853 [http://example.com) foo]
5854 !! html/php
5855 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
5856 </p><p><a rel="nofollow" class="external free" href="http://example.com/test">http://example.com/test</a>)
5857 </p><p><a rel="nofollow" class="external free" href="http://example.com/(test)">http://example.com/(test)</a>
5858 </p><p><a rel="nofollow" class="external free" href="http://example.com/((test)">http://example.com/((test)</a>
5859 </p><p>(<a rel="nofollow" class="external free" href="http://example.com/(test))">http://example.com/(test))</a>
5860 </p><p>(<a rel="nofollow" class="external free" href="http://example.com/(test)))))">http://example.com/(test)))))</a>
5861 </p><p><a rel="nofollow" class="external free" href="http://example.com/a)b">http://example.com/a)b</a>
5862 </p><p><a rel="nofollow" class="external text" href="http://example.com)">foo</a>
5863 </p>
5864 !! html/parsoid
5865 <p><a rel="mw:ExtLink" href="http://example.com">http://example.com</a>)</p>
5866 <p><a rel="mw:ExtLink" href="http://example.com/test">http://example.com/test</a>)</p>
5867 <p><a rel="mw:ExtLink" href="http://example.com/(test)">http://example.com/(test)</a></p>
5868 <p><a rel="mw:ExtLink" href="http://example.com/((test)">http://example.com/((test)</a></p>
5869 <p>(<a rel="mw:ExtLink" href="http://example.com/(test))">http://example.com/(test))</a></p>
5870 <p>(<a rel="mw:ExtLink" href="http://example.com/(test)))))">http://example.com/(test)))))</a></p>
5871 <p><a rel="mw:ExtLink" href="http://example.com/a)b">http://example.com/a)b</a></p>
5872 <p><a rel="mw:ExtLink" href="http://example.com)">foo</a></p>
5873 !! end
5874
5875 !! test
5876 Parenthesis in external links, w/ transclusion or comment
5877 !! wikitext
5878 (http://example.com/{{echo|hi}})
5879
5880 (http://example.com<!-- hi -->)
5881 !! html/php
5882 <p>(<a rel="nofollow" class="external free" href="http://example.com/hi">http://example.com/hi</a>)
5883 </p><p>(<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
5884 </p>
5885 !! html/parsoid
5886 <p>(<a typeof="mw:ExpandedAttrs" about="#mwt2" rel="mw:ExtLink" href="http://example.com/hi" data-parsoid='{"stx":"url","a":{"href":"http://example.com/hi"},"sa":{"href":"http://example.com/{{echo|hi}}"}}' data-mw='{"attribs":[[{"txt":"href"},{"html":"http://example.com/&lt;span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid=&#39;{\"pi\":[[{\"k\":\"1\"}]],\"dsr\":[20,31,null,null]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"hi\"}},\"i\":0}}]}&#39;>hi&lt;/span>"}]]}'>http://example.com/hi</a>)</p>
5887
5888 <p>(<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url","a":{"href":"http://example.com"},"sa":{"href":"http://example.com&lt;!-- hi -->"}}'>http://example.com</a>)</p>
5889 !! end
5890
5891 !! test
5892 Serialize <a> tags with invalid link targets as plain text
5893 !! options
5894 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
5895 !! html/parsoid
5896 <a rel="mw:WikiLink" href="[[foo]]">text</a>
5897 <a rel="mw:WikiLink" href="[[foo]]">*text</a>
5898 <a rel="mw:WikiLink" href="[[foo]]">[[foo]]</a>
5899 <a rel="mw:WikiLink" href="[[foo]]">*a [[foo]]</a>
5900 !! wikitext
5901 text
5902 <nowiki>*</nowiki>text
5903 <nowiki>[[foo]]</nowiki>
5904 <nowiki>*</nowiki>a <nowiki>[[foo]]</nowiki>
5905 !! end
5906
5907 !! test
5908 mw:ExtLink -vs- mw:WikiLink (T94723)
5909 !! options
5910 parsoid=html2wt
5911 !! html/parsoid
5912 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"piped","a":{"href":"./Foo"},"sa":{"href":"Foo"}}'>Bar</a>
5913 <a rel="mw:WikiLink" href="./Foo" title="Foo">Bar</a>
5914 <a rel="mw:WikiLink" href="http://en.wikipedia.org/wiki/Foo" title="Foo">Bar</a>
5915 <a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/Foo" title="Foo">Bar</a>
5916 <p>
5917 <a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/European_Robin">European Robin</a>
5918 <a rel="mw:WikiLink" href="http://en.wikipedia.org/wiki/European_Robin">European Robin</a>
5919 </p>
5920 !! wikitext
5921 [[Foo|Bar]]
5922 [[Foo|Bar]]
5923 [[wikipedia:Foo|Bar]]
5924 [[wikipedia:Foo|Bar]]
5925
5926 [[wikipedia:European_Robin|European Robin]]
5927 [[wikipedia:European_Robin|European Robin]]
5928 !! end
5929
5930 !! test
5931 mw:ExtLink linking to a interwiki URL can be round-tripped losslessly (T94723)
5932 !! options
5933 parsoid=wt2wt
5934 !! wikitext
5935 [http://en.wikipedia.org/wiki/European_Robin European Robin]
5936 !! html/parsoid
5937 THIS SECTION IS NOT USED (but Parsoid won't run the test without it)
5938 !! end
5939
5940
5941 ###
5942 ### Quotes
5943 ###
5944
5945 !! test
5946 Quotes
5947 !! wikitext
5948 Normal text. '''Bold text.''' Normal text. ''Italic text.''
5949
5950 Normal text. '''''Bold italic text.''''' Normal text.
5951 !! html
5952 <p>Normal text. <b>Bold text.</b> Normal text. <i>Italic text.</i>
5953 </p><p>Normal text. <i><b>Bold italic text.</b></i> Normal text.
5954 </p>
5955 !! end
5956
5957
5958 # Parsoid inserts an empty bold tag pair at the end of the line, that the PHP
5959 # parser strips. The wikitext contains just the first half of the bold
5960 # quote pair.
5961 !! test
5962 Unclosed and unmatched quotes
5963 !! wikitext
5964 '''''Bold italic text '''with bold deactivated''' in between.'''''
5965
5966 '''''Bold italic text ''with italic deactivated'' in between.'''''
5967
5968 '''Bold text..
5969
5970 ..spanning two paragraphs (should not work).'''
5971
5972 '''Bold tag left open
5973
5974 ''Italic tag left open
5975
5976 Normal text.
5977
5978 <!-- Unmatching number of opening, closing tags: -->
5979 '''This year''''s election ''should'' beat '''last year''''s.
5980
5981 ''Tom'''s car is bigger than ''Susan'''s.
5982
5983 Plain ''italic'''s plain
5984 !! html/php
5985 <p><i><b>Bold italic text </b>with bold deactivated<b> in between.</b></i>
5986 </p><p><b><i>Bold italic text </i>with italic deactivated<i> in between.</i></b>
5987 </p><p><b>Bold text..</b>
5988 </p><p>..spanning two paragraphs (should not work).
5989 </p><p><b>Bold tag left open</b>
5990 </p><p><i>Italic tag left open</i>
5991 </p><p>Normal text.
5992 </p><p><b>This year'</b>s election <i>should</i> beat <b>last year'</b>s.
5993 </p><p><i>Tom<b>s car is bigger than </b></i><b>Susan</b>s.
5994 </p><p>Plain <i>italic'</i>s plain
5995 </p>
5996 !! html/parsoid
5997 <p><i><b>Bold italic text </b>with bold deactivated<b> in between.</b></i>
5998 </p><p><b><i>Bold italic text </i>with italic deactivated<i> in between.</i></b>
5999 </p><p><b>Bold text..</b>
6000 </p><p>..spanning two paragraphs (should not work).<b></b>
6001 </p><p><b>Bold tag left open</b>
6002 </p><p><i>Italic tag left open</i>
6003 </p><p>Normal text.
6004 </p>
6005 <!-- Unmatching number of opening, closing tags: -->
6006 <p><b>This year'</b>s election <i>should</i> beat <b>last year'</b>s.
6007 </p><p><i>Tom<b>s car is bigger than </b></i><b>Susan</b>s.
6008 </p><p>Plain <i>italic'</i>s plain
6009 </p>
6010 !! end
6011
6012 ###
6013 ### Tables
6014 ###
6015 ### some content taken from http://meta.wikimedia.org/wiki/MediaWiki_User%27s_Guide:_Using_tables
6016 ###
6017
6018 # This should not produce <table></table> as <table><tr><td></td></tr></table>
6019 # is the bare minimum required by the spec, see:
6020 # https://www.w3.org/TR/xhtml-modularization/dtd_module_defs.html#a_module_Basic_Tables
6021 # Parsoid team replies: empty table tags are legal in HTML5
6022 !! test
6023 A table with no data.
6024 !! options
6025 parsoid=wt2html
6026 !! wikitext
6027 {||}
6028 !! html/php
6029
6030 !! html/parsoid
6031 <table></table>
6032
6033 !! end
6034
6035 !! test
6036 A table with stray table end tags on start tag line (wt2html)
6037 !! options
6038 parsoid=wt2html
6039 !! wikitext
6040 {|style="color: red;"|}
6041
6042 {|style="color: red;" |}
6043 |foo
6044 |}
6045
6046 {|style="color: red;"|} id="foo"
6047 |foo
6048 |}
6049
6050 {|style="color: red;" |} id="foo"
6051 |foo
6052 |}
6053 !! html
6054 <table style="color: red;"></table>
6055
6056 <table style="color: red;">
6057 <tbody><tr>
6058 <td>foo</td>
6059 </tr></tbody>
6060 </table>
6061
6062 <table style="color: red;" id="foo">
6063 <tbody><tr>
6064 <td>foo</td>
6065 </tr></tbody>
6066 </table>
6067
6068 <table style="color: red;" id="foo">
6069 <tbody><tr>
6070 <td>foo</td>
6071 </tr></tbody>
6072 </table>
6073
6074 !! end
6075
6076 !! test
6077 A table with no data (take 2)
6078 !! wikitext
6079 {|
6080 |}
6081 !! html/parsoid
6082 <table></table>
6083 !! end
6084
6085 # A table with nothing but a caption is invalid XHTML, we might want to render
6086 # this as <p>caption</p>
6087 # Parsoid team replies: table with only a caption is legal in HTML5
6088 !! test
6089 A table with nothing but a caption
6090 !! wikitext
6091 {|
6092 |+ caption
6093 |}
6094 !! html/php
6095 <table>
6096 <caption> caption
6097 </caption><tr><td></td></tr></table>
6098
6099 !! html/parsoid
6100 <table><caption> caption</caption></table>
6101 !! end
6102
6103 !! test
6104 A table with caption with default-spaced attributes and a table row
6105 !! wikitext
6106 {|
6107 |+ style="color: red;" | caption1
6108 |-
6109 | foo
6110 |}
6111 !! html
6112 <table>
6113 <caption style="color: red;"> caption1
6114 </caption>
6115 <tr>
6116 <td> foo
6117 </td></tr></table>
6118
6119 !! end
6120
6121 !! test
6122 A table with captions with non-default spaced attributes and a table row
6123 !! wikitext
6124 {|
6125 |+style="color: red;"|caption2
6126 |+ style="color: red;"| caption3
6127 |-
6128 | foo
6129 |}
6130 !! html
6131 <table>
6132 <caption style="color: red;">caption2
6133 </caption>
6134 <caption style="color: red;"> caption3
6135 </caption>
6136 <tr>
6137 <td> foo
6138 </td></tr></table>
6139
6140 !! end
6141
6142 !! test
6143 Table td-cell syntax variations
6144 !! wikitext
6145 {|
6146 | foo bar foo | baz
6147 | foo bar foo || baz
6148 | style='color:red;' | baz
6149 | style='color:red;' || baz
6150 |}
6151 !! html
6152 <table>
6153 <tr>
6154 <td> baz
6155 </td>
6156 <td> foo bar foo </td>
6157 <td> baz
6158 </td>
6159 <td style="color:red;"> baz
6160 </td>
6161 <td> style='color:red;' </td>
6162 <td> baz
6163 </td></tr></table>
6164
6165 !! end
6166
6167 !! test
6168 Simple table
6169 !! wikitext
6170 {|
6171 | 1 || 2
6172 |-
6173 | 3 || 4
6174 |}
6175 !! html
6176 <table>
6177 <tr>
6178 <td> 1 </td>
6179 <td> 2
6180 </td></tr>
6181 <tr>
6182 <td> 3 </td>
6183 <td> 4
6184 </td></tr></table>
6185
6186 !! end
6187
6188 !! test
6189 Simple table but with multiple dashes for row wikitext
6190 !! wikitext
6191 {|
6192 | foo
6193 |-----
6194 | bar
6195 |}
6196 !! html
6197 <table>
6198 <tr>
6199 <td> foo
6200 </td></tr>
6201 <tr>
6202 <td> bar
6203 </td></tr></table>
6204
6205 !! end
6206
6207 !! test
6208 Multiplication table
6209 !! wikitext
6210 {| border="1" cellpadding="2"
6211 |+Multiplication table
6212 |-
6213 ! &times; !! 1 !! 2 !! 3
6214 |-
6215 ! 1
6216 | 1 || 2 || 3
6217 |-
6218 ! 2
6219 | 2 || 4 || 6
6220 |-
6221 ! 3
6222 | 3 || 6 || 9
6223 |-
6224 ! 4
6225 | 4 || 8 || 12
6226 |-
6227 ! 5
6228 | 5 || 10 || 15
6229 |}
6230 !! html
6231 <table border="1" cellpadding="2">
6232 <caption>Multiplication table
6233 </caption>
6234 <tr>
6235 <th> &#215; </th>
6236 <th> 1 </th>
6237 <th> 2 </th>
6238 <th> 3
6239 </th></tr>
6240 <tr>
6241 <th> 1
6242 </th>
6243 <td> 1 </td>
6244 <td> 2 </td>
6245 <td> 3
6246 </td></tr>
6247 <tr>
6248 <th> 2
6249 </th>
6250 <td> 2 </td>
6251 <td> 4 </td>
6252 <td> 6
6253 </td></tr>
6254 <tr>
6255 <th> 3
6256 </th>
6257 <td> 3 </td>
6258 <td> 6 </td>
6259 <td> 9
6260 </td></tr>
6261 <tr>
6262 <th> 4
6263 </th>
6264 <td> 4 </td>
6265 <td> 8 </td>
6266 <td> 12
6267 </td></tr>
6268 <tr>
6269 <th> 5
6270 </th>
6271 <td> 5 </td>
6272 <td> 10 </td>
6273 <td> 15
6274 </td></tr></table>
6275
6276 !! end
6277
6278 !! test
6279 Accept "||" in table headings
6280 !! wikitext
6281 {|
6282 !h1 || h2
6283 |}
6284 !! html
6285 <table>
6286 <tr>
6287 <th>h1 </th>
6288 <th> h2
6289 </th></tr></table>
6290
6291 !! end
6292
6293 !! test
6294 Accept "!!" in table data
6295 !! wikitext
6296 {|
6297 | Foo!! ||
6298 |}
6299 !! html
6300 <table>
6301 <tr>
6302 <td> Foo!! </td>
6303 <td>
6304 </td></tr></table>
6305
6306 !! html/parsoid
6307 <table>
6308 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'> Foo!! </td><td data-parsoid='{"stx_v":"row","autoInsertedEnd":true}'></td></tr>
6309 </tbody></table>
6310 !! end
6311
6312 !! test
6313 Accept "||" in indented table headings
6314 !! wikitext
6315 :{|
6316 !h1 || h2
6317 |}
6318 !! html
6319 <dl><dd><table>
6320 <tr>
6321 <th>h1 </th>
6322 <th> h2
6323 </th></tr></table></dd></dl>
6324
6325 !! end
6326
6327 !! test
6328 Accept "!!" in templates
6329 !! wikitext
6330 {|
6331 !a {{echo|b!!c}}
6332 |}
6333 !! html/php
6334 <table>
6335 <tr>
6336 <th>a b</th>
6337 <th>c
6338 </th></tr></table>
6339
6340 !! html/parsoid
6341 <table>
6342 <tbody><tr><th typeof="mw:Transclusion" about="#mwt1" data-parsoid='{"autoInsertedEnd":true,"pi":[[{"k":"1"}]]}' data-mw='{"parts":["!a ",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"b!!c"}},"i":0}}]}'>a b</th><th about="#mwt1">c</th></tr>
6343 !! end
6344
6345 !! test
6346 Accept "!!" in table headings after newline
6347 !! wikitext
6348 {|
6349 !a
6350 b!!c
6351 |}
6352 !! html/php
6353 <table>
6354 <tr>
6355 <th>a
6356 <p>b!!c
6357 </p>
6358 </th></tr></table>
6359
6360 !! html/parsoid
6361 <table>
6362 <tbody><tr><th>a
6363 <p>b!!c</p></th></tr>
6364 </tbody></table>
6365 !! end
6366
6367 !! test
6368 Accept "!!" in table data of mixed wikitext / html syntax
6369 !! wikitext
6370 {|
6371 !a
6372 <tr><td>b!!c</td></tr>
6373 |}
6374 !! html+tidy
6375 <table>
6376 <tr>
6377 <th>a</th>
6378 </tr>
6379 <tr>
6380 <td>b!!c</td>
6381 </tr>
6382 </table>
6383 !! html/parsoid
6384 <table>
6385 <tbody><tr><th>a</th></tr>
6386 <tr data-parsoid='{"stx":"html"}'><td data-parsoid='{"stx":"html"}'>b!!c</td></tr>
6387 </tbody></table>
6388 !! end
6389
6390 !! test
6391 Accept empty attributes in td/th cells (td/th cells starting with leading ||)
6392 !! wikitext
6393 {|
6394 !| h1
6395 || a
6396 |}
6397 !! html
6398 <table>
6399 <tr>
6400 <th> h1
6401 </th>
6402 <td> a
6403 </td></tr></table>
6404
6405 !! end
6406
6407 !!test
6408 Accept "| !" at start of line in tables (ignore !-attribute)
6409 !! wikitext
6410 {|
6411 |-
6412 | !style="color:red" | bar
6413 |}
6414 !! html
6415 <table>
6416
6417 <tr>
6418 <td> bar
6419 </td></tr></table>
6420
6421 !!end
6422
6423 !!test
6424 Allow +/- in 2nd and later cells in a row, in 1st cell when td-attrs are present, or in 1st cell when there is a space between "|" and +/-
6425 !! wikitext
6426 {|
6427 |-
6428 |style='color:red;'|+1
6429 |style='color:blue;'|-1
6430 |-
6431 | 1 || 2 || 3
6432 | 1 ||+2 ||-3
6433 |-
6434 | +1
6435 | -1
6436 |}
6437 !! html
6438 <table>
6439
6440 <tr>
6441 <td style="color:red;">+1
6442 </td>
6443 <td style="color:blue;">-1
6444 </td></tr>
6445 <tr>
6446 <td> 1 </td>
6447 <td> 2 </td>
6448 <td> 3
6449 </td>
6450 <td> 1 </td>
6451 <td>+2 </td>
6452 <td>-3
6453 </td></tr>
6454 <tr>
6455 <td> +1
6456 </td>
6457 <td> -1
6458 </td></tr></table>
6459
6460 !!end
6461
6462 !! test
6463 Table rowspan
6464 !! wikitext
6465 {| border=1
6466 | Cell 1, row 1
6467 |rowspan=2| Cell 2, row 1 (and 2)
6468 | Cell 3, row 1
6469 |-
6470 | Cell 1, row 2
6471 | Cell 3, row 2
6472 |}
6473 !! html
6474 <table border="1">
6475 <tr>
6476 <td> Cell 1, row 1
6477 </td>
6478 <td rowspan="2"> Cell 2, row 1 (and 2)
6479 </td>
6480 <td> Cell 3, row 1
6481 </td></tr>
6482 <tr>
6483 <td> Cell 1, row 2
6484 </td>
6485 <td> Cell 3, row 2
6486 </td></tr></table>
6487
6488 !! end
6489
6490 !! test
6491 Nested table
6492 !! wikitext
6493 {| border=1
6494 | &alpha;
6495 |
6496 {| bgcolor=#ABCDEF border=2
6497 |nested
6498 |-
6499 |table
6500 |}
6501 |the original table again
6502 |}
6503 !! html
6504 <table border="1">
6505 <tr>
6506 <td> &#945;
6507 </td>
6508 <td>
6509 <table bgcolor="#ABCDEF" border="2">
6510 <tr>
6511 <td>nested
6512 </td></tr>
6513 <tr>
6514 <td>table
6515 </td></tr></table>
6516 </td>
6517 <td>the original table again
6518 </td></tr></table>
6519
6520 !! end
6521
6522 !! test
6523 Invalid attributes in table cell (T3830)
6524 !! wikitext
6525 {|
6526 |Cell:|broken
6527 |}
6528 !! html
6529 <table>
6530 <tr>
6531 <td>broken
6532 </td></tr></table>
6533
6534 !! end
6535
6536 !! test
6537 Table cell attributes: Pipes protected by nowikis should be treated as a plain character
6538 !! wikitext
6539 {|
6540 | title="foo" |bar
6541 | title="foo<nowiki>|</nowiki>" |bar
6542 | title="foo<nowiki>|</nowiki>" bar
6543 |}
6544 !! html/php
6545 <table>
6546 <tr>
6547 <td title="foo">bar
6548 </td>
6549 <td title="foo&#124;">bar
6550 </td>
6551 <td> title="foo|" bar
6552 </td></tr></table>
6553
6554 !! html/parsoid
6555 <table>
6556 <tbody><tr><td title="foo">bar</td>
6557 <td title="foo|" data-parsoid='{"a":{"title":"foo|"},"sa":{"title":"foo&lt;nowiki>|&lt;/nowiki>"},"autoInsertedEnd":true}'>bar</td>
6558 <td> title="foo<span typeof="mw:Nowiki">|</span>" bar</td></tr>
6559 </tbody></table>
6560 !! end
6561
6562 # See: http://lists.wikimedia.org/mailman/htdig/wikitech-l/2006-April/022293.html
6563 # N.B. The "|}" to close the table is missing from the input, so parsoid's
6564 # *2wt modes will fail.
6565 !! test
6566 Table security: embedded pipes
6567 !! options
6568 parsoid=wt2html,html2html
6569 !! wikitext
6570 {|
6571 | |[ftp://|x||]" onmouseover="alert(document.cookie)">test
6572 !! html/php
6573 <table>
6574 <tr>
6575 <td>[<a rel="nofollow" class="external free" href="ftp://%7Cx">ftp://%7Cx</a></td>
6576 <td>]" onmouseover="alert(document.cookie)"&gt;test
6577 </td>
6578 </tr>
6579 </table>
6580
6581 !! html/parsoid
6582 <table><tbody>
6583 <tr>
6584 <td data-parsoid='{"startTagSrc":"| ","attrSepSrc":"|","autoInsertedEnd":true}'>[<a rel="mw:ExtLink" href="ftp://%7Cx" data-parsoid='{"stx":"url","a":{"href":"ftp://%7Cx"},"sa":{"href":"ftp://|x"}}'>ftp://%7Cx</a></td><td data-parsoid='{"stx_v":"row","autoInsertedEnd":true}'>]" onmouseover="alert(document.cookie)">test</td></tr></tbody></table>
6585 !! end
6586
6587 !! test
6588 Element attributes with double ! should not be broken up by <th>
6589 !! wikitext
6590 {|
6591 ! hi <div class="!!">ha</div> ho
6592 |}
6593 !! html/php
6594 <table>
6595 <tr>
6596 <th> hi <div class="!!">ha</div> ho
6597 </th></tr></table>
6598
6599 !! html/parsoid
6600 <table>
6601 <tbody><tr><th> hi <div class="!!" data-parsoid='{"stx":"html"}'>ha</div> ho</th></tr>
6602 </tbody></table>
6603 !! end
6604
6605 !! test
6606 ! and || in element attributes should not be parsed as <th>/<td>
6607 !! wikitext
6608 {|
6609 | <div style="color: red !important;" data-contrived="put this here ||">hi</div>
6610 |}
6611 !! html/php
6612 <table>
6613 <tr>
6614 <td> <div style="color: red !important;" data-contrived="put this here &#124;&#124;">hi</div>
6615 </td></tr></table>
6616
6617 !! html/parsoid
6618 <table>
6619 <tbody><tr><td> <div style="color: red !important;" data-contrived="put this here ||" data-parsoid='{"stx":"html"}'>hi</div></td></tr>
6620 </tbody></table>
6621 !! end
6622
6623 # FIXME: The output seems broken. Filed as T110268.
6624 !! test
6625 ! and || in td attributes should not be parsed as <th>/<td>
6626 !! options
6627 parsoid=wt2html
6628 !! wikitext
6629 {|
6630 | style="color: red !important;" data-contrived="put this here ||" | foo
6631 |}
6632 !! html/php
6633 <table>
6634 <tr>
6635 <td> style="color: red !important;" data-contrived="put this here </td>
6636 <td> foo
6637 </td></tr></table>
6638
6639 !! html/parsoid
6640 <table>
6641 <tbody><tr><td> style="color: red !important;" data-contrived="put this here </td><td data-parsoid='{"stx_v":"row","a":{"\"":null},"sa":{"\"":""},"autoInsertedEnd":true}'> foo</td></tr>
6642 </tbody></table>
6643 !! end
6644
6645 !! test
6646 Break on | in element attribute in template
6647 !! options
6648 parsoid=wt2html,html2html
6649 !! wikitext
6650 {{echo|1=<div class="hi|ho">ha</div>}}
6651 !! html/php
6652 <p>ho"&gt;ha&lt;/div&gt;
6653 </p>
6654 !! html/parsoid
6655 <span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"ho\">ha&lt;/div>"}},"i":0}}]}'>ho">ha</span>
6656 !! end
6657
6658 !! test
6659 Break on | in element attribute name in template
6660 !! wikitext
6661 {{echo|<div cla|ss="hiho">ha</div>}}
6662 !! html/parsoid
6663 <p about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1"},{"k":"ss","named":true}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;div cla"},"ss":{"wt":"\"hiho\">ha&lt;/div>"}},"i":0}}]}'>&lt;div cla</p>
6664 !! end
6665
6666 !! test
6667 Don't break on | in extension attribute in template
6668 !! wikitext
6669 {{echo|<ref name="hi|ho">ha</ref>}}
6670
6671 <references />
6672 !! html/parsoid
6673 <p><span about="#mwt2" class="mw-ref" id="cite_ref-hi.7Cho_1-0" rel="dc:references" typeof="mw:Transclusion mw:Extension/ref" data-parsoid='{"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;ref name=\"hi|ho\">ha&lt;/ref>"}},"i":0}}]}'><a href="./Main_Page#cite_note-hi.7Cho-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></span></p>
6674
6675 <ol class="mw-references" typeof="mw:Extension/references" about="#mwt5" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-hi.7Cho-1" id="cite_note-hi.7Cho-1"><a href="./Main_Page#cite_ref-hi.7Cho_1-0" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-hi.7Cho-1" class="mw-reference-text">ha</span></li></ol>
6676 !! end
6677
6678 ## We don't support roundtripping of these attributes in Parsoid.
6679 ## Selective serialization takes care of preventing dirty diffs.
6680 ## But, on edits, we dirty-diff the invalid attribute text.
6681 !! test
6682 Invalid text in table attributes should be discarded
6683 !! options
6684 parsoid=wt2html
6685 !! wikitext
6686 {| <span>boo</span> style='border:1px solid black'
6687 | <span>boo</span> style='color:blue' | 1
6688 |<span>boo</span> style='color:blue'| 2
6689 |}
6690 !! html/php
6691 <table style="border:1px solid black">
6692 <tr>
6693 <td style="color:blue"> 1
6694 </td>
6695 <td style="color:blue"> 2
6696 </td></tr></table>
6697
6698 !! html/parsoid
6699 <table style="border:1px solid black">
6700 <tr>
6701 <td style="color:blue"> 1</td>
6702 <td style="color:blue"> 2</td>
6703 </tr>
6704 </table>
6705 !! end
6706
6707 !! test
6708 Invalid text in table attributes should be preserved by selective serializer
6709 !! options
6710 parsoid={
6711 "modes": ["selser"],
6712 "changes": [
6713 ["td:first-child", "text", "abc"],
6714 ["td + td", "text", "xyz"]
6715 ]
6716 }
6717 !! wikitext
6718 {| <span>boo</span> style='border:1px solid black'
6719 | <span>boo</span> style='color:blue' | 1
6720 |<span>boo</span> style='color:blue'| 2
6721 |}
6722 !! wikitext/edited
6723 {| <span>boo</span> style='border:1px solid black'
6724 | <span>boo</span> style='color:blue' |abc
6725 |<span>boo</span> style='color:blue'|xyz
6726 |}
6727 !! end
6728
6729 !! test
6730 1. Template-generated table cell attributes and cell content
6731 !! wikitext
6732 {|
6733 |{{table_attribs}}
6734 | {{table_attribs}}
6735 || {{table_attribs_5}}
6736 | <!--foo--> <!--bar--> <!--baz--> {{table_attribs}}
6737 |align=center {{table_attribs}}
6738 | <!--foo--> align=center <!--bar--> {{table_attribs}}
6739 |}
6740 !! html
6741 <table>
6742 <tr>
6743 <td style="color:red;">Foo
6744 </td>
6745 <td style="color:red;">Foo
6746 </td>
6747 <td> style="color:red;"</td>
6748 <td>Bar
6749 </td>
6750 <td style="color:red;">Foo
6751 </td>
6752 <td align="center" style="color:red;">Foo
6753 </td>
6754 <td align="center" style="color:red;">Foo
6755 </td></tr></table>
6756
6757 !! end
6758
6759 !! test
6760 2. Template-generated table cell attributes and cell content
6761 !! wikitext
6762 {|
6763 |{{table_attribs_2}}
6764 |}
6765 !! html/php
6766 <table>
6767 <tr>
6768 <td style="color:red;">Foo
6769 </td>
6770 <td>Bar</td>
6771 <td>Baz
6772 </td></tr></table>
6773
6774 !! html/parsoid
6775 <table>
6776 <tbody><tr><td about="#mwt1" typeof="mw:Transclusion" style="color:red;" data-mw='{"parts":["|",{"template":{"target":{"wt":"table_attribs_2","href":"./Template:Table_attribs_2"},"params":{},"i":0}}]}'>Foo</td>
6777 <td about="#mwt1">Bar</td><td about="#mwt1">Baz</td></tr>
6778 </tbody></table>
6779 !! end
6780
6781 !! test
6782 3. Template-generated table cell attributes and cell content
6783 !! wikitext
6784 {|
6785 !align=center {{table_header_cells}}
6786 |-
6787 |align=center {{table_cells}}
6788 |}
6789 !! html/php
6790 <table>
6791 <tr>
6792 <th align="center" style="color:red;">Foo</th>
6793 <th style="color:red;"><i>Bar</i></th>
6794 <th style="color:brown;"><i>Foo</i> and Baz
6795 </th></tr>
6796 <tr>
6797 <td align="center" style="color:red;">Foo</td>
6798 <td style="color:red;"><i>Bar</i></td>
6799 <td style="color:brown;"><i>Foo</i> and Baz
6800 </td></tr></table>
6801
6802 !! html/parsoid
6803 <table>
6804 <tbody><tr><th align="center" style="color:red;" typeof="mw:Transclusion" about="#mwt1" data-mw='{"parts":["!align=center ",{"template":{"target":{"wt":"table_header_cells","href":"./Template:Table_header_cells"},"params":{},"i":0}}]}'>Foo</th><th about="#mwt1" style="color:red;"><i about="#mwt1">Bar</i></th><th about="#mwt1" style="color:brown;"><i about="#mwt1">Foo</i> and Baz</th></tr><tr>
6805 <td align="center" style="color:red;" typeof="mw:Transclusion" about="#mwt1" data-mw='{"parts":["|align=center ",{"template":{"target":{"wt":"table_cells","href":"./Template:Table_cells"},"params":{},"i":0}}]}'>Foo</td><td about="#mwt1" style="color:red;"><i about="#mwt1">Bar</i></td><td about="#mwt1" style="color:brown;"><i about="#mwt1">Foo</i> and Baz</td></tr>
6806 </tbody></table>
6807 !! end
6808
6809 !! test
6810 4. Template-generated table cell attributes and cell content inside a templated table
6811 !! wikitext
6812 {{tbl-start}}
6813 !align=center {{table_header_cells}}
6814 |-
6815 |align=center {{table_cells}}
6816 {{tbl-end}}
6817 !! html/php
6818 <table>
6819 <tr>
6820 <th align="center" style="color:red;">Foo</th>
6821 <th style="color:red;"><i>Bar</i></th>
6822 <th style="color:brown;"><i>Foo</i> and Baz
6823 </th></tr>
6824 <tr>
6825 <td align="center" style="color:red;">Foo</td>
6826 <td style="color:red;"><i>Bar</i></td>
6827 <td style="color:brown;"><i>Foo</i> and Baz
6828 </td></tr></table>
6829
6830 !! html/parsoid
6831 <table about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[],[],[],[]]}' data-mw='{"parts":[{"template":{"target":{"wt":"tbl-start","href":"./Template:Tbl-start"},"params":{},"i":0}},"\n!align=center ",{"template":{"target":{"wt":"table_header_cells","href":"./Template:Table_header_cells"},"params":{},"i":1}},"\n|-\n|align=center ",{"template":{"target":{"wt":"table_cells","href":"./Template:Table_cells"},"params":{},"i":2}},"\n",{"template":{"target":{"wt":"tbl-end","href":"./Template:Tbl-end"},"params":{},"i":3}}]}'>
6832 <tbody><tr><th align="center" style="color:red;">Foo</th><th style="color:red;"><i>Bar</i></th><th style="color:brown;"><i>Foo</i> and Baz</th></tr>
6833 <tr>
6834 <td align="center" style="color:red;">Foo</td><td style="color:red;"><i>Bar</i></td><td style="color:brown;"><i>Foo</i> and Baz</td></tr>
6835 </tbody></table>
6836 !! end
6837
6838 ## Edge case fix to prevent future regressions
6839 !! test
6840 T107652: <ref>s in templates that also generate table cell attributes should be rendered properly
6841 !! wikitext
6842 {|
6843 |{{table_attribs_7}}
6844 |}
6845 <references />
6846 !! html/parsoid
6847 <table>
6848 <tbody><tr><td style="background:#f9f9f9;" typeof="mw:Transclusion" about="#mwt1" data-mw='{"parts":["|",{"template":{"target":{"wt":"table_attribs_7","href":"./Template:Table_attribs_7"},"params":{},"i":0}}]}'>Foo<span class="mw-ref" id="cite_ref-1" rel="dc:references" data-mw='{"name":"ref","body":{"id":"mw-reference-text-cite_note-1"},"attrs":{}}'><a href="./Main_Page#cite_note-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></span></td></tr>
6849 </tbody></table>
6850 <ol class="mw-references" typeof="mw:Extension/references" about="#mwt5" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text" data-parsoid="{}">foo</span></li></ol>
6851 !! end
6852
6853 !! test
6854 Table with row followed by newlines and table heading
6855 !! options
6856 parsoid=wt2html,html2html
6857 !! wikitext
6858 {|
6859 |-
6860
6861 ! foo
6862 |}
6863 !! html/*
6864 <table>
6865
6866
6867 <tr>
6868 <th> foo
6869 </th></tr></table>
6870
6871 !! end
6872
6873 !! test
6874 Table with empty line following the start tag
6875 !! options
6876 parsoid=wt2html,html2html
6877 !! wikitext
6878 {|
6879
6880 |-
6881 | foo
6882 |}
6883 !! html/*
6884 <table>
6885
6886
6887 <tr>
6888 <td> foo
6889 </td></tr></table>
6890
6891 !! end
6892
6893 !! test
6894 Table attributes with empty value
6895 !! options
6896 parsoid=wt2html,html2html
6897 !! wikitext
6898 {|
6899 | style=| hello
6900 |}
6901 !! html/php
6902 <table>
6903 <tr>
6904 <td style=""> hello
6905 </td></tr></table>
6906
6907 !! html/parsoid
6908 <table>
6909 <tbody><tr><td style=""> hello</td></tr>
6910 </tbody></table>
6911 !! end
6912
6913 !! test
6914 Wikitext table with a lot of comments
6915 !! wikitext
6916 {|
6917 <!-- c0 -->
6918 | foo
6919 <!-- c1 -->
6920 |-<!-- c2 -->
6921 <!-- c3 -->
6922 |<!-- c4 -->
6923 <!-- c5 -->
6924 |}
6925 !! html
6926 <table>
6927 <tr>
6928 <td> foo
6929 </td></tr>
6930 <tr>
6931 <td>
6932 </td></tr></table>
6933
6934 !! end
6935
6936 !! test
6937 Wikitext table comments represented in parsoid dom
6938 !! wikitext
6939 {|<!--c1--><!--c2-->
6940 |-<!--c3-->
6941 | x
6942 |}
6943 !! html/php+tidy
6944 <table>
6945 <tr>
6946 <td>x</td>
6947 </tr>
6948 </table>
6949 !! html/parsoid
6950 <table><!--c1--><!--c2-->
6951 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'><!--c3-->
6952 <td data-parsoid='{"autoInsertedEnd":true}'> x</td></tr>
6953 </tbody></table>
6954 !! end
6955
6956 !! test
6957 Wikitext table with double-line table cell
6958 !! wikitext
6959 {|
6960 |a
6961 b
6962 |}
6963 !! html
6964 <table>
6965 <tr>
6966 <td>a
6967 <p>b
6968 </p>
6969 </td></tr></table>
6970
6971 !! end
6972
6973 !! test
6974 Table cell with a single comment
6975 !! wikitext
6976 {|
6977 | <!-- c1 -->
6978 | a
6979 |}
6980 !! html
6981 <table>
6982 <tr>
6983 <td>
6984 </td>
6985 <td> a
6986 </td></tr></table>
6987
6988 !! end
6989
6990 !! test
6991 Table-cell after a comment-only-empty-line
6992 !! wikitext
6993 {|
6994 |a
6995 <!--c1-->
6996 <!--c2-->| b
6997 |}
6998 !! html
6999 <table>
7000 <tr>
7001 <td>a
7002 </td>
7003 <td> b
7004 </td></tr></table>
7005
7006 !! html/parsoid
7007 <table>
7008 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'>a</td>
7009 <!--c1-->
7010 <!--c2--><td data-parsoid='{"autoInsertedEnd":true}'> b</td></tr>
7011 </tbody></table>
7012
7013 !! end
7014
7015 !! test
7016 Build table with {{!}}
7017 !! wikitext
7018 {{{!}} class="wikitable"
7019 ! header
7020 ! second header
7021 {{!}}- style="color:red;"
7022 {{!}} data {{!}}{{!}} style="color:red;" {{!}} second data
7023 {{!}}}
7024 !! html
7025 <table class="wikitable">
7026 <tr>
7027 <th> header
7028 </th>
7029 <th> second header
7030 </th></tr>
7031 <tr style="color:red;">
7032 <td> data </td>
7033 <td style="color:red;"> second data
7034 </td></tr></table>
7035
7036 !! end
7037
7038 !! test
7039 Build table with pipe as data
7040 !! wikitext
7041 {| class="wikitable"
7042 ! header
7043 ! second header
7044 |- style="color:red;"
7045 | data || style="color:red;" | second data
7046 |-
7047 | style="color:red;" | data with | || style="color:red;" | second data with |
7048 |-
7049 || data with | ||| second data with |
7050 |}
7051 !! html
7052 <table class="wikitable">
7053 <tr>
7054 <th> header
7055 </th>
7056 <th> second header
7057 </th></tr>
7058 <tr style="color:red;">
7059 <td> data </td>
7060 <td style="color:red;"> second data
7061 </td></tr>
7062 <tr>
7063 <td style="color:red;"> data with | </td>
7064 <td style="color:red;"> second data with |
7065 </td></tr>
7066 <tr>
7067 <td> data with | </td>
7068 <td> second data with |
7069 </td></tr></table>
7070
7071 !! end
7072
7073 !! test
7074 Build table with wikilink
7075 !! wikitext
7076 {| class="wikitable"
7077 ! header || second header
7078 |- style="color:red;"
7079 | data [[Main Page|linktext]] || second data [[Main Page|linktext]]
7080 |-
7081 | data || second data [[Main Page|link|text with pipe]]
7082 |}
7083 !! html
7084 <table class="wikitable">
7085 <tr>
7086 <th> header </th>
7087 <th> second header
7088 </th></tr>
7089 <tr style="color:red;">
7090 <td> data <a href="/wiki/Main_Page" title="Main Page">linktext</a> </td>
7091 <td> second data <a href="/wiki/Main_Page" title="Main Page">linktext</a>
7092 </td></tr>
7093 <tr>
7094 <td> data </td>
7095 <td> second data <a href="/wiki/Main_Page" title="Main Page">link|text with pipe</a>
7096 </td></tr></table>
7097
7098 !! end
7099
7100 # The expected HTML structure in this test is debatable. The PHP parser does
7101 # not parse this kind of table at all. The main focus for Parsoid is on
7102 # round-tripping, so this output is ok for now. TODO: revisit!
7103 !! test
7104 Wikitext table with html-syntax row
7105 !! wikitext
7106 {|
7107 |-
7108 <td>foo</td>
7109 |}
7110 !! html/parsoid
7111 <table>
7112 <tbody>
7113 <tr>
7114 <td>foo</td></tr></tbody></table>
7115 !! end
7116
7117 !! test
7118 Implicit <td> after a |-
7119 !! options
7120 parsoid=wt2html,html2html
7121 !! wikitext
7122 {|
7123 |-
7124 a
7125 |}
7126 !! html/php
7127 <table>
7128
7129 a
7130 </table>
7131
7132 !! html/php+tidy
7133 <p>a</p>
7134 !! html/parsoid
7135 <p data-parsoid='{"fostered":true,"autoInsertedEnd":true}'>a</p><table>
7136 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
7137
7138 </tr></tbody></table>
7139 !! end
7140
7141 !! test
7142 Lists should be recognized in an implicit <td> context
7143 !! options
7144 parsoid=wt2html,html2html
7145 !! wikitext
7146 {|
7147 |-
7148 *a
7149 |}
7150 !! html/php
7151 <table>
7152
7153 <ul><li>a</li></ul>
7154 </table>
7155
7156 !! html/php+tidy
7157 <ul>
7158 <li>a</li>
7159 </ul>
7160 !! html/parsoid
7161 <ul data-parsoid='{"fostered":true,"autoInsertedEnd":true}'><li>a</li></ul><table>
7162 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
7163
7164 </tr></tbody></table>
7165 !! end
7166
7167 !! test
7168 Table cells not properly parsed in an implicit-td context
7169 !! wikitext
7170 {|
7171 |-
7172 {{table_attribs_4}} || a || b
7173 |}
7174 !! html/php+tidy
7175 <table>
7176 <tr>
7177 <td style="background-color:#DC241f;" width="10px"></td>
7178 <td>a</td>
7179 <td>b</td>
7180 </tr>
7181 </table>
7182 !! html/parsoid
7183 <table>
7184 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
7185 <td style="background-color:#DC241f;" width="10px" about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"autoInsertedEnd":true,"pi":[[]]}' data-mw='{"parts":[{"template":{"target":{"wt":"table_attribs_4","href":"./Template:Table_attribs_4"},"params":{},"i":0}}," || a || b"]}'> </td><td about="#mwt1"> a </td><td about="#mwt1"> b</td></tr>
7186 !! end
7187
7188 !! test
7189 Parsoid: Round-trip tables directly followed by content (T53219)
7190 !! options
7191 parsoid=wt2html,wt2wt
7192 !! wikitext
7193 {|
7194 |foo
7195 |} bar
7196
7197 {|
7198 |baz
7199 |}<b>quux</b>
7200 !! html+tidy
7201 <table>
7202 <tr>
7203 <td>foo</td>
7204 </tr>
7205 </table>
7206 <p>bar</p>
7207 <table>
7208 <tr>
7209 <td>baz</td>
7210 </tr>
7211 </table>
7212 <p><b>quux</b></p>
7213 !! end
7214
7215 !! test
7216 Parsoid: Default to a newline after tables in new content (T53219)
7217 !! options
7218 parsoid=html2wt
7219 !! html/parsoid
7220 <table><tbody>
7221 <tr><td>foo</td></tr></tbody></table> bar
7222 <table><tbody>
7223 <tr><td>baz</td></tr></tbody></table><b>quux</b>
7224 !! wikitext
7225 {|
7226 |foo
7227 |}
7228 <nowiki> </nowiki>bar
7229 {|
7230 |baz
7231 |}
7232 '''quux'''
7233 !! end
7234
7235 !! test
7236 Parsoid: newline inducing block nodes don't suppress <nowiki>
7237 !! options
7238 parsoid=html2wt
7239 !! html/parsoid
7240 a<h1>foo</h1>
7241 !! wikitext
7242 <nowiki> </nowiki>a
7243
7244 = foo =
7245 !! end
7246
7247 !! test
7248 Parsoid: Row-syntax table headings followed by comment & table cells
7249 !! options
7250 parsoid=wt2html,wt2wt
7251 !! wikitext
7252 {|
7253 ! foo || bar
7254 <!-- foo --> || baz || quux
7255 |}
7256 !! html/php
7257 <table>
7258 <tr>
7259 <th> foo </th>
7260 <th> bar
7261 </th>
7262 <td> baz </td>
7263 <td> quux
7264 </td></tr></table>
7265
7266 !! html/parsoid
7267 <table>
7268 <tbody><tr><th> foo </th><th> bar
7269 <!-- foo --> </th><td> baz </td><td> quux</td></tr>
7270 </tbody></table>
7271 !! end
7272
7273 !!test
7274 Parsoid: Recover better from broken table attributes
7275 !!options
7276 parsoid=wt2html
7277 !!wikitext
7278 {| class="foo
7279 | class="bar" |
7280 foo
7281 |}
7282 !!html/php+tidy
7283 <table class="foo">
7284 <tr>
7285 <td class="bar">
7286 <p>foo</p>
7287 </td>
7288 </tr>
7289 </table>
7290 !!html/parsoid
7291 <table class="foo">
7292 <tr>
7293 <td class="bar">
7294 <p>foo</p></td></tr>
7295 </tbody></table>
7296 !!end
7297
7298 !! test
7299 Tables: Digest broken attributes on table and tr tag
7300 !! options
7301 parsoid=wt2html
7302 !! wikitext
7303 {| || |} ++
7304 |- || || ++ --
7305 |- > [
7306 |}
7307 !! html
7308 <table>
7309 <tbody>
7310 <tr></tr>
7311 <tr></tr>
7312 </tbody></table>
7313 !! end
7314
7315 # T137406: Whitespace in the HTML
7316 !! test
7317 1. Generate correct wikitext for tables with thead/tbody/tfoot
7318 !! options
7319 parsoid=html2wt
7320 !! html/parsoid
7321 <table>
7322 <caption>Test</caption>
7323 <thead>
7324 <tr>
7325 <th>Month</th>
7326 <th>Savings</th>
7327 </tr>
7328 </thead>
7329 <tbody>
7330 <tr>
7331 <td>January</td>
7332 <td>$100</td>
7333 </tr>
7334 <tr>
7335 <td>February</td>
7336 <td>$80</td>
7337 </tr>
7338 </tbody>
7339 <tfoot>
7340 <tr>
7341 <td>Sum</td>
7342 <td>$180</td>
7343 </tr>
7344 </tfoot>
7345 </table>
7346 !! wikitext
7347 {|
7348 |+Test
7349 !Month
7350 !Savings
7351 |-
7352 |January
7353 |$100
7354 |-
7355 |February
7356 |$80
7357 |-
7358 |Sum
7359 |$180
7360 |}
7361 !! html/php+tidy
7362 <table>
7363 <caption>Test</caption>
7364 <tr>
7365 <th>Month</th>
7366 <th>Savings</th>
7367 </tr>
7368 <tr>
7369 <td>January</td>
7370 <td>$100</td>
7371 </tr>
7372 <tr>
7373 <td>February</td>
7374 <td>$80</td>
7375 </tr>
7376 <tr>
7377 <td>Sum</td>
7378 <td>$180</td>
7379 </tr>
7380 </table>
7381 !! end
7382
7383 # T137406: No whitespace in the HTML
7384 !! test
7385 2. Generate correct wikitext for tables with thead/tbody/tfoot
7386 !! options
7387 parsoid=html2wt
7388 !! html/parsoid
7389 <table><thead><tr><th>heading</th></tr></thead><tbody><tr><td>foo</td></tr></tbody></table>
7390 !! wikitext
7391 {|
7392 !heading
7393 |-
7394 |foo
7395 |}
7396 !! end
7397
7398 !! test
7399 Testing serialization after deletion in references
7400 !! options
7401 parsoid={
7402 "modes": ["wt2wt"],
7403 "changes": [
7404 ["#x", "remove"]
7405 ]
7406 }
7407 !! wikitext
7408 hi <ref><div id="x">ho</div></ref>
7409
7410 <references />
7411 !! wikitext/edited
7412 hi <ref></ref>
7413
7414 <references />
7415 !! end
7416
7417 !!test
7418 Testing serialization after deletion of table cells
7419 !!options
7420 parsoid={
7421 "modes": ["wt2wt", "selser"],
7422 "changes": [
7423 ["#x", "remove"]
7424 ]
7425 }
7426 !!wikitext
7427 {|
7428 !h1 !!h2 !!h3
7429 | id="x" |c1 {{!}}{{!}}{{!}}c2 |||c3
7430 |}
7431 !! wikitext/edited
7432 {|
7433 !h1 !!h2 !!h3
7434 |c2 |||c3
7435 |}
7436 !!end
7437
7438 !! test
7439 Testing selser after addition of new row before first row (T125419)
7440 !! options
7441 parsoid={
7442 "modes": ["wt2wt", "selser"],
7443 "changes": [
7444 [ "tr", "before", "<tr><td>X</td></tr>" ]
7445 ]
7446 }
7447 !! wikitext
7448 {|
7449 |a
7450 |}
7451 !! wikitext/edited
7452 {|
7453 |X
7454 |-
7455 |a
7456 |}
7457 !! end
7458
7459 !! test
7460 Serialize new table rows in a HTML table using HTML tags
7461 !! options
7462 parsoid={
7463 "modes": ["wt2wt", "selser"],
7464 "changes": [
7465 [ "tr", "before", "<tr><td>X</td></tr>" ]
7466 ]
7467 }
7468 !! wikitext
7469 <table><tr><td>a</td></tr></table>
7470 !! wikitext/edited
7471 <table><tr><td>X</td></tr><tr><td>a</td></tr></table>
7472 !! end
7473
7474 !! test
7475 Serialize new table cells in a HTML row using HTML tags
7476 !! options
7477 parsoid={
7478 "modes": ["wt2wt", "selser"],
7479 "changes": [
7480 [ "td", "before", "<td>X</td>" ]
7481 ]
7482 }
7483 !! wikitext
7484 <table><tr><td>a</td></tr></table>
7485 !! wikitext/edited
7486 <table><tr><td>X</td><td>a</td></tr></table>
7487 !! end
7488
7489 !! test
7490 Wikitext tables can be nested inside HTML tables
7491 !! options
7492 parsoid=html2wt
7493 !! html
7494 <table data-parsoid='{"stx":"html"}'>
7495 <tr><td>
7496 <table>
7497 <tr><td>foo</td></tr>
7498 </table>
7499 </td></tr>
7500 </table>
7501 !! wikitext
7502 <table>
7503 <tr><td>
7504 {|
7505 |foo
7506 |}
7507 </td></tr>
7508 </table>
7509 !! end
7510
7511 !! test
7512 Serialize wikitext list items as HTML list items when embedded in a HTML list
7513 !! options
7514 parsoid=html2wt
7515 !! html
7516 <ul data-parsoid='{"stx": "html"}'>
7517 <li data-parsoid='{}'>a</li>
7518 <li>b</li>
7519 </ul>
7520 !! wikitext
7521 <ul>
7522 <li>a</li>
7523 <li>b</li>
7524 </ul>
7525 !! end
7526
7527 # SSS FIXME: Is this actually a good thing given the
7528 # odd nested list output that is generated by MW?
7529 # <ul><li>foo<ul>..</ul></li></ul> instead of
7530 # <ul><li>foo</li><ul>..</ul></ul>
7531 !! test
7532 Wikitext lists can be nested inside HTML lists
7533 !! options
7534 parsoid=html2wt
7535 !! html
7536 <ul data-parsoid='{"stx": "html"}'>
7537 <li data-parsoid='{"stx": "html"}'>a
7538 <ul><li>b</li></ul>
7539 </li>
7540 </ul>
7541
7542 <ul data-parsoid='{"stx": "html"}'>
7543 <li>x
7544 <ul><li>y</li></ul>
7545 </li>
7546 </ul>
7547 !! wikitext
7548 <ul>
7549 <li>a
7550 * b
7551 </li>
7552 </ul>
7553
7554 <ul>
7555 <li>x
7556 * y
7557 </li>
7558 </ul>
7559 !! end
7560
7561 ###
7562 ### Internal links
7563 ###
7564 !! test
7565 Plain link, capitalized
7566 !! wikitext
7567 [[Main Page]]
7568 !! html
7569 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
7570 </p>
7571 !! end
7572
7573 !! test
7574 Plain link, uncapitalized
7575 !! wikitext
7576 [[main Page]]
7577 !! html
7578 <p><a href="/wiki/Main_Page" title="Main Page">main Page</a>
7579 </p>
7580 !! end
7581
7582 !! test
7583 Piped link
7584 !! wikitext
7585 [[Main Page|The Main Page]]
7586 !! html
7587 <p><a href="/wiki/Main_Page" title="Main Page">The Main Page</a>
7588 </p>
7589 !! end
7590
7591 !! test
7592 Piped link with comment in link text
7593 !! wikitext
7594 [[Main Page|The Main<!--front--> Page]]
7595 !! html
7596 <p><a href="/wiki/Main_Page" title="Main Page">The Main Page</a>
7597 </p>
7598 !! end
7599
7600 !! test
7601 Piped link with multiple pipe characters in link text
7602 !! wikitext
7603 [[Main Page||The|Main|Page|]]
7604 !! html/php
7605 <p><a href="/wiki/Main_Page" title="Main Page">|The|Main|Page|</a>
7606 </p>
7607 !! html/parsoid
7608 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">|The|Main|Page|</a></p>
7609 !! end
7610
7611 !! test
7612 Piped link with no link text
7613 !! wikitext
7614 [[Thomas Bek (bishop of St David's)|]]
7615 !! html/php
7616 <p>[[Thomas Bek (bishop of St David's)|]]
7617 </p>
7618 !! html/parsoid
7619 <p>[[Thomas Bek (bishop of St David's)|]]</p>
7620 !! end
7621
7622 !! test
7623 Piped link with empty link text
7624 !! wikitext
7625 [[Main Page|<nowiki/>]] - empty nowiki
7626 [[Main Page| ]] - empty space
7627 [[Main Page|&nbsp;]] - empty non breaking space
7628 !! html/php
7629 <p><a href="/wiki/Main_Page" title="Main Page"></a> - empty nowiki
7630 <a href="/wiki/Main_Page" title="Main Page"> </a> - empty space
7631 <a href="/wiki/Main_Page" title="Main Page">&#160;</a> - empty non breaking space
7632 </p>
7633 !! html/parsoid
7634 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page"><span typeof="mw:Nowiki"></span></a> - empty nowiki
7635 <a rel="mw:WikiLink" href="./Main_Page" title="Main Page"> </a> - empty space
7636 <a rel="mw:WikiLink" href="./Main_Page" title="Main Page"><span typeof="mw:Entity" data-parsoid='{"src":"&amp;nbsp;","srcContent":" "}'> </span></a> - empty non breaking space</p>
7637 !! end
7638
7639 !! test
7640 Broken link
7641 !! wikitext
7642 [[Zigzagzogzagzig]]
7643 !! html
7644 <p><a href="/index.php?title=Zigzagzogzagzig&amp;action=edit&amp;redlink=1" class="new" title="Zigzagzogzagzig (page does not exist)">Zigzagzogzagzig</a>
7645 </p>
7646 !! end
7647
7648 !! test
7649 Broken link with fragment
7650 !! wikitext
7651 [[Zigzagzogzagzig#zug]]
7652 !! html
7653 <p><a href="/index.php?title=Zigzagzogzagzig&amp;action=edit&amp;redlink=1" class="new" title="Zigzagzogzagzig (page does not exist)">Zigzagzogzagzig#zug</a>
7654 </p>
7655 !! end
7656
7657 !! test
7658 Special page link with fragment
7659 !! wikitext
7660 [[Special:Version#anchor]]
7661 !! html
7662 <p><a href="/wiki/Special:Version#anchor" title="Special:Version">Special:Version#anchor</a>
7663 </p>
7664 !! end
7665
7666 !! test
7667 Nonexistent special page link with fragment
7668 !! wikitext
7669 [[Special:ThisNameWillHopefullyNeverBeUsed#anchor]]
7670 !! html
7671 <p><a href="/wiki/Special:ThisNameWillHopefullyNeverBeUsed" class="new" title="Special:ThisNameWillHopefullyNeverBeUsed (page does not exist)">Special:ThisNameWillHopefullyNeverBeUsed#anchor</a>
7672 </p>
7673 !! end
7674
7675 !! test
7676 Link with prefix
7677 !! wikitext
7678 xxx[[main Page]], xxx[[Main Page]], Xxx[[main Page]] XXX[[main Page]], XXX[[Main Page]]
7679 !! html
7680 <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>
7681 </p>
7682 !! end
7683
7684 !! test
7685 Link with suffix
7686 !! wikitext
7687 [[Main Page]]xxx, [[Main Page]]XXX, [[Main Page]]!!!
7688 !! html
7689 <p><a href="/wiki/Main_Page" title="Main Page">Main Pagexxx</a>, <a href="/wiki/Main_Page" title="Main Page">Main Page</a>XXX, <a href="/wiki/Main_Page" title="Main Page">Main Page</a>!!!
7690 </p>
7691 !! end
7692
7693 !! article
7694 prefixed article
7695 !! text
7696 Some text
7697 !! endarticle
7698
7699 !! test
7700 T45661: Piped links with identical prefixes
7701 !! wikitext
7702 [[prefixed article|prefixed articles with spaces]]
7703
7704 [[prefixed article|prefixed articlesaoeu]]
7705
7706 [[Main Page|Main Page test]]
7707 !! html
7708 <p><a href="/wiki/Prefixed_article" title="Prefixed article">prefixed articles with spaces</a>
7709 </p><p><a href="/wiki/Prefixed_article" title="Prefixed article">prefixed articlesaoeu</a>
7710 </p><p><a href="/wiki/Main_Page" title="Main Page">Main Page test</a>
7711 </p>
7712 !! end
7713
7714
7715 !! test
7716 Link with HTML entity in suffix / tail
7717 !! wikitext
7718 [[Main Page]]&quot;, [[Main Page]]&#97;
7719 !! html/php
7720 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>&quot;, <a href="/wiki/Main_Page" title="Main Page">Main Page</a>&#97;
7721 </p>
7722 !! html/parsoid
7723 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a><span typeof="mw:Entity" data-parsoid='{"src":"&amp;quot;","srcContent":"\""}'>"</span>, <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#97;","srcContent":"a"}'>a</span></p>
7724 !! end
7725
7726 !! test
7727 Link with 3 brackets
7728 !! wikitext
7729 [[[Main Page]]]
7730 Foo [[[Main Page]]]
7731 !! html
7732 <p>[[[Main Page]]]
7733 Foo [[[Main Page]]]
7734 </p>
7735 !! end
7736
7737 !! test
7738 Link with 4 brackets
7739 !! wikitext
7740 [[[[Main Page]]]]
7741 !! html
7742 <p>[[<a href="/wiki/Main_Page" title="Main Page">Main Page</a>]]
7743 </p>
7744 !! end
7745
7746 !! test
7747 Piped link with 3 brackets
7748 !! wikitext
7749 [[[main page|the main page]]]
7750 !! html
7751 <p>[[[main page|the main page]]]
7752 </p>
7753 !! end
7754
7755 !! test
7756 Piped link with extlink-like text
7757 !! wikitext
7758 [[Main Page|[bar]]]
7759 [[Main Page|This is a [bar]]]
7760 [[Main Page|[bar]]
7761 !! html/php
7762 <p><a href="/wiki/Main_Page" title="Main Page">[bar]</a>
7763 <a href="/wiki/Main_Page" title="Main Page">This is a [bar]</a>
7764 <a href="/wiki/Main_Page" title="Main Page">[bar</a>
7765 </p>
7766 !! html/parsoid
7767 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"piped"}'>[bar]</a>
7768 <a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"piped"}'>This is a [bar]</a>
7769 <a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"piped"}'>[bar</a></p>
7770 !! end
7771
7772 !! test
7773 Link with multiple pipes
7774 !! wikitext
7775 [[Main Page|The|Main|Page]]
7776 !! html
7777 <p><a href="/wiki/Main_Page" title="Main Page">The|Main|Page</a>
7778 </p>
7779 !! end
7780
7781 !! test
7782 Anchor containing a #. (T65430)
7783 !! wikitext
7784 [[Main Page#And#Link]]
7785 !! html/php
7786 <p><a href="/wiki/Main_Page#And.23Link" title="Main Page">Main Page#And#Link</a>
7787 </p>
7788 !! html/parsoid
7789 <p><a rel="mw:WikiLink" href="./Main_Page#And.23Link" title="Main Page" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#And.23Link"},"sa":{"href":"Main Page#And#Link"}}'>Main Page#And#Link</a></p>
7790 !! end
7791
7792 !! test
7793 Link to namespaces
7794 !! wikitext
7795 [[Talk:Parser testing]], [[Meta:Disclaimers]]
7796 !! html
7797 <p><a href="/index.php?title=Talk:Parser_testing&amp;action=edit&amp;redlink=1" class="new" title="Talk:Parser testing (page does not exist)">Talk:Parser testing</a>, <a href="/index.php?title=Meta:Disclaimers&amp;action=edit&amp;redlink=1" class="new" title="Meta:Disclaimers (page does not exist)">Meta:Disclaimers</a>
7798 </p>
7799 !! end
7800
7801 !! test
7802 Link with space in namespace
7803 !! wikitext
7804 [[User talk:Foo bar]]
7805 !! html
7806 <p><a href="/index.php?title=User_talk:Foo_bar&amp;action=edit&amp;redlink=1" class="new" title="User talk:Foo bar (page does not exist)">User talk:Foo bar</a>
7807 </p>
7808 !! end
7809
7810 !! article
7811 MemoryAlpha:AlphaTest
7812 !! text
7813 This is an article in the MemoryAlpha namespace
7814 (which shadows the memoryalpha interwiki link).
7815 !! endarticle
7816
7817 !! test
7818 Namespace takes precedence over interwiki link (T53680)
7819 !! wikitext
7820 [[MemoryAlpha:AlphaTest]]
7821 !! html
7822 <p><a href="/wiki/MemoryAlpha:AlphaTest" title="MemoryAlpha:AlphaTest">MemoryAlpha:AlphaTest</a>
7823 </p>
7824 !! end
7825
7826 # The previous test doesn't work correctly in html2*, due to not recognizing the
7827 # link as an internal one. This one checks for the correct behavior.
7828 !! test
7829 Link to namespace preferred over interwiki with correct rel attribute
7830 !! options
7831 parsoid=html2wt,html2html
7832 !! html/parsoid
7833 <p><a rel="mw:WikiLink" href="./MemoryAlpha:AlphaTest" title="MemoryAlpha:AlphaTest">MemoryAlpha:AlphaTest</a></p>
7834 !! wikitext
7835 [[MemoryAlpha:AlphaTest]]
7836 !! end
7837
7838 !! test
7839 Piped link to namespace
7840 !! wikitext
7841 [[Meta:Disclaimers|The disclaimers]]
7842 !! html
7843 <p><a href="/index.php?title=Meta:Disclaimers&amp;action=edit&amp;redlink=1" class="new" title="Meta:Disclaimers (page does not exist)">The disclaimers</a>
7844 </p>
7845 !! end
7846
7847 !! test
7848 Link containing }
7849 !! wikitext
7850 [[Usually caused by a typo (oops}]]
7851 !! html
7852 <p>[[Usually caused by a typo (oops}]]
7853 </p>
7854 !! end
7855
7856 !! article
7857 7% Solution
7858 !! text
7859 Just a test of an article title containing a percent.
7860 !! endarticle
7861
7862 !! test
7863 Link containing % (not as a hex sequence)
7864 !! wikitext
7865 [[7% Solution]]
7866 [[7% Solution|7%25 Solution]]
7867 !! html/php
7868 <p><a href="/wiki/7%25_Solution" title="7% Solution">7% Solution</a>
7869 <a href="/wiki/7%25_Solution" title="7% Solution">7%25 Solution</a>
7870 </p>
7871 !! html/parsoid
7872 <p><a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7% Solution</a>
7873 <a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7%25 Solution</a></p>
7874 !! end
7875
7876 # note that the parsoid HTML is identical to the previous test output,
7877 # so the previous test ensures that the html2wt mode will generate the
7878 # "not as a hex sequence" wikitext.
7879 !! test
7880 Link containing % as a single hex sequence interpreted to char
7881 !! options
7882 parsoid=wt2wt,wt2html,html2html
7883 !! wikitext
7884 [[7%25 Solution]]
7885 [[7%25 Solution|7%25 Solution]]
7886 !! html/php
7887 <p><a href="/wiki/7%25_Solution" title="7% Solution">7% Solution</a>
7888 <a href="/wiki/7%25_Solution" title="7% Solution">7%25 Solution</a>
7889 </p>
7890 !! html/parsoid
7891 <p><a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7% Solution</a>
7892 <a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7%25 Solution</a></p>
7893 !!end
7894
7895 !! test
7896 Link containing % as a double hex sequence interpreted to hex sequence
7897 !! wikitext
7898 [[7%2525 Solution]]
7899 !! html
7900 <p>[[7%2525 Solution]]
7901 </p>
7902 !!end
7903
7904 ## Example for such a section: == < ==
7905 !! test
7906 Link containing "#<" and "#>" % as a hex sequences- these are valid section anchors
7907 !! wikitext
7908 [[%23%3c]][[%23%3e]]
7909 !! html/php
7910 <p><a href="#.3C">#&lt;</a><a href="#.3E">#&gt;</a>
7911 </p>
7912 !! html/parsoid
7913 <p><a rel="mw:WikiLink" href="./Main_Page#.3C" title="Main Page" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#.3C"},"sa":{"href":"%23%3c"}}'>#&lt;</a><a rel="mw:WikiLink" href="./Main_Page#.3E" title="Main Page" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#.3E"},"sa":{"href":"%23%3e"}}'>#></a></p>
7914 !! end
7915
7916 !! test
7917 Link containing "<#" and ">#" as a hex sequences
7918 !! wikitext
7919 [[%3c%23]][[%3e%23]]
7920 !! html
7921 <p>[[%3c%23]][[%3e%23]]
7922 </p>
7923 !! end
7924
7925 !! test
7926 Link containing an equals sign
7927 !! wikitext
7928 [[Special:BookSources/isbn=4-00-026157-6]]
7929 !! html/php
7930 <p><a href="/wiki/Special:BookSources/isbn%3D4-00-026157-6" title="Special:BookSources/isbn=4-00-026157-6">Special:BookSources/isbn=4-00-026157-6</a>
7931 </p>
7932 !! html/parsoid
7933 <p><a rel="mw:WikiLink" href="./Special:BookSources/isbn=4-00-026157-6" title="Special:BookSources/isbn=4-00-026157-6">Special:BookSources/isbn=4-00-026157-6</a></p>
7934 !! end
7935
7936 !! article
7937 Foo~bar
7938 !! text
7939 Just a test of an article title containing a tilde.
7940 !! endarticle
7941
7942 # note that links containing signatures, like [[Foo~~~~]], are
7943 # massaged by the pre-save transform (PST) and so the tildes are never
7944 # seen by the parser.
7945 !! test
7946 Link containing a tilde
7947 !! wikitext
7948 [[Foo~bar]]
7949 !! html/php
7950 <p><a href="/wiki/Foo~bar" title="Foo~bar">Foo~bar</a>
7951 </p>
7952 !! html/parsoid
7953 <p><a rel="mw:WikiLink" href="./Foo~bar" title="Foo~bar">Foo~bar</a></p>
7954 !! end
7955
7956 !! test
7957 Link containing double-single-quotes '' (T6598)
7958 !! wikitext
7959 [[Lista d''e paise d''o munno]]
7960 !! html/php
7961 <p><a href="/index.php?title=Lista_d%27%27e_paise_d%27%27o_munno&amp;action=edit&amp;redlink=1" class="new" title="Lista d''e paise d''o munno (page does not exist)">Lista d''e paise d''o munno</a>
7962 </p>
7963 !! html/parsoid
7964 <p><a rel="mw:WikiLink" href="./Lista_d''e_paise_d''o_munno" title="Lista d''e paise d''o munno">Lista d''e paise d''o munno</a></p>
7965 !! end
7966
7967 !! test
7968 Link containing double quotes and spaces
7969 !! wikitext
7970 [[Cool "Gator"]]
7971 !! html/php
7972 <p><a href="/index.php?title=Cool_%22Gator%22&amp;action=edit&amp;redlink=1" class="new" title="Cool &quot;Gator&quot; (page does not exist)">Cool "Gator"</a>
7973 </p>
7974 !! html/parsoid
7975 <p><a rel="mw:WikiLink" href="./Cool_%22Gator%22" title='Cool "Gator"'>Cool "Gator"</a></p>
7976 !! end
7977
7978 !! test
7979 File containing double quotes and spaces
7980 !! wikitext
7981 [[File:Cool "Gator".png]]
7982 !! html/parsoid
7983 <p><span class="mw-default-size" typeof="mw:Error mw:Image" data-parsoid='{"optList":[]}' data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}]}'><a href="./File:Cool_%22Gator%22.png" data-parsoid='{"a":{"href":"./File:Cool_%22Gator%22.png"},"sa":{"href":"File:Cool \"Gator\".png"}}'><img resource='./File:Cool_"Gator".png' src="./Special:FilePath/Cool_%22Gator%22.png" height="220" width="220" data-parsoid='{"a":{"resource":"./File:Cool_\"Gator\".png","height":"220","width":"220","src":"./Special:FilePath/Cool_%22Gator%22.png"},"sa":{"resource":"File:Cool \"Gator\".png","src":"./Special:FilePath/Cool_\"Gator\".png"}}'/></a></span></p>
7984 !! end
7985
7986 !! test
7987 Redirect containing double quotes and spaces
7988 !! wikitext
7989 #REDIRECT [[Cool "Gator"]]
7990 !! html/parsoid
7991 <link rel="mw:PageProp/redirect" href="./Cool_%22Gator%22" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./Cool_%22Gator%22"},"sa":{"href":"Cool \"Gator\""}}'/>
7992 !! end
7993
7994 !! test
7995 Link containing double-single-quotes '' in text (T6598 sanity check)
7996 !! wikitext
7997 Some [[Link|pretty ''italics'' and stuff]]!
7998 !! html/php
7999 <p>Some <a href="/index.php?title=Link&amp;action=edit&amp;redlink=1" class="new" title="Link (page does not exist)">pretty <i>italics</i> and stuff</a>!
8000 </p>
8001 !! html/parsoid
8002 <p>Some <a rel="mw:WikiLink" href="./Link" title="Link">pretty <i>italics</i> and stuff</a>!</p>
8003 !! end
8004
8005 !! test
8006 Link containing double-single-quotes '' in text embedded in italics (T6598 sanity check)
8007 !! wikitext
8008 ''Some [[Link|pretty ''italics'' and stuff]]!''
8009 !! html
8010 <p><i>Some <a href="/index.php?title=Link&amp;action=edit&amp;redlink=1" class="new" title="Link (page does not exist)">pretty <i>italics</i> and stuff</a>!</i>
8011 </p>
8012 !! end
8013
8014 !! test
8015 Link with double quotes in title part (literal) and alternate part (interpreted)
8016 !! wikitext
8017 [[File:Denys_Savchenko_''Pentecoste''.jpg]]
8018
8019 [[''Pentecoste'']]
8020
8021 [[''Pentecoste''|Pentecoste]]
8022
8023 [[''Pentecoste''|''Pentecoste'']]
8024 !! html/php
8025 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=Denys_Savchenko_%27%27Pentecoste%27%27.jpg" class="new" title="File:Denys Savchenko &#39;&#39;Pentecoste&#39;&#39;.jpg">File:Denys Savchenko <i>Pentecoste</i>.jpg</a>
8026 </p><p><a href="/index.php?title=%27%27Pentecoste%27%27&amp;action=edit&amp;redlink=1" class="new" title="''Pentecoste'' (page does not exist)">''Pentecoste''</a>
8027 </p><p><a href="/index.php?title=%27%27Pentecoste%27%27&amp;action=edit&amp;redlink=1" class="new" title="''Pentecoste'' (page does not exist)">Pentecoste</a>
8028 </p><p><a href="/index.php?title=%27%27Pentecoste%27%27&amp;action=edit&amp;redlink=1" class="new" title="''Pentecoste'' (page does not exist)"><i>Pentecoste</i></a>
8029 </p>
8030 !! html/parsoid
8031 <p><span class="mw-default-size" typeof="mw:Error mw:Image" data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}]}'><a href="./File:Denys_Savchenko_''Pentecoste''.jpg"><img resource="./File:Denys_Savchenko_''Pentecoste''.jpg" src="./Special:FilePath/Denys_Savchenko_''Pentecoste''.jpg" height="220" width="220"/></a></span></p>
8032 <p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''">''Pentecoste''</a></p>
8033 <p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''">Pentecoste</a></p>
8034 <p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''"><i>Pentecoste</i></a></p>
8035 !! end
8036
8037 !! test
8038 Broken image links with HTML captions (T41700)
8039 !! wikitext
8040 [[File:Nonexistent|<script></script>]]
8041 [[File:Nonexistent|100x100px|<script></script>]]
8042 [[File:Nonexistent|&lt;]]
8043 [[File:Nonexistent|a<i>b</i>c]]
8044 !! html/php
8045 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">&lt;script&gt;&lt;/script&gt;</a>
8046 <a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">&lt;script&gt;&lt;/script&gt;</a>
8047 <a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">&lt;</a>
8048 <a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">abc</a>
8049 </p>
8050 !! html/parsoid
8051 <p><span class="mw-default-size" typeof="mw:Error mw:Image" data-parsoid='{"optList":[{"ck":"caption","ak":"&lt;script>&lt;/script>"}]}' data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}],"caption":"&amp;lt;script>&amp;lt;/script>"}'><a href="./File:Nonexistent" data-parsoid='{"a":{"href":"./File:Nonexistent"},"sa":{}}'><img resource="./File:Nonexistent" src="./Special:FilePath/Nonexistent" height="220" width="220" data-parsoid='{"a":{"resource":"./File:Nonexistent","height":"220","width":"220"},"sa":{"resource":"File:Nonexistent"}}'/></a></span>
8052 <span typeof="mw:Error mw:Image" data-parsoid='{"optList":[{"ck":"width","ak":"100x100px"},{"ck":"caption","ak":"&lt;script>&lt;/script>"}]}' data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}],"caption":"&amp;lt;script>&amp;lt;/script>"}'><a href="./File:Nonexistent" data-parsoid='{"a":{"href":"./File:Nonexistent"},"sa":{}}'><img resource="./File:Nonexistent" src="./Special:FilePath/Nonexistent" height="100" width="100" data-parsoid='{"a":{"resource":"./File:Nonexistent","height":"100","width":"100"},"sa":{"resource":"File:Nonexistent"}}'/></a></span>
8053 <span class="mw-default-size" typeof="mw:Error mw:Image" data-parsoid='{"optList":[{"ck":"caption","ak":"&amp;lt;"}]}' data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}],"caption":"&lt;span typeof=\"mw:Entity\" data-parsoid=&#39;{\"src\":\"&amp;amp;lt;\",\"srcContent\":\"&amp;lt;\",\"dsr\":[107,111,null,null]}&#39;>&amp;lt;&lt;/span>"}'><a href="./File:Nonexistent" data-parsoid='{"a":{"href":"./File:Nonexistent"},"sa":{}}'><img resource="./File:Nonexistent" src="./Special:FilePath/Nonexistent" height="220" width="220" data-parsoid='{"a":{"resource":"./File:Nonexistent","height":"220","width":"220"},"sa":{"resource":"File:Nonexistent"}}'/></a></span>
8054 <span class="mw-default-size" typeof="mw:Error mw:Image" data-parsoid='{"optList":[{"ck":"caption","ak":"a&lt;i>b&lt;/i>c"}]}' data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}],"caption":"a&lt;i data-parsoid=&#39;{\"stx\":\"html\",\"dsr\":[134,142,3,4]}&#39;>b&lt;/i>c"}'><a href="./File:Nonexistent" data-parsoid='{"a":{"href":"./File:Nonexistent"},"sa":{}}'><img resource="./File:Nonexistent" src="./Special:FilePath/Nonexistent" height="220" width="220" data-parsoid='{"a":{"resource":"./File:Nonexistent","height":"220","width":"220"},"sa":{"resource":"File:Nonexistent"}}'/></a></span></p>
8055 !! end
8056
8057 !! test
8058 Plain link to URL
8059 !! wikitext
8060 [[http://www.example.com]]
8061 !! html/php
8062 <p>[<a rel="nofollow" class="external autonumber" href="http://www.example.com">[1]</a>]
8063 </p>
8064 !! html/parsoid
8065 <p>[<a rel="mw:ExtLink" href="http://www.example.com"></a>]</p>
8066 !! end
8067
8068 !! test
8069 Plain link to URL with link text
8070 !! wikitext
8071 [[http://www.example.com Link text]]
8072 !! html
8073 <p>[<a rel="nofollow" class="external text" href="http://www.example.com">Link text</a>]
8074 </p>
8075 !! end
8076
8077 !! test
8078 Plain link to protocol-relative URL
8079 !! wikitext
8080 [[//www.example.com]]
8081 !! html/php
8082 <p>[<a rel="nofollow" class="external autonumber" href="//www.example.com">[1]</a>]
8083 </p>
8084 !! html/parsoid
8085 <p>[<a rel="mw:ExtLink" href="//www.example.com"></a>]</p>
8086 !! end
8087
8088 !! test
8089 Plain link to protocol-relative URL with link text
8090 !! wikitext
8091 [[//www.example.com Link text]]
8092 !! html
8093 <p>[<a rel="nofollow" class="external text" href="//www.example.com">Link text</a>]
8094 </p>
8095 !! end
8096
8097 !! test
8098 Plain link to page with question mark in title
8099 !! wikitext
8100 [[A?b]]
8101
8102 [[A?b|Baz]]
8103 !! html
8104 <p><a href="/wiki/A%3Fb" title="A?b">A?b</a>
8105 </p><p><a href="/wiki/A%3Fb" title="A?b">Baz</a>
8106 </p>
8107 !! end
8108
8109 # I'm fairly sure the expected result here is wrong.
8110 # We want these to be URL links, not pseudo-pages with URLs for titles....
8111 # However the current output is also pretty screwy.
8112 #
8113 # ----
8114 # I'm changing it to match the current output--it arguably makes more
8115 # sense in the light of the test above. Old expected result was:
8116 #<p>Piped link to URL: <a href="/index.php?title=Http://www.example.com&amp;action=edit" class="new">an example URL</a>
8117 #</p>
8118 # But I think this test is bordering on "garbage in, garbage out" anyway.
8119 # -- wtm
8120 !! test
8121 Piped link to URL
8122 !! wikitext
8123 Piped link to URL: [[http://www.example.com|an example URL]]
8124 !! html/php
8125 <p>Piped link to URL: [<a rel="nofollow" class="external text" href="http://www.example.com%7Can">example URL</a>]
8126 </p>
8127 !! html/parsoid
8128 <p>Piped link to URL: [<a rel="mw:ExtLink" href="http://www.example.com%7Can" data-parsoid='{"a":{"href":"http://www.example.com%7Can"},"sa":{"href":"http://www.example.com|an"}}'>example URL</a>]</p>
8129 !! end
8130
8131 !! test
8132 Plain link in template argument
8133 !! options
8134 parsoid=wt2html
8135 !! wikitext
8136 {{echo|[http://www.example.com |123]}}
8137
8138 {{echo|[[http://www.example.com |123]]}}
8139
8140 {{echo|[[http://www.example.com |123]}}
8141
8142 {{echo|[http://www.example.com |123]]}}
8143 !! html/php
8144 <p>[<a rel="nofollow" class="external free" href="http://www.example.com">http://www.example.com</a>
8145 </p><p>[<a rel="nofollow" class="external text" href="http://www.example.com">|123</a>]
8146 </p><p>{{echo|[<a rel="nofollow" class="external text" href="http://www.example.com">|123</a>}}
8147 </p><p>[<a rel="nofollow" class="external free" href="http://www.example.com">http://www.example.com</a>
8148 </p>
8149 !! html/parsoid
8150 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[http://www.example.com "},"2":{"wt":"123]"}},"i":0}}]}'>[<a rel="mw:ExtLink" href="http://www.example.com">http://www.example.com</a> </p>
8151
8152 <p about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[http://www.example.com |123]]"}},"i":0}}]}'>[<a rel="mw:ExtLink" href="http://www.example.com">|123</a>]</p>
8153
8154 <p>{{echo|[<a rel="mw:ExtLink" href="http://www.example.com" data-parsoid='{"targetOff":114,"contentOffsets":[114,118],"dsr":[90,119,24,1]}'>|123</a>}}</p>
8155
8156 <p about="#mwt3" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[http://www.example.com "},"2":{"wt":"123]]"}},"i":0}}]}'>[<a rel="mw:ExtLink" href="http://www.example.com">http://www.example.com</a> </p>
8157 !! end
8158
8159 !! test
8160 T2002: [[page|http://url/]] should link to page, not http://url/
8161 !! wikitext
8162 [[Main Page|http://url/]]
8163 !! html/php
8164 <p><a href="/wiki/Main_Page" title="Main Page">http://url/</a>
8165 </p>
8166 !! html/parsoid
8167 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">http://url/</a></p>
8168 !! end
8169
8170 # Parsoid does not mark self-links, by design.
8171 !! test
8172 T2337: Escaped self-links should be bold
8173 !! options
8174 title=[[Bug462]]
8175 !! wikitext
8176 [[Bu&#103;462]] [[Bug462]]
8177 !! html/php
8178 <p><a class="mw-selflink selflink">Bu&#103;462</a> <a class="mw-selflink selflink">Bug462</a>
8179 </p>
8180 !! html/php+tidy
8181 <p><a class="mw-selflink selflink">Bug462</a> <a class="mw-selflink selflink">Bug462</a></p>
8182 !! html/parsoid
8183 <p><a rel="mw:WikiLink" href="./Bug462" title="Bug462">Bug462</a> <a rel="mw:WikiLink" href="./Bug462" title="Bug462">Bug462</a></p>
8184 !! end
8185
8186 !! test
8187 Self-link to section should not be bold
8188 !! options
8189 title=[[Main Page]]
8190 !! wikitext
8191 [[Main Page#section]]
8192 !! html
8193 <p><a href="/wiki/Main_Page#section" title="Main Page">Main Page#section</a>
8194 </p>
8195 !! end
8196
8197 !! article
8198 00
8199 !! text
8200 This is 00.
8201 !! endarticle
8202
8203 !!test
8204 Self-link to numeric title
8205 !!options
8206 title=[[0]]
8207 !! wikitext
8208 [[0]]
8209 !! html
8210 <p><a class="mw-selflink selflink">0</a>
8211 </p>
8212 !!end
8213
8214 !!test
8215 Link to numeric-equivalent title
8216 !!options
8217 title=[[0]]
8218 !! wikitext
8219 [[00]]
8220 !! html
8221 <p><a href="/wiki/00" title="00">00</a>
8222 </p>
8223 !!end
8224
8225 !! test
8226 <nowiki> inside a link
8227 !! wikitext
8228 [[Main<nowiki> Page</nowiki>]] [[Main Page|the main page <nowiki>[it's not very good]</nowiki>]]
8229 !! html
8230 <p>[[Main Page]] <a href="/wiki/Main_Page" title="Main Page">the main page [it's not very good]</a>
8231 </p>
8232 !! end
8233
8234 !! test
8235 Non-breaking spaces in title
8236 !! wikitext
8237 [[&nbsp; Main &nbsp; Page &nbsp;]]
8238 !! html
8239 <p><a href="/wiki/Main_Page" title="Main Page">&#160; Main &#160; Page &#160;</a>
8240 </p>
8241 !!end
8242
8243 # Add new article for the test below so that it doesn't red-link
8244 !! article
8245 Foo bar baz
8246 !! text
8247 boo
8248 !! endarticle
8249
8250 !! test
8251 Multiple spaces in titles should normalize to a single underscore
8252 !! options
8253 parsoid=wt2html,wt2wt
8254 !! wikitext
8255 [[Foo bar baz|x]]
8256 [[Foo bar baz|x]]
8257 [[Foo bar baz|x]]
8258 !! html/php
8259 <p><a href="/wiki/Foo_bar_baz" title="Foo bar baz">x</a>
8260 <a href="/wiki/Foo_bar_baz" title="Foo bar baz">x</a>
8261 <a href="/wiki/Foo_bar_baz" title="Foo bar baz">x</a>
8262 </p>
8263 !! html/parsoid
8264 <p><a rel="mw:WikiLink" href="./Foo_bar_baz" title="Foo bar baz">x</a>
8265 <a rel="mw:WikiLink" href="./Foo_bar_baz" title="Foo bar baz">x</a>
8266 <a rel="mw:WikiLink" href="./Foo_bar_baz" title="Foo bar baz">x</a>
8267 </p>
8268 !! end
8269
8270 !! test
8271 Internal link with ca linktrail, surrounded by bold apostrophes (T29473 primary issue)
8272 !! options
8273 language=ca
8274 !! wikitext
8275 '''[[Main Page]]'''
8276 !! html
8277 <p><b><a href="/wiki/Main_Page" title="Main Page">Main Page</a></b>
8278 </p>
8279 !! end
8280
8281 !! test
8282 Internal link with ca linktrail, surrounded by italic apostrophes (T29473 primary issue)
8283 !! options
8284 language=ca
8285 !! wikitext
8286 ''[[Main Page]]''
8287 !! html
8288 <p><i><a href="/wiki/Main_Page" title="Main Page">Main Page</a></i>
8289 </p>
8290 !! end
8291
8292 !! test
8293 Internal link with en linktrail: no apostrophes (T29473)
8294 !! options
8295 language=en
8296 !! wikitext
8297 [[Something]]'nice
8298 !! html
8299 <p><a href="/index.php?title=Something&amp;action=edit&amp;redlink=1" class="new" title="Something (page does not exist)">Something</a>'nice
8300 </p>
8301 !! end
8302
8303 !! test
8304 Internal link with ca linktrail with apostrophes (T29473)
8305 !! options
8306 language=ca
8307 !! wikitext
8308 [[Something]]'nice
8309 !! html
8310 <p><a href="/index.php?title=Something&amp;action=edit&amp;redlink=1" class="new" title="Something (encara no existeix)">Something'nice</a>
8311 </p>
8312 !! end
8313
8314 !! test
8315 Internal link with kaa linktrail with apostrophes (T29473)
8316 !! options
8317 language=kaa
8318 !! wikitext
8319 [[Something]]'nice
8320 !! html
8321 <p><a href="/index.php?title=Something&amp;action=edit&amp;redlink=1" class="new" title="Something (bet ele jaratılmag'an)">Something'nice</a>
8322 </p>
8323 !! end
8324
8325 !! test
8326 Link with multiple ":" in a subpage-supporting namespace (T65636)
8327 !! wikitext
8328 [[User:Foo/Test/63636:Bar|Test]]
8329 !! html/php
8330 <p><a href="/index.php?title=User:Foo/Test/63636:Bar&amp;action=edit&amp;redlink=1" class="new" title="User:Foo/Test/63636:Bar (page does not exist)">Test</a>
8331 </p>
8332 !! html/parsoid
8333 <p><a rel="mw:WikiLink" href="./User:Foo/Test/63636:Bar" title="User:Foo/Test/63636:Bar">Test</a></p>
8334 !! end
8335
8336 ## Mainly a sanity check for Parsoid
8337 !! test
8338 Handle title parsing for subpages
8339 !! options
8340 title=[[/123123]]
8341 subpage
8342 !! wikitext
8343 123
8344 !! html/php
8345 <p>123
8346 </p>
8347 !! html/parsoid
8348 <p>123</p>
8349 !! end
8350
8351 !! article
8352 User:Test/123
8353 !! text
8354 test 123
8355 !! endarticle
8356
8357 !! test
8358 Link to a subpage from a namespace other than main
8359 !! options
8360 title=[[User:Test]]
8361 subpage
8362 !! wikitext
8363 [[/123]]
8364 !! html/php
8365 <p><a href="/wiki/User:Test/123" title="User:Test/123">/123</a>
8366 </p>
8367 !! html/parsoid
8368 <p><a rel="mw:WikiLink" href="./User:Test/123" title="User:Test/123" data-parsoid='{"stx":"simple","a":{"href":"./User:Test/123"},"sa":{"href":"/123"}}'>/123</a></p>
8369 !! end
8370
8371 !! test
8372 Ensure that transclusion titles are not url-decoded
8373 !! options
8374 subpage title=[[Test]]
8375 parsoid=wt2html
8376 !! wikitext
8377 {{Bar%C3%A9}} {{/Bar%C3%A9}}
8378 !! html/php
8379 <p>{{Bar%C3%A9}} {{/Bar%C3%A9}}
8380 </p>
8381 !! html/parsoid
8382 <p>{{Bar%C3%A9}} {{/Bar%C3%A9}}</p>
8383 !! end
8384
8385 !! test
8386 Purely hash wikilink
8387 !! options
8388 title=[[User:Test/123]]
8389 subpage
8390 !! wikitext
8391 [[#a|b]]
8392 !! html/php
8393 <p><a href="#a">b</a>
8394 </p>
8395 !! html/parsoid
8396 <p><a rel="mw:WikiLink" href="./User:Test/123#a" data-parsoid='{"stx":"piped","a":{"href":"./User:Test/123#a"},"sa":{"href":"#a"}}'>b</a></p>
8397 !! end
8398
8399 !! test
8400 Serialization of purely hash wikilink
8401 !! options
8402 title=[[User:Test/123]]
8403 subpage
8404 parsoid=html2wt
8405 !! html/parsoid
8406 <p><a href="#a">[[</a></p>
8407 !! wikitext
8408 [[#a|<nowiki>[[</nowiki>]]
8409 !! html/php
8410 <p><a href="#a">[[</a>
8411 </p>
8412 !! end
8413
8414 !! test
8415 1. Interaction of linktrail and template encapsulation
8416 !! wikitext
8417 {{echo|[[Foo]]}}l
8418 !! html/parsoid
8419 <p><a rel="mw:WikiLink" href="./Foo" title="Foo" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[Foo]]"}},"i":0}},"l"]}'>Fool</a></p>
8420 !! end
8421
8422 !! test
8423 2. Interaction of linktrail and template encapsulation
8424 !! options
8425 parsoid
8426 !! wikitext
8427 {{echo|Some [[Fool]]}}s
8428 !! html
8429 <p><span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"Some [[Fool]]"}},"i":0}},"s"]}' data-parsoid='{"pi":[[{"k":"1"}]]}'>Some </span><a rel="mw:WikiLink" href="./Fool" title="Fool" about="#mwt1" data-parsoid='{"stx":"simple","a":{"href":"./Fool"},"sa":{"href":"Fool"},"tail":"s"}'>Fools</a></p>
8430 !! end
8431
8432 !! test
8433 3. Interaction of linktrail and template encapsulation
8434 !! options
8435 parsoid
8436 !! wikitext
8437 {{echo|Some [[Fool]]s are '''bold and foolish'''}}
8438 !! html
8439 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"Some [[Fool]]s are &#39;&#39;&#39;bold and foolish&#39;&#39;&#39;"}},"i":0}}]}' data-parsoid='{"pi":[[{"k":"1"}]]}'>Some <a rel="mw:WikiLink" href="./Fool" title="Fool" data-parsoid='{"stx":"simple","a":{"href":"./Fool"},"sa":{"href":"Fool"},"tail":"s"}'>Fools</a> are <b>bold and foolish</b></p>
8440 !! end
8441
8442 !! article
8443 Söfnuður
8444 !! text
8445 Test.
8446 !! endarticle
8447
8448 !! test
8449 Internal link with is link prefix
8450 !! options
8451 language=is
8452 !! wikitext
8453 Aðrir mótmælenda[[söfnuður|söfnuðir]] og
8454 !! html
8455 <p>Aðrir <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðir</a> og
8456 </p>
8457 !! end
8458
8459 !! article
8460 Mótmælendatrú
8461 !! text
8462 Test.
8463 !! endarticle
8464
8465 !! test
8466 Internal link with is link trail and link prefix
8467 !! options
8468 language=is
8469 !! wikitext
8470 [[mótmælendatrú|xxx]]ar
8471 [[mótmælendatrú]]ar
8472 mótmælenda[[söfnuður]]
8473 mótmælenda[[söfnuður|söfnuðir]]
8474 mótmælenda[[söfnuður|söfnuðir]]xxx
8475 !! html
8476 <p><a href="/wiki/M%C3%B3tm%C3%A6lendatr%C3%BA" title="Mótmælendatrú">xxxar</a>
8477 <a href="/wiki/M%C3%B3tm%C3%A6lendatr%C3%BA" title="Mótmælendatrú">mótmælendatrúar</a>
8478 <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuður</a>
8479 <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðir</a>
8480 <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðirxxx</a>
8481 </p>
8482 !! end
8483
8484 !! test
8485 Parsoid link trail escaping
8486 !! options
8487 parsoid=html2wt,html2html
8488 !! html/parsoid
8489 <p><a rel="mw:WikiLink" href="./Apple" title="Apple">apple</a>s</p>
8490 !! wikitext
8491 [[apple]]<nowiki/>s
8492 !! end
8493
8494 !! test
8495 Parsoid link prefix escaping
8496 !! options
8497 language=is
8498 parsoid=html2wt,html2html
8499 !! html/parsoid
8500 <p>Aðrir mótmælenda<a rel="mw:WikiLink" href="./Söfnuður" title="Söfnuður">söfnuður</a></p>
8501 !! wikitext
8502 Aðrir mótmælenda<nowiki/>[[söfnuður]]
8503 !! end
8504
8505 !! test
8506 Parsoid-centric test: Whitespace in ext- and wiki-links should be preserved
8507 !! wikitext
8508 [[Foo| bar]]
8509
8510 [[Foo| ''bar'']]
8511
8512 [http://wp.org foo]
8513
8514 [http://wp.org ''foo'']
8515 !! html
8516 <p><a href="/wiki/Foo" title="Foo"> bar</a>
8517 </p><p><a href="/wiki/Foo" title="Foo"> <i>bar</i></a>
8518 </p><p><a rel="nofollow" class="external text" href="http://wp.org">foo</a>
8519 </p><p><a rel="nofollow" class="external text" href="http://wp.org"><i>foo</i></a>
8520 </p>
8521 !! end
8522
8523 !! test
8524 Parsoid: Scoped parsing should handle mixed transclusions and plain text
8525 !! wikitext
8526 [[Foo|{{echo|a}} b {{echo|c}}]]
8527 !! html/parsoid
8528 <p><a rel="mw:WikiLink" href="./Foo" title="Foo"><span about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"a"}},"i":0}}]}'>a</span> b <span about="#mwt3" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"c"}},"i":0}}]}'>c</span></a></p>
8529 !! end
8530
8531 !! test
8532 Link with angle bracket after anchor
8533 !! wikitext
8534 [[Foo#<bar>]]
8535 !! html/php
8536 <p><a href="/wiki/Foo#.3Cbar.3E" title="Foo">Foo#&lt;bar&gt;</a>
8537 </p>
8538 !! html/parsoid
8539 <p><a rel="mw:WikiLink" href="./Foo#.3Cbar.3E" title="Foo" data-parsoid='{"stx":"simple","a":{"href":"./Foo#.3Cbar.3E"},"sa":{"href":"Foo#&lt;bar>"}}'>Foo#&lt;bar></a></p>
8540 !! end
8541
8542 ###
8543 ### Interwiki links (see maintenance/interwiki.sql)
8544 ###
8545
8546 !! test
8547 Inline interwiki link
8548 !! options
8549 parsoid=wt2html,wt2wt,html2html
8550 !! wikitext
8551 [[MeatBall:SoftSecurity]]
8552 !! html/php
8553 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity" class="extiw" title="meatball:SoftSecurity">MeatBall:SoftSecurity</a>
8554 </p>
8555 !! html/parsoid
8556 <p><a rel="mw:ExtLink" href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity" title="meatball:SoftSecurity">MeatBall:SoftSecurity</a></p>
8557 !! end
8558
8559 !! test
8560 Inline interwiki link with empty title (T4372)
8561 !! options
8562 parsoid=wt2html,wt2wt,html2html
8563 !! wikitext
8564 [[MeatBall:]]
8565 !! html/php
8566 <p><a href="http://www.usemod.com/cgi-bin/mb.pl" class="extiw" title="meatball:">MeatBall:</a>
8567 </p>
8568 !! html/parsoid
8569 <p><a rel="mw:ExtLink" href="http://www.usemod.com/cgi-bin/mb.pl?" title="meatball:">MeatBall:</a></p>
8570 !! end
8571
8572 !! test
8573 Interwiki link encoding conversion (T3636)
8574 !! wikitext
8575 *[[Wikipedia:ro:Olteni&#0355;a]]
8576 *[[Wikipedia:ro:Olteni&#355;a]]
8577 !! html
8578 <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></li>
8579 <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></li></ul>
8580
8581 !! html+tidy
8582 <ul>
8583 <li><a href="http://en.wikipedia.org/wiki/ro:Olteni%C5%A3a" class="extiw" title="wikipedia:ro:Olteniţa">Wikipedia:ro:Olteniţa</a></li>
8584 <li><a href="http://en.wikipedia.org/wiki/ro:Olteni%C5%A3a" class="extiw" title="wikipedia:ro:Olteniţa">Wikipedia:ro:Olteniţa</a></li>
8585 </ul>
8586 !! end
8587
8588 !! test
8589 Interwiki link with fragment (T4130)
8590 !! wikitext
8591 [[MeatBall:SoftSecurity#foo]]
8592 !! html
8593 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity#foo" class="extiw" title="meatball:SoftSecurity">MeatBall:SoftSecurity#foo</a>
8594 </p>
8595 !! end
8596
8597 !! test
8598 Link scenarios with escaped fragments
8599 !! wikitext
8600 [[#Is this great?]]
8601 [[Foo#Is this great?]]
8602 [[meatball:Foo#Is this great?]]
8603 !! html/php
8604 <p><a href="#Is_this_great.3F">#Is this great?</a>
8605 <a href="/wiki/Foo#Is_this_great.3F" title="Foo">Foo#Is this great?</a>
8606 <a href="http://www.usemod.com/cgi-bin/mb.pl?Foo#Is_this_great.3F" class="extiw" title="meatball:Foo">meatball:Foo#Is this great?</a>
8607 </p>
8608 !! html/parsoid
8609 <p><a rel="mw:WikiLink" href="./Main_Page#Is_this_great.3F" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#Is_this_great.3F"},"sa":{"href":"#Is this great?"}}'>#Is this great?</a>
8610 <a rel="mw:WikiLink" href="./Foo#Is_this_great.3F" title="Foo" data-parsoid='{"stx":"simple","a":{"href":"./Foo#Is_this_great.3F"},"sa":{"href":"Foo#Is this great?"}}'>Foo#Is this great?</a>
8611 <a rel="mw:ExtLink" href="http://www.usemod.com/cgi-bin/mb.pl?Foo#Is_this_great.3F" title="meatball:Foo" data-parsoid='{"stx":"simple","a":{"href":"http://www.usemod.com/cgi-bin/mb.pl?Foo#Is_this_great.3F"},"sa":{"href":"meatball:Foo#Is this great?"},"isIW":true}'>meatball:Foo#Is this great?</a></p>
8612 !! end
8613
8614 # Ideally the wikipedia: prefix here should be proto-relative too
8615 # [CSA]: this is kind of a bogus test, as the PHP parser test doesn't
8616 # define the 'en' prefix, and originally the test used 'wikipedia',
8617 # which isn't a localinterwiki prefix hence the links to the 'en:Foo'
8618 # article.
8619 !! test
8620 Different interwiki prefixes mapping to the same URL
8621 !! wikitext
8622 [[:en:Foo]]
8623
8624 [[:en:Foo|Foo]]
8625
8626 [[wikipedia:Foo]]
8627
8628 [[:wikipedia:Foo|Foo]]
8629
8630 [[wikipedia:en:Foo]]
8631
8632 [[:wikipedia:en:Foo]]
8633
8634 [[ wikiPEdia :Foo]]
8635 !! html/parsoid
8636 <p><a rel="mw:ExtLink" href="//en.wikipedia.org/wiki/Foo" data-parsoid='{"stx":"simple","a":{"href":"//en.wikipedia.org/wiki/Foo"},"sa":{"href":":en:Foo"},"isIW":true}' title="en:Foo">en:Foo</a></p>
8637
8638 <p><a rel="mw:ExtLink" href="//en.wikipedia.org/wiki/Foo" data-parsoid='{"stx":"piped","a":{"href":"//en.wikipedia.org/wiki/Foo"},"sa":{"href":":en:Foo"},"isIW":true}' title="en:Foo">Foo</a></p>
8639
8640 <p><a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/Foo" data-parsoid='{"stx":"simple","a":{"href":"http://en.wikipedia.org/wiki/Foo"},"sa":{"href":"wikipedia:Foo"},"isIW":true}' title="wikipedia:Foo">wikipedia:Foo</a></p>
8641
8642 <p><a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/Foo" data-parsoid='{"stx":"piped","a":{"href":"http://en.wikipedia.org/wiki/Foo"},"sa":{"href":":wikipedia:Foo"},"isIW":true}' title="wikipedia:Foo">Foo</a></p>
8643
8644 <p><a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/en:Foo" data-parsoid='{"stx":"simple","a":{"href":"http://en.wikipedia.org/wiki/en:Foo"},"sa":{"href":"wikipedia:en:Foo"},"isIW":true}' title="wikipedia:en:Foo">wikipedia:en:Foo</a></p>
8645
8646 <p><a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/en:Foo" data-parsoid='{"stx":"simple","a":{"href":"http://en.wikipedia.org/wiki/en:Foo"},"sa":{"href":":wikipedia:en:Foo"},"isIW":true}' title="wikipedia:en:Foo">wikipedia:en:Foo</a></p>
8647
8648 <p><a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/Foo" data-parsoid='{"stx":"simple","a":{"href":"http://en.wikipedia.org/wiki/Foo"},"sa":{"href":" wikiPEdia :Foo"},"isIW":true}' title="wikipedia:Foo"> wikiPEdia :Foo</a></p>
8649 !! end
8650
8651 !! test
8652 Interwiki links that cannot be represented in wiki syntax
8653 !! wikitext
8654 [[meatball:ok]]
8655 [[meatball:ok#foo|ok with fragment]]
8656 [[meatball:ok_as_well?|ok ending with ? mark]]
8657 [http://de.wikipedia.org/wiki/Foo?action=history has query]
8658 [http://de.wikipedia.org/wiki/#foo is just fragment]
8659
8660 !! html/php
8661 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?ok" class="extiw" title="meatball:ok">meatball:ok</a>
8662 <a href="http://www.usemod.com/cgi-bin/mb.pl?ok#foo" class="extiw" title="meatball:ok">ok with fragment</a>
8663 <a href="http://www.usemod.com/cgi-bin/mb.pl?ok_as_well%3F" class="extiw" title="meatball:ok as well?">ok ending with ? mark</a>
8664 <a rel="nofollow" class="external text" href="http://de.wikipedia.org/wiki/Foo?action=history">has query</a>
8665 <a rel="nofollow" class="external text" href="http://de.wikipedia.org/wiki/#foo">is just fragment</a>
8666 </p>
8667 !! html/parsoid
8668 <p><a rel="mw:ExtLink" href="http://www.usemod.com/cgi-bin/mb.pl?ok" title="meatball:ok">meatball:ok</a>
8669 <a rel="mw:ExtLink" href="http://www.usemod.com/cgi-bin/mb.pl?ok#foo" title="meatball:ok">ok with fragment</a>
8670 <a rel="mw:ExtLink" href="http://www.usemod.com/cgi-bin/mb.pl?ok_as_well?" title="meatball:ok as well?">ok ending with ? mark</a>
8671 <a rel="mw:ExtLink" href="http://de.wikipedia.org/wiki/Foo?action=history">has query</a>
8672 <a rel="mw:ExtLink" href="http://de.wikipedia.org/wiki/#foo">is just fragment</a></p>
8673 !! end
8674
8675 !! test
8676 Interwiki links: trail
8677 !! wikitext
8678 [[wikipedia:Foo|Ba]]r
8679 !! html/php
8680 <p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo">Bar</a>
8681 </p>
8682 !! html/parsoid
8683 <p><a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/Foo" data-parsoid='{"stx":"piped","a":{"href":"http://en.wikipedia.org/wiki/Foo"},"sa":{"href":"wikipedia:Foo"},"isIW":true,"tail":"r"}' title="wikipedia:Foo">Bar</a></p>
8684 !! end
8685
8686 !! test
8687 Local interwiki link
8688 !! options
8689 parsoid=wt2html,wt2wt,html2html
8690 !! wikitext
8691 [[local:Template:Foo]]
8692 !! html/php
8693 <p><a href="/wiki/Template:Foo" title="Template:Foo">local:Template:Foo</a>
8694 </p>
8695 !! html/parsoid
8696 <p><a rel="mw:WikiLink" href="./Template:Foo" title="Template:Foo">local:Template:Foo</a></p>
8697 !! end
8698
8699 # Parsoid does not mark self-links, by design.
8700 !! test
8701 Local interwiki link: self-link to current page
8702 !! options
8703 title=[[Main Page]]
8704 parsoid=wt2html,wt2wt,html2html
8705 !! wikitext
8706 [[local:Main Page]]
8707 !! html/php
8708 <p><a class="mw-selflink selflink">local:Main Page</a>
8709 </p>
8710 !! html/parsoid
8711 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">local:Main Page</a></p>
8712 !! end
8713
8714 !! test
8715 Local interwiki link: prefix only (T66167)
8716 !! options
8717 parsoid=wt2html,wt2wt,html2html
8718 !! wikitext
8719 [[local:]]
8720 !! html/php
8721 <p><a href="/wiki/Main_Page" title="Main Page">local:</a>
8722 </p>
8723 !! html/parsoid
8724 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">local:</a></p>
8725 !! end
8726
8727 !! test
8728 Local interwiki link: with additional interwiki prefix (T63357)
8729 !! options
8730 parsoid=wt2html,wt2wt,html2html
8731 !! wikitext
8732 [[local:meatball:Hello]]
8733 !! html/php
8734 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?Hello" class="extiw" title="meatball:Hello">local:meatball:Hello</a>
8735 </p>
8736 !! html/parsoid
8737 <p><a rel="mw:ExtLink" href="http://www.usemod.com/cgi-bin/mb.pl?Hello" title="meatball:Hello">local:meatball:Hello</a></p>
8738 !! end
8739
8740 !! test
8741 Multiple local interwiki link prefixes
8742 !! wikitext
8743 [[local:local:local:local:mi:local:Foo]]
8744 !! options
8745 parsoid=wt2html,wt2wt,html2html
8746 !! html/php
8747 <p><a href="/wiki/Foo" title="Foo">local:local:local:local:mi:local:Foo</a>
8748 </p>
8749 !! html/parsoid
8750 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">local:local:local:local:mi:local:Foo</a></p>
8751 !! end
8752
8753 ###
8754 ### Interlanguage links
8755 ### Language links (so that searching for '### language' matches..)
8756 ###
8757
8758 !! test
8759 Interlanguage link
8760 !! wikitext
8761 Blah blah blah
8762 [[zh:Chinese]]
8763 !! html/php
8764 <p>Blah blah blah
8765 </p>
8766 !! html/parsoid
8767 <p>Blah blah blah</p>
8768 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
8769 !! end
8770
8771 ## parsoid html2wt will lose the space variations
8772 !! test
8773 Interlanguage link with spacing
8774 !! options
8775 parsoid=wt2html,wt2wt,html2html
8776 !! wikitext
8777 Blah blah blah
8778 [[ zh : Chinese ]]
8779 !! html/php
8780 <p>Blah blah blah
8781 </p>
8782 !! html/parsoid
8783 <p>Blah blah blah</p>
8784 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
8785 !! end
8786
8787 !! test
8788 Double interlanguage link
8789 !! wikitext
8790 Blah blah blah
8791 [[es:Spanish]]
8792 [[zh:Chinese]]
8793 !! html/php
8794 <p>Blah blah blah
8795 </p>
8796 !! html/parsoid
8797 <p>Blah blah blah</p>
8798 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Spanish"/>
8799 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
8800 !! end
8801
8802 ## parsoid html2wt will lose the space variations
8803 !! test
8804 Interlanguage link variations
8805 !! options
8806 parsoid=wt2html,wt2wt,html2html
8807 !! wikitext
8808 Blah blah blah
8809 [[ es :Spanish]]
8810 [[ ZH :Chinese]]
8811 [[es:Foo_bar]]
8812 !! html/php
8813 <p>Blah blah blah
8814 </p>
8815 !! html/parsoid
8816 <p>Blah blah blah</p>
8817 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Spanish" />
8818 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese" />
8819 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo_bar" />
8820 !! end
8821
8822 !! test
8823 Escaping of interlanguage links (T129218, T156308)
8824 !! wikitext
8825 Blah blah blah
8826 [[:es:Spanish]]
8827 [[ : zh : Chinese ]]
8828 !! html/php
8829 <p>Blah blah blah
8830 <a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">es:Spanish</a>
8831 <a href="http://zh.wikipedia.org/wiki/Chinese" class="extiw" title="zh:Chinese"> zh : Chinese </a>
8832 </p>
8833 !! html/parsoid
8834 <p>Blah blah blah
8835 <a rel="mw:ExtLink" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">es:Spanish</a>
8836 <a rel="mw:ExtLink" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese"> zh : Chinese </a></p>
8837 !! end
8838
8839 !! test
8840 Multiple colons escaping interlanguage links
8841 !! options
8842 parsoid=wt2html
8843 !! wikitext
8844 [[:es:Spanish]]
8845 [[::es:Spanish]]
8846 [[:::es:Spanish]]
8847 !! html/php
8848 <p><a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">es:Spanish</a>
8849 [[::es:Spanish]]
8850 [[:::es:Spanish]]
8851 </p>
8852 !! html/parsoid
8853 <p><a rel="mw:ExtLink" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">es:Spanish</a>
8854 [[::es:Spanish]]
8855 [[:::es:Spanish]]</p>
8856 !! end
8857
8858 ## parsoid html2wt will normalize the space to _
8859 !! test
8860 Space and question mark encoding in interlanguage links (T95473)
8861 !! options
8862 parsoid=wt2html,wt2wt,html2html
8863 !! wikitext
8864 Blah blah blah
8865 [[es:Foo bar?]]
8866 !! html/php
8867 <p>Blah blah blah
8868 </p>
8869 !! html/parsoid
8870 <p>Blah blah blah</p>
8871 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo_bar%3F" />
8872 !! end
8873
8874 !! test
8875 Interlanguage link, with prefix links
8876 !! options
8877 language=ln
8878 !! wikitext
8879 Blah blah blah
8880 [[zh:Chinese]]
8881 !! html/php
8882 <p>Blah blah blah
8883 </p>
8884 !! html/parsoid
8885 <p>Blah blah blah</p>
8886 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
8887 !! end
8888
8889 !! test
8890 Double interlanguage link, with prefix links (T10897)
8891 !! options
8892 language=ln
8893 !! wikitext
8894 Blah blah blah
8895 [[es:Spanish]]
8896 [[zh:Chinese]]
8897 !! html/php
8898 <p>Blah blah blah
8899 </p>
8900 !! html/parsoid
8901 <p>Blah blah blah</p>
8902 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Spanish"/>
8903 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
8904 !! end
8905
8906 !! test
8907 "Extra" interlanguage links (T34189 / gerrit 111390)
8908 !! wikitext
8909 Blah blah blah
8910 [[mul:Article]]
8911 !! html/php
8912 <p>Blah blah blah
8913 </p>
8914 !! html/parsoid
8915 <p>Blah blah blah</p>
8916 <link rel="mw:PageProp/Language" title="Multilingual" href="http://wikisource.org/wiki/Article"/>
8917 !! end
8918
8919 ## PHP parser tests script needs an update
8920 ## Parsoid html2wt will normalize output to [[:zh:Chinese]]
8921 !! test
8922 Language links render as inline links if $wgInterwikiMagic=false
8923 !! options
8924 wgInterwikiMagic=false
8925 parsoid=wt2html,wt2wt,html2html
8926 !! wikitext
8927 Blah blah blah
8928 [[zh:Chinese]]
8929 !! html/parsoid
8930 <p>Blah blah blah <a rel="mw:ExtLink" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese">zh:Chinese</a></p>
8931 !! end
8932
8933 ## PHP parser tests script needs an update
8934 ## Parsoid html2wt will normalize output to [[:zh:Chinese]]
8935 !! test
8936 Language links render as inline links in the Talk namespace
8937 !! options
8938 title=Talk:Foo
8939 parsoid=wt2html,wt2wt,html2html
8940 !! wikitext
8941 Blah blah blah
8942 [[zh:Chinese]]
8943 !! html/parsoid
8944 <p>Blah blah blah <a rel="mw:ExtLink" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese">zh:Chinese</a></p>
8945 !! end
8946
8947 !! test
8948 Parsoid-specific test: Wikilinks with &nbsp; should RT properly
8949 !! options
8950 language=ln
8951 !! wikitext
8952 [[WW&nbsp;II]]
8953 !! html
8954 <p><a href="/index.php?title=WW_II&amp;action=edit&amp;redlink=1" class="new" title="WW II (lonkásá ezalí tɛ̂)">WW&#160;II</a>
8955 </p>
8956 !! end
8957
8958 !! test
8959 Parsoid T55221: Wikilinks should be properly entity-escaped
8960 !! options
8961 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
8962 !! html/parsoid
8963 <p>He&amp;nbsp;llo <a href="./Foo" rel="mw:WikiLink">He&amp;nbsp;llo</a></p>
8964 <p>He&amp;nbsp;llo <a href="./He&amp;nbsp;llo" rel="mw:WikiLink">He&amp;nbsp;llo</a></p>
8965 !! wikitext
8966 He&amp;nbsp;llo [[Foo|He&amp;nbsp;llo]]
8967
8968 He&amp;nbsp;llo He&amp;nbsp;llo
8969 !! html/php
8970 <p>He&amp;nbsp;llo <a href="/wiki/Foo" title="Foo">He&amp;nbsp;llo</a>
8971 </p><p>He&amp;nbsp;llo He&amp;nbsp;llo
8972 </p>
8973 !! end
8974
8975 # html2wt will fail because of title normalization without data-parsoid
8976 !! test
8977 Parsoid: handle constructor well
8978 !! options
8979 parsoid=wt2html,wt2wt
8980 !! wikitext
8981 [[constructor]]
8982
8983 [[constructor:foo]]
8984 !! html/php
8985 <p><a href="/index.php?title=Constructor&amp;action=edit&amp;redlink=1" class="new" title="Constructor (page does not exist)">constructor</a>
8986 </p><p><a href="/index.php?title=Constructor:foo&amp;action=edit&amp;redlink=1" class="new" title="Constructor:foo (page does not exist)">constructor:foo</a>
8987 </p>
8988 !! html/parsoid
8989 <p><a rel="mw:WikiLink" href="./Constructor" title="Constructor" data-parsoid='{"stx":"simple","a":{"href":"./Constructor"},"sa":{"href":"constructor"}}'>constructor</a></p>
8990
8991 <p><a rel="mw:WikiLink" href="./Constructor:foo" title="Constructor:foo" data-parsoid='{"stx":"simple","a":{"href":"./Constructor:foo"},"sa":{"href":"constructor:foo"}}'>constructor:foo</a></p>
8992 !! end
8993
8994 !! article
8995 ko:
8996 !! text
8997 Test.
8998 !! endarticle
8999
9000 # Note that `ko` isn't a known interlanguage prefix
9001 !! test
9002 Parsoid: recognize interlanguage links without a target page
9003 !! options
9004 ill
9005 !! wikitext
9006 [[es:]]
9007
9008 [[ko:]]
9009 !! html/php
9010 es:
9011 !! html/parsoid
9012 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/"/>
9013
9014 <p><a rel="mw:WikiLink" href="./Ko:" title="Ko:">ko:</a></p>
9015 !! end
9016
9017 # Note that `ko` isn't a known interwiki prefix
9018 !! test
9019 Parsoid: recognize interwiki links without a target page
9020 !! options
9021 parsoid=wt2html,wt2wt,html2html
9022 !! wikitext
9023 [[:es:]]
9024
9025 [[:ko:]]
9026 !! html/php
9027 <p><a href="http://es.wikipedia.org/wiki/" class="extiw" title="es:">es:</a>
9028 </p><p><a href="/wiki/Ko:" title="Ko:">ko:</a>
9029 </p>
9030 !! html/parsoid
9031 <p><a rel="mw:ExtLink" href="http://es.wikipedia.org/wiki/" title="es:">es:</a></p>
9032 <p><a rel="mw:WikiLink" href="./Ko:" title="Ko:">ko:</a></p>
9033 !! end
9034
9035 !! test
9036 Handle interwiki links pointing to the current wiki as plain wiki links (T47209)
9037 !! wikitext
9038 [[mi:Foo]]
9039 !! html/php
9040 <p><a href="/wiki/Foo" title="Foo">mi:Foo</a>
9041 </p>
9042 !! html/parsoid
9043 <p><a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"simple","a":{"href":"./Foo"},"sa":{"href":"mi:Foo"}}'>mi:Foo</a></p>
9044 !! end
9045
9046 !! test
9047 Interlanguage link with preceding local interwiki link (T70085)
9048 !! options
9049 parsoid=wt2html,wt2wt,html2html
9050 !! wikitext
9051 Blah blah blah
9052 [[local:es:Spanish]]
9053 !! html/php
9054 <p>Blah blah blah
9055 <a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">local:es:Spanish</a>
9056 </p>
9057 !! html/parsoid
9058 <p>Blah blah blah
9059 <a rel="mw:ExtLink" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">local:es:Spanish</a></p>
9060 !! end
9061
9062 !! test
9063 Looks like an interlanguage link, but is actually a local interwiki
9064 !! options
9065 parsoid=wt2html,wt2wt,html2html
9066 !! wikitext
9067 Blah blah blah
9068 [[mi:Template:Foo]]
9069 !! html/php
9070 <p>Blah blah blah
9071 <a href="/wiki/Template:Foo" title="Template:Foo">mi:Template:Foo</a>
9072 </p>
9073 !! html/parsoid
9074 <p>Blah blah blah
9075 <a rel="mw:WikiLink" href="./Template:Foo" title="Template:Foo">mi:Template:Foo</a></p>
9076 !! end
9077
9078 ###
9079 ### Redirects, Parsoid-only
9080 ###
9081
9082 !! test
9083 1. Simple redirect to page
9084 !! wikitext
9085 #REDIRECT [[Main Page]]
9086 !! html/parsoid
9087 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9088 !! end
9089
9090 !! test
9091 2. Other redirect variants
9092 !! wikitext
9093 #REDIRECT [[Main_Page]]
9094 !! html/parsoid
9095 <link rel="mw:PageProp/redirect" href="./Main_Page" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./Main_Page"},"sa":{"href":"Main_Page"}}'/>
9096 !! end
9097
9098 # Not a valid redirect in PHP (although perhaps it was, once upon a time)
9099 # This tests the Parsoid bail-out code.
9100 !! test
9101 3. Other redirect variants
9102 !! wikitext
9103 #REDIRECT [[<nowiki>[[Bar]]</nowiki>]]
9104 !! html/parsoid
9105 <ol><li data-parsoid>REDIRECT [[[[Bar]]]]</li></ol>
9106 !! end
9107
9108 !! test
9109 4. Redirect to a templated destination
9110 !! wikitext
9111 #REDIRECT [[{{echo|Foo}}bar]]
9112 !! html/parsoid
9113 <link about="#mwt2" typeof="mw:ExpandedAttrs" rel="mw:PageProp/redirect" href="./Foobar" data-parsoid='{"a":{"href":"./Foobar"},"sa":{"href":"{{echo|Foo}}bar"}}' data-mw='{"attribs":[[{"txt":"href"},{"html":"&lt;span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid=&#39;{\"pi\":[[{\"k\":\"1\"}]],\"dsr\":[12,24,null,null]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"Foo\"}},\"i\":0}}]}&#39;>Foo&lt;/span>bar"}]]}'/>
9114 !! end
9115
9116 !! test
9117 Empty redirect
9118 !! options
9119 parsoid=wt2html,wt2wt
9120 !! wikitext
9121 #REDIRECT [[]]
9122 !! html/parsoid
9123 <ol>
9124 <li>REDIRECT [[]]</li></ol>
9125 !! end
9126
9127 !! test
9128 Optional colon in #REDIRECT
9129 !! options
9130 # the colon is archaic syntax. we support it for wt2html, but we
9131 # don't care that it roundtrips back to the modern syntax.
9132 parsoid=wt2html,html2html
9133 !! wikitext
9134 #REDIRECT:[[Main Page]]
9135 !! html/parsoid
9136 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9137 !! end
9138
9139 !! test
9140 Whitespace in #REDIRECT with optional colon
9141 !! options
9142 # the colon and gratuitous whitespace is archaic syntax. we support
9143 # it for wt2html, but we don't care that it roundtrips back to the
9144 # modern syntax (without extra whitespace)
9145 parsoid=wt2html,html2html
9146 !! wikitext
9147
9148 #REDIRECT
9149 :
9150 [[Main Page]]
9151 !! html/parsoid
9152 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9153 !! end
9154
9155 !! test
9156 Piped link in #REDIRECT
9157 !! options
9158 # content after piped link is ignored. we support this syntax,
9159 # but don't care that the piped link is lost when we roundtrip this.
9160 parsoid=wt2html
9161 !! wikitext
9162 #REDIRECT [[Main Page|bar]]
9163 !! html/parsoid
9164 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9165 !! end
9166
9167 !! test
9168 Redirect to category (T104502)
9169 !! options
9170 parsoid=wt2html,wt2wt
9171 !! wikitext
9172 #REDIRECT [[Category:Foo]]
9173 !! html/parsoid
9174 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
9175 !! end
9176
9177 !! test
9178 Redirect to category with URL encoding (T104502)
9179 !! options
9180 parsoid=wt2html
9181 !! wikitext
9182 #REDIRECT [[Category%3AFoo]]
9183 !! html/parsoid
9184 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
9185 !! end
9186
9187 !! test
9188 Redirect to category page
9189 !! wikitext
9190 #REDIRECT [[:Category:Foo]]
9191 !! html/parsoid
9192 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
9193 !! end
9194
9195 !! test
9196 Redirect to image page (1)
9197 !! wikitext
9198 #REDIRECT [[File:Wiki.png]]
9199 !! html/parsoid
9200 <link rel="mw:PageProp/redirect" href="./File:Wiki.png"/>
9201 !! end
9202
9203 !! test
9204 Redirect to image page (2)
9205 !! wikitext
9206 #REDIRECT [[Image:Wiki.png]]
9207 !! html/parsoid
9208 <link rel="mw:PageProp/redirect" href="./File:Wiki.png" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./File:Wiki.png"},"sa":{"href":"Image:Wiki.png"}}'/>
9209 !! end
9210
9211 # html2wt disabled because wts serializes as "#REDIRECT [[:en:File:Wiki.png]]"
9212 # Next test confirms this.
9213 !! test
9214 Redirect to language (1) (T104918)
9215 !! options
9216 parsoid=wt2html,wt2wt,html2html
9217 !! wikitext
9218 #REDIRECT [[en:File:Wiki.png]]
9219 !! html/parsoid
9220 <link rel="mw:PageProp/redirect" href="//en.wikipedia.org/wiki/File:Wiki.png"/>
9221 !! end
9222
9223 !! test
9224 Redirect to language (2) (T104918)
9225 !! wikitext
9226 #REDIRECT [[:en:File:Wiki.png]]
9227 !! html/parsoid
9228 <link rel="mw:PageProp/redirect" href="//en.wikipedia.org/wiki/File:Wiki.png"/>
9229 !! end
9230
9231 !! test
9232 Redirect to interwiki (T104918)
9233 !! wikitext
9234 #REDIRECT [[meatball:File:Wiki.png]]
9235 !! html/parsoid
9236 <link rel="mw:PageProp/redirect" href="http://www.usemod.com/cgi-bin/mb.pl?File:Wiki.png"/>
9237 !! end
9238
9239 !! test
9240 Non-English #REDIRECT
9241 !! options
9242 language=is
9243 !! wikitext
9244 #TILVÍSUN [[Main Page]]
9245 !! html/parsoid
9246 <link rel="mw:PageProp/redirect" href="./Main_Page" data-parsoid='{"src":"#TILVÍSUN ","a":{"href":"./Main_Page"},"sa":{"href":"Main Page"}}'/>
9247 !! end
9248
9249 !! test
9250 Redirect syntax under text isn't considered a redirect
9251 !! wikitext
9252 some text
9253 #redirect [[Main Page]]
9254 !! html/parsoid
9255 <p>some text</p>
9256 <ol data-parsoid='{}'><li data-parsoid='{}'>redirect <a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page"},"sa":{"href":"Main Page"}}'>Main Page</a></li></ol>
9257 !! end
9258
9259 !! test
9260 New redirect
9261 !! options
9262 parsoid=html2wt
9263 !! html/parsoid
9264 <p>Foo<link rel="mw:PageProp/redirect" href="./Foo"/></p>
9265 !! wikitext
9266 #REDIRECT [[Foo]]
9267 Foo
9268 !! end
9269
9270 !! test
9271 Redirect followed by block on the same line
9272 !! options
9273 parsoid=wt2html
9274 !! wikitext
9275 #REDIRECT [[Main Page]]<!-- haha -->== hi ==
9276 !! html/parsoid
9277 <link rel="mw:PageProp/redirect" href="./Main_Page"/><!-- haha --><h2 id="hi"> hi </h2>
9278 !! end
9279
9280 !! test
9281 Redirect followed by a newline
9282 !! wikitext
9283 #REDIRECT [[Main Page]]
9284 A newline
9285 !! html/parsoid
9286 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9287 <p>A newline</p>
9288 !! end
9289
9290 !! test
9291 Redirect followed by multiple newlines
9292 !! wikitext
9293 #REDIRECT [[Main Page]]
9294
9295
9296 A newline
9297 !! html/parsoid
9298 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9299
9300 <p><br/>
9301 A newline</p>
9302 !! end
9303
9304 !! test
9305 Drop duplicate redirects
9306 !! options
9307 parsoid=html2wt
9308 !! html/parsoid
9309 <link rel="mw:PageProp/redirect" href="./Foo"/>
9310 <link rel="mw:PageProp/redirect" href="./Bar"/>
9311 <link rel="mw:PageProp/redirect" href="./Baz"/>
9312 !! wikitext
9313 #REDIRECT [[Foo]]
9314 !! end
9315
9316 ##
9317 ## XHTML tidiness
9318 ###
9319
9320 !! test
9321 <br> to <br />
9322 !! wikitext
9323 1<br>2<br />3
9324 !! html
9325 <p>1<br />2<br />3
9326 </p>
9327 !! end
9328
9329 !! test
9330 Broken br tag sanitization
9331 !! wikitext
9332 </br>
9333 !! html/php
9334 <p>&lt;/br&gt;
9335 </p>
9336 !! end
9337
9338 # TODO: Fix html2html mode (T53055)!
9339 !! test
9340 Parsoid: Broken br tag recognition
9341 !! options
9342 parsoid=wt2html
9343 !! wikitext
9344 </br>
9345
9346 <br/ >
9347 !! html+tidy
9348 <p><br /></p>
9349 <p><br /></p>
9350 !! end
9351
9352 !! test
9353 Incorrecly removing closing slashes from correctly formed XHTML
9354 !! wikitext
9355 <br style="clear:both;" />
9356 !! html
9357 <p><br style="clear:both;" />
9358 </p>
9359 !! end
9360
9361 !! test
9362 Failing to transform badly formed HTML into correct XHTML
9363 !! wikitext
9364 <br style="clear: left;">
9365 <br style="clear: right;">
9366 <br style="clear: both;">
9367 !! html
9368 <p><br style="clear: left;" />
9369 <br style="clear: right;" />
9370 <br style="clear: both;" />
9371 </p>
9372 !!end
9373
9374 ## FIXME: Is Parsoid's acceptance of self-closing html-tags
9375 ## a feature or a bug? See https://phabricator.wikimedia.org/T76962
9376 !! test
9377 Handling html with a div self-closing tag
9378 !! wikitext
9379 <div title />
9380 <div title/>
9381 <div title/ >
9382 <div title=bar />
9383 <div title=bar/>
9384 <div title=bar/ >
9385 !! html/php
9386 <p>&lt;div title /&gt;
9387 &lt;div title/&gt;
9388 </p>
9389 <div>
9390 <p>&lt;div title=bar /&gt;
9391 &lt;div title=bar/&gt;
9392 </p>
9393 <div title="bar/"></div>
9394 </div>
9395
9396 !! html/parsoid
9397 <div title="" data-parsoid='{"stx":"html","selfClose":true}'></div>
9398 <div title="" data-parsoid='{"stx":"html","selfClose":true}'></div>
9399 <div title="" data-parsoid='{"stx":"html","selfClose":true,"brokenHTMLTag":true}'></div>
9400 <div title="bar" data-parsoid='{"stx":"html","selfClose":true}'></div>
9401 <div title="bar" data-parsoid='{"stx":"html","selfClose":true}'></div>
9402 <div title="bar/" data-parsoid='{"stx":"html","autoInsertedEnd":true}'></div>
9403 !! end
9404
9405 !! test
9406 Handling html with a br self-closing tag
9407 !! wikitext
9408 <br title />
9409 <br title/>
9410 <br title/ >
9411 <br title=bar />
9412 <br title=bar/>
9413 <br title=bar/ >
9414 !! html/php
9415 <p><br title="" />
9416 <br title="" />
9417 <br />
9418 <br title="bar" />
9419 <br title="bar" />
9420 <br title="bar/" />
9421 </p>
9422 !! html/parsoid
9423 <p><br title="" />
9424 <br title="" />
9425 <br title="" />
9426 <br title="bar" />
9427 <br title="bar" />
9428 <br title="bar/" />
9429 </p>
9430 !! end
9431
9432 !! test
9433 Horizontal ruler (should it add that extra space?)
9434 !! wikitext
9435 <hr>
9436 <hr >
9437 foo <hr
9438 > bar
9439 !! html+tidy
9440 <hr />
9441 <hr />
9442 <p>foo</p>
9443 <hr />
9444 <p>bar</p>
9445 !! end
9446
9447 !! test
9448 Horizontal ruler -- 4+ dashes render hr
9449 !! wikitext
9450 ----
9451 !! html
9452 <hr />
9453
9454 !! end
9455
9456 !! test
9457 Horizontal ruler -- eats additional dashes on the same line
9458 !! wikitext
9459 ---------
9460 !! html
9461 <hr />
9462
9463 !! end
9464
9465 !! test
9466 Horizontal ruler -- does not collapse dashes on consecutive lines
9467 !! wikitext
9468 ----
9469 ----
9470 !! html
9471 <hr />
9472 <hr />
9473
9474 !! end
9475
9476 !! test
9477 Horizontal ruler -- <4 dashes render as plain text
9478 !! wikitext
9479 ---
9480 !! html
9481 <p>---
9482 </p>
9483 !! end
9484
9485 !! test
9486 Horizontal ruler -- Supports content following dashes on same line
9487 !! wikitext
9488 ---- Foo
9489 !! html
9490 <hr /> Foo
9491
9492 !! html+tidy
9493 <hr />
9494 <p>Foo</p>
9495 !! end
9496
9497 ###
9498 ### Block-level elements
9499 ###
9500 !! test
9501 Common list
9502 !! wikitext
9503 *Common list
9504 * item 2
9505 *item 3
9506 !! html
9507 <ul><li>Common list</li>
9508 <li> item 2</li>
9509 <li>item 3</li></ul>
9510
9511 !! end
9512
9513 !! test
9514 Numbered list
9515 !! wikitext
9516 #Numbered list
9517 #item 2
9518 # item 3
9519 !! html
9520 <ol><li>Numbered list</li>
9521 <li>item 2</li>
9522 <li> item 3</li></ol>
9523
9524 !! end
9525
9526 !! test
9527 Mixed list
9528 !! wikitext
9529 *Mixed list
9530 *# with numbers
9531 ** and bullets
9532 *# and numbers
9533 *bullets again
9534 **bullet level 2
9535 ***bullet level 3
9536 ***#Number on level 4
9537 **bullet level 2
9538 **#Number on level 3
9539 **#Number on level 3
9540 *#number level 2
9541 *Level 1
9542 *** Level 3
9543 #** Level 3, but ordered
9544 !! html
9545 <ul><li>Mixed list
9546 <ol><li> with numbers</li></ol>
9547 <ul><li> and bullets</li></ul>
9548 <ol><li> and numbers</li></ol></li>
9549 <li>bullets again
9550 <ul><li>bullet level 2
9551 <ul><li>bullet level 3
9552 <ol><li>Number on level 4</li></ol></li></ul></li>
9553 <li>bullet level 2
9554 <ol><li>Number on level 3</li>
9555 <li>Number on level 3</li></ol></li></ul>
9556 <ol><li>number level 2</li></ol></li>
9557 <li>Level 1
9558 <ul><li><ul><li> Level 3</li></ul></li></ul></li></ul>
9559 <ol><li><ul><li><ul><li> Level 3, but ordered</li></ul></li></ul></li></ol>
9560
9561 !! end
9562
9563 !! test
9564 1. Nested mixed wikitext and html list
9565 !! wikitext
9566 * hi
9567 * <ul><li>ho</li></ul>
9568 * hi
9569 ** ho
9570 !! html/php
9571 <ul><li> hi</li>
9572 <li> <ul><li>ho</li></ul></li>
9573 <li> hi
9574 <ul><li> ho</li></ul></li></ul>
9575
9576 !! html/parsoid
9577 <ul><li> hi</li>
9578 <li> <ul data-parsoid='{"stx":"html"}'><li data-parsoid='{"stx":"html"}'>ho</li></ul></li>
9579 <li> hi
9580 <ul><li> ho</li></ul></li></ul>
9581 !! end
9582
9583 !! test
9584 2. Nested mixed wikitext and html list (incompatible)
9585 !! wikitext
9586 ; hi
9587 : {{echo|<li>ho</li>}}
9588 !! html/php
9589 <dl><dt> hi</dt>
9590 <dd> <li>ho</li></dd></dl>
9591
9592 !! html/parsoid
9593 <dl><dt> hi</dt>
9594 <dd> <li about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"stx":"html","pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;li>ho&lt;/li>"}},"i":0}}]}'>ho</li></dd></dl>
9595 !! end
9596
9597 !! test
9598 Nested lists 1
9599 !! wikitext
9600 *foo
9601 **bar
9602 !! html
9603 <ul><li>foo
9604 <ul><li>bar</li></ul></li></ul>
9605
9606 !! end
9607
9608 !! test
9609 Nested lists 2
9610 !! wikitext
9611 **foo
9612 *bar
9613 !! html
9614 <ul><li><ul><li>foo</li></ul></li>
9615 <li>bar</li></ul>
9616
9617 !! end
9618
9619 !! test
9620 Nested lists 3 (first element empty)
9621 !! wikitext
9622 *
9623 **bar
9624 !! html
9625 <ul><li>
9626 <ul><li>bar</li></ul></li></ul>
9627
9628 !! end
9629
9630 !! test
9631 Nested lists 4 (first element empty)
9632 !! wikitext
9633 **
9634 *bar
9635 !! html
9636 <ul><li><ul><li></li></ul></li>
9637 <li>bar</li></ul>
9638
9639 !! end
9640
9641 !! test
9642 Nested lists 5 (both elements empty)
9643 !! wikitext
9644 **
9645 *
9646 !! html
9647 <ul><li><ul><li></li></ul></li>
9648 <li></li></ul>
9649
9650 !! end
9651
9652 !! test
9653 Nested lists 6 (both elements empty)
9654 !! wikitext
9655 *
9656 **
9657 !! html
9658 <ul><li>
9659 <ul><li></li></ul></li></ul>
9660
9661 !! end
9662
9663 !! test
9664 Nested lists 7 (skip initial nesting levels)
9665 !! wikitext
9666 *** foo
9667 !! html
9668 <ul><li><ul><li><ul><li> foo</li></ul></li></ul></li></ul>
9669
9670 !! end
9671
9672 !! test
9673 Nested lists 8 (multiple nesting transitions)
9674 !! wikitext
9675 * foo
9676 *** bar
9677 ** baz
9678 * boo
9679 !! html
9680 <ul><li> foo
9681 <ul><li><ul><li> bar</li></ul></li>
9682 <li> baz</li></ul></li>
9683 <li> boo</li></ul>
9684
9685 !! end
9686
9687 !! test
9688 Nested lists 9 (extension interaction)
9689 !! options
9690 parsoid
9691 !! wikitext
9692 *<references />
9693 !! html/parsoid
9694 <ul><li data-parsoid='{}'><ol class="mw-references" typeof="mw:Extension/references" about="#mwt2" data-parsoid='{}' data-mw='{"name":"references","attrs":{}}'></ol></li></ul>
9695 !! end
9696
9697 !! test
9698 1. Lists with start-of-line-transparent tokens before bullets: Comments
9699 !! wikitext
9700 *foo
9701 *<!--cmt-->bar
9702 <!--cmt-->*baz
9703 !! html
9704 <ul><li>foo</li>
9705 <li>bar</li>
9706 <li>baz</li></ul>
9707
9708 !! end
9709
9710 !! test
9711 2. Lists with start-of-line-transparent tokens before bullets: Template close
9712 !! wikitext
9713 *foo {{echo|bar
9714 }}*baz
9715 !! html
9716 <ul><li>foo bar</li>
9717 <li>baz</li></ul>
9718
9719 !! end
9720
9721 !! test
9722 List items are not parsed correctly following a <pre> block (T2785)
9723 !! wikitext
9724 * <pre>foo</pre>
9725 * <pre>bar</pre>
9726 * zar
9727 !! html/php
9728 <ul><li> <pre>foo</pre></li>
9729 <li> <pre>bar</pre></li>
9730 <li> zar</li></ul>
9731
9732 !! html/parsoid
9733 <ul><li> <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo"}}'>foo</pre></li>
9734 <li> <pre typeof="mw:Extension/pre" about="#mwt4" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"bar"}}'>bar</pre></li>
9735 <li> zar</li></ul>
9736 !! end
9737
9738 !! test
9739 List items from template
9740 !! wikitext
9741
9742 {{inner list}}
9743 * item 2
9744
9745 * item 0
9746 {{inner list}}
9747 * item 2
9748
9749 * item 0
9750 * notSOL{{inner list}}
9751 * item 2
9752 !! html
9753 <ul><li> item 1</li>
9754 <li> item 2</li></ul>
9755 <ul><li> item 0</li>
9756 <li> item 1</li>
9757 <li> item 2</li></ul>
9758 <ul><li> item 0</li>
9759 <li> notSOL</li>
9760 <li> item 1</li>
9761 <li> item 2</li></ul>
9762
9763 !! end
9764
9765 !! test
9766 List interrupted by empty line or heading
9767 !! wikitext
9768 * foo
9769
9770 ** bar
9771 == A heading ==
9772 * Another list item
9773 !! html
9774 <ul><li> foo</li></ul>
9775 <ul><li><ul><li> bar</li></ul></li></ul>
9776 <h2><span class="mw-headline" id="A_heading">A heading</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: A heading">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
9777 <ul><li> Another list item</li></ul>
9778
9779 !!end
9780
9781 !!test
9782 Multiple list tags generated by templates
9783 !! wikitext
9784 {{echo|<li>}}a
9785 {{echo|<li>}}b
9786 {{echo|<li>}}c
9787 !! html
9788 <li>a
9789 <li>b
9790 <li>c</li>
9791 </li>
9792 </li>
9793
9794 !! html+tidy
9795 <ul>
9796 <li>a</li>
9797 <li>b</li>
9798 <li>c</li>
9799 </ul>
9800 !!end
9801
9802 !!test
9803 Single-comment whitespace lines dont break lists, and neither do multi-comment whitespace lines
9804 !! wikitext
9805 *a
9806 <!--This line will NOT split the list-->
9807 *b
9808 <!--This line will NOT split the list either-->
9809 *c
9810 <!--foo--> <!----> <!--This line NOT split the list either-->
9811 *d
9812 !! html
9813 <ul><li>a</li>
9814 <li>b</li>
9815 <li>c</li>
9816 <li>d</li></ul>
9817
9818 !!end
9819
9820 !!test
9821 Replacing whitespace with tabs still doesn't break the list (gerrit 78327)
9822 !! wikitext
9823 *a
9824 <!--This line will NOT split the list-->
9825 *b
9826 <!--This line will NOT split the list either-->
9827 *c
9828 <!--foo--> <!----> <!--This line NOT split the list
9829 either-->
9830 *d
9831 !! html
9832 <ul><li>a</li>
9833 <li>b</li>
9834 <li>c</li>
9835 <li>d</li></ul>
9836
9837 !!end
9838
9839 !!test
9840 Test the li-hack
9841 (The PHP parser relies on Tidy for the hack)
9842 !!options
9843 parsoid=wt2html,wt2wt
9844 !! wikitext
9845 * foo
9846 * <li>li-hack
9847 * {{echo|<li>templated li-hack}}
9848 * <!--foo--> <li> unsupported li-hack with preceding comments
9849
9850 <ul>
9851 <li><li>not a li-hack
9852 </li>
9853 </ul>
9854 !! html+tidy
9855 <ul>
9856 <li>foo</li>
9857 <li>li-hack</li>
9858 <li>templated li-hack</li>
9859 <li>unsupported li-hack with preceding comments</li>
9860 </ul>
9861 <ul>
9862 <li>not a li-hack</li>
9863 </ul>
9864 !!end
9865
9866 !! test
9867 Parsoid: Make sure nested lists are serialized on their own line even if HTML contains no newlines
9868 !! options
9869 parsoid
9870 !! wikitext
9871 # foo
9872 ## bar
9873 * foo
9874 ** bar
9875 : foo
9876 :: bar
9877 !! html
9878 <ol>
9879 <li> foo<ol>
9880 <li> bar</li>
9881 </ol></li>
9882 </ol><ul>
9883 <li> foo<ul>
9884 <li> bar</li>
9885 </ul></li>
9886 </ul><dl>
9887 <dd> foo<dl>
9888 <dd> bar</dd>
9889 </dl></dd>
9890 </dl>
9891 !! end
9892
9893 !! test
9894 Parsoid: Test of whitespace serialization with Templated bullets
9895 !! options
9896 parsoid
9897 !! wikitext
9898 * {{bullet}}
9899 !! html
9900 <ul>
9901 <li> </li><li about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"bullet","href":"./Template:Bullet"},"params":{},"i":0}}]}'> Bar</li>
9902 </ul>
9903 !! end
9904
9905 # ------------------------------------------------------------------------
9906 # The next set of tests are about Parsoid's ability to handle badly nested
9907 # tags (parse, minimize scope of fixup, and roundtrip back)
9908 # ------------------------------------------------------------------------
9909
9910 !! test
9911 Unbalanced closing block tags break a list
9912 (php parser relies on Tidy to fix up)
9913 !! wikitext
9914 <div>
9915 *a</div><div>
9916 *b</div>
9917 !! html+tidy
9918 <div>
9919 <ul>
9920 <li>a</li>
9921 </ul>
9922 </div>
9923 <div>
9924 <ul>
9925 <li>b</li>
9926 </ul>
9927 </div>
9928 !! end
9929
9930 # Parsoid fails this test, but it might be tricky to support properly.
9931 # See T70395.
9932 !! test
9933 Unbalanced closing non-block tags don't break a list
9934 (php parser relies on Tidy to fix up)
9935 !! wikitext
9936 <span>
9937 *a</span><span>
9938 *b</span>
9939 !! html/php+tidy
9940 <ul>
9941 <li><span>a</span></li>
9942 <li><span>b</span></li>
9943 </ul>
9944 !! html/parsoid
9945 <span>
9946 <ul>
9947 <li>a<span></span>
9948 </li>
9949 <li>b
9950 </li>
9951 </ul>
9952 </span>
9953 !! end
9954
9955 !! test
9956 Unclosed formatting tags that straddle lists are closed and reopened
9957 (php parser relies on Tidy to fix up)
9958 !! options
9959 parsoid=wt2html,wt2wt,html2html
9960 !! wikitext
9961 # <s> a
9962 # b </s>
9963 !! html/php+tidy
9964 <ol>
9965 <li><s>a</s></li>
9966 <li><s>b</s></li>
9967 </ol>
9968 !! html/parsoid
9969 <ol><li> <s> a</s></li>
9970 <li><s> b </s></li></ol>
9971 !! end
9972
9973 # See T70395.
9974 !!test
9975 1. List embedded in a formatting tag
9976 !! wikitext
9977 <small>
9978 * foo
9979 </small>
9980 !! html/php+tidy
9981 <ul>
9982 <li><small>foo</small></li>
9983 </ul>
9984 !! html/parsoid
9985 <small>
9986 <ul>
9987 <li> foo</li>
9988 </ul>
9989 </small>
9990 !!end
9991
9992 ## Ugly Parsoid output here
9993 ## Not sure what the right output is.
9994 !!test
9995 2. List embedded in a formatting tag
9996 !! wikitext
9997 <small>
9998 *a
9999 *b</small>
10000 !! html/php+tidy
10001 <ul>
10002 <li><small>a</small></li>
10003 <li><small>b</small></li>
10004 </ul>
10005 !! html/parsoid
10006 <small></small>
10007 <ul><small>
10008 <li>a</li>
10009 </small>
10010 <li><small>b</small></li>
10011 </ul>
10012 !!end
10013
10014 # Ugly Parsoid and PHP parser output here
10015 # Not sure if we want to make this a test!
10016 #
10017 ## !!test
10018 ## 3. Unclosed formatting tags in list elements
10019 ## !! wikitext
10020 ## *<small>a
10021 ## *<small>b
10022 ## !! html/php+tidy
10023 ## <ul>
10024 ## <li><small>a</small></li>
10025 ## <li><small><small>b</small></small></li>
10026 ## </ul>
10027 ## !! html/parsoid
10028 ## <ul>
10029 ## <li><small>a</small></li>
10030 ## <small>
10031 ## <li><small>b</small></li>
10032 ## </small></ul>
10033 ## !!end
10034
10035 # This is a bug in the PHP parser + tidy combination.
10036 # (The </tr> tag gets parsed as text and html-escaped by PHP,
10037 # and then fostered out of the table by tidy.)
10038 # We believe the Parsoid output to be correct.
10039 !! test
10040 Table with missing opening <tr> tag
10041 !! options
10042 parsoid=wt2html,wt2wt
10043 !! wikitext
10044 <table>
10045 <td>foo</td>
10046 </tr>
10047 </table>
10048 !! html+tidy
10049 <table>
10050 <tr>
10051 <td>foo</td>
10052 </tr>
10053 </table>
10054 !! end
10055
10056 ###
10057 ### Magic Words
10058 ###
10059
10060 # Note that the current date is hard-coded as
10061 # 1970-01-01T00:02:03Z (a Thursday)
10062 # when running parser tests. The timezone is also fixed to GMT, so
10063 # local date will be identical to current date.
10064
10065 !! test
10066 Magic Word: {{CURRENTDAY}}
10067 !! wikitext
10068 {{CURRENTDAY}}
10069 !! html
10070 <p>1
10071 </p>
10072 !! end
10073
10074 !! test
10075 Magic Word: {{CURRENTDAY2}}
10076 !! wikitext
10077 {{CURRENTDAY2}}
10078 !! html
10079 <p>01
10080 </p>
10081 !! end
10082
10083 !! test
10084 Magic Word: {{CURRENTDAYNAME}}
10085 !! wikitext
10086 {{CURRENTDAYNAME}}
10087 !! html
10088 <p>Thursday
10089 </p>
10090 !! end
10091
10092 !! test
10093 Magic Word: {{CURRENTDOW}}
10094 !! wikitext
10095 {{CURRENTDOW}}
10096 !! html
10097 <p>4
10098 </p>
10099 !! end
10100
10101 !! test
10102 Magic Word: {{CURRENTMONTH}}
10103 !! wikitext
10104 {{CURRENTMONTH}}
10105 !! html
10106 <p>01
10107 </p>
10108 !! end
10109
10110 !! test
10111 Magic Word: {{CURRENTMONTH1}}
10112 !! wikitext
10113 {{CURRENTMONTH1}}
10114 !! html
10115 <p>1
10116 </p>
10117 !! end
10118
10119 !! test
10120 Magic Word: {{CURRENTMONTHABBREV}}
10121 !! wikitext
10122 {{CURRENTMONTHABBREV}}
10123 !! html
10124 <p>Jan
10125 </p>
10126 !! end
10127
10128 !! test
10129 Magic Word: {{CURRENTMONTHNAME}}
10130 !! wikitext
10131 {{CURRENTMONTHNAME}}
10132 !! html
10133 <p>January
10134 </p>
10135 !! end
10136
10137 !! test
10138 Magic Word: {{CURRENTMONTHNAMEGEN}}
10139 !! wikitext
10140 {{CURRENTMONTHNAMEGEN}}
10141 !! html
10142 <p>January
10143 </p>
10144 !! end
10145
10146 !! test
10147 Magic Word: {{CURRENTTIME}}
10148 !! wikitext
10149 {{CURRENTTIME}}
10150 !! html
10151 <p>00:02
10152 </p>
10153 !! end
10154
10155 !! test
10156 Magic Word: {{CURRENTHOUR}}
10157 !! wikitext
10158 {{CURRENTHOUR}}
10159 !! html
10160 <p>00
10161 </p>
10162 !! end
10163
10164 !! test
10165 Magic Word: {{CURRENTWEEK}} (T6594)
10166 !! wikitext
10167 {{CURRENTWEEK}}
10168 !! html
10169 <p>1
10170 </p>
10171 !! end
10172
10173 !! test
10174 Magic Word: {{CURRENTYEAR}}
10175 !! wikitext
10176 {{CURRENTYEAR}}
10177 !! html
10178 <p>1970
10179 </p>
10180 !! end
10181
10182 !! test
10183 Magic Word: {{CURRENTTIMESTAMP}}
10184 !! wikitext
10185 {{CURRENTTIMESTAMP}}
10186 !! html
10187 <p>19700101000203
10188 </p>
10189 !! end
10190
10191 !! test
10192 Magic Words LOCAL (UTC)
10193 !! wikitext
10194 * {{LOCALMONTH}}
10195 * {{LOCALMONTH1}}
10196 * {{LOCALMONTHNAME}}
10197 * {{LOCALMONTHNAMEGEN}}
10198 * {{LOCALMONTHABBREV}}
10199 * {{LOCALDAY}}
10200 * {{LOCALDAY2}}
10201 * {{LOCALDAYNAME}}
10202 * {{LOCALYEAR}}
10203 * {{LOCALTIME}}
10204 * {{LOCALHOUR}}
10205 * {{LOCALWEEK}}
10206 * {{LOCALDOW}}
10207 * {{LOCALTIMESTAMP}}
10208 !! html
10209 <ul><li> 01</li>
10210 <li> 1</li>
10211 <li> January</li>
10212 <li> January</li>
10213 <li> Jan</li>
10214 <li> 1</li>
10215 <li> 01</li>
10216 <li> Thursday</li>
10217 <li> 1970</li>
10218 <li> 00:02</li>
10219 <li> 00</li>
10220 <li> 1</li>
10221 <li> 4</li>
10222 <li> 19700101000203</li></ul>
10223
10224 !! end
10225
10226 !! test
10227 Magic Word: {{FULLPAGENAME}}
10228 !! options
10229 title=[[User:Ævar Arnfjörð Bjarmason]]
10230 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10231 !! wikitext
10232 {{FULLPAGENAME}}
10233 !! html/*
10234 <p>User:Ævar Arnfjörð Bjarmason
10235 </p>
10236 !! end
10237
10238 !! test
10239 Magic Word: {{FULLPAGENAMEE}}
10240 !! options
10241 title=[[User:Ævar Arnfjörð Bjarmason]]
10242 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10243 !! wikitext
10244 {{FULLPAGENAMEE}}
10245 !! html/*
10246 <p>User:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10247 </p>
10248 !! end
10249
10250 !! test
10251 Magic Word: {{TALKSPACE}}
10252 !! options
10253 title=[[User:Ævar Arnfjörð Bjarmason]]
10254 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10255 !! wikitext
10256 {{TALKSPACE}}
10257 !! html/*
10258 <p>User talk
10259 </p>
10260 !! end
10261
10262 !! test
10263 Magic Word: {{TALKSPACE}}, same namespace
10264 !! options
10265 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10266 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10267 !! wikitext
10268 {{TALKSPACE}}
10269 !! html/*
10270 <p>User talk
10271 </p>
10272 !! end
10273
10274 !! test
10275 Magic Word: {{TALKSPACE}}, main namespace
10276 !! options
10277 title=[[Parser Test]]
10278 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10279 !! wikitext
10280 {{TALKSPACE}}
10281 !! html/*
10282 <p>Talk
10283 </p>
10284 !! end
10285
10286 !! test
10287 Magic Word: {{TALKSPACEE}}
10288 !! options
10289 title=[[User:Ævar Arnfjörð Bjarmason]]
10290 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10291 !! wikitext
10292 {{TALKSPACEE}}
10293 !! html/*
10294 <p>User_talk
10295 </p>
10296 !! end
10297
10298 !! test
10299 Magic Word: {{SUBJECTSPACE}}
10300 !! options
10301 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10302 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10303 !! wikitext
10304 {{SUBJECTSPACE}}
10305 !! html/*
10306 <p>User
10307 </p>
10308 !! end
10309
10310 !! test
10311 Magic Word: {{SUBJECTSPACE}}, same namespace
10312 !! options
10313 title=[[User:Ævar Arnfjörð Bjarmason]]
10314 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10315 !! wikitext
10316 {{SUBJECTSPACE}}
10317 !! html/*
10318 <p>User
10319 </p>
10320 !! end
10321
10322 !! test
10323 Magic Word: {{SUBJECTSPACE}}, main namespace
10324 !! options
10325 title=[[Parser Test]]
10326 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10327 !! wikitext
10328 {{SUBJECTSPACE}}
10329 !! html/*
10330
10331 !! end
10332
10333 !! test
10334 Magic Word: {{SUBJECTSPACEE}}
10335 !! options
10336 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10337 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10338 !! wikitext
10339 {{SUBJECTSPACEE}}
10340 !! html/*
10341 <p>User
10342 </p>
10343 !! end
10344
10345 !! test
10346 Magic Word: {{NAMESPACE}}
10347 !! options
10348 title=[[User:Ævar Arnfjörð Bjarmason]]
10349 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10350 !! wikitext
10351 {{NAMESPACE}}
10352 !! html/*
10353 <p>User
10354 </p>
10355 !! end
10356
10357 !! test
10358 Magic Word: {{NAMESPACEE}}
10359 !! options
10360 title=[[User:Ævar Arnfjörð Bjarmason]]
10361 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10362 !! wikitext
10363 {{NAMESPACEE}}
10364 !! html/*
10365 <p>User
10366 </p>
10367 !! end
10368
10369 !! test
10370 Magic Word: {{NAMESPACENUMBER}}
10371 !! options
10372 title=[[User:Ævar Arnfjörð Bjarmason]]
10373 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10374 !! wikitext
10375 {{NAMESPACENUMBER}}
10376 !! html/*
10377 <p>2
10378 </p>
10379 !! end
10380
10381 !! test
10382 Magic Word: {{SUBPAGENAME}}
10383 !! options
10384 title=[[Ævar Arnfjörð Bjarmason/sub ö]] subpage
10385 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10386 !! wikitext
10387 {{SUBPAGENAME}}
10388 !! html/*
10389 <p>sub ö
10390 </p>
10391 !! end
10392
10393 !! test
10394 Magic Word: {{SUBPAGENAMEE}}
10395 !! options
10396 title=[[Ævar Arnfjörð Bjarmason/sub ö]] subpage
10397 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10398 !! wikitext
10399 {{SUBPAGENAMEE}}
10400 !! html/*
10401 <p>sub_%C3%B6
10402 </p>
10403 !! end
10404
10405 !! test
10406 Magic Word: {{ROOTPAGENAME}}
10407 !! options
10408 title=[[Ævar Arnfjörð Bjarmason/sub/sub2]] subpage
10409 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10410 !! wikitext
10411 {{ROOTPAGENAME}}
10412 !! html/*
10413 <p>Ævar Arnfjörð Bjarmason
10414 </p>
10415 !! end
10416
10417 !! test
10418 Magic Word: {{ROOTPAGENAMEE}}
10419 !! options
10420 title=[[Ævar Arnfjörð Bjarmason/sub/sub2]] subpage
10421 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10422 !! wikitext
10423 {{ROOTPAGENAMEE}}
10424 !! html/*
10425 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10426 </p>
10427 !! end
10428
10429 !! test
10430 Magic Word: {{BASEPAGENAME}}
10431 !! options
10432 title=[[Ævar Arnfjörð Bjarmason/sub]] subpage
10433 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10434 !! wikitext
10435 {{BASEPAGENAME}}
10436 !! html/*
10437 <p>Ævar Arnfjörð Bjarmason
10438 </p>
10439 !! end
10440
10441 !! test
10442 Magic Word: {{BASEPAGENAMEE}}
10443 !! options
10444 title=[[Ævar Arnfjörð Bjarmason/sub]] subpage
10445 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10446 !! wikitext
10447 {{BASEPAGENAMEE}}
10448 !! html/*
10449 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10450 </p>
10451 !! end
10452
10453 !! test
10454 Magic Word: {{TALKPAGENAME}}
10455 !! options
10456 title=[[User:Ævar Arnfjörð Bjarmason]]
10457 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10458 !! wikitext
10459 {{TALKPAGENAME}}
10460 !! html/*
10461 <p>User talk:Ævar Arnfjörð Bjarmason
10462 </p>
10463 !! end
10464
10465 !! test
10466 Magic Word: {{TALKPAGENAMEE}}
10467 !! options
10468 title=[[User:Ævar Arnfjörð Bjarmason]]
10469 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10470 !! wikitext
10471 {{TALKPAGENAMEE}}
10472 !! html/*
10473 <p>User_talk:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10474 </p>
10475 !! end
10476
10477 !! test
10478 Magic Word: {{SUBJECTPAGENAME}}
10479 !! options
10480 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10481 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10482 !! wikitext
10483 {{SUBJECTPAGENAME}}
10484 !! html/*
10485 <p>User:Ævar Arnfjörð Bjarmason
10486 </p>
10487 !! end
10488
10489 !! test
10490 Magic Word: {{SUBJECTPAGENAMEE}}
10491 !! options
10492 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10493 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10494 !! wikitext
10495 {{SUBJECTPAGENAMEE}}
10496 !! html/*
10497 <p>User:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10498 </p>
10499 !! end
10500
10501 !! test
10502 Magic Word: {{NUMBEROFFILES}}
10503 !! options
10504 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10505 !! wikitext
10506 {{NUMBEROFFILES}}
10507 !! html/*
10508 <p>7
10509 </p>
10510 !! end
10511
10512 !! test
10513 Magic Word: {{PAGENAME}}
10514 !! options
10515 title=[[User:Ævar Arnfjörð Bjarmason]]
10516 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10517 !! wikitext
10518 {{PAGENAME}}
10519 !! html/*
10520 <p>Ævar Arnfjörð Bjarmason
10521 </p>
10522 !! end
10523
10524 !! test
10525 Magic Word: {{PAGENAME}} with metacharacters
10526 !! options
10527 title=[['foo & bar = baz']]
10528 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10529 !! wikitext
10530 ''{{PAGENAME}}''
10531 !! html/php
10532 <p><i>&#39;foo &#38; bar &#61; baz&#39;</i>
10533 </p>
10534 !! html+tidy
10535 <p><i>'foo &amp; bar = baz'</i></p>
10536 !! end
10537
10538 !! test
10539 Magic Word: {{PAGENAME}} with metacharacters (T28781)
10540 !! options
10541 title=[[*RFC 1234 http://example.com/]]
10542 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10543 !! wikitext
10544 {{PAGENAME}}
10545 !! html/php
10546 <p>&#42;RFC&#32;1234 http&#58;//example.com/
10547 </p>
10548 !! html+tidy
10549 <p>*RFC 1234 http://example.com/</p>
10550 !! end
10551
10552 !! test
10553 Magic Word: {{PAGENAMEE}}
10554 !! options
10555 title=[[User:Ævar Arnfjörð Bjarmason]]
10556 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10557 !! wikitext
10558 {{PAGENAMEE}}
10559 !! html/*
10560 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10561 </p>
10562 !! end
10563
10564 !! test
10565 Magic Word: {{PAGENAMEE}} with metacharacters (T28781)
10566 !! options
10567 title=[[*RFC 1234 http://example.com/]]
10568 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10569 !! wikitext
10570 {{PAGENAMEE}}
10571 !! html/php
10572 <p>&#42;RFC_1234_http&#58;//example.com/
10573 </p>
10574 !! html+tidy
10575 <p>*RFC_1234_http://example.com/</p>
10576 !! end
10577
10578 !! test
10579 Magic Word: {{REVISIONID}}
10580 !! options
10581 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10582 showflags
10583 !! wikitext
10584 {{REVISIONID}}
10585 !! html/*
10586 <p>1337
10587 </p>
10588 flags=vary-revision-id
10589 !! end
10590
10591 !! test
10592 Magic Word: {{SCRIPTPATH}}
10593 !! options
10594 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10595 !! wikitext
10596 {{SCRIPTPATH}}
10597 !! html/*
10598
10599 !! end
10600
10601 !! test
10602 Magic Word: {{STYLEPATH}}
10603 !! options
10604 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10605 !! wikitext
10606 {{STYLEPATH}}
10607 !! html/*
10608 <p>/skins
10609 </p>
10610 !! end
10611
10612 !! test
10613 Magic Word: {{SERVER}}
10614 !! options
10615 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10616 !! wikitext
10617 {{SERVER}}
10618 !! html/*
10619 <p><a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>
10620 </p>
10621 !! end
10622
10623 !! test
10624 Magic Word: {{SERVERNAME}}
10625 !! options
10626 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10627 !! wikitext
10628 {{SERVERNAME}}
10629 !! html/*
10630 <p>example.org
10631 </p>
10632 !! end
10633
10634 !! test
10635 Magic Word: {{SITENAME}}
10636 !! options
10637 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10638 !! wikitext
10639 {{SITENAME}}
10640 !! html/*
10641 <p>MediaWiki
10642 </p>
10643 !! end
10644
10645 !! test
10646 Magic Word: {{PAGELANGUAGE}}
10647 !! options
10648 language=fr
10649 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10650 !! wikitext
10651 {{PAGELANGUAGE}}
10652 !! html/*
10653 <p>fr
10654 </p>
10655 !! end
10656
10657 !! test
10658 Magic Word: {{PAGELANGUAGE}} on a page with no explicitly set language
10659 !! options
10660 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10661 !! wikitext
10662 {{PAGELANGUAGE}}
10663 !! html/*
10664 <p>en
10665 </p>
10666 !! end
10667
10668 !! test
10669 Case-sensitive magic words, when cased differently, should just be template transclusions
10670 !! wikitext
10671 {{CurrentMonth}}
10672 {{currentday}}
10673 {{cURreNTweEK}}
10674 {{currentHour}}
10675 !! html
10676 <p><a href="/index.php?title=Template:CurrentMonth&amp;action=edit&amp;redlink=1" class="new" title="Template:CurrentMonth (page does not exist)">Template:CurrentMonth</a>
10677 <a href="/index.php?title=Template:Currentday&amp;action=edit&amp;redlink=1" class="new" title="Template:Currentday (page does not exist)">Template:Currentday</a>
10678 <a href="/index.php?title=Template:CURreNTweEK&amp;action=edit&amp;redlink=1" class="new" title="Template:CURreNTweEK (page does not exist)">Template:CURreNTweEK</a>
10679 <a href="/index.php?title=Template:CurrentHour&amp;action=edit&amp;redlink=1" class="new" title="Template:CurrentHour (page does not exist)">Template:CurrentHour</a>
10680 </p>
10681 !! end
10682
10683 !! test
10684 Case-insensitive magic words should still work with weird casing.
10685 !! wikitext
10686 {{sErVeRNaMe}}
10687 {{LCFirst:AOEU}}
10688 {{ucFIRST:aoeu}}
10689 {{SERver}}
10690 !! html
10691 <p>example.org
10692 aOEU
10693 Aoeu
10694 <a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>
10695 </p>
10696 !! end
10697
10698 # From plwiki:PLOS_ONE
10699 !! test
10700 Parsoid: Page property magic word with magic word contents
10701 !! wikitext
10702 {{DISPLAYTITLE:''{{PAGENAME}}''}}
10703 !! html/parsoid
10704 <meta property="mw:PageProp/displaytitle" content="Main Page" about="#mwt3" typeof="mw:ExpandedAttrs" data-parsoid='{"src":"{{DISPLAYTITLE:&#39;&#39;{{PAGENAME}}&#39;&#39;}}"}' data-mw='{"attribs":[[{"txt":"content"},{"html":"DISPLAYTITLE:&lt;i data-parsoid=&#39;{\"dsr\":[15,31,2,2]}&#39;>&lt;span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid=&#39;{\"pi\":[[]],\"dsr\":[17,29,null,null]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"PAGENAME\",\"function\":\"pagename\"},\"params\":{},\"i\":0}}]}&#39;>Main Page&lt;/span>&lt;/i>"}]]}'/>
10705 !! end
10706
10707 # NOTE: mw:ExpandedAttrs is not the best typeof here. mw:Transclusion is better.
10708 # But, this is a limitation of our representation and is documented in
10709 # TemplateHandler.js in processSpecialMagicWord
10710 !! test
10711 Parsoid: Template-generated DISPLAYTITLE
10712 !! wikitext
10713 {{{{echo|DISPLAYTITLE}}:Foo}}
10714 !! options
10715 showtitle
10716 !! config
10717 wgAllowDisplayTitle=true
10718 wgRestrictDisplayTitle=false
10719 !! html/php
10720 Foo
10721
10722 !! html/parsoid
10723 <meta property="mw:PageProp/displaytitle" content="Foo" about="#mwt1" typeof="mw:ExpandedAttrs" data-parsoid='{"pi":[[]]}' data-mw='{"attribs":[[{"txt":"content"},{"html":"&lt;span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid=&#39;{\"pi\":[[{\"k\":\"1\"}]],\"dsr\":[2,23,null,null]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"DISPLAYTITLE\"}},\"i\":0}}]}&#39;>DISPLAYTITLE&lt;/span>:Foo"}]]}'/>
10724 !! end
10725
10726 !! test
10727 Namespace 1 {{ns:1}}
10728 !! wikitext
10729 {{ns:1}}
10730 !! html
10731 <p>Talk
10732 </p>
10733 !! end
10734
10735 !! test
10736 Namespace 1 {{ns:01}}
10737 !! wikitext
10738 {{ns:01}}
10739 !! html
10740 <p>Talk
10741 </p>
10742 !! end
10743
10744 !! test
10745 Namespace 0 {{ns:0}} (T6783)
10746 !! wikitext
10747 {{ns:0}}
10748 !! html
10749
10750 !! end
10751
10752 !! test
10753 Namespace 0 {{ns:00}} (T6783)
10754 !! wikitext
10755 {{ns:00}}
10756 !! html
10757
10758 !! end
10759
10760 !! test
10761 Namespace -1 {{ns:-1}}
10762 !! wikitext
10763 {{ns:-1}}
10764 !! html
10765 <p>Special
10766 </p>
10767 !! end
10768
10769 !! test
10770 Namespace User {{ns:User}}
10771 !! wikitext
10772 {{ns:User}}
10773 !! html
10774 <p>User
10775 </p>
10776 !! end
10777
10778 !! test
10779 Namespace User talk {{ns:User_talk}}
10780 !! wikitext
10781 {{ns:User_talk}}
10782 !! html
10783 <p>User talk
10784 </p>
10785 !! end
10786
10787 !! test
10788 Namespace User talk {{ns:uSeR tAlK}}
10789 !! wikitext
10790 {{ns:uSeR tAlK}}
10791 !! html
10792 <p>User talk
10793 </p>
10794 !! end
10795
10796 !! test
10797 Namespace File {{ns:File}}
10798 !! wikitext
10799 {{ns:File}}
10800 !! html
10801 <p>File
10802 </p>
10803 !! end
10804
10805 !! test
10806 Namespace File {{ns:Image}}
10807 !! wikitext
10808 {{ns:Image}}
10809 !! html
10810 <p>File
10811 </p>
10812 !! end
10813
10814 !! test
10815 Namespace (lang=de) Benutzer {{ns:User}}
10816 !! options
10817 language=de
10818 !! wikitext
10819 {{ns:User}}
10820 !! html
10821 <p>Benutzer
10822 </p>
10823 !! end
10824
10825 !! test
10826 Namespace (lang=de) Benutzer Diskussion {{ns:3}}
10827 !! options
10828 language=de
10829 !! wikitext
10830 {{ns:3}}
10831 !! html
10832 <p>Benutzer Diskussion
10833 </p>
10834 !! end
10835
10836 !! test
10837 Urlencode
10838 !! wikitext
10839 {{urlencode:hi world?!}}
10840 {{urlencode:hi world?!|WIKI}}
10841 {{urlencode:hi world?!|PATH}}
10842 {{urlencode:hi world?!|QUERY}}
10843 !! html/php
10844 <p>hi+world%3F%21
10845 hi_world%3F!
10846 hi%20world%3F%21
10847 hi+world%3F%21
10848 </p>
10849 !! end
10850
10851 !! test
10852 Magic Word: prioritize type info over data-parsoid
10853 !! options
10854 parsoid=html2wt
10855 !! html/parsoid
10856 <meta property="mw:PageProp/forcetoc" data-parsoid='{"magicSrc":"__NOTOC__"}'/>
10857 !! wikitext
10858 __FORCETOC__
10859 !! end
10860
10861 !! test
10862 Magic Word: serialize on separate line (parsoid)
10863 !! options
10864 parsoid=wt2wt,html2wt
10865 !! wikitext
10866 foo
10867 __NOTOC__
10868 bar
10869 !! html/parsoid
10870 foo<meta property="mw:PageProp/notoc"/>bar
10871 !! end
10872
10873 !! test
10874 Magic Word: rt non-english wikis
10875 !! options
10876 parsoid=wt2wt
10877 language=de
10878 !! wikitext
10879 __NOEDITSECTION__
10880 !! html/parsoid
10881 <meta property="mw:PageProp/noeditsection" data-parsoid='{"magicSrc":"__NOEDITSECTION__"}'/>
10882 !! end
10883
10884 !!test
10885 __proto__ is treated as normal wikitext (T105997)
10886 !!wikitext
10887 __proto__
10888 !!html
10889 <p>__proto__
10890 </p>
10891 !!end
10892
10893 ###
10894 ### Magic links
10895 ###
10896 !! test
10897 Magic links: internal link to RFC (T2479)
10898 !! wikitext
10899 [[RFC 123]]
10900 !! html/php
10901 <p><a href="/index.php?title=RFC_123&amp;action=edit&amp;redlink=1" class="new" title="RFC 123 (page does not exist)">RFC 123</a>
10902 </p>
10903 !! html/parsoid
10904 <p><a rel="mw:WikiLink" href="./RFC_123" title="RFC 123">RFC 123</a></p>
10905 !! end
10906
10907 !! test
10908 Magic links: RFC (T2479)
10909 !! wikitext
10910 RFC 822
10911 !! html/php
10912 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc822">RFC 822</a>
10913 </p>
10914 !! html/parsoid
10915 <p><a href="//tools.ietf.org/html/rfc822" rel="mw:ExtLink">RFC 822</a></p>
10916 !! end
10917
10918 !! test
10919 Magic links: RFC (T67278)
10920 !! wikitext
10921 This is RFC 822 but thisRFC 822 is not RFC 822linked.
10922 !! html/php
10923 <p>This is <a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc822">RFC 822</a> but thisRFC 822 is not RFC 822linked.
10924 </p>
10925 !! html/parsoid
10926 <p>This is <a href="//tools.ietf.org/html/rfc822" rel="mw:ExtLink">RFC 822</a> but thisRFC 822 is not RFC 822linked.</p>
10927 !! end
10928
10929 !! test
10930 Magic links: RFC (w/ non-newline whitespace, T30950/T31025)
10931 !! wikitext
10932 RFC &nbsp;&#160;&#0160;&#xA0;&#Xa0; 822
10933 RFC
10934 822
10935 !! html/php
10936 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc822">RFC 822</a>
10937 RFC
10938 822
10939 </p>
10940 !! html/parsoid
10941 <p><a href="//tools.ietf.org/html/rfc822" rel="mw:ExtLink">RFC <span typeof="mw:Entity" data-parsoid='{"src":"&amp;nbsp;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#160;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#0160;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#xA0;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#Xa0;","srcContent":" "}'> </span> 822</a>
10942 RFC
10943 822</p>
10944 !! end
10945
10946 !! test
10947 Magic links: ISBN (T3937)
10948 !! wikitext
10949 ISBN 0-306-40615-2
10950 !! html/php
10951 <p><a href="/wiki/Special:BookSources/0306406152" class="internal mw-magiclink-isbn">ISBN 0-306-40615-2</a>
10952 </p>
10953 !! html/parsoid
10954 <p><a href="./Special:BookSources/0306406152" rel="mw:WikiLink">ISBN 0-306-40615-2</a></p>
10955 !! end
10956
10957 !! test
10958 Magic links: ISBN (T67278)
10959 !! wikitext
10960 This is ISBN 978-0-316-09811-3 but thisISBN 978-0-316-09811-3 is not ISBN 978-0-316-09811-3linked.
10961 !! html/php
10962 <p>This is <a href="/wiki/Special:BookSources/9780316098113" class="internal mw-magiclink-isbn">ISBN 978-0-316-09811-3</a> but thisISBN 978-0-316-09811-3 is not ISBN 978-0-316-09811-3linked.
10963 </p>
10964 !! html/parsoid
10965 <p>This is <a href="./Special:BookSources/9780316098113" rel="mw:WikiLink">ISBN 978-0-316-09811-3</a> but thisISBN 978-0-316-09811-3 is not ISBN 978-0-316-09811-3linked.</p>
10966 !! end
10967
10968 !! test
10969 Magic links: ISBN (w/ non-newline whitespace, T30950/T31025)
10970 !! wikitext
10971 ISBN &nbsp;&#160;&#0160;&#xA0;&#Xa0; 978&nbsp;0&#160;316&#0160;09811&#xA0;3
10972 ISBN
10973 9780316098113
10974 ISBN 978
10975 0316098113
10976 !! html/php
10977 <p><a href="/wiki/Special:BookSources/9780316098113" class="internal mw-magiclink-isbn">ISBN 978 0 316 09811 3</a>
10978 ISBN
10979 9780316098113
10980 ISBN 978
10981 0316098113
10982 </p>
10983 !! html/parsoid
10984 <p><a href="./Special:BookSources/9780316098113" rel="mw:WikiLink">ISBN <span typeof="mw:Entity" data-parsoid='{"src":"&amp;nbsp;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#160;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#0160;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#xA0;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#Xa0;","srcContent":" "}'> </span> 978<span typeof="mw:Entity" data-parsoid='{"src":"&amp;nbsp;","srcContent":" "}'> </span>0<span typeof="mw:Entity" data-parsoid='{"src":"&amp;#160;","srcContent":" "}'> </span>316<span typeof="mw:Entity" data-parsoid='{"src":"&amp;#0160;","srcContent":" "}'> </span>09811<span typeof="mw:Entity" data-parsoid='{"src":"&amp;#xA0;","srcContent":" "}'> </span>3</a>
10985 ISBN
10986 9780316098113
10987 ISBN 978
10988 0316098113</p>
10989 !! end
10990
10991 !! test
10992 Magic links: PMID incorrectly converts space to underscore
10993 !! wikitext
10994 PMID 1234
10995 !! html/php
10996 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a>
10997 </p>
10998 !! html/parsoid
10999 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract" rel="mw:ExtLink">PMID 1234</a></p>
11000 !! end
11001
11002 !! test
11003 Magic links: PMID (T67278)
11004 !! wikitext
11005 This is PMID 1234 but thisPMID 1234 is not PMID 1234linked.
11006 !! html/php
11007 <p>This is <a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a> but thisPMID 1234 is not PMID 1234linked.
11008 </p>
11009 !! html/parsoid
11010 <p>This is <a href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract" rel="mw:ExtLink">PMID 1234</a> but thisPMID 1234 is not PMID 1234linked.</p>
11011 !! end
11012
11013 !! test
11014 Magic links: PMID (w/ non-newline whitespace, T30950/T31025)
11015 !! wikitext
11016 PMID &nbsp;&#160;&#0160;&#xA0;&#Xa0; 1234
11017 PMID
11018 1234
11019 !! html/php
11020 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a>
11021 PMID
11022 1234
11023 </p>
11024 !! html/parsoid
11025 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract" rel="mw:ExtLink">PMID <span typeof="mw:Entity" data-parsoid='{"src":"&amp;nbsp;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#160;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#0160;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#xA0;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#Xa0;","srcContent":" "}'> </span> 1234</a>
11026 PMID
11027 1234</p>
11028 !! end
11029
11030 # <nowiki> nodes shouldn't be inserted during html2wt by Parsoid,
11031 # since these are ExtLinkText, not MagicLinkText
11032 !! test
11033 Magic links: use appropriate serialization for "almost" magic links.
11034 !! wikitext
11035 X[[Special:BookSources/0978739256|foo]]
11036
11037 X[//tools.ietf.org/html/rfc1234 foo]
11038 !! html/php
11039 <p>X<a href="/wiki/Special:BookSources/0978739256" title="Special:BookSources/0978739256">foo</a>
11040 </p><p>X<a rel="nofollow" class="external text" href="//tools.ietf.org/html/rfc1234">foo</a>
11041 </p>
11042 !! html/parsoid
11043 <p>X<a rel="mw:WikiLink" href="./Special:BookSources/0978739256" title="Special:BookSources/0978739256">foo</a></p>
11044 <p>X<a rel="mw:ExtLink" href="//tools.ietf.org/html/rfc1234">foo</a></p>
11045 !! end
11046
11047 !! test
11048 Magic links: All disabled (T47942)
11049 !! options
11050 wgEnableMagicLinks={"ISBN":false, "PMID":false, "RFC":false}
11051 !! wikitext
11052 ISBN 0-306-40615-2
11053 PMID 1234
11054 RFC 4321
11055 !! html/php
11056 <p>ISBN 0-306-40615-2
11057 PMID 1234
11058 RFC 4321
11059 </p>
11060 !! end
11061
11062 ###
11063 ### Templates
11064 ####
11065
11066 !! test
11067 Nonexistent template
11068 !! wikitext
11069 {{thistemplatedoesnotexist}}
11070 !! html
11071 <p><a href="/index.php?title=Template:Thistemplatedoesnotexist&amp;action=edit&amp;redlink=1" class="new" title="Template:Thistemplatedoesnotexist (page does not exist)">Template:Thistemplatedoesnotexist</a>
11072 </p>
11073 !! end
11074
11075 !! test
11076 Template with invalid target containing tags
11077 !! wikitext
11078 {{a<b>b</b>|{{echo|foo}}|{{echo|a}}={{echo|b}}|a = b}}
11079 !! html
11080 <p>{{a<b>b</b>|foo|a=b|a = b}}
11081 </p>
11082 !! end
11083
11084 !! test
11085 Template with invalid target containing unclosed tag
11086 !! wikitext
11087 {{a<b>|{{echo|foo}}|{{echo|a}}={{echo|b}}|a = b}}
11088 !! html
11089 <p>{{a<b>|foo|a=b|a = b}}</b>
11090 </p>
11091 !! end
11092
11093 !! test
11094 Template with invalid target containing wikilink
11095 !! wikitext
11096 {{[[Main Page]]}}
11097 !! html/php
11098 <p>{{<a href="/wiki/Main_Page" title="Main Page">Main Page</a>}}
11099 </p>
11100 !! html/parsoid
11101 <p><span typeof="mw:Transclusion" about="#mwt1" data-mw='{"parts":[{"template":{"target":{"wt":"[[Main Page]]"},"params":{},"i":0}}]}'>{{</span><a rel="mw:WikiLink" href="./Main_Page" about="#mwt1">Main Page</a><span about="#mwt1">}}</span></p>
11102 !! end
11103
11104 !! test
11105 Template with just whitespace in it, T70421
11106 !! wikitext
11107 {{echo|{{ }}}}
11108 !! html/parsoid
11109 <p about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"{{ }}"}},"i":0}}]}'>{{ }}</p>
11110 !! end
11111
11112 !! article
11113 Template:test
11114 !! text
11115 This is a test template
11116 !! endarticle
11117
11118 !! test
11119 Simple template
11120 !! wikitext
11121 {{test}}
11122 !! html
11123 <p>This is a test template
11124 </p>
11125 !! end
11126
11127 !! test
11128 Template with explicit namespace
11129 !! wikitext
11130 {{Template:test}}
11131 !! html
11132 <p>This is a test template
11133 </p>
11134 !! end
11135
11136
11137 !! article
11138 Template:paramtest
11139 !! text
11140 This is a test template with parameter {{{param}}}
11141 !! endarticle
11142
11143 !! test
11144 Template parameter
11145 !! wikitext
11146 {{paramtest|param=foo}}
11147 !! html
11148 <p>This is a test template with parameter foo
11149 </p>
11150 !! end
11151
11152 !! article
11153 Template:paramtestnum
11154 !! text
11155 [[{{{1}}}|{{{2}}}]]
11156 !! endarticle
11157
11158 !! test
11159 Template unnamed parameter
11160 !! wikitext
11161 {{paramtestnum|Main Page|the main page}}
11162 !! html
11163 <p><a href="/wiki/Main_Page" title="Main Page">the main page</a>
11164 </p>
11165 !! end
11166
11167 !! article
11168 Template:templatesimple
11169 !! text
11170 (test)
11171 !! endarticle
11172
11173 !! article
11174 Template:templateredirect
11175 !! text
11176 #redirect [[Template:templatesimple]]
11177 !! endarticle
11178
11179 !! article
11180 Template:templateasargtestnum
11181 !! text
11182 {{{{{1}}}}}
11183 !! endarticle
11184
11185 !! article
11186 Template:templateasargtest
11187 !! text
11188 {{template{{{templ}}}}}
11189 !! endarticle
11190
11191 !! article
11192 Template:templateasargtest2
11193 !! text
11194 {{{{{templ}}}}}
11195 !! endarticle
11196
11197 !! test
11198 Template with template name as unnamed argument
11199 !! wikitext
11200 {{templateasargtestnum|templatesimple}}
11201 !! html
11202 <p>(test)
11203 </p>
11204 !! end
11205
11206 !! test
11207 Template with template name as argument
11208 !! wikitext
11209 {{templateasargtest|templ=simple}}
11210 !! html
11211 <p>(test)
11212 </p>
11213 !! end
11214
11215 !! test
11216 Template with template name as argument (2)
11217 !! wikitext
11218 {{templateasargtest2|templ=templatesimple}}
11219 !! html
11220 <p>(test)
11221 </p>
11222 !! end
11223
11224 !! article
11225 Template:templateasargtestdefault
11226 !! text
11227 {{{{{templ|templatesimple}}}}}
11228 !! endarticle
11229
11230 !! article
11231 Template:templa
11232 !! text
11233 '''templ'''
11234 !! endarticle
11235
11236 !! test
11237 Template with default value
11238 !! wikitext
11239 {{templateasargtestdefault}}
11240 !! html
11241 <p>(test)
11242 </p>
11243 !! end
11244
11245 !! test
11246 Template with default value (value set)
11247 !! wikitext
11248 {{templateasargtestdefault|templ=templa}}
11249 !! html
11250 <p><b>templ</b>
11251 </p>
11252 !! end
11253
11254 !! test
11255 Template redirect
11256 !! wikitext
11257 {{templateredirect}}
11258 !! html/php
11259 <p>(test)
11260 </p>
11261 !! html/parsoid
11262 <link rel="mw:PageProp/redirect" href="./Template:Templatesimple" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"templateredirect","href":"./Template:Templateredirect"},"params":{},"i":0}}]}'/>
11263 !! end
11264
11265 !! test
11266 Template with argument in separate line
11267 !! wikitext
11268 {{ templateasargtest |
11269 templ = simple }}
11270 !! html
11271 <p>(test)
11272 </p>
11273 !! end
11274
11275 !! test
11276 Template with complex template as argument
11277 !! wikitext
11278 {{paramtest|
11279 param ={{ templateasargtest |
11280 templ = simple }}}}
11281 !! html
11282 <p>This is a test template with parameter (test)
11283 </p>
11284 !! end
11285
11286 !! test
11287 Templates with templated name
11288 !! wikitext
11289 {{{{echo|echo}}|foo}}
11290 {{{{echo|inner list}} }}
11291 !! html
11292 <p>foo
11293 </p>
11294 <ul><li> item 1</li></ul>
11295
11296 !! html/parsoid
11297 <p about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"{{echo|echo}}","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</p>
11298 <ul about="#mwt4" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"{{echo|inner list}} ","href":"./Template:Inner_list"},"params":{},"i":0}}]}'><li> item 1</li></ul>
11299 !! end
11300
11301 # Parsoid markup is deliberate "broken". This is an edge case.
11302 # See long comment in TemplateHandler.js:convertAttribsToString.
11303 !! test
11304 Templates with invalid templated targets
11305 !! wikitext
11306 {{echo
11307 {{echo|foo}}
11308 }}
11309 !! html/php
11310 <p>{{echo
11311 foo
11312 }}
11313 </p>
11314 !! html/parsoid
11315 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo\n{{echo|foo}}\n"},"params":{},"i":0}}]}'>{{echo
11316 foo }}</p>
11317 !! end
11318
11319 !! test
11320 Template with thumb image (with link in description)
11321 !! wikitext
11322 {{paramtest|param=[[Image:noimage.png|thumb|[[no link|link]] [[no link|caption]]]]}}
11323 !! html/php
11324 This is a test template with parameter <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/index.php?title=Special:Upload&amp;wpDestFile=Noimage.png" class="new" title="File:Noimage.png">File:Noimage.png</a> <div class="thumbcaption"><a href="/index.php?title=No_link&amp;action=edit&amp;redlink=1" class="new" title="No link (page does not exist)">link</a> <a href="/index.php?title=No_link&amp;action=edit&amp;redlink=1" class="new" title="No link (page does not exist)">caption</a></div></div></div>
11325
11326 !! html+tidy
11327 <p>This is a test template with parameter</p>
11328 <div class="thumb tright">
11329 <div class="thumbinner" style="width:182px;"><a href="/index.php?title=Special:Upload&amp;wpDestFile=Noimage.png" class="new" title="File:Noimage.png">File:Noimage.png</a>
11330 <div class="thumbcaption"><a href="/index.php?title=No_link&amp;action=edit&amp;redlink=1" class="new" title="No link (page does not exist)">link</a> <a href="/index.php?title=No_link&amp;action=edit&amp;redlink=1" class="new" title="No link (page does not exist)">caption</a></div>
11331 </div>
11332 </div>
11333 !! html/parsoid
11334 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"paramtest","href":"./Template:Paramtest"},"params":{"param":{"wt":"[[Image:noimage.png|thumb|[[no link|link]] [[no link|caption]]]]"}},"i":0}}]}'>This is a test template with parameter </p><figure class="mw-default-size" typeof="mw:Error mw:Image/Thumb" about="#mwt1" data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}]}'><a href="./File:Noimage.png" ><img resource="./File:Noimage.png" src="./Special:FilePath/Noimage.png" height="220" width="220"/></a><figcaption><a rel="mw:WikiLink" href="./No_link" title="No link">link</a> <a rel="mw:WikiLink" href="./No_link" title="No link">caption</a></figcaption></figure>
11335 !! end
11336
11337 !! article
11338 Template:complextemplate
11339 !! text
11340 {{{1}}} {{paramtest|
11341 param ={{{param}}}}}
11342 !! endarticle
11343
11344 !! test
11345 Template with complex arguments
11346 !! wikitext
11347 {{complextemplate|
11348 param ={{ templateasargtest |
11349 templ = simple }}|[[Template:complextemplate|link]]}}
11350 !! html
11351 <p><a href="/wiki/Template:Complextemplate" title="Template:Complextemplate">link</a> This is a test template with parameter (test)
11352 </p>
11353 !! end
11354
11355 !! test
11356 T2553: link with two variables in a piped link
11357 !! wikitext
11358 {|
11359 |[[{{{1}}}|{{{2}}}]]
11360 |}
11361 !! html/php
11362 <table>
11363 <tr>
11364 <td>[[{{{1}}}|{{{2}}}]]
11365 </td></tr></table>
11366
11367 !! html/parsoid
11368 <table>
11369 <tbody><tr><td>[[<span about="#mwt5" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"1"},"params":{},"i":0}}]}'>{{{1}}}</span>|<span about="#mwt2" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"2"},"params":{},"i":0}}]}'>{{{2}}}</span>]]</td></tr>
11370 </tbody></table>
11371 !! end
11372
11373 # See: T2553
11374 !! test
11375 Abort table cell attribute parsing on wikilink
11376 !! wikitext
11377 {|
11378 | testing [[one|two]] | three || four
11379 | testing one two | three || four
11380 | testing="[[one|two]]" | three || four
11381 |}
11382 !! html/php
11383 <table>
11384 <tr>
11385 <td> testing <a href="/index.php?title=One&amp;action=edit&amp;redlink=1" class="new" title="One (page does not exist)">two</a> | three </td>
11386 <td> four
11387 </td>
11388 <td> three </td>
11389 <td> four
11390 </td>
11391 <td> testing="<a href="/index.php?title=One&amp;action=edit&amp;redlink=1" class="new" title="One (page does not exist)">two</a>" | three </td>
11392 <td> four
11393 </td></tr></table>
11394
11395 !! html/parsoid
11396 <table>
11397 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'> testing <a rel="mw:WikiLink" href="./One" title="One" data-parsoid='{"stx":"piped","a":{"href":"./One"},"sa":{"href":"one"}}'>two</a> | three </td><td data-parsoid='{"stx_v":"row","autoInsertedEnd":true}'> four</td>
11398 <td data-parsoid='{"a":{"testing":null,"one":null,"two":null},"sa":{"testing":"","one":"","two":""},"autoInsertedEnd":true}'> three </td><td data-parsoid='{"stx_v":"row","autoInsertedEnd":true}'> four</td>
11399 <td> testing="<a rel="mw:WikiLink" href="./One" title="One" data-parsoid='{"stx":"piped","a":{"href":"./One"},"sa":{"href":"one"}}'>two</a>" | three </td><td data-parsoid='{"stx_v":"row","autoInsertedEnd":true}'> four</td></tr>
11400 </tbody></table>
11401 !! end
11402
11403 !! test
11404 Don't abort table cell attribute parsing if wikilink is found in template arg
11405 !! wikitext
11406 {|
11407 | Test {{#tag:ref|One two "[[three]]" four}}
11408 |}
11409 !! html/parsoid
11410 <table>
11411 <tbody><tr><td> Test <ref about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"#tag:ref","function":"tag"},"params":{"1":{"wt":"One two \"[[three]]\" four"}},"i":0}}]}'>One two "<a rel="mw:WikiLink" href="./Three" title="Three">three</a>" four</ref></td></tr>
11412 </tbody></table>
11413 !! end
11414
11415 !! test
11416 Magic variable as template parameter
11417 !! wikitext
11418 {{paramtest|param={{SITENAME}}}}
11419 !! html
11420 <p>This is a test template with parameter MediaWiki
11421 </p>
11422 !! end
11423
11424 !! article
11425 Template:linktest
11426 !! text
11427 [[{{{param}}}|link]]
11428 !! endarticle
11429
11430 !! test
11431 Template parameter as link source
11432 !! wikitext
11433 {{linktest|param=Main Page}}
11434 !! html
11435 <p><a href="/wiki/Main_Page" title="Main Page">link</a>
11436 </p>
11437 !! end
11438
11439 !!article
11440 Template:paramtest2
11441 !! text
11442 including another template, {{paramtest|param={{{arg}}}}}
11443 !! endarticle
11444
11445 !! test
11446 Template passing argument to another template
11447 !! wikitext
11448 {{paramtest2|arg='hmm'}}
11449 !! html
11450 <p>including another template, This is a test template with parameter 'hmm'
11451 </p>
11452 !! end
11453
11454 !! article
11455 Template:Linktest2
11456 !! text
11457 Main Page
11458 !! endarticle
11459
11460 !! test
11461 Template as link source
11462 !! wikitext
11463 [[{{linktest2}}]]
11464
11465 [[{{linktest2}}|Main Page]]
11466
11467 [[{{linktest2}}]]Page
11468 !! html
11469 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
11470 </p><p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
11471 </p><p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>Page
11472 </p>
11473 !! end
11474
11475
11476 !! article
11477 Template:loop1
11478 !! text
11479 {{loop2}}
11480 !! endarticle
11481
11482 !! article
11483 Template:loop2
11484 !! text
11485 {{loop1}}
11486 !! endarticle
11487
11488 !! test
11489 Template infinite loop
11490 !! wikitext
11491 {{loop1}}
11492 !! html
11493 <p><span class="error">Template loop detected: <a href="/wiki/Template:Loop1" title="Template:Loop1">Template:Loop1</a></span>
11494 </p>
11495 !! end
11496
11497 !! test
11498 Template from main namespace
11499 !! wikitext
11500 {{:Main Page}}
11501 !! html
11502 <p>blah blah
11503 </p>
11504 !! end
11505
11506 !! article
11507 Template:table
11508 !! text
11509 {|
11510 | 1 || 2
11511 |-
11512 | 3 || 4
11513 |}
11514 !! endarticle
11515
11516 !! test
11517 T2529: Template with table, not included at beginning of line
11518 !! wikitext
11519 foo {{table}}
11520 !! html
11521 <p>foo
11522 </p>
11523 <table>
11524 <tr>
11525 <td> 1 </td>
11526 <td> 2
11527 </td></tr>
11528 <tr>
11529 <td> 3 </td>
11530 <td> 4
11531 </td></tr></table>
11532
11533 !! end
11534
11535 !! test
11536 T2523: Template shouldn't eat newline (or add an extra one before table)
11537 !! wikitext
11538 foo
11539 {{table}}
11540 !! html
11541 <p>foo
11542 </p>
11543 <table>
11544 <tr>
11545 <td> 1 </td>
11546 <td> 2
11547 </td></tr>
11548 <tr>
11549 <td> 3 </td>
11550 <td> 4
11551 </td></tr></table>
11552
11553 !! end
11554
11555 !! test
11556 T2041: Template parameters shown as broken links
11557 !! wikitext
11558 {{{parameter}}}
11559 !! html
11560 <p>{{{parameter}}}
11561 </p>
11562 !! end
11563
11564 !! test
11565 Template with targets containing wikilinks
11566 !! options
11567 parsoid=wt2html
11568 !! wikitext
11569 {{[[foo]]}}
11570
11571 {{[[{{echo|foo}}]]}}
11572
11573 {{{{echo|[[foo}}]]}}
11574 !! html/php
11575 <p>{{<a href="/wiki/Foo" title="Foo">foo</a>}}
11576 </p><p>{{<a href="/wiki/Foo" title="Foo">foo</a>}}
11577 </p><p>{{[[foo}}]]
11578 </p>
11579 !! html/parsoid
11580 <p>{{<a rel="mw:WikiLink" href="./Foo" title="Foo">foo</a>}}</p>
11581 <p>{{<a typeof="mw:ExpandedAttrs" rel="mw:WikiLink" href="./Foo" title="Foo" data-mw='{"attribs":[[{"txt":"href"},{"html":"&lt;span about=\"#mwt3\" typeof=\"mw:Transclusion\" data-parsoid=&#39;{\"pi\":[[{\"k\":\"1\"}]],\"dsr\":[17,29,null,null]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"foo\"}},\"i\":0}}]}&#39;>foo&lt;/span>"}]]}'>foo</a>}}</p>
11582 <p>{{<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[foo}}]]"}},"i":0}}]}'>[[foo}}]]</span></p>
11583 !! end
11584
11585 !! article
11586 Template:''
11587 !! text
11588 bar
11589 !! endarticle
11590
11591 !! test
11592 Templates: Double quotes as template target
11593 !! wikitext
11594 foo {{''}} baz
11595 !! html/php
11596 <p>foo bar baz
11597 </p>
11598 !! html/parsoid
11599 <p>foo <span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"&#39;&#39;","href":"./Template:&#39;&#39;"},"params":{},"i":0}}]}'>bar</span> baz
11600 </p>
11601 !! end
11602
11603 ## This test is about making sure Parsoid's data-mw is well formed in the
11604 ## face of multiple templates with intersecting and overlapping ranges. The
11605 ## wikitext itself is wretched.
11606 !! test
11607 Templates with intersecting and overlapping ranges
11608 !! wikitext
11609 {|{{echo|
11610 <p>ha</p>}}
11611 {|{{echo|
11612 <p>ho</p>}}
11613 {{echo|{{!}}hi}}
11614 |}
11615 !! html/php+tidy
11616 <p>ha</p>
11617 <p>ho</p>
11618 <table>
11619 <tr>
11620 <td></td>
11621 </tr>
11622 <tr>
11623 <td>hi</td>
11624 </tr>
11625 </table>
11626 <table>
11627 <tr>
11628 <td></td>
11629 </tr>
11630 </table>
11631 !! html/parsoid
11632 <p about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"stx":"html","autoInsertedEnd":true,"pi":[[{"k":"1"}],[{"k":"1"}],[{"k":"1"}]],"firstWikitextNode":"table"}' data-mw='{"parts":["{|",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"\n&lt;p>ha&lt;/p>"}},"i":0}},"\n","{|",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"\n&lt;p>ho&lt;/p>"}},"i":1}},"\n",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"{{!}}hi"}},"i":2}},"\n|}"]}'>ha</p><table about="#mwt1" typeof="mw:ExpandedAttrs" data-mw='{"attribs":[[{"txt":"","html":""},{"html":""}]]}'>
11633
11634 </table><p about="#mwt1">ho</p><table about="#mwt1" typeof="mw:ExpandedAttrs" data-mw='{"attribs":[[{"txt":"","html":""},{"html":""}]]}'>
11635
11636 <tbody><tr><td>hi</td></tr>
11637 </tbody></table>
11638 !! end
11639
11640 !! article
11641 Template:MSGNW test
11642 !! text
11643 ''None'' of '''this''' should be
11644 * interpreted
11645 but rather passed unmodified
11646 {{test}}
11647 <gallery>
11648 File:Foobar.jpg
11649 </gallery>
11650 <!-- comment -->
11651 !! endarticle
11652
11653 # hmm, fix this or just deprecate msgnw and document its behavior?
11654 !! test
11655 msgnw keyword
11656 !! wikitext
11657 {{msgnw:MSGNW test}}
11658 !! html/php
11659 <p>&#39;&#39;None&#39;&#39; of &#39;&#39;&#39;this&#39;&#39;&#39; should be
11660 &#42; interpreted
11661 &#32;but rather passed unmodified
11662 &#123;&#123;test&#125;&#125;
11663 &#60;gallery&#62;
11664 File:Foobar.jpg
11665 &#60;/gallery&#62;
11666 &#60;!-- comment --&#62;
11667 </p>
11668 !! end
11669
11670 !! test
11671 int keyword
11672 !! wikitext
11673 {{int:youhavenewmessages|lots of money|not!}}
11674 !! html
11675 <p>You have lots of money (not!).
11676 </p>
11677 !! end
11678
11679 !! test
11680 int keyword - non-existing message
11681 !! wikitext
11682 {{int:var}}
11683 !! html
11684 <p>⧼var⧽
11685 </p>
11686 !! end
11687
11688 !! article
11689 Template:Includes
11690 !! text
11691 Foo<noinclude>zar</noinclude><includeonly>bar</includeonly>
11692 !! endarticle
11693
11694 !! test
11695 <includeonly> and <noinclude> being included
11696 !! wikitext
11697 {{Includes}}
11698 !! html
11699 <p>Foobar
11700 </p>
11701 !! end
11702
11703 !! article
11704 Template:Includes2
11705 !! text
11706 <onlyinclude>Foo</onlyinclude>bar
11707 !! endarticle
11708
11709 !! test
11710 <onlyinclude> being included
11711 !! wikitext
11712 {{Includes2}}
11713 !! html
11714 <p>Foo
11715 </p>
11716 !! end
11717
11718
11719 !! article
11720 Template:Includes3
11721 !! text
11722 <onlyinclude>Foo</onlyinclude>bar<includeonly>zar</includeonly>
11723 !! endarticle
11724
11725 !! test
11726 <onlyinclude> and <includeonly> being included
11727 !! wikitext
11728 {{Includes3}}
11729 !! html
11730 <p>Foo
11731 </p>
11732 !! end
11733
11734 !! test
11735 <includeonly> and <noinclude> on a page
11736 !! wikitext
11737 Foo<noinclude>zar</noinclude><includeonly>bar</includeonly>
11738 !! html
11739 <p>Foozar
11740 </p>
11741 !! end
11742
11743 !! test
11744 Un-closed <noinclude>
11745 !! wikitext
11746 <noinclude>
11747 !! html
11748 !! end
11749
11750 !! test
11751 <onlyinclude> on a page
11752 !! wikitext
11753 <onlyinclude>Foo</onlyinclude>bar
11754 !! html
11755 <p>Foobar
11756 </p>
11757 !! end
11758
11759 !! test
11760 Un-closed <onlyinclude>
11761 !! wikitext
11762 <onlyinclude>
11763 !! html
11764 !! end
11765
11766 !!test
11767 Self-closed noinclude, includeonly, onlyinclude tags
11768 !! wikitext
11769 <noinclude />
11770 <includeonly />
11771 <onlyinclude />
11772 !! html
11773 <p><br />
11774 </p>
11775 !!end
11776
11777 !!test
11778 Unbalanced includeonly and noinclude tags
11779 !! wikitext
11780 {|
11781 |a</noinclude>
11782 |b</noinclude></noinclude>
11783 |c</noinclude></includeonly>
11784 |d</includeonly></includeonly>
11785 |}
11786 !! html
11787 <table>
11788 <tr>
11789 <td>a
11790 </td>
11791 <td>b
11792 </td>
11793 <td>c&lt;/includeonly&gt;
11794 </td>
11795 <td>d&lt;/includeonly&gt;&lt;/includeonly&gt;
11796 </td></tr></table>
11797
11798 !!end
11799
11800 !! article
11801 Template:Includeonly section
11802 !! text
11803 <includeonly>
11804 ==Includeonly section==
11805 </includeonly>
11806 ==Section T-1==
11807 !!endarticle
11808
11809 !! test
11810 T8563: Edit link generation for section shown by <includeonly>
11811 !! wikitext
11812 {{includeonly section}}
11813 !! html
11814 <h2><span class="mw-headline" id="Includeonly_section">Includeonly section</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Template:Includeonly_section&amp;action=edit&amp;section=T-1" title="Template:Includeonly section">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
11815 <h2><span class="mw-headline" id="Section_T-1">Section T-1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Template:Includeonly_section&amp;action=edit&amp;section=T-2" title="Template:Includeonly section">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
11816
11817 !! end
11818
11819 # Uses same input as the contents of [[Template:Includeonly section]]
11820 !! test
11821 T8563: Section extraction for section shown by <includeonly>
11822 !! options
11823 section=T-2
11824 !! wikitext
11825 <includeonly>
11826 ==Includeonly section==
11827 </includeonly>
11828 ==Section T-2==
11829 !! html
11830 ==Section T-2==
11831 !! end
11832
11833 !! test
11834 T8563: Edit link generation for section suppressed by <includeonly>
11835 !! wikitext
11836 <includeonly>
11837 ==Includeonly section==
11838 </includeonly>
11839 ==Section 1==
11840 !! html
11841 <h2><span class="mw-headline" id="Section_1">Section 1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: Section 1">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
11842
11843 !! end
11844
11845 !! test
11846 T8563: Section extraction for section suppressed by <includeonly>
11847 !! options
11848 section=1
11849 !! wikitext
11850 <includeonly>
11851 ==Includeonly section==
11852 </includeonly>
11853 ==Section 1==
11854 !! html
11855 ==Section 1==
11856 !! end
11857
11858 !! test
11859 Un-closed <includeonly>
11860 !! wikitext
11861 <includeonly>
11862 !! html/php
11863 !! html/parsoid
11864 <meta typeof="mw:Includes/IncludeOnly" data-parsoid='{"src":"&lt;includeonly>"}'/>
11865 !! end
11866
11867 ## We used to, but no longer wt2wt this test since the default serializer
11868 ## will normalize the include directives to serialize on their own line.
11869 ## Selser will take care of preserving formatting in scenarios where they
11870 ## intermingled with other wikitext.
11871 !! test
11872 Includes and comments at SOL
11873 !! options
11874 parsoid=wt2html,html2html
11875 !! wikitext
11876 <!-- comment --><noinclude><!-- comment --></noinclude><!-- comment -->== hu ==
11877
11878 <noinclude>
11879 some
11880 </noinclude>* stuff
11881 * here
11882
11883 <includeonly>can have stuff</includeonly>=== here ===
11884
11885 !! html/php
11886 <h2><span class="mw-headline" id="hu">hu</span></h2>
11887 <p>some
11888 </p>
11889 <ul><li> stuff</li>
11890 <li> here</li></ul>
11891 <h3><span class="mw-headline" id="here">here</span></h3>
11892
11893 !! html/parsoid
11894 <!-- comment --><meta typeof="mw:Includes/NoInclude" data-parsoid='{"src":"&lt;noinclude>"}'/><!-- comment --><meta typeof="mw:Includes/NoInclude/End" data-parsoid='{"src":"&lt;/noinclude>"}'/><!-- comment --><h2> hu </h2>
11895
11896 <meta typeof="mw:Includes/NoInclude" data-parsoid='{"src":"&lt;noinclude>"}'/>
11897 <p>some</p>
11898 <meta typeof="mw:Includes/NoInclude/End" data-parsoid='{"src":"&lt;/noinclude>"}'/><ul><li> stuff</li>
11899 <li> here</li></ul>
11900
11901 <meta typeof="mw:Includes/IncludeOnly" data-parsoid='{"src":"&lt;includeonly>can have stuff&lt;/includeonly>"}'/><meta typeof="mw:Includes/IncludeOnly/End" data-parsoid='{"src":""}'/><h3> here </h3>
11902
11903 !! end
11904
11905 # TODO: test with DOM fragment reuse!
11906 !! test
11907 Parsoid: DOM fragment reuse
11908 !! options
11909 parsoid=wt2wt,wt2html
11910 !! wikitext
11911 a{{echo|b<table></table>c}}d
11912
11913 a{{echo|b
11914 <table></table>
11915 c}}d
11916
11917 {{echo|a
11918
11919 <table></table>
11920
11921 b}}
11922 !! html
11923 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":["a",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"b&lt;table>&lt;/table>c"}},"i":0}},"d"]}' data-parsoid='{"pi":[[{"k":"1"}]]}'>ab</p><table about="#mwt1" data-parsoid='{"stx":"html"}'></table><p about="#mwt1">cd</p>
11924
11925 <p about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":["a",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"b\n&lt;table>&lt;/table>\nc"}},"i":0}},"d"]}' data-parsoid='{"pi":[[{"k":"1"}]]}'>ab</p><span about="#mwt2">
11926 </span><table about="#mwt2" data-parsoid='{"stx":"html"}'></table><span about="#mwt2">
11927 </span><p about="#mwt2">cd</p>
11928
11929 <p about="#mwt3" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"a\n\n&lt;table>&lt;/table>\n\nb"}},"i":0}}]}' data-parsoid='{"pi":[[{"k":"1"}]]}'>a</p><span about="#mwt3">
11930
11931 </span><table about="#mwt3" data-parsoid='{"stx":"html"}'></table><span about="#mwt3">
11932
11933 </span><p about="#mwt3">b</p>
11934 !! end
11935
11936 !! test
11937 Parsoid: Merge double tds (T52603)
11938 !! options
11939 parsoid
11940 !! wikitext
11941 {|
11942 |{{echo|{{!}} foo}}
11943 |}
11944 !! html
11945 <table><tbody>
11946 <tr><td about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":["|",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"{{!}} foo"}},"i":0}}]}'> foo</td></tr>
11947 </tbody></table>
11948 !! end
11949
11950 !! test
11951 Parsoid: Merge double tds in nested transclusion content (T52603)
11952 !! options
11953 parsoid
11954 !! wikitext
11955 {{echo|<div>}}
11956 {|
11957 |{{echo|{{!}} foo}}
11958 |}
11959 {{echo|</div>}}
11960 !! html
11961 <div about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"<div>"}},"i":0}},"\n{|\n|",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"{{!}} foo"}},"i":1}},"\n|}\n",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"</div>"}},"i":2}}]}'>
11962 <table><tbody>
11963 <tr><td data-mw='{"parts":["|"]}'> foo</td></tr>
11964 </tbody></table>
11965 </div>
11966 !! end
11967
11968 ###
11969 ### <includeonly> and <noinclude> in attributes
11970 ###
11971 !!test
11972 0. includeonly around the entire attribute
11973 !! wikitext
11974 <span <includeonly>id="v1"</includeonly><noinclude>id="v2"</noinclude>>bar</span>
11975 !! html
11976 <p><span id="v2">bar</span>
11977 </p>
11978 !!end
11979
11980 !!test
11981 1. includeonly in html attr key
11982 !! wikitext
11983 <span <noinclude>id</noinclude><includeonly>about</includeonly>="foo">bar</span>
11984 !! html
11985 <p><span id="foo">bar</span>
11986 </p>
11987 !!end
11988
11989 !!test
11990 2. includeonly in html attr value
11991 !! wikitext
11992 <span id="<noinclude>v1</noinclude><includeonly>v2</includeonly>">bar</span>
11993 <span id=<noinclude>"v1"</noinclude><includeonly>"v2"</includeonly>>bar</span>
11994 !! html
11995 <p><span id="v1">bar</span>
11996 <span id="v1">bar</span>
11997 </p>
11998 !!end
11999
12000 !!test
12001 3. includeonly in part of an attr value
12002 !! wikitext
12003 <span style="color:<noinclude>red</noinclude><includeonly>blue</includeonly>;">bar</span>
12004 !! html
12005 <p><span style="color:red;">bar</span>
12006 </p>
12007 !!end
12008
12009 !!test
12010 4. includeonly in table attributes
12011 !! wikitext
12012 {|
12013 |- <noinclude>
12014 |-
12015 |a
12016 </noinclude>
12017 |- <includeonly>
12018 |-
12019 |b
12020 </includeonly>
12021 |}
12022 !! html
12023 <table>
12024
12025
12026 <tr>
12027 <td>a
12028 </td></tr>
12029 </table>
12030
12031 !!end
12032
12033 ###
12034 ### Preprocessor precedence tests
12035 ### See: https://www.mediawiki.org/wiki/Preprocessor_ABNF
12036 ###
12037 ##{{[[-{{{{{{[[Foo|bar}}]]}-}}}}}]]
12038 !! test
12039 Preprocessor precedence 1: link is rightmost opening
12040 !! options
12041 parsoid=wt2html
12042 !! wikitext
12043 {{[[Foo|bar}}]]
12044
12045 But close-brace is not a valid character in a link title:
12046 {{[[Foo}}|bar]]
12047
12048 However, we can still tell this was handled as a link in the preprocessor:
12049 {{echo|[[Foo}}|bar]]|bat}}
12050 !! html/php
12051 <p>{{<a href="/wiki/Foo" title="Foo">bar}}</a>
12052 </p><p>But close-brace is not a valid character in a link title:
12053 {{[[Foo}}|bar]]
12054 </p><p>However, we can still tell this was handled as a link in the preprocessor:
12055 [[Foo}}|bar]]
12056 </p>
12057 !! html/parsoid
12058 <p>{{<a rel="mw:WikiLink" href="./Foo" title="Foo">bar}}</a></p>
12059 <p>But close-brace is not a valid character in a link title: {{[[Foo}}|bar]]</p>
12060 <p>However, we can still tell this was handled as a link in the preprocessor: <span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[Foo}}|bar]]"},"2":{"wt":"bat"}},"i":0}}]}'>[[Foo}}|bar]]</span></p>
12061 !! end
12062
12063 !! test
12064 Preprocessor precedence 2: template is rightmost opening
12065 !! options
12066 language=zh
12067 !! wikitext
12068 -{{echo|foo}-}}-
12069 !! html/php
12070 <p>-foo}--
12071 </p>
12072 !! html/parsoid
12073 <p>-<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo}-"}},"i":0}}]}'>foo}-</span>-</p>
12074 !! end
12075
12076 !! test
12077 Preprocessor precedence 3: language converter is rightmost opening
12078 !! options
12079 language=zh
12080 parsoid=wt2html
12081 !! wikitext
12082 {{echo|hi}}
12083
12084 {{-{R|echo|hi}}}-
12085
12086 [[-{R|raw]]}-
12087 !! html/php
12088 <p>hi
12089 </p><p>{{echo|hi}}
12090 </p><p>[[raw]]
12091 </p>
12092 !! html/parsoid
12093 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi"}},"i":0}}]}'>hi</p>
12094 <p>{{<span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"echo|hi}}"}}'></span></p>
12095 <p>[[<span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw]]"}}'></span></p>
12096 !! end
12097
12098 !! test
12099 Preprocessor precedence 4: left-most angle bracket
12100 !! options
12101 language=zh
12102 !! wikitext
12103 <!--{raw}-->
12104 !! html/php
12105 !! html/parsoid
12106 <!--{raw}-->
12107 !! end
12108
12109 !! article
12110 Template:Precedence5
12111 !! text
12112 {{{{{1}}}}}
12113 !! endarticle
12114
12115 !! test
12116 Preprocessor precedence 5: tplarg takes precedence over template
12117 !! wikitext
12118 {{Precedence5|Bullet}}
12119 !! html/php
12120 <ul><li> Bar</li></ul>
12121
12122 !! html/parsoid
12123 <ul typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"Precedence5","href":"./Template:Precedence5"},"params":{"1":{"wt":"Bullet"}},"i":0}}]}'><li> Bar</li></ul>
12124 !! end
12125
12126 !! test
12127 Preprocessor precedence 6: broken link is rightmost opening
12128 !! options
12129 parsoid=wt2html
12130 !! wikitext
12131 {{echo|[[Foo}}
12132
12133 {{echo|[[Foo|bar|bat=baz}}
12134 !! html/php
12135 <p>{{echo|[[Foo}}
12136 </p><p>{{echo|[[Foo|bar|bat=baz}}
12137 </p>
12138 !! html/parsoid
12139 <p>{{echo|[[Foo}}</p>
12140 <p>{{echo|[[Foo|bar|bat=baz}}</p>
12141 !! end
12142
12143 # This next test exposes a difference between PHP and Parsoid:
12144 # Given [[Foo|{{echo|Bar]]x}}y]]z:
12145 # 1) Both PHP and Parsoid ignore the `]]` inside the `echo` in the
12146 # "preprocessor" stage. The `{{echo` extends until the `x}}`, and the
12147 # outer `[[Foo` extends until the `y]]`
12148 # 2a) But then the PHP preprocessor emits `[[Foo|Bar]]xy]]z` as an
12149 # intermediate result (after template expansion), and link processing
12150 # happens on this intermediate result, which moves the wikilink
12151 # boundary leftward to `[[Foo|Bar]]`
12152 # 2b) Parsoid works in a single step, so it's going to keep the
12153 # wikilink as extending to the `y]]`
12154 # 3a) Then PHP does linktrail processing which slurps up the trailing
12155 # `xy` inside the link.
12156 # 3b) Parsoid will do linktrail processing to slurp up the trailing
12157 # `z` inside the link.
12158 # This is "correct" behavior. Parsoid's basic worldview is that the
12159 # `]]` inside the template shouldn't be allowed to leak out to affect
12160 # the surrounding wikilink. PHP may match Parsoid (in the future)
12161 # if you use {{#balance}} (T114445).
12162
12163 !! test
12164 Preprocessor precedence 7: broken template is rightmost opening
12165 !! options
12166 parsoid=wt2html
12167 !! wikitext
12168 [[Foo|{{echo|Bar]]
12169
12170 [[Foo|{{echo|Bar]]-x}}-y]]-z
12171
12172 Careful: linktrails can move the end of the wikilink:
12173 [[Foo|{{echo|y']]a}}l]]l
12174 !! html/php
12175 <p><a href="/wiki/Foo" title="Foo">{{echo|Bar</a>
12176 </p><p><a href="/wiki/Foo" title="Foo">Bar</a>-x-y]]-z
12177 </p><p>Careful: linktrails can move the end of the wikilink:
12178 <a href="/wiki/Foo" title="Foo">y'al</a>]]l
12179 </p>
12180 !! html/parsoid
12181 <p>[[Foo|{{echo|Bar]]</p>
12182 <p><a rel="mw:WikiLink" href="./Foo" title="Foo"><span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"Bar]]-x"}},"i":0}}]}'>Bar]]-x</span>-y</a>-z</p>
12183 <p>Careful: linktrails can move the end of the wikilink:
12184 <a rel="mw:WikiLink" href="./Foo" title="Foo"><span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"y&#39;]]a"}},"i":0}}]}'>y']]a</span>ll</a></p>
12185 !! end
12186
12187 !! test
12188 Preprocessor precedence 8: broken language converter is rightmost opening
12189 !! options
12190 language=zh
12191 !! wikitext
12192 [[Foo-{R|raw]]
12193 !! html
12194 <p>[[Foo-{R|raw]]
12195 </p>
12196 !! end
12197
12198 !! article
12199 Template:Preprocessor_precedence_9
12200 !! text
12201 ;4: {{{{1}}}}
12202 ;5: {{{{{2}}}}}
12203 ;6: {{{{{{3}}}}}}
12204 ;7: {{{{{{{4}}}}}}}
12205 !! endarticle
12206
12207 !! test
12208 Preprocessor precedence 9: groups of braces
12209 !! wikitext
12210 {{Preprocessor precedence 9|Four|Bullet|1|2}}
12211 !! html/php
12212 <dl><dt>4</dt>
12213 <dd> {Four}</dd>
12214 <dt>5</dt>
12215 <dd> </dd></dl>
12216 <ul><li> Bar</li></ul>
12217 <dl><dt>6</dt>
12218 <dd> Four</dd>
12219 <dt>7</dt>
12220 <dd> {Bullet}</dd></dl>
12221
12222 !! html/parsoid
12223 <dl about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"Preprocessor precedence 9","href":"./Template:Preprocessor_precedence_9"},"params":{"1":{"wt":"Four"},"2":{"wt":"Bullet"},"3":{"wt":"1"},"4":{"wt":"2"}},"i":0}}]}'>
12224 <dt>4</dt>
12225 <dd>{Four}</dd>
12226 <dt>5</dt>
12227 <dd></dd>
12228 </dl><ul about="#mwt1">
12229 <li>Bar</li>
12230 </ul><span about="#mwt1"> </span><dl about="#mwt1">
12231 <dt>6</dt>
12232 <dd>Four</dd>
12233 <dt>7</dt>
12234 <dd>{Bullet}</dd>
12235 </dl>
12236 !! end
12237
12238 !! article
12239 Template:Preprocessor_precedence_10
12240 !! text
12241 ;1: -{R|raw}-
12242 ;2: -{{Bullet}}-
12243 ;3: -{{{1}}}-
12244 ;4: -{{{{2}}}}-
12245 ;5: -{{{{{3}}}}}-
12246 ;6: -{{{{{{4}}}}}}-
12247 ;7: -{{{{{{{5}}}}}}}-
12248 !! endarticle
12249
12250 !! test
12251 Preprocessor precedence 10: groups of braces with leading dash
12252 !! options
12253 language=zh
12254 !! wikitext
12255 {{Preprocessor precedence 10|Three|raw2|Bullet|1|2}}
12256 !! html/php
12257 <dl><dt>1</dt>
12258 <dd> raw</dd>
12259 <dt>2</dt>
12260 <dd> -</dd></dl>
12261 <ul><li> Bar-</li></ul>
12262 <dl><dt>3</dt>
12263 <dd> -Three-</dd>
12264 <dt>4</dt>
12265 <dd> raw2</dd>
12266 <dt>5</dt>
12267 <dd> -</dd></dl>
12268 <ul><li> Bar-</li></ul>
12269 <dl><dt>6</dt>
12270 <dd> -Three-</dd>
12271 <dt>7</dt>
12272 <dd> raw2</dd></dl>
12273
12274 !! html/parsoid
12275 <dl about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"Preprocessor precedence 10","href":"./Template:Preprocessor_precedence_10"},"params":{"1":{"wt":"Three"},"2":{"wt":"raw2"},"3":{"wt":"Bullet"},"4":{"wt":"1"},"5":{"wt":"2"}},"i":0}}]}'>
12276 <dt>1</dt>
12277 <dd><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw"}}'></span></dd>
12278 <dt>2</dt>
12279 <dd>-</dd>
12280 </dl><ul about="#mwt1">
12281 <li>Bar-</li>
12282 </ul><span about="#mwt1"> </span><dl about="#mwt1">
12283 <dt>3</dt>
12284 <dd>-Three-</dd>
12285 <dt>4</dt>
12286 <dd><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw2"}}'></span></dd>
12287 <dt>5</dt>
12288 <dd>-</dd>
12289 </dl><ul about="#mwt1">
12290 <li>Bar-</li>
12291 </ul><span about="#mwt1"> </span><dl about="#mwt1">
12292 <dt>6</dt>
12293 <dd>-Three-</dd>
12294 <dt>7</dt>
12295 <dd><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw2"}}'></span></dd>
12296 </dl>
12297 !! end
12298
12299 !! test
12300 Preprocessor precedence 11: found during visual diff testing
12301 !! wikitext
12302 {{#tag:span|-{{#tag:span|-{{echo|x}}}}}}
12303
12304 {{echo|-{{echo|-{{echo|x}}}}}}
12305
12306 {{echo|-{{echo|x}}}}
12307 !! html/php
12308 <p><span>-<span>-x</span></span>
12309 </p><p>--x
12310 </p><p>-x
12311 </p>
12312 !! html/parsoid
12313 <p><span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"#tag:span","function":"tag"},"params":{"1":{"wt":"-{{#tag:span|-{{echo|x}}}}"}},"i":0}}]}'>-<span>-x</span></span></p>
12314
12315 <p about="#mwt4" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"-{{echo|-{{echo|x}}}}"}},"i":0}}]}'>--x</p>
12316
12317 <p about="#mwt7" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"-{{echo|x}}"}},"i":0}}]}'>-x</p>
12318 !! end
12319
12320 !! test
12321 Preprocessor precedence 12: broken language converter closed by brace.
12322 !! options
12323 parsoid=wt2html
12324 !! wikitext
12325 This form breaks the template, which is unfortunate:
12326 * {{echo|foo-{bar}bat}}
12327
12328 But if the broken language converter markup is inside an extension
12329 tag, nothing bad happens:
12330 * <nowiki>foo-{bar}bat</nowiki>
12331 * {{echo|<nowiki>foo-{bar}bat</nowiki>}}
12332 * <pre>foo-{bar}bat</pre>
12333 * {{echo|<pre>foo-{bar}bat</pre>}}
12334
12335 <tag>foo-{bar}bat</tag>
12336 {{echo|<tag>foo-{bar}bat</tag>}}
12337
12338 !! html/php+tidy
12339 <p>This form breaks the template, which is unfortunate:</p>
12340 <ul>
12341 <li>{{echo|foo-{bar}bat}}</li>
12342 </ul>
12343 <p>But if the broken language converter markup is inside an extension tag, nothing bad happens:</p>
12344 <ul>
12345 <li>foo-{bar}bat</li>
12346 <li>foo-{bar}bat</li>
12347 <li>
12348 <pre>
12349 foo-{bar}bat
12350 </pre></li>
12351 <li>
12352 <pre>
12353 foo-{bar}bat
12354 </pre></li>
12355 </ul>
12356 <pre>
12357 'foo-{bar}bat'
12358 array (
12359 )
12360 </pre>
12361 <pre>
12362 'foo-{bar}bat'
12363 array (
12364 )
12365 </pre>
12366 !! html/parsoid
12367 <p>This form breaks the template, which is unfortunate:</p>
12368 <ul>
12369 <li>{{echo|foo-{bar}bat}}</li>
12370 </ul>
12371 <p>But if the broken language converter markup is inside an extension tag, nothing bad happens:</p>
12372 <ul>
12373 <li><span typeof="mw:Nowiki">foo-{bar}bat</span></li>
12374 <li><span typeof="mw:Transclusion mw:Nowiki" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;nowiki>foo-{bar}bat&lt;/nowiki>"}},"i":0}}]}'>foo-{bar}bat</span></li>
12375 <li><pre typeof="mw:Extension/pre" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo-{bar}bat"}}'>foo-{bar}bat</pre></li>
12376 <li><pre typeof="mw:Transclusion mw:Extension/pre" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;pre>foo-{bar}bat&lt;/pre>"}},"i":0}}]}'>foo-{bar}bat</pre></li>
12377 </ul>
12378 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"foo-{bar}bat"}}'></pre> <pre typeof="mw:Extension/tag mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;tag>foo-{bar}bat&lt;/tag>"}},"i":0}}]}'></pre>
12379 !! end
12380
12381 !! test
12382 Preprocessor precedence 13: broken language converter in external link
12383 !! options
12384 parsoid=wt2html
12385 !! wikitext
12386 * [http://example.com/-{foo Example in URL]
12387 * [http://example.com Example in -{link} description]
12388 * {{echo|[http://example.com/-{foo Breaks template, however]}}
12389 !! html/php+tidy
12390 <ul>
12391 <li><a rel="nofollow" class="external text" href="http://example.com/-{foo">Example in URL</a></li>
12392 <li><a rel="nofollow" class="external text" href="http://example.com">Example in -{link} description</a></li>
12393 <li>{{echo|<a rel="nofollow" class="external text" href="http://example.com/-{foo">Breaks template, however</a>}}</li>
12394 </ul>
12395 !! html/parsoid
12396 <ul>
12397 <li><a rel="mw:ExtLink" href="http://example.com/-{foo">Example in URL</a></li>
12398 <li><a rel="mw:ExtLink" href="http://example.com">Example in -{link} description</a></li>
12399 <li>{{echo|<a rel="mw:ExtLink" href="http://example.com/-{foo">Breaks template, however</a>}}</li>
12400 </ul>
12401 !! end
12402
12403 !! test
12404 Preprocessor precedence 14: broken language converter in comment
12405 !! wikitext
12406 * <!--{{foo}}--> ...should be ok
12407 * <!---{{foo}}--> ...extra dashes
12408 * {{echo|foo<!-- -{bar} -->bat}} ...should be ok
12409 !! html/php+tidy
12410 <ul>
12411 <li>...should be ok</li>
12412 <li>...extra dashes</li>
12413 <li>foobat ...should be ok</li>
12414 </ul>
12415 !! html/parsoid
12416 <ul>
12417 <li><!--{{foo}}--> ...should be ok</li>
12418 <li><!--&#x2D;{{foo}}--> ...extra dashes</li>
12419 <li><span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo&lt;!-- -{bar} -->bat"}},"i":0}}]}'>foo</span><span about="#mwt1"><!-- &#x2D;{bar} --></span><span about="#mwt1">bat</span> ...should be ok</li>
12420 </ul>
12421 !! end
12422
12423 !! test
12424 Preprocessor precedence 15: broken brace markup in headings
12425 !! options
12426 parsoid=wt2html
12427 !! wikitext
12428 __NOTOC__ __NOEDITSECTION__
12429 ===1 foo[bar 1===
12430 1
12431 ===2 foo[[bar 2===
12432 2
12433 ===3 foo{bar 3===
12434 3
12435 ===4 foo{{bar 4===
12436 4
12437 ===5 foo{{{bar 5===
12438 5
12439 ===6 foo-{bar 6===
12440 6
12441 !! html/php+tidy
12442 <h3><span class="mw-headline" id="1_foo.5Bbar_1">1 foo[bar 1</span></h3>
12443 <p>1</p>
12444 <h3><span class="mw-headline" id="2_foo.5B.5Bbar_2">2 foo[[bar 2</span></h3>
12445 <p>2</p>
12446 <h3><span class="mw-headline" id="3_foo.7Bbar_3">3 foo{bar 3</span></h3>
12447 <p>3</p>
12448 <h3><span class="mw-headline" id="4_foo.7B.7Bbar_4">4 foo{{bar 4</span></h3>
12449 <p>4</p>
12450 <h3><span class="mw-headline" id="5_foo.7B.7B.7Bbar_5">5 foo{{{bar 5</span></h3>
12451 <p>5</p>
12452 <h3><span class="mw-headline" id="6_foo-.7Bbar_6">6 foo-{bar 6</span></h3>
12453 <p>6</p>
12454 !! html/parsoid
12455 <meta property="mw:PageProp/notoc"/> <meta property="mw:PageProp/noeditsection"/
12456 >
12457 <h3>1 foo[bar 1</h3>
12458 <p>1</p>
12459 <h3>2 foo[[bar 2</h3>
12460 <p>2</p>
12461 <h3>3 foo{bar 3</h3>
12462 <p>3</p>
12463 <h3>4 foo{{bar 4</h3>
12464 <p>4</p>
12465 <h3>5 foo{{{bar 5</h3>
12466 <p>5</p>
12467 <h3>6 foo-{bar 6</h3>
12468 <p>6</p>
12469 !! end
12470
12471 !! test
12472 Preprocessor precedence 16: matching closing braces to opening braces
12473 !! options
12474 language=zh
12475 parsoid=wt2html
12476 !! wikitext
12477 -{{{echo|foo}}bar}-
12478 !! html/php
12479 <p>foobar
12480 </p>
12481 !! html/parsoid
12482 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"&lt;span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid=&#39;{\"pi\":[[{\"k\":\"1\"}]],\"dsr\":[2,14,null,null]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"foo\"}},\"i\":0}}]}&#39;>foo&lt;/span>bar"}}'></span></p>
12483 !! end
12484
12485 ###
12486 ### Token Stream Patcher tests
12487 ###
12488 ### These tests won't always pass wt2wt and other modes because
12489 ### on serialization, the table will be output on a new line.
12490 ### For now, we are blacklisting them, and using this to test selser.
12491 ###
12492
12493 !!test
12494 1. Table tag in SOL posn. should get reparsed correctly with valid TSR
12495 !!options
12496 parsoid=wt2html,wt2wt
12497 !!wikitext
12498 {{echo|}}{| width = '100%'
12499 |foo
12500 |}
12501 !!html/parsoid
12502 <span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":""}},"i":0}}]}'></span><table width="100%">
12503 <tbody><tr><td>foo</td></tr>
12504 </tbody></table>
12505 !!end
12506
12507 ## We used to, but no longer wt2wt this test since the default serializer
12508 ## will normalize the include directives to serialize on their own line.
12509 ## Selser will take care of preserving formatting in scenarios where they
12510 ## intermingled with other wikitext.
12511 !!test
12512 2. Table tag in SOL posn. should get reparsed correctly with valid TSR
12513 !!options
12514 parsoid=wt2html
12515 !!wikitext
12516 <includeonly>a</includeonly>{| {{{b}}}
12517 |c
12518 |}
12519 !!html/parsoid
12520 <meta typeof="mw:Includes/IncludeOnly" data-parsoid='{"src":"&lt;includeonly>a&lt;/includeonly>"}'/><meta typeof="mw:Includes/IncludeOnly/End" data-parsoid='{"src":""}'/><table about="#mwt2" typeof="mw:ExpandedAttrs" data-parsoid='{"a":{"{{{b}}}":null},"sa":{"{{{b}}}":""}}' data-mw='{"attribs":[[{"txt":"{{{b}}}","html":"&lt;span about=\"#mwt1\" typeof=\"mw:Param\" data-parsoid=&#39;{\"pi\":[[]],\"dsr\":[31,38,null,null]}&#39; data-mw=&#39;{\"parts\":[{\"templatearg\":{\"target\":{\"wt\":\"b\"},\"params\":{},\"i\":0}}]}&#39;>{{{b}}}&lt;/span>"},{"html":""}]]}'>
12521 <tbody><tr><td>c</td></tr>
12522 </tbody></table>
12523 !!end
12524
12525 !! test
12526 Table wikitext syntax outside wiki-tables
12527 !! wikitext
12528 a
12529 |+ not a caption
12530 ! not a table heading
12531 |- not a table row
12532 | not a table cell
12533 | class="foo bar" | baz
12534 b
12535 |}
12536 |-
12537 c
12538 !! html
12539 <p>a
12540 |+ not a caption
12541 ! not a table heading
12542 |- not a table row
12543 | not a table cell
12544 | class="foo bar" | baz
12545 b
12546 |}
12547 |-
12548 c
12549 </p>
12550 !! end
12551
12552 ###
12553 ### Testing parsing of templates where a template arg
12554 ### has the same name as the template itself.
12555 ###
12556
12557 !! article
12558 Template:quote
12559 !! text
12560 {{{quote|{{{1}}}}}}
12561 !! endarticle
12562
12563 !!test
12564 Templates: Template Name/Arg clash: 1. Use of positional param
12565 !! wikitext
12566 {{quote|foo}}
12567 !! html
12568 <p>foo
12569 </p>
12570 !!end
12571
12572 !!test
12573 Templates: Template Name/Arg clash: 2. Use of named param
12574 !! wikitext
12575 {{quote|quote=foo}}
12576 !! html
12577 <p>foo
12578 </p>
12579 !!end
12580
12581 !!test
12582 Templates: Template Name/Arg clash: 3. Use of named param with empty input
12583 !! wikitext
12584 {{quote|quote}}
12585 !! html
12586 <p>quote
12587 </p>
12588 !!end
12589
12590 ###
12591 ### Parsoid-centric tests to stress Parsoid's ability to RT them unchanged
12592 ###
12593
12594 !!test
12595 Templates: 1. Simple use
12596 !! wikitext
12597 {{echo|Foo}}
12598 !! html
12599 <p>Foo
12600 </p>
12601 !!end
12602
12603 !!test
12604 Templates: 2. Inside a block tag
12605 !! wikitext
12606 <div>{{echo|Foo}}</div>
12607 <blockquote>{{echo|Foo}}</blockquote>
12608 !! html
12609 <div>Foo</div>
12610 <blockquote>Foo</blockquote>
12611
12612 !! html+tidy
12613 <div>Foo</div>
12614 <blockquote>
12615 <p>Foo</p>
12616 </blockquote>
12617 !!end
12618
12619 !!test
12620 Templates: P-wrapping: 1a. Templates on consecutive lines
12621 !! wikitext
12622 {{echo|Foo}}
12623 {{echo|bar}}
12624 !! html
12625 <p>Foo
12626 bar
12627 </p>
12628 !!end
12629
12630 !!test
12631 Templates: P-wrapping: 1b. Templates on consecutive lines
12632 !! wikitext
12633 Foo
12634
12635 {{echo|bar}}
12636 {{echo|baz}}
12637 !! html
12638 <p>Foo
12639 </p><p>bar
12640 baz
12641 </p>
12642 !!end
12643
12644 !!test
12645 Templates: P-wrapping: 1c. Templates on consecutive lines
12646 !! wikitext
12647 {{echo|Foo}}
12648 {{echo|bar}} <div>baz</div>
12649 !! html
12650 <p>Foo
12651 </p>
12652 bar <div>baz</div>
12653
12654 !! html+tidy
12655 <p>Foo</p>
12656 <p>bar</p>
12657 <div>baz</div>
12658 !! end
12659
12660 !!test
12661 Templates: P-wrapping: 1d. Template preceded by comment-only line
12662 !!options
12663 parsoid
12664 !! wikitext
12665 <!-- foo -->
12666 {{echo|Bar}}
12667 !! html
12668 <!-- foo -->
12669
12670 <p about="#mwt223" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"Bar"}},"i":0}}]}'>Bar</p>
12671 !!end
12672
12673 !!test
12674 Templates: Inline Text: 1. Multiple template uses
12675 !! wikitext
12676 {{echo|Foo}}bar{{echo|baz}}
12677 !! html
12678 <p>Foobarbaz
12679 </p>
12680 !!end
12681
12682 !!test
12683 Templates: Inline Text: 2. Back-to-back template uses
12684 !! wikitext
12685 {{echo|Foo}}{{echo|bar}}
12686 !! html
12687 <p>Foobar
12688 </p>
12689 !!end
12690
12691 !!test
12692 Templates: Block Tags: 1. Multiple template uses
12693 !! wikitext
12694 {{echo|<div>Foo</div>}}<div>bar</div>{{echo|<div>baz</div>}}
12695 !! html
12696 <div>Foo</div><div>bar</div><div>baz</div>
12697
12698 !!end
12699
12700 !!test
12701 Templates: Block Tags: 2. Back-to-back template uses
12702 !! wikitext
12703 {{echo|<div>Foo</div>}}{{echo|<div>bar</div>}}
12704 !! html
12705 <div>Foo</div><div>bar</div>
12706
12707 !!end
12708
12709 # This is an edge case relating to paragraph wrapping.
12710 !!test
12711 Templates: Correctly encapsulate templates producing </p> tag without a corresponding <p> tag
12712 !! wikitext
12713 {{echo|a
12714 b</p>}}
12715 !! html/parsoid
12716 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"a\nb&lt;/p>"}},"i":0}}]}'>a
12717 b</p>
12718 !!end
12719
12720 !!test
12721 Templates: Links: 1. Simple example
12722 !! wikitext
12723 {{echo|[[Foo|bar]]}}
12724 !! html
12725 <p><a href="/wiki/Foo" title="Foo">bar</a>
12726 </p>
12727 !!end
12728
12729 !!test
12730 Templates: Links: 2. Generation of link href
12731 !! wikitext
12732 [[{{echo|Foo}}|bar]]
12733 !! html
12734 <p><a href="/wiki/Foo" title="Foo">bar</a>
12735 </p>
12736 !!end
12737
12738 !!test
12739 Templates: Links: 3. Generation of part of a link href
12740 !! wikitext
12741 [[Fo{{echo|o}}|bar]]
12742
12743 [[Foo{{echo|bar}}]]
12744
12745 [[Foo{{echo|bar}}baz]]
12746
12747 [[Foo{{echo|bar}}|bar]]
12748
12749 [[:Foo{{echo|bar}}]]
12750
12751 [[:Foo{{echo|bar}}|bar]]
12752 !! html
12753 <p><a href="/wiki/Foo" title="Foo">bar</a>
12754 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
12755 </p><p><a href="/index.php?title=Foobarbaz&amp;action=edit&amp;redlink=1" class="new" title="Foobarbaz (page does not exist)">Foobarbaz</a>
12756 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">bar</a>
12757 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
12758 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">bar</a>
12759 </p>
12760 !!end
12761
12762 !!test
12763 Templates: Links: 4. Multiple templates generating link href
12764 !! wikitext
12765 [[{{echo|F}}{{echo|o}}ob{{echo|ar}}]]
12766 !! html
12767 <p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
12768 </p>
12769 !!end
12770
12771 !!test
12772 Templates: Links: 5. Generation of link text
12773 !! wikitext
12774 [[Foo|{{echo|bar}}]]
12775 !! html
12776 <p><a href="/wiki/Foo" title="Foo">bar</a>
12777 </p>
12778 !!end
12779
12780 !!test
12781 Templates: Links: 5. Nested templates (only outermost template should be marked)
12782 !! wikitext
12783 {{echo|[[{{echo|Foo}}|bar]]}}
12784 !! html
12785 <p><a href="/wiki/Foo" title="Foo">bar</a>
12786 </p>
12787 !!end
12788
12789 !!test
12790 Templates: HTML Tag: 1. Generation of HTML attr. key
12791 !! wikitext
12792 <div {{echo|style}}="color:red;">foo</div>
12793 !! html
12794 <div style="color:red;">foo</div>
12795
12796 !!end
12797
12798 !!test
12799 Templates: HTML Tag: 2. Generation of HTML attr. value
12800 !! wikitext
12801 <div style={{echo|'color:red;'}}>foo</div>
12802 !! html
12803 <div style="color:red;">foo</div>
12804
12805 !!end
12806
12807 !!test
12808 Templates: HTML Tag: 3. Generation of HTML attr key and value
12809 !! wikitext
12810 <div {{echo|style}}={{echo|'color:red;'}}>foo</div>
12811 !! html
12812 <div style="color:red;">foo</div>
12813
12814 !!end
12815
12816 !!test
12817 Templates: HTML Tag: 4. Generation of starting piece of HTML attr value
12818 !! wikitext
12819 <div title="{{echo|This is a long title}} with just one piece templated">foo</div>
12820 !! html
12821 <div title="This is a long title with just one piece templated">foo</div>
12822
12823 !!end
12824
12825 !!test
12826 Templates: HTML Tag: 5. Generation of middle piece of HTML attr value
12827 !! wikitext
12828 <div title="This is a long title with just {{echo|one piece}} templated">foo</div>
12829 !! html
12830 <div title="This is a long title with just one piece templated">foo</div>
12831
12832 !!end
12833
12834 !!test
12835 Templates: HTML Tag: 6. Generation of end piece of HTML attr value
12836 !! wikitext
12837 <div title="This is a long title with just one piece {{echo|templated}}">foo</div>
12838 !! html
12839 <div title="This is a long title with just one piece templated">foo</div>
12840
12841 !!end
12842
12843 # SSS FIXME: While it is great we added support for all this,
12844 # do we want to make this part of the spec? Maybe we want to
12845 # deprecate this kind of usage in the future?
12846 !!test
12847 Templates: HTML Tag: 7. Generation of partial attribute key string
12848 !! wikitext
12849 <div st{{echo|yle}}="color:red;">foo</div>
12850 !! html
12851 <div style="color:red;">foo</div>
12852
12853 !!end
12854
12855 !! test
12856 Templates: HTML Tag: 8. Template-generated attribute (k=v)
12857 !! wikitext
12858 <div {{echo|1=id="v1"}}>bar</div>
12859 !! html
12860 <div id="v1">bar</div>
12861
12862 !!end
12863
12864 !! test
12865 Templates: HTML Tag: 9. Multiple template-generated attributes
12866 !! wikitext
12867 <div {{echo|1=id="v1" title="foo"}}>bar</div>
12868 !! html
12869 <div id="v1" title="foo">bar</div>
12870
12871 !!end
12872
12873 !! test
12874 Templates: Support for templates generating attributes and content
12875 !! wikitext
12876 {| {{mixed_attr_content_template}}
12877 |-
12878 |bar
12879 |}
12880 !! html/php
12881 <table style="color:red;" title="T48811">
12882
12883 <tr>
12884 <td>foo
12885 </td></tr>
12886 <tr>
12887 <td>bar
12888 </td></tr></table>
12889
12890 !! html/parsoid
12891 <table style="color:red;" title="T48811" about="#mwt1" typeof="mw:Transclusion mw:ExpandedAttrs" data-mw='{"parts":["{| ",{"template":{"target":{"wt":"mixed_attr_content_template","href":"./Template:Mixed_attr_content_template"},"params":{},"i":0}},"\n|-\n|bar\n|}"]}'>
12892 <tbody><tr>
12893 <td>foo</td></tr>
12894 <tr>
12895 <td>bar</td></tr>
12896 </tbody></table>
12897 !!end
12898
12899 !! test
12900 1. Entities and nowikis inside templated attributes should be handled correctly
12901 !! wikitext
12902 <div {{echo|style{{=}}"background:&#35;f9f9f9;"}}>foo</div>
12903 !! html/php
12904 <div style="background:#f9f9f9;">foo</div>
12905
12906 !! html/parsoid
12907 <div style="background:#f9f9f9;" about="#mwt3" typeof="mw:ExpandedAttrs" data-parsoid='{"stx":"html"}' data-mw='{"attribs":[[{"txt":"style","html":"&lt;span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid=&#39;{\"pi\":[[{\"k\":\"1\"}]],\"dsr\":[5,49,null,null]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"style{{=}}\\\"background:&amp;amp;#35;f9f9f9;\\\"\"}},\"i\":0}}]}&#39;>style&lt;/span>&lt;span typeof=\"mw:Nowiki\" about=\"#mwt1\" data-parsoid=\"{}\">=&lt;/span>&lt;span about=\"#mwt1\" data-parsoid=\"{}\">\"background:&lt;/span>&lt;span typeof=\"mw:Entity\" about=\"#mwt1\" data-parsoid=&#39;{\"src\":\"&amp;amp;#35;\",\"srcContent\":\"#\"}&#39;>#&lt;/span>&lt;span about=\"#mwt1\" data-parsoid=\"{}\">f9f9f9;\"&lt;/span>"},{"html":""}]]}'>foo</div>
12908 !! end
12909
12910 !! test
12911 2. Entities and nowikis inside templated attributes should be handled correctly
12912 !! wikitext
12913 {|
12914 |{{table_attribs_3}}
12915 |}
12916 !! html/php
12917 <table>
12918 <tr>
12919 <td style="background:#f9f9f9;">Foo
12920 </td></tr></table>
12921
12922 !! html/parsoid
12923 <table>
12924 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td style="background:#f9f9f9;" typeof="mw:Transclusion" about="#mwt1" data-parsoid='{"autoInsertedEnd":true,"pi":[[]]}' data-mw='{"parts":["|",{"template":{"target":{"wt":"table_attribs_3","href":"./Template:Table_attribs_3"},"params":{},"i":0}}]}'>Foo</td></tr>
12925 </tbody></table>
12926 !! end
12927
12928 !! test
12929 3. Entities and nowikis inside templated attributes should be handled correctly inside templated tables
12930 !! wikitext
12931 {{tbl-start}}
12932 |{{table_attribs_3}}
12933 {{tbl-end}}
12934 !! html/php
12935 <table>
12936 <tr>
12937 <td style="background:#f9f9f9;">Foo
12938 </td></tr></table>
12939
12940 !! html/parsoid
12941 <table about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[],[],[]]}' data-mw='{"parts":[{"template":{"target":{"wt":"tbl-start","href":"./Template:Tbl-start"},"params":{},"i":0}},"\n|",{"template":{"target":{"wt":"table_attribs_3","href":"./Template:Table_attribs_3"},"params":{},"i":1}},"\n",{"template":{"target":{"wt":"tbl-end","href":"./Template:Tbl-end"},"params":{},"i":2}}]}'>
12942 <tbody><tr><td style="background:#f9f9f9;">Foo</td></tr>
12943 </tbody></table>
12944 !! end
12945
12946 # T107622
12947 !! test
12948 4. Entities and nowikis inside templated attributes should be handled correctly inside templated tables
12949 !! wikitext
12950 {|
12951 | {{table_attribs_6}} hi
12952 |}
12953 !! html/php
12954 <table>
12955 <tr>
12956 <td style="background: red;"> hi
12957 </td></tr></table>
12958
12959 !! html/parsoid
12960 <table>
12961 <tbody><tr><td style="background: red;" typeof="mw:Transclusion" about="#mwt1" data-parsoid='{"autoInsertedEnd":true,"pi":[[]]}' data-mw='{"parts":["| ",{"template":{"target":{"wt":"table_attribs_6","href":"./Template:Table_attribs_6"},"params":{},"i":0}}," hi"]}'> hi</td></tr>
12962 </tbody></table>
12963 !! end
12964
12965 !!test
12966 Templates: HTML Tables: 1. Generating start of a HTML table
12967 !! wikitext
12968 {{echo|<table><tr><td>foo</td>}}</tr></table>
12969 !! html
12970 <table><tr><td>foo</td></tr></table>
12971
12972 !!end
12973
12974 !!test
12975 Templates: HTML Tables: 2a. Generating middle of a HTML table
12976 !! wikitext
12977 <table><tr>{{echo|<td>foo</td>}}</tr></table>
12978 !! html
12979 <table><tr><td>foo</td></tr></table>
12980
12981 !!end
12982
12983 !!test
12984 Templates: HTML Tables: 2b. Generating middle of a HTML table
12985 !! wikitext
12986 <table>{{echo|<tr><td>foo</td></tr>}}</table>
12987 !! html
12988 <table><tr><td>foo</td></tr></table>
12989
12990 !!end
12991
12992 !!test
12993 Templates: HTML Tables: 3. Generating end of a HTML table
12994 !! wikitext
12995 <table><tr>{{echo|<td>foo</td></tr></table>}}
12996 !! html
12997 <table><tr><td>foo</td></tr></table>
12998
12999 !!end
13000
13001 !!test
13002 Templates: HTML Tables: 4a. Generating a single tag of a HTML table
13003 !! wikitext
13004 {{echo|<table>}}<tr><td>foo</td></tr></table>
13005 !! html
13006 <table><tr><td>foo</td></tr></table>
13007
13008 !!end
13009
13010 !!test
13011 Templates: HTML Tables: 4b. Generating a single tag of a HTML table
13012 !! wikitext
13013 <table>{{echo|<tr>}}<td>foo</td></tr></table>
13014 !! html
13015 <table><tr><td>foo</td></tr></table>
13016
13017 !!end
13018
13019 !!test
13020 Templates: HTML Tables: 4c. Generating a single tag of a HTML table
13021 !! wikitext
13022 <table><tr>{{echo|<td>}}foo</td></tr></table>
13023 !! html
13024 <table><tr><td>foo</td></tr></table>
13025
13026 !!end
13027
13028 !!test
13029 Templates: HTML Tables: 4d. Generating a single tag of a HTML table
13030 !! wikitext
13031 <table><tr><td>foo{{echo|</td>}}</tr></table>
13032 !! html
13033 <table><tr><td>foo</td></tr></table>
13034
13035 !!end
13036
13037 !!test
13038 Templates: HTML Tables: 4e. Generating a single tag of a HTML table
13039 !! wikitext
13040 <table><tr><td>foo</td>{{echo|</tr>}}</table>
13041 !! html
13042 <table><tr><td>foo</td></tr></table>
13043
13044 !!end
13045
13046 !!test
13047 Templates: HTML Tables: 4f. Generating a single tag of a HTML table
13048 !! wikitext
13049 <table><tr><td>foo</td></tr>{{echo|</table>}}
13050 !! html
13051 <table><tr><td>foo</td></tr></table>
13052
13053 !!end
13054
13055 !!test
13056 Templates: HTML Tables: 5. Proper fostering of categories from inside
13057 !!options
13058 parsoid=wt2html,wt2wt
13059 !! wikitext
13060 <table>[[Category:foo1]]<tr><td>foo</td></tr></table>
13061 <!--Two categories (T52330)-->
13062 <table>[[Category:bar1]][[Category:bar2]]<tr><td>foo</td></tr></table>
13063 !! html
13064 <link rel="mw:PageProp/Category" href="./Category:Foo1"><table><tbody><tr><td>foo</td></tr></tbody></table>
13065 <!--Two categories (T52330)-->
13066 <link rel="mw:PageProp/Category" href="./Category:Bar1"><link rel="mw:PageProp/Category" href="./Category:Bar2"><table><tbody><tr><td>foo</td></tr></tbody></table>
13067 !!end
13068
13069 !!test
13070 Templates: Wiki Tables: 1a. Fostering of entire template content
13071 !! wikitext
13072 {|
13073 {{echo|a}}
13074 |}
13075 !! html
13076 <table>
13077 a
13078 <tr><td></td></tr></table>
13079
13080 !! html+tidy
13081 <p>a</p>
13082 <table>
13083 <tr>
13084 <td></td>
13085 </tr>
13086 </table>
13087 !! end
13088
13089 !!test
13090 Templates: Wiki Tables: 1b. Fostering of entire template content
13091 !! wikitext
13092 {|
13093 {{echo|<div>}}
13094 foo
13095 {{echo|</div>}}
13096 |}
13097 !! html
13098 <table>
13099 <div>
13100 <p>foo
13101 </p>
13102 </div>
13103 <tr><td></td></tr></table>
13104
13105 !! html+tidy
13106 <div>
13107 <p>foo</p>
13108 </div>
13109 <table>
13110 <tr>
13111 <td></td>
13112 </tr>
13113 </table>
13114 !! end
13115
13116 !!test
13117 Templates: Wiki Tables: 2. Fostering of partial template content
13118 !! wikitext
13119 {|
13120 {{echo|a
13121 <div>b</div>}}
13122 |}
13123 !! html
13124 <table>
13125 a
13126 <div>b</div>
13127 <tr><td></td></tr></table>
13128
13129 !! html+tidy
13130 <p>a</p>
13131 <div>b</div>
13132 <table>
13133 <tr>
13134 <td></td>
13135 </tr>
13136 </table>
13137 !! end
13138
13139 !!test
13140 Templates: Wiki Tables: 3. td-content via multiple templates
13141 !! wikitext
13142 {|
13143 {{echo|{{pipe}}a}}{{echo|b}}
13144 |}
13145 !! html
13146 <table>
13147 <tr>
13148 <td>ab
13149 </td></tr></table>
13150
13151 !!end
13152
13153 !!test
13154 Templates: Wiki Tables: 4. Templated tags, no content
13155 !! wikitext
13156 {{tbl-start}}
13157 {{tbl-end}}
13158 !! html
13159 <table>
13160 <tr><td></td></tr></table>
13161
13162 !!end
13163
13164 !!test
13165 Templates: Wiki Tables: 5. Templated tags, regular td-tags
13166 !! wikitext
13167 {{tbl-start}}
13168 |foo
13169 {{tbl-end}}
13170 !! html
13171 <table>
13172 <tr>
13173 <td>foo
13174 </td></tr></table>
13175
13176 !!end
13177
13178 !!test
13179 Templates: Wiki Tables: 6. Templated tags, templated td-tags
13180 !! wikitext
13181 {{tbl-start}}
13182 {{!}}foo
13183 {{tbl-end}}
13184 !! html
13185 <table>
13186 <tr>
13187 <td>foo
13188 </td></tr></table>
13189
13190 !!end
13191
13192 ## This test case is very specific to Parsoid's internals
13193 ## and is hence only tested for Parsoid's code. Parsoid uses
13194 ## a <meta> marker tag for <ref> tags and they are expanded
13195 ## much later. We are verifying that this <meta> tag usage
13196 ## doesn't prevent foster parenting.
13197 !!test
13198 Templates: Wiki Tables: 7. Fosterable <ref>s should get fostered
13199 !!wikitext
13200 {{PartialTable}}<ref>foo</ref>
13201 |}
13202
13203 <references />
13204 !!html/parsoid
13205 <span about="#mwt2" class="mw-ref" id="cite_ref-1" rel="dc:references" typeof="mw:Transclusion mw:Extension/ref" data-mw='{"parts":[{"template":{"target":{"wt":"PartialTable","href":"./Template:PartialTable"},"params":{},"i":0}},"&lt;ref>foo&lt;/ref>\n|}"]}'><a href="./Main_Page#cite_note-1"><span class="mw-reflink-text">[1]</span></a></span><table about="#mwt2">
13206 <tbody>
13207 </tbody></table>
13208
13209 <ol class="mw-references" typeof="mw:Extension/references" about="#mwt4" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text">foo</span></li></ol>
13210 !!end
13211
13212 !! test
13213 Templates: Wiki Tables: 8. Fosterable meta-tags should get fostered
13214 !! wikitext
13215 {{echo|
13216 {{{!}}
13217 {{!}}-}}
13218 <onlyinclude>
13219 |foo
13220 </onlyinclude>
13221 {{!}}}
13222 !! html/parsoid
13223 <span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"\n{{{!}}\n{{!}}-"}},"i":0}},"\n&lt;onlyinclude>\n|foo\n&lt;/onlyinclude>\n{{!}}}"]}'>
13224 </span><meta typeof="mw:Includes/OnlyInclude" about="#mwt1"/><table about="#mwt1">
13225 <tbody><tr>
13226
13227 <td>foo
13228 <meta typeof="mw:Includes/OnlyInclude/End"/></td></tr>
13229 </tbody></table>
13230 !! end
13231
13232 !!test
13233 Templates: Lists: Multi-line list-items via templates
13234 !! wikitext
13235 *{{echo|a {{nonexistent|
13236 unused}}}}
13237 *{{echo|b {{nonexistent|
13238 unused}}}}
13239 !! html
13240 <ul><li>a <a href="/index.php?title=Template:Nonexistent&amp;action=edit&amp;redlink=1" class="new" title="Template:Nonexistent (page does not exist)">Template:Nonexistent</a></li>
13241 <li>b <a href="/index.php?title=Template:Nonexistent&amp;action=edit&amp;redlink=1" class="new" title="Template:Nonexistent (page does not exist)">Template:Nonexistent</a></li></ul>
13242
13243 !!end
13244
13245 !!test
13246 Templates: Ugly nesting: 1. Quotes opened/closed across templates (echo)
13247 !! wikitext
13248 {{echo|''a}}{{echo|b''c''d}}{{echo|''e}}
13249 !! html
13250 <p><i>ab</i>c<i>d</i>e
13251 </p>
13252 !!end
13253
13254 !!test
13255 Templates: Ugly nesting: 2. Quotes opened/closed across templates (echo_with_span)
13256 (PHP parser generates misnested html)
13257 !! wikitext
13258 {{echo_with_span|''a}}{{echo_with_span|b''c''d}}{{echo_with_span|''e}}
13259 !! html/parsoid
13260 <p><span about="#mwt1" typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo_with_span&quot;,&quot;href&quot;:&quot;./Template:Echo_with_span&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;''a&quot;}},&quot;i&quot;:0}}]}"><i>a</i></span><i about="#mwt2" typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo_with_span&quot;,&quot;href&quot;:&quot;./Template:Echo_with_span&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;b''c''d&quot;}},&quot;i&quot;:0}},{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo_with_span&quot;,&quot;href&quot;:&quot;./Template:Echo_with_span&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;''e&quot;}},&quot;i&quot;:1}}]}"><span>b</span></i><span about="#mwt2">c</span><i about="#mwt2">d<span></span></i><span about="#mwt2">e</span></p>
13261 !!end
13262
13263 !!test
13264 Templates: Ugly nesting: 3. Quotes opened/closed across templates (echo_with_div)
13265 (PHP parser generates misnested html; Parsoid html2wt mode adds newlines between {{echo}}s)
13266 !! options
13267 parsoid=wt2html,wt2wt
13268 !! wikitext
13269 {{echo_with_div|''a}}{{echo_with_div|b''c''d}}{{echo_with_div|''e}}
13270 !! html
13271 <div about="#mwt1" typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo_with_div&quot;,&quot;href&quot;:&quot;./Template:Echo_with_div&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;''a&quot;}},&quot;i&quot;:0}}]}"><i>a</i></div>
13272 <div about="#mwt2" typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo_with_div&quot;,&quot;href&quot;:&quot;./Template:Echo_with_div&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;b''c''d&quot;}},&quot;i&quot;:0}}]}"><i>b</i>c<i>d</i></div>
13273 <div about="#mwt3" typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo_with_div&quot;,&quot;href&quot;:&quot;./Template:Echo_with_div&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;''e&quot;}},&quot;i&quot;:0}}]}">e</div>
13274 !!end
13275
13276 !!test
13277 Templates: Ugly nesting: 4. Divs opened/closed across templates
13278 !! wikitext
13279 a<div>b{{echo|c</div>d}}e
13280 !! html
13281 a<div>bc</div>de
13282
13283 !! html+tidy
13284 <p>a</p>
13285 <div>bc</div>
13286 <p>de</p>
13287 !! end
13288
13289 !!test
13290 Templates: Ugly templates: 1. Navbox template parses badly leading to table misnesting
13291 (Parsoid-centric)
13292 !! options
13293 parsoid
13294 !! wikitext
13295 {|
13296 |{{echo|foo</table>}}
13297 |bar
13298 |}
13299 !! html
13300 <table about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":["{|\n|",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo</table>"}},"i":0}},"\n|bar\n|}"]}'>
13301
13302 <tbody>
13303 <tr>
13304 <td>foo</td></tr></tbody></table><span about="#mwt1">
13305 </span><span about="#mwt1">|bar</span><span about="#mwt1">
13306 |}</span>
13307 !!end
13308
13309 !!test
13310 Templates: Ugly templates: 2. Navbox template parses badly leading to table misnesting
13311 (Parsoid-centric)
13312 !! options
13313 parsoid
13314 !! wikitext
13315 <table>
13316 <tr>
13317 <td>
13318 <table>
13319 <tr>
13320 <td>1. {{echo|foo </table>}}</td>
13321 <td> bar </td>
13322 <td>2. {{echo|baz </table>}}</td>
13323 </tr>
13324 <tr>
13325 <td>abc</td>
13326 </tr>
13327 </table>
13328 </td>
13329 </tr>
13330 <tr>
13331 <td>xyz</td>
13332 </tr>
13333 </table>
13334 !! html
13335 <table about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":["<table>\n <tr>\n <td>\n <table>\n <tr>\n <td>1. ",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo </table>"}},"i":0}},"</td>\n <td> bar </td>\n <td>2. ",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"baz </table>"}},"i":1}},"</td>\n </tr>\n <tr>\n <td>abc</td>\n </tr>\n </table>\n </td>\n </tr>\n <tr>\n <td>xyz</td>\n </tr>\n</table>"]}'>
13336 <tbody><tr>
13337 <td>
13338 <table>
13339 <tbody><tr>
13340 <td>1. foo </td></tr></tbody></table></td>
13341 <td> bar </td>
13342 <td>2. baz </td></tr></tbody></table><span about="#mwt2">
13343 </span><span about="#mwt2">
13344 </span><span about="#mwt2">
13345 </span><span about="#mwt2">abc</span><span about="#mwt2">
13346 </span><span about="#mwt2">
13347 </span><span about="#mwt2">
13348 </span><span about="#mwt2">
13349 </span><span about="#mwt2">
13350 </span><span about="#mwt2">
13351 </span><span about="#mwt2">xyz</span><span about="#mwt2">
13352 </span><span about="#mwt2">
13353 </span>
13354 !!end
13355
13356 !! test
13357 Templates: Ugly templates: 3. newline-only template parameter
13358 !! wikitext
13359 foo {{echo|
13360 }}
13361 !! html
13362 <p>foo
13363 </p>
13364 !! end
13365
13366 # This looks like a bug: a single newline triggers p/br for some reason.
13367 !! test
13368 Templates: Ugly templates: 4. newline-only template parameter inconsistency
13369 !! wikitext
13370 {{echo|
13371 }}
13372 !! html
13373 <p><br />
13374 </p>
13375 !! end
13376
13377 # T66017 -- ugly wikitext with fostered content generates two template ranges that
13378 # have a true overlap (T1-start - T2-start - T1-end - T2-end).
13379 !! test
13380 Templates: Ugly templates: 5. Template encapsulation test: Non-trivial overlap of template ranges is properly handled
13381 !! wikitext
13382 {{echo|<table>}}
13383 {{echo|<div>foo}}
13384 {{echo|</table>}}
13385 !! html/parsoid
13386 <div about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;table>"}},"i":0}},"\n",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;div>foo"}},"i":1}},"\n",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;/table>"}},"i":2}}]}' data-parsoid='{"stx":"html","autoInsertedEnd":true,"pi":[[{"k":"1"}],[{"k":"1"}],[{"k":"1"}]]}'>foo
13387 </div><table about="#mwt1" data-parsoid='{"stx":"html"}'>
13388 </table>
13389 !! end
13390
13391 # T66017 -- ugly wikitext with fostered content generates two template ranges
13392 # that are "identical" and generate nesting cycles in the algorithm
13393 !! test
13394 Templates: Ugly templates: 6. Template encapsulation test: Cyclical nesting of template ranges is properly handled
13395 !! wikitext
13396 {{echo|<table><tr><td><table>}}
13397 {{echo|<div>}}
13398 {{echo|</div>}}
13399 !! html/parsoid
13400 <table about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;table>&lt;tr>&lt;td>&lt;table>"}},"i":0}},"\n",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;div>"}},"i":1}},"\n",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;/div>"}},"i":2}}]}' data-parsoid='{"stx":"html","autoInsertedEnd":true,"pi":[[{"k":"1"}],[{"k":"1"}],[{"k":"1"}]]}'><tbody><tr data-parsoid='{"stx":"html"}'><td data-parsoid='{"stx":"html"}'><div data-parsoid='{"stx":"html"}'>
13401 </div><table about="#mwt1" data-parsoid='{"stx":"html"}'>
13402 </table></td></tr></tbody></table>
13403 !! end
13404
13405 !! test
13406 Templates: Parameters substituted at the top-level
13407 !! wikitext
13408 {{{foo|''who'' {{echo|me}}? '''never!'''}}}
13409
13410 {{{foo|bar|baz}}}
13411 !! html/php
13412 <p><i>who</i> me? <b>never!</b>
13413 </p><p>bar
13414 </p>
13415 !! html/parsoid
13416 <p about="#mwt2" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"foo"},"params":{"1":{"wt":"&#39;&#39;who&#39;&#39; {{echo|me}}? &#39;&#39;&#39;never!&#39;&#39;&#39;"}},"i":0}}]}'><i>who</i> me? <b>never!</b></p>
13417
13418 <p about="#mwt3" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"foo"},"params":{"1":{"wt":"bar"},"2":{"wt":"baz"}},"i":0}}]}'>bar</p>
13419 !! end
13420
13421 !! test
13422 Templates: Param with empty arg in the final position
13423 !! wikitext
13424 {{{hi|}}}
13425 !! html/parsoid
13426 <span about="#mwt1" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"hi"},"params":{"1":{"wt":""}},"i":0}}]}'></span>
13427 !! end
13428
13429 !!test
13430 Parser Functions: 1. Simple example
13431 !! wikitext
13432 {{uc:foo}}
13433 !! html
13434 <p>FOO
13435 </p>
13436 !!end
13437
13438 !!test
13439 Parser Functions: 2. Nested use (only outermost should be marked up)
13440 !! wikitext
13441 {{uc:{{lc:FOO}}}}
13442 !! html
13443 <p>FOO
13444 </p>
13445 !!end
13446
13447 ###
13448 ### Pre-save transform tests
13449 ###
13450 !! test
13451 pre-save transform: subst:
13452 !! options
13453 pst
13454 !! wikitext
13455 {{subst:test}}
13456 !! html/php
13457 This is a test template
13458 !! end
13459
13460 !! test
13461 pre-save transform: normal template
13462 !! options
13463 pst
13464 !! wikitext
13465 {{test}}
13466 !! html/php
13467 {{test}}
13468 !! end
13469
13470 !! test
13471 pre-save transform: nonexistent template
13472 !! options
13473 pst
13474 !! wikitext
13475 {{thistemplatedoesnotexist}}
13476 !! html/php
13477 {{thistemplatedoesnotexist}}
13478 !! end
13479
13480 !! test
13481 pre-save transform: subst magic variables
13482 !! options
13483 pst
13484 !! wikitext
13485 {{subst:SITENAME}}
13486 !! html/php
13487 MediaWiki
13488 !! end
13489
13490 # This is T2089, which I fixed. -- wtm
13491 !! test
13492 pre-save transform: subst: templates with parameters
13493 !! options
13494 pst
13495 !! wikitext
13496 {{subst:paramtest|param="something else"}}
13497 !! html/php
13498 This is a test template with parameter "something else"
13499 !! end
13500
13501 !! article
13502 Template:nowikitest
13503 !! text
13504 <nowiki>'''not wiki'''</nowiki>
13505 !! endarticle
13506
13507 !! test
13508 pre-save transform: nowiki in subst (T3188)
13509 !! options
13510 pst
13511 !! wikitext
13512 {{subst:nowikitest}}
13513 !! html/php
13514 <nowiki>'''not wiki'''</nowiki>
13515 !! end
13516
13517 !! article
13518 Template:commenttest
13519 !! text
13520 This template has <!-- a comment --> in it.
13521 !! endarticle
13522
13523 !! test
13524 pre-save transform: comment in subst (T3936)
13525 !! options
13526 pst
13527 !! wikitext
13528 {{subst:commenttest}}
13529 !! html/php
13530 This template has <!-- a comment --> in it.
13531 !! end
13532
13533 !! test
13534 pre-save transform: unclosed tag
13535 !! options
13536 pst
13537 !! wikitext
13538 <nowiki>'''not wiki'''
13539 !! html/php
13540 <nowiki>'''not wiki'''
13541 !! end
13542
13543 !! test
13544 pre-save transform: mixed tag case
13545 !! options
13546 pst
13547 !! wikitext
13548 <NOwiki>'''not wiki'''</noWIKI>
13549 !! html/php
13550 <NOwiki>'''not wiki'''</noWIKI>
13551 !! end
13552
13553 !! test
13554 pre-save transform: unclosed comment in <nowiki>
13555 !! options
13556 pst
13557 !! wikitext
13558 wiki<nowiki>nowiki<!--nowiki</nowiki>wiki
13559 !! html/php
13560 wiki<nowiki>nowiki<!--nowiki</nowiki>wiki
13561 !!end
13562
13563 # Leading @ in this template definition works around a limitation
13564 # in parsoid's parserTests which otherwise strips the <span> from the
13565 # result (confusing it for a template wrapper)
13566 !! article
13567 Template:dangerous
13568 !!text
13569 @<span onmouseover="alert('crap')">Oh no</span>
13570 !!endarticle
13571
13572 !!test
13573 (confirming safety of fix for subst T3936)
13574 !! wikitext
13575 {{Template:dangerous}}
13576 !! html
13577 <p>@<span>Oh no</span>
13578 </p>
13579 !! end
13580
13581 !! test
13582 pre-save transform: comment containing gallery (T7024)
13583 !! options
13584 pst
13585 !! wikitext
13586 <!-- <gallery>data</gallery> -->
13587 !! html/php
13588 <!-- <gallery>data</gallery> -->
13589 !!end
13590
13591 !! test
13592 pre-save transform: comment containing extension
13593 !! options
13594 pst
13595 !! wikitext
13596 <!-- <tag>data</tag> -->
13597 !! html/php
13598 <!-- <tag>data</tag> -->
13599 !!end
13600
13601 !! test
13602 pre-save transform: comment containing nowiki
13603 !! options
13604 pst
13605 !! wikitext
13606 <!-- <nowiki>data</nowiki> -->
13607 !! html/php
13608 <!-- <nowiki>data</nowiki> -->
13609 !!end
13610
13611 !! test
13612 pre-save transform: <noinclude> in subst (T5298)
13613 !! options
13614 pst
13615 !! wikitext
13616 {{subst:Includes}}
13617 !! html/php
13618 Foobar
13619 !! end
13620
13621 !! test
13622 pre-save transform: <onlyinclude> in subst (T5298)
13623 !! options
13624 pst
13625 !! wikitext
13626 {{subst:Includes2}}
13627 !! html/php
13628 Foo
13629 !! end
13630
13631 !! article
13632 Template:SubstTest
13633 !!text
13634 {{<includeonly>subst:</includeonly>Includes}}
13635 !! endarticle
13636
13637 !! article
13638 Template:SafeSubstTest
13639 !! text
13640 {{<includeonly>safesubst:</includeonly>Includes}}
13641 !! endarticle
13642
13643 !! test
13644 T24297: safesubst: works during PST
13645 !! options
13646 pst
13647 !! wikitext
13648 {{subst:SafeSubstTest}}{{safesubst:SubstTest}}
13649 !! html/php
13650 FoobarFoobar
13651 !! end
13652
13653 !! test
13654 T24297: safesubst: works during normal parse
13655 !! wikitext
13656 {{SafeSubstTest}}
13657 !! html
13658 <p>Foobar
13659 </p>
13660 !! end
13661
13662 !! test
13663 subst: does not work during normal parse
13664 !! wikitext
13665 {{SubstTest}}
13666 !! html
13667 <p>{{subst:Includes}}
13668 </p>
13669 !! end
13670
13671 !! test
13672 pre-save transform: context links ("pipe trick")
13673 !! options
13674 pst
13675 !! wikitext
13676 [[Article (context)|]]
13677 [[Bar:Article|]]
13678 [[:Bar:Article|]]
13679 [[Bar:Article (context)|]]
13680 [[:Bar:Article (context)|]]
13681 [[|Article]]
13682 [[|Article (context)]]
13683 [[Bar:X (Y) Z|]]
13684 [[:Bar:X (Y) Z|]]
13685 !! html/php
13686 [[Article (context)|Article]]
13687 [[Bar:Article|Article]]
13688 [[:Bar:Article|Article]]
13689 [[Bar:Article (context)|Article]]
13690 [[:Bar:Article (context)|Article]]
13691 [[Article]]
13692 [[Article (context)]]
13693 [[Bar:X (Y) Z|X (Y) Z]]
13694 [[:Bar:X (Y) Z|X (Y) Z]]
13695 !! end
13696
13697 !! test
13698 pre-save transform: context links ("pipe trick") with interwiki prefix
13699 !! options
13700 pst
13701 !! wikitext
13702 [[interwiki:Article|]]
13703 [[:interwiki:Article|]]
13704 [[interwiki:Bar:Article|]]
13705 [[:interwiki:Bar:Article|]]
13706 !! html/php
13707 [[interwiki:Article|Article]]
13708 [[:interwiki:Article|Article]]
13709 [[interwiki:Bar:Article|Bar:Article]]
13710 [[:interwiki:Bar:Article|Bar:Article]]
13711 !! end
13712
13713 !! test
13714 pre-save transform: context links ("pipe trick") with parens in title
13715 !! options
13716 pst title=[[Somearticle (context)]]
13717 !! wikitext
13718 [[|Article]]
13719 !! html/php
13720 [[Article (context)|Article]]
13721 !! end
13722
13723 !! test
13724 pre-save transform: context links ("pipe trick") with comma in title
13725 !! options
13726 pst title=[[Someplace, Somewhere]]
13727 !! wikitext
13728 [[|Otherplace]]
13729 [[Otherplace, Elsewhere|]]
13730 [[Otherplace, Elsewhere, Anywhere|]]
13731 !! html/php
13732 [[Otherplace, Somewhere|Otherplace]]
13733 [[Otherplace, Elsewhere|Otherplace]]
13734 [[Otherplace, Elsewhere, Anywhere|Otherplace]]
13735 !! end
13736
13737 !! test
13738 pre-save transform: context links ("pipe trick") with parens and comma
13739 !! options
13740 pst title=[[Someplace (IGNORED), Somewhere]]
13741 !! wikitext
13742 [[|Otherplace]]
13743 [[Otherplace (place), Elsewhere|]]
13744 !! html/php
13745 [[Otherplace, Somewhere|Otherplace]]
13746 [[Otherplace (place), Elsewhere|Otherplace]]
13747 !! end
13748
13749 !! test
13750 pre-save transform: context links ("pipe trick") with comma and parens
13751 !! options
13752 pst title=[[Who, me? (context)]]
13753 !! wikitext
13754 [[|Yes, you.]]
13755 [[Me, Myself, and I (1937 song)|]]
13756 !! html/php
13757 [[Yes, you. (context)|Yes, you.]]
13758 [[Me, Myself, and I (1937 song)|Me, Myself, and I]]
13759 !! end
13760
13761 !! test
13762 pre-save transform: context links ("pipe trick") with namespace
13763 !! options
13764 pst title=[[Ns:Somearticle]]
13765 !! wikitext
13766 [[|Article]]
13767 !! html/php
13768 [[Ns:Article|Article]]
13769 !! end
13770
13771 !! test
13772 pre-save transform: context links ("pipe trick") with namespace and parens
13773 !! options
13774 pst title=[[Ns:Somearticle (context)]]
13775 !! wikitext
13776 [[|Article]]
13777 !! html/php
13778 [[Ns:Article (context)|Article]]
13779 !! end
13780
13781 !! test
13782 pre-save transform: context links ("pipe trick") with namespace and comma
13783 !! options
13784 pst title=[[Ns:Somearticle, Context, Whatever]]
13785 !! wikitext
13786 [[|Article]]
13787 !! html/php
13788 [[Ns:Article, Context, Whatever|Article]]
13789 !! end
13790
13791 !! test
13792 pre-save transform: context links ("pipe trick") with namespace, comma and parens
13793 !! options
13794 pst title=[[Ns:Somearticle, Context (context)]]
13795 !! wikitext
13796 [[|Article]]
13797 !! html/php
13798 [[Ns:Article (context)|Article]]
13799 !! end
13800
13801 !! test
13802 pre-save transform: context links ("pipe trick") with namespace, parens and comma
13803 !! options
13804 pst title=[[Ns:Somearticle (IGNORED), Context]]
13805 !! wikitext
13806 [[|Article]]
13807 !! html/php
13808 [[Ns:Article, Context|Article]]
13809 !! end
13810
13811 !! test
13812 pre-save transform: context links ("pipe trick") with full-width parens and no space (Japanese and Chinese style, T32149)
13813 !! options
13814 pst
13815 !! wikitext
13816 [[Article(context)|]]
13817 [[Bar:Article(context)|]]
13818 [[:Bar:Article(context)|]]
13819 [[|Article(context)]]
13820 [[Bar:X(Y)Z|]]
13821 [[:Bar:X(Y)Z|]]
13822 !! html/php
13823 [[Article(context)|Article]]
13824 [[Bar:Article(context)|Article]]
13825 [[:Bar:Article(context)|Article]]
13826 [[Article(context)]]
13827 [[Bar:X(Y)Z|X(Y)Z]]
13828 [[:Bar:X(Y)Z|X(Y)Z]]
13829 !! end
13830
13831 !! test
13832 pre-save transform: context links ("pipe trick") with full-width parens and space (Japanese and Chinese style, T32149)
13833 !! options
13834 pst
13835 !! wikitext
13836 [[Article (context)|]]
13837 [[Bar:Article (context)|]]
13838 [[:Bar:Article (context)|]]
13839 [[|Article (context)]]
13840 [[Bar:X (Y) Z|]]
13841 [[:Bar:X (Y) Z|]]
13842 !! html/php
13843 [[Article (context)|Article]]
13844 [[Bar:Article (context)|Article]]
13845 [[:Bar:Article (context)|Article]]
13846 [[Article (context)]]
13847 [[Bar:X (Y) Z|X (Y) Z]]
13848 [[:Bar:X (Y) Z|X (Y) Z]]
13849 !! end
13850
13851 !! test
13852 pre-save transform: context links ("pipe trick") with parens and no space (Korean style, T32149)
13853 !! options
13854 pst
13855 !! wikitext
13856 [[Article(context)|]]
13857 [[Bar:Article(context)|]]
13858 [[:Bar:Article(context)|]]
13859 [[|Article(context)]]
13860 [[Bar:X(Y)Z|]]
13861 [[:Bar:X(Y)Z|]]
13862 !! html/php
13863 [[Article(context)|Article]]
13864 [[Bar:Article(context)|Article]]
13865 [[:Bar:Article(context)|Article]]
13866 [[Article(context)]]
13867 [[Bar:X(Y)Z|X(Y)Z]]
13868 [[:Bar:X(Y)Z|X(Y)Z]]
13869 !! end
13870
13871 !! test
13872 pre-save transform: context links ("pipe trick") with commas (T23660)
13873 !! options
13874 pst
13875 !! wikitext
13876 [[Article (context), context|]]
13877 [[Article (context),context|]]
13878 [[Bar:Article (context), context|]]
13879 [[Bar:Article (context),context|]]
13880 [[:Bar:Article (context), context|]]
13881 [[:Bar:Article (context),context|]]
13882 !! html/php
13883 [[Article (context), context|Article]]
13884 [[Article (context),context|Article]]
13885 [[Bar:Article (context), context|Article]]
13886 [[Bar:Article (context),context|Article]]
13887 [[:Bar:Article (context), context|Article]]
13888 [[:Bar:Article (context),context|Article]]
13889 !! end
13890
13891 !! test
13892 Parsoid: backwards pipe trick
13893 !! wikitext
13894 [[|'''bar''']]
13895 !! html/php
13896 <p>[[|<b>bar</b>]]
13897 </p>
13898 !! html/parsoid
13899 <p>[[|<b>bar</b>]]</p>
13900 !! end
13901
13902 !! test
13903 pre-save transform: trim trailing empty lines
13904 !! options
13905 pst
13906 !! wikitext
13907 Empty lines are trimmed
13908
13909
13910
13911
13912 !! html/php
13913 Empty lines are trimmed
13914 !! end
13915
13916 !! test
13917 pre-save transform: Signature expansion
13918 !! options
13919 pst
13920 !! wikitext
13921 * ~~~
13922 * ~~~~
13923 * ~~~~~
13924 * <noinclude>~~~</noinclude>
13925 * <includeonly>~~~</includeonly>
13926 * <onlyinclude>~~~</onlyinclude>
13927 !! html/php
13928 * [[Special:Contributions/127.0.0.1|127.0.0.1]]
13929 * [[Special:Contributions/127.0.0.1|127.0.0.1]] 00:02, 1 January 1970 (UTC)
13930 * 00:02, 1 January 1970 (UTC)
13931 * <noinclude>[[Special:Contributions/127.0.0.1|127.0.0.1]]</noinclude>
13932 * <includeonly>[[Special:Contributions/127.0.0.1|127.0.0.1]]</includeonly>
13933 * <onlyinclude>[[Special:Contributions/127.0.0.1|127.0.0.1]]</onlyinclude>
13934 !! end
13935
13936
13937 !! test
13938 ParserOutput flags from signature expansion (T84843)
13939 !! options
13940 pst
13941 showflags
13942 !! wikitext
13943 ~~~~
13944 !! html/php
13945 [[Special:Contributions/127.0.0.1|127.0.0.1]] 00:02, 1 January 1970 (UTC)
13946 flags=user-signature
13947 !! end
13948
13949
13950 !! test
13951 pre-save transform: Signature expansion in nowiki tags (T2093)
13952 !! options
13953 pst disabled
13954 !! wikitext
13955 Shall not expand:
13956
13957 <nowiki>~~~~</nowiki>
13958
13959 <includeonly><nowiki>~~~~</nowiki></includeonly>
13960
13961 <noinclude><nowiki>~~~~</nowiki></noinclude>
13962
13963 <onlyinclude><nowiki>~~~~</nowiki></onlyinclude>
13964
13965 {{subst:Foo}} shall be converted to FOO
13966
13967 As well as inside noinclude/onlyinclude
13968 <noinclude>{{subst:Foo}}</noinclude>
13969 <onlyinclude>{{subst:Foo}}</onlyinclude>
13970
13971 But not inside includeonly
13972 <includeonly>{{subst:Foo}}</includeonly>
13973 !! html/php
13974 Shall not expand:
13975
13976 <nowiki>~~~~</nowiki>
13977
13978 <includeonly><nowiki>~~~~</nowiki></includeonly>
13979
13980 <noinclude><nowiki>~~~~</nowiki></noinclude>
13981
13982 <onlyinclude><nowiki>~~~~</nowiki></onlyinclude>
13983
13984 FOO shall be converted to FOO
13985
13986 As well as inside noinclude/onlyinclude
13987 <noinclude>FOO</noinclude>
13988 <onlyinclude>FOO</onlyinclude>
13989
13990 But not inside includeonly
13991 <includeonly>{{subst:Foo}}</includeonly>
13992 !! end
13993
13994 !! test
13995 Parsoid: Recognize nowiki with trailing space in tags
13996 !! options
13997 parsoid=wt2html
13998 !! wikitext
13999 <nowiki ><div>[[foo]]</nowiki >
14000
14001 a<nowiki / >b
14002
14003 c<nowiki />d
14004
14005 e<nowiki/ >f
14006 !! html
14007 <p><span typeof="mw:Nowiki">&lt;div&gt;[[foo]]</span></p>
14008 <p>ab</p>
14009 <p>cd</p>
14010 <p>ef</p>
14011 !! end
14012
14013 !! test
14014 Parsoid: Recognize nowiki with odd capitalization
14015 !! options
14016 parsoid=wt2html
14017 !! wikitext
14018 <noWikI ><div>[[foo]]</Nowiki >
14019 !! html
14020 <p><span typeof="mw:Nowiki">&lt;div&gt;[[foo]]</span></p>
14021 !! end
14022
14023
14024 !! test
14025 Parsoid: Escape nowiki with trailing space in tags
14026 !! options
14027 parsoid=html2wt
14028 !! html/parsoid
14029 <p>&lt;nowiki &gt; foo &lt/nowiki ></p>
14030 <p>a&lt;nowiki /&gt;b</p>
14031 <p>c&lt;nowiki/ &gt;d</p>
14032 !! wikitext
14033 &lt;nowiki &gt; foo &lt;/nowiki &gt;
14034
14035 a&lt;nowiki /&gt;b
14036
14037 c&lt;nowiki/ &gt;d
14038 !! end
14039
14040 !! test
14041 Parsoid: Escape weird noWikI capitalizations
14042 !! options
14043 parsoid=html2wt
14044 !! html/parsoid
14045 <p>&lt;noWikI &gt; foo &lt/NoWikI ></p>
14046 !! wikitext
14047 &lt;noWikI &gt; foo &lt;/NoWikI &gt;
14048 !! end
14049
14050 ###
14051 ### Message transform tests
14052 ###
14053 !! test
14054 message transform: magic variables
14055 !! options
14056 msg
14057 !! wikitext
14058 {{SITENAME}}
14059 !! html
14060 MediaWiki
14061 !! end
14062
14063 !! test
14064 message transform: should not transform wiki markup
14065 !! options
14066 msg
14067 !! wikitext
14068 ''test''
14069 !! html
14070 ''test''
14071 !! end
14072
14073 !! test
14074 message transform: <noinclude> in transcluded template (T6926)
14075 !! options
14076 msg
14077 !! wikitext
14078 {{Includes}}
14079 !! html
14080 Foobar
14081 !! end
14082
14083 !! test
14084 message transform: <onlyinclude> in transcluded template (T6926)
14085 !! options
14086 msg
14087 !! wikitext
14088 {{Includes2}}
14089 !! html
14090 Foo
14091 !! end
14092
14093 !! test
14094 {{#special:}} page name, known
14095 !! options
14096 msg
14097 !! wikitext
14098 {{#special:Recentchanges}}
14099 !! html
14100 Special:RecentChanges
14101 !! end
14102
14103 !! test
14104 {{#special:}} page name with subpage, known
14105 !! options
14106 msg
14107 !! wikitext
14108 {{#special:Recentchanges/param}}
14109 !! html
14110 Special:RecentChanges/param
14111 !! end
14112
14113 !! test
14114 {{#special:}} page name, unknown
14115 !! options
14116 msg
14117 !! wikitext
14118 {{#special:foobar nonexistent}}
14119 !! html
14120 Special:Foobar nonexistent
14121 !! end
14122
14123 !! test
14124 {{#speciale:}} page name, known
14125 !! options
14126 msg
14127 !! wikitext
14128 {{#speciale:Recentchanges}}
14129 !! html
14130 Special:RecentChanges
14131 !! end
14132
14133 !! test
14134 {{#speciale:}} page name with subpage, known
14135 !! options
14136 msg
14137 !! wikitext
14138 {{#speciale:Recentchanges/param}}
14139 !! html
14140 Special:RecentChanges/param
14141 !! end
14142
14143 !! test
14144 {{#speciale:}} page name, unknown
14145 !! options
14146 msg
14147 !! wikitext
14148 {{#speciale:foobar nonexistent}}
14149 !! html
14150 Special:Foobar_nonexistent
14151 !! end
14152
14153 ###
14154 ### Images
14155 ###
14156 ### For Parsoid-specific tests, see
14157 #### https://www.mediawiki.org/wiki/Parsoid/MediaWiki_DOM_spec#Images
14158
14159 !! test
14160 Simple image
14161 !! options
14162 parsoid=wt2html,wt2wt,html2html
14163 !! wikitext
14164 [[Image:foobar.jpg]]
14165 !! html/php
14166 <p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14167 </p>
14168 !! html/parsoid
14169 <p><span class="mw-default-size" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></span></p>
14170 !! end
14171
14172 !! test
14173 Serialize simple image with figure-inline wrapper
14174 !! options
14175 parsoid=html2wt
14176 !! html/parsoid
14177 <p><figure-inline class="mw-default-size" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></figure-inline></p>
14178 !! wikitext
14179 [[File:Foobar.jpg]]
14180 !! end
14181
14182 !! test
14183 Simple image (using File: namespace, now canonical)
14184 !! wikitext
14185 [[File:Foobar.jpg]]
14186 !! html/php
14187 <p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14188 </p>
14189 !! html/parsoid
14190 <p><span class="mw-default-size" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></span></p>
14191 !! end
14192
14193 !! test
14194 Right-aligned image
14195 !! wikitext
14196 [[File:Foobar.jpg|right]]
14197 !! html/php
14198 <div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div>
14199
14200 !! html/parsoid
14201 <figure class="mw-default-size mw-halign-right" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></figure>
14202 !! end
14203
14204 !! test
14205 Image with caption
14206 !! wikitext
14207 [[File:Foobar.jpg|right|Caption text]]
14208 !! html/php
14209 <div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image" title="Caption text"><img alt="Caption text" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div>
14210
14211 !! html/parsoid
14212 <figure class="mw-default-size mw-halign-right" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a><figcaption>Caption text</figcaption></figure>
14213 !! end
14214
14215 !! test
14216 Image with caption, T55312 #1
14217 !! wikitext
14218 [[File:Foobar.jpg|right|Caption page stuff]]
14219 !! html/php
14220 <div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image" title="Caption page stuff"><img alt="Caption page stuff" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div>
14221
14222 !! html/parsoid
14223 <figure class="mw-default-size mw-halign-right" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a><figcaption>Caption page stuff</figcaption></figure>
14224 !! end
14225
14226 !! test
14227 Image with caption, T55312 #2
14228 !! wikitext
14229 [[File:Foobar.jpg|right|Caption page=]]
14230 !! html/php
14231 <div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image" title="Caption page="><img alt="Caption page=" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div>
14232
14233 !! html/parsoid
14234 <figure class="mw-default-size mw-halign-right" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a><figcaption>Caption page=</figcaption></figure>
14235 !! end
14236
14237 !! test
14238 Image with caption, T55312 #3
14239 !! wikitext
14240 [[File:Foobar.jpg|right|Caption page=stuff]]
14241 !! html/php
14242 <div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image" title="Caption page=stuff"><img alt="Caption page=stuff" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div>
14243
14244 !! html/parsoid
14245 <figure class="mw-default-size mw-halign-right" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a><figcaption>Caption page=stuff</figcaption></figure>
14246 !! end
14247
14248 !! test
14249 Allow empty links in image captions (T62753)
14250 !! options
14251 thumbsize=220
14252 !! wikitext
14253 [[File:Foobar.jpg|thumb|Caption [[Link1]]
14254 [[]]
14255 [[Link2]]
14256 ]]
14257 !! html/php
14258 <div class="thumb tright"><div class="thumbinner" style="width:222px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" width="220" height="25" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>Caption <a href="/index.php?title=Link1&amp;action=edit&amp;redlink=1" class="new" title="Link1 (page does not exist)">Link1</a> [[]] <a href="/index.php?title=Link2&amp;action=edit&amp;redlink=1" class="new" title="Link2 (page does not exist)">Link2</a></div></div></div>
14259
14260 !! html/parsoid
14261 <figure class="mw-default-size" typeof="mw:Image/Thumb" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"},{"ck":"caption","ak":"Caption [[Link1]]\n[[]]\n[[Link2]]\n"}]}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"}}'><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"25","width":"220"},"sa":{"resource":"File:Foobar.jpg"}}'/></a><figcaption>Caption <a rel="mw:WikiLink" href="./Link1" title="Link1" data-parsoid='{"stx":"simple","a":{"href":"./Link1"},"sa":{"href":"Link1"}}'>Link1</a>
14262 [[]]
14263 <a rel="mw:WikiLink" href="./Link2" title="Link2" data-parsoid='{"stx":"simple","a":{"href":"./Link2"},"sa":{"href":"Link2"}}'>Link2</a>
14264 </figcaption></figure>
14265 !! end
14266
14267 !! test
14268 Titles in unlinked images (T23454)
14269 !! wikitext
14270 [[File:Foobar.jpg|link=|stuff]]
14271 !! html/php
14272 <p><img alt="stuff" src="http://example.com/images/3/3a/Foobar.jpg" title="stuff" width="1941" height="220" />
14273 </p>
14274 !! end
14275
14276 !! test
14277 Link with empty target
14278 !! wikitext
14279 [[]]
14280 !! html
14281 <p>[[]]
14282 </p>
14283 !! end
14284
14285 !! test
14286 Image with link trail
14287 !! wikitext
14288 Linktrails should not work for images: [[File:Foobar.jpg]]s
14289 !! html/php
14290 <p>Linktrails should not work for images: <a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>s
14291 </p>
14292 !! html/parsoid
14293 <p>Linktrails should not work for images: <span class="mw-default-size" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></span>s</p>
14294 !! end
14295
14296 !! test
14297 Image with empty attribute
14298 !! options
14299 parsoid=wt2html,wt2wt,html2html
14300 !! wikitext
14301 [[File:Foobar.jpg|right||Caption text]]
14302 !! html/php
14303 <div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image" title="Caption text"><img alt="Caption text" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div>
14304
14305 !! html/parsoid
14306 <figure class="mw-default-size mw-halign-right" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a><figcaption>Caption text</figcaption></figure>
14307 !! end
14308
14309 !! test
14310 1. Block image with individual attributes from templates
14311 !! wikitext
14312 [[File:Foobar.jpg|thumb|{{echo|137px}}|This is a caption]]
14313 !! html/php
14314 <div class="thumb tright"><div class="thumbinner" style="width:139px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/137px-Foobar.jpg" width="137" height="16" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/206px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/274px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>This is a caption</div></div></div>
14315
14316 !! html/parsoid
14317 <figure typeof="mw:Image/Thumb mw:ExpandedAttrs" about="#mwt2" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"},{"ck":"width","ak":"{{echo|137px}}"},{"ck":"caption","ak":"This is a caption"}]}' data-mw='{"attribs":[["thumbnail",{"html":"thumb"}],["width",{"html":"&lt;span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid=&#39;{\"pi\":[[{\"k\":\"1\"}]],\"dsr\":[24,38,null,null]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"137px\"}},\"i\":0}}]}&#39;>137px&lt;/span>"}]]}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{}}'><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/137px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="16" width="137" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"16","width":"137"},"sa":{"resource":"File:Foobar.jpg"}}'/></a><figcaption>This is a caption</figcaption></figure>
14318 !! end
14319
14320 !! test
14321 2. Block Image with individual attributes from templates
14322 !! wikitext
14323 [[File:Foobar.jpg|{{echo|thumb}}|{{echo|137px}}|This is a caption]]
14324 !! html/php
14325 <div class="thumb tright"><div class="thumbinner" style="width:139px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/137px-Foobar.jpg" width="137" height="16" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/206px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/274px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>This is a caption</div></div></div>
14326
14327 !! html/parsoid
14328 <figure typeof="mw:Image/Thumb mw:ExpandedAttrs" about="#mwt3" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"{{echo|thumb}}"},{"ck":"width","ak":"{{echo|137px}}"},{"ck":"caption","ak":"This is a caption"}]}' data-mw='{"attribs":[["thumbnail",{"html":"&lt;span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid=&#39;{\"pi\":[[{\"k\":\"1\"}]],\"dsr\":[18,32,null,null]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"thumb\"}},\"i\":0}}]}&#39;>thumb&lt;/span>"}],["width",{"html":"&lt;span about=\"#mwt2\" typeof=\"mw:Transclusion\" data-parsoid=&#39;{\"pi\":[[{\"k\":\"1\"}]],\"dsr\":[33,47,null,null]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"137px\"}},\"i\":0}}]}&#39;>137px&lt;/span>"}]]}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{}}'><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/137px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="16" width="137" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"16","width":"137"},"sa":{"resource":"File:Foobar.jpg"}}'/></a><figcaption>This is a caption</figcaption></figure>
14329 !! end
14330
14331 !! test
14332 3. Inline image with individual attributes from templates
14333 !! wikitext
14334 [[File:Foobar.jpg|{{echo|50px}}]]
14335 !! html/php
14336 <p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/50px-Foobar.jpg" width="50" height="6" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/75px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/100px-Foobar.jpg 2x" /></a>
14337 </p>
14338 !! html/parsoid
14339 <p><span typeof="mw:Image mw:ExpandedAttrs" about="#mwt2" data-parsoid='{"optList":[{"ck":"width","ak":"{{echo|50px}}"}]}' data-mw='{"attribs":[["width",{"html":"&lt;span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid=&#39;{\"pi\":[[{\"k\":\"1\"}]],\"dsr\":[18,31,null,null]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"50px\"}},\"i\":0}}]}&#39;>50px&lt;/span>"}]]}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{}}'><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/50px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="6" width="50" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"6","width":"50"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></span></p>
14340 !! end
14341
14342 ## Parsoid does not provide editing support for images where templates produce multiple image attributes.
14343 ## To signal this, we add a 'mw:Placeholder' type to such images. This could change in the future.
14344 !! test
14345 Image with multiple attributes from the same template
14346 !! wikitext
14347 [[File:Foobar.jpg|{{image_attribs}}]]
14348 !! html/php
14349 <div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image" title="Caption text"><img alt="Caption text" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div>
14350
14351 !! html/parsoid
14352 <figure class="mw-default-size mw-halign-right" typeof="mw:Image mw:Placeholder"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a><figcaption>Caption text</figcaption></figure>
14353 !! end
14354
14355 !! test
14356 Image with link tails
14357 !! options
14358 thumbsize=220
14359 !! wikitext
14360 123[[File:Foobar.jpg]]456
14361 123[[File:Foobar.jpg|right]]456
14362 123[[File:Foobar.jpg|thumb]]456
14363 !! html/php
14364 <p>123<a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>456
14365 </p>
14366 123<div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div>456
14367 123<div class="thumb tright"><div class="thumbinner" style="width:222px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" width="220" height="25" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div></div></div></div>456
14368
14369 !! html/php+tidy
14370 <p>123<a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>456</p>
14371 <p>123</p>
14372 <div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div>
14373 <p>456 123</p>
14374 <div class="thumb tright">
14375 <div class="thumbinner" style="width:222px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" width="220" height="25" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a>
14376 <div class="thumbcaption">
14377 <div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>
14378 </div>
14379 </div>
14380 </div>
14381 <p>456</p>
14382 !! html/parsoid
14383 <p>123<span class="mw-default-size" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></span>456</p>
14384 <p>123</p><figure class="mw-default-size mw-halign-right" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></figure><p>456</p>
14385 <p>123</p><figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a></figure><p>456</p>
14386 !! end
14387
14388 !! test
14389 Image with multiple captions -- only last one is accepted
14390 !! wikitext
14391 [[File:Foobar.jpg|right|Caption1 - ignored|[[Caption2]] - ignored|Caption3 - accepted]]
14392 !! html/php
14393 <div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image" title="Caption3 - accepted"><img alt="Caption3 - accepted" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div>
14394
14395 !! html/parsoid
14396 <figure class="mw-default-size mw-halign-right" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a><figcaption>Caption3 - accepted</figcaption></figure>
14397 !! end
14398
14399 !! test
14400 Image with multiple widths -- use last
14401 !! wikitext
14402 [[File:Foobar.jpg|200px|300px|caption]]
14403 !! html/php
14404 <p><a href="/wiki/File:Foobar.jpg" class="image" title="caption"><img alt="caption" src="http://example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg" width="300" height="34" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/450px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/600px-Foobar.jpg 2x" /></a>
14405 </p>
14406 !! html/parsoid
14407 <p><span typeof="mw:Image" data-mw='{"caption":"caption"}'><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="34" width="300"/></a></span></p>
14408 !! end
14409
14410 !! test
14411 Image with multiple alignments -- use first (T50664)
14412 !! options
14413 thumbsize=220
14414 !! wikitext
14415 [[File:Foobar.jpg|thumb|left|right|center|caption]]
14416
14417 [[File:Foobar.jpg|middle|text-top|caption]]
14418 !! html/php
14419 <div class="thumb tleft"><div class="thumbinner" style="width:222px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" width="220" height="25" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>caption</div></div></div>
14420 <p><a href="/wiki/File:Foobar.jpg" class="image" title="caption"><img alt="caption" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" style="vertical-align: middle" /></a>
14421 </p>
14422 !! html/parsoid
14423 <figure class="mw-default-size mw-halign-left" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption>caption</figcaption></figure>
14424 <p><span class="mw-default-size mw-valign-middle" typeof="mw:Image" data-mw='{"caption":"caption"}'><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></span></p>
14425 !! end
14426
14427 !! test
14428 Image with width attribute at different positions
14429 !! wikitext
14430 [[File:Foobar.jpg|200px|right|Caption]]
14431 [[File:Foobar.jpg|right|200px|Caption]]
14432 [[File:Foobar.jpg|right|Caption|200px]]
14433 !! html/php
14434 <div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image" title="Caption"><img alt="Caption" src="http://example.com/images/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg" width="200" height="23" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/400px-Foobar.jpg 2x" /></a></div>
14435 <div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image" title="Caption"><img alt="Caption" src="http://example.com/images/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg" width="200" height="23" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/400px-Foobar.jpg 2x" /></a></div>
14436 <div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image" title="Caption"><img alt="Caption" src="http://example.com/images/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg" width="200" height="23" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/400px-Foobar.jpg 2x" /></a></div>
14437
14438 !! html/parsoid
14439 <figure class="mw-halign-right" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="23" width="200"/></a><figcaption>Caption</figcaption></figure>
14440 <figure class="mw-halign-right" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="23" width="200"/></a><figcaption>Caption</figcaption></figure>
14441 <figure class="mw-halign-right" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="23" width="200"/></a><figcaption>Caption</figcaption></figure>
14442 !! end
14443
14444 # a sad bit of backward-compatibility
14445 !! test
14446 Image with size specified with pxpx (T15500, T53628)
14447 !! options
14448 parsoid=wt2html,wt2wt,html2html
14449 !! wikitext
14450 [[File:Foobar.jpg|20pxpx]]
14451 [[File:Foobar.jpg|200x20pxpx]]
14452 !! html/php
14453 <p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/20px-Foobar.jpg" width="20" height="2" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/30px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/40px-Foobar.jpg 2x" /></a>
14454 <a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/177px-Foobar.jpg" width="177" height="20" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/265px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/353px-Foobar.jpg 2x" /></a>
14455 </p>
14456 !! html/parsoid
14457 <p><span typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/20px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="2" width="20"/></a></span> <span typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/177px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="20" width="177"/></a></span></p>
14458 !! end
14459
14460 !! test
14461 Image with link parameter, wiki target
14462 !! wikitext
14463 [[File:Foobar.jpg|link=Main Page]]
14464 !! html/php
14465 <p><a href="/wiki/Main_Page" title="Main Page"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14466 </p>
14467 !! html/parsoid
14468 <p><span class="mw-default-size" typeof="mw:Image"><a href="./Main_Page"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></span></p>
14469 !! end
14470
14471 # parsoid T51293 (part 1)
14472 !! test
14473 Image with link parameter, URL target
14474 !! wikitext
14475 [[File:Foobar.jpg|link=http://example.com/]]
14476 !! html/php
14477 <p><a href="http://example.com/" rel="nofollow"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14478 </p>
14479 !! html/parsoid
14480 <p><span class="mw-default-size" typeof="mw:Image"><a href="http://example.com/"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></span></p>
14481 !! end
14482
14483 # parsoid T51293 (part 2)
14484 !! test
14485 Image with link parameter, protocol-less URL target
14486 !! wikitext
14487 [[File:Foobar.jpg|link=//example.com/]]
14488 !! html/php
14489 <p><a href="//example.com/" rel="nofollow"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14490 </p>
14491 !! html/parsoid
14492 <p><span class="mw-default-size" typeof="mw:Image"><a href="//example.com/"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></span></p>
14493 !! end
14494
14495 !! test
14496 Escaping non-block captions (T107435)
14497 !! options
14498 parsoid={
14499 "modes": ["wt2wt"],
14500 "changes": [
14501 ["[typeof~='mw:Image']", "attr", "data-mw", "{\"caption\": \"|\"}"]
14502 ]
14503 }
14504 !! wikitext
14505 [[Image:Foobar.jpg|caption]]
14506 !! wikitext/edited
14507 [[Image:Foobar.jpg|<nowiki>|</nowiki>]]
14508 !! end
14509
14510 # wgExternalLinkTarget not supported by Parsoid
14511 !! test
14512 Image with link parameter, wgExternalLinkTarget
14513 !! wikitext
14514 [[Image:foobar.jpg|link=http://example.com/]]
14515 !! config
14516 wgExternalLinkTarget='foobar'
14517 !! html/php
14518 <p><a href="http://example.com/" target="foobar" rel="nofollow noreferrer noopener"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14519 </p>
14520 !! end
14521
14522 !! test
14523 Image with link parameter, wgNoFollowLinks set to false
14524 !! wikitext
14525 [[Image:foobar.jpg|link=http://example.com/]]
14526 !! config
14527 wgNoFollowLinks=false
14528 !! html
14529 <p><a href="http://example.com/"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14530 </p>
14531 !! end
14532
14533 !! test
14534 Image with link parameter, wgNoFollowDomainExceptions
14535 !! wikitext
14536 [[Image:foobar.jpg|link=http://example.com/]]
14537 !! config
14538 wgNoFollowDomainExceptions='example.com'
14539 !! html
14540 <p><a href="http://example.com/"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14541 </p>
14542 !! end
14543
14544 # wgExternalLinkTarget not supported by Parsoid
14545 !! test
14546 Image with link parameter, wgExternalLinkTarget, unnamed parameter
14547 !! wikitext
14548 [[Image:foobar.jpg|link=http://example.com/|Title]]
14549 !! config
14550 wgExternalLinkTarget='foobar'
14551 !! html/php
14552 <p><a href="http://example.com/" title="Title" target="foobar" rel="nofollow noreferrer noopener"><img alt="Title" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14553 </p>
14554 !! end
14555
14556 !! test
14557 Image with empty link parameter
14558 !! wikitext
14559 [[File:Foobar.jpg|link=]]
14560 !! html/php
14561 <p><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" />
14562 </p>
14563 !! html/parsoid
14564 <p><span class="mw-default-size" typeof="mw:Image"><span><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></span></span></p>
14565 !! end
14566
14567 !! test
14568 Image with link parameter (wiki target) and unnamed parameter
14569 !! wikitext
14570 [[File:Foobar.jpg|link=Main_Page|Title]]
14571 !! html/php
14572 <p><a href="/wiki/Main_Page" title="Title"><img alt="Title" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14573 </p>
14574 !! html/parsoid
14575 <p><span class="mw-default-size" typeof="mw:Image" data-mw='{"caption":"Title"}'><a href="./Main_Page"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></span></p>
14576 !! end
14577
14578 !! test
14579 Image with link parameter (URL target) and unnamed parameter
14580 !! wikitext
14581 [[File:Foobar.jpg|link=http://example.com/|Title]]
14582 !! html/php
14583 <p><a href="http://example.com/" title="Title" rel="nofollow"><img alt="Title" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14584 </p>
14585 !! html/parsoid
14586 <p><span class="mw-default-size" typeof="mw:Image" data-mw='{"caption":"Title"}'><a href="http://example.com/"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></span></p>
14587 !! end
14588
14589 !! test
14590 Thumbnail image with link parameter
14591 !! options
14592 thumbsize=220
14593 parsoid=wt2html,wt2wt,html2html
14594 !! wikitext
14595 [[File:Foobar.jpg|thumb|link=http://example.com/|Title]]
14596 !! html/php
14597 <div class="thumb tright"><div class="thumbinner" style="width:222px;"><a href="http://example.com/"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" width="220" height="25" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>Title</div></div></div>
14598
14599 !! html/parsoid
14600 <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="http://example.com/"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption>Title</figcaption></figure>
14601 !! end
14602
14603 !! test
14604 Manually-specified thumbnail image
14605 !! options
14606 thumbsize=220
14607 !! wikitext
14608 [[File:Foobar.jpg|thumbnail=Thumb.png|Title]]
14609 !! html/php
14610 <div class="thumb tright"><div class="thumbinner" style="width:137px;"><a href="/wiki/File:Foobar.jpg"><img alt="" src="http://example.com/images/e/ea/Thumb.png" width="135" height="135" class="thumbimage" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>Title</div></div></div>
14611
14612 !! html/parsoid
14613 <figure class="mw-default-size" typeof="mw:Image/Thumb" data-mw='{"thumb":"Thumb.png"}'><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/e/ea/Thumb.png" data-file-width="135" data-file-height="135" data-file-type="bitmap" height="135" width="135"/></a><figcaption>Title</figcaption></figure>
14614 !! end
14615
14616 !! test
14617 Manually-specified thumbnail image with explicit link to wiki page
14618 !! options
14619 thumbsize=220
14620 parsoid=wt2html,wt2wt,html2html
14621 !! wikitext
14622 [[File:Foobar.jpg|thumb=Thumb.png|link=Main_Page|Title]]
14623 !! html/php
14624 <div class="thumb tright"><div class="thumbinner" style="width:137px;"><a href="/wiki/Main_Page" title="Main Page"><img alt="" src="http://example.com/images/e/ea/Thumb.png" width="135" height="135" class="thumbimage" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>Title</div></div></div>
14625
14626 !! html/parsoid
14627 <figure class="mw-default-size" typeof="mw:Image/Thumb" data-mw='{"thumb":"Thumb.png"}'><a href="./Main_Page"><img resource="./File:Foobar.jpg" src="//example.com/images/e/ea/Thumb.png" data-file-width="135" data-file-height="135" data-file-type="bitmap" height="135" width="135"/></a><figcaption>Title</figcaption></figure>
14628 !! end
14629
14630 !! test
14631 Manually-specified thumbnail image with explicit link to url
14632 !! options
14633 thumbsize=220
14634 parsoid=wt2html,wt2wt,html2html
14635 !! wikitext
14636 [[File:Foobar.jpg|thumb=Thumb.png|link=http://example.com|Title]]
14637 !! html/php
14638 <div class="thumb tright"><div class="thumbinner" style="width:137px;"><a href="http://example.com"><img alt="" src="http://example.com/images/e/ea/Thumb.png" width="135" height="135" class="thumbimage" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>Title</div></div></div>
14639
14640 !! html/parsoid
14641 <figure class="mw-default-size" typeof="mw:Image/Thumb" data-mw='{"thumb":"Thumb.png"}'><a href="http://example.com"><img resource="./File:Foobar.jpg" src="//example.com/images/e/ea/Thumb.png" data-file-width="135" data-file-height="135" data-file-type="bitmap" height="135" width="135"/></a><figcaption>Title</figcaption></figure>
14642 !! end
14643
14644 !! test
14645 Manually-specified thumbnail image with explicit no link
14646 !! options
14647 thumbsize=220
14648 parsoid=wt2html,wt2wt,html2html
14649 !! wikitext
14650 [[File:Foobar.jpg|thumb=Thumb.png|link=|Title]]
14651 !! html/php
14652 <div class="thumb tright"><div class="thumbinner" style="width:137px;"><img alt="" src="http://example.com/images/e/ea/Thumb.png" width="135" height="135" class="thumbimage" /> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>Title</div></div></div>
14653
14654 !! html/parsoid
14655 <figure class="mw-default-size" typeof="mw:Image/Thumb" data-mw='{"thumb":"Thumb.png"}'><span><img resource="./File:Foobar.jpg" src="//example.com/images/e/ea/Thumb.png" data-file-width="135" data-file-height="135" data-file-type="bitmap" height="135" width="135"/></span><figcaption>Title</figcaption></figure>
14656 !! end
14657
14658 !! test
14659 Manually-specified thumbnail image with explicit link and alt text
14660 !! options
14661 thumbsize=220
14662 parsoid=wt2html,wt2wt,html2html
14663 !! wikitext
14664 [[File:Foobar.jpg|thumb=Thumb.png|link=Main_Page|alt=alttext|Title]]
14665 !! html/php
14666 <div class="thumb tright"><div class="thumbinner" style="width:137px;"><a href="/wiki/Main_Page" title="Main Page"><img alt="alttext" src="http://example.com/images/e/ea/Thumb.png" width="135" height="135" class="thumbimage" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>Title</div></div></div>
14667
14668 !! html/parsoid
14669 <figure class="mw-default-size" typeof="mw:Image/Thumb" data-mw='{"thumb":"Thumb.png"}'><a href="./Main_Page"><img alt="alttext" resource="./File:Foobar.jpg" src="//example.com/images/e/ea/Thumb.png" data-file-width="135" data-file-height="135" data-file-type="bitmap" height="135" width="135"/></a><figcaption>Title</figcaption></figure>
14670 !! end
14671
14672 !! test
14673 Image with frame and link
14674 !! options
14675 parsoid=wt2html,wt2wt,html2html
14676 !! wikitext
14677 [[File:Foobar.jpg|frame|left|This is a test image [[Main Page]]]]
14678 !! html/php
14679 <div class="thumb tleft"><div class="thumbinner" style="width:1943px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" class="thumbimage" /></a> <div class="thumbcaption">This is a test image <a href="/wiki/Main_Page" title="Main Page">Main Page</a></div></div></div>
14680
14681 !! html/parsoid
14682 <figure class="mw-default-size mw-halign-left" typeof="mw:Image/Frame"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a><figcaption>This is a test image <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></figcaption></figure>
14683 !! end
14684
14685 !! test
14686 Image with frame and link and explicit alt
14687 !! options
14688 parsoid=wt2html,wt2wt,html2html
14689 !! wikitext
14690 [[Image:Foobar.jpg|frame|left|This is a test image [[Main Page]]|alt=Altitude]]
14691 !! html/php
14692 <div class="thumb tleft"><div class="thumbinner" style="width:1943px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Altitude" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" class="thumbimage" /></a> <div class="thumbcaption">This is a test image <a href="/wiki/Main_Page" title="Main Page">Main Page</a></div></div></div>
14693
14694 !! html/parsoid
14695 <figure class="mw-default-size mw-halign-left" typeof="mw:Image/Frame"><a href="./File:Foobar.jpg"><img alt="Altitude" resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a><figcaption>This is a test image <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></figcaption></figure>
14696 !! end
14697
14698 !! test
14699 Image with wiki markup in implicit alt
14700 !! wikitext
14701 [[Image:Foobar.jpg|testing '''bold''' in alt]]
14702
14703 [[Image:Foobar.jpg|alt=testing '''bold''' in alt]]
14704 !! html/php
14705 <p><a href="/wiki/File:Foobar.jpg" class="image" title="testing bold in alt"><img alt="testing bold in alt" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14706 </p><p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="testing bold in alt" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14707 </p>
14708 !! html/parsoid
14709 <p><span class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"caption","ak":"testing &#39;&#39;&#39;bold&#39;&#39;&#39; in alt"}]}' data-mw='{"caption":"testing &lt;b data-parsoid=&#39;{\"dsr\":[27,37,3,3]}&#39;>bold&lt;/b> in alt"}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{}}'><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"Image:Foobar.jpg"}}'/></a></span></p>
14710
14711 <p><span class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"alt","ak":"alt=testing &#39;&#39;&#39;bold&#39;&#39;&#39; in alt"}]}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{}}'><img alt="testing bold in alt" resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"alt":"testing bold in alt","resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"alt":"alt=testing &#39;&#39;&#39;bold&#39;&#39;&#39; in alt","resource":"Image:Foobar.jpg"}}'/></a></span></p>
14712 !! end
14713
14714 !! test
14715 Alt image option should handle most kinds of wikitext without barfing
14716 !! wikitext
14717 [[Image:Foobar.jpg|thumb|This is the image caption|alt=This is a [[link]] and a {{echo|''bold template''}}.]]
14718 !! html/php
14719 <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="This is a link and a bold template." src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>This is the image caption</div></div></div>
14720
14721 !! html/parsoid
14722 <figure class="mw-default-size" typeof="mw:Image/Thumb mw:ExpandedAttrs" about="#mwt2" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"},{"ck":"caption","ak":"This is the image caption"},{"ck":"alt","ak":"alt=This is a [[link]] and a {{echo|&#39;&#39;bold template&#39;&#39;}}."}]}' data-mw='{"attribs":[["thumbnail",{"html":"thumb"}],["alt",{"html":"alt=This is a &lt;a rel=\"mw:WikiLink\" href=\"./Link\" title=\"Link\" data-parsoid=&#39;{\"stx\":\"simple\",\"a\":{\"href\":\"./Link\"},\"sa\":{\"href\":\"link\"},\"dsr\":[65,73,2,2]}&#39;>link&lt;/a> and a &lt;i about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid=&#39;{\"dsr\":[80,106,null,null],\"pi\":[[{\"k\":\"1\"}]]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"&amp;#39;&amp;#39;bold template&amp;#39;&amp;#39;\"}},\"i\":0}}]}&#39;>bold template&lt;/i>."}]]}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{}}'><img alt="This is a link and a bold template." resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220" data-parsoid='{"a":{"alt":"This is a link and a bold template.","resource":"./File:Foobar.jpg","height":"25","width":"220"},"sa":{"alt":"alt=This is a [[link]] and a {{echo|&#39;&#39;bold template&#39;&#39;}}.","resource":"Image:Foobar.jpg"}}'/></a><figcaption>This is the image caption</figcaption></figure>
14723 !! end
14724
14725 ###################
14726 # Conflicting image format options.
14727 # First option specified should 'win'.
14728 # All three cases in each test should be identical.
14729
14730 !! test
14731 Image with 'frameless' first.
14732 !! options
14733 parsoid=wt2html,wt2wt,html2html
14734 !! wikitext
14735 [[File:Foobar.jpg|frameless|caption]]
14736
14737 [[File:Foobar.jpg|frameless|frame|caption]]
14738
14739 [[File:Foobar.jpg|frameless|thumb|caption]]
14740 !! html/php
14741 <p><a href="/wiki/File:Foobar.jpg" class="image" title="caption"><img alt="caption" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a>
14742 </p><p><a href="/wiki/File:Foobar.jpg" class="image" title="caption"><img alt="caption" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a>
14743 </p><p><a href="/wiki/File:Foobar.jpg" class="image" title="caption"><img alt="caption" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a>
14744 </p>
14745 !! html/parsoid
14746 <p><span class="mw-default-size" typeof="mw:Image/Frameless" data-mw='{"caption":"caption"}'><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a></span></p>
14747 <p><span class="mw-default-size" typeof="mw:Image/Frameless" data-mw='{"caption":"caption"}'><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a></span></p>
14748 <p><span class="mw-default-size" typeof="mw:Image/Frameless" data-mw='{"caption":"caption"}'><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a></span></p>
14749 !! end
14750
14751 !! test
14752 Image with 'frame' first.
14753 !! options
14754 parsoid=wt2html,wt2wt,html2html
14755 !! wikitext
14756 [[File:Foobar.jpg|frame|caption]]
14757 [[File:Foobar.jpg|frame|frameless|caption]]
14758 [[File:Foobar.jpg|frame|thumb|caption]]
14759 !! html/php
14760 <div class="thumb tright"><div class="thumbinner" style="width:1943px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" class="thumbimage" /></a> <div class="thumbcaption">caption</div></div></div>
14761 <div class="thumb tright"><div class="thumbinner" style="width:1943px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" class="thumbimage" /></a> <div class="thumbcaption">caption</div></div></div>
14762 <div class="thumb tright"><div class="thumbinner" style="width:1943px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" class="thumbimage" /></a> <div class="thumbcaption">caption</div></div></div>
14763
14764 !! html/parsoid
14765 <figure class="mw-default-size" typeof="mw:Image/Frame"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a><figcaption>caption</figcaption></figure>
14766 <figure class="mw-default-size" typeof="mw:Image/Frame"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a><figcaption>caption</figcaption></figure>
14767 <figure class="mw-default-size" typeof="mw:Image/Frame"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a><figcaption>caption</figcaption></figure>
14768 !! end
14769
14770 !! test
14771 Image with 'thumb' first.
14772 !! options
14773 parsoid=wt2html,wt2wt,html2html
14774 !! wikitext
14775 [[File:Foobar.jpg|thumb|caption]]
14776 [[File:Foobar.jpg|thumb|frameless|caption]]
14777 [[File:Foobar.jpg|thumb|frame|caption]]
14778 !! html/php
14779 <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>caption</div></div></div>
14780 <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>caption</div></div></div>
14781 <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>caption</div></div></div>
14782
14783 !! html/parsoid
14784 <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption>caption</figcaption></figure>
14785 <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption>caption</figcaption></figure>
14786 <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption>caption</figcaption></figure>
14787 !! end
14788
14789 ###################
14790 # Image sizing.
14791 # See https://www.mediawiki.org/wiki/Help:Images#Size_and_frame
14792 # and https://phabricator.wikimedia.org/T64258
14793 # Foobar has actual size of 1941x220
14794 # 1. Thumbs & frameless always reduce, can't be enlarged unless it's
14795 # a scalable format.
14796 # 2. Framed images always ignore size options; always render at default size.
14797 # 3. "Unspecified format" and border are the only types which can be
14798 # enlarged.
14799
14800 !! test
14801 Image: unspecified format and border enlarge
14802 !! options
14803 parsoid=wt2html,wt2wt,html2html
14804 !! wikitext
14805 [[File:Foobar.jpg|2000px]]
14806
14807 [[File:Foobar.jpg|border|2000px]]
14808 !! html/php
14809 <p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="2000" height="227" /></a>
14810 </p><p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="2000" height="227" class="thumbborder" /></a>
14811 </p>
14812 !! html/parsoid
14813 <p><span typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="227" width="2000"/></a></span></p>
14814 <p><span class="mw-image-border" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="227" width="2000"/></a></span></p>
14815 !! end
14816
14817 !! test
14818 Image: "unspecified format" and border reduce
14819 !! options
14820 parsoid=wt2html,wt2wt,html2html
14821 !! wikitext
14822 [[File:Foobar.jpg|1000px]]
14823
14824 [[File:Foobar.jpg|border|1000px]]
14825 !! html/php
14826 <p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/1000px-Foobar.jpg" width="1000" height="113" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/1500px-Foobar.jpg 1.5x, http://example.com/images/3/3a/Foobar.jpg 2x" /></a>
14827 </p><p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/1000px-Foobar.jpg" width="1000" height="113" class="thumbborder" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/1500px-Foobar.jpg 1.5x, http://example.com/images/3/3a/Foobar.jpg 2x" /></a>
14828 </p>
14829 !! html/parsoid
14830 <p><span typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/1000px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="113" width="1000"/></a></span></p>
14831 <p><span class="mw-image-border" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/1000px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="113" width="1000"/></a></span></p>
14832 !! end
14833
14834 !! test
14835 Image: thumbs reduce
14836 !! options
14837 parsoid=wt2html,wt2wt,html2html
14838 !! wikitext
14839 [[File:Foobar.jpg|thumb|50px]]
14840 !! html/php
14841 <div class="thumb tright"><div class="thumbinner" style="width:52px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/50px-Foobar.jpg" width="50" height="6" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/75px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/100px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div></div></div></div>
14842
14843 !! html/parsoid
14844 <figure typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/50px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="6" width="50"/></a></figure>
14845 !! end
14846
14847 !! test
14848 Image: bitmap thumbs can't be enlarged past original size, but vector can.
14849 !! options
14850 parsoid=wt2html,wt2wt,html2html
14851 !! wikitext
14852 [[File:Foobar.jpg|thumb|2000px]]
14853
14854 [[File:Foobar.svg|thumb|2000px]]
14855 !! html/php
14856 <div class="thumb tright"><div class="thumbinner" style="width:1943px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" class="thumbimage" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div></div></div></div>
14857 <div class="thumb tright"><div class="thumbinner" style="width:2002px;"><a href="/wiki/File:Foobar.svg" class="image"><img alt="Foobar.svg" src="http://example.com/images/thumb/f/ff/Foobar.svg/2000px-Foobar.svg.png" width="2000" height="1500" class="thumbimage" srcset="http://example.com/images/thumb/f/ff/Foobar.svg/3000px-Foobar.svg.png 1.5x, http://example.com/images/thumb/f/ff/Foobar.svg/4000px-Foobar.svg.png 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.svg" class="internal" title="Enlarge"></a></div></div></div></div>
14858
14859 !! html/parsoid
14860 <figure typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></figure>
14861 <figure typeof="mw:Image/Thumb"><a href="./File:Foobar.svg"><img resource="./File:Foobar.svg" src="//example.com/images/thumb/f/ff/Foobar.svg/2000px-Foobar.svg.png" data-file-width="240" data-file-height="180" data-file-type="drawing" height="1500" width="2000"/></a></figure>
14862 !! end
14863
14864 !! test
14865 Image: frameless can reduce in size
14866 !! options
14867 parsoid=wt2html,wt2wt,html2html
14868 !! wikitext
14869 [[File:Foobar.jpg|frameless|50px]]
14870 !! html/php
14871 <p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/50px-Foobar.jpg" width="50" height="6" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/75px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/100px-Foobar.jpg 2x" /></a>
14872 </p>
14873 !! html/parsoid
14874 <p><span typeof="mw:Image/Frameless"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/50px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="6" width="50"/></a></span></p>
14875 !! end
14876
14877 !! test
14878 Image: bitmap frameless can't be enlarged past original size, but vector can
14879 !! options
14880 parsoid=wt2html,wt2wt,html2html
14881 !! wikitext
14882 [[File:Foobar.jpg|frameless|2000px]]
14883
14884 [[File:Foobar.svg|frameless|2000px]]
14885 !! html/php
14886 <p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14887 </p><p><a href="/wiki/File:Foobar.svg" class="image"><img alt="Foobar.svg" src="http://example.com/images/thumb/f/ff/Foobar.svg/2000px-Foobar.svg.png" width="2000" height="1500" srcset="http://example.com/images/thumb/f/ff/Foobar.svg/3000px-Foobar.svg.png 1.5x, http://example.com/images/thumb/f/ff/Foobar.svg/4000px-Foobar.svg.png 2x" /></a>
14888 </p>
14889 !! html/parsoid
14890 <p><span typeof="mw:Image/Frameless"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></span></p>
14891 <p><span typeof="mw:Image/Frameless"><a href="./File:Foobar.svg"><img resource="./File:Foobar.svg" src="//example.com/images/thumb/f/ff/Foobar.svg/2000px-Foobar.svg.png" data-file-width="240" data-file-height="180" data-file-type="drawing" height="1500" width="2000"/></a></span></p>
14892 !! end
14893
14894 !! test
14895 Image: framed images are always unscaled.
14896 !! options
14897 parsoid=wt2html,wt2wt,html2html
14898 !! wikitext
14899 [[File:Foobar.jpg|frame]]
14900
14901 [[File:Foobar.jpg|frame|50px]]
14902
14903 [[File:Foobar.jpg|frame|50x50px]]
14904
14905 [[File:Foobar.jpg|frame|2000px]]
14906 !! html/php
14907 <div class="thumb tright"><div class="thumbinner" style="width:1943px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" class="thumbimage" /></a> <div class="thumbcaption"></div></div></div>
14908 <div class="thumb tright"><div class="thumbinner" style="width:1943px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" class="thumbimage" /></a> <div class="thumbcaption"></div></div></div>
14909 <div class="thumb tright"><div class="thumbinner" style="width:1943px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" class="thumbimage" /></a> <div class="thumbcaption"></div></div></div>
14910 <div class="thumb tright"><div class="thumbinner" style="width:1943px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" class="thumbimage" /></a> <div class="thumbcaption"></div></div></div>
14911
14912 !! html/parsoid
14913 <figure class="mw-default-size" typeof="mw:Image/Frame"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></figure>
14914 <figure typeof="mw:Image/Frame"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></figure>
14915 <figure typeof="mw:Image/Frame"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></figure>
14916 <figure typeof="mw:Image/Frame"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></figure>
14917 !! end
14918
14919 ###################
14920
14921 !! test
14922 Link to image page- image page normally doesn't exists, hence edit link
14923 Add test with existing image page
14924 #<p><a href="/wiki/File:Test" title="Image:Test">Image:test</a>
14925 !! wikitext
14926 [[:Image:test]]
14927 !! html
14928 <p><a href="/index.php?title=File:Test&amp;action=edit&amp;redlink=1" class="new" title="File:Test (page does not exist)">Image:test</a>
14929 </p>
14930 !! end
14931
14932 !! test
14933 T20784 Link to non-existent image page with caption should use caption as link text
14934 !! wikitext
14935 [[:Image:test|caption]]
14936 !! html
14937 <p><a href="/index.php?title=File:Test&amp;action=edit&amp;redlink=1" class="new" title="File:Test (page does not exist)">caption</a>
14938 </p>
14939 !! end
14940
14941 !! test
14942 Frameless image caption with a free URL
14943 !! wikitext
14944 [[File:Foobar.jpg|http://example.com]]
14945 !! html/php
14946 <p><a href="/wiki/File:Foobar.jpg" class="image" title="http://example.com"><img alt="http://example.com" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14947 </p>
14948 !! html/parsoid
14949 <p><span class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"caption","ak":"http://example.com"}]}' data-mw='{"caption":"&lt;a rel=\"mw:ExtLink\" href=\"http://example.com\" data-parsoid=&#39;{\"stx\":\"url\",\"dsr\":[18,36,0,0]}&#39;>http://example.com&lt;/a>"}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{}}'><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></span></p>
14950 !! end
14951
14952 !! test
14953 Thumbnail image caption with a free URL
14954 !! options
14955 thumbsize=220
14956 !! wikitext
14957 [[File:Foobar.jpg|thumb|http://example.com]]
14958 !! html/php
14959 <div class="thumb tright"><div class="thumbinner" style="width:222px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" width="220" height="25" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a></div></div></div>
14960
14961 !! html/parsoid
14962 <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption><a rel="mw:ExtLink" href="http://example.com">http://example.com</a></figcaption></figure>
14963 !! end
14964
14965 !! test
14966 Thumbnail image caption with a free URL and explicit alt
14967 !! options
14968 thumbsize=220
14969 parsoid=wt2html,wt2wt,html2html
14970 !! wikitext
14971 [[File:Foobar.jpg|thumb|http://example.com|alt=Alteration]]
14972 !! html/php
14973 <div class="thumb tright"><div class="thumbinner" style="width:222px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Alteration" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" width="220" height="25" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a></div></div></div>
14974
14975 !! html/parsoid
14976 <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img alt="Alteration" resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption><a rel="mw:ExtLink" href="http://example.com">http://example.com</a></figcaption></figure>
14977 !! end
14978
14979 !! test
14980 SVG thumbnails with no language set
14981 !! options
14982 !! wikitext
14983 [[File:Foobar.svg|thumb|caption]]
14984 !! html/php
14985 <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.svg" class="image"><img alt="" src="http://example.com/images/thumb/f/ff/Foobar.svg/180px-Foobar.svg.png" width="180" height="135" class="thumbimage" srcset="http://example.com/images/thumb/f/ff/Foobar.svg/270px-Foobar.svg.png 1.5x, http://example.com/images/thumb/f/ff/Foobar.svg/360px-Foobar.svg.png 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.svg" class="internal" title="Enlarge"></a></div>caption</div></div></div>
14986
14987 !! html/parsoid
14988 <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.svg"><img resource="./File:Foobar.svg" src="//example.com/images/thumb/f/ff/Foobar.svg/220px-Foobar.svg.png" data-file-width="240" data-file-height="180" data-file-type="drawing" height="165" width="220"/></a><figcaption>caption</figcaption></figure>
14989 !! end
14990
14991 !! test
14992 SVG thumbnails with language de
14993 !! options
14994 parsoid=wt2html,wt2wt,html2html
14995 !! wikitext
14996 [[File:Foobar.svg|thumb|caption|lang=de]]
14997 !! html/php
14998 <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/index.php?title=File:Foobar.svg&amp;lang=de" class="image"><img alt="" src="http://example.com/images/thumb/f/ff/Foobar.svg/langde-180px-Foobar.svg.png" width="180" height="135" class="thumbimage" srcset="http://example.com/images/thumb/f/ff/Foobar.svg/langde-270px-Foobar.svg.png 1.5x, http://example.com/images/thumb/f/ff/Foobar.svg/langde-360px-Foobar.svg.png 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.svg" class="internal" title="Enlarge"></a></div>caption</div></div></div>
14999
15000 !! html/parsoid
15001 <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.svg"><img resource="./File:Foobar.svg" src="//example.com/images/thumb/f/ff/Foobar.svg/220px-Foobar.svg.png" lang="de" data-file-width="240" data-file-height="180" data-file-type="drawing" height="165" width="220"/></a><figcaption>caption</figcaption></figure>
15002 !! end
15003
15004 !! test
15005 SVG thumbnails with invalid language code
15006 !! options
15007 parsoid=wt2html,wt2wt,html2html
15008 !! wikitext
15009 [[File:Foobar.svg|thumb|caption|lang=invalid.language.code]]
15010 !! html/php
15011 <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.svg" class="image"><img alt="" src="http://example.com/images/thumb/f/ff/Foobar.svg/180px-Foobar.svg.png" width="180" height="135" class="thumbimage" srcset="http://example.com/images/thumb/f/ff/Foobar.svg/270px-Foobar.svg.png 1.5x, http://example.com/images/thumb/f/ff/Foobar.svg/360px-Foobar.svg.png 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.svg" class="internal" title="Enlarge"></a></div>lang=invalid.language.code</div></div></div>
15012
15013 !! html/parsoid
15014 <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.svg"><img resource="./File:Foobar.svg" src="//example.com/images/f/ff/Foobar.svg" data-file-width="240" data-file-height="180" data-file-type="drawing" height="165" width="220"/></a><figcaption>lang=invalid.language.code</figcaption></figure>
15015 !! end
15016
15017 !! test
15018 T3887: A ISBN with a thumbnail
15019 !! wikitext
15020 [[File:Foobar.jpg|thumb|ISBN 1235467890]]
15021 !! html/php
15022 <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div><a href="/wiki/Special:BookSources/1235467890" class="internal mw-magiclink-isbn">ISBN 1235467890</a></div></div></div>
15023
15024 !! html/parsoid
15025 <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption><a href="./Special:BookSources/1235467890" rel="mw:WikiLink">ISBN 1235467890</a></figcaption></figure>
15026 !! end
15027
15028 !! test
15029 T3887: A RFC with a thumbnail
15030 !! wikitext
15031 [[File:Foobar.jpg|thumb|This is RFC 12354]]
15032 !! html/php
15033 <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>This is <a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc12354">RFC 12354</a></div></div></div>
15034
15035 !! html/parsoid
15036 <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption>This is <a href="//tools.ietf.org/html/rfc12354" rel="mw:ExtLink">RFC 12354</a></figcaption></figure>
15037 !! end
15038
15039 !! test
15040 T3887: A mailto link with a thumbnail
15041 !! wikitext
15042 [[File:Foobar.jpg|thumb|Please mailto:nobody@example.com]]
15043 !! html/php
15044 <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>Please <a rel="nofollow" class="external free" href="mailto:nobody@example.com">mailto:nobody@example.com</a></div></div></div>
15045
15046 !! html/parsoid
15047 <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption>Please <a rel="mw:ExtLink" href="mailto:nobody@example.com">mailto:nobody@example.com</a></figcaption></figure>
15048 !! end
15049
15050 # Pending resolution to T2368
15051 !! test
15052 T2648: Frameless image caption with a link
15053 !! wikitext
15054 [[File:Foobar.jpg|text with a [[link]] in it]]
15055 !! html/php
15056 <p><a href="/wiki/File:Foobar.jpg" class="image" title="text with a link in it"><img alt="text with a link in it" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
15057 </p>
15058 !! html/parsoid
15059 <p><span class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"caption","ak":"text with a [[link]] in it"}]}' data-mw='{"caption":"text with a &lt;a rel=\"mw:WikiLink\" href=\"./Link\" title=\"Link\" data-parsoid=&#39;{\"stx\":\"simple\",\"a\":{\"href\":\"./Link\"},\"sa\":{\"href\":\"link\"},\"dsr\":[30,38,2,2]}&#39;>link&lt;/a> in it"}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{}}'><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></span></p>
15060 !! end
15061
15062 !! test
15063 T2648: Frameless image caption with a link (suffix)
15064 !! wikitext
15065 [[File:Foobar.jpg|text with a [[link]]foo in it]]
15066 !! html/php
15067 <p><a href="/wiki/File:Foobar.jpg" class="image" title="text with a linkfoo in it"><img alt="text with a linkfoo in it" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
15068 </p>
15069 !! html/parsoid
15070 <p><span class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"caption","ak":"text with a [[link]]foo in it"}]}' data-mw='{"caption":"text with a &lt;a rel=\"mw:WikiLink\" href=\"./Link\" title=\"Link\" data-parsoid=&#39;{\"stx\":\"simple\",\"a\":{\"href\":\"./Link\"},\"sa\":{\"href\":\"link\"},\"dsr\":[30,41,2,5],\"tail\":\"foo\"}&#39;>linkfoo&lt;/a> in it"}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{}}'><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></span></p>
15071 !! end
15072
15073 !! test
15074 T2648: Frameless image caption with an interwiki link
15075 !! wikitext
15076 [[File:Foobar.jpg|text with a [[MeatBall:Link]] in it]]
15077 !! html/php
15078 <p><a href="/wiki/File:Foobar.jpg" class="image" title="text with a MeatBall:Link in it"><img alt="text with a MeatBall:Link in it" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
15079 </p>
15080 !! html/parsoid
15081 <p><span class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"caption","ak":"text with a [[MeatBall:Link]] in it"}]}' data-mw='{"caption":"text with a &lt;a rel=\"mw:ExtLink\" href=\"http://www.usemod.com/cgi-bin/mb.pl?Link\" title=\"meatball:Link\" data-parsoid=&#39;{\"stx\":\"simple\",\"a\":{\"href\":\"http://www.usemod.com/cgi-bin/mb.pl?Link\"},\"sa\":{\"href\":\"MeatBall:Link\"},\"isIW\":true,\"dsr\":[30,47,2,2]}&#39;>MeatBall:Link&lt;/a> in it"}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{}}'><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></span></p>
15082 !! end
15083
15084 !! test
15085 T2648: Frameless image caption with a piped interwiki link
15086 !! wikitext
15087 [[File:Foobar.jpg|text with a [[MeatBall:Link|link]] in it]]
15088 !! html/php
15089 <p><a href="/wiki/File:Foobar.jpg" class="image" title="text with a link in it"><img alt="text with a link in it" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
15090 </p>
15091 !! html/parsoid
15092 <p><span class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"caption","ak":"text with a [[MeatBall:Link|link]] in it"}]}' data-mw='{"caption":"text with a &lt;a rel=\"mw:ExtLink\" href=\"http://www.usemod.com/cgi-bin/mb.pl?Link\" title=\"meatball:Link\" data-parsoid=&#39;{\"stx\":\"piped\",\"a\":{\"href\":\"http://www.usemod.com/cgi-bin/mb.pl?Link\"},\"sa\":{\"href\":\"MeatBall:Link\"},\"isIW\":true,\"dsr\":[30,52,16,2]}&#39;>link&lt;/a> in it"}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{}}'><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></span></p>
15093 !! end
15094
15095 !! test
15096 T107474: Frameless image caption with <nowiki>
15097 !! wikitext
15098 [[File:Foobar.jpg|<nowiki>text with a [[MeatBall:Link|link]] in it</nowiki>]]
15099 !! html/parsoid
15100 <p><span class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"caption","ak":"&lt;nowiki>text with a [[MeatBall:Link|link]] in it&lt;/nowiki>"}]}' data-mw='{"caption":"&lt;span typeof=\"mw:Nowiki\" data-parsoid=&#39;{\"dsr\":[18,75,8,9]}&#39;>text with a [[MeatBall:Link|link]] in it&lt;/span>"}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{}}'><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></span></p>
15101 !! end
15102
15103 !! test
15104 Escape HTML special chars in image alt text
15105 !! wikitext
15106 [[File:Foobar.jpg|& < > "]]
15107 !! html/php
15108 <p><a href="/wiki/File:Foobar.jpg" class="image" title="&amp; &lt; &gt; &quot;"><img alt="&amp; &lt; &gt; &quot;" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
15109 </p>
15110 !! html/parsoid
15111 <p><span class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"caption","ak":"&amp; &lt; > \""}]}' data-mw='{"caption":"&amp;amp; &amp;lt; > \""}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{}}'><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></span></p>
15112 !! end
15113
15114 !! test
15115 Escape HTML special chars in image alt text with LanguageConverter
15116 !! options
15117 language=zh
15118 !! wikitext
15119 [[File:Foobar.jpg|& < > "]]
15120 !! html/php
15121 <p><a href="/wiki/File:Foobar.jpg" class="image" title="&amp; &lt; &gt; &quot;"><img alt="&amp; &lt; &gt; &quot;" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
15122 </p>
15123 !! html/parsoid
15124 <p><span class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"caption","ak":"&amp; &lt; > \""}]}' data-mw='{"caption":"&amp;amp; &amp;lt; > \""}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{}}'><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></span></p>
15125 !! end
15126
15127 !! test
15128 Entities in file name and attributes
15129 !! wikitext
15130 [[File:7%25 solution.gif|manualthumb=7%25 solution.gif|link=7%25 solution|[[7%25 solution]]]]
15131 !! html/php
15132 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=7%25_solution.gif" class="new" title="File:7% solution.gif">7% solution</a>
15133 </p>
15134 !! html/parsoid
15135 <p><span class="mw-default-size" typeof="mw:Error mw:Image" data-parsoid='{"optList":[{"ck":"bogus","ak":"manualthumb=7%25 solution.gif"},{"ck":"link","ak":"link=7%25 solution"},{"ck":"caption","ak":"[[7%25 solution]]"}]}' data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}],"caption":"&lt;a rel=\"mw:WikiLink\" href=\"./7%25_solution\" title=\"7% solution\" data-parsoid=&#39;{\"stx\":\"simple\",\"a\":{\"href\":\"./7%25_solution\"},\"sa\":{\"href\":\"7%25 solution\"},\"dsr\":[74,91,2,2]}&#39;>7% solution&lt;/a>"}'><a href="./7%25_solution" data-parsoid='{"a":{"href":"./7%25_solution"},"sa":{"href":"link=7%25 solution"}}'><img resource="./File:7%25_solution.gif" src="./Special:FilePath/7%25_solution.gif" height="220" width="220" data-parsoid='{"a":{"resource":"./File:7%25_solution.gif","height":"220","width":"220"},"sa":{"resource":"File:7%25 solution.gif"}}'/></a></span></p>
15136 !! end
15137
15138 !! test
15139 T2499: Alt text should have &#1234;, not &amp;1234;
15140 !! wikitext
15141 [[File:Foobar.jpg|&#9792;]]
15142 !! html/php
15143 <p><a href="/wiki/File:Foobar.jpg" class="image" title="♀"><img alt="♀" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
15144 </p>
15145 !! html/parsoid
15146 <p><span class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"caption","ak":"&amp;#9792;"}]}' data-mw='{"caption":"&lt;span typeof=\"mw:Entity\" data-parsoid=&#39;{\"src\":\"&amp;amp;#9792;\",\"srcContent\":\"♀\",\"dsr\":[18,25,null,null]}&#39;>♀&lt;/span>"}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{}}'><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></span></p>
15147 !! end
15148
15149 !! test
15150 Broken image caption with link
15151 !! options
15152 parsoid=wt2html,wt2wt,html2html
15153 !! wikitext
15154 [[Image:Foobar.jpg|thumb|This is a broken caption. But [[Main Page|this]] is just an ordinary link.
15155 !! html/php
15156 <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.
15157 </p>
15158 !! html/parsoid
15159 <p>[[Image:Foobar.jpg|thumb|This is a broken caption. But <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">this</a> is just an ordinary link.</p>
15160 !! end
15161
15162 !! test
15163 Image caption containing another image
15164 !! wikitext
15165 [[File:Foobar.jpg|thumb|This is a caption with another [[File:Thumb.png|image]] inside it!]]
15166 !! html/php
15167 <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>This is a caption with another <a href="/wiki/File:Thumb.png" class="image" title="image"><img alt="image" src="http://example.com/images/e/ea/Thumb.png" width="135" height="135" /></a> inside it!</div></div></div>
15168
15169 !! html/parsoid
15170 <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption>This is a caption with another <span class="mw-default-size" typeof="mw:Image" data-mw='{"caption":"image"}'><a href="./File:Thumb.png"><img resource="./File:Thumb.png" src="//example.com/images/e/ea/Thumb.png" data-file-width="135" data-file-height="135" data-file-type="bitmap" height="135" width="135"/></a></span> inside it!</figcaption></figure>
15171 !! end
15172
15173 !! test
15174 Image: caption containing a newline
15175 !! wikitext
15176 [[File:Foobar.jpg|This
15177 *is some text]]
15178 !! html/php
15179 <p><a href="/wiki/File:Foobar.jpg" class="image" title="This *is some text"><img alt="This *is some text" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
15180 </p>
15181 !! html/parsoid
15182 <p><span class="mw-default-size" typeof="mw:Image" data-mw='{"caption":"This\n*is some text"}'><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></span></p>
15183 !!end
15184
15185 !!test
15186 Image: caption containing leading space
15187 (The leading space should not trigger nowiki escaping in wt2wt mode)
15188 !! wikitext
15189 [[File:Foobar.jpg|thumb| bar]]
15190 !! html/php
15191 <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>bar</div></div></div>
15192
15193 !! html/parsoid
15194 <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption> bar</figcaption></figure>
15195 !!end
15196
15197 !! test
15198 Image: caption containing a table
15199 !! options
15200 parsoid=wt2html,wt2wt,html2html
15201 !! wikitext
15202 [[Image:Foobar.jpg|thumb|200px|This is an example image thumbnail caption with a table
15203 {|
15204 ! Foo !! Bar
15205 |-
15206 | Foo1 || Bar1
15207 |}
15208 and some more text.]]
15209 !! html/php
15210 <div class="thumb tright"><div class="thumbinner" style="width:202px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg" width="200" height="23" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/400px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>This is an example image thumbnail caption with a table <table> <tr> <th> Foo </th> <th> Bar </th></tr> <tr> <td> Foo1 </td> <td> Bar1 </td></tr></table> and some more text.</div></div></div>
15211
15212 !! html/parsoid
15213 <figure typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="23" width="200"/></a><figcaption>This is an example image thumbnail caption with a table
15214 <table>
15215 <tbody>
15216 <tr><th>Foo </th><th>Bar</th></tr>
15217 <tr>
15218 <td>Foo1 </td>
15219 <td>Bar1</td></tr></tbody></table>and some more text.</figcaption></figure>
15220 !! end
15221
15222 !! test
15223 T5090: External links other than http: in image captions
15224 !! wikitext
15225 [[File:Foobar.jpg|thumb|200x200px|This caption has [irc://example.net irc] and [https://example.com Secure] ext links in it.]]
15226 !! html/php
15227 <div class="thumb tright"><div class="thumbinner" style="width:202px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg" width="200" height="23" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/400px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>This caption has <a rel="nofollow" class="external text" href="irc://example.net">irc</a> and <a rel="nofollow" class="external text" href="https://example.com">Secure</a> ext links in it.</div></div></div>
15228
15229 !! html/parsoid
15230 <figure typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="23" width="200"/></a><figcaption>This caption has <a rel="mw:ExtLink" href="irc://example.net">irc</a> and <a rel="mw:ExtLink" href="https://example.com">Secure</a> ext links in it.</figcaption></figure>
15231 !! end
15232
15233 !! test
15234 Custom class
15235 !! options
15236 parsoid=wt2html,wt2wt,html2html
15237 !! wikitext
15238 [[Image:foobar.jpg|a|class=b]]
15239 !! html/php
15240 <p><a href="/wiki/File:Foobar.jpg" class="image" title="a"><img alt="a" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" class="b" /></a>
15241 </p>
15242 !! html/parsoid
15243 <p><span class="mw-default-size b" typeof="mw:Image" data-mw='{"caption":"a"}'><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></span></p>
15244 !! end
15245
15246 !! test
15247 Localized image handling (1).
15248 !! options
15249 parsoid=wt2html,wt2wt,html2html
15250 language=es
15251 !! wikitext
15252 [[Archivo:Foobar.jpg|izquierda|enlace=foo|caption]]
15253 !! html/php
15254 <div class="floatleft"><a href="/wiki/Foo" title="caption"><img alt="caption" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div>
15255
15256 !! html/parsoid
15257 <figure class="mw-default-size mw-halign-left" typeof="mw:Image"><a href="./Foo"><img resource="./Archivo:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a><figcaption>caption</figcaption></figure>
15258 !! end
15259
15260 !! test
15261 Localized image handling (2).
15262 !! options
15263 thumbsize=220
15264 parsoid=wt2html,wt2wt,html2html
15265 language=es
15266 !! wikitext
15267 [[Archivo:Foobar.jpg|miniatura|izquierda|enlace=foo|caption]]
15268 !! html/php
15269 <div class="thumb tleft"><div class="thumbinner" style="width:222px;"><a href="/wiki/Foo" title="Foo"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" width="220" height="25" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/Archivo:Foobar.jpg" class="internal" title="Aumentar"></a></div>caption</div></div></div>
15270
15271 !! html/parsoid
15272 <figure class="mw-default-size mw-halign-left" typeof="mw:Image/Thumb"><a href="./Foo"><img resource="./Archivo:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption>caption</figcaption></figure>
15273 !! end
15274
15275 !! test
15276 Localized image handling (3).
15277 !! options
15278 language=fa
15279 parsoid=html2wt
15280 !! html/parsoid
15281 <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a></figure>
15282 !! wikitext
15283 [[File:Foobar.jpg|بندانگشتی]]
15284 !! end
15285
15286 !! test
15287 "border", "frameless" and "class" attributes on an image.
15288 !! options
15289 thumbsize=220
15290 parsoid=wt2html,wt2wt,html2html
15291 !! wikitext
15292 [[File:Foobar.jpg|frameless|border|class=extra|caption]]
15293 !! html/php
15294 <p><a href="/wiki/File:Foobar.jpg" class="image" title="caption"><img alt="caption" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" width="220" height="25" class="extra thumbborder" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a>
15295 </p>
15296 !! html/parsoid
15297 <p><span class="mw-default-size mw-image-border extra" typeof="mw:Image/Frameless" data-mw='{"caption":"caption"}'><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a></span></p>
15298 !! end
15299
15300 # Note that 'right' is the default alignment, despite the misspelled 'righ' below
15301 !! test
15302 Invalid image attributes (T64500)
15303 !! options
15304 thumbsize=220
15305 parsoid=wt2html,wt2wt,html2html
15306 !! wikitext
15307 [[File:Foobar.jpg|thumb|float|left|caption]]
15308
15309 [[File:Foobar.jpg|thumb|righ|caption]]
15310
15311 [[File:Foobar.jpg|bogus1|thumb|bogus2|left|bogus3|caption]]
15312 !! html/php
15313 <div class="thumb tleft"><div class="thumbinner" style="width:222px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" width="220" height="25" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>caption</div></div></div>
15314 <div class="thumb tright"><div class="thumbinner" style="width:222px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" width="220" height="25" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>caption</div></div></div>
15315 <div class="thumb tleft"><div class="thumbinner" style="width:222px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" width="220" height="25" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/330px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/440px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>caption</div></div></div>
15316
15317 !! html/parsoid
15318 <figure class="mw-default-size mw-halign-left" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption>caption</figcaption></figure>
15319 <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption>caption</figcaption></figure>
15320 <figure class="mw-default-size mw-halign-left" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption>caption</figcaption></figure>
15321 !! end
15322
15323 !! article
15324 File:Barfoo.jpg
15325 !! text
15326 #REDIRECT [[File:Barfoo.jpg]]
15327 !! endarticle
15328
15329 # FIXME: Parsoid should run this test -- but we'd need to teach the
15330 # mockAPI about the redirected Barfoo.jpg image.
15331 !! test
15332 Redirected image
15333 !! wikitext
15334 [[Image:Barfoo.jpg]]
15335 !! html/php
15336 <p><a href="/wiki/File:Barfoo.jpg" class="mw-redirect" title="File:Barfoo.jpg">File:Barfoo.jpg</a>
15337 </p>
15338 !! end
15339
15340 !! test
15341 Missing image with uploads disabled
15342 !! options
15343 wgEnableUploads=0
15344 !! wikitext
15345 [[File:Foobaz.jpg]]
15346 !! html/php
15347 <p><a href="/wiki/File:Foobaz.jpg" title="File:Foobaz.jpg">File:Foobaz.jpg</a>
15348 </p>
15349 !! html/parsoid
15350 <p><span class="mw-default-size" typeof="mw:Error mw:Image" data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}]}'><a href="./File:Foobaz.jpg"><img resource="./File:Foobaz.jpg" src="./Special:FilePath/Foobaz.jpg" height="220" width="220"/></a></span></p>
15351 !! end
15352
15353 # Parsoid-specific testing for images
15354 # https://www.mediawiki.org/wiki/Parsoid/MediaWiki_DOM_spec#Images
15355 # Currently imperfect due to a flaw in the Parsoid testrunner
15356 # Work in progress
15357 # THESE TESTS SHOULD BE MOVED UP and merged with the php-specific
15358 # image tests.
15359
15360 !! test
15361 Parsoid-specific image handling - simple image with size and middle alignment
15362 !! wikitext
15363 [[File:Foobar.jpg|middle|50px]]
15364 !! html/parsoid
15365 <p><span class="mw-valign-middle" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/50px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="6" width="50"/></a></span></p>
15366 !! end
15367
15368 !! test
15369 Parsoid-specific image handling - simple image with size, middle alignment,
15370 non-standard namespace alias
15371 !! options
15372 parsoid=wt2wt,wt2html,html2html
15373 !! wikitext
15374 [[Image:Foobar.jpg|middle|50px]]
15375 !! html/parsoid
15376 <p><span class="mw-valign-middle" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/50px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="6" width="50"/></a></span></p>
15377 !! end
15378
15379 !! test
15380 Parsoid-specific image handling - simple image with size and middle alignment
15381 (existing content)
15382 !! wikitext
15383 [[File:Foobar.jpg|50px|middle]]
15384 !! html/parsoid
15385 <p><span class="mw-valign-middle" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"width","ak":"50px"},{"ck":"middle","ak":"middle"}]}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"}}'><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/50px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="6" width="50" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"6","width":"50"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></span></p>
15386 !! end
15387
15388 !! test
15389 Parsoid-specific image handling - simple image with size and middle alignment
15390 and non-standard namespace name
15391 !! options
15392 parsoid=wt2html,wt2wt,html2html
15393 !! wikitext
15394 [[Image:Foobar.jpg|50px|middle]]
15395 !! html/parsoid
15396 <p><span class="mw-valign-middle" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/50px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="6" width="50"/></a></span></p>
15397 !! end
15398
15399 !! test
15400 Parsoid-specific image handling - simple image with both sizes, a baseline alignment, and a caption
15401 !! wikitext
15402 [[File:Foobar.jpg|500x10px|baseline|caption]]
15403 !! html/parsoid
15404 <p><span class="mw-valign-baseline" typeof="mw:Image" data-mw='{"caption":"caption"}' data-parsoid='{"optList":[{"ck":"width","ak":"500x10px"},{"ck":"baseline","ak":"baseline"},{"ck":"caption","ak":"caption"}],"size":"500x10"}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"}}'><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/89px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="10" width="89" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"10","width":"89"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></span></p>
15405 !! end
15406
15407 !! test
15408 Parsoid-specific image handling - simple image with border and size spec
15409 !! wikitext
15410 [[File:Foobar.jpg|50px|border|caption]]
15411 !! html/parsoid
15412 <p><span class="mw-image-border" typeof="mw:Image" data-mw='{"caption":"caption"}' data-parsoid='{"optList":[{"ck":"width","ak":"50px"},{"ck":"border","ak":"border"},{"ck":"caption","ak":"caption"}]}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"}}'><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/50px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="6" width="50" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"6","width":"50"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></span></p>
15413 !! end
15414
15415 !! test
15416 Parsoid-specific image handling - thumbnail with halign, valign, and caption
15417 !! wikitext
15418 [[File:Foobar.jpg|left|baseline|thumb|caption content]]
15419 !! html/parsoid
15420 <figure class="mw-default-size mw-halign-left mw-valign-baseline" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption>caption content</figcaption></figure>
15421 !! end
15422
15423 !! test
15424 Parsoid-specific image handling - thumbnail with halign, valign, and caption
15425 (existing content)
15426 !! wikitext
15427 [[File:Foobar.jpg|thumb|left|baseline|caption content]]
15428 !! html/parsoid
15429 <figure class="mw-default-size mw-halign-left mw-valign-baseline" typeof="mw:Image/Thumb" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"},{"ck":"left","ak":"left"},{"ck":"baseline","ak":"baseline"},{"ck":"caption","ak":"caption content"}]}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"}}'><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"25","width":"220"},"sa":{"resource":"File:Foobar.jpg"}}'/></a><figcaption>caption content</figcaption></figure>
15430 !! end
15431
15432 !! test
15433 Parsoid-specific image handling - thumbnail with specific size, halign, valign, and caption
15434 !! wikitext
15435 [[Image:Foobar.jpg|right|middle|thumb|50x50px|caption]]
15436 !! html/parsoid
15437 <figure class="mw-halign-right mw-valign-middle" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/50px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="6" width="50"/></a><figcaption>caption</figcaption></figure>
15438 !! end
15439
15440 !! test
15441 Parsoid-specific image handling - thumbnail with specific size, halign,
15442 valign, and caption (existing content)
15443 !! wikitext
15444 [[File:Foobar.jpg|thumb|50x50px|right|middle|caption]]
15445 !! html/parsoid
15446 <figure class="mw-halign-right mw-valign-middle" typeof="mw:Image/Thumb" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"},{"ck":"width","ak":"50x50px"},{"ck":"right","ak":"right"},{"ck":"middle","ak":"middle"},{"ck":"caption","ak":"caption"}],"size":"50x50"}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"}}'><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/50px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="6" width="50" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"6","width":"50"},"sa":{"resource":"File:Foobar.jpg"}}'/></a><figcaption>caption</figcaption></figure>
15447 !! end
15448
15449 !! test
15450 Parsoid-specific image handling - framed image with specific size and caption
15451 (size is ignored)
15452 !! options
15453 parsoid=wt2html,wt2wt,html2html
15454 !! wikitext
15455 [[File:Foobar.jpg|frame|500x50px|caption]]
15456 !! html/parsoid
15457 <figure typeof="mw:Image/Frame"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a><figcaption>caption</figcaption></figure>
15458 !! end
15459
15460 !! test
15461 Parsoid-specific image handling - framed image with specific size, halign, valign, and caption
15462 (size is ignored)
15463 !! options
15464 parsoid=wt2html,wt2wt,html2html
15465 !! wikitext
15466 [[File:Foobar.jpg|left|baseline|frame|500x50px|caption]]
15467 !! html/parsoid
15468 <figure class="mw-halign-left mw-valign-baseline" typeof="mw:Image/Frame"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a><figcaption>caption</figcaption></figure>
15469 !! end
15470
15471 !! test
15472 Parsoid-specific image handling - frameless image with specific size, border, and caption
15473 !! wikitext
15474 [[File:Foobar.jpg|frameless|442x50px|border|caption]]
15475 !! html/parsoid
15476 <p><span class="mw-image-border" typeof="mw:Image/Frameless" data-mw='{"caption":"caption"}' data-parsoid='{"optList":[{"ck":"frameless","ak":"frameless"},{"ck":"width","ak":"442x50px"},{"ck":"border","ak":"border"},{"ck":"caption","ak":"caption"}],"size":"442x50"}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"}}'><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/442px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="50" width="442" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"50","width":"442"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></span></p>
15477 !! end
15478
15479 !! test
15480 Parsoid-specific image handling - simple image with a formatted caption
15481 !! wikitext
15482 [[File:Foobar.jpg|<table><tr><td>a</td><td>b</td></tr><tr><td>c</td></tr></table>]]
15483 !! html/parsoid
15484 <p><span class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"caption","ak":"&lt;table>&lt;tr>&lt;td>a&lt;/td>&lt;td>b&lt;/td>&lt;/tr>&lt;tr>&lt;td>c&lt;/td>&lt;/tr>&lt;/table>"}]}' data-mw='{"caption":"&lt;table data-parsoid=&#39;{\"stx\":\"html\",\"dsr\":[18,81,7,8]}&#39;>&lt;tbody data-parsoid=&#39;{\"dsr\":[25,73,0,0]}&#39;>&lt;tr data-parsoid=&#39;{\"stx\":\"html\",\"dsr\":[25,54,4,5]}&#39;>&lt;td data-parsoid=&#39;{\"stx\":\"html\",\"dsr\":[29,39,4,5]}&#39;>a&lt;/td>&lt;td data-parsoid=&#39;{\"stx\":\"html\",\"dsr\":[39,49,4,5]}&#39;>b&lt;/td>&lt;/tr>&lt;tr data-parsoid=&#39;{\"stx\":\"html\",\"dsr\":[54,73,4,5]}&#39;>&lt;td data-parsoid=&#39;{\"stx\":\"html\",\"dsr\":[58,68,4,5]}&#39;>c&lt;/td>&lt;/tr>&lt;/tbody>&lt;/table>"}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{}}'><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></span></p>
15485 !! end
15486
15487 !! test
15488 Parsoid-specific image handling - caption with a template in it
15489 !! wikitext
15490 [[File:Foobar.jpg|thumb|200x23px|This caption has a {{echo|transclusion}} in it.]]
15491 !! html/parsoid
15492 <figure typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="23" width="200"></a><figcaption>This caption has a <span about="#mwt1" typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;transclusion&quot;}},&quot;i&quot;:0}}]}">transclusion</span> in it.</figcaption></figure>
15493 !! end
15494
15495 !! test
15496 Parsoid-specific image handling - caption with unbalanced tags in it
15497 !! options
15498 parsoid=wt2html,wt2wt,html2html
15499 !! wikitext
15500 foo
15501 [[File:Foobar.jpg|thumb|200x200px|This caption has a <center>unbalanced tag in it.]]
15502 bar
15503 !! html/parsoid
15504 <p>foo</p>
15505 <figure typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="23" width="200"/></a><figcaption>This caption has a <center>unbalanced tag in it.</center></figcaption></figure>
15506 <p>bar</p>
15507 !! end
15508
15509 !! test
15510 Parsoid-specific image handling - empty caption (1)
15511 !! options
15512 parsoid=wt2html,wt2wt
15513 !! wikitext
15514 [[File:Foobar.jpg|thumb|]]
15515 !! html/parsoid
15516 <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption></figcaption></figure>
15517 !! end
15518
15519 # empty captions don't get serialized unless we're in the "round trip" case
15520 !! test
15521 Parsoid-specific image handling - empty caption (2)
15522 !! options
15523 parsoid=html2wt
15524 !! html/parsoid
15525 <figure class="mw-default-size" typeof="mw:Image/Thumb">
15526 <a href="./File:Foobar.jpg">
15527 <img resource="./File:Foobar.jpg"
15528 src="//example.com/images/3/3a/Foobar.jpg"
15529 data-file-width="1941" data-file-height="220" data-file-type="bitmap"
15530 height="25" width="220"/>
15531 </a>
15532 <figcaption></figcaption>
15533 </figure>
15534 !! wikitext
15535 [[File:Foobar.jpg|thumb]]
15536 !! end
15537
15538 !! test
15539 Parsoid-specific image handling - whitespace caption
15540 !! wikitext
15541 [[File:Foobar.jpg|thumb| ]]
15542 !! html/parsoid
15543 <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption> </figcaption></figure>
15544 !! end
15545
15546 !! test
15547 Parsoid-specific image handling - lang option
15548 !! wikitext
15549 foo
15550 [[File:Foobar.svg|lang=de|caption]]
15551 bar
15552 !! html/parsoid
15553 <p>foo
15554 <span class="mw-default-size" typeof="mw:Image" data-mw='{"caption":"caption"}'><a href="./File:Foobar.svg"><img resource="./File:Foobar.svg" src="//example.com/images/f/ff/Foobar.svg" lang="de" data-file-width="240" data-file-height="180" data-file-type="drawing" height="180" width="240"/></a></span>
15555 bar</p>
15556 !! end
15557
15558 ## Edge case bugs in Parsoid from T93580
15559 !! test
15560 T93580: 1. Templated <ref> inside block images
15561 !! wikitext
15562 [[File:Foobar.jpg|thumb|Caption with templated ref: {{echo|<ref>foo</ref>}}]]
15563
15564 <references />
15565 !! html/parsoid
15566 <figure class="mw-default-size" typeof="mw:Image/Thumb" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"},{"ck":"caption","ak":"Caption with templated ref: {{echo|&lt;ref>foo&lt;/ref>}}"}]}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{}}'><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"25","width":"220"},"sa":{"resource":"File:Foobar.jpg"}}'/></a><figcaption>Caption with templated ref: <span about="#mwt5" class="mw-ref" id="cite_ref-1" rel="dc:references" typeof="mw:Transclusion mw:Extension/ref" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;ref>foo&lt;/ref>"}},"i":0}}]}'><a href="./Main_Page#cite_note-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></span></figcaption></figure>
15567
15568 <ol class="mw-references" typeof="mw:Extension/references" about="#mwt6" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text" data-parsoid="{}">foo</span></li></ol>
15569 !! end
15570
15571 !! test
15572 T93580: 2. <ref> inside inline images
15573 !! wikitext
15574 [[File:Foobar.jpg|Undisplayed caption in inline image with ref: <ref>foo</ref>]]
15575
15576 <references />
15577 !! html/parsoid
15578 <p><span class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"caption","ak":"Undisplayed caption in inline image with ref: &lt;ref>foo&lt;/ref>"}]}' data-mw='{"caption":"Undisplayed caption in inline image with ref: &lt;span about=\"#mwt2\" class=\"mw-ref\" id=\"cite_ref-1\" rel=\"dc:references\" typeof=\"mw:Extension/ref\" data-parsoid=&#39;{\"dsr\":[64,78,5,6]}&#39; data-mw=&#39;{\"name\":\"ref\",\"body\":{\"id\":\"mw-reference-text-cite_note-1\"},\"attrs\":{}}&#39;>&lt;a href=\"./Main_Page#cite_note-1\" style=\"counter-reset: mw-Ref 1;\" data-parsoid=\"{}\">&lt;span class=\"mw-reflink-text\" data-parsoid=\"{}\">[1]&lt;/span>&lt;/a>&lt;/span>&lt;meta typeof=\"mw:Extension/ref/Marker\" about=\"#mwt2\" data-parsoid=&#39;{\"group\":\"\",\"name\":\"\",\"content\":\"foo\",\"hasRefInRef\":false,\"dsr\":[64,78,5,6]}&#39;/>"}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{}}'><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></span></p>
15579
15580 <ol class="mw-references" typeof="mw:Extension/references" about="#mwt4" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text" data-parsoid="{}">foo</span></li></ol>
15581 !! end
15582
15583 !! test
15584 T93580: 3. Templated <ref> inside inline images
15585 !! wikitext
15586 [[File:Foobar.jpg|Undisplayed caption in inline image with ref: {{echo|<ref>{{echo|foo}}</ref>}}]]
15587
15588 <references />
15589 !! html/parsoid
15590 <p><span class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"caption","ak":"Undisplayed caption in inline image with ref: {{echo|&lt;ref>{{echo|foo}}&lt;/ref>}}"}]}' data-mw='{"caption":"Undisplayed caption in inline image with ref: &lt;span about=\"#mwt2\" class=\"mw-ref\" id=\"cite_ref-1\" rel=\"dc:references\" typeof=\"mw:Transclusion mw:Extension/ref\" data-parsoid=&#39;{\"dsr\":[64,96,null,null],\"pi\":[[{\"k\":\"1\"}]]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"&amp;lt;ref>{{echo|foo}}&amp;lt;/ref>\"}},\"i\":0}}]}&#39;>&lt;a href=\"./Main_Page#cite_note-1\" style=\"counter-reset: mw-Ref 1;\" data-parsoid=\"{}\">&lt;span class=\"mw-reflink-text\" data-parsoid=\"{}\">[1]&lt;/span>&lt;/a>&lt;/span>&lt;meta typeof=\"mw:Transclusion mw:Extension/ref/Marker\" about=\"#mwt2\" data-parsoid=&#39;{\"group\":\"\",\"name\":\"\",\"content\":\"foo\",\"hasRefInRef\":false,\"dsr\":[64,96,null,null],\"pi\":[[{\"k\":\"1\"}]]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"&amp;lt;ref>{{echo|foo}}&amp;lt;/ref>\"}},\"i\":0}}]}&#39;/>"}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{}}'><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></span></p>
15591
15592 <ol class="mw-references" typeof="mw:Extension/references" about="#mwt6" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text" data-parsoid="{}">foo</span></li></ol>
15593 !! end
15594
15595 ###
15596 ### Subpages
15597 ###
15598 !! article
15599 Subpage test/subpage
15600 !! text
15601 foo
15602 !! endarticle
15603
15604 !! test
15605 Subpage link
15606 !! options
15607 subpage title=[[Subpage test]]
15608 !! wikitext
15609 [[/subpage]]
15610 !! html
15611 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a>
15612 </p>
15613 !! end
15614
15615 !! test
15616 Subpage noslash link
15617 !! options
15618 subpage title=[[Subpage test]]
15619 !! wikitext
15620 [[/subpage/]]
15621 !! html
15622 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">subpage</a>
15623 </p>
15624 !! end
15625
15626 !! article
15627 Subpage test/1/2/subpage
15628 !! text
15629 blah
15630 !! endarticle
15631
15632 !! test
15633 Relative subpage noslash link
15634 !! options
15635 parsoid=wt2wt,wt2html,html2html
15636 subpage title=[[Subpage test/1/2/3/4]]
15637 !! wikitext
15638 [[../../subpage/]]
15639
15640 [[../../subpage]]
15641 !! html/php
15642 <p><a href="/wiki/Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">subpage</a>
15643 </p><p><a href="/wiki/Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">Subpage test/1/2/subpage</a>
15644 </p>
15645 !! html/parsoid
15646 <p><a rel="mw:WikiLink" href="./Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">subpage</a></p>
15647 <p><a rel="mw:WikiLink" href="./Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">Subpage_test/1/2/subpage</a></p>
15648 !! end
15649
15650 !! test
15651 Parsoid: dot-slash prefixed wikilinks
15652 !! wikitext
15653 [[./foo]]
15654
15655 [[././bar]]
15656
15657 [[././baz/]]
15658 !! html/php
15659 <p>[[./foo]]
15660 </p><p>[[././bar]]
15661 </p><p>[[././baz/]]
15662 </p>
15663 !! html/parsoid
15664 <p>[[./foo]]
15665 </p><p>[[././bar]]
15666 </p><p>[[././baz/]]
15667 </p>
15668 !! end
15669
15670 !! test
15671 Render invalid page names as plain text (T53090)
15672 !! wikitext
15673 [[./../foo|bar]]
15674 [[foo�|bar]]
15675 [[foo/.|bar]]
15676 [[foo/..|bar]]
15677 [[foo~~~bar]]
15678 [[foo>bar]]
15679 [[foo[bar]]
15680 [[.]]
15681 [[..]]
15682 [[foo././bar]]
15683 [[foo[http://example.com]xyz]]
15684
15685 [[{{echo|./../foo}}|bar]]
15686 [[{{echo|foo/.}}|bar]]
15687 [[{{echo|foo/..}}|bar]]
15688 [[{{echo|foo~~~~bar}}]]
15689 [[{{echo|foo>bar}}]]
15690 [[{{echo|foo././bar}}]]
15691 [[{{echo|foo{bar}}]]
15692 [[{{echo|foo}bar}}]]
15693 [[{{echo|foo[bar}}]]
15694 [[{{echo|foo]bar}}]]
15695 [[{{echo|foo<bar}}]]
15696 !!html/php
15697 <p>[[./../foo|bar]]
15698 [[foo�|bar]]
15699 [[foo/.|bar]]
15700 [[foo/..|bar]]
15701 [[foo~~~bar]]
15702 [[foo&gt;bar]]
15703 [[foo[bar]]
15704 [[.]]
15705 [[..]]
15706 [[foo././bar]]
15707 [[foo<a rel="nofollow" class="external autonumber" href="http://example.com">[1]</a>xyz]]
15708 </p><p>[[./../foo|bar]]
15709 [[foo/.|bar]]
15710 [[foo/..|bar]]
15711 [[foo~~~~bar]]
15712 [[foo&gt;bar]]
15713 [[foo././bar]]
15714 [[foo{bar]]
15715 [[foo}bar]]
15716 [[foo[bar]]
15717 [[foo]bar]]
15718 [[foo&lt;bar]]
15719 </p>
15720 !!html/parsoid
15721 <p>[[./../foo|bar]]
15722 [[foo�|bar]]
15723 [[foo/.|bar]]
15724 [[foo/..|bar]]
15725 [[foo~~~bar]]
15726 [[foo>bar]]
15727 [[foo[bar]]
15728 [[.]]
15729 [[..]]
15730 [[foo././bar]]
15731 [[foo<a rel="mw:ExtLink" href="http://example.com"></a>xyz]]</p>
15732
15733 <p>[[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"./../foo"}},"i":0}}]}'>./../foo</span>|bar]]
15734 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo/."}},"i":0}}]}'>foo/.</span>|bar]]
15735 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo/.."}},"i":0}}]}'>foo/..</span>|bar]]
15736 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo~~~~bar"}},"i":0}}]}'>foo~~~~bar</span>]]
15737 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo>bar"}},"i":0}}]}'>foo>bar</span>]]
15738 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo././bar"}},"i":0}}]}'>foo././bar</span>]]
15739 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo{bar"}},"i":0}}]}'>foo{bar</span>]]
15740 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo}bar"}},"i":0}}]}'>foo}bar</span>]]
15741 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo[bar"}},"i":0}}]}'>foo[bar</span>]]
15742 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo]bar"}},"i":0}}]}'>foo]bar</span>]]
15743 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo&lt;bar"}},"i":0}}]}'>foo&lt;bar</span>]]</p>
15744 !!end
15745
15746 !! test
15747 Disabled subpages
15748 !! wikitext
15749 [[/subpage]]
15750 !! html
15751 <p><a href="/index.php?title=/subpage&amp;action=edit&amp;redlink=1" class="new" title="/subpage (page does not exist)">/subpage</a>
15752 </p>
15753 !! end
15754
15755 !! test
15756 T2561: {{/Subpage}}
15757 !! options
15758 subpage title=[[Page]]
15759 !! wikitext
15760 {{/Subpage}}
15761 !! html
15762 <p><a href="/index.php?title=Page/Subpage&amp;action=edit&amp;redlink=1" class="new" title="Page/Subpage (page does not exist)">Page/Subpage</a>
15763 </p>
15764 !! end
15765
15766 ###
15767 ### Categories
15768 ###
15769 !! article
15770 Category:MediaWiki User's Guide
15771 !! text
15772 blah
15773 !! endarticle
15774
15775 !! test
15776 Link to category
15777 !! wikitext
15778 [[:Category:MediaWiki User's Guide]]
15779 !! html
15780 <p><a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User's Guide">Category:MediaWiki User's Guide</a>
15781 </p>
15782 !! end
15783
15784 !! test
15785 Simple category
15786 !! options
15787 cat
15788 !! wikitext
15789 [[Category:MediaWiki User's Guide]]
15790 !! html/php
15791 cat=MediaWiki_User's_Guide sort=
15792 !! html/parsoid
15793 <link rel="mw:PageProp/Category" href="./Category:MediaWiki_User's_Guide" data-parsoid='{"stx":"simple","a":{"href":"./Category:MediaWiki_User&#39;s_Guide"},"sa":{"href":"Category:MediaWiki User&#39;s Guide"}}'/>
15794 !! end
15795
15796 !! test
15797 PAGESINCATEGORY invalid title fatal (r33546 fix)
15798 !! wikitext
15799 {{PAGESINCATEGORY:<bogus>}}
15800 !! html
15801 <p>0
15802 </p>
15803 !! end
15804
15805 !! test
15806 Category with different sort key
15807 !! options
15808 cat
15809 !! wikitext
15810 [[Category:MediaWiki User's Guide|Foo]]
15811 !! html/php
15812 cat=MediaWiki_User's_Guide sort=Foo
15813 !! html/parsoid
15814 <link rel="mw:PageProp/Category" href="./Category:MediaWiki_User's_Guide#Foo" data-parsoid='{"stx":"piped","a":{"href":"./Category:MediaWiki_User&#39;s_Guide"},"sa":{"href":"Category:MediaWiki User&#39;s Guide"}}'/>
15815 !! end
15816
15817 !! test
15818 Category with identical sort key
15819 !! options
15820 cat
15821 !! wikitext
15822 [[Category:MediaWiki User's Guide|MediaWiki User's Guide]]
15823 !! html/php
15824 cat=MediaWiki_User's_Guide sort=MediaWiki User's Guide
15825 !! html/parsoid
15826 <link rel="mw:PageProp/Category" href="./Category:MediaWiki_User's_Guide#MediaWiki%20User's%20Guide" data-parsoid='{"stx":"piped","a":{"href":"./Category:MediaWiki_User&#39;s_Guide"},"sa":{"href":"Category:MediaWiki User&#39;s Guide"}}'/>
15827 !! end
15828
15829 !! test
15830 Category with empty sort key
15831 !! options
15832 cat
15833 pst
15834 !! wikitext
15835 [[Category:MediaWiki User's Guide|]]
15836 !! html/php
15837 [[Category:MediaWiki User's Guide|MediaWiki User's Guide]]
15838 !! end
15839
15840 !! test
15841 Category with empty sort key and parentheses
15842 !! options
15843 cat
15844 pst
15845 !! wikitext
15846 [[Category:Foo (bar)|]]
15847 !! html/php
15848 [[Category:Foo (bar)|Foo]]
15849 !! end
15850
15851 !! test
15852 Category with link tail
15853 !! options
15854 cat
15855 pst
15856 !! wikitext
15857 123[[Category:Foo]]456
15858 !! html/php
15859 123[[Category:Foo]]456
15860 !! end
15861
15862 !! test
15863 Category with template
15864 !! options
15865 cat
15866 pst
15867 !! wikitext
15868 [[Category:{{echo|Foo}}]]
15869 !! html/php
15870 [[Category:{{echo|Foo}}]]
15871 !! end
15872
15873 !! test
15874 Category with template in sort key
15875 !! options
15876 cat
15877 pst
15878 !! wikitext
15879 [[Category:Foo|{{echo|Bar}}]]
15880 !! html/php
15881 [[Category:Foo|{{echo|Bar}}]]
15882 !! end
15883
15884 !! test
15885 Category with template in sort key and title
15886 !! options
15887 cat
15888 pst
15889 !! wikitext
15890 [[Category:{{echo|Foo}}|{{echo|Bar}}]]
15891 !! html/php
15892 [[Category:{{echo|Foo}}|{{echo|Bar}}]]
15893 !! end
15894
15895 ## We used to, but no longer wt2wt this test since the default serializer
15896 ## will normalize all categories to serialize on their own line.
15897 ## This wikitext usage is going to be fairly uncommon in production and
15898 ## selser will take care of preserving formatting in those scenarios.
15899 !! test
15900 Category / paragraph interactions
15901 !! options
15902 parsoid=wt2html
15903 !! wikitext
15904 Foo [[Category:Baz]] Bar
15905
15906 Foo [[Category:Baz]]
15907 Bar
15908
15909 Foo
15910 [[Category:Baz]]
15911 Bar
15912
15913 Foo
15914 [[Category:Baz]] Bar
15915
15916 Foo
15917 [[Category:Baz]]
15918 [[Category:Baz]]
15919 [[Category:Baz]]
15920 Bar
15921
15922 [[Category:Baz]]
15923 [[Category:Baz]]
15924 [[Category:Baz]]
15925
15926 [[Category:Baz]]
15927 {{echo|[[Category:Baz]]}}
15928 [[Category:Baz]]
15929 !! html/php
15930 <p>Foo Bar
15931 </p><p>Foo
15932 Bar
15933 </p><p>Foo
15934 Bar
15935 </p><p>Foo Bar
15936 </p><p>Foo
15937 Bar
15938 </p>
15939 !! html/parsoid
15940 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
15941 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
15942 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
15943 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
15944 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> <link rel="mw:PageProp/Category" href="./Category:Baz"/> <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar <link rel="mw:PageProp/Category" href="./Category:Baz"/> <link rel="mw:PageProp/Category" href="./Category:Baz"/> <link rel="mw:PageProp/Category" href="./Category:Baz"/> <link rel="mw:PageProp/Category" href="./Category:Baz"/> <link rel="mw:PageProp/Category" href="./Category:Baz" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[Category:Baz]]"}},"i":0}}]}'/></p>
15945 <link rel="mw:PageProp/Category" href="./Category:Baz"/>
15946 !! end
15947
15948 ## We used to, but no longer wt2wt this test since the default serializer
15949 ## will normalize all categories to serialize on their own line.
15950 ## This wikitext usage is going to be fairly uncommon in production and
15951 ## selser will take care of preserving formatting in those scenarios.
15952 ##
15953 ## The whitespace on the empty line is part of the test. Please do not delete
15954 !! test
15955 1. Categories and newlines: All preceding newlines should be suppressed (courtesy T2087)
15956 !! options
15957 parsoid=wt2html
15958 !! wikitext
15959 This
15960
15961 [[Category:Foo]] and this should be part of same paragraph (not an indent-pre)
15962
15963 {{echo|[[Category:Foo]] and so should this!}}
15964 !! html/php
15965 <p>This and this should be part of same paragraph (not an indent-pre) and so should this!
15966 </p>
15967 !! html/parsoid
15968 <p>This
15969
15970 <link rel="mw:PageProp/Category" href="./Category:Foo"/> and this should be part of same paragraph (not an indent-pre)
15971
15972 <link rel="mw:PageProp/Category" href="./Category:Foo" about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[Category:Foo]] and so should this!"}},"i":0}}]}'/><span about="#mwt1"> and so should this!</span></p>
15973 !! end
15974
15975 ## Parsoid will not try to wt2wt this while preserving newlines because
15976 ## it suppresses excess newlines within list items -- and we don't want to
15977 ## introduce a special case just for categories, which is, in reality somewhat
15978 ## odd behavior -- categories are unlikely to be used in list items like this
15979 ## in top-level pages and are only likely to show up in template-generated
15980 ## list items where this RT-ing is a non-issue.
15981 ##
15982 ## The whitespace on the empty line is part of the test. Please do not delete
15983 !! test
15984 2. Categories and newlines: All preceding newlines should be suppressed (courtesy T2087)
15985 !! options
15986 parsoid=wt2html
15987 !! wikitext
15988 * This
15989
15990 [[Category:Foo]] and this should be part of the same list item
15991 * So should this
15992
15993 {{echo|[[Category:Foo]] and this should be part of the same list item}}
15994 !! html
15995 <ul><li>This and this should be part of the same list item</li>
15996 <li>So should this and this should be part of the same list item</li></ul>
15997 !! html/parsoid
15998 <ul>
15999 <li>This <link rel="mw:PageProp/Category" href="./Category:Foo"/> and this should be part of the same list item</li>
16000 <li>So should this <link rel="mw:PageProp/Category" href="./Category:Foo" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[Category:Foo]] and this should be part of the same list item"}},"i":0}}]}'/><span> and this should be part of the same list item</span></li>
16001 </ul>
16002 !! end
16003
16004 ## Newlines and categories that follow the last item of a list
16005 ## are treated differently because this (list followed by categories)
16006 ## is an extremely common pattern on wikis.
16007 !! test
16008 3. Categories and newlines: newline suppression for last list item should RT properly
16009 !! wikitext
16010 * a
16011 * b
16012
16013 [[Category:Foo]]
16014
16015 [[Category:Bar]]
16016 [[Category:Baz]]
16017 !! html/parsoid
16018 <ul><li> a</li>
16019 <li> b</li></ul>
16020
16021 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
16022
16023 <link rel="mw:PageProp/Category" href="./Category:Bar" data-parsoid='{"stx":"simple","a":{"href":"./Category:Bar"},"sa":{"href":"Category:Bar"}}'/>
16024 <link rel="mw:PageProp/Category" href="./Category:Baz" data-parsoid='{"stx":"simple","a":{"href":"./Category:Baz"},"sa":{"href":"Category:Baz"}}'/>
16025 !! end
16026
16027 !! test
16028 4. Categories and newlines: newline suppression for last list item should RT properly
16029 !! wikitext
16030 * a
16031 **** b
16032
16033 [[Category:Foo]]
16034 !! html/parsoid
16035 <ul><li> a
16036 <ul><li><ul><li><ul><li> b</li></ul></li></ul></li></ul></li></ul>
16037
16038 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
16039 !! end
16040
16041 ## only wt2html for this to make sure the algo only applies to the rightmost path
16042 !! test
16043 5. Categories and newlines: migrateTrailingCategories dom pass should only run on the rightmost path of nested lists
16044 !! options
16045 parsoid=wt2html
16046 !! wikitext
16047 * a
16048 ** b
16049 [[Category:Foo]]
16050 * c
16051 ** d
16052 [[Category:Foo]]
16053 !! html/parsoid
16054 <ul><li> a
16055 <ul><li> b
16056 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/></li></ul></li>
16057 <li> c
16058 <ul><li> d</li></ul></li></ul>
16059 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
16060 !! end
16061
16062 ## We used to, but no longer wt2wt this test since the default serializer
16063 ## will normalize all categories to serialize on their own line.
16064 ## This wikitext usage is going to be fairly uncommon in production and
16065 ## selser will take care of preserving formatting in those scenarios.
16066 !! test
16067 6. Categories and newlines: migrateTrailingCategories dom pass should not migrate categories not preceded by newlines
16068 !! options
16069 parsoid=wt2html
16070 !! wikitext
16071 * a [[Category:Foo]]
16072 !! html/parsoid
16073 <ul><li>a <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/></li></ul>
16074 !! end
16075
16076 # This test also demonstrates because of newline+category tunneling
16077 # through the list hander, template wrapping doesn't expand to the
16078 # containing list when the list item swallows the category.
16079 !! test
16080 7. Categories and newlines: migrateTrailingCategories dom pass should leave template content alone
16081 !! wikitext
16082 * {{echo|a
16083 [[Category:Foo]]}}
16084 !! html/parsoid
16085 <ul><li> <span about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"a\n[[Category:Foo]]"}},"i":0}}]}'>a
16086 </span><link rel="mw:PageProp/Category" href="./Category:Foo" about="#mwt1" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/></li></ul>
16087 !! end
16088
16089 !! test
16090 8. Categories and newlines: migrateTrailingCategories dom pass should not get tripped by intervening templates
16091 !! wikitext
16092 * a
16093
16094 {{echo|[[Category:Foo]]
16095 [[Category:Bar]]}}
16096 [[Category:Baz]]
16097 !! html/parsoid
16098 <ul><li> a</li></ul>
16099
16100 <link rel="mw:PageProp/Category" href="./Category:Foo" about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"},"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[Category:Foo]]\n[[Category:Bar]]"}},"i":0}}]}'/><span about="#mwt1">
16101 </span><link rel="mw:PageProp/Category" href="./Category:Bar" about="#mwt1" data-parsoid='{"stx":"simple","a":{"href":"./Category:Bar"},"sa":{"href":"Category:Bar"}}'/>
16102 <link rel="mw:PageProp/Category" href="./Category:Baz" data-parsoid='{"stx":"simple","a":{"href":"./Category:Baz"},"sa":{"href":"Category:Baz"}}'/>
16103 !! end
16104
16105 !! test
16106 9. Categories and newlines: should behave properly with linkprefix (T87753)
16107 !! options
16108 language=ar
16109 !! wikitext
16110 foo bar
16111 foo bar
16112 [[تصنيف:Foo]]
16113 [[تصنيف:Bar]]
16114 !! html/php
16115 <p>foo bar
16116 foo bar
16117 </p>
16118 !! html/parsoid
16119 <p>foo bar
16120 foo bar</p>
16121 <link rel="mw:PageProp/Category" href="./تصنيف:Foo"/>
16122 <link rel="mw:PageProp/Category" href="./تصنيف:Bar"/>
16123 !! end
16124
16125 !! test
16126 10. No regressions on internal links following category (T174639)
16127 !! options
16128 parsoid=wt2html,html2html
16129 !! wikitext
16130 [[Category:Foo]]<div>a
16131
16132 [[Foo]]</div>
16133 !! html/php
16134 <div>a
16135 <a href="/wiki/Foo" title="Foo">Foo</a></div>
16136
16137 !! html/parsoid
16138 <link rel="mw:PageProp/Category" href="./Category:Foo"/><div>a
16139
16140 <a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></div>
16141 !! end
16142
16143 # NOTE that Parsoid does not currently implement this special case
16144 # (T175416). The plan is to remove this weird special-case in the PHP
16145 # parser to make it match the Parsoid output.
16146 !! test
16147 11. Special case where only newlines separate links
16148 !! options
16149 parsoid=wt2html,html2html
16150 !! wikitext
16151 [[Category:Foo]]
16152
16153 [[Foo]][[es:Alimento]]
16154
16155 [[Foo]]
16156 !! html/php
16157 <p><a href="/wiki/Foo" title="Foo">Foo</a><a href="/wiki/Foo" title="Foo">Foo</a>
16158 </p>
16159 !! html/parsoid
16160 <link rel="mw:PageProp/Category" href="./Category:Foo"/>
16161
16162 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></p><link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Alimento"/>
16163
16164 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></p>
16165 !! end
16166
16167 !! test
16168 Category links with multiple namespaces
16169 !! wikitext
16170 [[Category:Project:Foo]]
16171 !! html/parsoid
16172 <link rel="mw:PageProp/Category" href="./Category:Project:Foo" />
16173 !! end
16174
16175 !! test
16176 Parsoid: Serialize link to category page with colon escape
16177 !! options
16178 parsoid
16179 !! wikitext
16180
16181 [[:Category:Foo]]
16182 [[:Category:Foo|Bar]]
16183 !! html
16184 <p>
16185 <a rel="mw:WikiLink" href="./Category:Foo" title="Category:Foo">Category:Foo</a>
16186 <a rel="mw:WikiLink" href="./Category:Foo" title="Category:Foo">Bar</a>
16187 </p>
16188 !! end
16189
16190 # We used to, but no longer wt2wt this test since the default serializer
16191 # will normalize all categories to serialize on their own line.
16192 # This wikitext usage is going to be fairly uncommon in production and
16193 # selser will take care of preventing whitespace insertion if this
16194 # occurs in an article.
16195 #
16196 # html2html disabled for the same reason (whitespace insertion between
16197 # x and y).
16198 #
16199 # html2wt disabled because it localizes the "Category" namespace.
16200 !! test
16201 Link prefix/suffixes aren't applied to category links
16202 !! options
16203 parsoid=wt2html
16204 language=is
16205 !! wikitext
16206 x[[Category:Foo]]y
16207 !! html/php
16208 <p>xy
16209 </p>
16210 !! html/parsoid
16211 <p>x<link rel="mw:PageProp/Category" href="./Flokkur:Foo" data-parsoid=""/>y</p>
16212 !! end
16213
16214 !! test
16215 Link prefix/suffixes aren't applied to language links
16216 !! options
16217 parsoid=wt2html
16218 language=is
16219 !! wikitext
16220 x[[es:Foo]]y
16221 !! html/php
16222 <p>xy
16223 </p>
16224 !! html/parsoid
16225 <p>x<link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo" data-parsoid=""/>y</p>
16226 !! end
16227
16228 !! test
16229 Parsoid: Serialize link to file page with colon escape
16230 !! options
16231 parsoid
16232 !! wikitext
16233
16234 [[:File:Foo.png]]
16235 [[:File:Foo.png|Bar]]
16236 !! html
16237 <p>
16238 <a rel="mw:WikiLink" href="./File:Foo.png" title="File:Foo.png">File:Foo.png</a>
16239 <a rel="mw:WikiLink" href="./File:Foo.png" title="File:Foo.png">Bar</a>
16240 </p>
16241 !! end
16242
16243 !! test
16244 Parsoid: Serialize a genuine category link without colon escape
16245 !! options
16246 parsoid
16247 !! wikitext
16248 [[Category:Foo]]
16249 [[Category:Foo|Bar]]
16250 !! html
16251 <link rel="mw:PageProp/Category" href="./Category:Foo">
16252 <link rel="mw:PageProp/Category" href="./Category:Foo#Bar">
16253 !! end
16254
16255 !! test
16256 Normalize hrefs properly before testing for invalid link targets (T72894)
16257 !! options
16258 parsoid=html2wt
16259 !! html/parsoid
16260 <link rel="mw:PageProp/Category" href="./Category:Toxine_bactérienne"/>
16261 !! wikitext
16262 [[Category:Toxine bactérienne]]
16263 !! end
16264
16265 !! test
16266 Parsoid: Defaultsort
16267 !! wikitext
16268 {{DEFAULTSORT:Foo}}
16269 !! html/parsoid
16270 <meta property="mw:PageProp/categorydefaultsort" content="Foo"/>
16271 !! end
16272
16273 # NOTE: mw:ExpandedAttrs is not the best typeof here. mw:Transclusion is better.
16274 # But, this is a limitation of our representation and is documented in
16275 # TemplateHandler.js in processSpecialMagicWord
16276 !! test
16277 Parsoid: Defaultsort (template-generated)
16278 !! wikitext
16279 {{{{echo|DEFAULTSORT}}:Foo}}
16280 !! html/parsoid
16281 <meta property="mw:PageProp/categorydefaultsort" content="Foo" about="#mwt3" typeof="mw:ExpandedAttrs" data-parsoid='{"src":"{{{{echo|DEFAULTSORT}}:Foo}}","dsr":[0,26,null,null]}' data-mw='{"attribs":[[{"txt":"content"},{"html":"&lt;span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid=&#39;{\"pi\":[[{\"k\":\"1\"}]],\"dsr\":[2,22,null,null]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"DEFAULTSORT\"}},\"i\":0}}]}&#39;>DEFAULTSORT&lt;/span>:Foo"}]]}'/>
16282 !! end
16283
16284 ###
16285 ### Inter-language links
16286 ###
16287 !! test
16288 Interlanguage links
16289 !! options
16290 ill
16291 !! wikitext
16292 [[es:Alimento]]
16293 [[fr:Nourriture]]
16294 [[zh:食品]]
16295 !! html/php
16296 es:Alimento fr:Nourriture zh:食品
16297 !! html/parsoid
16298 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Alimento"/>
16299 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/Nourriture"/>
16300 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/食品"/>
16301 !! end
16302
16303 !! test
16304 Duplicate interlanguage links (T26502)
16305 !! options
16306 ill
16307 !! wikitext
16308 [[es:1]]
16309 [[es:2]]
16310 [[fr:1]]
16311 [[fr:2]]
16312 !! html/php
16313 es:1 fr:1
16314 !! html/parsoid
16315 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/1"/>
16316 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/2"/>
16317 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/1"/>
16318 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/2"/>
16319 !! end
16320
16321 ###
16322 ### Sections
16323 ###
16324 !! test
16325 Basic section headings
16326 !! wikitext
16327 == Headline 1 ==
16328 Some text
16329
16330 ==Headline 2==
16331 More
16332 ===Smaller headline===
16333 Blah blah
16334 !! html
16335 <h2><span class="mw-headline" id="Headline_1">Headline 1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: Headline 1">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
16336 <p>Some text
16337 </p>
16338 <h2><span class="mw-headline" id="Headline_2">Headline 2</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: Headline 2">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
16339 <p>More
16340 </p>
16341 <h3><span class="mw-headline" id="Smaller_headline">Smaller headline</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=3" title="Edit section: Smaller headline">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
16342 <p>Blah blah
16343 </p>
16344 !! end
16345
16346 !! test
16347 Section headings with TOC
16348 !! wikitext
16349 == Headline 1 ==
16350 === Subheadline 1 ===
16351 ===== Skipping a level =====
16352 ====== Skipping a level ======
16353
16354 == Headline 2 ==
16355 Some text
16356 ===Another headline===
16357 !! html
16358 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
16359 <ul>
16360 <li class="toclevel-1 tocsection-1"><a href="#Headline_1"><span class="tocnumber">1</span> <span class="toctext">Headline 1</span></a>
16361 <ul>
16362 <li class="toclevel-2 tocsection-2"><a href="#Subheadline_1"><span class="tocnumber">1.1</span> <span class="toctext">Subheadline 1</span></a>
16363 <ul>
16364 <li class="toclevel-3 tocsection-3"><a href="#Skipping_a_level"><span class="tocnumber">1.1.1</span> <span class="toctext">Skipping a level</span></a>
16365 <ul>
16366 <li class="toclevel-4 tocsection-4"><a href="#Skipping_a_level_2"><span class="tocnumber">1.1.1.1</span> <span class="toctext">Skipping a level</span></a></li>
16367 </ul>
16368 </li>
16369 </ul>
16370 </li>
16371 </ul>
16372 </li>
16373 <li class="toclevel-1 tocsection-5"><a href="#Headline_2"><span class="tocnumber">2</span> <span class="toctext">Headline 2</span></a>
16374 <ul>
16375 <li class="toclevel-2 tocsection-6"><a href="#Another_headline"><span class="tocnumber">2.1</span> <span class="toctext">Another headline</span></a></li>
16376 </ul>
16377 </li>
16378 </ul>
16379 </div>
16380
16381 <h2><span class="mw-headline" id="Headline_1">Headline 1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: Headline 1">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
16382 <h3><span class="mw-headline" id="Subheadline_1">Subheadline 1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: Subheadline 1">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
16383 <h5><span class="mw-headline" id="Skipping_a_level">Skipping a level</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=3" title="Edit section: Skipping a level">edit</a><span class="mw-editsection-bracket">]</span></span></h5>
16384 <h6><span class="mw-headline" id="Skipping_a_level_2">Skipping a level</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=4" title="Edit section: Skipping a level">edit</a><span class="mw-editsection-bracket">]</span></span></h6>
16385 <h2><span class="mw-headline" id="Headline_2">Headline 2</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=5" title="Edit section: Headline 2">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
16386 <p>Some text
16387 </p>
16388 <h3><span class="mw-headline" id="Another_headline">Another headline</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=6" title="Edit section: Another headline">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
16389
16390 !! end
16391
16392 !! test
16393 TOC anchors don't collide
16394 !! wikitext
16395 __FORCETOC__
16396 == Headline 2 ==
16397 == Headline ==
16398 == Headline 2 ==
16399 == Headline ==
16400 !! html/php
16401 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
16402 <ul>
16403 <li class="toclevel-1 tocsection-1"><a href="#Headline_2"><span class="tocnumber">1</span> <span class="toctext">Headline 2</span></a></li>
16404 <li class="toclevel-1 tocsection-2"><a href="#Headline"><span class="tocnumber">2</span> <span class="toctext">Headline</span></a></li>
16405 <li class="toclevel-1 tocsection-3"><a href="#Headline_2_2"><span class="tocnumber">3</span> <span class="toctext">Headline 2</span></a></li>
16406 <li class="toclevel-1 tocsection-4"><a href="#Headline_3"><span class="tocnumber">4</span> <span class="toctext">Headline</span></a></li>
16407 </ul>
16408 </div>
16409
16410 <h2><span class="mw-headline" id="Headline_2">Headline 2</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: Headline 2">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
16411 <h2><span class="mw-headline" id="Headline">Headline</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: Headline">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
16412 <h2><span class="mw-headline" id="Headline_2_2">Headline 2</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=3" title="Edit section: Headline 2">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
16413 <h2><span class="mw-headline" id="Headline_3">Headline</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=4" title="Edit section: Headline">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
16414
16415 !! end
16416
16417 # perl -e 'print "="x$_," Level $_ heading","="x$_,"\n" for 1..10'
16418 !! test
16419 Handling of sections up to level 6 and beyond
16420 !! wikitext
16421 = Level 1 Heading=
16422 == Level 2 Heading==
16423 === Level 3 Heading===
16424 ==== Level 4 Heading====
16425 ===== Level 5 Heading=====
16426 ====== Level 6 Heading======
16427 ======= Level 7 Heading=======
16428 ======== Level 8 Heading========
16429 ========= Level 9 Heading=========
16430 ========== Level 10 Heading==========
16431 !! html
16432 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
16433 <ul>
16434 <li class="toclevel-1 tocsection-1"><a href="#Level_1_Heading"><span class="tocnumber">1</span> <span class="toctext">Level 1 Heading</span></a>
16435 <ul>
16436 <li class="toclevel-2 tocsection-2"><a href="#Level_2_Heading"><span class="tocnumber">1.1</span> <span class="toctext">Level 2 Heading</span></a>
16437 <ul>
16438 <li class="toclevel-3 tocsection-3"><a href="#Level_3_Heading"><span class="tocnumber">1.1.1</span> <span class="toctext">Level 3 Heading</span></a>
16439 <ul>
16440 <li class="toclevel-4 tocsection-4"><a href="#Level_4_Heading"><span class="tocnumber">1.1.1.1</span> <span class="toctext">Level 4 Heading</span></a>
16441 <ul>
16442 <li class="toclevel-5 tocsection-5"><a href="#Level_5_Heading"><span class="tocnumber">1.1.1.1.1</span> <span class="toctext">Level 5 Heading</span></a>
16443 <ul>
16444 <li class="toclevel-6 tocsection-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>
16445 <li class="toclevel-6 tocsection-7"><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>
16446 <li class="toclevel-6 tocsection-8"><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>
16447 <li class="toclevel-6 tocsection-9"><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>
16448 <li class="toclevel-6 tocsection-10"><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>
16449 </ul>
16450 </li>
16451 </ul>
16452 </li>
16453 </ul>
16454 </li>
16455 </ul>
16456 </li>
16457 </ul>
16458 </li>
16459 </ul>
16460 </div>
16461
16462 <h1><span class="mw-headline" id="Level_1_Heading">Level 1 Heading</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: Level 1 Heading">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
16463 <h2><span class="mw-headline" id="Level_2_Heading">Level 2 Heading</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: Level 2 Heading">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
16464 <h3><span class="mw-headline" id="Level_3_Heading">Level 3 Heading</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=3" title="Edit section: Level 3 Heading">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
16465 <h4><span class="mw-headline" id="Level_4_Heading">Level 4 Heading</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=4" title="Edit section: Level 4 Heading">edit</a><span class="mw-editsection-bracket">]</span></span></h4>
16466 <h5><span class="mw-headline" id="Level_5_Heading">Level 5 Heading</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=5" title="Edit section: Level 5 Heading">edit</a><span class="mw-editsection-bracket">]</span></span></h5>
16467 <h6><span class="mw-headline" id="Level_6_Heading">Level 6 Heading</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=6" title="Edit section: Level 6 Heading">edit</a><span class="mw-editsection-bracket">]</span></span></h6>
16468 <h6><span class="mw-headline" id=".3D_Level_7_Heading.3D">= Level 7 Heading=</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=7" title="Edit section: = Level 7 Heading=">edit</a><span class="mw-editsection-bracket">]</span></span></h6>
16469 <h6><span class="mw-headline" id=".3D.3D_Level_8_Heading.3D.3D">== Level 8 Heading==</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=8" title="Edit section: == Level 8 Heading==">edit</a><span class="mw-editsection-bracket">]</span></span></h6>
16470 <h6><span class="mw-headline" id=".3D.3D.3D_Level_9_Heading.3D.3D.3D">=== Level 9 Heading===</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=9" title="Edit section: === Level 9 Heading===">edit</a><span class="mw-editsection-bracket">]</span></span></h6>
16471 <h6><span class="mw-headline" id=".3D.3D.3D.3D_Level_10_Heading.3D.3D.3D.3D">==== Level 10 Heading====</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=10" title="Edit section: ==== Level 10 Heading====">edit</a><span class="mw-editsection-bracket">]</span></span></h6>
16472
16473 !! end
16474
16475 !! test
16476 TOC regression (T11764)
16477 !! wikitext
16478 == title 1 ==
16479 === title 1.1 ===
16480 ==== title 1.1.1 ====
16481 === title 1.2 ===
16482 == title 2 ==
16483 === title 2.1 ===
16484 !! html
16485 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
16486 <ul>
16487 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
16488 <ul>
16489 <li class="toclevel-2 tocsection-2"><a href="#title_1.1"><span class="tocnumber">1.1</span> <span class="toctext">title 1.1</span></a>
16490 <ul>
16491 <li class="toclevel-3 tocsection-3"><a href="#title_1.1.1"><span class="tocnumber">1.1.1</span> <span class="toctext">title 1.1.1</span></a></li>
16492 </ul>
16493 </li>
16494 <li class="toclevel-2 tocsection-4"><a href="#title_1.2"><span class="tocnumber">1.2</span> <span class="toctext">title 1.2</span></a></li>
16495 </ul>
16496 </li>
16497 <li class="toclevel-1 tocsection-5"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a>
16498 <ul>
16499 <li class="toclevel-2 tocsection-6"><a href="#title_2.1"><span class="tocnumber">2.1</span> <span class="toctext">title 2.1</span></a></li>
16500 </ul>
16501 </li>
16502 </ul>
16503 </div>
16504
16505 <h2><span class="mw-headline" id="title_1">title 1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: title 1">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
16506 <h3><span class="mw-headline" id="title_1.1">title 1.1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: title 1.1">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
16507 <h4><span class="mw-headline" id="title_1.1.1">title 1.1.1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=3" title="Edit section: title 1.1.1">edit</a><span class="mw-editsection-bracket">]</span></span></h4>
16508 <h3><span class="mw-headline" id="title_1.2">title 1.2</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=4" title="Edit section: title 1.2">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
16509 <h2><span class="mw-headline" id="title_2">title 2</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=5" title="Edit section: title 2">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
16510 <h3><span class="mw-headline" id="title_2.1">title 2.1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=6" title="Edit section: title 2.1">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
16511
16512 !! end
16513
16514 !! test
16515 TOC for heading containing <span id="..."></span> (T96153)
16516 !! wikitext
16517 __FORCETOC__
16518 ==<span id="old-anchor"></span>New title==
16519 !! html/php
16520 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
16521 <ul>
16522 <li class="toclevel-1 tocsection-1"><a href="#New_title"><span class="tocnumber">1</span> <span class="toctext">New title</span></a></li>
16523 </ul>
16524 </div>
16525
16526 <h2><span class="mw-headline" id="New_title"><span id="old-anchor"></span>New title</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: New title">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
16527
16528 !! end
16529
16530 !! test
16531 TOC with wgMaxTocLevel=3 (T8204)
16532 !! options
16533 wgMaxTocLevel=3
16534 !! wikitext
16535 == title 1 ==
16536 === title 1.1 ===
16537 ==== title 1.1.1 ====
16538 === title 1.2 ===
16539 == title 2 ==
16540 === title 2.1 ===
16541 !! html
16542 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
16543 <ul>
16544 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
16545 <ul>
16546 <li class="toclevel-2 tocsection-2"><a href="#title_1.1"><span class="tocnumber">1.1</span> <span class="toctext">title 1.1</span></a></li>
16547 <li class="toclevel-2 tocsection-4"><a href="#title_1.2"><span class="tocnumber">1.2</span> <span class="toctext">title 1.2</span></a></li>
16548 </ul>
16549 </li>
16550 <li class="toclevel-1 tocsection-5"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a>
16551 <ul>
16552 <li class="toclevel-2 tocsection-6"><a href="#title_2.1"><span class="tocnumber">2.1</span> <span class="toctext">title 2.1</span></a></li>
16553 </ul>
16554 </li>
16555 </ul>
16556 </div>
16557
16558 <h2><span class="mw-headline" id="title_1">title 1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: title 1">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
16559 <h3><span class="mw-headline" id="title_1.1">title 1.1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: title 1.1">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
16560 <h4><span class="mw-headline" id="title_1.1.1">title 1.1.1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=3" title="Edit section: title 1.1.1">edit</a><span class="mw-editsection-bracket">]</span></span></h4>
16561 <h3><span class="mw-headline" id="title_1.2">title 1.2</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=4" title="Edit section: title 1.2">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
16562 <h2><span class="mw-headline" id="title_2">title 2</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=5" title="Edit section: title 2">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
16563 <h3><span class="mw-headline" id="title_2.1">title 2.1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=6" title="Edit section: title 2.1">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
16564
16565 !! end
16566
16567 !! test
16568 TOC with wgMaxTocLevel=3 and two level four headings (T8204)
16569 !! options
16570 wgMaxTocLevel=3
16571 !! wikitext
16572 ==Section 1==
16573 ===Section 1.1===
16574 ====Section 1.1.1====
16575 ====Section 1.1.1.1====
16576 ==Section 2==
16577 !! html
16578 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
16579 <ul>
16580 <li class="toclevel-1 tocsection-1"><a href="#Section_1"><span class="tocnumber">1</span> <span class="toctext">Section 1</span></a>
16581 <ul>
16582 <li class="toclevel-2 tocsection-2"><a href="#Section_1.1"><span class="tocnumber">1.1</span> <span class="toctext">Section 1.1</span></a></li>
16583 </ul>
16584 </li>
16585 <li class="toclevel-1 tocsection-5"><a href="#Section_2"><span class="tocnumber">2</span> <span class="toctext">Section 2</span></a></li>
16586 </ul>
16587 </div>
16588
16589 <h2><span class="mw-headline" id="Section_1">Section 1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: Section 1">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
16590 <h3><span class="mw-headline" id="Section_1.1">Section 1.1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: Section 1.1">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
16591 <h4><span class="mw-headline" id="Section_1.1.1">Section 1.1.1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=3" title="Edit section: Section 1.1.1">edit</a><span class="mw-editsection-bracket">]</span></span></h4>
16592 <h4><span class="mw-headline" id="Section_1.1.1.1">Section 1.1.1.1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=4" title="Edit section: Section 1.1.1.1">edit</a><span class="mw-editsection-bracket">]</span></span></h4>
16593 <h2><span class="mw-headline" id="Section_2">Section 2</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=5" title="Edit section: Section 2">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
16594
16595 !! end
16596
16597
16598 !! test
16599 Resolving duplicate section names
16600 !! wikitext
16601 == Foo bar ==
16602 == Foo bar ==
16603 !! html
16604 <h2><span class="mw-headline" id="Foo_bar">Foo bar</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: Foo bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
16605 <h2><span class="mw-headline" id="Foo_bar_2">Foo bar</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: Foo bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
16606
16607 !! end
16608
16609 !! test
16610 Resolving duplicate section names with differing case (T12721)
16611 !! wikitext
16612 == Foo bar ==
16613 == Foo Bar ==
16614 !! html
16615 <h2><span class="mw-headline" id="Foo_bar">Foo bar</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: Foo bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
16616 <h2><span class="mw-headline" id="Foo_Bar_2">Foo Bar</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: Foo Bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
16617
16618 !! end
16619
16620 !! article
16621 Template:sections
16622 !! text
16623 ===Section 1===
16624 ==Section 2==
16625 !! endarticle
16626
16627 !! test
16628 Template with sections, __NOTOC__
16629 !! wikitext
16630 __NOTOC__
16631 ==Section 0==
16632 {{sections}}
16633 ==Section 4==
16634 !! html
16635 <h2><span class="mw-headline" id="Section_0">Section 0</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: Section 0">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
16636 <h3><span class="mw-headline" id="Section_1">Section 1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Template:Sections&amp;action=edit&amp;section=T-1" title="Template:Sections">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
16637 <h2><span class="mw-headline" id="Section_2">Section 2</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Template:Sections&amp;action=edit&amp;section=T-2" title="Template:Sections">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
16638 <h2><span class="mw-headline" id="Section_4">Section 4</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: Section 4">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
16639
16640 !! end
16641
16642 !! test
16643 __NOEDITSECTION__ keyword
16644 !! wikitext
16645 __NOEDITSECTION__
16646 ==Section 1==
16647 ==Section 2==
16648 !! html
16649 <h2><span class="mw-headline" id="Section_1">Section 1</span></h2>
16650 <h2><span class="mw-headline" id="Section_2">Section 2</span></h2>
16651
16652 !! end
16653
16654 !! test
16655 Link inside a section heading
16656 !! wikitext
16657 ==Section with a [[Main Page|link]] in it==
16658 !! html
16659 <h2><span class="mw-headline" id="Section_with_a_link_in_it">Section with a <a href="/wiki/Main_Page" title="Main Page">link</a> in it</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: Section with a link in it">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
16660
16661 !! end
16662
16663 !! test
16664 TOC regression (T14077)
16665 !! wikitext
16666 __TOC__
16667 == title 1 ==
16668 === title 1.1 ===
16669 == title 2 ==
16670 !! html
16671 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
16672 <ul>
16673 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
16674 <ul>
16675 <li class="toclevel-2 tocsection-2"><a href="#title_1.1"><span class="tocnumber">1.1</span> <span class="toctext">title 1.1</span></a></li>
16676 </ul>
16677 </li>
16678 <li class="toclevel-1 tocsection-3"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a></li>
16679 </ul>
16680 </div>
16681
16682 <h2><span class="mw-headline" id="title_1">title 1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: title 1">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
16683 <h3><span class="mw-headline" id="title_1.1">title 1.1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: title 1.1">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
16684 <h2><span class="mw-headline" id="title_2">title 2</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=3" title="Edit section: title 2">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
16685
16686 !! end
16687
16688 !! test
16689 T3219 URL next to image (good)
16690 !! wikitext
16691 http://example.com [[File:Foobar.jpg]]
16692 !! html/php
16693 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> <a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
16694 </p>
16695 !! html/parsoid
16696 <p><a rel="mw:ExtLink" href="http://example.com">http://example.com</a> <span class="mw-default-size" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></span></p>
16697 !!end
16698
16699 !! test
16700 Short headings with trailing space should match behavior of Parser::doHeadings (T21910)
16701 !! wikitext
16702 ===
16703 The line above must have a trailing space!
16704 === <!--
16705 --> <!-- -->
16706 But just in case it doesn't...
16707 !! html
16708 <h1><span class="mw-headline" id=".3D">=</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: =">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
16709 <p>The line above must have a trailing space!
16710 </p>
16711 <h1><span class="mw-headline" id=".3D_2">=</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: =">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
16712 <p>But just in case it doesn't...
16713 </p>
16714 !! end
16715
16716 !! test
16717 Header with special characters (T27462)
16718 !! wikitext
16719 The tooltips shall not show entities to the user (ie. be double escaped)
16720
16721 == text > text ==
16722 section 1
16723
16724 == text < text ==
16725 section 2
16726
16727 == text & text ==
16728 section 3
16729
16730 == text ' text ==
16731 section 4
16732
16733 == text " text ==
16734 section 5
16735 !! html
16736 <p>The tooltips shall not show entities to the user (ie. be double escaped)
16737 </p>
16738 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
16739 <ul>
16740 <li class="toclevel-1 tocsection-1"><a href="#text_.3E_text"><span class="tocnumber">1</span> <span class="toctext">text &gt; text</span></a></li>
16741 <li class="toclevel-1 tocsection-2"><a href="#text_.3C_text"><span class="tocnumber">2</span> <span class="toctext">text &lt; text</span></a></li>
16742 <li class="toclevel-1 tocsection-3"><a href="#text_.26_text"><span class="tocnumber">3</span> <span class="toctext">text &amp; text</span></a></li>
16743 <li class="toclevel-1 tocsection-4"><a href="#text_.27_text"><span class="tocnumber">4</span> <span class="toctext">text ' text</span></a></li>
16744 <li class="toclevel-1 tocsection-5"><a href="#text_.22_text"><span class="tocnumber">5</span> <span class="toctext">text " text</span></a></li>
16745 </ul>
16746 </div>
16747
16748 <h2><span class="mw-headline" id="text_.3E_text">text &gt; text</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: text &gt; text">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
16749 <p>section 1
16750 </p>
16751 <h2><span class="mw-headline" id="text_.3C_text">text &lt; text</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: text &lt; text">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
16752 <p>section 2
16753 </p>
16754 <h2><span class="mw-headline" id="text_.26_text">text &amp; text</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=3" title="Edit section: text &amp; text">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
16755 <p>section 3
16756 </p>
16757 <h2><span class="mw-headline" id="text_.27_text">text ' text</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=4" title="Edit section: text ' text">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
16758 <p>section 4
16759 </p>
16760 <h2><span class="mw-headline" id="text_.22_text">text " text</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=5" title="Edit section: text &quot; text">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
16761 <p>section 5
16762 </p>
16763 !! end
16764
16765 !! test
16766 Header with space, plus and underscore as entity
16767 !! wikitext
16768 Id should not contain + for spaces
16769
16770 == Space between Text ==
16771 section 1
16772
16773 == Space-Entity&#32;between&#32;Text ==
16774 section 2
16775
16776 == Plus+between+Text ==
16777 section 3
16778
16779 == Plus-Entity&#43;between&#43;Text ==
16780 section 4
16781
16782 == Underscore_between_Text ==
16783 section 5
16784
16785 == Underscore-Entity&#95;between&#95;Text ==
16786 section 6
16787
16788 [[#Space between Text]]
16789 [[#Space-Entity&#32;between&#32;Text]]
16790 [[#Plus+between+Text]]
16791 [[#Plus-Entity&#43;between&#43;Text]]
16792 [[#Underscore_between_Text]]
16793 [[#Underscore-Entity&#95;between&#95;Text]]
16794 !! html
16795 <p>Id should not contain + for spaces
16796 </p>
16797 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
16798 <ul>
16799 <li class="toclevel-1 tocsection-1"><a href="#Space_between_Text"><span class="tocnumber">1</span> <span class="toctext">Space between Text</span></a></li>
16800 <li class="toclevel-1 tocsection-2"><a href="#Space-Entity_between_Text"><span class="tocnumber">2</span> <span class="toctext">Space-Entity&#32;between&#32;Text</span></a></li>
16801 <li class="toclevel-1 tocsection-3"><a href="#Plus.2Bbetween.2BText"><span class="tocnumber">3</span> <span class="toctext">Plus+between+Text</span></a></li>
16802 <li class="toclevel-1 tocsection-4"><a href="#Plus-Entity.2Bbetween.2BText"><span class="tocnumber">4</span> <span class="toctext">Plus-Entity&#43;between&#43;Text</span></a></li>
16803 <li class="toclevel-1 tocsection-5"><a href="#Underscore_between_Text"><span class="tocnumber">5</span> <span class="toctext">Underscore_between_Text</span></a></li>
16804 <li class="toclevel-1 tocsection-6"><a href="#Underscore-Entity_between_Text"><span class="tocnumber">6</span> <span class="toctext">Underscore-Entity&#95;between&#95;Text</span></a></li>
16805 </ul>
16806 </div>
16807
16808 <h2><span class="mw-headline" id="Space_between_Text">Space between Text</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: Space between Text">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
16809 <p>section 1
16810 </p>
16811 <h2><span class="mw-headline" id="Space-Entity_between_Text">Space-Entity&#32;between&#32;Text</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: Space-Entity between Text">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
16812 <p>section 2
16813 </p>
16814 <h2><span class="mw-headline" id="Plus.2Bbetween.2BText">Plus+between+Text</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=3" title="Edit section: Plus+between+Text">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
16815 <p>section 3
16816 </p>
16817 <h2><span class="mw-headline" id="Plus-Entity.2Bbetween.2BText">Plus-Entity&#43;between&#43;Text</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=4" title="Edit section: Plus-Entity+between+Text">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
16818 <p>section 4
16819 </p>
16820 <h2><span class="mw-headline" id="Underscore_between_Text">Underscore_between_Text</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=5" title="Edit section: Underscore between Text">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
16821 <p>section 5
16822 </p>
16823 <h2><span class="mw-headline" id="Underscore-Entity_between_Text">Underscore-Entity&#95;between&#95;Text</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=6" title="Edit section: Underscore-Entity_between_Text">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
16824 <p>section 6
16825 </p><p><a href="#Space_between_Text">#Space between Text</a>
16826 <a href="#Space-Entity_between_Text">#Space-Entity&#32;between&#32;Text</a>
16827 <a href="#Plus.2Bbetween.2BText">#Plus+between+Text</a>
16828 <a href="#Plus-Entity.2Bbetween.2BText">#Plus-Entity&#43;between&#43;Text</a>
16829 <a href="#Underscore_between_Text">#Underscore_between_Text</a>
16830 <a href="#Underscore-Entity_between_Text">#Underscore-Entity&#95;between&#95;Text</a>
16831 </p>
16832 !! end
16833
16834 !! test
16835 Headers with excess '=' characters
16836 (Are similar tests necessary beyond the 1st level?)
16837 !! wikitext
16838 =foo==
16839 ==foo=
16840 =''italic'' heading==
16841 ==''italic'' heading=
16842 !! html
16843 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
16844 <ul>
16845 <li class="toclevel-1 tocsection-1"><a href="#foo.3D"><span class="tocnumber">1</span> <span class="toctext">foo=</span></a></li>
16846 <li class="toclevel-1 tocsection-2"><a href="#.3Dfoo"><span class="tocnumber">2</span> <span class="toctext">=foo</span></a></li>
16847 <li class="toclevel-1 tocsection-3"><a href="#italic_heading.3D"><span class="tocnumber">3</span> <span class="toctext"><i>italic</i> heading=</span></a></li>
16848 <li class="toclevel-1 tocsection-4"><a href="#.3Ditalic_heading"><span class="tocnumber">4</span> <span class="toctext">=<i>italic</i> heading</span></a></li>
16849 </ul>
16850 </div>
16851
16852 <h1><span class="mw-headline" id="foo.3D">foo=</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: foo=">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
16853 <h1><span class="mw-headline" id=".3Dfoo">=foo</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: =foo">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
16854 <h1><span class="mw-headline" id="italic_heading.3D"><i>italic</i> heading=</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=3" title="Edit section: italic heading=">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
16855 <h1><span class="mw-headline" id=".3Ditalic_heading">=<i>italic</i> heading</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=4" title="Edit section: =italic heading">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
16856
16857 !! end
16858
16859 !! test
16860 HTML headers vs TOC (T25393)
16861 (__NOEDITSECTION__ for clearer output, doesn't matter here)
16862 !! wikitext
16863 <h1>Header 1</h1>
16864 == Header 1.1 ==
16865 == Header 1.2 ==
16866
16867 <h1>Header 2
16868 </h1>
16869 == Header 2.1 ==
16870 == Header 2.2 ==
16871 __NOEDITSECTION__
16872 !! html
16873 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
16874 <ul>
16875 <li class="toclevel-1"><a href="#Header_1"><span class="tocnumber">1</span> <span class="toctext">Header 1</span></a>
16876 <ul>
16877 <li class="toclevel-2 tocsection-1"><a href="#Header_1.1"><span class="tocnumber">1.1</span> <span class="toctext">Header 1.1</span></a></li>
16878 <li class="toclevel-2 tocsection-2"><a href="#Header_1.2"><span class="tocnumber">1.2</span> <span class="toctext">Header 1.2</span></a></li>
16879 </ul>
16880 </li>
16881 <li class="toclevel-1"><a href="#Header_2"><span class="tocnumber">2</span> <span class="toctext">Header 2</span></a>
16882 <ul>
16883 <li class="toclevel-2 tocsection-3"><a href="#Header_2.1"><span class="tocnumber">2.1</span> <span class="toctext">Header 2.1</span></a></li>
16884 <li class="toclevel-2 tocsection-4"><a href="#Header_2.2"><span class="tocnumber">2.2</span> <span class="toctext">Header 2.2</span></a></li>
16885 </ul>
16886 </li>
16887 </ul>
16888 </div>
16889
16890 <h1><span class="mw-headline" id="Header_1">Header 1</span></h1>
16891 <h2><span class="mw-headline" id="Header_1.1">Header 1.1</span></h2>
16892 <h2><span class="mw-headline" id="Header_1.2">Header 1.2</span></h2>
16893 <h1><span class="mw-headline" id="Header_2">Header 2</span></h1>
16894 <h2><span class="mw-headline" id="Header_2.1">Header 2.1</span></h2>
16895 <h2><span class="mw-headline" id="Header_2.2">Header 2.2</span></h2>
16896
16897 !! end
16898
16899 !! test
16900 Single-line or multiline-comments can follow headings
16901 !! options
16902 parsoid=wt2html,wt2wt
16903 !! wikitext
16904 ==foo==<!---->
16905 ==bar==<!--c1-->
16906 ==baz==<!--
16907 c2
16908 c3-->
16909 !! html
16910 <h2><span class="mw-headline" id="foo">foo</span></h2>
16911 <h2><span class="mw-headline" id="bar">bar</span></h2>
16912 <h2><span class="mw-headline" id="baz">baz</span></h2>
16913
16914 !! end
16915
16916 !! test
16917 T3219 URL next to image (broken)
16918 !! wikitext
16919 http://example.com[[File:Foobar.jpg]]
16920 !! html/php
16921 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
16922 </p>
16923 !! html/parsoid
16924 <p><a rel="mw:ExtLink" href="http://example.com">http://example.com</a><span class="mw-default-size" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></span></p>
16925 !!end
16926
16927 !! test
16928 T3186 news: in the middle of text
16929 !! wikitext
16930 http://en.wikinews.org/wiki/Wikinews:Workplace
16931 !! html
16932 <p><a rel="nofollow" class="external free" href="http://en.wikinews.org/wiki/Wikinews:Workplace">http://en.wikinews.org/wiki/Wikinews:Workplace</a>
16933 </p>
16934 !!end
16935
16936
16937 !! test
16938 Namespaced link must have a title
16939 !! wikitext
16940 [[Project:]]
16941 !! html
16942 <p>[[Project:]]
16943 </p>
16944 !!end
16945
16946 !! test
16947 Namespaced link must have a title (bad fragment version)
16948 !! wikitext
16949 [[Project:#fragment]]
16950 !! html
16951 <p>[[Project:#fragment]]
16952 </p>
16953 !!end
16954
16955
16956 ###
16957 ### HTML tags and HTML attributes
16958 ###
16959
16960 !! test
16961 div with no attributes
16962 !! wikitext
16963 <div>HTML rocks</div>
16964 !! html
16965 <div>HTML rocks</div>
16966
16967 !! end
16968
16969 !! test
16970 div with double-quoted attribute
16971 !! wikitext
16972 <div id="rock">HTML rocks</div>
16973 !! html
16974 <div id="rock">HTML rocks</div>
16975
16976 !! end
16977
16978 !! test
16979 div with single-quoted attribute
16980 !! wikitext
16981 <div id='rock'>HTML rocks</div>
16982 !! html
16983 <div id="rock">HTML rocks</div>
16984
16985 !! end
16986
16987 !! test
16988 div with unquoted attribute
16989 !! wikitext
16990 <div id=rock>HTML rocks</div>
16991 !! html
16992 <div id="rock">HTML rocks</div>
16993
16994 !! end
16995
16996 !! test
16997 div with illegal double attributes
16998 !! wikitext
16999 <div id="a" id="b">HTML rocks</div>
17000 !! html
17001 <div id="b">HTML rocks</div>
17002
17003 !!end
17004
17005 !! test
17006 div with empty attribute value, space before equals
17007 !! options
17008 parsoid=wt2html,html2html
17009 !! wikitext
17010 <div class =>HTML rocks</div>
17011 !! html/php
17012 <div class="">HTML rocks</div>
17013
17014 !! html/parsoid
17015 <div class="" data-parsoid='{"stx":"html"}'>HTML rocks</div>
17016 !! end
17017
17018 !! test
17019 div with multiple empty attribute values
17020 !! options
17021 parsoid=wt2html,html2html
17022 !! wikitext
17023 <div id= title=>HTML rocks</div>
17024 !! html/php
17025 <div id="title.3D">HTML rocks</div>
17026
17027 !! html/parsoid
17028 <div id="title.3D" data-parsoid='{"stx":"html"}'>HTML rocks</div>
17029 !! end
17030
17031 !! test
17032 table with multiple empty attribute values
17033 !! options
17034 parsoid=wt2html,html2html
17035 !! wikitext
17036 {| title= id=
17037 | hi
17038 |}
17039 !! html/php
17040 <table title="id=">
17041 <tr>
17042 <td> hi
17043 </td></tr></table>
17044
17045 !! html/parsoid
17046 <table title="id=">
17047 <tbody><tr><td> hi</td></tr>
17048 </tbody></table>
17049 !! end
17050
17051 !! test
17052 div with braces in attribute value
17053 !! wikitext
17054 <div title="{}">Foo</div>
17055 !! html/php
17056 <div title="&#123;&#125;">Foo</div>
17057
17058 !! html/parsoid
17059 <div title="{}">Foo</div>
17060 !! end
17061
17062 !! test
17063 div with empty attribute value, no space before equals
17064 !! options
17065 parsoid=wt2html,html2html
17066 !! wikitext
17067 <div class=>HTML rocks</div>
17068 !! html/php
17069 <div class="">HTML rocks</div>
17070
17071 !! html/parsoid
17072 <div class="">HTML rocks</div>
17073 !! end
17074
17075 !! test
17076 HTML multiple attributes correction
17077 !! wikitext
17078 <p class="error" class="awesome">Awesome!</p>
17079 !! html
17080 <p class="awesome">Awesome!</p>
17081
17082 !!end
17083
17084 !! test
17085 Table multiple attributes correction
17086 !! wikitext
17087 {|
17088 !+ class="error" class="awesome"| status
17089 |}
17090 !! html
17091 <table>
17092 <tr>
17093 <th class="awesome"> status
17094 </th></tr></table>
17095
17096 !!end
17097
17098 !! test
17099 DIV IN UPPERCASE
17100 !! wikitext
17101 <DIV ID="x">HTML ROCKS</DIV>
17102 !! html
17103 <div id="x">HTML ROCKS</div>
17104
17105 !!end
17106
17107 !! test
17108 Non-ASCII pseudo-tags are rendered as text
17109 !! wikitext
17110 <khyô>
17111 !! html
17112 <p>&lt;khyô&gt;
17113 </p>
17114 !! end
17115
17116 !! test
17117 Pseudo-tag with URL 'name' renders as url link
17118 !! wikitext
17119 <http://example.com/>
17120 !! html
17121 <p>&lt;<a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a>&gt;
17122 </p>
17123 !! end
17124
17125 !! test
17126 text with amp in the middle of nowhere
17127 !! wikitext
17128 Remember AT&T?
17129 !! html
17130 <p>Remember AT&amp;T?
17131 </p>
17132 !! end
17133
17134 !! test
17135 text with character entity: eacute
17136 !! wikitext
17137 I always thought &eacute; was a cute letter.
17138 !! html
17139 <p>I always thought &#233; was a cute letter.
17140 </p>
17141 !! html+tidy
17142 <p>I always thought é was a cute letter.</p>
17143 !! end
17144
17145 !! test
17146 text with entity-escaped character entity-like string: eacute
17147 !! wikitext
17148 I always thought &amp;eacute; was a cute letter.
17149 !! html
17150 <p>I always thought &amp;eacute; was a cute letter.
17151 </p>
17152 !! end
17153
17154 !! test
17155 text with undefined character entity: xacute
17156 !! wikitext
17157 I always thought &xacute; was a cute letter.
17158 !! html
17159 <p>I always thought &amp;xacute; was a cute letter.
17160 </p>
17161 !! end
17162
17163 !! test
17164 HTML5 tags
17165 !! wikitext
17166 <data value="5">five</data>
17167 <time datetime="2000-01-01T00:00Z">The new millenium started</time>
17168 <mark>This highlighted text</mark>
17169 !! html
17170 <p><data value="5">five</data>
17171 <time datetime="2000-01-01T00:00Z">The new millenium started</time>
17172 <mark>This highlighted text</mark>
17173 </p>
17174 !! end
17175
17176 !! test
17177 HTML tag with leading space is parsed as text
17178 !! wikitext
17179 < div>foo< /div>
17180 !! html
17181 <p>&lt; div&gt;foo&lt; /div&gt;
17182 </p>
17183 !! end
17184
17185 ## Don't expect Parsoid and PHP to match, since PHP isn't exactly following
17186 ## the HTML5 parsing spec.
17187 !! test
17188 Element with broken attribute syntax
17189 !! options
17190 parsoid=wt2html
17191 !! wikitext
17192 <div style=" style="123">hi</div>
17193 <div =>ho</div>
17194 !! html/php
17195 <div style="123">hi</div>
17196 <div>ho</div>
17197
17198 !! html/parsoid
17199 <div style=" style=" data-parsoid='{"stx":"html","a":{"123\"":null},"sa":{"123\"":""}}'>hi</div>
17200 <div data-parsoid='{"stx":"html","a":{"=":null},"sa":{"=":""}}'>ho</div>
17201 !! end
17202
17203 ###
17204 ### Nesting tests (see T43545, T52604, T53081)
17205 ###
17206
17207 # This test case is fixed in Parsoid by domino 1.0.12. (T52604)
17208 # Note that html2wt is considerably more difficult if we use <b> in
17209 # the test case, instead of <small>
17210 !! test
17211 Ensure that HTML adoption agency algorithm is properly implemented.
17212 !! wikitext
17213 <small>X<small>Y</small>Z</small>
17214 !! html
17215 <p><small>X<small>Y</small>Z</small>
17216 </p>
17217 !! end
17218
17219 # This was T43545 in the PHP parser.
17220 # Note that tidy doesn't handle this correctly.
17221 !! test
17222 Nesting of <kbd>
17223 !! wikitext
17224 <kbd>X<kbd>Y</kbd>Z</kbd>
17225 !! html
17226 <p><kbd>X<kbd>Y</kbd>Z</kbd>
17227 </p>
17228 !! end
17229
17230 # The following cases were T53081 in the PHP parser.
17231 # Note that there are some other nestable tags (b, i, etc) which are
17232 # not covered; see T53081 for discussion.
17233
17234 # Note that tidy doesn't handle this correctly.
17235 !! test
17236 Nesting of <em>
17237 !! wikitext
17238 <em>X<em>Y</em>Z</em>
17239 !! html
17240 <p><em>X<em>Y</em>Z</em>
17241 </p>
17242 !! end
17243
17244 # Note that tidy doesn't handle this correctly.
17245 !! test
17246 Nesting of <strong>
17247 !! wikitext
17248 <strong>X<strong>Y</strong>Z</strong>
17249 !! html
17250 <p><strong>X<strong>Y</strong>Z</strong>
17251 </p>
17252 !! end
17253
17254 !! test
17255 Nesting of <q>
17256 !! wikitext
17257 <q>X<q>Y</q>Z</q>
17258 !! html+tidy
17259 <p><q>X<q>Y</q>Z</q></p>
17260 !! end
17261
17262 # Note that tidy doesn't handle this correctly.
17263 !! test
17264 Nesting of <ruby>
17265 !! wikitext
17266 <ruby>X<ruby>Y</ruby>Z</ruby>
17267 !! html
17268 <p><ruby>X<ruby>Y</ruby>Z</ruby>
17269 </p>
17270 !! end
17271
17272 # Note that tidy doesn't handle this correctly.
17273 !! test
17274 Nesting of <bdo>
17275 !! wikitext
17276 <bdo>X<bdo>Y</bdo>Z</bdo>
17277 !! html
17278 <p><bdo>X<bdo>Y</bdo>Z</bdo>
17279 </p>
17280 !! end
17281
17282
17283 ###
17284 ### Media links
17285 ###
17286
17287 !! test
17288 Media link
17289 !! wikitext
17290 [[Media:Foobar.jpg]]
17291 [[Media:Video.ogv]]
17292 [[:Media:Video.ogv]]
17293 !! html/php
17294 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Media:Foobar.jpg</a>
17295 <a href="http://example.com/images/0/00/Video.ogv" class="internal" title="Video.ogv">Media:Video.ogv</a>
17296 <a href="http://example.com/images/0/00/Video.ogv" class="internal" title="Video.ogv">Media:Video.ogv</a>
17297 </p>
17298 !! html/parsoid
17299 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg">Media:Foobar.jpg</a>
17300 <a rel="mw:MediaLink" href="//example.com/images/0/00/Video.ogv" title="Video.ogv">Media:Video.ogv</a>
17301 <a rel="mw:MediaLink" href="//example.com/images/0/00/Video.ogv" title="Video.ogv" data-parsoid='{"a":{"namespace":"Media"},"sa":{"namespace":":Media"}}'>Media:Video.ogv</a></p>
17302 !! end
17303
17304 !! test
17305 Media link with text
17306 !! wikitext
17307 [[Media:Foobar.jpg|A neat file to look at]]
17308 !! html/php
17309 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">A neat file to look at</a>
17310 </p>
17311 !! html/parsoid
17312 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg">A neat file to look at</a></p>
17313 !! end
17314
17315 # FIXME: this is still bad HTML tag nesting
17316 # FIXME: doBlockLevels won't wrap this in a paragraph because it contains a div
17317 !! test
17318 Media link with nasty text
17319 !! wikitext
17320 [[Media:Foobar.jpg|Safe Link<div style=display:none>" onmouseover="alert(document.cookie)" onfoo="</div>]]
17321 !! html/php
17322 <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>
17323
17324 !! html+php/tidy
17325 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Safe Link</a></p>
17326 <div style="display:none">" onmouseover="alert(document.cookie)" onfoo="</div>
17327 !! html/parsoid
17328 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg" data-parsoid='{"autoInsertedEnd":true}'>Safe Link</a></p><div style="display:none" data-parsoid='{"stx":"html"}'><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg" data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'>" onmouseover="alert(document.cookie)" onfoo="</a></div>
17329
17330 !! end
17331
17332 !! test
17333 Media link to nonexistent file (T3702)
17334 !! wikitext
17335 [[Media:No such.jpg]]
17336 [[Media:No_such file.jpg]]
17337 !! html/php
17338 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=No_such.jpg" class="new" title="No such.jpg">Media:No such.jpg</a>
17339 <a href="/index.php?title=Special:Upload&amp;wpDestFile=No_such_file.jpg" class="new" title="No such file.jpg">Media:No_such file.jpg</a>
17340 </p>
17341 !! html/parsoid
17342 <p><a rel="mw:MediaLink" href="./Special:FilePath/No_such.jpg" title="No such.jpg" typeof="mw:Error" data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}]}' data-parsoid='{"a":{"fileName":"No_such.jpg"},"sa":{"fileName":"No such.jpg"}}'>Media:No such.jpg</a>
17343 <a rel="mw:MediaLink" href="./Special:FilePath/No_such_file.jpg" title="No such file.jpg" typeof="mw:Error" data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}]}' data-parsoid='{"a":{"fileName":"No_such_file.jpg"},"sa":{"fileName":"No_such file.jpg"}}'>Media:No_such file.jpg</a></p>
17344 !! end
17345
17346 !! test
17347 Image link to nonexistent file (T3850 - good)
17348 !! wikitext
17349 [[File:No_such.jpg]]
17350 !! html/php
17351 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=No_such.jpg" class="new" title="File:No such.jpg">File:No such.jpg</a>
17352 </p>
17353 !! html/parsoid
17354 <p><span class="mw-default-size" typeof="mw:Error mw:Image" data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}]}'><a href="./File:No_such.jpg"><img resource="./File:No_such.jpg" src="./Special:FilePath/No_such.jpg" height="220" width="220"/></a></span></p>
17355 !! end
17356
17357 !! test
17358 :Image link to nonexistent file (T3850 - bad)
17359 !! wikitext
17360 [[:Image:No such.jpg]]
17361 !! html/php
17362 <p><a href="/index.php?title=File:No_such.jpg&amp;action=edit&amp;redlink=1" class="new" title="File:No such.jpg (page does not exist)">Image:No such.jpg</a>
17363 </p>
17364 !! html/parsoid
17365 <p><a rel="mw:WikiLink" href="./File:No_such.jpg" title="File:No such.jpg">Image:No such.jpg</a></p>
17366 !! end
17367
17368 !! test
17369 Character reference normalization in link text (T3938)
17370 !! wikitext
17371 [[Main Page|this&that]]
17372 !! html
17373 <p><a href="/wiki/Main_Page" title="Main Page">this&amp;that</a>
17374 </p>
17375 !!end
17376
17377 !! article
17378 אַ
17379 !! text
17380 Test for unicode normalization
17381
17382 The page's name is U+05d0 U+05b7, with non-canonical form U+FB2E
17383 !! endarticle
17384
17385 !! test
17386 (T21451) Links should refer to the normalized form.
17387 !! wikitext
17388 [[&#xFB2E;]]
17389 [[&#x5d0;&#x5b7;]]
17390 [[&#x5d0;ַ]]
17391 [[א&#x5b7;]]
17392 [[אַ]]
17393 !! html
17394 <p><a href="/wiki/%D7%90%D6%B7" title="אַ">&#xfb2e;</a>
17395 <a href="/wiki/%D7%90%D6%B7" title="אַ">&#x5d0;&#x5b7;</a>
17396 <a href="/wiki/%D7%90%D6%B7" title="אַ">&#x5d0;ַ</a>
17397 <a href="/wiki/%D7%90%D6%B7" title="אַ">א&#x5b7;</a>
17398 <a href="/wiki/%D7%90%D6%B7" title="אַ">אַ</a>
17399 </p>
17400 !! end
17401
17402 !! test
17403 Empty attribute crash test (T4067)
17404 !! wikitext
17405 <font color="">foo</font>
17406 !! html
17407 <p><font color="">foo</font>
17408 </p>
17409 !! end
17410
17411 !! test
17412 Empty attribute crash test single-quotes (T4067)
17413 !! wikitext
17414 <font color=''>foo</font>
17415 !! html
17416 <p><font color="">foo</font>
17417 </p>
17418 !! end
17419
17420 !! test
17421 Attribute test: equals, then nothing
17422 !! options
17423 parsoid=wt2html,html2html
17424 !! wikitext
17425 <font color=>foo</font>
17426 !! html/php
17427 <p><font color="">foo</font>
17428 </p>
17429 !! html/parsoid
17430 <p><font color="" data-parsoid='{"stx":"html"}'>foo</font></p>
17431 !! end
17432
17433 !! test
17434 Attribute test: unquoted value
17435 !! options
17436 parsoid=wt2html,html2html
17437 !! wikitext
17438 <font color=x>foo</font>
17439 !! html/php
17440 <p><font color="x">foo</font>
17441 </p>
17442 !! html/parsoid
17443 <p><font color="x" data-parsoid='{"stx":"html"}'>foo</font></p>
17444 !! end
17445
17446 !! test
17447 Attribute test: unquoted but illegal value (hash)
17448 !! wikitext
17449 <font color=#x>foo</font>
17450 !! html
17451 <p><font color="#x">foo</font>
17452 </p>
17453 !! end
17454
17455 # Parsoid does not serialize to empty attribute syntax,
17456 # so wt2wt and html2wt cases are skipped
17457 !! test
17458 Attribute test: no value (T54330)
17459 !! options
17460 parsoid=wt2html,html2html
17461 !! wikitext
17462 <font color>foo</font>
17463 !! html/php
17464 <p><font color="">foo</font>
17465 </p>
17466 !! html/parsoid
17467 <p><font color="">foo</font></p>
17468 !! end
17469
17470 !! test
17471 T4095: link with three closing brackets
17472 !! wikitext
17473 [[Main Page]]]
17474 !! html/php
17475 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>]
17476 </p>
17477 !! html/parsoid
17478 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a>]</p>
17479 !! end
17480
17481 !! test
17482 T4095: link with pipe and three closing brackets
17483 !! wikitext
17484 [[Main Page|link]]]
17485 !! html/php
17486 <p><a href="/wiki/Main_Page" title="Main Page">link</a>]
17487 </p>
17488 !! html/parsoid
17489 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">link</a>]</p>
17490 !! end
17491
17492 !! test
17493 T4095: link with pipe and three closing brackets, version 2
17494 !! wikitext
17495 [[Main Page|[http://example.com/]]]
17496 !! html/php
17497 <p><a href="/wiki/Main_Page" title="Main Page">[http://example.com/]</a>
17498 </p>
17499 !! html/parsoid
17500 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">[http://example.com/]</a></p>
17501 !! end
17502
17503
17504 ###
17505 ### Safety
17506 ###
17507
17508 !! article
17509 Template:Dangerous attribute
17510 !! text
17511 " onmouseover="alert(document.cookie)
17512 !! endarticle
17513
17514 !! article
17515 Template:Dangerous style attribute
17516 !! text
17517 border-size: expression(alert(document.cookie))
17518 !! endarticle
17519
17520 !! article
17521 Template:Div style
17522 !! text
17523 <div style="float: right; {{{1}}}">Magic div</div>
17524 !! endarticle
17525
17526 !! test
17527 T4304: HTML attribute safety (safe template; regression T4309)
17528 !! wikitext
17529 <div title="{{test}}"></div>
17530 !! html/php
17531 <div title="This is a test template"></div>
17532
17533 !! html/parsoid
17534 <div title="This is a test template" about="#mwt2" typeof="mw:ExpandedAttrs" data-parsoid='{"stx":"html","a":{"title":"This is a test template"},"sa":{"title":"{{test}}"}}' data-mw='{"attribs":[[{"txt":"title"},{"html":"&lt;span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid=&#39;{\"pi\":[[]],\"dsr\":[12,20,null,null]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"test\",\"href\":\"./Template:Test\"},\"params\":{},\"i\":0}}]}&#39;>This is a test template&lt;/span>"}]]}'></div>
17535 !! end
17536
17537 # Parsoid has enough context to handle this case
17538 !! test
17539 T4304: HTML attribute safety (dangerous template; 2309)
17540 !! wikitext
17541 <div title="{{dangerous attribute}}"></div>
17542 !! html/php
17543 <div title=""></div>
17544
17545 !! html/parsoid
17546 <div title='" onmouseover="alert(document.cookie)' about="#mwt2" typeof="mw:ExpandedAttrs" data-parsoid='{"stx":"html","a":{"title":"\" onmouseover=\"alert(document.cookie)"},"sa":{"title":"{{dangerous attribute}}"}}' data-mw='{"attribs":[[{"txt":"title"},{"html":"&lt;span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid=&#39;{\"pi\":[[]],\"dsr\":[12,35,null,null]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"dangerous attribute\",\"href\":\"./Template:Dangerous_attribute\"},\"params\":{},\"i\":0}}]}&#39;>\" onmouseover=\"alert(document.cookie)&lt;/span>"}]]}'></div>
17547 !! end
17548
17549 !! test
17550 T4304: HTML attribute safety (dangerous style template; 2309)
17551 !! wikitext
17552 <div style="{{dangerous style attribute}}"></div>
17553 !! html/php
17554 <div style="/* insecure input */"></div>
17555
17556 !! html/parsoid
17557 <div style="/* insecure input */" about="#mwt2" typeof="mw:ExpandedAttrs" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"{{dangerous style attribute}}"}}' data-mw='{"attribs":[[{"txt":"style"},{"html":"&lt;span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid=&#39;{\"pi\":[[]],\"dsr\":[12,41,null,null]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"dangerous style attribute\",\"href\":\"./Template:Dangerous_style_attribute\"},\"params\":{},\"i\":0}}]}&#39;>border-size: expression(alert(document.cookie))&lt;/span>"}]]}'></div>
17558 !! end
17559
17560 !! test
17561 T4304: HTML attribute safety (safe parameter; 2309)
17562 !! wikitext
17563 {{div style|width: 200px}}
17564 !! html/php
17565 <div style="float: right; width: 200px">Magic div</div>
17566
17567 !! html/parsoid
17568 <div style="float: right; width: 200px" about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"stx":"html","a":{"style":"float: right; width: 200px"},"sa":{"style":"float: right; {{{1}}}"},"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"div style","href":"./Template:Div_style"},"params":{"1":{"wt":"width: 200px"}},"i":0}}]}'>Magic div</div>
17569 !! end
17570
17571 !! test
17572 T4304: HTML attribute safety (unsafe parameter; 2309)
17573 !! wikitext
17574 {{div style|width: expression(alert(document.cookie))}}
17575 !! html/php
17576 <div style="/* insecure input */">Magic div</div>
17577
17578 !! html/parsoid
17579 <div style="/* insecure input */" about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"float: right; {{{1}}}"},"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"div style","href":"./Template:Div_style"},"params":{"1":{"wt":"width: expression(alert(document.cookie))"}},"i":0}}]}'>Magic div</div>
17580 !! end
17581
17582 ## Parsoid output here differs; needs investigation.
17583 !! test
17584 T4304: HTML attribute safety (unsafe breakout parameter; 2309)
17585 !! wikitext
17586 {{div style|"><script>alert(document.cookie)</script>}}
17587 !! html
17588 <div style="float: right;">&lt;script&gt;alert(document.cookie)&lt;/script&gt;"&gt;Magic div</div>
17589
17590 !! end
17591
17592 ## Parsoid output here differs; needs investigation.
17593 !! test
17594 T4304: HTML attribute safety (unsafe breakout parameter 2; 2309)
17595 !! wikitext
17596 {{div style|" ><script>alert(document.cookie)</script>}}
17597 !! html
17598 <div style="float: right;">&lt;script&gt;alert(document.cookie)&lt;/script&gt;"&gt;Magic div</div>
17599
17600 !! end
17601
17602 !! test
17603 T4304: HTML attribute safety (link)
17604 !! wikitext
17605 <div title="[[Main Page]]"></div>
17606 !! html
17607 <div title="&#91;&#91;Main Page]]"></div>
17608
17609 !! end
17610
17611 !! test
17612 T4304: HTML attribute safety (italics)
17613 !! wikitext
17614 <div title="''foobar''"></div>
17615 !! html
17616 <div title="&#39;&#39;foobar&#39;&#39;"></div>
17617
17618 !! end
17619
17620 !! test
17621 T4304: HTML attribute safety (bold)
17622 !! wikitext
17623 <div title="'''foobar'''"></div>
17624 !! html
17625 <div title="&#39;&#39;&#39;foobar&#39;&#39;&#39;"></div>
17626
17627 !! end
17628
17629 !! test
17630 T4304: HTML attribute safety (ISBN)
17631 !! wikitext
17632 <div title="ISBN 1234567890"></div>
17633 !! html
17634 <div title="&#73;SBN 1234567890"></div>
17635
17636 !! end
17637
17638 !! test
17639 T4304: HTML attribute safety (RFC)
17640 !! wikitext
17641 <div title="RFC 1234"></div>
17642 !! html
17643 <div title="&#82;FC 1234"></div>
17644
17645 !! end
17646
17647 !! test
17648 T4304: HTML attribute safety (PMID)
17649 !! wikitext
17650 <div title="PMID 1234567890"></div>
17651 !! html
17652 <div title="&#80;MID 1234567890"></div>
17653
17654 !! end
17655
17656 !! test
17657 T4304: HTML attribute safety (web link)
17658 !! wikitext
17659 <div title="http://example.com/"></div>
17660 !! html
17661 <div title="http&#58;//example.com/"></div>
17662
17663 !! end
17664
17665 !! test
17666 T4304: HTML attribute safety (named web link)
17667 !! wikitext
17668 <div title="[http://example.com/ link]"></div>
17669 !! html
17670 <div title="&#91;http&#58;//example.com/ link]"></div>
17671
17672 !! end
17673
17674 !! test
17675 T5244: HTML attribute safety (extension; safe)
17676 !! wikitext
17677 <div style="<nowiki>background:blue</nowiki>"></div>
17678 !! html/php
17679 <div style="background:blue"></div>
17680
17681 !! html/parsoid
17682 <div style="background:blue" data-parsoid='{"stx":"html","a":{"style":"background:blue"},"sa":{"style":"&lt;nowiki>background:blue&lt;/nowiki>"}}'></div>
17683 !! end
17684
17685 !! test
17686 T5244: HTML attribute safety (extension; unsafe)
17687 !! wikitext
17688 <div style="<nowiki>border-left:expression(alert(document.cookie))</nowiki>"></div>
17689 !! html/php
17690 <div style="/* insecure input */"></div>
17691
17692 !! html/parsoid
17693 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"&lt;nowiki>border-left:expression(alert(document.cookie))&lt;/nowiki>"}}'></div>
17694 !! end
17695
17696 # More MSIE fun discovered by Tom Gilder
17697
17698 !! test
17699 MSIE CSS safety test: spurious slash
17700 !! wikitext
17701 <div style="background-image:u\rl(javascript:alert('boo'))">evil</div>
17702 !! html/php
17703 <div style="/* insecure input */">evil</div>
17704
17705 !! html/parsoid
17706 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:u\\rl(javascript:alert(&#39;boo&#39;))"}}'>evil</div>
17707 !! end
17708
17709 !! test
17710 MSIE CSS safety test: hex code
17711 !! wikitext
17712 <div style="background-image:u\72l(javascript:alert('boo'))">evil</div>
17713 !! html/php
17714 <div style="/* insecure input */">evil</div>
17715
17716 !! html/parsoid
17717 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:u\\72l(javascript:alert(&#39;boo&#39;))"}}'>evil</div>
17718 !! end
17719
17720 !! test
17721 MSIE CSS safety test: comment in url
17722 !! wikitext
17723 <div style="background-image:u/**/rl(javascript:alert('boo'))">evil</div>
17724 !! html/php
17725 <div style="background-image:u rl(javascript:alert(&#39;boo&#39;))">evil</div>
17726
17727 !! html/parsoid
17728 <div style="background-image:u rl(javascript:alert('boo'))" data-parsoid='{"stx":"html","a":{"style":"background-image:u rl(javascript:alert(&#39;boo&#39;))"},"sa":{"style":"background-image:u/**/rl(javascript:alert(&#39;boo&#39;))"}}'>evil</div>
17729 !! end
17730
17731 !! test
17732 MSIE CSS safety test: comment in expression
17733 !! wikitext
17734 <div style="background-image:expres/**/sion(alert('boo4'))">evil4</div>
17735 !! html/php
17736 <div style="background-image:expres sion(alert(&#39;boo4&#39;))">evil4</div>
17737
17738 !! html/parsoid
17739 <div style="background-image:expres sion(alert('boo4'))" data-parsoid='{"stx":"html","a":{"style":"background-image:expres sion(alert(&#39;boo4&#39;))"},"sa":{"style":"background-image:expres/**/sion(alert(&#39;boo4&#39;))"}}'>evil4</div>
17740 !! end
17741
17742 !! test
17743 CSS safety test (all browsers): vertical tab (T57332 / CVE-2013-4567)
17744 !! wikitext
17745 <p style="font-size: 100px; background-image:url\b(https://www.google.com/images/srpr/logo6w.png)">A</p>
17746 !! html/php
17747 <p style="/* invalid control char */">A</p>
17748
17749 !! html/parsoid
17750 <p style="/* invalid control char */" data-parsoid='{"stx":"html","a":{"style":"/* invalid control char */"},"sa":{"style":"font-size: 100px; background-image:url\\b(https://www.google.com/images/srpr/logo6w.png)"}}'>A</p>
17751 !! end
17752
17753 !! test
17754 MSIE 6 CSS safety test: Fullwidth (T57332)
17755 !! wikitext
17756 <p style="font-size: 100px; color: expression((title='XSSed'),'red')">A</p>
17757 <div style="top:EXPRESSION(alert())">B</div>
17758 !! html/php
17759 <p style="/* insecure input */">A</p>
17760 <div style="/* insecure input */">B</div>
17761
17762 !! html/parsoid
17763 <p style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"font-size: 100px; color: expression((title=&#39;XSSed&#39;),&#39;red&#39;)"}}'>A</p>
17764 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"top:EXPRESSION(alert())"}}'>B</div>
17765 !! end
17766
17767 !! test
17768 MSIE 6 CSS safety test: IPA extensions (T57332)
17769 !! wikitext
17770 <div style="background-image:uʀʟ(javascript:alert())">A</div>
17771 <p style="font-size: 100px; color: expʀessɪoɴ((title='XSSed'),'red')">B</p>
17772 !! html/php
17773 <div style="/* insecure input */">A</div>
17774 <p style="/* insecure input */">B</p>
17775
17776 !! html/parsoid
17777 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:uʀʟ(javascript:alert())"}}'>A</div>
17778 <p style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"font-size: 100px; color: expʀessɪoɴ((title=&#39;XSSed&#39;),&#39;red&#39;)"}}'>B</p>
17779 !! end
17780
17781 !! test
17782 MSIE 6 CSS safety test: sup/sub script (T57332)
17783 !! wikitext
17784 <div style="background-image:url⁽javascript:alert())">A</div>
17785 <div style="background-image:url₍javascript:alert())">B</div>
17786 <p style="font-size: 100px; color: expressioⁿ((title='XSSed'),'red')">C</p>
17787 !! html/php
17788 <div style="/* insecure input */">A</div>
17789 <div style="/* insecure input */">B</div>
17790 <p style="/* insecure input */">C</p>
17791
17792 !! html/parsoid
17793 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:url⁽javascript:alert())"}}'>A</div>
17794 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:url₍javascript:alert())"}}'>B</div>
17795 <p style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"font-size: 100px; color: expressioⁿ((title=&#39;XSSed&#39;),&#39;red&#39;)"}}'>C</p>
17796 !! end
17797
17798 !! test
17799 Opera -o-link CSS
17800 !! options
17801 parsoid=wt2html,html2html
17802 !! wikitext
17803 <div
17804 title="&#100;&#97;&#116;&#97;&#58;&#116;&#101;&#120;&#116;&#47;&#104;&#116;&#109;&#108;&#44;&#60;&#105;&#109;&#103;&#32;&#115;&#114;&#99;&#61;&#49;&#32;&#111;&#110;&#101;&#114;&#114;&#111;&#114;&#61;&#97;&#108;&#101;&#114;&#116;&#40;&#49;&#41;&#62;"
17805 style="-o-link:attr(title);-o-link-source:current">X</div>
17806 !! html/php
17807 <div title="data:text/html,&lt;img src=1 onerror=alert(1)&gt;" style="/* insecure input */">X</div>
17808
17809 !! html/parsoid
17810 <div title="data:text/html,&lt;img src=1 onerror=alert(1)>" style="/* insecure input */" data-parsoid='{"stx":"html","a":{"title":"data:text/html,&lt;img src=1 onerror=alert(1)>","style":"/* insecure input */"},"sa":{"title":"&amp;#100;&amp;#97;&amp;#116;&amp;#97;&amp;#58;&amp;#116;&amp;#101;&amp;#120;&amp;#116;&amp;#47;&amp;#104;&amp;#116;&amp;#109;&amp;#108;&amp;#44;&amp;#60;&amp;#105;&amp;#109;&amp;#103;&amp;#32;&amp;#115;&amp;#114;&amp;#99;&amp;#61;&amp;#49;&amp;#32;&amp;#111;&amp;#110;&amp;#101;&amp;#114;&amp;#114;&amp;#111;&amp;#114;&amp;#61;&amp;#97;&amp;#108;&amp;#101;&amp;#114;&amp;#116;&amp;#40;&amp;#49;&amp;#41;&amp;#62;","style":"-o-link:attr(title);-o-link-source:current"}}'>X</div>
17811 !! end
17812
17813 !! test
17814 MSIE 6 CSS safety test: Repetition markers (T57332)
17815 !! wikitext
17816 <p style="font-size: 100px; color: expres〱ion((title='XSSed'),'red')">A</p>
17817 <p style="font-size: 100px; color: expresゝion((title='XSSed'),'red')">B</p>
17818 <p style="font-size: 100px; color: expresーion((title='XSSed'),'red')">C</p>
17819 <p style="font-size: 100px; color: expresヽion((title='XSSed'),'red')">D</p>
17820 <p style="font-size: 100px; color: expresﹽion((title='XSSed'),'red')">E</p>
17821 <p style="font-size: 100px; color: expresﹼion((title='XSSed'),'red')">F</p>
17822 <p style="font-size: 100px; color: expresーion((title='XSSed'),'red')">G</p>
17823 !! html/php
17824 <p style="/* insecure input */">A</p>
17825 <p style="/* insecure input */">B</p>
17826 <p style="/* insecure input */">C</p>
17827 <p style="/* insecure input */">D</p>
17828 <p style="/* insecure input */">E</p>
17829 <p style="/* insecure input */">F</p>
17830 <p style="/* insecure input */">G</p>
17831
17832 !! html/parsoid
17833 <p style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"font-size: 100px; color: expres〱ion((title=&#39;XSSed&#39;),&#39;red&#39;)"}}'>A</p>
17834 <p style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"font-size: 100px; color: expresゝion((title=&#39;XSSed&#39;),&#39;red&#39;)"}}'>B</p>
17835 <p style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"font-size: 100px; color: expresーion((title=&#39;XSSed&#39;),&#39;red&#39;)"}}'>C</p>
17836 <p style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"font-size: 100px; color: expresヽion((title=&#39;XSSed&#39;),&#39;red&#39;)"}}'>D</p>
17837 <p style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"font-size: 100px; color: expresﹽion((title=&#39;XSSed&#39;),&#39;red&#39;)"}}'>E</p>
17838 <p style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"font-size: 100px; color: expresﹼion((title=&#39;XSSed&#39;),&#39;red&#39;)"}}'>F</p>
17839 <p style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"font-size: 100px; color: expresーion((title=&#39;XSSed&#39;),&#39;red&#39;)"}}'>G</p>
17840 !! end
17841
17842 !! test
17843 Table attribute legitimate extension
17844 !! wikitext
17845 {|
17846 !+ style="<nowiki>color:blue</nowiki>"| status
17847 |}
17848 !! html
17849 <table>
17850 <tr>
17851 <th style="color:blue"> status
17852 </th></tr></table>
17853
17854 !!end
17855
17856 !! test
17857 Table attribute safety
17858 !! wikitext
17859 {|
17860 !+ style="<nowiki>border-width:expression(0+alert(document.cookie))</nowiki>"| status
17861 |}
17862 !! html
17863 <table>
17864 <tr>
17865 <th style="/* insecure input */"> status
17866 </th></tr></table>
17867
17868 !! end
17869
17870 !! test
17871 CSS line continuation 1
17872 !! wikitext
17873 <div style="background-image: u\&#10;rl(test.jpg);"></div>
17874 !! html
17875 <div style="/* insecure input */"></div>
17876
17877 !! end
17878
17879 !! test
17880 CSS line continuation 2
17881 !! wikitext
17882 <div style="background-image: u\&#13;rl(test.jpg); "></div>
17883 !! html
17884 <div style="/* invalid control char */"></div>
17885
17886 !! end
17887
17888 !! article
17889 Template:Identity
17890 !! text
17891 {{{1}}}
17892 !! endarticle
17893
17894 !! test
17895 Expansion of multi-line templates in attribute values (T8255)
17896 !! wikitext
17897 <div style="background: {{identity|#00FF00}}">-</div>
17898 !! html
17899 <div style="background: #00FF00">-</div>
17900
17901 !! end
17902
17903 !! test
17904 Expansion of multi-line templates in attribute values (T8255 sanity check)
17905 !! wikitext
17906 <div style="background:
17907 #00FF00">-</div>
17908 !! html/php
17909 <div style="background: #00FF00">-</div>
17910
17911 !! html/parsoid
17912 <div style="background:
17913 #00FF00">-</div>
17914 !! end
17915
17916 !! test
17917 Expansion of multi-line templates in attribute values (T8255 sanity check 2)
17918 !! wikitext
17919 <div style="background: &#10;#00FF00">-</div>
17920 !! html
17921 <div style="background: &#10;#00FF00">-</div>
17922
17923 !! end
17924
17925 !! test
17926 Tags which are hidden from Tidy cannot pass through the Sanitizer
17927 !! wikitext
17928 <mw:toc><script>alert();</script></mw:toc>
17929 !! html+tidy
17930 <p>&lt;mw:toc&gt;&lt;script&gt;alert();&lt;/script&gt;&lt;/mw:toc&gt;</p>
17931 !! end
17932
17933 ###
17934 ### Parser hooks (see tests/parser/parserTestsParserHook.php for the <tag> extension)
17935 ###
17936
17937 !! test
17938 Parser hook: empty input
17939 !! wikitext
17940 <tag></tag>
17941 !! html/php
17942 <pre>
17943 ''
17944 array (
17945 )
17946 </pre>
17947
17948 !! html/parsoid
17949 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
17950 !! end
17951
17952 ## Don't expect parsoid to rt this form.
17953 !! test
17954 Parser hook: empty input using terminated empty elements
17955 !! options
17956 parsoid=wt2html,html2html
17957 !! wikitext
17958 <tag/>
17959 !! html/php
17960 <pre>
17961 NULL
17962 array (
17963 )
17964 </pre>
17965
17966 !! html/parsoid
17967 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":null}' data-parsoid='{}' about="#mwt2"></pre>
17968 !! end
17969
17970 !! test
17971 Parser hook: empty input using terminated empty elements (space before)
17972 !! wikitext
17973 <tag />
17974 !! html/php
17975 <pre>
17976 NULL
17977 array (
17978 )
17979 </pre>
17980
17981 !! html/parsoid
17982 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":null}' data-parsoid='{}' about="#mwt2"></pre>
17983 !! end
17984
17985 !! test
17986 Parser hook: basic input
17987 !! wikitext
17988 <tag>input</tag>
17989 !! html/php
17990 <pre>
17991 'input'
17992 array (
17993 )
17994 </pre>
17995
17996 !! html/parsoid
17997 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
17998 !! end
17999
18000 ## Don't expect parsoid to rt this form.
18001 !! test
18002 Parser hook: case insensitive
18003 !! options
18004 parsoid=wt2html,html2html
18005 !! wikitext
18006 <TAG>input</TAG>
18007 !! html/php
18008 <pre>
18009 'input'
18010 array (
18011 )
18012 </pre>
18013
18014 !! html/parsoid
18015 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
18016 !! end
18017
18018 ## Don't expect parsoid to rt this form.
18019 !! test
18020 Parser hook: case insensitive, redux
18021 !! options
18022 parsoid=wt2html,html2html
18023 !! wikitext
18024 <TaG>input</TAg>
18025 !! html/php
18026 <pre>
18027 'input'
18028 array (
18029 )
18030 </pre>
18031
18032 !! html/parsoid
18033 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
18034 !! end
18035
18036 !! test
18037 Parser hook: nested tags
18038 !! wikitext
18039 <tag><tag></tag></tag>
18040 !! html/php
18041 <pre>
18042 '<tag>'
18043 array (
18044 )
18045 </pre>&lt;/tag&gt;
18046
18047 !! html/parsoid
18048 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"&lt;tag>"}}' data-parsoid='{}' about="#mwt2"></pre>&lt;/tag>
18049 !! end
18050
18051 !! test
18052 Parser hook: basic arguments
18053 !! wikitext
18054 <tag width="200" height="100" depth="50" square=""></tag>
18055 !! html/php
18056 <pre>
18057 ''
18058 array (
18059 'width' => '200',
18060 'height' => '100',
18061 'depth' => '50',
18062 'square' => '',
18063 )
18064 </pre>
18065
18066 !! html/parsoid
18067 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
18068 !! end
18069
18070 ## Don't expect parsoid to rt this form.
18071 !! test
18072 Parser hook: basic arguments, variations
18073 !! options
18074 parsoid=wt2html,html2html
18075 !! wikitext
18076 <tag width=200 height = "100" depth = '50' square></tag>
18077 !! html/php
18078 <pre>
18079 ''
18080 array (
18081 'width' => '200',
18082 'height' => '100',
18083 'depth' => '50',
18084 'square' => '',
18085 )
18086 </pre>
18087
18088 !! html/parsoid
18089 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
18090 !! end
18091
18092 !! test
18093 Parser hook: argument containing a forward slash (T7344)
18094 !! wikitext
18095 <tag filename="/tmp/bla"></tag>
18096 !! html/php
18097 <pre>
18098 ''
18099 array (
18100 'filename' => '/tmp/bla',
18101 )
18102 </pre>
18103
18104 !! html/parsoid
18105 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"filename":"/tmp/bla"},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
18106 !! end
18107
18108 ## Don't expect parsoid to rt this form.
18109 !! test
18110 Parser hook: empty input using terminated empty elements (T4374)
18111 !! options
18112 parsoid=wt2html,html2html
18113 !! wikitext
18114 <tag foo=bar/>text
18115 !! html/php
18116 <pre>
18117 NULL
18118 array (
18119 'foo' => 'bar',
18120 )
18121 </pre>text
18122
18123 !! html/parsoid
18124 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"foo":"bar"},"body":null}' data-parsoid='{}' about="#mwt2"></pre>text
18125 !! end
18126
18127 ## </tag> should be output literally since there is no matching tag that begins it
18128 ## Don't expect parsoid to rt this form.
18129 !! test
18130 Parser hook: basic arguments using terminated empty elements (T4374)
18131 !! options
18132 parsoid=wt2html
18133 !! wikitext
18134 <tag width=200 height = "100" depth = '50' square/>
18135 other stuff
18136 </tag>
18137 !! html/php
18138 <pre>
18139 NULL
18140 array (
18141 'width' => '200',
18142 'height' => '100',
18143 'depth' => '50',
18144 'square' => '',
18145 )
18146 </pre>
18147 <p>other stuff
18148 &lt;/tag&gt;
18149 </p>
18150 !! html/parsoid
18151 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""},"body":null}' about="#mwt2"></pre><p>other stuff
18152 &lt;/tag></p>
18153 !! end
18154
18155 ## Don't expect parsoid to rt this form.
18156 !! test
18157 Parser hook: Don't allow unclosed extension tags
18158 !! options
18159 parsoid=wt2html
18160 !! wikitext
18161 test <tag>123
18162
18163 this is a '''test'''
18164 !! html/php
18165 <p>test &lt;tag&gt;123
18166 </p><p>this is a <b>test</b>
18167 </p>
18168 !! html/parsoid
18169 <p>test &lt;tag>123</p>
18170
18171 <p>this is a <b>test</b></p>
18172 !! end
18173
18174 ###
18175 ### (see tests/parser/parserTestsParserHook.php for the <statictag> extension)
18176 ###
18177
18178 !! test
18179 Parser hook: static parser hook not inside a comment
18180 !! wikitext
18181 <statictag>hello, world</statictag>
18182
18183 <statictag action="flush" />
18184 !! html/php
18185 <p><br />
18186 hello, world
18187 </p>
18188 !! html/parsoid
18189 <p><span typeof="mw:Extension/statictag" data-mw='{"name":"statictag","attrs":{},"body":{"extsrc":"hello, world"}}' data-parsoid='{}' about="#mwt2"></span></p>
18190 <p typeof="mw:Extension/statictag" data-mw='{"name":"statictag","attrs":{"action":"flush"},"body":null}' data-parsoid='{}' about="#mwt4">hello, world</p>
18191 !! end
18192
18193 !! test
18194 Parser hook: static parser hook inside a comment
18195 !! wikitext
18196 <!-- <statictag>hello, world</statictag> -->
18197 <statictag action="flush" />
18198 !! html/php
18199 <p><br />
18200 </p>
18201 !! html/parsoid
18202 <!-- <statictag&#x3E;hello, world</statictag&#x3E; -->
18203 <p typeof="mw:Extension/statictag" data-mw='{"name":"statictag","attrs":{"action":"flush"},"body":null}' data-parsoid='{}' about="#mwt2"></p>
18204 !! end
18205
18206 # Nested template calls; this case was broken by Parser.php rev 1.506,
18207 # since reverted.
18208
18209 !! article
18210 Template:One-parameter
18211 !! text
18212 (My parameter is: {{{1}}})
18213 !! endarticle
18214
18215 !! article
18216 Template:Map-one-parameter
18217 !! text
18218 {{{{{1}}}|{{{2}}}}}
18219 !! endarticle
18220
18221 !! test
18222 Nested template calls
18223 !! wikitext
18224 {{Map-one-parameter|One-parameter|param}}
18225 !! html
18226 <p>(My parameter is: param)
18227 </p>
18228 !! end
18229
18230
18231 ###
18232 ### Sanitizer
18233 ###
18234
18235 # HTML+Tidy effectively strips out the empty tags completely
18236 # But since Parsoid doesn't it wraps the <s></s> tags in p-tags
18237 # which Tidy would have done for the PHP parser had there been content inside it.
18238 !! test
18239 Sanitizer: Closing of open tags
18240 !! wikitext
18241 <s></s><table></table>
18242 !! html
18243 <s></s><table></table>
18244
18245 !! html/parsoid
18246 <p><s></s></p><table></table>
18247 !! end
18248
18249 !! test
18250 Sanitizer: Closing of open but not closed tags
18251 !! wikitext
18252 <s>foo
18253 !! html
18254 <p><s>foo</s>
18255 </p>
18256 !! end
18257
18258 !! test
18259 Sanitizer: Closing of closed but not open tags
18260 !! options
18261 parsoid=wt2html
18262 !! wikitext
18263 </s>
18264 !! html/php+tidy
18265 !! html/parsoid
18266 !! end
18267
18268 !! test
18269 Sanitizer: Closing of closed but not open table tags
18270 !! options
18271 parsoid=wt2html
18272 !! wikitext
18273 Table not started</td></tr></table>
18274 !! html/php+tidy
18275 <p>Table not started</p>
18276 !! html/parsoid
18277 <p>Table not started</p>
18278 !! end
18279
18280 !! test
18281 Sanitizer: Escaping of spaces, multibyte characters, colons & other stuff in id=""
18282 !! wikitext
18283 <span id="æ: v">byte</span>[[#æ: v|backlink]]
18284 !! html/php
18285 <p><span id=".C3.A6:_v">byte</span><a href="#.C3.A6:_v">backlink</a>
18286 </p>
18287 !! html/parsoid
18288 <p><span id=".C3.A6:_v" data-parsoid='{"stx":"html","a":{"id":".C3.A6:_v"},"sa":{"id":"æ: v"}}'>byte</span><a rel="mw:WikiLink" href="./Main_Page#.C3.A6:_v" data-parsoid='{"stx":"piped","a":{"href":"./Main_Page#.C3.A6:_v"},"sa":{"href":"#æ: v"}}'>backlink</a></p>
18289 !! end
18290
18291 # In HTML5, the restrictions are that id must contain at least one character,
18292 # and must not contain any space characters.
18293 !! test
18294 Sanitizer: Validating the contents of the id attribute (T6515)
18295 !! options
18296 disabled
18297 !! wikitext
18298 <br id="" /><br id="a space" />
18299 !! html
18300 Something ...
18301 !! end
18302
18303 # In HTML5, id must be unique amongst all the ids in the element's home subtree.
18304 !! test
18305 Sanitizer: Validating id attribute uniqueness (T6515, T8301)
18306 !! options
18307 disabled
18308 !! wikitext
18309 <br id="foo" /><br id="foo" />
18310 !! html
18311 Something need to be done. foo-2 ?
18312 !! end
18313
18314 !! test
18315 Sanitizer: Validating that <meta> and <link> work, but only for Microdata
18316 !! wikitext
18317 <div itemscope>
18318 <meta itemprop="hello" content="world">
18319 <meta http-equiv="refresh" content="5">
18320 <meta itemprop="hello" http-equiv="refresh" content="5">
18321 <link itemprop="hello" href="{{SERVER}}">
18322 <link rel="stylesheet" href="{{SERVER}}">
18323 <link rel="stylesheet" itemprop="hello" href="{{SERVER}}">
18324 </div>
18325 !! html
18326 <div itemscope="">
18327 <p> <meta itemprop="hello" content="world" />
18328 &lt;meta http-equiv="refresh" content="5"&gt;
18329 <meta itemprop="hello" content="5" />
18330 <link itemprop="hello" href="http&#58;//example.org" />
18331 &lt;link rel="stylesheet" href="<a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>"&gt;
18332 <link itemprop="hello" href="http&#58;//example.org" />
18333 </p>
18334 </div>
18335
18336 !! end
18337
18338 !! test
18339 Sanitizer: Strip comments from CSS attributes
18340 !! options
18341 parsoid=wt2html,wt2wt
18342 !! wikitext
18343 <span style="margin:/*negate mbox-text padding */-0.125em -0.45em; /*rainbow*/rgba(255, 0, 0, 0.3)">2013</span>
18344 !! html/php
18345 <p><span style="margin: -0.125em -0.45em; rgba(255, 0, 0, 0.3)">2013</span>
18346 </p>
18347 !! html/parsoid
18348 <p><span style="margin: -0.125em -0.45em; rgba(255, 0, 0, 0.3)">2013</span></p>
18349 !! end
18350
18351 !! test
18352 Language converter: output gets cut off unexpectedly (T7757)
18353 !! options
18354 language=zh
18355 !! wikitext
18356 this bit is safe: }-
18357
18358 but if we add a conversion instance: -{zh-cn:xxx;zh-tw:yyy}-
18359
18360 then we get cut off here: }-
18361
18362 all additional text is vanished
18363 !! html/php
18364 <p>this bit is safe: }-
18365 </p><p>but if we add a conversion instance: xxx
18366 </p><p>then we get cut off here: }-
18367 </p><p>all additional text is vanished
18368 </p>
18369 !! html/parsoid
18370 <p>this bit is safe: }-</p>
18371 <p>but if we add a conversion instance: <span typeof="mw:LanguageVariant" data-parsoid='{"tSp":[6]}' data-mw-variant='{"twoway":[{"l":"zh-cn","t":"xxx"},{"l":"zh-tw","t":"yyy"}]}'></span></p>
18372 <p>then we get cut off here: }-</p>
18373 <p>all additional text is vanished</p>
18374 !! end
18375
18376 !! test
18377 Self closed html pairs (T7487)
18378 !! wikitext
18379 <center><font id="bug" />Centered text</center>
18380 <div><font id="bug2" />In div text</div>
18381 !! html+tidy
18382 <center><font id="bug"></font>Centered text</center>
18383 <div><font id="bug2"></font>In div text</div>
18384 !! end
18385
18386 #
18387 #
18388 #
18389
18390 !! test
18391 Punctuation: nbsp before exclamation
18392 !! wikitext
18393 C'est grave !
18394 !! html
18395 <p>C'est grave&#160;!
18396 </p>
18397 !! end
18398
18399 !! test
18400 Punctuation: CSS !important (T13874)
18401 !! wikitext
18402 <div style="width:50% !important">important</div>
18403 !! html
18404 <div style="width:50% !important">important</div>
18405
18406 !!end
18407
18408 !! test
18409 Punctuation: CSS ! important (T13874; with space after)
18410 !! wikitext
18411 <div style="width:50% ! important">important</div>
18412 !! html
18413 <div style="width:50% ! important">important</div>
18414
18415 !!end
18416
18417 !! test
18418 HTML bullet list, closed tags (T7497)
18419 !! wikitext
18420 <ul>
18421 <li>One</li>
18422 <li>Two</li>
18423 </ul>
18424 !! html/php
18425 <ul>
18426 <li>One</li>
18427 <li>Two</li>
18428 </ul>
18429
18430 !! html/parsoid
18431 <ul data-parsoid='{"stx":"html"}'>
18432 <li data-parsoid='{"stx":"html"}'>One</li>
18433 <li data-parsoid='{"stx":"html"}'>Two</li>
18434 </ul>
18435
18436 !! end
18437
18438 !! test
18439 HTML bullet list, unclosed tags (T7497)
18440 !! wikitext
18441 <ul>
18442 <li>One
18443 <li>Two
18444 </ul>
18445 !! html/php+tidy
18446 <ul>
18447 <li>One</li>
18448 <li>Two</li>
18449 </ul>
18450 !! html/parsoid
18451 <ul data-parsoid='{"stx":"html"}'>
18452 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>One</li>
18453 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>Two</li>
18454 </ul>
18455
18456 !! end
18457
18458 !! test
18459 HTML ordered list, closed tags (T7497)
18460 !! wikitext
18461 <ol>
18462 <li>One</li>
18463 <li>Two</li>
18464 </ol>
18465 !! html/php
18466 <ol>
18467 <li>One</li>
18468 <li>Two</li>
18469 </ol>
18470
18471 !! html/parsoid
18472 <ol data-parsoid='{"stx":"html"}'>
18473 <li data-parsoid='{"stx":"html"}'>One</li>
18474 <li data-parsoid='{"stx":"html"}'>Two</li>
18475 </ol>
18476
18477 !! end
18478
18479 !! test
18480 HTML ordered list, unclosed tags (T7497)
18481 !! options
18482 !! wikitext
18483 <ol>
18484 <li>One
18485 <li>Two
18486 </ol>
18487 !! html/php+tidy
18488 <ol>
18489 <li>One</li>
18490 <li>Two</li>
18491 </ol>
18492 !! html/parsoid
18493 <ol data-parsoid='{"stx":"html"}'>
18494 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>One</li>
18495 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>Two</li>
18496 </ol>
18497
18498 !! end
18499
18500 !! test
18501 HTML nested bullet list, closed tags (T7497)
18502 !! wikitext
18503 <ul>
18504 <li>One</li>
18505 <li>Two:
18506 <ul>
18507 <li>Sub-one</li>
18508 <li>Sub-two</li>
18509 </ul>
18510 </li>
18511 </ul>
18512 !! html/php
18513 <ul>
18514 <li>One</li>
18515 <li>Two:
18516 <ul>
18517 <li>Sub-one</li>
18518 <li>Sub-two</li>
18519 </ul>
18520 </li>
18521 </ul>
18522
18523 !! html/parsoid
18524 <ul data-parsoid='{"stx":"html"}'>
18525 <li data-parsoid='{"stx":"html"}'>One</li>
18526 <li data-parsoid='{"stx":"html"}'>Two:
18527 <ul data-parsoid='{"stx":"html"}'>
18528 <li data-parsoid='{"stx":"html"}'>Sub-one</li>
18529 <li data-parsoid='{"stx":"html"}'>Sub-two</li>
18530 </ul>
18531 </li>
18532 </ul>
18533 !! end
18534
18535 !! test
18536 HTML nested bullet list, open tags (T7497)
18537 !! wikitext
18538 <ul>
18539 <li>One
18540 <li>Two:
18541 <ul>
18542 <li>Sub-one
18543 <li>Sub-two
18544 </ul>
18545 </ul>
18546 !! html/php+tidy
18547 <ul>
18548 <li>One</li>
18549 <li>Two:
18550 <ul>
18551 <li>Sub-one</li>
18552 <li>Sub-two</li>
18553 </ul>
18554 </li>
18555 </ul>
18556 !! html/parsoid
18557 <ul>
18558 <li>One
18559 </li>
18560 <li>Two:
18561 <ul>
18562 <li>Sub-one
18563 </li>
18564 <li>Sub-two
18565 </li>
18566 </ul>
18567 </li>
18568 </ul>
18569
18570 !! end
18571
18572 !! test
18573 HTML nested ordered list, closed tags (T7497)
18574 !! wikitext
18575 <ol>
18576 <li>One</li>
18577 <li>Two:
18578 <ol>
18579 <li>Sub-one</li>
18580 <li>Sub-two</li>
18581 </ol>
18582 </li>
18583 </ol>
18584 !! html
18585 <ol>
18586 <li>One</li>
18587 <li>Two:
18588 <ol>
18589 <li>Sub-one</li>
18590 <li>Sub-two</li>
18591 </ol>
18592 </li>
18593 </ol>
18594
18595 !! end
18596
18597 !! test
18598 HTML nested ordered list, open tags (T7497)
18599 !! wikitext
18600 <ol>
18601 <li>One
18602 <li>Two:
18603 <ol>
18604 <li>Sub-one
18605 <li>Sub-two
18606 </ol>
18607 </ol>
18608 !! html/php
18609 <ol>
18610 <li>One
18611 <li>Two:
18612 <ol>
18613 <li>Sub-one
18614 <li>Sub-two
18615 </ol>
18616 </ol>
18617
18618 !! html/parsoid
18619 <ol>
18620 <li>One
18621 </li>
18622 <li>Two:
18623 <ol>
18624 <li>Sub-one
18625 </li>
18626 <li>Sub-two
18627 </li>
18628 </ol>
18629 </li>
18630 </ol>
18631
18632 !! end
18633
18634 !! test
18635 HTML ordered list item with parameters oddity
18636 !! wikitext
18637 <ol><li id="fragment">One</li>
18638 </ol>
18639 !! html
18640 <ol><li id="fragment">One</li>
18641 </ol>
18642
18643 !! end
18644
18645 # parsoid doesn't explicitly mark autonumbered links, see T55505
18646 !!test
18647 T7918: autonumbering
18648 !! wikitext
18649 [http://first/] [http://second] [ftp://ftp]
18650
18651 ftp://inlineftp
18652
18653 [mailto:enclosed@mail.tld With target]
18654
18655 [mailto:enclosed@mail.tld]
18656
18657 mailto:inline@mail.tld
18658 !! html/php
18659 <p><a rel="nofollow" class="external autonumber" href="http://first/">[1]</a> <a rel="nofollow" class="external autonumber" href="http://second">[2]</a> <a rel="nofollow" class="external autonumber" href="ftp://ftp">[3]</a>
18660 </p><p><a rel="nofollow" class="external free" href="ftp://inlineftp">ftp://inlineftp</a>
18661 </p><p><a rel="nofollow" class="external text" href="mailto:enclosed@mail.tld">With target</a>
18662 </p><p><a rel="nofollow" class="external autonumber" href="mailto:enclosed@mail.tld">[4]</a>
18663 </p><p><a rel="nofollow" class="external free" href="mailto:inline@mail.tld">mailto:inline@mail.tld</a>
18664 </p>
18665 !! html/parsoid
18666 <p><a rel="mw:ExtLink" href="http://first/"></a> <a rel="mw:ExtLink" href="http://second"></a> <a rel="mw:ExtLink" href="ftp://ftp"></a></p>
18667 <p><a rel="mw:ExtLink" href="ftp://inlineftp">ftp://inlineftp</a></p>
18668 <p><a rel="mw:ExtLink" href="mailto:enclosed@mail.tld">With target</a></p>
18669 <p><a rel="mw:ExtLink" href="mailto:enclosed@mail.tld"></a></p>
18670 <p><a rel="mw:ExtLink" href="mailto:inline@mail.tld">mailto:inline@mail.tld</a></p>
18671 !! end
18672
18673
18674 #
18675 # Security and HTML correctness
18676 # From Nick Jenkins' fuzz testing
18677 #
18678
18679 !! test
18680 Fuzz testing: Parser13
18681 !! wikitext
18682 {|
18683 | http://a|
18684 !! html
18685 <table>
18686 <tr>
18687 <td>
18688 </td>
18689 </tr>
18690 </table>
18691
18692 !! end
18693
18694 !! test
18695 Fuzz testing: Parser14
18696 !! wikitext
18697 == onmouseover= ==
18698 http://__TOC__
18699 !! html
18700 <h2><span class="mw-headline" id="onmouseover.3D">onmouseover=</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: onmouseover=">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
18701 http://<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
18702 <ul>
18703 <li class="toclevel-1 tocsection-1"><a href="#onmouseover.3D"><span class="tocnumber">1</span> <span class="toctext">onmouseover=</span></a></li>
18704 </ul>
18705 </div>
18706
18707
18708 !! html+tidy
18709 <h2><span class="mw-headline" id="onmouseover.3D">onmouseover=</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: onmouseover=">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
18710 <p>http://</p>
18711 <div id="toc" class="toc">
18712 <div class="toctitle">
18713 <h2>Contents</h2>
18714 </div>
18715 <ul>
18716 <li class="toclevel-1 tocsection-1"><a href="#onmouseover.3D"><span class="tocnumber">1</span> <span class="toctext">onmouseover=</span></a></li>
18717 </ul>
18718 </div>
18719 <p></p>
18720 !! end
18721
18722 !! test
18723 Fuzz testing: Parser14-table
18724 !! options
18725 parsoid=wt2html,html2html
18726 !! wikitext
18727 ==a==
18728 {| STYLE=__TOC__
18729 !! html
18730 <h2><span class="mw-headline" id="a">a</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: a">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
18731 <table style="&#95;_TOC&#95;_">
18732 <tr><td></td></tr>
18733 </table>
18734
18735 !! html+tidy
18736 <h2><span class="mw-headline" id="a">a</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: a">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
18737 <table style="__TOC__">
18738 <tr>
18739 <td></td>
18740 </tr>
18741 </table>
18742 !! html/parsoid
18743 <h2>a</h2>
18744 <table style="__TOC__"></table>
18745 !! end
18746
18747 # Known to produce bogus xml (extra </td>)
18748 !! test
18749 Fuzz testing: Parser16
18750 !! wikitext
18751 {|
18752 !https://||||||
18753 !! html
18754 <table>
18755 <tr>
18756 <th>https://</th>
18757 <th></th>
18758 <th></th>
18759 <th>
18760 </td>
18761 </tr>
18762 </table>
18763
18764 !! html+tidy
18765 <table>
18766 <tr>
18767 <th>https://</th>
18768 <th></th>
18769 <th></th>
18770 <th></th>
18771 </tr>
18772 </table>
18773 !! end
18774
18775 !! test
18776 Fuzz testing: Parser21
18777 !! wikitext
18778 {|
18779 ! irc://{{ftp://a" onmouseover="alert('hello world');"
18780 |
18781 !! html
18782 <table>
18783 <tr>
18784 <th> <a rel="nofollow" class="external free" href="irc://{{ftp://a">irc://{{ftp://a</a>" onmouseover="alert('hello world');"
18785 </th>
18786 <td>
18787 </td>
18788 </tr>
18789 </table>
18790
18791 !! end
18792
18793 !! test
18794 Fuzz testing: Parser22
18795 !! wikitext
18796 http://===r:::https://b
18797
18798 {|
18799 !! html
18800 <p><a rel="nofollow" class="external free" href="http://===r:::https://b">http://===r:::https://b</a>
18801 </p>
18802 <table>
18803 <tr><td></td></tr>
18804 </table>
18805
18806 !! end
18807
18808 # Known to produce bad XML for now
18809 !! test
18810 Fuzz testing: Parser24
18811 !! options
18812 parsoid=wt2html
18813 !! wikitext
18814 {|
18815 {{{|
18816 <u CLASS=
18817 | {{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx--><noinclude>}}}} >
18818 <br style="onmouseover='alert(document.cookie);' " />
18819
18820 MOVE YOUR MOUSE CURSOR OVER THIS TEXT
18821 |
18822 !! html/php
18823 <table>
18824 {{{|
18825 <u class="&#124;">}}}} &gt;
18826 <br style="onmouseover=&#39;alert(document.cookie);&#39;" />
18827
18828 MOVE YOUR MOUSE CURSOR OVER THIS TEXT
18829 <tr>
18830 <td></u>
18831 </td>
18832 </tr>
18833 </table>
18834
18835 !! html/parsoid
18836 <p data-parsoid='{"fostered":true,"autoInsertedEnd":true}'>{{{|
18837 <u class="|" data-parsoid='{"stx":"html","a":{"{{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx--":null},"sa":{"{{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx--":""},"autoInsertedEnd":true}'><meta typeof="mw:Includes/NoInclude" data-parsoid='{"src":"&lt;noinclude>"}'/>}}}} >
18838 <br style="onmouseover='alert(document.cookie);' " data-parsoid='{"stx":"html","selfClose":true}'/></u></p><p data-parsoid='{"fostered":true,"autoInsertedEnd":true}'><u class="|" data-parsoid='{"stx":"html","a":{"{{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx--":null},"sa":{"{{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx--":""},"autoInsertedEnd":true,"autoInsertedStart":true}'>MOVE YOUR MOUSE CURSOR OVER THIS TEXT</u></p><table data-parsoid='{"autoInsertedEnd":true}'>
18839
18840
18841
18842 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'></td></tr></tbody></table>
18843 !! end
18844
18845 # Note: the current result listed for this is not what the original one was,
18846 # but the original bug was JavaScript injection, which is fixed in any case.
18847 # It's not clear that the original result listed was any more correct than the
18848 # current one. Original result:
18849 # <p>{{{|
18850 # </p>
18851 # <li class="&#124;&#124;">
18852 # }}}blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b>
18853 !!test
18854 Fuzz testing: Parser25 (T8055)
18855 !! wikitext
18856 {{{
18857 |
18858 <LI CLASS=||
18859 >
18860 }}}blah" onmouseover="alert('hello world');" align="left"'''MOVE MOUSE CURSOR OVER HERE
18861 !! html/php
18862 <p>&lt;LI CLASS=blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b>
18863 </p>
18864 !! html/parsoid
18865 <span about="#mwt1" typeof="mw:Param" data-parsoid='{"pi":[[{"k":"1"},{"k":"2"},{"k":"3"}]]}' data-mw='{"parts":[{"templatearg":{"target":{"wt":"\n"},"params":{"1":{"wt":" \n&lt;LI CLASS="},"2":{"wt":""},"3":{"wt":"\n >\n"}},"i":0}},"blah\" onmouseover=\"alert(&#39;hello world&#39;);\" align=\"left\"&#39;&#39;&#39;MOVE MOUSE CURSOR OVER HERE"]}'>
18866 </span><p about="#mwt1">&lt;LI CLASS=blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b></p>
18867 !! end
18868
18869 !!test
18870 Fuzz testing: URL adjacent extension (with space, clean)
18871 !! wikitext
18872 http://example.com <nowiki>junk</nowiki>
18873 !! html/php
18874 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> junk
18875 </p>
18876 !! html/parsoid
18877 <p><a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a> <span typeof="mw:Nowiki">junk</span></p>
18878 !! end
18879
18880 !!test
18881 Fuzz testing: URL adjacent extension (no space, dirty; nowiki)
18882 !! wikitext
18883 http://example.com<nowiki>junk</nowiki>
18884 !! html/php
18885 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>junk
18886 </p>
18887 !! html/parsoid
18888 <p><a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a><span typeof="mw:Nowiki">junk</span></p>
18889 !! end
18890
18891 !! test
18892 Fuzz testing: URL adjacent extension (no space, dirty; pre)
18893 !! wikitext
18894 http://example.com<pre>junk</pre>
18895 !! html/php
18896 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a><pre>junk</pre>
18897
18898 !! html/php+tidy
18899 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a></p>
18900 <pre>
18901 junk
18902 </pre>
18903 !! html/parsoid
18904 <p><a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a></p><pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"junk"}}'>junk</pre>
18905 !! end
18906
18907 !! test
18908 Fuzz testing: image with bogus manual thumbnail
18909 !! wikitext
18910 [[Image:foobar.jpg|thumbnail= ]]
18911 !! html/php
18912 <div class="thumb tright"><div class="thumbinner" style="width:182px;">Error creating thumbnail: <div class="thumbcaption"></div></div></div>
18913
18914 !! html/parsoid
18915 <figure class="mw-default-size" typeof="mw:Error mw:Image/Thumb" data-parsoid='{"optList":[{"ck":"manualthumb","ak":"thumbnail= "}]}' data-mw='{"errors":[{"key":"apierror-invalidtitle","message":"Invalid thumbnail title.","params":{"name":""}}],"thumb":""}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{"href":"Image:foobar.jpg"}}'><img resource="./File:Foobar.jpg" src="./Special:FilePath/Foobar.jpg" height="220" width="220" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"220"},"sa":{"resource":"Image:foobar.jpg"}}'/></a></figure>
18916 !! end
18917
18918 !! test
18919 Fuzz testing: encoded newline in generated HTML replacements (T8577)
18920 !! wikitext
18921 <pre dir="&#10;"></pre>
18922 !! html/php
18923 <pre dir="&#10;"></pre>
18924
18925 !! html/parsoid
18926 <pre typeof="mw:Extension/pre" about="#mwt2" dir="&amp;#10;" data-mw='{"name":"pre","attrs":{"dir":"&amp;#10;"},"body":{"extsrc":""}}'></pre>
18927 !! end
18928
18929 !! test
18930 Parsing optional HTML elements (T8171)
18931 !! options
18932 !! wikitext
18933 <table>
18934 <tr>
18935 <td> Some tabular data</td>
18936 <td> More tabular data ...
18937 <td> And yet som tabular data</td>
18938 </tr>
18939 </table>
18940 !! html
18941 <table>
18942 <tr>
18943 <td> Some tabular data</td>
18944 <td> More tabular data ...
18945 </td><td> And yet som tabular data</td>
18946 </tr>
18947 </table>
18948
18949 !! end
18950
18951 !! test
18952 Correct handling of <td>, <tr> (T8171)
18953 !! options
18954 !! wikitext
18955 <table>
18956 <tr>
18957 <td> Some tabular data</td>
18958 <td> More tabular data ...</td>
18959 <td> And yet som tabular data</td>
18960 </tr>
18961 </table>
18962 !! html
18963 <table>
18964 <tr>
18965 <td> Some tabular data</td>
18966 <td> More tabular data ...</td>
18967 <td> And yet som tabular data</td>
18968 </tr>
18969 </table>
18970
18971 !! end
18972
18973
18974 !! test
18975 Parsing crashing regression (fr:JavaScript)
18976 !! wikitext
18977 </body></x>
18978 !! html
18979 <p>&lt;/body&gt;&lt;/x&gt;
18980 </p>
18981 !! end
18982
18983 !! test
18984 Inline wiki vs wiki block nesting
18985 !! wikitext
18986 '''Bold paragraph
18987
18988 New wiki paragraph
18989 !! html
18990 <p><b>Bold paragraph</b>
18991 </p><p>New wiki paragraph
18992 </p>
18993 !! end
18994
18995 # FIXME: The current php output is documented
18996 # and desired output is the parsoid target.
18997 !! test
18998 Inline HTML vs wiki block nesting
18999 !! wikitext
19000 <b>Bold paragraph
19001
19002 New wiki paragraph
19003 !! html/php
19004 <p><b>Bold paragraph
19005 </p><p>New wiki paragraph</b>
19006 </p>
19007 !! html/parsoid
19008 <p><b>Bold paragraph</b>
19009 </p><p>New wiki paragraph
19010 </p>
19011 !! end
19012
19013 # Original result was this:
19014 # <p><b>bold</b><b>bold<i>bolditalics</i></b>
19015 # </p>
19016 # While that might be marginally more intuitive, maybe, the six-apostrophe
19017 # construct is clearly pathological and the result stated here (which is what
19018 # the parser actually does) is about as reasonable as anything.
19019 !!test
19020 Mixing markup for italics and bold
19021 !! options
19022 !! wikitext
19023 '''bold''''''bold''bolditalics'''''
19024 !! html
19025 <p>'<i>bold'</i><b>bold<i>bolditalics</i></b>
19026 </p>
19027 !! end
19028
19029
19030 !! article
19031 Xyzzyx
19032 !! text
19033 Article for special page transclusion test
19034 !! endarticle
19035
19036 !! test
19037 Special page transclusion
19038 !! options
19039 !! wikitext
19040 {{Special:Prefixindex/Xyzzyx}}
19041 !! html
19042 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
19043 </ul>
19044
19045 !! end
19046
19047 !! test
19048 Special page transclusion twice (T7021)
19049 !! options
19050 !! wikitext
19051 {{Special:Prefixindex/Xyzzyx}}
19052 {{Special:Prefixindex/Xyzzyx}}
19053 !! html
19054 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
19055 </ul>
19056 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
19057 </ul>
19058
19059 !! end
19060
19061 !! test
19062 Transclusion of default MediaWiki message
19063 !! wikitext
19064 {{MediaWiki:Mainpage}}
19065 !! html
19066 <p>Main Page
19067 </p>
19068 !! end
19069
19070 !! test
19071 Transclusion of nonexistent MediaWiki message
19072 !! wikitext
19073 {{MediaWiki:Mainpagexxx}}
19074 !! html
19075 <p><a href="/index.php?title=MediaWiki:Mainpagexxx&amp;action=edit&amp;redlink=1" class="new" title="MediaWiki:Mainpagexxx (page does not exist)">MediaWiki:Mainpagexxx</a>
19076 </p>
19077 !! end
19078
19079 !! test
19080 Transclusion of MediaWiki message with underscore
19081 !! wikitext
19082 {{MediaWiki:history_short}}
19083 !! html
19084 <p>History
19085 </p>
19086 !! end
19087
19088 !! test
19089 Transclusion of MediaWiki message with space
19090 !! wikitext
19091 {{MediaWiki:history short}}
19092 !! html
19093 <p>History
19094 </p>
19095 !! end
19096
19097 !! test
19098 Invalid header with following text
19099 !! wikitext
19100 = x = y
19101 !! html
19102 <p>= x = y
19103 </p>
19104 !! end
19105
19106
19107 !! test
19108 Section extraction test (section 0)
19109 !! options
19110 section=0
19111 !! wikitext
19112 start
19113 ==a==
19114 ===aa===
19115 ====aaa====
19116 ==b==
19117 ===ba===
19118 ===bb===
19119 ====bba====
19120 ===bc===
19121 ==c==
19122 ===ca===
19123 !! html/php
19124 start
19125 !! end
19126
19127 !! test
19128 Section extraction test (section 1)
19129 !! options
19130 section=1
19131 !! wikitext
19132 start
19133 ==a==
19134 ===aa===
19135 ====aaa====
19136 ==b==
19137 ===ba===
19138 ===bb===
19139 ====bba====
19140 ===bc===
19141 ==c==
19142 ===ca===
19143 !! html/php
19144 ==a==
19145 ===aa===
19146 ====aaa====
19147 !! end
19148
19149 !! test
19150 Section extraction test (section 2)
19151 !! options
19152 section=2
19153 !! wikitext
19154 start
19155 ==a==
19156 ===aa===
19157 ====aaa====
19158 ==b==
19159 ===ba===
19160 ===bb===
19161 ====bba====
19162 ===bc===
19163 ==c==
19164 ===ca===
19165 !! html/php
19166 ===aa===
19167 ====aaa====
19168 !! end
19169
19170 !! test
19171 Section extraction test (section 3)
19172 !! options
19173 section=3
19174 !! wikitext
19175 start
19176 ==a==
19177 ===aa===
19178 ====aaa====
19179 ==b==
19180 ===ba===
19181 ===bb===
19182 ====bba====
19183 ===bc===
19184 ==c==
19185 ===ca===
19186 !! html/php
19187 ====aaa====
19188 !! end
19189
19190 !! test
19191 Section extraction test (section 4)
19192 !! options
19193 section=4
19194 !! wikitext
19195 start
19196 ==a==
19197 ===aa===
19198 ====aaa====
19199 ==b==
19200 ===ba===
19201 ===bb===
19202 ====bba====
19203 ===bc===
19204 ==c==
19205 ===ca===
19206 !! html/php
19207 ==b==
19208 ===ba===
19209 ===bb===
19210 ====bba====
19211 ===bc===
19212 !! end
19213
19214 !! test
19215 Section extraction test (section 5)
19216 !! options
19217 section=5
19218 !! wikitext
19219 start
19220 ==a==
19221 ===aa===
19222 ====aaa====
19223 ==b==
19224 ===ba===
19225 ===bb===
19226 ====bba====
19227 ===bc===
19228 ==c==
19229 ===ca===
19230 !! html/php
19231 ===ba===
19232 !! end
19233
19234 !! test
19235 Section extraction test (section 6)
19236 !! options
19237 section=6
19238 !! wikitext
19239 start
19240 ==a==
19241 ===aa===
19242 ====aaa====
19243 ==b==
19244 ===ba===
19245 ===bb===
19246 ====bba====
19247 ===bc===
19248 ==c==
19249 ===ca===
19250 !! html/php
19251 ===bb===
19252 ====bba====
19253 !! end
19254
19255 !! test
19256 Section extraction test (section 7)
19257 !! options
19258 section=7
19259 !! wikitext
19260 start
19261 ==a==
19262 ===aa===
19263 ====aaa====
19264 ==b==
19265 ===ba===
19266 ===bb===
19267 ====bba====
19268 ===bc===
19269 ==c==
19270 ===ca===
19271 !! html/php
19272 ====bba====
19273 !! end
19274
19275 !! test
19276 Section extraction test (section 8)
19277 !! options
19278 section=8
19279 !! wikitext
19280 start
19281 ==a==
19282 ===aa===
19283 ====aaa====
19284 ==b==
19285 ===ba===
19286 ===bb===
19287 ====bba====
19288 ===bc===
19289 ==c==
19290 ===ca===
19291 !! html/php
19292 ===bc===
19293 !! end
19294
19295 !! test
19296 Section extraction test (section 9)
19297 !! options
19298 section=9
19299 !! wikitext
19300 start
19301 ==a==
19302 ===aa===
19303 ====aaa====
19304 ==b==
19305 ===ba===
19306 ===bb===
19307 ====bba====
19308 ===bc===
19309 ==c==
19310 ===ca===
19311 !! html/php
19312 ==c==
19313 ===ca===
19314 !! end
19315
19316 !! test
19317 Section extraction test (section 10)
19318 !! options
19319 section=10
19320 !! wikitext
19321 start
19322 ==a==
19323 ===aa===
19324 ====aaa====
19325 ==b==
19326 ===ba===
19327 ===bb===
19328 ====bba====
19329 ===bc===
19330 ==c==
19331 ===ca===
19332 !! html/php
19333 ===ca===
19334 !! end
19335
19336 !! test
19337 Section extraction test (nonexistent section 11)
19338 !! options
19339 section=11
19340 !! wikitext
19341 start
19342 ==a==
19343 ===aa===
19344 ====aaa====
19345 ==b==
19346 ===ba===
19347 ===bb===
19348 ====bba====
19349 ===bc===
19350 ==c==
19351 ===ca===
19352 !! html/php
19353 !! end
19354
19355 !! test
19356 Section extraction test with bogus heading (section 1)
19357 !! options
19358 section=1
19359 !! wikitext
19360 ==a==
19361 ==bogus== not a legal section
19362 ==b==
19363 !! html/php
19364 ==a==
19365 ==bogus== not a legal section
19366 !! end
19367
19368 !! test
19369 Section extraction test with bogus heading (section 2)
19370 !! options
19371 section=2
19372 !! wikitext
19373 ==a==
19374 ==bogus== not a legal section
19375 ==b==
19376 !! html/php
19377 ==b==
19378 !! end
19379
19380 !! test
19381 Section extraction test with comment after heading (section 1)
19382 !! options
19383 section=1
19384 !! wikitext
19385 ==a==
19386 ==b== <!-- -->
19387 ==c==
19388 !! html/php
19389 ==a==
19390 !! end
19391
19392 !! test
19393 Section extraction test with comment after heading (section 2)
19394 !! options
19395 section=2
19396 !! wikitext
19397 ==a==
19398 ==b== <!-- -->
19399 ==c==
19400 !! html/php
19401 ==b== <!-- -->
19402 !! end
19403
19404 !! test
19405 Section extraction test with bogus <nowiki> heading (section 1)
19406 !! options
19407 section=1
19408 !! wikitext
19409 ==a==
19410 ==bogus== <nowiki>not a legal section</nowiki>
19411 ==b==
19412 !! html/php
19413 ==a==
19414 ==bogus== <nowiki>not a legal section</nowiki>
19415 !! end
19416
19417 !! test
19418 Section extraction test with bogus <nowiki> heading (section 2)
19419 !! options
19420 section=2
19421 !! wikitext
19422 ==a==
19423 ==bogus== <nowiki>not a legal section</nowiki>
19424 ==b==
19425 !! html/php
19426 ==b==
19427 !! end
19428
19429 # Formerly testing for T4587, now resolved by the use of unmarked sections
19430 # instead of respecting commented sections
19431 !! test
19432 Section extraction prefixed by comment (section 1)
19433 !! options
19434 section=1
19435 !! wikitext
19436 <!-- -->==sec1==
19437 ==sec2==
19438 !! html/php
19439 ==sec2==
19440 !!end
19441
19442 !! test
19443 Section extraction prefixed by comment (section 2)
19444 !! options
19445 section=2
19446 !! wikitext
19447 <!-- -->==sec1==
19448 ==sec2==
19449 !! html/php
19450
19451 !!end
19452
19453 # Formerly testing for T4607, now resolved by the use of unmarked sections
19454 # instead of respecting HTML-style headings
19455 !! test
19456 Section extraction, mixed wiki and html (section 1)
19457 !! options
19458 section=1
19459 !! wikitext
19460 <h2>unmarked</h2>
19461 unmarked
19462 ==1==
19463 one
19464 ==2==
19465 two
19466 !! html/php
19467 ==1==
19468 one
19469 !! end
19470
19471 !! test
19472 Section extraction, mixed wiki and html (section 2)
19473 !! options
19474 section=2
19475 !! wikitext
19476 <h2>unmarked</h2>
19477 unmarked
19478 ==1==
19479 one
19480 ==2==
19481 two
19482 !! html/php
19483 ==2==
19484 two
19485 !! end
19486
19487
19488 # Formerly testing for T5342
19489 !! test
19490 Section extraction, heading surrounded by <noinclude>
19491 !! options
19492 section=1
19493 !! wikitext
19494 <noinclude>==unmarked==</noinclude>
19495 ==marked==
19496 !! html/php
19497 ==marked==
19498 !!end
19499
19500 # Test behavior of T21910
19501 !! test
19502 Sectiion with all-equals
19503 !! options
19504 section=2
19505 !! wikitext
19506 ===
19507 The line above must have a trailing space
19508 === <!--
19509 --> <!-- -->
19510 But just in case it doesn't...
19511 !! html/php
19512 === <!--
19513 --> <!-- -->
19514 But just in case it doesn't...
19515 !! end
19516
19517 !! test
19518 Section replacement test (section 0)
19519 !! options
19520 replace=0,"xxx"
19521 !! wikitext
19522 start
19523 ==a==
19524 ===aa===
19525 ====aaa====
19526 ==b==
19527 ===ba===
19528 ===bb===
19529 ====bba====
19530 ===bc===
19531 ==c==
19532 ===ca===
19533 !! html/php
19534 xxx
19535
19536 ==a==
19537 ===aa===
19538 ====aaa====
19539 ==b==
19540 ===ba===
19541 ===bb===
19542 ====bba====
19543 ===bc===
19544 ==c==
19545 ===ca===
19546 !! end
19547
19548 !! test
19549 Section replacement test (section 1)
19550 !! options
19551 replace=1,"xxx"
19552 !! wikitext
19553 start
19554 ==a==
19555 ===aa===
19556 ====aaa====
19557 ==b==
19558 ===ba===
19559 ===bb===
19560 ====bba====
19561 ===bc===
19562 ==c==
19563 ===ca===
19564 !! html/php
19565 start
19566 xxx
19567
19568 ==b==
19569 ===ba===
19570 ===bb===
19571 ====bba====
19572 ===bc===
19573 ==c==
19574 ===ca===
19575 !! end
19576
19577 !! test
19578 Section replacement test (section 2)
19579 !! options
19580 replace=2,"xxx"
19581 !! wikitext
19582 start
19583 ==a==
19584 ===aa===
19585 ====aaa====
19586 ==b==
19587 ===ba===
19588 ===bb===
19589 ====bba====
19590 ===bc===
19591 ==c==
19592 ===ca===
19593 !! html/php
19594 start
19595 ==a==
19596 xxx
19597
19598 ==b==
19599 ===ba===
19600 ===bb===
19601 ====bba====
19602 ===bc===
19603 ==c==
19604 ===ca===
19605 !! end
19606
19607 !! test
19608 Section replacement test (section 3)
19609 !! options
19610 replace=3,"xxx"
19611 !! wikitext
19612 start
19613 ==a==
19614 ===aa===
19615 ====aaa====
19616 ==b==
19617 ===ba===
19618 ===bb===
19619 ====bba====
19620 ===bc===
19621 ==c==
19622 ===ca===
19623 !! html/php
19624 start
19625 ==a==
19626 ===aa===
19627 xxx
19628
19629 ==b==
19630 ===ba===
19631 ===bb===
19632 ====bba====
19633 ===bc===
19634 ==c==
19635 ===ca===
19636 !! end
19637
19638 !! test
19639 Section replacement test (section 4)
19640 !! options
19641 replace=4,"xxx"
19642 !! wikitext
19643 start
19644 ==a==
19645 ===aa===
19646 ====aaa====
19647 ==b==
19648 ===ba===
19649 ===bb===
19650 ====bba====
19651 ===bc===
19652 ==c==
19653 ===ca===
19654 !! html/php
19655 start
19656 ==a==
19657 ===aa===
19658 ====aaa====
19659 xxx
19660
19661 ==c==
19662 ===ca===
19663 !! end
19664
19665 !! test
19666 Section replacement test (section 5)
19667 !! options
19668 replace=5,"xxx"
19669 !! wikitext
19670 start
19671 ==a==
19672 ===aa===
19673 ====aaa====
19674 ==b==
19675 ===ba===
19676 ===bb===
19677 ====bba====
19678 ===bc===
19679 ==c==
19680 ===ca===
19681 !! html/php
19682 start
19683 ==a==
19684 ===aa===
19685 ====aaa====
19686 ==b==
19687 xxx
19688
19689 ===bb===
19690 ====bba====
19691 ===bc===
19692 ==c==
19693 ===ca===
19694 !! end
19695
19696 !! test
19697 Section replacement test (section 6)
19698 !! options
19699 replace=6,"xxx"
19700 !! wikitext
19701 start
19702 ==a==
19703 ===aa===
19704 ====aaa====
19705 ==b==
19706 ===ba===
19707 ===bb===
19708 ====bba====
19709 ===bc===
19710 ==c==
19711 ===ca===
19712 !! html/php
19713 start
19714 ==a==
19715 ===aa===
19716 ====aaa====
19717 ==b==
19718 ===ba===
19719 xxx
19720
19721 ===bc===
19722 ==c==
19723 ===ca===
19724 !! end
19725
19726 !! test
19727 Section replacement test (section 7)
19728 !! options
19729 replace=7,"xxx"
19730 !! wikitext
19731 start
19732 ==a==
19733 ===aa===
19734 ====aaa====
19735 ==b==
19736 ===ba===
19737 ===bb===
19738 ====bba====
19739 ===bc===
19740 ==c==
19741 ===ca===
19742 !! html/php
19743 start
19744 ==a==
19745 ===aa===
19746 ====aaa====
19747 ==b==
19748 ===ba===
19749 ===bb===
19750 xxx
19751
19752 ===bc===
19753 ==c==
19754 ===ca===
19755 !! end
19756
19757 !! test
19758 Section replacement test (section 8)
19759 !! options
19760 replace=8,"xxx"
19761 !! wikitext
19762 start
19763 ==a==
19764 ===aa===
19765 ====aaa====
19766 ==b==
19767 ===ba===
19768 ===bb===
19769 ====bba====
19770 ===bc===
19771 ==c==
19772 ===ca===
19773 !! html/php
19774 start
19775 ==a==
19776 ===aa===
19777 ====aaa====
19778 ==b==
19779 ===ba===
19780 ===bb===
19781 ====bba====
19782 xxx
19783
19784 ==c==
19785 ===ca===
19786 !!end
19787
19788 !! test
19789 Section replacement test (section 9)
19790 !! options
19791 replace=9,"xxx"
19792 !! wikitext
19793 start
19794 ==a==
19795 ===aa===
19796 ====aaa====
19797 ==b==
19798 ===ba===
19799 ===bb===
19800 ====bba====
19801 ===bc===
19802 ==c==
19803 ===ca===
19804 !! html/php
19805 start
19806 ==a==
19807 ===aa===
19808 ====aaa====
19809 ==b==
19810 ===ba===
19811 ===bb===
19812 ====bba====
19813 ===bc===
19814 xxx
19815 !! end
19816
19817 !! test
19818 Section replacement test (section 10)
19819 !! options
19820 replace=10,"xxx"
19821 !! wikitext
19822 start
19823 ==a==
19824 ===aa===
19825 ====aaa====
19826 ==b==
19827 ===ba===
19828 ===bb===
19829 ====bba====
19830 ===bc===
19831 ==c==
19832 ===ca===
19833 !! html/php
19834 start
19835 ==a==
19836 ===aa===
19837 ====aaa====
19838 ==b==
19839 ===ba===
19840 ===bb===
19841 ====bba====
19842 ===bc===
19843 ==c==
19844 xxx
19845 !! end
19846
19847 !! test
19848 Section replacement test with initial whitespace (T15728)
19849 !! options
19850 replace=2,"xxx"
19851 !! wikitext
19852 Preformatted initial line
19853 ==a==
19854 ===a===
19855 !! html/php
19856 Preformatted initial line
19857 ==a==
19858 xxx
19859 !! end
19860
19861
19862 !! test
19863 Section extraction, heading followed by pre with 20 spaces (T8398)
19864 !! options
19865 section=1
19866 !! wikitext
19867 ==a==
19868 a
19869 !! html/php
19870 ==a==
19871 a
19872 !! end
19873
19874 !! test
19875 Section extraction, heading followed by pre with 19 spaces (T8398 sanity check)
19876 !! options
19877 section=1
19878 !! wikitext
19879 ==a==
19880 a
19881 !! html/php
19882 ==a==
19883 a
19884 !! end
19885
19886
19887 !! test
19888 Section extraction, <pre> around bogus header (T12309)
19889 !! options
19890 section=2
19891 !! wikitext
19892 == Section One ==
19893 <pre>
19894 =======
19895 </pre>
19896
19897 == Section Two ==
19898 stuff
19899 !! html/php
19900 == Section Two ==
19901 stuff
19902 !! end
19903
19904 !! test
19905 Section replacement, <pre> around bogus header (T12309)
19906 !! options
19907 replace=2,"xxx"
19908 !! wikitext
19909 == Section One ==
19910 <pre>
19911 =======
19912 </pre>
19913
19914 == Section Two ==
19915 stuff
19916 !! html/php
19917 == Section One ==
19918 <pre>
19919 =======
19920 </pre>
19921
19922 xxx
19923 !! end
19924
19925 !! test
19926 Handling of &#x0A; in URLs
19927 !! wikitext
19928 ** irc://&#x0A;a
19929 !! html/php
19930 <ul><li><ul><li> <a rel="nofollow" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul></li></ul>
19931
19932 !! html/parsoid
19933 <ul><li><ul><li> <a rel="mw:ExtLink" href="irc://%0Aa" data-parsoid='{"stx":"url","a":{"href":"irc://%0Aa"},"sa":{"href":"irc://&amp;#x0A;a"}}'>irc://%0Aa</a></li></ul></li></ul>
19934 !! end
19935
19936 !! test
19937 Handling of %0A in URLs
19938 !! wikitext
19939 ** irc://%0Aa
19940 !! html/php
19941 <ul><li><ul><li> <a rel="nofollow" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul></li></ul>
19942
19943 !! html/parsoid
19944 <ul><li><ul><li> <a rel="mw:ExtLink" href="irc://%0Aa">irc://%0Aa</a></li></ul></li></ul>
19945 !! end
19946
19947 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
19948 !! test
19949 5 quotes, code coverage +1 line
19950 !! options
19951 parsoid=wt2html
19952 !! wikitext
19953 '''''
19954 !! html/php
19955 !! html/parsoid
19956 <p><b><i></i></b></p>
19957 !! end
19958
19959 # same html as previous, but wikitext adjusted to match parsoid html2wt
19960 # note that wt2html and html2html will put the <i> before the <b>
19961 !! test
19962 5 quotes, code coverage +1 line w/ nowiki (1)
19963 !! options
19964 parsoid=wt2wt,html2wt
19965 !! wikitext
19966 '''''<nowiki/>'''''
19967 !! html/php
19968 <p><i></i>
19969 </p>
19970 !! html/parsoid
19971 <p><b><i></i></b></p>
19972 !! end
19973
19974 # same as previous, just swapping the <i> and <b>
19975 !! test
19976 5 quotes, code coverage +1 line w/ nowiki (2)
19977 !! wikitext
19978 '''''<nowiki/>'''''
19979 !! html/php
19980 <p><i></i>
19981 </p>
19982 !! html/parsoid
19983 <p><i><b></b></i></p>
19984 !! end
19985
19986 !! test
19987 Special:Search page linking.
19988 !! wikitext
19989 {{Special:search}}
19990 !! html
19991 <p><a href="/wiki/Special:Search" title="Special:Search">Special:Search</a>
19992 </p>
19993 !! end
19994
19995 !! test
19996 {{!}} is a magic word
19997 !! wikitext
19998 {{!}} is a magic word there and {{!}} is still a magic word here
19999 | is not a magic word here but {{!}} is still a magic word here
20000 !! html/php
20001 <p>| is a magic word there and | is still a magic word here
20002 | is not a magic word here but | is still a magic word here
20003 </p>
20004 !! html/parsoid
20005 <p><span about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[]]}' data-mw='{"parts":[{"template":{"target":{"wt":"!","function":"!"},"params":{},"i":0}}]}'>|</span> is a magic word there and <span about="#mwt2" typeof="mw:Transclusion" data-parsoid='{"pi":[[]]}' data-mw='{"parts":[{"template":{"target":{"wt":"!","function":"!"},"params":{},"i":0}}]}'>|</span> is still a magic word here
20006 | is not a magic word here but <span about="#mwt3" typeof="mw:Transclusion" data-parsoid='{"pi":[[]]}' data-mw='{"parts":[{"template":{"target":{"wt":"!","function":"!"},"params":{},"i":0}}]}'>|</span> is still a magic word here</p>
20007 !! end
20008
20009 !! test
20010 Say the magic word
20011 !! options
20012 title=[[Parser test]]
20013 !! wikitext
20014 * {{PAGENAME}}
20015 * {{PAGENAMEE}}
20016 * {{FULLPAGENAME}}
20017 * {{FULLPAGENAMEE}}
20018 * {{BASEPAGENAME}}
20019 * {{BASEPAGENAMEE}}
20020 * {{SUBPAGENAME}}
20021 * {{SUBPAGENAMEE}}
20022 * {{ROOTPAGENAME}}
20023 * {{ROOTPAGENAMEE}}
20024 * {{TALKPAGENAME}}
20025 * {{TALKPAGENAMEE}}
20026 * {{SUBJECTPAGENAME}}
20027 * {{SUBJECTPAGENAMEE}}
20028 * {{NAMESPACEE}}
20029 * {{NAMESPACE}}
20030 * {{NAMESPACENUMBER}}
20031 * {{TALKSPACE}}
20032 * {{TALKSPACEE}}
20033 * {{SUBJECTSPACE}}
20034 * {{SUBJECTSPACEE}}
20035 * {{Dynamic|{{NUMBEROFUSERS}}|{{NUMBEROFPAGES}}|{{CURRENTVERSION}}|{{CONTENTLANGUAGE}}|{{DIRECTIONMARK}}|{{CURRENTTIMESTAMP}}|{{NUMBEROFARTICLES}}}}
20036 !! html
20037 <ul><li> Parser test</li>
20038 <li> Parser_test</li>
20039 <li> Parser test</li>
20040 <li> Parser_test</li>
20041 <li> Parser test</li>
20042 <li> Parser_test</li>
20043 <li> Parser test</li>
20044 <li> Parser_test</li>
20045 <li> Parser test</li>
20046 <li> Parser_test</li>
20047 <li> Talk:Parser test</li>
20048 <li> Talk:Parser_test</li>
20049 <li> Parser test</li>
20050 <li> Parser_test</li>
20051 <li> </li>
20052 <li> </li>
20053 <li> 0</li>
20054 <li> Talk</li>
20055 <li> Talk</li>
20056 <li> </li>
20057 <li> </li>
20058 <li> <a href="/index.php?title=Template:Dynamic&amp;action=edit&amp;redlink=1" class="new" title="Template:Dynamic (page does not exist)">Template:Dynamic</a></li></ul>
20059
20060 !! end
20061 ### Note: Above tests excludes the "{{NUMBEROFADMINS}}" magic word because it generates a MySQL error when included.
20062
20063 !! test
20064 Gallery with valid attributes
20065 !! wikitext
20066 <gallery type="123" summary="345">
20067 File:File:Foobar.jpg
20068 </gallery>
20069 !! html/php
20070 <ul class="gallery mw-gallery-traditional" type="123">
20071 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20072 <div class="thumb" style="height: 150px;">File:Foobar.jpg</div>
20073 <div class="gallerytext">
20074 </div>
20075 </div></li>
20076 </ul>
20077
20078 !! html/parsoid
20079 <ul class="gallery mw-gallery-traditional" type="123" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{"type":"123","summary":"345"},"body":{"extsrc":"\nFile:File:Foobar.jpg\n"}}'>
20080 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:Error mw:Image"><a href="./File:File:Foobar.jpg"><img resource="./File:File:Foobar.jpg" src="./Special:FilePath/File:Foobar.jpg" height="120" width="120"/></a></span></div><div class="gallerytext"></div></li>
20081 </ul>
20082 !! end
20083
20084 ## Parsoid thinks the "centre" here is a property, not a caption.
20085 !! test
20086 Gallery
20087 !! options
20088 parsoid={
20089 "modes": ["wt2html"],
20090 "nativeGallery": true
20091 }
20092 !! wikitext
20093 <gallery>
20094 image1.png |
20095 image2.gif|||||
20096
20097 image3|
20098 image4 |300px| centre
20099 image5.svg| http://///////
20100 [[x|xx]]]]
20101 * image6
20102 </gallery>
20103 !! html/php
20104 <ul class="gallery mw-gallery-traditional">
20105 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20106 <div class="thumb" style="height: 150px;">Image1.png</div>
20107 <div class="gallerytext">
20108 </div>
20109 </div></li>
20110 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20111 <div class="thumb" style="height: 150px;">Image2.gif</div>
20112 <div class="gallerytext">
20113 </div>
20114 </div></li>
20115 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20116 <div class="thumb" style="height: 150px;">Image3</div>
20117 <div class="gallerytext">
20118 </div>
20119 </div></li>
20120 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20121 <div class="thumb" style="height: 150px;">Image4</div>
20122 <div class="gallerytext">
20123 <pre>centre
20124 </pre>
20125 </div>
20126 </div></li>
20127 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20128 <div class="thumb" style="height: 150px;">Image5.svg</div>
20129 <div class="gallerytext">
20130 <p><a rel="nofollow" class="external free" href="http://///////">http://///////</a>
20131 </p>
20132 </div>
20133 </div></li>
20134 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20135 <div class="thumb" style="height: 150px;">* image6</div>
20136 <div class="gallerytext">
20137 </div>
20138 </div></li>
20139 </ul>
20140
20141 !! html/parsoid
20142 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20143 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:Error mw:Image"><a href="./File:Image1.png"><img resource="./File:Image1.png" src="./Special:FilePath/Image1.png" height="120" width="120"/></a></span></div><div class="gallerytext"></div></li>
20144 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:Error mw:Image"><a href="./File:Image2.gif"><img resource="./File:Image2.gif" src="./Special:FilePath/Image2.gif" height="120" width="120"/></a></span></div><div class="gallerytext"></div></li>
20145 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:Error mw:Image"><a href="./File:Image3"><img resource="./File:Image3" src="./Special:FilePath/Image3" height="120" width="120"/></a></span></div><div class="gallerytext"></div></li>
20146 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:Error mw:Image"><a href="./File:Image4"><img resource="./File:Image4" src="./Special:FilePath/Image4" height="300" width="300"/></a></span></div><div class="gallerytext"></div></li>
20147 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:Error mw:Image"><a href="./File:Image5.svg"><img resource="./File:Image5.svg" src="./Special:FilePath/Image5.svg" height="120" width="120"/></a></span></div><div class="gallerytext"> <a rel="mw:ExtLink" href="http://///////">http://///////</a></div></li>
20148 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:Error mw:Image"><a href="./File:*_image6"><img resource="./File:*_image6" src="./Special:FilePath/*_image6" height="120" width="120"/></a></span></div><div class="gallerytext"></div></li>
20149 </ul>
20150 !! end
20151
20152 !! test
20153 Gallery (with options, html)
20154 !! options
20155 parsoid={
20156 "modes": ["wt2html", "html2html"],
20157 "nativeGallery": true
20158 }
20159 !! wikitext
20160 <gallery widths="70px" heights="40px" perrow="2" caption="Foo [[Main Page]]">
20161 File:Nonexistent.jpg|caption
20162 File:Nonexistent.jpg
20163 image:foobar.jpg|some '''caption''' [[Main Page]]
20164 image:foobar.jpg
20165 image:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla.
20166 </gallery>
20167 !! html/php
20168 <ul class="gallery mw-gallery-traditional" style="max-width: 226px;_width: 226px;">
20169 <li class='gallerycaption'>Foo <a href="/wiki/Main_Page" title="Main Page">Main Page</a></li>
20170 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20171 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
20172 <div class="gallerytext">
20173 <p>caption
20174 </p>
20175 </div>
20176 </div></li>
20177 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20178 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
20179 <div class="gallerytext">
20180 </div>
20181 </div></li>
20182 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20183 <div class="thumb" style="width: 100px;"><div style="margin:31px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/70px-Foobar.jpg" width="70" height="8" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/105px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/140px-Foobar.jpg 2x" /></a></div></div>
20184 <div class="gallerytext">
20185 <p>some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
20186 </p>
20187 </div>
20188 </div></li>
20189 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20190 <div class="thumb" style="width: 100px;"><div style="margin:31px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/70px-Foobar.jpg" width="70" height="8" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/105px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/140px-Foobar.jpg 2x" /></a></div></div>
20191 <div class="gallerytext">
20192 </div>
20193 </div></li>
20194 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20195 <div class="thumb" style="width: 100px;"><div style="margin:31px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="This is a foo-bar." src="http://example.com/images/thumb/3/3a/Foobar.jpg/70px-Foobar.jpg" width="70" height="8" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/105px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/140px-Foobar.jpg 2x" /></a></div></div>
20196 <div class="gallerytext">
20197 <p>blabla.
20198 </p>
20199 </div>
20200 </div></li>
20201 </ul>
20202
20203 !! html/parsoid
20204 <ul class="gallery mw-gallery-traditional" style="max-width: 226px; _width: 226px;" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{"widths":"70px","heights":"40px","perrow":"2"},"body":{}}'>
20205 <li class="gallerycaption">Foo <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></li>
20206 <li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><span typeof="mw:Error mw:Image"><a href="./File:Nonexistent.jpg"><img resource="./File:Nonexistent.jpg" src="./Special:FilePath/Nonexistent.jpg" height="40" width="70"/></a></span></div><div class="gallerytext">caption</div></li>
20207 <li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><span typeof="mw:Error mw:Image"><a href="./File:Nonexistent.jpg"><img resource="./File:Nonexistent.jpg" src="./Special:FilePath/Nonexistent.jpg" height="40" width="70"/></a></span></div><div class="gallerytext"></div></li>
20208 <li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><span typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/70px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="8" width="70"/></a></span></div><div class="gallerytext">some <b>caption</b> <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></div></li>
20209 <li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><span typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/70px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="8" width="70"/></a></span></div><div class="gallerytext"></div></li>
20210 <li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><span typeof="mw:Image"><a href="./File:Foobar.jpg"><img alt="This is a foo-bar." resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/70px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="8" width="70"/></a></span></div><div class="gallerytext">blabla.</div></li>
20211 </ul>
20212 !! end
20213
20214 !! test
20215 Gallery (with options, extsrc)
20216 !! options
20217 parsoid={
20218 "nativeGallery": false
20219 }
20220 !! wikitext
20221 <gallery widths="70px" heights="40px" perrow="2" caption="Foo [[Main Page]]">
20222 File:Nonexistent.jpg|caption
20223 File:Nonexistent.jpg
20224 image:foobar.jpg|some '''caption''' [[Main Page]]
20225 image:foobar.jpg
20226 image:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla.
20227 </gallery>
20228 !! html/php
20229 <ul class="gallery mw-gallery-traditional" style="max-width: 226px;_width: 226px;">
20230 <li class='gallerycaption'>Foo <a href="/wiki/Main_Page" title="Main Page">Main Page</a></li>
20231 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20232 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
20233 <div class="gallerytext">
20234 <p>caption
20235 </p>
20236 </div>
20237 </div></li>
20238 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20239 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
20240 <div class="gallerytext">
20241 </div>
20242 </div></li>
20243 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20244 <div class="thumb" style="width: 100px;"><div style="margin:31px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/70px-Foobar.jpg" width="70" height="8" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/105px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/140px-Foobar.jpg 2x" /></a></div></div>
20245 <div class="gallerytext">
20246 <p>some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
20247 </p>
20248 </div>
20249 </div></li>
20250 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20251 <div class="thumb" style="width: 100px;"><div style="margin:31px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/70px-Foobar.jpg" width="70" height="8" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/105px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/140px-Foobar.jpg 2x" /></a></div></div>
20252 <div class="gallerytext">
20253 </div>
20254 </div></li>
20255 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20256 <div class="thumb" style="width: 100px;"><div style="margin:31px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="This is a foo-bar." src="http://example.com/images/thumb/3/3a/Foobar.jpg/70px-Foobar.jpg" width="70" height="8" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/105px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/140px-Foobar.jpg 2x" /></a></div></div>
20257 <div class="gallerytext">
20258 <p>blabla.
20259 </p>
20260 </div>
20261 </div></li>
20262 </ul>
20263
20264 !! html/parsoid
20265 <ul class="gallery mw-gallery-traditional" style="max-width: 226px; _width: 226px;" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{"widths":"70px","heights":"40px","perrow":"2","caption":"Foo [[Main Page]]"},"body":{"extsrc":"\nFile:Nonexistent.jpg|caption\nFile:Nonexistent.jpg\nimage:foobar.jpg|some &#39;&#39;&#39;caption&#39;&#39;&#39; [[Main Page]]\nimage:foobar.jpg\nimage:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla.\n"}}'>
20266 <li class="gallerycaption">Foo <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></li>
20267 <li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><span typeof="mw:Error mw:Image"><a href="./File:Nonexistent.jpg"><img resource="./File:Nonexistent.jpg" src="./Special:FilePath/Nonexistent.jpg" height="40" width="70"/></a></span></div><div class="gallerytext">caption</div></li>
20268 <li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><span typeof="mw:Error mw:Image"><a href="./File:Nonexistent.jpg"><img resource="./File:Nonexistent.jpg" src="./Special:FilePath/Nonexistent.jpg" height="40" width="70"/></a></span></div><div class="gallerytext"></div></li>
20269 <li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><span typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/70px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="8" width="70"/></a></span></div><div class="gallerytext">some <b>caption</b> <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></div></li>
20270 <li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><span typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/70px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="8" width="70"/></a></span></div><div class="gallerytext"></div></li>
20271 <li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><span typeof="mw:Image"><a href="./File:Foobar.jpg"><img alt="This is a foo-bar." resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/70px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="8" width="70"/></a></span></div><div class="gallerytext">blabla.</div></li>
20272 </ul>
20273 !! end
20274
20275 !! test
20276 Gallery with link that has fragment
20277 !! options
20278 parsoid={
20279 "modes": ["wt2html", "html2html"],
20280 "nativeGallery": true
20281 }
20282 !! wikitext
20283 <gallery>
20284 image:foobar.jpg|link=Main_Page
20285 image:foobar.jpg|link=Main_Page#section
20286 image:foobar.jpg|link=Main Page#section|caption
20287 </gallery>
20288 !! html/php
20289 <ul class="gallery mw-gallery-traditional">
20290 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20291 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/Main_Page"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
20292 <div class="gallerytext">
20293 </div>
20294 </div></li>
20295 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20296 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/Main_Page#section"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
20297 <div class="gallerytext">
20298 </div>
20299 </div></li>
20300 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20301 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/Main_Page#section"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
20302 <div class="gallerytext">
20303 <p>caption
20304 </p>
20305 </div>
20306 </div></li>
20307 </ul>
20308
20309 !! html/parsoid
20310 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20311 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:Image"><a href="./Main_Page"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></span></div><div class="gallerytext"></div></li>
20312 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:Image"><a href="./Main_Page#section"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></span></div><div class="gallerytext"></div></li>
20313 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:Image"><a href="./Main_Page#section"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></span></div><div class="gallerytext">caption</div></li>
20314 </ul>
20315 !! end
20316
20317 ## Whoops, Parsoid shouldn't be parsing templates in the attribute caption!
20318 !! test
20319 Gallery with template inside caption
20320 !! options
20321 parsoid={
20322 "nativeGallery": true
20323 }
20324 !! wikitext
20325 <gallery caption="{{echo|hi}}">
20326 File:Foobar.jpg|{{echo|ho}}
20327 </gallery>
20328 !! html/php
20329 <ul class="gallery mw-gallery-traditional">
20330 <li class='gallerycaption'>{{echo|hi}}</li>
20331 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20332 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
20333 <div class="gallerytext">
20334 <p>ho
20335 </p>
20336 </div>
20337 </div></li>
20338 </ul>
20339
20340 !! html/parsoid
20341 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt6" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20342 <li class="gallerycaption"><span about="#mwt3" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi"}},"i":0}}]}'>hi</span></li>
20343 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></span></div><div class="gallerytext"><span about="#mwt5" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"ho"}},"i":0}}]}'>ho</span></div></li>
20344 </ul>
20345 !! end
20346
20347 !! test
20348 Gallery with wikitext inside caption
20349 !! options
20350 parsoid={
20351 "nativeGallery": true
20352 }
20353 !! wikitext
20354 <gallery>
20355 File:Foobar.jpg|alt=galleryalt|[[File:Foobar.jpg|alt=inneralt|20x20px|desc]]
20356 File:Foobar.jpg|alt=galleryalt|{{Test|unamedParam|alt=param}}
20357 </gallery>
20358 !! html/php
20359 <ul class="gallery mw-gallery-traditional">
20360 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20361 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="galleryalt" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
20362 <div class="gallerytext">
20363 <p><a href="/wiki/File:Foobar.jpg" class="image" title="desc"><img alt="inneralt" src="http://example.com/images/thumb/3/3a/Foobar.jpg/20px-Foobar.jpg" width="20" height="2" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/30px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/40px-Foobar.jpg 2x" /></a>
20364 </p>
20365 </div>
20366 </div></li>
20367 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20368 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="galleryalt" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
20369 <div class="gallerytext">
20370 <p>This is a test template
20371 </p>
20372 </div>
20373 </div></li>
20374 </ul>
20375
20376 !! html/parsoid
20377 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt6" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20378 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:Image"><a href="./File:Foobar.jpg"><img alt="galleryalt" resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></span></div><div class="gallerytext"><span typeof="mw:Image" data-mw='{"caption":"desc"}'><a href="./File:Foobar.jpg"><img alt="inneralt" resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/20px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="2" width="20"/></a></span></div></li>
20379 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:Image"><a href="./File:Foobar.jpg"><img alt="galleryalt" resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></span></div><div class="gallerytext"><span about="#mwt4" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"Test","href":"./Template:Test"},"params":{"1":{"wt":"unamedParam"},"alt":{"wt":"param"}},"i":0}}]}'>This is a test template</span></div></li>
20380 </ul>
20381 !! end
20382
20383 !! test
20384 Gallery (with showfilename option)
20385 !! options
20386 parsoid={
20387 "nativeGallery": true
20388 }
20389 !! wikitext
20390 <gallery showfilename="">
20391 File:Nonexistent.jpg|caption
20392 File:Nonexistent.jpg
20393 File:Foobar.jpg|some '''caption''' [[Main Page]]
20394 File:Foobar.jpg
20395 </gallery>
20396 !! html/php
20397 <ul class="gallery mw-gallery-traditional">
20398 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20399 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
20400 <div class="gallerytext">
20401 <p><a href="/wiki/File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">Nonexistent.jpg</a>
20402 caption
20403 </p>
20404 </div>
20405 </div></li>
20406 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20407 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
20408 <div class="gallerytext">
20409 <p><a href="/wiki/File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">Nonexistent.jpg</a>
20410 </p>
20411 </div>
20412 </div></li>
20413 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20414 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
20415 <div class="gallerytext">
20416 <p><a href="/wiki/File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">Foobar.jpg</a>
20417 some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
20418 </p>
20419 </div>
20420 </div></li>
20421 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20422 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
20423 <div class="gallerytext">
20424 <p><a href="/wiki/File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">Foobar.jpg</a>
20425 </p>
20426 </div>
20427 </div></li>
20428 </ul>
20429
20430 !! html/parsoid
20431 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{"showfilename":""},"body":{}}'>
20432 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:Error mw:Image"><a href="./File:Nonexistent.jpg"><img resource="./File:Nonexistent.jpg" src="./Special:FilePath/Nonexistent.jpg" height="120" width="120"/></a></span></div><div class="gallerytext"><a href="./File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">File:Nonexistent.jpg</a>caption</div></li>
20433 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:Error mw:Image"><a href="./File:Nonexistent.jpg"><img resource="./File:Nonexistent.jpg" src="./Special:FilePath/Nonexistent.jpg" height="120" width="120"/></a></span></div><div class="gallerytext"><a href="./File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">File:Nonexistent.jpg</a></div></li>
20434 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></span></div><div class="gallerytext"><a href="./File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">File:Foobar.jpg</a>some <b>caption</b> <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></div></li>
20435 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></span></div><div class="gallerytext"><a href="./File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">File:Foobar.jpg</a></div></li>
20436 </ul>
20437 !! end
20438
20439 ## Should Parsoid be preserving these variations? See T151367
20440 !! test
20441 Gallery (with namespace-less filenames)
20442 !! options
20443 parsoid={
20444 "modes": ["wt2html", "html2html"],
20445 "nativeGallery": true
20446 }
20447 !! wikitext
20448 <gallery>
20449 File:Nonexistent.jpg
20450 Nonexistent.jpg
20451 image:foobar.jpg
20452 foobar.jpg
20453 </gallery>
20454 !! html/php
20455 <ul class="gallery mw-gallery-traditional">
20456 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20457 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
20458 <div class="gallerytext">
20459 </div>
20460 </div></li>
20461 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20462 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
20463 <div class="gallerytext">
20464 </div>
20465 </div></li>
20466 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20467 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
20468 <div class="gallerytext">
20469 </div>
20470 </div></li>
20471 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20472 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
20473 <div class="gallerytext">
20474 </div>
20475 </div></li>
20476 </ul>
20477
20478 !! html/parsoid
20479 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20480 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:Error mw:Image"><a href="./File:Nonexistent.jpg"><img resource="./File:Nonexistent.jpg" src="./Special:FilePath/Nonexistent.jpg" height="120" width="120"/></a></span></div><div class="gallerytext"></div></li>
20481 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:Error mw:Image"><a href="./File:Nonexistent.jpg"><img resource="./File:Nonexistent.jpg" src="./Special:FilePath/Nonexistent.jpg" height="120" width="120"/></a></span></div><div class="gallerytext"></div></li>
20482 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></span></div><div class="gallerytext"></div></li>
20483 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></span></div><div class="gallerytext"></div></li>
20484 </ul>
20485 !! end
20486
20487 !! test
20488 Gallery override link with WikiLink (T36852)
20489 !! options
20490 parsoid={
20491 "nativeGallery": true
20492 }
20493 !! wikitext
20494 <gallery>
20495 File:Foobar.jpg|alt=galleryalt|link=InterWikiLink
20496 </gallery>
20497 !! html/php
20498 <ul class="gallery mw-gallery-traditional">
20499 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20500 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/InterWikiLink"><img alt="galleryalt" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
20501 <div class="gallerytext">
20502 </div>
20503 </div></li>
20504 </ul>
20505
20506 !! html/parsoid
20507 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-parsoid='{"dsr":[0,70,2,2]}' data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20508 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:Image"><a href="./InterWikiLink"><img alt="galleryalt" resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></span></div><div class="gallerytext"></div></li>
20509 </ul>
20510 !! end
20511
20512 !! test
20513 Gallery override link with absolute external link (T36852)
20514 !! options
20515 parsoid={
20516 "nativeGallery": true
20517 }
20518 !! wikitext
20519 <gallery>
20520 File:Foobar.jpg|alt=galleryalt|link=http://www.example.org
20521 </gallery>
20522 !! html/php
20523 <ul class="gallery mw-gallery-traditional">
20524 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20525 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="http://www.example.org"><img alt="galleryalt" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
20526 <div class="gallerytext">
20527 </div>
20528 </div></li>
20529 </ul>
20530
20531 !! html/parsoid
20532 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20533 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:Image"><a href="http://www.example.org"><img alt="galleryalt" resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></span></div><div class="gallerytext"></div></li>
20534 </ul>
20535 !! end
20536
20537 !! test
20538 Gallery override link with absolute external link with LanguageConverter
20539 !! options
20540 language=zh
20541 !! input
20542 <gallery>
20543 File:foobar.jpg|caption|alt=galleryalt|link=http://www.example.org
20544 </gallery>
20545 !! result
20546 <ul class="gallery mw-gallery-traditional">
20547 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20548 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="http://www.example.org"><img alt="galleryalt" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
20549 <div class="gallerytext">
20550 <p>caption
20551 </p>
20552 </div>
20553 </div></li>
20554 </ul>
20555
20556 !! end
20557
20558 !! test
20559 Gallery override link with malicious javascript (T36852)
20560 !! options
20561 parsoid={
20562 "modes": ["wt2html", "html2html"],
20563 "nativeGallery": true
20564 }
20565 !! wikitext
20566 <gallery>
20567 File:Foobar.jpg|alt=galleryalt|link=" onclick="alert('malicious javascript code!');
20568 </gallery>
20569 !! html/php
20570 <ul class="gallery mw-gallery-traditional">
20571 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20572 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/%22_onclick%3D%22alert(%27malicious_javascript_code!%27);"><img alt="galleryalt" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
20573 <div class="gallerytext">
20574 </div>
20575 </div></li>
20576 </ul>
20577
20578 !! html/parsoid
20579 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20580 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:Image"><a href="./%22_onclick=%22alert('malicious_javascript_code!');"><img alt="galleryalt" resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></span></div><div class="gallerytext"></div></li>
20581 </ul>
20582 !! end
20583
20584 # Note that parsoid uses the invalid link as a caption, PHP does not.
20585 !! test
20586 Gallery with invalid title as link (T45964)
20587 !! options
20588 parsoid={
20589 "modes": ["wt2html", "html2html"],
20590 "nativeGallery": true
20591 }
20592 !! wikitext
20593 <gallery>
20594 File:Foobar.jpg|link=<
20595 </gallery>
20596 !! html/php
20597 <ul class="gallery mw-gallery-traditional">
20598 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20599 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
20600 <div class="gallerytext">
20601 </div>
20602 </div></li>
20603 </ul>
20604
20605 !! html/parsoid
20606 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20607 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></span></div><div class="gallerytext">link=&lt;</div></li>
20608 </ul>
20609 !! end
20610
20611 !! test
20612 Serialize gallery without attrs in data-mw
20613 !! options
20614 parsoid={
20615 "modes": ["html2wt"],
20616 "nativeGallery": true
20617 }
20618 !! html/parsoid
20619 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","body":{}}'>
20620 <li class="gallerycaption">123</li>
20621 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span>File:Test.png</span></div><div class="gallerytext"></div></li>
20622 </ul>
20623 !! wikitext
20624 <gallery caption="123">
20625 File:Test.png
20626 </gallery>
20627 !! end
20628
20629 !! test
20630 Gallery with class and style attributes
20631 !! options
20632 parsoid={
20633 "nativeGallery": true
20634 }
20635 !! wikitext
20636 <gallery class="center" style="text-align: center;">
20637 File:Foobar.jpg
20638 </gallery>
20639 !! html/php
20640 <ul class="gallery mw-gallery-traditional center" style="text-align: center;">
20641 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20642 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
20643 <div class="gallerytext">
20644 </div>
20645 </div></li>
20646 </ul>
20647
20648 !! html/parsoid
20649 <ul class="gallery mw-gallery-traditional center" style="text-align: center;" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{"class":"center","style":"text-align: center;"},"body":{}}'>
20650 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></span></div><div class="gallerytext"></div></li>
20651 </ul>
20652 !! end
20653
20654 !! test
20655 Gallery in slideshow mode
20656 !! options
20657 parsoid={
20658 "nativeGallery": true
20659 }
20660 !! wikitext
20661 <gallery mode="slideshow" showthumbnails="">
20662 File:Foobar.jpg
20663 </gallery>
20664 !! html/php
20665 <ul class="gallery mw-gallery-slideshow" data-showthumbnails="1">
20666 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20667 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
20668 <div class="gallerytext">
20669 </div>
20670 </div></li>
20671 </ul>
20672
20673 !! html/parsoid
20674 <ul class="gallery mw-gallery-slideshow" data-showthumbnails="1" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{"mode":"slideshow","showthumbnails":""},"body":{}}'>
20675 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px;"><span typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></span></div><div class="gallerytext"></div></li>
20676 </ul>
20677 !! end
20678
20679 !! test
20680 HTML Hex character encoding (spells the word "JavaScript")
20681 !! options
20682 parsoid=wt2html,wt2wt,html2html
20683 !! wikitext
20684 &#x4A;&#x061;&#x0076;&#x00061;&#x000053;&#x0000063;&#114;&#x0000069;&#00000112;&#x0000000074;
20685 !! html/php
20686 <p>&#x4a;&#x61;&#x76;&#x61;&#x53;&#x63;&#114;&#x69;&#112;&#x74;
20687 </p>
20688 !! html/php+tidy
20689 <p>JavaScript</p>
20690 !! html/parsoid
20691 <p><span typeof="mw:Entity">J</span><span typeof="mw:Entity">a</span><span typeof="mw:Entity">v</span><span typeof="mw:Entity">a</span><span typeof="mw:Entity">S</span><span typeof="mw:Entity">c</span><span typeof="mw:Entity">r</span><span typeof="mw:Entity">i</span><span typeof="mw:Entity">p</span><span typeof="mw:Entity">t</span></p>
20692 !! end
20693
20694 !! test
20695 HTML Hex character encoding bogus encoding (T28437 regression check)
20696 !! wikitext
20697 &#xsee;&#XSEE;
20698 !! html/php
20699 <p>&amp;#xsee;&amp;#XSEE;
20700 </p>
20701 !! html/parsoid
20702 <p>&amp;#xsee;&amp;#XSEE;</p>
20703 !! end
20704
20705 !! test
20706 HTML Hex character encoding mixed case
20707 !! options
20708 parsoid=wt2html,wt2wt,html2html
20709 !! wikitext
20710 &#xEE;&#Xee;
20711 !! html/php
20712 <p>&#xee;&#xee;
20713 </p>
20714 !! html/php+tidy
20715 <p>îî</p>
20716 !! html/parsoid
20717 <p><span typeof="mw:Entity">î</span><span typeof="mw:Entity">î</span></p>
20718 !! end
20719
20720 # See: https://www.w3.org/TR/html5/syntax.html#character-references
20721 # Note that U+000C (form feed) is not a valid XML character, so
20722 # it is banned even though allowed in HTML5.
20723 !! test
20724 Illegal character references (T106578)
20725 !! wikitext
20726 ; Null: &#00;
20727 ; FF: &#xC;
20728 ; CR: &#xD;
20729 ; Control (low): &#8;
20730 ; Control (high): &#x7F; &#x9F;
20731 ; Surrogate: &#xD83D;&#xDCA9;
20732 ; This is an okay astral character: &#x1F4A9;
20733 !! html+tidy
20734 <dl>
20735 <dt>Null</dt>
20736 <dd>&amp;#00;</dd>
20737 <dt>FF</dt>
20738 <dd>&amp;#xC;</dd>
20739 <dt>CR</dt>
20740 <dd>&amp;#xD;</dd>
20741 <dt>Control (low)</dt>
20742 <dd>&amp;#8;</dd>
20743 <dt>Control (high)</dt>
20744 <dd>&amp;#x7F; &amp;#x9F;</dd>
20745 <dt>Surrogate</dt>
20746 <dd>&amp;#xD83D;&amp;#xDCA9;</dd>
20747 <dt>This is an okay astral character</dt>
20748 <dd>💩</dd>
20749 </dl>
20750 !! end
20751
20752 !! test
20753 __FORCETOC__ override
20754 !! wikitext
20755 __NEWSECTIONLINK__
20756 __FORCETOC__
20757 !! html/php
20758 <p><br />
20759 </p>
20760 !! end
20761
20762 !! test
20763 ISBN code coverage
20764 !! wikitext
20765 ISBN 978-0-1234-56&#x20;789
20766 !! html
20767 <p><a href="/wiki/Special:BookSources/9780123456" class="internal mw-magiclink-isbn">ISBN 978-0-1234-56</a>&#x20;789
20768 </p>
20769 !! html+tidy
20770 <p><a href="/wiki/Special:BookSources/9780123456" class="internal mw-magiclink-isbn">ISBN 978-0-1234-56</a> 789</p>
20771 !! html/parsoid
20772 <p><a href="./Special:BookSources/9780123456" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978-0-1234-56</a><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#x20;","srcContent":" "}'> </span>789</p>
20773 !! end
20774
20775 !! test
20776 ISBN followed by 5 spaces
20777 !! wikitext
20778 ISBN
20779 !! html
20780 <p>ISBN
20781 </p>
20782 !! end
20783
20784 !! test
20785 Double ISBN
20786 !! wikitext
20787 ISBN ISBN 1234567890
20788 !! html/php
20789 <p>ISBN <a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
20790 </p>
20791 !! html/parsoid
20792 <p>ISBN <a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a></p>
20793 !! end
20794
20795 # Uppercase X and lowercase x as well
20796 !! test
20797 ISBN with an X
20798 !! wikitext
20799 ISBN 3-462-04561-X
20800 ISBN 3-462-04561-x
20801 ISBN 080442957X
20802 ISBN 080442957x
20803 ISBN 978080442957X
20804 ISBN 978080442957x
20805 !! html/php
20806 <p><a href="/wiki/Special:BookSources/346204561X" class="internal mw-magiclink-isbn">ISBN 3-462-04561-X</a>
20807 <a href="/wiki/Special:BookSources/346204561X" class="internal mw-magiclink-isbn">ISBN 3-462-04561-x</a>
20808 <a href="/wiki/Special:BookSources/080442957X" class="internal mw-magiclink-isbn">ISBN 080442957X</a>
20809 <a href="/wiki/Special:BookSources/080442957X" class="internal mw-magiclink-isbn">ISBN 080442957x</a>
20810 <a href="/wiki/Special:BookSources/978080442957X" class="internal mw-magiclink-isbn">ISBN 978080442957X</a>
20811 <a href="/wiki/Special:BookSources/978080442957X" class="internal mw-magiclink-isbn">ISBN 978080442957x</a>
20812 </p>
20813 !! html/parsoid
20814 <p><a href="./Special:BookSources/346204561X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 3-462-04561-X</a>
20815 <a href="./Special:BookSources/346204561X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 3-462-04561-x</a>
20816 <a href="./Special:BookSources/080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 080442957X</a>
20817 <a href="./Special:BookSources/080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 080442957x</a>
20818 <a href="./Special:BookSources/978080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978080442957X</a>
20819 <a href="./Special:BookSources/978080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978080442957x</a></p>
20820 !! end
20821
20822 !! test
20823 ISBN with empty prefix (parsoid test)
20824 !! wikitext
20825 ISBN 1234567890
20826 !! html/php
20827 <p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
20828 </p>
20829 !! html/parsoid
20830 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink">ISBN 1234567890</a></p>
20831 !! end
20832
20833 !! test
20834 T24905: <abbr> followed by ISBN followed by </a>
20835 !! wikitext
20836 <abbr>(fr)</abbr> ISBN 2753300917 [http://www.example.com example.com]
20837 !! html/php
20838 <p><abbr>(fr)</abbr> <a href="/wiki/Special:BookSources/2753300917" class="internal mw-magiclink-isbn">ISBN 2753300917</a> <a rel="nofollow" class="external text" href="http://www.example.com">example.com</a>
20839 </p>
20840 !! html/parsoid
20841 <p><abbr data-parsoid='{"stx":"html"}'>(fr)</abbr> <a href="./Special:BookSources/2753300917" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 2753300917</a> <a rel="mw:ExtLink" href="http://www.example.com">example.com</a></p>
20842 !! end
20843
20844 !! test
20845 Double RFC
20846 !! wikitext
20847 RFC RFC 1234
20848 !! html
20849 <p>RFC <a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc1234">RFC 1234</a>
20850 </p>
20851 !! end
20852
20853 !! test
20854 Double RFC with a wiki link
20855 !! wikitext
20856 RFC [[RFC 1234]]
20857 !! html
20858 <p>RFC <a href="/index.php?title=RFC_1234&amp;action=edit&amp;redlink=1" class="new" title="RFC 1234 (page does not exist)">RFC 1234</a>
20859 </p>
20860 !! end
20861
20862 !! test
20863 RFC code coverage
20864 !! wikitext
20865 RFC 983&#x20;987
20866 !! html
20867 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc983">RFC 983</a>&#x20;987
20868 </p>
20869 !! html+tidy
20870 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc983">RFC 983</a> 987</p>
20871 !! end
20872
20873 !! test
20874 Centre-aligned image
20875 !! wikitext
20876 [[Image:foobar.jpg|centre]]
20877 !! html
20878 <div class="center"><div class="floatnone"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div></div>
20879
20880 !!end
20881
20882 !! test
20883 None-aligned image
20884 !! wikitext
20885 [[Image:foobar.jpg|none]]
20886 !! html
20887 <div class="floatnone"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div>
20888
20889 !!end
20890
20891 !! test
20892 Width + Height sized image (using px) (height is ignored)
20893 !! wikitext
20894 [[Image:foobar.jpg|640x480px]]
20895 !! html
20896 <p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/640px-Foobar.jpg" width="640" height="73" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/960px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/1280px-Foobar.jpg 2x" /></a>
20897 </p>
20898 !!end
20899
20900 !! test
20901 Width-sized image (using px, no following whitespace)
20902 !! wikitext
20903 [[Image:foobar.jpg|640px]]
20904 !! html
20905 <p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/640px-Foobar.jpg" width="640" height="73" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/960px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/1280px-Foobar.jpg 2x" /></a>
20906 </p>
20907 !!end
20908
20909 !! test
20910 Width-sized image (using px, with following whitespace - test regression from r39467)
20911 !! wikitext
20912 [[Image:foobar.jpg|640px ]]
20913 !! html
20914 <p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/640px-Foobar.jpg" width="640" height="73" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/960px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/1280px-Foobar.jpg 2x" /></a>
20915 </p>
20916 !!end
20917
20918 !! test
20919 Width-sized image (using px, with preceding whitespace - test regression from r39467)
20920 !! wikitext
20921 [[Image:foobar.jpg| 640px]]
20922 !! html
20923 <p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/640px-Foobar.jpg" width="640" height="73" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/960px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/1280px-Foobar.jpg 2x" /></a>
20924 </p>
20925 !!end
20926
20927 !! test
20928 Image with page parameter
20929 !! options
20930 djvu
20931 !! wikitext
20932 [[File:LoremIpsum.djvu|page=2]]
20933 !! html/php
20934 <p><a href="/index.php?title=File:LoremIpsum.djvu&amp;page=2" class="image"><img alt="LoremIpsum.djvu" src="http://example.com/images/thumb/5/5f/LoremIpsum.djvu/page2-2480px-LoremIpsum.djvu.jpg" width="2480" height="3508" srcset="http://example.com/images/thumb/5/5f/LoremIpsum.djvu/page2-3720px-LoremIpsum.djvu.jpg 1.5x, http://example.com/images/thumb/5/5f/LoremIpsum.djvu/page2-4960px-LoremIpsum.djvu.jpg 2x" /></a>
20935 </p>
20936 !! html/parsoid
20937 <p><span class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"page","ak":"page=2"}]}' data-mw='{"page":"2"}'><a href="./File:LoremIpsum.djvu" data-parsoid='{"a":{"href":"./File:LoremIpsum.djvu"},"sa":{"href":"File:LoremIpsum.djvu"}}'><img resource="./File:LoremIpsum.djvu" src="//example.com/images/5/5f/LoremIpsum.djvu" data-file-width="2480" data-file-height="3508" data-file-type="bitmap" height="3508" width="2480" data-parsoid='{"a":{"resource":"./File:LoremIpsum.djvu","height":"3508","width":"2480"},"sa":{"resource":"File:LoremIpsum.djvu"}}'/></a></span></p>
20938 !! end
20939
20940 !! test
20941 Another italics / bold test
20942 !! wikitext
20943 ''' ''x'
20944 !! html
20945 <pre>'<i> </i>x'
20946 </pre>
20947 !!end
20948
20949 # FIXME: The php output seems broken. It's interleaving some open/close tags.
20950 !! test
20951 dt/dd/dl test
20952 !! wikitext
20953 :;;;::
20954 !! html/php
20955 <dl><dd><dl><dt><dl><dt><dl><dt><dl><dd><dl><dd></dt></dl></dd></dl></dd></dl></dd></dl></dd></dl></dd></dl>
20956
20957 !! html/parsoid
20958 <dl><dd><dl><dt><dl><dt><dl><dt><dl><dd><dl><dd></dd></dl></dd></dl></dt></dl></dt></dl></dt></dl></dd></dl>
20959
20960 !!end
20961
20962 # Images with the "|" character in external URLs in comment tags; Eats half the comment, leaves unmatched "</a>" tag.
20963 !! test
20964 Images with the "|" character in the comment
20965 !! wikitext
20966 [[File:Foobar.jpg|thumb|An [http://test/?param1=|left|&param2=|x external] URL]]
20967 !! html/php
20968 <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>An <a rel="nofollow" class="external text" href="http://test/?param1=%7Cleft%7C&amp;param2=%7Cx">external</a> URL</div></div></div>
20969
20970 !! html/parsoid
20971 <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption>An <a rel="mw:ExtLink" href="http://test/?param1=%7Cleft%7C&amp;param2=%7Cx" data-parsoid='{"a":{"href":"http://test/?param1=%7Cleft%7C&amp;param2=%7Cx"},"sa":{"href":"http://test/?param1=|left|&amp;param2=|x"}}'>external</a> URL</figcaption></figure>
20972 !! end
20973
20974 !! test
20975 [Before] HTML without raw HTML enabled ($wgRawHtml==false)
20976 !! wikitext
20977 <html><script>alert(1);</script></html>
20978 !! html
20979 <p>&lt;html&gt;&lt;script&gt;alert(1);&lt;/script&gt;&lt;/html&gt;
20980 </p>
20981 !! end
20982
20983 !! test
20984 HTML with raw HTML ($wgRawHtml==true)
20985 !! options
20986 wgRawHtml=1
20987 !! wikitext
20988 <html><script>alert(1);</script></html>
20989 !! html
20990 <p><script>alert(1);</script>
20991 </p>
20992 !! end
20993
20994 !! test
20995 Parents of subpages, one level up
20996 !! options
20997 subpage title=[[Subpage test/L1/L2/L3]]
20998 !! wikitext
20999 [[../|L2]]
21000 !! html
21001 <p><a href="/index.php?title=Subpage_test/L1/L2&amp;action=edit&amp;redlink=1" class="new" title="Subpage test/L1/L2 (page does not exist)">L2</a>
21002 </p>
21003 !! end
21004
21005
21006 !! test
21007 Parents of subpages, one level up, not named
21008 !! options
21009 subpage title=[[Subpage test/L1/L2/L3]]
21010 !! wikitext
21011 [[../]]
21012 !! html
21013 <p><a href="/index.php?title=Subpage_test/L1/L2&amp;action=edit&amp;redlink=1" class="new" title="Subpage test/L1/L2 (page does not exist)">Subpage test/L1/L2</a>
21014 </p>
21015 !! end
21016
21017
21018
21019 !! test
21020 Parents of subpages, two levels up
21021 !! options
21022 subpage title=[[Subpage test/L1/L2/L3]]
21023 !! wikitext
21024 [[../../|L1]]2
21025
21026 [[../../|L1]]l
21027 !! html
21028 <p><a href="/index.php?title=Subpage_test/L1&amp;action=edit&amp;redlink=1" class="new" title="Subpage test/L1 (page does not exist)">L1</a>2
21029 </p><p><a href="/index.php?title=Subpage_test/L1&amp;action=edit&amp;redlink=1" class="new" title="Subpage test/L1 (page does not exist)">L1l</a>
21030 </p>
21031 !! end
21032
21033 !! test
21034 Parents of subpages, two levels up, without trailing slash or name.
21035 !! options
21036 subpage title=[[Subpage test/L1/L2/L3]]
21037 !! wikitext
21038 [[../..]]
21039 !! html
21040 <p>[[../..]]
21041 </p>
21042 !! end
21043
21044 !! test
21045 Parents of subpages, two levels up, with lots of extra trailing slashes.
21046 !! options
21047 subpage title=[[Subpage test/L1/L2/L3]]
21048 !! wikitext
21049 [[../../////]]
21050 !! html
21051 <p><a href="/index.php?title=Subpage_test/L1&amp;action=edit&amp;redlink=1" class="new" title="Subpage test/L1 (page does not exist)">Subpage test/L1</a>
21052 </p>
21053 !! end
21054
21055 !! article
21056 Subpage test/L1/L2/L3Sibling
21057 !! text
21058 Sibling article
21059 !! endarticle
21060
21061 !! test
21062 Transclusion of a sibling page (one level up)
21063 !! options
21064 subpage title=[[Subpage test/L1/L2/L3]]
21065 !! wikitext
21066 {{../L3Sibling}}
21067 !! html
21068 <p>Sibling article
21069 </p>
21070 !! end
21071
21072 !! test
21073 Transclusion of a child page
21074 !! options
21075 subpage title=[[Subpage test/L1/L2]]
21076 !! wikitext
21077 {{/L3Sibling}}
21078 !! html
21079 <p>Sibling article
21080 </p>
21081 !! end
21082
21083 # This is wt2html only in Parsoid because we add <nowiki>
21084 # because of {{..}} and we don't expect to fix that to
21085 # eliminate the nowikis selective for {{..}} markup.
21086 !! test
21087 Non-transclusion because of too many up levels
21088 !! options
21089 subpage title=[[Subpage test/L1/L2/L3]]
21090 parsoid=wt2html
21091 !! wikitext
21092 {{../../../../More than parent}}
21093 !! html/php
21094 <p>{{../../../../More than parent}}
21095 </p>
21096 !! html/parsoid
21097 <p>{{../../../../More than parent}}</p>
21098 !! end
21099
21100 !! test
21101 Definition list code coverage
21102 !! wikitext
21103 ; title : def
21104 ; title : def
21105 ;title: def
21106 !! html/php
21107 <dl><dt> title &#160;</dt>
21108 <dd> def</dd>
21109 <dt> title&#160;</dt>
21110 <dd> def</dd>
21111 <dt>title</dt>
21112 <dd> def</dd></dl>
21113
21114 !! html/parsoid
21115 <dl><dt> title <span typeof="mw:Placeholder"> </span></dt><dd> def</dd>
21116 <dt> title<span typeof="mw:Placeholder"> </span></dt><dd> def</dd>
21117 <dt>title</dt><dd> def</dd></dl>
21118 !! end
21119
21120 !! test
21121 Don't fall for the self-closing div
21122 !! wikitext
21123 <div>hello world</div/>
21124 !! html
21125 <div>hello world</div>
21126
21127 !! end
21128
21129 !! test
21130 MSGNW magic word
21131 !! wikitext
21132 {{MSGNW:msg}}
21133 !! html/php
21134 <p>&#91;&#91;:Template:Msg&#93;&#93;
21135 </p>
21136 !! end
21137
21138 !! test
21139 RAW magic word
21140 !! wikitext
21141 {{RAW:QUERTY}}
21142 !! html
21143 <p><a href="/index.php?title=Template:QUERTY&amp;action=edit&amp;redlink=1" class="new" title="Template:QUERTY (page does not exist)">Template:QUERTY</a>
21144 </p>
21145 !! end
21146
21147 # This isn't needed for XHTML conformance, but would be handy as a fallback security measure
21148 !! test
21149 Always escape literal '>' in output, not just after '<'
21150 !! wikitext
21151 ><>
21152 !! html
21153 <p>&gt;&lt;&gt;
21154 </p>
21155 !! end
21156
21157 !! test
21158 Template caching
21159 !! wikitext
21160 {{Test}}
21161 {{Test}}
21162 !! html
21163 <p>This is a test template
21164 This is a test template
21165 </p>
21166 !! end
21167
21168
21169 !! article
21170 MediaWiki:Fake
21171 !! text
21172 ==header==
21173 !! endarticle
21174
21175 !! test
21176 Inclusion of !userCanEdit() content
21177 !! wikitext
21178 {{MediaWiki:Fake}}
21179 !! html
21180 <h2><span class="mw-headline" id="header">header</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=MediaWiki:Fake&amp;action=edit&amp;section=T-1" title="MediaWiki:Fake">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
21181
21182 !! end
21183
21184
21185 !! test
21186 Out-of-order TOC heading levels
21187 !! wikitext
21188 ==2==
21189 ======6======
21190 ===3===
21191 =1=
21192 =====5=====
21193 ==2==
21194 !! html
21195 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
21196 <ul>
21197 <li class="toclevel-1 tocsection-1"><a href="#2"><span class="tocnumber">1</span> <span class="toctext">2</span></a>
21198 <ul>
21199 <li class="toclevel-2 tocsection-2"><a href="#6"><span class="tocnumber">1.1</span> <span class="toctext">6</span></a></li>
21200 <li class="toclevel-2 tocsection-3"><a href="#3"><span class="tocnumber">1.2</span> <span class="toctext">3</span></a></li>
21201 </ul>
21202 </li>
21203 <li class="toclevel-1 tocsection-4"><a href="#1"><span class="tocnumber">2</span> <span class="toctext">1</span></a>
21204 <ul>
21205 <li class="toclevel-2 tocsection-5"><a href="#5"><span class="tocnumber">2.1</span> <span class="toctext">5</span></a></li>
21206 <li class="toclevel-2 tocsection-6"><a href="#2_2"><span class="tocnumber">2.2</span> <span class="toctext">2</span></a></li>
21207 </ul>
21208 </li>
21209 </ul>
21210 </div>
21211
21212 <h2><span class="mw-headline" id="2">2</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: 2">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
21213 <h6><span class="mw-headline" id="6">6</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: 6">edit</a><span class="mw-editsection-bracket">]</span></span></h6>
21214 <h3><span class="mw-headline" id="3">3</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=3" title="Edit section: 3">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
21215 <h1><span class="mw-headline" id="1">1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=4" title="Edit section: 1">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
21216 <h5><span class="mw-headline" id="5">5</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=5" title="Edit section: 5">edit</a><span class="mw-editsection-bracket">]</span></span></h5>
21217 <h2><span class="mw-headline" id="2_2">2</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=6" title="Edit section: 2">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
21218
21219 !! end
21220
21221
21222 !! test
21223 ISBN with a dummy number
21224 !! wikitext
21225 ISBN ---
21226 !! html
21227 <p>ISBN ---
21228 </p>
21229 !! end
21230
21231
21232 !! test
21233 ISBN with space-delimited number
21234 !! wikitext
21235 ISBN 92 9017 032 8
21236 !! html/php
21237 <p><a href="/wiki/Special:BookSources/9290170328" class="internal mw-magiclink-isbn">ISBN 92 9017 032 8</a>
21238 </p>
21239 !! html/parsoid
21240 <p data-parsoid='{"dsr":[0,18,0,0]}'><a href="./Special:BookSources/9290170328" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink","dsr":[0,18,2,2]}'>ISBN 92 9017 032 8</a></p>
21241 !! end
21242
21243
21244 !! test
21245 ISBN with multiple spaces, no number
21246 !! wikitext
21247 ISBN foo
21248 !! html
21249 <p>ISBN foo
21250 </p>
21251 !! end
21252
21253
21254 !! test
21255 ISBN length
21256 !! wikitext
21257 ISBN 123456789
21258
21259 ISBN 1234567890
21260
21261 ISBN 12345678901
21262 !! html/php
21263 <p>ISBN 123456789
21264 </p><p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
21265 </p><p>ISBN 12345678901
21266 </p>
21267 !! html/parsoid
21268 <p>ISBN 123456789</p>
21269
21270 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a></p>
21271
21272 <p>ISBN 12345678901</p>
21273 !! end
21274
21275
21276 !! test
21277 ISBN with trailing year (T9110)
21278 !! wikitext
21279 ISBN 1-234-56789-0 - 2006
21280
21281 ISBN 1 234 56789 0 - 2006
21282 !! html/php
21283 <p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1-234-56789-0</a> - 2006
21284 </p><p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1 234 56789 0</a> - 2006
21285 </p>
21286 !! html/parsoid
21287 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1-234-56789-0</a> - 2006</p>
21288
21289 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1 234 56789 0</a> - 2006</p>
21290 !! end
21291
21292
21293 !! test
21294 anchorencode
21295 !! wikitext
21296 {{anchorencode:foo bar©#%n}}
21297 !! html
21298 <p>foo_bar.C2.A9.23.25n
21299 </p>
21300 !! end
21301
21302 !! test
21303 anchorencode trims spaces
21304 !! wikitext
21305 {{anchorencode: __pretty__please__}}
21306 !! html
21307 <p>pretty_please
21308 </p>
21309 !! end
21310
21311 !! test
21312 anchorencode deals with links
21313 !! wikitext
21314 {{anchorencode: [[hello|world]] [[hi]]}}
21315 !! html
21316 <p>world_hi
21317 </p>
21318 !! end
21319
21320 !! test
21321 anchorencode deals with templates
21322 !! wikitext
21323 {{anchorencode: {{Foo}} }}
21324 !! html
21325 <p>FOO
21326 </p>
21327 !! end
21328
21329 !! test
21330 anchorencode encodes like the TOC generator: (T20431)
21331 !! wikitext
21332 === _ +:.3A%3A&&amp;]] ===
21333 {{anchorencode: _ +:.3A%3A&&amp;]] }}
21334 __NOEDITSECTION__
21335 !! html
21336 <h3><span class="mw-headline" id=".2B:.3A.253A.26.26.5D.5D">_ +:.3A%3A&amp;&amp;]]</span></h3>
21337 <p>.2B:.3A.253A.26.26.5D.5D
21338 </p>
21339 !! end
21340
21341 !! test
21342 T8200: blockquotes and paragraph formatting
21343 !! wikitext
21344 <blockquote>
21345 foo
21346 </blockquote>
21347
21348 bar
21349
21350 baz
21351 !! html
21352 <blockquote>
21353 <p>foo
21354 </p>
21355 </blockquote>
21356 <p>bar
21357 </p>
21358 <pre>baz
21359 </pre>
21360 !! end
21361
21362 !! test
21363 T10293: Use of center tag ruins paragraph formatting
21364 !! wikitext
21365 <center>
21366 foo
21367 </center>
21368
21369 bar
21370
21371 baz
21372 !! html
21373 <center>
21374 <p>foo
21375 </p>
21376 </center>
21377 <p>bar
21378 </p>
21379 <pre>baz
21380 </pre>
21381 !! end
21382
21383 !!test
21384 Parsing of overlapping (improperly nested) inline html tags
21385 !! wikitext
21386 <span><s>x</span></s>
21387 !! html/php
21388 <p><span><s>x&lt;/span&gt;</s></span>
21389 </p>
21390 !! html/parsoid
21391 <p><span><s>x</s></span>
21392 </p>
21393 !!end
21394
21395 ###
21396 ### Language variants related tests
21397 ###
21398
21399 # Parsoid does not mark self-links.
21400 # Parsoid does not convert links; PHP will do any necessary redirects.
21401
21402 !! test
21403 Self-link in language variants
21404 !! options
21405 title=[[Dunav]] language=sr
21406 !! wikitext
21407 Both [[Dunav]] and [[Дунав]] are names for this river.
21408 !! html/php
21409 <p>Both <a class="mw-selflink selflink">Dunav</a> and <a class="mw-selflink selflink">Дунав</a> are names for this river.
21410 </p>
21411 !! html/parsoid
21412 <p>Both <a rel="mw:WikiLink" href="./Dunav" title="Dunav">Dunav</a> and <a rel="mw:WikiLink" href="./Дунав" title="Дунав">Дунав</a> are names for this river.</p>
21413 !! end
21414
21415 !! article
21416 Дуна
21417 !! text
21418 content
21419 !! endarticle
21420
21421 !! test
21422 Link to another existing title shouldn't be parsed as self-link even if it's a variant of this title
21423 !! options
21424 title=[[Duna]] language=sr
21425 !! wikitext
21426 [[Дуна]] is not a self-link while [[Duna]] and [[Dуна]] are still self-links.
21427 !! html/php
21428 <p><a href="/wiki/%D0%94%D1%83%D0%BD%D0%B0" title="Дуна">Дуна</a> is not a self-link while <a class="mw-selflink selflink">Duna</a> and <a class="mw-selflink selflink">Dуна</a> are still self-links.
21429 </p>
21430 !! html/parsoid
21431 <p><a rel="mw:WikiLink" href="./Дуна" title="Дуна">Дуна</a> is not a self-link while <a rel="mw:WikiLink" href="./Duna" title="Duna">Duna</a> and <a rel="mw:WikiLink" href="./Dуна" title="Dуна">Dуна</a> are still self-links.</p>
21432 !! end
21433
21434 !! test
21435 Link to a section of a variant of this title shouldn't be parsed as self-link
21436 !! options
21437 title=[[Duna]] language=sr
21438 !! wikitext
21439 [[Dуна]] is a self-link while [[Dunа#Foo]] and [[Dуна#Foo]] are not self-links.
21440 !! html/php
21441 <p><a class="mw-selflink selflink">Dуна</a> is a self-link while <a href="/wiki/%D0%94%D1%83%D0%BD%D0%B0" title="Дуна">Dunа#Foo</a> and <a href="/wiki/%D0%94%D1%83%D0%BD%D0%B0" title="Дуна">Dуна#Foo</a> are not self-links.
21442 </p>
21443 !! html/parsoid
21444 <p><a rel="mw:WikiLink" href="./Dуна" title="Dуна">Dуна</a> is a self-link while <a rel="mw:WikiLink" href="./Dunа#Foo" title="Dunа">Dunа#Foo</a> and <a rel="mw:WikiLink" href="./Dуна#Foo" title="Dуна">Dуна#Foo</a> are not self-links.</p>
21445 !! end
21446
21447 !! test
21448 Link to pages in language variants
21449 !! options
21450 language=sr
21451 !! wikitext
21452 Main Page can be written as [[Маин Паге]]
21453 !! html/php
21454 <p>Main Page can be written as <a href="/wiki/Main_Page" title="Main Page">Маин Паге</a>
21455 </p>
21456 !! html/parsoid
21457 <p>Main Page can be written as <a rel="mw:WikiLink" href="./Маин_Паге" title="Маин Паге">Маин Паге</a></p>
21458 !! end
21459
21460
21461 !! test
21462 Multiple links to pages in language variants
21463 !! options
21464 language=sr
21465 !! wikitext
21466 [[Main Page]] can be written as [[Маин Паге]] same as [[Маин Паге]].
21467 !! html/php
21468 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a> can be written as <a href="/wiki/Main_Page" title="Main Page">Маин Паге</a> same as <a href="/wiki/Main_Page" title="Main Page">Маин Паге</a>.
21469 </p>
21470 !! html/parsoid
21471 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a> can be written as <a rel="mw:WikiLink" href="./Маин_Паге" title="Маин Паге">Маин Паге</a> same as <a rel="mw:WikiLink" href="./Маин_Паге" title="Маин Паге">Маин Паге</a>.</p>
21472 !! end
21473
21474
21475 !! test
21476 Simple template in language variants
21477 !! options
21478 language=sr
21479 !! wikitext
21480 {{тест}}
21481 !! html/php
21482 <p>This is a test template
21483 </p>
21484 !! end
21485
21486
21487 !! test
21488 Template with explicit namespace in language variants
21489 !! options
21490 language=sr
21491 !! wikitext
21492 {{Template:тест}}
21493 !! html/php
21494 <p>This is a test template
21495 </p>
21496 !! end
21497
21498
21499 !! test
21500 Basic test for template parameter in language variants
21501 !! options
21502 language=sr
21503 !! wikitext
21504 {{парамтест|param=foo}}
21505 !! html/php
21506 <p>This is a test template with parameter foo
21507 </p>
21508 !! end
21509
21510 !! test
21511 Simple category in language variants
21512 !! options
21513 language=sr cat
21514 !! wikitext
21515 [[Category:МедиаWики Усер'с Гуиде]]
21516 !! html/php
21517 cat=МедиаWики_Усер'с_Гуиде sort=
21518 !! html/parsoid
21519 <link rel="mw:PageProp/Category" href="./Категорија:МедиаWики_Усер'с_Гуиде" data-parsoid='{"stx":"simple","a":{"href":"./Категорија:МедиаWики_Усер&#39;с_Гуиде"},"sa":{"href":"Category:МедиаWики Усер&#39;с Гуиде"}}'/>
21520 !! end
21521
21522 !! article
21523 Category:分类
21524 !! text
21525 blah
21526 !! endarticle
21527
21528 !! article
21529 Category:分類
21530 !! text
21531 blah
21532 !! endarticle
21533
21534 ## We used to, but no longer wt2wt this test since the default serializer
21535 ## will normalize all categories to serialize on their own line.
21536 ## This wikitext usage is going to be fairly uncommon in production and
21537 ## selser will take care of preserving formatting in those scenarios.
21538 !! test
21539 Don't convert blue categorylinks to another variant (T35210)
21540 !! options
21541 cat
21542 language=zh
21543 parsoid=wt2html
21544 !! wikitext
21545 [[A]][[Category:分类]]
21546 !! html/php
21547 cat=分类 sort=
21548 !! html/parsoid
21549 <p><a rel="mw:WikiLink" href="./A" title="A">A</a></p>
21550 <link rel="mw:PageProp/Category" href="./Category:分类"/>
21551 !! end
21552
21553 !! test
21554 Stripping -{}- tags (language variants)
21555 !! options
21556 language=sr
21557 !! wikitext
21558 Latin proverb: -{Ne nuntium necare}-
21559 !! html/php
21560 <p>Latin proverb: Ne nuntium necare
21561 </p>
21562 !! html/parsoid
21563 <p>Latin proverb: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
21564 !! end
21565
21566
21567 !! test
21568 Prevent conversion with -{}- tags (language variants)
21569 !! options
21570 language=sr variant=sr-ec
21571 !! wikitext
21572 Latinski: -{Ne nuntium necare}-
21573 !! html/php
21574 <p>Латински: Ne nuntium necare
21575 </p>
21576 !! html/parsoid
21577 <p>Latinski: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
21578 !! end
21579
21580
21581 !! test
21582 Prevent conversion of text with -{}- tags (language variants)
21583 !! options
21584 language=sr variant=sr-ec
21585 !! wikitext
21586 Latinski: -{Ne nuntium necare}-
21587 !! html/php
21588 <p>Латински: Ne nuntium necare
21589 </p>
21590 !! html/parsoid
21591 <p>Latinski: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
21592 !! end
21593
21594
21595 !! test
21596 Prevent conversion of links with -{}- tags (language variants)
21597 !! options
21598 language=sr variant=sr-ec
21599 !! wikitext
21600 -{[[Main Page]]}-
21601 !! html/php
21602 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
21603 </p>
21604 !! html/parsoid
21605 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"&lt;a rel=\"mw:WikiLink\" href=\"./Main_Page\" title=\"Main Page\" data-parsoid=&#39;{\"stx\":\"simple\",\"a\":{\"href\":\"./Main_Page\"},\"sa\":{\"href\":\"Main Page\"},\"dsr\":[2,15,2,2]}&#39;>Main Page&lt;/a>"}}'></span></p>
21606 !! end
21607
21608
21609 !! test
21610 -{}- tags within headlines (within html for parserConvert())
21611 !! options
21612 language=sr variant=sr-ec
21613 !! wikitext
21614 == -{Naslov}- ==
21615
21616 Note that even an unprotected headline ID is not affected by language
21617 conversion:
21618
21619 == Latinski ==
21620 !! html/php
21621 <h2><span class="mw-headline" id="-.7BNaslov.7D-">Naslov</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Уреди одељак „Naslov“">уреди</a><span class="mw-editsection-bracket">]</span></span></h2>
21622 <p>Ноте тхат евен ан унпротецтед хеадлине ИД ис нот аффецтед бy лангуаге
21623 цонверсион:
21624 </p>
21625 <h2><span class="mw-headline" id="Latinski">Латински</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Уреди одељак „Латински“">уреди</a><span class="mw-editsection-bracket">]</span></span></h2>
21626
21627 !! html/parsoid
21628 <h2 id="-.7BNaslov.7D-"><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Naslov"}}'></span></h2>
21629
21630 <p>Note that even an unprotected headline ID is not affected by language
21631 conversion:</p>
21632
21633 <h2 id="Latinski">Latinski</h2>
21634 !! end
21635
21636 !! test
21637 Explicit definition of language variant alternatives
21638 !! options
21639 language=zh variant=zh-tw
21640 !! wikitext
21641 -{zh:China;zh-tw:Taiwan}-, not China
21642 !! html/php
21643 <p>Taiwan, not China
21644 </p>
21645 !! html/parsoid
21646 <p><span typeof="mw:LanguageVariant" data-parsoid='{"tSp":[6]}' data-mw-variant='{"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'></span>, not China</p>
21647 !! end
21648
21649 !! test
21650 Filter syntax for language variants
21651 !! options
21652 language=zh variant=zh-tw
21653 !! wikitext
21654 foo-{zh;zh-hans;zh-hant|blog, WEBJOURNAL, WEBLOG}-quux
21655 !! html/php
21656 <p>fooblog, WEBJOURNAL, WEBLOGquux
21657 </p>
21658 !! html/parsoid
21659 <p>foo<span typeof="mw:LanguageVariant" data-mw-variant='{"filter":{"l":["zh","zh-hans","zh-hant"],"t":"blog, WEBJOURNAL, WEBLOG"}}'></span>quux</p>
21660 !! end
21661
21662 # Note that Parsoid post-processing for language variants needs to
21663 # update the `title` attribute here, based on the mw:ExpandedAttrs property
21664 !! test
21665 Conversion around HTML tags
21666 !! options
21667 language=sr variant=sr-ec
21668 !! wikitext
21669 -{H|span=>sr-ec:script;title=>sr-ec:src}-
21670 <span title="La-{sr-el:L;sr-ec:C}-tin">ski</span>
21671 !! html/php
21672 <p>
21673 <span title="ЛаCтин">ски</span>
21674 </p>
21675 !! html/parsoid
21676 <p><meta typeof="mw:LanguageVariant" data-parsoid='{"tSp":[8]}' data-mw-variant='{"add":true,"oneway":[{"f":"span","l":"sr-ec","t":"script"},{"f":"title","l":"sr-ec","t":"src"}]}'/>
21677 <span title="Latin" typeof="mw:ExpandedAttrs" data-mw='{"attribs":[[{"txt":"title"},{"html":"La&lt;span typeof=\"mw:LanguageVariant\" data-mw-variant=&#39;{\"twoway\":[{\"l\":\"sr-el\",\"t\":\"L\"},{\"l\":\"sr-ec\",\"t\":\"C\"}]}&#39; data-parsoid=&#39;{\"fl\":[],\"tSp\":[6],\"dsr\":[57,76,null,2]}&#39;>&lt;/span>tin"}]]}'>ski</span></p>
21678 !! end
21679
21680 !! test
21681 Explicit session-wise two-way language variant mapping (A flag and - flag)
21682 !! options
21683 language=zh variant=zh-tw
21684 !! wikitext
21685 This is -{zh:China; zh-tw:Taiwan}-, but we'll forget that now.
21686
21687 Taiwan is not China.
21688
21689 But -{A|zh:China; zh-tw:Taiwan}- is China,
21690
21691 (This-{-|zh:China; zh-tw:Taiwan}- should be stripped!)
21692
21693 and -{China}- is China.
21694 !! html/php
21695 <p>This is Taiwan, but we'll forget that now.
21696 </p><p>Taiwan is not China.
21697 </p><p>But Taiwan is Taiwan,
21698 </p><p>(This should be stripped!)
21699 </p><p>and China is China.
21700 </p>
21701 !! html/parsoid
21702 <p>This is <span typeof="mw:LanguageVariant" data-mw-variant='{"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'></span>, but we'll forget that now.</p>
21703 <p>Taiwan is not China.</p>
21704 <p>But <span typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'></span> is China,</p>
21705 <p>(This<meta typeof="mw:LanguageVariant" data-mw-variant='{"remove":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/> should be stripped!)</p>
21706 <p>and <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"China"}}'></span> is China.</p>
21707 !! end
21708
21709 !! test
21710 Explicit session-wise one-way language variant mapping (A flag and - flag)
21711 !! options
21712 language=zh variant=zh-tw
21713 !! wikitext
21714 This is -{COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}-, but we'll forget that now.
21715
21716 COUNTRY is China or Taiwan.
21717
21718 But -{A|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- is COUNTRY,
21719
21720 (This-{-|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- should be stripped!)
21721
21722 and -{COUNTRY}- is COUNTRY.
21723 !! html/php
21724 <p>This is Taiwan, but we'll forget that now.
21725 </p><p>COUNTRY is China or Taiwan.
21726 </p><p>But Taiwan is Taiwan,
21727 </p><p>(This should be stripped!)
21728 </p><p>and COUNTRY is COUNTRY.
21729 </p>
21730 !! html/parsoid
21731 <p>This is <span typeof="mw:LanguageVariant" data-mw-variant='{"oneway":[{"f":"COUNTRY","l":"zh","t":"China"},{"f":"COUNTRY","l":"zh-tw","t":"Taiwan"}]}'></span>, but we'll forget that now.</p>
21732 <p>COUNTRY is China or Taiwan.</p>
21733 <p>But <span typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"COUNTRY","l":"zh","t":"China"},{"f":"COUNTRY","l":"zh-tw","t":"Taiwan"}]}'></span> is COUNTRY,</p>
21734 <p>(This<meta typeof="mw:LanguageVariant" data-mw-variant='{"oneway":[{"f":"COUNTRY","l":"zh","t":"China"},{"f":"COUNTRY","l":"zh-tw","t":"Taiwan"}],"remove":true}'/> should be stripped!)</p>
21735 <p>and <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"COUNTRY"}}'></span> is COUNTRY.</p>
21736 !! end
21737
21738 !! test
21739 Explicit session-wise two-way language variant mapping (H flag for hide)
21740 !! options
21741 language=zh variant=zh-tw
21742 !! wikitext
21743 (This-{H|zh:China;zh-tw:Taiwan}- should be stripped!)
21744
21745 Taiwan is China.
21746 !! html/php
21747 <p>(This should be stripped!)
21748 </p><p>Taiwan is Taiwan.
21749 </p>
21750 !! html/parsoid
21751 <p>(This<meta typeof="mw:LanguageVariant" data-parsoid='{"tSp":[6]}' data-mw-variant='{"add":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/> should be stripped!)</p>
21752 <p>Taiwan is China.</p>
21753 !! end
21754
21755 !! test
21756 Explicit session-wise one-way language variant mapping (H flag for hide)
21757 !! options
21758 language=zh variant=zh-tw
21759 !! wikitext
21760 (This-{H|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- should be stripped!)
21761
21762 COUNTRY is Taiwan or China.
21763 !! html/php
21764 <p>(This should be stripped!)
21765 </p><p>Taiwan is Taiwan or China.
21766 </p>
21767 !! html/parsoid
21768 <p>(This<meta typeof="mw:LanguageVariant" data-parsoid='{"tSp":[8]}' data-mw-variant='{"add":true,"oneway":[{"f":"COUNTRY","l":"zh","t":"China"},{"f":"COUNTRY","l":"zh-tw","t":"Taiwan"}]}'/> should be stripped!)</p>
21769 <p>COUNTRY is Taiwan or China.</p>
21770 !! end
21771
21772 ## Note that parsoid test runner does not support 'showtitle' option.
21773 !! test
21774 Adding explicit conversion rule for title (T flag)
21775 !! options
21776 language=zh variant=zh-tw showtitle
21777 !! wikitext
21778 Should be stripped-{T|zh:China;zh-tw:Taiwan}-!
21779
21780 Taiwan is China.
21781 !! html/php
21782 Taiwan
21783 <p>Should be stripped!
21784 </p><p>Taiwan is China.
21785 </p>
21786 !! html/parsoid
21787 <p>Should be stripped<meta typeof="mw:LanguageVariant" data-parsoid='{"tSp":[6]}' data-mw-variant='{"title":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>!</p>
21788 <p>Taiwan is China.</p>
21789 !! end
21790
21791 !! test
21792 Code coverage: T combined with H flag
21793 !! options
21794 language=zh variant=zh-tw showtitle
21795 !! wikitext
21796 Should be stripped-{T;H|zh:China; zh-tw:Taiwan}-!
21797
21798 Taiwan is China.
21799 !! html/php
21800 Taiwan
21801 <p>Should be stripped!
21802 </p><p>Taiwan is Taiwan.
21803 </p>
21804 !! html/parsoid
21805 <p>Should be stripped<meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"title":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>!</p>
21806 <p>Taiwan is China.</p>
21807 !! end
21808
21809 !! test
21810 Code coverage: T with no variants
21811 !! options
21812 language=zh variant=zh-tw showtitle
21813 !! wikitext
21814 -{H|zh:China; zh-tw:Taiwan}-
21815 Taiwan is China.-{T|Taiwan is China}-
21816 !! html/php
21817 Taiwan is China
21818 <p>
21819 Taiwan is Taiwan.
21820 </p>
21821 !! html/parsoid
21822 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>
21823 Taiwan is China.<meta typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Taiwan is China"},"title":true}'/></p>
21824 !! end
21825
21826 !! test
21827 Code coverage: rules with no variants
21828 !! options
21829 language=zh variant=zh-tw
21830 !! wikitext
21831 -{H|zh:China; zh-tw:Taiwan}-
21832 Taiwan is China.
21833 -{H|China}-
21834 Taiwan is China.
21835 !! html/php
21836 <p>
21837 Taiwan is Taiwan.
21838
21839 Taiwan is China.
21840 </p>
21841 !! html/parsoid
21842 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>
21843 Taiwan is China.
21844 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"*","t":"China"}]}'/>
21845 Taiwan is China.</p>
21846 !! end
21847
21848
21849 !! test
21850 Code coverage: D flag for conversion rule
21851 !! options
21852 language=zh variant=zh-tw
21853 !! wikitext
21854 -{D|zh-cn:XA; zh-tw:YA}-
21855 -{A;D|zh-cn:XB; zh-tw:YB}-
21856 -{D;H|zh-cn:XC; zh-tw:YC}-
21857
21858 -{D;H|FOO=>zh-tw:BAR;FOO=>zh-cn:BAT}-
21859
21860 -{D|0=>zh-tw:1}-
21861 -{A;D|2=>zh-tw:3}-
21862 -{D;H|4=>zh-tw:5}-
21863
21864 XA XB XC YA YB YC FOO BAR BAT 012345
21865 !! html/php
21866 <p>大陆:XA;台灣:YA;
21867
21868 大陆:XC;台灣:YC;
21869 </p><p>FOO⇒台灣:BAR;FOO⇒大陆:BAT;
21870 </p><p>0⇒台灣:1;
21871
21872 4⇒台灣:5;
21873 </p><p>XA YB YC YA YB YC BAR BAR BAT 013355
21874 </p>
21875 !! html/parsoid
21876 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"describe":true,"twoway":[{"l":"zh-cn","t":"XA"},{"l":"zh-tw","t":"YA"}]}'></span>
21877 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"twoway":[{"l":"zh-cn","t":"XB"},{"l":"zh-tw","t":"YB"}]}'/>
21878 <span typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"twoway":[{"l":"zh-cn","t":"XC"},{"l":"zh-tw","t":"YC"}]}'></span></p>
21879 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"oneway":[{"f":"FOO","l":"zh-tw","t":"BAR"},{"f":"FOO","l":"zh-cn","t":"BAT"}]}'></span></p>
21880 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"describe":true,"oneway":[{"f":"0","l":"zh-tw","t":"1"}]}'></span>
21881 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"oneway":[{"f":"2","l":"zh-tw","t":"3"}]}'/>
21882 <span typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"oneway":[{"f":"4","l":"zh-tw","t":"5"}]}'></span></p>
21883 <p>XA XB XC YA YB YC FOO BAR BAT 012345</p>
21884 !! end
21885
21886 !! test
21887 Code coverage: N flag for conversion rule
21888 !! options
21889 language=zh variant=zh-cn
21890 !! wikitext
21891 -{N|zh-cn}-
21892
21893 -{N|zh-tw}-
21894
21895 -{N|sr-ec}-
21896 !! html/php
21897 <p>大陆
21898 </p><p>台灣
21899 </p><p>српски (ћирилица)‎
21900 </p>
21901 !! html/parsoid
21902 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"zh-cn"}}'></span></p>
21903 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"zh-tw"}}'></span></p>
21904 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"sr-ec"}}'></span></p>
21905 !! end
21906
21907 # html2wt suppresses the bogus 'D' flag, so this is wt2html only
21908 !! test
21909 Code coverage: N flag for conversion rule (wt2html only)
21910 !! options
21911 language=zh variant=zh-cn
21912 parsoid=wt2html,html2html
21913 !! wikitext
21914 -{D;N|en}-
21915 !! html/php
21916 <p>English
21917 </p>
21918 !! html/parsoid
21919 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"en"}}' data-parsoid='{"fl":["D","N"]}'></span></p>
21920 !! end
21921
21922 !! test
21923 Testing that changing the language variant here in the tests actually works
21924 !! options
21925 language=zh variant=zh showtitle
21926 !! wikitext
21927 Should be stripped-{T|zh:China; zh-tw:Taiwan}-!
21928 !! html/php
21929 China
21930 <p>Should be stripped!
21931 </p>
21932 !! html/parsoid
21933 <p>Should be stripped<meta typeof="mw:LanguageVariant" data-mw-variant='{"title":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>!</p>
21934 !! end
21935
21936 !! test
21937 Recursive conversion of alt and title attrs shouldn't clear converter state
21938 !! options
21939 language=zh variant=zh-cn
21940 showtitle
21941 !! wikitext
21942 -{H|zh-cn:Exclamation; zh-tw:exclamation}-
21943 Should be stripped-{T|zh-cn:China; zh-tw:Taiwan}-<span title="exclamation">!</span>
21944 !! html/php
21945 China
21946 <p>
21947 Should be stripped<span title="Exclamation">!</span>
21948 </p>
21949 !! html/parsoid
21950 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh-cn","t":"Exclamation"},{"l":"zh-tw","t":"exclamation"}]}'/>
21951 Should be stripped<meta typeof="mw:LanguageVariant" data-mw-variant='{"title":true,"twoway":[{"l":"zh-cn","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/><span title="exclamation">!</span></p>
21952 !! end
21953
21954 !! test
21955 T26072: more test on conversion rule for title
21956 !! options
21957 language=zh variant=zh-tw showtitle
21958 !! wikitext
21959 This should be stripped-{T|zh:China; zh-tw:Taiwan}-!
21960
21961 This won't take interferes with the title rule-{H|zh:Beijing; zh-tw:Taipei}-.
21962 !! html/php
21963 Taiwan
21964 <p>This should be stripped!
21965 </p><p>This won't take interferes with the title rule.
21966 </p>
21967 !! html/parsoid
21968 <p>This should be stripped<meta typeof="mw:LanguageVariant" data-mw-variant='{"title":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>!</p>
21969 <p>This won't take interferes with the title rule<meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh","t":"Beijing"},{"l":"zh-tw","t":"Taipei"}]}'/>.</p>
21970 !! end
21971
21972 !! test
21973 Partly disable title conversion if variant == main language code
21974 !! options
21975 language=zh variant=zh title=[[ZH]] showtitle
21976 !! wikitext
21977 -{T|zh-cn:CN;zh-tw:TW}-
21978 !! html/php
21979 ZH
21980 <p>
21981 </p>
21982 !! html/parsoid
21983 <p><meta typeof="mw:LanguageVariant" data-parsoid='{"tSp":[6]}' data-mw-variant='{"title":true,"twoway":[{"l":"zh-cn","t":"CN"},{"l":"zh-tw","t":"TW"}]}'/></p>
21984 !! end
21985
21986 !! test
21987 Partly disable title conversion if variant == main language code, more
21988 !! options
21989 language=zh variant=zh title=[[ZH]] showtitle
21990 !! wikitext
21991 -{T|TW}-
21992 !! html/php
21993 ZH
21994 <p>
21995 </p>
21996 !! html/parsoid
21997 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"TW"},"title":true}'/></p>
21998 !! end
21999
22000 !! test
22001 Raw output of variant escape tags (R flag)
22002 !! options
22003 language=zh variant=zh-tw
22004 !! wikitext
22005 Raw: -{R|zh:China;zh-tw:Taiwan}-
22006 !! html/php
22007 <p>Raw: zh:China;zh-tw:Taiwan
22008 </p>
22009 !! html/parsoid
22010 <p>Raw: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"zh:China;zh-tw:Taiwan"}}'></span></p>
22011 !! end
22012
22013 # html2wt suppresses the bogus 'D' flags, so this is wt2html only
22014 !! test
22015 Raw output of variant escape tags (R flag) (wt2html only)
22016 !! options
22017 language=zh variant=zh-tw
22018 parsoid=wt2html,html2html
22019 !! wikitext
22020 -{Variant}- -{D|syntax}- -{D;R|options}-
22021 !! html/php
22022 <p>Variant syntax options
22023 </p>
22024 !! html/parsoid
22025 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Variant"}}'></span> <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"syntax"}}'></span> <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"options"}}'></span></p>
22026 !! end
22027
22028 !! test
22029 Nested markup inside raw output of variant escape tags (R flag)
22030 !! options
22031 language=zh variant=zh-tw
22032 !! wikitext
22033 Nested raw: -{R|nested -{zh:China;zh-tw:Taiwan}- nested}-
22034 !! html/php
22035 <p>Nested raw: nested Taiwan nested
22036 </p>
22037 !! html/parsoid
22038 <p>Nested raw: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"nested &lt;span typeof=\"mw:LanguageVariant\" data-mw-variant=&#39;{\"twoway\":[{\"l\":\"zh\",\"t\":\"China\"},{\"l\":\"zh-tw\",\"t\":\"Taiwan\"}]}&#39; data-parsoid=&#39;{\"fl\":[],\"tSp\":[6],\"dsr\":[23,48,null,2]}&#39;>&lt;/span> nested"}}'></span></p>
22039 !! end
22040
22041 !! test
22042 Nested markup and spaces inside raw output of variant escape tags (R flag)
22043 !! options
22044 language=zh variant=zh-tw
22045 !! wikitext
22046 X-{ outer -{ inner }- outer }-X
22047 !! html/php
22048 <p>X outer inner outer X
22049 </p>
22050 !! html/parsoid
22051 <p>X<span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":" outer &lt;span typeof=\"mw:LanguageVariant\" data-mw-variant=&#39;{\"disabled\":{\"t\":\" inner \"}}&#39; data-parsoid=&#39;{\"fl\":[],\"dsr\":[10,21,null,2]}&#39;>&lt;/span> outer "}}'></span>X</p>
22052 !! end
22053
22054 !! test
22055 Templates inside raw output of variant escape tags (R flag)
22056 !! options
22057 language=zh variant=zh-tw
22058 !! wikitext
22059 Nested raw: -{R|nested {{echo|hi}} templates}-
22060 !! html/php
22061 <p>Nested raw: nested hi templates
22062 </p>
22063 !! html/parsoid
22064 <p>Nested raw: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"nested &lt;span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid=&#39;{\"pi\":[[{\"k\":\"1\"}]],\"dsr\":[23,34,null,null]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"hi\"}},\"i\":0}}]}&#39;>hi&lt;/span> templates"}}'></span></p>
22065 !! end
22066
22067 !! test
22068 Strings evaluating false shouldn't be ignored by Language converter (T51072)
22069 !! options
22070 language=zh variant=zh-cn
22071 !! input
22072 -{zh-cn:0;zh-sg:1;zh-tw:2;zh-hk:3}-
22073 !! html/php
22074 <p>0
22075 </p>
22076 !! html/parsoid
22077 <p><span typeof="mw:LanguageVariant" data-parsoid='{"tSp":[12]}' data-mw-variant='{"twoway":[{"l":"zh-cn","t":"0"},{"l":"zh-sg","t":"1"},{"l":"zh-tw","t":"2"},{"l":"zh-hk","t":"3"}]}'></span></p>
22078 !! end
22079
22080 !! test
22081 Conversion rules from [numeric-only string] to [something else] (T48634)
22082 !! options
22083 language=zh variant=zh-cn
22084 !! input
22085 -{H|0=>zh-cn:B}--{H|0=>zh-cn:C;0=>zh-cn:D}--{H|0=>zh-hans:A}-012345-{A|zh-tw:0;zh-cn:E;}-012345
22086 !! html/php
22087 <p>D12345EE12345
22088 </p>
22089 !! html/parsoid
22090 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"0","l":"zh-cn","t":"B"}]}'/><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"0","l":"zh-cn","t":"C"},{"f":"0","l":"zh-cn","t":"D"}]}'/><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"0","l":"zh-hans","t":"A"}]}'/>012345<span typeof="mw:LanguageVariant" data-parsoid='{"fl":["A"],"tSp":[7]}' data-mw-variant='{"add":true,"twoway":[{"l":"zh-tw","t":"0"},{"l":"zh-cn","t":"E"}]}'></span>012345</p>
22091 !! end
22092
22093 !! test
22094 Two-way converter rule entries with an empty value should be ignored (T53551)
22095 !! options
22096 language=zh variant=zh-cn
22097 !! input
22098 -{H|zh-cn:foo;zh-tw:;}-foobar
22099 !! html/php
22100 <p>foobar
22101 </p>
22102 !! html/parsoid
22103 <p><meta typeof="mw:LanguageVariant" data-parsoid='{"tSp":[7]}' data-mw-variant='{"add":true,"twoway":[{"l":"zh-cn","t":"foo"},{"l":"zh-tw","t":""}]}'/>foobar</p>
22104 !! end
22105
22106 !! test
22107 One-way converter rule entries with an empty "from" string should be ignored (T53551)
22108 !! options
22109 language=zh variant=zh-cn
22110 !! input
22111 -{H|=>zh-cn:foo;}-foobar
22112 !! html/php
22113 <p>foobar
22114 </p>
22115 !! html/parsoid
22116 <p><meta typeof="mw:LanguageVariant" data-parsoid='{"tSp":[5]}' data-mw-variant='{"add":true,"oneway":[{"f":"","l":"zh-cn","t":"foo"}]}'/>foobar</p>
22117 !! end
22118
22119 !! test
22120 Empty converter rule entries shouldn't be inserted into the conversion table (T53551)
22121 !! options
22122 language=zh variant=zh-cn
22123 !! input
22124 -{H|}-foobar
22125 !! html/php
22126 <p>foobar
22127 </p>
22128 !! html/parsoid
22129 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"*","t":""}]}'/>foobar</p>
22130 !! end
22131
22132 !! test
22133 Nested using of manual convert syntax
22134 !! options
22135 language=zh variant=zh-hk
22136 !! wikitext
22137 Nested: -{zh-hans:Hi -{zh-cn:China;zh-sg:Singapore;}-;zh-hant:Hello -{zh-tw:Taiwan;zh-hk:H-{ong}- K-{}-ong;}-;}-!
22138 !! html/php
22139 <p>Nested: Hello Hong Kong!
22140 </p>
22141 !! html/parsoid
22142 <p>Nested: <span typeof="mw:LanguageVariant" data-parsoid='{"tSp":[7]}' data-mw-variant='{"twoway":[{"l":"zh-hans","t":"Hi &lt;span typeof=\"mw:LanguageVariant\" data-mw-variant=&#39;{\"twoway\":[{\"l\":\"zh-cn\",\"t\":\"China\"},{\"l\":\"zh-sg\",\"t\":\"Singapore\"}]}&#39; data-parsoid=&#39;{\"fl\":[],\"tSp\":[7],\"dsr\":[21,53,null,2]}&#39;>&lt;/span>"},{"l":"zh-hant","t":"Hello &lt;span typeof=\"mw:LanguageVariant\" data-mw-variant=&#39;{\"twoway\":[{\"l\":\"zh-tw\",\"t\":\"Taiwan\"},{\"l\":\"zh-hk\",\"t\":\"H&amp;lt;span typeof=\\\"mw:LanguageVariant\\\" data-mw-variant=&amp;#39;{\\\"disabled\\\":{\\\"t\\\":\\\"ong\\\"}}&amp;#39; data-parsoid=&amp;#39;{\\\"fl\\\":[],\\\"dsr\\\":[90,97,null,2]}&amp;#39;>&amp;lt;/span> K&amp;lt;span typeof=\\\"mw:LanguageVariant\\\" data-mw-variant=&amp;#39;{\\\"disabled\\\":{\\\"t\\\":\\\"\\\"}}&amp;#39; data-parsoid=&amp;#39;{\\\"fl\\\":[],\\\"dsr\\\":[99,103,null,2]}&amp;#39;>&amp;lt;/span>ong\"}]}&#39; data-parsoid=&#39;{\"fl\":[],\"tSp\":[7],\"dsr\":[68,109,null,2]}&#39;>&lt;/span>"}]}'></span>!</p>
22143 !! end
22144
22145 !! test
22146 HTML markups with conversion syntax in attribs, nested in other conversion blocks
22147 !! options
22148 language=zh variant=zh-cn
22149 !! wikitext
22150 -{zh;zh-hans;zh-hant|<span title="-{X}-">A</span>}-
22151 !! html/php
22152 <p><span title="X">A</span>
22153 </p>
22154 !! html/parsoid
22155 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"filter":{"l":["zh","zh-hans","zh-hant"],"t":"&lt;span title=\"\" about=\"#mwt1\" typeof=\"mw:ExpandedAttrs\" data-parsoid=&#39;{\"stx\":\"html\",\"a\":{\"title\":\"\"},\"sa\":{\"title\":\"-{X}-\"},\"dsr\":[21,49,20,7]}&#39; data-mw=&#39;{\"attribs\":[[{\"txt\":\"title\"},{\"html\":\"&amp;lt;span typeof=\\\"mw:LanguageVariant\\\" data-mw-variant=&amp;#39;{\\\"disabled\\\":{\\\"t\\\":\\\"X\\\"}}&amp;#39; data-parsoid=&amp;#39;{\\\"fl\\\":[],\\\"dsr\\\":[34,39,null,2]}&amp;#39;>&amp;lt;/span>\"}]]}&#39;>A&lt;/span>"}}'></span></p>
22156 !! end
22157
22158 !! test
22159 HTML markups with conversion syntax in attribs, nested in other conversion blocks (not working yet in PHP parser)
22160 !! options
22161 language=zh variant=zh-cn
22162 !! wikitext
22163 -{<span title="-{X}-">A</span>}-
22164 !! html/php+disabled
22165 <p><span title="X">A</span>
22166 </p>
22167 !! html/parsoid
22168 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"&lt;span title=\"\" about=\"#mwt1\" typeof=\"mw:ExpandedAttrs\" data-parsoid=&#39;{\"stx\":\"html\",\"a\":{\"title\":\"\"},\"sa\":{\"title\":\"-{X}-\"},\"dsr\":[2,30,20,7]}&#39; data-mw=&#39;{\"attribs\":[[{\"txt\":\"title\"},{\"html\":\"&amp;lt;span typeof=\\\"mw:LanguageVariant\\\" data-mw-variant=&amp;#39;{\\\"disabled\\\":{\\\"t\\\":\\\"X\\\"}}&amp;#39; data-parsoid=&amp;#39;{\\\"fl\\\":[],\\\"dsr\\\":[15,20,null,2]}&amp;#39;>&amp;lt;/span>\"}]]}&#39;>A&lt;/span>"}}'></span></p>
22169 !! end
22170
22171 # Parsoid and PHP disagree on how to parse this example: Parsoid
22172 # insists that the content of a language converter element be a valid
22173 # DOM fragment or attribute string
22174 !! test
22175 Language converter markup with block content
22176 !! options
22177 language=zh variant=zh-cn
22178 !! wikitext
22179 <span>a-{b<div>c}-d
22180
22181 <span>a-{zh;zh-hans;zh-hant|b<div>c}-d
22182
22183 <span>a-{H|0=>zh-cn:x<span>y;0=>zh-tw:b<div>c}-d
22184 !! html/php+tidy
22185 <p><span>ab</span></p>
22186 <div><span>cd <span>ab</span></span>
22187 <div><span>cd <span>ad</span></span></div>
22188 </div>
22189 !! html/parsoid
22190 <p><span data-parsoid='{"stx":"html","autoInsertedEnd":true}'>a</span></p><div typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"b&lt;div data-parsoid=&#39;{\"stx\":\"html\",\"autoInsertedEnd\":true,\"dsr\":[10,16,5,0]}&#39;>c&lt;/div>"}}'></div><p>d</p>
22191
22192 <p><span data-parsoid='{"stx":"html","autoInsertedEnd":true}'>a</span></p><div typeof="mw:LanguageVariant" data-mw-variant='{"filter":{"l":["zh","zh-hans","zh-hant"],"t":"b&lt;div data-parsoid=&#39;{\"stx\":\"html\",\"autoInsertedEnd\":true,\"dsr\":[50,56,5,0]}&#39;>c&lt;/div>"}}'></div><p>d</p>
22193
22194 <p><span data-parsoid='{"stx":"html","autoInsertedEnd":true}'>a<meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"0","l":"zh-cn","t":"x&lt;span data-parsoid=&#39;{\"stx\":\"html\",\"autoInsertedEnd\":true,\"dsr\":[82,89,6,0]}&#39;>y&lt;/span>"},{"f":"0","l":"zh-tw","t":"b&lt;div data-parsoid=&#39;{\"stx\":\"html\",\"autoInsertedEnd\":true,\"dsr\":[100,106,5,0]}&#39;>c&lt;/div>"}]}'/>d</span></p>
22195 !! end
22196
22197 !! test
22198 LanguageConverter selser (1)
22199 !! options
22200 language=zh variant=zh-cn
22201 parsoid={
22202 "modes": ["wt2wt", "selser"],
22203 "changes": [
22204 ["span[typeof]", "attr", "data-mw-variant", "{\"disabled\":{\"t\":\"edited\"}}"]
22205 ]
22206 }
22207 !! wikitext
22208 -{raw}-
22209 !! wikitext/edited
22210 -{edited}-
22211 !! end
22212
22213 !! test
22214 LanguageConverter selser (2)
22215 !! options
22216 language=zh variant=zh-cn
22217 parsoid={
22218 "modes": ["wt2wt", "selser"],
22219 "changes": [
22220 ["span[class='x']", "contents", "text", "-{foo}-"],
22221 ["a", "contents", "text", "-{"],
22222 ["span[typeof]", "attr", "data-mw", "{\"parts\":[{\"template\":{\"target\":{\"wt\":\"1x\",\"href\":\"./Template:1x\"},\"params\":{\"1\":{\"wt\":\"-{\"}},\"i\":0}}]}"]
22223 ]
22224 }
22225 !! wikitext
22226 <span class="x">TEXT1</span>
22227 [http://example.com TEXT2]
22228 [[Foo|TEXT3]]
22229 {{echo|TEXT4}}
22230 !! wikitext/edited
22231 <span class="x"><nowiki>-{foo}-</nowiki></span>
22232 [http://example.com -{]
22233 [[Foo|<nowiki>-{</nowiki>]]
22234 {{1x|<nowiki>-{</nowiki>}}
22235 !! end
22236
22237 # Tests LanguageVariantText in ConstrainedText
22238 !! test
22239 LanguageConverter selser (3)
22240 !! options
22241 language=zh variant=zh-cn
22242 parsoid={
22243 "modes": ["wt2wt", "selser"],
22244 "changes": [
22245 ["td > span", "attr", "typeof", "mw:LanguageVariant"],
22246 ["td > span", "attr", "data-mw-variant", "{\"disabled\":{\"t\":\"edited\"}}"]
22247 ]
22248 }
22249 !! wikitext
22250 {|
22251 |-
22252 |<span>Foo</span>
22253 |}
22254 !! wikitext/edited
22255 {|
22256 |-
22257 |<nowiki/>-{edited}-
22258 |}
22259 !! end
22260
22261 # Tests LanguageVariantText._fromSelser
22262 !! test
22263 LanguageConverter selser (4)
22264 !! options
22265 language=zh variant=zh-cn
22266 parsoid={
22267 "modes": ["wt2wt", "selser"],
22268 "changes": [
22269 ["td > span.x", "remove"]
22270 ]
22271 }
22272 !! wikitext
22273 {|
22274 |-
22275 |<span class="x">Foo</span>-{Bar}-
22276 ||<span class="x">Foo</span>-{Bar}-
22277 |}
22278 !! wikitext/edited
22279 {|
22280 |-
22281 |<nowiki/>-{Bar}-
22282 ||-{Bar}-
22283 |}
22284 !! end
22285
22286 # Since Parsoid is starting to emit canonical wikitext for links,
22287 # [http://example.com http://example.com] will not RT back to that
22288 # form anymore.
22289 # Parsoid does not language-convert links (it is done in a
22290 # post-processing step)
22291 !! test
22292 Proper conversion of text in external links
22293 !! options
22294 language=sr variant=sr-ec
22295 parsoid=wt2html
22296 !! wikitext
22297 http://www.google.com
22298 gopher://www.google.com
22299 [http://www.google.com http://www.google.com]
22300 [gopher://www.google.com gopher://www.google.com]
22301 [https://www.google.com irc://www.google.com]
22302 [ftp://www.google.com www.google.com/ftp://dir]
22303 [//www.google.com www.google.com]
22304 !! html/php
22305 <p><a rel="nofollow" class="external free" href="http://www.google.com">http://www.google.com</a>
22306 <a rel="nofollow" class="external free" href="gopher://www.google.com">gopher://www.google.com</a>
22307 <a rel="nofollow" class="external free" href="http://www.google.com">http://www.google.com</a>
22308 <a rel="nofollow" class="external free" href="gopher://www.google.com">gopher://www.google.com</a>
22309 <a rel="nofollow" class="external text" href="https://www.google.com">irc://www.google.com</a>
22310 <a rel="nofollow" class="external text" href="ftp://www.google.com">www.гоогле.цом/фтп://дир</a>
22311 <a rel="nofollow" class="external text" href="//www.google.com">www.гоогле.цом</a>
22312 </p>
22313 !! html/parsoid
22314 <p><a rel="mw:ExtLink" href="http://www.google.com">http://www.google.com</a>
22315 <a rel="mw:ExtLink" href="gopher://www.google.com">gopher://www.google.com</a>
22316 <a rel="mw:ExtLink" href="http://www.google.com">http://www.google.com</a>
22317 <a rel="mw:ExtLink" href="gopher://www.google.com">gopher://www.google.com</a>
22318 <a rel="mw:ExtLink" href="https://www.google.com">irc://www.google.com</a>
22319 <a rel="mw:ExtLink" href="ftp://www.google.com">www.google.com/ftp://dir</a>
22320 <a rel="mw:ExtLink" href="//www.google.com">www.google.com</a></p>
22321 !! end
22322
22323 !! test
22324 Do not convert roman numbers to language variants
22325 !! options
22326 language=sr variant=sr-ec
22327 !! wikitext
22328 Fridrih IV je car.
22329 !! html/php
22330 <p>Фридрих IV је цар.
22331 </p>
22332 !! html/parsoid
22333 <p>Fridrih IV je car.</p>
22334 !! end
22335
22336 !! test
22337 Unclosed language converter markup "-{"
22338 !! options
22339 language=sr
22340 !! wikitext
22341 -{T|hello
22342 !! html
22343 <p>-{T|hello
22344 </p>
22345 !! end
22346
22347 !! test
22348 Don't convert raw rule "-{R|=&gt;}-" to "=>"
22349 !! options
22350 language=sr
22351 !! wikitext
22352 -{R|=&gt;}-
22353 !! html/php
22354 <p>=&gt;
22355 </p>
22356 !! html/parsoid
22357 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"=&lt;span typeof=\"mw:Entity\" data-parsoid=&#39;{\"src\":\"&amp;amp;gt;\",\"srcContent\":\">\",\"dsr\":[5,9,null,null]}&#39;>>&lt;/span>"}}'></span></p>
22358 !!end
22359
22360 !! test
22361 Don't break link parsing if language converter markup is in the caption.
22362 !! options
22363 language=sr variant=sr-ec
22364 !! wikitext
22365 [[Main Page|-{R|main page}-]]
22366 !! html/php
22367 <p><a href="/wiki/Main_Page" title="Маин Паге">main page</a>
22368 </p>
22369 !! html/parsoid
22370 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page"><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"main page"}}' data-parsoid='{"fl":["R"]}'></span></a></p>
22371 !! end
22372
22373 !! test
22374 T146304: Don't break template parsing if language converter markup is in the parameter.
22375 !! options
22376 language=sr variant=sr-ec
22377 !! wikitext
22378 {{echo|-{R|foo}-}}
22379 !! html/php
22380 <p>foo
22381 </p>
22382 !! html/parsoid
22383 <p><span typeof="mw:Transclusion mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"foo"}}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Шаблон:Echo"},"params":{"1":{"wt":"-{R|foo}-"}},"i":0}}]}'></span></p>
22384 !! end
22385
22386 !! test
22387 T146305: Don't break image parsing if language converter markup is in the caption.
22388 !! options
22389 language=sr
22390 !! wikitext
22391 [[Датотека:Foobar.jpg|thumb|-{R|caption:}-]]
22392 !! html/php
22393 <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/%D0%94%D0%B0%D1%82%D0%BE%D1%82%D0%B5%D0%BA%D0%B0:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/%D0%94%D0%B0%D1%82%D0%BE%D1%82%D0%B5%D0%BA%D0%B0:Foobar.jpg" class="internal" title="Повећај"></a></div>caption:</div></div></div>
22394
22395 !! html/parsoid
22396 <figure class="mw-default-size" typeof="mw:Image/Thumb" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"}]}'><a href="./Датотека:Foobar.jpg"><img resource="./Датотека:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"caption:"}}' data-parsoid='{"fl":["R"]}'></span></figcaption></figure>
22397 !! end
22398
22399 !! test
22400 T146305: Don't break image parsing if nested language converter markup is in the caption.
22401 !! options
22402 language=zh variant=zh-cn
22403 !! wikitext
22404 [[File:Foobar.jpg|thumb|-{|zh-cn:blog (hk: -{zh-hans|WEBJOURNAL}-, tw: -{zh-hans|WEBLOG}-)}-]]
22405 !! html/php
22406 <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="放大"></a></div>blog (hk: WEBJOURNAL, tw: WEBLOG)</div></div></div>
22407
22408 !! html/parsoid
22409 <figure class="mw-default-size" typeof="mw:Image/Thumb" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"}]}'><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption><span typeof="mw:LanguageVariant" data-mw-variant='{"twoway":[{"l":"zh-cn","t":"blog (hk: &lt;span typeof=\"mw:LanguageVariant\" data-mw-variant=&#39;{\"filter\":{\"l\":[\"zh-hans\"],\"t\":\"WEBJOURNAL\"}}&#39; data-parsoid=&#39;{\"fl\":[\"zh-hans\"],\"dsr\":[43,65,null,2]}&#39;>&lt;/span>, tw: &lt;span typeof=\"mw:LanguageVariant\" data-mw-variant=&#39;{\"filter\":{\"l\":[\"zh-hans\"],\"t\":\"WEBLOG\"}}&#39; data-parsoid=&#39;{\"fl\":[\"zh-hans\"],\"dsr\":[71,89,null,2]}&#39;>&lt;/span>)"}]}'></span></figcaption></figure>
22410 !! end
22411
22412 # XXX html2wt disabled because rich markup in alt is not preserved.
22413 !! test
22414 Don't break gallery if language converter markup is inside.
22415 !! options
22416 language=zh
22417 !! wikitext
22418 <gallery>
22419 File:foobar.jpg|[[File:foobar.jpg|20px|desc|alt=-{R|foo}-|-{R|bar}-]]|alt=-{R|bat}-
22420 File:foobar.jpg|{{Test|unamedParam|alt=-{R|param}-}}|alt=galleryalt
22421 </gallery>
22422 !! html/php
22423 <ul class="gallery mw-gallery-traditional">
22424 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
22425 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="bat" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
22426 <div class="gallerytext">
22427 <p><a href="/wiki/File:Foobar.jpg" class="image" title="bar"><img alt="foo" src="http://example.com/images/thumb/3/3a/Foobar.jpg/20px-Foobar.jpg" width="20" height="2" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/30px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/40px-Foobar.jpg 2x" /></a>
22428 </p>
22429 </div>
22430 </div></li>
22431 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
22432 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="galleryalt" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
22433 <div class="gallerytext">
22434 <p>This is a test template
22435 </p>
22436 </div>
22437 </div></li>
22438 </ul>
22439
22440 !! html/parsoid
22441 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" data-mw='{"name":"gallery","attrs":{},"body":{"extsrc":"\nFile:foobar.jpg|[[File:foobar.jpg|20px|desc|alt=-{R|foo}-|-{R|bar}-]]|alt=-{R|bat}-\nFile:foobar.jpg|{{Test|unamedParam|alt=-{R|param}-}}|alt=galleryalt\n"}}'>
22442 <li class="gallerybox">
22443 <div class="thumb"><span typeof="mw:Image"><a href="./File:Foobar.jpg"><img alt="" resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></span></div>
22444 <div class="gallerytext"><span typeof="mw:Image" data-mw='{"caption":"&lt;span typeof=\"mw:LanguageVariant\" data-mw-variant=&#39;{\"disabled\":{\"t\":\"bar\"}}&#39; data-parsoid=&#39;{\"fl\":[\"R\"],\"dsr\":[68,77,null,2]}&#39;>&lt;/span>"}'><a href="./File:Foobar.jpg"><img alt="" resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/20px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="2" width="20"/></a></span></div>
22445 </li>
22446 <li class="gallerybox">
22447 <div class="thumb"><span typeof="mw:Image"><a href="./File:Foobar.jpg"><img alt="galleryalt" resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></span></div>
22448 <div class="gallerytext"><span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"Test","href":"./Template:Test"},"params":{"1":{"wt":"unamedParam"},"alt":{"wt":"-{R|param}-"}},"i":0}}]}'>This is a test template</span></div>
22449 </li>
22450 </ul>
22451 !! end
22452
22453 !! test
22454 T153135: Don't break list handling if language converter markup is in the item.
22455 !! options
22456 language=zh variant=zh-cn
22457 !! wikitext
22458 ;-{zh-cn:AAA;zh-tw:BBB}-
22459 ;-{R|foo:bar}-
22460 !! html/php
22461 <dl><dt>AAA</dt>
22462 <dt>foo:bar</dt></dl>
22463
22464 !! html/parsoid
22465 <dl><dt data-parsoid='{"dsr":[0,24,1,0]}'><span typeof="mw:LanguageVariant" data-parsoid='{"tSp":[6]}' data-mw-variant='{"twoway":[{"l":"zh-cn","t":"AAA"},{"l":"zh-tw","t":"BBB"}]}'></span></dt>
22466 <dt data-parsoid='{"dsr":[25,39,1,0]}'><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"foo:bar"}}'></span></dt>
22467 </dl>
22468 !! end
22469
22470 // Note that parsoid does not protect colons unless language converter
22471 // markup is properly nested, because it is a backtracking parser.
22472 !! test
22473 T153135: Unclosed markup in definition list (code coverage)
22474 !! options
22475 language=zh variant=zh-cn
22476 !! wikitext
22477 ;<b>foo:bar
22478 ;-{zh-cn:AAA
22479 !! html/php+tidy
22480 <dl>
22481 <dt><b>foo:bar</b></dt>
22482 <dt><b>-{zh-cn:AAA</b></dt>
22483 </dl>
22484 !! html/parsoid
22485 <dl><dt data-parsoid='{"dsr":[0,11,1,0]}'><b data-parsoid='{"stx":"html","autoInsertedEnd":true}'>foo:bar</b></dt><b data-parsoid='{"stx":"html","autoInsertedEnd":true,"autoInsertedStart":true}'>
22486 <dt data-parsoid='{"dsr":[12,20,1,0]}'>-{zh-cn</dt>
22487 <dd data-parsoid='{"stx":"row","dsr":[20,24,1,0]}'>AAA</dd>
22488 </b></dl>
22489 !! end
22490
22491 !! test
22492 T153135: Nested language converter markup in definition list (code coverage)
22493 !! options
22494 language=zh variant=zh-cn
22495 !! wikitext
22496 ;-{|zh-cn:AAA -{zh-hans|foo:bar}- -{R|bat:baz}-}-:def
22497 !! html/php
22498 <dl><dt>AAA foo:bar bat:baz</dt>
22499 <dd>def</dd></dl>
22500
22501 !! html/parsoid
22502 <dl><dt data-parsoid='{"dsr":[0,49,1,0]}'><span typeof="mw:LanguageVariant" data-mw-variant='{"twoway":[{"l":"zh-cn","t":"AAA &lt;span typeof=\"mw:LanguageVariant\" data-mw-variant=&#39;{\"filter\":{\"l\":[\"zh-hans\"],\"t\":\"foo:bar\"}}&#39; data-parsoid=&#39;{\"fl\":[\"zh-hans\"],\"dsr\":[14,33,null,2]}&#39;>&lt;/span> &lt;span typeof=\"mw:LanguageVariant\" data-mw-variant=&#39;{\"disabled\":{\"t\":\"bat:baz\"}}&#39; data-parsoid=&#39;{\"fl\":[\"R\"],\"dsr\":[34,47,null,2]}&#39;>&lt;/span>"}]}'></span></dt>
22503 <dd data-parsoid='{"stx":"row","dsr":[49,53,1,0]}'>def</dd>
22504 </dl>
22505 !! end
22506
22507 # html2wt mode disabled due to <nowiki> insertion.
22508 !! test
22509 T153140: Don't break table handling if language converter markup is in the cell.
22510 !! options
22511 language=sr variant=sr-ec
22512 parsoid=wt2html,wt2wt,html2html
22513 !! wikitext
22514 {|
22515 |-
22516 | -{R|B}-
22517 |}
22518 !! html/php
22519 <table>
22520
22521 <tr>
22522 <td> B
22523 </td></tr></table>
22524
22525 !! html/parsoid
22526 <table>
22527 <tbody>
22528 <tr>
22529 <td><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"B"}}'></span></td>
22530 </tr>
22531 </tbody>
22532 </table>
22533 !! end
22534
22535 !! test
22536 Language converter tricky html2wt cases (1)
22537 !! options
22538 language=sr
22539 parsoid=html2wt,wt2wt
22540 !! html/parsoid
22541 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"}-"}}'></span></p>
22542 !! wikitext
22543 -{<nowiki>}-</nowiki>}-
22544 !! html/php
22545 <p>&#125;-
22546 </p>
22547 !! end
22548
22549 !! test
22550 Language converter tricky html2wt cases (2)
22551 !! options
22552 language=sr
22553 parsoid=html2wt,wt2wt
22554 !! html/parsoid
22555 <p>-{foo}-</p>
22556 !! wikitext
22557 <nowiki>-{foo}-</nowiki>
22558 !! html/php
22559 <p>-&#123;foo&#125;-
22560 </p>
22561 !! end
22562
22563 !! test
22564 Language converter tricky html2wt cases (3)
22565 !! options
22566 language=sr
22567 parsoid=html2wt,wt2wt
22568 !! html/parsoid
22569 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"|"}}'></span></p>
22570 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"R|raw"}}'></span></p>
22571 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"-{foo}-"}}'></span></p>
22572 !! wikitext
22573 -{R||}-
22574
22575 -{R|R|raw}-
22576
22577 -{<nowiki>-{foo}-</nowiki>}-
22578 !! html/php
22579 <p>|
22580 </p><p>R|raw
22581 </p><p>-&#123;foo&#125;-
22582 </p>
22583 !! end
22584
22585 !! test
22586 Language converter tricky html2wt cases (4)
22587 !! options
22588 language=sr
22589 parsoid=html2wt,wt2wt
22590 !! html/parsoid
22591 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"&lt;span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid=&#39;{\"pi\":[[{\"k\":\"1\"}]],\"dsr\":[2,14,null,null]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"hey\"}},\"i\":0}}]}&#39;>hey&lt;/span>"}}'></span></p>
22592 !! wikitext
22593 -{R|{{echo|hey}}}-
22594 !! html/php
22595 <p>hey
22596 </p>
22597 !! end
22598
22599 # Note that the <nowiki> escaping added by parsoid for source text,
22600 # destination text, and language names only works on the PHP side
22601 # for *destination text*. (HTML entity escaping wouldn't work
22602 # any better.) This is probably a bug, at least for source texts.
22603 # (For language names PHP uses a precise regexp based on the languages
22604 # it currently knows have variants, which is fragile since this set
22605 # can grow/shrink over time.)
22606 !! test
22607 Language converter tricky html2wt cases (5)
22608 !! options
22609 language=zh variant=zh-cn
22610 !! html/parsoid
22611 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"a:b=>c","l":"zh-cn","t":"x;foo=>zh-cn:boo"},{"f":"bar","l":"zh-cn","t":"bat;xyz=>zh-cn:abc"}]}'/>foobar</p>
22612 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"A","l":"bo:g;us","t":"B"}]}'/></p>
22613 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh-tw","t":"xyz"},{"l":"zh-cn","t":"0;zh-tw:bar"}]}'></span></p>
22614 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"twoway":[{"l":"bo:g;us","t":"xyz"},{"l":"zh-cn","t":"abc"}]}'></span></p>
22615 <p>a:b=>c xyz</p>
22616 !! wikitext
22617 -{H|<nowiki>a:b=>c</nowiki>=>zh-cn:<nowiki>x;foo=>zh-cn:boo</nowiki>;bar=>zh-cn:<nowiki>bat;xyz=>zh-cn:abc</nowiki>}-foobar
22618
22619 -{H|A=><nowiki>bo:g;us</nowiki>:B}-
22620
22621 -{A|zh-tw:xyz; zh-cn:<nowiki>0;zh-tw:bar</nowiki>}-
22622
22623 -{<nowiki>bo:g;us</nowiki>:xyz; zh-cn:abc}-
22624
22625 a:b=>c xyz
22626 !! html/php+disabled
22627 <p>foobat;xyz=&gt;zh-cn:abc
22628 </p><p>A
22629 </p><p>0;zh-tw:bar
22630 </p><p>abc
22631 </p><p>a:b=&gt;c 0;zh-tw:bar
22632 </p>
22633 !! end
22634
22635 !! test
22636 T2529: Uncovered bullet
22637 !! wikitext
22638 * Foo {{bullet}}
22639 !! html
22640 <ul><li> Foo </li>
22641 <li> Bar</li></ul>
22642
22643 !! end
22644
22645 # Plain MediaWiki does not remove empty lists, but tidy actually does.
22646 # Templates in Wikipedia rely on this behavior, as tidy has always been
22647 # enabled there. These tests are normally run *without* tidy, so specify the
22648 # full output here.
22649 # To test realistic parsing behavior, apply a tidy-like transformation to both
22650 # the expected output and your parser's output.
22651 !! test
22652 T2529: Uncovered bullet leaving empty list, normally removed by tidy
22653 !! wikitext
22654 ******* Foo {{bullet}}
22655 !! html
22656 <ul><li><ul><li><ul><li><ul><li><ul><li><ul><li><ul><li> Foo </li></ul></li></ul></li></ul></li></ul></li></ul></li></ul></li>
22657 <li> Bar</li></ul>
22658
22659 !! end
22660
22661 !! test
22662 T2529: Uncovered table already at line-start
22663 !! wikitext
22664 x
22665
22666 {{table}}
22667 y
22668 !! html
22669 <p>x
22670 </p>
22671 <table>
22672 <tr>
22673 <td> 1 </td>
22674 <td> 2
22675 </td></tr>
22676 <tr>
22677 <td> 3 </td>
22678 <td> 4
22679 </td></tr></table>
22680 <p>y
22681 </p>
22682 !! end
22683
22684 !! test
22685 T2529: Uncovered bullet in parser function result
22686 !! wikitext
22687 * Foo {{lc:{{bullet}} }}
22688 !! html
22689 <ul><li> Foo </li>
22690 <li> bar</li></ul>
22691
22692 !! end
22693
22694 !! test
22695 T7678: Double-parsed template argument
22696 !! wikitext
22697 {{lc:{{{1}}}|hello}}
22698 !! html
22699 <p>{{{1}}}
22700 </p>
22701 !! end
22702
22703 !! test
22704 T7678: Double-parsed template invocation
22705 !! wikitext
22706 {{lc:{{paramtest {{!}} param = hello }} }}
22707 !! html
22708 <p>{{paramtest | param = hello }}
22709 </p>
22710 !! end
22711
22712 !! test
22713 Case insensitivity of parser functions for non-ASCII characters (T10143)
22714 !! options
22715 language=cs
22716 title=[[Main Page]]
22717 !! wikitext
22718 {{PRVNÍVELKÉ:ěščř}}
22719 {{prvnívelké:ěščř}}
22720 {{PRVNÍMALÉ:ěščř}}
22721 {{prvnímalé:ěščř}}
22722 {{MALÁ:ěščř}}
22723 {{malá:ěščř}}
22724 {{VELKÁ:ěščř}}
22725 {{velká:ěščř}}
22726 !! html
22727 <p>Ěščř
22728 Ěščř
22729 ěščř
22730 ěščř
22731 ěščř
22732 ěščř
22733 ĚŠČŘ
22734 ĚŠČŘ
22735 </p>
22736 !! end
22737
22738 !! test
22739 Morwen/13: Unclosed link followed by heading
22740 !! wikitext
22741 [[link
22742 ==heading==
22743 !! html
22744 <p>[[link
22745 </p>
22746 <h2><span class="mw-headline" id="heading">heading</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: heading">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
22747
22748 !! end
22749
22750 !! test
22751 HHP2.1: Heuristics for headings in preprocessor parenthetical structures
22752 !! wikitext
22753 {{foo|
22754 =heading=
22755 !! html
22756 <p>{{foo|
22757 </p>
22758 <h1><span class="mw-headline" id="heading">heading</span></h1>
22759
22760 !! end
22761
22762 !! test
22763 HHP2.2: Heuristics for headings in preprocessor parenthetical structures
22764 !! wikitext
22765 {{foo|
22766 ==heading==
22767 !! html
22768 <p>{{foo|
22769 </p>
22770 <h2><span class="mw-headline" id="heading">heading</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: heading">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
22771
22772 !! end
22773
22774 !! test
22775 Tildes in comments
22776 !! options
22777 pst
22778 !! wikitext
22779 <!-- ~~~~ -->
22780 !! html/php
22781 <!-- ~~~~ -->
22782 !! end
22783
22784 !! test
22785 Paragraphs inside divs (no extra line breaks)
22786 !! wikitext
22787 <div>Line one
22788
22789 Line two</div>
22790 !! html
22791 <div>Line one
22792 Line two</div>
22793
22794 !! end
22795
22796 !! test
22797 Paragraphs inside divs (extra line break on open)
22798 !! wikitext
22799 <div>
22800 Line one
22801
22802 Line two</div>
22803 !! html
22804 <div>
22805 <p>Line one
22806 </p>
22807 Line two</div>
22808
22809 !! end
22810
22811 !! test
22812 Paragraphs inside divs (extra line break on close)
22813 !! wikitext
22814 <div>Line one
22815
22816 Line two
22817 </div>
22818 !! html
22819 <div>Line one
22820 <p>Line two
22821 </p>
22822 </div>
22823
22824 !! end
22825
22826 !! test
22827 Paragraphs inside divs (extra line break on open and close)
22828 !! wikitext
22829 <div>
22830 Line one
22831
22832 Line two
22833 </div>
22834 !! html
22835 <div>
22836 <p>Line one
22837 </p><p>Line two
22838 </p>
22839 </div>
22840
22841 !! end
22842
22843 !! test
22844 Nesting tags, paragraphs on lines which begin with <div>
22845 !! wikitext
22846 <div></div><strong>A
22847 B</strong>
22848 !! html/php+tidy
22849 <p><strong>A</strong></p>
22850 <p><strong>B</strong></p>
22851 !! html/parsoid
22852 <div></div>
22853 <p><strong>A
22854 B</strong>
22855 </p>
22856 !! end
22857
22858 # T8200: <blockquote> should behave like <div> with respect to line breaks
22859 !! test
22860 T8200: paragraphs inside blockquotes (no extra line breaks)
22861 !! wikitext
22862 <blockquote>Line one
22863
22864 Line two</blockquote>
22865 !! html
22866 <blockquote>Line one
22867 Line two</blockquote>
22868
22869 !! html+tidy
22870 <blockquote>
22871 <p>Line one Line two</p>
22872 </blockquote>
22873 !! end
22874
22875 !! test
22876 T8200: paragraphs inside blockquotes (extra line break on open)
22877 !! wikitext
22878 <blockquote>
22879 Line one
22880
22881 Line two</blockquote>
22882 !! html
22883 <blockquote>
22884 <p>Line one
22885 </p>
22886 Line two</blockquote>
22887
22888 !! html+tidy
22889 <blockquote>
22890 <p>Line one</p>
22891 Line two</blockquote>
22892 !! end
22893
22894 !! test
22895 T8200: paragraphs inside blockquotes (extra line break on close)
22896 !! wikitext
22897 <blockquote>Line one
22898
22899 Line two
22900 </blockquote>
22901 !! html
22902 <blockquote>Line one
22903 <p>Line two
22904 </p>
22905 </blockquote>
22906
22907 !! html+tidy
22908 <blockquote>
22909 <p>Line one</p>
22910 <p>Line two</p>
22911 </blockquote>
22912 !! end
22913
22914 !! test
22915 T8200: paragraphs inside blockquotes (extra line break on open and close)
22916 !! wikitext
22917 <blockquote>
22918 Line one
22919
22920 Line two
22921 </blockquote>
22922 !! html
22923 <blockquote>
22924 <p>Line one
22925 </p><p>Line two
22926 </p>
22927 </blockquote>
22928
22929 !! html+tidy
22930 <blockquote>
22931 <p>Line one</p>
22932 <p>Line two</p>
22933 </blockquote>
22934 !! end
22935
22936 !! test
22937 Paragraphs inside blockquotes/divs (no extra line breaks)
22938 !! wikitext
22939 <blockquote><div>Line one
22940
22941 Line two</div></blockquote>
22942 !! html
22943 <blockquote><div>Line one
22944 Line two</div></blockquote>
22945
22946 !! end
22947
22948 !! test
22949 Paragraphs inside blockquotes/divs (extra line break on open)
22950 !! wikitext
22951 <blockquote><div>
22952 Line one
22953
22954 Line two</div></blockquote>
22955 !! html
22956 <blockquote><div>
22957 <p>Line one
22958 </p>
22959 Line two</div></blockquote>
22960
22961 !! end
22962
22963 !! test
22964 Paragraphs inside blockquotes/divs (extra line break on close)
22965 !! wikitext
22966 <blockquote><div>Line one
22967
22968 Line two
22969 </div></blockquote>
22970 !! html
22971 <blockquote><div>Line one
22972 <p>Line two
22973 </p>
22974 </div></blockquote>
22975
22976 !! end
22977
22978 !! test
22979 Paragraphs inside blockquotes/divs (extra line break on open and close)
22980 !! wikitext
22981 <blockquote><div>
22982 Line one
22983
22984 Line two
22985 </div></blockquote>
22986 !! html
22987 <blockquote><div>
22988 <p>Line one
22989 </p><p>Line two
22990 </p>
22991 </div></blockquote>
22992
22993 !! end
22994
22995 !! test
22996 Interwiki links trounced by replaceExternalLinks after early LinkHolderArray expansion
22997 !! options
22998 wgLinkHolderBatchSize=0
22999 !! wikitext
23000 [[meatball:1]]
23001 [[meatball:2]]
23002 [[meatball:3]]
23003 !! html
23004 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?1" class="extiw" title="meatball:1">meatball:1</a>
23005 <a href="http://www.usemod.com/cgi-bin/mb.pl?2" class="extiw" title="meatball:2">meatball:2</a>
23006 <a href="http://www.usemod.com/cgi-bin/mb.pl?3" class="extiw" title="meatball:3">meatball:3</a>
23007 </p>
23008 !! end
23009
23010 !! test
23011 Free external link invading image caption
23012 !! wikitext
23013 [[Image:Foobar.jpg|thumb|http://x|hello]]
23014 !! html
23015 <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>hello</div></div></div>
23016
23017 !! end
23018
23019 !! test
23020 T17196: localised external link numbers
23021 !! options
23022 language=fa
23023 !! wikitext
23024 [http://en.wikipedia.org/]
23025 !! html/php
23026 <p><a rel="nofollow" class="external autonumber" href="http://en.wikipedia.org/">[۱]</a>
23027 </p>
23028 !! html/parsoid
23029 <p><a rel="mw:ExtLink" href="http://en.wikipedia.org/"></a></p>
23030 !! end
23031
23032 !! test
23033 Multibyte character in padleft
23034 !! wikitext
23035 {{padleft:-Hello|7|Æ}}
23036 !! html
23037 <p>Æ-Hello
23038 </p>
23039 !! end
23040
23041 !! test
23042 Multibyte character in padright
23043 !! wikitext
23044 {{padright:Hello-|7|Æ}}
23045 !! html
23046 <p>Hello-Æ
23047 </p>
23048 !! end
23049
23050 !!test
23051 formatdate parser function
23052 !! wikitext
23053 {{#formatdate:2009-03-24}}
23054 !! html
23055 <p><span class="mw-formatted-date" title="2009-03-24">2009-03-24</span>
23056 </p>
23057 !! end
23058
23059 !!test
23060 formatdate parser function, with default format
23061 !! wikitext
23062 {{#formatdate:2009-03-24|mdy}}
23063 !! html
23064 <p><span class="mw-formatted-date" title="2009-03-24">March 24, 2009</span>
23065 </p>
23066 !! end
23067
23068 !! test
23069 Spacing of numbers in formatted dates
23070 !! wikitext
23071 {{#formatdate:January 15}}
23072 !! html
23073 <p><span class="mw-formatted-date" title="01-15">January 15</span>
23074 </p>
23075 !! end
23076
23077 !! test
23078 formatdate parser function, with default format and on a page of which the content language is always English and different from the wiki content language
23079 !! options
23080 language=nl title=[[MediaWiki:Common.css]]
23081 !! wikitext
23082 {{#formatdate:2009-03-24|dmy}}
23083 !! html
23084 <p><span class="mw-formatted-date" title="2009-03-24">24 March 2009</span>
23085 </p>
23086 !! end
23087
23088 #
23089 #
23090 #
23091
23092 #
23093 # Edit comments
23094 #
23095
23096 !! test
23097 Edit comment with link
23098 !! options
23099 comment
23100 !! wikitext
23101 I like the [[Main Page]] a lot
23102 !! html/php
23103 I like the <a href="/wiki/Main_Page" title="Main Page">Main Page</a> a lot
23104 !!end
23105
23106 !! test
23107 Edit comment with link and link text
23108 !! options
23109 comment
23110 !! wikitext
23111 I like the [[Main Page|best pages]] a lot
23112 !! html/php
23113 I like the <a href="/wiki/Main_Page" title="Main Page">best pages</a> a lot
23114 !!end
23115
23116 !! test
23117 Edit comment with link and link text with suffix
23118 !! options
23119 comment
23120 !! wikitext
23121 I like the [[Main Page|best page]]s a lot
23122 !! html/php
23123 I like the <a href="/wiki/Main_Page" title="Main Page">best pages</a> a lot
23124 !!end
23125
23126 !! test
23127 Edit comment with section link (non-local, eg in history list)
23128 !! options
23129 comment title=[[Main Page]]
23130 !! wikitext
23131 /* External links */ removed bogus entries
23132 !! html/php
23133 <a href="/wiki/Main_Page#External_links" title="Main Page">→</a>‎<span dir="auto"><span class="autocomment">External links: </span> removed bogus entries</span>
23134 !!end
23135
23136 !! test
23137 Edit comment with section link and text before it (non-local, eg in history list)
23138 !! options
23139 comment title=[[Main Page]]
23140 !! wikitext
23141 pre-comment text /* External links */ removed bogus entries
23142 !! html/php
23143 pre-comment text <a href="/wiki/Main_Page#External_links" title="Main Page">→</a>‎<span dir="auto"><span class="autocomment">External links: </span> removed bogus entries</span>
23144 !!end
23145
23146 !! test
23147 Edit comment with section link (local, eg in diff view)
23148 !! options
23149 comment local title=[[Main Page]]
23150 !! wikitext
23151 /* External links */ removed bogus entries
23152 !! html/php
23153 <a href="#External_links">→</a>‎<span dir="auto"><span class="autocomment">External links: </span> removed bogus entries</span>
23154 !!end
23155
23156 !! test
23157 Edit comment with subpage link (T16080)
23158 !! options
23159 comment
23160 subpage
23161 title=[[Subpage test]]
23162 !! wikitext
23163 Poked at a [[/subpage]] here...
23164 !! html/php
23165 Poked at a <a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a> here...
23166 !!end
23167
23168 !! test
23169 Edit comment with subpage link and link text (T16080)
23170 !! options
23171 comment
23172 subpage
23173 title=[[Subpage test]]
23174 !! wikitext
23175 Poked at a [[/subpage|neat little page]] here...
23176 !! html/php
23177 Poked at a <a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">neat little page</a> here...
23178 !!end
23179
23180 !! test
23181 Edit comment with bogus subpage link in non-subpage NS (T16080)
23182 !! options
23183 comment
23184 title=[[Subpage test]]
23185 !! wikitext
23186 Poked at a [[/subpage]] here...
23187 !! html/php
23188 Poked at a <a href="/index.php?title=/subpage&amp;action=edit&amp;redlink=1" class="new" title="/subpage (page does not exist)">/subpage</a> here...
23189 !!end
23190
23191 !! test
23192 Edit comment with bare anchor link (local, as on diff)
23193 !! options
23194 comment
23195 local
23196 title=[[Main Page]]
23197 !! wikitext
23198 [[#section]]
23199 !! html/php
23200 <a href="#section">#section</a>
23201 !! end
23202
23203 !! test
23204 Edit comment with bare anchor link (non-local, as on history)
23205 !! options
23206 comment
23207 title=[[Main Page]]
23208 !! wikitext
23209 [[#section]]
23210 !! html/php
23211 <a href="/wiki/Main_Page#section" title="Main Page">#section</a>
23212 !! end
23213
23214 !! test
23215 Anchor starting with underscore
23216 !! options
23217 title=[[Foo]]
23218 !! wikitext
23219 [[#_ref|One]]
23220 !! html/php
23221 <p><a href="#_ref">One</a>
23222 </p>
23223 !! html/parsoid
23224 <p><a rel="mw:WikiLink" href="./Foo#_ref" data-parsoid='{"stx":"piped","a":{"href":"./Foo#_ref"},"sa":{"href":"#_ref"}}'>One</a></p>
23225 !! end
23226
23227 !! test
23228 Id starting with underscore
23229 !! wikitext
23230 <div id="_ref"></div>
23231 !! html/*
23232 <div id="_ref"></div>
23233
23234 !! end
23235
23236 !! test
23237 Edit comment with link with more than one pipe (T99346)
23238 !! options
23239 comment
23240 !! wikitext
23241 [[Main Page|Many|pipes]]
23242 !! html/php
23243 <a href="/wiki/Main_Page" title="Main Page">Many|pipes</a>
23244 !! end
23245
23246 !! test
23247 Complex edit comment with link with more than one pipe (T99346)
23248 !! options
23249 comment
23250 !! wikitext
23251 Created page with "<noinclude>[[Category:Requests for permissions/Bot|{{subst:#titleparts:{{subst:PAGENAME}}|1|3}}]]</noinclude> === [[User:MineoBot|]] 8=== {{Request for permissions/links|Mineo..."
23252 !! html/php
23253 Created page with &quot;&lt;noinclude&gt;<a href="/index.php?title=Category:Requests_for_permissions/Bot&amp;action=edit&amp;redlink=1" class="new" title="Category:Requests for permissions/Bot (page does not exist)">{{subst:#titleparts:{{subst:PAGENAME}}|1|3}}</a>&lt;/noinclude&gt; === <a href="/index.php?title=User:MineoBot&amp;action=edit&amp;redlink=1" class="new" title="User:MineoBot (page does not exist)">User:MineoBot</a> 8=== {{Request for permissions/links|Mineo...&quot;
23254 !! end
23255
23256 !! test
23257 Space normalisation on autocomment (T24784)
23258 !! options
23259 comment
23260 title=[[Main Page]]
23261 !! wikitext
23262 /* __hello__world__ */
23263 !! html/php
23264 <a href="/wiki/Main_Page#hello_world" title="Main Page">→</a>‎<span dir="auto"><span class="autocomment">__hello__world__</span></span>
23265 !! end
23266
23267 !! test
23268 percent-encoding and + signs in comments (T28410)
23269 !! options
23270 comment
23271 !! wikitext
23272 [[ABC%33D% ++]] [[ABC%33D% ++|+%20]]
23273 !! html/php
23274 <a href="/index.php?title=ABC3D%25_%2B%2B&amp;action=edit&amp;redlink=1" class="new" title="ABC3D% ++ (page does not exist)">ABC3D% ++</a> <a href="/index.php?title=ABC3D%25_%2B%2B&amp;action=edit&amp;redlink=1" class="new" title="ABC3D% ++ (page does not exist)">+%20</a>
23275 !! end
23276
23277 # Parsoid doesn't support this yet: see T75581
23278 # but it *should* omit the 'src' attribute if the image is bad.
23279 # PHP side of tests was disabled in
23280 # mediawiki/core:6bd31e7d95161a6e88fa86df60871051da997c3c
23281 # because of issues in the PHP parserTests infrastructure
23282 # (but the output below is indeed what the PHP side emits)
23283 !! test
23284 Bad images - basic functionality
23285 !! wikitext
23286 [[File:Bad.jpg]]
23287 !! DISABLED/html/php
23288 !! html/parsoid
23289 <p><span class="mw-default-size" typeof="mw:Error mw:Image" data-mw='{"errors":[{"key":"bad-image","message":"This image is blacklisted in this context."}]}'><a href="./File:Bad.jpg"><img resource="./File:Bad.jpg" height="220" width="220"/></a></span></p>
23290 !! end
23291
23292 !! test
23293 Bad images - T18039: text after bad image disappears
23294 !! wikitext
23295 Foo bar
23296 [[File:Bad.jpg]]
23297 Bar foo
23298 !! DISABLED/html/php
23299 <p>Foo bar
23300 </p><p>Bar foo
23301 </p>
23302 !! html/parsoid
23303 <p>Foo bar
23304 <span class="mw-default-size" typeof="mw:Error mw:Image" data-mw='{"errors":[{"key":"bad-image","message":"This image is blacklisted in this context."}]}'><a href="./File:Bad.jpg"><img resource="./File:Bad.jpg" height="220" width="220"/></a></span>
23305 Bar foo</p>
23306 !! end
23307
23308 !! test
23309 Verify that displaytitle works (T24501) no displaytitle
23310 !! options
23311 showtitle
23312 !! config
23313 wgAllowDisplayTitle=true
23314 wgRestrictDisplayTitle=false
23315 !! wikitext
23316 this is not the the title
23317 !! html/php
23318 Parser test
23319 <p>this is not the the title
23320 </p>
23321 !! end
23322
23323 !! test
23324 Verify that displaytitle works (T24501) RestrictDisplayTitle=false
23325 !! options
23326 showtitle
23327 title=[[Screen]]
23328 !! config
23329 wgAllowDisplayTitle=true
23330 wgRestrictDisplayTitle=false
23331 !! wikitext
23332 this is not the the title
23333 {{DISPLAYTITLE:whatever}}
23334 !! html/php
23335 whatever
23336 <p>this is not the the title
23337 </p>
23338 !! end
23339
23340 !! test
23341 Verify that displaytitle works (T24501) RestrictDisplayTitle=true mismatch
23342 !! options
23343 showtitle
23344 title=[[Screen]]
23345 !! config
23346 wgAllowDisplayTitle=true
23347 wgRestrictDisplayTitle=true
23348 !! wikitext
23349 this is not the the title
23350 {{DISPLAYTITLE:whatever}}
23351 !! html/php
23352 Screen
23353 <p>this is not the the title
23354 </p>
23355 !! end
23356
23357 !! test
23358 Verify that displaytitle works (T24501) RestrictDisplayTitle=true matching
23359 !! options
23360 showtitle
23361 title=[[Screen]]
23362 !! config
23363 wgAllowDisplayTitle=true
23364 wgRestrictDisplayTitle=true
23365 !! wikitext
23366 this is not the the title
23367 {{DISPLAYTITLE:screen}}
23368 !! html/php
23369 screen
23370 <p>this is not the the title
23371 </p>
23372 !! end
23373
23374 !! test
23375 Verify that displaytitle works (T24501) AllowDisplayTitle=false
23376 !! options
23377 showtitle
23378 title=[[Screen]]
23379 !! config
23380 wgAllowDisplayTitle=false
23381 !! wikitext
23382 this is not the the title
23383 {{DISPLAYTITLE:screen}}
23384 !! html/php
23385 Screen
23386 <p>this is not the the title
23387 <a href="/index.php?title=Template:DISPLAYTITLE:screen&amp;action=edit&amp;redlink=1" class="new" title="Template:DISPLAYTITLE:screen (page does not exist)">Template:DISPLAYTITLE:screen</a>
23388 </p>
23389 !! end
23390
23391 !! test
23392 Verify that displaytitle works (T24501) AllowDisplayTitle=false no DISPLAYTITLE
23393 !! options
23394 showtitle
23395 title=[[Screen]]
23396 !! config
23397 wgAllowDisplayTitle=false
23398 !! wikitext
23399 this is not the the title
23400 !! html/php
23401 Screen
23402 <p>this is not the the title
23403 </p>
23404 !! end
23405
23406 !! test
23407 Verify that displaytitle handles inline CSS styles (T28547) - rejected value
23408 !! options
23409 showtitle
23410 title=[[Screen]]
23411 !! config
23412 wgAllowDisplayTitle=true
23413 wgRestrictDisplayTitle=true
23414 !! wikitext
23415 this is not the the title
23416 {{DISPLAYTITLE:<span style="display: none;">s</span>creen}}
23417 !! html/php
23418 <span style="/* attempt to bypass $wgRestrictDisplayTitle */">s</span>creen
23419 <p>this is not the the title
23420 </p>
23421 !! end
23422
23423 !! test
23424 Verify that displaytitle handles inline CSS styles (T28547) - accepted value
23425 !! options
23426 showtitle
23427 title=[[Screen]]
23428 !! config
23429 wgAllowDisplayTitle=true
23430 wgRestrictDisplayTitle=true
23431 !! wikitext
23432 this is not the the title
23433 {{DISPLAYTITLE:<span style="color: red;">s</span>creen}}
23434 !! html/php
23435 <span style="color: red;">s</span>creen
23436 <p>this is not the the title
23437 </p>
23438 !! end
23439
23440 !! test
23441 Page status indicators: Empty name is invalid
23442 !! options
23443 showindicators
23444 !! wikitext
23445 <indicator name=" "></indicator>
23446 <indicator></indicator>
23447 !! html/php
23448 <p><span class="error"><strong>Error:</strong> Page status indicators' <code>name</code> attribute must not be empty.</span>
23449 <span class="error"><strong>Error:</strong> Page status indicators' <code>name</code> attribute must not be empty.</span>
23450 </p>
23451 !! end
23452
23453 !! test
23454 Page status indicators: Weird syntaxes that are okay
23455 !! options
23456 showindicators
23457 !! wikitext
23458 <indicator name="empty" />
23459 <indicator name="name"></indicator>
23460 !! html/php
23461 empty=
23462 name=
23463 <p><br />
23464 </p>
23465 !! end
23466
23467 !! test
23468 Page status indicators: Torture test
23469 !! options
23470 showindicators
23471 !! wikitext
23472 <indicator name="01">hello world</indicator>
23473 <indicator name="02">[[Main Page]]</indicator>
23474 <indicator name="03">[[File:Foobar.jpg|25px|link=]]</indicator>
23475 <indicator name="04">[[File:Foobar.jpg|25px]]</indicator>
23476 <indicator name="05">* foo
23477 * bar</indicator>
23478 <indicator name="06"><nowiki>foo</nowiki></indicator>
23479 <indicator name="07"> Preformatted</indicator>
23480 <indicator name="08"><div>Broken tag</indicator>
23481 <indicator name="09">{| class=wikitable
23482 | cell
23483 |}</indicator>
23484 <indicator name="10">Two
23485
23486 paragraphs</indicator>
23487 !! html/php
23488 01=hello world
23489 02=<a href="/wiki/Main_Page" title="Main Page">Main Page</a>
23490 03=<img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/25px-Foobar.jpg" width="25" height="3" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/38px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/50px-Foobar.jpg 2x" />
23491 04=<a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/25px-Foobar.jpg" width="25" height="3" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/38px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/50px-Foobar.jpg 2x" /></a>
23492 05=<ul><li> foo</li>
23493 <li> bar</li></ul>
23494
23495 06=foo
23496 07=<pre>Preformatted
23497 </pre>
23498 08=<div>Broken tag</div>
23499
23500 09=<table class="wikitable">
23501 <tr>
23502 <td> cell
23503 </td></tr></table>
23504
23505 10=<p>Two
23506 </p><p>paragraphs
23507 </p>
23508 <p><br />
23509 </p><p><br />
23510 </p><p><br />
23511 </p><p><br />
23512 </p><p><br />
23513 </p>
23514 !! end
23515
23516 !! test
23517 preload: check <noinclude> and <includeonly>
23518 !! options
23519 preload
23520 !! wikitext
23521 Hello <noinclude>cruel</noinclude><includeonly>kind</includeonly> world.
23522 !! html/php
23523 Hello kind world.
23524 !! end
23525
23526 !! test
23527 preload: check <onlyinclude>
23528 !! options
23529 preload
23530 !! wikitext
23531 Goodbye <onlyinclude>Hello world</onlyinclude>
23532 !! html/php
23533 Hello world
23534 !! end
23535
23536 !! test
23537 preload: can pass tags through if we want to
23538 !! options
23539 preload
23540 !! wikitext
23541 <includeonly><</includeonly>includeonly>Hello world<includeonly><</includeonly>/includeonly>
23542 !! html/php
23543 <includeonly>Hello world</includeonly>
23544 !! end
23545
23546 !! test
23547 preload: check that it doesn't try to do tricks
23548 !! options
23549 preload
23550 !! wikitext
23551 * <!-- Hello --> ''{{world}}'' {{<includeonly>subst:</includeonly>How are you}}{{ {{{|safesubst:}}} #if:1|2|3}}
23552 !! html/php
23553 * <!-- Hello --> ''{{world}}'' {{subst:How are you}}{{ {{{|safesubst:}}} #if:1|2|3}}
23554 !! end
23555
23556 !! test
23557 Play a bit with r67090 and T5158
23558 !! wikitext
23559 <div style="width:50% !important">&nbsp;</div>
23560 <div style="width:50%&nbsp;!important">&nbsp;</div>
23561 <div style="width:50%&#160;!important">&nbsp;</div>
23562 <div style="border : solid;">&nbsp;</div>
23563 !! html/php
23564 <div style="width:50% !important">&#160;</div>
23565 <div style="width:50% !important">&#160;</div>
23566 <div style="width:50% !important">&#160;</div>
23567 <div style="border&#160;: solid;">&#160;</div>
23568
23569 !! html/parsoid
23570 <div style="width:50% !important" data-parsoid='{"stx":"html"}'><span typeof="mw:Entity" data-parsoid='{"srcContent":" "}'> </span></div>
23571 <div style="width:50% !important" data-parsoid='{"stx":"html","a":{"style":"width:50% !important"},"sa":{"style":"width:50%&amp;nbsp;!important"}}'><span typeof="mw:Entity" data-parsoid='{"srcContent":" "}'> </span></div>
23572 <div style="width:50% !important" data-parsoid='{"stx":"html","a":{"style":"width:50% !important"},"sa":{"style":"width:50%&amp;#160;!important"}}'><span typeof="mw:Entity" data-parsoid='{"srcContent":" "}'> </span></div>
23573 <div style="border : solid;" data-parsoid='{"stx":"html"}'><span typeof="mw:Entity" data-parsoid='{"srcContent":" "}'> </span></div>
23574
23575 !! end
23576
23577 !! test
23578 HTML5 data attributes
23579 !! wikitext
23580 <span data-foo="bar">Baz</span>
23581 <p data-abc-def_hij="">Quuz</p>
23582 !! html/php
23583 <p><span data-foo="bar">Baz</span>
23584 </p>
23585 <p data-abc-def_hij="">Quuz</p>
23586
23587 !! html/parsoid
23588 <p><span data-foo="bar" data-parsoid='{"stx":"html"}'>Baz</span></p>
23589 <p data-abc-def_hij="" data-parsoid='{"stx":"html"}'>Quuz</p>
23590 !! end
23591
23592 !! test
23593 Strip reserved data attributes
23594 !! wikitext
23595 <div data-mw="foo" data-parsoid="bar" data-mw-someext="baz" data-ok="fred" data-ooui="xyzzy" data-bad:ns="ns">d</div>
23596 !! html/php
23597 <div data-ok="fred">d</div>
23598
23599 !! html/parsoid
23600 <div data-x-data-mw="foo" data-x-data-parsoid="bar" data-x-data-mw-someext="baz" data-ok="fred" data-parsoid='{"stx":"html","a":{"data-ooui":null,"data-bad:ns":null},"sa":{"data-ooui":"xyzzy","data-bad:ns":"ns"}}'>d</div>
23601 !! end
23602
23603 !! test
23604 percent-encoding and + signs in internal links (T28410)
23605 !! wikitext
23606 [[User:+%]] [[Page+title%]]
23607 [[%+]] [[%+|%20]] [[%+ ]] [[%+r]]
23608 [[%]] [[+]] [[File:%+abc%39|foo|[[bar]]]]
23609 [[%33%45]] [[%33%45+]]
23610 !! html/php
23611 <p><a href="/index.php?title=User:%2B%25&amp;action=edit&amp;redlink=1" class="new" title="User:+% (page does not exist)">User:+%</a> <a href="/index.php?title=Page%2Btitle%25&amp;action=edit&amp;redlink=1" class="new" title="Page+title% (page does not exist)">Page+title%</a>
23612 <a href="/index.php?title=%25%2B&amp;action=edit&amp;redlink=1" class="new" title="%+ (page does not exist)">%+</a> <a href="/index.php?title=%25%2B&amp;action=edit&amp;redlink=1" class="new" title="%+ (page does not exist)">%20</a> <a href="/index.php?title=%25%2B&amp;action=edit&amp;redlink=1" class="new" title="%+ (page does not exist)">%+ </a> <a href="/index.php?title=%25%2Br&amp;action=edit&amp;redlink=1" class="new" title="%+r (page does not exist)">%+r</a>
23613 <a href="/index.php?title=%25&amp;action=edit&amp;redlink=1" class="new" title="% (page does not exist)">%</a> <a href="/index.php?title=%2B&amp;action=edit&amp;redlink=1" class="new" title="+ (page does not exist)">+</a> <a href="/index.php?title=Special:Upload&amp;wpDestFile=%25%2Babc9" class="new" title="File:%+abc9">bar</a>
23614 <a href="/index.php?title=3E&amp;action=edit&amp;redlink=1" class="new" title="3E (page does not exist)">3E</a> <a href="/index.php?title=3E%2B&amp;action=edit&amp;redlink=1" class="new" title="3E+ (page does not exist)">3E+</a>
23615 </p>
23616 !! html/parsoid
23617 <p><a rel="mw:WikiLink" href="./User:+%25" title="User:+%" data-parsoid='{"stx":"simple","a":{"href":"./User:+%25"},"sa":{"href":"User:+%"}}'>User:+%</a> <a rel="mw:WikiLink" href="./Page+title%25" title="Page+title%" data-parsoid='{"stx":"simple","a":{"href":"./Page+title%25"},"sa":{"href":"Page+title%"}}'>Page+title%</a>
23618 <a rel="mw:WikiLink" href="./%25+" title="%+" data-parsoid='{"stx":"simple","a":{"href":"./%25+"},"sa":{"href":"%+"}}'>%+</a> <a rel="mw:WikiLink" href="./%25+" title="%+" data-parsoid='{"stx":"piped","a":{"href":"./%25+"},"sa":{"href":"%+"}}'>%20</a> <a rel="mw:WikiLink" href="./%25+" title="%+" data-parsoid='{"stx":"simple","a":{"href":"./%25+"},"sa":{"href":"%+ "}}'>%+ </a> <a rel="mw:WikiLink" href="./%25+r" title="%+r" data-parsoid='{"stx":"simple","a":{"href":"./%25+r"},"sa":{"href":"%+r"}}'>%+r</a>
23619 <a rel="mw:WikiLink" href="./%25" title="%" data-parsoid='{"stx":"simple","a":{"href":"./%25"},"sa":{"href":"%"}}'>%</a> <a rel="mw:WikiLink" href="./+" title="+" data-parsoid='{"stx":"simple","a":{"href":"./+"},"sa":{"href":"+"}}'>+</a> <span class="mw-default-size" typeof="mw:Error mw:Image" data-parsoid='{"optList":[{"ck":"bogus","ak":"foo"},{"ck":"caption","ak":"[[bar]]"}]}' data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}],"caption":"&lt;a rel=\"mw:WikiLink\" href=\"./Bar\" title=\"Bar\" data-parsoid=&#39;{\"stx\":\"simple\",\"a\":{\"href\":\"./Bar\"},\"sa\":{\"href\":\"bar\"},\"dsr\":[94,101,2,2]}&#39;>bar&lt;/a>"}'><a href="./File:%25+abc9" data-parsoid='{"a":{"href":"./File:%25+abc9"},"sa":{}}'><img resource="./File:%25+abc9" src="./Special:FilePath/%25+abc9" height="220" width="220" data-parsoid='{"a":{"resource":"./File:%25+abc9","height":"220","width":"220"},"sa":{"resource":"File:%+abc%39"}}'/></a></span>
23620 <a rel="mw:WikiLink" href="./3E" title="3E" data-parsoid='{"stx":"simple","a":{"href":"./3E"},"sa":{"href":"%33%45"}}'>3E</a> <a rel="mw:WikiLink" href="./3E+" title="3E+" data-parsoid='{"stx":"simple","a":{"href":"./3E+"},"sa":{"href":"%33%45+"}}'>3E+</a></p>
23621 !! end
23622
23623 !! test
23624 Special characters in embedded file links (T29679)
23625 !! wikitext
23626 [[File:Contains & ampersand.jpg]]
23627 [[File:Does not exist.jpg|Title with & ampersand]]
23628 !! html/php
23629 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=Contains_%26_ampersand.jpg" class="new" title="File:Contains &amp; ampersand.jpg">File:Contains &amp; ampersand.jpg</a>
23630 <a href="/index.php?title=Special:Upload&amp;wpDestFile=Does_not_exist.jpg" class="new" title="File:Does not exist.jpg">Title with &amp; ampersand</a>
23631 </p>
23632 !! html/parsoid
23633 <p><span class="mw-default-size" typeof="mw:Error mw:Image" data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}]}'><a href="./File:Contains_&amp;_ampersand.jpg"><img resource="./File:Contains_&amp;_ampersand.jpg" src="./Special:FilePath/Contains_&amp;_ampersand.jpg" height="220" width="220"/></a></span>
23634 <span class="mw-default-size" typeof="mw:Error mw:Image" data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}],"caption":"Title with &amp;amp; ampersand"}'><a href="./File:Does_not_exist.jpg"><img resource="./File:Does_not_exist.jpg" src="./Special:FilePath/Does_not_exist.jpg" height="220" width="220"/></a></span></p>
23635 !! end
23636
23637 !! test
23638 Confirm that 'apos' named character reference doesn't make it to output (not legal in HTML 4)
23639 !! wikitext
23640 Text&apos;s been normalized?
23641 !! html
23642 <p>Text&#39;s been normalized?
23643 </p>
23644 !! end
23645
23646 !! test
23647 T21052 U+3000 IDEOGRAPHIC SPACE should terminate free external links
23648 !! wikitext
23649 http://www.example.org/ <-- U+3000 (vim: ^Vu3000)
23650 !! html
23651 <p><a rel="nofollow" class="external free" href="http://www.example.org/">http://www.example.org/</a> &lt;-- U+3000 (vim: ^Vu3000)
23652 </p>
23653 !! end
23654
23655 !! test
23656 T21052 U+3000 IDEOGRAPHIC SPACE should terminate bracketed external links
23657 !! wikitext
23658 [http://www.example.org/ ideograms]
23659 !! html
23660 <p><a rel="nofollow" class="external text" href="http://www.example.org/">ideograms</a>
23661 </p>
23662 !! end
23663
23664 !! test
23665 T21052 U+3000 IDEOGRAPHIC SPACE should terminate external images links
23666 !! wikitext
23667 http://www.example.org/pic.png <-- U+3000 (vim: ^Vu3000)
23668 !! html
23669 <p><img src="http://www.example.org/pic.png" alt="pic.png"/> &lt;-- U+3000 (vim: ^Vu3000)
23670 </p>
23671 !! end
23672
23673 !! article
23674 Mediawiki:loop1
23675 !! text
23676 {{Identical|A}}
23677 !! endarticle
23678
23679 !! article
23680 Mediawiki:loop2
23681 !! text
23682 {{Identical|B}}
23683 !! endarticle
23684
23685 !! article
23686 Template:Identical
23687 !! text
23688 {{int:loop1}}
23689 {{int:loop2}}
23690 !! endarticle
23691
23692 !! test
23693 T33098 Template which includes system messages which includes the template
23694 !! wikitext
23695 {{Identical}}
23696 !! html
23697 <p><span class="error">Template loop detected: <a href="/wiki/Template:Identical" title="Template:Identical">Template:Identical</a></span>
23698 <span class="error">Template loop detected: <a href="/wiki/Template:Identical" title="Template:Identical">Template:Identical</a></span>
23699 </p>
23700 !! end
23701
23702 !! test
23703 T33490 Turkish: ucfirst 'blah'
23704 !! options
23705 language=tr
23706 !! wikitext
23707 {{ucfirst:blah}}
23708 !! html
23709 <p>Blah
23710 </p>
23711 !! end
23712
23713 !! test
23714 T33490 Turkish: ucfirst 'ix'
23715 !! options
23716 language=tr
23717 !! wikitext
23718 {{ucfirst:ix}}
23719 !! html
23720 <p>İx
23721 </p>
23722 !! end
23723
23724 !! test
23725 T33490 Turkish: lcfirst 'BLAH'
23726 !! options
23727 language=tr
23728 !! wikitext
23729 {{lcfirst:BLAH}}
23730 !! html
23731 <p>bLAH
23732 </p>
23733 !! end
23734
23735 !! test
23736 T33490 Turkish: ucfırst (with a dotless i)
23737 !! options
23738 language=tr
23739 !! wikitext
23740 {{ucfırst:blah}}
23741 !! html
23742 <p><a href="/index.php?title=%C5%9Eablon:Ucf%C4%B1rst:blah&amp;action=edit&amp;redlink=1" class="new" title="Şablon:Ucfırst:blah (sayfa mevcut değil)">Şablon:Ucfırst:blah</a>
23743 </p>
23744 !! end
23745
23746 !! test
23747 T33490 ucfırst (with a dotless i) with English language
23748 !! options
23749 language=en
23750 !! wikitext
23751 {{ucfırst:blah}}
23752 !! html
23753 <p><a href="/index.php?title=Template:Ucf%C4%B1rst:blah&amp;action=edit&amp;redlink=1" class="new" title="Template:Ucfırst:blah (page does not exist)">Template:Ucfırst:blah</a>
23754 </p>
23755 !! end
23756
23757 # Note that Parsoid doesn't emit an explicit TOC.
23758 # Note also that the html2wt direction tends to emit an extra newline
23759 # between the __TOC__ magicword and the first heading unless *both*
23760 # the <meta> and the <h2> have a data-parsoid attribute set (even if
23761 # it's "{}").
23762
23763 !! test
23764 T28375: TOC with italics
23765 !! options
23766 title=[[Main Page]]
23767 !! wikitext
23768 __TOC__
23769 == ''Lost'' episodes ==
23770 !! html/php
23771 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
23772 <ul>
23773 <li class="toclevel-1 tocsection-1"><a href="#Lost_episodes"><span class="tocnumber">1</span> <span class="toctext"><i>Lost</i> episodes</span></a></li>
23774 </ul>
23775 </div>
23776
23777 <h2><span class="mw-headline" id="Lost_episodes"><i>Lost</i> episodes</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Main_Page&amp;action=edit&amp;section=1" title="Edit section: Lost episodes">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
23778
23779 !! html/parsoid
23780 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
23781 <h2 data-parsoid='{}'> <i>Lost</i> episodes </h2>
23782 !! end
23783
23784 !! test
23785 T28375: TOC with bold
23786 !! options
23787 title=[[Main Page]]
23788 !! wikitext
23789 __TOC__
23790 == '''should be bold''' then normal text ==
23791 !! html/php
23792 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
23793 <ul>
23794 <li class="toclevel-1 tocsection-1"><a href="#should_be_bold_then_normal_text"><span class="tocnumber">1</span> <span class="toctext"><b>should be bold</b> then normal text</span></a></li>
23795 </ul>
23796 </div>
23797
23798 <h2><span class="mw-headline" id="should_be_bold_then_normal_text"><b>should be bold</b> then normal text</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Main_Page&amp;action=edit&amp;section=1" title="Edit section: should be bold then normal text">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
23799
23800 !! html/parsoid
23801 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
23802 <h2 data-parsoid='{}'> <b>should be bold</b> then normal text </h2>
23803 !! end
23804
23805 !! test
23806 T35845: Headings become cursive in TOC when they contain an image
23807 !! options
23808 title=[[Main Page]]
23809 !! wikitext
23810 __TOC__
23811 == Image [[Image:foobar.jpg]] ==
23812 !! html/php
23813 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
23814 <ul>
23815 <li class="toclevel-1 tocsection-1"><a href="#Image"><span class="tocnumber">1</span> <span class="toctext">Image</span></a></li>
23816 </ul>
23817 </div>
23818
23819 <h2><span class="mw-headline" id="Image">Image <a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Main_Page&amp;action=edit&amp;section=1" title="Edit section: Image">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
23820
23821 !! html/parsoid
23822 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
23823 <h2 data-parsoid='{}'> Image <span class="mw-default-size" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"Image:foobar.jpg"}}'/></a></span> </h2>
23824 !! end
23825
23826 !! test
23827 T35845 (2): Headings become bold in TOC when they contain a blockquote
23828 !! options
23829 title=[[Main Page]]
23830 !! wikitext
23831 __TOC__
23832 == <blockquote>Quote</blockquote> ==
23833 !! html/php
23834 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
23835 <ul>
23836 <li class="toclevel-1 tocsection-1"><a href="#Quote"><span class="tocnumber">1</span> <span class="toctext">Quote</span></a></li>
23837 </ul>
23838 </div>
23839
23840 <h2><span class="mw-headline" id="Quote"><blockquote>Quote</blockquote></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Main_Page&amp;action=edit&amp;section=1" title="Edit section: Quote">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
23841
23842 !! html/php+tidy
23843 <p></p>
23844 <div id="toc" class="toc">
23845 <div class="toctitle">
23846 <h2>Contents</h2>
23847 </div>
23848 <ul>
23849 <li class="toclevel-1 tocsection-1"><a href="#Quote"><span class="tocnumber">1</span> <span class="toctext">Quote</span></a></li>
23850 </ul>
23851 </div>
23852 <p></p>
23853 <h2><span class="mw-headline" id="Quote"></span></h2>
23854 <blockquote>
23855 <p><span class="mw-headline" id="Quote">Quote</span></p>
23856 </blockquote>
23857 <p><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Main_Page&amp;action=edit&amp;section=1" title="Edit section: Quote">edit</a><span class="mw-editsection-bracket">]</span></span></p>
23858 !! html/parsoid
23859 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
23860 <h2 data-parsoid='{}'> <blockquote>Quote</blockquote> </h2>
23861 !! end
23862
23863 !! test
23864 Unclosed tags in TOC
23865 !! options
23866 title=[[Main Page]]
23867 !! wikitext
23868 __TOC__
23869 == Proof: 2 < 3 ==
23870 <small>Hanc marginis exiguitas non caperet.</small>
23871 QED
23872 !! html/php
23873 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
23874 <ul>
23875 <li class="toclevel-1 tocsection-1"><a href="#Proof:_2_.3C_3"><span class="tocnumber">1</span> <span class="toctext">Proof: 2 &lt; 3</span></a></li>
23876 </ul>
23877 </div>
23878
23879 <h2><span class="mw-headline" id="Proof:_2_.3C_3">Proof: 2 &lt; 3</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Main_Page&amp;action=edit&amp;section=1" title="Edit section: Proof: 2 &lt; 3">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
23880 <p><small>Hanc marginis exiguitas non caperet.</small>
23881 QED
23882 </p>
23883 !! html/parsoid
23884 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
23885 <h2 data-parsoid='{}'> Proof: 2 &lt; 3 </h2>
23886 <p><small>Hanc marginis exiguitas non caperet.</small>
23887 QED</p>
23888 !! end
23889
23890 !! test
23891 Multiple tags in TOC
23892 !! wikitext
23893 __TOC__
23894 == <i>Foo</i> <b>Bar</b> ==
23895
23896 == <i>Foo</i> <blockquote>Bar</blockquote> ==
23897 !! html/php
23898 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
23899 <ul>
23900 <li class="toclevel-1 tocsection-1"><a href="#Foo_Bar"><span class="tocnumber">1</span> <span class="toctext"><i>Foo</i> <b>Bar</b></span></a></li>
23901 <li class="toclevel-1 tocsection-2"><a href="#Foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext"><i>Foo</i> Bar</span></a></li>
23902 </ul>
23903 </div>
23904
23905 <h2><span class="mw-headline" id="Foo_Bar"><i>Foo</i> <b>Bar</b></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: Foo Bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
23906 <h2><span class="mw-headline" id="Foo_Bar_2"><i>Foo</i> <blockquote>Bar</blockquote></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: Foo Bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
23907
23908 !! html/php+tidy
23909 <p></p>
23910 <div id="toc" class="toc">
23911 <div class="toctitle">
23912 <h2>Contents</h2>
23913 </div>
23914 <ul>
23915 <li class="toclevel-1 tocsection-1"><a href="#Foo_Bar"><span class="tocnumber">1</span> <span class="toctext"><i>Foo</i> <b>Bar</b></span></a></li>
23916 <li class="toclevel-1 tocsection-2"><a href="#Foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext"><i>Foo</i> Bar</span></a></li>
23917 </ul>
23918 </div>
23919 <p></p>
23920 <h2><span class="mw-headline" id="Foo_Bar"><i>Foo</i> <b>Bar</b></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: Foo Bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
23921 <h2><span class="mw-headline" id="Foo_Bar_2"><i>Foo</i></span></h2>
23922 <blockquote>
23923 <p><span class="mw-headline" id="Foo_Bar_2">Bar</span></p>
23924 </blockquote>
23925 <p><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: Foo Bar">edit</a><span class="mw-editsection-bracket">]</span></span></p>
23926 !! html/parsoid
23927 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
23928 <h2 data-parsoid='{}'> <i data-parsoid='{"stx":"html"}'>Foo</i> <b data-parsoid='{"stx":"html"}'>Bar</b> </h2>
23929 <h2> <i data-parsoid='{"stx":"html"}'>Foo</i> <blockquote>Bar</blockquote> </h2>
23930 !! end
23931
23932 # Don't expect Parsoid to roundtrip this until the php parser comes closer to
23933 # html5 tag parsing.
23934 !! test
23935 Tags with parameters in TOC
23936 !! options
23937 parsoid=wt2html
23938 !! wikitext
23939 __TOC__
23940 == <sup class="in-h2">Hello</sup> ==
23941
23942 == <sup class="a > b">Evilbye</sup> ==
23943 !! html/php
23944 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
23945 <ul>
23946 <li class="toclevel-1 tocsection-1"><a href="#Hello"><span class="tocnumber">1</span> <span class="toctext"><sup>Hello</sup></span></a></li>
23947 <li class="toclevel-1 tocsection-2"><a href="#b.22.3EEvilbye"><span class="tocnumber">2</span> <span class="toctext"><sup> b"&gt;Evilbye</sup></span></a></li>
23948 </ul>
23949 </div>
23950
23951 <h2><span class="mw-headline" id="Hello"><sup class="in-h2">Hello</sup></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: Hello">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
23952 <h2><span class="mw-headline" id="b.22.3EEvilbye"><sup class="a"> b"&gt;Evilbye</sup></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: b&quot;&gt;Evilbye">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
23953
23954 !! html/parsoid
23955 <meta property="mw:PageProp/toc" />
23956 <h2> <sup class="in-h2" data-parsoid='{"stx":"html"}'>Hello</sup> </h2>
23957
23958 <h2> <sup class="a " data-parsoid='{"stx":"html"}'> b">Evilbye</sup> </h2>
23959 !! end
23960
23961 !! test
23962 span tags with directionality in TOC
23963 !! wikitext
23964 __TOC__
23965 == <span dir="ltr">C++</span> ==
23966
23967 == <span dir="rtl">זבנג!</span> ==
23968
23969 == <span style="font-style: italic">The attributes on these span tags must be deleted from the TOC</span> ==
23970
23971 == <span style="font-style: italic" dir="ltr">All attributes on these span tags must be deleted from the TOC</span> ==
23972
23973 == <span dir="ltr" style="font-style: italic">Attributes after dir on these span tags must be deleted from the TOC</span> ==
23974 !! html/php
23975 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
23976 <ul>
23977 <li class="toclevel-1 tocsection-1"><a href="#C.2B.2B"><span class="tocnumber">1</span> <span class="toctext"><span dir="ltr">C++</span></span></a></li>
23978 <li class="toclevel-1 tocsection-2"><a href="#.D7.96.D7.91.D7.A0.D7.92.21"><span class="tocnumber">2</span> <span class="toctext"><span dir="rtl">זבנג!</span></span></a></li>
23979 <li class="toclevel-1 tocsection-3"><a href="#The_attributes_on_these_span_tags_must_be_deleted_from_the_TOC"><span class="tocnumber">3</span> <span class="toctext"><span>The attributes on these span tags must be deleted from the TOC</span></span></a></li>
23980 <li class="toclevel-1 tocsection-4"><a href="#All_attributes_on_these_span_tags_must_be_deleted_from_the_TOC"><span class="tocnumber">4</span> <span class="toctext"><span>All attributes on these span tags must be deleted from the TOC</span></span></a></li>
23981 <li class="toclevel-1 tocsection-5"><a href="#Attributes_after_dir_on_these_span_tags_must_be_deleted_from_the_TOC"><span class="tocnumber">5</span> <span class="toctext"><span dir="ltr">Attributes after dir on these span tags must be deleted from the TOC</span></span></a></li>
23982 </ul>
23983 </div>
23984
23985 <h2><span class="mw-headline" id="C.2B.2B"><span dir="ltr">C++</span></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: C++">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
23986 <h2><span class="mw-headline" id=".D7.96.D7.91.D7.A0.D7.92.21"><span dir="rtl">זבנג!</span></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: זבנג!">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
23987 <h2><span class="mw-headline" id="The_attributes_on_these_span_tags_must_be_deleted_from_the_TOC"><span style="font-style: italic">The attributes on these span tags must be deleted from the TOC</span></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=3" title="Edit section: The attributes on these span tags must be deleted from the TOC">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
23988 <h2><span class="mw-headline" id="All_attributes_on_these_span_tags_must_be_deleted_from_the_TOC"><span style="font-style: italic" dir="ltr">All attributes on these span tags must be deleted from the TOC</span></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=4" title="Edit section: All attributes on these span tags must be deleted from the TOC">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
23989 <h2><span class="mw-headline" id="Attributes_after_dir_on_these_span_tags_must_be_deleted_from_the_TOC"><span dir="ltr" style="font-style: italic">Attributes after dir on these span tags must be deleted from the TOC</span></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=5" title="Edit section: Attributes after dir on these span tags must be deleted from the TOC">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
23990
23991 !! html/parsoid
23992 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
23993 <h2 data-parsoid='{}'> <span dir="ltr">C++</span> </h2>
23994 <h2> <span dir="rtl">זבנג!</span> </h2>
23995 <h2> <span style="font-style: italic">The attributes on these span tags must be deleted from the TOC</span> </h2>
23996 <h2> <span style="font-style: italic" dir="ltr">All attributes on these span tags must be deleted from the TOC</span> </h2>
23997 <h2> <span dir="ltr" style="font-style: italic">Attributes after dir on these span tags must be deleted from the TOC</span> </h2>
23998 !! end
23999
24000 !! test
24001 T74884: bdi element in ToC
24002 !! wikitext
24003 __TOC__
24004 == <bdi>test</bdi> ==
24005 !! html/php
24006 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
24007 <ul>
24008 <li class="toclevel-1 tocsection-1"><a href="#test"><span class="tocnumber">1</span> <span class="toctext"><bdi>test</bdi></span></a></li>
24009 </ul>
24010 </div>
24011
24012 <h2><span class="mw-headline" id="test"><bdi>test</bdi></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: test">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
24013
24014 !! html/parsoid
24015 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24016 <h2 data-parsoid='{}'> <bdi>test</bdi> </h2>
24017 !! end
24018
24019 !! test
24020 T35715: s/strike element in ToC
24021 !! wikitext
24022 __TOC__
24023 == <s>test</s> test <strike>test</strike> ==
24024 !! html/php
24025 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
24026 <ul>
24027 <li class="toclevel-1 tocsection-1"><a href="#test_test_test"><span class="tocnumber">1</span> <span class="toctext"><s>test</s> test <strike>test</strike></span></a></li>
24028 </ul>
24029 </div>
24030
24031 <h2><span class="mw-headline" id="test_test_test"><s>test</s> test <strike>test</strike></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: test test test">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
24032
24033 !! html/parsoid
24034 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24035 <h2 data-parsoid='{}'> <s>test</s> test <strike>test</strike> </h2>
24036 !! end
24037
24038 # Note that the html output does not have the <p></p>, but the
24039 # html+tidy output *does*. This is because the empty <p></p> is
24040 # removed by the sanitizer, but only when tidy is *not* enabled (!).
24041 !! test
24042 Empty <p> tag in TOC, removed by Sanitizer (T92892)
24043 !! wikitext
24044 __TOC__
24045 == x ==
24046 !! html/php
24047 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
24048 <ul>
24049 <li class="toclevel-1 tocsection-1"><a href="#x"><span class="tocnumber">1</span> <span class="toctext">x</span></a></li>
24050 </ul>
24051 </div>
24052
24053 <h2><span class="mw-headline" id="x">x</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: x">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
24054
24055 !! html/php+tidy
24056 <p></p>
24057 <div id="toc" class="toc">
24058 <div class="toctitle">
24059 <h2>Contents</h2>
24060 </div>
24061 <ul>
24062 <li class="toclevel-1 tocsection-1"><a href="#x"><span class="tocnumber">1</span> <span class="toctext">x</span></a></li>
24063 </ul>
24064 </div>
24065 <p></p>
24066 <h2><span class="mw-headline" id="x">x</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: x">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
24067 !! html/parsoid
24068 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24069 <h2 data-parsoid='{}'> x </h2>
24070 !! end
24071
24072 !! article
24073 MediaWiki:T34057
24074 !! text
24075 == {{int:headline_sample}} ==
24076 !! endarticle
24077
24078 !! test
24079 T34057: Title needed when expanding <h> nodes.
24080 !! options
24081 title=[[Main Page]]
24082 !! wikitext
24083 {{int:T34057}}
24084 !! html
24085 <h2><span class="mw-headline" id="Headline_text">Headline text</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Main_Page&amp;action=edit&amp;section=1" title="Edit section: Headline text">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
24086
24087 !! end
24088
24089 !! test
24090 Strip marker in urlencode
24091 !! wikitext
24092 {{urlencode:x<nowiki/>y}}
24093 {{urlencode:x<nowiki/>y|wiki}}
24094 {{urlencode:x<nowiki/>y|path}}
24095 {{urlencode:x<pre id="one">two</pre>y}}
24096 !! html/php
24097 <p>xy
24098 xy
24099 xy
24100 xy
24101 </p>
24102 !! end
24103
24104 !! test
24105 Strip marker in lc
24106 !! wikitext
24107 {{lc:x<nowiki/>y}}
24108 !! html
24109 <p>xy
24110 </p>
24111 !! end
24112
24113 !! test
24114 Strip marker in uc
24115 !! wikitext
24116 {{uc:x<nowiki/>y}}
24117 !! html
24118 <p>XY
24119 </p>
24120 !! end
24121
24122 !! test
24123 Strip marker in formatNum
24124 !! wikitext
24125 {{formatnum:1<nowiki/>2}}
24126 {{formatnum:1<nowiki/>2|R}}
24127 !! html
24128 <p>12
24129 12
24130 </p>
24131 !! end
24132
24133 !! test
24134 Check noCommafy in formatNum
24135 !! options
24136 language=be-tarask
24137 !! wikitext
24138 {{formatnum:123456.78}}
24139 {{formatnum:123456.78|NOSEP}}
24140 !! html
24141 <p>123 456,78
24142 123456.78
24143 </p>
24144 !! end
24145
24146 !! test
24147 Wrong option for formatNum (T58199)
24148 !! wikitext
24149 {{formatnum:1,234.56|Random}}
24150 {{formatnum:1,234.56|EVERYTHING}}
24151 {{formatnum:1234.56|any argument that has the string 'NOSEP'}}
24152 !! html
24153 <p>1,234.56
24154 1,234.56
24155 1,234.56
24156 </p>
24157 !! end
24158
24159 !! test
24160 Strip marker in grammar
24161 !! options
24162 language=fi
24163 !! wikitext
24164 {{grammar:elative|foo<nowiki/>bar}}
24165 !! html
24166 <p>foobarista
24167 </p>
24168 !! end
24169
24170 !! test
24171 Strip marker in padleft
24172 !! wikitext
24173 {{padleft:|2|x<nowiki/>y}}
24174 !! html
24175 <p>xy
24176 </p>
24177 !! end
24178
24179 !! test
24180 Strip marker in padright
24181 !! wikitext
24182 {{padright:|2|x<nowiki/>y}}
24183 !! html
24184 <p>xy
24185 </p>
24186 !! end
24187
24188 !! test
24189 Strip marker in anchorencode
24190 !! wikitext
24191 {{anchorencode:x<nowiki/>y}}
24192 !! html
24193 <p>xy
24194 </p>
24195 !! end
24196
24197 !! test
24198 nowiki inside link inside heading (T20295)
24199 !! wikitext
24200 ==[[foo|x<nowiki>y</nowiki>z]]==
24201 !! html
24202 <h2><span class="mw-headline" id="xyz"><a href="/wiki/Foo" title="Foo">xyz</a></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: xyz">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
24203
24204 !! end
24205
24206 !! test
24207 new support for bdi element (T33817)
24208 !! wikitext
24209 <p dir="rtl" lang="he">ולדימיר לנין (ברוסית: <bdi lang="ru">Владимир Ленин</bdi>, 24 באפריל 1870–22 בינואר 1924) הוא מנהיג פוליטי קומוניסטי רוסי.</p>
24210 !! html
24211 <p dir="rtl" lang="he">ולדימיר לנין (ברוסית: <bdi lang="ru">Владимир Ленин</bdi>, 24 באפריל 1870–22 בינואר 1924) הוא מנהיג פוליטי קומוניסטי רוסי.</p>
24212
24213 !!end
24214
24215 !! test
24216 Ignore pipe between table row attributes
24217 !! wikitext
24218 {|
24219 | quux
24220 |- id=foo | style='color: red'
24221 | bar
24222 |}
24223 !! html
24224 <table>
24225 <tr>
24226 <td> quux
24227 </td></tr>
24228 <tr id="foo" style="color: red">
24229 <td> bar
24230 </td></tr></table>
24231
24232 !! end
24233
24234 !!test
24235 Language parser function
24236 !! wikitext
24237 {{#language:ar}}
24238 !! html
24239 <p>العربية
24240 </p>
24241 !! end
24242
24243 !!test
24244 Padleft and padright as substr
24245 !! wikitext
24246 {{padleft:|3|abcde}}
24247 {{padright:|3|abcde}}
24248 !! html
24249 <p>abc
24250 abc
24251 </p>
24252 !! end
24253
24254 !!test
24255 Special parser function
24256 !! wikitext
24257 {{#special:RandomPage}}
24258 {{#special:BaDtItLe}}
24259 {{#special:Foobar}}
24260 !! html
24261 <p>Special:Random
24262 Special:Badtitle
24263 Special:Foobar
24264 </p>
24265 !! end
24266
24267 !!test
24268 T36939 - Case insensitive link parsing ([HttP://])
24269 !! wikitext
24270 [HttP://MediaWiki.Org/]
24271 !! html/php
24272 <p><a rel="nofollow" class="external autonumber" href="HttP://MediaWiki.Org/">[1]</a>
24273 </p>
24274 !! html/parsoid
24275 <p><a rel="mw:ExtLink" href="HttP://MediaWiki.Org/"></a></p>
24276 !! end
24277
24278 !!test
24279 T36939 - Case insensitive link parsing ([HttP:// title])
24280 !! wikitext
24281 [HttP://MediaWiki.Org/ MediaWiki]
24282 !! html
24283 <p><a rel="nofollow" class="external text" href="HttP://MediaWiki.Org/">MediaWiki</a>
24284 </p>
24285 !! end
24286
24287 !!test
24288 T36939 - Case insensitive link parsing (HttP://)
24289 !! wikitext
24290 HttP://MediaWiki.Org/
24291 !! html/php
24292 <p><a rel="nofollow" class="external free" href="HttP://MediaWiki.Org/">HttP://MediaWiki.Org/</a>
24293 </p>
24294 !! html/parsoid
24295 <p><a rel="mw:ExtLink" href="HttP://MediaWiki.Org/">HttP://MediaWiki.Org/</a></p>
24296 !! end
24297
24298 !!test
24299 Disable TOC
24300 !! options
24301 notoc
24302 !! wikitext
24303 Lead
24304 == Section 1 ==
24305 == Section 2 ==
24306 == Section 3 ==
24307 == Section 4 ==
24308 == Section 5 ==
24309 !! html
24310 <p>Lead
24311 </p>
24312
24313 <h2><span class="mw-headline" id="Section_1">Section 1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: Section 1">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
24314 <h2><span class="mw-headline" id="Section_2">Section 2</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: Section 2">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
24315 <h2><span class="mw-headline" id="Section_3">Section 3</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=3" title="Edit section: Section 3">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
24316 <h2><span class="mw-headline" id="Section_4">Section 4</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=4" title="Edit section: Section 4">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
24317 <h2><span class="mw-headline" id="Section_5">Section 5</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=5" title="Edit section: Section 5">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
24318
24319 !! end
24320
24321
24322 ###
24323 ### Parsoid-specific tests
24324 ### Parsoid-PHP parser incompatibilities
24325 ###
24326 !!test
24327 1. SOL-sensitive wikitext tokens as template-args
24328 !!options
24329 parsoid=wt2html,wt2wt
24330 !! wikitext
24331 {{echo|*a}}
24332 {{echo|#a}}
24333 {{echo|:a}}
24334 !! html
24335 <span about="#mwt1" typeof="mw:Transclusion">
24336 </span><ul about="#mwt1"><li>a</li>
24337 </ul>
24338 <span about="#mwt2" typeof="mw:Transclusion">
24339 </span><ol about="#mwt2"><li>a</li>
24340 </ol>
24341 <span about="#mwt3" typeof="mw:Transclusion">
24342 </span><dl about="#mwt3"><dd>a</dd>
24343 </dl>
24344 !!end
24345
24346 #### -----------------------------------------------------------------
24347 #### Parsoid-specific functionality tests
24348 #### -----------------------------------------------------------------
24349
24350 # T65642/T68749: Formatting elt fixup around images is cleaned up.
24351 # We know wt2wt will fail, but we expect selser to pass.
24352 # Due to the nature of our testing, wt2wt and selser tests will enter the
24353 # blacklist and we'll catch selser regressions based on changes to the
24354 # blacklist entries for selser tests.
24355 !! test
24356 1. Bad treebuilder fixup of formatting elt is cleaned up
24357 !! options
24358 parsoid=wt2html,wt2wt
24359 !! wikitext
24360 {|
24361 |
24362 <small>
24363 [[Image:Foobar.jpg|right|Test]]
24364 </small>
24365 |}
24366 !! html/parsoid
24367 <table>
24368 <tbody><tr><td>
24369 <small>
24370 <figure class="mw-default-size mw-halign-right" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a><figcaption>Test</figcaption></figure>
24371 </small>
24372 </td></tr>
24373 </tbody></table>
24374 !! end
24375
24376 !! test
24377 2. Bad treebuilder fixup of formatting elt is cleaned up
24378 !! options
24379 parsoid=wt2html,wt2wt
24380 !! wikitext
24381 '''foo[[File:Foobar.jpg|thumb|caption]]bar'''
24382
24383 <small>[[Image:Foobar.jpg|right|300px]]</small>
24384 !! html/parsoid
24385
24386 <p><b>foo</b></p>
24387 <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption><b>caption</b></figcaption></figure>
24388 <p><b>bar</b></p>
24389 <small><figure class="mw-halign-right" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="34" width="300"/></a></figure></small>
24390 !! end
24391
24392 !! test
24393 3. Bad treebuilder fixup of formatting elt is cleaned up
24394 !! options
24395 parsoid=wt2html,wt2wt
24396 !! wikitext
24397 <small>'''foo[[File:Foobar.jpg|thumb|caption]]bar'''</small>
24398 !! html/parsoid
24399 <p><small><b>foo</b></small></p>
24400 <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption><small><b>caption</b></small></figcaption></figure>
24401 <p><small><b>bar</b></small></p>
24402 !! end
24403
24404 !! test
24405 4. Bad treebuilder fixup of formatting elt is cleaned up: formatting tags around captionless images are ignored
24406 !! options
24407 parsoid=wt2html,wt2wt
24408 !! wikitext
24409 '''<small>[[Image:Foobar.jpg|right|300px]]</small>'''
24410 !! html/parsoid
24411 <p><b><small></small></b></p>
24412 <figure class="mw-halign-right" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="34" width="300"/></a></figure>
24413 <p></p>
24414 !! end
24415
24416 #### ----------------------------------------------------------------
24417 #### Parsoid-only testing of Parsoid's impl of LST
24418 #### Not implemented yet, see
24419 #### https://www.mediawiki.org/wiki/Parsoid/HTML_based_LST
24420 #### ----------------------------------------------------------------
24421
24422 ## We still need to support serializing the older format while content is stored.
24423 !! test
24424 LST Sections: Backwards compatibility
24425 !! options
24426 parsoid={
24427 "suppressErrors": true,
24428 "modes": ["html2wt"]
24429 }
24430 !! wikitext
24431 <section begin="2011-05-16" />
24432 <section end="2014-04-10 (MW 1.23wmf22)" />
24433 !! html/parsoid
24434 <p><meta typeof="mw:Extension/LabeledSectionTransclusion/begin" content="2011-05-16"/>
24435 <meta typeof="mw:Extension/LabeledSectionTransclusion/end" content="2014-04-10 (MW 1.23wmf22)"/></p>
24436 !! end
24437
24438 !! test
24439 LST Sections: Newfangled approach
24440 !! wikitext
24441 <section begin="2011-05-16" />
24442 <section end="2014-04-10 (MW 1.23wmf22)" />
24443 !! html/parsoid
24444 <p><span typeof="mw:Extension/section" about="#mwt4" data-mw='{"name":"section","attrs":{"begin":"2011-05-16"},"body":null}'>
24445 </span>
24446 <span typeof="mw:Extension/section" about="#mwt6" data-mw='{"name":"section","attrs":{"end":"2014-04-10 (MW 1.23wmf22)"},"body":null}'>
24447 </span></p>
24448 !! end
24449
24450 #--------- Test stripping of empty nodes in template content ----------
24451
24452 !! test
24453 Empty LI and TR nodes should be stripped from template content
24454 !! wikitext
24455 {{EmptyLITest}}
24456 {{EmptyTRTest}}
24457 !! html/parsoid
24458 <ul about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyLITest","href":"./Template:EmptyLITest"},"params":{},"i":0}}]}'>
24459 <li>a</li>
24460 <li>b</li>
24461 </ul>
24462 <table about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyTRTest","href":"./Template:EmptyTRTest"},"params":{},"i":0}}]}'>
24463 <tbody>
24464 <tr>
24465 <td>foo</td>
24466 </tr>
24467 <tr>
24468 <td>bar</td>
24469 </tr>
24470 </tbody>
24471 </table>
24472 !! end
24473
24474 !! test
24475 Empty LI and TR nodes should not be stripped from top-level content
24476 !! wikitext
24477 * a
24478 *
24479 * b
24480 {|
24481 |-
24482 |-
24483 |foo
24484 |}
24485 !! html/parsoid
24486 <ul>
24487 <li> a</li>
24488 <li></li>
24489 <li> b</li>
24490 </ul>
24491 <table>
24492 <tbody>
24493 <tr></tr>
24494 <tr>
24495 <td>foo</td>
24496 </tr>
24497 </tbody>
24498 </table>
24499 !! end
24500
24501 !! test
24502 Empty TR nodes should not be stripped if they have any attributes set
24503 !! wikitext
24504 {{EmptyTRWithHTMLAttrTest}}
24505 !! html/parsoid
24506 <table about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyTRWithHTMLAttrTest","href":"./Template:EmptyTRWithHTMLAttrTest"},"params":{},"i":0}}]}'>
24507 <tr align="center"></tr>
24508 <tr><td>foo</td></tr>
24509 <tr align="center"></tr>
24510 <tr><td>bar</td></tr>
24511 </table>
24512 !! end
24513
24514 #### ----------------------------------------------------------------
24515 #### The following section of tests are primarily to test
24516 #### wikitext escaping capabilities of Parsoid. Given that
24517 #### escaping can be done any number of ways, the wikitext (input)
24518 #### is always adjusted to reflect how Parsoid adds nowiki
24519 #### escape tags.
24520 ####
24521 #### We are marking several tests as parsoid-only since the
24522 #### HTML in the result section is different from what the
24523 #### PHP parser generates for it.
24524 #### ----------------------------------------------------------------
24525
24526
24527 #### --------------- Headings ---------------
24528 #### 0. Unnested
24529 #### 1. Nested inside html <h1>=foo=</h1>
24530 #### 2. Outside heading nest on a single line <h1>foo</h1>*bar
24531 #### 3. Nested inside html with wikitext split by html tags
24532 #### 4. No escape needed
24533 #### 5. Empty headings <h1></h1>
24534 #### 6. Heading chars in SOL context
24535 #### ----------------------------------------
24536 !! test
24537 Headings: 0. Unnested
24538 !! options
24539 parsoid=html2wt
24540 !! html/parsoid
24541 <p>=foo=</p>
24542
24543 <p> =foo=
24544 <!--cmt-->
24545 =foo=</p>
24546
24547 <p>=foo<i>a</i>=</p>
24548 !! wikitext
24549 <nowiki>=foo=</nowiki>
24550
24551 <nowiki> </nowiki>=foo=
24552 <!--cmt-->
24553 <nowiki>=foo=</nowiki>
24554
24555 =foo''a''<nowiki>=</nowiki>
24556 !!end
24557
24558 # New headings and existing headings are handled differently
24559 !! test
24560 Headings: 1. Nested inside html
24561 !! options
24562 parsoid=html2wt
24563 !! html/parsoid
24564 <h1>=foo=</h1>
24565 <h2>=foo=</h2>
24566 <h3>=foo=</h3>
24567
24568 <h1 data-parsoid=''>=foo=</h1>
24569 <h2 data-parsoid=''>=foo=</h2>
24570 <h3 data-parsoid=''>=foo=</h3>
24571 <h4 data-parsoid=''>=foo=</h4>
24572 <h5 data-parsoid=''>=foo=</h5>
24573 <h6 data-parsoid=''>=foo=</h6>
24574 !! wikitext
24575 = =foo= =
24576
24577 == =foo= ==
24578
24579 === =foo= ===
24580
24581 =<nowiki>=foo=</nowiki>=
24582 ==<nowiki>=foo=</nowiki>==
24583 ===<nowiki>=foo=</nowiki>===
24584 ====<nowiki>=foo=</nowiki>====
24585 =====<nowiki>=foo=</nowiki>=====
24586 ======<nowiki>=foo=</nowiki>======
24587
24588 !!end
24589
24590 !! test
24591 Headings: 2. Outside heading nest on a single line <h1>foo</h1>*bar
24592 !! options
24593 parsoid=html2wt
24594 !! html/parsoid
24595 <h1>foo</h1>*bar
24596 <h1>foo</h1>=bar
24597 <h1>foo</h1>=bar=
24598 !! wikitext
24599 = foo =
24600 <nowiki>*</nowiki>bar
24601
24602 = foo =
24603 =bar
24604
24605 = foo =
24606 <nowiki>=bar=</nowiki>
24607 !!end
24608
24609 !! test
24610 Headings: 3. Nested inside html with wikitext split by html tags
24611 !! options
24612 parsoid=html2wt
24613 !! html/parsoid
24614 <h1>=<b>bold</b>foo=</h1>
24615 !! wikitext
24616 = ='''bold'''foo= =
24617 !!end
24618
24619 !! test
24620 Headings: 4a. No escaping needed (testing just h1 and h2)
24621 !! options
24622 parsoid=html2wt
24623 !! html/parsoid
24624 <h1>=foo</h1>
24625 <h1>foo=</h1>
24626 <h1> =foo= </h1>
24627 <h1>=foo= bar</h1>
24628 <h2>=foo</h2>
24629 <h2>foo=</h2>
24630 <h1>=</h1>
24631 <h1><i>=</i>foo=</h1>
24632 !! wikitext
24633 = =foo =
24634
24635 = foo= =
24636
24637 = =foo= =
24638
24639 = =foo= bar =
24640
24641 == =foo ==
24642
24643 == foo= ==
24644
24645 = = =
24646
24647 = ''=''foo= =
24648 !!end
24649
24650 !! test
24651 Headings: 4b. No escaping needed (inside p-tags)
24652 !! options
24653 parsoid=html2wt
24654 !! html/parsoid
24655 <p>===
24656 =foo= x
24657 =foo= <s></s>
24658 </p>
24659 !! wikitext
24660 ===
24661 =foo= x
24662 =foo= <s></s>
24663 !!end
24664
24665 !! test
24666 Headings: 5. Empty headings
24667 !! options
24668 parsoid=html2wt
24669 !! html/parsoid
24670 <h1 data-parsoid='{}'></h1>
24671
24672 <h2 data-parsoid='{}'></h2>
24673
24674 <h3 data-parsoid='{}'></h3>
24675
24676 <h4 data-parsoid='{}'></h4>
24677
24678 <h5 data-parsoid='{}'></h5>
24679
24680 <h6 data-parsoid='{}'></h6>
24681 !! wikitext
24682 =<nowiki/>=
24683
24684 ==<nowiki/>==
24685
24686 ===<nowiki/>===
24687
24688 ====<nowiki/>====
24689
24690 =====<nowiki/>=====
24691
24692 ======<nowiki/>======
24693 !!end
24694
24695 !! test
24696 Headings: 6a. Heading chars in SOL context (with trailing spaces)
24697 !! options
24698 parsoid=html2wt
24699 !! html/parsoid
24700 <p>=a=</p>
24701
24702 <p>=a=</p>
24703
24704 <p>=a=</p>
24705 !! wikitext
24706 <nowiki>=a=</nowiki>
24707
24708 <nowiki>=a=</nowiki>
24709
24710 <nowiki>=a=</nowiki>
24711 !!end
24712
24713 !! test
24714 Headings: 6b. Heading chars in SOL context (with trailing newlines)
24715 !! options
24716 parsoid=html2wt
24717 !! html/parsoid
24718 <p>=a=
24719 b</p>
24720
24721 <p>=a=
24722 b</p>
24723
24724 <p>=a=
24725 b</p>
24726 !! wikitext
24727 <nowiki>=a=</nowiki>
24728 b
24729
24730 <nowiki>=a=</nowiki>
24731 b
24732
24733 <nowiki>=a=</nowiki>
24734 b
24735 !!end
24736
24737 !! test
24738 Headings: 6c. Heading chars in SOL context (leading newline break)
24739 !! options
24740 parsoid=html2wt
24741 !! html/parsoid
24742 <p>a
24743 =b=</p>
24744 !! wikitext
24745 a
24746 <nowiki>=b=</nowiki>
24747 !!end
24748
24749 !! test
24750 Headings: 6d. Heading chars in SOL context (with interspersed comments)
24751 !! options
24752 parsoid=html2wt
24753 !! html/parsoid
24754 <!--c0--><p>=a=</p>
24755
24756 <!--c1--><p>=a=</p> <!--c2--> <!--c3-->
24757 !! wikitext
24758 <!--c0--><nowiki>=a=</nowiki>
24759
24760 <!--c1--><nowiki>=a=</nowiki> <!--c2--> <!--c3-->
24761 !!end
24762
24763 !! test
24764 Headings: 6d. Heading chars in SOL context (No escaping needed)
24765 !! options
24766 parsoid=html2wt
24767 !! html/parsoid
24768 =a=<div>b</div>
24769 !! wikitext
24770 =a=<div>b</div>
24771 !!end
24772
24773 !! test
24774 Headings: 7. Insert a newline between new content and headings
24775 !! options
24776 parsoid=html2wt
24777 !! html/parsoid
24778 <h2>NEW</h2>
24779 <p>new</p>
24780 <h2 data-parsoid='{}'>A</h2>
24781 <p data-parsoid='{}'>a</p>
24782 !! wikitext
24783 == NEW ==
24784 new
24785
24786 ==A==
24787 a
24788
24789 !! end
24790
24791 #### --------------- Lists ---------------
24792 #### 0. Outside nests (*foo, etc.)
24793 #### 1. Nested inside html <ul><li>*foo</li></ul>
24794 #### 2. Inside definition lists
24795 #### 3. Only bullets at start should be escaped
24796 #### 4. No escapes needed
24797 #### 5. No unnecessary escapes
24798 #### 6. Escape bullets in SOL position
24799 #### 7. Escape bullets in a multi-line context
24800 #### ----------------------------------------
24801
24802 !! test
24803 Lists: 0. Outside nests
24804 !! options
24805 parsoid=html2wt
24806 !! html/parsoid
24807 <p>*foo</p>
24808
24809 <p>#foo</p>
24810
24811 <p>;Foo:bar</p>
24812 !! wikitext
24813 <nowiki>*</nowiki>foo
24814
24815 <nowiki>#</nowiki>foo
24816
24817 <nowiki>;</nowiki>Foo<nowiki>:</nowiki>bar
24818 !!end
24819
24820 ## Making these next 3 tests Parsoid-only since they are html2wt tests
24821 ## to test wikitext escaping, and insignificant whitespace diffs
24822 ## cause PHP parser tests to barf
24823 !! test
24824 Lists: 1. Nested inside html (No unnecessary escapes)
24825 !! options
24826 parsoid=html2wt
24827 !! html/parsoid
24828 <ul>
24829 <li>*foo</li>
24830 <li>#foo</li>
24831 <li>:foo</li>
24832 <li>;foo</li>
24833 <li data-parsoid='{}'>*foo</li>
24834 <li data-parsoid='{}'>#foo</li>
24835 <li data-parsoid='{}'>:foo</li>
24836 <li data-parsoid='{}'>;foo</li>
24837 </ul>
24838
24839 <ol>
24840 <li>*foo</li>
24841 <li>#foo</li>
24842 <li>:foo</li>
24843 <li>;foo</li>
24844 <li data-parsoid='{}'>*foo</li>
24845 <li data-parsoid='{}'>#foo</li>
24846 <li data-parsoid='{}'>:foo</li>
24847 <li data-parsoid='{}'>;foo</li>
24848 </ol>
24849 !! wikitext
24850 * *foo
24851 * #foo
24852 * :foo
24853 * ;foo
24854 *<nowiki>*foo</nowiki>
24855 *<nowiki>#foo</nowiki>
24856 *<nowiki>:foo</nowiki>
24857 *<nowiki>;foo</nowiki>
24858
24859 # *foo
24860 # #foo
24861 # :foo
24862 # ;foo
24863 #<nowiki>*foo</nowiki>
24864 #<nowiki>#foo</nowiki>
24865 #<nowiki>:foo</nowiki>
24866 #<nowiki>;foo</nowiki>
24867 !!end
24868
24869 !! test
24870 Lists: 2. Inside definition lists
24871 !! options
24872 parsoid=html2wt
24873 !! html/parsoid
24874 <dl><dt>;foo</dt></dl>
24875 <dl><dt>:foo</dt></dl>
24876 <dl><dt>:foo</dt>
24877 <dd>bar</dd></dl>
24878 <dl><dd>:foo</dd></dl>
24879 !! wikitext
24880 ; ;foo
24881
24882 ; <nowiki>:foo</nowiki>
24883
24884 ; <nowiki>:foo</nowiki>
24885 : bar
24886
24887 : :foo
24888 !!end
24889
24890 !! test
24891 Lists: 3. Only bullets at start of text in wikitext-generated HTML should be escaped
24892 !! options
24893 parsoid=html2wt
24894 !! html/parsoid
24895 <ul>
24896 <li>*foo*bar</li>
24897 <li data-parsoid='{}'>*foo<i>it</i>*bar</li>
24898 </ul>
24899 !! wikitext
24900 * *foo*bar
24901 *<nowiki>*foo</nowiki>''it''*bar
24902 !!end
24903
24904 !! test
24905 Lists: 4. No escapes needed
24906 !! options
24907 parsoid=html2wt
24908 !! html/parsoid
24909 <ul>
24910 <li>foo*bar
24911 </li>
24912 </ul>
24913 <ul>
24914 <li><i>foo</i>*bar
24915 </li>
24916 </ul>
24917 <ul>
24918 <li><a rel="mw:WikiLink" href="Foo" title="Foo">Foo</a>: bar
24919 </li>
24920 </ul>
24921 <ul>
24922 <li><a rel="mw:WikiLink" href="Foo" title="Foo">Foo</a>*bar
24923 </li>
24924 </ul>
24925 !! wikitext
24926 *foo*bar
24927
24928 *''foo''*bar
24929
24930 *[[Foo]]: bar
24931
24932 *[[Foo]]*bar
24933 !!end
24934
24935 !! test
24936 Lists: 5. No unnecessary escapes
24937 !! options
24938 parsoid=html2wt
24939 !! html/parsoid
24940 <ul><li> bar <span>[[foo]]</span></li></ul>
24941 <ul><li> =bar <span>[[foo]]</span></li></ul>
24942 <ul><li> [[bar <span>[[foo]]</span></li></ul>
24943 <ul><li> ]]bar <span>[[foo]]</span></li></ul>
24944 <ul><li> =bar <span>foo]]</span>=</li></ul>
24945 <ul><li> <s></s>: a</li></ul>
24946 <ul><li> <i>* foo</i></li></ul>
24947
24948 !! wikitext
24949 * bar <span><nowiki>[[foo]]</nowiki></span>
24950
24951 * =bar <span><nowiki>[[foo]]</nowiki></span>
24952
24953 * [[bar <span><nowiki>[[foo]]</nowiki></span>
24954
24955 * ]]bar <span><nowiki>[[foo]]</nowiki></span>
24956
24957 * =bar <span>foo]]</span>=
24958
24959 * <s></s>: a
24960
24961 * ''* foo''
24962 !!end
24963
24964 !! test
24965 Lists: 6. Escape bullets in SOL position
24966 !! options
24967 parsoid=html2wt
24968 !! html/parsoid
24969 <p><!--cmt-->*foo</p>
24970 !! wikitext
24971 <!--cmt--><nowiki>*</nowiki>foo
24972 !!end
24973
24974 !! test
24975 Lists: 7. Escape bullets in a multi-line context
24976 !! options
24977 parsoid=html2wt
24978 !! html/parsoid
24979 <p>a
24980 *b
24981 </p>
24982 !! wikitext
24983 a
24984 <nowiki>*</nowiki>b
24985 !!end
24986
24987 !! test
24988 Lists: 8. Escape colons only if not present in tags
24989 !! options
24990 parsoid=html2wt
24991 !! html/parsoid
24992 <dl><dt>a:b<i>c:d</i></dt></dl>
24993 !! wikitext
24994 ; <nowiki>a:b</nowiki>''c:d''
24995 !! end
24996
24997 #### --------------- HRs ---------------
24998 #### 1. Single line
24999 #### -----------------------------------
25000
25001 !! test
25002 HRs: 1. Single line
25003 !! options
25004 parsoid=html2wt
25005 !! html/parsoid
25006 <hr />----
25007 <hr />=foo=
25008 <hr />*foo
25009 !! wikitext
25010 ----<nowiki>----</nowiki>
25011 ----=foo=
25012 ----*foo
25013 !! end
25014
25015 #### --------------- Tables ---------------
25016 #### 1a. Simple example
25017 #### 1b. No escaping needed (!foo)
25018 #### 1c. No escaping needed (|foo)
25019 #### 1d. No escaping needed (|}foo)
25020 ####
25021 #### 2a. Nested in td (<td>foo|bar</td>)
25022 #### 2b. Nested in td (<td>foo||bar</td>)
25023 #### 2c. Nested in td -- no escaping needed(<td>foo!!bar</td>)
25024 ####
25025 #### 3a. Nested in th (<th>foo!bar</th>)
25026 #### 3b. Nested in th (<th>foo!!bar</th>)
25027 #### 3c. Nested in th -- no escaping needed(<th>foo||bar</th>)
25028 ####
25029 #### 4a. Escape -
25030 #### 4b. Escape +
25031 #### 4c. No escaping needed
25032 #### --------------------------------------
25033
25034 !! test
25035 Tables: 1a. Simple example
25036 !! options
25037 parsoid=html2wt
25038 !! html/parsoid
25039 <p>{|
25040 |}
25041 </p>
25042 !! wikitext
25043 <nowiki>{|</nowiki>
25044 |}
25045 !! end
25046
25047 !! test
25048 Tables: 1b. No escaping needed
25049 !! options
25050 parsoid=html2wt
25051 !! html/parsoid
25052 <p>!foo
25053 </p>
25054 !! wikitext
25055 !foo
25056 !! end
25057
25058 !! test
25059 Tables: 1c. No escaping needed
25060 !! options
25061 parsoid=html2wt
25062 !! html/parsoid
25063 <p>|foo
25064 </p>
25065 !! wikitext
25066 |foo
25067 !! end
25068
25069 !! test
25070 Tables: 1d. No escaping needed
25071 !! options
25072 parsoid=html2wt
25073 !! html/parsoid
25074 <p>|}foo
25075 </p>
25076 !! wikitext
25077 |}foo
25078 !! end
25079
25080 !! test
25081 Tables: 2a. Nested in td
25082 !! options
25083 parsoid=html2wt
25084 !! html/parsoid
25085 <table><tbody><tr>
25086 <td>foo|bar</td></tr>
25087 <tr><td>x<div>a|b</div></td>
25088 </tbody></table>
25089 !! wikitext
25090 {|
25091 |<nowiki>foo|bar</nowiki>
25092 |-
25093 |x<div><nowiki>a|b</nowiki></div>
25094 |}
25095 !! html/php+tidy
25096 <table>
25097 <tr>
25098 <td>foo|bar</td>
25099 </tr>
25100 <tr>
25101 <td>x
25102 <div>a|b</div>
25103 </td>
25104 </tr>
25105 </table>
25106 !! end
25107
25108 !! test
25109 Tables: 2b. Nested in td
25110 !! options
25111 parsoid=html2wt
25112 !! html/parsoid
25113 <table><tbody><tr>
25114 <td>foo||bar</td>
25115 <td>a<i>b||c</i></td>
25116 <td>a<i><div>b||c</div></i></td>
25117 </tr></tbody></table>
25118 !! wikitext
25119 {|
25120 |<nowiki>foo||bar</nowiki>
25121 |a''<nowiki>b||c</nowiki>''
25122 |a''<div><nowiki>b||c</nowiki></div>''
25123 |}
25124 !! html/php
25125 <table>
25126 <tr>
25127 <td>foo||bar
25128 </td>
25129 <td>a<i>b||c</i>
25130 </td>
25131 <td>a<i><div>b||c</div></i>
25132 </td></tr></table>
25133
25134 !! end
25135
25136 !! test
25137 Tables: 2c. Nested in td -- no escaping needed
25138 !! options
25139 parsoid=html2wt
25140 !! html/*
25141 <table>
25142 <tr>
25143 <td>foo!!bar
25144 </td></tr></table>
25145
25146 !! wikitext
25147 {|
25148 |foo!!bar
25149 |}
25150 !! end
25151
25152 !! test
25153 Tables: 3a. Nested in th
25154 !! options
25155 parsoid=html2wt
25156 !! html/*
25157 <table>
25158 <tr>
25159 <th>foo!bar
25160 </th></tr></table>
25161
25162 !! wikitext
25163 {|
25164 !foo!bar
25165 |}
25166 !! end
25167
25168 !! test
25169 Tables: 3b. Nested in th
25170 !! options
25171 parsoid=html2wt
25172 !! html/parsoid
25173 <table><tbody>
25174 <tr><th>foo!!bar</th>
25175 <th><i>foo|bar</i></th>
25176 <th><i>foo!!bar</i></th>
25177 <th><i><span>foo!!bar</span></i></th>
25178 </tr></tbody></table>
25179 !! wikitext
25180 {|
25181 !<nowiki>foo!!bar</nowiki>
25182 !''<nowiki>foo|bar</nowiki>''
25183 !''<nowiki>foo!!bar</nowiki>''
25184 !''<span><nowiki>foo!!bar</nowiki></span>''
25185 |}
25186 !! html/php
25187 <table>
25188 <tr>
25189 <th>foo!!bar
25190 </th>
25191 <th><i>foo|bar</i>
25192 </th>
25193 <th><i>foo!!bar</i>
25194 </th>
25195 <th><i><span>foo!!bar</span></i>
25196 </th></tr></table>
25197
25198 !! end
25199
25200 !! test
25201 Tables: 3c. Nested in th
25202 !! options
25203 parsoid=html2wt
25204 !! html/parsoid
25205 <table><tbody>
25206 <tr><th>foo||bar</th>
25207 <th><span typeof="mw:Nowiki">foo||bar</span></th>
25208 </tr></tbody></table>
25209 !! wikitext
25210 {|
25211 !<nowiki>foo||bar</nowiki>
25212 !<nowiki>foo||bar</nowiki>
25213 |}
25214 !! html/php
25215 <table>
25216 <tr>
25217 <th>foo||bar
25218 </th>
25219 <th>foo||bar
25220 </th></tr></table>
25221
25222 !! end
25223
25224 !! test
25225 Tables: 4a. Escape -
25226 !! options
25227 parsoid=html2wt
25228 !! html/*
25229 <table>
25230 <tr>
25231 <th>-bar
25232 </th></tr>
25233 <tr>
25234 <td>-bar
25235 </td></tr></table>
25236
25237 !! wikitext
25238 {|
25239 !-bar
25240 |-
25241 |<nowiki>-bar</nowiki>
25242 |}
25243 !! end
25244
25245 !! test
25246 Tables: 4b. Escape +
25247 !! options
25248 parsoid=html2wt
25249 !! html/*
25250 <table>
25251 <tr>
25252 <th>+bar
25253 </th></tr>
25254 <tr>
25255 <td>+bar
25256 </td></tr></table>
25257
25258 !! wikitext
25259 {|
25260 !+bar
25261 |-
25262 |<nowiki>+bar</nowiki>
25263 |}
25264 !! end
25265
25266 !! test
25267 Tables: 4c. No escaping needed
25268 !! options
25269 parsoid=html2wt
25270 !! html/parsoid
25271 <table><tbody>
25272 <tr><td>foo-bar</td><td>foo+bar</td></tr>
25273 <tr><td><i>foo</i>-bar</td><td><i>foo</i>+bar</td></tr>
25274 <tr><td>foo
25275 <p>bar|baz
25276 +bar
25277 -bar</p></td></tr>
25278 <tr><td>x
25279 <div>a|b</div></td>
25280 </tbody></table>
25281 !! wikitext
25282 {|
25283 |foo-bar
25284 |foo+bar
25285 |-
25286 |''foo''-bar
25287 |''foo''+bar
25288 |-
25289 |foo
25290 bar|baz
25291 +bar
25292 -bar
25293 |-
25294 |x
25295 <div>a|b</div>
25296 |}
25297 !! html/php
25298 <table>
25299 <tr>
25300 <td>foo-bar
25301 </td>
25302 <td>foo+bar
25303 </td></tr>
25304 <tr>
25305 <td><i>foo</i>-bar
25306 </td>
25307 <td><i>foo</i>+bar
25308 </td></tr>
25309 <tr>
25310 <td>foo
25311 <p>bar|baz
25312 +bar
25313 -bar
25314 </p>
25315 </td></tr>
25316 <tr>
25317 <td>x
25318 <div>a|b</div>
25319 </td></tr></table>
25320
25321 !! end
25322
25323 !! test
25324 Tables: 4d. No escaping needed
25325 !! options
25326 parsoid=html2wt
25327 !! html/parsoid
25328 <table>
25329 <tbody><tr><td><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a>-bar</td>
25330 <td data-parsoid='{"startTagSrc":"|","attrSepSrc":"|"}'>+1</td>
25331 <td data-parsoid='{"startTagSrc":"|","attrSepSrc":"|"}'>-2</td></tr>
25332 </tbody></table>
25333 !! wikitext
25334 {|
25335 |[[Foo]]-bar
25336 ||+1
25337 ||-2
25338 |}
25339 !! html/php
25340 <table>
25341 <tr>
25342 <td><a href="/wiki/Foo" title="Foo">Foo</a>-bar
25343 </td>
25344 <td>+1
25345 </td>
25346 <td>-2
25347 </td></tr></table>
25348
25349 !! end
25350
25351 !! test
25352 T97430: Don't emit empty nowiki pairs around marker meta tags
25353 !! options
25354 parsoid=html2wt
25355 !! html/parsoid
25356 <p>*This is a long sentence here that will make the nowiki algo split up the nowikis into multiple pairs
25357 |** Make this another long long long sentence forcing the nowiki algo to split up the nowikis.</p>
25358 !! wikitext
25359 <nowiki>*</nowiki>This is a long sentence here that will make the nowiki algo split up the nowikis into multiple pairs
25360 |** Make this another long long long sentence forcing the nowiki algo to split up the nowikis.
25361 !! end
25362
25363 !! test
25364 Unclosed xmlish element in table line shouldn't eat end delimiters
25365 !! options
25366 parsoid=html2wt
25367 !! html/parsoid
25368 <table>
25369 <tbody><tr><td> &lt;foo</td>
25370 <td> bar></td></tr>
25371 </tbody></table>
25372 !! wikitext
25373 {|
25374 | <foo
25375 | bar>
25376 |}
25377 !! html/php
25378 <table>
25379 <tr>
25380 <td> &lt;foo
25381 </td>
25382 <td> bar&gt;
25383 </td></tr></table>
25384
25385 !! end
25386
25387 #### --------------- Links ----------------
25388 #### 1. Quote marks in link text
25389 #### 2. Wikilinks: Escapes needed
25390 #### 3. Wikilinks: No escapes needed
25391 #### 4. Extlinks: Escapes needed
25392 #### 5. Extlinks: No escapes needed
25393 #### --------------------------------------
25394 !! test
25395 Links 1. WikiLinks: No escapes needed
25396 !! options
25397 parsoid=html2wt
25398 !! html/parsoid
25399 <p><a rel="mw:WikiLink" href="Foo" title="Foo">Foo<i>boo</i></a>
25400 <a rel="mw:WikiLink" href="Foo" title="Foo">[Foobar]</a>
25401 <a rel="mw:WikiLink" href="Foo" title="Foo">x [Foobar] x</a></p>
25402 !! wikitext
25403 [[Foo|Foo''boo'']]
25404 [[Foo|[Foobar]]]
25405 [[Foo|x [Foobar] x]]
25406 !! html/php
25407 <p><a href="/wiki/Foo" title="Foo">Foo<i>boo</i></a>
25408 <a href="/wiki/Foo" title="Foo">[Foobar]</a>
25409 <a href="/wiki/Foo" title="Foo">x [Foobar] x</a>
25410 </p>
25411 !! end
25412
25413 !! test
25414 Links 2. WikiLinks: Escapes needed
25415 !! options
25416 parsoid=html2wt
25417 !! html/parsoid
25418 <a href="Foo" rel="mw:WikiLink">Foobar]</a>
25419 <a href="Foo" rel="mw:WikiLink">x [http://google.com g] x</a>
25420 <a href="Foo" rel="mw:WikiLink">[[Bar]]</a>
25421 <a href="Foo" rel="mw:WikiLink">x [[Bar]] x</a>
25422 <a href="Foo" rel="mw:WikiLink">|Bar</a>
25423 <a href="Foo" rel="mw:WikiLink">]]bar</a>
25424 <a href="Foo" rel="mw:WikiLink">[[bar</a>
25425 <a href="Foo" rel="mw:WikiLink">x [[ y</a>
25426 <a href="Foo" rel="mw:WikiLink">x ]] y</a>
25427 <a href="Foo" rel="mw:WikiLink">x ]] y [[ z</a>
25428 !! wikitext
25429 [[Foo|<nowiki>Foobar]</nowiki>]]
25430 [[Foo|x <nowiki>[http://google.com g]</nowiki> x]]
25431 [[Foo|<nowiki>[[Bar]]</nowiki>]]
25432 [[Foo|<nowiki>x [[Bar]] x</nowiki>]]
25433 [[Foo|<nowiki>|Bar</nowiki>]]
25434 [[Foo|<nowiki>]]bar</nowiki>]]
25435 [[Foo|<nowiki>[[bar</nowiki>]]
25436 [[Foo|<nowiki>x [[ y</nowiki>]]
25437 [[Foo|<nowiki>x ]] y</nowiki>]]
25438 [[Foo|<nowiki>x ]] y [[ z</nowiki>]]
25439 !! html/php
25440 <p><a href="/wiki/Foo" title="Foo">Foobar]</a>
25441 <a href="/wiki/Foo" title="Foo">x [http://google.com g] x</a>
25442 <a href="/wiki/Foo" title="Foo">[[Bar]]</a>
25443 <a href="/wiki/Foo" title="Foo">x [[Bar]] x</a>
25444 <a href="/wiki/Foo" title="Foo">|Bar</a>
25445 <a href="/wiki/Foo" title="Foo">]]bar</a>
25446 <a href="/wiki/Foo" title="Foo">[[bar</a>
25447 <a href="/wiki/Foo" title="Foo">x [[ y</a>
25448 <a href="/wiki/Foo" title="Foo">x ]] y</a>
25449 <a href="/wiki/Foo" title="Foo">x ]] y [[ z</a>
25450 </p>
25451 !! end
25452
25453 !! test
25454 Links 3. WikiLinks: No escapes needed
25455 !! options
25456 parsoid=html2wt
25457 !! html/parsoid
25458 <p><a rel="mw:WikiLink" href="Foo">[Foobar</a>
25459 <a rel="mw:WikiLink" href="Foo" title="Foo">foo|bar</a></p>
25460 !! wikitext
25461 [[Foo|[Foobar]]
25462 [[Foo|foo|bar]]
25463 !! html/php
25464 <p><a href="/wiki/Foo" title="Foo">[Foobar</a>
25465 <a href="/wiki/Foo" title="Foo">foo|bar</a>
25466 </p>
25467 !! end
25468
25469 !! test
25470 Links 4. ExtLinks: Escapes needed
25471 !! options
25472 parsoid=html2wt
25473 !! html/parsoid
25474 <p><a rel="mw:ExtLink" href="http://google.com">[google]</a>
25475 <a rel="mw:ExtLink" href="http://google.com">google]</a>
25476 <a rel="mw:ExtLink" href="http://google.com">goog] le</a></p>
25477 <p>[http://google.com]</p>
25478 <p>[http://google.com google]</p>
25479 <p>[<a rel="mw:ExtLink" href="http://google.com">http://google.com</a>]</p>
25480 <p>[<a rel="mw:ExtLink" href="http://google.com" about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"http://google.com"}},"i":0}}]}'>http://google.com</a>]</p>
25481 !! wikitext
25482 [http://google.com <nowiki>[google]</nowiki>]
25483 [http://google.com <nowiki>google]</nowiki>]
25484 [http://google.com <nowiki>goog] le</nowiki>]
25485
25486 <nowiki>[http://google.com]</nowiki>
25487
25488 <nowiki>[http://google.com google]</nowiki>
25489
25490 [http://google.com<nowiki>]</nowiki>
25491
25492 [{{echo|http://google.com}}<nowiki>]</nowiki>
25493 !! html/php
25494 <p><a rel="nofollow" class="external text" href="http://google.com">[google]</a>
25495 <a rel="nofollow" class="external text" href="http://google.com">google]</a>
25496 <a rel="nofollow" class="external text" href="http://google.com">goog] le</a>
25497 </p><p>[http://google.com]
25498 </p><p>[http://google.com google]
25499 </p><p>[<a rel="nofollow" class="external free" href="http://google.com">http://google.com</a>]
25500 </p><p>[<a rel="nofollow" class="external free" href="http://google.com">http://google.com</a>]
25501 </p>
25502 !! end
25503
25504 !! test
25505 Links 5. ExtLinks: No escapes needed
25506 !! options
25507 parsoid=html2wt
25508 !! html/parsoid
25509 <p><a rel="mw:ExtLink" href="http://google.com">[google</a></p>
25510 <p>[<a ref="mw:ExtLink" href="http://google.com"></a>]</p>
25511 !! wikitext
25512 [http://google.com [google]
25513
25514 [[http://google.com]]
25515 !! html/php
25516 <p><a rel="nofollow" class="external text" href="http://google.com">[google</a>
25517 </p><p>[<a rel="nofollow" class="external autonumber" href="http://google.com">[1]</a>]
25518 </p>
25519 !! end
25520
25521 !! test
25522 Links 6. Add <nowiki/>s between text-nodes and url-links when required (T66300)
25523 !! options
25524 parsoid=html2wt
25525 !! html/parsoid
25526 <p>x<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>y
25527 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>?x
25528 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>&amp;x
25529 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>'x
25530 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>,x
25531 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>.x
25532 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>;x
25533 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>:x
25534 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>;x
25535 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>!x
25536 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>=x
25537 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>(x)
25538 <a rel="mw:ExtLink" href="http://example.com(x" data-parsoid='{"stx":"url"}'>http://example.com(x</a>)
25539 </p>
25540 !! wikitext
25541 x<nowiki/>http://example.com<nowiki/>y
25542 http://example.com<nowiki/>?x
25543 http://example.com<nowiki/>&x
25544 http://example.com<nowiki/>'x
25545 http://example.com<nowiki/>,x
25546 http://example.com<nowiki/>.x
25547 http://example.com<nowiki/>;x
25548 http://example.com<nowiki/>:x
25549 http://example.com<nowiki/>;x
25550 http://example.com<nowiki/>!x
25551 http://example.com<nowiki/>=x
25552 http://example.com<nowiki/>(x)
25553 http://example.com(x<nowiki/>)
25554 !! end
25555
25556 !! test
25557 Links 7a. Don't add spurious <nowiki/>s between text-nodes and url-links (T66300)
25558 !! options
25559 parsoid=html2wt
25560 !! html/parsoid
25561 <p>x
25562 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>
25563 y
25564 "<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>"
25565 (<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>)
25566 (<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>) foo
25567 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>,
25568 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>, foo
25569 </p>
25570 !! wikitext
25571 x
25572 http://example.com
25573 y
25574 "http://example.com"
25575 (http://example.com)
25576 (http://example.com) foo
25577 http://example.com,
25578 http://example.com, foo
25579 !! html/php
25580 <p>x
25581 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
25582 y
25583 "<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>"
25584 (<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
25585 (<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>) foo
25586 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>,
25587 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>, foo
25588 </p>
25589 !! end
25590
25591 !! test
25592 Links 7b. Don't add spurious <nowiki/>s between text-nodes and url-links (T66300)
25593 !! options
25594 parsoid=html2wt
25595 !! html/parsoid
25596 <p><a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>.,;:!?\
25597 -<a rel="mw:ExtLink" href="http://example.com">http://example.com</a>:</p>
25598 !! wikitext
25599 http://example.com.,;:!?\
25600 -http://example.com:
25601 !! html/php
25602 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>.,;:!?\
25603 -<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>:
25604 </p>
25605 !! end
25606
25607 !! test
25608 Links 8. Add <nowiki/>s between text-nodes and RFC-links when required (T66300)
25609 !! options
25610 parsoid=html2wt
25611 !! html/parsoid
25612 <p><a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>4
25613 <a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y
25614 X<a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y</p>
25615 !! wikitext
25616 RFC 123<nowiki/>4
25617 RFC 123<nowiki/>y
25618 X<nowiki/>RFC 123<nowiki/>y
25619 !! end
25620
25621 !! test
25622 Links 9. Don't add spurious <nowiki/>s between text-nodes and RFC-links (T66300)
25623 !! options
25624 parsoid=html2wt
25625 !! html/parsoid
25626 <p><a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>?foo
25627 <a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>&amp;foo
25628 -<a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>-
25629 </p>
25630 !! wikitext
25631 RFC 123?foo
25632 RFC 123&foo
25633 -RFC 123-
25634 !! html/php
25635 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc123">RFC 123</a>?foo
25636 <a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc123">RFC 123</a>&amp;foo
25637 -<a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc123">RFC 123</a>-
25638 </p>
25639 !! end
25640
25641 !! test
25642 Links 10. Add <nowiki/>s between text-nodes and PMID-links when required (T66300)
25643 !! options
25644 parsoid=html2wt
25645 !! html/parsoid
25646 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>4
25647 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>y
25648 X<a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>y
25649 !! wikitext
25650 PMID 123<nowiki/>4
25651 PMID 123<nowiki/>y
25652 X<nowiki/>PMID 123<nowiki/>y
25653 !! end
25654
25655 !! test
25656 Links 11. Don't add spurious <nowiki/>s between text-nodes and PMID-links (T66300)
25657 !! options
25658 parsoid=html2wt
25659 !! html/parsoid
25660 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>?foo
25661 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>&foo
25662 -<a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>-
25663 </p>
25664 !! wikitext
25665 PMID 123?foo
25666 PMID 123&foo
25667 -PMID 123-
25668 !! html/php
25669 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>?foo
25670 <a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>&amp;foo
25671 -<a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>-
25672 </p>
25673 !! end
25674
25675 !! test
25676 Links 12. Add <nowiki/>s between text-nodes and ISBN-links when required (T66300)
25677 !! options
25678 parsoid=html2wt
25679 !! html/parsoid
25680 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>1
25681 <a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>x
25682 a<a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>b
25683 </p>
25684 !! wikitext
25685 ISBN 1234567890<nowiki/>1
25686 ISBN 1234567890<nowiki/>x
25687 a<nowiki/>ISBN 1234567890<nowiki/>b
25688 !! end
25689
25690 !! test
25691 Links 13. Don't add spurious <nowiki/>s between text-nodes and ISBN-links (T66300)
25692 !! options
25693 parsoid=html2wt
25694 !! html/parsoid
25695 <p>-<a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>'s
25696 !! wikitext
25697 -ISBN 1234567890's
25698 !! html/php
25699 <p>-<a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>'s
25700 </p>
25701 !! end
25702
25703 !! test
25704 Links 14. Protect link-like plain text. (Parsoid bug T78425)
25705 !! options
25706 parsoid=html2wt
25707 !! html/*
25708 <p>this is not a link: http://example.com
25709 </p>
25710 !! wikitext
25711 this is not a link: <nowiki>http://example.com</nowiki>
25712 !! end
25713
25714 !! test
25715 Links 15. Link trails can't become link prefixes.
25716 !! options
25717 language=is
25718 parsoid=html2wt
25719 !! html/parsoid
25720 <p><a rel="mw:WikiLink" href="Söfnuður" title="Söfnuður" data-parsoid='{"stx":"simple","tail":"-"}'>Söfnuður-</a><a rel="mw:WikiLink" href="00" title="00">00</a></p>
25721 !! wikitext
25722 [[Söfnuður]]-[[00]]
25723 !! html/php
25724 <p><a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">Söfnuður-</a><a href="/wiki/00" title="00">00</a>
25725 </p>
25726 !! end
25727
25728 #### --------------- Quotes ---------------
25729 #### 1. Quotes inside <b> and <i>
25730 #### 2. Link fragments separated by <i> and <b> tags
25731 #### 3. Link fragments inside <i> and <b>
25732 #### 4. No escaping needed
25733 #### --------------------------------------
25734 !! test
25735 1a. Quotes inside <b> and <i>
25736 !! options
25737 parsoid=html2wt
25738 !! html/*
25739 <p><i>'foo'</i>
25740 <i>''foo''</i>
25741 <i>'''foo'''</i>
25742 <i>foo</i>'s
25743 <b>'foo'</b>
25744 <b>''foo''</b>
25745 <b>'''foo'''</b>
25746 <b>foo'<i>bar'</i>baz</b>
25747 <b>foo</b>'s
25748 '<i>foo</i>
25749 <i>foo</i>'
25750 <i>foo'</i>'
25751 '<i>foo</i>'
25752 '<b>foo</b>
25753 <b>foo</b>'
25754 '<b>foo</b>'
25755 <i>fools'<span> errand</span></i>
25756 <i><span>fool</span>'s errand</i>
25757 '<i>foo</i> bar '<i>baz</i>
25758 a|!*#-:;+-~[]{}b'<i>x</i>
25759 </p>
25760 !! wikitext
25761 ''<nowiki/>'foo'''
25762 ''<nowiki>''foo''</nowiki>''
25763 ''<nowiki>'''foo'''</nowiki>''
25764 ''foo''<nowiki/>'s
25765 '''<nowiki/>'foo''''
25766 '''<nowiki>''foo''</nowiki>'''
25767 '''<nowiki>'''foo'''</nowiki>'''
25768 '''foo'<nowiki/>''bar'<nowiki/>''baz'''
25769 '''foo'''<nowiki/>'s
25770 '''foo''
25771 ''foo''<nowiki/>'
25772 ''foo'''<nowiki/>'
25773 '''foo''<nowiki/>'
25774 ''''foo'''
25775 '''foo'''<nowiki/>'
25776 ''''foo'''<nowiki/>'
25777 ''fools'<span> errand</span>''
25778 ''<span>fool</span>'s errand''
25779 '<nowiki/>''foo'' bar '''baz''
25780 a|!*#-:;+-~[]{}b'''x''
25781 !! end
25782
25783 !! test
25784 1b. Quotes inside <b> and <i> with other tags on same line
25785 !! options
25786 parsoid=html2wt
25787 !! html/parsoid
25788 '<i>a</i> foo <i><a rel="mw:WikiLink" href="Bar" title="Bar">bar</a></i>
25789 <i>a'</i> foo <i><a rel="mw:WikiLink" href="Bar" title="Bar">bar</a></i>
25790 <i>a'</i> foo <b><a rel="mw:WikiLink" href="Bar" title="Bar" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[bar]]"}},"i":0}}]}'>bar</a></b>
25791 <a rel="mw:WikiLink" href="Foo" title="Foo">foo</a> x'<i><a href="Bar" rel="mw:WikiLink" title="Bar">bar</a></i>
25792 '<i>foo</i> <span class="mw-ref" id="cite_ref-1-0" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","body":{"id":"mw-reference-text-cite_note-1"},"attrs":{}}'><a href="./Main_Page#cite_note-1"><span class="mw-reflink-text">[1]</span></a></span>
25793 '<i>foo</i> <div title="name">test</div>
25794 '<i>foo</i> and <br data-parsoid='{"stx":"html","noClose":true}'/> bar
25795 <ol class="mw-references" typeof="mw:Extension/references" about="#mwt5" data-mw='{"name":"references","attrs":{}}'>
25796 <li about="#cite_note-1" id="cite_note-1"><span rel="mw:referencedBy"><a href="./Main_Page#cite_ref-1">↑</a></span> <span id="mw-reference-text-cite_note-1" class="mw-reference-text" data-parsoid="{}">test</span></li>
25797 </ol>
25798 !! wikitext
25799 '''a'' foo ''[[bar]]''
25800 ''a''' foo ''[[bar]]''
25801 ''a''' foo '''{{echo|[[bar]]}}'''
25802 [[foo]] x'''[[bar]]''
25803 '''foo'' <ref>test</ref>
25804 '''foo'' <div title="name">test</div>
25805 '''foo'' and <br> bar
25806 <references />
25807 !! end
25808
25809 !! test
25810 2. Link fragments separated by <i> and <b> tags
25811 !! options
25812 parsoid=html2wt
25813 !! html/parsoid
25814 <p>[[<i>foo</i>hello]]</p>
25815 <p>[[<b>foo</b>hello]]</p>
25816 !! wikitext
25817 [[''foo''<nowiki>hello]]</nowiki>
25818
25819 [['''foo'''<nowiki>hello]]</nowiki>
25820 !! end
25821
25822 # FIXME: Escaping one or both of [[ and ]] is also acceptable --
25823 # this is one of the shortcomings of this format
25824 !! test
25825 3. Link fragments inside <i> and <b>
25826 !! options
25827 parsoid=html2wt
25828 !! html/parsoid
25829 <p><i>[[foo</i>]]</p>
25830 <p><b>[[foo</b>]]</p>
25831 !! wikitext
25832 ''[[foo''<nowiki>]]</nowiki>
25833
25834 '''[[foo'''<nowiki>]]</nowiki>
25835 !! end
25836
25837 !! test
25838 4. No escaping needed
25839 !! options
25840 parsoid=html2wt
25841 !! html/parsoid
25842 <p>'<span><i>bar</i></span>'
25843 '<span><b>bar</b></span>'
25844 'a:b'foo
25845 </p>
25846 !! wikitext
25847 '<span>''bar''</span>'
25848 '<span>'''bar'''</span>'
25849 'a:b'foo
25850 !! end
25851
25852 #### ----------- Paragraphs ---------------
25853 #### 1. No unnecessary escapes
25854 #### --------------------------------------
25855
25856 !! test
25857 1. No unnecessary escapes
25858 !! options
25859 parsoid=html2wt
25860 !! html/parsoid
25861 <p>bar <span>[[foo]]</span>
25862 </p><p>=bar <span>[[foo]]</span>
25863 </p><p>[[bar <span>[[foo]]</span>
25864 </p><p>]]bar <span>[[foo]]</span>
25865 </p><p>=bar <span>foo]]</span>=
25866 </p>
25867 !! wikitext
25868 bar <span><nowiki>[[foo]]</nowiki></span>
25869
25870 =bar <span><nowiki>[[foo]]</nowiki></span>
25871
25872 [[bar <span><nowiki>[[foo]]</nowiki></span>
25873
25874 ]]bar <span><nowiki>[[foo]]</nowiki></span>
25875
25876 =bar <span>foo]]</span><nowiki>=</nowiki>
25877 !!end
25878
25879 #### ----------------------- PRE --------------------------
25880 #### 1. Leading whitespace in SOL context should be escaped
25881 #### ------------------------------------------------------
25882 !! test
25883 1. Leading whitespace in SOL context should be escaped
25884 !! options
25885 parsoid=html2wt
25886 !! html/parsoid
25887 <p> a</p>
25888
25889 <p> a</p>
25890
25891 <p> a(tab)</p>
25892
25893 <p> a
25894 <!--cmt-->
25895 a</p>
25896
25897 <p>a
25898 b</p>
25899
25900 <p>a
25901 b</p>
25902
25903 <p>a
25904 b</p>
25905 !! wikitext
25906 <nowiki> </nowiki>a
25907
25908 <nowiki> </nowiki> a
25909
25910 a(tab)
25911
25912 <nowiki> </nowiki> a
25913 <!--cmt-->
25914 <nowiki> </nowiki>a
25915
25916 a
25917 <nowiki> </nowiki>b
25918
25919 a
25920 b
25921
25922 a
25923 b
25924 !! html/php
25925 <p> a
25926 </p><p> a
25927 </p><p> a(tab)
25928 </p><p> a
25929 a
25930 </p><p>a
25931 b
25932 </p><p>a
25933 b
25934 </p><p>a
25935 b
25936 </p>
25937 !! end
25938
25939 !! test
25940 2. Leading whitespace in non-indent-pre contexts should not be escaped
25941 !! options
25942 parsoid=html2wt
25943 !! html/parsoid
25944 <p>foo <span about="#mwt2" class="mw-ref" id="cite_ref-1" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","body":{"id":"mw-reference-text-cite_note-1"},"attrs":{}}'><a href="./Main_Page#cite_note-1"><span class="mw-reflink-text">[1]</span></a></span></p>
25945 <ol class="mw-references" typeof="mw:Extension/references" about="#mwt4" data-mw='{"name":"references","attrs":{}}'>
25946 <li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text"><i>a</i>
25947 b</span></li>
25948 </ol>
25949 !! wikitext
25950 foo <ref>''a''
25951 b</ref>
25952 <references />
25953 !! end
25954
25955 !! test
25956 3. Leading whitespace in indent-pre suppressing contexts should not be escaped
25957 !! options
25958 parsoid=html2wt
25959 !! html/parsoid
25960 <blockquote>
25961 <p>
25962 a
25963 <span>b</span>
25964 c</p>
25965 </blockquote>
25966 !! wikitext
25967 <blockquote>
25968 a
25969 <span>b</span>
25970 c
25971 </blockquote>
25972 !! end
25973
25974 !! test
25975 4. Leading whitespace in indent-pre suppressing contexts should not be escaped
25976 !! options
25977 parsoid=html2wt
25978 !! html/parsoid
25979 <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption>caption</figcaption></figure>
25980 !! wikitext
25981 [[File:Foobar.jpg|thumb|caption]]
25982 !! end
25983
25984 !! test
25985 5. Nowiki escaping should account for indent-pres
25986 !! options
25987 parsoid=html2wt
25988 !! html/parsoid
25989 <pre>==foo==</pre>
25990 !! wikitext
25991 ==foo==
25992 !! end
25993
25994 !!test
25995 T95794: nowiki escaping should account for leading space at start-of-line in an indent-pre block
25996 !! options
25997 parsoid=html2wt
25998 !! html/parsoid
25999 <pre>
26000 * foo
26001 * bar
26002 </pre>
26003 !! wikitext
26004 * foo
26005 * bar
26006 !! end
26007
26008 #### --------------- Behavior Switches --------------------
26009
26010 !! test
26011 1. Valid behavior switches should be escaped
26012 !! options
26013 parsoid=html2wt
26014 !! html/parsoid
26015 __TOC__
26016 <i>__TOC__</i>
26017 !! wikitext
26018 <nowiki>__TOC__</nowiki>
26019 ''<nowiki>__TOC__</nowiki>''
26020 !! end
26021
26022 !! test
26023 2. Invalid behavior switches should not be escaped
26024 !! options
26025 parsoid=html2wt
26026 !! html/parsoid
26027 __TOO__
26028 __|__
26029 !! wikitext
26030 __TOO__
26031 __|__
26032 !! end
26033
26034 # We use indent-pre as an indirect way to test for sol-transparent behavior.
26035 !! test
26036 Behavior switches should be SOL-transparent
26037 !! options
26038 parsoid=html2wt
26039 !! html/parsoid
26040 <meta property="mw:PageProp/toc" />
26041
26042 <!-- this one's bogus -->
26043 <pre>__TOO__</pre>
26044
26045 <pre data-parsoid='{}'><meta property="mw:PageProp/toc" data-parsoid='{"src":"__TOC__","magicSrc":"__TOC__"}'/> foo</pre>
26046
26047 <meta property="mw:PageProp/toc" data-parsoid='{"src":"__TOC__","magicSrc":"__TOC__"}'/><pre data-parsoid='{}'>bar</pre>
26048 !! wikitext
26049 __TOC__
26050
26051 <!-- this one's bogus -->
26052 __TOO__
26053
26054 __TOC__ foo
26055
26056 __TOC__
26057 bar
26058 !! end
26059
26060 #### --------------- HTML tags ---------------
26061 #### 1. a tags
26062 #### 2. other tags
26063 #### 3. multi-line html tag
26064 #### 4. extension tags
26065 #### -----------------------------------------
26066 !! test
26067 1. a tags
26068 !! options
26069 parsoid=html2wt
26070 !! html/parsoid
26071 &lt;a href=&quot;http://google.com&quot;&gt;google&lt;/a&gt;
26072 !! wikitext
26073 <a href="http://google.com">google</a>
26074 !! end
26075
26076 !! test
26077 2. other tags
26078 !! options
26079 parsoid=html2wt
26080 !! html/parsoid
26081 <ul><li> &lt;div&gt;foo&lt;/div&gt;</li>
26082 <li> &lt;div style=&quot;color:red&quot;&gt;foo&lt;/div&gt;</li>
26083 <li> &lt;td&gt;</li></ul>
26084
26085 !! wikitext
26086 * <nowiki><div>foo</div></nowiki>
26087 * <nowiki><div style="color:red">foo</div></nowiki>
26088 * <nowiki><td></nowiki>
26089 !! end
26090
26091 !! test
26092 3. multi-line html tag
26093 !! options
26094 parsoid=html2wt
26095 !! html/parsoid
26096 <p>&lt;div
26097 &gt;foo&lt;/div
26098 &gt;
26099 </p>
26100 !! wikitext
26101 <nowiki><div
26102 >foo</div
26103 ></nowiki>
26104 !! end
26105
26106 !! test
26107 4. extension tags
26108 !! options
26109 parsoid=html2wt
26110 !! html/parsoid
26111 <p>&lt;ref&gt;foo&lt;/ref&gt;
26112 </p><p>&lt;ref&gt;bar
26113 </p><p>baz&lt;/ref&gt;
26114 </p>
26115 !! wikitext
26116 <nowiki><ref>foo</ref></nowiki>
26117
26118 <nowiki><ref>bar</nowiki>
26119
26120 baz<nowiki></ref></nowiki>
26121 !! end
26122
26123 #### --------------- Others ---------------
26124 !! test
26125 Escaping nowikis
26126 !! options
26127 parsoid=html2wt
26128 !! html/parsoid
26129 <p>&lt;nowiki&gt;foo&lt;/nowiki&gt;
26130 </p>
26131 !! wikitext
26132 &lt;nowiki&gt;foo&lt;/nowiki&gt;
26133 !! end
26134
26135 ## The quote-char in the input is necessary for triggering the bug
26136 !! test
26137 (T54035) Nowiki-escaping should not get tripped by " :" in text
26138 !! options
26139 parsoid=html2wt
26140 !! html/parsoid
26141 <p>foo's bar :</p>
26142 !! wikitext
26143 foo's bar :
26144 !! end
26145
26146 #----------- End of wikitext escaping tests --------------
26147
26148 !! test
26149
26150 Tag-like HTML structures are passed through as text
26151 !! wikitext
26152 <x y>
26153
26154 <x.y>
26155
26156 <x-y>
26157
26158 1>2
26159
26160 x<y
26161
26162 a>b
26163
26164 1<d e>f
26165 !! html
26166 <p>&lt;x y&gt;
26167 </p><p>&lt;x.y&gt;
26168 </p><p>&lt;x-y&gt;
26169 </p><p>1&gt;2
26170 </p><p>x&lt;y
26171 </p><p>a&gt;b
26172 </p><p>1&lt;d e&gt;f
26173 </p>
26174 !! end
26175
26176 !! test
26177 HTML tag with necessary entities in attributes
26178 !! wikitext
26179 <span title="&amp;amp;">foo</span>
26180 !! html
26181 <p><span title="&amp;amp;">foo</span>
26182 </p>
26183 !! end
26184
26185 !! test
26186 HTML tag with 'unnecessary' entity encoding in attributes
26187 !! wikitext
26188 <span title="&amp;">foo</span>
26189 !! html
26190 <p><span title="&amp;">foo</span>
26191 </p>
26192 !! end
26193
26194 !! test
26195 HTML tag with broken attribute value quoting
26196 !! options
26197 parsoid=wt2html,html2html
26198 !! wikitext
26199 <span title="Hello world>Foo</span>
26200 !! html/php
26201 <p><span title="Hello world">Foo</span>
26202 </p>
26203 !! html/parsoid
26204 <p><span title="Hello world">Foo</span></p>
26205 !! end
26206
26207 !! test
26208 Self-closed tag with broken attribute value quoting
26209 !! options
26210 parsoid=wt2html,html2html
26211 !! wikitext
26212 <div title="Hello world />Foo
26213 !! html/php+tidy
26214 <div title="Hello world"></div>
26215 <p>Foo</p>
26216 !! html/parsoid
26217 <div title="Hello world " data-parsoid='{"stx":"html","selfClose":true}'></div><p>Foo</p>
26218 !! end
26219
26220 !! test
26221 Table with broken attribute value quoting
26222 !! options
26223 parsoid=wt2html,html2html
26224 !! wikitext
26225 {|
26226 | title="Hello world|Foo
26227 |}
26228 !! html/php
26229 <table>
26230 <tr>
26231 <td title="Hello world">Foo
26232 </td></tr></table>
26233
26234 !! html/parsoid
26235 <table>
26236 <tr>
26237 <td title="Hello world">Foo
26238 </td></tr></table>
26239
26240 !! end
26241
26242 !! test
26243 Table with broken attribute value quoting on consecutive lines
26244 !! options
26245 parsoid=wt2html,html2html
26246 !! wikitext
26247 {|
26248 | title="Hello world|Foo
26249 | style="color:red|Bar
26250 |}
26251 !! html/php
26252 <table>
26253 <tr>
26254 <td title="Hello world">Foo
26255 </td>
26256 <td style="color:red">Bar
26257 </td></tr></table>
26258
26259 !! html/parsoid
26260 <table><tbody>
26261 <tr>
26262 <td title="Hello world">Foo
26263 </td><td style="color: red">Bar
26264 </td></tr></tbody></table>
26265
26266 !! end
26267
26268 !!test
26269 Accept empty td cell attribute
26270 !! wikitext
26271 {|
26272 | align="center" | foo || |
26273 |}
26274 !! html
26275 <table>
26276 <tr>
26277 <td align="center"> foo </td>
26278 <td>
26279 </td></tr></table>
26280
26281 !!end
26282
26283 !!test
26284 Non-empty attributes in th-cells
26285 !! wikitext
26286 {|
26287 ! Foo !! style="color: red" | Bar
26288 |}
26289 !! html
26290 <table>
26291 <tr>
26292 <th> Foo </th>
26293 <th style="color: red"> Bar
26294 </th></tr></table>
26295
26296 !!end
26297
26298 !!test
26299 Accept empty attributes in th-cells
26300 !! wikitext
26301 {|
26302 !| foo !!| bar
26303 |}
26304 !! html
26305 <table>
26306 <tr>
26307 <th> foo </th>
26308 <th> bar
26309 </th></tr></table>
26310
26311 !!end
26312
26313 !!test
26314 Empty table rows go away
26315 !! wikitext
26316 {|
26317 | Hello
26318 | there
26319 |- class="foo"
26320 |-
26321 |}
26322 !! html
26323 <table>
26324 <tr>
26325 <td> Hello
26326 </td>
26327 <td> there
26328 </td></tr>
26329
26330 </table>
26331
26332 !! end
26333
26334 ###
26335 ### Parsoid-centric tests for testing RTing of inter-element separators
26336 ### Edge cases not tested by existing parser tests and specific to
26337 ### Parsoid-specific serialization strategies.
26338 ###
26339
26340 !!test
26341 RT-ed inter-element separators should be valid separators
26342 !! wikitext
26343 {|
26344 |- [[foo]]
26345 |}
26346 !! html/php
26347 <table>
26348
26349 </table>
26350
26351 !! html/parsoid
26352 <table>
26353 <tbody><tr data-parsoid='{"startTagSrc":"|-","a":{"[[foo]]":null},"sa":{"[[foo]]":""},"autoInsertedEnd":true}'></tr>
26354 </tbody></table>
26355 !!end
26356
26357 # Parsoid-only since PHP parser relies on Tidy for correct output
26358 !!test
26359 Trailing newlines in a deep dom-subtree that ends a wikitext line should be migrated out
26360 !!options
26361 parsoid
26362 !! wikitext
26363 {|
26364 |<small>foo
26365 bar
26366 |}
26367
26368 {|
26369 |<small>foo<small>
26370 |}
26371 !! html
26372 <table>
26373 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'><small data-parsoid='{"stx":"html","autoInsertedEnd":true}'>foo
26374 <p>bar</p></small></td></tr>
26375 </tbody></table>
26376
26377 <table>
26378 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'><small data-parsoid='{"stx":"html","autoInsertedEnd":true}'>foo<small data-parsoid='{"stx":"html","autoInsertedEnd":true}'></small></small></td></tr>
26379 </tbody></table>
26380 !!end
26381
26382 # Note that the "style" attribute is really a template parameter here.
26383 # The = would have to be {{=}} if you wanted the literal.
26384 !!test
26385 Empty TD followed by TD with tpl-generated attribute
26386 !! wikitext
26387 {|
26388 |-
26389 |
26390 |{{echo|style='color:red'}}|foo
26391 |}
26392 !! html
26393 <table>
26394
26395 <tr>
26396 <td>
26397 </td>
26398 <td>foo
26399 </td></tr></table>
26400
26401 !!end
26402
26403 !!test
26404 Indented table with an empty td
26405 !! wikitext
26406 {|
26407 |-
26408 |
26409 |foo
26410 |}
26411 !! html
26412 <table>
26413
26414 <tr>
26415 <td>
26416 </td>
26417 <td>foo
26418 </td></tr></table>
26419
26420 !!end
26421
26422 ## We have some newline diffs RT-ing this edge case
26423 ## and it is not important enough -- we seem to be emitting
26424 ## at most 2 newlines after a </tr> and this is unrelated to
26425 ## the issue from T85627 that this is testing.
26426 !!test
26427 Indented table with blank lines in between (T85627)
26428 !! options
26429 parsoid=wt2html
26430 !! wikitext
26431 {|
26432 |foo
26433
26434
26435 |}
26436 !! html
26437 <table>
26438
26439 <tr>
26440 <td>foo
26441 </td></tr></table>
26442
26443 !!end
26444
26445 !!test
26446 Indented block & table
26447 !! wikitext
26448 <div>foo</div>
26449 {|
26450 |foo
26451 |}
26452 !! html/php
26453 <div>foo</div>
26454 <table>
26455 <tr>
26456 <td>foo
26457 </td></tr></table>
26458
26459 !! html/parsoid
26460 <div data-parsoid='{"stx":"html"}'>foo</div>
26461 <table><tbody>
26462 <tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'>foo</td></tr>
26463 </tbody></table>
26464 !!end
26465
26466 !! test
26467 Indent and comment before table row
26468 !! wikitext
26469 {|
26470 <!--hi-->|-
26471 | there
26472 |}
26473 !! html/php
26474 <table>
26475
26476 <tr>
26477 <td> there
26478 </td></tr></table>
26479
26480 !! html/parsoid
26481 <table>
26482 <!--hi--><tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
26483 <td data-parsoid='{"autoInsertedEnd":true}'> there</td></tr>
26484 </tbody></table>
26485 !! end
26486
26487 # Parsoid-specific since PHP parser doesn't handle this mixed tbl-wikitext
26488 !!test
26489 Empty TR followed by a template-generated TR
26490 !!options
26491 parsoid
26492 !! wikitext
26493 {|
26494 |-
26495 {{echo|<tr><td>foo</td></tr>}}
26496 |}
26497 !! html
26498 <table>
26499 <tbody>
26500 <tr></tr>
26501 <tr about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"<tr><td>foo</td></tr>"}},"i":0}}]}'>
26502 <td>foo</td></tr>
26503 </tbody></table>
26504 !!end
26505
26506 ## PHP and parsoid output differ for this, and since this is primarily
26507 ## for testing Parsoid's serializer, marking this Parsoid only
26508 !!test
26509 Empty TR followed by mixed-ws-comment line should RT correctly
26510 !!options
26511 parsoid
26512 !! wikitext
26513 {|
26514 |-
26515 <!--c-->
26516 |-
26517 <!--c--> <!--d-->
26518 |}
26519 !! html
26520 <table>
26521 <tbody>
26522 <tr></tr>
26523 <!--c-->
26524 <tr>
26525 <!--c--> </tr><!--d-->
26526 </tbody></table>
26527
26528 !!end
26529
26530 !!test
26531 Multi-line image caption generated by templates with/without trailing newlines
26532 !! wikitext
26533 [[File:Foobar.jpg|thumb|300x300px|foo\n{{echo|A}}\n{{echo|B}}\n{{echo|C}}]]
26534 [[File:Foobar.jpg|thumb|300x300px|foo\n{{echo|A}}\n{{echo|B}}\n{{echo|C}}\n\n]]
26535 !! html/parsoid
26536 <figure typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="34" width="300"/></a><figcaption>foo\n<span about="#mwt9" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"A"}},"i":0}}]}'>A</span>\n<span about="#mwt10" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"B"}},"i":0}}]}'>B</span>\n<span about="#mwt11" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"C"}},"i":0}}]}'>C</span></figcaption></figure>
26537 <figure typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="34" width="300"/></a><figcaption>foo\n<span about="#mwt12" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"A"}},"i":0}}]}'>A</span>\n<span about="#mwt13" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"B"}},"i":0}}]}'>B</span>\n<span about="#mwt14" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"C"}},"i":0}}]}'>C</span>\n\n</figcaption></figure>
26538 !!end
26539
26540 !! test
26541 New element inserted (without intervening newlines) after an old sol-transparent node should serialize correctly
26542 !! options
26543 parsoid=html2wt
26544 !! html/parsoid
26545 <meta typeof="mw:Includes/IncludeOnly" data-parsoid='{"src":"&lt;includeonly>foo&lt;/includeonly>"}'/><meta typeof="mw:Includes/IncludeOnly/End" data-parsoid='{"src":""}'/><p>new para</p>
26546
26547 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{}'/><h1>new heading</h1>
26548 !! wikitext
26549 <includeonly>foo</includeonly>
26550 new para
26551
26552 [[Category:Foo]]
26553
26554 = new heading =
26555 !! end
26556
26557 ## PHP emits broken html for this, and since this is primarily
26558 ## a Parsoid serializer test, marking this Parsoid only
26559 !!test
26560 Improperly nested inline or quotes tags with whitespace in between
26561 !! wikitext
26562 <span> <s>x</span> </s>
26563 ''' ''x''' ''
26564 !! html/parsoid
26565 <p><span> <s>x</s></span><s> </s>
26566 <b> <i>x</i></b><i> </i>
26567 </p>
26568 !!end
26569
26570 !!test
26571 Encapsulate protected attributes from wt
26572 !! wikitext
26573 <div typeof="mw:placeholder stuff" data-mw="whoo" data-parsoid="weird" data-parsoid-other="no" about="time" rel="mw:true">foo</div>
26574
26575 {| typeof="mw:placeholder stuff" data-mw="whoo" data-parsoid="weird" data-parsoid-other="no" about="time" rel="mw:true"
26576 | ok
26577 |}
26578 !! html/parsoid
26579 <div data-x-typeof="mw:placeholder stuff" data-x-data-mw="whoo" data-x-data-parsoid="weird" data-x-data-parsoid-other="no" data-x-about="time" data-x-rel="mw:true">foo</div>
26580
26581 <table data-x-typeof="mw:placeholder stuff" data-x-data-mw="whoo" data-x-data-parsoid="weird" data-x-data-parsoid-other="no" data-x-about="time" data-x-rel="mw:true">
26582 <tbody><tr><td data-parsoid='{"autoInsertedEnd":true}'> ok</td></tr>
26583 </tbody></table>
26584 !!end
26585
26586 ## Currently the p-wrapper is fragile in how it adds / removes transformations.
26587 ## Having nested or stray pre tags results in the attempt to add duplicates,
26588 ## causing an assertion fail. This test tries to prevent that situation.
26589 !!test
26590 Ensure ParagraphWrapper can deal with stray closing pre tags
26591 !!options
26592 parsoid=wt2html
26593 !! wikitext
26594 plain text</pre>
26595 !! html/parsoid
26596 plain text
26597 !!end
26598
26599 !!test
26600 1. Ensure fostered text content is wrapped in element nodes
26601 !!options
26602 parsoid=wt2html
26603 !! wikitext
26604 <table>hi</table><table>ho</table>
26605 !! html/parsoid
26606 <p>hi</p>
26607 <table></table>
26608 <p>ho</p>
26609 <table></table>
26610 !!end
26611
26612 !!test
26613 2. Ensure fostered text content is wrapped in element nodes (traps regressions around fostered marker on the element getting lost)
26614 !!options
26615 parsoid=wt2html,wt2wt
26616 !! wikitext
26617 <table>
26618 <tr> || ||
26619 <td> a
26620 </table>
26621 !! html/parsoid
26622 <p> || ||
26623 </p><table>
26624 <tbody><tr><td> a</td></tr>
26625 </tbody></table>
26626 !!end
26627
26628 !!test
26629 Encapsulation properly handles null DSR information from foster box
26630 !!options
26631 parsoid=wt2html,wt2wt
26632 !! wikitext
26633 {{echo|<table>foo<tr><td>bar</td></tr></table>}}
26634 !! html/parsoid
26635 <span typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;<table>foo<tr><td>bar</td></tr></table>&quot;}},&quot;i&quot;:0}}]}">foo</span><table><tbody><tr><td>bar</td></tr></tbody></table>
26636 !!end
26637
26638 !!test
26639 1. Encapsulate foster-parented transclusion content
26640 !!options
26641 parsoid=wt2wt,wt2html
26642 !! wikitext
26643 <table>{{echo|foo<tr><td>bar</td></tr>}}</table>
26644 !! html/parsoid
26645 <p typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[&quot;<table>&quot;,{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;foo<tr><td>bar</td></tr>&quot;}},&quot;i&quot;:0}},&quot;</table>&quot;]}">foo</p><table>
26646 <tbody>
26647 <tr>
26648 <td>bar</td>
26649 </tr>
26650 </tbody>
26651 </table>
26652 !!end
26653
26654 !!test
26655 2. Encapsulate foster-parented transclusion content
26656 !!options
26657 parsoid=wt2wt,wt2html
26658 !! wikitext
26659 <table><div>{{echo|foo}}</div><tr><td>bar</td></tr></table>
26660 !! html/parsoid
26661 <div typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[&quot;<table><div>&quot;,{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;foo&quot;}},&quot;i&quot;:0}},&quot;</div><tr><td>bar</td></tr></table>&quot;]}">foo</div>
26662 <table>
26663 <tbody>
26664 <tr>
26665 <td>bar</td>
26666 </tr>
26667 </tbody>
26668 </table>
26669 !!end
26670
26671 !!test
26672 3. Encapsulate foster-parented transclusion content
26673 !!options
26674 parsoid=wt2wt,wt2html
26675 !! wikitext
26676 <table><div><p>{{echo|foo</p></div><tr><td>}}bar</td></tr></table>
26677 !! html/parsoid
26678 <div typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[&quot;<table><div><p>&quot;,{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;foo</p></div><tr><td>&quot;}},&quot;i&quot;:0}},&quot;bar</td></tr></table>&quot;]}">
26679 <p>foo</p>
26680 </div>
26681 <table>
26682 <tbody>
26683 <tr>
26684 <td>bar</td>
26685 </tr>
26686 </tbody>
26687 </table>
26688 !!end
26689
26690 !!test
26691 4. Encapsulate foster-parented transclusion content
26692 !!options
26693 parsoid=wt2wt,wt2html
26694 !! wikitext
26695 <table><div><p>{{echo|foo</p></div><tr><td>}}bar</td></tr></table>
26696 !! html/parsoid
26697 <div typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[&quot;<table><div><p>&quot;,{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;foo</p></div><tr><td>&quot;}},&quot;i&quot;:0}},&quot;bar</td></tr></table>&quot;]}">
26698 <p>foo</p>
26699 </div>
26700 <table>
26701 <tbody>
26702 <tr>
26703 <td>bar</td>
26704 </tr>
26705 </tbody>
26706 </table>
26707 !!end
26708
26709 !!test
26710 5. Encapsulate foster-parented transclusion content
26711 !!options
26712 parsoid=wt2wt,wt2html
26713 !! wikitext
26714 <table><tr><td><div><p>{{echo|foo</p></div></td>foo}}</tr></table>
26715 !! html/parsoid
26716 <p typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[&quot;<table><tr><td><div><p>&quot;,{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;foo</p></div></td>foo&quot;}},&quot;i&quot;:0}},&quot;</tr></table>&quot;]}">foo</p>
26717 <table>
26718 <tbody>
26719 <tr>
26720 <td>
26721 <div>
26722 <p>foo</p>
26723 </div>
26724 </td>
26725 </tr>
26726 </tbody>
26727 </table>
26728 !!end
26729
26730 !!test
26731 6. Encapsulate foster-parented transclusion content
26732 !!options
26733 parsoid=wt2wt,wt2html
26734 !! wikitext
26735 <table><tr><td><div><p>{{echo|foo</p></div></td>foo</tr></table>}}<p>ok</p>
26736 !! html/parsoid
26737 <p typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[&quot;<table><tr><td><div><p>&quot;,{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;foo</p></div></td>foo</tr></table>&quot;}},&quot;i&quot;:0}}]}">foo</p>
26738 <table>
26739 <tbody>
26740 <tr>
26741 <td>
26742 <div>
26743 <p>foo</p>
26744 </div>
26745 </td>
26746 </tr>
26747 </tbody>
26748 </table>
26749 <p>ok</p>
26750 !!end
26751
26752 !!test
26753 7. Encapsulate foster-parented transclusion content
26754 !!options
26755 parsoid=wt2wt,wt2html
26756 !! wikitext
26757 <table>{{echo|<p>foo</p>}}<td>bar</td></table>
26758 !! html/parsoid
26759 <p typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[&quot;<table>&quot;,{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;<p>foo</p>&quot;}},&quot;i&quot;:0}},&quot;<td>bar</td></table>&quot;]}">foo</p>
26760 <table>
26761 <tbody>
26762 <tr>
26763 <td>bar</td>
26764 </tr>
26765 </tbody>
26766 </table>
26767 !!end
26768
26769 # Note that the wt is broken on purpose: the = should be {{=}} if you
26770 # don't want it to be a template parameter key.
26771 !!test
26772 8. Encapsulate foster-parented transclusion content
26773 !!options
26774 parsoid=wt2wt,wt2html
26775 !! wikitext
26776 {{echo|a
26777 }}{|{{echo|style='color:red'}}
26778 |-
26779 |b
26780 |}
26781 !! html/parsoid
26782 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"a\n"}},"i":0}}]}'>a</p>
26783 <span> </span>
26784 <p typeof="mw:Transclusion" data-mw='{"parts":["{|",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"style":{"wt":"&#39;color:red&#39;"}},"i":0}},"\n|-\n|b\n|}"]}'>{{{1}}}</p>
26785 <table>
26786 <tbody>
26787 <tr>
26788 <td>b</td>
26789 </tr>
26790 </tbody>
26791 </table>
26792 !!end
26793
26794 !!test
26795 9. Encapsulate foster-parented transclusion content
26796 !!options
26797 parsoid=wt2wt,wt2html
26798 !! wikitext
26799 <table>{{echo|hi</table>hello}}
26800 !! html/parsoid
26801 <p about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":["&lt;table>",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi&lt;/table>hello"}},"i":0}}]}' data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true,"pi":[[{"k":"1"}]]}'>hi</p><table about="#mwt2" data-parsoid='{"stx":"html"}'></table><p about="#mwt2">hello</p>
26802 !!end
26803
26804 !!test
26805 Table in fosterable position
26806 !!options
26807 parsoid=wt2html
26808 !! wikitext
26809 {{OpenTable}}
26810 <div>
26811 {|
26812 |}
26813 </div>
26814 |}
26815 !! html/parsoid
26816 <div about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"OpenTable","href":"./Template:OpenTable"},"params":{},"i":0}},"\n&lt;div>\n"]}' data-parsoid='{"stx":"html","autoInsertedEnd":true,"pi":[[]]}'></div><span about="#mwt1">
26817 </span>
26818 <table about="#mwt1" data-parsoid='{"autoInsertedEnd":true}'></table>
26819
26820 <table>
26821 </table>
26822 !!end
26823
26824 # Parsoid only for T66747
26825 !! test
26826 Properly encapsulate empty-content transclusions in fosterable positions
26827 !! wikitext
26828 <table>
26829 {{#if:|
26830 <td>foo</td>
26831 }}
26832 </table>
26833 !! html/parsoid
26834 <table about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":["&lt;table>\n",{"template":{"target":{"wt":"#if:","function":"if"},"params":{"1":{"wt":"\n&lt;td>foo&lt;/td>\n"}},"i":0}},"\n&lt;/table>"]}' data-parsoid='{"stx":"html","pi":[[{"k":"1"}]]}'>
26835
26836 </table>
26837 !! end
26838
26839 !! test
26840 Always encapsulate foster box when template range is expanded to table
26841 !! options
26842 parsoid=wt2wt
26843 !! wikitext
26844 {|
26845 hello
26846 {{OpenTable}}
26847 |}
26848 !! html/parsoid
26849
26850 !! end
26851
26852 !! test
26853 T115289: Unclosed table
26854 !! wikitext
26855 {{echo|<table>}}<!--c-->[[Category:Two]]
26856 !! html/parsoid
26857 <link rel="mw:PageProp/Category" href="./Category:Two" about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"stx":"simple","a":{"href":"./Category:Two"},"sa":{"href":"Category:Two"},"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;table>"}},"i":0}},"&lt;!--c-->[[Category:Two]]"]}'/><table about="#mwt1" data-parsoid='{"stx":"html","autoInsertedEnd":true}'><!--c--></table>
26858 !! end
26859
26860 !! test
26861 T115289: Don't migrate newlines out of tables with fostered content
26862 !! wikitext
26863 <table><td></td>{{echo|<tr>[[Category:One]]}}<!--c-->[[Category:Two]]
26864 !! html/parsoid
26865 <link rel="mw:PageProp/Category" href="./Category:One" about="#mwt2" typeof="mw:Transclusion" data-parsoid='{"stx":"simple","a":{"href":"./Category:One"},"sa":{"href":"Category:One"},"fostered":true,"pi":[[{"k":"1"}]]}' data-mw='{"parts":["&lt;table>&lt;td>&lt;/td>",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;tr>[[Category:One]]"}},"i":0}},"&lt;!--c-->[[Category:Two]]"]}'/><link rel="mw:PageProp/Category" href="./Category:Two" about="#mwt2"/><table about="#mwt2" data-parsoid='{"stx":"html","autoInsertedEnd":true}'><tbody><tr><td></td></tr><tr><!--c--></tr></tbody></table>
26866 !! end
26867
26868 !! test
26869 T73074: More fostering fun
26870 !! wikitext
26871 <table><td></td>{{echo|<tr>}}<!--c-->[[Category:Two]]
26872 !! html/parsoid
26873 <link rel="mw:PageProp/Category" href="./Category:Two" data-parsoid='{"stx":"simple","a":{"href":"./Category:Two"},"sa":{"href":"Category:Two"},"fostered":true}'/><table data-parsoid='{"stx":"html","autoInsertedEnd":true}'><tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"stx":"html"}'></td></tr><tr about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"stx":"html","autoInsertedEnd":true,"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;tr>"}},"i":0}},"&lt;!--c-->[[Category:Two]]"]}'><!--c--></tr></tbody></table>
26874 !! end
26875
26876 !!test
26877 Support <object> element with .data attribute
26878 !!options
26879 parsoid=html2wt
26880 !! html/parsoid
26881 <object data="test.swf"></object>
26882 !! wikitext
26883 <object data="test.swf"></object>
26884 !!end
26885
26886 !! test
26887 Don't block XML namespace declaration
26888 !! wikitext
26889 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">MediaWiki</span>
26890 !! html/php
26891 <p><span xmlns:dct="http&#58;//purl.org/dc/terms/" property="dct:title">MediaWiki</span>
26892 </p>
26893 !! html/parsoid
26894 <p><span xmlns:dct="http://purl.org/dc/terms/" data-x-property="dct:title" data-parsoid='{"stx":"html"}'>MediaWiki</span></p>
26895 !! end
26896
26897 # -----------------------------------------------------------------
26898 # The following section of tests are primarily to spec requirements
26899 # around Parsoid's serialization (old, new, edited content)
26900 #
26901 # All these tests are marked Parsoid html2wt and html2html only
26902 # ----------------------------------------------------------------
26903
26904 !! test
26905 Ignore rel attribute in a-tags during serialization to url-links
26906 !! options
26907 parsoid=html2wt
26908 !! html/parsoid
26909 <a href='http://en.wikipedia.org/wiki/Foobar'>http://en.wikipedia.org/wiki/Foobar</a>
26910 <a href='http://en.wikipedia.org/wiki/Foobar' rel='mw:ExtLink'>http://en.wikipedia.org/wiki/Foobar</a>
26911 <a href='http://en.wikipedia.org/wiki/Foobar' rel='mw:WikiLink'>http://en.wikipedia.org/wiki/Foobar</a>
26912 !! wikitext
26913 http://en.wikipedia.org/wiki/Foobar
26914 http://en.wikipedia.org/wiki/Foobar
26915 http://en.wikipedia.org/wiki/Foobar
26916 !! end
26917
26918 # 'mi' is a localinterwiki prefix as well as a language
26919 !! test
26920 Serialize interwiki links pointing to the current wiki as plain wiki links (T67869)
26921 !! options
26922 parsoid=html2wt
26923 !! html/parsoid
26924 <p><a rel="mw:ExtLink" href="http://mi.wikipedia.org/wiki/Foo">Foo</a></p>
26925 !! wikitext
26926 [[Foo]]
26927 !! end
26928
26929 !! test
26930 Parsoid should accept interwiki shortcuts
26931 !! options
26932 parsoid=html2wt
26933 !! html/parsoid
26934 <p><a rel='mw:WikiLink' href='./fr:Foo'>Foo</a>
26935 <a rel='mw:ExtLink' href='./fr:Foo'>Foo</a>
26936 <a href='./fr:Foo'>Foo</a></p>
26937 <p><a rel='mw:WikiLink' href='fr%3AFoo'>Foo</a>
26938 <a rel='mw:ExtLink' href='fr%3AFoo'>Foo</a>
26939 <a href='fr%3AFoo'>Foo</a></p>
26940 <p><a href='FR%3AFoo'>Foo</a>
26941 <a href='./FR:Foo'>Foo</a></p>
26942 !! wikitext
26943 [[:fr:Foo|Foo]]
26944 [[:fr:Foo|Foo]]
26945 [[:fr:Foo|Foo]]
26946
26947 [[:fr:Foo|Foo]]
26948 [[:fr:Foo|Foo]]
26949 [[:fr:Foo|Foo]]
26950
26951 [[:fr:Foo|Foo]]
26952 [[:fr:Foo|Foo]]
26953 !! end
26954
26955 !! test
26956 Parsoid should not accept invalid interwiki shortcuts
26957 !! options
26958 parsoid=html2wt
26959 !! html/parsoid
26960 <p><a rel='mw:WikiLink' href='news:Foo'>Foo</a>
26961 <a rel='mw:ExtLink' href='news:Foo'>Foo</a>
26962 <a href='news:Foo'>Foo</a></p>
26963 !! wikitext
26964 [news:Foo Foo]
26965 [news:Foo Foo]
26966 [news:Foo Foo]
26967 !! end
26968
26969 # See T93839
26970 !! test
26971 New wikilinks should be serialized properly
26972 !! options
26973 parsoid=html2wt
26974 !! html/parsoid
26975 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{}'>Foo</a>
26976 <a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a>
26977 <a href="//en.wikipedia.org/wiki/Foo">//en.wikipedia.org/wiki/Foo</a>
26978 <a href="http://en.wikipedia.org/wiki/Foo">http://en.wikipedia.org/wiki/Foo</a>
26979 <a href="//en.wikipedia.org/wiki/Foo_bar">//en.wikipedia.org/wiki/Foo bar</a>
26980 !! wikitext
26981 [[Foo]]
26982 [[Foo]]
26983 [[:en:Foo|//en.wikipedia.org/wiki/Foo]]
26984 http://en.wikipedia.org/wiki/Foo
26985 [[:en:Foo_bar|//en.wikipedia.org/wiki/Foo bar]]
26986 !! end
26987
26988 !! test
26989 New wiki links (href variations)
26990 !! options
26991 parsoid=html2wt
26992 !! html/parsoid
26993 <a rel="mw:WikiLink" href="./Foo_bar">Foo_bar</a>
26994 <a rel="mw:WikiLink" href="Foo_bar">Foo_bar</a>
26995 <a rel="mw:WikiLink" href="Foo bar">Foo_bar</a>
26996 <a rel="mw:WikiLink" href="./Toxine_bact%C3%A9rienne">Toxine bactérienne</a>
26997 !! wikitext
26998 [[Foo_bar]]
26999 [[Foo_bar]]
27000 [[Foo_bar]]
27001 [[Toxine bactérienne]]
27002 !! end
27003
27004 !! test
27005 New wiki links (content string variations)
27006 !! options
27007 parsoid=html2wt
27008 !! html/parsoid
27009 <a rel="mw:WikiLink" href="./Foo_bar">Foo_bar</a>
27010 <a rel="mw:WikiLink" href="./Foo_bar">Foo bar</a>
27011 <a rel="mw:WikiLink" href="./Foo_bar">./Foo_bar</a>
27012 !! wikitext
27013 [[Foo_bar]]
27014 [[Foo bar]]
27015 [[Foo_bar|./Foo_bar]]
27016 !! end
27017
27018 !! test
27019 New category links (href variations)
27020 !! options
27021 parsoid=html2wt
27022 !! html/parsoid
27023 <link rel="mw:PageProp/Category" href="./Category:Toxine_bactérienne" />
27024 <link rel="mw:PageProp/Category" href="./Category:Toxine_bact%C3%A9rienne" />
27025 <link rel="mw:PageProp/Category" href="Category:Toxine_bact%C3%A9rienne" />
27026 !! wikitext
27027 [[Category:Toxine bactérienne]]
27028 [[Category:Toxine bactérienne]]
27029 [[Category:Toxine bactérienne]]
27030 !! end
27031
27032 !! test
27033 New sol transparent links don't need indent-pre nowiki protection
27034 !! options
27035 parsoid=html2wt
27036 language=de
27037 !! html/parsoid
27038 <link rel="mw:PageProp/redirect" href="./Main_Page">
27039 <!-- this is good --> <link rel="mw:PageProp/Category" href="./Category:Good" />
27040 <!-- this is great --> <link rel="mw:PageProp/Category" href="./Kategorie:Great" />
27041 !! wikitext
27042 #WEITERLEITUNG [[Main Page]]
27043 <!-- this is good --> [[Category:Good]]
27044 <!-- this is great --> [[Kategorie:Great]]
27045 !! end
27046
27047 !! test
27048 New interlanguage links (href variations)
27049 !! options
27050 parsoid=html2wt
27051 !! html/parsoid
27052 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine bactérienne" />
27053 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine_bactérienne" />
27054 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine_bact%C3%A9rienne" />
27055 !! wikitext
27056 [[es:Toxine bactérienne]]
27057 [[es:Toxine_bactérienne]]
27058 [[es:Toxine_bactérienne]]
27059 !! end
27060
27061 !! test
27062 Image: Modifying size of an image (1)
27063 !! options
27064 parsoid={
27065 "modes": ["wt2wt"],
27066 "changes": [
27067 ["img[height]", "attr", "height", "22"],
27068 ["img[width]", "attr", "width", "200"]
27069 ]
27070 }
27071 !! wikitext
27072 [[Image:Foobar.jpg|230x230px]]
27073 !! wikitext/edited
27074 [[Image:Foobar.jpg|200x200px]]
27075 !!end
27076
27077 !! test
27078 Image: Modifying size of an image (2)
27079 !! options
27080 parsoid={
27081 "modes": ["wt2wt"],
27082 "changes": [
27083 ["img[height]", "attr", "height", "100"],
27084 ["img[width]", "attr", "width", "500"]
27085 ]
27086 }
27087 !! wikitext
27088 [[Image:Foobar.jpg|230x230px]]
27089 !! wikitext/edited
27090 [[Image:Foobar.jpg|500x500px]]
27091 !!end
27092
27093 # Change in size is ignored so long as class='mw-default-size'
27094 !! test
27095 Image: Modifying size of an image (3)
27096 !! options
27097 parsoid={
27098 "modes": ["wt2wt"],
27099 "changes": [
27100 ["figure[class]", "removeClass", "mw-default-size"],
27101 ["figure img", "attr", "height", "19"],
27102 ["figure img", "attr", "width", "170"]
27103 ]
27104 }
27105 !! wikitext
27106 [[Image:Foobar.jpg|thumb]]
27107 !! wikitext/edited
27108 [[Image:Foobar.jpg|thumb|170x170px]]
27109 !!end
27110
27111 !! test
27112 Image: Modifying alignment of an image (T50665)
27113 !! options
27114 parsoid={
27115 "modes": ["wt2wt"],
27116 "changes": [
27117 ["figure[class]", "removeClass", "mw-halign-right"],
27118 ["figure[class]", "addClass", "mw-halign-left"]
27119 ]
27120 }
27121 !! wikitext
27122 [[Image:Foobar.jpg|thumb|caption|right]]
27123 !! wikitext/edited
27124 [[Image:Foobar.jpg|thumb|caption|left]]
27125 !! end
27126
27127 !! test
27128 Image: Modifying mw-default-size of an frameless image (T64805)
27129 !! options
27130 parsoid={
27131 "modes": ["wt2wt"],
27132 "changes": [
27133 ["figure.mw-default-size", "removeClass", "mw-default-size"]
27134 ]
27135 }
27136 !! wikitext
27137 [[Image:Foobar.jpg|frameless|right]]
27138 !! wikitext/edited
27139 [[Image:Foobar.jpg|frameless|right|220x220px]]
27140 !! end
27141
27142 !! test
27143 Image: Modifying valign of an image (T51221)
27144 !! options
27145 parsoid={
27146 "modes": ["wt2wt"],
27147 "changes": [
27148 ["*[typeof=\"mw:Image\"]", "removeClass", "mw-valign-middle"],
27149 ["*[typeof=\"mw:Image\"]", "addClass", "mw-valign-text-top"]
27150 ]
27151 }
27152 !! wikitext
27153 [[File:Foobar.jpg|20px|middle]]
27154 !! wikitext/edited
27155 [[File:Foobar.jpg|20px|text-top]]
27156 !! end
27157
27158 !! test
27159 Image: Modifying alt attribute of an image (T58400)
27160 !! options
27161 parsoid={
27162 "modes": ["wt2wt"],
27163 "changes": [
27164 ["img[alt]", "attr", "alt", "some alternate edited text"]
27165 ]
27166 }
27167 !! wikitext
27168 [[File:Foobar.jpg|thumb|some caption|alt=some alternate text]]
27169 !! wikitext/edited
27170 [[File:Foobar.jpg|thumb|some caption|alt=some alternate edited text]]
27171 !!end
27172
27173 !! test
27174 Image: Modifying caption of an image
27175 !! options
27176 parsoid={
27177 "modes": ["wt2wt"],
27178 "changes": [
27179 ["figcaption", "text", "new caption"]
27180 ]
27181 }
27182 !! wikitext
27183 [[Image:Foobar.jpg|thumb|original caption]]
27184 !! wikitext/edited
27185 [[Image:Foobar.jpg|thumb|new caption]]
27186 !!end
27187
27188 !! test
27189 Image: empty alt attribute (T50924)
27190 !! options
27191 parsoid
27192 !! wikitext
27193 [[File:Foobar.jpg|thumb|alt=|bar]]
27194 !! html
27195 <figure class="mw-default-size" typeof="mw:Image/Thumb" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"},{"ck":"alt","ak":"alt="},{"ck":"caption","ak":"bar"}]}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"}}'><img alt="" resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220" data-parsoid='{"a":{"alt":"","resource":"./File:Foobar.jpg","height":"25","width":"220"},"sa":{"alt":"alt=","resource":"File:Foobar.jpg"}}'/></a><figcaption>bar</figcaption></figure>
27196 !! end
27197
27198 !! test
27199 Image: new attributes should be serialized in wiki's language for RTL languages (T53852)
27200 !! options
27201 parsoid=html2wt
27202 language=ar
27203 disabled
27204 !! html/parsoid
27205 <figure class="mw-default-size mw-halign-right" typeof="mw:Image/Thumb"><a href="./Imagen:Foobar.jpg"><img resource="./Imagen:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="20" width="180"/></a></figure>
27206 !! wikitext
27207 [[Imagen:Foobar.jpg|derecha|miniaturadeimagen]]
27208 !! end
27209
27210 !! test
27211 Image: Block level image should have \n before and after
27212 !! wikitext
27213 123
27214 [[File:Foobar.jpg|right|thumb|150x150px]]
27215 456
27216 !! html/parsoid
27217 <p>123</p>
27218 <figure class="mw-halign-right" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/150px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="17" width="150"/></a></figure>
27219 <p>456</p>
27220 !! end
27221
27222 !! test
27223 Image: New block level image should have \n before and after (existing content)
27224 !! wikitext
27225 123
27226 [[File:Foobar.jpg|right|thumb|150x150px]]
27227 456
27228 !! html/parsoid
27229 <p>123</p>
27230 <figure class="mw-halign-right" typeof="mw:Image/Thumb" data-parsoid='{"optList":[{"ck":"right","ak":"right"},{"ck":"thumbnail","ak":"thumb"},{"ck":"width","ak":"150x150px"}]}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"}}'><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/150px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="17" width="150" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"17","width":"150"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></figure>
27231 <p>456</p>
27232 !! end
27233
27234 !! test
27235 Image: upright option (parsoid)
27236 !! wikitext
27237 [[File:Foobar.jpg|thumb|upright|caption]]
27238 [[File:Foobar.jpg|thumb|upright=0.5|caption]]
27239 [[File:Foobar.jpg|thumb|500x500px|upright=0.5|caption]]
27240 !! html/parsoid
27241 <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/170px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="19" width="170"/></a><figcaption>caption</figcaption></figure>
27242 <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/110px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="12" width="110"/></a><figcaption>caption</figcaption></figure>
27243 <figure typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/500px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="57" width="500"/></a><figcaption>caption</figcaption></figure>
27244 !! end
27245
27246 !! test
27247 Image: upright option is ignored on inline and frame images (parsoid)
27248 !! wikitext
27249 [[File:Foobar.jpg|500x500px|upright=0.5|caption]]
27250 !! html/parsoid
27251 <p><span typeof="mw:Image" data-mw='{"caption":"caption"}'><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/500px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="57" width="500"/></a></span></p>
27252 !! end
27253
27254 !! test
27255 Image: in template parameter with empty parameter
27256 !! wikitext
27257 {{echo|[[File:Foobar.jpg|link=]]}}
27258 !! html/parsoid
27259 <p><span class="mw-default-size" typeof="mw:Transclusion mw:Image" about="#mwt1" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[File:Foobar.jpg|link=]]"}},"i":0}}]}'><span><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></span></span></p>
27260 !! end
27261
27262 !! test
27263 Image: from basic HTML (1)
27264 !! options
27265 parsoid=html2wt
27266 !! html/parsoid
27267 <span typeof="mw:Image">
27268 <img src="./File:Foobar.jpg" width=100 height=100 alt="Alt">
27269 </span>
27270 !! wikitext
27271 [[File:Foobar.jpg|link=|alt=Alt|100x100px]]
27272 !! end
27273
27274 !! test
27275 Image: from basic HTML (2)
27276 !! options
27277 parsoid=html2wt
27278 !! html/parsoid
27279 <img src="./File:Foobar.jpg" width=100 height=100 alt="Alt">
27280 !! wikitext
27281 [[File:Foobar.jpg|link=|alt=Alt|100x100px]]
27282 !! end
27283
27284 !! test
27285 Image: from basic HTML (3)
27286 !! options
27287 parsoid=html2wt
27288 !! html/parsoid
27289 <a href="Main"><img src="./File:Foobar.jpg" width=100 height=100 alt="Alt"></a>
27290 !! wikitext
27291 [[File:Foobar.jpg|link=Main|alt=Alt|100x100px]]
27292 !! end
27293
27294 !! test
27295 Image: from basic HTML (4)
27296 !! options
27297 parsoid=html2wt
27298 !! html/parsoid
27299 <img src="./File:Foobar.jpg">
27300 !! wikitext
27301 [[File:Foobar.jpg|link=]]
27302 !! end
27303
27304 !! test
27305 Image: Invalid title as link
27306 !! wikitext
27307 [[File:Foobar.jpg|link=<]]
27308 !! html/php
27309 <p><a href="/wiki/File:Foobar.jpg" class="image" title="link=&lt;"><img alt="link=&lt;" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
27310 </p>
27311 !! html/parsoid
27312 <p><span class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"link","ak":"link=&lt;"}]}' data-mw='{"caption":"link=&amp;lt;"}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{}}'><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></span></p>
27313 !! end
27314
27315 !! test
27316 Lists: Serialize correctly even when list content is wrapped in p-tags (like VE does)
27317 !! options
27318 parsoid=html2wt
27319 !! html/parsoid
27320 <ul>
27321 <li><p>foo</p></li>
27322 </ul>
27323 !! wikitext
27324 * foo
27325 !! end
27326
27327 !! test
27328 Lists: Serialize correctly even when list tags has unneeded whitespace between tags
27329 !! options
27330 parsoid=html2wt
27331 !! html/parsoid
27332 <ul> <li>foo</li></ul>
27333 !! wikitext
27334 * foo
27335 !! end
27336
27337 !! test
27338 Don't strip leading whitespace when handling indent-pre suppressing tags
27339 !! options
27340 parsoid=html2wt
27341 !! html/parsoid
27342 <table>
27343 <tr><td> indented row</td></tr>
27344 </table>
27345 <blockquote><p>
27346 <b>This is very bold of you!</b>
27347 </p>
27348 <table><tr><td>
27349 indented cell (no pre-wrapping!)
27350 </td></tr></table>
27351 </blockquote>
27352 <p>foo</p>
27353 <div>bar</div>
27354 !! wikitext
27355 {|
27356 | indented row
27357 |}
27358 <blockquote>
27359 '''This is very bold of you!'''
27360
27361 {|
27362 |
27363 indented cell (no pre-wrapping!)
27364 |}
27365 </blockquote>
27366 foo
27367 <div>bar</div>
27368 !! end
27369
27370 !! test
27371 Nowiki-wrap leading whitespace when handling indent-pre inducing tags
27372 !! options
27373 parsoid=html2wt
27374 !! html/parsoid
27375 <p>foo</p>
27376 <span>bar</span>
27377
27378 <span>foo2
27379 </span>bar2
27380
27381 <div>foo</div>
27382 <span>bar</span>
27383
27384 <div>
27385 <span>foo</span>
27386 </div>
27387 !! wikitext
27388 foo
27389
27390 <span>bar</span>
27391
27392 <span>foo2
27393 <nowiki> </nowiki></span>bar2
27394
27395 <div>foo</div>
27396 <nowiki> </nowiki><span>bar</span>
27397
27398 <div>
27399 <nowiki> </nowiki><span>foo</span>
27400 </div>
27401 !! end
27402
27403 !! test
27404 Lists: Dont insert newlines in a serialized list item.
27405 !! options
27406 parsoid=html2wt
27407 !! html/parsoid
27408 <ul><li>a<br>b</li><li>c</li></ul>
27409 !! wikitext
27410 * a<br>b
27411 * c
27412 !! end
27413
27414 !! test
27415 1. Headings: Force sol-transparent links and behavior switches to serialize before/after
27416 !! options
27417 parsoid={
27418 "modes": ["html2wt"],
27419 "scrubWikitext": false
27420 }
27421 !! html/parsoid
27422 <h2>hello there<link href="./Category:A1" rel="mw:PageProp/Category" /></h2>
27423 <h2><link href="./Category:A2" rel="mw:PageProp/Category" />hi pal</h2>
27424
27425 <h2><!--foo--> <link href="./Category:A3" rel="mw:PageProp/Category" /> how goes it</h2>
27426 <h2>it goes well <link href="./Category:A4" rel="mw:PageProp/Category" /> <!--bar--></h2>
27427
27428 <h2 data-parsoid='{}'>howdy<link href="./Category:A5" rel="mw:PageProp/Category" /></h2>
27429
27430 <h2><meta property="mw:PageProp/toc" /> ok</h2>
27431 !! wikitext
27432 == hello there [[Category:A1]] ==
27433
27434 == [[Category:A2]] hi pal ==
27435
27436 == <!--foo--> [[Category:A3]] how goes it ==
27437
27438 == it goes well [[Category:A4]] <!--bar--> ==
27439
27440 ==howdy [[Category:A5]]==
27441
27442 == __TOC__ ok ==
27443 !! end
27444
27445 !! test
27446 2. Headings: Force sol-transparent links and behavior switches to serialize before/after
27447 !! options
27448 parsoid={
27449 "modes": ["html2wt"],
27450 "scrubWikitext": true
27451 }
27452 !! html/parsoid
27453 <h2>hello there<link href="./Category:A1" rel="mw:PageProp/Category" /></h2>
27454 <h2><link href="./Category:A2" rel="mw:PageProp/Category" />hi pal</h2>
27455
27456 <h2><!--foo--> <link href="./Category:A3" rel="mw:PageProp/Category" /> how goes it</h2>
27457 <h2>it goes well <link href="./Category:A4" rel="mw:PageProp/Category" /> <!--bar--></h2>
27458
27459 <h2><meta property="mw:PageProp/toc" /> ok</h2>
27460 !! wikitext
27461 == hello there ==
27462 [[Category:A1]]
27463 [[Category:A2]]
27464
27465 == hi pal ==
27466
27467 <!--foo--> [[Category:A3]]
27468
27469 == how goes it ==
27470
27471 == it goes well ==
27472 [[Category:A4]] <!--bar-->
27473
27474 __TOC__
27475
27476 == ok ==
27477 !! end
27478
27479 !! test
27480 Headings: Don't hoist metas that come from templates
27481 !! options
27482 parsoid={
27483 "modes": ["html2wt"],
27484 "scrubWikitext": true
27485 }
27486 !! html/parsoid
27487 <h2><span about="#mwt1" typeof="mw:Transclusion" data-parsoid="{}" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo [[Category:Foo]]"}},"i":0}}]}'>foo </span><link rel="mw:PageProp/Category" href="./Category:Foo" about="#mwt1" data-parsoid="{}" /></h2>
27488 !! wikitext
27489 == {{echo|foo [[Category:Foo]]}} ==
27490 !! end
27491
27492 !! test
27493 Headings: Category in ref isn't hoisted
27494 !! options
27495 parsoid={
27496 "modes": ["html2wt"],
27497 "scrubWikitext": true
27498 }
27499 !! html/parsoid
27500 <h2> foo <span about="#mwt2" class="mw-ref" id="cite_ref-1" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","body":{"id":"mw-reference-text-cite_note-1"},"attrs":{}}'><a href="./Main_Page#cite_note-1"><span class="mw-reflink-text">[1]</span></a></span> </h2>
27501
27502 <ol class="references" typeof="mw:Extension/references" about="#mwt3" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><span rel="mw:referencedBy"><a href="./Main_Page#cite_ref-1">↑</a></span> <span id="mw-reference-text-cite_note-1" class="mw-reference-text">bar <link rel="mw:PageProp/Category" href="./Category:Baz" /> </span></li></ol>
27503 !! wikitext
27504 == foo <ref>bar
27505 [[Category:Baz]] </ref> ==
27506
27507 <references />
27508 !! end
27509
27510 !! test
27511 Parsoid: Serialize positional parameters with = in them as named parameter
27512 !! options
27513 parsoid=html2wt
27514 !! html/parsoid
27515 <p about="#mwt1" typeof="mw:Transclusion"
27516 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"f=oo"}},"i":0}}]}'>foo</p>
27517
27518 <p about="#mwt1" typeof="mw:Transclusion"
27519 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"f=oo"}, "2":{"wt":"bar"}},"i":0}}]}'>foo</p>
27520
27521 <!--Orig params with data-parsoid has heuristics for handling = chars-->
27522 <!--FIXME: But maybe the heuristic needs fixing to apply to new params as well-->
27523 <p data-parsoid='{"pi":[[{"k":"1"},{"k":"2"}]]}' about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"f=oo"},"2":{"wt":"bar"}},"i":0}}]}'>foo</p>
27524 !! wikitext
27525 {{echo|1=f=oo}}
27526
27527 {{echo|1=f=oo|2=bar}}
27528
27529 <!--Orig params with data-parsoid has heuristics for handling = chars-->
27530 <!--FIXME: But maybe the heuristic needs fixing to apply to new params as well-->
27531 {{echo|<nowiki>f=oo</nowiki>|bar}}
27532 !! end
27533
27534 !! test
27535 Parsoid: Serialize positional parameters with = in extlink as named parameter
27536 !! options
27537 parsoid=html2wt
27538 !! html/parsoid
27539 <p><a rel="mw:ExtLink" href="http://stuff?is=ok" about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"http://stuff?is=ok"}},"i":0}}]}'>http://stuff?is=ok</a></p>
27540 !! wikitext
27541 {{echo|1=http://stuff?is=ok}}
27542 !! end
27543
27544 !! test
27545 Parsoid: Correctly serialize block-node children when they are a combination of text and p-nodes
27546 !! options
27547 parsoid=html2wt
27548 !! html/parsoid
27549 <div>a<p>b</p></div>
27550 <div>a
27551 <p>b</p></div>
27552 <div>
27553 a
27554 <p>b</p></div>
27555 !! wikitext
27556 <div>a
27557 b
27558 </div>
27559 <div>a
27560 b
27561 </div>
27562 <div>
27563 a
27564
27565 b
27566 </div>
27567 !! end
27568
27569 !! test
27570 Substrings resembling wikitext in hrefs should not get nowiki escapes
27571 !! options
27572 parsoid=html2wt
27573 !! html/parsoid
27574 <a rel="mw:WikiLink" href="./Foo''bar''baz">Foo''bar''baz</a>
27575 !! wikitext
27576 [[Foo''bar''baz]]
27577 !! end
27578
27579 !! test
27580 Enforce single-line context in the serializer
27581 !! options
27582 parsoid=html2wt
27583 !! html/parsoid
27584 <h2>testing
27585 123</h2>
27586
27587 <h2> hi <span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"bogus","href":"./Template:Bogus"},"params":{"1":{"wt":"there\nyou"}},"i":0}}]}'>there</span><span about="#mwt1">
27588 </span><span about="#mwt1">you</span> </h2>
27589
27590 <h2> foo <span about="#mwt2" class="mw-ref" id="cite_ref-1" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","body":{"id":"mw-reference-text-cite_note-1"},"attrs":{}}'><a href="./Main_Page#cite_note-1"><span class="mw-reflink-text">[1]</span></a></span> </h2>
27591
27592 <ol class="references" typeof="mw:Extension/references" about="#mwt3" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><span rel="mw:referencedBy"><a href="./Main_Page#cite_ref-1">↑</a></span> <span id="mw-reference-text-cite_note-1" class="mw-reference-text" data-parsoid="{}">hello
27593 there</span></li></ol>
27594
27595 <ul><li>asd
27596 sdf</li></ul>
27597
27598 <ul><li>foo
27599 bar
27600 baz</li>
27601 <li>foo <b>bar</b>
27602 baz</li></ul>
27603
27604 <dl><dt>hi
27605 ho </dt><dd data-parsoid='{"stx":"row"}'> hi
27606 ho</dd></dl>
27607
27608 <dl><dd> <table>
27609 <tbody><tr><td> ha
27610 ha
27611 ha</td></tr>
27612 </tbody></table></dd></dl>
27613 !! wikitext
27614 == testing 123 ==
27615
27616 == hi {{bogus|there
27617 you}} ==
27618
27619 == foo <ref>hello
27620 there</ref> ==
27621
27622 <references />
27623
27624 * asd sdf
27625
27626 * foo bar baz
27627 * foo '''bar''' baz
27628
27629 ; hi ho : hi ho
27630
27631 : {|
27632 | ha
27633 ha
27634 ha
27635 |}
27636 !! end
27637
27638 !! test
27639 Serialize new placeholder space without spans
27640 !! options
27641 parsoid=html2wt
27642 !! html/parsoid
27643 <p>foo<span typeof="mw:Placeholder"> </span>: bar</p>
27644
27645 <p>foo<span typeof="mw:DisplaySpace mw:Placeholder" data-parsoid='{"src":" ","isDisplayHack":true}'> </span>: bar</p>
27646
27647 <span typeof="mw:Extension/ref" data-mw="{&quot;name&quot;:&quot;ref&quot;,&quot;body&quot;:{&quot;html&quot;:&quot;foo<span typeof=\&quot;mw:Placeholder\&quot;>&amp;nbsp;</span>: bar&quot;}}"><sup>[1]</sup></span>ok</p>
27648 !! wikitext
27649 foo : bar
27650
27651 foo : bar
27652
27653 <ref>foo : bar</ref>ok
27654 !! end
27655
27656
27657 #-----------------------
27658 # Tag minimization tests
27659 #-----------------------
27660
27661 !! test
27662 1. I/B quote minimization: wikitext-only tags should be combined
27663 !! options
27664 parsoid=html2wt
27665 !! html/parsoid
27666 <p><i>A</i><i>B</i></p>
27667 <p><b>A</b><b>B</b></p>
27668 <p><i>A</i><b><i>B</i></b></p>
27669 <p><b>A</b><i><b>B</b></i></p>
27670 <p><b>A</b><i><b>B</b><b>C</b></i><b>D</b></p>
27671 <p><i><b>A</b></i><i><b>B</b></i></p>
27672 <p><i><b>A</b></i><b><i>B</i></b></p>
27673 <p><b><i>A</i></b><i><b>B</b></i></p>
27674 !! wikitext
27675 ''AB''
27676
27677 '''AB'''
27678
27679 ''A'''B'''''
27680
27681 '''A''B'''''
27682
27683 '''A''BC''D'''
27684
27685 '''''AB'''''
27686
27687 '''''AB'''''
27688
27689 '''''AB'''''
27690 !! end
27691
27692 !! test
27693 2. I/B quote minimization: wikitext and html tags should not be combined
27694 !! options
27695 parsoid=html2wt
27696 !! html/parsoid
27697 <p><i>A</i><i data-parsoid='{"stx":"html"}'>B</i></p>
27698 <p><i>A</i><b><i data-parsoid='{"stx":"html"}'>B</i></b></p>
27699 !! wikitext
27700 ''A''<i>B</i>
27701
27702 ''A''<nowiki/>'''<i>B</i>'''
27703 !! end
27704
27705 !! test
27706 3. I/B quote minimization: templated content stops minimization
27707 !! options
27708 parsoid=html2wt
27709 !! html/parsoid
27710 <p><i>A</i><i about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&#39;&#39;B&#39;&#39;"}},"i":0}}]}'>B</i>
27711 <p><i>A</i><b about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&#39;&#39;&#39;&#39;&#39;B&#39;&#39;&#39;&#39;&#39;"}},"i":0}}]}'><i>B</i></b>
27712 !! wikitext
27713 ''A''{{echo|''B''}}
27714
27715 ''A''{{echo|'''''B'''''}}
27716 !! end
27717
27718 !! test
27719 4. I/B quote minimization: new content should be mimimized with adjacent old content
27720 !! options
27721 parsoid=html2wt
27722 !! html/parsoid
27723 <p><i>A</i><i>B</i></p>
27724 <p><b>A</b><b>B</b></p>
27725 <p><i>A</i><b><i>B</i></b></p>
27726 !! wikitext
27727 ''AB''
27728
27729 '''AB'''
27730
27731 ''A'''B'''''
27732 !! end
27733
27734 !! test
27735 5a. Merge adjacent quote nodes if they've been edited
27736 !! options
27737 parsoid={
27738 "modes": ["wt2wt", "selser"],
27739 "changes": [
27740 ["p", "contents", "remove", ":contains('b')"]
27741 ]
27742 }
27743 !! wikitext
27744 ''a''b''c''
27745 !! wikitext/edited
27746 ''ac''
27747 !! end
27748
27749 !! test
27750 5b. Merge adjacent quote nodes if they've been edited
27751 !! options
27752 parsoid={
27753 "modes": ["wt2wt", "selser"],
27754 "changes": [
27755 ["#x", "remove"]
27756 ]
27757 }
27758 !! wikitext
27759 ''a''<span id="x">b</span>''c''
27760 !! wikitext/edited
27761 ''ac''
27762 !! end
27763
27764 !! test
27765 1. Merge adjacent link nodes as long as at least one element is new
27766 !! options
27767 parsoid={
27768 "modes": ["html2wt"],
27769 "scrubWikitext": true
27770 }
27771 !! html/parsoid
27772 <a rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
27773 <a data-parsoid="{}" rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
27774 <a data-parsoid="{}" rel="mw:WikiLink" href="./Football">Foot</a><a data-parsoid="{}" rel="mw:WikiLink" href="./Football">ball</a>
27775 !! wikitext
27776 [[Football]]
27777 [[Football]]
27778 [[Football|Foot]][[Football|ball]]
27779 !! end
27780
27781 !! test
27782 2. Merge adjacent link nodes and enable additional normalizations
27783 !! options
27784 parsoid={
27785 "modes": ["html2wt"],
27786 "scrubWikitext": true
27787 }
27788 !! html/parsoid
27789 <a rel="mw:WikiLink" href="./Football"><i>Foot</i></a><a rel="mw:WikiLink" href="./Football"><i>ball</i></a>
27790 !! wikitext
27791 [[Football|''Football'']]
27792 !! end
27793
27794 !! test
27795 3. Don't merge adjacent link nodes if scrubWikitext is false
27796 !! options
27797 parsoid={
27798 "modes": ["html2wt"],
27799 "scrubWikitext": false
27800 }
27801 !! html/parsoid
27802 <a rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
27803 !! wikitext
27804 [[Football|Foot]][[Football|ball]]
27805 !! end
27806
27807 #------------------------------
27808 # End of tag minimization tests
27809 #------------------------------
27810
27811 !!test
27812 T56262: New entities
27813 !! options
27814 parsoid=html2wt
27815 !! html/parsoid
27816 <span typeof="mw:Entity">&nbsp;</span>
27817 !! wikitext
27818 &nbsp;
27819 !! end
27820
27821 ## Note that there is no wikitext output for 'unknownproperty' ##
27822 ## Unknown magic words are silently dropped ##
27823
27824 !! test
27825 Magic words
27826 !! options
27827 parsoid=html2wt
27828 !! html/parsoid
27829 <meta property='mw:PageProp/toc' />
27830 <meta property='mw:PageProp/notoc' />
27831 <meta property='mw:PageProp/forcetoc' />
27832 <meta property='mw:PageProp/index' />
27833 <meta property='mw:PageProp/noindex' />
27834 <meta property='mw:PageProp/nogallery' />
27835 <meta property='mw:PageProp/noeditsection' />
27836 <meta property='mw:PageProp/notitleconvert' />
27837 <meta property='mw:PageProp/nocontentconvert' />
27838 <meta property='mw:PageProp/unknownproperty' />
27839 !! wikitext
27840 __TOC__
27841 __NOTOC__
27842 __FORCETOC__
27843 __INDEX__
27844 __NOINDEX__
27845 __NOGALLERY__
27846 __NOEDITSECTION__
27847 __NOTITLECONVERT__
27848 __NOCONTENTCONVERT__
27849 !! end
27850
27851 !! test
27852 Consecutive <pre>s should not get merged
27853 !! options
27854 parsoid=html2wt,html2html
27855 !! html/parsoid
27856 <pre>a</pre><pre>b</pre>
27857
27858 <pre>c
27859 </pre><pre>
27860 d</pre>
27861
27862 <pre>e
27863
27864 </pre><pre>
27865
27866 f</pre>
27867 !! wikitext
27868 a
27869
27870 b
27871
27872 c
27873
27874 d
27875
27876 e
27877
27878
27879
27880 f
27881 !! end
27882
27883 !! test
27884 Edited ISBN links not serializable as ISBN links should serialize as wikilinks
27885 !! options
27886 parsoid=html2wt
27887 !! html/parsoid
27888 <a href="./Special:BookSources/1234567890" rel="mw:ExtLink">ISBN 1234567895</a>
27889 !! wikitext
27890 [[Special:BookSources/1234567890|ISBN 1234567895]]
27891 !! end
27892
27893 !! test
27894 Edited RFC links not serializable as RFC links should serialize as extlinks
27895 !! options
27896 parsoid=html2wt
27897 !! html/parsoid
27898 <a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink">New RFC</a>
27899 !! wikitext
27900 [//tools.ietf.org/html/rfc123 New RFC]
27901 !! end
27902
27903 !! test
27904 Edited PMID links not serializable as PMID links should serialize as extlinks
27905 !! options
27906 parsoid=html2wt
27907 !! html/parsoid
27908 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink">New PMID</a>
27909 !! wikitext
27910 [//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract New PMID]
27911 !! end
27912
27913 !! test
27914 WTS of autolinks with trailing/surrounding context
27915 !! options
27916 parsoid=html2wt
27917 !! html/parsoid
27918 <p><a href="http://cscott.net">http://cscott.net</a><b>foo</b></p>
27919 <p><a href="http://cscott.net">http://cscott.net</a><b data-parsoid='{"stx":"html"}'>foo</b></p>
27920 <p><b><a href="http://cscott.net">http://cscott.net</a></b></p>
27921 <p><b><a href="http://cscott.net">http://cscott.net</a> </b></p>
27922 <p><b><a href="http://cscott.net">http://cscott.net</a>x</b></p>
27923 <p><a href="http://cscott.net">http://cscott.net</a>x</p>
27924 !! wikitext
27925 http://cscott.net'''foo'''
27926
27927 http://cscott.net<b>foo</b>
27928
27929 '''http://cscott.net'''
27930
27931 '''http://cscott.net '''
27932
27933 '''http://cscott.net<nowiki/>x'''
27934
27935 http://cscott.net<nowiki/>x
27936 !! end
27937
27938 !! test
27939 WTS of autolinks with nowikis (round-trip)
27940 !! wikitext
27941 x<nowiki/>http://cscott.net<nowiki/>x
27942 !! html/parsoid
27943 <p>x<a rel="mw:ExtLink" href="http://cscott.net">http://cscott.net</a>x</p>
27944 !! end
27945
27946 # this is the "easy" test because it leaves in place all the
27947 # data-parsoid information indicating this is an autolink
27948 !! test
27949 WTS of autolinks with escapes (editing)
27950 !! options
27951 parsoid={
27952 "modes": ["wt2wt"],
27953 "changes": [
27954 [ "span", "remove" ]
27955 ]
27956 }
27957 !! wikitext
27958 x<nowiki/>http://cscott.net<nowiki/>x
27959 !! wikitext/edited
27960 x<nowiki/>http://cscott.net<nowiki/>x
27961 !! end
27962
27963 !! test
27964 WTS of edited autolink-like text (T103364)
27965 !! options
27966 parsoid={
27967 "modes": ["wt2wt"],
27968 "changes": [
27969 [ "span[typeof]", "removeAttr", "typeof" ]
27970 ]
27971 }
27972 !! wikitext
27973 Not a link: <nowiki>http://example.com</nowiki>.
27974 !! wikitext/edited
27975 Not a link: <span><nowiki>http://example.com</nowiki></span>.
27976 !! end
27977
27978 !! test
27979 WTS of newly-authored autolink-like text (T103364)
27980 !! options
27981 parsoid=html2wt
27982 !! html/parsoid
27983 <p>http://example.com is not a link.</p>
27984 !! wikitext
27985 <nowiki>http://example.com</nowiki> is not a link.
27986 !! end
27987
27988 !! test
27989 WTS of autolink-like text after an autolink (T108563)
27990 !! options
27991 parsoid=html2wt
27992 !! html/parsoid
27993 <p><a rel="mw:ExtLink" href="http://example.com">http://example.com</a> http://example.com is not a link.</p>
27994 !! wikitext
27995 http://example.com <nowiki>http://example.com</nowiki> is not a link.
27996 !! end
27997
27998 !! test
27999 Magic links inside links (not autolinked)
28000 !! wikitext
28001 [[Foo|http://example.com]]
28002 [[Foo|RFC 1234]]
28003 [[Foo|PMID 1234]]
28004 [[Foo|ISBN 123456789x]]
28005
28006 [http://foo.com http://example.com]
28007 [http://foo.com RFC 1234]
28008 [http://foo.com PMID 1234]
28009 [http://foo.com ISBN 123456789x]
28010 !! html+tidy
28011 <p><a href="/wiki/Foo" title="Foo">http://example.com</a> <a href="/wiki/Foo" title="Foo">RFC 1234</a> <a href="/wiki/Foo" title="Foo">PMID 1234</a> <a href="/wiki/Foo" title="Foo">ISBN 123456789x</a></p>
28012 <p><a rel="nofollow" class="external text" href="http://foo.com">http://example.com</a> <a rel="nofollow" class="external text" href="http://foo.com">RFC 1234</a> <a rel="nofollow" class="external text" href="http://foo.com">PMID 1234</a> <a rel="nofollow" class="external text" href="http://foo.com">ISBN 123456789x</a></p>
28013 !! html/parsoid
28014 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">http://example.com</a>
28015 <a rel="mw:WikiLink" href="./Foo" title="Foo">RFC 1234</a>
28016 <a rel="mw:WikiLink" href="./Foo" title="Foo">PMID 1234</a>
28017 <a rel="mw:WikiLink" href="./Foo" title="Foo">ISBN 123456789x</a></p>
28018
28019 <p><a rel="mw:ExtLink" href="http://foo.com">http://example.com</a>
28020 <a rel="mw:ExtLink" href="http://foo.com">RFC 1234</a>
28021 <a rel="mw:ExtLink" href="http://foo.com">PMID 1234</a>
28022 <a rel="mw:ExtLink" href="http://foo.com">ISBN 123456789x</a></p>
28023 !! end
28024
28025 !! test
28026 Magic links inside image captions (autolinked)
28027 !! wikitext
28028 [[File:Foobar.jpg|thumb|http://example.com]]
28029 [[File:Foobar.jpg|thumb|RFC 1234]]
28030 [[File:Foobar.jpg|thumb|PMID 1234]]
28031 [[File:Foobar.jpg|thumb|ISBN 123456789x]]
28032 !! html+tidy
28033 <div class="thumb tright">
28034 <div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a>
28035 <div class="thumbcaption">
28036 <div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>
28037 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a></div>
28038 </div>
28039 </div>
28040 <div class="thumb tright">
28041 <div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a>
28042 <div class="thumbcaption">
28043 <div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>
28044 <a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc1234">RFC 1234</a></div>
28045 </div>
28046 </div>
28047 <div class="thumb tright">
28048 <div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a>
28049 <div class="thumbcaption">
28050 <div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>
28051 <a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a></div>
28052 </div>
28053 </div>
28054 <div class="thumb tright">
28055 <div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a>
28056 <div class="thumbcaption">
28057 <div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>
28058 <a href="/wiki/Special:BookSources/123456789X" class="internal mw-magiclink-isbn">ISBN 123456789x</a></div>
28059 </div>
28060 </div>
28061 !! html/parsoid
28062 <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption><a rel="mw:ExtLink" href="http://example.com">http://example.com</a></figcaption></figure>
28063 <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption><a href="//tools.ietf.org/html/rfc1234" rel="mw:ExtLink">RFC 1234</a></figcaption></figure>
28064 <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption><a href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract" rel="mw:ExtLink">PMID 1234</a></figcaption></figure>
28065 <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption><a href="./Special:BookSources/123456789X" rel="mw:WikiLink">ISBN 123456789x</a></figcaption></figure>
28066 !! end
28067
28068 !! test
28069 WTS of magic word text (T109371)
28070 !! options
28071 parsoid=html2wt
28072 !! html/parsoid
28073 <p>RFC 1234</p>
28074 <p><a href="http://foo.com" rel="mw:ExtLink">RFC 1234</a></p>
28075 <p><a href="./Foo" rel="mw:WikiLink">RFC 1234</a></p>
28076 !! wikitext
28077 <nowiki>RFC 1234</nowiki>
28078
28079 [http://foo.com RFC 1234]
28080
28081 [[Foo|RFC 1234]]
28082 !! end
28083
28084 !! test
28085 Edited Redirect link should emit a non-piped wikitext link
28086 !! options
28087 parsoid=html2wt
28088 !! html/parsoid
28089 <link rel="mw:PageProp/redirect" href="Bar" data-parsoid='{"a":{"href":"./Foo"},"sa":{"href":"Foo"}}'>
28090 !! wikitext
28091 #REDIRECT [[Bar]]
28092 !! end
28093
28094 !! test
28095 T75121: Infer extension name from typeOf if data-mw is not present
28096 !! options
28097 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
28098 !! html/parsoid
28099 <div typeOf="mw:Extension/foo"></div>
28100 !! wikitext
28101 <foo />
28102 !! end
28103
28104 # Note that the <p> wrapping isn't present in PHP parser output
28105 # The important thing for this test is that P-wrapping doesn't
28106 # interfere with the <nowiki> protection for leading - in <td>
28107 # (which isn't necessary for <th>).
28108 !! test
28109 T88318: p-wrapped dash in table.
28110 !! options
28111 parsoid=html2wt,wt2wt
28112 !! html/parsoid
28113 <table><tbody>
28114 <tr><th><p>-</p></th><th><p>- </p></th></tr>
28115 <tr><td><p>-</p></td><td><p>- </p></td></tr>
28116 <tr><td><small>-</small></td><td><br/><p>-</p></td><td><br/>-</td></tr>
28117 </tbody></table>
28118 !! wikitext
28119 {|
28120 !-
28121 !-
28122 |-
28123 |<nowiki>-</nowiki>
28124 |<nowiki>- </nowiki>
28125 |-
28126 |<small>-</small>
28127 |<br>
28128 -
28129 |<br>
28130 -
28131 |}
28132 !! html/php+tidy
28133 <table>
28134 <tr>
28135 <th>-</th>
28136 <th>-</th>
28137 </tr>
28138 <tr>
28139 <td>-</td>
28140 <td>-</td>
28141 </tr>
28142 <tr>
28143 <td><small>-</small></td>
28144 <td><br />
28145 <p>-</p>
28146 </td>
28147 <td><br />
28148 <p>-</p>
28149 </td>
28150 </tr>
28151 </table>
28152 !! end
28153
28154 !! test
28155 T149209: WTS: Handle newlines in table cells properly
28156 !! options
28157 parsoid=html2wt
28158 !! html/parsoid
28159 <table>
28160 <tbody>
28161 <tr><td>a
28162 b
28163 </td><td data-parsoid='{"stx_v":"row"}'>c</td></tr>
28164 <tr><td><p>x</p>
28165 </td><td data-parsoid='{"stx_v":"row", "startTagSrc": "{{!}}{{!}}"}'>y</td></tr>
28166 </tbody></table>
28167 <table>
28168 <tbody>
28169 <tr><th>a
28170 b
28171 </th><th data-parsoid='{"stx_v":"row"}'>c</th></tr>
28172 <tr><th><p>x</h>
28173 </th><th data-parsoid='{"stx_v":"row"}'>y</th></tr>
28174 </tbody></table>
28175 !! wikitext
28176 {|
28177 |a
28178 b
28179 |c
28180 |-
28181 |x
28182 {{!}}y
28183 |}
28184 {|
28185 !a
28186 b
28187 !c
28188 |-
28189 !x
28190 !y
28191 |}
28192 !! end
28193
28194 !! test
28195 T149209: Selser: Handle newlines in table cells properly
28196 !! options
28197 parsoid={
28198 "modes": ["selser"],
28199 "changes": [
28200 [ "#h1", "html", "a\nb\n" ],
28201 [ "#h2", "html", "a\nb\n" ],
28202 [ "#c1", "html", "a\nb\n" ],
28203 [ "#c2", "html", "<p>a</p>" ],
28204 [ "#c3", "html", "<p>a</p>" ],
28205 [ "#c4", "html", "edit-me<p>a</p>" ]
28206 ]
28207 }
28208 !! wikitext
28209 {|
28210 ! id="h1" |edit-me!!1
28211 |-
28212 ! id="h2" |edit-me||2
28213 |-
28214 | id="c1" |edit-me||3
28215 |-
28216 | id="c2" |edit-me||4
28217 |-
28218 | id="c3" |edit-me||p||q||r
28219 |-
28220 | id="c4" |edit-me||p||q||r
28221 |}
28222 !! wikitext/edited
28223 {|
28224 ! id="h1" |a
28225 b
28226 !1
28227 |-
28228 ! id="h2" |a
28229 b
28230 !2
28231 |-
28232 | id="c1" |a
28233 b
28234 |3
28235 |-
28236 | id="c2" |a
28237 |4
28238 |-
28239 | id="c3" |a
28240 |p||q||r
28241 |-
28242 | id="c4" |edit-me
28243 a
28244 |p||q||r
28245 |}
28246 !! end
28247
28248 !! test
28249 HTML id attribute with Parsoid-like element ids should not be serialized to wikitext
28250 !! options
28251 parsoid=html2wt
28252 !! html/parsoid
28253 <table id='mwAb'>
28254 <td id='mwAc'>foo</td>
28255 <td id='serialize-this'>bar</td>
28256 </table>
28257 !! wikitext
28258 {|
28259 |foo
28260 | id="serialize-this" |bar
28261 |}
28262 !! end
28263
28264 !! test
28265 Parsoid-like element ids should not be serialized to wikitext unless shadowed
28266 !! options
28267 parsoid=html2wt
28268 !! html/parsoid
28269 <div id="mwAQ" data-parsoid='{"stx":"html","a":{"id":"mwAQ"},"sa":{"id":"hello"}}'>ok</div>
28270 !! wikitext
28271 <div id="hello">ok</div>
28272 !! end
28273
28274 !! test
28275 WTS change modes
28276 !! options
28277 parsoid={
28278 "modes": ["wt2wt"],
28279 "changes": [
28280 [ "#xyz", "before", "<b>before</b> stuff " ],
28281 [ "#xyz", "after", " stuff <i>after</i>" ],
28282 [ "#xyz", "html", "x <b>y</b> z" ]
28283 ]
28284 }
28285 !! wikitext
28286 <span id="xyz">hello</span>
28287 !! wikitext/edited
28288 '''before''' stuff <span id="xyz">x '''y''' z</span> stuff ''after''
28289 !! end
28290
28291 !! test
28292 Never serialize a-tag as html, regardless of what data-parsoid has to say
28293 !! options
28294 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
28295 !! html/parsoid
28296 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"html"}'>Foo</a>
28297 !! wikitext
28298 [[Foo]]
28299 !! end
28300
28301 ## SSS FIXME: This is broken output nevertheless.
28302 ## What might be a reasonable non-broken output for this?
28303 ## This is an edge case unlikely to be seen in production
28304 ## that I am not wasting more time on this right now.
28305 !! test
28306 Never serialize a-tag as html, no matter what attributes it has
28307 !! options
28308 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
28309 !! html/parsoid
28310 <a bad='true' href='http://boo.org'><img src='http://boohoo.org' /></a>
28311 !! wikitext
28312 [http://boo.org http://boohoo.org]
28313 !! end
28314
28315 # Misnested is an indication that selser can reuse the source but these have
28316 # shown to sneak through on occasion. See T101768.
28317 # The original wikitext here is: [http://test.com [[one]] two three]
28318 !! test
28319 Strip span tags added to mark misnested links
28320 !! options
28321 parsoid=html2wt
28322 !! html/parsoid
28323 <p data-parsoid='{}'><a rel="mw:ExtLink" href="http://test.com" data-parsoid='{"targetOff":17,"contentOffsets":[17,34]}'></a><a rel="mw:WikiLink" href="./One" title="One" data-parsoid='{"stx":"simple","a":{"href":"./One"},"sa":{"href":"one"},"misnested":true}'>one</a><span data-parsoid='{"misnested":true}'> two three</span></p>
28324 !! wikitext
28325 [http://test.com][[one]] two three
28326 !! end
28327
28328 !! test
28329 Catch regression when unpacking misnested links
28330 !! options
28331 parsoid=wt2html
28332 !! wikitext
28333 {{echo|hi}}[http://example.com [[ho]]]
28334 !! html/parsoid
28335 <p><span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi"}},"i":0}}]}'>hi</span><a rel="mw:ExtLink" href="http://example.com"></a><a rel="mw:WikiLink" href="./Ho" title="Ho" data-parsoid='{"misnested":true}'>ho</a></p>
28336 !! end
28337
28338 !! test
28339 Use data-parsoid.firstWikitextNode to compute newline constraints for template content
28340 !! options
28341 parsoid=html2wt
28342 !! html/parsoid
28343 <span about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"a"}},"i":0}}]}'>a</span><table about="#mwt2" typeof="mw:Transclusion mw:ExpandedAttrs" data-parsoid='{"a":{"{{echo|c\n{{!}}d\n}}":null},"sa":{"{{echo|c\n{{!}}d\n}}":""},"firstWikitextNode":"table","pi":[[{"k":"1"}]]}' data-mw='{"parts":["{|",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"c\n{{!}}d\n"}},"i":0}},"\n|}"]}'>
28344 <tbody><tr><td>d
28345 </td></tr>
28346 </tbody></table>
28347 !! wikitext
28348 {{echo|a}}
28349 {|{{echo|c
28350 {{!}}d
28351 }}
28352 |}
28353 !! end
28354
28355 ## This test verifies the presence and computation of this attribute indirectly
28356 ## by making an edit and ensuring that the serialization is correct (which it would be
28357 ## only if firstWikitextNode is properly set).
28358 !! test
28359 data-parsoid.firstWikitextNode should be computed properly in the presence of fostered content
28360 !! options
28361 parsoid= {
28362 "modes": ["wt2wt"],
28363 "changes": [
28364 [ "div#x", "remove" ],
28365 [ "div", "before", "<div>new</div>" ]
28366 ]
28367 }
28368 !! wikitext
28369 <div id="x">foo</div>
28370 {|
28371 {{echo|<div>boo</div>
28372 {{!}}b}}
28373 |c
28374 |}
28375 !! wikitext/edited
28376
28377 <div>new</div>
28378 {|
28379 {{echo|<div>boo</div>
28380 {{!}}b}}
28381 |c
28382 |}
28383 !! end
28384
28385 # --------------------------------------------
28386 # Tests spec'ing wikitext serialization norms |
28387 # --------------------------------------------
28388
28389 !! test
28390 Serialize multi-line indent-pre starting with wikitext syntax
28391 !! options
28392 parsoid=html2wt
28393 !! html/parsoid
28394 <pre>* 1
28395 ** 2
28396 * 3</pre>
28397 !! wikitext
28398 * 1
28399 ** 2
28400 * 3
28401 !! end
28402
28403 !! test
28404 1. Categories should always be serialized on their own line
28405 !! options
28406 parsoid=html2wt
28407 !! html/parsoid
28408 foo<link rel="mw:PageProp/Category" href="./Category:Foo">bar
28409 !! wikitext
28410 foo
28411 [[Category:Foo]]
28412 bar
28413 !! end
28414
28415 !! test
28416 2. Categories that are part of templates should not introduce a line break
28417 !! wikitext
28418 foo {{echo|<span>bar</span> [[Category:baz]]}} bar
28419 !! html/parsoid
28420 <p>foo <span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;span>bar&lt;/span> [[Category:baz]]"}},"i":0}}]}'>bar</span><span about="#mwt1"> </span><link rel="mw:PageProp/Category" href="./Category:Baz" about="#mwt1" data-parsoid='{"stx":"simple","a":{"href":"./Category:Baz"},"sa":{"href":"Category:baz"}}'/> bar</p>
28421 !! end
28422
28423 # Careful while editing these next 2 tests. There are \u200f characters
28424 # before and after the <link> tags in the HTML and following some
28425 # of the categories in wikitext
28426 # Do not remove these characters in edits.
28427 #
28428 # As part of the serialization, these bidi characters will get stripped.
28429 !! test
28430 RTL (\u200f) and LTR (\u200e) markers around category tags should be stripped
28431 !! options
28432 parsoid={
28433 "modes": ["html2wt"],
28434 "scrubWikitext": true
28435 }
28436 !! html/parsoid
28437 <p>‏<link rel="mw:PageProp/Category" href="./קטגוריה:טקסים" />‏
28438 ‏<link rel="mw:PageProp/Category" href="./קטגוריה:_שיטות_משפט" />‏</p>
28439 !! wikitext
28440 [[קטגוריה:טקסים]]
28441 [[קטגוריה: שיטות משפט]]
28442 !! end
28443
28444 !! test
28445 RTL (\u200f) and LTR (\u200e) markers should not be stripped if followed by a text node
28446 !! options
28447 parsoid={
28448 "modes": ["html2wt"],
28449 "scrubWikitext": true
28450 }
28451 !! html/parsoid
28452 <p>‏<link rel="mw:PageProp/Category" href="./קטגוריה:טקסים" />‏y</p>
28453 !! wikitext
28454 [[קטגוריה:טקסים]]
28455 ‏y
28456 !! end
28457
28458 !! test
28459 Lists: Add space after bullets
28460 !! options
28461 parsoid=html2wt
28462 !! html/parsoid
28463 <ul>
28464 <li>foo</li>
28465 <li> bar</li>
28466 <li><span> baz</span></li>
28467 </ul>
28468 !! wikitext
28469 * foo
28470 * bar
28471 * <span> baz</span>
28472 !! end
28473
28474 !! test
28475 1. Headings: Add space before/after == (T53744)
28476 !! options
28477 parsoid=html2wt
28478 !! html/parsoid
28479 <h2>foo</h2>
28480 <h2> bar</h2>
28481 <h2>baz </h2>
28482 <h2><span> baz</span></h2>
28483 !! wikitext
28484 == foo ==
28485
28486 == bar ==
28487
28488 == baz ==
28489
28490 == <span> baz</span> ==
28491 !! end
28492
28493 !! test
28494 2. Headings: Add space before/after == even after hoisted content
28495 !! options
28496 parsoid={
28497 "modes": ["html2wt"],
28498 "scrubWikitext": true
28499 }
28500 !! html/parsoid
28501 <h2> <link href="./Category:A2" rel="mw:PageProp/Category" />ok</h2>
28502 !! wikitext
28503 [[Category:A2]]
28504
28505 == ok ==
28506 !! end
28507
28508 !! test
28509 1. Headings: suppress newly created empty headings
28510 !! options
28511 parsoid={
28512 "modes": ["html2wt"],
28513 "scrubWikitext": true
28514 }
28515 !! html/parsoid
28516 <h2></h2>
28517 !! wikitext
28518 !! end
28519
28520 !! test
28521 2. Headings: don't suppress empty headings if scrubWikitext is false
28522 !! options
28523 parsoid=html2wt
28524 !! html/parsoid
28525 <h2></h2>
28526 !! wikitext
28527 ==<nowiki/>==
28528 !! end
28529
28530 !! test
28531 3. Headings: suppress empty headings on edits
28532 !! options
28533 parsoid={
28534 "modes": ["selser"],
28535 "scrubWikitext": true,
28536 "changes": [
28537 [ "#x", "remove"]
28538 ]
28539 }
28540 !! wikitext
28541 ==<span id="x">foo</span>==
28542 !! wikitext/edited
28543 !! end
28544
28545 !! test
28546 Headings: Replace <br/> with a single whitespace char (when scrubWikitext = true)
28547 !! options
28548 parsoid={
28549 "modes": ["html2wt"],
28550 "scrubWikitext": true
28551 }
28552 !! html/parsoid
28553 <h2>foo<br/>bar</h2>
28554 <h2>foo <span><br/>bar</span> baz</h2>
28555 !! wikitext
28556 == foo bar ==
28557
28558 == foo <span> bar</span> baz ==
28559 !! end
28560
28561 !! test
28562 Headings: Replace <br/> with a single whitespace char (when scrubWikitext = false)
28563 !! options
28564 parsoid={
28565 "modes": ["html2wt"],
28566 "scrubWikitext": false
28567 }
28568 !! html/parsoid
28569 <h2>foo<br/>bar</h2>
28570 !! wikitext
28571 == foo<br> bar ==
28572 !! end
28573
28574 !! test
28575 1. WT Quote Tags: suppress newly created empty style tags
28576 !! options
28577 parsoid={
28578 "modes": ["html2wt"],
28579 "scrubWikitext": true
28580 }
28581 !! html/parsoid
28582 <i></i><b></b>
28583 !! wikitext
28584 !! end
28585
28586 !! test
28587 2. WT Quote Tags: don't suppress empty style tags if scrubWikitext is false
28588 !! options
28589 parsoid=html2wt
28590 !! html/parsoid
28591 <i></i><b></b>
28592 !! wikitext
28593 ''<nowiki/>'''''<nowiki/>'''
28594 !! end
28595
28596 !! test
28597 3. WT Quote Tags: suppress empty style tags on edits
28598 !! options
28599 parsoid={
28600 "modes": ["selser"],
28601 "scrubWikitext": true,
28602 "changes": [
28603 [ "#x", "remove"]
28604 ]
28605 }
28606 !! wikitext
28607 '''<span id="x">foo</span>'''
28608 !! wikitext/edited
28609 !! end
28610
28611 !! test
28612 1. Anchors: suppress newly created empty anchors
28613 !! options
28614 parsoid={
28615 "modes": ["html2wt"],
28616 "scrubWikitext": true
28617 }
28618 !! html/parsoid
28619 <a rel="mw:WikiLink" href="./Test" title="Test"></a>
28620 !! wikitext
28621 !! end
28622
28623 !! test
28624 2. Anchors: don't suppress empty anchors if scrubWikitext is false
28625 !! options
28626 parsoid={
28627 "modes": ["html2wt"],
28628 "scrubWikitext": false
28629 }
28630 !! html/parsoid
28631 <a rel="mw:WikiLink" href="./Test" title="Test"></a>
28632 !! wikitext
28633 [[Test|<nowiki/>]]
28634 !! end
28635
28636 !! test
28637 3. Anchors: suppress empty anchors on edits
28638 !! options
28639 parsoid={
28640 "modes": ["selser"],
28641 "scrubWikitext": true,
28642 "changes": [
28643 [ "#x", "remove"]
28644 ]
28645 }
28646 !! wikitext
28647 [[Test|<span id="x">foo</span>]]
28648 !! wikitext/edited
28649 !! end
28650
28651 !! test
28652 3a. Anchors: do not suppress numbered extlinks
28653 !! options
28654 parsoid={
28655 "modes": ["wt2wt"],
28656 "scrubWikitext": true
28657 }
28658 !! wikitext
28659 [http://foo.com]
28660 !! html/parsoid
28661 <a rel="mw:ExtLink" href="http://foo.com"></a>
28662 !! end
28663
28664 !! test
28665 3b. Anchors: do not suppress numbered extlinks
28666 !! options
28667 parsoid={
28668 "modes": ["wt2wt"],
28669 "scrubWikitext": true,
28670 "changes": [
28671 [ "#x", "remove"]
28672 ]
28673 }
28674 !! wikitext
28675 [http://foo.com <span id="x">foo</span>]
28676 !! wikitext/edited
28677 [http://foo.com]
28678 !! end
28679
28680 !!test
28681 Normalizations should be restricted to edited content
28682 !!options
28683 parsoid={
28684 "modes": ["selser"],
28685 "scrubWikitext": true,
28686 "changes": [
28687 [ "h1", "before", "<i></i>"]
28688 ]
28689 }
28690 !!wikitext
28691 a
28692 = =
28693 b
28694 !!wikitext/edited
28695 a
28696 = =
28697 b
28698 !!end
28699
28700 !! test
28701 1. Multiple normalizations (html2wt)
28702 !! options
28703 parsoid={
28704 "modes": ["html2wt"],
28705 "scrubWikitext": true
28706 }
28707 !! html
28708 <h2><i></i></h2>
28709 <p><a href='Foo' rel='mw:WikiLink'>foo<i></i>
28710 </a><b><i></i></b>x</p>
28711 !! wikitext
28712
28713 [[foo]]
28714 x
28715
28716 !! end
28717
28718 !! test
28719 2. Multiple normalizations (selser)
28720 !! options
28721 parsoid={
28722 "modes": ["selser"],
28723 "scrubWikitext": true,
28724 "changes": [
28725 [ "#x", "after", "<h1><i></i></h1>\n<p> x<b></b></p>"]
28726 ]
28727 }
28728 !! wikitext
28729 <span id="x">foo</span>
28730 !! wikitext/edited
28731 <span id="x">foo</span>
28732
28733 x
28734 !! end
28735
28736 !! test
28737 1. Indent Pre Nowiki: suppress whitespace at the start of new paragraph
28738 !! options
28739 parsoid={
28740 "modes": ["html2wt"],
28741 "scrubWikitext": true
28742 }
28743 !! html/parsoid
28744 <p> hi</p>
28745 <p> hello</p>
28746 !! wikitext
28747 hi
28748
28749 hello
28750 !! end
28751
28752 !! test
28753 2. Indent Pre Nowiki: don't suppress whitespace at the start of new paragraph if scrubWikitext is false
28754 !! options
28755 parsoid=html2wt
28756 !! html/parsoid
28757 <p> hi</p>
28758 <p> hello</p>
28759 !! wikitext
28760 <nowiki> </nowiki>hi
28761
28762 <nowiki> </nowiki> hello
28763 !! end
28764
28765 !! test
28766 3. Indent Pre Nowiki: suppress whitespace after newlines in new paragraph or table cell
28767 !! options
28768 parsoid={
28769 "modes": ["html2wt"],
28770 "scrubWikitext": true
28771 }
28772 !! html/parsoid
28773 <p>Foo
28774 bar
28775 baz</p>
28776
28777 <table><tr><td>Foo
28778 bar
28779 baz bang</td></tr></table>
28780
28781 <p><!--boo--> foo
28782 bar</p>
28783
28784 <p> foo
28785 bar<span>boo</span></p>
28786 !! wikitext
28787 Foo
28788 bar
28789 baz
28790
28791 {|
28792 |Foo
28793 bar
28794 baz bang
28795 |}
28796
28797 <!--boo-->foo
28798 bar
28799
28800 foo
28801 bar<span>boo</span>
28802 !! end
28803
28804 !! test
28805 4. Indent Pre Nowiki: suppress leading whitespace in edited paragraphs
28806 !! options
28807 parsoid={
28808 "modes": ["selser"],
28809 "scrubWikitext": true,
28810 "changes": [
28811 [ "p", "html", " a\n b" ]
28812 ]
28813 }
28814 !! wikitext
28815 xyz
28816 !! wikitext/edited
28817 a
28818 b
28819 !! end
28820
28821 !! test
28822 1. New links that end in spaces
28823 !! options
28824 parsoid={
28825 "modes": ["html2wt"],
28826 "scrubWikitext": false
28827 }
28828 !! html/parsoid
28829 <p><a rel="mw:WikiLink" href="./Berlin" title="Berlin">Berlin </a>is the capital of Germany.</p>
28830 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo </a><b>bar</b></p>
28831 <p><a rel="mw:WikiLink" href="./Boston" title="Boston">Boston </a> is a city.</p>
28832 !! wikitext
28833 [[Berlin ]]<nowiki/>is the capital of Germany.
28834
28835 [[Foo ]]'''bar'''
28836
28837 [[Boston ]] is a city.
28838 !! end
28839
28840 !! test
28841 2. New links that end in spaces
28842 !! options
28843 parsoid={
28844 "modes": ["html2wt"],
28845 "scrubWikitext": true
28846 }
28847 !! html/parsoid
28848 <p><a rel="mw:WikiLink" href="./Berlin" title="Berlin">Berlin </a>is the capital of Germany.</p>
28849 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo </a><b>bar</b></p>
28850 <p><a rel="mw:WikiLink" href="./Boston" title="Boston">Boston </a> is a city.</p>
28851 !! wikitext
28852 [[Berlin]] is the capital of Germany.
28853
28854 [[Foo]] '''bar'''
28855
28856 [[Boston]] is a city.
28857 !! end
28858
28859 !! test
28860 1. Table cells with escapable prefixes
28861 !! options
28862 parsoid={
28863 "modes": ["html2wt"],
28864 "scrubWikitext": false
28865 }
28866 !! html
28867 <table>
28868 <tr><td>a</td></tr>
28869 <tr><td>-</td></tr>
28870 <tr><td>+</td></tr>
28871 </table>
28872 !! wikitext
28873 {|
28874 |a
28875 |-
28876 |<nowiki>-</nowiki>
28877 |-
28878 |<nowiki>+</nowiki>
28879 |}
28880 !! end
28881
28882 !! test
28883 2. Table cells with escapable prefixes
28884 !! options
28885 parsoid={
28886 "modes": ["html2wt"],
28887 "scrubWikitext": true
28888 }
28889 !! html
28890 <table>
28891 <tr><td>a</td></tr>
28892 <tr><td>-</td></tr>
28893 <tr><td>+</td></tr>
28894 </table>
28895 !! wikitext
28896 {|
28897 |a
28898 |-
28899 | -
28900 |-
28901 | +
28902 |}
28903 !! end
28904
28905 !! test
28906 3a. Table cells with escapable prefixes after edits
28907 !! options
28908 parsoid={
28909 "modes": ["selser"],
28910 "scrubWikitext": true,
28911 "changes": [
28912 [ "table tbody tr:first-child td:first-child", "remove"]
28913 ]
28914 }
28915 !! wikitext
28916 {|
28917 |a||-
28918 |}
28919 !! wikitext/edited
28920 {|
28921 | -
28922 |}
28923 !! end
28924
28925 !! test
28926 3b. Table cells with escapable prefixes after edits
28927 !! options
28928 parsoid={
28929 "modes": ["selser"],
28930 "scrubWikitext": true,
28931 "changes": [
28932 [ "table tbody tr:first-child td:first-child", "html", "-" ],
28933 [ "#x", "remove" ]
28934 ]
28935 }
28936 !! wikitext
28937 {|
28938 |pqr
28939 |<span id="x">foo</span>+
28940 |}
28941 !! wikitext/edited
28942 {|
28943 | -
28944 | +
28945 |}
28946 !! end
28947
28948 # FIXME: This test will fail because
28949 # normalization doesn't realize that the id attribute
28950 # will eliminate the escapable scenario
28951 !! test
28952 4a. Table cells without escapable prefixes after edits
28953 !! options
28954 parsoid={
28955 "modes": ["selser"],
28956 "scrubWikitext": true,
28957 "changes": [
28958 [ "#x", "html", "-" ]
28959 ]
28960 }
28961 !! wikitext
28962 {|
28963 | id="x" |abcd
28964 |}
28965 !! wikitext/edited
28966 {|
28967 | id="x" |-
28968 |}
28969 !! end
28970
28971 ## This tests normalizer's ability to discriminate between
28972 ## cells having identical content.
28973 !! test
28974 4b. Table cells without escapable prefixes after edits
28975 !! options
28976 parsoid={
28977 "modes": ["selser"],
28978 "scrubWikitext": true,
28979 "changes": [
28980 [ "td", "html", "-" ]
28981 ]
28982 }
28983 !! wikitext
28984 {|
28985 |a||b
28986 |}
28987 !! wikitext/edited
28988 {|
28989 | -||-
28990 |}
28991 !! end
28992
28993 ## This tests normalizer's ability to not be tripped by
28994 ## comments (and whitespace)
28995 !! test
28996 4c. Table cells without escapable prefixes after edits
28997 !! options
28998 parsoid={
28999 "modes": ["selser"],
29000 "scrubWikitext": true,
29001 "changes": [
29002 [ "table tbody tr td:first-child", "remove" ]
29003 ]
29004 }
29005 !! wikitext
29006 {|
29007 |-
29008 <!--foo--> |a||-
29009 |}
29010 !! wikitext/edited
29011 {|
29012 |-
29013 <!--foo--> | -
29014 |}
29015 !! end
29016
29017 ## This tests normalizer's ability to handle HTML cells
29018 !! test
29019 4d. Table cells without escapable prefixes after edits
29020 !! options
29021 parsoid={
29022 "modes": ["selser"],
29023 "scrubWikitext": true,
29024 "changes": [
29025 [ "td", "html", "-" ]
29026 ]
29027 }
29028 !! wikitext
29029 <table>
29030 <tr><td>a</td></tr>
29031 </table>
29032 !! wikitext/edited
29033 <table>
29034 <tr><td>-</td></tr>
29035 </table>
29036 !! end
29037
29038 ## T111151 Remove font elements without attributes
29039 !! test
29040 5a. font tags without attributes should be dropped in scrubWikitext mode
29041 !! options
29042 parsoid={
29043 "modes": ["html2wt"],
29044 "scrubWikitext": true
29045 }
29046 !! html
29047 <font>foo</font>
29048 <font><font>bar</font></font>
29049 <font class="x">boo</font>
29050 !! wikitext
29051 foo
29052 bar
29053 <font class="x">boo</font>
29054 !! end
29055
29056 !! test
29057 5b. font tags should not be dropped without scrubWikitext being enabled
29058 !! options
29059 parsoid={
29060 "modes": ["html2wt"],
29061 "scrubWikitext": false
29062 }
29063 !! html
29064 <font>foo</font>
29065 !! wikitext
29066 <font>foo</font>
29067 !! end
29068
29069 !! test
29070 Escape nowiki DOM elements
29071 !! options
29072 parsoid=html2wt
29073 !! html/parsoid
29074 <nowiki><i>foo</i></nowiki>
29075 !! wikitext
29076 &lt;nowiki&gt;''foo''&lt;/nowiki&gt;
29077 !! end
29078
29079 # This is meant to be an interim fix while we go about figuring out
29080 # how to not introduce these trailing <nowiki/>s in the first place.
29081 !! test
29082 T115717: Strip trailing <nowiki/>s (without affecting valid uses)
29083 !! options
29084 parsoid=html2wt
29085 !! html/parsoid
29086 <p>x<meta typeof="mw:Placeholder" data-parsoid='{"src":"&lt;nowiki/>"}'/><meta typeof="mw:Placeholder" data-parsoid='{"src":"&lt;nowiki/>"}'/>
29087 y</p>
29088 <p><span about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1","named":true,"spc":["\n"," "," ",""]}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;nowiki/>"}},"i":0}}]}'></span></p>
29089 <p><span about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1","named":true,"spc":["\n"," "," ","\n"]}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;nowiki/>"}},"i":0}}]}'></span></p>
29090 !! wikitext
29091 x
29092 y
29093
29094 {{echo|
29095 1 = <nowiki/>}}
29096
29097 {{echo|
29098 1 = <nowiki/>
29099 }}
29100 !! end
29101
29102 # ---------------------------------------------------
29103 # End of tests spec'ing wikitext serialization norms |
29104 # ---------------------------------------------------
29105
29106 # T104032
29107 !! test
29108 Bare inline nodes not wrapped inside p-tags should be treated as p-wrapped
29109 !! options
29110 parsoid=html2wt
29111 !! html/parsoid
29112 a<p>b</p>
29113 <b>c</b><p>d</p>
29114 <table><tr>
29115 <td>a<p>b</p></td>
29116 <td><b>c</b><p>d</p></td>
29117 </tr></table>
29118 !! wikitext
29119 a
29120
29121 b
29122
29123 '''c'''
29124
29125 d
29126 {|
29127 |a
29128 b
29129 |'''c'''
29130 d
29131 |}
29132 !! end
29133
29134 !! test
29135 Anchor without href scenarios
29136 !! options
29137 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
29138 !! html/parsoid
29139 <a class="bc"></a>
29140 <a class="no">dice</a>
29141 <a name="foo"></a>
29142 !! wikitext
29143
29144 dice
29145 <span name="foo"></span>
29146 !! end
29147
29148 !! test
29149 New transclusion added after a list should be serialized after the list
29150 !! options
29151 parsoid=html2wt
29152 !! html/parsoid
29153 <ul><li>a</li></ul><span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</span>
29154 !! wikitext
29155 * a
29156 {{echo|foo}}
29157 !! end
29158
29159 # -----------------------------------------------------------------
29160 # End of section for Parsoid-only html2wt tests for serialization
29161 # of new content
29162 # -----------------------------------------------------------------
29163
29164 # -----------------------------------------------------------------
29165 # The following section of tests are primarily to spec behavior of
29166 # the selective serializer. All these tests have manual selser
29167 # changes. The automated selser changes for all tests handle the
29168 # wide variation of changes, but these tests here capture specs
29169 # deterministically.
29170 # ----------------------------------------------------------------
29171
29172 ## T90517
29173 !! test
29174 Selser: New comments should not be lost
29175 !! options
29176 parsoid={
29177 "modes": ["selser"],
29178 "changes": [
29179 [ "#a", "after", "<!--c1-->" ],
29180 [ "#b", "before", "<!--c2-->" ]
29181 ]
29182 }
29183 !! wikitext
29184 <span id="a">a</span>
29185
29186 <span id="b">b</span>
29187 !! wikitext/edited
29188 <span id="a">a</span><!--c1-->
29189
29190 <!--c2--><span id="b">b</span>
29191 !! end
29192
29193 ## T89383
29194 !! test
29195 Selser: Check for validity of DSR before using it
29196 !! options
29197 parsoid={
29198 "modes": ["selser"],
29199 "changes": [
29200 [ "#a", "before", "<meta property='mw:PageProp/displaytitle' content='foo'>" ]
29201 ]
29202 }
29203 !! wikitext
29204 <span id="a">a</span>
29205 !! wikitext/edited
29206 {{DISPLAYTITLE:foo}}
29207 <span id="a">a</span>
29208 !! end
29209
29210 !! test
29211 1. DOMDiff: Changes to <ref> content should be looked up using id
29212 !! options
29213 parsoid={
29214 "modes": ["selser"],
29215 "changes": [
29216 ["#X", "after", "bar"],
29217 ["#Y", "after", "baz"]
29218 ]
29219 }
29220 !! wikitext
29221 X <ref><span id="X">foo</span></ref>
29222 Y <ref name="a" />
29223 <references>
29224 <ref name="a"><span id="Y">foo</span></ref>
29225 </references>
29226 !! wikitext/edited
29227 X <ref><span id="X">foo</span>bar</ref>
29228 Y <ref name="a" />
29229 <references>
29230 <ref name="a"><span id="Y">foo</span>baz</ref>
29231 </references>
29232 !! end
29233
29234 !! test
29235 2. DOMDiff: Changes to <ref> content should be looked up using id
29236 !! options
29237 parsoid={
29238 "modes": ["selser"],
29239 "changes": [
29240 ["#Z", "after", "bar"]
29241 ]
29242 }
29243 !! wikitext
29244 A <ref>foo bar for a</ref>
29245 B <ref group="X" name="b" />
29246
29247 <references />
29248
29249 <references group="X">
29250 <ref name="b"><span id="Z">foo</span></ref>
29251 </references>
29252 !! wikitext/edited
29253 A <ref>foo bar for a</ref>
29254 B <ref group="X" name="b" />
29255
29256 <references />
29257
29258 <references group="X">
29259 <ref name="b"><span id="Z">foo</span>bar</ref>
29260 </references>
29261 !! end
29262
29263 !! test
29264 DOMDiff: Edits to content nested in elements with templated attributes should not be lost (T139388)
29265 !! options
29266 parsoid={
29267 "modes": ["selser"],
29268 "changes": [
29269 [ "div:first-child", "text", "bar" ]
29270 ]
29271 }
29272 !! wikitext
29273 <div style="{{1x|color:red;}}%">foo</div>
29274 !! wikitext/edited
29275 <div style="{{1x|color:red;}}%">bar</div>
29276 !! end
29277
29278 !! test
29279 Empty LI (T49673)
29280 !! wikitext
29281 * a
29282 *
29283 *
29284 * b
29285 !! html/php+tidy
29286 <ul>
29287 <li>a</li>
29288 <li class="mw-empty-elt"></li>
29289 <li class="mw-empty-elt"></li>
29290 <li>b</li>
29291 </ul>
29292 !! end
29293
29294 !! test
29295 Thumbnail output
29296 !! wikitext
29297 [[File:Thumb.png|thumb]]
29298 !! html/php+tidy
29299 <div class="thumb tright">
29300 <div class="thumbinner" style="width:137px;"><a href="/wiki/File:Thumb.png" class="image"><img alt="Thumb.png" src="http://example.com/images/e/ea/Thumb.png" width="135" height="135" class="thumbimage" /></a>
29301 <div class="thumbcaption">
29302 <div class="magnify"><a href="/wiki/File:Thumb.png" class="internal" title="Enlarge"></a></div>
29303 </div>
29304 </div>
29305 </div>
29306 !! end
29307
29308 !! test
29309 unclosed internal link XSS (T137264)
29310 !! wikitext
29311 [[#%3Cscript%3Ealert(1)%3C/script%3E|
29312 !! html/php
29313 <p>[[#&lt;script&gt;alert(1)&lt;/script&gt;|
29314 </p>
29315 !! html/parsoid
29316 <p>[[#%3Cscript%3Ealert(1)%3C/script%3E|</p>
29317 !! end
29318
29319 !! test
29320 Validating that <style> isn't eaten by tidy (T167349)
29321 !! options
29322 # Use $wgRawHtml to inject a <style> tag, since you normally can't in wikitext
29323 wgRawHtml=1
29324 !! wikitext
29325 <div class="foo">
29326 <html><style>.foo::before { content: "<foo>"; }</style></html>
29327 <html><style data-mw-foobar="baz">.foo::after { content: "<bar>"; }</style></html>
29328 </div>
29329 !! html+tidy
29330 <div class="foo">
29331 <style>.foo::before { content: "<foo>"; }</style>
29332 <style data-mw-foobar="baz">.foo::after { content: "<bar>"; }</style>
29333 </div>
29334 !! end
29335
29336 !! test
29337 Decoding of HTML entities in headings and links for IDs and link fragments (T103714)
29338 !! wikitext
29339 == A&B&amp;C&amp;amp;D&amp;amp;amp;E ==
29340 [[#A&B&amp;C&amp;amp;D&amp;amp;amp;E]]
29341 !! html/php
29342 <h2><span class="mw-headline" id="A.26B.26C.26amp.3BD.26amp.3Bamp.3BE">A&amp;B&amp;C&amp;amp;D&amp;amp;amp;E</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: A&amp;B&amp;C&amp;amp;D&amp;amp;amp;E">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
29343 <p><a href="#A.26B.26C.26D.26amp.3BE">#A&amp;B&amp;C&amp;amp;D&amp;amp;amp;E</a>
29344 </p>
29345 !! end
29346
29347 !! test
29348 Decoding of HTML entities in indicator names for IDs (T104196)
29349 !! options
29350 showindicators
29351 !! wikitext
29352 <indicator name="1&2&amp;3&amp;amp;4&amp;amp;amp;5">Indicator</indicator>
29353 !! html/php
29354 1&2&3&amp;4&amp;amp;5=Indicator
29355
29356 !! end
29357
29358 !! test
29359 HTML5 ids: fallback to legacy
29360 !! config
29361 wgFragmentMode=[ 'html5', 'legacy' ]
29362 !! wikitext
29363 == Foo bar ==
29364
29365 == foo Bar ==
29366
29367 == Тест ==
29368
29369 == Тест ==
29370
29371 == тест ==
29372
29373 == Hey < # " > % : ' ==
29374 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
29375
29376 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
29377
29378 <!-- These two links should produce identical HTML -->
29379 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
29380
29381 !! html/php
29382 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
29383 <ul>
29384 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
29385 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
29386 <li class="toclevel-1 tocsection-3"><a href="#%D0%A2%D0%B5%D1%81%D1%82"><span class="tocnumber">3</span> <span class="toctext">Тест</span></a></li>
29387 <li class="toclevel-1 tocsection-4"><a href="#%D0%A2%D0%B5%D1%81%D1%82_2"><span class="tocnumber">4</span> <span class="toctext">Тест</span></a></li>
29388 <li class="toclevel-1 tocsection-5"><a href="#%D1%82%D0%B5%D1%81%D1%82"><span class="tocnumber">5</span> <span class="toctext">тест</span></a></li>
29389 <li class="toclevel-1 tocsection-6"><a href="#Hey_%3C_%23_%22_%3E_%25_:_%27"><span class="tocnumber">6</span> <span class="toctext">Hey &lt; # " &gt;&#160;%&#160;: '</span></a></li>
29390 </ul>
29391 </div>
29392
29393 <h2><span class="mw-headline" id="Foo_bar">Foo bar</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: Foo bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
29394 <h2><span class="mw-headline" id="foo_Bar_2">foo Bar</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: foo Bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
29395 <h2><span id=".D0.A2.D0.B5.D1.81.D1.82"></span><span class="mw-headline" id="Тест">Тест</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=3" title="Edit section: Тест">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
29396 <h2><span id=".D0.A2.D0.B5.D1.81.D1.82_2"></span><span class="mw-headline" id="Тест_2">Тест</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=4" title="Edit section: Тест">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
29397 <h2><span id=".D1.82.D0.B5.D1.81.D1.82"></span><span class="mw-headline" id="тест">тест</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=5" title="Edit section: тест">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
29398 <h2><span id="Hey_.3C_.23_.22_.3E_.25_:_.27"></span><span class="mw-headline" id="Hey_&lt;_#_&quot;_&gt;_%_:_'">Hey &lt; # " &gt;&#160;%&#160;: '</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=6" title="Edit section: Hey &lt; # &quot; &gt; % : '">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
29399 <p><a href="#Foo_bar">#Foo bar</a> <a href="#foo_Bar">#foo Bar</a> <a href="#%D0%A2%D0%B5%D1%81%D1%82">#Тест</a> <a href="#%D1%82%D0%B5%D1%81%D1%82">#тест</a> <a href="#Hey_%3C_%23_%22_%3E_%25_:_%27">#Hey &lt; # " &gt;&#160;%&#160;: '</a>
29400 </p><p>%F0%9F%92%A9 <span id="%F0%9F%92%A9"></span>
29401 </p><p><a href="#%E5%95%A4%E9%85%92">#啤酒</a> <a href="#%E5%95%A4%E9%85%92">#啤酒</a>
29402 </p>
29403 !! end
29404
29405 !! test
29406 HTML5 ids: legacy with a fallback to modern
29407 !! config
29408 wgFragmentMode=[ 'legacy', 'html5' ]
29409 !! wikitext
29410 == Foo bar ==
29411
29412 == foo Bar ==
29413
29414 == Тест ==
29415
29416 == Тест ==
29417
29418 == тест ==
29419
29420 == Hey < # " > % : ' ==
29421 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
29422
29423 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
29424
29425 <!-- These two links should produce identical HTML -->
29426 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
29427
29428 !! html/php
29429 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
29430 <ul>
29431 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
29432 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
29433 <li class="toclevel-1 tocsection-3"><a href="#.D0.A2.D0.B5.D1.81.D1.82"><span class="tocnumber">3</span> <span class="toctext">Тест</span></a></li>
29434 <li class="toclevel-1 tocsection-4"><a href="#.D0.A2.D0.B5.D1.81.D1.82_2"><span class="tocnumber">4</span> <span class="toctext">Тест</span></a></li>
29435 <li class="toclevel-1 tocsection-5"><a href="#.D1.82.D0.B5.D1.81.D1.82"><span class="tocnumber">5</span> <span class="toctext">тест</span></a></li>
29436 <li class="toclevel-1 tocsection-6"><a href="#Hey_.3C_.23_.22_.3E_.25_:_.27"><span class="tocnumber">6</span> <span class="toctext">Hey &lt; # " &gt;&#160;%&#160;: '</span></a></li>
29437 </ul>
29438 </div>
29439
29440 <h2><span class="mw-headline" id="Foo_bar">Foo bar</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: Foo bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
29441 <h2><span class="mw-headline" id="foo_Bar_2">foo Bar</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: foo Bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
29442 <h2><span id="Тест"></span><span class="mw-headline" id=".D0.A2.D0.B5.D1.81.D1.82">Тест</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=3" title="Edit section: Тест">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
29443 <h2><span id="Тест_2"></span><span class="mw-headline" id=".D0.A2.D0.B5.D1.81.D1.82_2">Тест</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=4" title="Edit section: Тест">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
29444 <h2><span id="тест"></span><span class="mw-headline" id=".D1.82.D0.B5.D1.81.D1.82">тест</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=5" title="Edit section: тест">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
29445 <h2><span id="Hey_&lt;_#_&quot;_&gt;_%_:_'"></span><span class="mw-headline" id="Hey_.3C_.23_.22_.3E_.25_:_.27">Hey &lt; # " &gt;&#160;%&#160;: '</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=6" title="Edit section: Hey &lt; # &quot; &gt; % : '">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
29446 <p><a href="#Foo_bar">#Foo bar</a> <a href="#foo_Bar">#foo Bar</a> <a href="#.D0.A2.D0.B5.D1.81.D1.82">#Тест</a> <a href="#.D1.82.D0.B5.D1.81.D1.82">#тест</a> <a href="#Hey_.3C_.23_.22_.3E_.25_:_.27">#Hey &lt; # " &gt;&#160;%&#160;: '</a>
29447 </p><p>.F0.9F.92.A9 <span id=".F0.9F.92.A9"></span>
29448 </p><p><a href="#.E5.95.A4.E9.85.92">#啤酒</a> <a href="#.E5.95.A4.E9.85.92">#啤酒</a>
29449 </p>
29450 !! end
29451
29452 !! test
29453 HTML5 ids: no legacy
29454 !! config
29455 wgFragmentMode=[ 'html5' ]
29456 !! wikitext
29457 == Foo bar ==
29458
29459 == foo Bar ==
29460
29461 == Тест ==
29462
29463 == Тест ==
29464
29465 == тест ==
29466
29467 == Hey < # " > % : ' ==
29468 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
29469
29470 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
29471
29472 <!-- These two links should produce identical HTML -->
29473 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
29474
29475 !! html/php
29476 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
29477 <ul>
29478 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
29479 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
29480 <li class="toclevel-1 tocsection-3"><a href="#%D0%A2%D0%B5%D1%81%D1%82"><span class="tocnumber">3</span> <span class="toctext">Тест</span></a></li>
29481 <li class="toclevel-1 tocsection-4"><a href="#%D0%A2%D0%B5%D1%81%D1%82_2"><span class="tocnumber">4</span> <span class="toctext">Тест</span></a></li>
29482 <li class="toclevel-1 tocsection-5"><a href="#%D1%82%D0%B5%D1%81%D1%82"><span class="tocnumber">5</span> <span class="toctext">тест</span></a></li>
29483 <li class="toclevel-1 tocsection-6"><a href="#Hey_%3C_%23_%22_%3E_%25_:_%27"><span class="tocnumber">6</span> <span class="toctext">Hey &lt; # " &gt;&#160;%&#160;: '</span></a></li>
29484 </ul>
29485 </div>
29486
29487 <h2><span class="mw-headline" id="Foo_bar">Foo bar</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: Foo bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
29488 <h2><span class="mw-headline" id="foo_Bar_2">foo Bar</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: foo Bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
29489 <h2><span class="mw-headline" id="Тест">Тест</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=3" title="Edit section: Тест">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
29490 <h2><span class="mw-headline" id="Тест_2">Тест</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=4" title="Edit section: Тест">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
29491 <h2><span class="mw-headline" id="тест">тест</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=5" title="Edit section: тест">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
29492 <h2><span class="mw-headline" id="Hey_&lt;_#_&quot;_&gt;_%_:_'">Hey &lt; # " &gt;&#160;%&#160;: '</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=6" title="Edit section: Hey &lt; # &quot; &gt; % : '">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
29493 <p><a href="#Foo_bar">#Foo bar</a> <a href="#foo_Bar">#foo Bar</a> <a href="#%D0%A2%D0%B5%D1%81%D1%82">#Тест</a> <a href="#%D1%82%D0%B5%D1%81%D1%82">#тест</a> <a href="#Hey_%3C_%23_%22_%3E_%25_:_%27">#Hey &lt; # " &gt;&#160;%&#160;: '</a>
29494 </p><p>%F0%9F%92%A9 <span id="%F0%9F%92%A9"></span>
29495 </p><p><a href="#%E5%95%A4%E9%85%92">#啤酒</a> <a href="#%E5%95%A4%E9%85%92">#啤酒</a>
29496 </p>
29497 !! end