Merge "resourceloader: Minor optimisation in variable declarations"
[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 Foo''s bar''s
61 !!text
62 Article titles can contain single quotes!
63 !!endarticle
64
65 !!article
66 Template:Foo
67 !!text
68 FOO
69 !!endarticle
70
71 !! article
72 Template:redirect to foo
73 !! text
74 #REDIRECT [[Template:Foo]]
75 !! endarticle
76
77 !! article
78 Template:Blank
79 !! text
80 !! endarticle
81
82 !! article
83 Template:pipe
84 !! text
85 |
86 !! endarticle
87
88 !! article
89 Template:=
90 !! text
91 <nowiki>=</nowiki>
92 !! endarticle
93
94 !!article
95 MediaWiki:bad image list
96 !!text
97 * [[File:Bad.jpg]] except [[Nasty page]]
98 !!endarticle
99
100 !! article
101 Template:inner list
102 !! text
103 * item 1
104 !! endarticle
105
106 !! article
107 Template:tbl-start
108 !! text
109 {|
110 !! endarticle
111
112 !! article
113 Template:tbl-end
114 !! text
115 |}
116 !! endarticle
117
118 !! article
119 Template:echo
120 !! text
121 {{{1}}}
122 !! endarticle
123
124 !! article
125 Template:echo3
126 !! text
127 {{{1}}}
128 {{{1}}}
129 {{{1}}}
130 !! endarticle
131
132 // For Serbian; localize Template namespace
133 !! article
134 Шаблон:Echo
135 !! text
136 {{{1}}}
137 !! endarticle
138
139 !! article
140 Template:echo_with_span
141 !! text
142 <span>{{{1}}}</span>
143 !! endarticle
144
145 !! article
146 Template:echo_with_div
147 !! text
148 <div>{{{1}}}</div>
149 !! endarticle
150
151 !! article
152 Template:echo with depth
153 !! text
154 {{echo|{{{1}}}}}
155 !! endarticle
156
157 !! article
158 Template:blank_param
159 !! text
160 {{{1}}}
161 {{{}}}
162 !! endarticle
163
164 !! article
165 Template:table_attribs
166 !! text
167 <noinclude>
168 |</noinclude>style="color:red;"|Foo
169 !! endarticle
170
171 !! article
172 Template:table_attribs_2
173 !! text
174 <noinclude>
175 |</noinclude>style="color:red;"|Foo
176 |Bar||Baz
177 !! endarticle
178
179 !! article
180 Template:table_attribs_3
181 !! text
182 <noinclude>
183 |</noinclude>style{{=}}"background:&#35;f9f9f9;"|Foo
184 !! endarticle
185
186 !! article
187 Template:table_attribs_4
188 !! text
189 | style="background-color:#DC241f;" width="10px" |
190 !! endarticle
191
192 !! article
193 Template:table_attribs_5
194 !! text
195 <noinclude>
196 |</noinclude>style="color:red;"||Bar
197 !! endarticle
198
199 !! article
200 Template:table_attribs_6
201 !! text
202 style="background: <nowiki>
203
204
205 red;</nowiki>" |
206 !! endarticle
207
208 !! article
209 Template:table_attribs_7
210 !! text
211 <noinclude>
212 |</noinclude>style{{=}}"background:&#35;f9f9f9;"|Foo<ref>foo</ref>
213 !! endarticle
214
215 !! article
216 Template:table_header_cells
217 !! text
218 {{table_attribs}}!!style='color:red;'|''Bar''||style='color:brown;'|''Foo'' and Baz
219 !! endarticle
220
221 !! article
222 Template:table_cells
223 !! text
224 {{table_attribs}}||style='color:red;'|''Bar''||style='color:brown;'|''Foo'' and Baz
225 !! endarticle
226
227 !! article
228 Template:PartialTable
229 !! text
230 {|
231 |-
232 !! endarticle
233
234 !! article
235 Template:image_attribs
236 !! text
237 <noinclude>
238 [[File:foobar.jpg|</noinclude>right|Caption text<noinclude>]]</noinclude>
239 !! endarticle
240
241 ## See T48811 for details
242 !! article
243 Template:mixed_attr_content_template
244 !! text
245 style="color:red;" title="T48811"
246 |-
247 |foo
248 !! endarticle
249
250 !! article
251 Template:definition_list
252 !! text
253 one
254 ::two
255 !! endarticle
256
257 !! article
258 A?b
259 !! text
260 Weirdo titles!
261 !! endarticle
262
263 !!article
264 Template:Bullet
265 !!text
266 *Bar
267 !!endarticle
268
269 !!article
270 Template:OpenTable
271 !!text
272 {|
273 !!endarticle
274
275 !!article
276 Template:EmptyLITest
277 !!text
278 *a
279 *
280 *
281 *b
282 !!endarticle
283
284 !!article
285 Template:EmptyTRTest
286 !!text
287 {|
288 |-
289 |-
290 |foo
291 |-
292 |-
293 |bar
294 |}
295 !!endarticle
296
297 !!article
298 Template:EmptyTRWithHTMLAttrTest
299 !!text
300 <table>
301 <tr align="center"></tr>
302 <tr><td>foo</td></tr>
303 <tr align="center"></tr>
304 <tr><td>bar</td></tr>
305 </table>
306 !!endarticle
307
308 !! article
309 Template:With: Colon
310 !! text
311 Template with colon
312 !! endarticle
313
314 ###
315 ### Basic tests
316 ###
317
318 !! test
319 Blank input
320 !! wikitext
321 !! html
322 !! end
323
324 !! test
325 Simple paragraph
326 !! wikitext
327 This is a simple paragraph.
328 !! html
329 <p>This is a simple paragraph.
330 </p>
331 !! end
332
333 !! test
334 Paragraphs with extra newline spacing
335 !! wikitext
336 a
337
338 b (+2 nls)
339
340
341 c (+3 nls)
342
343
344
345 d (+4 nls)
346
347
348
349
350 e (+5 nls)
351 !! html
352 <p>a
353 </p><p>b (+2 nls)
354 </p><p><br />
355 c (+3 nls)
356 </p><p><br />
357 </p><p>d (+4 nls)
358 </p><p><br />
359 </p><p><br />
360 e (+5 nls)
361 </p>
362 !! end
363
364 !! test
365 Paragraphs with newline spacing with comment lines in between
366 !! wikitext
367 ----
368 a
369 <!--foo-->
370 b
371 ----
372 a
373 <!--foo--><!--More than 1 comment, still stripped-->
374 b
375 ----
376 a
377 <!--foo--> <!----> <!-- bar -->
378 b
379 ----
380 a
381 <!--foo-->
382
383 b
384 ----
385 a
386
387 <!--foo-->
388 b
389 ----
390 a
391 <!--foo-->
392
393
394 b
395 ----
396 a
397
398
399 <!--foo-->
400 b
401 ----
402 !! html
403 <hr />
404 <p>a
405 b
406 </p>
407 <hr />
408 <p>a
409 b
410 </p>
411 <hr />
412 <p>a
413 b
414 </p>
415 <hr />
416 <p>a
417 </p><p>b
418 </p>
419 <hr />
420 <p>a
421 </p><p>b
422 </p>
423 <hr />
424 <p>a
425 </p><p><br />
426 b
427 </p>
428 <hr />
429 <p>a
430 </p><p><br />
431 b
432 </p>
433 <hr />
434
435 !! end
436
437 !! test
438 Paragraphs with newline spacing with non-empty white-space lines in between
439 !! wikitext
440 ----
441 a
442
443 b
444 ----
445 a
446
447
448 b
449 ----
450 !! html
451 <hr />
452 <p>a
453 </p><p>b
454 </p>
455 <hr />
456 <p>a
457 </p><p><br />
458 b
459 </p>
460 <hr />
461
462 !! end
463
464 !! test
465 Paragraphs with newline spacing with non-empty mixed comment and white-space lines in between
466 !! wikitext
467 ----
468 a
469 <!--foo-->
470 b
471 ----
472 a
473 <!--foo--><!--More than 1 comment doesn't disable stripping of this line!-->
474 b
475 ----
476 a
477
478 <!--foo-->
479 <!--bar-->
480 b
481 ----
482 a
483
484 <!--foo-->
485 <!--bar-->
486
487 b
488 ----
489 !! html
490 <hr />
491 <p>a
492 b
493 </p>
494 <hr />
495 <p>a
496 b
497 </p>
498 <hr />
499 <p>a
500 </p><p>b
501 </p>
502 <hr />
503 <p>a
504 </p><p><br />
505 b
506 </p>
507 <hr />
508
509 !! end
510
511 !! test
512 Extra newlines: More paragraphs with indented comment
513 !! wikitext
514 a
515
516 <!--boo-->
517
518 b
519 !! html
520 <p>a
521 </p><p><br />
522 b
523 </p>
524 !!end
525
526 !! test
527 Extra newlines followed by heading
528 !! wikitext
529 a
530
531
532 =b=
533 [[a]]
534
535
536 =b=
537 !! html
538 <p>a
539 </p><p><br />
540 </p>
541 <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>
542 <p><a href="/index.php?title=A&amp;action=edit&amp;redlink=1" class="new" title="A (page does not exist)">a</a>
543 </p><p><br />
544 </p>
545 <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>
546
547 !! end
548
549 !! test
550 Extra newlines between heading and content are swallowed (Parsoid does not)
551 !! wikitext
552 =b=
553
554
555
556 [[a]]
557 !! html/php+tidy
558 <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>
559 <p><a href="/index.php?title=A&amp;action=edit&amp;redlink=1" class="new" title="A (page does not exist)">a</a>
560 </p>
561 !! html/parsoid
562 <h1 id="b">b</h1>
563 <p>
564 <br></p>
565
566 <p><a rel="mw:WikiLink" href="./A" title="A">a</a></p>
567 !! end
568
569 !! test
570 Extra new lines before and after lists are preserved
571 !! wikitext
572 a
573
574
575 *b
576
577
578 c
579 !! html/php+tidy
580 <p>a
581 </p><p><br />
582 </p>
583 <ul><li>b</li></ul>
584 <p><br />
585 c
586 </p>
587 !! html/parsoid
588 <p>a</p>
589 <p>
590 <br></p>
591 <ul><li>b</li></ul>
592 <p>
593 <br>
594 c</p>
595 !! end
596
597 # Parsoid regression test
598 !!test
599 Multiple newlines after tables are converted to p-br-p tags
600 !!options
601 parsoid=wt2html,wt2wt
602 !!wikitext
603 {|
604 |x
605 |}
606
607
608
609
610 =b=
611 !!html/php+tidy
612 <table>
613 <tbody><tr>
614 <td>x
615 </td></tr></tbody></table>
616 <p><br />
617 </p><p><br />
618 </p>
619 <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>
620 !!html/parsoid
621 <table>
622 <tbody>
623 <tr>
624 <td>x</td>
625 </tr>
626 </tbody>
627 </table>
628 <p><br/></p>
629 <p><br/></p>
630 <h1 id="b">b</h1>
631 !!end
632
633 !! test
634 Heading with line break in nowiki
635 !! options
636 parsoid=wt2html
637 !! config
638 wgFragmentMode=[ 'html5', 'legacy' ]
639 !! wikitext
640 ==A <nowiki>B
641 C</nowiki>==
642 !! html/php
643 <h2><span id="A_B.0AC"></span><span class="mw-headline" id="A_B
644 C">A B
645 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>
646
647 !! html/parsoid
648 <h2 id="A_B
649 C"><span id="A_B.0AC" typeof="mw:FallbackId"></span>A <span typeof="mw:Nowiki">B
650 C</span></h2>
651 !! end
652
653 !! test
654 Parsing an URL
655 !! wikitext
656 http://fr.wikipedia.org/wiki/🍺
657 <!-- EasterEgg we love beer, better be able be able to link to it -->
658 !! html
659 <p><a rel="nofollow" class="external free" href="http://fr.wikipedia.org/wiki/🍺">http://fr.wikipedia.org/wiki/🍺</a>
660 </p>
661 !! end
662
663 !! test
664 Simple list
665 !! wikitext
666 *Item 1
667 *Item 2
668 !! html
669 <ul><li>Item 1</li>
670 <li>Item 2</li></ul>
671
672 !! end
673
674 !! test
675 Italics and bold
676 !! wikitext
677 *plain
678 *plain''italic''plain
679 *plain''italic''plain''italic''plain
680 *plain'''bold'''plain
681 *plain'''bold'''plain'''bold'''plain
682 *plain''italic''plain'''bold'''plain
683 *plain'''bold'''plain''italic''plain
684 *plain''italic'''bold-italic'''italic''plain
685 *plain'''bold''bold-italic''bold'''plain
686 *plain'''''bold-italic'''italic''plain
687 *plain'''''bold-italic''bold'''plain
688 *plain''italic'''bold-italic'''''plain
689 *plain'''bold''bold-italic'''''plain
690 *plain l'''italic''plain
691 *plain l''''bold''' plain
692 !! html
693 <ul><li>plain</li>
694 <li>plain<i>italic</i>plain</li>
695 <li>plain<i>italic</i>plain<i>italic</i>plain</li>
696 <li>plain<b>bold</b>plain</li>
697 <li>plain<b>bold</b>plain<b>bold</b>plain</li>
698 <li>plain<i>italic</i>plain<b>bold</b>plain</li>
699 <li>plain<b>bold</b>plain<i>italic</i>plain</li>
700 <li>plain<i>italic<b>bold-italic</b>italic</i>plain</li>
701 <li>plain<b>bold<i>bold-italic</i>bold</b>plain</li>
702 <li>plain<i><b>bold-italic</b>italic</i>plain</li>
703 <li>plain<b><i>bold-italic</i>bold</b>plain</li>
704 <li>plain<i>italic<b>bold-italic</b></i>plain</li>
705 <li>plain<b>bold<i>bold-italic</i></b>plain</li>
706 <li>plain l'<i>italic</i>plain</li>
707 <li>plain l'<b>bold</b> plain</li></ul>
708
709 !! end
710
711 # this example taken from the [[simple:Moon]] article (T49326)
712 !! test
713 Italics and possessives (1)
714 !! wikitext
715 obtained by ''[[Lunar Prospector]]'''s gamma-ray spectrometer
716 !! html
717 <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
718 </p>
719 !! end
720
721 # this example taken from [[en:Flaming Pie]] (T51926)
722 !! test
723 Italics and possessives (2)
724 !! wikitext
725 '''''Flaming Pie''''' is ... released in 1997. In ''Flaming Pie'''s liner notes
726 !! html
727 <p><i><b>Flaming Pie</b></i> is ... released in 1997. In <i>Flaming Pie'</i>s liner notes
728 </p>
729 !! end
730
731 # this example taken from [[en:Dictionary]] (T51926)
732 !! test
733 Italics and possessives (3)
734 !! wikitext
735 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''.
736 !! html
737 <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>.
738 </p>
739 !! end
740
741
742 ###
743 ### 2-quote opening sequence tests
744 ###
745 !! test
746 Italics and bold: 2-quote opening sequence: (2,2)
747 !! wikitext
748 ''foo''
749 !! html
750 <p><i>foo</i>
751 </p>
752 !!end
753
754 !! test
755 Italics and bold: 2-quote opening sequence: (2,3)
756 !! wikitext
757 ''foo'''
758 !! html/*
759 <p><i>foo'</i>
760 </p>
761 !!end
762
763 !! test
764 Italics and bold: 2-quote opening sequence: (2,4)
765 !! options
766 parsoid=wt2html
767 !! wikitext
768 ''foo''''
769 !! html/*
770 <p><i>foo''</i>
771 </p>
772 !!end
773
774 # same html as previous, but wikitext adjusted to match parsoid html2wt
775 !! test
776 Italics and bold: 2-quote opening sequence: (2,4) w/ nowiki
777 !! wikitext
778 ''foo<nowiki>''</nowiki>''
779 !! html
780 <p><i>foo''</i>
781 </p>
782 !! end
783
784 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
785 !! test
786 Italics and bold: 2-quote opening sequence: (2,5)
787 !! options
788 parsoid=wt2html
789 !! wikitext
790 ''foo'''''
791 !! html/php
792 <p><i>foo</i>
793 </p>
794 !! html/parsoid
795 <p><i>foo</i><b></b>
796 </p>
797 !!end
798
799 # same html as previous, but wikitext adjusted to match parsoid html2wt
800 !! test
801 Italics and bold: 2-quote opening sequence: (2,5+3) w/ nowiki
802 !! wikitext
803 ''foo'''''<nowiki/>'''
804 !! html/php
805 <p><i>foo</i>
806 </p>
807 !! html/parsoid
808 <p><i>foo</i><b></b>
809 </p>
810 !! end
811
812
813 ###
814 ### 3-quote opening sequence tests
815 ###
816
817 !! test
818 Italics and bold: 3-quote opening sequence: (3,2)
819 !! wikitext
820 '''foo''
821 !! html/*
822 <p>'<i>foo</i>
823 </p>
824 !!end
825
826 !! test
827 Italics and bold: 3-quote opening sequence: (3,3)
828 !! wikitext
829 '''foo'''
830 !! html
831 <p><b>foo</b>
832 </p>
833 !!end
834
835 !! test
836 Italics and bold: 3-quote opening sequence: (3,4)
837 !! wikitext
838 '''foo''''
839 !! html/*
840 <p><b>foo'</b>
841 </p>
842 !!end
843
844 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
845 !! test
846 Italics and bold: 3-quote opening sequence: (3,5)
847 !! options
848 parsoid=wt2html
849 !! wikitext
850 '''foo'''''
851 !! html/php
852 <p><b>foo</b>
853 </p>
854 !! html/parsoid
855 <p><b>foo</b><i></i>
856 </p>
857 !!end
858
859 # same html as previous, but wikitext adjusted to match parsoid html2wt
860 !! test
861 Italics and bold: 3-quote opening sequence: (3,5+2) w/ nowiki
862 !! wikitext
863 '''foo'''''<nowiki/>''
864 !! html/php
865 <p><b>foo</b>
866 </p>
867 !! html/parsoid
868 <p><b>foo</b><i></i>
869 </p>
870 !! end
871
872
873 ###
874 ### 4-quote opening sequence tests
875 ###
876
877 !! test
878 Italics and bold: 4-quote opening sequence: (4,2)
879 !! options
880 parsoid=wt2html
881 !! wikitext
882 ''''foo''
883 !! html/*
884 <p>''<i>foo</i>
885 </p>
886 !!end
887
888 # same html as previous, but wikitext adjusted to match parsoid html2wt
889 !! test
890 Italics and bold: 4-quote opening sequence: (4,2) w/ nowiki
891 !! wikitext
892 <nowiki>''</nowiki>''foo''
893 !! html
894 <p>''<i>foo</i>
895 </p>
896 !! end
897
898 !! test
899 Italics and bold: 4-quote opening sequence: (4,3)
900 !! wikitext
901 ''''foo'''
902 !! html/*
903 <p>'<b>foo</b>
904 </p>
905 !!end
906
907 !! test
908 Italics and bold: 4-quote opening sequence: (4,4)
909 !! options
910 parsoid=wt2html
911 !! wikitext
912 ''''foo''''
913 !! html/*
914 <p>'<b>foo'</b>
915 </p>
916 !!end
917
918 # same html as previous, but wikitext adjusted to match parsoid html2wt
919 !! test
920 Italics and bold: 4-quote opening sequence: (4,4) w/ nowiki
921 !! wikitext
922 '<nowiki/>'''foo''''
923 !! html
924 <p>'<b>foo'</b>
925 </p>
926 !! end
927
928 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
929 !! test
930 Italics and bold: 4-quote opening sequence: (4,5)
931 !! options
932 parsoid=wt2html
933 !! wikitext
934 ''''foo'''''
935 !! html/php
936 <p>'<b>foo</b>
937 </p>
938 !! html/parsoid
939 <p>'<b>foo</b><i></i>
940 </p>
941 !!end
942
943 # same html as previous, but wikitext adjusted to match parsoid html2wt
944 !! test
945 Italics and bold: 4-quote opening sequence: (4,5+2) w/ nowiki
946 !! wikitext
947 '<nowiki/>'''foo'''''<nowiki/>''
948 !! html/php
949 <p>'<b>foo</b>
950 </p>
951 !! html/parsoid
952 <p>'<b>foo</b><i></i>
953 </p>
954 !! end
955
956
957 ###
958 ### 5-quote opening sequence tests
959 ###
960
961 !! test
962 Italics and bold: 5-quote opening sequence: (5,2)
963 !! options
964 parsoid=wt2html
965 !! wikitext
966 '''''foo''
967 !! html/*
968 <p><b><i>foo</i></b>
969 </p>
970 !!end
971
972 # same html as previous, but wikitext adjusted to match parsoid html2wt
973 !! test
974 Italics and bold: 5-quote opening sequence: (5,2+3)
975 !! wikitext
976 '''''foo'''''
977 !! html/*
978 <p><i><b>foo</b></i>
979 </p>
980 !! end
981
982 !! test
983 Italics and bold: 5-quote opening sequence: (5,3)
984 !! options
985 parsoid=wt2html
986 !! wikitext
987 '''''foo'''
988 !! html/*
989 <p><i><b>foo</b></i>
990 </p>
991 !!end
992
993 # same html as previous, but wikitext adjusted to match parsoid html2wt
994 !! test
995 Italics and bold: 5-quote opening sequence: (5,3+2)
996 !! wikitext
997 '''''foo'''''
998 !! html
999 <p><i><b>foo</b></i>
1000 </p>
1001 !! end
1002
1003 !! test
1004 Italics and bold: 5-quote opening sequence: (5,4)
1005 !! options
1006 parsoid=wt2html
1007 !! wikitext
1008 '''''foo''''
1009 !! html/*
1010 <p><i><b>foo'</b></i>
1011 </p>
1012 !!end
1013
1014 !! test
1015 Italics and bold: 5-quote opening sequence: (5,5)
1016 !! wikitext
1017 '''''foo'''''
1018 !! html
1019 <p><i><b>foo</b></i>
1020 </p>
1021 !!end
1022
1023 !! test
1024 Italics and bold: 5-quote opening sequence: (5,6)
1025 !! wikitext
1026 '''''foo''''''
1027 !! html/*
1028 <p><i><b>foo'</b></i>
1029 </p>
1030 !! end
1031
1032 ###
1033 ### multiple quote sequences in a line
1034 ###
1035
1036 !! test
1037 Italics and bold: multiple quote sequences: (2,4,2)
1038 !! options
1039 parsoid=wt2html
1040 !! wikitext
1041 ''foo''''bar''
1042 !! html/*
1043 <p><i>foo'<b>bar</b></i>
1044 </p>
1045 !! end
1046
1047 # same html as previous, but wikitext adjusted to match parsoid html2wt
1048 !! test
1049 Italics and bold: multiple quote sequences: (2,4,2+3) w/ nowiki
1050 !! wikitext
1051 ''foo'<nowiki/>'''bar'''''
1052 !! html
1053 <p><i>foo'<b>bar</b></i>
1054 </p>
1055 !! end
1056
1057 !! test
1058 Italics and bold: multiple quote sequences: (2,4,3)
1059 !! options
1060 parsoid=wt2html
1061 !! wikitext
1062 ''foo''''bar'''
1063 !! html/*
1064 <p><i>foo'<b>bar</b></i>
1065 </p>
1066 !! end
1067
1068 # same html as previous, but wikitext adjusted to match parsoid html2wt
1069 !! test
1070 Italics and bold: multiple quote sequences: (2,4,3+2) w/ nowiki
1071 !! wikitext
1072 ''foo'<nowiki/>'''bar'''''
1073 !! html
1074 <p><i>foo'<b>bar</b></i>
1075 </p>
1076 !! end
1077
1078 !! test
1079 Italics and bold: multiple quote sequences: (2,4,4)
1080 !! options
1081 parsoid=wt2html
1082 !! wikitext
1083 ''foo''''bar''''
1084 !! html/*
1085 <p><i>foo'<b>bar'</b></i>
1086 </p>
1087 !! end
1088
1089 # same html as previous, but wikitext adjusted to match parsoid html2wt
1090 !! test
1091 Italics and bold: multiple quote sequences: (2,4,4+2) w/ nowiki
1092 !! wikitext
1093 ''foo'<nowiki/>'''bar'<nowiki/>'''''
1094 !! html
1095 <p><i>foo'<b>bar'</b></i>
1096 </p>
1097 !! end
1098
1099 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
1100 !! test
1101 Italics and bold: multiple quote sequences: (3,4,2)
1102 !! options
1103 parsoid=wt2html
1104 !! wikitext
1105 '''foo''''bar''
1106 !! html/php
1107 <p><b>foo'</b>bar
1108 </p>
1109 !! html/parsoid
1110 <p><b>foo'</b>bar<i></i>
1111 </p>
1112 !! end
1113
1114 # same html as previous, but wikitext adjusted to match parsoid html2wt
1115 !! test
1116 Italics and bold: multiple quote sequences: (3,4,2+2) w/ nowiki
1117 !! wikitext
1118 '''foo''''bar''<nowiki/>''
1119 !! html/php
1120 <p><b>foo'</b>bar
1121 </p>
1122 !! html/parsoid
1123 <p><b>foo'</b>bar<i></i>
1124 </p>
1125 !! end
1126
1127 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
1128 !! test
1129 Italics and bold: multiple quote sequences: (3,4,3)
1130 !! options
1131 parsoid=wt2html
1132 !! wikitext
1133 '''foo''''bar'''
1134 !! html/php
1135 <p><b>foo'</b>bar
1136 </p>
1137 !! html/parsoid
1138 <p><b>foo'</b>bar<b></b>
1139 </p>
1140 !! end
1141
1142 # same html as previous, but wikitext adjusted to match parsoid html2wt
1143 !! test
1144 Italics and bold: multiple quote sequences: (3,4,3+3) w/ nowiki
1145 !! wikitext
1146 '''foo''''bar'''<nowiki/>'''
1147 !! html/php
1148 <p><b>foo'</b>bar
1149 </p>
1150 !! html/parsoid
1151 <p><b>foo'</b>bar<b></b>
1152 </p>
1153 !! end
1154
1155 ###
1156 ### other quote tests
1157 ###
1158 !! test
1159 Italics and bold: other quote tests: (2,3,5)
1160 !! wikitext
1161 ''this is about '''foo's family'''''
1162 !! html
1163 <p><i>this is about <b>foo's family</b></i>
1164 </p>
1165 !!end
1166
1167
1168 !! test
1169 Italics and bold: other quote tests: (2,(3,3),2)
1170 !! wikitext
1171 ''this is about '''foo's''' family''
1172 !! html
1173 <p><i>this is about <b>foo's</b> family</i>
1174 </p>
1175 !!end
1176
1177
1178 !! test
1179 Italics and bold: other quote tests: (3,2,3,2)
1180 !! options
1181 parsoid=wt2html
1182 !! wikitext
1183 '''this is about ''foo'''s family''
1184 !! html/*
1185 <p><b>this is about <i>foo</i></b><i>s family</i>
1186 </p>
1187 !!end
1188
1189
1190 # same html as previous, but wikitext adjusted to match parsoid html2wt
1191 !! test
1192 Italics and bold: other quote tests: (3,2,3+2+2,2)
1193 !! wikitext
1194 '''this is about ''foo'''''<nowiki/>''s family''
1195 !! html
1196 <p><b>this is about <i>foo</i></b><i>s family</i>
1197 </p>
1198 !! end
1199
1200
1201 !! test
1202 Italics and bold: other quote tests: (3,2,3,3)
1203 !! wikitext
1204 '''this is about ''foo'''s family'''
1205 !! html/*
1206 <p>'<i>this is about </i>foo<b>s family</b>
1207 </p>
1208 !!end
1209
1210
1211 !! test
1212 Italics and bold: other quote tests: (3,(2,2),3)
1213 !! wikitext
1214 '''this is about ''foo's'' family'''
1215 !! html
1216 <p><b>this is about <i>foo's</i> family</b>
1217 </p>
1218 !!end
1219
1220
1221 !! test
1222 Italicized possessive
1223 !! wikitext
1224 The ''[[Main Page]]'''s talk page.
1225 !! html/php
1226 <p>The <i><a href="/wiki/Main_Page" title="Main Page">Main Page</a>'</i>s talk page.
1227 </p>
1228 !! html/parsoid
1229 <p>The <i><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a>'</i>s talk page.</p>
1230 !! end
1231
1232 !! test
1233 Quote balancing context should be restricted to td/th cells on the same wikitext line
1234 !! options
1235 parsoid=wt2html,wt2wt
1236 !! wikitext
1237 {|
1238 !''a!!''b
1239 |''a||''b
1240 |}
1241 !! html+tidy
1242 <table>
1243 <tbody><tr>
1244 <th><i>a</i></th>
1245 <th><i>b</i>
1246 </th>
1247 <td><i>a</i></td>
1248 <td><i>b</i>
1249 </td></tr></tbody></table>
1250 !! end
1251
1252 !! test
1253 Bold conversion test
1254 !! wikitext
1255 a b'''c ''d e'''f'' g h'''i ''j
1256 !! options
1257 parsoid=wt2html
1258 !! html+tidy
1259 <p>a b'<i>c </i>d e<b>f<i> g h</i></b><i>i </i>j
1260 </p>
1261 !! end
1262
1263 ###
1264 ### Non-html5 tags
1265 ###
1266
1267 !! test
1268 Non-html5 tags should be accepted
1269 !! wikitext
1270 <center>''foo''</center>
1271 <big>''foo''</big>
1272 <font>''foo''</font>
1273 <strike>''foo''</strike>
1274 <tt>''foo''</tt>
1275 !! html
1276 <center><i>foo</i></center>
1277 <p><big><i>foo</i></big>
1278 <font><i>foo</i></font>
1279 <strike><i>foo</i></strike>
1280 <tt><i>foo</i></tt>
1281 </p>
1282 !! end
1283
1284 !! test
1285 <wbr> is valid wikitext (T54468)
1286 !! wikitext
1287 <wbr>
1288 !! html
1289 <p><wbr />
1290 </p>
1291 !! end
1292
1293 # <strike> is HTML4, <s> is HTML4/5.
1294 !! test
1295 <s> or <strike> for strikethrough
1296 !! wikitext
1297 <strike>strike</strike>
1298
1299 <s>s</s>
1300 !! html
1301 <p><strike>strike</strike>
1302 </p><p><s>s</s>
1303 </p>
1304 !! end
1305
1306 ## a not permitted
1307 ## i,b,br omitted
1308 !! test
1309 Text-level semantic html elements in wikitext
1310 !! wikitext
1311 <em>text</em>
1312 <strong>text</strong>
1313 <small>text</small>
1314 <s>text</s>
1315 <cite>text</cite>
1316 <q>text</q>
1317 <dfn>text</dfn>
1318 <abbr>text</abbr>
1319 <data>text</data>
1320 <time>text</time>
1321 <code>text</code>
1322 <var>text</var>
1323 <samp>text</samp>
1324 <kbd>text</kbd>
1325 <sub>text</sub>
1326 <u>text</u>
1327 <mark>text</mark>
1328 <ruby><rb>明日</rb><rp>(</rp><rt>Ashita</rt><rp> </rp><rtc>あした</rtc><rp>)</rp></ruby>
1329 <bdi>text</bdi>
1330 <bdo>text</bdo>
1331 <span>text</span>
1332 <wbr />
1333 !! html
1334 <p><em>text</em>
1335 <strong>text</strong>
1336 <small>text</small>
1337 <s>text</s>
1338 <cite>text</cite>
1339 <q>text</q>
1340 <dfn>text</dfn>
1341 <abbr>text</abbr>
1342 <data>text</data>
1343 <time>text</time>
1344 <code>text</code>
1345 <var>text</var>
1346 <samp>text</samp>
1347 <kbd>text</kbd>
1348 <sub>text</sub>
1349 <u>text</u>
1350 <mark>text</mark>
1351 <ruby><rb>明日</rb><rp>(</rp><rt>Ashita</rt><rp> </rp><rtc>あした</rtc><rp>)</rp></ruby>
1352 <bdi>text</bdi>
1353 <bdo>text</bdo>
1354 <span>text</span>
1355 <wbr />
1356 </p>
1357 !! end
1358
1359 # test cases taken from
1360 # https://www.w3.org/TR/html5/text-level-semantics.html#the-ruby-element
1361 !! test
1362 Ruby markup (W3C-style)
1363 !! wikitext
1364 ;Mono-ruby for individual base characters
1365 :<ruby>日<rt>に</rt>本<rt>ほん</rt>語<rt>ご</rt></ruby>
1366 ;Group ruby
1367 :<ruby>今日<rt>きょう</rt></ruby>
1368 ;Jukugo ruby
1369 :<ruby>法<rb>華</rb><rb>経</rb><rt>ほ</rt><rt>け</rt><rt>きょう</rt></ruby>
1370 ;Inline ruby
1371 :<ruby>東<rb>京</rb><rp>(</rp><rt>とう</rt><rt>きょう</rt><rp>)</rp></ruby>
1372 ;Double-sided ruby
1373 :<ruby><rb>旧</rb><rb>金</rb><rb>山</rb><rt>jiù</rt><rt>jīn</rt><rt>shān</rt><rtc>San Francisco</rtc></ruby>
1374
1375 <ruby>
1376 <rb>♥</rb><rtc><rt>Heart</rt></rtc><rtc lang="fr"><rt>Cœur</rt></rtc>
1377 <rb>☘</rb><rtc><rt>Shamrock</rt></rtc><rtc lang="fr"><rt>Trèfle</rt></rtc>
1378 <rb>✶</rb><rtc><rt>Star</rt></rtc><rtc lang="fr"><rt>Étoile</rt></rtc>
1379 </ruby>
1380 !! html
1381 <dl><dt>Mono-ruby for individual base characters</dt>
1382 <dd><ruby>日<rt>に</rt>本<rt>ほん</rt>語<rt>ご</rt></ruby></dd>
1383 <dt>Group ruby</dt>
1384 <dd><ruby>今日<rt>きょう</rt></ruby></dd>
1385 <dt>Jukugo ruby</dt>
1386 <dd><ruby>法<rb>華</rb><rb>経</rb><rt>ほ</rt><rt>け</rt><rt>きょう</rt></ruby></dd>
1387 <dt>Inline ruby</dt>
1388 <dd><ruby>東<rb>京</rb><rp>(</rp><rt>とう</rt><rt>きょう</rt><rp>)</rp></ruby></dd>
1389 <dt>Double-sided ruby</dt>
1390 <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>
1391 <p><ruby>
1392 <rb>♥</rb><rtc><rt>Heart</rt></rtc><rtc lang="fr"><rt>Cœur</rt></rtc>
1393 <rb>☘</rb><rtc><rt>Shamrock</rt></rtc><rtc lang="fr"><rt>Trèfle</rt></rtc>
1394 <rb>✶</rb><rtc><rt>Star</rt></rtc><rtc lang="fr"><rt>Étoile</rt></rtc>
1395 </ruby>
1396 </p>
1397 !! end
1398
1399 # The next two test different paths in the sanitizer.
1400 !! test
1401 Non-word characters don't terminate tag names (T19663, T42670, T54022)
1402 !! wikitext
1403 <blockquote|>a</blockquote>
1404
1405 <b→> doesn't terminate </b→>
1406
1407 <bä> doesn't terminate </bä>
1408
1409 <boo> doesn't terminate </boo>
1410
1411 <s.foo> doesn't terminate </s.foo>
1412
1413 <sub-ID#1>
1414 !! html/php
1415 <p>&lt;blockquote|&gt;a&lt;/blockquote&gt;
1416 </p><p>&lt;b→&gt; doesn't terminate &lt;/b→&gt;
1417 </p><p>&lt;bä&gt; doesn't terminate &lt;/bä&gt;
1418 </p><p>&lt;boo&gt; doesn't terminate &lt;/boo&gt;
1419 </p><p>&lt;s.foo&gt; doesn't terminate &lt;/s.foo&gt;
1420 </p><p>&lt;sub-ID#1&gt;
1421 </p>
1422 !! end
1423
1424 !! test
1425 Non-word characters don't terminate tag names
1426 !! wikitext
1427 <blockquote|>a</blockquote>
1428
1429 <b→> doesn't terminate </b→>
1430
1431 <bä> doesn't terminate </bä>
1432
1433 <boo> doesn't terminate </boo>
1434
1435 <s.foo> doesn't terminate </s.foo>
1436
1437 <sub-ID#1>
1438 !! html+tidy
1439 <p>&lt;blockquote|&gt;a
1440 </p><p>&lt;b→&gt; doesn't terminate &lt;/b→&gt;
1441 </p><p>&lt;bä&gt; doesn't terminate &lt;/bä&gt;
1442 </p><p>&lt;boo&gt; doesn't terminate &lt;/boo&gt;
1443 </p><p>&lt;s.foo&gt; doesn't terminate &lt;/s.foo&gt;
1444 </p><p>&lt;sub-ID#1&gt;
1445 </p>
1446 !! end
1447
1448 ###
1449 ### See tests/parser/ParserTestParserHook.php for the <tåg> extension)
1450 ### This checks that HTML5 tags (with non-word characters in the tag
1451 ### name) make it safely through the parser -- the Sanitizer will
1452 ### munge them later, as it should.
1453 ###
1454 !! test
1455 Non-word characters are valid in extension tags (T19663)
1456 !! wikitext
1457 <tåg>tåg</tåg>
1458 !! html/php
1459 <pre>
1460 'tåg'
1461 array (
1462 )
1463 </pre>
1464
1465 !! html/parsoid
1466 <pre typeof="mw:Extension/tåg" data-mw='{"name":"tåg","attrs":{},"body":{"extsrc":"tåg"}}' data-parsoid='{}' about="#mwt2"></pre>
1467 !! end
1468
1469 !! test
1470 Isolated close tags should be treated as literal text (T54760)
1471 !! options
1472 parsoid=wt2html
1473 !! wikitext
1474 </b>
1475
1476 <s.foo>s</s>
1477 !! html+tidy
1478 <p class="mw-empty-elt">
1479 </p><p>&lt;s.foo&gt;s
1480 </p>
1481 !! end
1482
1483 ###
1484 ### Special characters
1485 ###
1486
1487 !! test
1488 Bare pipe character (T54363)
1489 !! wikitext
1490 |
1491 !! html
1492 <p>|
1493 </p>
1494 !! end
1495
1496 !! test
1497 Bare pipe character from a template (T54363)
1498 !! wikitext
1499 {{pipe}}
1500 !! html
1501 <p>|
1502 </p>
1503 !! end
1504
1505 ###
1506 ### <nowiki> test cases
1507 ###
1508
1509 !! test
1510 <nowiki> unordered list
1511 !! wikitext
1512 <nowiki>* This is not an unordered list item.</nowiki>
1513 !! html/php
1514 <p>* This is not an unordered list item.
1515 </p>
1516 !! html/parsoid
1517 <p><span typeof="mw:Nowiki">* This is not an unordered list item.</span></p>
1518 !! end
1519
1520 !! test
1521 <nowiki> spacing
1522 !! wikitext
1523 <nowiki>Lorem ipsum dolor
1524
1525 sed abit.
1526 sed nullum.
1527
1528 :and a colon
1529 </nowiki>
1530 !! html/php
1531 <p>Lorem ipsum dolor
1532
1533 sed abit.
1534 sed nullum.
1535
1536 :and a colon
1537
1538 </p>
1539 !! html/parsoid
1540 <p><span typeof="mw:Nowiki">Lorem ipsum dolor
1541
1542 sed abit.
1543 sed nullum.
1544
1545 :and a colon
1546 </span></p>
1547 !! end
1548
1549 !! test
1550 Don't parse <nowiki><span class="error"></nowiki> (T149622)
1551 !! wikitext
1552 <nowiki><span class="error"></nowiki>
1553 !! html/php
1554 <p>&lt;span class="error"&gt;
1555 </p>
1556 !! html/parsoid
1557 <p><span typeof="mw:Nowiki">&lt;span class="error"></span></p>
1558 !! end
1559
1560 !! test
1561 nowiki 3
1562 !! wikitext
1563 :There is not nowiki.
1564 :There is <nowiki>nowiki</nowiki>.
1565
1566 #There is not nowiki.
1567 #There is <nowiki>nowiki</nowiki>.
1568
1569 *There is not nowiki.
1570 *There is <nowiki>nowiki</nowiki>.
1571 !! html/php
1572 <dl><dd>There is not nowiki.</dd>
1573 <dd>There is nowiki.</dd></dl>
1574 <ol><li>There is not nowiki.</li>
1575 <li>There is nowiki.</li></ol>
1576 <ul><li>There is not nowiki.</li>
1577 <li>There is nowiki.</li></ul>
1578
1579 !! html/parsoid
1580 <dl><dd data-parsoid='{}'>There is not nowiki.</dd>
1581 <dd data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</dd></dl>
1582
1583 <ol><li data-parsoid='{}'>There is not nowiki.</li>
1584 <li data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</li></ol>
1585
1586 <ul><li data-parsoid='{}'>There is not nowiki.</li>
1587 <li data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</li></ul>
1588 !! end
1589
1590 !! test
1591 Entities inside <nowiki>
1592 !! wikitext
1593 <nowiki>&lt;</nowiki>
1594 !! html/php
1595 <p>&lt;
1596 </p>
1597 !! html/parsoid
1598 <p><span typeof="mw:Nowiki"><span typeof="mw:Entity" data-parsoid='{"src":"&amp;lt;","srcContent":"&lt;"}'>&lt;</span></span></p>
1599 !! end
1600
1601 !! test
1602 Entities inside template parameters
1603 !! wikitext
1604 {{echo|&ndash;}}
1605 !! html/php+tidy
1606 <p>&#8211;
1607 </p>
1608 !! html/parsoid
1609 <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>
1610 !! end
1611
1612 !! test
1613 Properly escape nowiki when combined with other wiki markup
1614 !! options
1615 parsoid=html2wt
1616 !! html/parsoid
1617 <p>* &lt;/nowiki&gt; tag</p>
1618 !! wikitext
1619 <nowiki>*</nowiki> <nowiki>&lt;/nowiki&gt;</nowiki> tag
1620 !! end
1621
1622 !! test
1623 T93824: Put escaped HTML tags inside nowiki
1624 !! options
1625 parsoid=html2wt
1626 !! html/parsoid
1627 <p>&lt;h2&gt;foo&lt;/h2&gt;</p>
1628 !! wikitext
1629 <nowiki><h2>foo</h2></nowiki>
1630 !! end
1631
1632 !! test
1633 T71950: 1. Put nowiki as close to cause as possible, even with non-quote escapable chars
1634 !! options
1635 parsoid=html2wt
1636 !! html/parsoid
1637 <p>This text: L'<a rel="mw:WikiLink" href="./Foo">Foo</a>
1638 This text: L''<a rel="mw:WikiLink" href="./Foo">Foo</a>
1639 This text: L'''<a rel="mw:WikiLink" href="./Foo">Foo</a>''</p>
1640 !! wikitext
1641 This text: L'[[Foo]]
1642 This text: L<nowiki>''</nowiki>[[Foo]]
1643 This text: L<nowiki>'''</nowiki>[[Foo]]<nowiki>''</nowiki>
1644 !! end
1645
1646 # This test fails because wikitext whitespace is not normalized before comparing.
1647 !! test
1648 T71950: 2. Put nowiki as close to cause as possible, after ' :'
1649 !! options
1650 parsoid=html2wt
1651 !! html/parsoid
1652 <p>This text : L''<a rel="mw:WikiLink" href="./Foo">Foo</a>
1653 </p>
1654 !! wikitext
1655 This text : L<nowiki>''</nowiki>[[Foo]]
1656 !! end
1657
1658 # This test and the next one are html2wt only as they test that incorrect wikitext
1659 # passed in template arguments gets escaped or wrapped in nowikis where required.
1660 !! test
1661 T71482: Use {{!}} instead of nowiki for single pipe in template argument
1662 !! options
1663 parsoid=html2wt
1664 !! html/parsoid
1665 <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>
1666 <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>
1667 !! wikitext
1668 {{echo|foo{{!}}bar}}
1669 {{echo|<nowiki>foo|bar |[[</nowiki>}}
1670 !! end
1671
1672 !! test
1673 T53961: Output correct nowikis in template arguments
1674 !! options
1675 parsoid=html2wt
1676 !! html/parsoid
1677 <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>
1678 <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>
1679 <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>
1680 <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>
1681 <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>
1682 !! wikitext
1683 {{echo|a [ b}}
1684 {{echo|<nowiki>a }} b</nowiki>}}
1685 {{echo|<nowiki>a [[ b</nowiki>}}
1686 {{echo|<nowiki>a | {{ ]]</nowiki>}}
1687 {{echo|a <nowiki>}</nowiki>}}
1688 !! end
1689
1690 !! test
1691 Cases where "!!" needs nowiki protection
1692 !! options
1693 parsoid=html2wt
1694 !! html/parsoid
1695 <table>
1696 <tr><th>this needs protection !! here</th></tr>
1697 </table>
1698
1699 <table>
1700 <tr><th>this does not need
1701 protection !! here</th></tr>
1702 </table>
1703 !! wikitext
1704 {|
1705 !<nowiki>this needs protection !! here</nowiki>
1706 |}
1707
1708 {|
1709 !this does not need
1710 protection !! here
1711 |}
1712 !! end
1713
1714 ###
1715 ### Comments
1716 ###
1717 !! test
1718 Comments and Indent-Pre
1719 !! wikitext
1720 <!-- comment 1 --> asdf
1721
1722 <!-- comment 1 --> asdf
1723 <!-- comment 2 -->
1724
1725 <!-- comment 1 --> asdf
1726 <!-- comment 2 -->xyz
1727
1728 <!-- comment 1 --> asdf
1729 <!-- comment 2 --> xyz
1730 !! html
1731 <pre>asdf
1732 </pre>
1733 <pre>asdf
1734 </pre>
1735 <pre>asdf
1736 </pre>
1737 <p>xyz
1738 </p>
1739 <pre>asdf
1740 xyz
1741 </pre>
1742 !! end
1743
1744 !! test
1745 Comment test 2a
1746 !! wikitext
1747 asdf
1748 <!-- comment 1 -->
1749 jkl
1750 !! html
1751 <p>asdf
1752 jkl
1753 </p>
1754 !! end
1755
1756 !! test
1757 Comment test 2b
1758 !! wikitext
1759 asdf
1760 <!-- comment 1 -->
1761
1762 jkl
1763 !! html
1764 <p>asdf
1765 </p><p>jkl
1766 </p>
1767 !! end
1768
1769 !! test
1770 Comment test 3
1771 !! wikitext
1772 asdf
1773 <!-- comment 1 -->
1774 <!-- comment 2 -->
1775 jkl
1776 !! html
1777 <p>asdf
1778 jkl
1779 </p>
1780 !! end
1781
1782 !! test
1783 Comment test 4
1784 !! wikitext
1785 asdf<!-- comment 1 -->jkl
1786 !! html
1787 <p>asdfjkl
1788 </p>
1789 !! end
1790
1791 !! test
1792 Comment spacing
1793 !! wikitext
1794 a
1795 <!-- foo --> b <!-- bar -->
1796 c
1797 !! html
1798 <p>a
1799 </p>
1800 <pre> b
1801 </pre>
1802 <p>c
1803 </p>
1804 !! end
1805
1806 !! test
1807 Comment whitespace
1808 !! wikitext
1809 <!-- returns a single newline, not nothing, since the newline after > is not stripped -->
1810 !! html
1811
1812 !! end
1813
1814 !! test
1815 Comment semantics and delimiters
1816 !! wikitext
1817 <!-- --><!----><!-----><!------>
1818 !! html/php
1819
1820 !! html/parsoid
1821 <!-- --><!----><!--&#x2D;--><!--&#x2D;&#x2D;-->
1822 !! end
1823
1824 !! test
1825 Comment semantics and delimiters, redux
1826 !! wikitext
1827 <!-- In SGML every "foo" here would actually show up in the text -- foo -- bar
1828 -- foo -- funky huh? ... -->
1829 !! html/php
1830
1831 !! html/parsoid
1832 <!-- In SGML every "foo" here would actually show up in the text &#x2D;&#x2D; foo &#x2D;&#x2D; bar
1833 &#x2D;&#x2D; foo &#x2D;&#x2D; funky huh? ... -->
1834 !! end
1835
1836 !! test
1837 Comment semantics and delimiters: directors cut
1838 !! wikitext
1839 <!-- ... However we like to keep things simple and somewhat XML-ish so we eat
1840 everything starting with < followed by !-- until the first -- and > we see,
1841 that wouldn't be valid XML however, since in XML -- has to terminate a comment
1842 -->-->
1843 !! html/php
1844 <p>--&gt;
1845 </p>
1846 !! html/parsoid
1847 <!-- ... However we like to keep things simple and somewhat XML&#x2D;ish so we eat
1848 everything starting with < followed by !&#x2D;&#x2D; until the first &#x2D;&#x2D; and &#x3E; we see,
1849 that wouldn't be valid XML however, since in XML &#x2D;&#x2D; has to terminate a comment
1850 --><p>--></p>
1851 !! end
1852
1853 !! test
1854 Comment semantics: nesting
1855 !! wikitext
1856 <!--<!-- no, we're not going to do anything fancy here -->-->
1857 !! html/php
1858 <p>--&gt;
1859 </p>
1860 !! html/parsoid
1861 <!--<!&#x2D;&#x2D; no, we're not going to do anything fancy here --><p>--></p>
1862 !! end
1863
1864 # Parsoid closes the unclosed comment, even if it means a slight
1865 # round-trip diff.
1866 !! test
1867 Comment semantics: unclosed comment at end
1868 !! options
1869 parsoid=wt2html,html2html
1870 !! wikitext
1871 <!--This comment will run out to the end of the document
1872 !! html/php
1873
1874 !! html/parsoid
1875 <!--This comment will run out to the end of the document-->
1876 !! end
1877
1878 !! test
1879 Comment semantics: normalize comments to play nice with XML and browsers
1880 !! wikitext
1881 <!-- Browsers --!> think this is closed -->
1882 <!--> This would normally be text -->
1883 <!---> As would this -->
1884 <!-- XML doesn't like trailing dashes -------->
1885 <!-- Nor doubled hyphens -- anywhere in the data -->
1886 But this is not a comment.
1887 !! html/php
1888 <p>But this is not a comment.
1889 </p>
1890 !! html/parsoid
1891 <!-- Browsers &#x2D;&#x2D;!&#x3E; think this is closed -->
1892 <!--&#x3E; This would normally be text -->
1893 <!--&#x2D;&#x3E; As would this -->
1894 <!-- XML doesn't like trailing dashes &#x2D;&#x2D;&#x2D;&#x2D;&#x2D;&#x2D;-->
1895 <!-- Nor doubled hyphens &#x2D;&#x2D; anywhere in the data -->
1896 <p>But this is not a comment.</p>
1897 !! end
1898
1899 !! test
1900 Comment semantics: round-trip even text which contains encoded -->
1901 !! wikitext
1902 <!-- hello & goodbye - > --&gt; --&amp;gt; --&xx -->
1903 !! html/parsoid
1904 <!-- hello &#x26; goodbye &#x2D; &#x3E; &#x2D;&#x2D;&#x3E; &#x2D;&#x2D;&#x26;gt; &#x2D;&#x2D;&#x26;xx -->
1905 !! end
1906
1907 !! test
1908 Comment in template title
1909 !! wikitext
1910 {{f<!---->oo}}
1911 !! html
1912 <p>FOO
1913 </p>
1914 !! end
1915
1916 !! test
1917 Comment on its own line post-expand
1918 !! wikitext
1919 a
1920 {{blank}}<!---->
1921 b
1922 !! html
1923 <p>a
1924 </p><p>b
1925 </p>
1926 !! end
1927
1928 !! test
1929 Comment on its own line post-expand with non-significant whitespace
1930 !! wikitext
1931 a
1932 {{blank}} <!---->
1933 b
1934 !! html
1935 <p>a
1936 </p><p>b
1937 </p>
1938 !! end
1939
1940 !! test
1941 post-expand include size being exceeded
1942 !! options
1943 maxincludesize=20
1944 !! wikitext
1945 {{echo3|1234567890}}
1946 !! html
1947 <p><a href="/wiki/Template:Echo3" title="Template:Echo3">Template:Echo3</a><!-- WARNING: template omitted, post-expand include size too large -->
1948 </p>
1949 !! end
1950
1951 !! test
1952 max template depth being reached
1953 !! options
1954 maxtemplatedepth=1
1955 !! wikitext
1956 {{echo with depth|too deep!}}
1957 !! html
1958 <p><span class="error">Template recursion depth limit exceeded (1)</span>
1959 </p>
1960 !! end
1961
1962 !! test
1963 multiple templates that are redirects
1964 !! wikitext
1965 {{redirect to foo}}
1966 {{redirect to foo}}
1967 !! html
1968 <p>FOO
1969 FOO
1970 </p>
1971 !! end
1972
1973 !! test
1974 Multiple comments should still parse as SOL-transparent
1975 !! options
1976 parsoid=wt2html,wt2wt
1977 !! wikitext
1978 <!--c1-->*a
1979 <!--c2--><!--c3--><!--c4-->*b
1980 !! html/php
1981 <ul><li>a</li>
1982 <li>b</li></ul>
1983
1984 !! html/parsoid
1985 <!--c1--><ul>
1986 <li>a
1987 </li>
1988 <!--c2--><!--c3--><!--c4-->
1989 <li>b
1990 </li>
1991 </ul>
1992 !! end
1993
1994 ## Make sure ">" gets escaped in comments to avoid XSS
1995 !! test
1996 IE conditional comments
1997 !! wikitext
1998 <!--[if lt IE 9]>
1999 <script>alert('hi');</script>
2000 <![endif]-->
2001 !! html/parsoid
2002 <!--[if lt IE 9]&#x3E;
2003 <script&#x3E;alert('hi');</script&#x3E;
2004 <![endif]-->
2005 !! end
2006
2007 ###
2008 ### paragraph wrapping tests
2009 ###
2010
2011 !! test
2012 No block tags
2013 !! wikitext
2014 a
2015
2016 b
2017 !! html
2018 <p>a
2019 </p><p>b
2020 </p>
2021 !! end
2022
2023 !! test
2024 Block tag on one line (<div>)
2025 !! wikitext
2026 a <div>foo</div>
2027
2028 b
2029 !! html
2030 a <div>foo</div>
2031 <p>b
2032 </p>
2033 !! html+tidy
2034 <p>a </p><div>foo</div>
2035 <p>b
2036 </p>
2037 !! end
2038
2039 !! test
2040 No p-wrappable content
2041 !! options
2042 parsoid=wt2html,html2html
2043 !! wikitext
2044 <span><div>x</div></span>
2045 <span><s><div>x</div></s></span>
2046 <small><em></em></small><span><s><div>x</div></s></span>
2047 !! html+tidy
2048 <span><div>x</div></span>
2049 <span><s><div>x</div></s></span>
2050 <p><small><em></em></small></p><span><s><div>x</div></s></span>
2051 !! end
2052
2053 # T177612: Parsoid-only test
2054 !! test
2055 Transclusion meta tags shouldn't trip Parsoid's useless p-wrapper stripping code
2056 !! wikitext
2057 {{echo|<span><div>x</div></span>}}
2058 x
2059 !! html/parsoid
2060 <span 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;span>&lt;div>x&lt;/div>&lt;/span>"}},"i":0}}]}'><div>x</div></span>
2061 <p>x</p>
2062 !! end
2063
2064 !! test
2065 Block tag on one line (<blockquote>)
2066 !! wikitext
2067 a <blockquote>foo</blockquote>
2068
2069 b
2070 !! html
2071 a <blockquote>foo</blockquote>
2072 <p>b
2073 </p>
2074 !! html+tidy
2075 <p>a </p><blockquote><p>foo</p></blockquote>
2076 <p>b
2077 </p>
2078 !! end
2079
2080 !! test
2081 Block tag on both lines (<div>)
2082 !! wikitext
2083 a <div>foo</div>
2084
2085 b <div>foo</div>
2086 !! html
2087 a <div>foo</div>
2088 b <div>foo</div>
2089
2090 !! html+tidy
2091 <p>a </p><div>foo</div><p>
2092 b </p><div>foo</div>
2093 !! end
2094
2095 !! test
2096 Block tag on both lines (<blockquote>)
2097 !! wikitext
2098 a <blockquote>foo</blockquote>
2099
2100 b <blockquote>foo</blockquote>
2101 !! html
2102 a <blockquote>foo</blockquote>
2103 b <blockquote>foo</blockquote>
2104
2105 !! html+tidy
2106 <p>a </p><blockquote><p>foo</p></blockquote><p>
2107 b </p><blockquote><p>foo</p></blockquote>
2108 !! end
2109
2110 !! test
2111 Multiple lines without block tags
2112 !! wikitext
2113 <div>foo</div> a
2114 b
2115 c
2116 d<!--foo--> e
2117 x <div>foo</div> z
2118 !! html
2119 <div>foo</div> a
2120 <p>b
2121 c
2122 d e
2123 </p>
2124 x <div>foo</div> z
2125
2126 !! html+tidy
2127 <div>foo</div><p> a
2128 </p><p>b
2129 c
2130 d e
2131 </p><p>
2132 x </p><div>foo</div><p> z
2133 </p>
2134 !! end
2135
2136 !! test
2137 Empty lines between lines with block tags
2138 !! wikitext
2139 <div></div>
2140
2141
2142 <div></div>a
2143
2144 b
2145 <div>a</div>b
2146
2147 <div>b</div>d
2148
2149
2150 <div>e</div>
2151 !! html
2152 <div></div>
2153 <p><br />
2154 </p>
2155 <div></div>a
2156 <p>b
2157 </p>
2158 <div>a</div>b
2159 <div>b</div>d
2160 <p><br />
2161 </p>
2162 <div>e</div>
2163
2164 !! html+tidy
2165 <div></div>
2166 <p><br />
2167 </p>
2168 <div></div><p>a
2169 </p><p>b
2170 </p>
2171 <div>a</div><p>b
2172 </p><div>b</div><p>d
2173 </p><p><br />
2174 </p>
2175 <div>e</div>
2176 !! html/parsoid
2177 <div data-parsoid='{"stx":"html"}'></div>
2178
2179 <p><br /></p>
2180 <div data-parsoid='{"stx":"html"}'></div><p>a</p>
2181
2182 <p>b</p>
2183 <div data-parsoid='{"stx":"html"}'>a</div><p>b</p>
2184
2185 <div data-parsoid='{"stx":"html"}'>b</div><p>d</p>
2186
2187 <p><br /></p>
2188 <div data-parsoid='{"stx":"html"}'>e</div>
2189 !! end
2190
2191 !! test
2192 Unclosed HTML p-tags should be handled properly
2193 !! wikitext
2194 <div><p>foo</div>
2195 a
2196
2197 b
2198 !! html/php+tidy
2199 <div><p>foo</p></div>
2200 <p>a
2201 </p><p>b
2202 </p>
2203 !! html/parsoid
2204 <div data-parsoid='{"stx":"html"}'><p data-parsoid='{"stx":"html", "autoInsertedEnd":true}'>foo</p></div>
2205 <p>a</p>
2206 <p>b</p>
2207 !! end
2208
2209 ## SSS FIXME: I can come up with other scenarios where this doesn't work because
2210 ## of eager output of buffered tokens in the p-wrapper. But, I'm going to ignore
2211 ## them for now.
2212 !! test
2213 1. P-wrapping should leave sol-transparent tags outside p-tags where possible
2214 !! options
2215 parsoid=wt2html
2216 !! wikitext
2217 a [[Category:A1]] [[Category:A2]]
2218 [[Category:A3]]
2219 [[Category:A4]]
2220 !! html/parsoid
2221 <p>a</p>
2222 <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"/>
2223 !! end
2224
2225 !! test
2226 2. P-wrapping should leave sol-transparent tags outside p-tags where possible
2227 !! options
2228 parsoid=wt2html
2229 !! wikitext
2230 [[Category:A1]]a
2231 !! html/parsoid
2232 <link rel="mw:PageProp/Category" href="./Category:A1"/><p>a</p>
2233 !! end
2234
2235 !! test
2236 No paragraph necessary for SOL transparent template
2237 !! wikitext
2238 <span><div>foo</div></span>
2239 [[Category:Foo]]
2240
2241 <span><div>foo</div></span>
2242 {{echo|[[Category:Foo]]}}
2243 !! html/php
2244 <span><div>foo</div></span>
2245 <span><div>foo</div></span>
2246
2247 !! html/parsoid
2248 <span data-parsoid='{"stx":"html"}'><div data-parsoid='{"stx":"html"}'>foo</div></span>
2249 <link rel="mw:PageProp/Category" href="./Category:Foo"/>
2250
2251 <span data-parsoid='{"stx":"html"}'><div data-parsoid='{"stx":"html"}'>foo</div></span>
2252 <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]]"}},"i":0}}]}'/>
2253 !! end
2254
2255 !! test
2256 Avoid expanding multiline sol transparent template ranges unnecessarily
2257 !! wikitext
2258 hi
2259
2260
2261 {{echo|<br/>
2262 }}
2263
2264 [[Category:Ho]]
2265 !! html/php
2266 <p>hi
2267 </p><p><br />
2268 <br />
2269 </p>
2270 !! html/parsoid
2271 <p>hi</p>
2272
2273 <p><br />
2274 <br about="#mwt1" typeof="mw:Transclusion" data-parsoid='{}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;br/>\n"}},"i":0}}]}'/><span about="#mwt1">
2275 </span></p>
2276
2277 <link rel="mw:PageProp/Category" href="./Category:Ho" />
2278 !! end
2279
2280 !! test
2281 Paragraph wrapping following unclosed table
2282 !! options
2283 parsoid=wt2html,html2html
2284 !! wikitext
2285 {|
2286 |-
2287
2288 {|
2289 | x
2290 |}
2291
2292 a
2293
2294 b
2295
2296 c
2297 !! html/php+tidy
2298 <table>
2299
2300
2301 </table><table>
2302 <tbody><tr>
2303 <td>x
2304 </td></tr></tbody></table>
2305 <p>a
2306 </p><p>b
2307 </p><p>c
2308 </p>
2309 !! html/parsoid
2310 <table data-parsoid='{"autoInsertedEnd":true}'>
2311 <tbody><tr class="mw-empty-elt" data-parsoid='{"startTagSrc":"|-"}'></tr>
2312
2313 </tbody></table><table>
2314 <tbody><tr data-parsoid='{"autoInsertedStart":true}'><td>x</td></tr>
2315 </tbody></table>
2316
2317 <p>a</p>
2318
2319 <p>b</p>
2320
2321 <p>c</p>
2322 !! end
2323
2324 !! test
2325 Paragraph wrapping suppressed in html p
2326 !! options
2327 parsoid=wt2html,html2html
2328 !! wikitext
2329 <p>
2330
2331
2332 hi
2333
2334
2335
2336 </p>
2337 !! html/php+tidy
2338 <p>
2339
2340
2341 hi
2342
2343
2344
2345 </p>
2346 !! html/parsoid
2347 <p data-parsoid='{"stx":"html"}'>
2348
2349
2350 hi
2351
2352
2353
2354 </p>
2355 !! end
2356
2357 !! test
2358 Dangling table row doesn't prevent p-wrapping
2359 !! options
2360 parsoid=wt2html,html2html
2361 !! wikitext
2362 {|
2363 | hi
2364 |-
2365 |} ho
2366 !! html/parsoid
2367 <table>
2368 <tbody><tr><td>hi</td></tr>
2369 <tr class="mw-empty-elt"></tr>
2370 </tbody></table><p> ho</p>
2371 !! end
2372
2373 !! test
2374 P-wrapping non-breaking spaces
2375 !! wikitext
2376  
2377 !! html/php+tidy
2378 <p>&#160;
2379 </p>
2380 !! html/parsoid
2381 <p> </p>
2382 !! end
2383
2384 ###
2385 ### Preformatted text
2386 ###
2387
2388 !! test
2389 Preformatted text
2390 !! wikitext
2391 This is some
2392 Preformatted text
2393 With ''italic''
2394 And '''bold'''
2395 And a [[Main Page|link]]
2396 !! html
2397 <pre>This is some
2398 Preformatted text
2399 With <i>italic</i>
2400 And <b>bold</b>
2401 And a <a href="/wiki/Main_Page" title="Main Page">link</a>
2402 </pre>
2403 !! end
2404
2405 !! test
2406 Tabs don't trigger preformatted text
2407 !! wikitext
2408 This is not
2409 preformatted text.
2410 This is preformatted text.
2411 So is this.
2412 !! html/php
2413 <p> This is not
2414 preformatted text.
2415 </p>
2416 <pre>This is preformatted text.
2417 So is this.
2418 </pre>
2419 !! html/parsoid
2420 <p> This is not
2421 preformatted text.</p>
2422 <pre>This is preformatted text.
2423 So is this.</pre>
2424 !! end
2425
2426 !! test
2427 Space before tab needs nowiki pre protection
2428 !! options
2429 parsoid=html2wt
2430 !! html/parsoid
2431 <p> a</p>
2432 !! wikitext
2433 <nowiki> </nowiki> a
2434 !! end
2435
2436 !! test
2437 Ident preformatting with inline content
2438 !! wikitext
2439 a
2440 ''b''
2441 !! html
2442 <pre>a
2443 <i>b</i>
2444 </pre>
2445 !! end
2446
2447 !! test
2448 <pre> with <nowiki> inside (compatibility with 1.6 and earlier)
2449 !! wikitext
2450 <pre><nowiki>
2451 <b>
2452 <cite>
2453 <em>
2454 </nowiki></pre>
2455 !! html
2456 <pre>
2457 &lt;b&gt;
2458 &lt;cite&gt;
2459 &lt;em&gt;
2460 </pre>
2461
2462 !! end
2463
2464 !! test
2465 Regression with preformatted in <center>
2466 !! wikitext
2467 <center>
2468 Blah
2469 </center>
2470 !! html
2471 <center>
2472 <pre>Blah
2473 </pre>
2474 </center>
2475
2476 !! end
2477
2478 !! test
2479 T54763: Preformatted in <blockquote>
2480 !! wikitext
2481 <blockquote>
2482 Blah
2483 {|
2484 |
2485 indented cell (no pre-wrapping!)
2486 |}
2487 </blockquote>
2488 !! html
2489 <blockquote>
2490 <p> Blah
2491 </p>
2492 <table>
2493 <tr>
2494 <td>
2495 <p> indented cell (no pre-wrapping!)
2496 </p>
2497 </td></tr></table>
2498 </blockquote>
2499
2500 !! end
2501
2502 !! test
2503 T53086: Double newlines in blockquotes should be turned into paragraphs
2504 !! wikitext
2505 <blockquote>
2506 Foo
2507
2508 Bar
2509 </blockquote>
2510 !! html
2511 <blockquote>
2512 <p>Foo
2513 </p><p>Bar
2514 </p>
2515 </blockquote>
2516
2517 !! end
2518
2519 !! test
2520 T17491: <ins>/<del> in blockquote
2521 !! wikitext
2522 <blockquote>
2523 Foo <del>bar</del> <ins>baz</ins> quux
2524 </blockquote>
2525 !! html
2526 <blockquote>
2527 <p>Foo <del>bar</del> <ins>baz</ins> quux
2528 </p>
2529 </blockquote>
2530
2531 !! html+tidy
2532 <blockquote>
2533 <p>Foo <del>bar</del> <ins>baz</ins> quux
2534 </p>
2535 </blockquote>
2536 !! end
2537
2538 !! test
2539 T17491: <ins>/<del> in blockquote (2)
2540 !! wikitext
2541 <blockquote>Foo <del>bar</del> <ins>baz</ins> quux
2542 </blockquote>
2543 !! html
2544 <blockquote>Foo <del>bar</del> <ins>baz</ins> quux
2545 </blockquote>
2546
2547 !! html+tidy
2548 <blockquote><p>Foo <del>bar</del> <ins>baz</ins> quux
2549 </p></blockquote>
2550 !! end
2551
2552 !! test
2553 <pre> with attributes (T5202)
2554 !! wikitext
2555 <pre style="background: blue; color:white">Bluescreen of WikiDeath</pre>
2556 !! html
2557 <pre style="background: blue; color:white">Bluescreen of WikiDeath</pre>
2558
2559 !! end
2560
2561 !! test
2562 <pre> with width attribute (T5202)
2563 !! wikitext
2564 <pre width="8">Narrow screen goodies</pre>
2565 !! html
2566 <pre width="8">Narrow screen goodies</pre>
2567
2568 !! end
2569
2570 !! test
2571 <pre> with forbidden attribute (T5202)
2572 !! wikitext
2573 <pre width="8" onmouseover="alert(document.cookie)">Narrow screen goodies</pre>
2574 !! html
2575 <pre width="8">Narrow screen goodies</pre>
2576
2577 !! end
2578
2579 !! test
2580 Entities inside <pre>
2581 !! wikitext
2582 <pre>&lt;</pre>
2583 !! html
2584 <pre>&lt;</pre>
2585
2586 !! end
2587
2588 !! test
2589 <pre> with forbidden attribute values (T5202)
2590 !! wikitext
2591 <pre width="8" style="border-width: expression(alert(document.cookie))">Narrow screen goodies</pre>
2592 !! html
2593 <pre width="8" style="/* insecure input */">Narrow screen goodies</pre>
2594
2595 !! end
2596
2597 !! test
2598 <nowiki> inside <pre> (T15238)
2599 !! wikitext
2600 <pre>
2601 <nowiki>
2602 </pre>
2603 <pre>
2604 <nowiki></nowiki>
2605 </pre>
2606 <pre><nowiki><nowiki></nowiki>Foo<nowiki></nowiki></nowiki></pre>
2607 !! html
2608 <pre>
2609 &lt;nowiki&gt;
2610 </pre>
2611 <pre>
2612
2613 </pre>
2614 <pre>&lt;nowiki&gt;Foo&lt;/nowiki&gt;</pre>
2615
2616 !! end
2617
2618 !! test
2619 <nowiki> inside of #tag:pre
2620 !! wikitext
2621 {{#tag:pre|Foo <nowiki>&rarr;bar</nowiki>}}
2622 !! html/php
2623 <pre>Foo &#8594;bar</pre>
2624
2625 !! html/parsoid
2626 <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>
2627 !! end
2628
2629 ## Don't expect this to rt, Parsoid drops the unmatched closing pre tags that
2630 ## aren't enclosed in nowikis.
2631 !! test
2632 <nowiki> and <pre> preference (first one wins)
2633 !! options
2634 parsoid=wt2html
2635 !! wikitext
2636 <pre>
2637 <nowiki>
2638 </pre>
2639 </nowiki>
2640 </pre>
2641
2642 <nowiki>
2643 <pre>
2644 <nowiki>
2645 </pre>
2646 </nowiki>
2647 </pre>
2648
2649 !! html/php
2650 <pre>
2651 &lt;nowiki&gt;
2652 </pre>
2653 <p>&lt;/nowiki&gt;
2654 &lt;/pre&gt;
2655 </p><p>
2656 &lt;pre&gt;
2657 &lt;nowiki&gt;
2658 &lt;/pre&gt;
2659
2660 &lt;/pre&gt;
2661 </p>
2662 !! html/parsoid
2663 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n&lt;nowiki>\n"}}'>&lt;nowiki>
2664 </pre>
2665 <p>&lt;/nowiki></p>
2666
2667
2668 <p><span typeof="mw:Nowiki">
2669 &lt;pre>
2670 &lt;nowiki>
2671 &lt;/pre>
2672 </span></p>
2673 !! end
2674
2675 !! test
2676 </pre> inside nowiki
2677 !! wikitext
2678 <nowiki></pre></nowiki>
2679 !! html
2680 <p>&lt;/pre&gt;
2681 </p>
2682 !! end
2683
2684 !! test
2685 Empty pre; pre inside other HTML tags (T56946)
2686 !! wikitext
2687 a
2688
2689 <div><pre>
2690 foo
2691 </pre></div>
2692 <pre></pre>
2693 !! html/php+tidy
2694 <p>a
2695 </p>
2696 <div><pre>foo
2697 </pre></div>
2698 <pre></pre>
2699 !! html/parsoid
2700 <p>a</p>
2701
2702 <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
2703 </pre></div>
2704 <pre typeof="mw:Extension/pre" about="#mwt4" data-parsoid='{"stx":"html"}' data-mw='{"name":"pre","attrs":{},"body":{"extsrc":""}}'></pre>
2705 !! end
2706
2707 !! test
2708 HTML pre followed by indent-pre
2709 !! wikitext
2710 <pre>foo</pre>
2711 bar
2712 !! html
2713 <pre>foo</pre>
2714 <pre>bar
2715 </pre>
2716 !! end
2717
2718 !! test
2719 Block tag pre
2720 !! wikitext
2721 <p><pre>foo</pre></p>
2722 !! html/php+tidy
2723 <p class="mw-empty-elt"></p><pre>foo</pre><p class="mw-empty-elt"></p>
2724 !! html/parsoid
2725 <p class='mw-empty-elt' 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 class='mw-empty-elt' data-parsoid='{"autoInsertedStart":true,"stx":"html"}'></p>
2726 !! end
2727
2728 !!test
2729 Templates: Indent-Pre: 1a. Templates that break a line should suppress <pre>
2730 !! wikitext
2731 {{echo|}}
2732 !! html
2733
2734 !!end
2735
2736 !!test
2737 Templates: Indent-Pre: 1b. Templates that break a line should suppress <pre>
2738 !! wikitext
2739 {{echo|
2740 foo}}
2741 !! html
2742 <p>foo
2743 </p>
2744 !!end
2745
2746 !! test
2747 Templates: Indent-Pre: 1c: Wrapping should be based on expanded content
2748 !! wikitext
2749 {{echo|a
2750 b}}
2751 !! html
2752 <pre>a
2753 </pre>
2754 <p>b
2755 </p>
2756 !!end
2757
2758 !! test
2759 Templates: Indent-Pre: 1d: Wrapping should be based on expanded content
2760 !! wikitext
2761 {{echo|a
2762 b
2763 c
2764 d
2765 e
2766 }}
2767 !! html
2768 <pre>a
2769 </pre>
2770 <p>b
2771 c
2772 </p>
2773 <pre>d
2774 </pre>
2775 <p>e
2776 </p>
2777 !!end
2778
2779 !!test
2780 Templates: Indent-Pre: 1e. Wrapping should be based on expanded content
2781 !! wikitext
2782 {{echo| foo}}
2783
2784 {{echo| foo}}{{echo| bar}}
2785
2786 {{echo| foo}}
2787 {{echo| bar}}
2788
2789 {{echo|<!--cmt--> foo}}
2790
2791 <!--cmt-->{{echo| foo}}
2792
2793 {{echo|{{echo| }}bar}}
2794 !! html
2795 <pre>foo
2796 </pre>
2797 <pre>foo bar
2798 </pre>
2799 <pre>foo
2800 bar
2801 </pre>
2802 <pre>foo
2803 </pre>
2804 <pre>foo
2805 </pre>
2806 <pre>bar
2807 </pre>
2808 !!end
2809
2810 !! test
2811 Templates: Indent-Pre: 1f: Wrapping should be based on expanded content
2812 !! wikitext
2813 {{echo| }}a
2814
2815 {{echo|
2816 }}a
2817
2818 {{echo|
2819 b}}
2820
2821 {{echo|a
2822 }}b
2823
2824 {{echo|a
2825 }} b
2826 !! html
2827 <pre>a
2828 </pre>
2829 <p><br />
2830 </p>
2831 <pre>a
2832 </pre>
2833 <p><br />
2834 </p>
2835 <pre>b
2836 </pre>
2837 <p>a
2838 </p>
2839 <pre>b
2840 </pre>
2841 <p>a
2842 </p>
2843 <pre>b
2844 </pre>
2845 !!end
2846
2847 ## Hmm, should Parsoid rt this?
2848 !! test
2849 Pres with newline attributes
2850 !! options
2851 parsoid=wt2html,html2html
2852 !! wikitext
2853 <pre class="one
2854 two">hi</pre>
2855 !! html/php
2856 <pre class="one two">hi</pre>
2857
2858 !! html/parsoid
2859 <pre class="one two" typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{"class":"one two"},"body":{"extsrc":"hi"}}'>hi</pre>
2860 !! end
2861
2862 !! test
2863 Things that look like <pre> tags aren't treated as such
2864 !! wikitext
2865 Barack Obama <President> of the United States
2866 <President></President>
2867 !! html
2868 <p>Barack Obama &lt;President&gt; of the United States
2869 &lt;President&gt;&lt;/President&gt;
2870 </p>
2871 !! end
2872
2873 ## Remex doesn't account for fostered content.
2874 ## The difference between Parsoid and the PHP parser can be attributed to core
2875 ## commit 674e8388cba and 710618f89af in Parsoid's repo. Parsoid doesn't
2876 ## tokenize unmatched extension tags that shadow html tags as strings to ease
2877 ## an escaping mechanism. See the comment in `maybeExtensionTag`.
2878 !! test
2879 Handle broken pre-like tags (T66025)
2880 !! options
2881 parsoid=wt2html
2882 !! wikitext
2883 {{echo|<pre <pre>x</pre>}}
2884
2885 <table><pre </table>
2886 !! html/php
2887 <pre>x</pre>
2888 <table>&lt;pre </table>
2889
2890 !! html/php+tidy
2891 <pre>x</pre>
2892 &lt;pre <table></table>
2893 !! html/parsoid
2894 <pre typeof="mw:Extension/pre mw:Transclusion" about="#mwt2" data-parsoid='{"stx":"html","a":{"&lt;pre":null},"sa":{"&lt;pre":""},"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>
2895
2896 <pre data-parsoid='{"stx":"html","src":"&lt;pre &lt;/table>","tagWidths":[13,0],"a":{"&lt;":null,"table":null},"sa":{"&lt;":"","table":""},"fostered":true,"autoInsertedEnd":true}'></pre><table data-parsoid='{"stx":"html","autoInsertedEnd":true}'></table>
2897 !! end
2898
2899 ## Similar to the above, but shows the difference between extension and html tags
2900 !! test
2901 Less than in attribute position
2902 !! wikitext
2903 <pre <pre>123</pre>
2904
2905 <div <div>123</div>
2906 !! html/php+tidy
2907 <pre>123</pre><p>
2908 &lt;div </p><div>123</div>
2909 !! html/parsoid
2910 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{"&lt;pre":""},"body":{"extsrc":"123"}}'>123</pre><p>
2911
2912 &lt;div </p><div>123</div>
2913 !! end
2914
2915 !! test
2916 Parsoid: handle pre with space after attribute
2917 !! options
2918 parsoid=wt2html
2919 !! wikitext
2920 <pre style="width:50%;" >{{echo|foo}}</pre>
2921 !! html/php
2922 <pre style="width:50%;">{{echo|foo}}</pre>
2923
2924 !! html/parsoid
2925 <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>
2926 !! end
2927
2928 !! test
2929 Self-closed pre
2930 !! wikitext
2931 <pre />
2932 !! html/php
2933 <pre></pre>
2934
2935 !! html/parsoid
2936 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{}}'></pre>
2937 !! end
2938
2939 !! test
2940 Newline before table-close generates empty table row: T208619
2941 !! wikitext
2942 {|
2943
2944 |}
2945 !! html/php+tidy
2946 <table>
2947
2948 <tbody><tr><td></td></tr></tbody></table>
2949 !! html/parsoid
2950 <table data-parsoid='{}'>
2951
2952 </table>
2953 !! end
2954
2955 # PHP has one more row in the output than Parsoid does: T208619
2956 !! test
2957 Parsoid: Don't paragraph-wrap fosterable content even if table syntax is unbalanced
2958 !! options
2959 parsoid=wt2html
2960 !! wikitext
2961 {|
2962 <td>
2963 <td>
2964 </td>
2965
2966
2967
2968 |}
2969 !! html/php+tidy
2970 <table>
2971 <tbody><tr><td>
2972 </td><td>
2973 </td>
2974
2975
2976
2977 </tr><tr><td></td></tr></tbody></table>
2978 !! html/parsoid
2979 <table>
2980
2981 <tbody>
2982 <tr>
2983 <td></td>
2984
2985 <td>
2986 </td></tr>
2987
2988
2989
2990 </tbody></table>
2991 !! end
2992
2993
2994 #--------------------------------------------------------------------
2995 # Transclusion parameter whitespace stripping tests
2996 # Behavior is different for positional and named parameters
2997 #--------------------------------------------------------------------
2998 !! test
2999 Templates: Strip leading and trailing whitespace from named-param values
3000 !! wikitext
3001 {{echo|1= a }}
3002
3003 {{echo|1= {{echo|b}} }}
3004
3005 {{echo| 1 =
3006 c }}
3007
3008 {{echo| 1 =
3009 * d
3010 }}
3011 !! html
3012 <p>a
3013 </p><p>b
3014 </p><p>c
3015 </p>
3016 <ul><li>d</li></ul>
3017
3018 !! end
3019
3020 !! test
3021 Templates: Don't strip whitespace from positional-param values
3022 !! wikitext
3023 {{echo|a }}
3024
3025 {{echo|{{echo|b}} }}
3026
3027 {{echo| c
3028 }}
3029
3030 {{echo| {{echo|d}}
3031 }}
3032
3033 {{echo|
3034 e}}
3035
3036 {{echo|
3037 *f}}
3038
3039 {{echo|
3040 }}g
3041 !! html
3042 <p>a
3043 </p><p>b
3044 </p>
3045 <pre>c
3046 </pre>
3047 <p><br />
3048 </p>
3049 <pre>d
3050 </pre>
3051 <p><br />
3052 </p>
3053 <pre>e
3054 </pre>
3055 <p><br />
3056 </p>
3057 <ul><li>f</li></ul>
3058 <p><br />
3059 </p>
3060 <pre>g
3061 </pre>
3062 !! end
3063
3064 !! test
3065 Templates: Don't recognize targets split by newlines
3066 !! options
3067 parsoid=wt2html
3068 !! wikitext
3069 {{ech
3070 o|foo}}
3071 !! html/php
3072 <p>{{ech
3073 o|foo}}
3074 </p>
3075 !! html/parsoid
3076 <p>{{ech
3077 o|foo}}</p>
3078 !! end
3079
3080 !! test
3081 Templates: Recognize targets when newlines and comments don't split the target
3082 !! options
3083 parsoid=wt2html
3084 !! wikitext
3085 {{
3086 <!--X--> ech<!--X-->o<!--X-->
3087 <!--X--> <!--X-->
3088
3089 |foo}}
3090 !! html/php
3091 <p>foo
3092 </p>
3093 !! html/parsoid
3094 <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>
3095 !! end
3096
3097 !! test
3098 Templates: Handle empty comment-and-ws-only lines correctly
3099 !! wikitext
3100 {{echo|foo
3101 <!--should be ignored-->
3102 <!--should be ignored as well-->
3103 bar}}
3104 !! html/php
3105 <p>foo
3106 bar
3107 </p>
3108 !! html/parsoid
3109 <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>
3110 !! end
3111
3112 !! test
3113 Templates: Handle comments in the target
3114 !! wikitext
3115 {{echo
3116 <!-- should be ignored -->
3117 |foo}}
3118
3119 {{echo
3120 <!-- should be ignored and spaces on next line should not trip us up (T147742) -->
3121 |foo}}
3122
3123 {{echo<!-- should be ignored -->
3124 |foo}}
3125
3126 {{echo<!-- should be ignored -->|foo}}
3127
3128 {{<!-- should be ignored -->echo|foo}}
3129 !! html/php
3130 <p>foo
3131 </p><p>foo
3132 </p><p>foo
3133 </p><p>foo
3134 </p><p>foo
3135 </p>
3136 !! html/parsoid
3137 <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>
3138
3139 <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>
3140
3141 <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>
3142
3143 <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>
3144
3145 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</p>
3146 !! end
3147
3148 !! test
3149 Templates: Handle comments in parameter names (T69657)
3150 !! wikitext
3151 {{echo|1
3152 <!-- should be ignored -->
3153 =foo}}
3154
3155 {{echo|
3156 <!-- should be ignored -->
3157 1 = foo}}
3158
3159 {{echo|1<!-- should be ignored -->=foo}}
3160
3161 {{echo|<!-- should be ignored -->1=foo}}
3162 !! html/php
3163 <p>foo
3164 </p><p>foo
3165 </p><p>foo
3166 </p><p>foo
3167 </p>
3168 !! html/parsoid
3169 <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>
3170
3171 <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>
3172
3173 <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>
3174
3175 <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>
3176 !! end
3177
3178 !! test
3179 Templates: Other wikitext in parameter names (T69657)
3180 !! wikitext
3181 {{echo|''1''=foo}}
3182 !! html/php
3183 <p>{{{1}}}
3184 </p>
3185 !! html/parsoid
3186 <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>
3187 !! end
3188
3189 !! test
3190 Templates: With colons
3191 !! wikitext
3192 {{With: Colon}}
3193 !! html/php
3194 <p>Template with colon
3195 </p>
3196 !! html/parsoid
3197 <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>
3198 !! end
3199
3200 #--------------------------------------------------------------------
3201 # Transclusion parameter escaping tests
3202 #--------------------------------------------------------------------
3203
3204 !! test
3205 Templates: Parsoid parameter escaping test 1
3206 !! wikitext
3207 {{echo|[foo]|{{echo|[bar]}}}}
3208 !! html/php+tidy
3209 <p>[foo]
3210 </p>
3211 !! html/parsoid
3212 <p about="#mwt1" typeof="mw:Transclusion"
3213 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[foo]"},"2":{"wt":"{{echo|[bar]}}"}},"i":0}}]}'>[foo]</p>
3214 !! end
3215
3216 !! test
3217 Parsoid: Pipes in external links in template parameter
3218 !! wikitext
3219 {{echo|[{{echo|http://example.com}} link]}}
3220 !! html/php+tidy
3221 <p><a rel="nofollow" class="external text" href="http://example.com">link</a>
3222 </p>
3223 !! html/parsoid
3224 <p><a rel="mw:ExtLink" class="external text" 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>
3225 !! end
3226
3227 !! test
3228 Parsoid: pipe in transclusion parameter
3229 !! wikitext
3230 {{echo|http://foo.com/a&#124;b}}
3231 !! html/php+tidy
3232 <p><a rel="nofollow" class="external free" href="http://foo.com/a%7Cb">http://foo.com/a%7Cb</a>
3233 </p>
3234 !! html/parsoid
3235 <p><a rel="mw:ExtLink" class="external free" href="http://foo.com/a%7Cb" about="#mwt1" typeof="mw:Transclusion" 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>
3236 !! end
3237
3238 !! test
3239 Parsoid: Pipe in external link target and content in template parameter
3240 !! options
3241 parsoid=html2wt,wt2wt
3242 !! wikitext
3243 {{echo|[http://foo.com/a&#124;b a&#124;b]}}
3244 !! html/php+tidy
3245 <p><a rel="nofollow" class="external text" href="http://foo.com/a%7Cb">a&#124;b</a>
3246 </p>
3247 !! html/parsoid
3248 <p><a rel="mw:ExtLink" href="http://foo.com/a|b" about="#mwt1"
3249 typeof="mw:Transclusion"
3250 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},
3251 "params":{"1":{"wt":"[http://foo.com/a|b a|b]"}},"i":0}}]}'>a|b</a></p>
3252 !! end
3253
3254 !! test
3255 Parsoid: Pipe in template with nested template in external link target in template parameter (seriously)
3256 !! wikitext
3257 {{echo|[{{fullurl:{{FULLPAGENAME}}|action=edit}} bar]}}
3258 !! html/php+tidy
3259 <p><a rel="nofollow" class="external text" href="http://example.org/index.php?title=Parser_test&amp;action=edit">bar</a>
3260 </p>
3261 !! html/parsoid
3262 <p><a rel="mw:ExtLink" class="external text" href="http://example.org/index.php?title=Parser_test&amp;action=edit" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[{{fullurl:{{FULLPAGENAME}}|action=edit}} bar]"}},"i":0}}]}'>bar</a></p>
3263 !! end
3264
3265 !! test
3266 Templates: Don't escape already nowiki-escaped text in template parameters
3267 !! options
3268 parsoid=html2wt,wt2wt
3269 !! wikitext
3270 {{echo|foo<nowiki>|</nowiki>bar}}
3271 {{echo|<nowiki>&lt;div&gt;</nowiki>}}
3272 {{echo|<nowiki></nowiki>}}
3273 !! html/php+tidy
3274 <p>foo|bar
3275 &lt;div&gt;
3276
3277 </p>
3278 !! html/parsoid
3279 <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>
3280 <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>
3281 <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>
3282 </p>
3283 !! end
3284
3285 ## T54824
3286 !! test
3287 Templates: '=' char in nested transclusions should not trigger nowiki escapes or conversion to named param
3288 !! options
3289 parsoid=html2wt,wt2wt
3290 !! wikitext
3291 {{echo|{{echo|1=bar}}}}
3292 !! html/php+tidy
3293 <p>bar
3294 </p>
3295 !! html/parsoid
3296 <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>
3297 !! end
3298
3299 ## T58733
3300 !! test
3301 Templates parameters with special tokenizing behavior dont get modified because of arg escaping
3302 !! wikitext
3303 {{echo|a : b}}
3304 !! html/php+tidy
3305 <p>a&#160;: b
3306 </p>
3307 !! html/parsoid
3308 <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>
3309 !! end
3310
3311 ## T73412
3312 !! test
3313 Templates: Preserve blank parameter names
3314 !! wikitext
3315 {{echo|=foo}}
3316 !! html/php+tidy
3317 <p>{{{1}}}
3318 </p>
3319 !! html/parsoid
3320 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"":{"wt":"foo"}},"i":0}}]}'>{{{1}}}</p>
3321 !! end
3322
3323 !! test
3324 Templates: Preserve blank parameter names in other positions
3325 !! wikitext
3326 {{blank_param|bar|=foo}}
3327 !! html/php+tidy
3328 <p>bar
3329 foo
3330 </p>
3331 !! html/parsoid
3332 <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
3333 foo</p>
3334 !! end
3335
3336 ###
3337 ### Parsoid-centric tests for testing RT edge cases for pre
3338 ###
3339
3340 !!test
3341 1a. Indent-Pre and Comments
3342 !! wikitext
3343 a
3344 <!--a-->
3345 c
3346 !! html
3347 <pre>a
3348 </pre>
3349 <p>c
3350 </p>
3351 !!end
3352
3353 !!test
3354 1b. Indent-Pre and Comments
3355 !! wikitext
3356 a
3357 <!--a-->
3358 c
3359 !! html
3360 <pre>a
3361 </pre>
3362 <p>c
3363 </p>
3364 !!end
3365
3366 !!test
3367 1c. Indent-Pre and Comments
3368 !! wikitext
3369 <!--a--> a
3370
3371 <!--a--> a
3372 !! html
3373 <pre> a
3374 </pre>
3375 <pre> a
3376 </pre>
3377 !!end
3378
3379 !!test
3380 1d. Indent-Pre and Comments
3381 (Pre-handler currently cannot distinguish between comment/ws order and normalizes them to [comment,ws] order)
3382 !! wikitext
3383 <!--a--> a
3384
3385 <!--b-->b
3386 !! html
3387 <pre>a
3388 </pre>
3389 <pre>b
3390 </pre>
3391 !!end
3392
3393 !!test
3394 2a. Indent-Pre and tables
3395 !! wikitext
3396 {|
3397 |-
3398 !h1!!h2
3399 |foo||bar
3400 |}
3401 !! html
3402 <table>
3403
3404 <tr>
3405 <th>h1</th>
3406 <th>h2
3407 </th>
3408 <td>foo</td>
3409 <td>bar
3410 </td></tr></table>
3411
3412 !!end
3413
3414 !!test
3415 2b. Indent-Pre and tables
3416 !! wikitext
3417 {|
3418 |-
3419 |foo
3420 |}
3421 !! html
3422 <table>
3423
3424 <tr>
3425 <td>foo
3426 </td></tr></table>
3427
3428 !!end
3429
3430 !!test
3431 2c. Indent-Pre and tables (T44252)
3432 !! wikitext
3433 {|
3434 |+foo
3435 ! |bar
3436 |}
3437 !! html
3438 <table>
3439 <caption>foo
3440 </caption>
3441 <tr>
3442 <th>bar
3443 </th></tr></table>
3444
3445 !!end
3446
3447 !!test
3448 2d. Indent-Pre and tables
3449 !! wikitext
3450 a
3451 {|
3452 |b
3453 |}
3454 !! html/php
3455 <pre>a
3456 </pre>
3457 <table>
3458 <tr>
3459 <td>b
3460 </td></tr></table>
3461
3462 !! html/parsoid
3463 <pre>a</pre>
3464 <table>
3465 <tbody><tr><td> b</td></tr>
3466 </tbody></table>
3467 !!end
3468
3469 !!test
3470 2e. Indent-Pre and table-line syntax
3471 !! wikitext
3472 a
3473 | b
3474 | c
3475 !! html/php
3476 <pre>a
3477 | b
3478 | c
3479 </pre>
3480 !!end
3481
3482 !!test
3483 2f. Indent-pre started by table-line syntax
3484 !! wikitext
3485 a
3486 | b
3487 | c
3488 !! html/php
3489 <p>a
3490 </p>
3491 <pre>| b
3492 | c
3493 </pre>
3494 !! html/parsoid
3495 <p>a</p>
3496 <pre>
3497 | b
3498 | c</pre>
3499 !!end
3500
3501 !! test
3502 2g. Indented table markup mixed with indented pre content (proposed in T8200)
3503 !! wikitext
3504 <table>
3505 <tr>
3506 <td>
3507 Text that should be rendered preformatted
3508 </td>
3509 </tr>
3510 </table>
3511 !! html
3512 <table>
3513 <tr>
3514 <td>
3515 <pre>Text that should be rendered preformatted
3516 </pre>
3517 </td>
3518 </tr>
3519 </table>
3520
3521 !! end
3522
3523 !! test
3524 2h. Indent pre in tables
3525 !! options
3526 parsoid=wt2html,html2html
3527 !! wikitext
3528 {|
3529 !
3530 foo
3531 !
3532 bar
3533 |-
3534 |
3535 baz
3536 {{!}}
3537 bam
3538 |}
3539 !! html/php
3540 <table>
3541 <tr>
3542 <th>
3543 <pre>foo
3544 </pre>
3545 </th>
3546 <th>
3547 <pre>bar
3548 </pre>
3549 </th></tr>
3550 <tr>
3551 <td>
3552 <pre>baz
3553 </pre>
3554 </td>
3555 <td>
3556 <pre>bam
3557 </pre>
3558 </td></tr></table>
3559
3560 !! html/parsoid
3561 <table>
3562 <tbody><tr><th>
3563 <pre>foo</pre>
3564 </th><th>
3565 <pre>bar</pre>
3566 </th></tr><tr>
3567 <td>
3568 <pre>baz</pre>
3569 </td><td data-parsoid='{"startTagSrc":"{{!}}"}'>
3570 <pre>bam</pre>
3571 </td></tr></tbody></table>
3572 !! end
3573
3574 !! test
3575 3a. Indent-Pre and block tags (single-line html)
3576 !! wikitext
3577 a <p> foo </p>
3578 b <div> foo </div>
3579 c <blockquote> foo </blockquote>
3580 <span> foo </span>
3581 !! html
3582 a <p> foo </p>
3583 b <div> foo </div>
3584 c <blockquote> foo </blockquote>
3585 <pre><span> foo </span>
3586 </pre>
3587 !! html/php+tidy
3588 <p> a </p><p> foo </p><p>
3589 b </p><div> foo </div><p>
3590 c </p><blockquote><p> foo </p></blockquote>
3591 <pre><span> foo </span>
3592 </pre>
3593 !! html/parsoid
3594 <p> a </p><p data-parsoid='{"stx":"html"}'> foo </p><p>
3595 b </p><div data-parsoid='{"stx":"html"}'> foo </div><p>
3596 c </p><blockquote data-parsoid='{"stx":"html"}'><p> foo </p></blockquote>
3597 <pre><span data-parsoid='{"stx":"html"}'> foo </span></pre>
3598 !! end
3599
3600 !! test
3601 3b. Indent-Pre and block tags (multi-line html)
3602 !! wikitext
3603 a <span>foo</span>
3604 <!-- comment --> b <div> foo </div>
3605 !! html/php
3606 <pre>a <span>foo</span>
3607 </pre>
3608 b <div> foo </div>
3609
3610 !! html/parsoid
3611 <pre>a <span data-parsoid='{"stx":"html"}'>foo</span></pre>
3612 <!-- comment --> <p>b </p><div data-parsoid='{"stx":"html"}'> foo </div>
3613 !! html/php+tidy
3614 <pre>a <span>foo</span>
3615 </pre><p>
3616 b </p><div> foo </div>
3617 !! end
3618
3619 !! test
3620 3c. Indent-Pre and block tags (pre-content on separate line)
3621 !! wikitext
3622 <p>
3623 foo
3624 </p>
3625
3626 <div>
3627 foo
3628 </div>
3629
3630 <center>
3631 foo
3632 </center>
3633
3634 <blockquote>
3635 foo
3636 </blockquote>
3637
3638 <blockquote>
3639 <pre>
3640 foo
3641 </pre>
3642 </blockquote>
3643
3644 <table><tr><td>
3645 foo
3646 </td></tr></table>
3647
3648 <ul><li>
3649 foo
3650 </li></ul>
3651
3652 !! html/php
3653 <p>
3654 foo
3655 </p>
3656 <div>
3657 <pre>foo
3658 </pre>
3659 </div>
3660 <center>
3661 <pre>foo
3662 </pre>
3663 </center>
3664 <blockquote>
3665 <p> foo
3666 </p>
3667 </blockquote>
3668 <blockquote>
3669 <pre>
3670 foo
3671 </pre>
3672 </blockquote>
3673 <table><tr><td>
3674 <pre>foo
3675 </pre>
3676 </td></tr></table>
3677 <ul><li>
3678 foo
3679 </li></ul>
3680
3681 !! html/parsoid
3682 <p data-parsoid='{"stx":"html"}'>
3683 foo
3684 </p>
3685
3686 <div>
3687 <pre>foo</pre>
3688 </div>
3689
3690 <center>
3691 <pre>foo</pre>
3692 </center>
3693
3694 <blockquote>
3695 <p> foo</p>
3696 </blockquote>
3697
3698 <blockquote>
3699 <pre typeof="mw:Extension/pre" about="#mwt3" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\nfoo\n"}}'>foo
3700 </pre>
3701 </blockquote>
3702
3703 <table data-parsoid='{"stx":"html"}'><tbody><tr data-parsoid='{"stx":"html"}'><td data-parsoid='{"stx":"html"}'>
3704 <pre>foo</pre>
3705 </td></tr></tbody></table>
3706
3707 <ul data-parsoid='{"stx":"html"}'><li data-parsoid='{"stx":"html"}'>
3708 foo
3709 </li></ul>
3710 !! end
3711
3712 !! test
3713 4. Indent-Pre and extension tags
3714 !! options
3715 parsoid=wt2html,html2html
3716 !! wikitext
3717 a <tag />
3718 !! html/php+tidy
3719 <p> a </p><pre>NULL
3720 array (
3721 )
3722 </pre>
3723 !! html/parsoid
3724 <p> a </p><pre typeof="mw:Extension/tag" about="#mwt2" data-mw='{"name":"tag","attrs":{}}'></pre>
3725 !! end
3726
3727 !! test
3728 5. Indent-Pre and html pre
3729 !! wikitext
3730 <pre class="123">hi</pre>
3731 !! html/php
3732 <pre class="123">hi</pre>
3733
3734 !! html/parsoid
3735 <pre class="123" typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{"class":"123"},"body":{"extsrc":"hi"}}'>hi</pre>
3736 !! end
3737
3738 !!test
3739 Render paragraphs when indent-pre is suppressed in blocklevels
3740 !! wikitext
3741 <blockquote>
3742 foo
3743
3744 bar
3745 </blockquote>
3746 !! html
3747 <blockquote>
3748 <p> foo
3749 </p><p> bar
3750 </p>
3751 </blockquote>
3752
3753 !!end
3754
3755 !!test
3756 4. Multiple spaces at start-of-line
3757 !! wikitext
3758 <p> foo </p>
3759 foo
3760 {|
3761 |foo
3762 |}
3763 !! html
3764 <p> foo </p>
3765 <pre> foo
3766 </pre>
3767 <table>
3768 <tr>
3769 <td>foo
3770 </td></tr></table>
3771
3772 !!end
3773
3774 ## NOTE: the leading white-space chars on empty line are significant
3775 !! test
3776 5a. White-space in indent-pre
3777 !! wikitext
3778 a<br />
3779
3780 b
3781 !! html
3782 <pre>a<br />
3783
3784 b
3785 </pre>
3786 !! end
3787
3788 ## NOTE: the leading white-space chars on empty line are significant
3789 !! test
3790 5b. White-space in indent-pre
3791 !! wikitext
3792 a
3793
3794 b
3795
3796
3797 c
3798 !! html
3799 <pre>a
3800
3801 b
3802
3803
3804 c
3805 </pre>
3806 !! end
3807
3808 !! test
3809 5c. White-space in indent-pre
3810 !! wikitext
3811 ''a''
3812 ''b''
3813 ''c''
3814 !! html
3815 <pre><i>a</i>
3816 <i>b</i>
3817 <i>c</i>
3818 </pre>
3819 !! end
3820
3821 !! test
3822 6. Pre-blocks should extend across lines with leading WS even when there is no wrappable content
3823 !! wikitext
3824 a
3825
3826 <!-- continue -->
3827 b
3828
3829 c
3830
3831 d
3832 !! html
3833 <pre>a
3834
3835 b
3836 </pre>
3837 <pre>c
3838
3839 </pre>
3840 <p>d
3841 </p>
3842 !! end
3843
3844 !! test
3845 7a. Indent-pre and category links
3846 !! options
3847 parsoid=wt2html,wt2wt
3848 !! wikitext
3849 [[Category:foo]] <!-- No pre-wrapping -->
3850 {{echo| [[Category:foo]]}} <!-- No pre-wrapping -->
3851 !! html/php+tidy
3852 !! html/parsoid
3853 <link rel="mw:PageProp/Category" href="./Category:Foo"> <!-- No pre&#x2D;wrapping -->
3854 <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 -->
3855 !! end
3856
3857 ## We used to, but no longer wt2wt this test since the default serializer
3858 ## will normalize all categories to serialize on their own line.
3859 ## This wikitext usage is going to be fairly uncommon in production and
3860 ## selser will take care of preserving formatting in those scenarios.
3861 !! test
3862 7b. Indent-pre and category links
3863 !! options
3864 parsoid=wt2html
3865 !! wikitext
3866 [[Category:foo]] a
3867 [[Category:foo]] {{echo|b}}
3868 !! html/parsoid
3869 <pre><link rel="mw:PageProp/Category" href="./Category:Foo"> a
3870 <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>
3871 !! end
3872
3873 !! test
3874 Indent-Pre: Newlines in comments shouldn't affect sol state
3875 !! wikitext
3876 a <!--
3877 foo
3878 --> b
3879 !! html/php+tidy
3880 <p>a b
3881 </p>
3882 !! html/parsoid
3883 <p>a <!--
3884 foo
3885 --> b</p>
3886 !! end
3887
3888 ###
3889 ### HTML-pre (some to spec PHP parser behavior and some Parsoid-RT-centric)
3890 ###
3891
3892 !!test
3893 HTML-pre: 1. embedded newlines
3894 !! wikitext
3895 <pre>foo</pre>
3896
3897 <pre>
3898 foo
3899 </pre>
3900
3901 <pre>
3902
3903 foo
3904 </pre>
3905
3906 <pre>
3907
3908
3909 foo
3910 </pre>
3911 !! html/php+tidy
3912 <pre>foo</pre>
3913 <pre>foo
3914 </pre>
3915 <pre>
3916
3917 foo
3918 </pre>
3919 <pre>
3920
3921
3922 foo
3923 </pre>
3924 !! html/parsoid
3925 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo"}}'>foo</pre>
3926
3927 <pre typeof="mw:Extension/pre" about="#mwt4" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\nfoo\n"}}'>foo
3928 </pre>
3929
3930 <pre typeof="mw:Extension/pre" about="#mwt6" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n\nfoo\n"}}'>
3931
3932 foo
3933 </pre>
3934
3935 <pre typeof="mw:Extension/pre" about="#mwt8" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n\n\nfoo\n"}}'>
3936
3937
3938 foo
3939 </pre>
3940 !!end
3941
3942 !! test
3943 HTML-pre: big spaces
3944 !! wikitext
3945 <pre>
3946
3947
3948
3949
3950 haha
3951
3952
3953
3954
3955 haha
3956
3957
3958
3959
3960 </pre>
3961 !! html/php+tidy
3962 <pre>
3963
3964
3965
3966
3967 haha
3968
3969
3970
3971
3972 haha
3973
3974
3975
3976
3977 </pre>
3978 !! html/parsoid
3979 <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"}}'>
3980
3981
3982
3983
3984 haha
3985
3986
3987
3988
3989 haha
3990
3991
3992
3993
3994 </pre>
3995 !! end
3996
3997 !!test
3998 HTML-pre: 2: indented text
3999 !! wikitext
4000 <pre>
4001 foo
4002 </pre>
4003 !! html
4004 <pre>
4005 foo
4006 </pre>
4007
4008 !!end
4009
4010 !!test
4011 HTML-pre: 3: other wikitext
4012 !! wikitext
4013 <pre>
4014 * foo
4015 # bar
4016 = no-h =
4017 '' no-italic ''
4018 [[ NoLink ]]
4019 </pre>
4020 !! html/php
4021 <pre>
4022 * foo
4023 # bar
4024 = no-h =
4025 '' no-italic ''
4026 [[ NoLink ]]
4027 </pre>
4028
4029 !! html/parsoid
4030 <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
4031 # bar
4032 = no-h =
4033 '' no-italic ''
4034 [[ NoLink ]]
4035 </pre>
4036 !!end
4037
4038 ###
4039 ### Definition lists
4040 ###
4041 !! test
4042 Simple definition
4043 !! wikitext
4044 ;name :Definition
4045 !! html
4046 <dl><dt>name</dt>
4047 <dd>Definition</dd></dl>
4048
4049 !! end
4050
4051 !! test
4052 Definition list for indentation only
4053 !! wikitext
4054 :Indented text
4055 !! html
4056 <dl><dd>Indented text</dd></dl>
4057
4058 !! end
4059
4060 !! test
4061 Definition list with no space
4062 !! wikitext
4063 ;name:Definition
4064 !! html
4065 <dl><dt>name</dt>
4066 <dd>Definition</dd></dl>
4067
4068 !!end
4069
4070 !! test
4071 Definition list with URL link
4072 !! wikitext
4073 ;http://example.com/ :definition
4074 !! html
4075 <dl><dt><a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a></dt>
4076 <dd>definition</dd></dl>
4077
4078 !! end
4079
4080 !! test
4081 Definition list with bracketed URL link
4082 !! wikitext
4083 ;[http://www.example.com/ Example]:Something about it
4084 !! html
4085 <dl><dt><a rel="nofollow" class="external text" href="http://www.example.com/">Example</a></dt>
4086 <dd>Something about it</dd></dl>
4087
4088 !! end
4089
4090 !! test
4091 Definition list with wikilink containing colon
4092 !! wikitext
4093 ;[[Help:FAQ]]:The least-read page on Wikipedia
4094 !! html
4095 <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>
4096 <dd>The least-read page on Wikipedia</dd></dl>
4097
4098 !! end
4099
4100 # At Brion's and JeLuF's insistence... :)
4101 !! test
4102 Definition list with news link containing colon
4103 !! wikitext
4104 ;news:alt.wikipedia.rox :This isn't even a real newsgroup!
4105 !! html/php
4106 <dl><dt><a rel="nofollow" class="external free" href="news:alt.wikipedia.rox">news:alt.wikipedia.rox</a></dt>
4107 <dd>This isn't even a real newsgroup!</dd></dl>
4108
4109 !! html/parsoid
4110 <dl><dt><a rel="mw:ExtLink" class="external free" 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>
4111 !! end
4112
4113 !! test
4114 Malformed definition list with colon
4115 !! wikitext
4116 ;news:alt.wikipedia.rox -- don't crash or enter an infinite loop
4117 !! html
4118 <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>
4119
4120 !! end
4121
4122 !! test
4123 Definition lists: colon in external link text
4124 !! wikitext
4125 ;[http://www.wikipedia2.org/ Wikipedia :The Next Generation] :OK, I made that up
4126 !! html
4127 <dl><dt><a rel="nofollow" class="external text" href="http://www.wikipedia2.org/">Wikipedia :The Next Generation</a></dt>
4128 <dd>OK, I made that up</dd></dl>
4129
4130 !! end
4131
4132 !! test
4133 Definition lists: colon in HTML attribute
4134 !! wikitext
4135 ;<b style="display: inline">bold</b>
4136 !! html
4137 <dl><dt><b style="display: inline">bold</b></dt></dl>
4138
4139 !! end
4140
4141 !! test
4142 Definition lists: self-closed tag
4143 !! wikitext
4144 ;one<br/>two :two-line fun
4145 !! html
4146 <dl><dt>one<br />two</dt>
4147 <dd>two-line fun</dd></dl>
4148
4149 !! end
4150
4151 !! test
4152 Definition lists: ignore colons inside tags
4153 !! wikitext
4154 ;one <b>two : tag <i>fun:</i>:</b>:def
4155 !! html
4156 <dl><dt>one <b>two&#160;: tag <i>fun:</i>:</b></dt>
4157 <dd>def</dd></dl>
4158
4159 !! end
4160
4161 !! test
4162 Definition lists: excess closed tags
4163 !! wikitext
4164 ;one</b>two :bad tag fun
4165 !! html/php+tidy
4166 <dl><dt>onetwo</dt>
4167 <dd>bad tag fun</dd></dl>
4168 !! html/parsoid
4169 <dl>
4170 <dt>onetwo</dt>
4171 <dd>bad tag fun</dd>
4172 </dl>
4173 !! end
4174
4175 !! test
4176 T13748: Literal closing tags
4177 !! wikitext
4178 <dl>
4179 <dt>test 1</dt>
4180 <dd>test test test test test</dd>
4181 <dt>test 2</dt>
4182 <dd>test test test test test</dd>
4183 </dl>
4184 !! html
4185 <dl>
4186 <dt>test 1</dt>
4187 <dd>test test test test test</dd>
4188 <dt>test 2</dt>
4189 <dd>test test test test test</dd>
4190 </dl>
4191
4192 !! end
4193
4194 !! test
4195 Definition and unordered list using wiki syntax nested in unordered list using html tags.
4196 !! wikitext
4197 <ul><li>
4198 ;term :description
4199 *unordered
4200 </li></ul>
4201 !! html
4202 <ul><li>
4203 <dl><dt>term</dt>
4204 <dd>description</dd></dl>
4205 <ul><li>unordered</li></ul>
4206 </li></ul>
4207
4208 !! end
4209
4210 !! test
4211 Definition list with empty definition and following paragraph
4212 !! wikitext
4213 ;term:
4214
4215 Paragraph text
4216 !! html
4217 <dl><dt>term</dt>
4218 <dd></dd></dl>
4219 <p>Paragraph text
4220 </p>
4221 !! end
4222
4223 !! test
4224 Nested definition lists using html syntax
4225 !! wikitext
4226 <dl><dt>x</dt>
4227 <dd>a</dd>
4228 <dd>b</dd></dl>
4229 !! html
4230 <dl><dt>x</dt>
4231 <dd>a</dd>
4232 <dd>b</dd></dl>
4233
4234 !! end
4235
4236 !! test
4237 Definition Lists: No nesting: Multiple dd's
4238 !! wikitext
4239 ;x
4240 :a
4241 :b
4242 !! html
4243 <dl><dt>x</dt>
4244 <dd>a</dd>
4245 <dd>b</dd></dl>
4246
4247 !! end
4248
4249 !! test
4250 Definition Lists: Indentation: Regular
4251 !! wikitext
4252 :i1
4253 ::i2
4254 :::i3
4255 !! html
4256 <dl><dd>i1
4257 <dl><dd>i2
4258 <dl><dd>i3</dd></dl></dd></dl></dd></dl>
4259
4260 !! end
4261
4262 !! test
4263 Definition Lists: Indentation: Missing 1st level
4264 !! wikitext
4265 ::i2
4266 :::i3
4267 !! html
4268 <dl><dd><dl><dd>i2
4269 <dl><dd>i3</dd></dl></dd></dl></dd></dl>
4270
4271 !! end
4272
4273 !! test
4274 Definition Lists: Indentation: Multi-level indent
4275 !! wikitext
4276 :::i3
4277 !! html
4278 <dl><dd><dl><dd><dl><dd>i3</dd></dl></dd></dl></dd></dl>
4279
4280 !! end
4281
4282 !! test
4283 Definition Lists: Hacky use to indent tables
4284 !! wikitext
4285 ::{|
4286 |foo
4287 |bar
4288 |}
4289 this text
4290 should be left alone
4291 !! html
4292 <dl><dd><dl><dd><table>
4293 <tr>
4294 <td>foo
4295 </td>
4296 <td>bar
4297 </td></tr></table></dd></dl></dd></dl>
4298 <p>this text
4299 should be left alone
4300 </p>
4301 !! end
4302
4303 !! test
4304 Definition Lists: Hacky use to indent tables (with content following table)
4305 !! wikitext
4306 :{|
4307 |foo
4308 |bar
4309 |} <!--c1--> this text should be part of the dl
4310 !! html/php+tidy
4311 <dl><dd><table>
4312 <tbody><tr>
4313 <td>foo
4314 </td>
4315 <td>bar
4316 </td></tr></tbody></table> this text should be part of the dl</dd></dl>
4317 !! html/parsoid
4318 <dl><dd><table>
4319 <tbody><tr>
4320 <td>foo
4321 </td>
4322 <td>bar
4323 </td></tr></tbody></table> <!--c1--> this text should be part of the dl</dd></dl>
4324 !! end
4325
4326 !! test
4327 Definition Lists: Hacky use to indent tables, with comments (T65979)
4328 !! wikitext
4329 <!-- foo -->
4330 ::{|
4331 |foo
4332 |bar
4333 |}<!-- bar -->
4334 this text
4335 should be left alone
4336 !! html/parsoid
4337 <!-- foo -->
4338 <dl><dd><dl><dd><table><tr>
4339 <td>foo</td>
4340 <td>bar</td>
4341 </tr></table><!-- bar --></dd></dl></dd></dl>
4342 <p>this text
4343 should be left alone</p>
4344 !! end
4345
4346 !! test
4347 Definition Lists: Hacky use to indent tables, with comment before table
4348 !!options
4349 parsoid=wt2html
4350 !! wikitext
4351 ::<!-- foo -->{|
4352 |foo
4353 |}
4354 !! html/parsoid
4355 <dl><dd><dl><dd><!-- foo --><table><tr>
4356 <td>foo</td>
4357 </tr></table></dd></dl></dd></dl>
4358 !! end
4359
4360 # The trailing whitespace in this test is to catch a regression in
4361 # Parsoid after T54473.
4362 !! test
4363 Definition Lists: Hacky use to indent tables (WS-insensitive)
4364 !! wikitext
4365 :{|
4366 |a
4367 |}
4368 !! html/php
4369 <dl><dd><table>
4370 <tr>
4371 <td>a
4372 </td></tr></table></dd></dl>
4373
4374 !! html/parsoid
4375 <dl><dd><table>
4376 <tbody><tr><td>a</td></tr>
4377 </tbody></table></dd></dl>
4378 !! end
4379
4380 ## The PHP parser treats : items (dd) without a corresponding ; item (dt)
4381 ## as an empty dt item. It also ignores all but the last ";" when followed
4382 ## by ":" later on. So, ";" are not ignored in ";;;t3" but are ignored in
4383 ## ";;;t3 :d1". So, PHP parser behavior is a little inconsistent wrt multiple
4384 ## ";"s.
4385 ##
4386 ## Ex: ";;t2 ::d2" is transformed into:
4387 ##
4388 ## <dl>
4389 ## <dt>t2 </dt>
4390 ## <dd>
4391 ## <dl>
4392 ## <dt></dt>
4393 ## <dd>d2</dd>
4394 ## </dl>
4395 ## </dd>
4396 ## </dl>
4397 ##
4398 ## But, Parsoid treats "; :" as a tight atomic unit and excess ":" as plain text
4399 ## So, the same wikitext above (;;t2 ::d2) is transformed into:
4400 ##
4401 ## <dl>
4402 ## <dt>
4403 ## <dl>
4404 ## <dt>t2 </dt>
4405 ## <dd>:d2</dd>
4406 ## </dl>
4407 ## </dt>
4408 ## </dl>
4409 ##
4410 ## All Parsoid only definition list tests have this difference.
4411 ##
4412 ## See also: https://phabricator.wikimedia.org/T8569
4413 ## and https://lists.wikimedia.org/pipermail/wikitext-l/2011-November/000483.html
4414
4415 !! test
4416 Table / list interaction: indented table with lists in table contents
4417 !! wikitext
4418 :{|
4419 |-
4420 |a
4421
4422 *b
4423 |-
4424 |c
4425
4426 *d
4427 |}
4428 !! html
4429 <dl><dd><table>
4430
4431 <tr>
4432 <td>a
4433 <ul><li>b</li></ul>
4434 </td></tr>
4435 <tr>
4436 <td>c
4437 <ul><li>d</li></ul>
4438 </td></tr></table></dd></dl>
4439
4440 !! end
4441
4442 !!test
4443 Table / list interaction: lists nested in tables nested in indented lists
4444 !! wikitext
4445 :{|
4446 |
4447 :a
4448 :b
4449 |
4450 *c
4451 *d
4452 |}
4453
4454 *e
4455 *f
4456 !! html
4457 <dl><dd><table>
4458 <tr>
4459 <td>
4460 <dl><dd>a</dd>
4461 <dd>b</dd></dl>
4462 </td>
4463 <td>
4464 <ul><li>c</li>
4465 <li>d</li></ul>
4466 </td></tr></table></dd></dl>
4467 <ul><li>e</li>
4468 <li>f</li></ul>
4469
4470 !!end
4471
4472 !! test
4473 Definition Lists: Nesting: Multi-level (Parsoid only)
4474 !! wikitext
4475 ;t1 :d1
4476 ;;t2 ::d2
4477 ;;;t3 :::d3
4478 !! html/parsoid
4479 <dl>
4480 <dt>t1 </dt>
4481 <dd>d1</dd>
4482 <dt>
4483 <dl>
4484 <dt>t2 </dt>
4485 <dd>:d2</dd>
4486 <dt>
4487 <dl>
4488 <dt>t3 </dt>
4489 <dd>::d3</dd>
4490 </dl>
4491 </dt>
4492 </dl>
4493 </dt>
4494 </dl>
4495
4496
4497 !! end
4498
4499
4500 !! test
4501 Definition Lists: Nesting: Test 2
4502 !! wikitext
4503 ;t1
4504 ::d2
4505 !! html+tidy
4506 <dl><dt>t1</dt>
4507 <dd>
4508 <dl><dd>d2</dd></dl></dd></dl>
4509 !! end
4510
4511
4512 !! test
4513 Definition Lists: Nesting: Test 3
4514 !! wikitext
4515 :;t1
4516 ::::d2
4517 !! html+tidy
4518 <dl><dd><dl><dt>t1</dt>
4519 <dd>
4520 <dl><dd><dl><dd>d2</dd></dl></dd></dl></dd></dl></dd></dl>
4521 !! end
4522
4523
4524 !! test
4525 Definition Lists: Nesting: Test 4
4526 !! wikitext
4527 ::;t3
4528 :::d3
4529 !! html
4530 <dl><dd><dl><dd><dl><dt>t3</dt>
4531 <dd>d3</dd></dl></dd></dl></dd></dl>
4532
4533 !! end
4534
4535
4536 ## The Parsoid team believes the following three test exposes a
4537 ## bug in the PHP parser. (Parsoid team thinks the PHP parser is
4538 ## wrong to close the <dl> after the <dt> containing the <ul>.)
4539 ## It also exposes a "misfeature" in tidy, which doesn't like
4540 ## <dl> tags with a single <dt> child; it converts the <dt> into
4541 ## a <dd> in that case. (Parsoid leaves the <dt> alone!)
4542 !! test
4543 Definition Lists: Mixed Lists: Test 1
4544 !! wikitext
4545 :;*foo
4546 ::*bar
4547 :;baz
4548 !! html/php
4549 <dl><dd><dl><dt><ul><li>foo</li>
4550 <li>bar</li></ul></dt></dl>
4551 <dl><dt>baz</dt></dl></dd></dl>
4552
4553 !! html/php+tidy
4554 <dl><dd><dl><dt><ul><li>foo</li>
4555 <li>bar</li></ul></dt></dl>
4556 <dl><dt>baz</dt></dl></dd></dl>
4557 !! html/parsoid
4558 <dl>
4559 <dd><dl>
4560 <dt><ul>
4561 <li>foo
4562 </li>
4563 </ul></dt>
4564 <dd><ul>
4565 <li>bar
4566 </li>
4567 </ul></dd>
4568 <dt>baz</dt>
4569 </dl></dd>
4570 </dl>
4571 !! end
4572
4573 !! test
4574 Definition Lists: Mixed Lists: Test 2
4575 !! wikitext
4576 *:d1
4577 *:d2
4578 !! html
4579 <ul><li><dl><dd>d1</dd>
4580 <dd>d2</dd></dl></li></ul>
4581
4582 !! end
4583
4584
4585 !! test
4586 Definition Lists: Mixed Lists: Test 3
4587 !! wikitext
4588 *:::d1
4589 *:::d2
4590 !! html
4591 <ul><li><dl><dd><dl><dd><dl><dd>d1</dd>
4592 <dd>d2</dd></dl></dd></dl></dd></dl></li></ul>
4593
4594 !! end
4595
4596
4597 !! test
4598 Definition Lists: Mixed Lists: Test 4
4599 !! wikitext
4600 *;d1 :d2
4601 *;d3 :d4
4602 !! html
4603 <ul><li><dl><dt>d1</dt>
4604 <dd>d2</dd>
4605 <dt>d3</dt>
4606 <dd>d4</dd></dl></li></ul>
4607
4608 !! end
4609
4610
4611 !! test
4612 Definition Lists: Mixed Lists: Test 5
4613 !! wikitext
4614 *:d1
4615 *::d2
4616 !! html
4617 <ul><li><dl><dd>d1
4618 <dl><dd>d2</dd></dl></dd></dl></li></ul>
4619
4620 !! end
4621
4622
4623 !! test
4624 Definition Lists: Mixed Lists: Test 6
4625 !! wikitext
4626 #*:d1
4627 #*:::d3
4628 !! html
4629 <ol><li><ul><li><dl><dd>d1
4630 <dl><dd><dl><dd>d3</dd></dl></dd></dl></dd></dl></li></ul></li></ol>
4631
4632 !! end
4633
4634
4635 !! test
4636 Definition Lists: Mixed Lists: Test 7
4637 !! wikitext
4638 :*d1
4639 :*d2
4640 !! html
4641 <dl><dd><ul><li>d1</li>
4642 <li>d2</li></ul></dd></dl>
4643
4644 !! end
4645
4646
4647 !! test
4648 Definition Lists: Mixed Lists: Test 8
4649 !! wikitext
4650 :*d1
4651 ::*d2
4652 !! html
4653 <dl><dd><ul><li>d1</li></ul>
4654 <dl><dd><ul><li>d2</li></ul></dd></dl></dd></dl>
4655
4656 !! end
4657
4658
4659 !! test
4660 Definition Lists: Mixed Lists: Test 9
4661 !! wikitext
4662 *;foo :bar
4663 !! html
4664 <ul><li><dl><dt>foo</dt>
4665 <dd>bar</dd></dl></li></ul>
4666
4667 !! end
4668
4669
4670 !! test
4671 Definition Lists: Mixed Lists: Test 10
4672 !! wikitext
4673 *#;foo :bar
4674 !! html
4675 <ul><li><ol><li><dl><dt>foo</dt>
4676 <dd>bar</dd></dl></li></ol></li></ul>
4677
4678 !! end
4679
4680 # The Parsoid team disagrees with the PHP parser's seemingly-random
4681 # rules regarding dd/dt on the next few tests. Parsoid is more
4682 # consistent, and recognizes the shared nesting and keeps the
4683 # still-open tags around until the nesting is complete.
4684
4685 # This is a regression test for T175099
4686 !! test
4687 Definition Lists: Mixed Lists: Test 11
4688 !! wikitext
4689 ;a
4690 :*b
4691 !! html/php
4692 <dl><dt>a</dt>
4693 <dd>
4694 <ul><li>b</li></ul></dd></dl>
4695
4696 !! html/parsoid
4697 <dl><dt>a
4698 <dd><ul><li>b</li></ul></dd></dl>
4699 !! end
4700
4701 # FIXME: Maybe get rid of this test?
4702 !! test
4703 Definition Lists: Mixed Lists: Test 12
4704 !! wikitext
4705 *#*#;*;;foo :bar
4706 *#*#;boo :baz
4707 !! html/php
4708 <ul><li><ol><li><ul><li><ol><li><dl><dt>foo</dt>
4709 <dd><ul><li><dl><dt><dl><dt>bar</dt></dl></dd></dl></li></ul></dd></dl>
4710 <dl><dt>boo</dt>
4711 <dd>baz</dd></dl></li></ol></li></ul></li></ol></li></ul>
4712
4713 !! html/php+tidy
4714 <ul><li><ol><li><ul><li><ol><li><dl><dt>foo</dt>
4715 <dd><ul><li><dl><dt><dl><dt>bar</dt></dl></dt></dl></li></ul></dd></dl></li></ol></li></ul>
4716 <dl><dt>boo</dt>
4717 <dd>baz</dd></dl></li></ol></li></ul>
4718 !! html/parsoid
4719 <ul>
4720 <li>
4721 <ol>
4722 <li>
4723 <ul>
4724 <li>
4725 <ol>
4726 <li>
4727 <dl>
4728 <dt>
4729 <ul>
4730 <li>
4731 <dl>
4732 <dt>
4733 <dl>
4734 <dt>foo</dt>
4735 <dd data-parsoid='{"stx":"row"}'>bar</dd>
4736 </dl></dt>
4737 </dl></li>
4738 </ul></dt>
4739 <dt>boo</dt>
4740 <dd data-parsoid='{"stx":"row"}'>baz</dd>
4741 </dl></li>
4742 </ol></li>
4743 </ul></li>
4744 </ol></li>
4745 </ul>
4746 !! end
4747
4748 !! test
4749 Definition Lists: Mixed Lists: Test 13
4750 !! wikitext
4751 *#*#;*;;foo : bar
4752 *#*#;boo : baz
4753 !! html+tidy
4754 <ul><li><ol><li><ul><li><ol><li><dl><dt>foo&#160;</dt>
4755 <dd><ul><li><dl><dt><dl><dt>bar</dt></dl></dt></dl></li></ul></dd></dl></li></ol></li></ul>
4756 <dl><dt>boo&#160;</dt>
4757 <dd>baz</dd></dl></li></ol></li></ul>
4758 !! end
4759
4760 # FIXME: Maybe get rid of this test?
4761 # From whitelist:
4762 # * The test is wrong, there are two colons where there should be :;
4763 # * The PHP parser is wrong to close the <dl> after the <dt> containing the <ul>.
4764 !! test
4765 Definition Lists: Weird Ones: Test 1
4766 !! wikitext
4767 *#;*::;;foo :bar (who uses this?)
4768 !! html/php+tidy
4769 <ul><li><ol><li><dl><dt>foo</dt>
4770 <dd><ul><li><dl><dd><dl><dd><dl><dt><dl><dt>bar (who uses this?)</dt></dl></dt></dl></dd></dl></dd></dl></li></ul></dd></dl></li></ol></li></ul>
4771 !! html/parsoid
4772 <ul>
4773 <li>
4774 <ol>
4775 <li>
4776 <dl>
4777 <dt>
4778 <ul>
4779 <li>
4780 <dl>
4781 <dd>
4782 <dl>
4783 <dd>
4784 <dl>
4785 <dt>
4786 <dl>
4787 <dt>foo</dt>
4788 <dd data-parsoid='{"stx":"row"}'>bar (who uses this?)</dd>
4789 </dl></dt>
4790 </dl></dd>
4791 </dl></dd>
4792 </dl></li>
4793 </ul></dt>
4794 </dl></li>
4795 </ol></li>
4796 </ul>
4797 !! end
4798
4799 !! test
4800 Definition Lists: colons occurring in tags
4801 !! wikitext
4802 ;a:b
4803 ;'''a:b'''
4804 ;<i>a:b</i>
4805 ;<span>a:b</span>
4806 ;<div>a:b</div>
4807 ;<div>a
4808 :b</div>
4809 ;{{echo|a:b}}
4810 ;{{echo|''a:b''}}
4811 ;;;''a:b''
4812 !! html+tidy
4813 <dl><dt>a</dt>
4814 <dd>b</dd>
4815 <dt><b>a:b</b></dt>
4816 <dt><i>a:b</i></dt>
4817 <dt><span>a:b</span></dt>
4818 <dt><div>a:b</div></dt>
4819 <dt><div>a</div></dt>
4820 <dd>b</dd>
4821 <dt>a</dt>
4822 <dd>b</dd>
4823 <dt><i>a:b</i></dt></dl>
4824 <dl><dt><dl><dt><dl><dt><i>a:b</i></dt></dl></dt></dl></dt></dl>
4825 !! html/parsoid
4826 <dl><dt>a</dt><dd data-parsoid='{"stx":"row"}'>b</dd>
4827 <dt><b>a:b</b></dt>
4828 <dt><i data-parsoid='{"stx":"html"}'>a:b</i></dt>
4829 <dt><span data-parsoid='{"stx":"html"}'>a:b</span></dt>
4830 <dt><div data-parsoid='{"stx":"html"}'>a:b</div></dt>
4831 <dt><div data-parsoid='{"stx":"html","autoInsertedEnd":true}'>a</div></dt>
4832 <dd>b</dd>
4833 <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>
4834 <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>
4835 <dl><dt><dl><dt><i>a:b</i></dt></dl></dt></dl></dt></dl>
4836 !! end
4837
4838 # Parsoid's output differs here again because it shares
4839 # nesting between the two lists unlike the PHP parser.
4840 # Unsure which is more desirable.
4841 !! test
4842 Definition Lists: colons and tables 1
4843 !! wikitext
4844 :{|
4845 |x
4846 |}
4847 :{|
4848 |y
4849 |}
4850 !! html/php
4851 <dl><dd><table>
4852 <tr>
4853 <td>x
4854 </td></tr></table></dd></dl>
4855 <dl><dd><table>
4856 <tr>
4857 <td>y
4858 </td></tr></table></dd></dl>
4859
4860 !! html/parsoid
4861 <dl><dd><table>
4862 <tr>
4863 <td>x
4864 </td></tr></table></dd>
4865 <dd><table>
4866 <tr>
4867 <td>y
4868 </td></tr></table></dd></dl>
4869 !! end
4870
4871 # FIXME: Does this need a html/php section?
4872 !! test
4873 Definition Lists: template interaction
4874 !! wikitext
4875 ::{{definition_list}}
4876
4877 :one
4878 ::{{definition_list}}
4879 :::two
4880 :::three
4881 ::four
4882 !! html/parsoid
4883 <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">
4884 </span><dd about="#mwt1">two</dd></dl></dd></dl>
4885
4886 <dl><dd data-parsoid='{}'>one
4887 <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">
4888 </span><dd about="#mwt2">two
4889 <dl><dd>two</dd>
4890 <dd>three</dd></dl></dd>
4891 <dd data-parsoid='{}'>four</dd></dl></dd></dl>
4892 !! end
4893
4894
4895 ###
4896 ### External links
4897 ###
4898 !! test
4899 External links: non-bracketed
4900 !! wikitext
4901 Non-bracketed: http://example.com
4902 !! html
4903 <p>Non-bracketed: <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
4904 </p>
4905 !! end
4906
4907 # parsoid doesn't explicitly mark autonumbered links, see T55505
4908 !! test
4909 External links: numbered
4910 !! wikitext
4911 Numbered: [http://example.com]
4912 Numbered: [http://example.net]
4913 Numbered: [http://example.com]
4914 !! html/php
4915 <p>Numbered: <a rel="nofollow" class="external autonumber" href="http://example.com">[1]</a>
4916 Numbered: <a rel="nofollow" class="external autonumber" href="http://example.net">[2]</a>
4917 Numbered: <a rel="nofollow" class="external autonumber" href="http://example.com">[3]</a>
4918 </p>
4919 !! html/parsoid
4920 <p>Numbered: <a rel="mw:ExtLink" class="external autonumber" href="http://example.com"></a>
4921 Numbered: <a rel="mw:ExtLink" class="external autonumber" href="http://example.net"></a>
4922 Numbered: <a rel="mw:ExtLink" class="external autonumber" href="http://example.com"></a></p>
4923 !!end
4924
4925 !! test
4926 External links: specified text
4927 !! wikitext
4928 Specified text: [http://example.com link]
4929 !! html
4930 <p>Specified text: <a rel="nofollow" class="external text" href="http://example.com">link</a>
4931 </p>
4932 !!end
4933
4934 !! test
4935 External links: trail
4936 !! wikitext
4937 Linktrails should not work for external links: [http://example.com link]s
4938 !! html
4939 <p>Linktrails should not work for external links: <a rel="nofollow" class="external text" href="http://example.com">link</a>s
4940 </p>
4941 !! end
4942
4943 !! test
4944 External links: dollar sign in URL
4945 !! wikitext
4946 http://example.com/1$2345
4947 !! html
4948 <p><a rel="nofollow" class="external free" href="http://example.com/1$2345">http://example.com/1$2345</a>
4949 </p>
4950 !! end
4951
4952 # parsoid doesn't explicitly mark autonumbered links, see T55505
4953 !! test
4954 External links: dollar sign in URL (autonumber)
4955 !! wikitext
4956 [http://example.com/1$2345]
4957 !! html/php
4958 <p><a rel="nofollow" class="external autonumber" href="http://example.com/1$2345">[1]</a>
4959 </p>
4960 !! html/parsoid
4961 <p><a rel="mw:ExtLink" class="external autonumber" href="http://example.com/1$2345"></a></p>
4962 !!end
4963
4964 !! test
4965 External links: open square bracket forbidden in URL (T6377)
4966 !! options
4967 parsoid=wt2html,wt2wt,html2html
4968 !! wikitext
4969 http://example.com/1[2345
4970 !! html/php
4971 <p><a rel="nofollow" class="external free" href="http://example.com/1">http://example.com/1</a>[2345
4972 </p>
4973 !! html/parsoid
4974 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/1">http://example.com/1</a>[2345</p>
4975 !! end
4976
4977 !! test
4978 External links: open square bracket forbidden in URL (named) (T6377)
4979 !! options
4980 parsoid=wt2html,html2html
4981 !! wikitext
4982 [http://example.com/1[2345]
4983 !! html/php
4984 <p><a rel="nofollow" class="external text" href="http://example.com/1">[2345</a>
4985 </p>
4986 !! html/parsoid
4987 <p><a rel="mw:ExtLink" class="external text" href="http://example.com/1">[2345</a></p>
4988 !!end
4989
4990 # parsoid adds a space before the link name
4991 !! test
4992 External links: open square bracket forbidden in URL (named) (T6377)
4993 Parsoid variant.
4994 !! wikitext
4995 [http://example.com/1 [2345]
4996 !! html
4997 <p><a rel="nofollow" class="external text" href="http://example.com/1">[2345</a>
4998 </p>
4999 !!end
5000
5001 !! test
5002 External links: nowiki in URL link text (T8230)
5003 !! wikitext
5004 [http://example.com/ <nowiki>''example site''</nowiki>]
5005 !! html
5006 <p><a rel="nofollow" class="external text" href="http://example.com/">''example site''</a>
5007 </p>
5008 !! end
5009
5010 !! test
5011 External links: newline forbidden in text (T8230 regression check)
5012 !! wikitext
5013 [http://example.com/ first
5014 second]
5015 !! html
5016 <p>[<a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a> first
5017 second]
5018 </p>
5019 !!end
5020
5021 !! test
5022 External links: Pipe char between url and text
5023 !! wikitext
5024 [http://example.com | link]
5025 !! html
5026 <p><a rel="nofollow" class="external text" href="http://example.com">| link</a>
5027 </p>
5028 !!end
5029
5030 !! test
5031 External links: protocol-relative URL in brackets
5032 !! wikitext
5033 [//example.com/ Test]
5034 !! html
5035 <p><a rel="nofollow" class="external text" href="//example.com/">Test</a>
5036 </p>
5037 !! end
5038
5039 # parsoid doesn't explicitly mark autonumbered links, see T55505
5040 !! test
5041 External links: protocol-relative URL in brackets without text
5042 !! wikitext
5043 [//example.com]
5044 !! html/php
5045 <p><a rel="nofollow" class="external autonumber" href="//example.com">[1]</a>
5046 </p>
5047 !! html/parsoid
5048 <p><a rel="mw:ExtLink" class="external autonumber" href="//example.com"></a></p>
5049 !! end
5050
5051 !! test
5052 External links: protocol-relative URL in free text is left alone
5053 !! wikitext
5054 //example.com/Foo
5055 !! html
5056 <p>//example.com/Foo
5057 </p>
5058 !!end
5059
5060 !! test
5061 External links: protocol-relative URL in the middle of a word is left alone (T32269)
5062 !! wikitext
5063 foo//example.com/Foo
5064 !! html
5065 <p>foo//example.com/Foo
5066 </p>
5067 !! end
5068
5069 ## html2wt and html2html will fail because we will prefer the :en: interwiki prefix over wikipedia:
5070 !! test
5071 External links: with no contents
5072 !! options
5073 parsoid=wt2html,wt2wt
5074 !! wikitext
5075 [http://en.wikipedia.org/wiki/Foo]
5076
5077 [[wikipedia:Foo|Bar]]
5078
5079 [[wikipedia:Foo|<span>Bar</span>]]
5080 !! html/php
5081 <p><a rel="nofollow" class="external autonumber" href="http://en.wikipedia.org/wiki/Foo">[1]</a>
5082 </p><p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo">Bar</a>
5083 </p><p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo"><span>Bar</span></a>
5084 </p>
5085 !! html/parsoid
5086 <p><a rel="mw:ExtLink" class="external autonumber" href="http://en.wikipedia.org/wiki/Foo"></a></p>
5087 <p><a rel="mw:WikiLink/Interwiki" href="http://en.wikipedia.org/wiki/Foo" title="wikipedia:Foo">Bar</a></p>
5088 <p><a rel="mw:WikiLink/Interwiki" href="http://en.wikipedia.org/wiki/Foo" title="wikipedia:Foo"><span>Bar</span></a></p>
5089 !! end
5090
5091 !! test
5092 External links: Free with trailing punctuation
5093 !! wikitext
5094 http://example.com,
5095 http://example.com;
5096 http://example.com\
5097 http://example.com.
5098 http://example.com:
5099 http://example.com!
5100 http://example.com?
5101 http://example.com)
5102 http://example.com/url_with_(brackets)
5103 (http://example.com/url_without_brackets)
5104 http://example.com/url_with_entity&amp;
5105 http://example.com/url_with_entity&#x26;
5106 http://example.com/url_with_entity&#038;
5107 http://example.com/url_with_entity&nbsp;
5108 http://example.com/url_with_entity&#xA0;
5109 http://example.com/url_with_entity&#160;
5110 http://example.com/url_with_entity&lt;
5111 http://example.com/url_with_entity&#x3C;
5112 http://example.com/url_with_entity&#60;
5113 !! html/php
5114 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>,
5115 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>;
5116 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>\
5117 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>.
5118 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>:
5119 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>!
5120 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>?
5121 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
5122 <a rel="nofollow" class="external free" href="http://example.com/url_with_(brackets)">http://example.com/url_with_(brackets)</a>
5123 (<a rel="nofollow" class="external free" href="http://example.com/url_without_brackets">http://example.com/url_without_brackets</a>)
5124 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
5125 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
5126 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
5127 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#160;
5128 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#xa0;
5129 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#160;
5130 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&lt;
5131 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#x3c;
5132 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#60;
5133 </p>
5134 !! html/parsoid
5135 <p><a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>,
5136 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>;
5137 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>\
5138 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>.
5139 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>:
5140 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>!
5141 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>?
5142 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>)
5143 <a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_(brackets)">http://example.com/url_with_(brackets)</a>
5144 (<a rel="mw:ExtLink" class="external free" href="http://example.com/url_without_brackets">http://example.com/url_without_brackets</a>)
5145 <a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
5146 <a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
5147 <a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
5148 <a rel="mw:ExtLink" class="external free" 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>
5149 <a rel="mw:ExtLink" class="external free" 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>
5150 <a rel="mw:ExtLink" class="external free" 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>
5151 <a rel="mw:ExtLink" class="external free" 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>
5152 <a rel="mw:ExtLink" class="external free" 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>
5153 <a rel="mw:ExtLink" class="external free" 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>
5154 !! end
5155
5156 !! test
5157 External links: tricky Parsoid html2html case
5158 !! options
5159 parsoid=wt2html,wt2wt,html2html
5160 !! wikitext
5161 http://example.com/url_with_entity&amp;amp;
5162 !! html/php
5163 <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>;
5164 </p>
5165 !! html/parsoid
5166 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_entity&amp;amp">http://example.com/url_with_entity&amp;amp</a>;</p>
5167 !! end
5168
5169 !! test
5170 External links: Free with trailing quotes (T113666)
5171 !! wikitext
5172 '''News:''' Stuff here
5173
5174 news:'a'b''c''d e
5175 !! html/php
5176 <p><b>News:</b> Stuff here
5177 </p><p><a rel="nofollow" class="external free" href="news:&#39;a&#39;b">news:'a'b</a><i>c</i>d e
5178 </p>
5179 !! html/parsoid
5180 <p><b>News:</b> Stuff here</p>
5181 <p><a rel="mw:ExtLink" class="external free" href="news:'a'b">news:'a'b</a><i>c</i>d e</p>
5182 !! end
5183
5184 !! test
5185 External links: with entity
5186 !! wikitext
5187 [http://&#x20;www.librarieswithoutborders.org Libraries without borders]
5188 !! html/php
5189 <p><a rel="nofollow" class="external text" href="http://+www.librarieswithoutborders.org">Libraries without borders</a>
5190 </p>
5191 !! html/parsoid
5192 <p><a rel="mw:ExtLink" class="external text" 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>
5193 !! end
5194
5195 !! test
5196 External links: Lone protocols are never linked (T105697)
5197 !! wikitext
5198 http://
5199 http://;
5200 (http://)
5201 bitcoin:
5202 bitcoin:;
5203 (bitcoin:)
5204 !! html
5205 <p>http://
5206 http://;
5207 (http://)
5208 bitcoin:
5209 bitcoin:;
5210 (bitcoin:)
5211 </p>
5212 !! end
5213
5214 !! test
5215 External links: No preceding word characters allowed (T67278)
5216 !! wikitext
5217 NOPEhttp://example.com
5218 N0http://example.com
5219 ok:http://example.com
5220 ok-http://example.com
5221 !! html
5222 <p>NOPEhttp://example.com
5223 N0http://example.com
5224 ok:<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
5225 ok-<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
5226 </p>
5227 !! end
5228
5229 !! test
5230 External links: nofollow domain exception
5231 !! wikitext
5232 A [https://no-nofollow.org/foobar link], and another [https://example.org link].
5233 !! html
5234 <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>.
5235 </p>
5236 !!end
5237
5238 !! test
5239 External image
5240 !! wikitext
5241 External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
5242 !! html
5243 <p>External image: <img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png"/>
5244 </p>
5245 !! end
5246
5247 !! test
5248 External image from https
5249 !! wikitext
5250 External image from https: https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
5251 !! html
5252 <p>External image from https: <img src="https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png"/>
5253 </p>
5254 !! end
5255
5256 !! test
5257 External image (when not allowed)
5258 !! options
5259 wgAllowExternalImages=0
5260 !! wikitext
5261 External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
5262 !! html
5263 <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>
5264 </p>
5265 !! end
5266
5267 !! test
5268 Link to non-http image, no img tag
5269 !! wikitext
5270 Link to non-http image, no img tag: ftp://example.com/test.jpg
5271 !! html
5272 <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>
5273 </p>
5274 !! end
5275
5276 !! test
5277 External links: terminating separator
5278 !! wikitext
5279 Terminating separator: http://example.com/thing,
5280 !! html
5281 <p>Terminating separator: <a rel="nofollow" class="external free" href="http://example.com/thing">http://example.com/thing</a>,
5282 </p>
5283 !! end
5284
5285 !! test
5286 External links: intervening separator
5287 !! wikitext
5288 Intervening separator: http://example.com/1,2,3
5289 !! html
5290 <p>Intervening separator: <a rel="nofollow" class="external free" href="http://example.com/1,2,3">http://example.com/1,2,3</a>
5291 </p>
5292 !! end
5293
5294 !! test
5295 External links: old bug with URL in query
5296 !! wikitext
5297 Old bug with URL in query: [http://example.com/thing?url=http://example.com link]
5298 !! html
5299 <p>Old bug with URL in query: <a rel="nofollow" class="external text" href="http://example.com/thing?url=http://example.com">link</a>
5300 </p>
5301 !! end
5302
5303 !! test
5304 External links: old URL-in-URL bug, mixed protocols
5305 !! wikitext
5306 And again with mixed protocols: [ftp://example.com?url=http://example.com link]
5307 !! html
5308 <p>And again with mixed protocols: <a rel="nofollow" class="external text" href="ftp://example.com?url=http://example.com">link</a>
5309 </p>
5310 !!end
5311
5312 # Since Parsoid is starting to emit canonical wikitext for links,
5313 # [http://example.com http://example.com] will not RT back to that
5314 # form anymore.
5315 !! test
5316 External links: URL in text
5317 !! options
5318 parsoid=wt2html
5319 !! wikitext
5320 URL in text: [http://example.com http://example.com]
5321 !! html/php
5322 <p>URL in text: <a rel="nofollow" class="external text" href="http://example.com">http://example.com</a>
5323 </p>
5324 !! html/parsoid
5325 <p>URL in text: <a rel="mw:ExtLink" class="external text" href="http://example.com">http://example.com</a></p>
5326 !! end
5327
5328 !! test
5329 External links: Clickable images
5330 !! wikitext
5331 ja-style clickable images: [http://example.com http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png]
5332 !! html/php
5333 <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>
5334 </p>
5335 !! html/parsoid
5336 <p>ja-style clickable images: <a rel="mw:ExtLink" class="external text" href="http://example.com"><img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png" data-parsoid='{"type":"extlink"}'/></a></p>
5337 !! end
5338
5339 !! test
5340 External links: raw ampersand
5341 !! wikitext
5342 Old &amp; use: http://x&y
5343 !! html
5344 <p>Old &amp; use: <a rel="nofollow" class="external free" href="http://x&amp;y">http://x&amp;y</a>
5345 </p>
5346 !! end
5347
5348 !! test
5349 External links: encoded ampersand
5350 !! wikitext
5351 Old &amp; use: http://x&amp;y
5352 !! html/php
5353 <p>Old &amp; use: <a rel="nofollow" class="external free" href="http://x&amp;y">http://x&amp;y</a>
5354 </p>
5355 !! html/parsoid
5356 <p>Old <span typeof="mw:Entity">&amp;</span> use: <a rel="mw:ExtLink" class="external free" href="http://x&amp;y">http://x&amp;y</a></p>
5357 !! end
5358
5359 !! test
5360 External links: encoded equals (T8102)
5361 !! wikitext
5362 http://example.com/?foo&#61;bar
5363 !! html/php
5364 <p><a rel="nofollow" class="external free" href="http://example.com/?foo=bar">http://example.com/?foo=bar</a>
5365 </p>
5366 !! html/parsoid
5367 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/?foo=bar">http://example.com/?foo=bar</a></p>
5368 !! end
5369
5370 ##
5371 ## Note that parsoid doesn't explicit mark autonumbered links, nor
5372 ## does it number them. As discussed in T55505, we can identify
5373 ## autonumbered links via CSS.
5374 ##
5375
5376 !! test
5377 External links: [raw ampersand]
5378 !! wikitext
5379 Old &amp; use: [http://x&y]
5380 !! html/php
5381 <p>Old &amp; use: <a rel="nofollow" class="external autonumber" href="http://x&amp;y">[1]</a>
5382 </p>
5383 !! html/parsoid
5384 <p>Old <span typeof="mw:Entity">&amp;</span> use: <a rel="mw:ExtLink" class="external autonumber" href="http://x&amp;y"></a></p>
5385 !! end
5386
5387 # note that parsoid html is identical to [raw ampersand] case; so html2wt
5388 # mode will return the [raw ampersand] wikitext
5389 !! test
5390 External links: [encoded ampersand]
5391 !! options
5392 parsoid=wt2html,wt2wt,html2html
5393 !! wikitext
5394 Old &amp; use: [http://x&amp;y]
5395 !! html/php
5396 <p>Old &amp; use: <a rel="nofollow" class="external autonumber" href="http://x&amp;y">[1]</a>
5397 </p>
5398 !! html/parsoid
5399 <p>Old <span typeof="mw:Entity">&amp;</span> use: <a rel="mw:ExtLink" class="external autonumber" href="http://x&amp;y"></a></p>
5400 !! end
5401
5402 !! test
5403 External links: [raw equals]
5404 !! wikitext
5405 [http://example.com/?foo=bar]
5406 !! html/php
5407 <p><a rel="nofollow" class="external autonumber" href="http://example.com/?foo=bar">[1]</a>
5408 </p>
5409 !! html/parsoid
5410 <p><a rel="mw:ExtLink" class="external autonumber" href="http://example.com/?foo=bar"></a></p>
5411 !! end
5412
5413 # note that parsoid html is identical to [raw equals] case; so html2wt
5414 # mode will return the [raw equals] wikitext
5415 !! test
5416 External links: [encoded equals] (T8102)
5417 !! options
5418 parsoid=wt2html,wt2wt,html2html
5419 !! wikitext
5420 [http://example.com/?foo&#61;bar]
5421 !! html/php
5422 <p><a rel="nofollow" class="external autonumber" href="http://example.com/?foo=bar">[1]</a>
5423 </p>
5424 !! html/parsoid
5425 <p><a rel="mw:ExtLink" class="external autonumber" href="http://example.com/?foo=bar"></a></p>
5426 !! end
5427
5428 # xxx parsoid strips the IDN character, so the round-trip tests will
5429 # obviously fail and are disabled. --cscott
5430 !! test
5431 External links: [IDN ignored character reference in hostname; strip it right off]
5432 !! options
5433 parsoid=wt2html,wt2wt,html2html
5434 !! wikitext
5435 [http://e&zwnj;xample.com/]
5436 !! html/php
5437 <p><a rel="nofollow" class="external autonumber" href="http://example.com/">[1]</a>
5438 </p>
5439 !! html/parsoid
5440 <p><a rel="mw:ExtLink" class="external autonumber" href="http://example.com/"></a></p>
5441 !! end
5442
5443 # FIXME: This test (the IDN characters in the text of a link) is an inconsistency.
5444 # Where an external link could easily circumvent the sanitization of the text of
5445 # a link like this (where an IDN-ignore character is in the URL somewhere), this
5446 # test demands a higher standard. That's a bit strange.
5447 #
5448 # Example:
5449 #
5450 # http://e‌xample.com -> [http://example.com|http://example.com]
5451 # [http://example.com|http://e‌xample.com] -> [http://example.com|http://e‌xample.com]
5452 #
5453 # The first example is sanitized, but the second is not. Any security benefits
5454 # from this production are trivial to circumvent. Either remove this test and
5455 # let the parser(s) do their thing unaccosted, or fix the inconsistency and change
5456 # the test accordingly.
5457 #
5458 # All our love,
5459 # The Parsoid team.
5460 # xxx parsoid strips the IDN character, so the round-trip tests will
5461 # obviously fail and are disabled. --cscott
5462 !! test
5463 External links: IDN ignored character reference in hostname; strip it right off
5464 !! options
5465 parsoid=wt2html,html2html
5466 !! wikitext
5467 http://e&zwnj;xample.com/
5468 !! html/php
5469 <p><a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a>
5470 </p>
5471 !! html/parsoid
5472 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/">http://example.com/</a></p>
5473 !! end
5474
5475 !! test
5476 External links: www.jpeg.org (T2554)
5477 !! wikitext
5478 http://www.jpeg.org
5479 !! html
5480 <p><a rel="nofollow" class="external free" href="http://www.jpeg.org">http://www.jpeg.org</a>
5481 </p>
5482 !! end
5483
5484 # parsoid doesn't explicitly mark autonumbered links, see T55505
5485 !! test
5486 External links: URL within URL (T2002)
5487 !! wikitext
5488 [http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp]
5489 !! html/php
5490 <p><a rel="nofollow" class="external autonumber" href="http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp">[1]</a>
5491 </p>
5492 !! html/parsoid
5493 <p><a rel="mw:ExtLink" class="external autonumber" href="http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp"></a></p>
5494 !! end
5495
5496 !! test
5497 T2361: URL inside bracketed URL
5498 !! wikitext
5499 [http://www.example.com/foo http://www.example.com/bar]
5500 !! html
5501 <p><a rel="nofollow" class="external text" href="http://www.example.com/foo">http://www.example.com/bar</a>
5502 </p>
5503 !! end
5504
5505 !! test
5506 T2361: URL within URL, not bracketed
5507 !! wikitext
5508 http://www.example.com/foo?=http://www.example.com/bar
5509 !! html
5510 <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>
5511 </p>
5512 !! end
5513
5514 !! test
5515 T2289: ">"-token in URL-tail
5516 !! wikitext
5517 http://www.example.com/<hello>
5518 !! html
5519 <p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a>&lt;hello&gt;
5520 </p>
5521 !!end
5522
5523 !! test
5524 T2289: literal ">"-token in URL-tail
5525 !! wikitext
5526 http://www.example.com/<b>html</b>
5527 !! html/php
5528 <p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a><b>html</b>
5529 </p>
5530 !! html/parsoid
5531 <p><a rel="mw:ExtLink" class="external free" href="http://www.example.com/" data-parsoid='{"stx":"url"}'>http://www.example.com/</a><b data-parsoid='{"stx":"html"}'>html</b></p>
5532 !! end
5533
5534 !! test
5535 T2289: ">"-token in bracketed URL
5536 !! wikitext
5537 [http://www.example.com/<hello> stuff]
5538 !! html
5539 <p><a rel="nofollow" class="external text" href="http://www.example.com/">&lt;hello&gt; stuff</a>
5540 </p>
5541 !!end
5542
5543 !! test
5544 T2289: literal ">"-token in bracketed URL
5545 !! wikitext
5546 [http://www.example.com/<b>html</b> stuff]
5547 !! html
5548 <p><a rel="nofollow" class="external text" href="http://www.example.com/"><b>html</b> stuff</a>
5549 </p>
5550 !!end
5551
5552 !! test
5553 T2289: literal double quote at end of URL
5554 !! wikitext
5555 http://www.example.com/"hello"
5556 !! html
5557 <p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a>"hello"
5558 </p>
5559 !!end
5560
5561 !! test
5562 T2289: literal double quote in bracketed URL
5563 !! wikitext
5564 [http://www.example.com/"hello" stuff]
5565 !! html
5566 <p><a rel="nofollow" class="external text" href="http://www.example.com/">"hello" stuff</a>
5567 </p>
5568 !!end
5569
5570 !! test
5571 External links: multiple legal whitespace is fine, Magnus. Don't break it please. (T7081)
5572 !! wikitext
5573 [http://www.example.com test]
5574 !! html
5575 <p><a rel="nofollow" class="external text" href="http://www.example.com">test</a>
5576 </p>
5577 !! end
5578
5579 !! test
5580 External links: link text with spaces
5581 !! wikitext
5582 [http://www.example.com a b c]
5583 [http://www.example.com ''a'' ''b'']
5584 !! html
5585 <p><a rel="nofollow" class="external text" href="http://www.example.com">a b c</a>
5586 <a rel="nofollow" class="external text" href="http://www.example.com"><i>a</i> <i>b</i></a>
5587 </p>
5588 !! end
5589
5590 # Note edge case difference between PHP and Parsoid here.
5591 !! test
5592 External links: wiki links within external link (T5695)
5593 !! options
5594 parsoid=wt2html,html2html
5595 !! wikitext
5596 [http://example.com [[wikilink]] embedded in ext link]
5597
5598 [http://example.com test [[wikilink]] embedded in ext link]
5599 !! html/php
5600 <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>
5601 </p><p><a rel="nofollow" class="external text" href="http://example.com">test </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>
5602 </p>
5603 !! html/parsoid
5604 <p><a rel="mw:ExtLink" class="external autonumber" href="http://example.com"></a><a rel="mw:WikiLink" href="./Wikilink" title="Wikilink">wikilink</a><span> embedded in ext link</span></p>
5605 <p><a rel="mw:ExtLink" class="external text" href="http://example.com">test </a><a rel="mw:WikiLink" href="./Wikilink" title="Wikilink">wikilink</a><span> embedded in ext link</span></p>
5606 !! end
5607
5608 !! test
5609 T2787: Links with one slash after the url protocol are invalid
5610 !! wikitext
5611 http:/example.com
5612
5613 [http:/example.com title]
5614 !! html
5615 <p>http:/example.com
5616 </p><p>[http:/example.com title]
5617 </p>
5618 !! end
5619
5620 !! test
5621 Bracketed external links with template-generated invalid target
5622 !! wikitext
5623 [{{echo|http:/example.com}} title]
5624 !! html
5625 <p>[http:/example.com title]
5626 </p>
5627 !! end
5628
5629 # wt2html only because Parsoid would want to add <nowiki>s coming from html
5630 !! test
5631 Broken wikilinks (but not external links) prevent templates from closing
5632 !! options
5633 parsoid=wt2html
5634 !! wikitext
5635 [http://example.com x
5636
5637 {{echo|[http://example.com x}}
5638
5639 [[Foo
5640
5641 {{echo|[[Foo}}
5642 !! html/php
5643 <p>[<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> x
5644 </p><p>[<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> x
5645 </p><p>[[Foo
5646 </p><p>{{echo|[[Foo}}
5647 </p>
5648 !! html/parsoid
5649 <p>[<a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a> x</p>
5650 <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" class="external free" href="http://example.com">http://example.com</a> x</p>
5651 <p>[[Foo</p>
5652 <p>{{echo|[[Foo}}</p>
5653 !! end
5654
5655 !! test
5656 Wikilinks with embedded newlines are not broken
5657 !! wikitext
5658 {{echo|[[ Foo
5659 B
5660 C]]}}
5661 !! html/php
5662 <p>[[ Foo
5663 B
5664 C]]
5665 </p>
5666 !! html/parsoid
5667 <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>
5668 !! end
5669
5670 !! test
5671 Broken templates
5672 !! options
5673 parsoid=wt2html
5674 !! wikitext
5675 {{echo|[[Foo|}}]]
5676
5677 [[Foo|{{echo|]]}}
5678 !! html/php
5679 <p>{{echo|<a href="/wiki/Foo" title="Foo">}}</a>
5680 </p><p>[[Foo|]]
5681 </p>
5682 !! html/parsoid
5683 <p>{{echo|<a rel="mw:WikiLink" href="./Foo" title="Foo">}}</a></p>
5684 <p>[[Foo|<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"]]"}},"i":0}}]}'>]]</span></p>
5685 !! end
5686
5687 !! test
5688 T4702: Mismatched <i>, <b> and <a> tags are invalid
5689 !! wikitext
5690 ''[http://example.com text'']
5691 [http://example.com '''text]'''
5692 ''Something [http://example.com in italic'']
5693 ''Something [http://example.com mixed''''', even bold]'''
5694 '''''Now [http://example.com both''''']
5695 !! html
5696 <p><a rel="nofollow" class="external text" href="http://example.com"><i>text</i></a>
5697 <a rel="nofollow" class="external text" href="http://example.com"><b>text</b></a>
5698 <i>Something </i><a rel="nofollow" class="external text" href="http://example.com"><i>in italic</i></a>
5699 <i>Something </i><a rel="nofollow" class="external text" href="http://example.com"><i>mixed</i><b>, even bold</b></a>
5700 <i><b>Now </b></i><a rel="nofollow" class="external text" href="http://example.com"><i><b>both</b></i></a>
5701 </p>
5702 !! end
5703
5704
5705 !! test
5706 T6781: %26 in URL
5707 !! wikitext
5708 http://www.example.com/?title=AT%26T
5709 !! html/php
5710 <p><a rel="nofollow" class="external free" href="http://www.example.com/?title=AT%26T">http://www.example.com/?title=AT%26T</a>
5711 </p>
5712 !! html/parsoid
5713 <p><a rel="mw:ExtLink" class="external free" href="http://www.example.com/?title=AT%26T">http://www.example.com/?title=AT%26T</a></p>
5714 !! end
5715
5716 # According to https://www.w3.org/TR/2011/WD-html5-20110525/Overview.html#parsing-urls a plain
5717 # % is actually legal in HTML5. Any change in output would need testing though.
5718 !! test
5719 T6781, T7267: %25 in URL
5720 !! wikitext
5721 http://www.example.com/?title=100%25_Bran
5722 !! html/php
5723 <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>
5724 </p>
5725 !! html/parsoid
5726 <p><a rel="mw:ExtLink" class="external free" href="http://www.example.com/?title=100%25_Bran">http://www.example.com/?title=100%25_Bran</a></p>
5727 !! end
5728
5729 !! test
5730 T6781, T7267: %28, %29 in URL
5731 !! wikitext
5732 http://www.example.com/?title=Ben-Hur_%281959_film%29
5733 !! html/php
5734 <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>
5735 </p>
5736 !! html/parsoid
5737 <p><a rel="mw:ExtLink" 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></p>
5738 !! end
5739
5740
5741 !! test
5742 T6781: %26 in autonumber URL
5743 !! wikitext
5744 [http://www.example.com/?title=AT%26T]
5745 !! html/php
5746 <p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=AT%26T">[1]</a>
5747 </p>
5748 !! html/parsoid
5749 <p><a rel="mw:ExtLink" class="external autonumber" href="http://www.example.com/?title=AT%26T"></a></p>
5750 !! end
5751
5752 !! test
5753 T6781, T7267: %26 in autonumber URL
5754 !! wikitext
5755 [http://www.example.com/?title=100%25_Bran]
5756 !! html/php
5757 <p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=100%25_Bran">[1]</a>
5758 </p>
5759 !! html/parsoid
5760 <p><a rel="mw:ExtLink" class="external autonumber" href="http://www.example.com/?title=100%25_Bran"></a></p>
5761 !! end
5762
5763 !! test
5764 T6781, T7267: %28, %29 in autonumber URL
5765 !! wikitext
5766 [http://www.example.com/?title=Ben-Hur_%281959_film%29]
5767 !! html/php
5768 <p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">[1]</a>
5769 </p>
5770 !! html/parsoid
5771 <p><a rel="mw:ExtLink" class="external autonumber" href="http://www.example.com/?title=Ben-Hur_%281959_film%29"></a></p>
5772 !! end
5773
5774
5775 !! test
5776 T6781: %26 in bracketed URL
5777 !! wikitext
5778 [http://www.example.com/?title=AT%26T link]
5779 !! html/php
5780 <p><a rel="nofollow" class="external text" href="http://www.example.com/?title=AT%26T">link</a>
5781 </p>
5782 !! html/parsoid
5783 <p><a rel="mw:ExtLink" class="external text" href="http://www.example.com/?title=AT%26T">link</a></p>
5784 !! end
5785
5786 !! test
5787 T6781, T7267: %25 in bracketed URL
5788 !! wikitext
5789 [http://www.example.com/?title=100%25_Bran link]
5790 !! html
5791 <p><a rel="nofollow" class="external text" href="http://www.example.com/?title=100%25_Bran">link</a>
5792 </p>
5793 !! end
5794
5795 !! test
5796 T6781, T7267: %28, %29 in bracketed URL
5797 !! wikitext
5798 [http://www.example.com/?title=Ben-Hur_%281959_film%29 link]
5799 !! html/php
5800 <p><a rel="nofollow" class="external text" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">link</a>
5801 </p>
5802 !! html/parsoid
5803 <p><a rel="mw:ExtLink" class="external text" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">link</a></p>
5804 !! end
5805
5806 !! test
5807 External link containing a period in the anchor. (T65947)
5808 !! wikitext
5809 [//foo.org/bar#baz. bang]
5810
5811 [//foo.org/bar. bang]
5812 !! html/php
5813 <p><a rel="nofollow" class="external text" href="//foo.org/bar#baz.">bang</a>
5814 </p><p><a rel="nofollow" class="external text" href="//foo.org/bar.">bang</a>
5815 </p>
5816 !! html/parsoid
5817 <p><a rel="mw:ExtLink" class="external text" href="//foo.org/bar#baz.">bang</a></p>
5818 <p><a rel="mw:ExtLink" class="external text" href="//foo.org/bar.">bang</a></p>
5819 !! end
5820
5821 !! test
5822 External link containing a single quote. (T65947)
5823 !! wikitext
5824 [//foo.org/bar'baz]
5825
5826 [//foo.org/bar'baz bang]
5827 !! html/php
5828 <p><a rel="nofollow" class="external autonumber" href="//foo.org/bar&#39;baz">[1]</a>
5829 </p><p><a rel="nofollow" class="external text" href="//foo.org/bar&#39;baz">bang</a>
5830 </p>
5831 !! html/parsoid
5832 <p><a rel="mw:ExtLink" class="external autonumber" href="//foo.org/bar'baz"></a></p>
5833 <p><a rel="mw:ExtLink" class="external text" href="//foo.org/bar'baz">bang</a></p>
5834 !! end
5835
5836 !! test
5837 External link containing double-single-quotes in text '' (T6598 sanity check)
5838 !! wikitext
5839 Some [http://example.com/ pretty ''italics'' and stuff]!
5840 !! html
5841 <p>Some <a rel="nofollow" class="external text" href="http://example.com/">pretty <i>italics</i> and stuff</a>!
5842 </p>
5843 !! end
5844
5845 !! test
5846 External link containing double-single-quotes in text embedded in italics (T6598 sanity check)
5847 !! wikitext
5848 ''Some [http://example.com/ pretty ''italics'' and stuff]!''
5849 !! html
5850 <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>
5851 </p>
5852 !! end
5853
5854 # Don't add the html/php section since the output is broken and there isn't any reason to spec it
5855 !! test
5856 External link containing double-single-quotes with no space separating the url from text in italics
5857 !! wikitext
5858 [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]].]
5859 !! html/php+tidy
5860 <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>.
5861 </p>
5862 !! html/parsoid
5863 <p><a rel="mw:ExtLink" 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 rel="mw:WikiLink" href="./Museo_Picasso_(París)" title="Museo Picasso (París)">Museo Picasso</a><span>.</span></p>
5864 !! end
5865
5866 !! test
5867 External link with comments in link text
5868 !! wikitext
5869 [http://www.google.com Google <!-- comment -->]
5870 !! html/php
5871 <p><a rel="nofollow" class="external text" href="http://www.google.com">Google </a>
5872 </p>
5873 !! html/parsoid
5874 <p><a rel="mw:ExtLink" class="external text" href="http://www.google.com">Google <!-- comment --></a></p>
5875 !! end
5876
5877 !! test
5878 External link to bare IPv4 address
5879 !! wikitext
5880 [http://192.168.0.1 Link]
5881 !! html/php
5882 <p><a rel="nofollow" class="external text" href="http://192.168.0.1">Link</a>
5883 </p>
5884 !! html/parsoid
5885 <p><a rel="mw:ExtLink" class="external text" href="http://192.168.0.1">Link</a></p>
5886 !! end
5887
5888 !! test
5889 URL-encoding in URL functions (single parameter)
5890 !! wikitext
5891 {{localurl:Some page|amp=&}}
5892 !! html
5893 <p>/index.php?title=Some_page&amp;amp=&amp;
5894 </p>
5895 !! end
5896
5897 !! test
5898 URL-encoding in URL functions (multiple parameters)
5899 !! wikitext
5900 {{localurl:Some page|q=?&amp=&}}
5901 !! html
5902 <p>/index.php?title=Some_page&amp;q=?&amp;amp=&amp;
5903 </p>
5904 !! end
5905
5906 !! test
5907 Brackets in urls
5908 !! wikitext
5909 http://example.com/index.php?foozoid%5B%5D=bar
5910
5911 http://example.com/index.php?foozoid&#x5B;&#x5D;=bar
5912 !! html/php
5913 <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>
5914 </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>
5915 </p>
5916 !! html/parsoid
5917 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/index.php?foozoid%5B%5D=bar">http://example.com/index.php?foozoid%5B%5D=bar</a></p>
5918
5919 <p><a rel="mw:ExtLink" class="external free" 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>
5920 !! end
5921
5922 !! test
5923 IPv6 urls, autolink format (T23261)
5924 !! wikitext
5925 http://[2404:130:0:1000::187:2]/index.php
5926
5927 Examples from RFC 2373, section 2.2:
5928
5929 *http://[1080::8:800:200C:417A]/unicast
5930 *http://[FF01::101]/multicast
5931 *http://[::1]/loopback
5932 *http://[::]/unspecified
5933 *http://[::13.1.68.3]/ipv4compat
5934 *http://[::FFFF:129.144.52.38]/ipv4compat
5935
5936 Examples from RFC 2732, section 2:
5937
5938 *http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html
5939 *http://[1080:0:0:0:8:800:200C:417A]/index.html
5940 *http://[3ffe:2a00:100:7031::1]
5941 *http://[1080::8:800:200C:417A]/foo
5942 *http://[::192.9.5.5]/ipng
5943 *http://[::FFFF:129.144.52.38]:80/index.html
5944 *http://[2010:836B:4179::836B:4179]
5945 !! html/php
5946 <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>
5947 </p><p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc2373">RFC 2373</a>, section 2.2:
5948 </p>
5949 <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>
5950 <li><a rel="nofollow" class="external free" href="http://[FF01::101]/multicast">http://[FF01::101]/multicast</a></li>
5951 <li><a rel="nofollow" class="external free" href="http://[::1]/loopback">http://[::1]/loopback</a></li>
5952 <li><a rel="nofollow" class="external free" href="http://[::]/unspecified">http://[::]/unspecified</a></li>
5953 <li><a rel="nofollow" class="external free" href="http://[::13.1.68.3]/ipv4compat">http://[::13.1.68.3]/ipv4compat</a></li>
5954 <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>
5955 <p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc2732">RFC 2732</a>, section 2:
5956 </p>
5957 <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>
5958 <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>
5959 <li><a rel="nofollow" class="external free" href="http://[3ffe:2a00:100:7031::1]">http://[3ffe:2a00:100:7031::1]</a></li>
5960 <li><a rel="nofollow" class="external free" href="http://[1080::8:800:200C:417A]/foo">http://[1080::8:800:200C:417A]/foo</a></li>
5961 <li><a rel="nofollow" class="external free" href="http://[::192.9.5.5]/ipng">http://[::192.9.5.5]/ipng</a></li>
5962 <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>
5963 <li><a rel="nofollow" class="external free" href="http://[2010:836B:4179::836B:4179]">http://[2010:836B:4179::836B:4179]</a></li></ul>
5964
5965 !! html/parsoid
5966 <p><a rel="mw:ExtLink" class="external free" href="http://[2404:130:0:1000::187:2]/index.php">http://[2404:130:0:1000::187:2]/index.php</a></p>
5967
5968 <p>Examples from <a href="https://tools.ietf.org/html/rfc2373" rel="mw:ExtLink" class="external mw-magiclink">RFC 2373</a>, section 2.2:</p>
5969 <ul><li><a rel="mw:ExtLink" class="external free" href="http://[1080::8:800:200C:417A]/unicast">http://[1080::8:800:200C:417A]/unicast</a></li>
5970 <li><a rel="mw:ExtLink" class="external free" href="http://[FF01::101]/multicast">http://[FF01::101]/multicast</a></li>
5971 <li><a rel="mw:ExtLink" class="external free" href="http://[::1]/loopback">http://[::1]/loopback</a></li>
5972 <li><a rel="mw:ExtLink" class="external free" href="http://[::]/unspecified">http://[::]/unspecified</a></li>
5973 <li><a rel="mw:ExtLink" class="external free" href="http://[::13.1.68.3]/ipv4compat">http://[::13.1.68.3]/ipv4compat</a></li>
5974 <li><a rel="mw:ExtLink" class="external free" href="http://[::FFFF:129.144.52.38]/ipv4compat">http://[::FFFF:129.144.52.38]/ipv4compat</a></li></ul>
5975
5976 <p>Examples from <a href="https://tools.ietf.org/html/rfc2732" rel="mw:ExtLink" class="external mw-magiclink">RFC 2732</a>, section 2:</p>
5977 <ul><li><a rel="mw:ExtLink" 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>
5978 <li><a rel="mw:ExtLink" 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>
5979 <li><a rel="mw:ExtLink" class="external free" href="http://[3ffe:2a00:100:7031::1]">http://[3ffe:2a00:100:7031::1]</a></li>
5980 <li><a rel="mw:ExtLink" class="external free" href="http://[1080::8:800:200C:417A]/foo">http://[1080::8:800:200C:417A]/foo</a></li>
5981 <li><a rel="mw:ExtLink" class="external free" href="http://[::192.9.5.5]/ipng">http://[::192.9.5.5]/ipng</a></li>
5982 <li><a rel="mw:ExtLink" class="external free" href="http://[::FFFF:129.144.52.38]:80/index.html">http://[::FFFF:129.144.52.38]:80/index.html</a></li>
5983 <li><a rel="mw:ExtLink" class="external free" href="http://[2010:836B:4179::836B:4179]">http://[2010:836B:4179::836B:4179]</a></li></ul>
5984 !! end
5985
5986 !! test
5987 IPv6 urls, bracketed format (T23261)
5988 !! wikitext
5989 [http://[2404:130:0:1000::187:2]/index.php test]
5990
5991 Examples from RFC 2373, section 2.2:
5992
5993 *[http://[1080::8:800:200C:417A] unicast]
5994 *[http://[FF01::101] multicast]
5995 *[http://[::1]/ loopback]
5996 *[http://[::] unspecified]
5997 *[http://[::13.1.68.3] ipv4compat]
5998 *[http://[::FFFF:129.144.52.38] ipv4compat]
5999
6000 Examples from RFC 2732, section 2:
6001
6002 *[http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html 1]
6003 *[http://[1080:0:0:0:8:800:200C:417A]/index.html 2]
6004 *[http://[3ffe:2a00:100:7031::1] 3]
6005 *[http://[1080::8:800:200C:417A]/foo 4]
6006 *[http://[::192.9.5.5]/ipng 5]
6007 *[http://[::FFFF:129.144.52.38]:80/index.html 6]
6008 *[http://[2010:836B:4179::836B:4179] 7]
6009 !! html/php
6010 <p><a rel="nofollow" class="external text" href="http://[2404:130:0:1000::187:2]/index.php">test</a>
6011 </p><p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc2373">RFC 2373</a>, section 2.2:
6012 </p>
6013 <ul><li><a rel="nofollow" class="external text" href="http://[1080::8:800:200C:417A]">unicast</a></li>
6014 <li><a rel="nofollow" class="external text" href="http://[FF01::101]">multicast</a></li>
6015 <li><a rel="nofollow" class="external text" href="http://[::1]/">loopback</a></li>
6016 <li><a rel="nofollow" class="external text" href="http://[::]">unspecified</a></li>
6017 <li><a rel="nofollow" class="external text" href="http://[::13.1.68.3]">ipv4compat</a></li>
6018 <li><a rel="nofollow" class="external text" href="http://[::FFFF:129.144.52.38]">ipv4compat</a></li></ul>
6019 <p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc2732">RFC 2732</a>, section 2:
6020 </p>
6021 <ul><li><a rel="nofollow" class="external text" href="http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html">1</a></li>
6022 <li><a rel="nofollow" class="external text" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">2</a></li>
6023 <li><a rel="nofollow" class="external text" href="http://[3ffe:2a00:100:7031::1]">3</a></li>
6024 <li><a rel="nofollow" class="external text" href="http://[1080::8:800:200C:417A]/foo">4</a></li>
6025 <li><a rel="nofollow" class="external text" href="http://[::192.9.5.5]/ipng">5</a></li>
6026 <li><a rel="nofollow" class="external text" href="http://[::FFFF:129.144.52.38]:80/index.html">6</a></li>
6027 <li><a rel="nofollow" class="external text" href="http://[2010:836B:4179::836B:4179]">7</a></li></ul>
6028
6029 !! html/parsoid
6030 <p><a rel="mw:ExtLink" class="external text" href="http://[2404:130:0:1000::187:2]/index.php">test</a></p>
6031
6032 <p>Examples from <a href="https://tools.ietf.org/html/rfc2373" rel="mw:ExtLink" class="external mw-magiclink">RFC 2373</a>, section 2.2:</p>
6033 <ul><li><a rel="mw:ExtLink" class="external text" href="http://[1080::8:800:200C:417A]">unicast</a></li>
6034 <li><a rel="mw:ExtLink" class="external text" href="http://[FF01::101]">multicast</a></li>
6035 <li><a rel="mw:ExtLink" class="external text" href="http://[::1]/">loopback</a></li>
6036 <li><a rel="mw:ExtLink" class="external text" href="http://[::]">unspecified</a></li>
6037 <li><a rel="mw:ExtLink" class="external text" href="http://[::13.1.68.3]">ipv4compat</a></li>
6038 <li><a rel="mw:ExtLink" class="external text" href="http://[::FFFF:129.144.52.38]">ipv4compat</a></li></ul>
6039
6040 <p>Examples from <a href="https://tools.ietf.org/html/rfc2732" rel="mw:ExtLink" class="external mw-magiclink">RFC 2732</a>, section 2:</p>
6041 <ul><li><a rel="mw:ExtLink" class="external text" href="http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html">1</a></li>
6042 <li><a rel="mw:ExtLink" class="external text" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">2</a></li>
6043 <li><a rel="mw:ExtLink" class="external text" href="http://[3ffe:2a00:100:7031::1]">3</a></li>
6044 <li><a rel="mw:ExtLink" class="external text" href="http://[1080::8:800:200C:417A]/foo">4</a></li>
6045 <li><a rel="mw:ExtLink" class="external text" href="http://[::192.9.5.5]/ipng">5</a></li>
6046 <li><a rel="mw:ExtLink" class="external text" href="http://[::FFFF:129.144.52.38]:80/index.html">6</a></li>
6047 <li><a rel="mw:ExtLink" class="external text" href="http://[2010:836B:4179::836B:4179]">7</a></li></ul>
6048 !! end
6049
6050 !! test
6051 Non-extlinks in brackets
6052 !! wikitext
6053 [foo]
6054 [foo bar]
6055 [foo ''bar'']
6056 [fool's] errand
6057 [fool's errand]
6058 [{{echo|foo}}]
6059 [{{echo|foo}} bar]
6060 [{{echo|foo}} ''bar'']
6061 [{{echo|foo}}l's] errand
6062 [{{echo|foo}}l's errand]
6063 [url={{echo|foo}}]
6064 [url=http://example.com]
6065 [http:// bare protocols don't count]
6066 !! html/php
6067 <p>[foo]
6068 [foo bar]
6069 [foo <i>bar</i>]
6070 [fool's] errand
6071 [fool's errand]
6072 [foo]
6073 [foo bar]
6074 [foo <i>bar</i>]
6075 [fool's] errand
6076 [fool's errand]
6077 [url=foo]
6078 [url=<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>]
6079 [http:// bare protocols don't count]
6080 </p>
6081 !! html/parsoid
6082 <p>[foo]
6083 [foo bar]
6084 [foo <i>bar</i>]
6085 [fool's] errand
6086 [fool's errand]
6087 [<span about="#mwt19" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</span>]
6088 [<span about="#mwt20" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</span> bar]
6089 [<span about="#mwt21" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</span> <i>bar</i>]
6090 [<span about="#mwt22" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</span>l's] errand
6091 [<span about="#mwt23" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</span>l's errand]
6092 [url=<span about="#mwt24" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</span>]
6093 [url=<a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>]
6094 [http:// bare protocols don't count]</p>
6095 !! end
6096
6097 !! test
6098 Percent encoding in external links
6099 !! wikitext
6100 [https://github.com/search?l=&q=ResourceLoader+%40wikimedia Search]
6101 !! html/php
6102 <p><a rel="nofollow" class="external text" href="https://github.com/search?l=&amp;q=ResourceLoader+%40wikimedia">Search</a>
6103 </p>
6104 !! html/parsoid
6105 <p><a rel="mw:ExtLink" class="external text" href="https://github.com/search?l=&amp;q=ResourceLoader+%40wikimedia">Search</a></p>
6106 !! end
6107
6108 !! test
6109 Use url link syntax for links where the content is equal the link target
6110 !! wikitext
6111 http://example.com
6112 !! html/php
6113 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
6114 </p>
6115 !! html/parsoid
6116 <p><a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a></p>
6117 !! end
6118
6119 !! test
6120 Parenthesis in external links, especially URL links
6121 !! wikitext
6122 http://example.com)
6123
6124 http://example.com/test)
6125
6126 http://example.com/(test)
6127
6128 http://example.com/((test)
6129
6130 (http://example.com/(test))
6131
6132 (http://example.com/(test)))))
6133
6134 http://example.com/a)b
6135
6136 [http://example.com) foo]
6137 !! html/php
6138 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
6139 </p><p><a rel="nofollow" class="external free" href="http://example.com/test">http://example.com/test</a>)
6140 </p><p><a rel="nofollow" class="external free" href="http://example.com/(test)">http://example.com/(test)</a>
6141 </p><p><a rel="nofollow" class="external free" href="http://example.com/((test)">http://example.com/((test)</a>
6142 </p><p>(<a rel="nofollow" class="external free" href="http://example.com/(test))">http://example.com/(test))</a>
6143 </p><p>(<a rel="nofollow" class="external free" href="http://example.com/(test)))))">http://example.com/(test)))))</a>
6144 </p><p><a rel="nofollow" class="external free" href="http://example.com/a)b">http://example.com/a)b</a>
6145 </p><p><a rel="nofollow" class="external text" href="http://example.com)">foo</a>
6146 </p>
6147 !! html/parsoid
6148 <p><a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>)</p>
6149 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/test">http://example.com/test</a>)</p>
6150 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/(test)">http://example.com/(test)</a></p>
6151 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/((test)">http://example.com/((test)</a></p>
6152 <p>(<a rel="mw:ExtLink" class="external free" href="http://example.com/(test))">http://example.com/(test))</a></p>
6153 <p>(<a rel="mw:ExtLink" class="external free" href="http://example.com/(test)))))">http://example.com/(test)))))</a></p>
6154 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/a)b">http://example.com/a)b</a></p>
6155 <p><a rel="mw:ExtLink" class="external text" href="http://example.com)">foo</a></p>
6156 !! end
6157
6158 !! test
6159 Parenthesis in external links, w/ transclusion or comment
6160 !! wikitext
6161 (http://example.com/{{echo|hi}})
6162
6163 (http://example.com<!-- hi -->)
6164 !! html/php
6165 <p>(<a rel="nofollow" class="external free" href="http://example.com/hi">http://example.com/hi</a>)
6166 </p><p>(<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
6167 </p>
6168 !! html/parsoid
6169 <p>(<a typeof="mw:ExpandedAttrs" about="#mwt2" rel="mw:ExtLink" class="external free" 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>
6170
6171 <p>(<a rel="mw:ExtLink" class="external free" 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>
6172 !! end
6173
6174 !! test
6175 Serialize <a> tags with invalid link targets as plain text
6176 !! options
6177 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
6178 !! html/parsoid
6179 <a rel="mw:WikiLink" href="[[foo]]">text</a>
6180 <a rel="mw:WikiLink" href="[[foo]]">*text</a>
6181 <a rel="mw:WikiLink" href="[[foo]]">[[foo]]</a>
6182 <a rel="mw:WikiLink" href="[[foo]]">*a [[foo]]</a>
6183 !! wikitext
6184 text
6185 <nowiki>*</nowiki>text
6186 <nowiki>[[foo]]</nowiki>
6187 <nowiki>*</nowiki>a <nowiki>[[foo]]</nowiki>
6188 !! end
6189
6190 !! test
6191 mw:ExtLink -vs- mw:WikiLink (T94723)
6192 !! options
6193 parsoid=html2wt
6194 !! html/parsoid
6195 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"piped","a":{"href":"./Foo"},"sa":{"href":"Foo"}}'>Bar</a>
6196 <a rel="mw:WikiLink" href="./Foo" title="Foo">Bar</a>
6197 <a rel="mw:WikiLink" href="http://en.wikipedia.org/wiki/Foo" title="Foo">Bar</a>
6198 <a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/Foo" title="Foo">Bar</a>
6199 <p>
6200 <a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/European_Robin">European Robin</a>
6201 <a rel="mw:WikiLink" href="http://en.wikipedia.org/wiki/European_Robin">European Robin</a>
6202 </p>
6203 !! wikitext
6204 [[Foo|Bar]]
6205 [[Foo|Bar]]
6206 [[:en:Foo|Bar]]
6207 [[:en:Foo|Bar]]
6208
6209 [[:en:European_Robin|European Robin]]
6210 [[:en:European_Robin|European Robin]]
6211 !! end
6212
6213 !! test
6214 mw:ExtLink linking to a interwiki URL can be round-tripped losslessly (T94723)
6215 !! options
6216 parsoid=wt2wt
6217 !! wikitext
6218 [http://en.wikipedia.org/wiki/European_Robin European Robin]
6219 !! html/parsoid
6220 THIS SECTION IS NOT USED (but Parsoid won't run the test without it)
6221 !! end
6222
6223
6224 ###
6225 ### Quotes
6226 ###
6227
6228 !! test
6229 Quotes
6230 !! wikitext
6231 Normal text. '''Bold text.''' Normal text. ''Italic text.''
6232
6233 Normal text. '''''Bold italic text.''''' Normal text.
6234 !! html
6235 <p>Normal text. <b>Bold text.</b> Normal text. <i>Italic text.</i>
6236 </p><p>Normal text. <i><b>Bold italic text.</b></i> Normal text.
6237 </p>
6238 !! end
6239
6240 !! test
6241 Quotes wrapping HTML table
6242 !! wikitext
6243 '''<table><tr><td>hi</td></tr></table>'''
6244 !! html/php+tidy
6245 <b><table><tbody><tr><td>hi</td></tr></tbody></table></b>
6246 !! html/parsoid
6247 <b><table data-parsoid='{"stx":"html"}'><tbody><tr data-parsoid='{"stx":"html"}'><td data-parsoid='{"stx":"html"}'>hi</td></tr></tbody></table></b>
6248 !! end
6249
6250 # Parsoid inserts an empty bold tag pair at the end of the line, that the PHP
6251 # parser strips. The wikitext contains just the first half of the bold
6252 # quote pair.
6253 !! test
6254 Unclosed and unmatched quotes
6255 !! wikitext
6256 '''''Bold italic text '''with bold deactivated''' in between.'''''
6257
6258 '''''Bold italic text ''with italic deactivated'' in between.'''''
6259
6260 '''Bold text..
6261
6262 ..spanning two paragraphs (should not work).'''
6263
6264 '''Bold tag left open
6265
6266 ''Italic tag left open
6267
6268 Normal text.
6269
6270 <!-- Unmatching number of opening, closing tags: -->
6271 '''This year''''s election ''should'' beat '''last year''''s.
6272
6273 ''Tom'''s car is bigger than ''Susan'''s.
6274
6275 Plain ''italic'''s plain
6276 !! html/php
6277 <p><i><b>Bold italic text </b>with bold deactivated<b> in between.</b></i>
6278 </p><p><b><i>Bold italic text </i>with italic deactivated<i> in between.</i></b>
6279 </p><p><b>Bold text..</b>
6280 </p><p>..spanning two paragraphs (should not work).
6281 </p><p><b>Bold tag left open</b>
6282 </p><p><i>Italic tag left open</i>
6283 </p><p>Normal text.
6284 </p><p><b>This year'</b>s election <i>should</i> beat <b>last year'</b>s.
6285 </p><p><i>Tom<b>s car is bigger than </b></i><b>Susan</b>s.
6286 </p><p>Plain <i>italic'</i>s plain
6287 </p>
6288 !! html/parsoid
6289 <p><i><b>Bold italic text </b>with bold deactivated<b> in between.</b></i>
6290 </p><p><b><i>Bold italic text </i>with italic deactivated<i> in between.</i></b>
6291 </p><p><b>Bold text..</b>
6292 </p><p>..spanning two paragraphs (should not work).<b></b>
6293 </p><p><b>Bold tag left open</b>
6294 </p><p><i>Italic tag left open</i>
6295 </p><p>Normal text.
6296 </p>
6297 <!-- Unmatching number of opening, closing tags: -->
6298 <p><b>This year'</b>s election <i>should</i> beat <b>last year'</b>s.
6299 </p><p><i>Tom<b>s car is bigger than </b></i><b>Susan</b>s.
6300 </p><p>Plain <i>italic'</i>s plain
6301 </p>
6302 !! end
6303
6304 ###
6305 ### Tables
6306 ###
6307 ### some content taken from http://meta.wikimedia.org/wiki/MediaWiki_User%27s_Guide:_Using_tables
6308 ###
6309
6310 # This should not produce <table></table> as <table><tr><td></td></tr></table>
6311 # is the bare minimum required by the spec, see:
6312 # https://www.w3.org/TR/xhtml-modularization/dtd_module_defs.html#a_module_Basic_Tables
6313 # Parsoid team replies: empty table tags are legal in HTML5
6314 !! test
6315 A table with no data.
6316 !! options
6317 parsoid=wt2html
6318 !! wikitext
6319 {||}
6320 !! html/php
6321
6322 !! html/parsoid
6323 <table></table>
6324
6325 !! end
6326
6327 !! test
6328 A table with stray table end tags on start tag line (wt2html)
6329 !! options
6330 parsoid=wt2html
6331 !! wikitext
6332 {|style="color: red;"|}
6333
6334 {|style="color: red;" |}
6335 |foo
6336 |}
6337
6338 {|style="color: red;"|} id="foo"
6339 |foo
6340 |}
6341
6342 {|style="color: red;" |} id="foo"
6343 |foo
6344 |}
6345 !! html/php+tidy
6346 <table style="color: red;">
6347
6348 </table><table style="color: red;">
6349 <tbody><tr>
6350 <td>foo
6351 </td></tr></tbody></table>
6352 <table style="color: red;" id="foo">
6353 <tbody><tr>
6354 <td>foo
6355 </td></tr></tbody></table>
6356 <table style="color: red;" id="foo">
6357 <tbody><tr>
6358 <td>foo
6359 </td></tr></tbody></table>
6360 !! html/parsoid
6361 <table style="color: red;"></table>
6362
6363 <table style="color: red;">
6364 <tbody><tr>
6365 <td>foo</td>
6366 </tr></tbody>
6367 </table>
6368
6369 <table style="color: red;" id="foo">
6370 <tbody><tr>
6371 <td>foo</td>
6372 </tr></tbody>
6373 </table>
6374
6375 <table style="color: red;" id="foo">
6376 <tbody><tr>
6377 <td>foo</td>
6378 </tr></tbody>
6379 </table>
6380
6381 !! end
6382
6383 !! test
6384 A table with no data (take 2)
6385 !! wikitext
6386 {|
6387 |}
6388 !! html/parsoid
6389 <table></table>
6390 !! end
6391
6392 # A table with nothing but a caption is invalid XHTML, we might want to render
6393 # this as <p>caption</p>
6394 # Parsoid team replies: table with only a caption is legal in HTML5
6395 !! test
6396 A table with nothing but a caption
6397 !! wikitext
6398 {|
6399 |+caption
6400 |}
6401 !! html/php
6402 <table>
6403 <caption>caption
6404 </caption><tr><td></td></tr></table>
6405
6406 !! html/parsoid
6407 <table><caption>caption</caption></table>
6408 !! end
6409
6410 !! test
6411 A table with caption with default-spaced attributes and a table row
6412 !! wikitext
6413 {|
6414 |+ style="color: red;" |caption1
6415 |-
6416 |foo
6417 |}
6418 !! html
6419 <table>
6420 <caption style="color: red;">caption1
6421 </caption>
6422 <tr>
6423 <td>foo
6424 </td></tr></table>
6425
6426 !! end
6427
6428 !! test
6429 A table with captions with non-default spaced attributes and a table row
6430 !! wikitext
6431 {|
6432 |+style="color: red;"|caption2
6433 |+ style="color: red;"|caption3
6434 |-
6435 |foo
6436 |}
6437 !! html
6438 <table>
6439 <caption style="color: red;">caption2
6440 </caption>
6441 <caption style="color: red;">caption3
6442 </caption>
6443 <tr>
6444 <td>foo
6445 </td></tr></table>
6446
6447 !! end
6448
6449 !! test
6450 Table td-cell syntax variations
6451 !! wikitext
6452 {|
6453 |foo bar foo|baz
6454 |foo bar foo||baz
6455 |style='color:red;'|baz
6456 |style='color:red;'||baz
6457 |}
6458 !! html
6459 <table>
6460 <tr>
6461 <td>baz
6462 </td>
6463 <td>foo bar foo</td>
6464 <td>baz
6465 </td>
6466 <td style="color:red;">baz
6467 </td>
6468 <td>style='color:red;'</td>
6469 <td>baz
6470 </td></tr></table>
6471
6472 !! end
6473
6474 !! test
6475 Simple table
6476 !! wikitext
6477 {|
6478 |1||2
6479 |-
6480 |3||4
6481 |}
6482 !! html
6483 <table>
6484 <tr>
6485 <td>1</td>
6486 <td>2
6487 </td></tr>
6488 <tr>
6489 <td>3</td>
6490 <td>4
6491 </td></tr></table>
6492
6493 !! end
6494
6495 !! test
6496 Simple table but with multiple dashes for row wikitext
6497 !! wikitext
6498 {|
6499 |foo
6500 |-----
6501 |bar
6502 |}
6503 !! html
6504 <table>
6505 <tr>
6506 <td>foo
6507 </td></tr>
6508 <tr>
6509 <td>bar
6510 </td></tr></table>
6511
6512 !! end
6513
6514 !! test
6515 Multiplication table
6516 !! wikitext
6517 {| border="1" cellpadding="2"
6518 |+Multiplication table
6519 |-
6520 !&times;!!1!!2!!3
6521 |-
6522 !1
6523 |1||2||3
6524 |-
6525 !2
6526 |2||4||6
6527 |-
6528 !3
6529 |3||6||9
6530 |-
6531 !4
6532 |4||8||12
6533 |-
6534 !5
6535 |5||10||15
6536 |}
6537 !! html
6538 <table border="1" cellpadding="2">
6539 <caption>Multiplication table
6540 </caption>
6541 <tr>
6542 <th>&#215;</th>
6543 <th>1</th>
6544 <th>2</th>
6545 <th>3
6546 </th></tr>
6547 <tr>
6548 <th>1
6549 </th>
6550 <td>1</td>
6551 <td>2</td>
6552 <td>3
6553 </td></tr>
6554 <tr>
6555 <th>2
6556 </th>
6557 <td>2</td>
6558 <td>4</td>
6559 <td>6
6560 </td></tr>
6561 <tr>
6562 <th>3
6563 </th>
6564 <td>3</td>
6565 <td>6</td>
6566 <td>9
6567 </td></tr>
6568 <tr>
6569 <th>4
6570 </th>
6571 <td>4</td>
6572 <td>8</td>
6573 <td>12
6574 </td></tr>
6575 <tr>
6576 <th>5
6577 </th>
6578 <td>5</td>
6579 <td>10</td>
6580 <td>15
6581 </td></tr></table>
6582
6583 !! end
6584
6585 !! test
6586 Accept "||" in table headings
6587 !! wikitext
6588 {|
6589 !h1||h2
6590 |}
6591 !! html
6592 <table>
6593 <tr>
6594 <th>h1</th>
6595 <th>h2
6596 </th></tr></table>
6597
6598 !! end
6599
6600 !! test
6601 Accept "!!" in table data
6602 !! wikitext
6603 {|
6604 |Foo!!||
6605 |}
6606 !! html
6607 <table>
6608 <tr>
6609 <td>Foo!!</td>
6610 <td>
6611 </td></tr></table>
6612
6613 !! html/parsoid
6614 <table>
6615 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'> Foo!! </td><td data-parsoid='{"stx":"row","autoInsertedEnd":true}'></td></tr>
6616 </tbody></table>
6617 !! end
6618
6619 !! test
6620 Accept "||" in indented table headings
6621 !! wikitext
6622 :{|
6623 !h1||h2
6624 |}
6625 !! html
6626 <dl><dd><table>
6627 <tr>
6628 <th>h1</th>
6629 <th>h2
6630 </th></tr></table></dd></dl>
6631
6632 !! end
6633
6634 !! test
6635 Accept "!!" in templates
6636 !! wikitext
6637 {|
6638 !a {{echo|b!!c}}
6639 |}
6640 !! html/php
6641 <table>
6642 <tr>
6643 <th>a b</th>
6644 <th>c
6645 </th></tr></table>
6646
6647 !! html/parsoid
6648 <table>
6649 <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>
6650 !! end
6651
6652 !! test
6653 Accept "!!" in table headings after newline
6654 !! wikitext
6655 {|
6656 !a
6657 b!!c
6658 |}
6659 !! html/php
6660 <table>
6661 <tr>
6662 <th>a
6663 <p>b!!c
6664 </p>
6665 </th></tr></table>
6666
6667 !! html/parsoid
6668 <table>
6669 <tbody><tr><th>a
6670 <p>b!!c</p></th></tr>
6671 </tbody></table>
6672 !! end
6673
6674 !! test
6675 Accept "!!" in table data of mixed wikitext / html syntax
6676 !! wikitext
6677 {|
6678 !a
6679 <tr><td>b!!c</td></tr>
6680 |}
6681 !! html/php+tidy
6682 <table>
6683 <tbody><tr>
6684 <th>a
6685 </th></tr><tr><td>b!!c</td></tr>
6686 </tbody></table>
6687 !! html/parsoid
6688 <table>
6689 <tbody><tr><th>a</th></tr>
6690 <tr data-parsoid='{"stx":"html"}'><td data-parsoid='{"stx":"html"}'>b!!c</td></tr>
6691 </tbody></table>
6692 !! end
6693
6694 !! test
6695 Accept empty attributes in td/th cells (td/th cells starting with leading ||)
6696 !! wikitext
6697 {|
6698 !|h1
6699 ||a
6700 |}
6701 !! html
6702 <table>
6703 <tr>
6704 <th>h1
6705 </th>
6706 <td>a
6707 </td></tr></table>
6708
6709 !! end
6710
6711 !!test
6712 Accept "| !" at start of line in tables (ignore !-attribute)
6713 !! wikitext
6714 {|
6715 |-
6716 |!style="color:red"|bar
6717 |}
6718 !! html
6719 <table>
6720
6721 <tr>
6722 <td>bar
6723 </td></tr></table>
6724
6725 !!end
6726
6727 !!test
6728 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 +/-
6729 !! wikitext
6730 {|
6731 |-
6732 |style='color:red;'|+1
6733 |style='color:blue;'|-1
6734 |-
6735 |1||2||3
6736 |1||+2||-3
6737 |-
6738 | +1
6739 | -1
6740 |}
6741 !! html
6742 <table>
6743
6744 <tr>
6745 <td style="color:red;">+1
6746 </td>
6747 <td style="color:blue;">-1
6748 </td></tr>
6749 <tr>
6750 <td>1</td>
6751 <td>2</td>
6752 <td>3
6753 </td>
6754 <td>1</td>
6755 <td>+2</td>
6756 <td>-3
6757 </td></tr>
6758 <tr>
6759 <td>+1
6760 </td>
6761 <td>-1
6762 </td></tr></table>
6763
6764 !!end
6765
6766 !! test
6767 Table rowspan
6768 !! wikitext
6769 {| border=1
6770 |Cell 1, row 1
6771 |rowspan=2|Cell 2, row 1 (and 2)
6772 |Cell 3, row 1
6773 |-
6774 |Cell 1, row 2
6775 |Cell 3, row 2
6776 |}
6777 !! html
6778 <table border="1">
6779 <tr>
6780 <td>Cell 1, row 1
6781 </td>
6782 <td rowspan="2">Cell 2, row 1 (and 2)
6783 </td>
6784 <td>Cell 3, row 1
6785 </td></tr>
6786 <tr>
6787 <td>Cell 1, row 2
6788 </td>
6789 <td>Cell 3, row 2
6790 </td></tr></table>
6791
6792 !! end
6793
6794 !! test
6795 Nested table
6796 !! wikitext
6797 {| border=1
6798 | &alpha;
6799 |
6800 {| bgcolor=#ABCDEF border=2
6801 |nested
6802 |-
6803 |table
6804 |}
6805 |the original table again
6806 |}
6807 !! html
6808 <table border="1">
6809 <tr>
6810 <td>&#945;
6811 </td>
6812 <td>
6813 <table bgcolor="#ABCDEF" border="2">
6814 <tr>
6815 <td>nested
6816 </td></tr>
6817 <tr>
6818 <td>table
6819 </td></tr></table>
6820 </td>
6821 <td>the original table again
6822 </td></tr></table>
6823
6824 !! end
6825
6826 !! test
6827 Invalid attributes in table cell (T3830)
6828 !! wikitext
6829 {|
6830 |Cell:|broken
6831 |}
6832 !! html
6833 <table>
6834 <tr>
6835 <td>broken
6836 </td></tr></table>
6837
6838 !! end
6839
6840 !! test
6841 Table cell attributes: Pipes protected by nowikis should be treated as a plain character
6842 !! wikitext
6843 {|
6844 |title="foo" |bar
6845 |title="foo<nowiki>|</nowiki>" |bar
6846 |title="foo<nowiki>|</nowiki>" bar
6847 |}
6848 !! html/php
6849 <table>
6850 <tr>
6851 <td title="foo">bar
6852 </td>
6853 <td title="foo&#124;">bar
6854 </td>
6855 <td>title="foo|" bar
6856 </td></tr></table>
6857
6858 !! html/parsoid
6859 <table>
6860 <tbody><tr><td title="foo">bar</td>
6861 <td title="foo|" about="#mwt3" typeof="mw:ExpandedAttrs" data-parsoid='{"a":{"title":"foo|"},"sa":{"title":"foo&lt;nowiki>|&lt;/nowiki>"}}' data-mw='{"attribs":[[{"txt":"title"},{"html":"foo&lt;span typeof=\"mw:Nowiki\" data-parsoid=&apos;{\"dsr\":[32,50,8,9]}&apos;>|&lt;/span>"}]]}'>bar</td>
6862 <td>title="foo<span typeof="mw:Nowiki">|</span>" bar</td></tr>
6863 </tbody></table>
6864 !! end
6865
6866 # See: http://lists.wikimedia.org/mailman/htdig/wikitech-l/2006-April/022293.html
6867 # N.B. The "|}" to close the table is missing from the input, so parsoid's
6868 # *2wt modes will fail.
6869 !! test
6870 Table security: embedded pipes
6871 !! options
6872 parsoid=wt2html,html2html
6873 !! wikitext
6874 {|
6875 | |[ftp://|x||]" onmouseover="alert(document.cookie)">test
6876 !! html/php
6877 <table>
6878 <tr>
6879 <td>[<a rel="nofollow" class="external free" href="ftp://%7Cx">ftp://%7Cx</a></td>
6880 <td>]" onmouseover="alert(document.cookie)"&gt;test
6881 </td>
6882 </tr>
6883 </table>
6884
6885 !! html/parsoid
6886 <table><tbody>
6887 <tr>
6888 <td data-parsoid='{"startTagSrc":"| ","attrSepSrc":"|","autoInsertedEnd":true}'>[<a rel="mw:ExtLink" class="external free" href="ftp://%7Cx" data-parsoid='{"stx":"url","a":{"href":"ftp://%7Cx"},"sa":{"href":"ftp://|x"}}'>ftp://%7Cx</a></td><td data-parsoid='{"stx":"row","autoInsertedEnd":true}'>]" onmouseover="alert(document.cookie)">test</td></tr></tbody></table>
6889 !! end
6890
6891 !! test
6892 Element attributes with double ! should not be broken up by <th>
6893 !! wikitext
6894 {|
6895 !hi <div class="!!">ha</div> ho
6896 |}
6897 !! html/php
6898 <table>
6899 <tr>
6900 <th>hi <div class="!!">ha</div> ho
6901 </th></tr></table>
6902
6903 !! html/parsoid
6904 <table>
6905 <tbody><tr><th>hi <div class="!!" data-parsoid='{"stx":"html"}'>ha</div> ho</th></tr>
6906 </tbody></table>
6907 !! end
6908
6909 !! test
6910 ! and || in element attributes should not be parsed as <th>/<td>
6911 !! wikitext
6912 {|
6913 |<div style="color: red !important;" data-contrived="put this here ||">hi</div>
6914 |}
6915 !! html/php
6916 <table>
6917 <tr>
6918 <td><div style="color: red !important;" data-contrived="put this here &#124;&#124;">hi</div>
6919 </td></tr></table>
6920
6921 !! html/parsoid
6922 <table>
6923 <tbody><tr><td><div style="color: red !important;" data-contrived="put this here ||" data-parsoid='{"stx":"html"}'>hi</div></td></tr>
6924 </tbody></table>
6925 !! end
6926
6927 # FIXME: The output seems broken. Filed as T110268.
6928 !! test
6929 ! and || in td attributes should not be parsed as <th>/<td>
6930 !! options
6931 parsoid=wt2html
6932 !! wikitext
6933 {|
6934 |style="color: red !important;" data-contrived="put this here ||"|foo
6935 |}
6936 !! html/php
6937 <table>
6938 <tr>
6939 <td>style="color: red !important;" data-contrived="put this here</td>
6940 <td>foo
6941 </td></tr></table>
6942
6943 !! html/parsoid
6944 <table>
6945 <tbody><tr><td>style="color: red !important;" data-contrived="put this here</td><td data-parsoid='{"stx":"row","a":{"\"":null},"sa":{"\"":""},"autoInsertedEnd":true}'>foo</td></tr>
6946 </tbody></table>
6947 !! end
6948
6949 !! test
6950 Break on | in element attribute in template
6951 !! options
6952 parsoid=wt2html,html2html
6953 !! wikitext
6954 {{echo|1=<div class="hi|ho">ha</div>}}
6955 !! html/php
6956 <p>ho"&gt;ha&lt;/div&gt;
6957 </p>
6958 !! html/parsoid
6959 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"ho\">ha&lt;/div>"}},"i":0}}]}'>ho">ha</p>
6960 !! end
6961
6962 !! test
6963 Break on | in element attribute name in template
6964 !! wikitext
6965 {{echo|<div cla|ss="hiho">ha</div>}}
6966 !! html/parsoid
6967 <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>
6968 !! end
6969
6970 !! test
6971 Don't break on | in extension attribute in template
6972 !! wikitext
6973 {{echo|<ref name="hi|ho">ha</ref>}}
6974
6975 <references />
6976 !! html/parsoid
6977 <p><sup about="#mwt2" class="mw-ref" id="cite_ref-hi|ho_1-0" rel="dc:references" typeof="mw:Transclusion mw:Extension/ref" 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="./Parser_test#cite_note-hi|ho-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></sup></p>
6978
6979 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt5" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-hi|ho-1" id="cite_note-hi|ho-1"><a href="./Parser_test#cite_ref-hi|ho_1-0" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-hi|ho-1" class="mw-reference-text">ha</span></li></ol>
6980 !! end
6981
6982 ## We don't support roundtripping of these attributes in Parsoid.
6983 ## Selective serialization takes care of preventing dirty diffs.
6984 ## But, on edits, we dirty-diff the invalid attribute text.
6985 !! test
6986 Invalid text in table attributes should be discarded
6987 !! options
6988 parsoid=wt2html
6989 !! wikitext
6990 {| <span>boo</span> style='border:1px solid black'
6991 | <span>boo</span> style='color:blue' |1
6992 |<span>boo</span> style='color:blue'|2
6993 |}
6994 !! html/php
6995 <table style="border:1px solid black">
6996 <tr>
6997 <td style="color:blue">1
6998 </td>
6999 <td style="color:blue">2
7000 </td></tr></table>
7001
7002 !! html/parsoid
7003 <table style="border:1px solid black">
7004 <tr>
7005 <td style="color:blue">1</td>
7006 <td style="color:blue">2</td>
7007 </tr>
7008 </table>
7009 !! end
7010
7011 !! test
7012 Invalid text in table attributes should be preserved by selective serializer
7013 !! options
7014 parsoid={
7015 "modes": ["selser"],
7016 "changes": [
7017 ["td:first-child", "text", "abc"],
7018 ["td + td", "text", "xyz"]
7019 ]
7020 }
7021 !! wikitext
7022 {| <span>boo</span> style='border:1px solid black'
7023 | <span>boo</span> style='color:blue' | 1
7024 |<span>boo</span> style='color:blue'| 2
7025 |}
7026 !! wikitext/edited
7027 {| <span>boo</span> style='border:1px solid black'
7028 | <span>boo</span> style='color:blue' | abc
7029 |<span>boo</span> style='color:blue'| xyz
7030 |}
7031 !! end
7032
7033 !! test
7034 1. Template-generated table cell attributes and cell content
7035 !! wikitext
7036 {|
7037 |{{table_attribs}}
7038 | {{table_attribs}}
7039 || {{table_attribs_5}}
7040 | <!--foo--> <!--bar--> <!--baz--> {{table_attribs}}
7041 |align=center {{table_attribs}}
7042 | <!--foo--> align=center <!--bar--> {{table_attribs}}
7043 |}
7044 !! html
7045 <table>
7046 <tr>
7047 <td style="color:red;">Foo
7048 </td>
7049 <td style="color:red;">Foo
7050 </td>
7051 <td>style="color:red;"</td>
7052 <td>Bar
7053 </td>
7054 <td style="color:red;">Foo
7055 </td>
7056 <td align="center" style="color:red;">Foo
7057 </td>
7058 <td align="center" style="color:red;">Foo
7059 </td></tr></table>
7060
7061 !! end
7062
7063 !! test
7064 2. Template-generated table cell attributes and cell content
7065 !! wikitext
7066 {|
7067 |{{table_attribs_2}}
7068 |}
7069 !! html/php
7070 <table>
7071 <tr>
7072 <td style="color:red;">Foo
7073 </td>
7074 <td>Bar</td>
7075 <td>Baz
7076 </td></tr></table>
7077
7078 !! html/parsoid
7079 <table>
7080 <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>
7081 <td about="#mwt1">Bar</td><td about="#mwt1">Baz</td></tr>
7082 </tbody></table>
7083 !! end
7084
7085 !! test
7086 3. Template-generated table cell attributes and cell content
7087 !! wikitext
7088 {|
7089 !align=center {{table_header_cells}}
7090 |-
7091 |align=center {{table_cells}}
7092 |}
7093 !! html/php
7094 <table>
7095 <tr>
7096 <th align="center" style="color:red;">Foo</th>
7097 <th style="color:red;"><i>Bar</i></th>
7098 <th style="color:brown;"><i>Foo</i> and Baz
7099 </th></tr>
7100 <tr>
7101 <td align="center" style="color:red;">Foo</td>
7102 <td style="color:red;"><i>Bar</i></td>
7103 <td style="color:brown;"><i>Foo</i> and Baz
7104 </td></tr></table>
7105
7106 !! html/parsoid
7107 <table>
7108 <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>
7109 <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>
7110 </tbody></table>
7111 !! end
7112
7113 !! test
7114 4. Template-generated table cell attributes and cell content inside a templated table
7115 !! wikitext
7116 {{tbl-start}}
7117 !align=center {{table_header_cells}}
7118 |-
7119 |align=center {{table_cells}}
7120 {{tbl-end}}
7121 !! html/php
7122 <table>
7123 <tr>
7124 <th align="center" style="color:red;">Foo</th>
7125 <th style="color:red;"><i>Bar</i></th>
7126 <th style="color:brown;"><i>Foo</i> and Baz
7127 </th></tr>
7128 <tr>
7129 <td align="center" style="color:red;">Foo</td>
7130 <td style="color:red;"><i>Bar</i></td>
7131 <td style="color:brown;"><i>Foo</i> and Baz
7132 </td></tr></table>
7133
7134 !! html/parsoid
7135 <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}}]}'>
7136 <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>
7137 <tr>
7138 <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>
7139 </tbody></table>
7140 !! end
7141
7142 ## Edge case fix to prevent future regressions
7143 !! test
7144 T107652: <ref>s in templates that also generate table cell attributes should be rendered properly
7145 !! wikitext
7146 {|
7147 |{{table_attribs_7}}
7148 |}
7149 <references />
7150 !! html/parsoid
7151 <table>
7152 <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<sup class="mw-ref" id="cite_ref-1" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{},"body":{"id":"mw-reference-text-cite_note-1"}}'><a href="./Parser_test#cite_note-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></s></td></tr>
7153 </tbody></table>
7154 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt5" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Parser_test#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>
7155 !! end
7156
7157 !! test
7158 Table with row followed by newlines and table heading
7159 !! options
7160 parsoid=wt2html,html2html
7161 !! wikitext
7162 {|
7163 |-
7164
7165 !foo
7166 |}
7167 !! html/*
7168 <table>
7169
7170
7171 <tr>
7172 <th>foo
7173 </th></tr></table>
7174
7175 !! end
7176
7177 !! test
7178 Table with empty line following the start tag
7179 !! options
7180 parsoid=wt2html,html2html
7181 !! wikitext
7182 {|
7183
7184 |-
7185 |foo
7186 |}
7187 !! html/*
7188 <table>
7189
7190
7191 <tr>
7192 <td>foo
7193 </td></tr></table>
7194
7195 !! end
7196
7197 !! test
7198 Table attributes with empty value
7199 !! options
7200 parsoid=wt2html,html2html
7201 !! wikitext
7202 {|
7203 | style=|hello
7204 |}
7205 !! html/php
7206 <table>
7207 <tr>
7208 <td style="">hello
7209 </td></tr></table>
7210
7211 !! html/parsoid
7212 <table>
7213 <tbody><tr><td style="">hello</td></tr>
7214 </tbody></table>
7215 !! end
7216
7217 !! test
7218 Wikitext table with a lot of comments
7219 !! wikitext
7220 {|
7221 <!-- c0 -->
7222 |foo
7223 <!-- c1 -->
7224 |-<!-- c2 -->
7225 <!-- c3 -->
7226 |<!-- c4 -->
7227 <!-- c5 -->
7228 |}
7229 !! html
7230 <table>
7231 <tr>
7232 <td>foo
7233 </td></tr>
7234 <tr>
7235 <td>
7236 </td></tr></table>
7237
7238 !! end
7239
7240 !! test
7241 Wikitext table comments represented in parsoid dom
7242 !! wikitext
7243 {|<!--c1--><!--c2-->
7244 |-<!--c3-->
7245 |x
7246 |}
7247 !! html/php+tidy
7248 <table>
7249
7250 <tbody><tr>
7251 <td>x
7252 </td></tr></tbody></table>
7253 !! html/parsoid
7254 <table><!--c1--><!--c2-->
7255 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'><!--c3-->
7256 <td data-parsoid='{"autoInsertedEnd":true}'>x</td></tr>
7257 </tbody></table>
7258 !! end
7259
7260 !! test
7261 Wikitext table with double-line table cell
7262 !! wikitext
7263 {|
7264 |a
7265 b
7266 |}
7267 !! html
7268 <table>
7269 <tr>
7270 <td>a
7271 <p>b
7272 </p>
7273 </td></tr></table>
7274
7275 !! end
7276
7277 !! test
7278 Table cell with a single comment
7279 !! wikitext
7280 {|
7281 |<!-- c1 -->
7282 |a
7283 |}
7284 !! html
7285 <table>
7286 <tr>
7287 <td>
7288 </td>
7289 <td>a
7290 </td></tr></table>
7291
7292 !! end
7293
7294 !! test
7295 Table-cell after a comment-only-empty-line
7296 !! wikitext
7297 {|
7298 |a
7299 <!--c1-->
7300 <!--c2-->|b
7301 |}
7302 !! html
7303 <table>
7304 <tr>
7305 <td>a
7306 </td>
7307 <td>b
7308 </td></tr></table>
7309
7310 !! html/parsoid
7311 <table>
7312 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'>a</td>
7313 <!--c1-->
7314 <!--c2--><td data-parsoid='{"autoInsertedEnd":true}'>b</td></tr>
7315 </tbody></table>
7316
7317 !! end
7318
7319 !! test
7320 Build table with {{!}}
7321 !! wikitext
7322 {{{!}} class="wikitable"
7323 !header
7324 !second header
7325 {{!}}- style="color:red;"
7326 {{!}}data{{!}}{{!}} style="color:red;" {{!}}second data
7327 {{!}}}
7328 !! html
7329 <table class="wikitable">
7330 <tr>
7331 <th>header
7332 </th>
7333 <th>second header
7334 </th></tr>
7335 <tr style="color:red;">
7336 <td>data</td>
7337 <td style="color:red;">second data
7338 </td></tr></table>
7339
7340 !! end
7341
7342 !! test
7343 Build table with pipe as data
7344 !! wikitext
7345 {| class="wikitable"
7346 !header
7347 !second header
7348 |- style="color:red;"
7349 |data|| style="color:red;" |second data
7350 |-
7351 | style="color:red;" |data with | || style="color:red;" | second data with |
7352 |-
7353 ||data with | |||second data with |
7354 |}
7355 !! html
7356 <table class="wikitable">
7357 <tr>
7358 <th>header
7359 </th>
7360 <th>second header
7361 </th></tr>
7362 <tr style="color:red;">
7363 <td>data</td>
7364 <td style="color:red;">second data
7365 </td></tr>
7366 <tr>
7367 <td style="color:red;">data with |</td>
7368 <td style="color:red;">second data with |
7369 </td></tr>
7370 <tr>
7371 <td>data with |</td>
7372 <td>second data with |
7373 </td></tr></table>
7374
7375 !! end
7376
7377 !! test
7378 Build table with wikilink
7379 !! wikitext
7380 {| class="wikitable"
7381 !header||second header
7382 |- style="color:red;"
7383 |data [[Main Page|linktext]]||second data [[Main Page|linktext]]
7384 |-
7385 |data||second data [[Main Page|link|text with pipe]]
7386 |}
7387 !! html
7388 <table class="wikitable">
7389 <tr>
7390 <th>header</th>
7391 <th>second header
7392 </th></tr>
7393 <tr style="color:red;">
7394 <td>data <a href="/wiki/Main_Page" title="Main Page">linktext</a></td>
7395 <td>second data <a href="/wiki/Main_Page" title="Main Page">linktext</a>
7396 </td></tr>
7397 <tr>
7398 <td>data</td>
7399 <td>second data <a href="/wiki/Main_Page" title="Main Page">link|text with pipe</a>
7400 </td></tr></table>
7401
7402 !! end
7403
7404 # The expected HTML structure in this test is debatable. The PHP parser does
7405 # not parse this kind of table at all. The main focus for Parsoid is on
7406 # round-tripping, so this output is ok for now. TODO: revisit!
7407 !! test
7408 Wikitext table with html-syntax row
7409 !! wikitext
7410 {|
7411 |-
7412 <td>foo</td>
7413 |}
7414 !! html/parsoid
7415 <table>
7416 <tbody>
7417 <tr>
7418 <td>foo</td></tr></tbody></table>
7419 !! end
7420
7421 ## Remex doesn't account for fostered content.
7422 !! test
7423 Fostered content in tables: Plain text
7424 !! options
7425 parsoid=wt2html
7426 !! wikitext
7427 {|
7428 |-
7429 a
7430 |}
7431 !! html/php
7432 <table>
7433
7434 a
7435 </table>
7436
7437 !! html/php+tidy
7438
7439
7440 a
7441 <table></table>
7442 !! html/parsoid
7443 <p data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true}'>
7444 a</p>
7445 <table>
7446 <tbody><tr class="mw-empty-elt" data-parsoid='{"startTagSrc":"|-"}'></tr></tbody></table>
7447 !! end
7448
7449 !! test
7450 Fostered content in tables: Lists
7451 !! options
7452 parsoid=wt2html,html2html
7453 !! wikitext
7454 {|
7455 |-
7456 *a
7457 |}
7458 !! html/php
7459 <table>
7460
7461 <ul><li>a</li></ul>
7462 </table>
7463
7464 !! html/php+tidy
7465 <ul><li>a</li></ul><table>
7466
7467
7468 </table>
7469 !! html/parsoid
7470 <ul data-parsoid='{"fostered":true,"autoInsertedEnd":true}'><li>a</li></ul><table>
7471 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
7472
7473 </tr></tbody></table>
7474 !! end
7475
7476 !! test
7477 Template generated table cell with attributes
7478 !! wikitext
7479 {|
7480 |-
7481 {{table_attribs_4}} ||a||b
7482 |}
7483 !! html/php+tidy
7484 <table>
7485
7486 <tbody><tr>
7487 <td style="background-color:#DC241f;" width="10px"></td>
7488 <td>a</td>
7489 <td>b
7490 </td></tr></tbody></table>
7491 !! html/parsoid
7492 <table>
7493 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
7494 <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>
7495 !! end
7496
7497 !! test
7498 Parsoid: Round-trip tables directly followed by content (T53219)
7499 !! options
7500 parsoid=wt2html,wt2wt
7501 !! wikitext
7502 {|
7503 |foo
7504 |} bar
7505
7506 {|
7507 |baz
7508 |}<b>quux</b>
7509 !! html+tidy
7510 <table>
7511 <tbody><tr>
7512 <td>foo
7513 </td></tr></tbody></table><p> bar
7514 </p><table>
7515 <tbody><tr>
7516 <td>baz
7517 </td></tr></tbody></table><p><b>quux</b>
7518 </p>
7519 !! end
7520
7521 !! test
7522 Parsoid: Default to a newline after tables in new content (T53219)
7523 !! options
7524 parsoid=html2wt
7525 !! html/parsoid
7526 <table><tbody>
7527 <tr><td>foo</td></tr></tbody></table> bar
7528 <table><tbody>
7529 <tr><td>baz</td></tr></tbody></table><b>quux</b>
7530 !! wikitext
7531 {|
7532 |foo
7533 |}
7534 <nowiki> </nowiki>bar
7535 {|
7536 |baz
7537 |}
7538 '''quux'''
7539 !! end
7540
7541 !! test
7542 Parsoid: Row-syntax table headings followed by comment & table cells
7543 !! options
7544 parsoid=wt2html,wt2wt
7545 !! wikitext
7546 {|
7547 !foo||bar
7548 <!-- foo --> ||baz||quux
7549 |}
7550 !! html/php
7551 <table>
7552 <tr>
7553 <th>foo</th>
7554 <th>bar
7555 </th>
7556 <td>baz</td>
7557 <td>quux
7558 </td></tr></table>
7559
7560 !! html/parsoid
7561 <table>
7562 <tbody><tr><th>foo</th><th>bar
7563 <!-- foo --></th><td> baz </td><td>quux</td></tr>
7564 </tbody></table>
7565 !! end
7566
7567 !!test
7568 Parsoid: Recover better from broken table attributes
7569 !!options
7570 parsoid=wt2html
7571 !!wikitext
7572 {| class="foo
7573 | class="bar" |
7574 foo
7575 |}
7576 !!html/php+tidy
7577 <table class="foo">
7578 <tbody><tr>
7579 <td class="bar">
7580 <p>foo
7581 </p>
7582 </td></tr></tbody></table>
7583 !!html/parsoid
7584 <table class="foo">
7585 <tr>
7586 <td class="bar">
7587 <p>foo</p></td></tr>
7588 </tbody></table>
7589 !!end
7590
7591 # Note: PHP parser omits empty rows
7592 !! test
7593 Tables: Digest broken attributes on table and tr tag
7594 !! options
7595 parsoid=wt2html
7596 !! wikitext
7597 {| || |} ++
7598 |- || || ++ --
7599 |- > [
7600 |}
7601 !! html/php+tidy
7602 <table>
7603
7604
7605 </table>
7606 !! html/parsoid
7607 <table>
7608 <tbody>
7609 <tr class='mw-empty-elt'></tr>
7610 <tr class='mw-empty-elt'></tr>
7611 </tbody></table>
7612 !! end
7613
7614 !! test
7615 Table with missing opening <tr> tag
7616 !! options
7617 parsoid=wt2html,wt2wt
7618 !! wikitext
7619 <table>
7620 <td>foo</td>
7621 </tr>
7622 </table>
7623 !! html+tidy
7624 <table>
7625 <tbody><tr><td>foo</td>
7626 </tr>
7627 </tbody></table>
7628 !! end
7629
7630 # T137406: Whitespace in the HTML
7631 !! test
7632 1. Generate correct wikitext for tables with thead/tbody/tfoot
7633 !! options
7634 parsoid=html2wt
7635 !! html/parsoid
7636 <table>
7637 <caption>Test</caption>
7638 <thead>
7639 <tr>
7640 <th>Month</th>
7641 <th>Savings</th>
7642 </tr>
7643 </thead>
7644 <tbody>
7645 <tr>
7646 <td>January</td>
7647 <td>$100</td>
7648 </tr>
7649 <tr>
7650 <td>February</td>
7651 <td>$80</td>
7652 </tr>
7653 </tbody>
7654 <tfoot>
7655 <tr>
7656 <td>Sum</td>
7657 <td>$180</td>
7658 </tr>
7659 </tfoot>
7660 </table>
7661 !! wikitext
7662 {|
7663 |+Test
7664 !Month
7665 !Savings
7666 |-
7667 |January
7668 |$100
7669 |-
7670 |February
7671 |$80
7672 |-
7673 |Sum
7674 |$180
7675 |}
7676 !! html/php+tidy
7677 <table>
7678 <caption>Test
7679 </caption>
7680 <tbody><tr>
7681 <th>Month
7682 </th>
7683 <th>Savings
7684 </th></tr>
7685 <tr>
7686 <td>January
7687 </td>
7688 <td>$100
7689 </td></tr>
7690 <tr>
7691 <td>February
7692 </td>
7693 <td>$80
7694 </td></tr>
7695 <tr>
7696 <td>Sum
7697 </td>
7698 <td>$180
7699 </td></tr></tbody></table>
7700 !! end
7701
7702 # T137406: No whitespace in the HTML
7703 !! test
7704 2. Generate correct wikitext for tables with thead/tbody/tfoot
7705 !! options
7706 parsoid=html2wt
7707 !! html/parsoid
7708 <table><thead><tr><th>heading</th></tr></thead><tbody><tr><td>foo</td></tr></tbody></table>
7709 !! wikitext
7710 {|
7711 !heading
7712 |-
7713 |foo
7714 |}
7715 !! end
7716
7717 !! test
7718 Wikitext tables can be nested inside HTML tables
7719 !! options
7720 parsoid=html2wt
7721 !! html/parsoid
7722 <table data-parsoid='{"stx":"html"}'>
7723 <tr><td>
7724 <table>
7725 <tr><td>foo</td></tr>
7726 </table>
7727 </td></tr>
7728 </table>
7729 !! wikitext
7730 <table>
7731 <tr><td>
7732 {|
7733 |foo
7734 |}
7735 </td></tr>
7736 </table>
7737 !! html/php+tidy
7738 <table>
7739 <tbody><tr><td>
7740 <table>
7741 <tbody><tr>
7742 <td>foo
7743 </td></tr></tbody></table>
7744 </td></tr>
7745 </tbody></table>
7746 !! end
7747
7748 ###
7749 ### Internal links
7750 ###
7751 !! test
7752 Plain link, capitalized
7753 !! wikitext
7754 [[Main Page]]
7755 !! html
7756 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
7757 </p>
7758 !! end
7759
7760 !! test
7761 Plain link, uncapitalized
7762 !! wikitext
7763 [[main Page]]
7764 !! html
7765 <p><a href="/wiki/Main_Page" title="Main Page">main Page</a>
7766 </p>
7767 !! end
7768
7769 !! test
7770 Piped link
7771 !! wikitext
7772 [[Main Page|The Main Page]]
7773 !! html
7774 <p><a href="/wiki/Main_Page" title="Main Page">The Main Page</a>
7775 </p>
7776 !! end
7777
7778 !! test
7779 Piped link with comment in link text
7780 !! wikitext
7781 [[Main Page|The Main<!--front--> Page]]
7782 !! html
7783 <p><a href="/wiki/Main_Page" title="Main Page">The Main Page</a>
7784 </p>
7785 !! end
7786
7787 !! test
7788 Piped link with multiple pipe characters in link text
7789 !! wikitext
7790 [[Main Page||The|Main|Page|]]
7791 !! html/php
7792 <p><a href="/wiki/Main_Page" title="Main Page">|The|Main|Page|</a>
7793 </p>
7794 !! html/parsoid
7795 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">|The|Main|Page|</a></p>
7796 !! end
7797
7798 !! test
7799 Piped link with no link text
7800 !! wikitext
7801 [[Thomas Bek (bishop of St David's)|]]
7802 !! html/php
7803 <p>[[Thomas Bek (bishop of St David's)|]]
7804 </p>
7805 !! html/parsoid
7806 <p>[[Thomas Bek (bishop of St David's)|]]</p>
7807 !! end
7808
7809 !! test
7810 Piped link with empty link text
7811 !! wikitext
7812 [[Main Page|<nowiki/>]] - empty nowiki
7813 [[Main Page| ]] - empty space
7814 [[Main Page|&nbsp;]] - empty non breaking space
7815 !! html/php
7816 <p><a href="/wiki/Main_Page" title="Main Page"></a> - empty nowiki
7817 <a href="/wiki/Main_Page" title="Main Page"> </a> - empty space
7818 <a href="/wiki/Main_Page" title="Main Page">&#160;</a> - empty non breaking space
7819 </p>
7820 !! html/parsoid
7821 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page"><span typeof="mw:Nowiki"></span></a> - empty nowiki
7822 <a rel="mw:WikiLink" href="./Main_Page" title="Main Page"> </a> - empty space
7823 <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>
7824 !! end
7825
7826 !! test
7827 Broken link
7828 !! wikitext
7829 [[Zigzagzogzagzig]]
7830 !! html
7831 <p><a href="/index.php?title=Zigzagzogzagzig&amp;action=edit&amp;redlink=1" class="new" title="Zigzagzogzagzig (page does not exist)">Zigzagzogzagzig</a>
7832 </p>
7833 !! end
7834
7835 !! test
7836 Broken link with fragment
7837 !! wikitext
7838 [[Zigzagzogzagzig#zug]]
7839 !! html
7840 <p><a href="/index.php?title=Zigzagzogzagzig&amp;action=edit&amp;redlink=1" class="new" title="Zigzagzogzagzig (page does not exist)">Zigzagzogzagzig#zug</a>
7841 </p>
7842 !! end
7843
7844 !! test
7845 Special page link with fragment
7846 !! wikitext
7847 [[Special:Version#anchor]]
7848 !! html
7849 <p><a href="/wiki/Special:Version#anchor" title="Special:Version">Special:Version#anchor</a>
7850 </p>
7851 !! end
7852
7853 !! test
7854 Nonexistent special page link with fragment
7855 !! wikitext
7856 [[Special:ThisNameWillHopefullyNeverBeUsed#anchor]]
7857 !! html
7858 <p><a href="/wiki/Special:ThisNameWillHopefullyNeverBeUsed" class="new" title="Special:ThisNameWillHopefullyNeverBeUsed (page does not exist)">Special:ThisNameWillHopefullyNeverBeUsed#anchor</a>
7859 </p>
7860 !! end
7861
7862 !! test
7863 Link with prefix
7864 !! wikitext
7865 xxx[[main Page]], xxx[[Main Page]], Xxx[[main Page]] XXX[[main Page]], XXX[[Main Page]]
7866 !! html
7867 <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>
7868 </p>
7869 !! end
7870
7871 !! test
7872 Link with suffix
7873 !! wikitext
7874 [[Main Page]]xxx, [[Main Page]]XXX, [[Main Page]]!!!
7875 !! html
7876 <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>!!!
7877 </p>
7878 !! end
7879
7880 !! article
7881 prefixed article
7882 !! text
7883 Some text
7884 !! endarticle
7885
7886 !! test
7887 T45661: Piped links with identical prefixes
7888 !! wikitext
7889 [[prefixed article|prefixed articles with spaces]]
7890
7891 [[prefixed article|prefixed articlesaoeu]]
7892
7893 [[Main Page|Main Page test]]
7894 !! html
7895 <p><a href="/wiki/Prefixed_article" title="Prefixed article">prefixed articles with spaces</a>
7896 </p><p><a href="/wiki/Prefixed_article" title="Prefixed article">prefixed articlesaoeu</a>
7897 </p><p><a href="/wiki/Main_Page" title="Main Page">Main Page test</a>
7898 </p>
7899 !! end
7900
7901
7902 !! test
7903 Link with HTML entity in suffix / tail
7904 !! wikitext
7905 [[Main Page]]&quot;, [[Main Page]]&#97;
7906 !! html/php
7907 <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;
7908 </p>
7909 !! html/parsoid
7910 <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>
7911 !! end
7912
7913 !! test
7914 Link with 3 brackets
7915 !! wikitext
7916 [[[Main Page]]]
7917 Foo [[[Main Page]]]
7918 !! html
7919 <p>[[[Main Page]]]
7920 Foo [[[Main Page]]]
7921 </p>
7922 !! end
7923
7924 !! test
7925 Link with 4 brackets
7926 !! wikitext
7927 [[[[Main Page]]]]
7928 !! html
7929 <p>[[<a href="/wiki/Main_Page" title="Main Page">Main Page</a>]]
7930 </p>
7931 !! end
7932
7933 !! test
7934 Piped link with 3 brackets
7935 !! wikitext
7936 [[[main page|the main page]]]
7937 !! html
7938 <p>[[[main page|the main page]]]
7939 </p>
7940 !! end
7941
7942 !! test
7943 Piped link with extlink-like text
7944 !! wikitext
7945 [[Main Page|[bar]]]
7946 [[Main Page|This is a [bar]]]
7947 [[Main Page|[bar]]
7948 !! html/php
7949 <p><a href="/wiki/Main_Page" title="Main Page">[bar]</a>
7950 <a href="/wiki/Main_Page" title="Main Page">This is a [bar]</a>
7951 <a href="/wiki/Main_Page" title="Main Page">[bar</a>
7952 </p>
7953 !! html/parsoid
7954 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"piped"}'>[bar]</a>
7955 <a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"piped"}'>This is a [bar]</a>
7956 <a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"piped"}'>[bar</a></p>
7957 !! end
7958
7959 !! test
7960 Link with multiple pipes
7961 !! wikitext
7962 [[Main Page|The|Main|Page]]
7963 !! html
7964 <p><a href="/wiki/Main_Page" title="Main Page">The|Main|Page</a>
7965 </p>
7966 !! end
7967
7968 !! test
7969 Anchor containing a #. (T65430)
7970 !! config
7971 wgFragmentMode=[ 'html5', 'legacy' ]
7972 !! wikitext
7973 [[Main Page#And#Link]]
7974 !! html/php
7975 <p><a href="/wiki/Main_Page#And#Link" title="Main Page">Main Page#And#Link</a>
7976 </p>
7977 !! html/parsoid
7978 <p><a rel="mw:WikiLink" href="./Main_Page#And#Link" title="Main Page" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#And#Link"},"sa":{"href":"Main Page#And#Link"}}'>Main Page#And#Link</a></p>
7979 !! end
7980
7981 !! test
7982 Link to namespaces
7983 !! wikitext
7984 [[Talk:Parser testing]], [[Meta:Disclaimers]]
7985 !! html
7986 <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>
7987 </p>
7988 !! end
7989
7990 !! test
7991 Link with space in namespace
7992 !! wikitext
7993 [[User talk:Foo bar]]
7994 !! html
7995 <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>
7996 </p>
7997 !! end
7998
7999 !! article
8000 MemoryAlpha:AlphaTest
8001 !! text
8002 This is an article in the MemoryAlpha namespace
8003 (which shadows the memoryalpha interwiki link).
8004 !! endarticle
8005
8006 !! test
8007 Namespace takes precedence over interwiki link (T53680)
8008 !! wikitext
8009 [[MemoryAlpha:AlphaTest]]
8010 !! html
8011 <p><a href="/wiki/MemoryAlpha:AlphaTest" title="MemoryAlpha:AlphaTest">MemoryAlpha:AlphaTest</a>
8012 </p>
8013 !! end
8014
8015 # The previous test doesn't work correctly in html2*, due to not recognizing the
8016 # link as an internal one. This one checks for the correct behavior.
8017 !! test
8018 Link to namespace preferred over interwiki with correct rel attribute
8019 !! options
8020 parsoid=html2wt,html2html
8021 !! html/parsoid
8022 <p><a rel="mw:WikiLink" href="./MemoryAlpha:AlphaTest" title="MemoryAlpha:AlphaTest">MemoryAlpha:AlphaTest</a></p>
8023 !! wikitext
8024 [[MemoryAlpha:AlphaTest]]
8025 !! end
8026
8027 !! test
8028 Piped link to namespace
8029 !! wikitext
8030 [[Meta:Disclaimers|The disclaimers]]
8031 !! html
8032 <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>
8033 </p>
8034 !! end
8035
8036 !! test
8037 Link containing }
8038 !! wikitext
8039 [[Usually caused by a typo (oops}]]
8040 !! html
8041 <p>[[Usually caused by a typo (oops}]]
8042 </p>
8043 !! end
8044
8045 !! article
8046 7% Solution
8047 !! text
8048 Just a test of an article title containing a percent.
8049 !! endarticle
8050
8051 !! test
8052 Link containing % (not as a hex sequence)
8053 !! wikitext
8054 [[7% Solution]]
8055 [[7% Solution|7%25 Solution]]
8056 !! html/php
8057 <p><a href="/wiki/7%25_Solution" title="7% Solution">7% Solution</a>
8058 <a href="/wiki/7%25_Solution" title="7% Solution">7%25 Solution</a>
8059 </p>
8060 !! html/parsoid
8061 <p><a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7% Solution</a>
8062 <a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7%25 Solution</a></p>
8063 !! end
8064
8065 # note that the parsoid HTML is identical to the previous test output,
8066 # so the previous test ensures that the html2wt mode will generate the
8067 # "not as a hex sequence" wikitext.
8068 !! test
8069 Link containing % as a single hex sequence interpreted to char
8070 !! options
8071 parsoid=wt2wt,wt2html,html2html
8072 !! wikitext
8073 [[7%25 Solution]]
8074 [[7%25 Solution|7%25 Solution]]
8075 !! html/php
8076 <p><a href="/wiki/7%25_Solution" title="7% Solution">7% Solution</a>
8077 <a href="/wiki/7%25_Solution" title="7% Solution">7%25 Solution</a>
8078 </p>
8079 !! html/parsoid
8080 <p><a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7% Solution</a>
8081 <a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7%25 Solution</a></p>
8082 !!end
8083
8084 !! test
8085 Link containing % as a double hex sequence interpreted to hex sequence
8086 !! wikitext
8087 [[7%2525 Solution]]
8088 !! html
8089 <p>[[7%2525 Solution]]
8090 </p>
8091 !!end
8092
8093 ## Example for such a section: == < ==
8094 !! test
8095 Link containing "#<" and "#>" % as a hex sequences- these are valid section anchors
8096 !! options
8097 title=[[Main Page]]
8098 !! config
8099 wgFragmentMode=[ 'html5', 'legacy' ]
8100 !! wikitext
8101 [[%23%3c]][[%23%3e]]
8102 !! html/php
8103 <p><a href="#&lt;">#&lt;</a><a href="#&gt;">#&gt;</a>
8104 </p>
8105 !! html/parsoid
8106 <p><a rel="mw:WikiLink" href="./Main_Page#&lt;" title="Main Page" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#&lt;"},"sa":{"href":"%23%3c"}}'>#&lt;</a><a rel="mw:WikiLink" href="./Main_Page#>" title="Main Page" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#>"},"sa":{"href":"%23%3e"}}'>#></a></p>
8107 !! end
8108
8109 ## Example for such a section: == < ==
8110 !! test
8111 Link containing "#<" and "#>" % as a hex sequences- these are valid section anchors (legacy)
8112 !! config
8113 wgFragmentMode=[ 'legacy' ]
8114 !! wikitext
8115 [[%23%3c]][[%23%3e]]
8116 !! html/php
8117 <p><a href="#.3C">#&lt;</a><a href="#.3E">#&gt;</a>
8118 </p>
8119 !! end
8120
8121 !! test
8122 Link containing "<#" and ">#" as a hex sequences
8123 !! wikitext
8124 [[%3c%23]][[%3e%23]]
8125 !! html
8126 <p>[[%3c%23]][[%3e%23]]
8127 </p>
8128 !! end
8129
8130 !! test
8131 Link containing an equals sign
8132 !! wikitext
8133 [[Special:BookSources/isbn=4-00-026157-6]]
8134 !! html/php
8135 <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>
8136 </p>
8137 !! html/parsoid
8138 <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>
8139 !! end
8140
8141 !! article
8142 Foo & bar
8143 !! text
8144 Just a test of an article title containing an ampersand
8145 !! endarticle
8146
8147 !! test
8148 Link containing an ampersand
8149 !! wikitext
8150 [[Foo & bar]]
8151
8152 [[Foo &amp; bar]]
8153
8154 [[Foo &amp;amp; bar]]
8155 !! html/php+tidy
8156 <p><a href="/wiki/Foo_%26_bar" title="Foo &amp; bar">Foo &amp; bar</a>
8157 </p><p><a href="/wiki/Foo_%26_bar" title="Foo &amp; bar">Foo &amp; bar</a>
8158 </p><p>[[Foo &amp;amp; bar]]
8159 </p>
8160 !! html/parsoid
8161 <p><a rel="mw:WikiLink" href="./Foo_&amp;_bar" title="Foo &amp; bar">Foo &amp; bar</a></p>
8162 <p><a rel="mw:WikiLink" href="./Foo_&amp;_bar" title="Foo &amp; bar" data-parsoid='{"stx":"simple","a":{"href":"./Foo_&amp;_bar"},"sa":{"href":"Foo &amp;amp; bar"}}'>Foo &amp; bar</a></p>
8163 <p>[[Foo <span typeof="mw:Entity" data-parsoid='{"src":"&amp;amp;","srcContent":"&amp;"}'>&amp;</span>amp; bar]]</p>
8164 !! end
8165
8166 !! article
8167 Foo~bar
8168 !! text
8169 Just a test of an article title containing a tilde.
8170 !! endarticle
8171
8172 # note that links containing signatures, like [[Foo~~~~]], are
8173 # massaged by the pre-save transform (PST) and so the tildes are never
8174 # seen by the parser.
8175 !! test
8176 Link containing a tilde
8177 !! wikitext
8178 [[Foo~bar]]
8179 !! html/php
8180 <p><a href="/wiki/Foo~bar" title="Foo~bar">Foo~bar</a>
8181 </p>
8182 !! html/parsoid
8183 <p><a rel="mw:WikiLink" href="./Foo~bar" title="Foo~bar">Foo~bar</a></p>
8184 !! end
8185
8186 !! test
8187 Link containing double-single-quotes '' (T6598)
8188 !! wikitext
8189 [[Lista d''e paise d''o munno]]
8190 !! html/php
8191 <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&#39;&#39;e paise d&#39;&#39;o munno (page does not exist)">Lista d''e paise d''o munno</a>
8192 </p>
8193 !! html/parsoid
8194 <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>
8195 !! end
8196
8197 !! test
8198 Link containing double quotes and spaces
8199 !! wikitext
8200 [[Cool "Gator"]]
8201 !! html/php
8202 <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>
8203 </p>
8204 !! html/parsoid
8205 <p><a rel="mw:WikiLink" href='./Cool_"Gator"' title='Cool "Gator"'>Cool "Gator"</a></p>
8206 !! end
8207
8208 !! test
8209 File containing double quotes and spaces
8210 !! wikitext
8211 [[File:Cool "Gator".png]]
8212 !! html/parsoid
8213 <p><figure-inline 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></figure-inline></p>
8214 !! end
8215
8216 !! test
8217 Redirect containing double quotes and spaces
8218 !! wikitext
8219 #REDIRECT [[Cool "Gator"]]
8220 !! html/parsoid
8221 <link rel="mw:PageProp/redirect" href="./Cool_%22Gator%22" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./Cool_%22Gator%22"},"sa":{"href":"Cool \"Gator\""}}'/>
8222 !! end
8223
8224 !! test
8225 Link containing double-single-quotes '' in text (T6598 sanity check)
8226 !! wikitext
8227 Some [[Link|pretty ''italics'' and stuff]]!
8228 !! html/php
8229 <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>!
8230 </p>
8231 !! html/parsoid
8232 <p>Some <a rel="mw:WikiLink" href="./Link" title="Link">pretty <i>italics</i> and stuff</a>!</p>
8233 !! end
8234
8235 !! test
8236 Link containing double-single-quotes '' in text embedded in italics (T6598 sanity check)
8237 !! wikitext
8238 ''Some [[Link|pretty ''italics'' and stuff]]!''
8239 !! html
8240 <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>
8241 </p>
8242 !! end
8243
8244 !! test
8245 Link with double quotes in title part (literal) and alternate part (interpreted)
8246 !! wikitext
8247 [[File:Denys_Savchenko_''Pentecoste''.jpg]]
8248
8249 [[''Pentecoste'']]
8250
8251 [[''Pentecoste''|Pentecoste]]
8252
8253 [[''Pentecoste''|''Pentecoste'']]
8254 !! html/php
8255 <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>
8256 </p><p><a href="/index.php?title=%27%27Pentecoste%27%27&amp;action=edit&amp;redlink=1" class="new" title="&#39;&#39;Pentecoste&#39;&#39; (page does not exist)">''Pentecoste''</a>
8257 </p><p><a href="/index.php?title=%27%27Pentecoste%27%27&amp;action=edit&amp;redlink=1" class="new" title="&#39;&#39;Pentecoste&#39;&#39; (page does not exist)">Pentecoste</a>
8258 </p><p><a href="/index.php?title=%27%27Pentecoste%27%27&amp;action=edit&amp;redlink=1" class="new" title="&#39;&#39;Pentecoste&#39;&#39; (page does not exist)"><i>Pentecoste</i></a>
8259 </p>
8260 !! html/parsoid
8261 <p><figure-inline 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></figure-inline></p>
8262 <p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''">''Pentecoste''</a></p>
8263 <p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''">Pentecoste</a></p>
8264 <p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''"><i>Pentecoste</i></a></p>
8265 !! end
8266
8267 !! test
8268 Broken image links with HTML captions (T41700)
8269 !! wikitext
8270 [[File:Nonexistent|<script></script>]]
8271 [[File:Nonexistent|100x100px|<script></script>]]
8272 [[File:Nonexistent|&lt;]]
8273 [[File:Nonexistent|a<i>b</i>c]]
8274 !! html/php
8275 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">&lt;script&gt;&lt;/script&gt;</a>
8276 <a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">&lt;script&gt;&lt;/script&gt;</a>
8277 <a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">&lt;</a>
8278 <a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">abc</a>
8279 </p>
8280 !! html/parsoid
8281 <p><figure-inline 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></figure-inline>
8282 <figure-inline 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></figure-inline>
8283 <figure-inline 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></figure-inline>
8284 <figure-inline 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></figure-inline></p>
8285 !! end
8286
8287 !! test
8288 Plain link to URL
8289 !! wikitext
8290 [[http://www.example.com]]
8291 !! html/php
8292 <p>[<a rel="nofollow" class="external autonumber" href="http://www.example.com">[1]</a>]
8293 </p>
8294 !! html/parsoid
8295 <p>[<a rel="mw:ExtLink" class="external autonumber" href="http://www.example.com"></a>]</p>
8296 !! end
8297
8298 !! test
8299 Plain link to URL with link text
8300 !! wikitext
8301 [[http://www.example.com Link text]]
8302 !! html
8303 <p>[<a rel="nofollow" class="external text" href="http://www.example.com">Link text</a>]
8304 </p>
8305 !! end
8306
8307 !! test
8308 Plain link to protocol-relative URL
8309 !! wikitext
8310 [[//www.example.com]]
8311 !! html/php
8312 <p>[<a rel="nofollow" class="external autonumber" href="//www.example.com">[1]</a>]
8313 </p>
8314 !! html/parsoid
8315 <p>[<a rel="mw:ExtLink" class="external autonumber" href="//www.example.com"></a>]</p>
8316 !! end
8317
8318 !! test
8319 Plain link to protocol-relative URL with link text
8320 !! wikitext
8321 [[//www.example.com Link text]]
8322 !! html
8323 <p>[<a rel="nofollow" class="external text" href="//www.example.com">Link text</a>]
8324 </p>
8325 !! end
8326
8327 !! test
8328 Plain link to page with question mark in title
8329 !! wikitext
8330 [[A?b]]
8331
8332 [[A?b|Baz]]
8333 !! html
8334 <p><a href="/wiki/A%3Fb" title="A?b">A?b</a>
8335 </p><p><a href="/wiki/A%3Fb" title="A?b">Baz</a>
8336 </p>
8337 !! end
8338
8339 # I'm fairly sure the expected result here is wrong.
8340 # We want these to be URL links, not pseudo-pages with URLs for titles....
8341 # However the current output is also pretty screwy.
8342 #
8343 # ----
8344 # I'm changing it to match the current output--it arguably makes more
8345 # sense in the light of the test above. Old expected result was:
8346 #<p>Piped link to URL: <a href="/index.php?title=Http://www.example.com&amp;action=edit" class="new">an example URL</a>
8347 #</p>
8348 # But I think this test is bordering on "garbage in, garbage out" anyway.
8349 # -- wtm
8350 !! test
8351 Piped link to URL
8352 !! wikitext
8353 Piped link to URL: [[http://www.example.com|an example URL]]
8354 !! html/php
8355 <p>Piped link to URL: [<a rel="nofollow" class="external text" href="http://www.example.com%7Can">example URL</a>]
8356 </p>
8357 !! html/parsoid
8358 <p>Piped link to URL: [<a rel="mw:ExtLink" class="external text" 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>
8359 !! end
8360
8361 !! test
8362 Plain link in template argument
8363 !! options
8364 parsoid=wt2html
8365 !! wikitext
8366 {{echo|[http://www.example.com |123]}}
8367
8368 {{echo|[[http://www.example.com |123]]}}
8369
8370 {{echo|[[http://www.example.com |123]}}
8371
8372 {{echo|[http://www.example.com |123]]}}
8373 !! html/php
8374 <p>[<a rel="nofollow" class="external free" href="http://www.example.com">http://www.example.com</a>
8375 </p><p>[<a rel="nofollow" class="external text" href="http://www.example.com">|123</a>]
8376 </p><p>{{echo|[<a rel="nofollow" class="external text" href="http://www.example.com">|123</a>}}
8377 </p><p>[<a rel="nofollow" class="external free" href="http://www.example.com">http://www.example.com</a>
8378 </p>
8379 !! html/parsoid
8380 <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" class="external free" href="http://www.example.com">http://www.example.com</a> </p>
8381
8382 <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" class="external text" href="http://www.example.com">|123</a>]</p>
8383
8384 <p>{{echo|[<a rel="mw:ExtLink" class="external text" href="http://www.example.com" data-parsoid='{"targetOff":114,"contentOffsets":[114,118],"dsr":[90,119,24,1]}'>|123</a>}}</p>
8385
8386 <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" class="external free" href="http://www.example.com">http://www.example.com</a> </p>
8387 !! end
8388
8389 !! test
8390 T2002: [[page|http://url/]] should link to page, not http://url/
8391 !! wikitext
8392 [[Main Page|http://url/]]
8393 !! html/php
8394 <p><a href="/wiki/Main_Page" title="Main Page">http://url/</a>
8395 </p>
8396 !! html/parsoid
8397 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">http://url/</a></p>
8398 !! end
8399
8400 # Parsoid does not mark self-links, by design.
8401 !! test
8402 T2337: Escaped self-links should be bold
8403 !! options
8404 title=[[Bug462]]
8405 !! wikitext
8406 [[Bu&#103;462]] [[Bug462]]
8407 !! html/php+tidy
8408 <p><a class="mw-selflink selflink">Bu&#103;462</a> <a class="mw-selflink selflink">Bug462</a>
8409 </p>
8410 !! html/parsoid
8411 <p><a rel="mw:WikiLink" href="./Bug462" title="Bug462">Bug462</a> <a rel="mw:WikiLink" href="./Bug462" title="Bug462">Bug462</a></p>
8412 !! end
8413
8414 !! test
8415 Self-link to section should not be bold
8416 !! options
8417 title=[[Main Page]]
8418 !! wikitext
8419 [[Main Page#section]]
8420 !! html
8421 <p><a href="/wiki/Main_Page#section" title="Main Page">Main Page#section</a>
8422 </p>
8423 !! end
8424
8425 !! article
8426 00
8427 !! text
8428 This is 00.
8429 !! endarticle
8430
8431 !!test
8432 Self-link to numeric title
8433 !!options
8434 title=[[0]]
8435 !! wikitext
8436 [[0]]
8437 !! html
8438 <p><a class="mw-selflink selflink">0</a>
8439 </p>
8440 !!end
8441
8442 !!test
8443 Link to numeric-equivalent title
8444 !!options
8445 title=[[0]]
8446 !! wikitext
8447 [[00]]
8448 !! html
8449 <p><a href="/wiki/00" title="00">00</a>
8450 </p>
8451 !!end
8452
8453 !! test
8454 <nowiki> inside a link
8455 !! wikitext
8456 [[Main<nowiki> Page</nowiki>]] [[Main Page|the main page <nowiki>[it's not very good]</nowiki>]]
8457 !! html/php+tidy
8458 <p>[[Main Page]] <a href="/wiki/Main_Page" title="Main Page">the main page [it's not very good]</a>
8459 </p>
8460 !! html/parsoid
8461 <p>[[Main<span typeof="mw:Nowiki"> Page</span>]] <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">the main page <span typeof="mw:Nowiki">[it's not very good]</span></a></p>
8462 !! end
8463
8464 ## Parsoid doesn't get this right and even fails wt2html because, when doing the
8465 ## normalization for comparison, the html serialization / re-parse doesn't
8466 ## roundtrip. This is T49963
8467 !! test
8468 <pre> inside a link
8469 !! wikitext
8470 [[Main<pre> Page</pre>]] [[Main Page|the main page <pre>[it's not very good]</pre>]]
8471 !! html/php+tidy
8472 <p>[[Main</p><pre> Page</pre><p>]] <a href="/wiki/Main_Page" title="Main Page">the main page </a></p><a href="/wiki/Main_Page" title="Main Page"><pre>[it's not very good]</pre></a>
8473 !! html/parsoid
8474 <p>[[Main</p><pre typeof="mw:Extension/pre" about="#mwt4" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":" Page"}}'> Page</pre><p>]] <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">the main page <pre typeof="mw:Extension/pre" about="#mwt6" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"[it&apos;s not very good]"}}'>[it's not very good]</pre></a></p>
8475 !! end
8476
8477 !! test
8478 Non-breaking spaces in title
8479 !! wikitext
8480 [[&nbsp; Main &nbsp; Page &nbsp;]]
8481 !! html
8482 <p><a href="/wiki/Main_Page" title="Main Page">&#160; Main &#160; Page &#160;</a>
8483 </p>
8484 !!end
8485
8486 # Add new article for the test below so that it doesn't red-link
8487 !! article
8488 Foo bar baz
8489 !! text
8490 boo
8491 !! endarticle
8492
8493 !! test
8494 Multiple spaces in titles should normalize to a single underscore
8495 !! options
8496 parsoid=wt2html,wt2wt
8497 !! wikitext
8498 [[Foo bar baz|x]]
8499 [[Foo bar baz|x]]
8500 [[Foo bar baz|x]]
8501 !! html/php
8502 <p><a href="/wiki/Foo_bar_baz" title="Foo bar baz">x</a>
8503 <a href="/wiki/Foo_bar_baz" title="Foo bar baz">x</a>
8504 <a href="/wiki/Foo_bar_baz" title="Foo bar baz">x</a>
8505 </p>
8506 !! html/parsoid
8507 <p><a rel="mw:WikiLink" href="./Foo_bar_baz" title="Foo bar baz">x</a>
8508 <a rel="mw:WikiLink" href="./Foo_bar_baz" title="Foo bar baz">x</a>
8509 <a rel="mw:WikiLink" href="./Foo_bar_baz" title="Foo bar baz">x</a>
8510 </p>
8511 !! end
8512
8513 !! test
8514 Internal link with ca linktrail, surrounded by bold apostrophes (T29473 primary issue)
8515 !! options
8516 language=ca
8517 !! wikitext
8518 '''[[Main Page]]'''
8519 !! html
8520 <p><b><a href="/wiki/Main_Page" title="Main Page">Main Page</a></b>
8521 </p>
8522 !! end
8523
8524 !! test
8525 Internal link with ca linktrail, surrounded by italic apostrophes (T29473 primary issue)
8526 !! options
8527 language=ca
8528 !! wikitext
8529 ''[[Main Page]]''
8530 !! html
8531 <p><i><a href="/wiki/Main_Page" title="Main Page">Main Page</a></i>
8532 </p>
8533 !! end
8534
8535 !! test
8536 Internal link with en linktrail: no apostrophes (T29473)
8537 !! options
8538 language=en
8539 !! wikitext
8540 [[Something]]'nice
8541 !! html
8542 <p><a href="/index.php?title=Something&amp;action=edit&amp;redlink=1" class="new" title="Something (page does not exist)">Something</a>'nice
8543 </p>
8544 !! end
8545
8546 !! test
8547 Internal link with ca linktrail with apostrophes (T29473)
8548 !! options
8549 language=ca
8550 !! wikitext
8551 [[Something]]'nice
8552 !! html
8553 <p><a href="/index.php?title=Something&amp;action=edit&amp;redlink=1" class="new" title="Something (encara no existeix)">Something'nice</a>
8554 </p>
8555 !! end
8556
8557 !! test
8558 Internal link with kaa linktrail with apostrophes (T29473)
8559 !! options
8560 language=kaa
8561 !! wikitext
8562 [[Something]]'nice
8563 !! html
8564 <p><a href="/index.php?title=Something&amp;action=edit&amp;redlink=1" class="new" title="Something (bet ele jaratılmag&#39;an)">Something'nice</a>
8565 </p>
8566 !! end
8567
8568 !! test
8569 Link with multiple ":" in a subpage-supporting namespace (T65636)
8570 !! wikitext
8571 [[User:Foo/Test/63636:Bar|Test]]
8572 !! html/php
8573 <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>
8574 </p>
8575 !! html/parsoid
8576 <p><a rel="mw:WikiLink" href="./User:Foo/Test/63636:Bar" title="User:Foo/Test/63636:Bar">Test</a></p>
8577 !! end
8578
8579 ## Mainly a sanity check for Parsoid
8580 !! test
8581 Handle title parsing for subpages
8582 !! options
8583 title=[[/123123]]
8584 subpage
8585 !! wikitext
8586 123
8587 !! html/php
8588 <p>123
8589 </p>
8590 !! html/parsoid
8591 <p>123</p>
8592 !! end
8593
8594 !! article
8595 User:Test/123
8596 !! text
8597 test 123
8598 !! endarticle
8599
8600 !! test
8601 Link to a subpage from a namespace other than main
8602 !! options
8603 title=[[User:Test]]
8604 subpage
8605 !! wikitext
8606 [[/123]]
8607 !! html/php
8608 <p><a href="/wiki/User:Test/123" title="User:Test/123">/123</a>
8609 </p>
8610 !! html/parsoid
8611 <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>
8612 !! end
8613
8614 !! test
8615 Ensure that transclusion titles are not url-decoded
8616 !! options
8617 subpage title=[[Test]]
8618 parsoid=wt2html
8619 !! wikitext
8620 {{Bar%C3%A9}} {{/Bar%C3%A9}}
8621 !! html/php
8622 <p>{{Bar%C3%A9}} {{/Bar%C3%A9}}
8623 </p>
8624 !! html/parsoid
8625 <p>{{Bar%C3%A9}} {{/Bar%C3%A9}}</p>
8626 !! end
8627
8628 !! test
8629 Purely hash wikilink
8630 !! options
8631 title=[[User:Test/123]]
8632 subpage
8633 !! wikitext
8634 [[#a|b]]
8635 !! html/php
8636 <p><a href="#a">b</a>
8637 </p>
8638 !! html/parsoid
8639 <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>
8640 !! end
8641
8642 !! test
8643 Serialization of purely hash wikilink
8644 !! options
8645 title=[[User:Test/123]]
8646 subpage
8647 parsoid=html2wt
8648 !! html/parsoid
8649 <p><a href="#a">[[</a></p>
8650 !! wikitext
8651 [[#a|<nowiki>[[</nowiki>]]
8652 !! html/php
8653 <p><a href="#a">[[</a>
8654 </p>
8655 !! end
8656
8657 !! test
8658 1. Interaction of linktrail and template encapsulation
8659 !! wikitext
8660 {{echo|[[Foo]]}}l
8661 !! html/php+tidy
8662 <p><a href="/wiki/Foo" title="Foo">Fool</a>
8663 </p>
8664 !! html/parsoid
8665 <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>
8666 !! end
8667
8668 !! test
8669 2. Interaction of linktrail and template encapsulation
8670 !! wikitext
8671 {{echo|Some [[Fool]]}}s
8672 !! html/php+tidy
8673 <p>Some <a href="/index.php?title=Fool&amp;action=edit&amp;redlink=1" class="new" title="Fool (page does not exist)">Fools</a>
8674 </p>
8675 !! html/parsoid
8676 <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>
8677 !! end
8678
8679 !! test
8680 3. Interaction of linktrail and template encapsulation
8681 !! wikitext
8682 {{echo|Some [[Fool]]s are '''bold and foolish'''}}
8683 !! html/php+tidy
8684 <p>Some <a href="/index.php?title=Fool&amp;action=edit&amp;redlink=1" class="new" title="Fool (page does not exist)">Fools</a> are <b>bold and foolish</b>
8685 </p>
8686 !! html/parsoid
8687 <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>
8688 !! end
8689
8690 !! article
8691 Söfnuður
8692 !! text
8693 Test.
8694 !! endarticle
8695
8696 !! test
8697 Internal link with is link prefix
8698 !! options
8699 language=is
8700 !! wikitext
8701 Aðrir mótmælenda[[söfnuður|söfnuðir]] og
8702 !! html
8703 <p>Aðrir <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðir</a> og
8704 </p>
8705 !! end
8706
8707 !! article
8708 Mótmælendatrú
8709 !! text
8710 Test.
8711 !! endarticle
8712
8713 !! test
8714 Internal link with is link trail and link prefix
8715 !! options
8716 language=is
8717 !! wikitext
8718 [[mótmælendatrú|xxx]]ar
8719 [[mótmælendatrú]]ar
8720 mótmælenda[[söfnuður]]
8721 mótmælenda[[söfnuður|söfnuðir]]
8722 mótmælenda[[söfnuður|söfnuðir]]xxx
8723 !! html
8724 <p><a href="/wiki/M%C3%B3tm%C3%A6lendatr%C3%BA" title="Mótmælendatrú">xxxar</a>
8725 <a href="/wiki/M%C3%B3tm%C3%A6lendatr%C3%BA" title="Mótmælendatrú">mótmælendatrúar</a>
8726 <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuður</a>
8727 <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðir</a>
8728 <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðirxxx</a>
8729 </p>
8730 !! end
8731
8732 !! test
8733 Parsoid link trail escaping
8734 !! options
8735 parsoid=html2wt,html2html
8736 !! html/parsoid
8737 <p><a rel="mw:WikiLink" href="./Apple" title="Apple">apple</a>s</p>
8738 !! wikitext
8739 [[apple]]<nowiki/>s
8740 !! end
8741
8742 !! test
8743 Parsoid link prefix escaping
8744 !! options
8745 language=is
8746 parsoid=html2wt,html2html
8747 !! html/parsoid
8748 <p>Aðrir mótmælenda<a rel="mw:WikiLink" href="./Söfnuður" title="Söfnuður">söfnuður</a></p>
8749 !! wikitext
8750 Aðrir mótmælenda<nowiki/>[[söfnuður]]
8751 !! end
8752
8753 !! test
8754 Parsoid link bracket escaping
8755 !! options
8756 parsoid=html2wt,html2html
8757 !! html/parsoid
8758 <p><a rel="mw:WikiLink" href="./Test" title="Test">Test</a></p>
8759 <p>[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]</p>
8760 <p>[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]</p>
8761 <p>[[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]]</p>
8762 <p>[[[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]]]</p>
8763 <p>[[[[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]]]]</p>
8764 !! wikitext
8765 [[Test]]
8766
8767 [<nowiki/>[[Test]]]
8768
8769 [[[[Test]]]]
8770
8771 [[[<nowiki/>[[Test]]]]]
8772
8773 [[[[[[Test]]]]]]
8774
8775 [[[[[<nowiki/>[[Test]]]]]]]
8776 !! end
8777
8778 !! test
8779 Parsoid-centric test: Whitespace in ext- and wiki-links should be preserved
8780 !! wikitext
8781 [[Foo| bar]]
8782
8783 [[Foo| ''bar'']]
8784
8785 [http://wp.org foo]
8786
8787 [http://wp.org ''foo'']
8788 !! html
8789 <p><a href="/wiki/Foo" title="Foo"> bar</a>
8790 </p><p><a href="/wiki/Foo" title="Foo"> <i>bar</i></a>
8791 </p><p><a rel="nofollow" class="external text" href="http://wp.org">foo</a>
8792 </p><p><a rel="nofollow" class="external text" href="http://wp.org"><i>foo</i></a>
8793 </p>
8794 !! end
8795
8796 !! test
8797 Parsoid: Scoped parsing should handle mixed transclusions and plain text
8798 !! wikitext
8799 [[Foo|{{echo|a}} b {{echo|c}}]]
8800 !! html/parsoid
8801 <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>
8802 !! end
8803
8804 !! test
8805 Link with angle bracket after anchor
8806 !! config
8807 wgFragmentMode=[ 'html5', 'legacy' ]
8808 !! wikitext
8809 [[Foo#<bar>]]
8810 !! html/php
8811 <p><a href="/wiki/Foo#&lt;bar&gt;" title="Foo">Foo#&lt;bar&gt;</a>
8812 </p>
8813 !! html/parsoid
8814 <p><a rel="mw:WikiLink" href="./Foo#&lt;bar>" title="Foo" data-parsoid='{"stx":"simple","a":{"href":"./Foo#&lt;bar>"},"sa":{"href":"Foo#&lt;bar>"}}'>Foo#&lt;bar></a></p>
8815 !! end
8816
8817 !! test
8818 Link with angle bracket after anchor (legacy)
8819 !! config
8820 wgFragmentMode=[ 'legacy' ]
8821 !! wikitext
8822 [[Foo#<bar>]]
8823 !! html/php
8824 <p><a href="/wiki/Foo#.3Cbar.3E" title="Foo">Foo#&lt;bar&gt;</a>
8825 </p>
8826 !! end
8827
8828 ###
8829 ### Interwiki links (see maintenance/interwiki.sql)
8830 ###
8831
8832 !! test
8833 Inline interwiki link
8834 !! options
8835 parsoid=wt2html,wt2wt,html2html
8836 !! wikitext
8837 [[MeatBall:SoftSecurity]]
8838 !! html/php
8839 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity" class="extiw" title="meatball:SoftSecurity">MeatBall:SoftSecurity</a>
8840 </p>
8841 !! html/parsoid
8842 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity" title="meatball:SoftSecurity">MeatBall:SoftSecurity</a></p>
8843 !! end
8844
8845 !! test
8846 Inline interwiki link with empty title (T4372)
8847 !! options
8848 parsoid=wt2html,wt2wt,html2html
8849 !! wikitext
8850 [[MeatBall:]]
8851 !! html/php
8852 <p><a href="http://www.usemod.com/cgi-bin/mb.pl" class="extiw" title="meatball:">MeatBall:</a>
8853 </p>
8854 !! html/parsoid
8855 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?" title="meatball:">MeatBall:</a></p>
8856 !! end
8857
8858 ## html2wt and html2html will fail because we will prefer the :en: interwiki prefix over wikipedia:
8859 !! test
8860 Interwiki link encoding conversion (T3636)
8861 !! options
8862 parsoid=wt2html,wt2wt
8863 !! wikitext
8864 *[[Wikipedia:ro:Olteni&#0355;a]]
8865 *[[Wikipedia:ro:Olteni&#355;a]]
8866 !! html/php
8867 <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>
8868 <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>
8869
8870 !! html/php+tidy
8871 <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>
8872 <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>
8873 !! html/parsoid
8874 <ul>
8875 <li><a rel="mw:WikiLink/Interwiki" href="http://en.wikipedia.org/wiki/ro:Olteniţa" title="wikipedia:ro:Olteniţa">Wikipedia:ro:Olteniţa</a></li>
8876 <li><a rel="mw:WikiLink/Interwiki" href="http://en.wikipedia.org/wiki/ro:Olteniţa" title="wikipedia:ro:Olteniţa">Wikipedia:ro:Olteniţa</a></li>
8877 </ul>
8878 !! end
8879
8880 !! test
8881 Interwiki link with fragment (T4130)
8882 !! wikitext
8883 [[MeatBall:SoftSecurity#foo]]
8884 !! html
8885 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity#foo" class="extiw" title="meatball:SoftSecurity">MeatBall:SoftSecurity#foo</a>
8886 </p>
8887 !! end
8888
8889 ## The interwiki case here continued to be legacy escaped because of the
8890 ## default setting of $wgExternalInterwikiFragmentMode
8891 !! test
8892 Link scenarios with escaped fragments
8893 !! options
8894 title=[[Main Page]]
8895 !! config
8896 wgFragmentMode=[ 'html5', 'legacy' ]
8897 !! wikitext
8898 [[#Is this great?]]
8899 [[Foo#Is this great?]]
8900 [[meatball:Foo#Is this great?]]
8901 !! html/php
8902 <p><a href="#Is_this_great?">#Is this great?</a>
8903 <a href="/wiki/Foo#Is_this_great?" title="Foo">Foo#Is this great?</a>
8904 <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>
8905 </p>
8906 !! html/parsoid
8907 <p><a rel="mw:WikiLink" href="./Main_Page#Is_this_great?" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#Is_this_great?"},"sa":{"href":"#Is this great?"}}'>#Is this great?</a>
8908 <a rel="mw:WikiLink" href="./Foo#Is_this_great?" title="Foo" data-parsoid='{"stx":"simple","a":{"href":"./Foo#Is_this_great?"},"sa":{"href":"Foo#Is this great?"}}'>Foo#Is this great?</a>
8909 <a rel="mw:WikiLink/Interwiki" 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>
8910 !! end
8911
8912 !! test
8913 Link scenarios with escaped fragments (legacy)
8914 !! config
8915 wgFragmentMode=[ 'legacy' ]
8916 !! wikitext
8917 [[#Is this great?]]
8918 [[Foo#Is this great?]]
8919 [[meatball:Foo#Is this great?]]
8920 !! html/php
8921 <p><a href="#Is_this_great.3F">#Is this great?</a>
8922 <a href="/wiki/Foo#Is_this_great.3F" title="Foo">Foo#Is this great?</a>
8923 <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>
8924 </p>
8925 !! end
8926
8927 # Ideally the wikipedia: prefix here should be proto-relative too
8928 # [CSA]: this is kind of a bogus test, as the PHP parser test doesn't
8929 # define the 'en' prefix, and originally the test used 'wikipedia',
8930 # which isn't a localinterwiki prefix hence the links to the 'en:Foo'
8931 # article.
8932 !! test
8933 Different interwiki prefixes mapping to the same URL
8934 !! wikitext
8935 [[:en:Foo]]
8936
8937 [[:en:Foo|Foo]]
8938
8939 [[wikipedia:Foo]]
8940
8941 [[:wikipedia:Foo|Foo]]
8942
8943 [[wikipedia:en:Foo]]
8944
8945 [[:wikipedia:en:Foo]]
8946
8947 [[ wikiPEdia :Foo]]
8948 !! html/parsoid
8949 <p><a rel="mw:WikiLink/Interwiki" 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>
8950
8951 <p><a rel="mw:WikiLink/Interwiki" 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>
8952
8953 <p><a rel="mw:WikiLink/Interwiki" 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>
8954
8955 <p><a rel="mw:WikiLink/Interwiki" 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>
8956
8957 <p><a rel="mw:WikiLink/Interwiki" 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>
8958
8959 <p><a rel="mw:WikiLink/Interwiki" 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>
8960
8961 <p><a rel="mw:WikiLink/Interwiki" 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>
8962 !! end
8963
8964 !! test
8965 Interwiki links that cannot be represented in wiki syntax
8966 !! wikitext
8967 [[meatball:ok]]
8968 [[meatball:ok#foo|ok with fragment]]
8969 [[meatball:ok_as_well?|ok ending with ? mark]]
8970 [http://de.wikipedia.org/wiki/Foo?action=history has query]
8971 [http://de.wikipedia.org/wiki/#foo is just fragment]
8972
8973 !! html/php
8974 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?ok" class="extiw" title="meatball:ok">meatball:ok</a>
8975 <a href="http://www.usemod.com/cgi-bin/mb.pl?ok#foo" class="extiw" title="meatball:ok">ok with fragment</a>
8976 <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>
8977 <a rel="nofollow" class="external text" href="http://de.wikipedia.org/wiki/Foo?action=history">has query</a>
8978 <a rel="nofollow" class="external text" href="http://de.wikipedia.org/wiki/#foo">is just fragment</a>
8979 </p>
8980 !! html/parsoid
8981 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?ok" title="meatball:ok">meatball:ok</a>
8982 <a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?ok#foo" title="meatball:ok">ok with fragment</a>
8983 <a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?ok_as_well%3F" title="meatball:ok as well?">ok ending with ? mark</a>
8984 <a rel="mw:ExtLink" class="external text" href="http://de.wikipedia.org/wiki/Foo?action=history">has query</a>
8985 <a rel="mw:ExtLink" class="external text" href="http://de.wikipedia.org/wiki/#foo">is just fragment</a></p>
8986 !! end
8987
8988 !! test
8989 Interwiki links: trail
8990 !! wikitext
8991 [[wikipedia:Foo|Ba]]r
8992 !! html/php
8993 <p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo">Bar</a>
8994 </p>
8995 !! html/parsoid
8996 <p><a rel="mw:WikiLink/Interwiki" 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>
8997 !! end
8998
8999 !! test
9000 Local interwiki link
9001 !! options
9002 parsoid=wt2html,wt2wt,html2html
9003 !! wikitext
9004 [[local:Template:Foo]]
9005 !! html/php
9006 <p><a href="/wiki/Template:Foo" title="Template:Foo">local:Template:Foo</a>
9007 </p>
9008 !! html/parsoid
9009 <p><a rel="mw:WikiLink" href="./Template:Foo" title="Template:Foo">local:Template:Foo</a></p>
9010 !! end
9011
9012 # Parsoid does not mark self-links, by design.
9013 !! test
9014 Local interwiki link: self-link to current page
9015 !! options
9016 title=[[Main Page]]
9017 parsoid=wt2html,wt2wt,html2html
9018 !! wikitext
9019 [[local:Main Page]]
9020 !! html/php
9021 <p><a class="mw-selflink selflink">local:Main Page</a>
9022 </p>
9023 !! html/parsoid
9024 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">local:Main Page</a></p>
9025 !! end
9026
9027 !! test
9028 Local interwiki link: prefix only (T66167)
9029 !! options
9030 parsoid=wt2html,wt2wt,html2html
9031 !! wikitext
9032 [[local:]]
9033 !! html/php
9034 <p><a href="/wiki/Main_Page" title="Main Page">local:</a>
9035 </p>
9036 !! html/parsoid
9037 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">local:</a></p>
9038 !! end
9039
9040 !! test
9041 Local interwiki link: with additional interwiki prefix (T63357)
9042 !! options
9043 parsoid=wt2html,wt2wt,html2html
9044 !! wikitext
9045 [[local:meatball:Hello]]
9046 !! html/php
9047 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?Hello" class="extiw" title="meatball:Hello">local:meatball:Hello</a>
9048 </p>
9049 !! html/parsoid
9050 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?Hello" title="meatball:Hello">local:meatball:Hello</a></p>
9051 !! end
9052
9053 !! test
9054 Multiple local interwiki link prefixes
9055 !! wikitext
9056 [[local:local:local:local:mi:local:Foo]]
9057 !! options
9058 parsoid=wt2html,wt2wt,html2html
9059 !! html/php
9060 <p><a href="/wiki/Foo" title="Foo">local:local:local:local:mi:local:Foo</a>
9061 </p>
9062 !! html/parsoid
9063 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">local:local:local:local:mi:local:Foo</a></p>
9064 !! end
9065
9066 !! test
9067 Interwiki link with percent encoded target
9068 !! wikitext
9069 [[:es:Nueva Guip%C3%BAzcoa|Nueva Guipúzcoa]]
9070 !! html/php
9071 <p><a href="http://es.wikipedia.org/wiki/Nueva_Guip%C3%BAzcoa" class="extiw" title="es:Nueva Guipúzcoa">Nueva Guipúzcoa</a>
9072 </p>
9073 !! html/parsoid
9074 <p><a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/Nueva%20Guipúzcoa" title="es:Nueva Guipúzcoa" data-parsoid='{"stx":"piped","a":{"href":"http://es.wikipedia.org/wiki/Nueva%20Guipúzcoa"},"sa":{"href":":es:Nueva Guip%C3%BAzcoa"},"isIW":true}'>Nueva Guipúzcoa</a></p>
9075 !! end
9076
9077 ###
9078 ### Interlanguage links
9079 ### Language links (so that searching for '### language' matches..)
9080 ###
9081
9082 !! test
9083 Interlanguage link
9084 !! wikitext
9085 Blah blah blah
9086 [[zh:Chinese]]
9087 !! html/php
9088 <p>Blah blah blah
9089 </p>
9090 !! html/parsoid
9091 <p>Blah blah blah</p>
9092 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
9093 !! end
9094
9095 ## parsoid html2wt will lose the space variations
9096 !! test
9097 Interlanguage link with spacing
9098 !! options
9099 parsoid=wt2html,wt2wt,html2html
9100 !! wikitext
9101 Blah blah blah
9102 [[ zh : Chinese ]]
9103 !! html/php
9104 <p>Blah blah blah
9105 </p>
9106 !! html/parsoid
9107 <p>Blah blah blah</p>
9108 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
9109 !! end
9110
9111 !! test
9112 Double interlanguage link
9113 !! wikitext
9114 Blah blah blah
9115 [[es:Spanish]]
9116 [[zh:Chinese]]
9117 !! html/php
9118 <p>Blah blah blah
9119 </p>
9120 !! html/parsoid
9121 <p>Blah blah blah</p>
9122 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Spanish"/>
9123 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
9124 !! end
9125
9126 ## parsoid html2wt will lose the space variations
9127 !! test
9128 Interlanguage link variations
9129 !! options
9130 parsoid=wt2html,wt2wt,html2html
9131 !! wikitext
9132 Blah blah blah
9133 [[ es :Spanish]]
9134 [[ ZH :Chinese]]
9135 [[es:Foo_bar]]
9136 !! html/php
9137 <p>Blah blah blah
9138 </p>
9139 !! html/parsoid
9140 <p>Blah blah blah</p>
9141 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Spanish" />
9142 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese" />
9143 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo_bar" />
9144 !! end
9145
9146 !! test
9147 Escaping of interlanguage links (T129218, T156308)
9148 !! wikitext
9149 Blah blah blah
9150 [[:es:Spanish]]
9151 [[ : zh : Chinese ]]
9152 !! html/php
9153 <p>Blah blah blah
9154 <a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">es:Spanish</a>
9155 <a href="http://zh.wikipedia.org/wiki/Chinese" class="extiw" title="zh:Chinese"> zh : Chinese </a>
9156 </p>
9157 !! html/parsoid
9158 <p>Blah blah blah
9159 <a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">es:Spanish</a>
9160 <a rel="mw:WikiLink/Interwiki" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese"> zh : Chinese </a></p>
9161 !! end
9162
9163 !! test
9164 Multiple colons escaping interlanguage links
9165 !! options
9166 parsoid=wt2html
9167 !! wikitext
9168 [[:es:Spanish]]
9169 [[::es:Spanish]]
9170 [[:::es:Spanish]]
9171 !! html/php
9172 <p><a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">es:Spanish</a>
9173 [[::es:Spanish]]
9174 [[:::es:Spanish]]
9175 </p>
9176 !! html/parsoid
9177 <p><a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">es:Spanish</a>
9178 [[::es:Spanish]]
9179 [[:::es:Spanish]]</p>
9180 !! end
9181
9182 ## parsoid html2wt will normalize the space to _
9183 !! test
9184 Space and question mark encoding in interlanguage links (T95473)
9185 !! options
9186 parsoid=wt2html,wt2wt,html2html
9187 !! wikitext
9188 Blah blah blah
9189 [[es:Foo bar?]]
9190 !! html/php
9191 <p>Blah blah blah
9192 </p>
9193 !! html/parsoid
9194 <p>Blah blah blah</p>
9195 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo_bar%3F" />
9196 !! end
9197
9198 !! test
9199 Interlanguage link, with prefix links
9200 !! options
9201 language=ln
9202 !! wikitext
9203 Blah blah blah
9204 [[zh:Chinese]]
9205 !! html/php
9206 <p>Blah blah blah
9207 </p>
9208 !! html/parsoid
9209 <p>Blah blah blah</p>
9210 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
9211 !! end
9212
9213 !! test
9214 Double interlanguage link, with prefix links (T10897)
9215 !! options
9216 language=ln
9217 !! wikitext
9218 Blah blah blah
9219 [[es:Spanish]]
9220 [[zh:Chinese]]
9221 !! html/php
9222 <p>Blah blah blah
9223 </p>
9224 !! html/parsoid
9225 <p>Blah blah blah</p>
9226 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Spanish"/>
9227 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
9228 !! end
9229
9230 !! test
9231 "Extra" interlanguage links (T34189 / gerrit 111390)
9232 !! wikitext
9233 Blah blah blah
9234 [[mul:Article]]
9235 !! html/php
9236 <p>Blah blah blah
9237 </p>
9238 !! html/parsoid
9239 <p>Blah blah blah</p>
9240 <link rel="mw:PageProp/Language" title="Multilingual" href="http://wikisource.org/wiki/Article"/>
9241 !! end
9242
9243 ## PHP parser tests script needs an update
9244 ## Parsoid html2wt will normalize output to [[:zh:Chinese]]
9245 !! test
9246 Language links render as inline links if $wgInterwikiMagic=false
9247 !! options
9248 wgInterwikiMagic=false
9249 parsoid=wt2html,wt2wt,html2html
9250 !! wikitext
9251 Blah blah blah
9252 [[zh:Chinese]]
9253 !! html/parsoid
9254 <p>Blah blah blah <a rel="mw:WikiLink/Interwiki" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese">zh:Chinese</a></p>
9255 !! end
9256
9257 ## PHP parser tests script needs an update
9258 ## Parsoid html2wt will normalize output to [[:zh:Chinese]]
9259 !! test
9260 Language links render as inline links in the Talk namespace
9261 !! options
9262 title=Talk:Foo
9263 parsoid=wt2html,wt2wt,html2html
9264 !! wikitext
9265 Blah blah blah
9266 [[zh:Chinese]]
9267 !! html/parsoid
9268 <p>Blah blah blah <a rel="mw:WikiLink/Interwiki" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese">zh:Chinese</a></p>
9269 !! end
9270
9271 !! test
9272 Parsoid-specific test: Wikilinks with &nbsp; should RT properly
9273 !! options
9274 language=ln
9275 !! wikitext
9276 [[WW&nbsp;II]]
9277 !! html
9278 <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>
9279 </p>
9280 !! end
9281
9282 !! test
9283 Parsoid T55221: Wikilinks should be properly entity-escaped
9284 !! options
9285 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
9286 !! html/parsoid
9287 <p>He&amp;nbsp;llo <a href="./Foo" rel="mw:WikiLink">He&amp;nbsp;llo</a></p>
9288 <p>He&amp;nbsp;llo <a href="./He&amp;nbsp;llo" rel="mw:WikiLink">He&amp;nbsp;llo</a></p>
9289 !! wikitext
9290 He&amp;nbsp;llo [[Foo|He&amp;nbsp;llo]]
9291
9292 He&amp;nbsp;llo He&amp;nbsp;llo
9293 !! html/php
9294 <p>He&amp;nbsp;llo <a href="/wiki/Foo" title="Foo">He&amp;nbsp;llo</a>
9295 </p><p>He&amp;nbsp;llo He&amp;nbsp;llo
9296 </p>
9297 !! end
9298
9299 # html2wt will fail because of title normalization without data-parsoid
9300 !! test
9301 Parsoid: handle constructor well
9302 !! options
9303 parsoid=wt2html,wt2wt
9304 !! wikitext
9305 [[constructor]]
9306
9307 [[constructor:foo]]
9308 !! html/php
9309 <p><a href="/index.php?title=Constructor&amp;action=edit&amp;redlink=1" class="new" title="Constructor (page does not exist)">constructor</a>
9310 </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>
9311 </p>
9312 !! html/parsoid
9313 <p><a rel="mw:WikiLink" href="./Constructor" title="Constructor" data-parsoid='{"stx":"simple","a":{"href":"./Constructor"},"sa":{"href":"constructor"}}'>constructor</a></p>
9314
9315 <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>
9316 !! end
9317
9318 !! test
9319 Template parameter named "constructor"
9320 !! wikitext
9321 {{echo| constructor = |hi}}
9322 !! html/parsoid
9323 <p about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"constructor","named":true,"spc":[" "," ",""," "]},{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi"},"constructor":{"wt":""}},"i":0}}]}'>hi</p>
9324 !! end
9325
9326 !! article
9327 ko:
9328 !! text
9329 Test.
9330 !! endarticle
9331
9332 # Note that `ko` isn't a known interlanguage prefix
9333 !! test
9334 Parsoid: recognize interlanguage links without a target page
9335 !! options
9336 ill
9337 !! wikitext
9338 [[es:]]
9339
9340 [[ko:]]
9341 !! html/php
9342 es:
9343 !! html/parsoid
9344 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/"/>
9345
9346 <p><a rel="mw:WikiLink" href="./Ko:" title="Ko:">ko:</a></p>
9347 !! end
9348
9349 # Note that `ko` isn't a known interwiki prefix
9350 !! test
9351 Parsoid: recognize interwiki links without a target page
9352 !! options
9353 parsoid=wt2html,wt2wt,html2html
9354 !! wikitext
9355 [[:es:]]
9356
9357 [[:ko:]]
9358 !! html/php
9359 <p><a href="http://es.wikipedia.org/wiki/" class="extiw" title="es:">es:</a>
9360 </p><p><a href="/wiki/Ko:" title="Ko:">ko:</a>
9361 </p>
9362 !! html/parsoid
9363 <p><a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/" title="es:">es:</a></p>
9364 <p><a rel="mw:WikiLink" href="./Ko:" title="Ko:">ko:</a></p>
9365 !! end
9366
9367 !! test
9368 Handle interwiki links pointing to the current wiki as plain wiki links (T47209)
9369 !! wikitext
9370 [[mi:Foo]]
9371 !! html/php
9372 <p><a href="/wiki/Foo" title="Foo">mi:Foo</a>
9373 </p>
9374 !! html/parsoid
9375 <p><a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"simple","a":{"href":"./Foo"},"sa":{"href":"mi:Foo"}}'>mi:Foo</a></p>
9376 !! end
9377
9378 !! test
9379 Interlanguage link with preceding local interwiki link (T70085)
9380 !! options
9381 parsoid=wt2html,wt2wt,html2html
9382 !! wikitext
9383 Blah blah blah
9384 [[local:es:Spanish]]
9385 !! html/php
9386 <p>Blah blah blah
9387 <a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">local:es:Spanish</a>
9388 </p>
9389 !! html/parsoid
9390 <p>Blah blah blah
9391 <a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">local:es:Spanish</a></p>
9392 !! end
9393
9394 !! test
9395 Looks like an interlanguage link, but is actually a local interwiki
9396 !! options
9397 parsoid=wt2html,wt2wt,html2html
9398 !! wikitext
9399 Blah blah blah
9400 [[mi:Template:Foo]]
9401 !! html/php
9402 <p>Blah blah blah
9403 <a href="/wiki/Template:Foo" title="Template:Foo">mi:Template:Foo</a>
9404 </p>
9405 !! html/parsoid
9406 <p>Blah blah blah
9407 <a rel="mw:WikiLink" href="./Template:Foo" title="Template:Foo">mi:Template:Foo</a></p>
9408 !! end
9409
9410 ###
9411 ### Redirects, Parsoid-only
9412 ###
9413
9414 !! test
9415 1. Simple redirect to page
9416 !! wikitext
9417 #REDIRECT [[Main Page]]
9418 !! html/parsoid
9419 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9420 !! end
9421
9422 !! test
9423 2. Other redirect variants
9424 !! wikitext
9425 #REDIRECT [[Main_Page]]
9426 !! html/parsoid
9427 <link rel="mw:PageProp/redirect" href="./Main_Page" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./Main_Page"},"sa":{"href":"Main_Page"}}'/>
9428 !! end
9429
9430 # Not a valid redirect in PHP (although perhaps it was, once upon a time)
9431 # This tests the Parsoid bail-out code.
9432 !! test
9433 3. Other redirect variants
9434 !! options
9435 parsoid=wt2html
9436 !! wikitext
9437 #REDIRECT [[<nowiki>[[Bar]]</nowiki>]]
9438 !! html/parsoid
9439 <ol><li>REDIRECT [[<span typeof="mw:Nowiki">[[Bar]]</span>]]</li></ol>
9440 !! end
9441
9442 !! test
9443 4. Redirect to a templated destination
9444 !! wikitext
9445 #REDIRECT [[{{echo|Foo}}bar]]
9446 !! html/parsoid
9447 <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"}]]}'/>
9448 !! end
9449
9450 !! test
9451 Empty redirect
9452 !! options
9453 parsoid=wt2html,wt2wt
9454 !! wikitext
9455 #REDIRECT [[]]
9456 !! html/parsoid
9457 <ol>
9458 <li>REDIRECT [[]]</li></ol>
9459 !! end
9460
9461 !! test
9462 Optional colon in #REDIRECT
9463 !! options
9464 # the colon is archaic syntax. we support it for wt2html, but we
9465 # don't care that it roundtrips back to the modern syntax.
9466 parsoid=wt2html,html2html
9467 !! wikitext
9468 #REDIRECT:[[Main Page]]
9469 !! html/parsoid
9470 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9471 !! end
9472
9473 !! test
9474 Whitespace in #REDIRECT with optional colon
9475 !! options
9476 # the colon and gratuitous whitespace is archaic syntax. we support
9477 # it for wt2html, but we don't care that it roundtrips back to the
9478 # modern syntax (without extra whitespace)
9479 parsoid=wt2html,html2html
9480 !! wikitext
9481
9482 #REDIRECT
9483 :
9484 [[Main Page]]
9485 !! html/parsoid
9486 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9487 !! end
9488
9489 !! test
9490 Piped link in #REDIRECT
9491 !! options
9492 # content after piped link is ignored. we support this syntax,
9493 # but don't care that the piped link is lost when we roundtrip this.
9494 parsoid=wt2html
9495 !! wikitext
9496 #REDIRECT [[Main Page|bar]]
9497 !! html/parsoid
9498 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9499 !! end
9500
9501 !! test
9502 Redirect to category (T104502)
9503 !! options
9504 parsoid=wt2html,wt2wt
9505 !! wikitext
9506 #REDIRECT [[Category:Foo]]
9507 !! html/parsoid
9508 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
9509 !! end
9510
9511 !! test
9512 Redirect to category with URL encoding (T104502)
9513 !! options
9514 parsoid=wt2html
9515 !! wikitext
9516 #REDIRECT [[Category%3AFoo]]
9517 !! html/parsoid
9518 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
9519 !! end
9520
9521 !! test
9522 Redirect to category page
9523 !! wikitext
9524 #REDIRECT [[:Category:Foo]]
9525 !! html/parsoid
9526 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
9527 !! end
9528
9529 !! test
9530 Redirect to image page (1)
9531 !! wikitext
9532 #REDIRECT [[File:Wiki.png]]
9533 !! html/parsoid
9534 <link rel="mw:PageProp/redirect" href="./File:Wiki.png"/>
9535 !! end
9536
9537 !! test
9538 Redirect to image page (2)
9539 !! wikitext
9540 #REDIRECT [[Image:Wiki.png]]
9541 !! html/parsoid
9542 <link rel="mw:PageProp/redirect" href="./File:Wiki.png" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./File:Wiki.png"},"sa":{"href":"Image:Wiki.png"}}'/>
9543 !! end
9544
9545 # html2wt disabled because wts serializes as "#REDIRECT [[:en:File:Wiki.png]]"
9546 # Next test confirms this.
9547 !! test
9548 Redirect to language (1) (T104918)
9549 !! options
9550 parsoid=wt2html,wt2wt,html2html
9551 !! wikitext
9552 #REDIRECT [[en:File:Wiki.png]]
9553 !! html/parsoid
9554 <link rel="mw:PageProp/redirect" href="//en.wikipedia.org/wiki/File:Wiki.png"/>
9555 !! end
9556
9557 !! test
9558 Redirect to language (2) (T104918)
9559 !! wikitext
9560 #REDIRECT [[:en:File:Wiki.png]]
9561 !! html/parsoid
9562 <link rel="mw:PageProp/redirect" href="//en.wikipedia.org/wiki/File:Wiki.png"/>
9563 !! end
9564
9565 !! test
9566 Redirect to interwiki (T104918)
9567 !! wikitext
9568 #REDIRECT [[meatball:File:Wiki.png]]
9569 !! html/parsoid
9570 <link rel="mw:PageProp/redirect" href="http://www.usemod.com/cgi-bin/mb.pl?File:Wiki.png"/>
9571 !! end
9572
9573 !! test
9574 Non-English #REDIRECT
9575 !! options
9576 language=is
9577 !! wikitext
9578 #TILVÍSUN [[Main Page]]
9579 !! html/parsoid
9580 <link rel="mw:PageProp/redirect" href="./Main_Page" data-parsoid='{"src":"#TILVÍSUN ","a":{"href":"./Main_Page"},"sa":{"href":"Main Page"}}'/>
9581 !! end
9582
9583 !! test
9584 Redirect syntax under text isn't considered a redirect
9585 !! wikitext
9586 some text
9587
9588 #redirect [[Main Page]]
9589 !! html/parsoid
9590 <p>some text</p>
9591 <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>
9592 !! end
9593
9594 !! test
9595 New redirect
9596 !! options
9597 parsoid=html2wt
9598 !! html/parsoid
9599 <p>Foo<link rel="mw:PageProp/redirect" href="./Foo"/></p>
9600 !! wikitext
9601 #REDIRECT [[Foo]]
9602 Foo
9603 !! end
9604
9605 !! test
9606 Redirect followed by block on the same line
9607 !! options
9608 parsoid=wt2html
9609 !! wikitext
9610 #REDIRECT [[Main Page]]<!-- haha -->==hi==
9611 !! html/parsoid
9612 <link rel="mw:PageProp/redirect" href="./Main_Page"/><!-- haha --><h2 id="hi">hi</h2>
9613 !! end
9614
9615 !! test
9616 Redirect followed by a newline
9617 !! wikitext
9618 #REDIRECT [[Main Page]]
9619 A newline
9620 !! html/parsoid
9621 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9622 <p>A newline</p>
9623 !! end
9624
9625 !! test
9626 Redirect followed by multiple newlines
9627 !! wikitext
9628 #REDIRECT [[Main Page]]
9629
9630
9631 A newline
9632 !! html/parsoid
9633 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9634
9635 <p><br/>
9636 A newline</p>
9637 !! end
9638
9639 !! test
9640 Drop duplicate redirects
9641 !! options
9642 parsoid=html2wt
9643 !! html/parsoid
9644 <link rel="mw:PageProp/redirect" href="./Foo"/>
9645 <link rel="mw:PageProp/redirect" href="./Bar"/>
9646 <link rel="mw:PageProp/redirect" href="./Baz"/>
9647 !! wikitext
9648 #REDIRECT [[Foo]]
9649 !! end
9650
9651 ##
9652 ## XHTML tidiness
9653 ###
9654
9655 !! test
9656 <br> to <br />
9657 !! wikitext
9658 1<br>2<br />3
9659 !! html
9660 <p>1<br />2<br />3
9661 </p>
9662 !! end
9663
9664 !! test
9665 Broken br tag sanitization
9666 !! wikitext
9667 </br>
9668 !! html/php
9669 <p>&lt;/br&gt;
9670 </p>
9671 !! end
9672
9673 # TODO: Fix html2html mode (T53055)!
9674 !! test
9675 Parsoid: Broken br tag recognition
9676 !! options
9677 parsoid=wt2html
9678 !! wikitext
9679 </br>
9680
9681 <br/ >
9682 !! html+tidy
9683 <p><br />
9684 </p><p><br />
9685 </p>
9686 !! end
9687
9688 !! test
9689 Incorrecly removing closing slashes from correctly formed XHTML
9690 !! wikitext
9691 <br style="clear:both;" />
9692 !! html
9693 <p><br style="clear:both;" />
9694 </p>
9695 !! end
9696
9697 !! test
9698 Failing to transform badly formed HTML into correct XHTML
9699 !! wikitext
9700 <br style="clear: left;">
9701 <br style="clear: right;">
9702 <br style="clear: both;">
9703 !! html
9704 <p><br style="clear: left;" />
9705 <br style="clear: right;" />
9706 <br style="clear: both;" />
9707 </p>
9708 !!end
9709
9710 ## FIXME: Is Parsoid's acceptance of self-closing html-tags
9711 ## a feature or a bug? See https://phabricator.wikimedia.org/T76962
9712 !! test
9713 Handling html with a div self-closing tag
9714 !! wikitext
9715 <div title />
9716 <div title/>
9717 <div title/ >
9718 <div title=bar />
9719 <div title=bar/>
9720 <div title=bar/ >
9721 !! html/php+tidy
9722 <div title=""></div>
9723 <div title=""></div>
9724 <div title="">
9725 <div title="bar"></div>
9726 <div title="bar"></div>
9727 <div title="bar/">
9728 </div></div>
9729 !! html/parsoid
9730 <div title="" data-parsoid='{"stx":"html","selfClose":true}'></div>
9731 <div title="" data-parsoid='{"stx":"html","selfClose":true}'></div>
9732 <div title="" data-parsoid='{"stx":"html","autoInsertedEnd":true}'>
9733 <div title="bar" data-parsoid='{"stx":"html","selfClose":true}'></div>
9734 <div title="bar" data-parsoid='{"stx":"html","selfClose":true}'></div>
9735 <div title="bar/" data-parsoid='{"stx":"html","autoInsertedEnd":true}'></div></div>
9736 !! end
9737
9738 !! test
9739 Elements with solidus in various attribute positions
9740 !! options
9741 parsoid=wt2html,html2html
9742 !! wikitext
9743 <div cla/ss="123">ha</div>
9744
9745 <div / class="123">ha</div>
9746
9747 <div class= / "123">ha</div>
9748 !! html/php+tidy
9749 <div>ha</div>
9750 <div class="123">ha</div>
9751 <div class="/">ha</div>
9752 !! html/parsoid
9753 <div data-parsoid='{"stx":"html","a":{"cla":null,"ss":null},"sa":{"cla":"","ss":"123"}}'>ha</div>
9754
9755 <div class="123" data-parsoid='{"stx":"html"}'>ha</div>
9756
9757 <div class="/" data-parsoid='{"stx":"html","a":{"\"123\"":null},"sa":{"\"123\"":""}}'>ha</div>
9758 !! end
9759
9760 !! test
9761 Handling html with a br self-closing tag
9762 !! wikitext
9763 <br title />
9764 <br title/>
9765 <br title/ >
9766 <br title=bar />
9767 <br title=bar/>
9768 <br title=bar/ >
9769 !! html/php+tidy
9770 <p><br title="" />
9771 <br title="" />
9772 <br title="" />
9773 <br title="bar" />
9774 <br title="bar" />
9775 <br title="bar/" />
9776 </p>
9777 !! html/parsoid
9778 <p><br title="" />
9779 <br title="" />
9780 <br title="" />
9781 <br title="bar" />
9782 <br title="bar" />
9783 <br title="bar/" />
9784 </p>
9785 !! end
9786
9787 !! test
9788 Quoted attributes without spaces
9789 !! options
9790 parsoid=wt2html
9791 !! wikitext
9792 <div class="foo"style="color:red">red</div>
9793 !! html/php+tidy
9794 <div class="foo" style="color:red">red</div>
9795 !! html/parsoid
9796 <div class="foo" style="color:red">red</div>
9797 !! end
9798
9799 !! test
9800 Horizontal ruler (should it add that extra space?)
9801 !! wikitext
9802 <hr>
9803 <hr >
9804 foo <hr
9805 > bar
9806 !! html+tidy
9807 <hr />
9808 <hr /><p>
9809 foo </p><hr /><p> bar
9810 </p>
9811 !! end
9812
9813 !! test
9814 Horizontal ruler -- 4+ dashes render hr
9815 !! wikitext
9816 ----
9817 !! html
9818 <hr />
9819
9820 !! end
9821
9822 !! test
9823 Horizontal ruler -- eats additional dashes on the same line
9824 !! wikitext
9825 ---------
9826 !! html
9827 <hr />
9828
9829 !! end
9830
9831 !! test
9832 Horizontal ruler -- does not collapse dashes on consecutive lines
9833 !! wikitext
9834 ----
9835 ----
9836 !! html
9837 <hr />
9838 <hr />
9839
9840 !! end
9841
9842 !! test
9843 Horizontal ruler -- <4 dashes render as plain text
9844 !! wikitext
9845 ---
9846 !! html
9847 <p>---
9848 </p>
9849 !! end
9850
9851 !! test
9852 Horizontal ruler -- Supports content following dashes on same line
9853 !! wikitext
9854 ---- Foo
9855 !! html
9856 <hr /> Foo
9857
9858 !! html+tidy
9859 <hr /><p> Foo
9860 </p>
9861 !! end
9862
9863 ###
9864 ### Block-level elements
9865 ###
9866 !! test
9867 Common list
9868 !! wikitext
9869 *Common list
9870 *item 2
9871 *item 3
9872 !! html
9873 <ul><li>Common list</li>
9874 <li>item 2</li>
9875 <li>item 3</li></ul>
9876
9877 !! end
9878
9879 !! test
9880 Numbered list
9881 !! wikitext
9882 #Numbered list
9883 #item 2
9884 #item 3
9885 !! html
9886 <ol><li>Numbered list</li>
9887 <li>item 2</li>
9888 <li>item 3</li></ol>
9889
9890 !! end
9891
9892 # the switch from level 3 to ordered should not introduce a newline between
9893 !! test
9894 Mixed list
9895 !! wikitext
9896 *Mixed list
9897 *#with numbers
9898 **and bullets
9899 *#and numbers
9900 *bullets again
9901 **bullet level 2
9902 ***bullet level 3
9903 ***#Number on level 4
9904 **bullet level 2
9905 **#Number on level 3
9906 **#Number on level 3
9907 *#number level 2
9908 *Level 1
9909 ***Level 3
9910 #**Level 3, but ordered
9911 !! html
9912 <ul><li>Mixed list
9913 <ol><li>with numbers</li></ol>
9914 <ul><li>and bullets</li></ul>
9915 <ol><li>and numbers</li></ol></li>
9916 <li>bullets again
9917 <ul><li>bullet level 2
9918 <ul><li>bullet level 3
9919 <ol><li>Number on level 4</li></ol></li></ul></li>
9920 <li>bullet level 2
9921 <ol><li>Number on level 3</li>
9922 <li>Number on level 3</li></ol></li></ul>
9923 <ol><li>number level 2</li></ol></li>
9924 <li>Level 1
9925 <ul><li><ul><li>Level 3</li></ul></li></ul></li></ul>
9926 <ol><li><ul><li><ul><li>Level 3, but ordered</li></ul></li></ul></li></ol>
9927
9928 !! end
9929
9930 !! test
9931 1. Nested mixed wikitext and html list
9932 !! wikitext
9933 *hi
9934 *<ul><li>ho</li></ul>
9935 *hi
9936 **ho
9937 !! html/php
9938 <ul><li>hi</li>
9939 <li><ul><li>ho</li></ul></li>
9940 <li>hi
9941 <ul><li>ho</li></ul></li></ul>
9942
9943 !! html/parsoid
9944 <ul><li>hi</li>
9945 <li><ul data-parsoid='{"stx":"html"}'><li data-parsoid='{"stx":"html"}'>ho</li></ul></li>
9946 <li>hi
9947 <ul><li>ho</li></ul></li></ul>
9948 !! end
9949
9950 !! test
9951 2. Nested mixed wikitext and html list (incompatible)
9952 !! wikitext
9953 ;hi
9954 :{{echo|<li>ho</li>}}
9955 !! html/php
9956 <dl><dt>hi</dt>
9957 <dd><li>ho</li></dd></dl>
9958
9959 !! html/parsoid
9960 <dl><dt>hi</dt>
9961 <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>
9962 !! end
9963
9964 !! test
9965 Nested lists 1
9966 !! wikitext
9967 *foo
9968 **bar
9969 !! html
9970 <ul><li>foo
9971 <ul><li>bar</li></ul></li></ul>
9972
9973 !! end
9974
9975 !! test
9976 Nested lists 2
9977 !! wikitext
9978 **foo
9979 *bar
9980 !! html
9981 <ul><li><ul><li>foo</li></ul></li>
9982 <li>bar</li></ul>
9983
9984 !! end
9985
9986 !! test
9987 Nested lists 3 (first element empty)
9988 !! wikitext
9989 *
9990 **bar
9991 !! html
9992 <ul><li>
9993 <ul><li>bar</li></ul></li></ul>
9994
9995 !! end
9996
9997 !! test
9998 Nested lists 4 (first element empty)
9999 !! wikitext
10000 **
10001 *bar
10002 !! html
10003 <ul><li><ul><li></li></ul></li>
10004 <li>bar</li></ul>
10005
10006 !! end
10007
10008 !! test
10009 Nested lists 5 (both elements empty)
10010 !! wikitext
10011 **
10012 *
10013 !! html
10014 <ul><li><ul><li></li></ul></li>
10015 <li></li></ul>
10016
10017 !! end
10018
10019 !! test
10020 Nested lists 6 (both elements empty)
10021 !! wikitext
10022 *
10023 **
10024 !! html
10025 <ul><li>
10026 <ul><li></li></ul></li></ul>
10027
10028 !! end
10029
10030 !! test
10031 Nested lists 7 (skip initial nesting levels)
10032 !! wikitext
10033 ***foo
10034 !! html
10035 <ul><li><ul><li><ul><li>foo</li></ul></li></ul></li></ul>
10036
10037 !! end
10038
10039 !! test
10040 Nested lists 8 (multiple nesting transitions)
10041 !! wikitext
10042 *foo
10043 ***bar
10044 **baz
10045 *boo
10046 !! html
10047 <ul><li>foo
10048 <ul><li><ul><li>bar</li></ul></li>
10049 <li>baz</li></ul></li>
10050 <li>boo</li></ul>
10051
10052 !! end
10053
10054 # XXX this test should be moved to citeParserTests, since it depends
10055 # on the Cite extension, which is "built in" to Parsoid.
10056 !! test
10057 Nested lists 9 (extension interaction)
10058 !! wikitext
10059 *<references />
10060 !! html/php+tidy-DISABLED
10061 <ul><li class="mw-empty-elt"></li></ul>
10062 !! html/parsoid
10063 <ul><li data-parsoid='{}'><ol class="mw-references references" typeof="mw:Extension/references" about="#mwt2" data-parsoid='{}' data-mw='{"name":"references","attrs":{}}'></ol></li></ul>
10064 !! end
10065
10066 !! test
10067 1. Lists with start-of-line-transparent tokens before bullets: Comments
10068 !! wikitext
10069 *foo
10070 *<!--cmt-->bar
10071 <!--cmt-->*baz
10072 !! html
10073 <ul><li>foo</li>
10074 <li>bar</li>
10075 <li>baz</li></ul>
10076
10077 !! end
10078
10079 !! test
10080 Nested lists 10 (list and span siblings: wt2wt regression)
10081 !! wikitext
10082 *a <span>x</span>
10083 **b <span>y</span>
10084 !! html/parsoid
10085 <ul><li>a <span>x</span>
10086 <ul><li>b <span>y</span></li></ul></li></ul>
10087 !! end
10088
10089 !! test
10090 2. Lists with start-of-line-transparent tokens before bullets: Template close
10091 !! wikitext
10092 *foo {{echo|bar
10093 }}*baz
10094 !! html
10095 <ul><li>foo bar</li>
10096 <li>baz</li></ul>
10097
10098 !! end
10099
10100 !! test
10101 List items are not parsed correctly following a <pre> block (T2785)
10102 !! wikitext
10103 *<pre>foo</pre>
10104 *<pre>bar</pre>
10105 *zar
10106 !! html/php
10107 <ul><li><pre>foo</pre></li>
10108 <li><pre>bar</pre></li>
10109 <li>zar</li></ul>
10110
10111 !! html/parsoid
10112 <ul><li><pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo"}}'>foo</pre></li>
10113 <li><pre typeof="mw:Extension/pre" about="#mwt4" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"bar"}}'>bar</pre></li>
10114 <li>zar</li></ul>
10115 !! end
10116
10117 # FIXME: Might benefit from a html/parsoid since this has a template
10118 !! test
10119 List items from template
10120 !! wikitext
10121
10122 {{inner list}}
10123 *item 2
10124
10125 *item 0
10126 {{inner list}}
10127 *item 2
10128
10129 *item 0
10130 *notSOL{{inner list}}
10131 *item 2
10132 !! html
10133 <ul><li>item 1</li>
10134 <li>item 2</li></ul>
10135 <ul><li>item 0</li>
10136 <li>item 1</li>
10137 <li>item 2</li></ul>
10138 <ul><li>item 0</li>
10139 <li>notSOL</li>
10140 <li>item 1</li>
10141 <li>item 2</li></ul>
10142
10143 !! end
10144
10145 !! test
10146 List interrupted by empty line or heading
10147 !! wikitext
10148 *foo
10149
10150 **bar
10151 ==A heading==
10152 *Another list item
10153 !! html
10154 <ul><li>foo</li></ul>
10155 <ul><li><ul><li>bar</li></ul></li></ul>
10156 <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>
10157 <ul><li>Another list item</li></ul>
10158
10159 !!end
10160
10161 !! test
10162 Multiple list tags generated by templates
10163 !! wikitext
10164 {{echo|<li>}}a
10165 {{echo|<li>}}b
10166 {{echo|<li>}}c
10167 !! html
10168 <li>a
10169 <li>b
10170 <li>c</li>
10171 </li>
10172 </li>
10173
10174
10175 !! html+tidy
10176 <li>a
10177 </li><li>b
10178 </li><li>c
10179 </li>
10180 !! html/parsoid
10181 <li 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;li>"}},"i":0}},"a"]}'>a</li>
10182 <li about="#mwt2" 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;li>"}},"i":0}},"b"]}'>b</li>
10183 <li about="#mwt3" 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;li>"}},"i":0}},"c"]}'>c</li>
10184 !! end
10185
10186 !! test
10187 Multiple newlines in between HTML list items don't induce paragraph wrapping
10188 !! wikitext
10189 <ul>
10190 <li>hi</li>
10191
10192
10193
10194
10195 <li>ho</li>
10196 </ul>
10197
10198 <dl>
10199 <dt>hi</dt>
10200 <dd>ho<div>123</div>
10201 </dd>
10202
10203
10204 </dl>
10205 !! html/php+tidy
10206 <ul>
10207 <li>hi</li>
10208
10209
10210
10211
10212 <li>ho</li>
10213 </ul>
10214 <dl>
10215 <dt>hi</dt>
10216 <dd>ho<div>123</div>
10217 </dd>
10218
10219
10220 </dl>
10221 !! end
10222
10223 !!test
10224 Single-comment whitespace lines dont break lists, and neither do multi-comment whitespace lines
10225 !! wikitext
10226 *a
10227 <!--This line will NOT split the list-->
10228 *b
10229 <!--This line will NOT split the list either-->
10230 *c
10231 <!--foo--> <!----> <!--This line NOT split the list either-->
10232 *d
10233 !! html
10234 <ul><li>a</li>
10235 <li>b</li>
10236 <li>c</li>
10237 <li>d</li></ul>
10238
10239 !!end
10240
10241 !!test
10242 Replacing whitespace with tabs still doesn't break the list (gerrit 78327)
10243 !! wikitext
10244 *a
10245 <!--This line will NOT split the list-->
10246 *b
10247 <!--This line will NOT split the list either-->
10248 *c
10249 <!--foo--> <!----> <!--This line NOT split the list
10250 either-->
10251 *d
10252 !! html
10253 <ul><li>a</li>
10254 <li>b</li>
10255 <li>c</li>
10256 <li>d</li></ul>
10257
10258 !!end
10259
10260 # FIXME: Parsoid has a dedicated DOM pass to mimic this Tidy-specific li-hack
10261 # That pass could possibly be removed.
10262 !!test
10263 Test the li-hack (a hack from Tidy days, but doesn't work as advertised with Remex)
10264 !!options
10265 parsoid=wt2html,wt2wt
10266 !! wikitext
10267 *foo
10268 *<li>li-hack
10269 *{{echo|<li>templated li-hack}}
10270 *<!--foo--><li> unsupported li-hack with preceding comments
10271
10272 <ul>
10273 <li><li>not a li-hack
10274 </li>
10275 </ul>
10276 !! html+tidy
10277 <ul><li>foo</li>
10278 <li class="mw-empty-elt"></li><li>li-hack</li>
10279 <li class="mw-empty-elt"></li><li>templated li-hack</li>
10280 <li class="mw-empty-elt"></li><li> unsupported li-hack with preceding comments</li></ul>
10281 <ul>
10282 <li class="mw-empty-elt"></li><li>not a li-hack
10283 </li>
10284 </ul>
10285 !! html/parsoid
10286 <ul><li> foo</li>
10287 <li data-parsoid='{"stx":"html","autoInsertedEnd":true,"liHackSrc":"*"}'>li-hack</li>
10288 <li 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;li>templated li-hack"}},"i":0}}]}'>templated li-hack</li>
10289 <li data-parsoid='{"autoInsertedEnd":true}'><!--foo--></li><li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>unsupported li-hack with preceding comments</li></ul>
10290
10291 <ul data-parsoid='{"stx":"html"}'>
10292 <li class="mw-empty-elt" data-parsoid='{"stx":"html","autoInsertedEnd":true}'></li><li data-parsoid='{"stx":"html"}'>not a li-hack
10293 </li>
10294 </ul>
10295
10296 !!end
10297
10298 !! test
10299 Parsoid: Make sure nested lists are serialized on their own line even if HTML contains no newlines
10300 !! wikitext
10301 #foo
10302 ##bar
10303
10304 *foo
10305 **bar
10306
10307 :foo
10308 ::bar
10309 !! html/php+tidy
10310 <ol><li>foo
10311 <ol><li>bar</li></ol></li></ol>
10312 <ul><li>foo
10313 <ul><li>bar</li></ul></li></ul>
10314 <dl><dd>foo
10315 <dl><dd>bar</dd></dl></dd></dl>
10316 !! html/parsoid
10317 <ol>
10318 <li>foo<ol>
10319 <li>bar</li>
10320 </ol></li>
10321 </ol><ul>
10322 <li>foo<ul>
10323 <li>bar</li>
10324 </ul></li>
10325 </ul><dl>
10326 <dd>foo<dl>
10327 <dd>bar</dd>
10328 </dl></dd>
10329 </dl>
10330 !! end
10331
10332 !! test
10333 Parsoid: Test of whitespace serialization with Templated bullets
10334 !! options
10335 parsoid=wt2html
10336 !! wikitext
10337 * {{bullet}}
10338 !! html/parsoid
10339 <ul>
10340 <li class="mw-empty-elt"> </li><li about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"bullet","href":"./Template:Bullet"},"params":{},"i":0}}]}'> Bar</li>
10341 </ul>
10342 !! end
10343
10344 # ------------------------------------------------------------------------
10345 # The next set of tests are about Parsoid's ability to handle badly nested
10346 # tags (parse, minimize scope of fixup, and roundtrip back)
10347 # ------------------------------------------------------------------------
10348
10349 # Remex and Parsoid output stems from list handling diffs because Parsoid & PHP parser.
10350 # Parsoid's list handling is more aware of block structure.
10351 !! test
10352 Unbalanced closing block tags break a list
10353 !! wikitext
10354 <div>
10355 *a</div><div>
10356 *b</div>
10357 !! html+tidy
10358 <div>
10359 <ul><li>a</li></ul></div><div>
10360 <li>b</li></div>
10361 !! html/parsoid
10362 <div><ul>
10363 <li>a</li>
10364 </ul></div>
10365 <div><ul>
10366 <li>b</li>
10367 </ul></div>
10368 !! end
10369
10370 !! test
10371 Unbalanced closing non-block tags don't break a list
10372 !! options
10373 parsoid=wt2html,html2html
10374 !! wikitext
10375 <span>
10376 *a</span><span>
10377 *b</span>
10378 !! html/php+tidy
10379 <p><span>
10380 </span></p>
10381 <ul><li>a<span></span></li>
10382 <li>b</li></ul>
10383 !! html/parsoid
10384 <p><span data-parsoid='{"stx":"html","autoInsertedEnd":true}'></span></p>
10385 <ul><li>a<span data-parsoid='{"stx":"html","autoInsertedEnd":true}'></span></li>
10386 <li>b</li></ul>
10387 !! end
10388
10389 # Parsoid does some post-dom-building cleanup
10390 # which is why its output differs from Remex.
10391 !! test
10392 Unclosed formatting tags that straddle lists are closed and reopened
10393 !! options
10394 parsoid=wt2html,wt2wt,html2html
10395 !! wikitext
10396 #<s> a
10397 #b </s>
10398 !! html/php+tidy
10399 <ol><li><s> a</s></li><s>
10400 </s><li><s>b </s></li></ol>
10401 !! html/parsoid
10402 <ol><li><s> a</s></li>
10403 <li><s>b </s></li></ol>
10404 !! end
10405
10406 # Output is ugly because of all the misnested tag fixups.
10407 !! test
10408 1. List embedded in a formatting tag
10409 !! wikitext
10410 <small>
10411 *foo
10412 </small>
10413 !! html/php+tidy
10414 <p><small>
10415 </small></p><small><ul><li>foo</li></ul></small><small></small><p><small></small>
10416 </p>
10417 !! html/parsoid
10418 <p><small data-parsoid='{"stx":"html","autoInsertedEnd":true}'></small></p><small data-parsoid='{"stx":"html","autoInsertedEnd":true,"autoInsertedStart":true}'>
10419 <ul><li data-parsoid='{}'>foo</li></ul></small>
10420 <p><small data-parsoid='{"stx":"html","autoInsertedStart":true}'></small></p>
10421 !! end
10422
10423 # Output is ugly because of all the misnested tag fixups.
10424 !! test
10425 2. List embedded in a formatting tag in a misnested way
10426 !! wikitext
10427 <small>
10428 *a
10429 *b</small>
10430 !! html/php+tidy
10431 <p><small>
10432 </small></p><small></small><ul><small><li>a</li>
10433 </small><li><small>b</small></li></ul>
10434 !! html/parsoid
10435 <p><small data-parsoid='{"stx":"html","autoInsertedEnd":true}'></small></p>
10436 <ul><small data-parsoid='{"stx":"html","autoInsertedEnd":true,"autoInsertedStart":true}'><li>a</li></small>
10437 <li><small data-parsoid='{"stx":"html","autoInsertedStart":true}'>b</small></li></ul>
10438 !! end
10439
10440 # Output is ugly because of all the misnested tag fixups.
10441 !! test
10442 3. List embedded in a formatting tag in a misnested way
10443 !! wikitext
10444 <small>
10445
10446 ** 123</small>
10447 !! html/php+tidy
10448 <p><small>
10449 </small></p><small></small><ul><small></small><li><small></small><ul><small></small><li><small>123</small></li></ul></li></ul>
10450 !! html/parsoid
10451 <p><small data-parsoid='{"stx":"html","autoInsertedEnd":true}'></small></p>
10452
10453 <ul><li><ul><li data-parsoid='{}'><small data-parsoid='{"stx":"html","autoInsertedStart":true}'> 123</small></li></ul></li></ul>
10454 !! end
10455
10456 ###
10457 ### Magic Words
10458 ###
10459
10460 # Note that the current date is hard-coded as
10461 # 1970-01-01T00:02:03Z (a Thursday)
10462 # when running parser tests. The timezone is also fixed to GMT, so
10463 # local date will be identical to current date.
10464
10465 !! test
10466 Magic Word: {{CURRENTDAY}}
10467 !! wikitext
10468 {{CURRENTDAY}}
10469 !! html
10470 <p>1
10471 </p>
10472 !! end
10473
10474 !! test
10475 Magic Word: {{CURRENTDAY2}}
10476 !! wikitext
10477 {{CURRENTDAY2}}
10478 !! html
10479 <p>01
10480 </p>
10481 !! end
10482
10483 !! test
10484 Magic Word: {{CURRENTDAYNAME}}
10485 !! wikitext
10486 {{CURRENTDAYNAME}}
10487 !! html
10488 <p>Thursday
10489 </p>
10490 !! end
10491
10492 !! test
10493 Magic Word: {{CURRENTDOW}}
10494 !! wikitext
10495 {{CURRENTDOW}}
10496 !! html
10497 <p>4
10498 </p>
10499 !! end
10500
10501 !! test
10502 Magic Word: {{CURRENTMONTH}}
10503 !! wikitext
10504 {{CURRENTMONTH}}
10505 !! html
10506 <p>01
10507 </p>
10508 !! end
10509
10510 !! test
10511 Magic Word: {{CURRENTMONTH1}}
10512 !! wikitext
10513 {{CURRENTMONTH1}}
10514 !! html
10515 <p>1
10516 </p>
10517 !! end
10518
10519 !! test
10520 Magic Word: {{CURRENTMONTHABBREV}}
10521 !! wikitext
10522 {{CURRENTMONTHABBREV}}
10523 !! html
10524 <p>Jan
10525 </p>
10526 !! end
10527
10528 !! test
10529 Magic Word: {{CURRENTMONTHNAME}}
10530 !! wikitext
10531 {{CURRENTMONTHNAME}}
10532 !! html
10533 <p>January
10534 </p>
10535 !! end
10536
10537 !! test
10538 Magic Word: {{CURRENTMONTHNAMEGEN}}
10539 !! wikitext
10540 {{CURRENTMONTHNAMEGEN}}
10541 !! html
10542 <p>January
10543 </p>
10544 !! end
10545
10546 !! test
10547 Magic Word: {{CURRENTTIME}}
10548 !! wikitext
10549 {{CURRENTTIME}}
10550 !! html
10551 <p>00:02
10552 </p>
10553 !! end
10554
10555 !! test
10556 Magic Word: {{CURRENTHOUR}}
10557 !! wikitext
10558 {{CURRENTHOUR}}
10559 !! html
10560 <p>00
10561 </p>
10562 !! end
10563
10564 !! test
10565 Magic Word: {{CURRENTWEEK}} (T6594)
10566 !! wikitext
10567 {{CURRENTWEEK}}
10568 !! html
10569 <p>1
10570 </p>
10571 !! end
10572
10573 !! test
10574 Magic Word: {{CURRENTYEAR}}
10575 !! wikitext
10576 {{CURRENTYEAR}}
10577 !! html
10578 <p>1970
10579 </p>
10580 !! end
10581
10582 !! test
10583 Magic Word: {{CURRENTTIMESTAMP}}
10584 !! wikitext
10585 {{CURRENTTIMESTAMP}}
10586 !! html
10587 <p>19700101000203
10588 </p>
10589 !! end
10590
10591 !! test
10592 Magic Words LOCAL (UTC)
10593 !! wikitext
10594 *{{LOCALMONTH}}
10595 *{{LOCALMONTH1}}
10596 *{{LOCALMONTHNAME}}
10597 *{{LOCALMONTHNAMEGEN}}
10598 *{{LOCALMONTHABBREV}}
10599 *{{LOCALDAY}}
10600 *{{LOCALDAY2}}
10601 *{{LOCALDAYNAME}}
10602 *{{LOCALYEAR}}
10603 *{{LOCALTIME}}
10604 *{{LOCALHOUR}}
10605 *{{LOCALWEEK}}
10606 *{{LOCALDOW}}
10607 *{{LOCALTIMESTAMP}}
10608 !! html
10609 <ul><li>01</li>
10610 <li>1</li>
10611 <li>January</li>
10612 <li>January</li>
10613 <li>Jan</li>
10614 <li>1</li>
10615 <li>01</li>
10616 <li>Thursday</li>
10617 <li>1970</li>
10618 <li>00:02</li>
10619 <li>00</li>
10620 <li>1</li>
10621 <li>4</li>
10622 <li>19700101000203</li></ul>
10623
10624 !! end
10625
10626 !! test
10627 Magic Word: {{FULLPAGENAME}}
10628 !! options
10629 title=[[User:Ævar Arnfjörð Bjarmason]]
10630 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10631 !! wikitext
10632 {{FULLPAGENAME}}
10633 !! html/*
10634 <p>User:Ævar Arnfjörð Bjarmason
10635 </p>
10636 !! end
10637
10638 !! test
10639 Magic Word: {{FULLPAGENAMEE}}
10640 !! options
10641 title=[[User:Ævar Arnfjörð Bjarmason]]
10642 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10643 !! wikitext
10644 {{FULLPAGENAMEE}}
10645 !! html/*
10646 <p>User:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10647 </p>
10648 !! end
10649
10650 !! test
10651 Magic Word: {{TALKSPACE}}
10652 !! options
10653 title=[[User:Ævar Arnfjörð Bjarmason]]
10654 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10655 !! wikitext
10656 {{TALKSPACE}}
10657 !! html/*
10658 <p>User talk
10659 </p>
10660 !! end
10661
10662 !! test
10663 Magic Word: {{TALKSPACE}}, same namespace
10664 !! options
10665 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10666 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10667 !! wikitext
10668 {{TALKSPACE}}
10669 !! html/*
10670 <p>User talk
10671 </p>
10672 !! end
10673
10674 !! test
10675 Magic Word: {{TALKSPACE}}, main namespace
10676 !! options
10677 title=[[Parser Test]]
10678 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10679 !! wikitext
10680 {{TALKSPACE}}
10681 !! html/*
10682 <p>Talk
10683 </p>
10684 !! end
10685
10686 !! test
10687 Magic Word: {{TALKSPACEE}}
10688 !! options
10689 title=[[User:Ævar Arnfjörð Bjarmason]]
10690 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10691 !! wikitext
10692 {{TALKSPACEE}}
10693 !! html/*
10694 <p>User_talk
10695 </p>
10696 !! end
10697
10698 !! test
10699 Magic Word: {{SUBJECTSPACE}}
10700 !! options
10701 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10702 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10703 !! wikitext
10704 {{SUBJECTSPACE}}
10705 !! html/*
10706 <p>User
10707 </p>
10708 !! end
10709
10710 !! test
10711 Magic Word: {{SUBJECTSPACE}}, same namespace
10712 !! options
10713 title=[[User:Ævar Arnfjörð Bjarmason]]
10714 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10715 !! wikitext
10716 {{SUBJECTSPACE}}
10717 !! html/*
10718 <p>User
10719 </p>
10720 !! end
10721
10722 !! test
10723 Magic Word: {{SUBJECTSPACE}}, main namespace
10724 !! options
10725 title=[[Parser Test]]
10726 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10727 !! wikitext
10728 {{SUBJECTSPACE}}
10729 !! html/*
10730
10731 !! end
10732
10733 !! test
10734 Magic Word: {{SUBJECTSPACEE}}
10735 !! options
10736 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10737 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10738 !! wikitext
10739 {{SUBJECTSPACEE}}
10740 !! html/*
10741 <p>User
10742 </p>
10743 !! end
10744
10745 !! test
10746 Magic Word: {{NAMESPACE}}
10747 !! options
10748 title=[[User:Ævar Arnfjörð Bjarmason]]
10749 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10750 !! wikitext
10751 {{NAMESPACE}}
10752 !! html/*
10753 <p>User
10754 </p>
10755 !! end
10756
10757 !! test
10758 Magic Word: {{NAMESPACEE}}
10759 !! options
10760 title=[[User:Ævar Arnfjörð Bjarmason]]
10761 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10762 !! wikitext
10763 {{NAMESPACEE}}
10764 !! html/*
10765 <p>User
10766 </p>
10767 !! end
10768
10769 !! test
10770 Magic Word: {{NAMESPACENUMBER}}
10771 !! options
10772 title=[[User:Ævar Arnfjörð Bjarmason]]
10773 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10774 !! wikitext
10775 {{NAMESPACENUMBER}}
10776 !! html/*
10777 <p>2
10778 </p>
10779 !! end
10780
10781 !! test
10782 Magic Word: {{SUBPAGENAME}}
10783 !! options
10784 title=[[Ævar Arnfjörð Bjarmason/sub ö]] subpage
10785 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10786 !! wikitext
10787 {{SUBPAGENAME}}
10788 !! html/*
10789 <p>sub ö
10790 </p>
10791 !! end
10792
10793 !! test
10794 Magic Word: {{SUBPAGENAMEE}}
10795 !! options
10796 title=[[Ævar Arnfjörð Bjarmason/sub ö]] subpage
10797 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10798 !! wikitext
10799 {{SUBPAGENAMEE}}
10800 !! html/*
10801 <p>sub_%C3%B6
10802 </p>
10803 !! end
10804
10805 !! test
10806 Magic Word: {{ROOTPAGENAME}}
10807 !! options
10808 title=[[Ævar Arnfjörð Bjarmason/sub/sub2]] subpage
10809 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10810 !! wikitext
10811 {{ROOTPAGENAME}}
10812 !! html/*
10813 <p>Ævar Arnfjörð Bjarmason
10814 </p>
10815 !! end
10816
10817 !! test
10818 Magic Word: {{ROOTPAGENAMEE}}
10819 !! options
10820 title=[[Ævar Arnfjörð Bjarmason/sub/sub2]] subpage
10821 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10822 !! wikitext
10823 {{ROOTPAGENAMEE}}
10824 !! html/*
10825 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10826 </p>
10827 !! end
10828
10829 !! test
10830 Magic Word: {{BASEPAGENAME}}
10831 !! options
10832 title=[[Ævar Arnfjörð Bjarmason/sub]] subpage
10833 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10834 !! wikitext
10835 {{BASEPAGENAME}}
10836 !! html/*
10837 <p>Ævar Arnfjörð Bjarmason
10838 </p>
10839 !! end
10840
10841 !! test
10842 Magic Word: {{BASEPAGENAMEE}}
10843 !! options
10844 title=[[Ævar Arnfjörð Bjarmason/sub]] subpage
10845 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10846 !! wikitext
10847 {{BASEPAGENAMEE}}
10848 !! html/*
10849 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10850 </p>
10851 !! end
10852
10853 !! test
10854 Magic Word: {{TALKPAGENAME}}
10855 !! options
10856 title=[[User:Ævar Arnfjörð Bjarmason]]
10857 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10858 !! wikitext
10859 {{TALKPAGENAME}}
10860 !! html/*
10861 <p>User talk:Ævar Arnfjörð Bjarmason
10862 </p>
10863 !! end
10864
10865 !! test
10866 Magic Word: {{TALKPAGENAMEE}}
10867 !! options
10868 title=[[User:Ævar Arnfjörð Bjarmason]]
10869 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10870 !! wikitext
10871 {{TALKPAGENAMEE}}
10872 !! html/*
10873 <p>User_talk:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10874 </p>
10875 !! end
10876
10877 !! test
10878 Magic Word: {{SUBJECTPAGENAME}}
10879 !! options
10880 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10881 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10882 !! wikitext
10883 {{SUBJECTPAGENAME}}
10884 !! html/*
10885 <p>User:Ævar Arnfjörð Bjarmason
10886 </p>
10887 !! end
10888
10889 !! test
10890 Magic Word: {{SUBJECTPAGENAMEE}}
10891 !! options
10892 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10893 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10894 !! wikitext
10895 {{SUBJECTPAGENAMEE}}
10896 !! html/*
10897 <p>User:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10898 </p>
10899 !! end
10900
10901 !! test
10902 Magic Word: {{NUMBEROFFILES}}
10903 !! options
10904 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10905 !! wikitext
10906 {{NUMBEROFFILES}}
10907 !! html/*
10908 <p>7
10909 </p>
10910 !! end
10911
10912 !! test
10913 Magic Word: {{PAGENAME}}
10914 !! options
10915 title=[[User:Ævar Arnfjörð Bjarmason]]
10916 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10917 !! wikitext
10918 {{PAGENAME}}
10919 !! html/*
10920 <p>Ævar Arnfjörð Bjarmason
10921 </p>
10922 !! end
10923
10924 !! test
10925 Magic Word: {{PAGENAME}} with metacharacters
10926 !! options
10927 title=[['foo & bar = baz']]
10928 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10929 !! wikitext
10930 ''{{PAGENAME}}''
10931 !! html+tidy
10932 <p><i>&#39;foo &#38; bar &#61; baz&#39;</i>
10933 </p>
10934 !! end
10935
10936 !! test
10937 Magic Word: {{PAGENAME}} with metacharacters (T28781)
10938 !! options
10939 title=[[*RFC 1234 http://example.com/]]
10940 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10941 !! wikitext
10942 {{PAGENAME}}
10943 !! html+tidy
10944 <p>&#42;RFC&#32;1234 http&#58;//example.com/
10945 </p>
10946 !! end
10947
10948 !! test
10949 Magic Word: {{PAGENAMEE}}
10950 !! options
10951 title=[[User:Ævar Arnfjörð Bjarmason]]
10952 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10953 !! wikitext
10954 {{PAGENAMEE}}
10955 !! html/*
10956 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10957 </p>
10958 !! end
10959
10960 !! test
10961 Magic Word: {{PAGENAMEE}} with metacharacters (T28781)
10962 !! options
10963 title=[[*RFC 1234 http://example.com/]]
10964 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10965 !! wikitext
10966 {{PAGENAMEE}}
10967 !! html+tidy
10968 <p>&#42;RFC_1234_http&#58;//example.com/
10969 </p>
10970 !! end
10971
10972 !! test
10973 Magic Word: {{REVISIONID}}
10974 !! options
10975 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10976 showflags
10977 !! wikitext
10978 {{REVISIONID}}
10979 !! html/*
10980 <p>1337
10981 </p>
10982 flags=vary-revision-id
10983 !! end
10984
10985 !! test
10986 Magic Word: {{SCRIPTPATH}}
10987 !! options
10988 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10989 !! wikitext
10990 {{SCRIPTPATH}}
10991 !! html/*
10992
10993 !! end
10994
10995 !! test
10996 Magic Word: {{STYLEPATH}}
10997 !! options
10998 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10999 !! wikitext
11000 {{STYLEPATH}}
11001 !! html/*
11002 <p>/skins
11003 </p>
11004 !! end
11005
11006 !! test
11007 Magic Word: {{SERVER}}
11008 !! options
11009 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
11010 !! wikitext
11011 {{SERVER}}
11012 !! html/*
11013 <p><a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>
11014 </p>
11015 !! end
11016
11017 !! test
11018 Magic Word: {{SERVERNAME}}
11019 !! options
11020 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
11021 !! wikitext
11022 {{SERVERNAME}}
11023 !! html/*
11024 <p>example.org
11025 </p>
11026 !! end
11027
11028 !! test
11029 Magic Word: {{SITENAME}}
11030 !! options
11031 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
11032 !! wikitext
11033 {{SITENAME}}
11034 !! html/*
11035 <p>MediaWiki
11036 </p>
11037 !! end
11038
11039 !! test
11040 Magic Word: {{PAGELANGUAGE}}
11041 !! options
11042 language=fr
11043 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
11044 !! wikitext
11045 {{PAGELANGUAGE}}
11046 !! html/*
11047 <p>fr
11048 </p>
11049 !! end
11050
11051 !! test
11052 Magic Word: {{PAGELANGUAGE}} on a page with no explicitly set language
11053 !! options
11054 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
11055 !! wikitext
11056 {{PAGELANGUAGE}}
11057 !! html/*
11058 <p>en
11059 </p>
11060 !! end
11061
11062 !! test
11063 Case-sensitive magic words, when cased differently, should just be template transclusions
11064 !! wikitext
11065 {{CurrentMonth}}
11066 {{currentday}}
11067 {{cURreNTweEK}}
11068 {{currentHour}}
11069 !! html
11070 <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>
11071 <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>
11072 <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>
11073 <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>
11074 </p>
11075 !! end
11076
11077 !! test
11078 Case-insensitive magic words should still work with weird casing.
11079 !! wikitext
11080 {{sErVeRNaMe}}
11081 {{LCFirst:AOEU}}
11082 {{ucFIRST:aoeu}}
11083 {{SERver}}
11084 !! html
11085 <p>example.org
11086 aOEU
11087 Aoeu
11088 <a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>
11089 </p>
11090 !! end
11091
11092 # From plwiki:PLOS_ONE
11093 !! test
11094 Parsoid: Page property magic word with magic word contents
11095 !! options
11096 showtitle
11097 !! config
11098 wgAllowDisplayTitle=true
11099 wgRestrictDisplayTitle=false
11100 !! wikitext
11101 {{DISPLAYTITLE:''{{PAGENAME}}''}}
11102 !! html/php+tidy
11103 <i>Parser test</i>
11104
11105 !! html/parsoid
11106 <meta property="mw:PageProp/displaytitle" content="Parser test" 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;>Parser test&lt;/span>&lt;/i>"}]]}'/>
11107 !! end
11108
11109 # NOTE: mw:ExpandedAttrs is not the best typeof here. mw:Transclusion is better.
11110 # But, this is a limitation of our representation and is documented in
11111 # TemplateHandler.js in processSpecialMagicWord
11112 !! test
11113 Parsoid: Template-generated DISPLAYTITLE
11114 !! wikitext
11115 {{{{echo|DISPLAYTITLE}}:Foo}}
11116 !! options
11117 showtitle
11118 !! config
11119 wgAllowDisplayTitle=true
11120 wgRestrictDisplayTitle=false
11121 !! html/php
11122 Foo
11123
11124 !! html/parsoid
11125 <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"}]]}'/>
11126 !! end
11127
11128 !! test
11129 Namespace 1 {{ns:1}}
11130 !! wikitext
11131 {{ns:1}}
11132 !! html
11133 <p>Talk
11134 </p>
11135 !! end
11136
11137 !! test
11138 Namespace 1 {{ns:01}}
11139 !! wikitext
11140 {{ns:01}}
11141 !! html
11142 <p>Talk
11143 </p>
11144 !! end
11145
11146 !! test
11147 Namespace 0 {{ns:0}} (T6783)
11148 !! wikitext
11149 {{ns:0}}
11150 !! html
11151
11152 !! end
11153
11154 !! test
11155 Namespace 0 {{ns:00}} (T6783)
11156 !! wikitext
11157 {{ns:00}}
11158 !! html
11159
11160 !! end
11161
11162 !! test
11163 Namespace -1 {{ns:-1}}
11164 !! wikitext
11165 {{ns:-1}}
11166 !! html
11167 <p>Special
11168 </p>
11169 !! end
11170
11171 !! test
11172 Namespace User {{ns:User}}
11173 !! wikitext
11174 {{ns:User}}
11175 !! html
11176 <p>User
11177 </p>
11178 !! end
11179
11180 !! test
11181 Namespace User talk {{ns:User_talk}}
11182 !! wikitext
11183 {{ns:User_talk}}
11184 !! html
11185 <p>User talk
11186 </p>
11187 !! end
11188
11189 !! test
11190 Namespace User talk {{ns:uSeR tAlK}}
11191 !! wikitext
11192 {{ns:uSeR tAlK}}
11193 !! html
11194 <p>User talk
11195 </p>
11196 !! end
11197
11198 !! test
11199 Namespace File {{ns:File}}
11200 !! wikitext
11201 {{ns:File}}
11202 !! html
11203 <p>File
11204 </p>
11205 !! end
11206
11207 !! test
11208 Namespace File {{ns:Image}}
11209 !! wikitext
11210 {{ns:Image}}
11211 !! html
11212 <p>File
11213 </p>
11214 !! end
11215
11216 !! test
11217 Namespace (lang=de) Benutzer {{ns:User}}
11218 !! options
11219 language=de
11220 !! wikitext
11221 {{ns:User}}
11222 !! html
11223 <p>Benutzer
11224 </p>
11225 !! end
11226
11227 !! test
11228 Namespace (lang=de) Benutzer Diskussion {{ns:3}}
11229 !! options
11230 language=de
11231 !! wikitext
11232 {{ns:3}}
11233 !! html
11234 <p>Benutzer Diskussion
11235 </p>
11236 !! end
11237
11238 !! test
11239 Urlencode
11240 !! wikitext
11241 {{urlencode:hi world?!}}
11242 {{urlencode:hi world?!|WIKI}}
11243 {{urlencode:hi world?!|PATH}}
11244 {{urlencode:hi world?!|QUERY}}
11245 !! html/php
11246 <p>hi+world%3F%21
11247 hi_world%3F!
11248 hi%20world%3F%21
11249 hi+world%3F%21
11250 </p>
11251 !! end
11252
11253 !! test
11254 Magic Word: prioritize type info over data-parsoid
11255 !! options
11256 parsoid=html2wt
11257 !! html/parsoid
11258 <meta property="mw:PageProp/forcetoc" data-parsoid='{"magicSrc":"__NOTOC__"}'/>
11259 !! wikitext
11260 __FORCETOC__
11261 !! end
11262
11263 !! test
11264 Magic Word: serialize on separate line (parsoid)
11265 !! options
11266 parsoid=wt2wt,html2wt
11267 !! wikitext
11268 foo
11269 __NOTOC__
11270 bar
11271 !! html/parsoid
11272 foo<meta property="mw:PageProp/notoc"/>bar
11273 !! end
11274
11275 !! test
11276 Magic Word: rt non-english wikis
11277 !! options
11278 parsoid=wt2wt
11279 language=de
11280 !! wikitext
11281 __NOEDITSECTION__
11282 !! html/parsoid
11283 <meta property="mw:PageProp/noeditsection" data-parsoid='{"magicSrc":"__NOEDITSECTION__"}'/>
11284 !! end
11285
11286 !!test
11287 __proto__ is treated as normal wikitext (T105997)
11288 !!wikitext
11289 __proto__
11290 !!html
11291 <p>__proto__
11292 </p>
11293 !!end
11294
11295 ###
11296 ### Magic links
11297 ###
11298 !! test
11299 Magic links: internal link to RFC (T2479)
11300 !! wikitext
11301 [[RFC 123]]
11302 !! html/php
11303 <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>
11304 </p>
11305 !! html/parsoid
11306 <p><a rel="mw:WikiLink" href="./RFC_123" title="RFC 123">RFC 123</a></p>
11307 !! end
11308
11309 !! test
11310 Magic links: RFC (T2479)
11311 !! wikitext
11312 RFC 822
11313 !! html/php
11314 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc822">RFC 822</a>
11315 </p>
11316 !! html/parsoid
11317 <p><a href="https://tools.ietf.org/html/rfc822" rel="mw:ExtLink" class="external mw-magiclink">RFC 822</a></p>
11318 !! end
11319
11320 !! test
11321 Magic links: RFC (T67278)
11322 !! wikitext
11323 This is RFC 822 but thisRFC 822 is not RFC 822linked.
11324 !! html/php
11325 <p>This is <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc822">RFC 822</a> but thisRFC 822 is not RFC 822linked.
11326 </p>
11327 !! html/parsoid
11328 <p>This is <a href="https://tools.ietf.org/html/rfc822" rel="mw:ExtLink" class="external mw-magiclink">RFC 822</a> but thisRFC 822 is not RFC 822linked.</p>
11329 !! end
11330
11331 !! test
11332 Magic links: RFC (w/ non-newline whitespace, T30950/T31025)
11333 !! wikitext
11334 RFC &nbsp;&#160;&#0160;&#xA0;&#Xa0; 822
11335 RFC
11336 822
11337 !! html/php
11338 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc822">RFC 822</a>
11339 RFC
11340 822
11341 </p>
11342 !! html/parsoid
11343 <p><a href="https://tools.ietf.org/html/rfc822" rel="mw:ExtLink" class="external mw-magiclink">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>
11344 RFC
11345 822</p>
11346 !! end
11347
11348 !! test
11349 Magic links: ISBN (T3937)
11350 !! wikitext
11351 ISBN 0-306-40615-2
11352 !! html/php
11353 <p><a href="/wiki/Special:BookSources/0306406152" class="internal mw-magiclink-isbn">ISBN 0-306-40615-2</a>
11354 </p>
11355 !! html/parsoid
11356 <p><a href="./Special:BookSources/0306406152" rel="mw:WikiLink">ISBN 0-306-40615-2</a></p>
11357 !! end
11358
11359 !! test
11360 Magic links: ISBN (T67278)
11361 !! wikitext
11362 This is ISBN 978-0-316-09811-3 but thisISBN 978-0-316-09811-3 is not ISBN 978-0-316-09811-3linked.
11363 !! html/php
11364 <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.
11365 </p>
11366 !! html/parsoid
11367 <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>
11368 !! end
11369
11370 !! test
11371 Magic links: ISBN (w/ non-newline whitespace, T30950/T31025)
11372 !! wikitext
11373 ISBN &nbsp;&#160;&#0160;&#xA0;&#Xa0; 978&nbsp;0&#160;316&#0160;09811&#xA0;3
11374 ISBN
11375 9780316098113
11376 ISBN 978
11377 0316098113
11378 !! html/php
11379 <p><a href="/wiki/Special:BookSources/9780316098113" class="internal mw-magiclink-isbn">ISBN 978 0 316 09811 3</a>
11380 ISBN
11381 9780316098113
11382 ISBN 978
11383 0316098113
11384 </p>
11385 !! html/parsoid
11386 <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>
11387 ISBN
11388 9780316098113
11389 ISBN 978
11390 0316098113</p>
11391 !! end
11392
11393 !! test
11394 Magic links: PMID incorrectly converts space to underscore
11395 !! wikitext
11396 PMID 1234
11397 !! html/php
11398 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a>
11399 </p>
11400 !! html/parsoid
11401 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract" rel="mw:ExtLink" class="external mw-magiclink">PMID 1234</a></p>
11402 !! end
11403
11404 !! test
11405 Magic links: PMID (T67278)
11406 !! wikitext
11407 This is PMID 1234 but thisPMID 1234 is not PMID 1234linked.
11408 !! html/php
11409 <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.
11410 </p>
11411 !! html/parsoid
11412 <p>This is <a href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract" rel="mw:ExtLink" class="external mw-magiclink">PMID 1234</a> but thisPMID 1234 is not PMID 1234linked.</p>
11413 !! end
11414
11415 !! test
11416 Magic links: PMID (w/ non-newline whitespace, T30950/T31025)
11417 !! wikitext
11418 PMID &nbsp;&#160;&#0160;&#xA0;&#Xa0; 1234
11419 PMID
11420 1234
11421 !! html/php
11422 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a>
11423 PMID
11424 1234
11425 </p>
11426 !! html/parsoid
11427 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract" rel="mw:ExtLink" class="external mw-magiclink">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>
11428 PMID
11429 1234</p>
11430 !! end
11431
11432 # <nowiki> nodes shouldn't be inserted during html2wt by Parsoid,
11433 # since these are ExtLinkText, not MagicLinkText
11434 !! test
11435 Magic links: use appropriate serialization for "almost" magic links.
11436 !! wikitext
11437 X[[Special:BookSources/0978739256|foo]]
11438
11439 X[https://tools.ietf.org/html/rfc1234 foo]
11440 !! html/php
11441 <p>X<a href="/wiki/Special:BookSources/0978739256" title="Special:BookSources/0978739256">foo</a>
11442 </p><p>X<a rel="nofollow" class="external text" href="https://tools.ietf.org/html/rfc1234">foo</a>
11443 </p>
11444 !! html/parsoid
11445 <p>X<a rel="mw:WikiLink" href="./Special:BookSources/0978739256" title="Special:BookSources/0978739256">foo</a></p>
11446 <p>X<a rel="mw:ExtLink" class="external text" href="https://tools.ietf.org/html/rfc1234">foo</a></p>
11447 !! end
11448
11449 !! test
11450 Magic links: All disabled (T47942)
11451 !! options
11452 wgEnableMagicLinks={"ISBN":false, "PMID":false, "RFC":false}
11453 !! wikitext
11454 ISBN 0-306-40615-2
11455 PMID 1234
11456 RFC 4321
11457 !! html/php
11458 <p>ISBN 0-306-40615-2
11459 PMID 1234
11460 RFC 4321
11461 </p>
11462 !! end
11463
11464 ###
11465 ### Templates
11466 ####
11467
11468 !! test
11469 Nonexistent template
11470 !! wikitext
11471 {{thistemplatedoesnotexist}}
11472 !! html
11473 <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>
11474 </p>
11475 !! end
11476
11477 !! test
11478 Template with invalid target containing tags
11479 !! wikitext
11480 {{a<b>b</b>|{{echo|foo}}|{{echo|a}}={{echo|b}}|a = b}}
11481 !! html
11482 <p>{{a<b>b</b>|foo|a=b|a = b}}
11483 </p>
11484 !! end
11485
11486 !! test
11487 Template with invalid target containing unclosed tag
11488 !! wikitext
11489 {{a<b>|{{echo|foo}}|{{echo|a}}={{echo|b}}|a = b}}
11490 !! html
11491 <p>{{a<b>|foo|a=b|a = b}}</b>
11492 </p>
11493 !! end
11494
11495 !! test
11496 Template with invalid target containing wikilink
11497 !! wikitext
11498 {{[[Main Page]]}}
11499 !! html/php
11500 <p>{{<a href="/wiki/Main_Page" title="Main Page">Main Page</a>}}
11501 </p>
11502 !! html/parsoid
11503 <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>
11504 !! end
11505
11506 !! test
11507 Template with just whitespace in it, T70421
11508 !! wikitext
11509 {{echo|{{ }}}}
11510 !! html/parsoid
11511 <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>
11512 !! end
11513
11514 !! article
11515 Template:test
11516 !! text
11517 This is a test template
11518 !! endarticle
11519
11520 !! test
11521 Simple template
11522 !! wikitext
11523 {{test}}
11524 !! html
11525 <p>This is a test template
11526 </p>
11527 !! end
11528
11529 !! test
11530 Template with explicit namespace
11531 !! wikitext
11532 {{Template:test}}
11533 !! html
11534 <p>This is a test template
11535 </p>
11536 !! end
11537
11538
11539 !! article
11540 Template:paramtest
11541 !! text
11542 This is a test template with parameter {{{param}}}
11543 !! endarticle
11544
11545 !! test
11546 Template parameter
11547 !! wikitext
11548 {{paramtest|param=foo}}
11549 !! html
11550 <p>This is a test template with parameter foo
11551 </p>
11552 !! end
11553
11554 !! article
11555 Template:paramtestnum
11556 !! text
11557 [[{{{1}}}|{{{2}}}]]
11558 !! endarticle
11559
11560 !! test
11561 Template unnamed parameter
11562 !! wikitext
11563 {{paramtestnum|Main Page|the main page}}
11564 !! html
11565 <p><a href="/wiki/Main_Page" title="Main Page">the main page</a>
11566 </p>
11567 !! end
11568
11569 !! article
11570 Template:templatesimple
11571 !! text
11572 (test)
11573 !! endarticle
11574
11575 !! article
11576 Template:templateredirect
11577 !! text
11578 #redirect [[Template:templatesimple]]
11579 !! endarticle
11580
11581 !! article
11582 Template:templateasargtestnum
11583 !! text
11584 {{{{{1}}}}}
11585 !! endarticle
11586
11587 !! article
11588 Template:templateasargtest
11589 !! text
11590 {{template{{{templ}}}}}
11591 !! endarticle
11592
11593 !! article
11594 Template:templateasargtest2
11595 !! text
11596 {{{{{templ}}}}}
11597 !! endarticle
11598
11599 !! test
11600 Template with template name as unnamed argument
11601 !! wikitext
11602 {{templateasargtestnum|templatesimple}}
11603 !! html
11604 <p>(test)
11605 </p>
11606 !! end
11607
11608 !! test
11609 Template with template name as argument
11610 !! wikitext
11611 {{templateasargtest|templ=simple}}
11612 !! html
11613 <p>(test)
11614 </p>
11615 !! end
11616
11617 !! test
11618 Template with template name as argument (2)
11619 !! wikitext
11620 {{templateasargtest2|templ=templatesimple}}
11621 !! html
11622 <p>(test)
11623 </p>
11624 !! end
11625
11626 !! article
11627 Template:templateasargtestdefault
11628 !! text
11629 {{{{{templ|templatesimple}}}}}
11630 !! endarticle
11631
11632 !! article
11633 Template:templa
11634 !! text
11635 '''templ'''
11636 !! endarticle
11637
11638 !! test
11639 Template with default value
11640 !! wikitext
11641 {{templateasargtestdefault}}
11642 !! html
11643 <p>(test)
11644 </p>
11645 !! end
11646
11647 !! test
11648 Template with default value (value set)
11649 !! wikitext
11650 {{templateasargtestdefault|templ=templa}}
11651 !! html
11652 <p><b>templ</b>
11653 </p>
11654 !! end
11655
11656 !! test
11657 Template redirect
11658 !! wikitext
11659 {{templateredirect}}
11660 !! html/php
11661 <p>(test)
11662 </p>
11663 !! html/parsoid
11664 <link rel="mw:PageProp/redirect" href="./Template:Templatesimple" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"templateredirect","href":"./Template:Templateredirect"},"params":{},"i":0}}]}'/>
11665 !! end
11666
11667 !! test
11668 Template with argument in separate line
11669 !! wikitext
11670 {{ templateasargtest |
11671 templ = simple }}
11672 !! html
11673 <p>(test)
11674 </p>
11675 !! end
11676
11677 !! test
11678 Template with complex template as argument
11679 !! wikitext
11680 {{paramtest|
11681 param ={{ templateasargtest |
11682 templ = simple }}}}
11683 !! html
11684 <p>This is a test template with parameter (test)
11685 </p>
11686 !! end
11687
11688 !! test
11689 Templates with templated name
11690 !! wikitext
11691 {{{{echo|echo}}|foo}}
11692 {{{{echo|inner list}} }}
11693 !! html
11694 <p>foo
11695 </p>
11696 <ul><li>item 1</li></ul>
11697
11698 !! html/parsoid
11699 <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>
11700 <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>
11701 !! end
11702
11703 ## Regression test; the output here isn't really that interesting.
11704 !! test
11705 Templates with templated name and top level template args
11706 !! wikitext
11707 {{1{{2{{{3}}}|4=5}}}}
11708 !! html/parsoid
11709 <p about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"1{{2{{{3}}}|4=5}}"},"params":{},"i":0}}]}'>{{1{{2{{{3}}}|4=5}}}}</p>
11710 !! end
11711
11712 # Parsoid markup is deliberate "broken". This is an edge case.
11713 # See long comment in TemplateHandler.js:convertAttribsToString.
11714 !! test
11715 Templates with invalid templated targets
11716 !! wikitext
11717 {{echo
11718 {{echo|foo}}
11719 }}
11720 !! html/php
11721 <p>{{echo
11722 foo
11723 }}
11724 </p>
11725 !! html/parsoid
11726 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo\n{{echo|foo}}\n"},"params":{},"i":0}}]}'>{{echo
11727 foo }}</p>
11728 !! end
11729
11730 !! test
11731 Template with thumb image (with link in description)
11732 !! wikitext
11733 {{paramtest|param=[[Image:noimage.png|thumb|[[no link|link]] [[no link|caption]]]]}}
11734 !! html/php
11735 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>
11736
11737 !! html+tidy
11738 <p>This is a test template with parameter </p><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>
11739 !! html/parsoid
11740 <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>
11741 !! end
11742
11743 !! article
11744 Template:complextemplate
11745 !! text
11746 {{{1}}} {{paramtest|
11747 param ={{{param}}}}}
11748 !! endarticle
11749
11750 !! test
11751 Template with complex arguments
11752 !! wikitext
11753 {{complextemplate|
11754 param ={{ templateasargtest |
11755 templ = simple }}|[[Template:complextemplate|link]]}}
11756 !! html
11757 <p><a href="/wiki/Template:Complextemplate" title="Template:Complextemplate">link</a> This is a test template with parameter (test)
11758 </p>
11759 !! end
11760
11761 !! test
11762 T2553: link with two variables in a piped link
11763 !! wikitext
11764 {|
11765 |[[{{{1}}}|{{{2}}}]]
11766 |}
11767 !! html/php
11768 <table>
11769 <tr>
11770 <td>[[{{{1}}}|{{{2}}}]]
11771 </td></tr></table>
11772
11773 !! html/parsoid
11774 <table>
11775 <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>
11776 </tbody></table>
11777 !! end
11778
11779 # See: T2553
11780 !! test
11781 Abort table cell attribute parsing on wikilink
11782 !! wikitext
11783 {|
11784 |testing [[one|two]] |three||four
11785 |testing one two |three||four
11786 |testing="[[one|two]]" |three||four
11787 |}
11788 !! html/php
11789 <table>
11790 <tr>
11791 <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>
11792 <td>four
11793 </td>
11794 <td>three</td>
11795 <td>four
11796 </td>
11797 <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>
11798 <td>four
11799 </td></tr></table>
11800
11801 !! html/parsoid
11802 <table>
11803 <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":"row","autoInsertedEnd":true}'>four</td>
11804 <td data-parsoid='{"a":{"testing":null,"one":null,"two":null},"sa":{"testing":"","one":"","two":""},"autoInsertedEnd":true}'>three</td><td data-parsoid='{"stx":"row","autoInsertedEnd":true}'>four</td>
11805 <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":"row","autoInsertedEnd":true}'>four</td></tr>
11806 </tbody></table>
11807 !! end
11808
11809 !! test
11810 Don't abort table cell attribute parsing if wikilink is found in template arg
11811 !! wikitext
11812 {|
11813 |Test {{#tag:ref|One two "[[three]]" four}}
11814 |}
11815 !! html/parsoid
11816 <table>
11817 <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>
11818 </tbody></table>
11819 !! end
11820
11821 !! test
11822 Magic variable as template parameter
11823 !! wikitext
11824 {{paramtest|param={{SITENAME}}}}
11825 !! html
11826 <p>This is a test template with parameter MediaWiki
11827 </p>
11828 !! end
11829
11830 !! article
11831 Template:linktest
11832 !! text
11833 [[{{{param}}}|link]]
11834 !! endarticle
11835
11836 !! test
11837 Template parameter as link source
11838 !! wikitext
11839 {{linktest|param=Main Page}}
11840 !! html
11841 <p><a href="/wiki/Main_Page" title="Main Page">link</a>
11842 </p>
11843 !! end
11844
11845 !!article
11846 Template:paramtest2
11847 !! text
11848 including another template, {{paramtest|param={{{arg}}}}}
11849 !! endarticle
11850
11851 !! test
11852 Template passing argument to another template
11853 !! wikitext
11854 {{paramtest2|arg='hmm'}}
11855 !! html
11856 <p>including another template, This is a test template with parameter 'hmm'
11857 </p>
11858 !! end
11859
11860 !! article
11861 Template:Linktest2
11862 !! text
11863 Main Page
11864 !! endarticle
11865
11866 !! test
11867 Template as link source
11868 !! wikitext
11869 [[{{linktest2}}]]
11870
11871 [[{{linktest2}}|Main Page]]
11872
11873 [[{{linktest2}}]]Page
11874 !! html
11875 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
11876 </p><p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
11877 </p><p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>Page
11878 </p>
11879 !! end
11880
11881
11882 !! article
11883 Template:loop1
11884 !! text
11885 {{loop2}}
11886 !! endarticle
11887
11888 !! article
11889 Template:loop2
11890 !! text
11891 {{loop1}}
11892 !! endarticle
11893
11894 !! test
11895 Template infinite loop
11896 !! wikitext
11897 {{loop1}}
11898 !! html
11899 <p><span class="error">Template loop detected: <a href="/wiki/Template:Loop1" title="Template:Loop1">Template:Loop1</a></span>
11900 </p>
11901 !! end
11902
11903 !! test
11904 Template from main namespace
11905 !! wikitext
11906 {{:Main Page}}
11907 !! html
11908 <p>blah blah
11909 </p>
11910 !! end
11911
11912 !! test
11913 Template from non-includable namespace
11914 !! options
11915 wgNonincludableNamespaces=10
11916 !! wikitext
11917 {{echo|uh oh!}}
11918 !! html
11919 <p><a href="/wiki/Template:Echo" title="Template:Echo">Template:Echo</a>
11920 </p>
11921 !! end
11922
11923 !! article
11924 Template:table
11925 !! text
11926 {|
11927 | 1 || 2
11928 |-
11929 | 3 || 4
11930 |}
11931 !! endarticle
11932
11933 !! test
11934 T2529: Template with table, not included at beginning of line
11935 !! wikitext
11936 foo {{table}}
11937 !! html
11938 <p>foo
11939 </p>
11940 <table>
11941 <tr>
11942 <td>1</td>
11943 <td>2
11944 </td></tr>
11945 <tr>
11946 <td>3</td>
11947 <td>4
11948 </td></tr></table>
11949
11950 !! end
11951
11952 !! test
11953 T2523: Template shouldn't eat newline (or add an extra one before table)
11954 !! wikitext
11955 foo
11956 {{table}}
11957 !! html
11958 <p>foo
11959 </p>
11960 <table>
11961 <tr>
11962 <td>1</td>
11963 <td>2
11964 </td></tr>
11965 <tr>
11966 <td>3</td>
11967 <td>4
11968 </td></tr></table>
11969
11970 !! end
11971
11972 !! test
11973 T2041: Template parameters shown as broken links
11974 !! wikitext
11975 {{{parameter}}}
11976 !! html
11977 <p>{{{parameter}}}
11978 </p>
11979 !! end
11980
11981 !! test
11982 Template with targets containing wikilinks
11983 !! options
11984 parsoid=wt2html
11985 !! wikitext
11986 {{[[foo]]}}
11987
11988 {{[[{{echo|foo}}]]}}
11989
11990 {{{{echo|[[foo}}]]}}
11991 !! html/php
11992 <p>{{<a href="/wiki/Foo" title="Foo">foo</a>}}
11993 </p><p>{{<a href="/wiki/Foo" title="Foo">foo</a>}}
11994 </p><p>{{[[foo}}]]
11995 </p>
11996 !! html/parsoid
11997 <p>{{<a rel="mw:WikiLink" href="./Foo" title="Foo">foo</a>}}</p>
11998 <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>
11999 <p>{{<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[foo}}]]"}},"i":0}}]}'>[[foo}}]]</span></p>
12000 !! end
12001
12002 !! article
12003 Template:''
12004 !! text
12005 bar
12006 !! endarticle
12007
12008 !! test
12009 Templates: Double quotes as template target
12010 !! wikitext
12011 foo {{''}} baz
12012 !! html/php
12013 <p>foo bar baz
12014 </p>
12015 !! html/parsoid
12016 <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
12017 </p>
12018 !! end
12019
12020 ## This test is about making sure Parsoid's data-mw is well formed in the
12021 ## face of multiple templates with intersecting and overlapping ranges. The
12022 ## wikitext itself is wretched.
12023 !! test
12024 Templates with intersecting and overlapping ranges
12025 !! wikitext
12026 {|{{echo|
12027 <p>ha</p>}}
12028 {|{{echo|
12029 <p>ho</p>}}
12030 {{echo|{{!}}hi}}
12031 |}
12032 !! html/php+tidy
12033 <p>ha</p><table>
12034
12035 </table><p>ho</p><table>
12036
12037 <tbody><tr>
12038 <td>hi
12039 </td></tr></tbody></table>
12040 !! html/parsoid
12041 <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":""}]]}'>
12042
12043 </table><p about="#mwt1">ho</p><table about="#mwt1" typeof="mw:ExpandedAttrs" data-mw='{"attribs":[[{"txt":"","html":""},{"html":""}]]}'>
12044
12045 <tbody><tr><td>hi</td></tr>
12046 </tbody></table>
12047 !! end
12048
12049 !! article
12050 Template:MSGNW test
12051 !! text
12052 ''None'' of '''this''' should be
12053 * interpreted
12054 but rather passed unmodified
12055 {{test}}
12056 <gallery>
12057 File:Foobar.jpg
12058 </gallery>
12059 <!-- comment -->
12060 !! endarticle
12061
12062 # hmm, fix this or just deprecate msgnw and document its behavior?
12063 !! test
12064 msgnw keyword
12065 !! wikitext
12066 {{msgnw:MSGNW test}}
12067 !! html/php
12068 <p>&#39;&#39;None&#39;&#39; of &#39;&#39;&#39;this&#39;&#39;&#39; should be
12069 &#42; interpreted
12070 &#32;but rather passed unmodified
12071 &#123;&#123;test&#125;&#125;
12072 &#60;gallery&#62;
12073 File:Foobar.jpg
12074 &#60;/gallery&#62;
12075 &#60;!-- comment --&#62;
12076 </p>
12077 !! end
12078
12079 !! test
12080 int keyword
12081 !! wikitext
12082 {{int:youhavenewmessages|lots of money|not!}}
12083 !! html
12084 <p>You have lots of money (not!).
12085 </p>
12086 !! end
12087
12088 !! test
12089 int keyword - non-existing message
12090 !! wikitext
12091 {{int:var}}
12092 !! html
12093 <p>⧼var⧽
12094 </p>
12095 !! end
12096
12097 !! article
12098 Template:Includes
12099 !! text
12100 Foo<noinclude>zar</noinclude><includeonly>bar</includeonly>
12101 !! endarticle
12102
12103 !! test
12104 <includeonly> and <noinclude> being included
12105 !! wikitext
12106 {{Includes}}
12107 !! html
12108 <p>Foobar
12109 </p>
12110 !! end
12111
12112 !! article
12113 Template:Includes2
12114 !! text
12115 <onlyinclude>Foo</onlyinclude>bar
12116 !! endarticle
12117
12118 !! test
12119 <onlyinclude> being included
12120 !! wikitext
12121 {{Includes2}}
12122 !! html
12123 <p>Foo
12124 </p>
12125 !! end
12126
12127
12128 !! article
12129 Template:Includes3
12130 !! text
12131 <onlyinclude>Foo</onlyinclude>bar<includeonly>zar</includeonly>
12132 !! endarticle
12133
12134 !! test
12135 <onlyinclude> and <includeonly> being included
12136 !! wikitext
12137 {{Includes3}}
12138 !! html
12139 <p>Foo
12140 </p>
12141 !! end
12142
12143 !! test
12144 <includeonly> and <noinclude> on a page
12145 !! wikitext
12146 Foo<noinclude>zar</noinclude><includeonly>bar</includeonly>
12147 !! html
12148 <p>Foozar
12149 </p>
12150 !! end
12151
12152 !! test
12153 Un-closed <noinclude>
12154 !! wikitext
12155 <noinclude>
12156 !! html
12157 !! end
12158
12159 !! test
12160 <onlyinclude> on a page
12161 !! wikitext
12162 <onlyinclude>Foo</onlyinclude>bar
12163 !! html
12164 <p>Foobar
12165 </p>
12166 !! end
12167
12168 !! test
12169 Un-closed <onlyinclude>
12170 !! wikitext
12171 <onlyinclude>
12172 !! html
12173 !! end
12174
12175 !!test
12176 Self-closed noinclude, includeonly, onlyinclude tags
12177 !! wikitext
12178 <noinclude />
12179 <includeonly />
12180 <onlyinclude />
12181 !! html
12182 <p><br />
12183 </p>
12184 !!end
12185
12186 !!test
12187 Unbalanced includeonly and noinclude tags
12188 !! wikitext
12189 {|
12190 |a</noinclude>
12191 |b</noinclude></noinclude>
12192 |c</noinclude></includeonly>
12193 |d</includeonly></includeonly>
12194 |}
12195 !! html
12196 <table>
12197 <tr>
12198 <td>a
12199 </td>
12200 <td>b
12201 </td>
12202 <td>c&lt;/includeonly&gt;
12203 </td>
12204 <td>d&lt;/includeonly&gt;&lt;/includeonly&gt;
12205 </td></tr></table>
12206
12207 !!end
12208
12209 !! article
12210 Template:Includeonly section
12211 !! text
12212 <includeonly>
12213 ==Includeonly section==
12214 </includeonly>
12215 ==Section T-1==
12216 !!endarticle
12217
12218 !! test
12219 T8563: Edit link generation for section shown by <includeonly>
12220 !! wikitext
12221 {{includeonly section}}
12222 !! html
12223 <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>
12224 <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>
12225
12226 !! end
12227
12228 # Uses same input as the contents of [[Template:Includeonly section]]
12229 !! test
12230 T8563: Section extraction for section shown by <includeonly>
12231 !! options
12232 section=T-2
12233 !! wikitext
12234 <includeonly>
12235 ==Includeonly section==
12236 </includeonly>
12237 ==Section T-2==
12238 !! html
12239 ==Section T-2==
12240 !! end
12241
12242 !! test
12243 T8563: Edit link generation for section suppressed by <includeonly>
12244 !! wikitext
12245 <includeonly>
12246 ==Includeonly section==
12247 </includeonly>
12248 ==Section 1==
12249 !! html
12250 <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>
12251
12252 !! end
12253
12254 !! test
12255 T8563: Section extraction for section suppressed by <includeonly>
12256 !! options
12257 section=1
12258 !! wikitext
12259 <includeonly>
12260 ==Includeonly section==
12261 </includeonly>
12262 ==Section 1==
12263 !! html
12264 ==Section 1==
12265 !! end
12266
12267 !! test
12268 Un-closed <includeonly>
12269 !! wikitext
12270 <includeonly>
12271 !! html/php
12272 !! html/parsoid
12273 <meta typeof="mw:Includes/IncludeOnly" data-parsoid='{"src":"&lt;includeonly>"}' data-mw='{"src":"&lt;includeonly>"}'/>
12274 !! end
12275
12276 ## We used to, but no longer wt2wt this test since the default serializer
12277 ## will normalize the include directives to serialize on their own line.
12278 ## Selser will take care of preserving formatting in scenarios where they
12279 ## intermingled with other wikitext.
12280 !! test
12281 Includes and comments at SOL
12282 !! options
12283 parsoid=wt2html,html2html
12284 !! wikitext
12285 <!-- comment --><noinclude><!-- comment --></noinclude><!-- comment -->==hu==
12286
12287 <noinclude>
12288 some
12289 </noinclude>*stuff
12290 *here
12291
12292 <noinclude>
12293 some</noinclude>* stuff
12294 * here
12295
12296 <includeonly>can have stuff</includeonly>===here===
12297
12298 !! html/php
12299 <h2><span class="mw-headline" id="hu">hu</span></h2>
12300 <p>some
12301 </p>
12302 <ul><li>stuff</li>
12303 <li>here</li></ul>
12304 <p><br />
12305 some* stuff
12306 </p>
12307 <ul><li>here</li></ul>
12308 <h3><span class="mw-headline" id="here">here</span></h3>
12309
12310 !! html/parsoid
12311 <!-- 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 id="hu">hu</h2>
12312
12313 <meta typeof="mw:Includes/NoInclude" data-parsoid='{"src":"&lt;noinclude>"}'/>
12314 <p>some</p>
12315 <meta typeof="mw:Includes/NoInclude/End" data-parsoid='{"src":"&lt;/noinclude>"}'/><ul><li>stuff</li>
12316 <li>here</li></ul>
12317
12318 <meta typeof="mw:Includes/NoInclude" data-parsoid='{"src":"&lt;noinclude>"}'/>
12319 <p>some<meta typeof="mw:Includes/NoInclude/End" data-parsoid='{"src":"&lt;/noinclude>"}'/>* stuff</p>
12320 <ul><li>here</li></ul>
12321
12322 <meta typeof="mw:Includes/IncludeOnly" data-parsoid='{"src":"&lt;includeonly>can have stuff&lt;/includeonly>"}' data-mw='{"src":"&lt;includeonly>can have stuff&lt;/includeonly>"}'/><meta typeof="mw:Includes/IncludeOnly/End" data-parsoid='{"src":""}'/><h3 id="here">here</h3>
12323
12324 !! end
12325
12326 # TODO: test with DOM fragment reuse!
12327 !! test
12328 Parsoid: DOM fragment reuse
12329 !! options
12330 parsoid=wt2wt,wt2html
12331 !! wikitext
12332 a{{echo|b<table></table>c}}d
12333
12334 a{{echo|b
12335 <table></table>
12336 c}}d
12337
12338 {{echo|a
12339
12340 <table></table>
12341
12342 b}}
12343 !! html/php+tidy
12344 <p>ab</p><table></table><p>cd
12345 </p><p>ab
12346 </p>
12347 <table></table>
12348 <p>cd
12349 </p><p>a
12350 </p>
12351 <table></table>
12352 <p>b
12353 </p>
12354 !! html/parsoid
12355 <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>
12356
12357 <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">
12358 </span><table about="#mwt2" data-parsoid='{"stx":"html"}'></table><span about="#mwt2">
12359 </span><p about="#mwt2">cd</p>
12360
12361 <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">
12362
12363 </span><table about="#mwt3" data-parsoid='{"stx":"html"}'></table><span about="#mwt3">
12364
12365 </span><p about="#mwt3">b</p>
12366 !! end
12367
12368 !! test
12369 Parsoid: Merge double tds (T52603)
12370 !! wikitext
12371 {|
12372 |{{echo|{{!}} foo}}
12373 |}
12374 !! html/php+tidy
12375 <table>
12376 <tbody><tr>
12377 <td>foo
12378 </td></tr></tbody></table>
12379 !! html/parsoid
12380 <table><tbody>
12381 <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>
12382 </tbody></table>
12383 !! end
12384
12385 !! test
12386 Parsoid: Merge double tds in nested transclusion content (T52603)
12387 !! wikitext
12388 {{echo|<div>}}
12389 {|
12390 |{{echo|{{!}} foo}}
12391 |}
12392 {{echo|</div>}}
12393 !! html/php+tidy
12394 <div>
12395 <table>
12396 <tbody><tr>
12397 <td>foo
12398 </td></tr></tbody></table>
12399 </div>
12400 !! html/parsoid
12401 <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}}]}'>
12402 <table><tbody>
12403 <tr><td data-mw='{"parts":["|"]}'> foo</td></tr>
12404 </tbody></table>
12405 </div>
12406 !! end
12407
12408 ###
12409 ### <includeonly> and <noinclude> in attributes
12410 ###
12411 !!test
12412 0. includeonly around the entire attribute
12413 !! wikitext
12414 <span <includeonly>id="v1"</includeonly><noinclude>id="v2"</noinclude>>bar</span>
12415 !! html
12416 <p><span id="v2">bar</span>
12417 </p>
12418 !!end
12419
12420 !!test
12421 1. includeonly in html attr key
12422 !! wikitext
12423 <span <noinclude>id</noinclude><includeonly>about</includeonly>="foo">bar</span>
12424 !! html
12425 <p><span id="foo">bar</span>
12426 </p>
12427 !!end
12428
12429 !!test
12430 2. includeonly in html attr value
12431 !! wikitext
12432 <span id="<noinclude>v1</noinclude><includeonly>v2</includeonly>">bar</span>
12433 <span id=<noinclude>"v1"</noinclude><includeonly>"v2"</includeonly>>bar</span>
12434 !! html
12435 <p><span id="v1">bar</span>
12436 <span id="v1">bar</span>
12437 </p>
12438 !!end
12439
12440 !!test
12441 3. includeonly in part of an attr value
12442 !! wikitext
12443 <span style="color:<noinclude>red</noinclude><includeonly>blue</includeonly>;">bar</span>
12444 !! html
12445 <p><span style="color:red;">bar</span>
12446 </p>
12447 !!end
12448
12449 !!test
12450 4. includeonly in table attributes
12451 !! wikitext
12452 {|
12453 |- <noinclude>
12454 |-
12455 |a
12456 </noinclude>
12457 |- <includeonly>
12458 |-
12459 |b
12460 </includeonly>
12461 |}
12462 !! html
12463 <table>
12464
12465
12466 <tr>
12467 <td>a
12468 </td></tr>
12469 </table>
12470
12471 !!end
12472
12473 ###
12474 ### Preprocessor precedence tests
12475 ### See: https://www.mediawiki.org/wiki/Preprocessor_ABNF
12476 ###
12477 ##{{[[-{{{{{{[[Foo|bar}}]]}-}}}}}]]
12478 !! test
12479 Preprocessor precedence 1: link is rightmost opening
12480 !! options
12481 parsoid=wt2html
12482 !! wikitext
12483 {{[[Foo|bar}}]]
12484
12485 But close-brace is not a valid character in a link title:
12486 {{[[Foo}}|bar]]
12487
12488 However, we can still tell this was handled as a link in the preprocessor:
12489 {{echo|[[Foo}}|bar]]|bat}}
12490 !! html/php
12491 <p>{{<a href="/wiki/Foo" title="Foo">bar}}</a>
12492 </p><p>But close-brace is not a valid character in a link title:
12493 {{[[Foo}}|bar]]
12494 </p><p>However, we can still tell this was handled as a link in the preprocessor:
12495 [[Foo}}|bar]]
12496 </p>
12497 !! html/parsoid
12498 <p>{{<a rel="mw:WikiLink" href="./Foo" title="Foo">bar}}</a></p>
12499 <p>But close-brace is not a valid character in a link title: {{[[Foo}}|bar]]</p>
12500 <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>
12501 !! end
12502
12503 !! test
12504 Preprocessor precedence 2: template is rightmost opening
12505 !! options
12506 language=zh
12507 !! wikitext
12508 -{{echo|foo}-}}-
12509 !! html/php
12510 <p>-foo}--
12511 </p>
12512 !! html/parsoid
12513 <p>-<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo}-"}},"i":0}}]}'>foo}-</span>-</p>
12514 !! end
12515
12516 !! test
12517 Preprocessor precedence 3: language converter is rightmost opening
12518 !! options
12519 language=zh
12520 parsoid=wt2html
12521 !! wikitext
12522 {{echo|hi}}
12523
12524 {{-{R|echo|hi}}}-
12525
12526 [[-{R|raw]]}-
12527 !! html/php
12528 <p>hi
12529 </p><p>{{echo|hi}}
12530 </p><p>[[raw]]
12531 </p>
12532 !! html/parsoid
12533 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi"}},"i":0}}]}'>hi</p>
12534 <p>{{<span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"echo|hi}}"}}'></span></p>
12535 <p>[[<span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw]]"}}'></span></p>
12536 !! end
12537
12538 !! test
12539 Preprocessor precedence 4: left-most angle bracket
12540 !! options
12541 language=zh
12542 !! wikitext
12543 <!--{raw}-->
12544 !! html/php
12545 !! html/parsoid
12546 <!--{raw}-->
12547 !! end
12548
12549 !! article
12550 Template:Precedence5
12551 !! text
12552 {{{{{1}}}}}
12553 !! endarticle
12554
12555 !! test
12556 Preprocessor precedence 5: tplarg takes precedence over template
12557 !! wikitext
12558 {{Precedence5|Bullet}}
12559 !! html/php
12560 <ul><li>Bar</li></ul>
12561
12562 !! html/parsoid
12563 <ul typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"Precedence5","href":"./Template:Precedence5"},"params":{"1":{"wt":"Bullet"}},"i":0}}]}'><li>Bar</li></ul>
12564 !! end
12565
12566 !! test
12567 Preprocessor precedence 6: broken link is rightmost opening
12568 !! options
12569 parsoid=wt2html
12570 !! wikitext
12571 {{echo|[[Foo}}
12572
12573 {{echo|[[Foo|bar|bat=baz}}
12574 !! html/php
12575 <p>{{echo|[[Foo}}
12576 </p><p>{{echo|[[Foo|bar|bat=baz}}
12577 </p>
12578 !! html/parsoid
12579 <p>{{echo|[[Foo}}</p>
12580 <p>{{echo|[[Foo|bar|bat=baz}}</p>
12581 !! end
12582
12583 # This next test exposes a difference between PHP and Parsoid:
12584 # Given [[Foo|{{echo|Bar]]x}}y]]z:
12585 # 1) Both PHP and Parsoid ignore the `]]` inside the `echo` in the
12586 # "preprocessor" stage. The `{{echo` extends until the `x}}`, and the
12587 # outer `[[Foo` extends until the `y]]`
12588 # 2a) But then the PHP preprocessor emits `[[Foo|Bar]]xy]]z` as an
12589 # intermediate result (after template expansion), and link processing
12590 # happens on this intermediate result, which moves the wikilink
12591 # boundary leftward to `[[Foo|Bar]]`
12592 # 2b) Parsoid works in a single step, so it's going to keep the
12593 # wikilink as extending to the `y]]`
12594 # 3a) Then PHP does linktrail processing which slurps up the trailing
12595 # `xy` inside the link.
12596 # 3b) Parsoid will do linktrail processing to slurp up the trailing
12597 # `z` inside the link.
12598 # This is "correct" behavior. Parsoid's basic worldview is that the
12599 # `]]` inside the template shouldn't be allowed to leak out to affect
12600 # the surrounding wikilink. PHP may match Parsoid (in the future)
12601 # if you use {{#balance}} (T114445).
12602
12603 !! test
12604 Preprocessor precedence 7: broken template is rightmost opening
12605 !! options
12606 parsoid=wt2html
12607 !! wikitext
12608 [[Foo|{{echo|Bar]]
12609
12610 [[Foo|{{echo|Bar]]-x}}-y]]-z
12611
12612 Careful: linktrails can move the end of the wikilink:
12613 [[Foo|{{echo|y']]a}}l]]l
12614 !! html/php
12615 <p><a href="/wiki/Foo" title="Foo">{{echo|Bar</a>
12616 </p><p><a href="/wiki/Foo" title="Foo">Bar</a>-x-y]]-z
12617 </p><p>Careful: linktrails can move the end of the wikilink:
12618 <a href="/wiki/Foo" title="Foo">y'al</a>]]l
12619 </p>
12620 !! html/parsoid
12621 <p>[[Foo|{{echo|Bar]]</p>
12622 <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>
12623 <p>Careful: linktrails can move the end of the wikilink:
12624 <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>
12625 !! end
12626
12627 !! test
12628 Preprocessor precedence 8: broken language converter is rightmost opening
12629 !! options
12630 language=zh
12631 !! wikitext
12632 [[Foo-{R|raw]]
12633 !! html
12634 <p>[[Foo-{R|raw]]
12635 </p>
12636 !! end
12637
12638 !! article
12639 Template:Preprocessor_precedence_9
12640 !! text
12641 ;4: {{{{1}}}}
12642 ;5: {{{{{2}}}}}
12643 ;6: {{{{{{3}}}}}}
12644 ;7: {{{{{{{4}}}}}}}
12645 !! endarticle
12646
12647 !! test
12648 Preprocessor precedence 9: groups of braces
12649 !! wikitext
12650 {{Preprocessor precedence 9|Four|Bullet|1|2}}
12651 !! html/php
12652 <dl><dt>4</dt>
12653 <dd>{Four}</dd>
12654 <dt>5</dt>
12655 <dd></dd></dl>
12656 <ul><li>Bar</li></ul>
12657 <dl><dt>6</dt>
12658 <dd>Four</dd>
12659 <dt>7</dt>
12660 <dd>{Bullet}</dd></dl>
12661
12662 !! html/parsoid
12663 <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}}]}'>
12664 <dt>4</dt>
12665 <dd>{Four}</dd>
12666 <dt>5</dt>
12667 <dd></dd>
12668 </dl><ul about="#mwt1">
12669 <li>Bar</li>
12670 </ul><span about="#mwt1"> </span><dl about="#mwt1">
12671 <dt>6</dt>
12672 <dd>Four</dd>
12673 <dt>7</dt>
12674 <dd>{Bullet}</dd>
12675 </dl>
12676 !! end
12677
12678 !! article
12679 Template:Preprocessor_precedence_10
12680 !! text
12681 ;1: -{R|raw}-
12682 ;2: -{{Bullet}}-
12683 ;3: -{{{1}}}-
12684 ;4: -{{{{2}}}}-
12685 ;5: -{{{{{3}}}}}-
12686 ;6: -{{{{{{4}}}}}}-
12687 ;7: -{{{{{{{5}}}}}}}-
12688 !! endarticle
12689
12690 !! test
12691 Preprocessor precedence 10: groups of braces with leading dash
12692 !! options
12693 language=zh
12694 !! wikitext
12695 {{Preprocessor precedence 10|Three|raw2|Bullet|1|2}}
12696 !! html/php
12697 <dl><dt>1</dt>
12698 <dd>raw</dd>
12699 <dt>2</dt>
12700 <dd>-</dd></dl>
12701 <ul><li>Bar-</li></ul>
12702 <dl><dt>3</dt>
12703 <dd>-Three-</dd>
12704 <dt>4</dt>
12705 <dd>raw2</dd>
12706 <dt>5</dt>
12707 <dd>-</dd></dl>
12708 <ul><li>Bar-</li></ul>
12709 <dl><dt>6</dt>
12710 <dd>-Three-</dd>
12711 <dt>7</dt>
12712 <dd>raw2</dd></dl>
12713
12714 !! html/parsoid
12715 <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}}]}'>
12716 <dt>1</dt>
12717 <dd><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw"}}'></span></dd>
12718 <dt>2</dt>
12719 <dd>-</dd>
12720 </dl><ul about="#mwt1">
12721 <li>Bar-</li>
12722 </ul><span about="#mwt1"> </span><dl about="#mwt1">
12723 <dt>3</dt>
12724 <dd>-Three-</dd>
12725 <dt>4</dt>
12726 <dd><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw2"}}'></span></dd>
12727 <dt>5</dt>
12728 <dd>-</dd>
12729 </dl><ul about="#mwt1">
12730 <li>Bar-</li>
12731 </ul><span about="#mwt1"> </span><dl about="#mwt1">
12732 <dt>6</dt>
12733 <dd>-Three-</dd>
12734 <dt>7</dt>
12735 <dd><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw2"}}'></span></dd>
12736 </dl>
12737 !! end
12738
12739 !! test
12740 Preprocessor precedence 11: found during visual diff testing
12741 !! wikitext
12742 {{#tag:span|-{{#tag:span|-{{echo|x}}}}}}
12743
12744 {{echo|-{{echo|-{{echo|x}}}}}}
12745
12746 {{echo|-{{echo|x}}}}
12747 !! html/php
12748 <p><span>-<span>-x</span></span>
12749 </p><p>--x
12750 </p><p>-x
12751 </p>
12752 !! html/parsoid
12753 <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>
12754
12755 <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>
12756
12757 <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>
12758 !! end
12759
12760 !! test
12761 Preprocessor precedence 12: broken language converter closed by brace.
12762 !! options
12763 parsoid=wt2html
12764 !! wikitext
12765 This form breaks the template, which is unfortunate:
12766 *{{echo|foo-{bar}bat}}
12767
12768 But if the broken language converter markup is inside an extension
12769 tag, nothing bad happens:
12770 *<nowiki>foo-{bar}bat</nowiki>
12771 *{{echo|<nowiki>foo-{bar}bat</nowiki>}}
12772 *<pre>foo-{bar}bat</pre>
12773 *{{echo|<pre>foo-{bar}bat</pre>}}
12774
12775 <tag>foo-{bar}bat</tag>
12776 {{echo|<tag>foo-{bar}bat</tag>}}
12777
12778 !! html/php+tidy
12779 <p>This form breaks the template, which is unfortunate:
12780 </p>
12781 <ul><li>{{echo|foo-{bar}bat}}</li></ul>
12782 <p>But if the broken language converter markup is inside an extension
12783 tag, nothing bad happens:
12784 </p>
12785 <ul><li>foo-&#123;bar}bat</li>
12786 <li>foo-&#123;bar}bat</li>
12787 <li><pre>foo-{bar}bat</pre></li>
12788 <li><pre>foo-{bar}bat</pre></li></ul>
12789 <pre>'foo-{bar}bat'
12790 array (
12791 )
12792 </pre>
12793 <pre>'foo-{bar}bat'
12794 array (
12795 )
12796 </pre>
12797 !! html/parsoid
12798 <p>This form breaks the template, which is unfortunate:</p>
12799 <ul>
12800 <li>{{echo|foo-{bar}bat}}</li>
12801 </ul>
12802 <p>But if the broken language converter markup is inside an extension tag, nothing bad happens:</p>
12803 <ul>
12804 <li><span typeof="mw:Nowiki">foo-{bar}bat</span></li>
12805 <li><span typeof="mw:Nowiki mw:Transclusion" 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>
12806 <li><pre typeof="mw:Extension/pre" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo-{bar}bat"}}'>foo-{bar}bat</pre></li>
12807 <li><pre typeof="mw:Extension/pre mw:Transclusion" 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>
12808 </ul>
12809 <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>
12810 !! end
12811
12812 !! test
12813 Preprocessor precedence 13: broken language converter in external link
12814 !! options
12815 parsoid=wt2html
12816 !! wikitext
12817 *[http://example.com/-{foo Example in URL]
12818 *[http://example.com Example in -{link} description]
12819 *{{echo|[http://example.com/-{foo Breaks template, however]}}
12820 !! html/php+tidy
12821 <ul><li><a rel="nofollow" class="external text" href="http://example.com/-{foo">Example in URL</a></li>
12822 <li><a rel="nofollow" class="external text" href="http://example.com">Example in -{link} description</a></li>
12823 <li>{{echo|<a rel="nofollow" class="external text" href="http://example.com/-{foo">Breaks template, however</a>}}</li></ul>
12824 !! html/parsoid
12825 <ul>
12826 <li><a rel="mw:ExtLink" class="external text" href="http://example.com/-{foo">Example in URL</a></li>
12827 <li><a rel="mw:ExtLink" class="external text" href="http://example.com">Example in -{link} description</a></li>
12828 <li>{{echo|<a rel="mw:ExtLink" class="external text" href="http://example.com/-{foo">Breaks template, however</a>}}</li>
12829 </ul>
12830 !! end
12831
12832 !! test
12833 Preprocessor precedence 14: broken language converter in comment
12834 !! wikitext
12835 *<!--{{foo}}-->...should be ok
12836 *<!---{{foo}}-->...extra dashes
12837 *{{echo|foo<!-- -{bar} -->bat}}...should be ok
12838 !! html/php+tidy
12839 <ul><li>...should be ok</li>
12840 <li>...extra dashes</li>
12841 <li>foobat...should be ok</li></ul>
12842 !! html/parsoid
12843 <ul>
12844 <li><!--{{foo}}-->...should be ok</li>
12845 <li><!--&#x2D;{{foo}}-->...extra dashes</li>
12846 <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>
12847 </ul>
12848 !! end
12849
12850 !! test
12851 Preprocessor precedence 15: broken brace markup in headings
12852 !! config
12853 wgFragmentMode=[ 'html5', 'legacy' ]
12854 !! options
12855 parsoid=wt2html
12856 !! wikitext
12857 __NOTOC__ __NOEDITSECTION__
12858 ===1 foo[bar 1===
12859 1
12860 ===2 foo[[bar 2===
12861 2
12862 ===3 foo{bar 3===
12863 3
12864 ===4 foo{{bar 4===
12865 4
12866 ===5 foo{{{bar 5===
12867 5
12868 ===6 foo-{bar 6===
12869 6
12870 !! html/php+tidy
12871 <h3><span id="1_foo.5Bbar_1"></span><span class="mw-headline" id="1_foo[bar_1">1 foo[bar 1</span></h3>
12872 <p>1
12873 </p>
12874 <h3><span id="2_foo.5B.5Bbar_2"></span><span class="mw-headline" id="2_foo[[bar_2">2 foo[[bar 2</span></h3>
12875 <p>2
12876 </p>
12877 <h3><span id="3_foo.7Bbar_3"></span><span class="mw-headline" id="3_foo{bar_3">3 foo{bar 3</span></h3>
12878 <p>3
12879 </p>
12880 <h3><span id="4_foo.7B.7Bbar_4"></span><span class="mw-headline" id="4_foo{{bar_4">4 foo{{bar 4</span></h3>
12881 <p>4
12882 </p>
12883 <h3><span id="5_foo.7B.7B.7Bbar_5"></span><span class="mw-headline" id="5_foo{{{bar_5">5 foo{{{bar 5</span></h3>
12884 <p>5
12885 </p>
12886 <h3><span id="6_foo-.7Bbar_6"></span><span class="mw-headline" id="6_foo-{bar_6">6 foo-{bar 6</span></h3>
12887 <p>6
12888 </p>
12889 !! html/parsoid
12890 <meta property="mw:PageProp/notoc"/> <meta property="mw:PageProp/noeditsection"/>
12891 <h3 id="1_foo[bar_1"><span id="1_foo.5Bbar_1" typeof="mw:FallbackId"></span>1 foo[bar 1</h3>
12892 <p>1</p>
12893 <h3 id="2_foo[[bar_2"><span id="2_foo.5B.5Bbar_2" typeof="mw:FallbackId"></span>2 foo[[bar 2</h3>
12894 <p>2</p>
12895 <h3 id="3_foo{bar_3"><span id="3_foo.7Bbar_3" typeof="mw:FallbackId"></span>3 foo{bar 3</h3>
12896 <p>3</p>
12897 <h3 id="4_foo{{bar_4"><span id="4_foo.7B.7Bbar_4" typeof="mw:FallbackId"></span>4 foo{{bar 4</h3>
12898 <p>4</p>
12899 <h3 id="5_foo{{{bar_5"><span id="5_foo.7B.7B.7Bbar_5" typeof="mw:FallbackId"></span>5 foo{{{bar 5</h3>
12900 <p>5</p>
12901 <h3 id="6_foo-{bar_6"><span id="6_foo-.7Bbar_6" typeof="mw:FallbackId"></span>6 foo-{bar 6</h3>
12902 <p>6</p>
12903 !! end
12904
12905 !! test
12906 Preprocessor precedence 16: matching closing braces to opening braces
12907 !! options
12908 language=zh
12909 parsoid=wt2html
12910 !! wikitext
12911 -{{{echo|foo}}bar}-
12912 !! html/php
12913 <p>foobar
12914 </p>
12915 !! html/parsoid
12916 <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>
12917 !! end
12918
12919 !! test
12920 Preprocessor precedence 17: template w/o target shouldn't prevent closing
12921 !! options
12922 parsoid=wt2html
12923 !! wikitext
12924 {{echo|hi {{}}}}
12925 !! html/php
12926 <p>hi {{}}
12927 </p>
12928 !! html/parsoid
12929 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi {{}}"}},"i":0}}]}'>hi {{}}</p>
12930 !! end
12931
12932 # Ensure we're using a language without variants for this test; even
12933 # if $wgUsePigLatinVariant is true. We've picked `de` arbitrarily.
12934 !! test
12935 Preprocessor precedence 18: another rightmost wins scenario
12936 !! options
12937 parsoid=wt2html
12938 language=de
12939 !! wikitext
12940 {{ -{{{{1|tplarg}}} }} }-
12941 !! html/php
12942 <p>{{ -{tplarg }} }-
12943 </p>
12944 !! html/parsoid
12945 <p>{{ -{<span about="#mwt1" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"1"},"params":{"1":{"wt":"tplarg"}},"i":0}}]}'>tplarg</span> }} }-</p>
12946 !! end
12947
12948 !! test
12949 Preprocessor precedence 19: break syntax
12950 !! options
12951 parsoid=wt2html
12952 !! wikitext
12953 -{{
12954 !! html/php
12955 <p>-{{
12956 </p>
12957 !! html/parsoid
12958 <p>-{{</p>
12959 !! end
12960
12961 ###
12962 ### Token Stream Patcher tests
12963 ###
12964 ### These tests won't always pass wt2wt and other modes because
12965 ### on serialization, the table will be output on a new line.
12966 ### For now, we are blacklisting them, and using this to test selser.
12967 ###
12968
12969 !!test
12970 1. Table tag in SOL posn. should get reparsed correctly with valid TSR
12971 !!options
12972 parsoid=wt2html,wt2wt
12973 !!wikitext
12974 {{echo|}}{| width = '100%'
12975 |foo
12976 |}
12977 !!html/parsoid
12978 <span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":""}},"i":0}}]}'></span><table width="100%">
12979 <tbody><tr><td>foo</td></tr>
12980 </tbody></table>
12981 !!end
12982
12983 ## We used to, but no longer wt2wt this test since the default serializer
12984 ## will normalize the include directives to serialize on their own line.
12985 ## Selser will take care of preserving formatting in scenarios where they
12986 ## intermingled with other wikitext.
12987 !!test
12988 2. Table tag in SOL posn. should get reparsed correctly with valid TSR
12989 !!options
12990 parsoid=wt2html
12991 !!wikitext
12992 <includeonly>a</includeonly>{| {{{b}}}
12993 |c
12994 |}
12995 !!html/parsoid
12996 <meta typeof="mw:Includes/IncludeOnly" data-parsoid='{"src":"&lt;includeonly>a&lt;/includeonly>"}' data-mw='{"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":""}]]}'>
12997 <tbody><tr><td>c</td></tr>
12998 </tbody></table>
12999 !!end
13000
13001 !! test
13002 Table wikitext syntax outside wiki-tables
13003 !! wikitext
13004 a
13005 |+ not a caption
13006 ! not a table heading
13007 |- not a table row
13008 | not a table cell
13009 | class="foo bar" | baz
13010 b
13011 |}
13012 |-
13013 c
13014 !! html
13015 <p>a
13016 |+ not a caption
13017 ! not a table heading
13018 |- not a table row
13019 | not a table cell
13020 | class="foo bar" | baz
13021 b
13022 |}
13023 |-
13024 c
13025 </p>
13026 !! end
13027
13028 ###
13029 ### Testing parsing of templates where a template arg
13030 ### has the same name as the template itself.
13031 ###
13032
13033 !! article
13034 Template:quote
13035 !! text
13036 {{{quote|{{{1}}}}}}
13037 !! endarticle
13038
13039 !!test
13040 Templates: Template Name/Arg clash: 1. Use of positional param
13041 !! wikitext
13042 {{quote|foo}}
13043 !! html
13044 <p>foo
13045 </p>
13046 !!end
13047
13048 !!test
13049 Templates: Template Name/Arg clash: 2. Use of named param
13050 !! wikitext
13051 {{quote|quote=foo}}
13052 !! html
13053 <p>foo
13054 </p>
13055 !!end
13056
13057 !!test
13058 Templates: Template Name/Arg clash: 3. Use of named param with empty input
13059 !! wikitext
13060 {{quote|quote}}
13061 !! html
13062 <p>quote
13063 </p>
13064 !!end
13065
13066 ###
13067 ### Parsoid-centric tests to stress Parsoid's ability to RT them unchanged
13068 ###
13069
13070 !!test
13071 Templates: 1. Simple use
13072 !! wikitext
13073 {{echo|Foo}}
13074 !! html
13075 <p>Foo
13076 </p>
13077 !!end
13078
13079 !!test
13080 Templates: 2. Inside a block tag
13081 !! wikitext
13082 <div>{{echo|Foo}}</div>
13083 <blockquote>{{echo|Foo}}</blockquote>
13084 !! html
13085 <div>Foo</div>
13086 <blockquote>Foo</blockquote>
13087
13088 !! html+tidy
13089 <div>Foo</div>
13090 <blockquote><p>Foo</p></blockquote>
13091 !!end
13092
13093 !!test
13094 Templates: P-wrapping: 1a. Templates on consecutive lines
13095 !! wikitext
13096 {{echo|Foo}}
13097 {{echo|bar}}
13098 !! html
13099 <p>Foo
13100 bar
13101 </p>
13102 !!end
13103
13104 !!test
13105 Templates: P-wrapping: 1b. Templates on consecutive lines
13106 !! wikitext
13107 Foo
13108
13109 {{echo|bar}}
13110 {{echo|baz}}
13111 !! html
13112 <p>Foo
13113 </p><p>bar
13114 baz
13115 </p>
13116 !!end
13117
13118 !!test
13119 Templates: P-wrapping: 1c. Templates on consecutive lines
13120 !! wikitext
13121 {{echo|Foo}}
13122 {{echo|bar}} <div>baz</div>
13123 !! html
13124 <p>Foo
13125 </p>
13126 bar <div>baz</div>
13127
13128 !! html+tidy
13129 <p>Foo
13130 </p><p>
13131 bar </p><div>baz</div>
13132 !! end
13133
13134 !! test
13135 Templates: P-wrapping: 1d. Template preceded by comment-only line
13136 !! wikitext
13137 <!-- foo -->
13138 {{echo|Bar}}
13139 !! html/php+tidy
13140 <p>Bar
13141 </p>
13142 !! html/parsoid
13143 <!-- foo -->
13144
13145 <p about="#mwt223" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"Bar"}},"i":0}}]}'>Bar</p>
13146 !!end
13147
13148 !! test
13149 Templates: Scopes should not be expanded unnecessarily
13150 !! options
13151 parsoid=wt2html,wt2wt
13152 !! wikitext
13153 {{echo|<div>a</div>}}b{{echo|
13154 <div>c</div>}}
13155 !! html/php+tidy
13156 <div>a</div><p>b
13157 </p><div>c</div>
13158 !! html/parsoid
13159 <div about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;div>a&lt;/div>"}},"i":0}}]}'>a</div><p>b</p><span about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"\n&lt;div>c&lt;/div>"}},"i":0}}]}'>
13160 </span><div about="#mwt2">c</div>
13161 !! end
13162
13163 !!test
13164 Templates: Inline Text: 1. Multiple template uses
13165 !! wikitext
13166 {{echo|Foo}}bar{{echo|baz}}
13167 !! html
13168 <p>Foobarbaz
13169 </p>
13170 !!end
13171
13172 !!test
13173 Templates: Inline Text: 2. Back-to-back template uses
13174 !! wikitext
13175 {{echo|Foo}}{{echo|bar}}
13176 !! html
13177 <p>Foobar
13178 </p>
13179 !!end
13180
13181 !!test
13182 Templates: Block Tags: 1. Multiple template uses
13183 !! wikitext
13184 {{echo|<div>Foo</div>}}<div>bar</div>{{echo|<div>baz</div>}}
13185 !! html
13186 <div>Foo</div><div>bar</div><div>baz</div>
13187
13188 !!end
13189
13190 !!test
13191 Templates: Block Tags: 2. Back-to-back template uses
13192 !! wikitext
13193 {{echo|<div>Foo</div>}}{{echo|<div>bar</div>}}
13194 !! html
13195 <div>Foo</div><div>bar</div>
13196
13197 !!end
13198
13199 ## Parsoid drops empty elements in templates.
13200 !! test
13201 Templates: Correctly encapsulate templates producing </p> tag without a corresponding <p> tag
13202 !! wikitext
13203 {{echo|a
13204 b</p>}}
13205 !! html/php+tidy
13206 <p>a
13207 </p><p>
13208 b</p><p class="mw-empty-elt"></p>
13209 !! html/parsoid
13210 <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</p><span about="#mwt1">
13211 </span><p about="#mwt1">b</p>
13212 !! end
13213
13214 !!test
13215 Templates: Links: 1. Simple example
13216 !! wikitext
13217 {{echo|[[Foo|bar]]}}
13218 !! html
13219 <p><a href="/wiki/Foo" title="Foo">bar</a>
13220 </p>
13221 !!end
13222
13223 !!test
13224 Templates: Links: 2. Generation of link href
13225 !! wikitext
13226 [[{{echo|Foo}}|bar]]
13227 !! html
13228 <p><a href="/wiki/Foo" title="Foo">bar</a>
13229 </p>
13230 !!end
13231
13232 !!test
13233 Templates: Links: 3. Generation of part of a link href
13234 !! wikitext
13235 [[Fo{{echo|o}}|bar]]
13236
13237 [[Foo{{echo|bar}}]]
13238
13239 [[Foo{{echo|bar}}baz]]
13240
13241 [[Foo{{echo|bar}}|bar]]
13242
13243 [[:Foo{{echo|bar}}]]
13244
13245 [[:Foo{{echo|bar}}|bar]]
13246 !! html
13247 <p><a href="/wiki/Foo" title="Foo">bar</a>
13248 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
13249 </p><p><a href="/index.php?title=Foobarbaz&amp;action=edit&amp;redlink=1" class="new" title="Foobarbaz (page does not exist)">Foobarbaz</a>
13250 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">bar</a>
13251 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
13252 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">bar</a>
13253 </p>
13254 !!end
13255
13256 !!test
13257 Templates: Links: 4. Multiple templates generating link href
13258 !! wikitext
13259 [[{{echo|F}}{{echo|o}}ob{{echo|ar}}]]
13260 !! html
13261 <p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
13262 </p>
13263 !!end
13264
13265 !!test
13266 Templates: Links: 5. Generation of link text
13267 !! wikitext
13268 [[Foo|{{echo|bar}}]]
13269 !! html
13270 <p><a href="/wiki/Foo" title="Foo">bar</a>
13271 </p>
13272 !!end
13273
13274 !!test
13275 Templates: Links: 5. Nested templates (only outermost template should be marked)
13276 !! wikitext
13277 {{echo|[[{{echo|Foo}}|bar]]}}
13278 !! html
13279 <p><a href="/wiki/Foo" title="Foo">bar</a>
13280 </p>
13281 !!end
13282
13283 !!test
13284 Templates: HTML Tag: 1. Generation of HTML attr. key
13285 !! wikitext
13286 <div {{echo|style}}="color:red;">foo</div>
13287 !! html
13288 <div style="color:red;">foo</div>
13289
13290 !!end
13291
13292 !!test
13293 Templates: HTML Tag: 2. Generation of HTML attr. value
13294 !! wikitext
13295 <div style={{echo|'color:red;'}}>foo</div>
13296 !! html
13297 <div style="color:red;">foo</div>
13298
13299 !!end
13300
13301 !!test
13302 Templates: HTML Tag: 3. Generation of HTML attr key and value
13303 !! wikitext
13304 <div {{echo|style}}={{echo|'color:red;'}}>foo</div>
13305 !! html
13306 <div style="color:red;">foo</div>
13307
13308 !!end
13309
13310 !!test
13311 Templates: HTML Tag: 4. Generation of starting piece of HTML attr value
13312 !! wikitext
13313 <div title="{{echo|This is a long title}} with just one piece templated">foo</div>
13314 !! html
13315 <div title="This is a long title with just one piece templated">foo</div>
13316
13317 !!end
13318
13319 !!test
13320 Templates: HTML Tag: 5. Generation of middle piece of HTML attr value
13321 !! wikitext
13322 <div title="This is a long title with just {{echo|one piece}} templated">foo</div>
13323 !! html
13324 <div title="This is a long title with just one piece templated">foo</div>
13325
13326 !!end
13327
13328 !!test
13329 Templates: HTML Tag: 6. Generation of end piece of HTML attr value
13330 !! wikitext
13331 <div title="This is a long title with just one piece {{echo|templated}}">foo</div>
13332 !! html
13333 <div title="This is a long title with just one piece templated">foo</div>
13334
13335 !!end
13336
13337 # SSS FIXME: While it is great we added support for all this,
13338 # do we want to make this part of the spec? Maybe we want to
13339 # deprecate this kind of usage in the future?
13340 !!test
13341 Templates: HTML Tag: 7. Generation of partial attribute key string
13342 !! wikitext
13343 <div st{{echo|yle}}="color:red;">foo</div>
13344 !! html
13345 <div style="color:red;">foo</div>
13346
13347 !!end
13348
13349 !! test
13350 Templates: HTML Tag: 8. Template-generated attribute (k=v)
13351 !! wikitext
13352 <div {{echo|1=id="v1"}}>bar</div>
13353 !! html
13354 <div id="v1">bar</div>
13355
13356 !!end
13357
13358 !! test
13359 Templates: HTML Tag: 9. Multiple template-generated attributes
13360 !! wikitext
13361 <div {{echo|1=id="v1" title="foo"}}>bar</div>
13362 !! html
13363 <div id="v1" title="foo">bar</div>
13364
13365 !!end
13366
13367 !! test
13368 Templates: Support for templates generating attributes and content
13369 !! wikitext
13370 {| {{mixed_attr_content_template}}
13371 |-
13372 |bar
13373 |}
13374 !! html/php
13375 <table style="color:red;" title="T48811">
13376
13377 <tr>
13378 <td>foo
13379 </td></tr>
13380 <tr>
13381 <td>bar
13382 </td></tr></table>
13383
13384 !! html/parsoid
13385 <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|}"]}'>
13386 <tbody><tr>
13387 <td>foo</td></tr>
13388 <tr>
13389 <td>bar</td></tr>
13390 </tbody></table>
13391 !!end
13392
13393 !! article
13394 Template:attribute_from_template
13395 !! text
13396 class="123"
13397 !! endarticle
13398
13399 !! test
13400 Table cell with attribute before expanded attribute
13401 !! wikitext
13402 {|
13403 | align="center" {{attribute_from_template}} |456
13404 |}
13405 !! html/parsoid
13406 <table>
13407 <tbody><tr><td align="center" class="123" about="#mwt2" typeof="mw:ExpandedAttrs" data-mw='{"attribs":[[{"txt":"class","html":"&lt;span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid=&apos;{\"pi\":[[]],\"dsr\":[20,47,null,null]}&apos; data-mw=&apos;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"attribute_from_template\",\"href\":\"./Template:Attribute_from_template\"},\"params\":{},\"i\":0}}]}&apos;>class=\"123\"&lt;/span>"},{"html":""}]]}'>456</td></tr>
13408 </tbody></table>
13409 !! end
13410
13411 !! test
13412 1. Entities and nowikis inside templated attributes should be handled correctly
13413 !! wikitext
13414 <div {{echo|style{{=}}"background:&#35;f9f9f9;"}}>foo</div>
13415 !! html/php
13416 <div style="background:#f9f9f9;">foo</div>
13417
13418 !! html/parsoid
13419 <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>
13420 !! end
13421
13422 !! test
13423 2. Entities and nowikis inside templated attributes should be handled correctly
13424 !! wikitext
13425 {|
13426 |{{table_attribs_3}}
13427 |}
13428 !! html/php
13429 <table>
13430 <tr>
13431 <td style="background:#f9f9f9;">Foo
13432 </td></tr></table>
13433
13434 !! html/parsoid
13435 <table>
13436 <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>
13437 </tbody></table>
13438 !! end
13439
13440 !! test
13441 3. Entities and nowikis inside templated attributes should be handled correctly inside templated tables
13442 !! wikitext
13443 {{tbl-start}}
13444 |{{table_attribs_3}}
13445 {{tbl-end}}
13446 !! html/php
13447 <table>
13448 <tr>
13449 <td style="background:#f9f9f9;">Foo
13450 </td></tr></table>
13451
13452 !! html/parsoid
13453 <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}}]}'>
13454 <tbody><tr><td style="background:#f9f9f9;">Foo</td></tr>
13455 </tbody></table>
13456 !! end
13457
13458 # T107622
13459 !! test
13460 4. Entities and nowikis inside templated attributes should be handled correctly inside templated tables
13461 !! wikitext
13462 {|
13463 |{{table_attribs_6}} hi
13464 |}
13465 !! html/php
13466 <table>
13467 <tr>
13468 <td style="background: red;">hi
13469 </td></tr></table>
13470
13471 !! html/parsoid
13472 <table>
13473 <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>
13474 </tbody></table>
13475 !! end
13476
13477 !!test
13478 Templates: HTML Tables: 1. Generating start of a HTML table
13479 !! wikitext
13480 {{echo|<table><tr><td>foo</td>}}</tr></table>
13481 !! html
13482 <table><tr><td>foo</td></tr></table>
13483
13484 !!end
13485
13486 !!test
13487 Templates: HTML Tables: 2a. Generating middle of a HTML table
13488 !! wikitext
13489 <table><tr>{{echo|<td>foo</td>}}</tr></table>
13490 !! html
13491 <table><tr><td>foo</td></tr></table>
13492
13493 !!end
13494
13495 !!test
13496 Templates: HTML Tables: 2b. Generating middle of a HTML table
13497 !! wikitext
13498 <table>{{echo|<tr><td>foo</td></tr>}}</table>
13499 !! html
13500 <table><tr><td>foo</td></tr></table>
13501
13502 !!end
13503
13504 !!test
13505 Templates: HTML Tables: 3. Generating end of a HTML table
13506 !! wikitext
13507 <table><tr>{{echo|<td>foo</td></tr></table>}}
13508 !! html
13509 <table><tr><td>foo</td></tr></table>
13510
13511 !!end
13512
13513 !!test
13514 Templates: HTML Tables: 4a. Generating a single tag of a HTML table
13515 !! wikitext
13516 {{echo|<table>}}<tr><td>foo</td></tr></table>
13517 !! html
13518 <table><tr><td>foo</td></tr></table>
13519
13520 !!end
13521
13522 !!test
13523 Templates: HTML Tables: 4b. Generating a single tag of a HTML table
13524 !! wikitext
13525 <table>{{echo|<tr>}}<td>foo</td></tr></table>
13526 !! html
13527 <table><tr><td>foo</td></tr></table>
13528
13529 !!end
13530
13531 !!test
13532 Templates: HTML Tables: 4c. Generating a single tag of a HTML table
13533 !! wikitext
13534 <table><tr>{{echo|<td>}}foo</td></tr></table>
13535 !! html
13536 <table><tr><td>foo</td></tr></table>
13537
13538 !!end
13539
13540 !!test
13541 Templates: HTML Tables: 4d. Generating a single tag of a HTML table
13542 !! wikitext
13543 <table><tr><td>foo{{echo|</td>}}</tr></table>
13544 !! html
13545 <table><tr><td>foo</td></tr></table>
13546
13547 !!end
13548
13549 !!test
13550 Templates: HTML Tables: 4e. Generating a single tag of a HTML table
13551 !! wikitext
13552 <table><tr><td>foo</td>{{echo|</tr>}}</table>
13553 !! html
13554 <table><tr><td>foo</td></tr></table>
13555
13556 !!end
13557
13558 !!test
13559 Templates: HTML Tables: 4f. Generating a single tag of a HTML table
13560 !! wikitext
13561 <table><tr><td>foo</td></tr>{{echo|</table>}}
13562 !! html
13563 <table><tr><td>foo</td></tr></table>
13564
13565 !!end
13566
13567 !!test
13568 Templates: HTML Tables: 5. Proper fostering of categories from inside
13569 !!options
13570 parsoid=wt2html,wt2wt
13571 !! wikitext
13572 <table>[[Category:foo1]]<tr><td>foo</td></tr></table>
13573 <!--Two categories (T52330)-->
13574 <table>[[Category:bar1]][[Category:bar2]]<tr><td>foo</td></tr></table>
13575 !! html/php+tidy
13576 <table><tbody><tr><td>foo</td></tr></tbody></table>
13577 <table><tbody><tr><td>foo</td></tr></tbody></table>
13578 !! html/parsoid
13579 <link rel="mw:PageProp/Category" href="./Category:Foo1"><table><tbody><tr><td>foo</td></tr></tbody></table>
13580 <!--Two categories (T52330)-->
13581 <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>
13582 !!end
13583
13584 ## Remex doesn't account for fostered content.
13585 !! test
13586 Templates: Wiki Tables: 1a. Fostering of entire template content
13587 !! wikitext
13588 {|
13589 {{echo|a}}
13590 |}
13591 !! html/php
13592 <table>
13593 a
13594 <tr><td></td></tr></table>
13595
13596 !! html/php+tidy
13597
13598 a
13599 <table><tbody><tr><td></td></tr></tbody></table>
13600 !! html/parsoid
13601 <p about="#mwt2" typeof="mw:Transclusion" data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true,"firstWikitextNode":"TABLE","pi":[[{"k":"1"}]]}' data-mw='{"parts":["{|\n",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"a"}},"i":0}},"\n|}"]}'>a</p><table about="#mwt2">
13602
13603 </table>
13604 !! end
13605
13606 !!test
13607 Templates: Wiki Tables: 1b. Fostering of entire template content
13608 !! wikitext
13609 {|
13610 {{echo|<div>}}
13611 foo
13612 {{echo|</div>}}
13613 |}
13614 !! html
13615 <table>
13616 <div>
13617 <p>foo
13618 </p>
13619 </div>
13620 <tr><td></td></tr></table>
13621
13622 !! html/php+tidy
13623 <div>
13624 <p>foo
13625 </p>
13626 </div><table>
13627
13628 <tbody><tr><td></td></tr></tbody></table>
13629 !! html/parsoid
13630 <div about="#mwt3" typeof="mw:Transclusion" data-parsoid='{"stx":"html","fostered":true,"autoInsertedEnd":true,"firstWikitextNode":"TABLE","pi":[[{"k":"1"}],[{"k":"1"}]]}' data-mw='{"parts":["{|\n",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;div>"}},"i":0}},"\nfoo\n",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;/div>"}},"i":1}},"\n|}"]}'>
13631 <p>foo</p>
13632 </div><table about="#mwt3">
13633
13634 </table>
13635 !! end
13636
13637 ## Remex doesn't account for fostered content.
13638 !! test
13639 Templates: Wiki Tables: 2. Fostering of partial template content
13640 !! wikitext
13641 {|
13642 {{echo|a
13643 <div>b</div>}}
13644 |}
13645 !! html/php
13646 <table>
13647 a
13648 <div>b</div>
13649 <tr><td></td></tr></table>
13650
13651 !! html/php+tidy
13652
13653 a
13654 <div>b</div><table>
13655 <tbody><tr><td></td></tr></tbody></table>
13656 !! html/parsoid
13657 <p about="#mwt2" typeof="mw:Transclusion" data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true,"firstWikitextNode":"TABLE","pi":[[{"k":"1"}]]}' data-mw='{"parts":["{|\n",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"a\n&lt;div>b&lt;/div>"}},"i":0}},"\n|}"]}'>a</p><div about="#mwt2">b</div><table about="#mwt2">
13658
13659
13660 </table>
13661 !! end
13662
13663 !!test
13664 Templates: Wiki Tables: 3. td-content via multiple templates
13665 !! wikitext
13666 {|
13667 {{echo|{{pipe}}a}}{{echo|b}}
13668 |}
13669 !! html
13670 <table>
13671 <tr>
13672 <td>ab
13673 </td></tr></table>
13674
13675 !!end
13676
13677 !!test
13678 Templates: Wiki Tables: 4. Templated tags, no content
13679 !! wikitext
13680 {{tbl-start}}
13681 {{tbl-end}}
13682 !! html
13683 <table>
13684 <tr><td></td></tr></table>
13685
13686 !!end
13687
13688 !!test
13689 Templates: Wiki Tables: 5. Templated tags, regular td-tags
13690 !! wikitext
13691 {{tbl-start}}
13692 |foo
13693 {{tbl-end}}
13694 !! html
13695 <table>
13696 <tr>
13697 <td>foo
13698 </td></tr></table>
13699
13700 !!end
13701
13702 !!test
13703 Templates: Wiki Tables: 6. Templated tags, templated td-tags
13704 !! wikitext
13705 {{tbl-start}}
13706 {{!}}foo
13707 {{tbl-end}}
13708 !! html
13709 <table>
13710 <tr>
13711 <td>foo
13712 </td></tr></table>
13713
13714 !!end
13715
13716 ## This test case is very specific to Parsoid's internals
13717 ## and is hence only tested for Parsoid's code. Parsoid uses
13718 ## a <meta> marker tag for <ref> tags and they are expanded
13719 ## much later. We are verifying that this <meta> tag usage
13720 ## doesn't prevent foster parenting.
13721 !! test
13722 Templates: Wiki Tables: 7. Fosterable <ref>s should get fostered
13723 !! wikitext
13724 {{PartialTable}}<ref>foo</ref>
13725 |}
13726
13727 <references />
13728 !! html/parsoid
13729 <p about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"PartialTable","href":"./Template:PartialTable"},"params":{},"i":0}},"&lt;ref>foo&lt;/ref>\n|}"]}'><sup about="#mwt3" class="mw-ref" id="cite_ref-1" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{},"body":{"id":"mw-reference-text-cite_note-1"}}'><a href="./Parser_test#cite_note-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></sup></p><table about="#mwt2">
13730 <tbody>
13731 </tbody></table>
13732
13733 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt5" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Parser_test#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>
13734 !! end
13735
13736 !! test
13737 Templates: Wiki Tables: 8. Fosterable meta-tags should get fostered
13738 !! wikitext
13739 {{echo|
13740 {{{!}}
13741 {{!}}-}}
13742 <onlyinclude>
13743 |foo
13744 </onlyinclude>
13745 {{!}}}
13746 !! html/parsoid
13747 <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{{!}}}"]}'>
13748 </span><meta typeof="mw:Includes/OnlyInclude" about="#mwt1"/><table about="#mwt1">
13749 <tbody><tr>
13750
13751 <td>foo
13752 <meta typeof="mw:Includes/OnlyInclude/End"/></td></tr>
13753 </tbody></table>
13754 !! end
13755
13756 !!test
13757 Templates: Lists: Multi-line list-items via templates
13758 !! wikitext
13759 *{{echo|a {{nonexistent|
13760 unused}}}}
13761 *{{echo|b {{nonexistent|
13762 unused}}}}
13763 !! html
13764 <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>
13765 <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>
13766
13767 !!end
13768
13769 !!test
13770 Templates: Ugly nesting: 1. Quotes opened/closed across templates (echo)
13771 !! wikitext
13772 {{echo|''a}}{{echo|b''c''d}}{{echo|''e}}
13773 !! html
13774 <p><i>ab</i>c<i>d</i>e
13775 </p>
13776 !!end
13777
13778 !!test
13779 Templates: Ugly nesting: 2. Quotes opened/closed across templates (echo_with_span)
13780 (PHP parser generates misnested html)
13781 !! wikitext
13782 {{echo_with_span|''a}}{{echo_with_span|b''c''d}}{{echo_with_span|''e}}
13783 !! html/parsoid
13784 <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>
13785 !!end
13786
13787 !!test
13788 Templates: Ugly nesting: 3. Quotes opened/closed across templates (echo_with_div)
13789 (PHP parser generates misnested html; Parsoid html2wt mode adds newlines between {{echo}}s)
13790 !! options
13791 parsoid=wt2html,wt2wt
13792 !! wikitext
13793 {{echo_with_div|''a}}{{echo_with_div|b''c''d}}{{echo_with_div|''e}}
13794 !! html/php+tidy
13795 <div><i>a</i></div><div><i>b</i>c<i>d</i></div><div>e</div>
13796 !! html/parsoid
13797 <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>
13798 <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>
13799 <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>
13800 !!end
13801
13802 !!test
13803 Templates: Ugly nesting: 4. Divs opened/closed across templates
13804 !! wikitext
13805 a<div>b{{echo|c</div>d}}e
13806 !! html
13807 a<div>bc</div>de
13808
13809 !! html+tidy
13810 <p>a</p><div>bc</div><p>de
13811 </p>
13812 !! end
13813
13814 !! test
13815 Templates: Ugly templates: 3. newline-only template parameter
13816 !! wikitext
13817 foo {{echo|
13818 }}
13819 !! html
13820 <p>foo
13821 </p>
13822 !! end
13823
13824 # This looks like a bug: a single newline triggers p/br for some reason.
13825 !! test
13826 Templates: Ugly templates: 4. newline-only template parameter inconsistency
13827 !! wikitext
13828 {{echo|
13829 }}
13830 !! html
13831 <p><br />
13832 </p>
13833 !! end
13834
13835 # T66017 -- ugly wikitext with fostered content generates two template ranges that
13836 # have a true overlap (T1-start - T2-start - T1-end - T2-end).
13837 !! test
13838 Templates: Ugly templates: 5. Template encapsulation test: Non-trivial overlap of template ranges is properly handled
13839 !! wikitext
13840 {{echo|<table>}}
13841 {{echo|<div>foo}}
13842 {{echo|</table>}}
13843 !! html/parsoid
13844 <div about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"stx":"html","autoInsertedEnd":true,"pi":[[{"k":"1"}],[{"k":"1"}],[{"k":"1"}]]}' 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}}]}'>foo</div><span about="#mwt1">
13845 </span><table about="#mwt1">
13846 </table>
13847 !! end
13848
13849 # T66017 -- ugly wikitext with fostered content generates two template ranges
13850 # that are "identical" and generate nesting cycles in the algorithm
13851 !! test
13852 Templates: Ugly templates: 6. Template encapsulation test: Cyclical nesting of template ranges is properly handled
13853 !! wikitext
13854 {{echo|<table><tr><td><table>}}
13855 {{echo|<div>}}
13856 {{echo|</div>}}
13857 !! html/parsoid
13858 <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"}'>
13859 </div><table about="#mwt1" data-parsoid='{"stx":"html"}'>
13860 </table></td></tr></tbody></table>
13861 !! end
13862
13863 !! test
13864 Templates: Parameters substituted at the top-level
13865 !! wikitext
13866 {{{foo|''who'' {{echo|me}}? '''never!'''}}}
13867
13868 {{{foo|bar|baz}}}
13869 !! html/php
13870 <p><i>who</i> me? <b>never!</b>
13871 </p><p>bar
13872 </p>
13873 !! html/parsoid
13874 <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>
13875
13876 <p about="#mwt3" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"foo"},"params":{"1":{"wt":"bar"},"2":{"wt":"baz"}},"i":0}}]}'>bar</p>
13877 !! end
13878
13879 !! test
13880 Templates: Param with empty arg in the final position
13881 !! wikitext
13882 {{{hi|}}}
13883 !! html/parsoid
13884 <span about="#mwt1" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"hi"},"params":{"1":{"wt":""}},"i":0}}]}'></span>
13885 !! end
13886
13887 !!test
13888 Parser Functions: 1. Simple example
13889 !! wikitext
13890 {{uc:foo}}
13891 !! html
13892 <p>FOO
13893 </p>
13894 !!end
13895
13896 !!test
13897 Parser Functions: 2. Nested use (only outermost should be marked up)
13898 !! wikitext
13899 {{uc:{{lc:FOO}}}}
13900 !! html
13901 <p>FOO
13902 </p>
13903 !!end
13904
13905 ## Note that the templates inside the references are not wrapped
13906 !! test
13907 Template nested in extension tag in template
13908 !! options
13909 title=[[Main Page]]
13910 language=zh
13911 !! wikitext
13912 {{echo|hi<ref>[[ho|{{echo|hi}}]]</ref>}}
13913 {{echo|hi<ref>[http://test.com?q={{echo|ho}}]</ref>}}
13914 {{echo|hi<ref>-{ho|{{echo|hi}}}-</ref>}}
13915 <references />
13916 !! html/parsoid
13917 <p><span about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi&lt;ref>[[ho|{{echo|hi}}]]&lt;/ref>"}},"i":0}}]}'>hi</span><sup about="#mwt2" class="mw-ref" id="cite_ref-1" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{},"body":{"id":"mw-reference-text-cite_note-1"}}'><a href="./Main_Page#cite_note-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></sup>
13918 <span about="#mwt8" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi&lt;ref>[http://test.com?q={{echo|ho}}]&lt;/ref>"}},"i":0}}]}'>hi</span><sup about="#mwt8" class="mw-ref" id="cite_ref-2" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{},"body":{"id":"mw-reference-text-cite_note-2"}}'><a href="./Main_Page#cite_note-2" style="counter-reset: mw-Ref 2;"><span class="mw-reflink-text">[2]</span></a></sup>
13919 <span about="#mwt13" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi&lt;ref>-{ho|{{echo|hi}}}-&lt;/ref>"}},"i":0}}]}'>hi</span><sup about="#mwt13" class="mw-ref" id="cite_ref-3" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{},"body":{"id":"mw-reference-text-cite_note-3"}}'><a href="./Main_Page#cite_note-3" style="counter-reset: mw-Ref 3;"><span class="mw-reflink-text">[3]</span></a></sup></p>
13920 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt17" 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"><a rel="mw:WikiLink" href="./Ho" title="Ho">hi</a></span></li><li about="#cite_note-2" id="cite_note-2"><a href="./Main_Page#cite_ref-2" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-2" class="mw-reference-text"><a rel="mw:ExtLink" class="external autonumber" href="http://test.com?q=ho"></a></span></li><li about="#cite_note-3" id="cite_note-3"><a href="./Main_Page#cite_ref-3" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-3" class="mw-reference-text"><span typeof="mw:LanguageVariant" data-mw-variant='{"filter":{"l":["ho"],"t":"hi"}}'></span></span></li></ol>
13921 !! end
13922
13923 ###
13924 ### Pre-save transform tests
13925 ###
13926
13927 !! test
13928 pre-save transform: subst:
13929 !! options
13930 pst
13931 !! wikitext
13932 {{subst:test}}
13933 !! html/php
13934 This is a test template
13935 !! end
13936
13937 !! test
13938 pre-save transform: normal template
13939 !! options
13940 pst
13941 !! wikitext
13942 {{test}}
13943 !! html/php
13944 {{test}}
13945 !! end
13946
13947 !! test
13948 pre-save transform: nonexistent template
13949 !! options
13950 pst
13951 !! wikitext
13952 {{thistemplatedoesnotexist}}
13953 !! html/php
13954 {{thistemplatedoesnotexist}}
13955 !! end
13956
13957 !! test
13958 pre-save transform: subst magic variables
13959 !! options
13960 pst
13961 !! wikitext
13962 {{subst:SITENAME}}
13963 !! html/php
13964 MediaWiki
13965 !! end
13966
13967 # This is T2089, which I fixed. -- wtm
13968 !! test
13969 pre-save transform: subst: templates with parameters
13970 !! options
13971 pst
13972 !! wikitext
13973 {{subst:paramtest|param="something else"}}
13974 !! html/php
13975 This is a test template with parameter "something else"
13976 !! end
13977
13978 !! article
13979 Template:nowikitest
13980 !! text
13981 <nowiki>'''not wiki'''</nowiki>
13982 !! endarticle
13983
13984 !! test
13985 pre-save transform: nowiki in subst (T3188)
13986 !! options
13987 pst
13988 !! wikitext
13989 {{subst:nowikitest}}
13990 !! html/php
13991 <nowiki>'''not wiki'''</nowiki>
13992 !! end
13993
13994 !! article
13995 Template:commenttest
13996 !! text
13997 This template has <!-- a comment --> in it.
13998 !! endarticle
13999
14000 !! test
14001 pre-save transform: comment in subst (T3936)
14002 !! options
14003 pst
14004 !! wikitext
14005 {{subst:commenttest}}
14006 !! html/php
14007 This template has <!-- a comment --> in it.
14008 !! end
14009
14010 !! test
14011 pre-save transform: unclosed tag
14012 !! options
14013 pst
14014 !! wikitext
14015 <nowiki>'''not wiki'''
14016 !! html/php
14017 <nowiki>'''not wiki'''
14018 !! end
14019
14020 !! test
14021 pre-save transform: mixed tag case
14022 !! options
14023 pst
14024 !! wikitext
14025 <NOwiki>'''not wiki'''</noWIKI>
14026 !! html/php
14027 <NOwiki>'''not wiki'''</noWIKI>
14028 !! end
14029
14030 !! test
14031 pre-save transform: unclosed comment in <nowiki>
14032 !! options
14033 pst
14034 !! wikitext
14035 wiki<nowiki>nowiki<!--nowiki</nowiki>wiki
14036 !! html/php
14037 wiki<nowiki>nowiki<!--nowiki</nowiki>wiki
14038 !!end
14039
14040 # Leading @ in this template definition works around a limitation
14041 # in parsoid's parserTests which otherwise strips the <span> from the
14042 # result (confusing it for a template wrapper)
14043 !! article
14044 Template:dangerous
14045 !!text
14046 @<span onmouseover="alert('crap')">Oh no</span>
14047 !!endarticle
14048
14049 !!test
14050 (confirming safety of fix for subst T3936)
14051 !! wikitext
14052 {{Template:dangerous}}
14053 !! html
14054 <p>@<span>Oh no</span>
14055 </p>
14056 !! end
14057
14058 !! test
14059 pre-save transform: comment containing gallery (T7024)
14060 !! options
14061 pst
14062 !! wikitext
14063 <!-- <gallery>data</gallery> -->
14064 !! html/php
14065 <!-- <gallery>data</gallery> -->
14066 !!end
14067
14068 !! test
14069 pre-save transform: comment containing extension
14070 !! options
14071 pst
14072 !! wikitext
14073 <!-- <tag>data</tag> -->
14074 !! html/php
14075 <!-- <tag>data</tag> -->
14076 !!end
14077
14078 !! test
14079 pre-save transform: comment containing nowiki
14080 !! options
14081 pst
14082 !! wikitext
14083 <!-- <nowiki>data</nowiki> -->
14084 !! html/php
14085 <!-- <nowiki>data</nowiki> -->
14086 !!end
14087
14088 !! test
14089 pre-save transform: <noinclude> in subst (T5298)
14090 !! options
14091 pst
14092 !! wikitext
14093 {{subst:Includes}}
14094 !! html/php
14095 Foobar
14096 !! end
14097
14098 !! test
14099 pre-save transform: <onlyinclude> in subst (T5298)
14100 !! options
14101 pst
14102 !! wikitext
14103 {{subst:Includes2}}
14104 !! html/php
14105 Foo
14106 !! end
14107
14108 !! article
14109 Template:SubstTest
14110 !!text
14111 {{<includeonly>subst:</includeonly>Includes}}
14112 !! endarticle
14113
14114 !! article
14115 Template:SafeSubstTest
14116 !! text
14117 {{<includeonly>safesubst:</includeonly>Includes}}
14118 !! endarticle
14119
14120 !! test
14121 T24297: safesubst: works during PST
14122 !! options
14123 pst
14124 !! wikitext
14125 {{subst:SafeSubstTest}}{{safesubst:SubstTest}}
14126 !! html/php
14127 FoobarFoobar
14128 !! end
14129
14130 !! test
14131 T24297: safesubst: works during normal parse
14132 !! wikitext
14133 {{SafeSubstTest}}
14134 !! html
14135 <p>Foobar
14136 </p>
14137 !! end
14138
14139 !! test
14140 subst: does not work during normal parse
14141 !! wikitext
14142 {{SubstTest}}
14143 !! html
14144 <p>{{subst:Includes}}
14145 </p>
14146 !! end
14147
14148 !! test
14149 pre-save transform: context links ("pipe trick")
14150 !! options
14151 pst
14152 !! wikitext
14153 [[Article (context)|]]
14154 [[Bar:Article|]]
14155 [[:Bar:Article|]]
14156 [[Bar:Article (context)|]]
14157 [[:Bar:Article (context)|]]
14158 [[|Article]]
14159 [[|Article (context)]]
14160 [[Bar:X (Y) Z|]]
14161 [[:Bar:X (Y) Z|]]
14162 !! html/php
14163 [[Article (context)|Article]]
14164 [[Bar:Article|Article]]
14165 [[:Bar:Article|Article]]
14166 [[Bar:Article (context)|Article]]
14167 [[:Bar:Article (context)|Article]]
14168 [[Article]]
14169 [[Article (context)]]
14170 [[Bar:X (Y) Z|X (Y) Z]]
14171 [[:Bar:X (Y) Z|X (Y) Z]]
14172 !! end
14173
14174 !! test
14175 pre-save transform: context links ("pipe trick") with interwiki prefix
14176 !! options
14177 pst
14178 !! wikitext
14179 [[interwiki:Article|]]
14180 [[:interwiki:Article|]]
14181 [[interwiki:Bar:Article|]]
14182 [[:interwiki:Bar:Article|]]
14183 !! html/php
14184 [[interwiki:Article|Article]]
14185 [[:interwiki:Article|Article]]
14186 [[interwiki:Bar:Article|Bar:Article]]
14187 [[:interwiki:Bar:Article|Bar:Article]]
14188 !! end
14189
14190 !! test
14191 pre-save transform: context links ("pipe trick") with parens in title
14192 !! options
14193 pst title=[[Somearticle (context)]]
14194 !! wikitext
14195 [[|Article]]
14196 !! html/php
14197 [[Article (context)|Article]]
14198 !! end
14199
14200 !! test
14201 pre-save transform: context links ("pipe trick") with comma in title
14202 !! options
14203 pst title=[[Someplace, Somewhere]]
14204 !! wikitext
14205 [[|Otherplace]]
14206 [[Otherplace, Elsewhere|]]
14207 [[Otherplace, Elsewhere, Anywhere|]]
14208 !! html/php
14209 [[Otherplace, Somewhere|Otherplace]]
14210 [[Otherplace, Elsewhere|Otherplace]]
14211 [[Otherplace, Elsewhere, Anywhere|Otherplace]]
14212 !! end
14213
14214 !! test
14215 pre-save transform: context links ("pipe trick") with parens and comma
14216 !! options
14217 pst title=[[Someplace (IGNORED), Somewhere]]
14218 !! wikitext
14219 [[|Otherplace]]
14220 [[Otherplace (place), Elsewhere|]]
14221 !! html/php
14222 [[Otherplace, Somewhere|Otherplace]]
14223 [[Otherplace (place), Elsewhere|Otherplace]]
14224 !! end
14225
14226 !! test
14227 pre-save transform: context links ("pipe trick") with comma and parens
14228 !! options
14229 pst title=[[Who, me? (context)]]
14230 !! wikitext
14231 [[|Yes, you.]]
14232 [[Me, Myself, and I (1937 song)|]]
14233 !! html/php
14234 [[Yes, you. (context)|Yes, you.]]
14235 [[Me, Myself, and I (1937 song)|Me, Myself, and I]]
14236 !! end
14237
14238 !! test
14239 pre-save transform: context links ("pipe trick") with namespace
14240 !! options
14241 pst title=[[Ns:Somearticle]]
14242 !! wikitext
14243 [[|Article]]
14244 !! html/php
14245 [[Ns:Article|Article]]
14246 !! end
14247
14248 !! test
14249 pre-save transform: context links ("pipe trick") with namespace and parens
14250 !! options
14251 pst title=[[Ns:Somearticle (context)]]
14252 !! wikitext
14253 [[|Article]]
14254 !! html/php
14255 [[Ns:Article (context)|Article]]
14256 !! end
14257
14258 !! test
14259 pre-save transform: context links ("pipe trick") with namespace and comma
14260 !! options
14261 pst title=[[Ns:Somearticle, Context, Whatever]]
14262 !! wikitext
14263 [[|Article]]
14264 !! html/php
14265 [[Ns:Article, Context, Whatever|Article]]
14266 !! end
14267
14268 !! test
14269 pre-save transform: context links ("pipe trick") with namespace, comma and parens
14270 !! options
14271 pst title=[[Ns:Somearticle, Context (context)]]
14272 !! wikitext
14273 [[|Article]]
14274 !! html/php
14275 [[Ns:Article (context)|Article]]
14276 !! end
14277
14278 !! test
14279 pre-save transform: context links ("pipe trick") with namespace, parens and comma
14280 !! options
14281 pst title=[[Ns:Somearticle (IGNORED), Context]]
14282 !! wikitext
14283 [[|Article]]
14284 !! html/php
14285 [[Ns:Article, Context|Article]]
14286 !! end
14287
14288 !! test
14289 pre-save transform: context links ("pipe trick") with full-width parens and no space (Japanese and Chinese style, T32149)
14290 !! options
14291 pst
14292 !! wikitext
14293 [[Article(context)|]]
14294 [[Bar:Article(context)|]]
14295 [[:Bar:Article(context)|]]
14296 [[|Article(context)]]
14297 [[Bar:X(Y)Z|]]
14298 [[:Bar:X(Y)Z|]]
14299 !! html/php
14300 [[Article(context)|Article]]
14301 [[Bar:Article(context)|Article]]
14302 [[:Bar:Article(context)|Article]]
14303 [[Article(context)]]
14304 [[Bar:X(Y)Z|X(Y)Z]]
14305 [[:Bar:X(Y)Z|X(Y)Z]]
14306 !! end
14307
14308 !! test
14309 pre-save transform: context links ("pipe trick") with full-width parens and space (Japanese and Chinese style, T32149)
14310 !! options
14311 pst
14312 !! wikitext
14313 [[Article (context)|]]
14314 [[Bar:Article (context)|]]
14315 [[:Bar:Article (context)|]]
14316 [[|Article (context)]]
14317 [[Bar:X (Y) Z|]]
14318 [[:Bar:X (Y) Z|]]
14319 !! html/php
14320 [[Article (context)|Article]]
14321 [[Bar:Article (context)|Article]]
14322 [[:Bar:Article (context)|Article]]
14323 [[Article (context)]]
14324 [[Bar:X (Y) Z|X (Y) Z]]
14325 [[:Bar:X (Y) Z|X (Y) Z]]
14326 !! end
14327
14328 !! test
14329 pre-save transform: context links ("pipe trick") with parens and no space (Korean style, T32149)
14330 !! options
14331 pst
14332 !! wikitext
14333 [[Article(context)|]]
14334 [[Bar:Article(context)|]]
14335 [[:Bar:Article(context)|]]
14336 [[|Article(context)]]
14337 [[Bar:X(Y)Z|]]
14338 [[:Bar:X(Y)Z|]]
14339 !! html/php
14340 [[Article(context)|Article]]
14341 [[Bar:Article(context)|Article]]
14342 [[:Bar:Article(context)|Article]]
14343 [[Article(context)]]
14344 [[Bar:X(Y)Z|X(Y)Z]]
14345 [[:Bar:X(Y)Z|X(Y)Z]]
14346 !! end
14347
14348 !! test
14349 pre-save transform: context links ("pipe trick") with commas (T23660)
14350 !! options
14351 pst
14352 !! wikitext
14353 [[Article (context), context|]]
14354 [[Article (context),context|]]
14355 [[Bar:Article (context), context|]]
14356 [[Bar:Article (context),context|]]
14357 [[:Bar:Article (context), context|]]
14358 [[:Bar:Article (context),context|]]
14359 !! html/php
14360 [[Article (context), context|Article]]
14361 [[Article (context),context|Article]]
14362 [[Bar:Article (context), context|Article]]
14363 [[Bar:Article (context),context|Article]]
14364 [[:Bar:Article (context), context|Article]]
14365 [[:Bar:Article (context),context|Article]]
14366 !! end
14367
14368 !! test
14369 Parsoid: backwards pipe trick
14370 !! wikitext
14371 [[|'''bar''']]
14372 !! html/php
14373 <p>[[|<b>bar</b>]]
14374 </p>
14375 !! html/parsoid
14376 <p>[[|<b>bar</b>]]</p>
14377 !! end
14378
14379 !! test
14380 pre-save transform: trim trailing empty lines
14381 !! options
14382 pst
14383 !! wikitext
14384 Empty lines are trimmed
14385
14386
14387
14388
14389 !! html/php
14390 Empty lines are trimmed
14391 !! end
14392
14393 !! test
14394 pre-save transform: Signature expansion
14395 !! options
14396 pst
14397 !! wikitext
14398 * ~~~
14399 * ~~~~
14400 * ~~~~~
14401 * <noinclude>~~~</noinclude>
14402 * <includeonly>~~~</includeonly>
14403 * <onlyinclude>~~~</onlyinclude>
14404 !! html/php
14405 * [[Special:Contributions/127.0.0.1|127.0.0.1]]
14406 * [[Special:Contributions/127.0.0.1|127.0.0.1]] 00:02, 1 January 1970 (UTC)
14407 * 00:02, 1 January 1970 (UTC)
14408 * <noinclude>[[Special:Contributions/127.0.0.1|127.0.0.1]]</noinclude>
14409 * <includeonly>[[Special:Contributions/127.0.0.1|127.0.0.1]]</includeonly>
14410 * <onlyinclude>[[Special:Contributions/127.0.0.1|127.0.0.1]]</onlyinclude>
14411 !! end
14412
14413
14414 !! test
14415 ParserOutput flags from signature expansion (T84843)
14416 !! options
14417 pst
14418 showflags
14419 !! wikitext
14420 ~~~~
14421 !! html/php
14422 [[Special:Contributions/127.0.0.1|127.0.0.1]] 00:02, 1 January 1970 (UTC)
14423 flags=user-signature
14424 !! end
14425
14426
14427 !! test
14428 pre-save transform: Signature expansion in nowiki tags (T2093)
14429 !! options
14430 pst disabled
14431 !! wikitext
14432 Shall not expand:
14433
14434 <nowiki>~~~~</nowiki>
14435
14436 <includeonly><nowiki>~~~~</nowiki></includeonly>
14437
14438 <noinclude><nowiki>~~~~</nowiki></noinclude>
14439
14440 <onlyinclude><nowiki>~~~~</nowiki></onlyinclude>
14441
14442 {{subst:Foo}} shall be converted to FOO
14443
14444 As well as inside noinclude/onlyinclude
14445 <noinclude>{{subst:Foo}}</noinclude>
14446 <onlyinclude>{{subst:Foo}}</onlyinclude>
14447
14448 But not inside includeonly
14449 <includeonly>{{subst:Foo}}</includeonly>
14450 !! html/php
14451 Shall not expand:
14452
14453 <nowiki>~~~~</nowiki>
14454
14455 <includeonly><nowiki>~~~~</nowiki></includeonly>
14456
14457 <noinclude><nowiki>~~~~</nowiki></noinclude>
14458
14459 <onlyinclude><nowiki>~~~~</nowiki></onlyinclude>
14460
14461 FOO shall be converted to FOO
14462
14463 As well as inside noinclude/onlyinclude
14464 <noinclude>FOO</noinclude>
14465 <onlyinclude>FOO</onlyinclude>
14466
14467 But not inside includeonly
14468 <includeonly>{{subst:Foo}}</includeonly>
14469 !! end
14470
14471 !! test
14472 Parsoid: Recognize nowiki with trailing space in tags
14473 !! options
14474 parsoid=wt2html
14475 !! wikitext
14476 <nowiki ><div>[[foo]]</nowiki >
14477
14478 a<nowiki / >b
14479
14480 c<nowiki />d
14481
14482 e<nowiki/ >f
14483 !! html/php+tidy
14484 <p>&lt;div&gt;[[foo]]
14485 </p><p>a&lt;nowiki / &gt;b
14486 </p><p>cd
14487 </p><p>e&lt;nowiki/ &gt;f
14488 </p>
14489 !! html/parsoid
14490 <p><span typeof="mw:Nowiki">&lt;div>[[foo]]</span></p>
14491
14492 <p>a&lt;nowiki / >b</p>
14493
14494 <p>c<span typeof="mw:Nowiki"></span>d</p>
14495
14496 <p>e&lt;nowiki/ >f</p>
14497 !! end
14498
14499 !! test
14500 Parsoid: Recognize nowiki with odd capitalization
14501 !! options
14502 parsoid=wt2html
14503 !! wikitext
14504 <noWikI ><div>[[foo]]</Nowiki >
14505 !! html/php+tidy
14506 <p>&lt;div&gt;[[foo]]
14507 </p>
14508 !! html/parsoid
14509 <p><span typeof="mw:Nowiki">&lt;div&gt;[[foo]]</span></p>
14510 !! end
14511
14512
14513 !! test
14514 Parsoid: Escape nowiki with trailing space in tags
14515 !! options
14516 parsoid=html2wt
14517 !! html/parsoid
14518 <p>&lt;nowiki &gt; foo &lt/nowiki ></p>
14519 <p>a&lt;nowiki /&gt;b</p>
14520 <p>c&lt;nowiki/ &gt;d</p>
14521 !! wikitext
14522 &lt;nowiki &gt; foo &lt;/nowiki &gt;
14523
14524 a&lt;nowiki /&gt;b
14525
14526 c&lt;nowiki/ &gt;d
14527 !! end
14528
14529 !! test
14530 Parsoid: Escape weird noWikI capitalizations
14531 !! options
14532 parsoid=html2wt
14533 !! html/parsoid
14534 <p>&lt;noWikI &gt; foo &lt/NoWikI ></p>
14535 !! wikitext
14536 &lt;noWikI &gt; foo &lt;/NoWikI &gt;
14537 !! end
14538
14539 ###
14540 ### Message transform tests
14541 ###
14542 !! test
14543 message transform: magic variables
14544 !! options
14545 msg
14546 !! wikitext
14547 {{SITENAME}}
14548 !! html
14549 MediaWiki
14550 !! end
14551
14552 !! test
14553 message transform: should not transform wiki markup
14554 !! options
14555 msg
14556 !! wikitext
14557 ''test''
14558 !! html
14559 ''test''
14560 !! end
14561
14562 !! test
14563 message transform: <noinclude> in transcluded template (T6926)
14564 !! options
14565 msg
14566 !! wikitext
14567 {{Includes}}
14568 !! html
14569 Foobar
14570 !! end
14571
14572 !! test
14573 message transform: <onlyinclude> in transcluded template (T6926)
14574 !! options
14575 msg
14576 !! wikitext
14577 {{Includes2}}
14578 !! html
14579 Foo
14580 !! end
14581
14582 !! test
14583 {{#special:}} page name, known
14584 !! options
14585 msg
14586 !! wikitext
14587 {{#special:Recentchanges}}
14588 !! html
14589 Special:RecentChanges
14590 !! end
14591
14592 !! test
14593 {{#special:}} page name with subpage, known
14594 !! options
14595 msg
14596 !! wikitext
14597 {{#special:Recentchanges/param}}
14598 !! html
14599 Special:RecentChanges/param
14600 !! end
14601
14602 !! test
14603 {{#special:}} page name, unknown
14604 !! options
14605 msg
14606 !! wikitext
14607 {{#special:foobar nonexistent}}
14608 !! html
14609 Special:Foobar nonexistent
14610 !! end
14611
14612 !! test
14613 {{#speciale:}} page name, known
14614 !! options
14615 msg
14616 !! wikitext
14617 {{#speciale:Recentchanges}}
14618 !! html
14619 Special:RecentChanges
14620 !! end
14621
14622 !! test
14623 {{#speciale:}} page name with subpage, known
14624 !! options
14625 msg
14626 !! wikitext
14627 {{#speciale:Recentchanges/param}}
14628 !! html
14629 Special:RecentChanges/param
14630 !! end
14631
14632 !! test
14633 {{#speciale:}} page name, unknown
14634 !! options
14635 msg
14636 !! wikitext
14637 {{#speciale:foobar nonexistent}}
14638 !! html
14639 Special:Foobar_nonexistent
14640 !! end
14641
14642 ###
14643 ### Images
14644 ###
14645 ### For Parsoid-specific tests, see
14646 #### https://www.mediawiki.org/wiki/Parsoid/MediaWiki_DOM_spec#Images
14647
14648 !! test
14649 Simple image
14650 !! options
14651 parsoid=wt2html,wt2wt,html2html
14652 !! wikitext
14653 [[Image:foobar.jpg]]
14654 !! html/php
14655 <p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" /></a>
14656 </p>
14657 !! html/parsoid
14658 <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>
14659 !! end
14660
14661 !! test
14662 Serialize simple image with span wrapper
14663 !! options
14664 parsoid=html2wt
14665 !! html/parsoid
14666 <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>
14667 !! wikitext
14668 [[File:Foobar.jpg]]
14669 !! end
14670
14671 !! test
14672 Simple image (using File: namespace, now canonical)
14673 !! wikitext
14674 [[File:Foobar.jpg]]
14675 !! html/php
14676 <p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" /></a>
14677 </p>
14678 !! html/parsoid
14679 <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>
14680 !! end
14681
14682 !! test
14683 Right-aligned image
14684 !! wikitext
14685 [[File:Foobar.jpg|right]]
14686 !! html/php
14687 <div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" /></a></div>
14688
14689 !! html/parsoid
14690 <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>
14691 !! end
14692
14693 !! test
14694 Image with caption
14695 !! wikitext
14696 [[File:Foobar.jpg|right|Caption text]]
14697 !! html/php
14698 <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" decoding="async" width="1941" height="220" /></a></div>
14699
14700 !! html/parsoid
14701 <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>
14702 !! end
14703
14704 !! test
14705 Image with caption, T55312 #1
14706 !! wikitext
14707 [[File:Foobar.jpg|right|Caption page stuff]]
14708 !! html/php
14709 <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" decoding="async" width="1941" height="220" /></a></div>
14710
14711 !! html/parsoid
14712 <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>
14713 !! end
14714
14715 !! test
14716 Image with caption, T55312 #2
14717 !! wikitext
14718 [[File:Foobar.jpg|right|Caption page=]]
14719 !! html/php
14720 <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" decoding="async" width="1941" height="220" /></a></div>
14721
14722 !! html/parsoid
14723 <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>
14724 !! end
14725
14726 !! test
14727 Image with caption, T55312 #3
14728 !! wikitext
14729 [[File:Foobar.jpg|right|Caption page=stuff]]
14730 !! html/php
14731 <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" decoding="async" width="1941" height="220" /></a></div>
14732
14733 !! html/parsoid
14734 <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>
14735 !! end
14736
14737 !! test
14738 Image caption with pipe entity
14739 !! wikitext
14740 [[File:Foobar.jpg|thumb|one &#x7C; two]]
14741 [[File:Foobar.jpg|thumb|one ''two'' &#x7C; three]]
14742 !! html/php
14743 <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" decoding="async" 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>one &#x7c; two</div></div></div>
14744 <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" decoding="async" 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>one <i>two</i> &#x7c; three</div></div></div>
14745
14746 !! html/parsoid
14747 <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>one <span typeof="mw:Entity">|</span> two</figcaption></figure>
14748 <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>one <i>two</i> <span typeof="mw:Entity">|</span> three</figcaption></figure>
14749 !! end
14750
14751 !! test
14752 Allow empty links in image captions (T62753)
14753 !! options
14754 thumbsize=220
14755 !! wikitext
14756 [[File:Foobar.jpg|thumb|Caption [[Link1]]
14757 [[]]
14758 [[Link2]]
14759 ]]
14760 !! html/php
14761 <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" decoding="async" 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>
14762
14763 !! html/parsoid
14764 <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>
14765 [[]]
14766 <a rel="mw:WikiLink" href="./Link2" title="Link2" data-parsoid='{"stx":"simple","a":{"href":"./Link2"},"sa":{"href":"Link2"}}'>Link2</a>
14767 </figcaption></figure>
14768 !! end
14769
14770 !! test
14771 Titles in unlinked images (T23454)
14772 !! wikitext
14773 [[File:Foobar.jpg|link=|stuff]]
14774 !! html/php
14775 <p><img alt="stuff" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" title="stuff" width="1941" height="220" />
14776 </p>
14777 !! html/parsoid
14778 <p><figure-inline class="mw-default-size" typeof="mw:Image" data-mw='{"caption":"stuff"}'><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></figure-inline></p>
14779 !! end
14780
14781 !! test
14782 Link with empty target
14783 !! wikitext
14784 [[]]
14785 !! html
14786 <p>[[]]
14787 </p>
14788 !! end
14789
14790 !! test
14791 Image with link trail
14792 !! wikitext
14793 Linktrails should not work for images: [[File:Foobar.jpg]]s
14794 !! html/php
14795 <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" decoding="async" width="1941" height="220" /></a>s
14796 </p>
14797 !! html/parsoid
14798 <p>Linktrails should not work for images: <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>s</p>
14799 !! end
14800
14801 !! test
14802 Image with empty attribute
14803 !! options
14804 parsoid=wt2html,wt2wt,html2html
14805 !! wikitext
14806 [[File:Foobar.jpg|right||Caption text]]
14807 !! html/php
14808 <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" decoding="async" width="1941" height="220" /></a></div>
14809
14810 !! html/parsoid
14811 <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>
14812 !! end
14813
14814 !! test
14815 1. Block image with individual attributes from templates
14816 !! wikitext
14817 [[File:Foobar.jpg|thumb|{{echo|137px}}|This is a caption]]
14818 !! html/php
14819 <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" decoding="async" 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>
14820
14821 !! html/parsoid
14822 <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>
14823 !! end
14824
14825 !! test
14826 2. Block Image with individual attributes from templates
14827 !! wikitext
14828 [[File:Foobar.jpg|{{echo|thumb}}|{{echo|137px}}|This is a caption]]
14829 !! html/php
14830 <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" decoding="async" 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>
14831
14832 !! html/parsoid
14833 <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>
14834 !! end
14835
14836 !! test
14837 3. Inline image with individual attributes from templates
14838 !! wikitext
14839 [[File:Foobar.jpg|{{echo|50px}}]]
14840 !! html/php
14841 <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" decoding="async" 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>
14842 </p>
14843 !! html/parsoid
14844 <p><figure-inline 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></figure-inline></p>
14845 !! end
14846
14847 ## Parsoid does not provide editing support for images where templates produce multiple image attributes.
14848 ## To signal this, we add a 'mw:Placeholder' type to such images. This could change in the future.
14849 !! test
14850 Image with multiple attributes from the same template
14851 !! wikitext
14852 [[File:Foobar.jpg|{{image_attribs}}]]
14853 !! html/php
14854 <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" decoding="async" width="1941" height="220" /></a></div>
14855
14856 !! html/parsoid
14857 <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>
14858 !! end
14859
14860 !! test
14861 Image with link tails
14862 !! options
14863 thumbsize=220
14864 !! wikitext
14865 123[[File:Foobar.jpg]]456
14866 123[[File:Foobar.jpg|right]]456
14867 123[[File:Foobar.jpg|thumb]]456
14868 !! html/php
14869 <p>123<a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" /></a>456
14870 </p>
14871 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" decoding="async" width="1941" height="220" /></a></div>456
14872 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" decoding="async" 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
14873
14874 !! html/php+tidy
14875 <p>123<a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" /></a>456
14876 </p><p>
14877 123</p><div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" /></a></div><p>456
14878 123</p><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" decoding="async" 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><p>456
14879 </p>
14880 !! html/parsoid
14881 <p>123<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>456</p>
14882 <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
14883 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>
14884 !! end
14885
14886 !! test
14887 Image with multiple captions -- only last one is accepted
14888 !! wikitext
14889 [[File:Foobar.jpg|right|Caption1 - ignored|[[Caption2]] - ignored|Caption3 - accepted]]
14890 !! html/php
14891 <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" decoding="async" width="1941" height="220" /></a></div>
14892
14893 !! html/parsoid
14894 <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>
14895 !! end
14896
14897 !! test
14898 Image with multiple widths -- use last
14899 !! wikitext
14900 [[File:Foobar.jpg|200px|300px|caption]]
14901 !! html/php
14902 <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" decoding="async" 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>
14903 </p>
14904 !! html/parsoid
14905 <p><figure-inline 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></figure-inline></p>
14906 !! end
14907
14908 !! test
14909 Image with multiple alignments -- use first (T50664)
14910 !! options
14911 thumbsize=220
14912 !! wikitext
14913 [[File:Foobar.jpg|thumb|left|right|center|caption]]
14914
14915 [[File:Foobar.jpg|middle|text-top|caption]]
14916 !! html/php
14917 <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" decoding="async" 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>
14918 <p><a href="/wiki/File:Foobar.jpg" class="image" title="caption"><img alt="caption" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" style="vertical-align: middle" /></a>
14919 </p>
14920 !! html/parsoid
14921 <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>
14922 <p><figure-inline 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></figure-inline></p>
14923 !! end
14924
14925 !! test
14926 Image with width attribute at different positions
14927 !! wikitext
14928 [[File:Foobar.jpg|200px|right|Caption]]
14929 [[File:Foobar.jpg|right|200px|Caption]]
14930 [[File:Foobar.jpg|right|Caption|200px]]
14931 !! html/php
14932 <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" decoding="async" 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>
14933 <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" decoding="async" 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>
14934 <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" decoding="async" 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>
14935
14936 !! html/parsoid
14937 <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>
14938 <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>
14939 <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>
14940 !! end
14941
14942 # a sad bit of backward-compatibility
14943 !! test
14944 Image with size specified with pxpx (T15500, T53628)
14945 !! options
14946 parsoid=wt2html,wt2wt,html2html
14947 !! wikitext
14948 [[File:Foobar.jpg|20pxpx]]
14949 [[File:Foobar.jpg|200x20pxpx]]
14950 !! html/php
14951 <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" decoding="async" 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>
14952 <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" decoding="async" 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>
14953 </p>
14954 !! html/parsoid
14955 <p><figure-inline 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></figure-inline> <figure-inline 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></figure-inline></p>
14956 !! end
14957
14958 !! test
14959 Image with link parameter, wiki target
14960 !! wikitext
14961 [[File:Foobar.jpg|link=Main Page]]
14962 !! html/php
14963 <p><a href="/wiki/Main_Page" title="Main Page"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" /></a>
14964 </p>
14965 !! html/parsoid
14966 <p><figure-inline 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></figure-inline></p>
14967 !! end
14968
14969 # parsoid T51293 (part 1)
14970 !! test
14971 Image with link parameter, URL target
14972 !! wikitext
14973 [[File:Foobar.jpg|link=http://example.com/]]
14974 !! html/php
14975 <p><a href="http://example.com/" rel="nofollow"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" /></a>
14976 </p>
14977 !! html/parsoid
14978 <p><figure-inline 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></figure-inline></p>
14979 !! end
14980
14981 # parsoid T51293 (part 2)
14982 !! test
14983 Image with link parameter, protocol-less URL target
14984 !! wikitext
14985 [[File:Foobar.jpg|link=//example.com/]]
14986 !! html/php
14987 <p><a href="//example.com/" rel="nofollow"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" /></a>
14988 </p>
14989 !! html/parsoid
14990 <p><figure-inline 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></figure-inline></p>
14991 !! end
14992
14993 !! test
14994 Escaping non-block captions (T107435)
14995 !! options
14996 parsoid={
14997 "modes": ["wt2wt"],
14998 "changes": [
14999 ["[typeof~='mw:Image']", "attr", "data-mw", "{\"caption\": \"|\"}"]
15000 ]
15001 }
15002 !! wikitext
15003 [[Image:Foobar.jpg|caption]]
15004 !! wikitext/edited
15005 [[Image:Foobar.jpg|<nowiki>|</nowiki>]]
15006 !! end
15007
15008 # wgExternalLinkTarget not supported by Parsoid
15009 !! test
15010 Image with link parameter, wgExternalLinkTarget
15011 !! wikitext
15012 [[Image:foobar.jpg|link=http://example.com/]]
15013 !! config
15014 wgExternalLinkTarget='foobar'
15015 !! html/php
15016 <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" decoding="async" width="1941" height="220" /></a>
15017 </p>
15018 !! end
15019
15020 !! test
15021 Image with link parameter, wgNoFollowLinks set to false
15022 !! wikitext
15023 [[Image:foobar.jpg|link=http://example.com/]]
15024 !! config
15025 wgNoFollowLinks=false
15026 !! html/php
15027 <p><a href="http://example.com/"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" /></a>
15028 </p>
15029 !! end
15030
15031 !! test
15032 Image with link parameter, wgNoFollowDomainExceptions
15033 !! wikitext
15034 [[Image:foobar.jpg|link=http://example.com/]]
15035 !! config
15036 wgNoFollowDomainExceptions='example.com'
15037 !! html/php
15038 <p><a href="http://example.com/"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" /></a>
15039 </p>
15040 !! end
15041
15042 # wgExternalLinkTarget not supported by Parsoid
15043 !! test
15044 Image with link parameter, wgExternalLinkTarget, unnamed parameter
15045 !! wikitext
15046 [[Image:foobar.jpg|link=http://example.com/|Title]]
15047 !! config
15048 wgExternalLinkTarget='foobar'
15049 !! html/php
15050 <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" decoding="async" width="1941" height="220" /></a>
15051 </p>
15052 !! end
15053
15054 !! test
15055 Image with empty link parameter
15056 !! wikitext
15057 [[File:Foobar.jpg|link=]]
15058 !! html/php
15059 <p><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" />
15060 </p>
15061 !! html/parsoid
15062 <p><figure-inline 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></figure-inline></p>
15063 !! end
15064
15065 !! test
15066 Image with link parameter (wiki target) and unnamed parameter
15067 !! wikitext
15068 [[File:Foobar.jpg|link=Main_Page|Title]]
15069 !! html/php
15070 <p><a href="/wiki/Main_Page" title="Title"><img alt="Title" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" /></a>
15071 </p>
15072 !! html/parsoid
15073 <p><figure-inline 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></figure-inline></p>
15074 !! end
15075
15076 !! test
15077 Image with link parameter (URL target) and unnamed parameter
15078 !! wikitext
15079 [[File:Foobar.jpg|link=http://example.com/|Title]]
15080 !! html/php
15081 <p><a href="http://example.com/" title="Title" rel="nofollow"><img alt="Title" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" /></a>
15082 </p>
15083 !! html/parsoid
15084 <p><figure-inline 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></figure-inline></p>
15085 !! end
15086
15087 !! test
15088 Thumbnail image with link parameter
15089 !! options
15090 thumbsize=220
15091 parsoid=wt2html,wt2wt,html2html
15092 !! wikitext
15093 [[File:Foobar.jpg|thumb|link=http://example.com/|Title]]
15094 !! html/php
15095 <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" decoding="async" 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>
15096
15097 !! html/parsoid
15098 <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>
15099 !! end
15100
15101 !! test
15102 Manually-specified thumbnail image
15103 !! options
15104 thumbsize=220
15105 !! wikitext
15106 [[File:Foobar.jpg|thumbnail=Thumb.png|Title]]
15107 !! html/php
15108 <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" decoding="async" 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>
15109
15110 !! html/parsoid
15111 <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>
15112 !! end
15113
15114 !! test
15115 Manually-specified thumbnail image with explicit link to wiki page
15116 !! options
15117 thumbsize=220
15118 parsoid=wt2html,wt2wt,html2html
15119 !! wikitext
15120 [[File:Foobar.jpg|thumb=Thumb.png|link=Main_Page|Title]]
15121 !! html/php
15122 <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" decoding="async" 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>
15123
15124 !! html/parsoid
15125 <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>
15126 !! end
15127
15128 !! test
15129 Manually-specified thumbnail image with explicit link to url
15130 !! options
15131 thumbsize=220
15132 parsoid=wt2html,wt2wt,html2html
15133 !! wikitext
15134 [[File:Foobar.jpg|thumb=Thumb.png|link=http://example.com|Title]]
15135 !! html/php
15136 <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" decoding="async" 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>
15137
15138 !! html/parsoid
15139 <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>
15140 !! end
15141
15142 !! test
15143 Manually-specified thumbnail image with explicit no link
15144 !! options
15145 thumbsize=220
15146 parsoid=wt2html,wt2wt,html2html
15147 !! wikitext
15148 [[File:Foobar.jpg|thumb=Thumb.png|link=|Title]]
15149 !! html/php
15150 <div class="thumb tright"><div class="thumbinner" style="width:137px;"><img alt="" src="http://example.com/images/e/ea/Thumb.png" decoding="async" 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>
15151
15152 !! html/parsoid
15153 <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>
15154 !! end
15155
15156 !! test
15157 Manually-specified thumbnail image with explicit link and alt text
15158 !! options
15159 thumbsize=220
15160 parsoid=wt2html,wt2wt,html2html
15161 !! wikitext
15162 [[File:Foobar.jpg|thumb=Thumb.png|link=Main_Page|alt=alttext|Title]]
15163 !! html/php
15164 <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" decoding="async" 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>
15165
15166 !! html/parsoid
15167 <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>
15168 !! end
15169
15170 !! test
15171 Image with frame and link
15172 !! options
15173 parsoid=wt2html,wt2wt,html2html
15174 !! wikitext
15175 [[File:Foobar.jpg|frame|left|This is a test image [[Main Page]]]]
15176 !! html/php
15177 <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" decoding="async" 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>
15178
15179 !! html/parsoid
15180 <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>
15181 !! end
15182
15183 !! test
15184 Image with frame and link and explicit alt
15185 !! options
15186 parsoid=wt2html,wt2wt,html2html
15187 !! wikitext
15188 [[Image:Foobar.jpg|frame|left|This is a test image [[Main Page]]|alt=Altitude]]
15189 !! html/php
15190 <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" decoding="async" 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>
15191
15192 !! html/parsoid
15193 <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>
15194 !! end
15195
15196 !! test
15197 Image with wiki markup in implicit alt
15198 !! wikitext
15199 [[Image:Foobar.jpg|testing '''bold''' in alt]]
15200
15201 [[Image:Foobar.jpg|alt=testing '''bold''' in alt]]
15202 !! html/php
15203 <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" decoding="async" width="1941" height="220" /></a>
15204 </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" decoding="async" width="1941" height="220" /></a>
15205 </p>
15206 !! html/parsoid
15207 <p><figure-inline 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></figure-inline></p>
15208
15209 <p><figure-inline 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></figure-inline></p>
15210 !! end
15211
15212 !! test
15213 Alt image option should handle most kinds of wikitext without barfing
15214 !! wikitext
15215 [[Image:Foobar.jpg|thumb|This is the image caption|alt=This is a [[link]] and a {{echo|''bold template''}}.]]
15216 !! html/php
15217 <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" decoding="async" 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>
15218
15219 !! html/parsoid
15220 <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|&apos;&apos;bold template&apos;&apos;}}."}]}' data-mw='{"attribs":[["thumbnail",{"html":"thumb"}],["alt",{"html":"alt=This is a &lt;a rel=\"mw:WikiLink\" href=\"./Link\" title=\"Link\" data-parsoid=&apos;{\"stx\":\"simple\",\"a\":{\"href\":\"./Link\"},\"sa\":{\"href\":\"link\"},\"dsr\":[65,73,2,2]}&apos;>link&lt;/a> and a &lt;i about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid=&apos;{\"dsr\":[80,106,null,null],\"pi\":[[{\"k\":\"1\"}]]}&apos; data-mw=&apos;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"&amp;apos;&amp;apos;bold template&amp;apos;&amp;apos;\"}},\"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>
15221 !! end
15222
15223 !! test
15224 Ampersand in alt attribute (T206940)
15225 !! options
15226 parsoid = {
15227 "nativeGallery": true
15228 }
15229 !! wikitext
15230 [[File:Foobar.jpg|alt=&amp;amp;]]
15231
15232 <!-- consistency with gallery extension -->
15233 <gallery>
15234 File:Foobar.jpg|alt=&amp;amp;
15235 </gallery>
15236 !! html/php+tidy
15237 <p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="&amp;amp;" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" /></a>
15238 </p>
15239 <ul class="gallery mw-gallery-traditional">
15240 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15241 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="&amp;amp;" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" decoding="async" 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>
15242 <div class="gallerytext">
15243 </div>
15244 </div></li>
15245 </ul>
15246 !! html/parsoid
15247 <p><figure-inline class="mw-default-size" typeof="mw:Image"><a href="./File:Foobar.jpg"><img alt="&amp;amp;" 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>
15248
15249 <!-- consistency with gallery extension -->
15250 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
15251 <li class="gallerybox">
15252 <div class="thumb"><figure-inline typeof="mw:Image"><a href="./File:Foobar.jpg"><img alt="&amp;amp;" 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></figure-inline></div>
15253 <div class="gallerytext"></div>
15254 </li>
15255 </ul>
15256 !! end
15257
15258 !! test
15259 Italics markup in alt attribute (T206940)
15260 !! wikitext
15261 [[File:Foobar.jpg|alt=''x''|caption]]
15262
15263 <!-- consistency with gallery extension -->
15264 <gallery>
15265 File:Foobar.jpg|alt=''x''|caption
15266 </gallery>
15267 !! html/php+tidy
15268 <p><a href="/wiki/File:Foobar.jpg" class="image" title="caption"><img alt="x" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" /></a>
15269 </p>
15270 <ul class="gallery mw-gallery-traditional">
15271 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15272 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="x" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" decoding="async" 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>
15273 <div class="gallerytext">
15274 <p>caption
15275 </p>
15276 </div>
15277 </div></li>
15278 </ul>
15279 !! html/parsoid
15280 <p><figure-inline class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"alt","ak":"alt=&apos;&apos;x&apos;&apos;"},{"ck":"caption","ak":"caption"}]}' data-mw='{"caption":"caption"}'><a href="./File:Foobar.jpg"><img alt="x" 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":"x","resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"alt":"alt=&apos;&apos;x&apos;&apos;","resource":"File:Foobar.jpg"}}'/></a></figure-inline></p>
15281
15282 <!-- consistency with gallery extension -->
15283 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{"extsrc":"\nFile:Foobar.jpg|alt=&apos;&apos;x&apos;&apos;|caption\n"}}'>
15284 <li class="gallerybox">
15285 <div class="thumb"><figure-inline typeof="mw:Image"><a href="./File:Foobar.jpg"><img alt="x" 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></figure-inline></div>
15286 <div class="gallerytext">caption</div>
15287 </li>
15288 </ul>
15289 !! end
15290
15291 !! test
15292 Nowiki markup in alt attribute (T206940)
15293 !! wikitext
15294 [[File:Foobar.jpg|alt=<nowiki>''</nowiki>x<nowiki>''</nowiki>|caption]]
15295
15296 <!-- consistency with gallery extension -->
15297 <gallery>
15298 File:Foobar.jpg|alt=<nowiki>''</nowiki>x<nowiki>''</nowiki>|caption
15299 </gallery>
15300 !! html/php+tidy
15301 <p><a href="/wiki/File:Foobar.jpg" class="image" title="caption"><img alt="&#39;&#39;x&#39;&#39;" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" /></a>
15302 </p>
15303 <ul class="gallery mw-gallery-traditional">
15304 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15305 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="&#39;&#39;x&#39;&#39;" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" decoding="async" 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>
15306 <div class="gallerytext">
15307 <p>caption
15308 </p>
15309 </div>
15310 </div></li>
15311 </ul>
15312 !! html/parsoid
15313 <p><figure-inline class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"alt","ak":"alt=&lt;nowiki>&apos;&apos;&lt;/nowiki>x&lt;nowiki>&apos;&apos;&lt;/nowiki>"},{"ck":"caption","ak":"caption"}],"dsr":[0,71,null,null]}' data-mw='{"caption":"caption"}'><a href="./File:Foobar.jpg"><img alt="''x''" 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":"&apos;&apos;x&apos;&apos;","resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"alt":"alt=&lt;nowiki>&apos;&apos;&lt;/nowiki>x&lt;nowiki>&apos;&apos;&lt;/nowiki>","resource":"File:Foobar.jpg"}}'/></a></figure-inline></p>
15314
15315 <!-- consistency with gallery extension -->
15316 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" data-mw='{"name":"gallery","attrs":{},"body":{"extsrc":"\nFile:Foobar.jpg|alt=&lt;nowiki>&apos;&apos;&lt;/nowiki>x&lt;nowiki>&apos;&apos;&lt;/nowiki>|caption\n"}}'>
15317 <li class="gallerybox">
15318 <div class="thumb"><figure-inline typeof="mw:Image"><a href="./File:Foobar.jpg"><img alt="''x''" 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></figure-inline></div>
15319 <div class="gallerytext">caption</div>
15320 </li>
15321 </ul>
15322 !! end
15323
15324 !! test
15325 Nowiki markup in alt attribute (edited html, no data-parsoid) (T206940)
15326 !! options
15327 parsoid = {
15328 "nativeGallery": true
15329 }
15330 !! wikitext
15331 [[File:Foobar.jpg|alt=<nowiki>''x''</nowiki>|caption]]
15332
15333 <!-- consistency with gallery extension -->
15334 <gallery>
15335 File:Foobar.jpg|alt=<nowiki>''x''</nowiki>|caption
15336 </gallery>
15337 !! html/php+tidy
15338 <p><a href="/wiki/File:Foobar.jpg" class="image" title="caption"><img alt="&#39;&#39;x&#39;&#39;" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" /></a>
15339 </p>
15340 <ul class="gallery mw-gallery-traditional">
15341 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15342 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="&#39;&#39;x&#39;&#39;" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" decoding="async" 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>
15343 <div class="gallerytext">
15344 <p>caption
15345 </p>
15346 </div>
15347 </div></li>
15348 </ul>
15349 !! html/parsoid
15350 <p><figure-inline class="mw-default-size" typeof="mw:Image" data-mw='{"caption":"caption"}'><a href="./File:Foobar.jpg"><img alt="''x''" 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>
15351
15352 <!-- consistency with gallery extension -->
15353 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
15354 <li class="gallerybox">
15355 <div class="thumb"><figure-inline typeof="mw:Image"><a href="./File:Foobar.jpg"><img alt="''x''" 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></figure-inline></div>
15356 <div class="gallerytext">caption</div>
15357 </li>
15358 </ul>
15359 !! end
15360
15361 !! test
15362 Ampersand in link attribute (T206940)
15363 !! wikitext
15364 [[File:Foobar.jpg|link=Foo &amp; bar]]
15365
15366 <!-- consistency with gallery extension -->
15367 <gallery>
15368 File:Foobar.jpg|link=Foo &amp; bar
15369 </gallery>
15370 !! html/php+tidy
15371 <p><a href="/wiki/Foo_%26_bar" title="Foo &amp; bar"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" /></a>
15372 </p>
15373 <ul class="gallery mw-gallery-traditional">
15374 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15375 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/Foo_%26_bar"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" decoding="async" 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>
15376 <div class="gallerytext">
15377 </div>
15378 </div></li>
15379 </ul>
15380 !! html/parsoid
15381 <p><figure-inline class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"link","ak":"link=Foo &amp;amp; bar"}]}'><a href="./Foo_&amp;_bar" data-parsoid='{"a":{"href":"./Foo_&amp;_bar"},"sa":{"href":"link=Foo &amp;amp; bar"}}'><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>
15382
15383 <!-- consistency with gallery extension -->
15384 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" data-mw='{"name":"gallery","attrs":{},"body":{"extsrc":"\nFile:Foobar.jpg|link=Foo &amp;amp; bar\n"}}'>
15385 <li class="gallerybox">
15386 <div class="thumb"><figure-inline typeof="mw:Image"><a href="./Foo_&amp;_bar"><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></figure-inline></div>
15387 <div class="gallerytext"></div>
15388 </li>
15389 </ul>
15390 !! end
15391
15392 !! test
15393 Ampersand in link attribute (edited html, no data-parsoid) (T206940)
15394 !! options
15395 parsoid = {
15396 "nativeGallery": true
15397 }
15398 !! wikitext
15399 [[File:Foobar.jpg|link=Foo_&_bar]]
15400
15401 <!-- consistency with gallery extension -->
15402 <gallery>
15403 File:Foobar.jpg|link=Foo_&_bar
15404 </gallery>
15405 !! html/php+tidy
15406 <p><a href="/wiki/Foo_%26_bar" title="Foo &amp; bar"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" /></a>
15407 </p>
15408 <ul class="gallery mw-gallery-traditional">
15409 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15410 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/Foo_%26_bar"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" decoding="async" 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>
15411 <div class="gallerytext">
15412 </div>
15413 </div></li>
15414 </ul>
15415 !! html/parsoid
15416 <p><figure-inline class="mw-default-size" typeof="mw:Image"><a href="./Foo_&amp;_bar"><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>
15417
15418 <!-- consistency with gallery extension -->
15419 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
15420 <li class="gallerybox">
15421 <div class="thumb"><figure-inline typeof="mw:Image"><a href="./Foo_&amp;_bar"><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></figure-inline></div>
15422 <div class="gallerytext"></div>
15423 </li>
15424 </ul>
15425 !! end
15426
15427 !! test
15428 Italics markup in link attribute (T206940)
15429 !! wikitext
15430 [[Foo''s bar''s]]
15431
15432 <!-- Note that "italics" are stripped, even though this is a valid page title -->
15433 [[File:Foobar.jpg|link=Foo''s bar''s|caption1]]
15434
15435 [[File:Foobar.jpg|link=''Main Page''|caption2]]
15436
15437 <!-- consistency with gallery extension -->
15438 <gallery>
15439 File:Foobar.jpg|link=Foo''s bar''s|caption1
15440 File:Foobar.jpg|link=''Main Page''|caption2
15441 </gallery>
15442 !! html/php+tidy
15443 <p><a href="/wiki/Foo%27%27s_bar%27%27s" title="Foo&#39;&#39;s bar&#39;&#39;s">Foo''s bar''s</a>
15444 </p><p><a href="/wiki/Foos_bars" title="caption1"><img alt="caption1" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" /></a>
15445 </p><p><a href="/wiki/Main_Page" title="caption2"><img alt="caption2" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" /></a>
15446 </p>
15447 <ul class="gallery mw-gallery-traditional">
15448 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15449 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/Foos_bars"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" decoding="async" 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>
15450 <div class="gallerytext">
15451 <p>caption1
15452 </p>
15453 </div>
15454 </div></li>
15455 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15456 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/Main_Page"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" decoding="async" 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>
15457 <div class="gallerytext">
15458 <p>caption2
15459 </p>
15460 </div>
15461 </div></li>
15462 </ul>
15463 !! html/parsoid
15464 <p><a rel="mw:WikiLink" href="./Foo''s_bar''s" title="Foo''s bar''s">Foo''s bar''s</a></p>
15465
15466 <!-- Note that "italics" are stripped, even though this is a valid page title -->
15467 <p><figure-inline class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"link","ak":"link=Foo&apos;&apos;s bar&apos;&apos;s"},{"ck":"caption","ak":"caption1"}]}' data-mw='{"caption":"caption1"}'><a href="./Foos_bars" data-parsoid='{"a":{"href":"./Foos_bars"},"sa":{"href":"link=Foo&apos;&apos;s bar&apos;&apos;s"}}'><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></figure-inline></p>
15468
15469 <p><figure-inline class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"link","ak":"link=&apos;&apos;Main Page&apos;&apos;"},{"ck":"caption","ak":"caption2"}]}' data-mw='{"caption":"caption2"}'><a href="./Main_Page" data-parsoid='{"a":{"href":"./Main_Page"},"sa":{"href":"link=&apos;&apos;Main Page&apos;&apos;"}}'><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></figure-inline></p>
15470
15471 <!-- consistency with gallery extension -->
15472 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" data-mw='{"name":"gallery","attrs":{},"body":{"extsrc":"\nFile:Foobar.jpg|link=Foo&apos;&apos;s bar&apos;&apos;s|caption1\nFile:Foobar.jpg|link=&apos;&apos;Main Page&apos;&apos;|caption2\n"}}'>
15473 <li class="gallerybox">
15474 <div class="thumb"><figure-inline typeof="mw:Image"><a href="./Foos_bars"><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></figure-inline></div>
15475 <div class="gallerytext">caption1</div>
15476 </li>
15477 <li class="gallerybox">
15478 <div class="thumb"><figure-inline 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></figure-inline></div>
15479 <div class="gallerytext">caption2</div>
15480 </li>
15481 </ul>
15482 !! end
15483
15484 !! test
15485 Nowiki markup in link attribute (T206940)
15486 !! wikitext
15487 [[File:Foobar.jpg|link=Foo<nowiki>''</nowiki>s_bar<nowiki>''</nowiki>s|caption]]
15488
15489 <!-- consistency with gallery extension -->
15490 <gallery>
15491 File:Foobar.jpg|link=Foo<nowiki>''</nowiki>s_bar<nowiki>''</nowiki>s|caption
15492 </gallery>
15493 !! html/php+tidy
15494 <p><a href="/wiki/Foo%27%27s_bar%27%27s" title="caption"><img alt="caption" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" /></a>
15495 </p>
15496 <ul class="gallery mw-gallery-traditional">
15497 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15498 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/Foo%27%27s_bar%27%27s"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" decoding="async" 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>
15499 <div class="gallerytext">
15500 <p>caption
15501 </p>
15502 </div>
15503 </div></li>
15504 </ul>
15505 !! html/parsoid
15506 <p><figure-inline class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"link","ak":"link=Foo&lt;nowiki>&apos;&apos;&lt;/nowiki>s_bar&lt;nowiki>&apos;&apos;&lt;/nowiki>s"},{"ck":"caption","ak":"caption"}]}' data-mw='{"caption":"caption"}'><a href="./Foo''s_bar''s" data-parsoid='{"a":{"href":"./Foo&apos;&apos;s_bar&apos;&apos;s"},"sa":{"href":"link=Foo&lt;nowiki>&apos;&apos;&lt;/nowiki>s_bar&lt;nowiki>&apos;&apos;&lt;/nowiki>s"}}'><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></figure-inline></p>
15507
15508 <!-- consistency with gallery extension -->
15509 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" data-mw='{"name":"gallery","attrs":{},"body":{"extsrc":"\nFile:Foobar.jpg|link=Foo&lt;nowiki>&apos;&apos;&lt;/nowiki>s_bar&lt;nowiki>&apos;&apos;&lt;/nowiki>s|caption\n"}}'>
15510 <li class="gallerybox">
15511 <div class="thumb"><figure-inline typeof="mw:Image"><a href="./Foo''s_bar''s"><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></figure-inline></div>
15512 <div class="gallerytext">caption</div>
15513 </li>
15514 </ul>
15515 !! end
15516
15517 !! test
15518 Nowiki markup in link attribute (edited html, no data-parsoid) (T206940)
15519 !! options
15520 parsoid = {
15521 "nativeGallery": true
15522 }
15523 !! wikitext
15524 [[File:Foobar.jpg|link=Foo<nowiki>''s_bar''</nowiki>s|caption]]
15525
15526 <!-- consistency with gallery extension -->
15527 <gallery>
15528 File:Foobar.jpg|link=Foo<nowiki>''s_bar''</nowiki>s|caption
15529 </gallery>
15530 !! html/php+tidy
15531 <p><a href="/wiki/Foo%27%27s_bar%27%27s" title="caption"><img alt="caption" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" /></a>
15532 </p>
15533 <ul class="gallery mw-gallery-traditional">
15534 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15535 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/Foo%27%27s_bar%27%27s"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" decoding="async" 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>
15536 <div class="gallerytext">
15537 <p>caption
15538 </p>
15539 </div>
15540 </div></li>
15541 </ul>
15542 !! html/parsoid
15543 <p><figure-inline class="mw-default-size" typeof="mw:Image" data-mw='{"caption":"caption"}'><a href="./Foo''s_bar''s"><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>
15544
15545 <!-- consistency with gallery extension -->
15546 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
15547 <li class="gallerybox">
15548 <div class="thumb"><figure-inline typeof="mw:Image"><a href="./Foo''s_bar''s"><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></figure-inline></div>
15549 <div class="gallerytext">caption</div>
15550 </li>
15551 </ul>
15552 !! end
15553
15554 !! test
15555 HTML entity prefix in link markup (T209236)
15556 !! wikitext
15557 [[File:Foobar.jpg|link=https://example.com?foo&params=bar]]
15558
15559 <!-- consistency with gallery extension -->
15560 <gallery>
15561 File:Foobar.jpg|link=https://example.com?foo&params=bar
15562 </gallery>
15563 !! html/php+tidy
15564 <p><a href="https://example.com?foo&amp;params=bar" rel="nofollow"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" /></a>
15565 </p>
15566 <ul class="gallery mw-gallery-traditional">
15567 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15568 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="https://example.com?foo&amp;params=bar"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" decoding="async" 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>
15569 <div class="gallerytext">
15570 </div>
15571 </div></li>
15572 </ul>
15573 !! html/parsoid
15574 <p><figure-inline class="mw-default-size" typeof="mw:Image"><a href="https://example.com?foo&amp;params=bar"><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>
15575
15576 <!-- consistency with gallery extension -->
15577 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" data-mw='{"name":"gallery","attrs":{},"body":{"extsrc":"\nFile:Foobar.jpg|link=https://example.com?foo&amp;params=bar\n"}}'>
15578 <li class="gallerybox">
15579 <div class="thumb"><figure-inline typeof="mw:Image"><a href="https://example.com?foo&amp;params=bar"><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></figure-inline></div>
15580 <div class="gallerytext"></div>
15581 </li>
15582 </ul>
15583 !! end
15584
15585 !! test
15586 Image with table with attributes in caption
15587 !! options
15588 parsoid=wt2html,html2html
15589 !! wikitext
15590 [[File:Foobar.jpg|thumb|
15591 {| class="123" |
15592 |- class="456" |
15593 | ha
15594 |}
15595 ]]
15596 !! html/parsoid
15597 <figure class="mw-default-size" typeof="mw:Image/Thumb" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"},{"ck":"caption","ak":"\n{| class=\"123\" |\n|- class=\"456\" |\n| ha\n|}\n"}]}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{"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>
15598 <table class="123">
15599 <tbody><tr class="456" data-parsoid='{"startTagSrc":"|-"}'>
15600 <td> ha</td></tr>
15601 </tbody></table>
15602 </figcaption></figure>
15603 !! end
15604
15605 !! test
15606 Image with table with rows from templates in caption
15607 !! wikitext
15608 [[File:Foobar.jpg|thumb|
15609 {|
15610 {{echo|{{!}} hi}}
15611 |}
15612 ]]
15613 !! html/parsoid
15614 <figure class="mw-default-size" typeof="mw:Image/Thumb" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"},{"ck":"caption","ak":"\n{|\n{{echo|{{!}} hi}}\n|}\n"}]}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{"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>
15615 <table>
15616 <tbody about="#mwt4" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"{{!}} hi"}},"i":0}},"\n"]}'><tr><td> hi</td></tr>
15617 </tbody></table>
15618 </figcaption></figure>
15619 !! end
15620
15621 !! test
15622 Image with nested tables in caption
15623 !! wikitext
15624 [[File:Foobar.jpg|thumb|Foo<br />
15625 {|
15626 |
15627 {|
15628 |z
15629 |}
15630 |}
15631 ]]
15632 !! html/parsoid
15633 <figure class="mw-default-size" typeof="mw:Image/Thumb" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"},{"ck":"caption","ak":"Foo&lt;br/>\n{|\n|\n{|\n|z\n|}\n|}\n"}]}'><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 data-parsoid='{"dsr":[null,50,null,null]}'>Foo<br data-parsoid='{"stx":"html","selfClose":true}'/>
15634 <table>
15635 <tbody><tr><td>
15636 <table>
15637 <tbody><tr><td>z</td></tr>
15638 </tbody></table></td></tr>
15639 </tbody></table>
15640 </figcaption></figure>
15641 !! end
15642
15643 !! test
15644 Image with heading and horizontal rule in caption
15645 !! wikitext
15646 [[File:Foobar.jpg|thumb|
15647 ===Testing===
15648 123
15649 --------------
15650 ]]
15651 !! html/php
15652 <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" decoding="async" 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><h3><span class="mw-headline" id="Testing">Testing</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: Testing">edit</a><span class="mw-editsection-bracket">]</span></span></h3> 123 <hr /></div></div></div>
15653
15654 !! html/parsoid
15655 <figure class="mw-default-size" typeof="mw:Image/Thumb" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"},{"ck":"caption","ak":"\n=== Testing ===\n123\n--------------\n"}]}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{"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>
15656 <h3 id="Testing">Testing</h3>
15657 123
15658 <hr data-parsoid='{"extra_dashes":10}'/>
15659 </figcaption></figure>
15660 !! end
15661
15662 ###################
15663 # Conflicting image format options.
15664 # First option specified should 'win'.
15665 # All three cases in each test should be identical.
15666
15667 !! test
15668 Image with 'frameless' first.
15669 !! options
15670 parsoid=wt2html,wt2wt,html2html
15671 !! wikitext
15672 [[File:Foobar.jpg|frameless|caption]]
15673
15674 [[File:Foobar.jpg|frameless|frame|caption]]
15675
15676 [[File:Foobar.jpg|frameless|thumb|caption]]
15677 !! html/php
15678 <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" decoding="async" 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>
15679 </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" decoding="async" 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>
15680 </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" decoding="async" 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>
15681 </p>
15682 !! html/parsoid
15683 <p><figure-inline 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></figure-inline></p>
15684 <p><figure-inline 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></figure-inline></p>
15685 <p><figure-inline 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></figure-inline></p>
15686 !! end
15687
15688 !! test
15689 Image with 'frame' first.
15690 !! options
15691 parsoid=wt2html,wt2wt,html2html
15692 !! wikitext
15693 [[File:Foobar.jpg|frame|caption]]
15694 [[File:Foobar.jpg|frame|frameless|caption]]
15695 [[File:Foobar.jpg|frame|thumb|caption]]
15696 !! html/php
15697 <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" decoding="async" width="1941" height="220" class="thumbimage" /></a> <div class="thumbcaption">caption</div></div></div>
15698 <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" decoding="async" width="1941" height="220" class="thumbimage" /></a> <div class="thumbcaption">caption</div></div></div>
15699 <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" decoding="async" width="1941" height="220" class="thumbimage" /></a> <div class="thumbcaption">caption</div></div></div>
15700
15701 !! html/parsoid
15702 <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>
15703 <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>
15704 <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>
15705 !! end
15706
15707 !! test
15708 Image with 'thumb' first.
15709 !! options
15710 parsoid=wt2html,wt2wt,html2html
15711 !! wikitext
15712 [[File:Foobar.jpg|thumb|caption]]
15713 [[File:Foobar.jpg|thumb|frameless|caption]]
15714 [[File:Foobar.jpg|thumb|frame|caption]]
15715 !! html/php
15716 <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" decoding="async" 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>
15717 <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" decoding="async" 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>
15718 <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" decoding="async" 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>
15719
15720 !! html/parsoid
15721 <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>
15722 <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>
15723 <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>
15724 !! end
15725
15726 ###################
15727 # Image sizing.
15728 # See https://www.mediawiki.org/wiki/Help:Images#Size_and_frame
15729 # and https://phabricator.wikimedia.org/T64258
15730 # Foobar has actual size of 1941x220
15731 # 1. Thumbs & frameless always reduce, can't be enlarged unless it's
15732 # a scalable format.
15733 # 2. Framed images always ignore size options; always render at default size.
15734 # 3. "Unspecified format" and border are the only types which can be
15735 # enlarged.
15736
15737 !! test
15738 Image: unspecified format and border enlarge
15739 !! options
15740 parsoid=wt2html,wt2wt,html2html
15741 !! wikitext
15742 [[File:Foobar.jpg|2000px]]
15743
15744 [[File:Foobar.jpg|border|2000px]]
15745 !! html/php
15746 <p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="2000" height="227" /></a>
15747 </p><p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="2000" height="227" class="thumbborder" /></a>
15748 </p>
15749 !! html/parsoid
15750 <p><figure-inline 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></figure-inline></p>
15751 <p><figure-inline 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></figure-inline></p>
15752 !! end
15753
15754 !! test
15755 Image: "unspecified format" and border reduce
15756 !! options
15757 parsoid=wt2html,wt2wt,html2html
15758 !! wikitext
15759 [[File:Foobar.jpg|1000px]]
15760
15761 [[File:Foobar.jpg|border|1000px]]
15762 !! html/php
15763 <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" decoding="async" 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>
15764 </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" decoding="async" 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>
15765 </p>
15766 !! html/parsoid
15767 <p><figure-inline 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></figure-inline></p>
15768 <p><figure-inline 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></figure-inline></p>
15769 !! end
15770
15771 !! test
15772 Image: thumbs reduce
15773 !! options
15774 parsoid=wt2html,wt2wt,html2html
15775 !! wikitext
15776 [[File:Foobar.jpg|thumb|50px]]
15777 !! html/php
15778 <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" decoding="async" 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>
15779
15780 !! html/parsoid
15781 <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>
15782 !! end
15783
15784 !! test
15785 Image: bitmap thumbs can't be enlarged past original size, but vector can.
15786 !! options
15787 parsoid=wt2html,wt2wt,html2html
15788 !! wikitext
15789 [[File:Foobar.jpg|thumb|2000px]]
15790
15791 [[File:Foobar.svg|thumb|2000px]]
15792 !! html/php
15793 <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" decoding="async" 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>
15794 <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" decoding="async" 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>
15795
15796 !! html/parsoid
15797 <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>
15798 <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>
15799 !! end
15800
15801 !! test
15802 Image: frameless can reduce in size
15803 !! options
15804 parsoid=wt2html,wt2wt,html2html
15805 !! wikitext
15806 [[File:Foobar.jpg|frameless|50px]]
15807 !! html/php
15808 <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" decoding="async" 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>
15809 </p>
15810 !! html/parsoid
15811 <p><figure-inline 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></figure-inline></p>
15812 !! end
15813
15814 !! test
15815 Image: bitmap frameless can't be enlarged past original size, but vector can
15816 !! options
15817 parsoid=wt2html,wt2wt,html2html
15818 !! wikitext
15819 [[File:Foobar.jpg|frameless|2000px]]
15820
15821 [[File:Foobar.svg|frameless|2000px]]
15822 !! html/php
15823 <p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" /></a>
15824 </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" decoding="async" 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>
15825 </p>
15826 !! html/parsoid
15827 <p><figure-inline 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></figure-inline></p>
15828 <p><figure-inline 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></figure-inline></p>
15829 !! end
15830
15831 !! test
15832 Image: framed images are always unscaled.
15833 !! options
15834 parsoid=wt2html,wt2wt,html2html
15835 !! wikitext
15836 [[File:Foobar.jpg|frame]]
15837
15838 [[File:Foobar.jpg|frame|50px]]
15839
15840 [[File:Foobar.jpg|frame|50x50px]]
15841
15842 [[File:Foobar.jpg|frame|2000px]]
15843 !! html/php
15844 <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" decoding="async" width="1941" height="220" class="thumbimage" /></a> <div class="thumbcaption"></div></div></div>
15845 <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" decoding="async" width="1941" height="220" class="thumbimage" /></a> <div class="thumbcaption"></div></div></div>
15846 <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" decoding="async" width="1941" height="220" class="thumbimage" /></a> <div class="thumbcaption"></div></div></div>
15847 <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" decoding="async" width="1941" height="220" class="thumbimage" /></a> <div class="thumbcaption"></div></div></div>
15848
15849 !! html/parsoid
15850 <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>
15851 <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>
15852 <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>
15853 <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>
15854 !! end
15855
15856 ###################
15857
15858 !! test
15859 Link to image page- image page normally doesn't exists, hence edit link
15860 Add test with existing image page
15861 #<p><a href="/wiki/File:Test" title="Image:Test">Image:test</a>
15862 !! wikitext
15863 [[:Image:test]]
15864 !! html
15865 <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>
15866 </p>
15867 !! end
15868
15869 !! test
15870 T20784 Link to non-existent image page with caption should use caption as link text
15871 !! wikitext
15872 [[:Image:test|caption]]
15873 !! html
15874 <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>
15875 </p>
15876 !! end
15877
15878 !! test
15879 Frameless image caption with a free URL
15880 !! wikitext
15881 [[File:Foobar.jpg|http://example.com]]
15882 !! html/php
15883 <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" decoding="async" width="1941" height="220" /></a>
15884 </p>
15885 !! html/parsoid
15886 <p><figure-inline 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></figure-inline></p>
15887 !! end
15888
15889 !! test
15890 Thumbnail image caption with a free URL
15891 !! options
15892 thumbsize=220
15893 !! wikitext
15894 [[File:Foobar.jpg|thumb|http://example.com]]
15895 !! html/php
15896 <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" decoding="async" 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>
15897
15898 !! html/parsoid
15899 <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" class="external free" href="http://example.com">http://example.com</a></figcaption></figure>
15900 !! end
15901
15902 !! test
15903 Thumbnail image caption with a free URL and explicit alt
15904 !! options
15905 thumbsize=220
15906 parsoid=wt2html,wt2wt,html2html
15907 !! wikitext
15908 [[File:Foobar.jpg|thumb|http://example.com|alt=Alteration]]
15909 !! html/php
15910 <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" decoding="async" 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>
15911
15912 !! html/parsoid
15913 <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" class="external free" href="http://example.com">http://example.com</a></figcaption></figure>
15914 !! end
15915
15916 !! test
15917 SVG thumbnails with no language set
15918 !! options
15919 !! wikitext
15920 [[File:Foobar.svg|thumb|caption]]
15921 !! html/php
15922 <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" decoding="async" 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>
15923
15924 !! html/parsoid
15925 <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>
15926 !! end
15927
15928 !! test
15929 SVG thumbnails with language de
15930 !! options
15931 parsoid=wt2html,wt2wt,html2html
15932 !! wikitext
15933 [[File:Foobar.svg|thumb|caption|lang=de]]
15934 !! html/php
15935 <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" decoding="async" 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>
15936
15937 !! html/parsoid
15938 <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>
15939 !! end
15940
15941 !! test
15942 SVG thumbnails with invalid language code
15943 !! options
15944 parsoid=wt2html,wt2wt,html2html
15945 !! wikitext
15946 [[File:Foobar.svg|thumb|caption|lang=invalid:language:code]]
15947 !! html/php
15948 <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" decoding="async" 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>
15949
15950 !! html/parsoid
15951 <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>lang=invalid:language:code</figcaption></figure>
15952 !! end
15953
15954 !! test
15955 SVG thumbnails in page language
15956 !! options
15957 language=ru
15958 !! wikitext
15959 [[File:Foobar.svg]] [[File:Foobar.svg|lang=en]]
15960 !! html/php
15961 <p><a href="/wiki/%D0%A4%D0%B0%D0%B9%D0%BB:Foobar.svg" class="image"><img alt="Foobar.svg" src="http://example.com/images/thumb/f/ff/Foobar.svg/langru-240px-Foobar.svg.png" decoding="async" width="240" height="180" srcset="http://example.com/images/thumb/f/ff/Foobar.svg/langru-360px-Foobar.svg.png 1.5x, http://example.com/images/thumb/f/ff/Foobar.svg/langru-480px-Foobar.svg.png 2x" /></a> <a href="/index.php?title=%D0%A4%D0%B0%D0%B9%D0%BB:Foobar.svg&amp;lang=en" class="image"><img alt="Foobar.svg" src="http://example.com/images/thumb/f/ff/Foobar.svg/240px-Foobar.svg.png" decoding="async" width="240" height="180" srcset="http://example.com/images/thumb/f/ff/Foobar.svg/360px-Foobar.svg.png 1.5x, http://example.com/images/thumb/f/ff/Foobar.svg/480px-Foobar.svg.png 2x" /></a>
15962 </p>
15963 !! end
15964
15965 !! test
15966 SVG thumbnails in page language not present in the file
15967 !! options
15968 language=de
15969 !! wikitext
15970 [[File:Foobar.svg]] [[File:Foobar.svg|lang=ru]]
15971 !! html/php
15972 <p><a href="/wiki/Datei:Foobar.svg" class="image"><img alt="Foobar.svg" src="http://example.com/images/thumb/f/ff/Foobar.svg/240px-Foobar.svg.png" decoding="async" width="240" height="180" srcset="http://example.com/images/thumb/f/ff/Foobar.svg/360px-Foobar.svg.png 1.5x, http://example.com/images/thumb/f/ff/Foobar.svg/480px-Foobar.svg.png 2x" /></a> <a href="/index.php?title=Datei:Foobar.svg&amp;lang=ru" class="image"><img alt="Foobar.svg" src="http://example.com/images/thumb/f/ff/Foobar.svg/langru-240px-Foobar.svg.png" decoding="async" width="240" height="180" srcset="http://example.com/images/thumb/f/ff/Foobar.svg/langru-360px-Foobar.svg.png 1.5x, http://example.com/images/thumb/f/ff/Foobar.svg/langru-480px-Foobar.svg.png 2x" /></a>
15973 </p>
15974 !! end
15975
15976 !! test
15977 T3887: A ISBN with a thumbnail
15978 !! wikitext
15979 [[File:Foobar.jpg|thumb|ISBN 1235467890]]
15980 !! html/php
15981 <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" decoding="async" 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>
15982
15983 !! html/parsoid
15984 <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>
15985 !! end
15986
15987 !! test
15988 T3887: A RFC with a thumbnail
15989 !! wikitext
15990 [[File:Foobar.jpg|thumb|This is RFC 12354]]
15991 !! html/php
15992 <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" decoding="async" 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="https://tools.ietf.org/html/rfc12354">RFC 12354</a></div></div></div>
15993
15994 !! html/parsoid
15995 <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="https://tools.ietf.org/html/rfc12354" rel="mw:ExtLink" class="external mw-magiclink">RFC 12354</a></figcaption></figure>
15996 !! end
15997
15998 !! test
15999 T3887: A mailto link with a thumbnail
16000 !! wikitext
16001 [[File:Foobar.jpg|thumb|Please mailto:nobody@example.com]]
16002 !! html/php
16003 <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" decoding="async" 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>
16004
16005 !! html/parsoid
16006 <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" class="external free" href="mailto:nobody@example.com">mailto:nobody@example.com</a></figcaption></figure>
16007 !! end
16008
16009 # Pending resolution to T2368
16010 !! test
16011 T2648: Frameless image caption with a link
16012 !! wikitext
16013 [[File:Foobar.jpg|text with a [[link]] in it]]
16014 !! html/php
16015 <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" decoding="async" width="1941" height="220" /></a>
16016 </p>
16017 !! html/parsoid
16018 <p><figure-inline 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></figure-inline></p>
16019 !! end
16020
16021 !! test
16022 T2648: Frameless image caption with a link (suffix)
16023 !! wikitext
16024 [[File:Foobar.jpg|text with a [[link]]foo in it]]
16025 !! html/php
16026 <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" decoding="async" width="1941" height="220" /></a>
16027 </p>
16028 !! html/parsoid
16029 <p><figure-inline 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></figure-inline></p>
16030 !! end
16031
16032 !! test
16033 T2648: Frameless image caption with an interwiki link
16034 !! wikitext
16035 [[File:Foobar.jpg|text with a [[MeatBall:Link]] in it]]
16036 !! html/php
16037 <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" decoding="async" width="1941" height="220" /></a>
16038 </p>
16039 !! html/parsoid
16040 <p><figure-inline 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:WikiLink/Interwiki\" 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></figure-inline></p>
16041 !! end
16042
16043 !! test
16044 T2648: Frameless image caption with a piped interwiki link
16045 !! wikitext
16046 [[File:Foobar.jpg|text with a [[MeatBall:Link|link]] in it]]
16047 !! html/php
16048 <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" decoding="async" width="1941" height="220" /></a>
16049 </p>
16050 !! html/parsoid
16051 <p><figure-inline 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:WikiLink/Interwiki\" 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></figure-inline></p>
16052 !! end
16053
16054 !! test
16055 T107474: Frameless image caption with <nowiki>
16056 !! wikitext
16057 [[File:Foobar.jpg|<nowiki>text with a [[MeatBall:Link|link]] in it</nowiki>]]
16058 !! html/parsoid
16059 <p><figure-inline 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></figure-inline></p>
16060 !! end
16061
16062 !! test
16063 Escape HTML special chars in image alt text
16064 !! wikitext
16065 [[File:Foobar.jpg|& < > "]]
16066 !! html/php
16067 <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" decoding="async" width="1941" height="220" /></a>
16068 </p>
16069 !! html/parsoid
16070 <p><figure-inline 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></figure-inline></p>
16071 !! end
16072
16073 !! test
16074 Escape HTML special chars in image alt text with LanguageConverter
16075 !! options
16076 language=zh
16077 !! wikitext
16078 [[File:Foobar.jpg|& < > "]]
16079 !! html/php
16080 <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" decoding="async" width="1941" height="220" /></a>
16081 </p>
16082 !! html/parsoid
16083 <p><figure-inline 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></figure-inline></p>
16084 !! end
16085
16086 !! test
16087 Entities in file name and attributes
16088 !! wikitext
16089 [[File:7%25 solution.gif|manualthumb=7%25 solution.gif|link=7%25 solution|[[7%25 solution]]]]
16090 !! html/php
16091 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=7%25_solution.gif" class="new" title="File:7% solution.gif">7% solution</a>
16092 </p>
16093 !! html/parsoid
16094 <p><figure-inline 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></figure-inline></p>
16095 !! end
16096
16097 !! test
16098 T2499: Alt text should have &#1234;, not &amp;1234;
16099 !! wikitext
16100 [[File:Foobar.jpg|&#9792;]]
16101 !! html/php
16102 <p><a href="/wiki/File:Foobar.jpg" class="image" title="♀"><img alt="♀" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" /></a>
16103 </p>
16104 !! html/parsoid
16105 <p><figure-inline 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></figure-inline></p>
16106 !! end
16107
16108 !! test
16109 Broken image caption with link
16110 !! options
16111 parsoid=wt2html,wt2wt,html2html
16112 !! wikitext
16113 [[Image:Foobar.jpg|thumb|This is a broken caption. But [[Main Page|this]] is just an ordinary link.
16114 !! html/php
16115 <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.
16116 </p>
16117 !! html/parsoid
16118 <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>
16119 !! end
16120
16121 !! test
16122 Image caption containing another image
16123 !! wikitext
16124 [[File:Foobar.jpg|thumb|This is a caption with another [[File:Thumb.png|image]] inside it!]]
16125 !! html/php
16126 <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" decoding="async" 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" decoding="async" width="135" height="135" /></a> inside it!</div></div></div>
16127
16128 !! html/parsoid
16129 <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 <figure-inline 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></figure-inline> inside it!</figcaption></figure>
16130 !! end
16131
16132 !! test
16133 Image: caption containing a newline
16134 !! wikitext
16135 [[File:Foobar.jpg|This
16136 *is some text]]
16137 !! html/php
16138 <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" decoding="async" width="1941" height="220" /></a>
16139 </p>
16140 !! html/parsoid
16141 <p><figure-inline 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></figure-inline></p>
16142 !!end
16143
16144 !!test
16145 Image: caption containing leading space
16146 (The leading space should not trigger nowiki escaping in wt2wt mode)
16147 !! wikitext
16148 [[File:Foobar.jpg|thumb| bar]]
16149 !! html/php
16150 <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" decoding="async" 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>
16151
16152 !! html/parsoid
16153 <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>
16154 !!end
16155
16156 # html/php output not have newlines after table, td, th, etc. because
16157 # Linker::makeThumbLink2() replaces the newlines with spaces since
16158 # the table is inside a caption.
16159 # FIXME: Verify if that circa 2004 fix is still required.
16160 !! test
16161 Image: caption containing a table
16162 !! options
16163 parsoid=wt2html,wt2wt,html2html
16164 !! wikitext
16165 [[Image:Foobar.jpg|thumb|200px|This is an example image thumbnail caption with a table
16166 {|
16167 !Foo!!Bar
16168 |-
16169 |Foo1||Bar1
16170 |}
16171 and some more text.]]
16172 !! html/php
16173 <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" decoding="async" 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>
16174
16175 !! html/parsoid
16176 <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
16177 <table>
16178 <tbody>
16179 <tr><th>Foo</th><th>Bar</th></tr>
16180 <tr>
16181 <td>Foo1</td>
16182 <td>Bar1</td></tr></tbody></table>and some more text.</figcaption></figure>
16183 !! end
16184
16185 !! test
16186 T5090: External links other than http: in image captions
16187 !! wikitext
16188 [[File:Foobar.jpg|thumb|200x200px|This caption has [irc://example.net irc] and [https://example.com Secure] ext links in it.]]
16189 !! html/php
16190 <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" decoding="async" 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>
16191
16192 !! html/parsoid
16193 <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" class="external text" href="irc://example.net">irc</a> and <a rel="mw:ExtLink" class="external text" href="https://example.com">Secure</a> ext links in it.</figcaption></figure>
16194 !! end
16195
16196 !! test
16197 Custom class
16198 !! options
16199 parsoid=wt2html,wt2wt,html2html
16200 !! wikitext
16201 [[Image:foobar.jpg|a|class=b]]
16202 !! html/php
16203 <p><a href="/wiki/File:Foobar.jpg" class="image" title="a"><img alt="a" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" class="b" /></a>
16204 </p>
16205 !! html/parsoid
16206 <p><figure-inline 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></figure-inline></p>
16207 !! end
16208
16209 !! test
16210 Localized image handling (1).
16211 !! options
16212 parsoid=wt2html,wt2wt,html2html
16213 language=es
16214 !! wikitext
16215 [[Archivo:Foobar.jpg|izquierda|enlace=foo|caption]]
16216 !! html/php
16217 <div class="floatleft"><a href="/wiki/Foo" title="caption"><img alt="caption" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" /></a></div>
16218
16219 !! html/parsoid
16220 <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>
16221 !! end
16222
16223 !! test
16224 Localized image handling (2).
16225 !! options
16226 thumbsize=220
16227 parsoid=wt2html,wt2wt,html2html
16228 language=es
16229 !! wikitext
16230 [[Archivo:Foobar.jpg|miniatura|izquierda|enlace=foo|caption]]
16231 !! html/php
16232 <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" decoding="async" 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>
16233
16234 !! html/parsoid
16235 <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>
16236 !! end
16237
16238 !! test
16239 Localized image handling (3).
16240 !! options
16241 language=fa
16242 parsoid=html2wt
16243 !! html/parsoid
16244 <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>
16245 !! wikitext
16246 [[File:Foobar.jpg|بندانگشتی]]
16247 !! end
16248
16249 !! test
16250 "border", "frameless" and "class" attributes on an image.
16251 !! options
16252 thumbsize=220
16253 parsoid=wt2html,wt2wt,html2html
16254 !! wikitext
16255 [[File:Foobar.jpg|frameless|border|class=extra|caption]]
16256 !! html/php
16257 <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" decoding="async" 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>
16258 </p>
16259 !! html/parsoid
16260 <p><figure-inline 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></figure-inline></p>
16261 !! end
16262
16263 # Note that 'right' is the default alignment, despite the misspelled 'righ' below
16264 !! test
16265 Invalid image attributes (T64500)
16266 !! options
16267 thumbsize=220
16268 parsoid=wt2html,wt2wt,html2html
16269 !! wikitext
16270 [[File:Foobar.jpg|thumb|float|left|caption]]
16271
16272 [[File:Foobar.jpg|thumb|righ|caption]]
16273
16274 [[File:Foobar.jpg|bogus1|thumb|bogus2|left|bogus3|caption]]
16275 !! html/php
16276 <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" decoding="async" 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>
16277 <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" decoding="async" 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>
16278 <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" decoding="async" 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>
16279
16280 !! html/parsoid
16281 <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>
16282 <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>
16283 <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>
16284 !! end
16285
16286 !! article
16287 File:Barfoo.jpg
16288 !! text
16289 #REDIRECT [[File:Barfoo.jpg]]
16290 !! endarticle
16291
16292 # FIXME: Parsoid should run this test -- but we'd need to teach the
16293 # mockAPI about the redirected Barfoo.jpg image.
16294 !! test
16295 Redirected image
16296 !! wikitext
16297 [[Image:Barfoo.jpg]]
16298 !! html/php
16299 <p><a href="/wiki/File:Barfoo.jpg" class="mw-redirect" title="File:Barfoo.jpg">File:Barfoo.jpg</a>
16300 </p>
16301 !! end
16302
16303 !! test
16304 Missing image with uploads disabled
16305 !! options
16306 wgEnableUploads=0
16307 !! wikitext
16308 [[File:Foobaz.jpg]]
16309 !! html/php
16310 <p><a href="/wiki/File:Foobaz.jpg" title="File:Foobaz.jpg">File:Foobaz.jpg</a>
16311 </p>
16312 !! html/parsoid
16313 <p><figure-inline 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></figure-inline></p>
16314 !! end
16315
16316 # Parsoid-specific testing for images
16317 # https://www.mediawiki.org/wiki/Parsoid/MediaWiki_DOM_spec#Images
16318 # Currently imperfect due to a flaw in the Parsoid testrunner
16319 # Work in progress
16320 # THESE TESTS SHOULD BE MOVED UP and merged with the php-specific
16321 # image tests.
16322
16323 !! test
16324 Parsoid-specific image handling - simple image with size and middle alignment
16325 !! wikitext
16326 [[File:Foobar.jpg|middle|50px]]
16327 !! html/parsoid
16328 <p><figure-inline 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></figure-inline></p>
16329 !! end
16330
16331 !! test
16332 Parsoid-specific image handling - simple image with size, middle alignment, non-standard namespace alias
16333 !! options
16334 parsoid=wt2wt,wt2html,html2html
16335 !! wikitext
16336 [[Image:Foobar.jpg|middle|50px]]
16337 !! html/parsoid
16338 <p><figure-inline 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></figure-inline></p>
16339 !! end
16340
16341 !! test
16342 Parsoid-specific image handling - simple image with size and middle alignment (existing content)
16343 !! wikitext
16344 [[File:Foobar.jpg|50px|middle]]
16345 !! html/parsoid
16346 <p><figure-inline 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></figure-inline></p>
16347 !! end
16348
16349 !! test
16350 Parsoid-specific image handling - simple image with size and middle alignment and non-standard namespace name
16351 !! options
16352 parsoid=wt2html,wt2wt,html2html
16353 !! wikitext
16354 [[Image:Foobar.jpg|50px|middle]]
16355 !! html/parsoid
16356 <p><figure-inline 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></figure-inline></p>
16357 !! end
16358
16359 !! test
16360 Parsoid-specific image handling - simple image with both sizes, a baseline alignment, and a caption
16361 !! wikitext
16362 [[File:Foobar.jpg|500x10px|baseline|caption]]
16363 !! html/parsoid
16364 <p><figure-inline 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></figure-inline></p>
16365 !! end
16366
16367 !! test
16368 Parsoid-specific image handling - simple image with border and size spec
16369 !! wikitext
16370 [[File:Foobar.jpg|50px|border|caption]]
16371 !! html/parsoid
16372 <p><figure-inline 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></figure-inline></p>
16373 !! end
16374
16375 !! test
16376 Parsoid-specific image handling - thumbnail with halign, valign, and caption
16377 !! options
16378 parsoid=wt2html,html2html
16379 !! wikitext
16380 [[File:Foobar.jpg|left|baseline|thumb|caption content]]
16381 !! html/parsoid
16382 <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 content</figcaption></figure>
16383 !! end
16384
16385 !! test
16386 Parsoid-specific image handling - thumbnail with halign, valign, and caption (existing content)
16387 !! options
16388 parsoid=wt2html,html2html
16389 !! wikitext
16390 [[File:Foobar.jpg|thumb|left|baseline|caption content]]
16391 !! html/parsoid
16392 <figure class="mw-default-size mw-halign-left" 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>
16393 !! end
16394
16395 !! test
16396 Parsoid-specific image handling - thumbnail with specific size, halign, valign, and caption
16397 !! options
16398 parsoid=wt2html,html2html
16399 !! wikitext
16400 [[Image:Foobar.jpg|right|middle|thumb|50x50px|caption]]
16401 !! html/parsoid
16402 <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/50px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="6" width="50"/></a><figcaption>caption</figcaption></figure>
16403 !! end
16404
16405 !! test
16406 Parsoid-specific image handling - thumbnail with specific size, halign, valign, and caption (existing content)
16407 !! options
16408 parsoid=wt2html,html2html
16409 !! wikitext
16410 [[File:Foobar.jpg|thumb|50x50px|right|middle|caption]]
16411 !! html/parsoid
16412 <figure class="mw-halign-right" 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>
16413 !! end
16414
16415 !! test
16416 Parsoid-specific image handling - framed image with specific size and caption (size is ignored)
16417 !! options
16418 parsoid=wt2html,wt2wt,html2html
16419 !! wikitext
16420 [[File:Foobar.jpg|frame|500x50px|caption]]
16421 !! html/parsoid
16422 <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>
16423 !! end
16424
16425 !! test
16426 Parsoid-specific image handling - framed image with specific size, halign, valign, and caption (size is ignored)
16427 !! options
16428 parsoid=wt2html,html2html
16429 !! wikitext
16430 [[File:Foobar.jpg|left|baseline|frame|500x50px|caption]]
16431 !! html/parsoid
16432 <figure class="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>caption</figcaption></figure>
16433 !! end
16434
16435 !! test
16436 Parsoid-specific image handling - frameless image with specific size, border, and caption
16437 !! wikitext
16438 [[File:Foobar.jpg|frameless|442x50px|border|caption]]
16439 !! html/parsoid
16440 <p><figure-inline 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></figure-inline></p>
16441 !! end
16442
16443 !! test
16444 Parsoid-specific image handling - simple image with a formatted caption
16445 !! wikitext
16446 [[File:Foobar.jpg|<table><tr><td>a</td><td>b</td></tr><tr><td>c</td></tr></table>]]
16447 !! html/parsoid
16448 <p><figure-inline 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></figure-inline></p>
16449 !! end
16450
16451 !! test
16452 Parsoid-specific image handling - caption with a template in it
16453 !! wikitext
16454 [[File:Foobar.jpg|thumb|200x23px|This caption has a {{echo|transclusion}} in it.]]
16455 !! html/parsoid
16456 <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>
16457 !! end
16458
16459 !! test
16460 Parsoid-specific image handling - caption with unbalanced tags in it
16461 !! options
16462 parsoid=wt2html,wt2wt,html2html
16463 !! wikitext
16464 foo
16465 [[File:Foobar.jpg|thumb|200x200px|This caption has a <center>unbalanced tag in it.]]
16466 bar
16467 !! html/parsoid
16468 <p>foo</p>
16469 <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>
16470 <p>bar</p>
16471 !! end
16472
16473 !! test
16474 Parsoid-specific image handling - empty caption (1)
16475 !! options
16476 parsoid=wt2html,wt2wt
16477 !! wikitext
16478 [[File:Foobar.jpg|thumb|]]
16479 !! html/parsoid
16480 <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>
16481 !! end
16482
16483 # empty captions don't get serialized unless we're in the "round trip" case
16484 !! test
16485 Parsoid-specific image handling - empty caption (2)
16486 !! options
16487 parsoid=html2wt
16488 !! html/parsoid
16489 <figure class="mw-default-size" typeof="mw:Image/Thumb">
16490 <a href="./File:Foobar.jpg">
16491 <img resource="./File:Foobar.jpg"
16492 src="//example.com/images/3/3a/Foobar.jpg"
16493 data-file-width="1941" data-file-height="220" data-file-type="bitmap"
16494 height="25" width="220"/>
16495 </a>
16496 <figcaption></figcaption>
16497 </figure>
16498 !! wikitext
16499 [[File:Foobar.jpg|thumb]]
16500 !! end
16501
16502 !! test
16503 Parsoid-specific image handling - whitespace caption
16504 !! wikitext
16505 [[File:Foobar.jpg|thumb| ]]
16506 !! html/parsoid
16507 <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>
16508 !! end
16509
16510 !! test
16511 Parsoid-specific image handling - lang option
16512 !! wikitext
16513 foo
16514 [[File:Foobar.svg|lang=de|caption]]
16515 bar
16516 !! html/parsoid
16517 <p>foo
16518 <figure-inline 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></figure-inline>
16519 bar</p>
16520 !! end
16521
16522 ## Edge case bugs in Parsoid from T93580
16523 !! test
16524 T93580: 1. Templated <ref> inside block images
16525 !! wikitext
16526 [[File:Foobar.jpg|thumb|Caption with templated ref: {{echo|<ref>foo</ref>}}]]
16527
16528 <references />
16529 !! html/parsoid
16530 <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: <sup 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="./Parser_test#cite_note-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></sup></figcaption></figure>
16531
16532 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt6" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Parser_test#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>
16533 !! end
16534
16535 !! test
16536 T93580: 2. <ref> inside inline images
16537 !! wikitext
16538 [[File:Foobar.jpg|Undisplayed caption in inline image with ref: <ref>foo</ref>]]
16539
16540 <references />
16541 !! html/parsoid
16542 <p><figure-inline 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;sup 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\",\"attrs\":{},\"body\":{\"id\":\"mw-reference-text-cite_note-1\"}}&#39;>&lt;a href=\"./Parser_test#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;/sup>"}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{"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":"File:Foobar.jpg"}}'/></a></figure-inline></p>
16543
16544 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt4" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Parser_test#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>
16545 !! end
16546
16547 !! test
16548 T93580: 3. Templated <ref> inside inline images
16549 !! wikitext
16550 [[File:Foobar.jpg|Undisplayed caption in inline image with ref: {{echo|<ref>{{echo|foo}}</ref>}}]]
16551
16552 <references />
16553 !! html/parsoid
16554 <p><figure-inline 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;sup 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=\"./Parser_test#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;/sup>"}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{"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":"File:Foobar.jpg"}}'/></a></figure-inline></p>
16555
16556 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt6" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Parser_test#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>
16557 !! end
16558
16559 ###
16560 ### Subpages
16561 ###
16562 !! article
16563 Subpage test/subpage
16564 !! text
16565 foo
16566 !! endarticle
16567
16568 !! test
16569 Subpage link
16570 !! options
16571 subpage title=[[Subpage test]]
16572 !! wikitext
16573 [[/subpage]]
16574 !! html
16575 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a>
16576 </p>
16577 !! end
16578
16579 !! test
16580 Subpage noslash link
16581 !! options
16582 subpage title=[[Subpage test]]
16583 !! wikitext
16584 [[/subpage/]]
16585 !! html
16586 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">subpage</a>
16587 </p>
16588 !! end
16589
16590 !! article
16591 Subpage test/1/2/subpage
16592 !! text
16593 blah
16594 !! endarticle
16595
16596 !! test
16597 Relative subpage noslash link
16598 !! options
16599 parsoid=wt2wt,wt2html,html2html
16600 subpage title=[[Subpage test/1/2/3/4]]
16601 !! wikitext
16602 [[../../subpage/]]
16603
16604 [[../../subpage]]
16605 !! html/php
16606 <p><a href="/wiki/Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">subpage</a>
16607 </p><p><a href="/wiki/Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">Subpage test/1/2/subpage</a>
16608 </p>
16609 !! html/parsoid
16610 <p><a rel="mw:WikiLink" href="./Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">subpage</a></p>
16611 <p><a rel="mw:WikiLink" href="./Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">Subpage_test/1/2/subpage</a></p>
16612 !! end
16613
16614 !! test
16615 Parsoid: dot-slash prefixed wikilinks
16616 !! wikitext
16617 [[./foo]]
16618
16619 [[././bar]]
16620
16621 [[././baz/]]
16622 !! html/php
16623 <p>[[./foo]]
16624 </p><p>[[././bar]]
16625 </p><p>[[././baz/]]
16626 </p>
16627 !! html/parsoid
16628 <p>[[./foo]]
16629 </p><p>[[././bar]]
16630 </p><p>[[././baz/]]
16631 </p>
16632 !! end
16633
16634 !! test
16635 Render invalid page names as plain text (T53090)
16636 !! wikitext
16637 [[./../foo|bar]]
16638 [[foo�|bar]]
16639 [[foo/.|bar]]
16640 [[foo/..|bar]]
16641 [[foo~~~bar]]
16642 [[foo>bar]]
16643 [[foo[bar]]
16644 [[.]]
16645 [[..]]
16646 [[foo././bar]]
16647 [[foo[http://example.com]xyz]]
16648
16649 [[{{echo|./../foo}}|bar]]
16650 [[{{echo|foo/.}}|bar]]
16651 [[{{echo|foo/..}}|bar]]
16652 [[{{echo|foo~~~~bar}}]]
16653 [[{{echo|foo>bar}}]]
16654 [[{{echo|foo././bar}}]]
16655 [[{{echo|foo{bar}}]]
16656 [[{{echo|foo}bar}}]]
16657 [[{{echo|foo[bar}}]]
16658 [[{{echo|foo]bar}}]]
16659 [[{{echo|foo<bar}}]]
16660 !!html/php
16661 <p>[[./../foo|bar]]
16662 [[foo�|bar]]
16663 [[foo/.|bar]]
16664 [[foo/..|bar]]
16665 [[foo~~~bar]]
16666 [[foo&gt;bar]]
16667 [[foo[bar]]
16668 [[.]]
16669 [[..]]
16670 [[foo././bar]]
16671 [[foo<a rel="nofollow" class="external autonumber" href="http://example.com">[1]</a>xyz]]
16672 </p><p>[[./../foo|bar]]
16673 [[foo/.|bar]]
16674 [[foo/..|bar]]
16675 [[foo~~~~bar]]
16676 [[foo&gt;bar]]
16677 [[foo././bar]]
16678 [[foo{bar]]
16679 [[foo}bar]]
16680 [[foo[bar]]
16681 [[foo]bar]]
16682 [[foo&lt;bar]]
16683 </p>
16684 !!html/parsoid
16685 <p>[[./../foo|bar]]
16686 [[foo�|bar]]
16687 [[foo/.|bar]]
16688 [[foo/..|bar]]
16689 [[foo~~~bar]]
16690 [[foo>bar]]
16691 [[foo[bar]]
16692 [[.]]
16693 [[..]]
16694 [[foo././bar]]
16695 [[foo<a rel="mw:ExtLink" class="external autonumber" href="http://example.com"></a>xyz]]</p>
16696
16697 <p>[[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"./../foo"}},"i":0}}]}'>./../foo</span>|bar]]
16698 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo/."}},"i":0}}]}'>foo/.</span>|bar]]
16699 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo/.."}},"i":0}}]}'>foo/..</span>|bar]]
16700 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo~~~~bar"}},"i":0}}]}'>foo~~~~bar</span>]]
16701 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo>bar"}},"i":0}}]}'>foo>bar</span>]]
16702 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo././bar"}},"i":0}}]}'>foo././bar</span>]]
16703 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo{bar"}},"i":0}}]}'>foo{bar</span>]]
16704 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo}bar"}},"i":0}}]}'>foo}bar</span>]]
16705 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo[bar"}},"i":0}}]}'>foo[bar</span>]]
16706 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo]bar"}},"i":0}}]}'>foo]bar</span>]]
16707 [[<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>
16708 !!end
16709
16710 !! test
16711 Disabled subpages
16712 !! wikitext
16713 [[/subpage]]
16714 !! html
16715 <p><a href="/index.php?title=/subpage&amp;action=edit&amp;redlink=1" class="new" title="/subpage (page does not exist)">/subpage</a>
16716 </p>
16717 !! end
16718
16719 !! test
16720 T2561: {{/Subpage}}
16721 !! options
16722 subpage title=[[Page]]
16723 !! wikitext
16724 {{/Subpage}}
16725 !! html
16726 <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>
16727 </p>
16728 !! end
16729
16730 ###
16731 ### Categories
16732 ###
16733 !! article
16734 Category:MediaWiki User's Guide
16735 !! text
16736 blah
16737 !! endarticle
16738
16739 !! test
16740 Link to category
16741 !! wikitext
16742 [[:Category:MediaWiki User's Guide]]
16743 !! html
16744 <p><a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User&#39;s Guide">Category:MediaWiki User's Guide</a>
16745 </p>
16746 !! end
16747
16748 !! test
16749 Simple category
16750 !! options
16751 cat
16752 !! wikitext
16753 [[Category:MediaWiki User's Guide]]
16754 !! html/php
16755 cat=MediaWiki_User's_Guide sort=
16756 !! html/parsoid
16757 <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"}}'/>
16758 !! end
16759
16760 !! test
16761 PAGESINCATEGORY invalid title fatal (r33546 fix)
16762 !! wikitext
16763 {{PAGESINCATEGORY:<bogus>}}
16764 !! html
16765 <p>0
16766 </p>
16767 !! end
16768
16769 !! test
16770 Category with different sort key
16771 !! options
16772 cat
16773 !! wikitext
16774 [[Category:MediaWiki User's Guide|Foo]]
16775 !! html/php
16776 cat=MediaWiki_User's_Guide sort=Foo
16777 !! html/parsoid
16778 <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"}}'/>
16779 !! end
16780
16781 !! test
16782 Category with identical sort key
16783 !! options
16784 cat
16785 !! wikitext
16786 [[Category:MediaWiki User's Guide|MediaWiki User's Guide]]
16787 !! html/php
16788 cat=MediaWiki_User's_Guide sort=MediaWiki User's Guide
16789 !! html/parsoid
16790 <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"}}'/>
16791 !! end
16792
16793 !! test
16794 Category with empty sort key
16795 !! options
16796 cat
16797 pst
16798 !! wikitext
16799 [[Category:MediaWiki User's Guide|]]
16800 !! html/php
16801 [[Category:MediaWiki User's Guide|MediaWiki User's Guide]]
16802 !! end
16803
16804 !! test
16805 Category with empty sort key and parentheses
16806 !! options
16807 cat
16808 pst
16809 !! wikitext
16810 [[Category:Foo (bar)|]]
16811 !! html/php
16812 [[Category:Foo (bar)|Foo]]
16813 !! end
16814
16815 !! test
16816 Category with link tail
16817 !! options
16818 cat
16819 pst
16820 !! wikitext
16821 123[[Category:Foo]]456
16822 !! html/php
16823 123[[Category:Foo]]456
16824 !! end
16825
16826 !! test
16827 Category with template
16828 !! options
16829 cat
16830 pst
16831 !! wikitext
16832 [[Category:{{echo|Foo}}]]
16833 !! html/php
16834 [[Category:{{echo|Foo}}]]
16835 !! end
16836
16837 !! test
16838 Category with template in sort key
16839 !! options
16840 cat
16841 pst
16842 !! wikitext
16843 [[Category:Foo|{{echo|Bar}}]]
16844 !! html/php
16845 [[Category:Foo|{{echo|Bar}}]]
16846 !! end
16847
16848 !! test
16849 Category with template in sort key and title
16850 !! options
16851 cat
16852 pst
16853 !! wikitext
16854 [[Category:{{echo|Foo}}|{{echo|Bar}}]]
16855 !! html/php
16856 [[Category:{{echo|Foo}}|{{echo|Bar}}]]
16857 !! end
16858
16859 ## We used to, but no longer wt2wt this test since the default serializer
16860 ## will normalize all categories to serialize on their own line.
16861 ## This wikitext usage is going to be fairly uncommon in production and
16862 ## selser will take care of preserving formatting in those scenarios.
16863 !! test
16864 Category / paragraph interactions
16865 !! options
16866 parsoid=wt2html
16867 !! wikitext
16868 Foo [[Category:Baz]] Bar
16869
16870 Foo [[Category:Baz]]
16871 Bar
16872
16873 Foo
16874 [[Category:Baz]]
16875 Bar
16876
16877 Foo
16878 [[Category:Baz]] Bar
16879
16880 Foo
16881 [[Category:Baz]]
16882 [[Category:Baz]]
16883 [[Category:Baz]]
16884 Bar
16885
16886 [[Category:Baz]]
16887 [[Category:Baz]]
16888 [[Category:Baz]]
16889
16890 [[Category:Baz]]
16891 {{echo|[[Category:Baz]]}}
16892 [[Category:Baz]]
16893 !! html/php
16894 <p>Foo Bar
16895 </p><p>Foo
16896 Bar
16897 </p><p>Foo
16898 Bar
16899 </p><p>Foo Bar
16900 </p><p>Foo
16901 Bar
16902 </p>
16903 !! html/parsoid
16904 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16905 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16906 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16907 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16908 <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</p>
16909 <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}}]}'/>
16910 <link rel="mw:PageProp/Category" href="./Category:Baz"/>
16911 !! end
16912
16913 ## We used to, but no longer wt2wt this test since the default serializer
16914 ## will normalize all categories to serialize on their own line.
16915 ## This wikitext usage is going to be fairly uncommon in production and
16916 ## selser will take care of preserving formatting in those scenarios.
16917 ##
16918 ## The whitespace on the empty line is part of the test. Please do not delete
16919 !! test
16920 1. Categories and newlines: All preceding newlines should be suppressed (courtesy T2087)
16921 !! options
16922 parsoid=wt2html
16923 !! wikitext
16924 This
16925
16926 [[Category:Foo]] and this should be part of same paragraph (not an indent-pre)
16927
16928 {{echo|[[Category:Foo]] and so should this!}}
16929 !! html/php
16930 <p>This and this should be part of same paragraph (not an indent-pre) and so should this!
16931 </p>
16932 !! html/parsoid
16933 <p>This
16934
16935 <link rel="mw:PageProp/Category" href="./Category:Foo"/> and this should be part of same paragraph (not an indent-pre)
16936
16937 <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>
16938 !! end
16939
16940 ## Parsoid will not try to wt2wt this while preserving newlines because
16941 ## it suppresses excess newlines within list items -- and we don't want to
16942 ## introduce a special case just for categories, which is, in reality somewhat
16943 ## odd behavior -- categories are unlikely to be used in list items like this
16944 ## in top-level pages and are only likely to show up in template-generated
16945 ## list items where this RT-ing is a non-issue.
16946 ##
16947 ## The whitespace on the empty line is part of the test. Please do not delete
16948 !! test
16949 2. Categories and newlines: All preceding newlines should be suppressed (courtesy T2087)
16950 !! options
16951 parsoid=wt2html
16952 !! wikitext
16953 * This
16954
16955 [[Category:Foo]] and this should be part of the same list item
16956 * So should this
16957
16958 {{echo|[[Category:Foo]] and this should be part of the same list item}}
16959 !! html/php+tidy
16960 <ul><li>This and this should be part of the same list item</li>
16961 <li>So should this and this should be part of the same list item</li></ul>
16962 !! html/parsoid
16963 <ul>
16964 <li>This <link rel="mw:PageProp/Category" href="./Category:Foo"/> and this should be part of the same list item</li>
16965 <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>
16966 </ul>
16967 !! end
16968
16969 ## Newlines and categories that follow the last item of a list
16970 ## are treated differently because this (list followed by categories)
16971 ## is an extremely common pattern on wikis.
16972 !! test
16973 3. Categories and newlines: newline suppression for last list item should RT properly
16974 !! wikitext
16975 *a
16976 *b
16977
16978 [[Category:Foo]]
16979
16980 [[Category:Bar]]
16981 [[Category:Baz]]
16982
16983 :c
16984
16985 [[Category:C]]
16986
16987 ;d
16988
16989 [[Category:D]]
16990 !! html/parsoid
16991 <ul><li>a</li>
16992 <li>b</li></ul>
16993
16994 <link rel="mw:PageProp/Category" href="./Category:Foo"/>
16995
16996 <link rel="mw:PageProp/Category" href="./Category:Bar"/>
16997 <link rel="mw:PageProp/Category" href="./Category:Baz"/>
16998
16999 <dl><dd>c</dd></dl>
17000
17001 <link rel="mw:PageProp/Category" href="./Category:C"/>
17002
17003 <dl><dt>d</dt></dl>
17004
17005 <link rel="mw:PageProp/Category" href="./Category:D"/>
17006 !! end
17007
17008 !! test
17009 4. Categories and newlines: newline suppression for last list item should RT properly
17010 !! wikitext
17011 *a
17012 ****b
17013
17014 [[Category:Foo]]
17015 !! html/parsoid
17016 <ul><li>a
17017 <ul><li><ul><li><ul><li>b</li></ul></li></ul></li></ul></li></ul>
17018
17019 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
17020 !! end
17021
17022 ## only wt2html for this to make sure the algo only applies to the rightmost path
17023 !! test
17024 5. Categories and newlines: migrateTrailingCategories dom pass should only run on the rightmost path of nested lists
17025 !! options
17026 parsoid=wt2html
17027 !! wikitext
17028 *a
17029 **b
17030 [[Category:Foo]]
17031 *c
17032 **d
17033 [[Category:Foo]]
17034 !! html/parsoid
17035 <ul><li>a
17036 <ul><li>b
17037 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/></li></ul></li>
17038 <li>c
17039 <ul><li>d</li></ul></li></ul>
17040 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
17041 !! end
17042
17043 ## We used to, but no longer wt2wt this test since the default serializer
17044 ## will normalize all categories to serialize on their own line.
17045 ## This wikitext usage is going to be fairly uncommon in production and
17046 ## selser will take care of preserving formatting in those scenarios.
17047 !! test
17048 6. Categories and newlines: migrateTrailingCategories dom pass should not migrate categories not preceded by newlines
17049 !! options
17050 parsoid=wt2html
17051 !! wikitext
17052 *a [[Category:Foo]]
17053 !! html/parsoid
17054 <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>
17055 !! end
17056
17057 # This test also demonstrates because of newline+category tunneling
17058 # through the list hander, template wrapping doesn't expand to the
17059 # containing list when the list item swallows the category.
17060 !! test
17061 7. Categories and newlines: migrateTrailingCategories dom pass should leave template content alone
17062 !! wikitext
17063 *{{echo|a
17064 [[Category:Foo]]}}
17065 !! html/parsoid
17066 <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
17067 </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>
17068 !! end
17069
17070 !! test
17071 8. Categories and newlines: migrateTrailingCategories dom pass should not get tripped by intervening templates
17072 !! wikitext
17073 *a
17074
17075 {{echo|[[Category:Foo]]
17076 [[Category:Bar]]}}
17077 [[Category:Baz]]
17078 !! html/parsoid
17079 <ul><li>a</li></ul>
17080
17081 <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">
17082 </span><link rel="mw:PageProp/Category" href="./Category:Bar" about="#mwt1" data-parsoid='{"stx":"simple","a":{"href":"./Category:Bar"},"sa":{"href":"Category:Bar"}}'/>
17083 <link rel="mw:PageProp/Category" href="./Category:Baz" data-parsoid='{"stx":"simple","a":{"href":"./Category:Baz"},"sa":{"href":"Category:Baz"}}'/>
17084 !! end
17085
17086 !! test
17087 Categories and newlines: migrateTrailingCategories dom pass should not get tripped by comments and whitespace
17088 !! wikitext
17089 *a
17090
17091 [[Category:Bar]]<!--boo1--> <!--boo2-->
17092 [[Category:Baz]]<!--boo3--> <!--boo4-->
17093 !! html/parsoid
17094 <ul><li>a</li></ul>
17095
17096 <link rel="mw:PageProp/Category" href="./Category:Bar"/><!--boo1--> <!--boo2-->
17097 <link rel="mw:PageProp/Category" href="./Category:Baz"/><!--boo3--> <!--boo4-->
17098 !! end
17099
17100 !! test
17101 Categories and newlines: should behave properly with linkprefix (T87753)
17102 !! options
17103 language=ar
17104 !! wikitext
17105 foo bar
17106 foo bar
17107 [[تصنيف:Foo]]
17108 [[تصنيف:Bar]]
17109 !! html/php
17110 <p>foo bar
17111 foo bar
17112 </p>
17113 !! html/parsoid
17114 <p>foo bar
17115 foo bar</p>
17116 <link rel="mw:PageProp/Category" href="./تصنيف:Foo"/>
17117 <link rel="mw:PageProp/Category" href="./تصنيف:Bar"/>
17118 !! end
17119
17120 !! test
17121 No regressions on internal links following category (T174639)
17122 !! options
17123 parsoid=wt2html,html2html
17124 !! wikitext
17125 [[Category:Foo]]<div>a
17126
17127 [[Foo]]</div>
17128 !! html/php
17129 <div>a
17130 <a href="/wiki/Foo" title="Foo">Foo</a></div>
17131
17132 !! html/parsoid
17133 <link rel="mw:PageProp/Category" href="./Category:Foo"/><div>a
17134
17135 <a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></div>
17136 !! end
17137
17138 # Note that Parsoid differs slightly from PHP due to T175421
17139 !! test
17140 11. Special case where only newlines separate links (T175416)
17141 !! options
17142 parsoid=wt2html,html2html
17143 !! wikitext
17144 [[Category:Foo]]
17145
17146 [[Foo]][[es:Alimento]]
17147
17148 [[Foo]]
17149 !! html/php
17150 <p><br />
17151 <a href="/wiki/Foo" title="Foo">Foo</a>
17152 </p><p><a href="/wiki/Foo" title="Foo">Foo</a>
17153 </p>
17154 !! html/parsoid
17155 <link rel="mw:PageProp/Category" href="./Category:Foo"/>
17156
17157 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></p><link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Alimento"/>
17158
17159 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></p>
17160 !! end
17161
17162 !! test
17163 Category links with multiple namespaces
17164 !! wikitext
17165 [[Category:Project:Foo]]
17166 !! html/parsoid
17167 <link rel="mw:PageProp/Category" href="./Category:Project:Foo" />
17168 !! end
17169
17170 !! test
17171 Parsoid: Serialize link to category page with colon escape
17172 !! wikitext
17173
17174 [[:Category:Foo]]
17175 [[:Category:Foo|Bar]]
17176 !! html/php+tidy
17177 <p><a href="/index.php?title=Category:Foo&amp;action=edit&amp;redlink=1" class="new" title="Category:Foo (page does not exist)">Category:Foo</a>
17178 <a href="/index.php?title=Category:Foo&amp;action=edit&amp;redlink=1" class="new" title="Category:Foo (page does not exist)">Bar</a>
17179 </p>
17180 !! html/parsoid
17181 <p>
17182 <a rel="mw:WikiLink" href="./Category:Foo" title="Category:Foo">Category:Foo</a>
17183 <a rel="mw:WikiLink" href="./Category:Foo" title="Category:Foo">Bar</a>
17184 </p>
17185 !! end
17186
17187 # We used to, but no longer wt2wt this test since the default serializer
17188 # will normalize all categories to serialize on their own line.
17189 # This wikitext usage is going to be fairly uncommon in production and
17190 # selser will take care of preventing whitespace insertion if this
17191 # occurs in an article.
17192 #
17193 # html2html disabled for the same reason (whitespace insertion between
17194 # x and y).
17195 #
17196 # html2wt disabled because it localizes the "Category" namespace.
17197 !! test
17198 Link prefix/suffixes aren't applied to category links
17199 !! options
17200 parsoid=wt2html
17201 language=is
17202 !! wikitext
17203 x[[Category:Foo]]y
17204 !! html/php
17205 <p>xy
17206 </p>
17207 !! html/parsoid
17208 <p>x<link rel="mw:PageProp/Category" href="./Flokkur:Foo" data-parsoid=""/>y</p>
17209 !! end
17210
17211 !! test
17212 Link prefix/suffixes aren't applied to language links
17213 !! options
17214 parsoid=wt2html
17215 language=is
17216 !! wikitext
17217 x[[es:Foo]]y
17218 !! html/php
17219 <p>xy
17220 </p>
17221 !! html/parsoid
17222 <p>x<link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo" data-parsoid=""/>y</p>
17223 !! end
17224
17225 !! test
17226 Parsoid: Serialize link to file page with colon escape
17227 !! wikitext
17228
17229 [[:File:Foo.png]]
17230 [[:File:Foo.png|Bar]]
17231 !! html/php+tidy
17232 <p><a href="/index.php?title=File:Foo.png&amp;action=edit&amp;redlink=1" class="new" title="File:Foo.png (page does not exist)">File:Foo.png</a>
17233 <a href="/index.php?title=File:Foo.png&amp;action=edit&amp;redlink=1" class="new" title="File:Foo.png (page does not exist)">Bar</a>
17234 </p>
17235 !! html/parsoid
17236 <p>
17237 <a rel="mw:WikiLink" href="./File:Foo.png" title="File:Foo.png">File:Foo.png</a>
17238 <a rel="mw:WikiLink" href="./File:Foo.png" title="File:Foo.png">Bar</a>
17239 </p>
17240 !! end
17241
17242 !! test
17243 Parsoid: Serialize a genuine category link without colon escape
17244 !! wikitext
17245 [[Category:Foo]]
17246 [[Category:Foo|Bar]]
17247 !! html/php+tidy
17248 !! html/parsoid
17249 <link rel="mw:PageProp/Category" href="./Category:Foo">
17250 <link rel="mw:PageProp/Category" href="./Category:Foo#Bar">
17251 !! end
17252
17253 !! test
17254 Normalize hrefs properly before testing for invalid link targets (T72894)
17255 !! options
17256 parsoid=html2wt
17257 !! html/parsoid
17258 <link rel="mw:PageProp/Category" href="./Category:Toxine_bactérienne"/>
17259 !! wikitext
17260 [[Category:Toxine bactérienne]]
17261 !! end
17262
17263 !! test
17264 Parsoid: Defaultsort
17265 !! wikitext
17266 {{DEFAULTSORT:Foo}}
17267 !! html/parsoid
17268 <meta property="mw:PageProp/categorydefaultsort" content="Foo"/>
17269 !! end
17270
17271 # NOTE: mw:ExpandedAttrs is not the best typeof here. mw:Transclusion is better.
17272 # But, this is a limitation of our representation and is documented in
17273 # TemplateHandler.js in processSpecialMagicWord
17274 !! test
17275 Parsoid: Defaultsort (template-generated)
17276 !! wikitext
17277 {{{{echo|DEFAULTSORT}}:Foo}}
17278 !! html/parsoid
17279 <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"}]]}'/>
17280 !! end
17281
17282 ###
17283 ### Inter-language links
17284 ###
17285 !! test
17286 Interlanguage links
17287 !! options
17288 ill
17289 !! wikitext
17290 [[es:Alimento]]
17291 [[fr:Nourriture]]
17292 [[zh:食品]]
17293 !! html/php
17294 es:Alimento fr:Nourriture zh:食品
17295 !! html/parsoid
17296 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Alimento"/>
17297 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/Nourriture"/>
17298 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/食品"/>
17299 !! end
17300
17301 !! test
17302 Duplicate interlanguage links (T26502)
17303 !! options
17304 ill
17305 !! wikitext
17306 [[es:1]]
17307 [[es:2]]
17308 [[fr:1]]
17309 [[fr:2]]
17310 !! html/php
17311 es:1 fr:1
17312 !! html/parsoid
17313 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/1"/>
17314 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/2"/>
17315 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/1"/>
17316 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/2"/>
17317 !! end
17318
17319 ###
17320 ### Sections
17321 ###
17322 !! test
17323 Basic section headings
17324 !! wikitext
17325 ==Headline 1==
17326 Some text
17327
17328 ==Headline 2==
17329 More
17330 ===Smaller headline===
17331 Blah blah
17332 !! html
17333 <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>
17334 <p>Some text
17335 </p>
17336 <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>
17337 <p>More
17338 </p>
17339 <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>
17340 <p>Blah blah
17341 </p>
17342 !! end
17343
17344 !! test
17345 Section headings with TOC
17346 !! wikitext
17347 ==Headline 1==
17348 ===Subheadline 1===
17349 =====Skipping a level=====
17350 ======Skipping a level======
17351
17352 ==Headline 2==
17353 Some text
17354 ===Another headline===
17355 !! html
17356 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
17357 <ul>
17358 <li class="toclevel-1 tocsection-1"><a href="#Headline_1"><span class="tocnumber">1</span> <span class="toctext">Headline 1</span></a>
17359 <ul>
17360 <li class="toclevel-2 tocsection-2"><a href="#Subheadline_1"><span class="tocnumber">1.1</span> <span class="toctext">Subheadline 1</span></a>
17361 <ul>
17362 <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>
17363 <ul>
17364 <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>
17365 </ul>
17366 </li>
17367 </ul>
17368 </li>
17369 </ul>
17370 </li>
17371 <li class="toclevel-1 tocsection-5"><a href="#Headline_2"><span class="tocnumber">2</span> <span class="toctext">Headline 2</span></a>
17372 <ul>
17373 <li class="toclevel-2 tocsection-6"><a href="#Another_headline"><span class="tocnumber">2.1</span> <span class="toctext">Another headline</span></a></li>
17374 </ul>
17375 </li>
17376 </ul>
17377 </div>
17378
17379 <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>
17380 <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>
17381 <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>
17382 <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>
17383 <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>
17384 <p>Some text
17385 </p>
17386 <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>
17387
17388 !! end
17389
17390 !! test
17391 TOC anchors don't collide
17392 !! wikitext
17393 __FORCETOC__
17394 ==Headline 2==
17395 ==Headline==
17396 ==Headline 2==
17397 ==Headline==
17398 !! html/php
17399 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
17400 <ul>
17401 <li class="toclevel-1 tocsection-1"><a href="#Headline_2"><span class="tocnumber">1</span> <span class="toctext">Headline 2</span></a></li>
17402 <li class="toclevel-1 tocsection-2"><a href="#Headline"><span class="tocnumber">2</span> <span class="toctext">Headline</span></a></li>
17403 <li class="toclevel-1 tocsection-3"><a href="#Headline_2_2"><span class="tocnumber">3</span> <span class="toctext">Headline 2</span></a></li>
17404 <li class="toclevel-1 tocsection-4"><a href="#Headline_3"><span class="tocnumber">4</span> <span class="toctext">Headline</span></a></li>
17405 </ul>
17406 </div>
17407
17408 <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>
17409 <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>
17410 <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>
17411 <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>
17412
17413 !! end
17414
17415 # perl -e 'print "="x$_," Level $_ heading","="x$_,"\n" for 1..10'
17416 # Parsoid html2wt direction adds <nowiki> for level 7 and up.
17417 !! test
17418 Handling of sections up to level 6 and beyond
17419 !! options
17420 parsoid=wt2html
17421 !! wikitext
17422 =Level 1 Heading=
17423 ==Level 2 Heading==
17424 ===Level 3 Heading===
17425 ====Level 4 Heading====
17426 =====Level 5 Heading=====
17427 ======Level 6 Heading======
17428 =======Level 7 Heading=======
17429 ========Level 8 Heading========
17430 =========Level 9 Heading=========
17431 ==========Level 10 Heading==========
17432 !! html/php
17433 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
17434 <ul>
17435 <li class="toclevel-1 tocsection-1"><a href="#Level_1_Heading"><span class="tocnumber">1</span> <span class="toctext">Level 1 Heading</span></a>
17436 <ul>
17437 <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>
17438 <ul>
17439 <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>
17440 <ul>
17441 <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>
17442 <ul>
17443 <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>
17444 <ul>
17445 <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>
17446 <li class="toclevel-6 tocsection-7"><a href="#.3DLevel_7_Heading.3D"><span class="tocnumber">1.1.1.1.1.2</span> <span class="toctext">=Level 7 Heading=</span></a></li>
17447 <li class="toclevel-6 tocsection-8"><a href="#.3D.3DLevel_8_Heading.3D.3D"><span class="tocnumber">1.1.1.1.1.3</span> <span class="toctext">==Level 8 Heading==</span></a></li>
17448 <li class="toclevel-6 tocsection-9"><a href="#.3D.3D.3DLevel_9_Heading.3D.3D.3D"><span class="tocnumber">1.1.1.1.1.4</span> <span class="toctext">===Level 9 Heading===</span></a></li>
17449 <li class="toclevel-6 tocsection-10"><a href="#.3D.3D.3D.3DLevel_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>
17450 </ul>
17451 </li>
17452 </ul>
17453 </li>
17454 </ul>
17455 </li>
17456 </ul>
17457 </li>
17458 </ul>
17459 </li>
17460 </ul>
17461 </div>
17462
17463 <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>
17464 <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>
17465 <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>
17466 <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>
17467 <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>
17468 <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>
17469 <h6><span class="mw-headline" id=".3DLevel_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>
17470 <h6><span class="mw-headline" id=".3D.3DLevel_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>
17471 <h6><span class="mw-headline" id=".3D.3D.3DLevel_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>
17472 <h6><span class="mw-headline" id=".3D.3D.3D.3DLevel_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>
17473
17474 !! html/parsoid
17475 <h1 id="Level_1_Heading" data-parsoid='{}'>Level 1 Heading</h1>
17476 <h2 id="Level_2_Heading" data-parsoid='{}'>Level 2 Heading</h2>
17477 <h3 id="Level_3_Heading" data-parsoid='{}'>Level 3 Heading</h3>
17478 <h4 id="Level_4_Heading" data-parsoid='{}'>Level 4 Heading</h4>
17479 <h5 id="Level_5_Heading" data-parsoid='{}'>Level 5 Heading</h5>
17480 <h6 id="Level_6_Heading" data-parsoid='{}'>Level 6 Heading</h6>
17481 <h6 id="=Level_7_Heading=" data-parsoid='{}'><span id=".3DLevel_7_Heading.3D" typeof="mw:FallbackId"></span>=Level 7 Heading=</h6>
17482 <h6 id="==Level_8_Heading==" data-parsoid='{}'><span id=".3D.3DLevel_8_Heading.3D.3D" typeof="mw:FallbackId"></span>==Level 8 Heading==</h6>
17483 <h6 id="===Level_9_Heading===" data-parsoid='{}'><span id=".3D.3D.3DLevel_9_Heading.3D.3D.3D" typeof="mw:FallbackId"></span>===Level 9 Heading===</h6>
17484 <h6 id="====Level_10_Heading====" data-parsoid='{}'><span id=".3D.3D.3D.3DLevel_10_Heading.3D.3D.3D.3D" typeof="mw:FallbackId"></span>====Level 10 Heading====</h6>
17485 !! end
17486
17487 !! test
17488 TOC regression (T11764)
17489 !! wikitext
17490 ==title 1==
17491 ===title 1.1===
17492 ====title 1.1.1====
17493 ===title 1.2===
17494 ==title 2==
17495 ===title 2.1===
17496 !! html
17497 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
17498 <ul>
17499 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
17500 <ul>
17501 <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>
17502 <ul>
17503 <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>
17504 </ul>
17505 </li>
17506 <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>
17507 </ul>
17508 </li>
17509 <li class="toclevel-1 tocsection-5"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a>
17510 <ul>
17511 <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>
17512 </ul>
17513 </li>
17514 </ul>
17515 </div>
17516
17517 <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>
17518 <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>
17519 <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>
17520 <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>
17521 <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>
17522 <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>
17523
17524 !! end
17525
17526 !! test
17527 TOC for heading containing <span id="..."></span> (T96153)
17528 !! wikitext
17529 __FORCETOC__
17530 ==<span id="old-anchor"></span>New title==
17531 !! html/php
17532 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
17533 <ul>
17534 <li class="toclevel-1 tocsection-1"><a href="#New_title"><span class="tocnumber">1</span> <span class="toctext">New title</span></a></li>
17535 </ul>
17536 </div>
17537
17538 <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>
17539
17540 !! end
17541
17542 !! test
17543 TOC with wgMaxTocLevel=3 (T8204)
17544 !! options
17545 wgMaxTocLevel=3
17546 !! wikitext
17547 ==title 1==
17548 ===title 1.1===
17549 ====title 1.1.1====
17550 ===title 1.2===
17551 ==title 2==
17552 ===title 2.1===
17553 !! html
17554 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
17555 <ul>
17556 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
17557 <ul>
17558 <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>
17559 <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>
17560 </ul>
17561 </li>
17562 <li class="toclevel-1 tocsection-5"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a>
17563 <ul>
17564 <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>
17565 </ul>
17566 </li>
17567 </ul>
17568 </div>
17569
17570 <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>
17571 <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>
17572 <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>
17573 <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>
17574 <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>
17575 <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>
17576
17577 !! end
17578
17579 !! test
17580 TOC with wgMaxTocLevel=3 and two level four headings (T8204)
17581 !! options
17582 wgMaxTocLevel=3
17583 !! wikitext
17584 ==Section 1==
17585 ===Section 1.1===
17586 ====Section 1.1.1====
17587 ====Section 1.1.1.1====
17588 ==Section 2==
17589 !! html
17590 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
17591 <ul>
17592 <li class="toclevel-1 tocsection-1"><a href="#Section_1"><span class="tocnumber">1</span> <span class="toctext">Section 1</span></a>
17593 <ul>
17594 <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>
17595 </ul>
17596 </li>
17597 <li class="toclevel-1 tocsection-5"><a href="#Section_2"><span class="tocnumber">2</span> <span class="toctext">Section 2</span></a></li>
17598 </ul>
17599 </div>
17600
17601 <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>
17602 <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>
17603 <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>
17604 <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>
17605 <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>
17606
17607 !! end
17608
17609
17610 !! test
17611 Resolving duplicate section names
17612 !! wikitext
17613 ==Foo bar==
17614 ==Foo bar==
17615 !! html
17616 <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>
17617 <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>
17618
17619 !! end
17620
17621 !! test
17622 Resolving duplicate section names with differing case (T12721)
17623 !! wikitext
17624 ==Foo bar==
17625 ==Foo Bar==
17626 !! html
17627 <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>
17628 <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>
17629
17630 !! end
17631
17632 !! article
17633 Template:sections
17634 !! text
17635 ===Section 1===
17636 ==Section 2==
17637 !! endarticle
17638
17639 !! test
17640 Template with sections, __NOTOC__
17641 !! wikitext
17642 __NOTOC__
17643 ==Section 0==
17644 {{sections}}
17645 ==Section 4==
17646 !! html
17647 <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>
17648 <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>
17649 <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>
17650 <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>
17651
17652 !! end
17653
17654 !! test
17655 __NOEDITSECTION__ keyword
17656 !! wikitext
17657 __NOEDITSECTION__
17658 ==Section 1==
17659 ==Section 2==
17660 !! html
17661 <h2><span class="mw-headline" id="Section_1">Section 1</span></h2>
17662 <h2><span class="mw-headline" id="Section_2">Section 2</span></h2>
17663
17664 !! end
17665
17666 !! test
17667 Link inside a section heading
17668 !! wikitext
17669 ==Section with a [[Main Page|link]] in it==
17670 !! html
17671 <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>
17672
17673 !! end
17674
17675 !! test
17676 TOC regression (T14077)
17677 !! wikitext
17678 __TOC__
17679 ==title 1==
17680 ===title 1.1===
17681 ==title 2==
17682 !! html
17683 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
17684 <ul>
17685 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
17686 <ul>
17687 <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>
17688 </ul>
17689 </li>
17690 <li class="toclevel-1 tocsection-3"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a></li>
17691 </ul>
17692 </div>
17693
17694 <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>
17695 <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>
17696 <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>
17697
17698 !! end
17699
17700 !! test
17701 T3219 URL next to image (good)
17702 !! wikitext
17703 http://example.com [[File:Foobar.jpg]]
17704 !! html/php
17705 <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" decoding="async" width="1941" height="220" /></a>
17706 </p>
17707 !! html/parsoid
17708 <p><a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a> <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>
17709 !!end
17710
17711 # Parsoid doesn't wt2wt this cleanly because it adds <nowiki>s.
17712 !! test
17713 Short headings with trailing space should match behavior of Parser::doHeadings (T21910)
17714 !! options
17715 parsoid=wt2html,html2html
17716 !! wikitext
17717 ===
17718 The line above must have a trailing space!
17719 === <!--
17720 --> <!-- -->
17721 But just in case it doesn't...
17722 !! html/php
17723 <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>
17724 <p>The line above must have a trailing space!
17725 </p>
17726 <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>
17727 <p>But just in case it doesn't...
17728 </p>
17729 !! html/parsoid
17730 <h1 id="="><span id=".3D" typeof="mw:FallbackId"></span>=</h1>
17731 <p>The line above must have a trailing space!</p>
17732 <h1 id="=_2"><span id=".3D_2" typeof="mw:FallbackId"></span>=</h1> <!--
17733 --> <!-- -->
17734 <p>But just in case it doesn't...</p>
17735 !! end
17736
17737 !! test
17738 Header with special characters (T27462)
17739 !! wikitext
17740 The tooltips shall not show entities to the user (ie. be double escaped)
17741
17742 ==text > text==
17743 section 1
17744
17745 ==text < text==
17746 section 2
17747
17748 ==text & text==
17749 section 3
17750
17751 ==text ' text==
17752 section 4
17753
17754 ==text " text==
17755 section 5
17756 !! html/php
17757 <p>The tooltips shall not show entities to the user (ie. be double escaped)
17758 </p>
17759 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
17760 <ul>
17761 <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>
17762 <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>
17763 <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>
17764 <li class="toclevel-1 tocsection-4"><a href="#text_.27_text"><span class="tocnumber">4</span> <span class="toctext">text ' text</span></a></li>
17765 <li class="toclevel-1 tocsection-5"><a href="#text_.22_text"><span class="tocnumber">5</span> <span class="toctext">text " text</span></a></li>
17766 </ul>
17767 </div>
17768
17769 <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>
17770 <p>section 1
17771 </p>
17772 <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>
17773 <p>section 2
17774 </p>
17775 <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>
17776 <p>section 3
17777 </p>
17778 <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 &#039; text">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
17779 <p>section 4
17780 </p>
17781 <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>
17782 <p>section 5
17783 </p>
17784 !! html/parsoid
17785 <p>The tooltips shall not show entities to the user (ie. be double escaped)</p>
17786
17787 <h2 id="text_>_text"><span id="text_.3E_text" typeof="mw:FallbackId"></span>text > text</h2>
17788 <p>section 1</p>
17789
17790 <h2 id="text_&lt;_text"><span id="text_.3C_text" typeof="mw:FallbackId"></span>text &lt; text</h2>
17791 <p>section 2</p>
17792
17793 <h2 id="text_&amp;_text"><span id="text_.26_text" typeof="mw:FallbackId"></span>text &amp; text</h2>
17794 <p>section 3</p>
17795
17796 <h2 id="text_'_text"><span id="text_.27_text" typeof="mw:FallbackId"></span>text ' text</h2>
17797 <p>section 4</p>
17798
17799 <h2 id='text_"_text'><span id="text_.22_text" typeof="mw:FallbackId"></span>text " text</h2>
17800 <p>section 5</p>
17801 !! end
17802
17803 !! test
17804 Header with space, plus and underscore as entity
17805 !! wikitext
17806 Id should not contain + for spaces
17807
17808 ==Space between Text==
17809 section 1
17810
17811 ==Space-Entity&#32;between&#32;Text==
17812 section 2
17813
17814 ==Plus+between+Text==
17815 section 3
17816
17817 ==Plus-Entity&#43;between&#43;Text==
17818 section 4
17819
17820 ==Underscore_between_Text==
17821 section 5
17822
17823 ==Underscore-Entity&#95;between&#95;Text==
17824 section 6
17825
17826 [[#Space between Text]]
17827 [[#Space-Entity&#32;between&#32;Text]]
17828 [[#Plus+between+Text]]
17829 [[#Plus-Entity&#43;between&#43;Text]]
17830 [[#Underscore_between_Text]]
17831 [[#Underscore-Entity&#95;between&#95;Text]]
17832 !! html/php
17833 <p>Id should not contain + for spaces
17834 </p>
17835 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
17836 <ul>
17837 <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>
17838 <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>
17839 <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>
17840 <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>
17841 <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>
17842 <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>
17843 </ul>
17844 </div>
17845
17846 <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>
17847 <p>section 1
17848 </p>
17849 <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>
17850 <p>section 2
17851 </p>
17852 <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>
17853 <p>section 3
17854 </p>
17855 <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>
17856 <p>section 4
17857 </p>
17858 <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>
17859 <p>section 5
17860 </p>
17861 <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>
17862 <p>section 6
17863 </p><p><a href="#Space_between_Text">#Space between Text</a>
17864 <a href="#Space-Entity_between_Text">#Space-Entity&#32;between&#32;Text</a>
17865 <a href="#Plus.2Bbetween.2BText">#Plus+between+Text</a>
17866 <a href="#Plus-Entity.2Bbetween.2BText">#Plus-Entity&#43;between&#43;Text</a>
17867 <a href="#Underscore_between_Text">#Underscore_between_Text</a>
17868 <a href="#Underscore-Entity_between_Text">#Underscore-Entity&#95;between&#95;Text</a>
17869 </p>
17870 !! html/parsoid
17871 <p>Id should not contain + for spaces</p>
17872
17873 <h2 id="Space_between_Text">Space between Text</h2>
17874 <p>section 1</p>
17875
17876 <h2 id="Space-Entity_between_Text">Space-Entity<span typeof="mw:Entity" data-parsoid='{"src":"&amp;#32;","srcContent":" "}'> </span>between<span typeof="mw:Entity" data-parsoid='{"src":"&amp;#32;","srcContent":" "}'> </span>Text</h2>
17877 <p>section 2</p>
17878
17879 <h2 id="Plus+between+Text"><span id="Plus.2Bbetween.2BText" typeof="mw:FallbackId"></span>Plus+between+Text</h2>
17880 <p>section 3</p>
17881
17882 <h2 id="Plus-Entity+between+Text"><span id="Plus-Entity.2Bbetween.2BText" typeof="mw:FallbackId"></span>Plus-Entity<span typeof="mw:Entity" data-parsoid='{"src":"&amp;#43;","srcContent":"+"}'>+</span>between<span typeof="mw:Entity" data-parsoid='{"src":"&amp;#43;","srcContent":"+"}'>+</span>Text</h2>
17883 <p>section 4</p>
17884
17885 <h2 id="Underscore_between_Text">Underscore_between_Text</h2>
17886 <p>section 5</p>
17887
17888 <h2 id="Underscore-Entity_between_Text">Underscore-Entity<span typeof="mw:Entity" data-parsoid='{"src":"&amp;#95;","srcContent":"_"}'>_</span>between<span typeof="mw:Entity" data-parsoid='{"src":"&amp;#95;","srcContent":"_"}'>_</span>Text</h2>
17889 <p>section 6</p>
17890
17891 <p><a rel="mw:WikiLink" href="./Parser_test#Space_between_Text" data-parsoid='{"stx":"simple","a":{"href":"./Parser_test#Space_between_Text"},"sa":{"href":"#Space between Text"}}'>#Space between Text</a>
17892 <a rel="mw:WikiLink" href="./Parser_test#Space-Entity_between_Text" data-parsoid='{"stx":"simple","a":{"href":"./Parser_test#Space-Entity_between_Text"},"sa":{"href":"#Space-Entity&amp;#32;between&amp;#32;Text"}}'>#Space-Entity between Text</a>
17893 <a rel="mw:WikiLink" href="./Parser_test#Plus+between+Text" data-parsoid='{"stx":"simple","a":{"href":"./Parser_test#Plus+between+Text"},"sa":{"href":"#Plus+between+Text"}}'>#Plus+between+Text</a>
17894 <a rel="mw:WikiLink" href="./Parser_test#Plus-Entity+between+Text" data-parsoid='{"stx":"simple","a":{"href":"./Parser_test#Plus-Entity+between+Text"},"sa":{"href":"#Plus-Entity&amp;#43;between&amp;#43;Text"}}'>#Plus-Entity+between+Text</a>
17895 <a rel="mw:WikiLink" href="./Parser_test#Underscore_between_Text" data-parsoid='{"stx":"simple","a":{"href":"./Parser_test#Underscore_between_Text"},"sa":{"href":"#Underscore_between_Text"}}'>#Underscore_between_Text</a>
17896 <a rel="mw:WikiLink" href="./Parser_test#Underscore-Entity_between_Text" data-parsoid='{"stx":"simple","a":{"href":"./Parser_test#Underscore-Entity_between_Text"},"sa":{"href":"#Underscore-Entity&amp;#95;between&amp;#95;Text"}}'>#Underscore-Entity_between_Text</a></p>
17897 !! end
17898
17899 # Parsoid html2wt disabled because it adds padding spaces around =
17900 !! test
17901 Headers with excess '=' characters
17902 (Are similar tests necessary beyond the 1st level?)
17903 !! options
17904 parsoid=wt2html,wt2wt,html2html
17905 !! wikitext
17906 =foo==
17907 ==foo=
17908 =''italic'' heading==
17909 ==''italic'' heading=
17910 !! html/php
17911 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
17912 <ul>
17913 <li class="toclevel-1 tocsection-1"><a href="#foo.3D"><span class="tocnumber">1</span> <span class="toctext">foo=</span></a></li>
17914 <li class="toclevel-1 tocsection-2"><a href="#.3Dfoo"><span class="tocnumber">2</span> <span class="toctext">=foo</span></a></li>
17915 <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>
17916 <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>
17917 </ul>
17918 </div>
17919
17920 <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>
17921 <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>
17922 <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>
17923 <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>
17924
17925 !! html/parsoid
17926 <h1 id="foo="><span id="foo.3D" typeof="mw:FallbackId"></span>foo=</h1>
17927 <h1 id="=foo"><span id=".3Dfoo" typeof="mw:FallbackId"></span>=foo</h1>
17928 <h1 id="italic_heading="><span id="italic_heading.3D" typeof="mw:FallbackId"></span><i>italic</i> heading=</h1>
17929 <h1 id="=italic_heading"><span id=".3Ditalic_heading" typeof="mw:FallbackId"></span>=<i>italic</i> heading</h1>
17930 !! end
17931
17932 !! test
17933 HTML headers vs TOC (T25393)
17934 (__NOEDITSECTION__ for clearer output, doesn't matter here)
17935 !! wikitext
17936 <h1>Header 1</h1>
17937 ==Header 1.1==
17938 ==Header 1.2==
17939
17940 <h1>Header 2
17941 </h1>
17942 ==Header 2.1==
17943 ==Header 2.2==
17944 __NOEDITSECTION__
17945 !! html/php
17946 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
17947 <ul>
17948 <li class="toclevel-1"><a href="#Header_1"><span class="tocnumber">1</span> <span class="toctext">Header 1</span></a>
17949 <ul>
17950 <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>
17951 <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>
17952 </ul>
17953 </li>
17954 <li class="toclevel-1"><a href="#Header_2"><span class="tocnumber">2</span> <span class="toctext">Header 2</span></a>
17955 <ul>
17956 <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>
17957 <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>
17958 </ul>
17959 </li>
17960 </ul>
17961 </div>
17962
17963 <h1><span class="mw-headline" id="Header_1">Header 1</span></h1>
17964 <h2><span class="mw-headline" id="Header_1.1">Header 1.1</span></h2>
17965 <h2><span class="mw-headline" id="Header_1.2">Header 1.2</span></h2>
17966 <h1><span class="mw-headline" id="Header_2">Header 2
17967 </span></h1>
17968 <h2><span class="mw-headline" id="Header_2.1">Header 2.1</span></h2>
17969 <h2><span class="mw-headline" id="Header_2.2">Header 2.2</span></h2>
17970
17971 !! html/parsoid
17972 <h1 id="Header_1" data-parsoid='{"stx":"html"}'>Header 1</h1>
17973 <h2 id="Header_1.1" data-parsoid='{}'>Header 1.1</h2>
17974 <h2 id="Header_1.2" data-parsoid='{}'>Header 1.2</h2>
17975
17976 <h1 id="Header_2" data-parsoid='{"stx":"html"}'>Header 2
17977 </h1>
17978 <h2 id="Header_2.1" data-parsoid='{}'>Header 2.1</h2>
17979 <h2 id="Header_2.2" data-parsoid='{}'>Header 2.2</h2>
17980 <meta property="mw:PageProp/noeditsection"/>
17981 !! end
17982
17983 !! test
17984 Single-line or multiline-comments can follow headings
17985 !! options
17986 parsoid=wt2html,wt2wt
17987 !! wikitext
17988 ==foo==<!---->
17989 ==bar==<!--c1-->
17990 ==baz==<!--
17991 c2
17992 c3-->
17993 !! html/php
17994 <h2><span class="mw-headline" id="foo">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></h2>
17995 <h2><span class="mw-headline" id="bar">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: bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
17996 <h2><span class="mw-headline" id="baz">baz</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: baz">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
17997
17998 !! html/parsoid
17999 <h2 id="foo">foo</h2><!---->
18000 <h2 id="bar">bar</h2><!--c1-->
18001 <h2 id="baz">baz</h2><!--
18002 c2
18003 c3-->
18004 !! end
18005
18006 !! test
18007 T3219 URL next to image (broken)
18008 !! wikitext
18009 http://example.com[[File:Foobar.jpg]]
18010 !! html/php
18011 <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" decoding="async" width="1941" height="220" /></a>
18012 </p>
18013 !! html/parsoid
18014 <p><a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a><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>
18015 !!end
18016
18017 !! test
18018 T3186 news: in the middle of text
18019 !! wikitext
18020 http://en.wikinews.org/wiki/Wikinews:Workplace
18021 !! html
18022 <p><a rel="nofollow" class="external free" href="http://en.wikinews.org/wiki/Wikinews:Workplace">http://en.wikinews.org/wiki/Wikinews:Workplace</a>
18023 </p>
18024 !!end
18025
18026
18027 !! test
18028 Namespaced link must have a title
18029 !! wikitext
18030 [[Project:]]
18031 !! html
18032 <p>[[Project:]]
18033 </p>
18034 !!end
18035
18036 !! test
18037 Namespaced link must have a title (bad fragment version)
18038 !! wikitext
18039 [[Project:#fragment]]
18040 !! html
18041 <p>[[Project:#fragment]]
18042 </p>
18043 !!end
18044
18045
18046 ###
18047 ### HTML tags and HTML attributes
18048 ###
18049
18050 !! test
18051 div with no attributes
18052 !! wikitext
18053 <div>HTML rocks</div>
18054 !! html
18055 <div>HTML rocks</div>
18056
18057 !! end
18058
18059 !! test
18060 div with double-quoted attribute
18061 !! wikitext
18062 <div id="rock">HTML rocks</div>
18063 !! html
18064 <div id="rock">HTML rocks</div>
18065
18066 !! end
18067
18068 !! test
18069 div with single-quoted attribute
18070 !! wikitext
18071 <div id='rock'>HTML rocks</div>
18072 !! html
18073 <div id="rock">HTML rocks</div>
18074
18075 !! end
18076
18077 !! test
18078 div with unquoted attribute
18079 !! wikitext
18080 <div id=rock>HTML rocks</div>
18081 !! html
18082 <div id="rock">HTML rocks</div>
18083
18084 !! end
18085
18086 !! test
18087 div with illegal double attributes
18088 !! wikitext
18089 <div id="a" id="b">HTML rocks</div>
18090 !! html
18091 <div id="b">HTML rocks</div>
18092
18093 !!end
18094
18095 !! test
18096 div with empty attribute value, space before equals
18097 !! options
18098 parsoid=wt2html,html2html
18099 !! wikitext
18100 <div class =>HTML rocks</div>
18101 !! html/php
18102 <div class="">HTML rocks</div>
18103
18104 !! html/parsoid
18105 <div class="" data-parsoid='{"stx":"html"}'>HTML rocks</div>
18106 !! end
18107
18108 !! test
18109 div with multiple empty attribute values
18110 !! config
18111 wgFragmentMode=[ 'html5', 'legacy' ]
18112 !! options
18113 parsoid=wt2html,html2html
18114 !! wikitext
18115 <div id= title=>HTML rocks</div>
18116 !! html/php
18117 <div id="title=">HTML rocks</div>
18118
18119 !! html/parsoid
18120 <div id="title=" data-parsoid='{"stx":"html"}'>HTML rocks</div>
18121 !! end
18122
18123 # FIXME Parsoid doesn't actually match PHP here.
18124 !! test
18125 Extension tag in attribute value
18126 !! options
18127 wgRawHtml=1
18128 !! wikitext
18129 <span title="<html><div>123</div></html>">ok</span>
18130 !! html/php+tidy
18131 <p><span title="&lt;div&gt;123&lt;/div&gt;">ok</span>
18132 </p>
18133 !! html/parsoid
18134 <p><span title="123" about="#mwt4" typeof="mw:ExpandedAttrs" data-parsoid='{"stx":"html","a":{"title":"123"},"sa":{"title":"&lt;html>&lt;div>123&lt;/div>&lt;/html>"}}' data-mw='{"attribs":[[{"txt":"title"},{"html":"&lt;div typeof=\"mw:Extension/html\" about=\"#mwt3\" data-parsoid=&apos;{\"dsr\":[13,40,2,2]}&apos; data-mw=&apos;{\"name\":\"html\",\"attrs\":{},\"body\":{\"extsrc\":\"&amp;lt;div>123&amp;lt;/div>\"}}&apos;>123&lt;/div>"}]]}'>ok</span></p>
18135 !! end
18136
18137 !! test
18138 table with multiple empty attribute values
18139 !! options
18140 parsoid=wt2html,html2html
18141 !! wikitext
18142 {| title= id=
18143 |hi
18144 |}
18145 !! html/php
18146 <table title="id=">
18147 <tr>
18148 <td>hi
18149 </td></tr></table>
18150
18151 !! html/parsoid
18152 <table title="id=">
18153 <tbody><tr><td>hi</td></tr>
18154 </tbody></table>
18155 !! end
18156
18157 !! test
18158 div with braces in attribute value
18159 !! wikitext
18160 <div title="{}">Foo</div>
18161 !! html/php
18162 <div title="&#123;&#125;">Foo</div>
18163
18164 !! html/parsoid
18165 <div title="{}">Foo</div>
18166 !! end
18167
18168 !! test
18169 div with empty attribute value, no space before equals
18170 !! options
18171 parsoid=wt2html,html2html
18172 !! wikitext
18173 <div class=>HTML rocks</div>
18174 !! html/php
18175 <div class="">HTML rocks</div>
18176
18177 !! html/parsoid
18178 <div class="">HTML rocks</div>
18179 !! end
18180
18181 !! test
18182 HTML multiple attributes correction
18183 !! wikitext
18184 <p class="error" class="awesome">Awesome!</p>
18185 !! html
18186 <p class="awesome">Awesome!</p>
18187
18188 !!end
18189
18190 !! test
18191 Table multiple attributes correction
18192 !! wikitext
18193 {|
18194 !+ class="error" class="awesome"|status
18195 |}
18196 !! html
18197 <table>
18198 <tr>
18199 <th class="awesome">status
18200 </th></tr></table>
18201
18202 !!end
18203
18204 !! test
18205 DIV IN UPPERCASE
18206 !! wikitext
18207 <DIV ID="x">HTML ROCKS</DIV>
18208 !! html
18209 <div id="x">HTML ROCKS</div>
18210
18211 !!end
18212
18213 !! test
18214 Non-ASCII pseudo-tags are rendered as text
18215 !! wikitext
18216 <khyô>
18217 !! html
18218 <p>&lt;khyô&gt;
18219 </p>
18220 !! end
18221
18222 !! test
18223 Pseudo-tag with URL 'name' renders as url link
18224 !! wikitext
18225 <http://example.com/>
18226 !! html
18227 <p>&lt;<a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a>&gt;
18228 </p>
18229 !! end
18230
18231 !! test
18232 text with amp in the middle of nowhere
18233 !! wikitext
18234 Remember AT&T?
18235 !! html
18236 <p>Remember AT&amp;T?
18237 </p>
18238 !! end
18239
18240 !! test
18241 text with character entity: eacute
18242 !! wikitext
18243 I always thought &eacute; was a cute letter.
18244 !! html+tidy
18245 <p>I always thought &#233; was a cute letter.
18246 </p>
18247 !! end
18248
18249 !! test
18250 text with entity-escaped character entity-like string: eacute
18251 !! wikitext
18252 I always thought &amp;eacute; was a cute letter.
18253 !! html
18254 <p>I always thought &amp;eacute; was a cute letter.
18255 </p>
18256 !! end
18257
18258 !! test
18259 text with undefined character entity: xacute
18260 !! wikitext
18261 I always thought &xacute; was a cute letter.
18262 !! html
18263 <p>I always thought &amp;xacute; was a cute letter.
18264 </p>
18265 !! end
18266
18267 !! test
18268 HTML5 tags
18269 !! wikitext
18270 <data value="5">five</data>
18271 <time datetime="2000-01-01T00:00Z">The new millenium started</time>
18272 <mark>This highlighted text</mark>
18273 !! html
18274 <p><data value="5">five</data>
18275 <time datetime="2000-01-01T00:00Z">The new millenium started</time>
18276 <mark>This highlighted text</mark>
18277 </p>
18278 !! end
18279
18280 !! test
18281 HTML tag with leading space is parsed as text
18282 !! wikitext
18283 < div>foo< /div>
18284 !! html
18285 <p>&lt; div&gt;foo&lt; /div&gt;
18286 </p>
18287 !! end
18288
18289 ## FIXME: The untrimmed attribute in Parsoid is T205737
18290 !! test
18291 Element with broken attribute syntax
18292 !! options
18293 parsoid=wt2html
18294 !! wikitext
18295 <div style=" style="123">hi</div>
18296 <div =>ho</div>
18297 !! html/php
18298 <div style="style=">hi</div>
18299 <div>ho</div>
18300
18301 !! html/parsoid
18302 <div style=" style=" data-parsoid='{"stx":"html","a":{"123\"":null},"sa":{"123\"":""}}'>hi</div>
18303 <div data-parsoid='{"stx":"html","a":{"=":null},"sa":{"=":""}}'>ho</div>
18304 !! end
18305
18306 ###
18307 ### Nesting tests (see T43545, T52604, T53081)
18308 ###
18309
18310 # This test case is fixed in Parsoid by domino 1.0.12. (T52604)
18311 # Note that html2wt is considerably more difficult if we use <b> in
18312 # the test case, instead of <small>
18313 !! test
18314 Ensure that HTML adoption agency algorithm is properly implemented.
18315 !! wikitext
18316 <small>X<small>Y</small>Z</small>
18317 !! html
18318 <p><small>X<small>Y</small>Z</small>
18319 </p>
18320 !! end
18321
18322 # This was T43545 in the PHP parser.
18323 !! test
18324 Nesting of <kbd>
18325 !! wikitext
18326 <kbd>X<kbd>Y</kbd>Z</kbd>
18327 !! html+tidy
18328 <p><kbd>X<kbd>Y</kbd>Z</kbd>
18329 </p>
18330 !! end
18331
18332 # The following cases were T53081 in the PHP parser.
18333 # Note that there are some other nestable tags (b, i, etc) which are
18334 # not covered; see T53081 for discussion.
18335
18336 !! test
18337 Nesting of <em>
18338 !! wikitext
18339 <em>X<em>Y</em>Z</em>
18340 !! html+tidy
18341 <p><em>X<em>Y</em>Z</em>
18342 </p>
18343 !! end
18344
18345 !! test
18346 Nesting of <strong>
18347 !! wikitext
18348 <strong>X<strong>Y</strong>Z</strong>
18349 !! html+tidy
18350 <p><strong>X<strong>Y</strong>Z</strong>
18351 </p>
18352 !! end
18353
18354 !! test
18355 Nesting of <q>
18356 !! wikitext
18357 <q>X<q>Y</q>Z</q>
18358 !! html+tidy
18359 <p><q>X<q>Y</q>Z</q>
18360 </p>
18361 !! end
18362
18363 !! test
18364 Nesting of <ruby>
18365 !! wikitext
18366 <ruby>X<ruby>Y</ruby>Z</ruby>
18367 !! html
18368 <p><ruby>X<ruby>Y</ruby>Z</ruby>
18369 </p>
18370 !! end
18371
18372 !! test
18373 Nesting of <bdo>
18374 !! wikitext
18375 <bdo>X<bdo>Y</bdo>Z</bdo>
18376 !! html
18377 <p><bdo>X<bdo>Y</bdo>Z</bdo>
18378 </p>
18379 !! end
18380
18381
18382 ###
18383 ### Media links
18384 ###
18385
18386 !! test
18387 Media link
18388 !! wikitext
18389 [[Media:Foobar.jpg]]
18390 [[Media:Video.ogv]]
18391 [[:Media:Video.ogv]]
18392 !! html/php
18393 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Media:Foobar.jpg</a>
18394 <a href="http://example.com/images/0/00/Video.ogv" class="internal" title="Video.ogv">Media:Video.ogv</a>
18395 <a href="http://example.com/images/0/00/Video.ogv" class="internal" title="Video.ogv">Media:Video.ogv</a>
18396 </p>
18397 !! html/parsoid
18398 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" resource="./Media:Foobar.jpg" title="Foobar.jpg">Media:Foobar.jpg</a>
18399 <a rel="mw:MediaLink" href="//example.com/images/0/00/Video.ogv" resource="./Media:Video.ogv" title="Video.ogv">Media:Video.ogv</a>
18400 <a rel="mw:MediaLink" href="//example.com/images/0/00/Video.ogv" resource="./Media:Video.ogv" title="Video.ogv" data-parsoid='{"a":{"resource":"./Media:Video.ogv"},"sa":{"resource":":Media:Video.ogv"}}'>Media:Video.ogv</a></p>
18401 !! end
18402
18403 !! test
18404 Media link with text
18405 !! wikitext
18406 [[Media:Foobar.jpg|A neat file to look at]]
18407 !! html/php
18408 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">A neat file to look at</a>
18409 </p>
18410 !! html/parsoid
18411 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" resource="./Media:Foobar.jpg" title="Foobar.jpg">A neat file to look at</a></p>
18412 !! end
18413
18414 !! test
18415 Localized media link
18416 !! options
18417 language=is
18418 !! wikitext
18419 [[Miðill:Foobar.jpg]]
18420
18421 [[Miðill:Foobar.jpg|Icelandic]]
18422 !! html/php
18423 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Miðill:Foobar.jpg</a>
18424 </p><p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Icelandic</a>
18425 </p>
18426 !! html/parsoid
18427 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" resource="./Miðill:Foobar.jpg" title="Foobar.jpg">Miðill:Foobar.jpg</a></p>
18428 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" resource="./Miðill:Foobar.jpg" title="Foobar.jpg">Icelandic</a></p>
18429 !! end
18430
18431 # FIXME: this is still bad HTML tag nesting
18432 # FIXME: doBlockLevels won't wrap this in a paragraph because it contains a div
18433 # Parsoid & Remex fix the p-wrapping since they operate on the DOM.
18434 !! test
18435 Media link with nasty text
18436 !! options
18437 parsoid=wt2html,html2html
18438 !! wikitext
18439 [[Media:Foobar.jpg|Safe Link<div style=display:none>" onmouseover="alert(document.cookie)" onfoo="</div>]]
18440 !! html/php
18441 <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>
18442
18443 !! html/php+tidy
18444 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Safe Link</a></p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg"><div style="display:none">" onmouseover="alert(document.cookie)" onfoo="</div></a>
18445 !! html/parsoid
18446 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" resource="./Media:Foobar.jpg" title="Foobar.jpg">Safe Link</a></p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" resource="./Media:Foobar.jpg" title="Foobar.jpg"><div style="display:none" data-parsoid='{"stx":"html"}'>" onmouseover="alert(document.cookie)" onfoo="</div></a>
18447 !! end
18448
18449 !! test
18450 Media link from missing resource (parsoid-only)
18451 !! options
18452 parsoid=html2wt
18453 !! html/parsoid
18454 <a rel="mw:MediaLink" href="http://example.com/images/3/3a/Foobar.jpg">Bat!</a>
18455 !! wikitext
18456 [[Media:Foobar.jpg|Bat!]]
18457 !! end
18458
18459 !! test
18460 Media link from missing resource, localized (parsoid-only)
18461 !! options
18462 parsoid=html2wt
18463 language=is
18464 !! html/parsoid
18465 <a rel="mw:MediaLink" href="http://example.com/images/3/3a/Foobar.jpg">Bat!</a>
18466 !! wikitext
18467 [[Miðill:Foobar.jpg|Bat!]]
18468 !! end
18469
18470 # This is a sanity test to ensure we don't crash or choke when given
18471 # old cached 1.7.0 HTML for media links; we don't require that the
18472 # result be "valid" because wt2wt was completely broken in 1.7.0
18473 !! test
18474 Media link from old 1.7.0 DOM spec (crash test, parsoid-only) T198511
18475 !! options
18476 parsoid=html2wt
18477 !! html/parsoid
18478 <p>This is what Parsoid would emit (and we still handle this HTML fine):</p>
18479 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg">A neat file to look at</a></p>
18480 <p>But VisualEditor would mangle the rel attribute, and give us back this:</p>
18481 <p><a rel="mw:ExtLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg">A neat file to look at</a></p>
18482 <p>But at least we don't crash when trying to handle the mangled HTML!</p>
18483 !! wikitext
18484 This is what Parsoid would emit (and we still handle this HTML fine):
18485
18486 [[Media:Foobar.jpg|A neat file to look at]]
18487
18488 But VisualEditor would mangle the rel attribute, and give us back this:
18489
18490 [//example.com/images/3/3a/Foobar.jpg A neat file to look at]
18491
18492 But at least we don't crash when trying to handle the mangled HTML!
18493 !! end
18494
18495 !! test
18496 Media link to nonexistent file (T3702)
18497 !! wikitext
18498 [[Media:No such.jpg]]
18499 [[Media:No_such file.jpg]]
18500 !! html/php
18501 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=No_such.jpg" class="new" title="No such.jpg">Media:No such.jpg</a>
18502 <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>
18503 </p>
18504 !! html/parsoid
18505 <p><a rel="mw:MediaLink" href="./Special:FilePath/No_such.jpg" resource="./Media: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":{"resource":"./Media:No_such.jpg"},"sa":{"resource":"Media:No such.jpg"}}'>Media:No such.jpg</a>
18506 <a rel="mw:MediaLink" href="./Special:FilePath/No_such_file.jpg" resource="./Media: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":{"resource":"./Media:No_such_file.jpg"},"sa":{"resource":"Media:No_such file.jpg"}}'>Media:No_such file.jpg</a></p>
18507 !! end
18508
18509 !! test
18510 Image link to nonexistent file (T3850 - good)
18511 !! wikitext
18512 [[File:No_such.jpg]]
18513 !! html/php
18514 <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>
18515 </p>
18516 !! html/parsoid
18517 <p><figure-inline 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></figure-inline></p>
18518 !! end
18519
18520 !! test
18521 :Image link to nonexistent file (T3850 - bad)
18522 !! wikitext
18523 [[:Image:No such.jpg]]
18524 !! html/php
18525 <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>
18526 </p>
18527 !! html/parsoid
18528 <p><a rel="mw:WikiLink" href="./File:No_such.jpg" title="File:No such.jpg">Image:No such.jpg</a></p>
18529 !! end
18530
18531 !! test
18532 Character reference normalization in link text (T3938)
18533 !! wikitext
18534 [[Main Page|this&that]]
18535 !! html
18536 <p><a href="/wiki/Main_Page" title="Main Page">this&amp;that</a>
18537 </p>
18538 !!end
18539
18540 !! article
18541 אַ
18542 !! text
18543 Test for unicode normalization
18544
18545 The page's name is U+05d0 U+05b7, with non-canonical form U+FB2E
18546 !! endarticle
18547
18548 !! test
18549 (T21451) Links should refer to the normalized form.
18550 !! wikitext
18551 [[&#xFB2E;]]
18552 [[&#x5d0;&#x5b7;]]
18553 [[&#x5d0;ַ]]
18554 [[א&#x5b7;]]
18555 [[אַ]]
18556 !! html
18557 <p><a href="/wiki/%D7%90%D6%B7" title="אַ">&#xfb2e;</a>
18558 <a href="/wiki/%D7%90%D6%B7" title="אַ">&#x5d0;&#x5b7;</a>
18559 <a href="/wiki/%D7%90%D6%B7" title="אַ">&#x5d0;ַ</a>
18560 <a href="/wiki/%D7%90%D6%B7" title="אַ">א&#x5b7;</a>
18561 <a href="/wiki/%D7%90%D6%B7" title="אַ">אַ</a>
18562 </p>
18563 !! end
18564
18565 !! test
18566 Empty attribute crash test (T4067)
18567 !! wikitext
18568 <font color="">foo</font>
18569 !! html
18570 <p><font color="">foo</font>
18571 </p>
18572 !! end
18573
18574 !! test
18575 Empty attribute crash test single-quotes (T4067)
18576 !! wikitext
18577 <font color=''>foo</font>
18578 !! html
18579 <p><font color="">foo</font>
18580 </p>
18581 !! end
18582
18583 !! test
18584 Attribute test: equals, then nothing
18585 !! options
18586 parsoid=wt2html,html2html
18587 !! wikitext
18588 <font color=>foo</font>
18589 !! html/php
18590 <p><font color="">foo</font>
18591 </p>
18592 !! html/parsoid
18593 <p><font color="" data-parsoid='{"stx":"html"}'>foo</font></p>
18594 !! end
18595
18596 !! test
18597 Attribute test: unquoted value
18598 !! options
18599 parsoid=wt2html,html2html
18600 !! wikitext
18601 <font color=x>foo</font>
18602 !! html/php
18603 <p><font color="x">foo</font>
18604 </p>
18605 !! html/parsoid
18606 <p><font color="x" data-parsoid='{"stx":"html"}'>foo</font></p>
18607 !! end
18608
18609 !! test
18610 Attribute test: unquoted but illegal value (hash)
18611 !! wikitext
18612 <font color=#x>foo</font>
18613 !! html
18614 <p><font color="#x">foo</font>
18615 </p>
18616 !! end
18617
18618 # Parsoid does not serialize to empty attribute syntax,
18619 # so wt2wt and html2wt cases are skipped
18620 !! test
18621 Attribute test: no value (T54330)
18622 !! options
18623 parsoid=wt2html,html2html
18624 !! wikitext
18625 <font color>foo</font>
18626 !! html/php
18627 <p><font color="">foo</font>
18628 </p>
18629 !! html/parsoid
18630 <p><font color="">foo</font></p>
18631 !! end
18632
18633 !! test
18634 T4095: link with three closing brackets
18635 !! wikitext
18636 [[Main Page]]]
18637 !! html/php
18638 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>]
18639 </p>
18640 !! html/parsoid
18641 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a>]</p>
18642 !! end
18643
18644 !! test
18645 T4095: link with pipe and three closing brackets
18646 !! wikitext
18647 [[Main Page|link]]]
18648 !! html/php
18649 <p><a href="/wiki/Main_Page" title="Main Page">link</a>]
18650 </p>
18651 !! html/parsoid
18652 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">link</a>]</p>
18653 !! end
18654
18655 !! test
18656 T4095: link with pipe and three closing brackets, version 2
18657 !! wikitext
18658 [[Main Page|[http://example.com/]]]
18659 !! html/php
18660 <p><a href="/wiki/Main_Page" title="Main Page">[http://example.com/]</a>
18661 </p>
18662 !! html/parsoid
18663 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">[http://example.com/]</a></p>
18664 !! end
18665
18666
18667 ###
18668 ### Safety
18669 ###
18670
18671 !! article
18672 Template:Dangerous attribute
18673 !! text
18674 " onmouseover="alert(document.cookie)
18675 !! endarticle
18676
18677 !! article
18678 Template:Dangerous style attribute
18679 !! text
18680 border-size: expression(alert(document.cookie))
18681 !! endarticle
18682
18683 !! article
18684 Template:Div style
18685 !! text
18686 <div style="float: right; {{{1}}}">Magic div</div>
18687 !! endarticle
18688
18689 !! test
18690 T4304: HTML attribute safety (safe template; regression T4309)
18691 !! wikitext
18692 <div title="{{test}}"></div>
18693 !! html/php
18694 <div title="This is a test template"></div>
18695
18696 !! html/parsoid
18697 <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>
18698 !! end
18699
18700 # Parsoid has enough context to handle this case
18701 !! test
18702 T4304: HTML attribute safety (dangerous template; 2309)
18703 !! wikitext
18704 <div title="{{dangerous attribute}}"></div>
18705 !! html/php
18706 <div title=""></div>
18707
18708 !! html/parsoid
18709 <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>
18710 !! end
18711
18712 !! test
18713 T4304: HTML attribute safety (dangerous style template; 2309)
18714 !! wikitext
18715 <div style="{{dangerous style attribute}}"></div>
18716 !! html/php
18717 <div style="/* insecure input */"></div>
18718
18719 !! html/parsoid
18720 <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>
18721 !! end
18722
18723 !! test
18724 T4304: HTML attribute safety (safe parameter; 2309)
18725 !! wikitext
18726 {{div style|width: 200px}}
18727 !! html/php
18728 <div style="float: right; width: 200px">Magic div</div>
18729
18730 !! html/parsoid
18731 <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>
18732 !! end
18733
18734 !! test
18735 T4304: HTML attribute safety (unsafe parameter; 2309)
18736 !! wikitext
18737 {{div style|width: expression(alert(document.cookie))}}
18738 !! html/php
18739 <div style="/* insecure input */">Magic div</div>
18740
18741 !! html/parsoid
18742 <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>
18743 !! end
18744
18745 ## Parsoid output here differs; needs investigation.
18746 !! test
18747 T4304: HTML attribute safety (unsafe breakout parameter; 2309)
18748 !! wikitext
18749 {{div style|"><script>alert(document.cookie)</script>}}
18750 !! html
18751 <div style="float: right;">&lt;script&gt;alert(document.cookie)&lt;/script&gt;"&gt;Magic div</div>
18752
18753 !! end
18754
18755 ## Parsoid output here differs; needs investigation.
18756 !! test
18757 T4304: HTML attribute safety (unsafe breakout parameter 2; 2309)
18758 !! wikitext
18759 {{div style|" ><script>alert(document.cookie)</script>}}
18760 !! html
18761 <div style="float: right;">&lt;script&gt;alert(document.cookie)&lt;/script&gt;"&gt;Magic div</div>
18762
18763 !! end
18764
18765 !! test
18766 T4304: HTML attribute safety (link)
18767 !! wikitext
18768 <div title="[[Main Page]]"></div>
18769 !! html/php
18770 <div title="&#91;&#91;Main Page&#93;&#93;"></div>
18771
18772 !! html/parsoid
18773 <div title="[[Main Page]]"></div>
18774 !! end
18775
18776 !! test
18777 T4304: HTML attribute safety (italics)
18778 !! wikitext
18779 <div title="''foobar''"></div>
18780 !! html
18781 <div title="&#39;&#39;foobar&#39;&#39;"></div>
18782
18783 !! end
18784
18785 !! test
18786 T4304: HTML attribute safety (bold)
18787 !! wikitext
18788 <div title="'''foobar'''"></div>
18789 !! html
18790 <div title="&#39;&#39;&#39;foobar&#39;&#39;&#39;"></div>
18791
18792 !! end
18793
18794 !! test
18795 T4304: HTML attribute safety (ISBN)
18796 !! wikitext
18797 <div title="ISBN 1234567890"></div>
18798 !! html
18799 <div title="&#73;SBN 1234567890"></div>
18800
18801 !! end
18802
18803 !! test
18804 T4304: HTML attribute safety (RFC)
18805 !! wikitext
18806 <div title="RFC 1234"></div>
18807 !! html
18808 <div title="&#82;FC 1234"></div>
18809
18810 !! end
18811
18812 !! test
18813 T4304: HTML attribute safety (PMID)
18814 !! wikitext
18815 <div title="PMID 1234567890"></div>
18816 !! html
18817 <div title="&#80;MID 1234567890"></div>
18818
18819 !! end
18820
18821 !! test
18822 T4304: HTML attribute safety (web link)
18823 !! wikitext
18824 <div title="http://example.com/"></div>
18825 !! html
18826 <div title="http&#58;//example.com/"></div>
18827
18828 !! end
18829
18830 !! test
18831 T4304: HTML attribute safety (named web link)
18832 !! wikitext
18833 <div title="[http://example.com/ link]"></div>
18834 !! html/php
18835 <div title="&#91;http&#58;//example.com/ link&#93;"></div>
18836
18837 !! html/parsoid
18838 <div title="[http://example.com/ link]"></div>
18839 !! end
18840
18841 !! test
18842 T5244: HTML attribute safety (extension; safe)
18843 !! wikitext
18844 <div style="<nowiki>background:blue</nowiki>"></div>
18845 !! html/php
18846 <div style="background:blue"></div>
18847
18848 !! html/parsoid
18849 <div style="background:blue" about="#mwt3" typeof="mw:ExpandedAttrs" data-parsoid='{"stx":"html","a":{"style":"background:blue"},"sa":{"style":"&lt;nowiki>background:blue&lt;/nowiki>"}}' data-mw='{"attribs":[[{"txt":"style"},{"html":"&lt;span typeof=\"mw:Nowiki\" data-parsoid=&apos;{\"dsr\":[12,44,8,9]}&apos;>background:blue&lt;/span>"}]]}'></div>
18850 !! end
18851
18852 !! test
18853 T5244: HTML attribute safety (extension; unsafe)
18854 !! wikitext
18855 <div style="<nowiki>border-left:expression(alert(document.cookie))</nowiki>"></div>
18856 !! html/php
18857 <div style="/* insecure input */"></div>
18858
18859 !! html/parsoid
18860 <div style="/* insecure input */" about="#mwt3" typeof="mw:ExpandedAttrs" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"&lt;nowiki>border-left:expression(alert(document.cookie))&lt;/nowiki>"}}' data-mw='{"attribs":[[{"txt":"style"},{"html":"&lt;span typeof=\"mw:Nowiki\" data-parsoid=&apos;{\"dsr\":[12,75,8,9]}&apos;>border-left:expression(alert(document.cookie))&lt;/span>"}]]}'></div>
18861 !! end
18862
18863 # More MSIE fun discovered by Tom Gilder
18864
18865 !! test
18866 MSIE CSS safety test: spurious slash
18867 !! wikitext
18868 <div style="background-image:u\rl(javascript:alert('boo'))">evil</div>
18869 !! html/php
18870 <div style="/* insecure input */">evil</div>
18871
18872 !! html/parsoid
18873 <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>
18874 !! end
18875
18876 !! test
18877 MSIE CSS safety test: hex code
18878 !! wikitext
18879 <div style="background-image:u\72l(javascript:alert('boo'))">evil</div>
18880 !! html/php
18881 <div style="/* insecure input */">evil</div>
18882
18883 !! html/parsoid
18884 <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>
18885 !! end
18886
18887 !! test
18888 MSIE CSS safety test: comment in url
18889 !! wikitext
18890 <div style="background-image:u/**/rl(javascript:alert('boo'))">evil</div>
18891 !! html/php
18892 <div style="background-image:u rl(javascript:alert(&#39;boo&#39;))">evil</div>
18893
18894 !! html/parsoid
18895 <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>
18896 !! end
18897
18898 !! test
18899 MSIE CSS safety test: comment in expression
18900 !! wikitext
18901 <div style="background-image:expres/**/sion(alert('boo4'))">evil4</div>
18902 !! html/php
18903 <div style="background-image:expres sion(alert(&#39;boo4&#39;))">evil4</div>
18904
18905 !! html/parsoid
18906 <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>
18907 !! end
18908
18909 !! test
18910 CSS safety test (all browsers): vertical tab (T57332 / CVE-2013-4567)
18911 !! wikitext
18912 <p style="font-size: 100px; background-image:url\b(https://www.google.com/images/srpr/logo6w.png)">A</p>
18913 !! html/php
18914 <p style="/* invalid control char */">A</p>
18915
18916 !! html/parsoid
18917 <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>
18918 !! end
18919
18920 !! test
18921 MSIE 6 CSS safety test: Fullwidth (T57332)
18922 !! wikitext
18923 <p style="font-size: 100px; color: expression((title='XSSed'),'red')">A</p>
18924 <div style="top:EXPRESSION(alert())">B</div>
18925 !! html/php
18926 <p style="/* insecure input */">A</p>
18927 <div style="/* insecure input */">B</div>
18928
18929 !! html/parsoid
18930 <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>
18931 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"top:EXPRESSION(alert())"}}'>B</div>
18932 !! end
18933
18934 !! test
18935 MSIE 6 CSS safety test: IPA extensions (T57332)
18936 !! wikitext
18937 <div style="background-image:uʀʟ(javascript:alert())">A</div>
18938 <p style="font-size: 100px; color: expʀessɪoɴ((title='XSSed'),'red')">B</p>
18939 !! html/php
18940 <div style="/* insecure input */">A</div>
18941 <p style="/* insecure input */">B</p>
18942
18943 !! html/parsoid
18944 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:uʀʟ(javascript:alert())"}}'>A</div>
18945 <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>
18946 !! end
18947
18948 !! test
18949 MSIE 6 CSS safety test: sup/sub script (T57332)
18950 !! wikitext
18951 <div style="background-image:url⁽javascript:alert())">A</div>
18952 <div style="background-image:url₍javascript:alert())">B</div>
18953 <p style="font-size: 100px; color: expressioⁿ((title='XSSed'),'red')">C</p>
18954 !! html/php
18955 <div style="/* insecure input */">A</div>
18956 <div style="/* insecure input */">B</div>
18957 <p style="/* insecure input */">C</p>
18958
18959 !! html/parsoid
18960 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:url⁽javascript:alert())"}}'>A</div>
18961 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:url₍javascript:alert())"}}'>B</div>
18962 <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>
18963 !! end
18964
18965 !! test
18966 Opera -o-link CSS
18967 !! options
18968 parsoid=wt2html,html2html
18969 !! wikitext
18970 <div
18971 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;"
18972 style="-o-link:attr(title);-o-link-source:current">X</div>
18973 !! html/php
18974 <div title="data:text/html,&lt;img src=1 onerror=alert(1)&gt;" style="/* insecure input */">X</div>
18975
18976 !! html/parsoid
18977 <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>
18978 !! end
18979
18980 !! test
18981 MSIE 6 CSS safety test: Repetition markers (T57332)
18982 !! wikitext
18983 <p style="font-size: 100px; color: expres〱ion((title='XSSed'),'red')">A</p>
18984 <p style="font-size: 100px; color: expresゝion((title='XSSed'),'red')">B</p>
18985 <p style="font-size: 100px; color: expresーion((title='XSSed'),'red')">C</p>
18986 <p style="font-size: 100px; color: expresヽion((title='XSSed'),'red')">D</p>
18987 <p style="font-size: 100px; color: expresﹽion((title='XSSed'),'red')">E</p>
18988 <p style="font-size: 100px; color: expresﹼion((title='XSSed'),'red')">F</p>
18989 <p style="font-size: 100px; color: expresーion((title='XSSed'),'red')">G</p>
18990 !! html/php
18991 <p style="/* insecure input */">A</p>
18992 <p style="/* insecure input */">B</p>
18993 <p style="/* insecure input */">C</p>
18994 <p style="/* insecure input */">D</p>
18995 <p style="/* insecure input */">E</p>
18996 <p style="/* insecure input */">F</p>
18997 <p style="/* insecure input */">G</p>
18998
18999 !! html/parsoid
19000 <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>
19001 <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>
19002 <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>
19003 <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>
19004 <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>
19005 <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>
19006 <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>
19007 !! end
19008
19009 !! test
19010 Table attribute legitimate extension
19011 !! wikitext
19012 {|
19013 !+ style="<nowiki>color:blue</nowiki>"|status
19014 |}
19015 !! html
19016 <table>
19017 <tr>
19018 <th style="color:blue">status
19019 </th></tr></table>
19020
19021 !!end
19022
19023 !! test
19024 Table attribute safety
19025 !! wikitext
19026 {|
19027 !+ style="<nowiki>border-width:expression(0+alert(document.cookie))</nowiki>"|status
19028 |}
19029 !! html
19030 <table>
19031 <tr>
19032 <th style="/* insecure input */">status
19033 </th></tr></table>
19034
19035 !! end
19036
19037 !! test
19038 CSS line continuation 1
19039 !! wikitext
19040 <div style="background-image: u\&#10;rl(test.jpg);"></div>
19041 !! html
19042 <div style="/* insecure input */"></div>
19043
19044 !! end
19045
19046 !! test
19047 CSS line continuation 2
19048 !! wikitext
19049 <div style="background-image: u\&#13;rl(test.jpg); "></div>
19050 !! html
19051 <div style="/* invalid control char */"></div>
19052
19053 !! end
19054
19055 !! article
19056 Template:Identity
19057 !! text
19058 {{{1}}}
19059 !! endarticle
19060
19061 !! test
19062 Expansion of multi-line templates in attribute values (T8255)
19063 !! wikitext
19064 <div style="background: {{identity|#00FF00}}">-</div>
19065 !! html
19066 <div style="background: #00FF00">-</div>
19067
19068 !! end
19069
19070 !! test
19071 Expansion of multi-line templates in attribute values (T8255 sanity check)
19072 !! wikitext
19073 <div style="background:
19074 #00FF00">-</div>
19075 !! html/php
19076 <div style="background: #00FF00">-</div>
19077
19078 !! html/parsoid
19079 <div style="background:
19080 #00FF00">-</div>
19081 !! end
19082
19083 !! test
19084 Expansion of multi-line templates in attribute values (T8255 sanity check 2)
19085 !! wikitext
19086 <div style="background: &#10;#00FF00">-</div>
19087 !! html
19088 <div style="background: &#10;#00FF00">-</div>
19089
19090 !! end
19091
19092 !! test
19093 Tags which are hidden from tidiers cannot pass through the Sanitizer
19094 !! wikitext
19095 <mw:toc><script>alert();</script></mw:toc>
19096 !! html+tidy
19097 <p>&lt;mw:toc&gt;&lt;script&gt;alert();&lt;/script&gt;&lt;/mw:toc&gt;
19098 </p>
19099 !! end
19100
19101 ###
19102 ### Parser hooks (see tests/parser/ParserTestParserHook.php for the <tag> extension)
19103 ###
19104
19105 !! test
19106 Parser hook: empty input
19107 !! wikitext
19108 <tag></tag>
19109 !! html/php
19110 <pre>
19111 ''
19112 array (
19113 )
19114 </pre>
19115
19116 !! html/parsoid
19117 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
19118 !! end
19119
19120 ## Don't expect parsoid to rt this form.
19121 !! test
19122 Parser hook: empty input using terminated empty elements
19123 !! options
19124 parsoid=wt2html,html2html
19125 !! wikitext
19126 <tag/>
19127 !! html/php
19128 <pre>
19129 NULL
19130 array (
19131 )
19132 </pre>
19133
19134 !! html/parsoid
19135 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{}}' data-parsoid='{}' about="#mwt2"></pre>
19136 !! end
19137
19138 !! test
19139 Parser hook: empty input using terminated empty elements (space before)
19140 !! wikitext
19141 <tag />
19142 !! html/php
19143 <pre>
19144 NULL
19145 array (
19146 )
19147 </pre>
19148
19149 !! html/parsoid
19150 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{}}' data-parsoid='{}' about="#mwt2"></pre>
19151 !! end
19152
19153 !! test
19154 Parser hook: basic input
19155 !! wikitext
19156 <tag>input</tag>
19157 !! html/php
19158 <pre>
19159 'input'
19160 array (
19161 )
19162 </pre>
19163
19164 !! html/parsoid
19165 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
19166 !! end
19167
19168 ## Don't expect parsoid to rt this form.
19169 !! test
19170 Parser hook: case insensitive
19171 !! options
19172 parsoid=wt2html,html2html
19173 !! wikitext
19174 <TAG>input</TAG>
19175 !! html/php
19176 <pre>
19177 'input'
19178 array (
19179 )
19180 </pre>
19181
19182 !! html/parsoid
19183 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
19184 !! end
19185
19186 ## Don't expect parsoid to rt this form.
19187 !! test
19188 Parser hook: case insensitive, redux
19189 !! options
19190 parsoid=wt2html,html2html
19191 !! wikitext
19192 <TaG>input</TAg>
19193 !! html/php
19194 <pre>
19195 'input'
19196 array (
19197 )
19198 </pre>
19199
19200 !! html/parsoid
19201 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
19202 !! end
19203
19204 !! test
19205 Parser hook: nested tags
19206 !! options
19207 parsoid=wt2html
19208 !! wikitext
19209 <tag><tag></tag></tag>
19210 !! html/php
19211 <pre>
19212 '<tag>'
19213 array (
19214 )
19215 </pre>&lt;/tag&gt;
19216
19217 !! html/php+tidy
19218 <pre>'<tag>'
19219 array (
19220 )
19221 </tag></pre><p>&lt;/tag&gt;
19222 </p>
19223 !! html/parsoid
19224 <pre typeof="mw:Extension/tag" about="#mwt2" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"&lt;tag>"}}'></pre><p>&lt;/tag></p>
19225 !! end
19226
19227 !! test
19228 Parser hook: basic arguments
19229 !! wikitext
19230 <tag width="200" height="100" depth="50" square=""></tag>
19231 !! html/php
19232 <pre>
19233 ''
19234 array (
19235 'width' => '200',
19236 'height' => '100',
19237 'depth' => '50',
19238 'square' => '',
19239 )
19240 </pre>
19241
19242 !! html/parsoid
19243 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
19244 !! end
19245
19246 ## Don't expect parsoid to rt this form.
19247 !! test
19248 Parser hook: basic arguments, variations
19249 !! options
19250 parsoid=wt2html,html2html
19251 !! wikitext
19252 <tag width=200 height = "100" depth = '50' square></tag>
19253 !! html/php
19254 <pre>
19255 ''
19256 array (
19257 'width' => '200',
19258 'height' => '100',
19259 'depth' => '50',
19260 'square' => '',
19261 )
19262 </pre>
19263
19264 !! html/parsoid
19265 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
19266 !! end
19267
19268 !! test
19269 Parser hook: argument containing a forward slash (T7344)
19270 !! wikitext
19271 <tag filename="/tmp/bla"></tag>
19272 !! html/php
19273 <pre>
19274 ''
19275 array (
19276 'filename' => '/tmp/bla',
19277 )
19278 </pre>
19279
19280 !! html/parsoid
19281 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"filename":"/tmp/bla"},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
19282 !! end
19283
19284 ## Don't expect parsoid to rt this form.
19285 !! test
19286 Parser hook: empty input using terminated empty elements (T4374)
19287 !! options
19288 parsoid=wt2html,html2html
19289 !! wikitext
19290 <tag foo=bar/>text
19291 !! html/php
19292 <pre>
19293 NULL
19294 array (
19295 'foo' => 'bar',
19296 )
19297 </pre>text
19298
19299 !! html/parsoid
19300 <pre typeof="mw:Extension/tag" about="#mwt2" data-mw='{"name":"tag","attrs":{"foo":"bar"}}'></pre><p>text</p>
19301 !! end
19302
19303 ## </tag> should be output literally since there is no matching tag that begins it
19304 ## Don't expect parsoid to rt this form.
19305 !! test
19306 Parser hook: basic arguments using terminated empty elements (T4374)
19307 !! options
19308 parsoid=wt2html
19309 !! wikitext
19310 <tag width=200 height = "100" depth = '50' square/>
19311 other stuff
19312 </tag>
19313 !! html/php
19314 <pre>
19315 NULL
19316 array (
19317 'width' => '200',
19318 'height' => '100',
19319 'depth' => '50',
19320 'square' => '',
19321 )
19322 </pre>
19323 <p>other stuff
19324 &lt;/tag&gt;
19325 </p>
19326 !! html/parsoid
19327 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""}}' about="#mwt2"></pre><p>other stuff
19328 &lt;/tag></p>
19329 !! end
19330
19331 ## Don't expect parsoid to rt this form.
19332 !! test
19333 Parser hook: Don't allow unclosed extension tags
19334 !! options
19335 parsoid=wt2html
19336 !! wikitext
19337 test <tag>123
19338
19339 this is a '''test'''
19340 !! html/php
19341 <p>test &lt;tag&gt;123
19342 </p><p>this is a <b>test</b>
19343 </p>
19344 !! html/parsoid
19345 <p>test &lt;tag>123</p>
19346
19347 <p>this is a <b>test</b></p>
19348 !! end
19349
19350 !! test
19351 Parser hook: horizontal rule inside extension tag that outputs <pre>
19352 !! wikitext
19353 <tag>
19354 Hello
19355 <hr/>
19356 Goodbye
19357 </tag>
19358 !! html/php
19359 <pre>
19360 '
19361 Hello
19362 <hr/>
19363 Goodbye
19364 '
19365 array (
19366 )
19367 </pre>
19368
19369 !! end
19370
19371 ###
19372 ### (see tests/parser/ParserTestParserHook.php for the <statictag> extension)
19373 ###
19374
19375 !! test
19376 Parser hook: static parser hook not inside a comment
19377 !! wikitext
19378 <statictag>hello, world</statictag>
19379
19380 <statictag action="flush" />
19381 !! html/php
19382 <p><br />
19383 hello, world
19384 </p>
19385 !! html/parsoid
19386 <p><span typeof="mw:Extension/statictag" data-mw='{"name":"statictag","attrs":{},"body":{"extsrc":"hello, world"}}' about="#mwt2"></span></p>
19387 <p><span typeof="mw:Extension/statictag" data-mw='{"name":"statictag","attrs":{"action":"flush"}}' about="#mwt4">hello, world</span></p>
19388 !! end
19389
19390 !! test
19391 Parser hook: static parser hook inside a comment
19392 !! wikitext
19393 <!-- <statictag>hello, world</statictag> -->
19394 <statictag action="flush" />
19395 !! html/php
19396 <p><br />
19397 </p>
19398 !! html/parsoid
19399 <!-- <statictag&#x3E;hello, world</statictag&#x3E; -->
19400 <p><span typeof='mw:Extension/statictag' data-mw='{"name":"statictag","attrs":{"action":"flush"}}' data-parsoid='{}' about='#mwt2'></span></p>
19401 !! end
19402
19403 # Nested template calls; this case was broken by Parser.php rev 1.506,
19404 # since reverted.
19405
19406 !! article
19407 Template:One-parameter
19408 !! text
19409 (My parameter is: {{{1}}})
19410 !! endarticle
19411
19412 !! article
19413 Template:Map-one-parameter
19414 !! text
19415 {{{{{1}}}|{{{2}}}}}
19416 !! endarticle
19417
19418 !! test
19419 Nested template calls
19420 !! wikitext
19421 {{Map-one-parameter|One-parameter|param}}
19422 !! html
19423 <p>(My parameter is: param)
19424 </p>
19425 !! end
19426
19427
19428 ###
19429 ### Sanitizer
19430 ###
19431
19432 !! test
19433 Sanitizer: Closing of open tags
19434 !! wikitext
19435 <s></s><table></table>
19436 !! html/php+tidy
19437 <p><s></s></p><table></table>
19438 !! html/parsoid
19439 <p><s data-parsoid='{"stx":"html"}'></s></p><table data-parsoid='{"stx":"html"}'></table>
19440 !! end
19441
19442 !! test
19443 Sanitizer: Closing of open but not closed tags
19444 !! wikitext
19445 <s>foo
19446 !! html
19447 <p><s>foo</s>
19448 </p>
19449 !! end
19450
19451 !! test
19452 Sanitizer: Closing of closed but not open tags
19453 !! options
19454 parsoid=wt2html
19455 !! wikitext
19456 </s>
19457 !! html+tidy
19458 <p class="mw-empty-elt">
19459 </p>
19460 !! end
19461
19462 !! test
19463 Sanitizer: Closing of closed but not open table tags
19464 !! options
19465 parsoid=wt2html
19466 !! wikitext
19467 Table not started</td></tr></table>
19468 !! html+tidy
19469 <p>Table not started
19470 </p>
19471 !! end
19472
19473 !! test
19474 Sanitizer: Escaping of spaces, multibyte characters, colons & other stuff in id=""
19475 !! options
19476 title=[[Main Page]]
19477 !! config
19478 wgFragmentMode=[ 'html5', 'legacy' ]
19479 !! wikitext
19480 <span id="æ: v">byte</span>[[#æ: v|backlink]]
19481 !! html/php
19482 <p><span id="æ:_v">byte</span><a href="#æ:_v">backlink</a>
19483 </p>
19484 !! html/parsoid
19485 <p><span id="æ:_v" data-parsoid='{"stx":"html","a":{"id":"æ:_v"},"sa":{"id":"æ: v"}}'>byte</span><a rel="mw:WikiLink" href="./Main_Page#æ:_v" data-parsoid='{"stx":"piped","a":{"href":"./Main_Page#æ:_v"},"sa":{"href":"#æ: v"}}'>backlink</a></p>
19486 !! end
19487
19488 !! test
19489 Sanitizer: Escaping of spaces, multibyte characters, colons & other stuff in id="" (legacy)
19490 !! config
19491 wgFragmentMode=[ 'legacy' ]
19492 !! wikitext
19493 <span id="æ: v">byte</span>[[#æ: v|backlink]]
19494 !! html/php
19495 <p><span id=".C3.A6:_v">byte</span><a href="#.C3.A6:_v">backlink</a>
19496 </p>
19497 !! end
19498
19499 # In HTML5, the restrictions are that id must contain at least one character,
19500 # and must not contain any space characters.
19501 !! test
19502 Sanitizer: Validating the contents of the id attribute (T6515)
19503 !! options
19504 disabled
19505 !! wikitext
19506 <br id="" /><br id="a space" />
19507 !! html
19508 Something ...
19509 !! end
19510
19511 # In HTML5, id must be unique amongst all the ids in the element's home subtree.
19512 !! test
19513 Sanitizer: Validating id attribute uniqueness (T6515, T8301)
19514 !! options
19515 disabled
19516 !! wikitext
19517 <br id="foo" /><br id="foo" />
19518 !! html
19519 Something need to be done. foo-2 ?
19520 !! end
19521
19522 !! test
19523 Sanitizer: Validating that <meta> and <link> work, but only for Microdata
19524 !! wikitext
19525 <div itemscope>
19526 <meta itemprop="hello" content="world">
19527 <meta http-equiv="refresh" content="5">
19528 <meta itemprop="hello" http-equiv="refresh" content="5">
19529 <link itemprop="hello" href="{{SERVER}}">
19530 <link rel="stylesheet" href="{{SERVER}}">
19531 <link rel="stylesheet" itemprop="hello" href="{{SERVER}}">
19532 </div>
19533 !! html
19534 <div itemscope="">
19535 <p> <meta itemprop="hello" content="world" />
19536 &lt;meta http-equiv="refresh" content="5"&gt;
19537 <meta itemprop="hello" content="5" />
19538 <link itemprop="hello" href="http&#58;//example.org" />
19539 &lt;link rel="stylesheet" href="<a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>"&gt;
19540 <link itemprop="hello" href="http&#58;//example.org" />
19541 </p>
19542 </div>
19543
19544 !! end
19545
19546 !! test
19547 Sanitizer: Strip comments from CSS attributes
19548 !! options
19549 parsoid=wt2html,wt2wt
19550 !! wikitext
19551 <span style="margin:/*negate mbox-text padding */-0.125em -0.45em; /*rainbow*/rgba(255, 0, 0, 0.3)">2013</span>
19552 !! html/php
19553 <p><span style="margin: -0.125em -0.45em; rgba(255, 0, 0, 0.3)">2013</span>
19554 </p>
19555 !! html/parsoid
19556 <p><span style="margin: -0.125em -0.45em; rgba(255, 0, 0, 0.3)">2013</span></p>
19557 !! end
19558
19559 !! test
19560 Sanitizer: Avoid unnecessary percent encoded characters in interwiki links
19561 !! wikitext
19562 [[meatball:Soft"Security]]
19563 !! html/php
19564 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?Soft%22Security" class="extiw" title="meatball:Soft&quot;Security">meatball:Soft"Security</a>
19565 </p>
19566 !! html/parsoid
19567 <p><a rel="mw:WikiLink/Interwiki" href='http://www.usemod.com/cgi-bin/mb.pl?Soft"Security' title='meatball:Soft"Security'>meatball:Soft"Security</a></p>
19568 !! end
19569
19570 !! test
19571 Sanitizer: angle brackets are invalid, even in interwiki links (T182338)
19572 !! wikitext
19573 [[meatball:Foo<Bar]]
19574 [[meatball:Foo>Bar]]
19575 [[meatball:Foo&lt;bar]]
19576 [[meatball:Foo&gt;bar]]
19577 !! html/php
19578 <p>[[meatball:Foo&lt;Bar]]
19579 [[meatball:Foo&gt;Bar]]
19580 [[meatball:Foo&lt;bar]]
19581 [[meatball:Foo&gt;bar]]
19582 </p>
19583 !! html/parsoid
19584 <p>[[meatball:Foo&lt;Bar]]
19585 [[meatball:Foo>Bar]]
19586 [[meatball:Foo<span typeof="mw:Entity" data-parsoid='{"src":"&amp;lt;","srcContent":"&lt;"}'>&lt;</span>bar]]
19587 [[meatball:Foo<span typeof="mw:Entity" data-parsoid='{"src":"&amp;gt;","srcContent":">"}'>></span>bar]]</p>
19588 !! end
19589
19590 !! test
19591 Language converter: output gets cut off unexpectedly (T7757)
19592 !! options
19593 language=zh
19594 !! wikitext
19595 this bit is safe: }-
19596
19597 but if we add a conversion instance: -{zh-cn:xxx;zh-tw:yyy}-
19598
19599 then we get cut off here: }-
19600
19601 all additional text is vanished
19602 !! html/php
19603 <p>this bit is safe: }-
19604 </p><p>but if we add a conversion instance: xxx
19605 </p><p>then we get cut off here: }-
19606 </p><p>all additional text is vanished
19607 </p>
19608 !! html/parsoid
19609 <p>this bit is safe: }-</p>
19610 <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>
19611 <p>then we get cut off here: }-</p>
19612 <p>all additional text is vanished</p>
19613 !! end
19614
19615 !! test
19616 Language converter glossary rules inside attributes (T119158)
19617 !! options
19618 language=sr variant=sr-el
19619 !! wikitext
19620 -{H|foAjrjvi=>sr-el:" onload="alert(1)" data-foo="}-
19621
19622 [[File:Foobar.jpg|alt=-{}-foAjrjvi-{}-]]
19623 !! html/php
19624 <p>
19625 </p><p><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="&quot; onload=&quot;alert(1)&quot; data-foo=&quot;" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" /></a>
19626 </p>
19627 !! html/parsoid
19628 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"foAjrjvi","l":"sr-el","t":"\" onload=\"alert(1)\" data-foo=\""}]}'/></p>
19629
19630 <p><figure-inline class="mw-default-size" typeof="mw:Image"><a href="./Датотека:Foobar.jpg"><img alt="foAjrjvi" resource="./Датотека: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":"foAjrjvi","resource":"./Датотека:Foobar.jpg","height":"220","width":"1941"},"sa":{"alt":"alt=-{}-foAjrjvi-{}-","resource":"File:Foobar.jpg"}}'/></a></figure-inline></p>
19631 !! end
19632
19633 !! test
19634 Self closed html pairs (T7487)
19635 !! wikitext
19636 <center><font id="bug" />Centered text</center>
19637 <div><font id="bug2" />In div text</div>
19638 !! html+tidy
19639 <center><font id="bug"></font>Centered text</center>
19640 <div><font id="bug2"></font>In div text</div>
19641 !! end
19642
19643 !! test
19644 Punctuation: nbsp before exclamation
19645 !! wikitext
19646 C'est grave !
19647 !! html
19648 <p>C'est grave&#160;!
19649 </p>
19650 !! end
19651
19652 !! test
19653 Punctuation: CSS !important (T13874)
19654 !! wikitext
19655 <div style="width:50% !important">important</div>
19656 !! html
19657 <div style="width:50% !important">important</div>
19658
19659 !!end
19660
19661 !! test
19662 Punctuation: CSS ! important (T13874; with space after)
19663 !! wikitext
19664 <div style="width:50% ! important">important</div>
19665 !! html
19666 <div style="width:50%&#32;! important">important</div>
19667
19668 !!end
19669
19670 !! test
19671 HTML bullet list, closed tags (T7497)
19672 !! wikitext
19673 <ul>
19674 <li>One</li>
19675 <li>Two</li>
19676 </ul>
19677 !! html/php
19678 <ul>
19679 <li>One</li>
19680 <li>Two</li>
19681 </ul>
19682
19683 !! html/parsoid
19684 <ul data-parsoid='{"stx":"html"}'>
19685 <li data-parsoid='{"stx":"html"}'>One</li>
19686 <li data-parsoid='{"stx":"html"}'>Two</li>
19687 </ul>
19688
19689 !! end
19690
19691 !! test
19692 HTML bullet list, unclosed tags (T7497)
19693 !! wikitext
19694 <ul>
19695 <li>One
19696 <li>Two
19697 </ul>
19698 !! html/php+tidy
19699 <ul>
19700 <li>One
19701 </li><li>Two
19702 </li></ul>
19703 !! html/parsoid
19704 <ul data-parsoid='{"stx":"html"}'>
19705 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>One</li>
19706 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>Two</li>
19707 </ul>
19708
19709 !! end
19710
19711 !! test
19712 HTML ordered list, closed tags (T7497)
19713 !! wikitext
19714 <ol>
19715 <li>One</li>
19716 <li>Two</li>
19717 </ol>
19718 !! html/php
19719 <ol>
19720 <li>One</li>
19721 <li>Two</li>
19722 </ol>
19723
19724 !! html/parsoid
19725 <ol data-parsoid='{"stx":"html"}'>
19726 <li data-parsoid='{"stx":"html"}'>One</li>
19727 <li data-parsoid='{"stx":"html"}'>Two</li>
19728 </ol>
19729
19730 !! end
19731
19732 !! test
19733 HTML ordered list, unclosed tags (T7497)
19734 !! options
19735 !! wikitext
19736 <ol>
19737 <li>One
19738 <li>Two
19739 </ol>
19740 !! html/php+tidy
19741 <ol>
19742 <li>One
19743 </li><li>Two
19744 </li></ol>
19745 !! html/parsoid
19746 <ol data-parsoid='{"stx":"html"}'>
19747 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>One</li>
19748 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>Two</li>
19749 </ol>
19750
19751 !! end
19752
19753 !! test
19754 HTML nested bullet list, closed tags (T7497)
19755 !! wikitext
19756 <ul>
19757 <li>One</li>
19758 <li>Two:
19759 <ul>
19760 <li>Sub-one</li>
19761 <li>Sub-two</li>
19762 </ul>
19763 </li>
19764 </ul>
19765 !! html/php
19766 <ul>
19767 <li>One</li>
19768 <li>Two:
19769 <ul>
19770 <li>Sub-one</li>
19771 <li>Sub-two</li>
19772 </ul>
19773 </li>
19774 </ul>
19775
19776 !! html/parsoid
19777 <ul data-parsoid='{"stx":"html"}'>
19778 <li data-parsoid='{"stx":"html"}'>One</li>
19779 <li data-parsoid='{"stx":"html"}'>Two:
19780 <ul data-parsoid='{"stx":"html"}'>
19781 <li data-parsoid='{"stx":"html"}'>Sub-one</li>
19782 <li data-parsoid='{"stx":"html"}'>Sub-two</li>
19783 </ul>
19784 </li>
19785 </ul>
19786 !! end
19787
19788 !! test
19789 HTML nested bullet list, open tags (T7497)
19790 !! wikitext
19791 <ul>
19792 <li>One
19793 <li>Two:
19794 <ul>
19795 <li>Sub-one
19796 <li>Sub-two
19797 </ul>
19798 </ul>
19799 !! html+tidy
19800 <ul>
19801 <li>One
19802 </li><li>Two:
19803 <ul>
19804 <li>Sub-one
19805 </li><li>Sub-two
19806 </li></ul>
19807 </li></ul>
19808 !! end
19809
19810 !! test
19811 HTML nested ordered list, closed tags (T7497)
19812 !! wikitext
19813 <ol>
19814 <li>One</li>
19815 <li>Two:
19816 <ol>
19817 <li>Sub-one</li>
19818 <li>Sub-two</li>
19819 </ol>
19820 </li>
19821 </ol>
19822 !! html
19823 <ol>
19824 <li>One</li>
19825 <li>Two:
19826 <ol>
19827 <li>Sub-one</li>
19828 <li>Sub-two</li>
19829 </ol>
19830 </li>
19831 </ol>
19832
19833 !! end
19834
19835 !! test
19836 HTML nested ordered list, open tags (T7497)
19837 !! wikitext
19838 <ol>
19839 <li>One
19840 <li>Two:
19841 <ol>
19842 <li>Sub-one
19843 <li>Sub-two
19844 </ol>
19845 </ol>
19846 !! html/php
19847 <ol>
19848 <li>One
19849 <li>Two:
19850 <ol>
19851 <li>Sub-one
19852 <li>Sub-two
19853 </ol>
19854 </ol>
19855
19856 !! html/parsoid
19857 <ol>
19858 <li>One
19859 </li>
19860 <li>Two:
19861 <ol>
19862 <li>Sub-one
19863 </li>
19864 <li>Sub-two
19865 </li>
19866 </ol>
19867 </li>
19868 </ol>
19869
19870 !! end
19871
19872 !! test
19873 HTML ordered list item with parameters oddity
19874 !! wikitext
19875 <ol><li id="fragment">One</li>
19876 </ol>
19877 !! html
19878 <ol><li id="fragment">One</li>
19879 </ol>
19880
19881 !! end
19882
19883 # parsoid doesn't explicitly mark autonumbered links, see T55505
19884 !!test
19885 T7918: autonumbering
19886 !! wikitext
19887 [http://first/] [http://second] [ftp://ftp]
19888
19889 ftp://inlineftp
19890
19891 [mailto:enclosed@mail.tld With target]
19892
19893 [mailto:enclosed@mail.tld]
19894
19895 mailto:inline@mail.tld
19896 !! html/php
19897 <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>
19898 </p><p><a rel="nofollow" class="external free" href="ftp://inlineftp">ftp://inlineftp</a>
19899 </p><p><a rel="nofollow" class="external text" href="mailto:enclosed@mail.tld">With target</a>
19900 </p><p><a rel="nofollow" class="external autonumber" href="mailto:enclosed@mail.tld">[4]</a>
19901 </p><p><a rel="nofollow" class="external free" href="mailto:inline@mail.tld">mailto:inline@mail.tld</a>
19902 </p>
19903 !! html/parsoid
19904 <p><a rel="mw:ExtLink" class="external autonumber" href="http://first/"></a> <a rel="mw:ExtLink" class="external autonumber" href="http://second"></a> <a rel="mw:ExtLink" class="external autonumber" href="ftp://ftp"></a></p>
19905 <p><a rel="mw:ExtLink" class="external free" href="ftp://inlineftp">ftp://inlineftp</a></p>
19906 <p><a rel="mw:ExtLink" class="external text" href="mailto:enclosed@mail.tld">With target</a></p>
19907 <p><a rel="mw:ExtLink" class="external autonumber" href="mailto:enclosed@mail.tld"></a></p>
19908 <p><a rel="mw:ExtLink" class="external free" href="mailto:inline@mail.tld">mailto:inline@mail.tld</a></p>
19909 !! end
19910
19911
19912 #
19913 # Security and HTML correctness
19914 # From Nick Jenkins' fuzz testing
19915 #
19916
19917 !! test
19918 Fuzz testing: Parser13
19919 !! wikitext
19920 {|
19921 | http://a|
19922 !! html
19923 <table>
19924 <tr>
19925 <td>
19926 </td>
19927 </tr>
19928 </table>
19929
19930 !! end
19931
19932 # Note that Parsoid output differs from the PHP parser here: the PHP
19933 # parser breaks the URL for the magic word, while in Parsoid the URL
19934 # production takes precedence.
19935 !! test
19936 Fuzz testing: Parser14
19937 !! wikitext
19938 ==onmouseover===
19939 http://__TOC__
19940 !! html/php
19941 <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>
19942 http://<div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
19943 <ul>
19944 <li class="toclevel-1 tocsection-1"><a href="#onmouseover.3D"><span class="tocnumber">1</span> <span class="toctext">onmouseover=</span></a></li>
19945 </ul>
19946 </div>
19947
19948
19949 !! html/php+tidy
19950 <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><p>
19951 http://</p><div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none" /><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
19952 <ul>
19953 <li class="toclevel-1 tocsection-1"><a href="#onmouseover.3D"><span class="tocnumber">1</span> <span class="toctext">onmouseover=</span></a></li>
19954 </ul>
19955 </div>
19956 !! html/parsoid
19957 <h2 id="onmouseover="><span id="onmouseover.3D" typeof="mw:FallbackId"></span>onmouseover=</h2>
19958 <p><a rel="mw:ExtLink" class="external free" href="http://__TOC__" data-parsoid='{"stx":"url"}'>http://__TOC__</a></p>
19959 !! end
19960
19961 !! test
19962 Fuzz testing: Parser14-table
19963 !! options
19964 parsoid=wt2html,html2html
19965 !! wikitext
19966 ==a==
19967 {| STYLE=__TOC__
19968 !! html/php
19969 <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>
19970 <table style="&#95;_TOC&#95;_">
19971 <tr><td></td></tr>
19972 </table>
19973
19974 !! html/php+tidy
19975 <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>
19976 <table style="&#95;_TOC&#95;_">
19977 <tbody><tr><td></td></tr>
19978 </tbody></table>
19979 !! html/parsoid
19980 <h2 id="a">a</h2>
19981 <table style="__TOC__"></table>
19982 !! end
19983
19984 # Known to produce bogus xml (extra </td>)
19985 # Don't add the html/php section since it generates broken HTML
19986 !! test
19987 Fuzz testing: Parser16
19988 !! wikitext
19989 {|
19990 !https://||||||
19991 !! html+tidy
19992 <table>
19993 <tbody><tr>
19994 <th>https://</th>
19995 <th></th>
19996 <th></th>
19997 <th>
19998
19999 </th></tr>
20000 </tbody></table>
20001 !! end
20002
20003 !! test
20004 Fuzz testing: Parser21
20005 !! wikitext
20006 {|
20007 !irc://{{ftp://a" onmouseover="alert('hello world');"
20008 |
20009 !! html
20010 <table>
20011 <tr>
20012 <th><a rel="nofollow" class="external free" href="irc://{{ftp://a">irc://{{ftp://a</a>" onmouseover="alert('hello world');"
20013 </th>
20014 <td>
20015 </td>
20016 </tr>
20017 </table>
20018
20019 !! end
20020
20021 !! test
20022 Fuzz testing: Parser22
20023 !! wikitext
20024 http://===r:::https://b
20025
20026 {|
20027 !! html
20028 <p><a rel="nofollow" class="external free" href="http://===r:::https://b">http://===r:::https://b</a>
20029 </p>
20030 <table>
20031 <tr><td></td></tr>
20032 </table>
20033
20034 !! end
20035
20036 ## Remex doesn't account for fostered content.
20037 ## Known to produce bad XML for now
20038 !! test
20039 Fuzz testing: Parser24
20040 !! options
20041 parsoid=wt2html
20042 !! wikitext
20043 {|
20044 {{{|
20045 <u CLASS=
20046 | {{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx--><noinclude>}}}} >
20047 <br style="onmouseover='alert(document.cookie);' " />
20048
20049 MOVE YOUR MOUSE CURSOR OVER THIS TEXT
20050 |
20051 !! html/php
20052 <table>
20053 {{{|
20054 <u class="&#124;">}}}} &gt;
20055 <br style="onmouseover=&#39;alert(document.cookie);&#39;" />
20056
20057 MOVE YOUR MOUSE CURSOR OVER THIS TEXT
20058 <tr>
20059 <td></u>
20060 </td>
20061 </tr>
20062 </table>
20063
20064 !! html/php+tidy
20065
20066 {{{|
20067 <u class="&#124;">}}}} &gt;
20068 <br style="onmouseover=&#39;alert(document.cookie);&#39;" />
20069
20070 MOVE YOUR MOUSE CURSOR OVER THIS TEXT
20071 </u><table><tbody><tr>
20072 <td>
20073 </td>
20074 </tr>
20075 </tbody></table><p><u class="&#124;">
20076 </u></p>
20077 !! html/parsoid
20078 <p data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true}'>
20079 {{{|
20080 <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>"}'/>}}}} >
20081 <br style="onmouseover='alert(document.cookie);' " data-parsoid='{"stx":"html","selfClose":true}'/>
20082
20083 MOVE YOUR MOUSE CURSOR OVER THIS TEXT</u></p>
20084 <table data-parsoid='{"autoInsertedEnd":true}'><tbody><tr data-parsoid='{"autoInsertedStart":true}'><td></td></tr></tbody></table>
20085 !! end
20086
20087 # Note: the current result listed for this is not what the original one was,
20088 # but the original bug was JavaScript injection, which is fixed in any case.
20089 # It's not clear that the original result listed was any more correct than the
20090 # current one. Original result:
20091 # <p>{{{|
20092 # </p>
20093 # <li class="&#124;&#124;">
20094 # }}}blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b>
20095 !!test
20096 Fuzz testing: Parser25 (T8055)
20097 !! wikitext
20098 {{{
20099 |
20100 <LI CLASS=||
20101 >
20102 }}}blah" onmouseover="alert('hello world');" align="left"'''MOVE MOUSE CURSOR OVER HERE
20103 !! html/php
20104 <p>&lt;LI CLASS=blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b>
20105 </p>
20106 !! html/parsoid
20107 <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"]}'>
20108 </span><p about="#mwt1">&lt;LI CLASS=blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b></p>
20109 !! end
20110
20111 !!test
20112 Fuzz testing: URL adjacent extension (with space, clean)
20113 !! wikitext
20114 http://example.com <nowiki>junk</nowiki>
20115 !! html/php
20116 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> junk
20117 </p>
20118 !! html/parsoid
20119 <p><a rel="mw:ExtLink" class="external free" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a> <span typeof="mw:Nowiki">junk</span></p>
20120 !! end
20121
20122 !!test
20123 Fuzz testing: URL adjacent extension (no space, dirty; nowiki)
20124 !! wikitext
20125 http://example.com<nowiki>junk</nowiki>
20126 !! html/php
20127 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>junk
20128 </p>
20129 !! html/parsoid
20130 <p><a rel="mw:ExtLink" class="external free" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a><span typeof="mw:Nowiki">junk</span></p>
20131 !! end
20132
20133 !! test
20134 Fuzz testing: URL adjacent extension (no space, dirty; pre)
20135 !! wikitext
20136 http://example.com<pre>junk</pre>
20137 !! html/php
20138 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a><pre>junk</pre>
20139
20140 !! html/php+tidy
20141 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a></p><pre>junk</pre>
20142 !! html/parsoid
20143 <p><a rel="mw:ExtLink" class="external free" 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>
20144 !! end
20145
20146 !! test
20147 Fuzz testing: image with bogus manual thumbnail
20148 !! wikitext
20149 [[Image:foobar.jpg|thumbnail= ]]
20150 !! html/php
20151 <div class="thumb tright"><div class="thumbinner" style="width:182px;">Error creating thumbnail: <div class="thumbcaption"></div></div></div>
20152
20153 !! html/parsoid
20154 <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>
20155 !! end
20156
20157 # Parsoid will emit the newline literally in wt2wt; see next test case.
20158 !! test
20159 Fuzz testing: encoded newline in generated HTML replacements (T8577)
20160 !! options
20161 parsoid=wt2html
20162 !! wikitext
20163 <pre dir="&#10;"></pre>
20164 !! html/php
20165 <pre dir="&#10;"></pre>
20166
20167 !! html/parsoid
20168 <pre dir="
20169 " typeof="mw:Extension/pre" about="#mwt2"data-mw='{"name":"pre","attrs":{"dir":"\n"},"body":{"extsrc":""}}'></pre>
20170 !! end
20171
20172 !! test
20173 Fuzz testing: encoded newline in generated HTML replacements, html2wt (T8577)
20174 !! options
20175 parsoid=html2wt
20176 !! html/parsoid
20177 <pre typeof="mw:Extension/pre" about="#mwt2" dir="
20178 " data-mw='{"name":"pre","attrs":{"dir":"\n"},"body":{"extsrc":""}}'></pre>
20179 !! wikitext
20180 <pre dir="
20181 "></pre>
20182 !! html/php
20183 <pre dir=""></pre>
20184
20185 !! end
20186
20187 !! test
20188 Templates in extension attributes are not expanded
20189 !! wikitext
20190 <pre dir="{{echo|ltr}}"></pre>
20191 !! html/php
20192 <pre dir="{{echo|ltr}}"></pre>
20193
20194 !! html/parsoid
20195 <pre dir="{{echo|ltr}}" typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{"dir":"{{echo|ltr}}"},"body":{"extsrc":""}}'></pre>
20196 !! end
20197
20198 !! test
20199 Parsing optional HTML elements (T8171)
20200 !! options
20201 !! wikitext
20202 <table>
20203 <tr>
20204 <td> Some tabular data</td>
20205 <td> More tabular data ...
20206 <td> And yet som tabular data</td>
20207 </tr>
20208 </table>
20209 !! html
20210 <table>
20211 <tr>
20212 <td> Some tabular data</td>
20213 <td> More tabular data ...
20214 </td><td> And yet som tabular data</td>
20215 </tr>
20216 </table>
20217
20218 !! end
20219
20220 !! test
20221 Correct handling of <td>, <tr> (T8171)
20222 !! options
20223 !! wikitext
20224 <table>
20225 <tr>
20226 <td> Some tabular data</td>
20227 <td> More tabular data ...</td>
20228 <td> And yet som tabular data</td>
20229 </tr>
20230 </table>
20231 !! html
20232 <table>
20233 <tr>
20234 <td> Some tabular data</td>
20235 <td> More tabular data ...</td>
20236 <td> And yet som tabular data</td>
20237 </tr>
20238 </table>
20239
20240 !! end
20241
20242
20243 !! test
20244 Parsing crashing regression (fr:JavaScript)
20245 !! wikitext
20246 </body></x>
20247 !! html
20248 <p>&lt;/body&gt;&lt;/x&gt;
20249 </p>
20250 !! end
20251
20252 !! test
20253 Inline wiki vs wiki block nesting
20254 !! wikitext
20255 '''Bold paragraph
20256
20257 New wiki paragraph
20258 !! html
20259 <p><b>Bold paragraph</b>
20260 </p><p>New wiki paragraph
20261 </p>
20262 !! end
20263
20264 # FIXME: The current php output is documented
20265 # and desired output is the parsoid target.
20266 !! test
20267 Inline HTML vs wiki block nesting
20268 !! wikitext
20269 <b>Bold paragraph
20270
20271 New wiki paragraph
20272 !! html/php
20273 <p><b>Bold paragraph
20274 </p><p>New wiki paragraph</b>
20275 </p>
20276 !! html/php+tidy
20277 <p><b>Bold paragraph
20278 </b></p><p><b>New wiki paragraph
20279 </b></p>
20280 !! html/parsoid
20281 <p><b>Bold paragraph</b>
20282 </p><p>New wiki paragraph
20283 </p>
20284 !! end
20285
20286 # Original result was this:
20287 # <p><b>bold</b><b>bold<i>bolditalics</i></b>
20288 # </p>
20289 # While that might be marginally more intuitive, maybe, the six-apostrophe
20290 # construct is clearly pathological and the result stated here (which is what
20291 # the parser actually does) is about as reasonable as anything.
20292 !!test
20293 Mixing markup for italics and bold
20294 !! options
20295 !! wikitext
20296 '''bold''''''bold''bolditalics'''''
20297 !! html
20298 <p>'<i>bold'</i><b>bold<i>bolditalics</i></b>
20299 </p>
20300 !! end
20301
20302
20303 !! article
20304 Xyzzyx
20305 !! text
20306 Article for special page transclusion test
20307 !! endarticle
20308
20309 !! test
20310 Special page transclusion
20311 !! options
20312 !! wikitext
20313 {{Special:Prefixindex/Xyzzyx}}
20314 !! html
20315 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
20316 </ul>
20317
20318 !! end
20319
20320 !! test
20321 Special page transclusion twice (T7021)
20322 !! options
20323 !! wikitext
20324 {{Special:Prefixindex/Xyzzyx}}
20325 {{Special:Prefixindex/Xyzzyx}}
20326 !! html
20327 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
20328 </ul>
20329 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
20330 </ul>
20331
20332 !! end
20333
20334 !! test
20335 Transclusion of default MediaWiki message
20336 !! wikitext
20337 {{MediaWiki:Mainpage}}
20338 !! html
20339 <p>Main Page
20340 </p>
20341 !! end
20342
20343 !! test
20344 Transclusion of nonexistent MediaWiki message
20345 !! wikitext
20346 {{MediaWiki:Mainpagexxx}}
20347 !! html
20348 <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>
20349 </p>
20350 !! end
20351
20352 !! test
20353 Transclusion of MediaWiki message with underscore
20354 !! wikitext
20355 {{MediaWiki:history_short}}
20356 !! html
20357 <p>History
20358 </p>
20359 !! end
20360
20361 !! test
20362 Transclusion of MediaWiki message with space
20363 !! wikitext
20364 {{MediaWiki:history short}}
20365 !! html
20366 <p>History
20367 </p>
20368 !! end
20369
20370 !! test
20371 Invalid header with following text
20372 !! wikitext
20373 = x = y
20374 !! html
20375 <p>= x = y
20376 </p>
20377 !! end
20378
20379
20380 !! test
20381 Section extraction test (section 0)
20382 !! options
20383 section=0
20384 !! wikitext
20385 start
20386 ==a==
20387 ===aa===
20388 ====aaa====
20389 ==b==
20390 ===ba===
20391 ===bb===
20392 ====bba====
20393 ===bc===
20394 ==c==
20395 ===ca===
20396 !! html/php
20397 start
20398 !! end
20399
20400 !! test
20401 Section extraction test (section 1)
20402 !! options
20403 section=1
20404 !! wikitext
20405 start
20406 ==a==
20407 ===aa===
20408 ====aaa====
20409 ==b==
20410 ===ba===
20411 ===bb===
20412 ====bba====
20413 ===bc===
20414 ==c==
20415 ===ca===
20416 !! html/php
20417 ==a==
20418 ===aa===
20419 ====aaa====
20420 !! end
20421
20422 !! test
20423 Section extraction test (section 2)
20424 !! options
20425 section=2
20426 !! wikitext
20427 start
20428 ==a==
20429 ===aa===
20430 ====aaa====
20431 ==b==
20432 ===ba===
20433 ===bb===
20434 ====bba====
20435 ===bc===
20436 ==c==
20437 ===ca===
20438 !! html/php
20439 ===aa===
20440 ====aaa====
20441 !! end
20442
20443 !! test
20444 Section extraction test (section 3)
20445 !! options
20446 section=3
20447 !! wikitext
20448 start
20449 ==a==
20450 ===aa===
20451 ====aaa====
20452 ==b==
20453 ===ba===
20454 ===bb===
20455 ====bba====
20456 ===bc===
20457 ==c==
20458 ===ca===
20459 !! html/php
20460 ====aaa====
20461 !! end
20462
20463 !! test
20464 Section extraction test (section 4)
20465 !! options
20466 section=4
20467 !! wikitext
20468 start
20469 ==a==
20470 ===aa===
20471 ====aaa====
20472 ==b==
20473 ===ba===
20474 ===bb===
20475 ====bba====
20476 ===bc===
20477 ==c==
20478 ===ca===
20479 !! html/php
20480 ==b==
20481 ===ba===
20482 ===bb===
20483 ====bba====
20484 ===bc===
20485 !! end
20486
20487 !! test
20488 Section extraction test (section 5)
20489 !! options
20490 section=5
20491 !! wikitext
20492 start
20493 ==a==
20494 ===aa===
20495 ====aaa====
20496 ==b==
20497 ===ba===
20498 ===bb===
20499 ====bba====
20500 ===bc===
20501 ==c==
20502 ===ca===
20503 !! html/php
20504 ===ba===
20505 !! end
20506
20507 !! test
20508 Section extraction test (section 6)
20509 !! options
20510 section=6
20511 !! wikitext
20512 start
20513 ==a==
20514 ===aa===
20515 ====aaa====
20516 ==b==
20517 ===ba===
20518 ===bb===
20519 ====bba====
20520 ===bc===
20521 ==c==
20522 ===ca===
20523 !! html/php
20524 ===bb===
20525 ====bba====
20526 !! end
20527
20528 !! test
20529 Section extraction test (section 7)
20530 !! options
20531 section=7
20532 !! wikitext
20533 start
20534 ==a==
20535 ===aa===
20536 ====aaa====
20537 ==b==
20538 ===ba===
20539 ===bb===
20540 ====bba====
20541 ===bc===
20542 ==c==
20543 ===ca===
20544 !! html/php
20545 ====bba====
20546 !! end
20547
20548 !! test
20549 Section extraction test (section 8)
20550 !! options
20551 section=8
20552 !! wikitext
20553 start
20554 ==a==
20555 ===aa===
20556 ====aaa====
20557 ==b==
20558 ===ba===
20559 ===bb===
20560 ====bba====
20561 ===bc===
20562 ==c==
20563 ===ca===
20564 !! html/php
20565 ===bc===
20566 !! end
20567
20568 !! test
20569 Section extraction test (section 9)
20570 !! options
20571 section=9
20572 !! wikitext
20573 start
20574 ==a==
20575 ===aa===
20576 ====aaa====
20577 ==b==
20578 ===ba===
20579 ===bb===
20580 ====bba====
20581 ===bc===
20582 ==c==
20583 ===ca===
20584 !! html/php
20585 ==c==
20586 ===ca===
20587 !! end
20588
20589 !! test
20590 Section extraction test (section 10)
20591 !! options
20592 section=10
20593 !! wikitext
20594 start
20595 ==a==
20596 ===aa===
20597 ====aaa====
20598 ==b==
20599 ===ba===
20600 ===bb===
20601 ====bba====
20602 ===bc===
20603 ==c==
20604 ===ca===
20605 !! html/php
20606 ===ca===
20607 !! end
20608
20609 !! test
20610 Section extraction test (nonexistent section 11)
20611 !! options
20612 section=11
20613 !! wikitext
20614 start
20615 ==a==
20616 ===aa===
20617 ====aaa====
20618 ==b==
20619 ===ba===
20620 ===bb===
20621 ====bba====
20622 ===bc===
20623 ==c==
20624 ===ca===
20625 !! html/php
20626 !! end
20627
20628 !! test
20629 Section extraction test with bogus heading (section 1)
20630 !! options
20631 section=1
20632 !! wikitext
20633 ==a==
20634 ==bogus== not a legal section
20635 ==b==
20636 !! html/php
20637 ==a==
20638 ==bogus== not a legal section
20639 !! end
20640
20641 !! test
20642 Section extraction test with bogus heading (section 2)
20643 !! options
20644 section=2
20645 !! wikitext
20646 ==a==
20647 ==bogus== not a legal section
20648 ==b==
20649 !! html/php
20650 ==b==
20651 !! end
20652
20653 !! test
20654 Section extraction test with comment after heading (section 1)
20655 !! options
20656 section=1
20657 !! wikitext
20658 ==a==
20659 ==b== <!-- -->
20660 ==c==
20661 !! html/php
20662 ==a==
20663 !! end
20664
20665 !! test
20666 Section extraction test with comment after heading (section 2)
20667 !! options
20668 section=2
20669 !! wikitext
20670 ==a==
20671 ==b== <!-- -->
20672 ==c==
20673 !! html/php
20674 ==b== <!-- -->
20675 !! end
20676
20677 !! test
20678 Section extraction test with bogus <nowiki> heading (section 1)
20679 !! options
20680 section=1
20681 !! wikitext
20682 ==a==
20683 ==bogus== <nowiki>not a legal section</nowiki>
20684 ==b==
20685 !! html/php
20686 ==a==
20687 ==bogus== <nowiki>not a legal section</nowiki>
20688 !! end
20689
20690 !! test
20691 Section extraction test with bogus <nowiki> heading (section 2)
20692 !! options
20693 section=2
20694 !! wikitext
20695 ==a==
20696 ==bogus== <nowiki>not a legal section</nowiki>
20697 ==b==
20698 !! html/php
20699 ==b==
20700 !! end
20701
20702 # Formerly testing for T4587, now resolved by the use of unmarked sections
20703 # instead of respecting commented sections
20704 !! test
20705 Section extraction prefixed by comment (section 1)
20706 !! options
20707 section=1
20708 !! wikitext
20709 <!-- -->==sec1==
20710 ==sec2==
20711 !! html/php
20712 ==sec2==
20713 !!end
20714
20715 !! test
20716 Section extraction prefixed by comment (section 2)
20717 !! options
20718 section=2
20719 !! wikitext
20720 <!-- -->==sec1==
20721 ==sec2==
20722 !! html/php
20723
20724 !!end
20725
20726 # Formerly testing for T4607, now resolved by the use of unmarked sections
20727 # instead of respecting HTML-style headings
20728 !! test
20729 Section extraction, mixed wiki and html (section 1)
20730 !! options
20731 section=1
20732 !! wikitext
20733 <h2>unmarked</h2>
20734 unmarked
20735 ==1==
20736 one
20737 ==2==
20738 two
20739 !! html/php
20740 ==1==
20741 one
20742 !! end
20743
20744 !! test
20745 Section extraction, mixed wiki and html (section 2)
20746 !! options
20747 section=2
20748 !! wikitext
20749 <h2>unmarked</h2>
20750 unmarked
20751 ==1==
20752 one
20753 ==2==
20754 two
20755 !! html/php
20756 ==2==
20757 two
20758 !! end
20759
20760
20761 # Formerly testing for T5342
20762 !! test
20763 Section extraction, heading surrounded by <noinclude>
20764 !! options
20765 section=1
20766 !! wikitext
20767 <noinclude>==unmarked==</noinclude>
20768 ==marked==
20769 !! html/php
20770 ==marked==
20771 !!end
20772
20773 # Test behavior of T21910
20774 !! test
20775 Sectiion with all-equals
20776 !! options
20777 section=2
20778 !! wikitext
20779 ===
20780 The line above must have a trailing space
20781 === <!--
20782 --> <!-- -->
20783 But just in case it doesn't...
20784 !! html/php
20785 === <!--
20786 --> <!-- -->
20787 But just in case it doesn't...
20788 !! end
20789
20790 !! test
20791 Section replacement test (section 0)
20792 !! options
20793 replace=0,"xxx"
20794 !! wikitext
20795 start
20796 ==a==
20797 ===aa===
20798 ====aaa====
20799 ==b==
20800 ===ba===
20801 ===bb===
20802 ====bba====
20803 ===bc===
20804 ==c==
20805 ===ca===
20806 !! html/php
20807 xxx
20808
20809 ==a==
20810 ===aa===
20811 ====aaa====
20812 ==b==
20813 ===ba===
20814 ===bb===
20815 ====bba====
20816 ===bc===
20817 ==c==
20818 ===ca===
20819 !! end
20820
20821 !! test
20822 Section replacement test (section 1)
20823 !! options
20824 replace=1,"xxx"
20825 !! wikitext
20826 start
20827 ==a==
20828 ===aa===
20829 ====aaa====
20830 ==b==
20831 ===ba===
20832 ===bb===
20833 ====bba====
20834 ===bc===
20835 ==c==
20836 ===ca===
20837 !! html/php
20838 start
20839 xxx
20840
20841 ==b==
20842 ===ba===
20843 ===bb===
20844 ====bba====
20845 ===bc===
20846 ==c==
20847 ===ca===
20848 !! end
20849
20850 !! test
20851 Section replacement test (section 2)
20852 !! options
20853 replace=2,"xxx"
20854 !! wikitext
20855 start
20856 ==a==
20857 ===aa===
20858 ====aaa====
20859 ==b==
20860 ===ba===
20861 ===bb===
20862 ====bba====
20863 ===bc===
20864 ==c==
20865 ===ca===
20866 !! html/php
20867 start
20868 ==a==
20869 xxx
20870
20871 ==b==
20872 ===ba===
20873 ===bb===
20874 ====bba====
20875 ===bc===
20876 ==c==
20877 ===ca===
20878 !! end
20879
20880 !! test
20881 Section replacement test (section 3)
20882 !! options
20883 replace=3,"xxx"
20884 !! wikitext
20885 start
20886 ==a==
20887 ===aa===
20888 ====aaa====
20889 ==b==
20890 ===ba===
20891 ===bb===
20892 ====bba====
20893 ===bc===
20894 ==c==
20895 ===ca===
20896 !! html/php
20897 start
20898 ==a==
20899 ===aa===
20900 xxx
20901
20902 ==b==
20903 ===ba===
20904 ===bb===
20905 ====bba====
20906 ===bc===
20907 ==c==
20908 ===ca===
20909 !! end
20910
20911 !! test
20912 Section replacement test (section 4)
20913 !! options
20914 replace=4,"xxx"
20915 !! wikitext
20916 start
20917 ==a==
20918 ===aa===
20919 ====aaa====
20920 ==b==
20921 ===ba===
20922 ===bb===
20923 ====bba====
20924 ===bc===
20925 ==c==
20926 ===ca===
20927 !! html/php
20928 start
20929 ==a==
20930 ===aa===
20931 ====aaa====
20932 xxx
20933
20934 ==c==
20935 ===ca===
20936 !! end
20937
20938 !! test
20939 Section replacement test (section 5)
20940 !! options
20941 replace=5,"xxx"
20942 !! wikitext
20943 start
20944 ==a==
20945 ===aa===
20946 ====aaa====
20947 ==b==
20948 ===ba===
20949 ===bb===
20950 ====bba====
20951 ===bc===
20952 ==c==
20953 ===ca===
20954 !! html/php
20955 start
20956 ==a==
20957 ===aa===
20958 ====aaa====
20959 ==b==
20960 xxx
20961
20962 ===bb===
20963 ====bba====
20964 ===bc===
20965 ==c==
20966 ===ca===
20967 !! end
20968
20969 !! test
20970 Section replacement test (section 6)
20971 !! options
20972 replace=6,"xxx"
20973 !! wikitext
20974 start
20975 ==a==
20976 ===aa===
20977 ====aaa====
20978 ==b==
20979 ===ba===
20980 ===bb===
20981 ====bba====
20982 ===bc===
20983 ==c==
20984 ===ca===
20985 !! html/php
20986 start
20987 ==a==
20988 ===aa===
20989 ====aaa====
20990 ==b==
20991 ===ba===
20992 xxx
20993
20994 ===bc===
20995 ==c==
20996 ===ca===
20997 !! end
20998
20999 !! test
21000 Section replacement test (section 7)
21001 !! options
21002 replace=7,"xxx"
21003 !! wikitext
21004 start
21005 ==a==
21006 ===aa===
21007 ====aaa====
21008 ==b==
21009 ===ba===
21010 ===bb===
21011 ====bba====
21012 ===bc===
21013 ==c==
21014 ===ca===
21015 !! html/php
21016 start
21017 ==a==
21018 ===aa===
21019 ====aaa====
21020 ==b==
21021 ===ba===
21022 ===bb===
21023 xxx
21024
21025 ===bc===
21026 ==c==
21027 ===ca===
21028 !! end
21029
21030 !! test
21031 Section replacement test (section 8)
21032 !! options
21033 replace=8,"xxx"
21034 !! wikitext
21035 start
21036 ==a==
21037 ===aa===
21038 ====aaa====
21039 ==b==
21040 ===ba===
21041 ===bb===
21042 ====bba====
21043 ===bc===
21044 ==c==
21045 ===ca===
21046 !! html/php
21047 start
21048 ==a==
21049 ===aa===
21050 ====aaa====
21051 ==b==
21052 ===ba===
21053 ===bb===
21054 ====bba====
21055 xxx
21056
21057 ==c==
21058 ===ca===
21059 !!end
21060
21061 !! test
21062 Section replacement test (section 9)
21063 !! options
21064 replace=9,"xxx"
21065 !! wikitext
21066 start
21067 ==a==
21068 ===aa===
21069 ====aaa====
21070 ==b==
21071 ===ba===
21072 ===bb===
21073 ====bba====
21074 ===bc===
21075 ==c==
21076 ===ca===
21077 !! html/php
21078 start
21079 ==a==
21080 ===aa===
21081 ====aaa====
21082 ==b==
21083 ===ba===
21084 ===bb===
21085 ====bba====
21086 ===bc===
21087 xxx
21088 !! end
21089
21090 !! test
21091 Section replacement test (section 10)
21092 !! options
21093 replace=10,"xxx"
21094 !! wikitext
21095 start
21096 ==a==
21097 ===aa===
21098 ====aaa====
21099 ==b==
21100 ===ba===
21101 ===bb===
21102 ====bba====
21103 ===bc===
21104 ==c==
21105 ===ca===
21106 !! html/php
21107 start
21108 ==a==
21109 ===aa===
21110 ====aaa====
21111 ==b==
21112 ===ba===
21113 ===bb===
21114 ====bba====
21115 ===bc===
21116 ==c==
21117 xxx
21118 !! end
21119
21120 !! test
21121 Section replacement test with initial whitespace (T15728)
21122 !! options
21123 replace=2,"xxx"
21124 !! wikitext
21125 Preformatted initial line
21126 ==a==
21127 ===a===
21128 !! html/php
21129 Preformatted initial line
21130 ==a==
21131 xxx
21132 !! end
21133
21134
21135 !! test
21136 Section extraction, heading followed by pre with 20 spaces (T8398)
21137 !! options
21138 section=1
21139 !! wikitext
21140 ==a==
21141 a
21142 !! html/php
21143 ==a==
21144 a
21145 !! end
21146
21147 !! test
21148 Section extraction, heading followed by pre with 19 spaces (T8398 sanity check)
21149 !! options
21150 section=1
21151 !! wikitext
21152 ==a==
21153 a
21154 !! html/php
21155 ==a==
21156 a
21157 !! end
21158
21159
21160 !! test
21161 Section extraction, <pre> around bogus header (T12309)
21162 !! options
21163 section=2
21164 !! wikitext
21165 == Section One ==
21166 <pre>
21167 =======
21168 </pre>
21169
21170 == Section Two ==
21171 stuff
21172 !! html/php
21173 == Section Two ==
21174 stuff
21175 !! end
21176
21177 !! test
21178 Section replacement, <pre> around bogus header (T12309)
21179 !! options
21180 replace=2,"xxx"
21181 !! wikitext
21182 == Section One ==
21183 <pre>
21184 =======
21185 </pre>
21186
21187 == Section Two ==
21188 stuff
21189 !! html/php
21190 == Section One ==
21191 <pre>
21192 =======
21193 </pre>
21194
21195 xxx
21196 !! end
21197
21198 !! test
21199 Handling of &#x0A; in URLs
21200 !! wikitext
21201 *irc://&#x0A;a
21202 !! html/php
21203 <ul><li><a rel="nofollow" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul>
21204
21205 !! html/parsoid
21206 <ul><li><a rel="mw:ExtLink" class="external free" href="irc://%0Aa" data-parsoid='{"stx":"url","a":{"href":"irc://%0Aa"},"sa":{"href":"irc://&amp;#x0A;a"}}'>irc://%0Aa</a></li></ul>
21207 !! end
21208
21209 !! test
21210 Handling of %0A in URLs
21211 !! wikitext
21212 *irc://%0Aa
21213 !! html/php
21214 <ul><li><a rel="nofollow" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul>
21215
21216 !! html/parsoid
21217 <ul><li><a rel="mw:ExtLink" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul>
21218 !! end
21219
21220 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
21221 !! test
21222 5 quotes, code coverage +1 line
21223 !! options
21224 parsoid=wt2html
21225 !! wikitext
21226 '''''
21227 !! html/php
21228 !! html/parsoid
21229 <p><b><i></i></b></p>
21230 !! end
21231
21232 # same html as previous, but wikitext adjusted to match parsoid html2wt
21233 # note that wt2html and html2html will put the <i> before the <b>
21234 !! test
21235 5 quotes, code coverage +1 line w/ nowiki (1)
21236 !! options
21237 parsoid=wt2wt,html2wt
21238 !! wikitext
21239 '''''<nowiki/>'''''
21240 !! html/php
21241 <p><i></i>
21242 </p>
21243 !! html/parsoid
21244 <p><b><i></i></b></p>
21245 !! end
21246
21247 # same as previous, just swapping the <i> and <b>
21248 !! test
21249 5 quotes, code coverage +1 line w/ nowiki (2)
21250 !! wikitext
21251 '''''<nowiki/>'''''
21252 !! html/php
21253 <p><i></i>
21254 </p>
21255 !! html/parsoid
21256 <p><i><b></b></i></p>
21257 !! end
21258
21259 !! test
21260 Special:Search page linking.
21261 !! wikitext
21262 {{Special:search}}
21263 !! html
21264 <p><a href="/wiki/Special:Search" title="Special:Search">Special:Search</a>
21265 </p>
21266 !! end
21267
21268 !! test
21269 {{!}} is a magic word
21270 !! wikitext
21271 {{!}} is a magic word there and {{!}} is still a magic word here
21272 | is not a magic word here but {{!}} is still a magic word here
21273 !! html/php
21274 <p>| is a magic word there and | is still a magic word here
21275 | is not a magic word here but | is still a magic word here
21276 </p>
21277 !! html/parsoid
21278 <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
21279 | 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>
21280 !! end
21281
21282 !! test
21283 Say the magic word
21284 !! options
21285 title=[[Parser test]]
21286 !! wikitext
21287 *{{PAGENAME}}
21288 *{{PAGENAMEE}}
21289 *{{FULLPAGENAME}}
21290 *{{FULLPAGENAMEE}}
21291 *{{BASEPAGENAME}}
21292 *{{BASEPAGENAMEE}}
21293 *{{SUBPAGENAME}}
21294 *{{SUBPAGENAMEE}}
21295 *{{ROOTPAGENAME}}
21296 *{{ROOTPAGENAMEE}}
21297 *{{TALKPAGENAME}}
21298 *{{TALKPAGENAMEE}}
21299 *{{SUBJECTPAGENAME}}
21300 *{{SUBJECTPAGENAMEE}}
21301 *{{NAMESPACEE}}
21302 *{{NAMESPACE}}
21303 *{{NAMESPACENUMBER}}
21304 *{{TALKSPACE}}
21305 *{{TALKSPACEE}}
21306 *{{SUBJECTSPACE}}
21307 *{{SUBJECTSPACEE}}
21308 *{{Dynamic|{{NUMBEROFUSERS}}|{{NUMBEROFPAGES}}|{{CURRENTVERSION}}|{{CONTENTLANGUAGE}}|{{DIRECTIONMARK}}|{{CURRENTTIMESTAMP}}|{{NUMBEROFARTICLES}}}}
21309 !! html
21310 <ul><li>Parser test</li>
21311 <li>Parser_test</li>
21312 <li>Parser test</li>
21313 <li>Parser_test</li>
21314 <li>Parser test</li>
21315 <li>Parser_test</li>
21316 <li>Parser test</li>
21317 <li>Parser_test</li>
21318 <li>Parser test</li>
21319 <li>Parser_test</li>
21320 <li>Talk:Parser test</li>
21321 <li>Talk:Parser_test</li>
21322 <li>Parser test</li>
21323 <li>Parser_test</li>
21324 <li></li>
21325 <li></li>
21326 <li>0</li>
21327 <li>Talk</li>
21328 <li>Talk</li>
21329 <li></li>
21330 <li></li>
21331 <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>
21332
21333 !! end
21334 ### Note: Above tests excludes the "{{NUMBEROFADMINS}}" magic word because it generates a MySQL error when included.
21335
21336 !! test
21337 Gallery with valid attributes
21338 !! wikitext
21339 <gallery type="123" summary="345">
21340 File:File:Foobar.jpg
21341 </gallery>
21342 !! html/php
21343 <ul class="gallery mw-gallery-traditional" type="123">
21344 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21345 <div class="thumb" style="height: 150px;">File:Foobar.jpg</div>
21346 <div class="gallerytext">
21347 </div>
21348 </div></li>
21349 </ul>
21350
21351 !! html/parsoid
21352 <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"}}'>
21353 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline 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></figure-inline></div><div class="gallerytext"></div></li>
21354 </ul>
21355 !! end
21356
21357 ## Parsoid thinks the "centre" here is a property, not a caption.
21358 !! test
21359 Gallery
21360 !! options
21361 parsoid={
21362 "modes": ["wt2html"],
21363 "nativeGallery": true
21364 }
21365 !! wikitext
21366 <gallery>
21367 image1.png |
21368 image2.gif|||||
21369
21370 image3|
21371 image4 |300px| centre
21372 image5.svg| http://///////
21373 [[x|xx]]]]
21374 * image6
21375 </gallery>
21376 !! html/php
21377 <ul class="gallery mw-gallery-traditional">
21378 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21379 <div class="thumb" style="height: 150px;">Image1.png</div>
21380 <div class="gallerytext">
21381 </div>
21382 </div></li>
21383 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21384 <div class="thumb" style="height: 150px;">Image2.gif</div>
21385 <div class="gallerytext">
21386 </div>
21387 </div></li>
21388 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21389 <div class="thumb" style="height: 150px;">Image3</div>
21390 <div class="gallerytext">
21391 </div>
21392 </div></li>
21393 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21394 <div class="thumb" style="height: 150px;">Image4</div>
21395 <div class="gallerytext">
21396 <pre>centre
21397 </pre>
21398 </div>
21399 </div></li>
21400 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21401 <div class="thumb" style="height: 150px;">Image5.svg</div>
21402 <div class="gallerytext">
21403 <p><a rel="nofollow" class="external free" href="http://///////">http://///////</a>
21404 </p>
21405 </div>
21406 </div></li>
21407 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21408 <div class="thumb" style="height: 150px;">* image6</div>
21409 <div class="gallerytext">
21410 </div>
21411 </div></li>
21412 </ul>
21413
21414 !! html/parsoid
21415 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21416 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline 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></figure-inline></div><div class="gallerytext"></div></li>
21417 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline 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></figure-inline></div><div class="gallerytext"></div></li>
21418 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline typeof="mw:Error mw:Image"><a href="./File:Image3"><img resource="./File:Image3" src="./Special:FilePath/Image3" height="120" width="120"/></a></figure-inline></div><div class="gallerytext"></div></li>
21419 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline typeof="mw:Error mw:Image"><a href="./File:Image4"><img resource="./File:Image4" src="./Special:FilePath/Image4" height="300" width="300"/></a></figure-inline></div><div class="gallerytext"></div></li>
21420 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline 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></figure-inline></div><div class="gallerytext"> <a rel="mw:ExtLink" class="external free" href="http://///////">http://///////</a></div></li>
21421 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline typeof="mw:Error mw:Image"><a href="./File:*_image6"><img resource="./File:*_image6" src="./Special:FilePath/*_image6" height="120" width="120"/></a></figure-inline></div><div class="gallerytext"></div></li>
21422 </ul>
21423 !! end
21424
21425 !! test
21426 Gallery (with options, html)
21427 !! options
21428 parsoid={
21429 "modes": ["wt2html", "html2html"],
21430 "nativeGallery": true
21431 }
21432 !! wikitext
21433 <gallery widths="70px" heights="40px" perrow="2" caption="Foo [[Main Page]]">
21434 File:Nonexistent.jpg|caption
21435 File:Nonexistent.jpg
21436 image:foobar.jpg|some '''caption''' [[Main Page]]
21437 image:foobar.jpg
21438 image:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla.
21439 </gallery>
21440 !! html/php
21441 <ul class="gallery mw-gallery-traditional" style="max-width: 226px;_width: 226px;">
21442 <li class='gallerycaption'>Foo <a href="/wiki/Main_Page" title="Main Page">Main Page</a></li>
21443 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21444 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
21445 <div class="gallerytext">
21446 <p>caption
21447 </p>
21448 </div>
21449 </div></li>
21450 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21451 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
21452 <div class="gallerytext">
21453 </div>
21454 </div></li>
21455 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21456 <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" decoding="async" 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>
21457 <div class="gallerytext">
21458 <p>some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
21459 </p>
21460 </div>
21461 </div></li>
21462 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21463 <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" decoding="async" 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>
21464 <div class="gallerytext">
21465 </div>
21466 </div></li>
21467 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21468 <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" decoding="async" 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>
21469 <div class="gallerytext">
21470 <p>blabla.
21471 </p>
21472 </div>
21473 </div></li>
21474 </ul>
21475
21476 !! html/parsoid
21477 <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":{}}'>
21478 <li class="gallerycaption">Foo <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></li>
21479 <li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><figure-inline 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></figure-inline></div><div class="gallerytext">caption</div></li>
21480 <li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><figure-inline 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></figure-inline></div><div class="gallerytext"></div></li>
21481 <li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><figure-inline 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></figure-inline></div><div class="gallerytext">some <b>caption</b> <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></div></li>
21482 <li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><figure-inline 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></figure-inline></div><div class="gallerytext"></div></li>
21483 <li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><figure-inline 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></figure-inline></div><div class="gallerytext">blabla.</div></li>
21484 </ul>
21485 !! end
21486
21487 !! test
21488 Gallery (with options, extsrc)
21489 !! options
21490 parsoid={
21491 "nativeGallery": false
21492 }
21493 !! wikitext
21494 <gallery widths="70px" heights="40px" perrow="2" caption="Foo [[Main Page]]">
21495 File:Nonexistent.jpg|caption
21496 File:Nonexistent.jpg
21497 image:foobar.jpg|some '''caption''' [[Main Page]]
21498 image:foobar.jpg
21499 image:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla.
21500 </gallery>
21501 !! html/php
21502 <ul class="gallery mw-gallery-traditional" style="max-width: 226px;_width: 226px;">
21503 <li class='gallerycaption'>Foo <a href="/wiki/Main_Page" title="Main Page">Main Page</a></li>
21504 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21505 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
21506 <div class="gallerytext">
21507 <p>caption
21508 </p>
21509 </div>
21510 </div></li>
21511 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21512 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
21513 <div class="gallerytext">
21514 </div>
21515 </div></li>
21516 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21517 <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" decoding="async" 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>
21518 <div class="gallerytext">
21519 <p>some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
21520 </p>
21521 </div>
21522 </div></li>
21523 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21524 <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" decoding="async" 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>
21525 <div class="gallerytext">
21526 </div>
21527 </div></li>
21528 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21529 <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" decoding="async" 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>
21530 <div class="gallerytext">
21531 <p>blabla.
21532 </p>
21533 </div>
21534 </div></li>
21535 </ul>
21536
21537 !! html/parsoid
21538 <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"}}'>
21539 <li class="gallerycaption">Foo <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></li>
21540 <li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><figure-inline 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></figure-inline></div><div class="gallerytext">caption</div></li>
21541 <li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><figure-inline 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></figure-inline></div><div class="gallerytext"></div></li>
21542 <li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><figure-inline 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></figure-inline></div><div class="gallerytext">some <b>caption</b> <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></div></li>
21543 <li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><figure-inline 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></figure-inline></div><div class="gallerytext"></div></li>
21544 <li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><figure-inline 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></figure-inline></div><div class="gallerytext">blabla.</div></li>
21545 </ul>
21546 !! end
21547
21548 !! test
21549 Gallery (without px units)
21550 !! wikitext
21551 <gallery widths="70" heights="40">
21552 File:Foobar.jpg
21553 </gallery>
21554 !! html/php
21555 <ul class="gallery mw-gallery-traditional">
21556 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21557 <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" decoding="async" 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>
21558 <div class="gallerytext">
21559 </div>
21560 </div></li>
21561 </ul>
21562
21563 !! html/parsoid
21564 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{"widths":"70","heights":"40"},"body":{"extsrc":"\nFile:Foobar.jpg\n"}}'>
21565 <li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><figure-inline 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></figure-inline></div><div class="gallerytext"></div></li>
21566 </ul>
21567 !! end
21568
21569 !! test
21570 Gallery (with invalid units)
21571 !! wikitext
21572 <gallery widths="70em" heights="40em">
21573 File:Foobar.jpg
21574 </gallery>
21575 !! html/php
21576 <ul class="gallery mw-gallery-traditional">
21577 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21578 <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" decoding="async" 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>
21579 <div class="gallerytext">
21580 </div>
21581 </div></li>
21582 </ul>
21583
21584 !! html/parsoid
21585 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{"widths":"70em","heights":"40em"},"body":{"extsrc":"\nFile:Foobar.jpg\n"}}'>
21586 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline 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></figure-inline></div><div class="gallerytext"></div></li>
21587 </ul>
21588 !! end
21589
21590 !! test
21591 Gallery with link that has fragment
21592 !! options
21593 parsoid={
21594 "modes": ["wt2html", "html2html"],
21595 "nativeGallery": true
21596 }
21597 !! wikitext
21598 <gallery>
21599 image:foobar.jpg|link=Main_Page
21600 image:foobar.jpg|link=Main_Page#section
21601 image:foobar.jpg|link=Main Page#section|caption
21602 </gallery>
21603 !! html/php
21604 <ul class="gallery mw-gallery-traditional">
21605 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21606 <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" decoding="async" 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>
21607 <div class="gallerytext">
21608 </div>
21609 </div></li>
21610 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21611 <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" decoding="async" 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>
21612 <div class="gallerytext">
21613 </div>
21614 </div></li>
21615 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21616 <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" decoding="async" 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>
21617 <div class="gallerytext">
21618 <p>caption
21619 </p>
21620 </div>
21621 </div></li>
21622 </ul>
21623
21624 !! html/parsoid
21625 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21626 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline 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></figure-inline></div><div class="gallerytext"></div></li>
21627 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline 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></figure-inline></div><div class="gallerytext"></div></li>
21628 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline 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></figure-inline></div><div class="gallerytext">caption</div></li>
21629 </ul>
21630 !! end
21631
21632 !! test
21633 Gallery with template inside caption
21634 !! options
21635 parsoid={
21636 "nativeGallery": true
21637 }
21638 !! wikitext
21639 <gallery caption="{{echo|hi}}">
21640 File:Foobar.jpg|{{echo|ho}}
21641 </gallery>
21642 !! html/php
21643 <ul class="gallery mw-gallery-traditional">
21644 <li class='gallerycaption'>hi</li>
21645 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21646 <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" decoding="async" 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>
21647 <div class="gallerytext">
21648 <p>ho
21649 </p>
21650 </div>
21651 </div></li>
21652 </ul>
21653
21654 !! html/parsoid
21655 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt6" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21656 <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>
21657 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline 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></figure-inline></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>
21658 </ul>
21659 !! end
21660
21661 !! test
21662 Gallery with wikitext inside gallery caption
21663 !! wikitext
21664 <gallery caption="# List item
21665
21666 Text '''bold''' [[link]] {{ns:-1}}
21667
21668 [[File:Foobar.jpg|thumb|File in gallery caption]]">
21669 File:Foobar.jpg|Image caption
21670 </gallery>
21671 !! html/php
21672 <ul class="gallery mw-gallery-traditional">
21673 <li class='gallerycaption'># List item Text <b>bold</b> <a href="/index.php?title=Link&amp;action=edit&amp;redlink=1" class="new" title="Link (page does not exist)">link</a> Special <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" decoding="async" 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>File in gallery caption</div></div></div></li>
21674 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21675 <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" decoding="async" 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>
21676 <div class="gallerytext">
21677 <p>Image caption
21678 </p>
21679 </div>
21680 </div></li>
21681 </ul>
21682
21683 !! end
21684
21685 !! test
21686 Gallery with wikitext inside caption
21687 !! options
21688 parsoid={
21689 "nativeGallery": true
21690 }
21691 !! wikitext
21692 <gallery>
21693 File:Foobar.jpg|alt=galleryalt|[[File:Foobar.jpg|alt=inneralt|20x20px|desc]]
21694 File:Foobar.jpg|alt=galleryalt|{{Test|unamedParam|alt=param}}
21695 </gallery>
21696 !! html/php
21697 <ul class="gallery mw-gallery-traditional">
21698 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21699 <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" decoding="async" 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>
21700 <div class="gallerytext">
21701 <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" decoding="async" 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>
21702 </p>
21703 </div>
21704 </div></li>
21705 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21706 <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" decoding="async" 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>
21707 <div class="gallerytext">
21708 <p>This is a test template
21709 </p>
21710 </div>
21711 </div></li>
21712 </ul>
21713
21714 !! html/parsoid
21715 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt6" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21716 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline 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></figure-inline></div><div class="gallerytext"><figure-inline 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></figure-inline></div></li>
21717 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline 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></figure-inline></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>
21718 </ul>
21719 !! end
21720
21721 !! test
21722 Gallery (with showfilename option)
21723 !! options
21724 parsoid={
21725 "nativeGallery": true
21726 }
21727 !! wikitext
21728 <gallery showfilename="">
21729 File:Nonexistent.jpg|caption
21730 File:Nonexistent.jpg
21731 File:Foobar.jpg|some '''caption''' [[Main Page]]
21732 File:Foobar.jpg
21733 </gallery>
21734 !! html/php
21735 <ul class="gallery mw-gallery-traditional">
21736 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21737 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
21738 <div class="gallerytext">
21739 <p><a href="/wiki/File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">Nonexistent.jpg</a>
21740 caption
21741 </p>
21742 </div>
21743 </div></li>
21744 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21745 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
21746 <div class="gallerytext">
21747 <p><a href="/wiki/File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">Nonexistent.jpg</a>
21748 </p>
21749 </div>
21750 </div></li>
21751 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21752 <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" decoding="async" 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>
21753 <div class="gallerytext">
21754 <p><a href="/wiki/File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">Foobar.jpg</a>
21755 some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
21756 </p>
21757 </div>
21758 </div></li>
21759 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21760 <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" decoding="async" 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>
21761 <div class="gallerytext">
21762 <p><a href="/wiki/File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">Foobar.jpg</a>
21763 </p>
21764 </div>
21765 </div></li>
21766 </ul>
21767
21768 !! html/parsoid
21769 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{"showfilename":""},"body":{}}'>
21770 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline 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></figure-inline></div><div class="gallerytext"><a href="./File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">File:Nonexistent.jpg</a>caption</div></li>
21771 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline 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></figure-inline></div><div class="gallerytext"><a href="./File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">File:Nonexistent.jpg</a></div></li>
21772 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline 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></figure-inline></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>
21773 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline 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></figure-inline></div><div class="gallerytext"><a href="./File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">File:Foobar.jpg</a></div></li>
21774 </ul>
21775 !! end
21776
21777 ## Should Parsoid be preserving these variations? See T151367
21778 !! test
21779 Gallery (with namespace-less filenames)
21780 !! options
21781 parsoid={
21782 "modes": ["wt2html", "html2html"],
21783 "nativeGallery": true
21784 }
21785 !! wikitext
21786 <gallery>
21787 File:Nonexistent.jpg
21788 Nonexistent.jpg
21789 image:foobar.jpg
21790 foobar.jpg
21791 </gallery>
21792 !! html/php
21793 <ul class="gallery mw-gallery-traditional">
21794 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21795 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
21796 <div class="gallerytext">
21797 </div>
21798 </div></li>
21799 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21800 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
21801 <div class="gallerytext">
21802 </div>
21803 </div></li>
21804 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21805 <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" decoding="async" 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>
21806 <div class="gallerytext">
21807 </div>
21808 </div></li>
21809 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21810 <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" decoding="async" 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>
21811 <div class="gallerytext">
21812 </div>
21813 </div></li>
21814 </ul>
21815
21816 !! html/parsoid
21817 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21818 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline 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></figure-inline></div><div class="gallerytext"></div></li>
21819 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline 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></figure-inline></div><div class="gallerytext"></div></li>
21820 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline 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></figure-inline></div><div class="gallerytext"></div></li>
21821 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline 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></figure-inline></div><div class="gallerytext"></div></li>
21822 </ul>
21823 !! end
21824
21825 !! test
21826 Gallery override link with wikilink (T36852)
21827 !! options
21828 parsoid={
21829 "nativeGallery": true
21830 }
21831 !! wikitext
21832 <gallery>
21833 File:Foobar.jpg|alt=galleryalt|link=Wikilink
21834 </gallery>
21835 !! html/php
21836 <ul class="gallery mw-gallery-traditional">
21837 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21838 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/Wikilink"><img alt="galleryalt" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" decoding="async" 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>
21839 <div class="gallerytext">
21840 </div>
21841 </div></li>
21842 </ul>
21843
21844 !! html/parsoid
21845 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21846 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline typeof="mw:Image"><a href="./Wikilink"><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></figure-inline></div><div class="gallerytext"></div></li>
21847 </ul>
21848 !! end
21849
21850 !! test
21851 Gallery override link with absolute external link (T36852)
21852 !! options
21853 parsoid={
21854 "nativeGallery": true
21855 }
21856 !! wikitext
21857 <gallery>
21858 File:Foobar.jpg|alt=galleryalt|link=http://www.example.org
21859 </gallery>
21860 !! html/php
21861 <ul class="gallery mw-gallery-traditional">
21862 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21863 <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" decoding="async" 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>
21864 <div class="gallerytext">
21865 </div>
21866 </div></li>
21867 </ul>
21868
21869 !! html/parsoid
21870 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21871 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline 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></figure-inline></div><div class="gallerytext"></div></li>
21872 </ul>
21873 !! end
21874
21875 !! test
21876 Gallery override link with absolute external link with LanguageConverter
21877 !! options
21878 language=zh
21879 !! wikitext
21880 <gallery>
21881 File:foobar.jpg|caption|alt=galleryalt|link=http://www.example.org
21882 </gallery>
21883 !! html/php
21884 <ul class="gallery mw-gallery-traditional">
21885 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21886 <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" decoding="async" 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>
21887 <div class="gallerytext">
21888 <p>caption
21889 </p>
21890 </div>
21891 </div></li>
21892 </ul>
21893
21894 !! html/parsoid
21895 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{"extsrc":"\nFile:foobar.jpg|caption|alt=galleryalt|link=http://www.example.org\n"}}'>
21896 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline 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></figure-inline></div><div class="gallerytext">caption</div></li>
21897 </ul>
21898 !! end
21899
21900 !! test
21901 Gallery override link with malicious javascript (T36852)
21902 !! options
21903 parsoid={
21904 "modes": ["wt2html", "html2html"],
21905 "nativeGallery": true
21906 }
21907 !! wikitext
21908 <gallery>
21909 File:Foobar.jpg|alt=galleryalt|link=" onclick="alert('malicious javascript code!');
21910 </gallery>
21911 !! html/php
21912 <ul class="gallery mw-gallery-traditional">
21913 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21914 <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" decoding="async" 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>
21915 <div class="gallerytext">
21916 </div>
21917 </div></li>
21918 </ul>
21919
21920 !! html/parsoid
21921 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21922 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline 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></figure-inline></div><div class="gallerytext"></div></li>
21923 </ul>
21924 !! end
21925
21926 # Note that parsoid uses the invalid link as a caption, PHP does not.
21927 !! test
21928 Gallery with invalid title as link (T45964)
21929 !! options
21930 parsoid={
21931 "modes": ["wt2html", "html2html"],
21932 "nativeGallery": true
21933 }
21934 !! wikitext
21935 <gallery>
21936 File:Foobar.jpg|link=<
21937 </gallery>
21938 !! html/php
21939 <ul class="gallery mw-gallery-traditional">
21940 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21941 <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" decoding="async" 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>
21942 <div class="gallerytext">
21943 </div>
21944 </div></li>
21945 </ul>
21946
21947 !! html/parsoid
21948 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21949 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline 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></figure-inline></div><div class="gallerytext">link=&lt;</div></li>
21950 </ul>
21951 !! end
21952
21953 !! test
21954 Serialize gallery without attrs in data-mw
21955 !! options
21956 parsoid={
21957 "modes": ["html2wt"],
21958 "nativeGallery": true
21959 }
21960 !! html/parsoid
21961 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","body":{}}'>
21962 <li class="gallerycaption">123</li>
21963 <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>
21964 </ul>
21965 !! wikitext
21966 <gallery caption="123">
21967 File:Test.png
21968 </gallery>
21969 !! end
21970
21971 !! test
21972 Gallery with class and style attributes
21973 !! options
21974 parsoid={
21975 "nativeGallery": true
21976 }
21977 !! wikitext
21978 <gallery class="center" style="text-align: center;">
21979 File:Foobar.jpg
21980 </gallery>
21981 !! html/php
21982 <ul class="gallery mw-gallery-traditional center" style="text-align: center;">
21983 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21984 <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" decoding="async" 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>
21985 <div class="gallerytext">
21986 </div>
21987 </div></li>
21988 </ul>
21989
21990 !! html/parsoid
21991 <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":{}}'>
21992 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline 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></figure-inline></div><div class="gallerytext"></div></li>
21993 </ul>
21994 !! end
21995
21996 !! test
21997 Gallery in slideshow mode
21998 !! options
21999 parsoid={
22000 "nativeGallery": true
22001 }
22002 !! wikitext
22003 <gallery mode="slideshow" showthumbnails="">
22004 File:Foobar.jpg
22005 </gallery>
22006 !! html/php
22007 <ul class="gallery mw-gallery-slideshow" data-showthumbnails="1">
22008 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
22009 <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" decoding="async" 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>
22010 <div class="gallerytext">
22011 </div>
22012 </div></li>
22013 </ul>
22014
22015 !! html/parsoid
22016 <ul class="gallery mw-gallery-slideshow" data-showthumbnails="1" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{"mode":"slideshow","showthumbnails":""},"body":{}}'>
22017 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px;"><figure-inline 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></figure-inline></div><div class="gallerytext"></div></li>
22018 </ul>
22019 !! end
22020
22021 !! test
22022 Serialize gallery image captions on a line
22023 !! options
22024 parsoid={
22025 "modes": ["html2wt"],
22026 "nativeGallery": true
22027 }
22028 !! html/parsoid
22029 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
22030 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px;"><figure-inline 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></figure-inline></div><div class="gallerytext"><p>hi</p><p>ho</p></div></li>
22031 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px;"><figure-inline 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></figure-inline></div><div class="gallerytext">hi<br />ho</div></li>
22032 </ul>
22033 !! wikitext
22034 <gallery>
22035 File:Foobar.jpg| hi ho
22036 File:Foobar.jpg|hi<br />ho
22037 </gallery>
22038 !! end
22039
22040 !! test
22041 HTML Hex character encoding (spells the word "JavaScript")
22042 !! options
22043 parsoid=wt2html,wt2wt,html2html
22044 !! wikitext
22045 &#x4A;&#x061;&#x0076;&#x00061;&#x000053;&#x0000063;&#114;&#x0000069;&#00000112;&#x0000000074;
22046 !! html/php
22047 <p>&#x4a;&#x61;&#x76;&#x61;&#x53;&#x63;&#114;&#x69;&#112;&#x74;
22048 </p>
22049 !! html/parsoid
22050 <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>
22051 !! end
22052
22053 !! test
22054 HTML Hex character encoding bogus encoding (T28437 regression check)
22055 !! wikitext
22056 &#xsee;&#XSEE;
22057 !! html
22058 <p>&amp;#xsee;&amp;#XSEE;
22059 </p>
22060 !! end
22061
22062 !! test
22063 HTML Hex character encoding mixed case
22064 !! options
22065 parsoid=wt2html,wt2wt,html2html
22066 !! wikitext
22067 &#xEE;&#Xee;
22068 !! html/php
22069 <p>&#xee;&#xee;
22070 </p>
22071 !! html/parsoid
22072 <p><span typeof="mw:Entity">î</span><span typeof="mw:Entity">î</span></p>
22073 !! end
22074
22075 # See: https://www.w3.org/TR/html5/syntax.html#character-references
22076 # Note that U+000C (form feed) is not a valid XML character, so
22077 # it is banned even though allowed in HTML5.
22078 !! test
22079 Illegal character references (T106578)
22080 !! wikitext
22081 ; Null: &#00;
22082 ; FF: &#xC;
22083 ; CR: &#xD;
22084 ; Control (low): &#8;
22085 ; Control (high): &#x7F; &#x9F;
22086 ; Surrogate: &#xD83D;&#xDCA9;
22087 ; This is an okay astral character: &#x1F4A9;
22088 !! html+tidy
22089 <dl><dt>Null</dt>
22090 <dd>&amp;#00;</dd>
22091 <dt>FF</dt>
22092 <dd>&amp;#xC;</dd>
22093 <dt>CR</dt>
22094 <dd>&amp;#xD;</dd>
22095 <dt>Control (low)</dt>
22096 <dd>&amp;#8;</dd>
22097 <dt>Control (high)</dt>
22098 <dd>&amp;#x7F; &amp;#x9F;</dd>
22099 <dt>Surrogate</dt>
22100 <dd>&amp;#xD83D;&amp;#xDCA9;</dd>
22101 <dt>This is an okay astral character</dt>
22102 <dd>&#x1f4a9;</dd></dl>
22103 !! end
22104
22105 !! test
22106 __FORCETOC__ override
22107 !! wikitext
22108 __NEWSECTIONLINK__
22109 __FORCETOC__
22110 !! html/php
22111 <p><br />
22112 </p>
22113 !! end
22114
22115 !! test
22116 ISBN code coverage
22117 !! wikitext
22118 ISBN 978-0-1234-56&#x20;789
22119 !! html/php
22120 <p><a href="/wiki/Special:BookSources/9780123456" class="internal mw-magiclink-isbn">ISBN 978-0-1234-56</a>&#x20;789
22121 </p>
22122 !! html/parsoid
22123 <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>
22124 !! end
22125
22126 !! test
22127 ISBN followed by 5 spaces
22128 !! wikitext
22129 ISBN
22130 !! html
22131 <p>ISBN
22132 </p>
22133 !! end
22134
22135 !! test
22136 Double ISBN
22137 !! wikitext
22138 ISBN ISBN 1234567890
22139 !! html/php
22140 <p>ISBN <a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
22141 </p>
22142 !! html/parsoid
22143 <p>ISBN <a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a></p>
22144 !! end
22145
22146 # Uppercase X and lowercase x as well
22147 !! test
22148 ISBN with an X
22149 !! wikitext
22150 ISBN 3-462-04561-X
22151 ISBN 3-462-04561-x
22152 ISBN 080442957X
22153 ISBN 080442957x
22154 ISBN 978080442957X
22155 ISBN 978080442957x
22156 !! html/php
22157 <p><a href="/wiki/Special:BookSources/346204561X" class="internal mw-magiclink-isbn">ISBN 3-462-04561-X</a>
22158 <a href="/wiki/Special:BookSources/346204561X" class="internal mw-magiclink-isbn">ISBN 3-462-04561-x</a>
22159 <a href="/wiki/Special:BookSources/080442957X" class="internal mw-magiclink-isbn">ISBN 080442957X</a>
22160 <a href="/wiki/Special:BookSources/080442957X" class="internal mw-magiclink-isbn">ISBN 080442957x</a>
22161 <a href="/wiki/Special:BookSources/978080442957X" class="internal mw-magiclink-isbn">ISBN 978080442957X</a>
22162 <a href="/wiki/Special:BookSources/978080442957X" class="internal mw-magiclink-isbn">ISBN 978080442957x</a>
22163 </p>
22164 !! html/parsoid
22165 <p><a href="./Special:BookSources/346204561X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 3-462-04561-X</a>
22166 <a href="./Special:BookSources/346204561X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 3-462-04561-x</a>
22167 <a href="./Special:BookSources/080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 080442957X</a>
22168 <a href="./Special:BookSources/080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 080442957x</a>
22169 <a href="./Special:BookSources/978080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978080442957X</a>
22170 <a href="./Special:BookSources/978080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978080442957x</a></p>
22171 !! end
22172
22173 !! test
22174 ISBN with empty prefix (parsoid test)
22175 !! wikitext
22176 ISBN 1234567890
22177 !! html/php
22178 <p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
22179 </p>
22180 !! html/parsoid
22181 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink">ISBN 1234567890</a></p>
22182 !! end
22183
22184 !! test
22185 T24905: <abbr> followed by ISBN followed by </a>
22186 !! wikitext
22187 <abbr>(fr)</abbr> ISBN 2753300917 [http://www.example.com example.com]
22188 !! html/php
22189 <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>
22190 </p>
22191 !! html/parsoid
22192 <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" class="external text" href="http://www.example.com">example.com</a></p>
22193 !! end
22194
22195 !! test
22196 Double RFC
22197 !! wikitext
22198 RFC RFC 1234
22199 !! html/php
22200 <p>RFC <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc1234">RFC 1234</a>
22201 </p>
22202 !! html/parsoid
22203 <p>RFC <a href="https://tools.ietf.org/html/rfc1234" rel="mw:ExtLink" class="external mw-magiclink">RFC 1234</a></p>
22204 !! end
22205
22206 !! test
22207 Double RFC with a wiki link
22208 !! wikitext
22209 RFC [[RFC 1234]]
22210 !! html/php
22211 <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>
22212 </p>
22213 !! html/parsoid
22214 <p>RFC <a rel="mw:WikiLink" href="./RFC_1234" title="RFC 1234">RFC 1234</a></p>
22215 !! end
22216
22217 !! test
22218 RFC code coverage
22219 !! wikitext
22220 RFC 983&#x20;987
22221 !! html/php
22222 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc983">RFC 983</a>&#x20;987
22223 </p>
22224 !! html/parsoid
22225 <p><a href="https://tools.ietf.org/html/rfc983" rel="mw:ExtLink" class="external mw-magiclink" data-parsoid='{"stx":"magiclink"}'>RFC 983</a><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#x20;","srcContent":" "}'> </span>987</p>
22226 !! end
22227
22228 !! test
22229 Centre-aligned image
22230 !! wikitext
22231 [[Image:foobar.jpg|centre]]
22232 !! html/php
22233 <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" decoding="async" width="1941" height="220" /></a></div></div>
22234
22235 !! html/parsoid
22236 <figure class="mw-default-size mw-halign-center" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"center","ak":"centre"}]}'><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></figure>
22237 !! end
22238
22239 !! test
22240 None-aligned image
22241 !! wikitext
22242 [[Image:foobar.jpg|none]]
22243 !! html/php
22244 <div class="floatnone"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" /></a></div>
22245
22246 !! html/parsoid
22247 <figure class="mw-default-size mw-halign-none" 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></figure>
22248 !! end
22249
22250 !! test
22251 Width + Height sized image (using px) (height is ignored)
22252 !! wikitext
22253 [[Image:foobar.jpg|640x480px]]
22254 !! html/php
22255 <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" decoding="async" 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>
22256 </p>
22257 !! html/parsoid
22258 <p><figure-inline typeof="mw:Image" data-parsoid='{"optList":[{"ck":"width","ak":"640x480px"}]}'><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/640px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="73" width="640" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"73","width":"640"},"sa":{"resource":"Image:foobar.jpg"}}'/></a></figure-inline></p>
22259 !! end
22260
22261 !! test
22262 Width-sized image (using px, no following whitespace)
22263 !! wikitext
22264 [[Image:foobar.jpg|640px]]
22265 !! html/php
22266 <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" decoding="async" 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>
22267 </p>
22268 !! html/parsoid
22269 <p><figure-inline typeof="mw:Image" data-parsoid='{"optList":[{"ck":"width","ak":"640px"}]}'><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/640px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="73" width="640" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"73","width":"640"},"sa":{"resource":"Image:foobar.jpg"}}'/></a></figure-inline></p>
22270 !! end
22271
22272 !! test
22273 Width-sized image (using px, with following whitespace - test regression from r39467)
22274 !! wikitext
22275 [[Image:foobar.jpg|640px ]]
22276 !! html/php
22277 <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" decoding="async" 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>
22278 </p>
22279 !! html/parsoid
22280 <p><figure-inline typeof="mw:Image" data-parsoid='{"optList":[{"ck":"width","ak":"640px "}]}'><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/640px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="73" width="640" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"73","width":"640"},"sa":{"resource":"Image:foobar.jpg"}}'/></a></figure-inline></p>
22281 !!end
22282
22283 !! test
22284 Width-sized image (using px, with preceding whitespace - test regression from r39467)
22285 !! wikitext
22286 [[Image:foobar.jpg| 640px]]
22287 !! html/php
22288 <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" decoding="async" 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>
22289 </p>
22290 !! html/parsoid
22291 <p><figure-inline typeof="mw:Image" data-parsoid='{"optList":[{"ck":"width","ak":" 640px"}]}'><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/640px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="73" width="640" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"73","width":"640"},"sa":{"resource":"Image:foobar.jpg"}}'/></a></figure-inline></p>
22292 !! end
22293
22294 !! test
22295 Image with page parameter
22296 !! options
22297 djvu
22298 !! wikitext
22299 [[File:LoremIpsum.djvu|page=2]]
22300 !! html/php
22301 <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" decoding="async" 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>
22302 </p>
22303 !! html/parsoid
22304 <p><figure-inline 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></figure-inline></p>
22305 !! end
22306
22307 !! test
22308 Another italics / bold test
22309 !! wikitext
22310 ''' ''x'
22311 !! html
22312 <pre>'<i> </i>x'
22313 </pre>
22314 !!end
22315
22316 # FIXME: The php output seems broken. It's interleaving some open/close tags.
22317 !! test
22318 dt/dd/dl test
22319 !! wikitext
22320 :;;;::
22321 !! html/php
22322 <dl><dd><dl><dt><dl><dt><dl><dt><dl><dd><dl><dd></dt></dl></dd></dl></dd></dl></dd></dl></dd></dl></dd></dl>
22323
22324 !! html/parsoid
22325 <dl><dd><dl><dt><dl><dt><dl><dt><dl><dd><dl><dd></dd></dl></dd></dl></dt></dl></dt></dl></dt></dl></dd></dl>
22326
22327 !!end
22328
22329 # Images with the "|" character in external URLs in comment tags; Eats half the comment, leaves unmatched "</a>" tag.
22330 !! test
22331 Images with the "|" character in the comment
22332 !! wikitext
22333 [[File:Foobar.jpg|thumb|An [http://test/?param1=|left|&param2=|x external] URL]]
22334 !! html/php
22335 <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" decoding="async" 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>
22336
22337 !! html/parsoid
22338 <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" class="external text" 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>
22339 !! end
22340
22341 !! test
22342 [Before] HTML without raw HTML enabled ($wgRawHtml==false)
22343 !! wikitext
22344 <html><script>alert(1);</script></html>
22345 !! html
22346 <p>&lt;html&gt;&lt;script&gt;alert(1);&lt;/script&gt;&lt;/html&gt;
22347 </p>
22348 !! end
22349
22350 !! test
22351 HTML with raw HTML ($wgRawHtml==true)
22352 !! options
22353 wgRawHtml=1
22354 !! wikitext
22355 <html><script>alert(1);</script></html>
22356 !! html/php
22357 <p><script>alert(1);</script>
22358 </p>
22359 !! html/parsoid
22360 <p><script typeof="mw:Extension/html" about="#mwt3" data-mw='{"name":"html","attrs":{},"body":{"extsrc":"&lt;script>alert(1);&lt;/script>"}}'>alert(1);</script></p>
22361 !! end
22362
22363 !! test
22364 Parents of subpages, one level up
22365 !! options
22366 subpage title=[[Subpage test/L1/L2/L3]]
22367 !! wikitext
22368 [[../|L2]]
22369 !! html
22370 <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>
22371 </p>
22372 !! end
22373
22374
22375 !! test
22376 Parents of subpages, one level up, not named
22377 !! options
22378 subpage title=[[Subpage test/L1/L2/L3]]
22379 !! wikitext
22380 [[../]]
22381 !! html
22382 <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>
22383 </p>
22384 !! end
22385
22386
22387
22388 !! test
22389 Parents of subpages, two levels up
22390 !! options
22391 subpage title=[[Subpage test/L1/L2/L3]]
22392 !! wikitext
22393 [[../../|L1]]2
22394
22395 [[../../|L1]]l
22396 !! html
22397 <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
22398 </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>
22399 </p>
22400 !! end
22401
22402 !! test
22403 Parents of subpages, two levels up, without trailing slash or name.
22404 !! options
22405 subpage title=[[Subpage test/L1/L2/L3]]
22406 !! wikitext
22407 [[../..]]
22408 !! html
22409 <p>[[../..]]
22410 </p>
22411 !! end
22412
22413 !! test
22414 Parents of subpages, two levels up, with lots of extra trailing slashes.
22415 !! options
22416 subpage title=[[Subpage test/L1/L2/L3]]
22417 !! wikitext
22418 [[../../////]]
22419 !! html
22420 <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>
22421 </p>
22422 !! end
22423
22424 !! article
22425 Subpage test/L1/L2/L3Sibling
22426 !! text
22427 Sibling article
22428 !! endarticle
22429
22430 !! test
22431 Transclusion of a sibling page (one level up)
22432 !! options
22433 subpage title=[[Subpage test/L1/L2/L3]]
22434 !! wikitext
22435 {{../L3Sibling}}
22436 !! html
22437 <p>Sibling article
22438 </p>
22439 !! end
22440
22441 !! test
22442 Transclusion of a child page
22443 !! options
22444 subpage title=[[Subpage test/L1/L2]]
22445 !! wikitext
22446 {{/L3Sibling}}
22447 !! html
22448 <p>Sibling article
22449 </p>
22450 !! end
22451
22452 # This is wt2html only in Parsoid because we add <nowiki>
22453 # because of {{..}} and we don't expect to fix that to
22454 # eliminate the nowikis selective for {{..}} markup.
22455 !! test
22456 Non-transclusion because of too many up levels
22457 !! options
22458 subpage title=[[Subpage test/L1/L2/L3]]
22459 parsoid=wt2html
22460 !! wikitext
22461 {{../../../../More than parent}}
22462 !! html/php
22463 <p>{{../../../../More than parent}}
22464 </p>
22465 !! html/parsoid
22466 <p>{{../../../../More than parent}}</p>
22467 !! end
22468
22469 !! test
22470 Definition list code coverage
22471 !! wikitext
22472 ;title :def
22473 ;title :def
22474 ;title:def
22475 !! html/php
22476 <dl><dt>title</dt>
22477 <dd>def</dd>
22478 <dt>title</dt>
22479 <dd>def</dd>
22480 <dt>title</dt>
22481 <dd>def</dd></dl>
22482
22483 !! html/parsoid
22484 <dl><dt>title </dt><dd>def</dd>
22485 <dt>title </dt><dd>def</dd>
22486 <dt>title</dt><dd>def</dd></dl>
22487 !! end
22488
22489 !! test
22490 Don't fall for the self-closing div
22491 !! wikitext
22492 <div>hello world</div/>
22493 !! html
22494 <div>hello world</div>
22495
22496 !! end
22497
22498 !! test
22499 MSGNW magic word
22500 !! wikitext
22501 {{MSGNW:msg}}
22502 !! html/php
22503 <p>&#91;&#91;:Template:Msg&#93;&#93;
22504 </p>
22505 !! end
22506
22507 !! test
22508 RAW magic word
22509 !! wikitext
22510 {{RAW:QUERTY}}
22511 !! html
22512 <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>
22513 </p>
22514 !! end
22515
22516 # This isn't needed for XHTML conformance, but would be handy as a fallback security measure
22517 !! test
22518 Always escape literal '>' in output, not just after '<'
22519 !! wikitext
22520 ><>
22521 !! html
22522 <p>&gt;&lt;&gt;
22523 </p>
22524 !! end
22525
22526 !! test
22527 Template caching
22528 !! wikitext
22529 {{Test}}
22530 {{Test}}
22531 !! html
22532 <p>This is a test template
22533 This is a test template
22534 </p>
22535 !! end
22536
22537
22538 !! article
22539 MediaWiki:Fake
22540 !! text
22541 ==header==
22542 !! endarticle
22543
22544 !! test
22545 Inclusion of !userCanEdit() content
22546 !! wikitext
22547 {{MediaWiki:Fake}}
22548 !! html
22549 <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>
22550
22551 !! end
22552
22553
22554 !! test
22555 Out-of-order TOC heading levels
22556 !! wikitext
22557 ==2==
22558 ======6======
22559 ===3===
22560 =1=
22561 =====5=====
22562 ==2==
22563 !! html
22564 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
22565 <ul>
22566 <li class="toclevel-1 tocsection-1"><a href="#2"><span class="tocnumber">1</span> <span class="toctext">2</span></a>
22567 <ul>
22568 <li class="toclevel-2 tocsection-2"><a href="#6"><span class="tocnumber">1.1</span> <span class="toctext">6</span></a></li>
22569 <li class="toclevel-2 tocsection-3"><a href="#3"><span class="tocnumber">1.2</span> <span class="toctext">3</span></a></li>
22570 </ul>
22571 </li>
22572 <li class="toclevel-1 tocsection-4"><a href="#1"><span class="tocnumber">2</span> <span class="toctext">1</span></a>
22573 <ul>
22574 <li class="toclevel-2 tocsection-5"><a href="#5"><span class="tocnumber">2.1</span> <span class="toctext">5</span></a></li>
22575 <li class="toclevel-2 tocsection-6"><a href="#2_2"><span class="tocnumber">2.2</span> <span class="toctext">2</span></a></li>
22576 </ul>
22577 </li>
22578 </ul>
22579 </div>
22580
22581 <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>
22582 <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>
22583 <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>
22584 <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>
22585 <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>
22586 <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>
22587
22588 !! end
22589
22590
22591 !! test
22592 ISBN with a dummy number
22593 !! wikitext
22594 ISBN ---
22595 !! html
22596 <p>ISBN ---
22597 </p>
22598 !! end
22599
22600
22601 !! test
22602 ISBN with space-delimited number
22603 !! wikitext
22604 ISBN 92 9017 032 8
22605 !! html/php
22606 <p><a href="/wiki/Special:BookSources/9290170328" class="internal mw-magiclink-isbn">ISBN 92 9017 032 8</a>
22607 </p>
22608 !! html/parsoid
22609 <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>
22610 !! end
22611
22612
22613 !! test
22614 ISBN with multiple spaces, no number
22615 !! wikitext
22616 ISBN foo
22617 !! html
22618 <p>ISBN foo
22619 </p>
22620 !! end
22621
22622
22623 !! test
22624 ISBN length
22625 !! wikitext
22626 ISBN 123456789
22627
22628 ISBN 1234567890
22629
22630 ISBN 12345678901
22631 !! html/php
22632 <p>ISBN 123456789
22633 </p><p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
22634 </p><p>ISBN 12345678901
22635 </p>
22636 !! html/parsoid
22637 <p>ISBN 123456789</p>
22638
22639 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a></p>
22640
22641 <p>ISBN 12345678901</p>
22642 !! end
22643
22644
22645 !! test
22646 ISBN with trailing year (T9110)
22647 !! wikitext
22648 ISBN 1-234-56789-0 - 2006
22649
22650 ISBN 1 234 56789 0 - 2006
22651 !! html/php
22652 <p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1-234-56789-0</a> - 2006
22653 </p><p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1 234 56789 0</a> - 2006
22654 </p>
22655 !! html/parsoid
22656 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1-234-56789-0</a> - 2006</p>
22657
22658 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1 234 56789 0</a> - 2006</p>
22659 !! end
22660
22661
22662 !! test
22663 anchorencode
22664 !! config
22665 wgFragmentMode=[ 'html5', 'legacy' ]
22666 !! wikitext
22667 {{anchorencode:foo bar©#%n}}
22668 !! html/php
22669 <p>foo_bar©#%n
22670 </p>
22671 !! html/parsoid
22672 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode:foo bar©#%n","function":"anchorencode"},"params":{},"i":0}}]}'>foo_bar©#%n</p>
22673 !! end
22674
22675 !! test
22676 anchorencode (legacy)
22677 !! config
22678 wgFragmentMode=[ 'legacy' ]
22679 !! wikitext
22680 {{anchorencode:foo bar©#%n}}
22681 !! html/php
22682 <p>foo_bar.C2.A9.23.25n
22683 </p>
22684 !! end
22685
22686 !! test
22687 anchorencode trims spaces
22688 !! config
22689 wgFragmentMode=[ 'html5', 'legacy' ]
22690 !! wikitext
22691 {{anchorencode: __pretty__please__}}
22692 !! html/php
22693 <p>pretty_please
22694 </p>
22695 !! html/parsoid
22696 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: __pretty__please__","function":"anchorencode"},"params":{},"i":0}}]}'>pretty_please</p>
22697 !! end
22698
22699 !! test
22700 anchorencode deals with links
22701 !! config
22702 wgFragmentMode=[ 'html5', 'legacy' ]
22703 !! wikitext
22704 {{anchorencode: [[hello|world]] [[hi]]}}
22705 !! html/php
22706 <p>world_hi
22707 </p>
22708 !! html/parsoid
22709 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: [[hello|world]] [[hi]]","function":"anchorencode"},"params":{},"i":0}}]}'>world_hi</p>
22710 !! end
22711
22712 !! test
22713 anchorencode deals with templates
22714 !! config
22715 wgFragmentMode=[ 'html5', 'legacy' ]
22716 !! wikitext
22717 {{anchorencode: {{Foo}} x}}
22718 !! html/php
22719 <p>FOO_x
22720 </p>
22721 !! html/parsoid
22722 <p about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: {{Foo}} x","function":"anchorencode"},"params":{},"i":0}}]}'>FOO_x</p>
22723 !! end
22724
22725 !! test
22726 anchorencode encodes like the TOC generator: (T20431)
22727 !! config
22728 wgFragmentMode=[ 'html5', 'legacy' ]
22729 !! wikitext
22730 ===_ +:.3A%3A _ &&amp;]] x===
22731 {{anchorencode: _ +:.3A%3A _ &&amp;]] x}}
22732 __NOEDITSECTION__
22733 !! html/php
22734 <h3><span id=".2B:.3A.253A_.26.26.5D.5D_x"></span><span class="mw-headline" id="+:.3A%3A_&amp;&amp;]]_x">_ +:.3A%3A _ &amp;&amp;]] x</span></h3>
22735 <p>+:.3A%3A_&amp;&amp;&#93;&#93;_x
22736 </p>
22737 !! html/parsoid
22738 <h3 id="+:.3A%3A_&amp;&amp;]]_x"><span id=".2B:.3A.253A_.26.26.5D.5D_x" typeof="mw:FallbackId"></span>_ +:.3A%3A _ &amp;<span typeof="mw:Entity" data-parsoid='{"src":"&amp;amp;","srcContent":"&amp;","dsr":[18,23,null,null]}'>&amp;</span>]] x</h3>
22739 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: _ +:.3A%3A _ &amp;&amp;amp;]] x","function":"anchorencode"},"params":{},"i":0}}]}'>+:.3A%3A_&amp;&amp;<span typeof="mw:Entity">]</span><span typeof="mw:Entity">]</span>_x</p>
22740 <meta property="mw:PageProp/noeditsection"/>
22741 !! end
22742
22743 !! test
22744 anchorencode encodes like the TOC generator: (T20431) (legacy)
22745 !! config
22746 wgFragmentMode=[ 'legacy' ]
22747 !! wikitext
22748 ===_ +:.3A%3A&&amp;]]===
22749 {{anchorencode: _ +:.3A%3A&&amp;]] }}
22750 __NOEDITSECTION__
22751 !! html/php
22752 <h3><span class="mw-headline" id=".2B:.3A.253A.26.26.5D.5D">_ +:.3A%3A&amp;&amp;]]</span></h3>
22753 <p>.2B:.3A.253A.26.26.5D.5D
22754 </p>
22755 !! end
22756
22757 !! test
22758 T8200: blockquotes and paragraph formatting
22759 !! wikitext
22760 <blockquote>
22761 foo
22762 </blockquote>
22763
22764 bar
22765
22766 baz
22767 !! html
22768 <blockquote>
22769 <p>foo
22770 </p>
22771 </blockquote>
22772 <p>bar
22773 </p>
22774 <pre>baz
22775 </pre>
22776 !! end
22777
22778 !! test
22779 T10293: Use of center tag ruins paragraph formatting
22780 !! wikitext
22781 <center>
22782 foo
22783 </center>
22784
22785 bar
22786
22787 baz
22788 !! html
22789 <center>
22790 <p>foo
22791 </p>
22792 </center>
22793 <p>bar
22794 </p>
22795 <pre>baz
22796 </pre>
22797 !! end
22798
22799 !!test
22800 Parsing of overlapping (improperly nested) inline html tags
22801 !! wikitext
22802 <span><s>x</span></s>
22803 !! html/php
22804 <p><span><s>x&lt;/span&gt;</s></span>
22805 </p>
22806 !! html/parsoid
22807 <p><span><s>x</s></span>
22808 </p>
22809 !!end
22810
22811 ###
22812 ### Language variants related tests
22813 ###
22814
22815 # Parsoid does not mark self-links.
22816 # Parsoid does not convert links; PHP will do any necessary redirects.
22817
22818 !! test
22819 Self-link in language variants
22820 !! options
22821 title=[[Dunav]] language=sr
22822 !! wikitext
22823 Both [[Dunav]] and [[Дунав]] are names for this river.
22824 !! html/php
22825 <p>Both <a class="mw-selflink selflink">Dunav</a> and <a class="mw-selflink selflink">Дунав</a> are names for this river.
22826 </p>
22827 !! html/parsoid
22828 <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>
22829 !! end
22830
22831 !! article
22832 Дуна
22833 !! text
22834 content
22835 !! endarticle
22836
22837 !! test
22838 Link to another existing title shouldn't be parsed as self-link even if it's a variant of this title
22839 !! options
22840 title=[[Duna]] language=sr
22841 !! wikitext
22842 [[Дуна]] is not a self-link while [[Duna]] and [[Dуна]] are still self-links.
22843 !! html/php
22844 <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.
22845 </p>
22846 !! html/parsoid
22847 <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>
22848 !! end
22849
22850 !! test
22851 Link to a section of a variant of this title shouldn't be parsed as self-link
22852 !! options
22853 title=[[Duna]] language=sr
22854 !! wikitext
22855 [[Dуна]] is a self-link while [[Dunа#Foo]] and [[Dуна#Foo]] are not self-links.
22856 !! html/php
22857 <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.
22858 </p>
22859 !! html/parsoid
22860 <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>
22861 !! end
22862
22863 !! test
22864 Link to pages in language variants
22865 !! options
22866 language=sr
22867 !! wikitext
22868 Main Page can be written as [[Маин Паге]]
22869 !! html/php
22870 <p>Main Page can be written as <a href="/wiki/Main_Page" title="Main Page">Маин Паге</a>
22871 </p>
22872 !! html/parsoid
22873 <p>Main Page can be written as <a rel="mw:WikiLink" href="./Маин_Паге" title="Маин Паге">Маин Паге</a></p>
22874 !! end
22875
22876
22877 !! test
22878 Multiple links to pages in language variants
22879 !! options
22880 language=sr
22881 !! wikitext
22882 [[Main Page]] can be written as [[Маин Паге]] same as [[Маин Паге]].
22883 !! html/php
22884 <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>.
22885 </p>
22886 !! html/parsoid
22887 <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>
22888 !! end
22889
22890
22891 !! test
22892 Simple template in language variants
22893 !! options
22894 language=sr
22895 !! wikitext
22896 {{тест}}
22897 !! html/php
22898 <p>This is a test template
22899 </p>
22900 !! end
22901
22902
22903 !! test
22904 Template with explicit namespace in language variants
22905 !! options
22906 language=sr
22907 !! wikitext
22908 {{Template:тест}}
22909 !! html/php
22910 <p>This is a test template
22911 </p>
22912 !! end
22913
22914
22915 !! test
22916 Basic test for template parameter in language variants
22917 !! options
22918 language=sr
22919 !! wikitext
22920 {{парамтест|param=foo}}
22921 !! html/php
22922 <p>This is a test template with parameter foo
22923 </p>
22924 !! end
22925
22926 !! test
22927 Simple category in language variants
22928 !! options
22929 language=sr cat
22930 !! wikitext
22931 [[Category:МедиаWики Усер'с Гуиде]]
22932 !! html/php
22933 cat=МедиаWики_Усер'с_Гуиде sort=
22934 !! html/parsoid
22935 <link rel="mw:PageProp/Category" href="./Категорија:МедиаWики_Усер'с_Гуиде" data-parsoid='{"stx":"simple","a":{"href":"./Категорија:МедиаWики_Усер&#39;с_Гуиде"},"sa":{"href":"Category:МедиаWики Усер&#39;с Гуиде"}}'/>
22936 !! end
22937
22938 !! article
22939 Category:分类
22940 !! text
22941 blah
22942 !! endarticle
22943
22944 !! article
22945 Category:分類
22946 !! text
22947 blah
22948 !! endarticle
22949
22950 ## We used to, but no longer wt2wt this test since the default serializer
22951 ## will normalize all categories to serialize on their own line.
22952 ## This wikitext usage is going to be fairly uncommon in production and
22953 ## selser will take care of preserving formatting in those scenarios.
22954 !! test
22955 Don't convert blue categorylinks to another variant (T35210)
22956 !! options
22957 cat
22958 language=zh
22959 parsoid=wt2html
22960 !! wikitext
22961 [[A]][[Category:分类]]
22962 !! html/php
22963 cat=分类 sort=
22964 !! html/parsoid
22965 <p><a rel="mw:WikiLink" href="./A" title="A">A</a></p>
22966 <link rel="mw:PageProp/Category" href="./Category:分类"/>
22967 !! end
22968
22969 !! test
22970 Stripping -{}- tags (language variants)
22971 !! options
22972 language=sr
22973 !! wikitext
22974 Latin proverb: -{Ne nuntium necare}-
22975 !! html/php
22976 <p>Latin proverb: Ne nuntium necare
22977 </p>
22978 !! html/parsoid
22979 <p>Latin proverb: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
22980 !! end
22981
22982
22983 !! test
22984 Prevent conversion with -{}- tags (language variants)
22985 !! options
22986 language=sr variant=sr-ec
22987 !! wikitext
22988 Latinski: -{Ne nuntium necare}-
22989 !! html/php
22990 <p>Латински: Ne nuntium necare
22991 </p>
22992 !! html/parsoid
22993 <p>Latinski: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
22994 !! end
22995
22996
22997 !! test
22998 Prevent conversion of text with -{}- tags (language variants)
22999 !! options
23000 language=sr variant=sr-ec
23001 !! wikitext
23002 Latinski: -{Ne nuntium necare}-
23003 !! html/php
23004 <p>Латински: Ne nuntium necare
23005 </p>
23006 !! html/parsoid
23007 <p>Latinski: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
23008 !! end
23009
23010
23011 !! test
23012 Prevent conversion of links with -{}- tags (language variants)
23013 !! options
23014 language=sr variant=sr-ec
23015 !! wikitext
23016 -{[[Main Page]]}-
23017 !! html/php
23018 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
23019 </p>
23020 !! html/parsoid
23021 <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>
23022 !! end
23023
23024
23025 !! test
23026 -{}- tags within headlines (within html for parserConvert())
23027 !! config
23028 wgFragmentMode=[ 'html5', 'legacy' ]
23029 !! options
23030 language=sr variant=sr-ec
23031 !! wikitext
23032 ==-{Naslov}-==
23033
23034 Note that even an unprotected headline ID is not affected by language
23035 conversion:
23036
23037 ==Latinski==
23038 !! html/php
23039 <h2><span id="-.7BNaslov.7D-"></span><span class="mw-headline" id="-{Naslov}-">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>
23040 <p>Ноте тхат евен ан унпротецтед хеадлине ИД ис нот аффецтед бy лангуаге
23041 цонверсион:
23042 </p>
23043 <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>
23044
23045 !! html/parsoid
23046 <h2 id="-{Naslov}-"><span id="-.7BNaslov.7D-" typeof="mw:FallbackId"></span><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Naslov"}}'></span></h2>
23047
23048 <p>Note that even an unprotected headline ID is not affected by language
23049 conversion:</p>
23050
23051 <h2 id="Latinski">Latinski</h2>
23052 !! end
23053
23054 !! test
23055 Explicit definition of language variant alternatives
23056 !! options
23057 language=zh variant=zh-tw
23058 !! wikitext
23059 -{zh:China;zh-tw:Taiwan}-, not China
23060 !! html/php
23061 <p>Taiwan, not China
23062 </p>
23063 !! html/parsoid
23064 <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>
23065 !! end
23066
23067 !! test
23068 Explicit definition of language variant alternatives (BCP 47 codes)
23069 !! options
23070 language=zh variant=zh-tw
23071 !! wikitext
23072 -{zh:China;zh-Hant-TW:Taiwan}-, not China
23073 !! html/php
23074 <p>Taiwan, not China
23075 </p>
23076 !! html/parsoid
23077 <p><span typeof="mw:LanguageVariant" data-parsoid='{"tSp":[6]}' data-mw-variant='{"twoway":[{"l":"zh","t":"China"},{"l":"zh-Hant-TW","t":"Taiwan"}]}'></span>, not China</p>
23078 !! end
23079
23080 !! test
23081 Filter syntax for language variants
23082 !! options
23083 language=zh variant=zh-tw
23084 !! wikitext
23085 foo-{zh;zh-hans;zh-hant|blog, WEBJOURNAL, WEBLOG}-quux
23086 !! html/php
23087 <p>fooblog, WEBJOURNAL, WEBLOGquux
23088 </p>
23089 !! html/parsoid
23090 <p>foo<span typeof="mw:LanguageVariant" data-mw-variant='{"filter":{"l":["zh","zh-hans","zh-hant"],"t":"blog, WEBJOURNAL, WEBLOG"}}'></span>quux</p>
23091 !! end
23092
23093 # Note that Parsoid post-processing for language variants needs to
23094 # update the `title` attribute here, based on the mw:ExpandedAttrs property
23095 !! test
23096 Conversion around HTML tags
23097 !! options
23098 language=sr variant=sr-ec
23099 !! wikitext
23100 -{H|span=>sr-ec:script;title=>sr-ec:src}-
23101 <span title="La-{sr-el:L;sr-ec:C}-tin">ski</span>
23102 !! html/php
23103 <p>
23104 <span title="ЛаCтин">ски</span>
23105 </p>
23106 !! html/parsoid
23107 <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"}]}'/>
23108 <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>
23109 !! end
23110
23111 !! test
23112 Explicit session-wise two-way language variant mapping (A flag and - flag)
23113 !! options
23114 language=zh variant=zh-tw
23115 !! wikitext
23116 This is -{zh:China; zh-tw:Taiwan}-, but we'll forget that now.
23117
23118 Taiwan is not China.
23119
23120 But -{A|zh:China; zh-tw:Taiwan}- is China,
23121
23122 (This-{-|zh:China; zh-tw:Taiwan}- should be stripped!)
23123
23124 and -{China}- is China.
23125 !! html/php
23126 <p>This is Taiwan, but we'll forget that now.
23127 </p><p>Taiwan is not China.
23128 </p><p>But Taiwan is Taiwan,
23129 </p><p>(This should be stripped!)
23130 </p><p>and China is China.
23131 </p>
23132 !! html/parsoid
23133 <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>
23134 <p>Taiwan is not China.</p>
23135 <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>
23136 <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>
23137 <p>and <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"China"}}'></span> is China.</p>
23138 !! end
23139
23140 !! test
23141 Explicit session-wise one-way language variant mapping (A flag and - flag)
23142 !! options
23143 language=zh variant=zh-tw
23144 !! wikitext
23145 This is -{COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}-, but we'll forget that now.
23146
23147 COUNTRY is China or Taiwan.
23148
23149 But -{A|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- is COUNTRY,
23150
23151 (This-{-|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- should be stripped!)
23152
23153 and -{COUNTRY}- is COUNTRY.
23154 !! html/php
23155 <p>This is Taiwan, but we'll forget that now.
23156 </p><p>COUNTRY is China or Taiwan.
23157 </p><p>But Taiwan is Taiwan,
23158 </p><p>(This should be stripped!)
23159 </p><p>and COUNTRY is COUNTRY.
23160 </p>
23161 !! html/parsoid
23162 <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>
23163 <p>COUNTRY is China or Taiwan.</p>
23164 <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>
23165 <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>
23166 <p>and <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"COUNTRY"}}'></span> is COUNTRY.</p>
23167 !! end
23168
23169 !! test
23170 Explicit session-wise two-way language variant mapping (H flag for hide)
23171 !! options
23172 language=zh variant=zh-tw
23173 !! wikitext
23174 (This-{H|zh:China;zh-tw:Taiwan}- should be stripped!)
23175
23176 Taiwan is China.
23177 !! html/php
23178 <p>(This should be stripped!)
23179 </p><p>Taiwan is Taiwan.
23180 </p>
23181 !! html/parsoid
23182 <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>
23183 <p>Taiwan is China.</p>
23184 !! end
23185
23186 !! test
23187 Explicit session-wise one-way language variant mapping (H flag for hide)
23188 !! options
23189 language=zh variant=zh-tw
23190 !! wikitext
23191 (This-{H|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- should be stripped!)
23192
23193 COUNTRY is Taiwan or China.
23194 !! html/php
23195 <p>(This should be stripped!)
23196 </p><p>Taiwan is Taiwan or China.
23197 </p>
23198 !! html/parsoid
23199 <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>
23200 <p>COUNTRY is Taiwan or China.</p>
23201 !! end
23202
23203 ## Note that parsoid test runner does not support 'showtitle' option.
23204 !! test
23205 Adding explicit conversion rule for title (T flag)
23206 !! options
23207 language=zh variant=zh-tw showtitle
23208 !! wikitext
23209 Should be stripped-{T|zh:China;zh-tw:Taiwan}-!
23210
23211 Taiwan is China.
23212 !! html/php
23213 Taiwan
23214 <p>Should be stripped!
23215 </p><p>Taiwan is China.
23216 </p>
23217 !! html/parsoid
23218 <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>
23219 <p>Taiwan is China.</p>
23220 !! end
23221
23222 !! test
23223 Code coverage: T combined with H flag
23224 !! options
23225 language=zh variant=zh-tw showtitle
23226 !! wikitext
23227 Should be stripped-{T;H|zh:China; zh-tw:Taiwan}-!
23228
23229 Taiwan is China.
23230 !! html/php
23231 Taiwan
23232 <p>Should be stripped!
23233 </p><p>Taiwan is Taiwan.
23234 </p>
23235 !! html/parsoid
23236 <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>
23237 <p>Taiwan is China.</p>
23238 !! end
23239
23240 !! test
23241 Code coverage: T with no variants
23242 !! options
23243 language=zh variant=zh-tw showtitle
23244 !! wikitext
23245 -{H|zh:China; zh-tw:Taiwan}-
23246 Taiwan is China.-{T|Taiwan is China}-
23247 !! html/php
23248 Taiwan is China
23249 <p>
23250 Taiwan is Taiwan.
23251 </p>
23252 !! html/parsoid
23253 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>
23254 Taiwan is China.<meta typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Taiwan is China"},"title":true}'/></p>
23255 !! end
23256
23257 !! test
23258 Code coverage: rules with no variants
23259 !! options
23260 language=zh variant=zh-tw
23261 !! wikitext
23262 -{H|zh:China; zh-tw:Taiwan}-
23263 Taiwan is China.
23264 -{H|China}-
23265 Taiwan is China.
23266 !! html/php
23267 <p>
23268 Taiwan is Taiwan.
23269
23270 Taiwan is China.
23271 </p>
23272 !! html/parsoid
23273 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>
23274 Taiwan is China.
23275 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"*","t":"China"}]}'/>
23276 Taiwan is China.</p>
23277 !! end
23278
23279
23280 !! test
23281 Code coverage: D flag for conversion rule
23282 !! options
23283 language=zh variant=zh-tw
23284 !! wikitext
23285 -{D|zh-cn:XA; zh-tw:YA}-
23286 -{A;D|zh-cn:XB; zh-tw:YB}-
23287 -{D;H|zh-cn:XC; zh-tw:YC}-
23288
23289 -{D;H|FOO=>zh-tw:BAR;FOO=>zh-cn:BAT}-
23290
23291 -{D|0=>zh-tw:1}-
23292 -{A;D|2=>zh-tw:3}-
23293 -{D;H|4=>zh-tw:5}-
23294
23295 XA XB XC YA YB YC FOO BAR BAT 012345
23296 !! html/php
23297 <p>大陆:XA;台灣:YA;
23298
23299 大陆:XC;台灣:YC;
23300 </p><p>FOO⇒台灣:BAR;FOO⇒大陆:BAT;
23301 </p><p>0⇒台灣:1;
23302
23303 4⇒台灣:5;
23304 </p><p>XA YB YC YA YB YC BAR BAR BAT 013355
23305 </p>
23306 !! html/parsoid
23307 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"describe":true,"twoway":[{"l":"zh-cn","t":"XA"},{"l":"zh-tw","t":"YA"}]}'></span>
23308 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"twoway":[{"l":"zh-cn","t":"XB"},{"l":"zh-tw","t":"YB"}]}'/>
23309 <span typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"twoway":[{"l":"zh-cn","t":"XC"},{"l":"zh-tw","t":"YC"}]}'></span></p>
23310 <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>
23311 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"describe":true,"oneway":[{"f":"0","l":"zh-tw","t":"1"}]}'></span>
23312 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"oneway":[{"f":"2","l":"zh-tw","t":"3"}]}'/>
23313 <span typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"oneway":[{"f":"4","l":"zh-tw","t":"5"}]}'></span></p>
23314 <p>XA XB XC YA YB YC FOO BAR BAT 012345</p>
23315 !! end
23316
23317 !! test
23318 Code coverage: N flag for conversion rule
23319 !! options
23320 language=zh variant=zh-cn
23321 !! wikitext
23322 -{N|zh-cn}-
23323
23324 -{N|zh-tw}-
23325
23326 -{N|sr-ec}-
23327 !! html/php
23328 <p>大陆
23329 </p><p>台灣
23330 </p><p>српски (ћирилица)‎
23331 </p>
23332 !! html/parsoid
23333 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"zh-cn"}}'></span></p>
23334 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"zh-tw"}}'></span></p>
23335 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"sr-ec"}}'></span></p>
23336 !! end
23337
23338 # html2wt suppresses the bogus 'D' flag, so this is wt2html only
23339 !! test
23340 Code coverage: N flag for conversion rule (wt2html only)
23341 !! options
23342 language=zh variant=zh-cn
23343 parsoid=wt2html,html2html
23344 !! wikitext
23345 -{D;N|en}-
23346 !! html/php
23347 <p>English
23348 </p>
23349 !! html/parsoid
23350 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"en"}}' data-parsoid='{"fl":["D","N"]}'></span></p>
23351 !! end
23352
23353 !! test
23354 Testing that changing the language variant here in the tests actually works
23355 !! options
23356 language=zh variant=zh showtitle
23357 !! wikitext
23358 Should be stripped-{T|zh:China; zh-tw:Taiwan}-!
23359 !! html/php
23360 China
23361 <p>Should be stripped!
23362 </p>
23363 !! html/parsoid
23364 <p>Should be stripped<meta typeof="mw:LanguageVariant" data-mw-variant='{"title":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>!</p>
23365 !! end
23366
23367 !! test
23368 Recursive conversion of alt and title attrs shouldn't clear converter state
23369 !! options
23370 language=zh variant=zh-cn
23371 showtitle
23372 !! wikitext
23373 -{H|zh-cn:Exclamation; zh-tw:exclamation}-
23374 Should be stripped-{T|zh-cn:China; zh-tw:Taiwan}-<span title="exclamation">!</span>
23375 !! html/php
23376 China
23377 <p>
23378 Should be stripped<span title="Exclamation">!</span>
23379 </p>
23380 !! html/parsoid
23381 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh-cn","t":"Exclamation"},{"l":"zh-tw","t":"exclamation"}]}'/>
23382 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>
23383 !! end
23384
23385 !! test
23386 T26072: more test on conversion rule for title
23387 !! options
23388 language=zh variant=zh-tw showtitle
23389 !! wikitext
23390 This should be stripped-{T|zh:China; zh-tw:Taiwan}-!
23391
23392 This won't take interferes with the title rule-{H|zh:Beijing; zh-tw:Taipei}-.
23393 !! html/php
23394 Taiwan
23395 <p>This should be stripped!
23396 </p><p>This won't take interferes with the title rule.
23397 </p>
23398 !! html/parsoid
23399 <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>
23400 <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>
23401 !! end
23402
23403 !! test
23404 Partly disable title conversion if variant == main language code
23405 !! options
23406 language=zh variant=zh title=[[ZH]] showtitle
23407 !! wikitext
23408 -{T|zh-cn:CN;zh-tw:TW}-
23409 !! html/php
23410 ZH
23411 <p>
23412 </p>
23413 !! html/parsoid
23414 <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>
23415 !! end
23416
23417 !! test
23418 Partly disable title conversion if variant == main language code, more
23419 !! options
23420 language=zh variant=zh title=[[ZH]] showtitle
23421 !! wikitext
23422 -{T|TW}-
23423 !! html/php
23424 ZH
23425 <p>
23426 </p>
23427 !! html/parsoid
23428 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"TW"},"title":true}'/></p>
23429 !! end
23430
23431 !! test
23432 Raw output of variant escape tags (R flag)
23433 !! options
23434 language=zh variant=zh-tw
23435 !! wikitext
23436 Raw: -{R|zh:China;zh-tw:Taiwan}-
23437 !! html/php
23438 <p>Raw: zh:China;zh-tw:Taiwan
23439 </p>
23440 !! html/parsoid
23441 <p>Raw: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"zh:China;zh-tw:Taiwan"}}'></span></p>
23442 !! end
23443
23444 # html2wt suppresses the bogus 'D' flags, so this is wt2html only
23445 !! test
23446 Raw output of variant escape tags (R flag) (wt2html only)
23447 !! options
23448 language=zh variant=zh-tw
23449 parsoid=wt2html,html2html
23450 !! wikitext
23451 -{Variant}- -{D|syntax}- -{D;R|options}-
23452 !! html/php
23453 <p>Variant syntax options
23454 </p>
23455 !! html/parsoid
23456 <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>
23457 !! end
23458
23459 !! test
23460 Nested markup inside raw output of variant escape tags (R flag)
23461 !! options
23462 language=zh variant=zh-tw
23463 !! wikitext
23464 Nested raw: -{R|nested -{zh:China;zh-tw:Taiwan}- nested}-
23465 !! html/php
23466 <p>Nested raw: nested Taiwan nested
23467 </p>
23468 !! html/parsoid
23469 <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>
23470 !! end
23471
23472 !! test
23473 Nested markup and spaces inside raw output of variant escape tags (R flag)
23474 !! options
23475 language=zh variant=zh-tw
23476 !! wikitext
23477 X-{ outer -{ inner }- outer }-X
23478 !! html/php
23479 <p>X outer inner outer X
23480 </p>
23481 !! html/parsoid
23482 <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>
23483 !! end
23484
23485 !! test
23486 Templates inside raw output of variant escape tags (R flag)
23487 !! options
23488 language=zh variant=zh-tw
23489 !! wikitext
23490 Nested raw: -{R|nested {{echo|hi}} templates}-
23491 !! html/php
23492 <p>Nested raw: nested hi templates
23493 </p>
23494 !! html/parsoid
23495 <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>
23496 !! end
23497
23498 !! test
23499 Strings evaluating false shouldn't be ignored by Language converter (T51072)
23500 !! options
23501 language=zh variant=zh-cn
23502 !! wikitext
23503 -{zh-cn:0;zh-sg:1;zh-tw:2;zh-hk:3}-
23504 !! html/php
23505 <p>0
23506 </p>
23507 !! html/parsoid
23508 <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>
23509 !! end
23510
23511 !! test
23512 Conversion rules from [numeric-only string] to [something else] (T48634)
23513 !! options
23514 language=zh variant=zh-cn
23515 !! wikitext
23516 -{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
23517 !! html/php
23518 <p>D12345EE12345
23519 </p>
23520 !! html/parsoid
23521 <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>
23522 !! end
23523
23524 !! test
23525 Two-way converter rule entries with an empty value should be ignored (T53551)
23526 !! options
23527 language=zh variant=zh-cn
23528 !! wikitext
23529 -{H|zh-cn:foo;zh-tw:;}-foobar
23530 !! html/php
23531 <p>foobar
23532 </p>
23533 !! html/parsoid
23534 <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>
23535 !! end
23536
23537 !! test
23538 One-way converter rule entries with an empty "from" string should be ignored (T53551)
23539 !! options
23540 language=zh variant=zh-cn
23541 !! wikitext
23542 -{H|=>zh-cn:foo;}-foobar
23543 !! html/php
23544 <p>foobar
23545 </p>
23546 !! html/parsoid
23547 <p><meta typeof="mw:LanguageVariant" data-parsoid='{"tSp":[5]}' data-mw-variant='{"add":true,"oneway":[{"f":"","l":"zh-cn","t":"foo"}]}'/>foobar</p>
23548 !! end
23549
23550 !! test
23551 Empty converter rule entries shouldn't be inserted into the conversion table (T53551)
23552 !! options
23553 language=zh variant=zh-cn
23554 !! wikitext
23555 -{H|}-foobar
23556 !! html/php
23557 <p>foobar
23558 </p>
23559 !! html/parsoid
23560 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"*","t":""}]}'/>foobar</p>
23561 !! end
23562
23563 !! test
23564 Nested using of manual convert syntax
23565 !! options
23566 language=zh variant=zh-hk
23567 !! wikitext
23568 Nested: -{zh-hans:Hi -{zh-cn:China;zh-sg:Singapore;}-;zh-hant:Hello -{zh-tw:Taiwan;zh-hk:H-{ong}- K-{}-ong;}-;}-!
23569 !! html/php
23570 <p>Nested: Hello Hong Kong!
23571 </p>
23572 !! html/parsoid
23573 <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=&apos;{\"twoway\":[{\"l\":\"zh-cn\",\"t\":\"China\"},{\"l\":\"zh-sg\",\"t\":\"Singapore\"}]}&apos; data-parsoid=&apos;{\"fl\":[],\"tSp\":[7],\"dsr\":[21,53,null,2]}&apos;>&lt;/span>"},{"l":"zh-hant","t":"Hello &lt;span typeof=\"mw:LanguageVariant\" data-mw-variant=&apos;{\"twoway\":[{\"l\":\"zh-tw\",\"t\":\"Taiwan\"},{\"l\":\"zh-hk\",\"t\":\"H&amp;lt;span typeof=\\\"mw:LanguageVariant\\\" data-mw-variant=&amp;apos;{\\\"disabled\\\":{\\\"t\\\":\\\"ong\\\"}}&amp;apos; data-parsoid=&amp;apos;{\\\"fl\\\":[],\\\"dsr\\\":[90,97,null,2]}&amp;apos;>&amp;lt;/span> K&amp;lt;span typeof=\\\"mw:LanguageVariant\\\" data-mw-variant=&amp;apos;{\\\"disabled\\\":{\\\"t\\\":\\\"\\\"}}&amp;apos; data-parsoid=&amp;apos;{\\\"fl\\\":[],\\\"dsr\\\":[99,103,null,2]}&amp;apos;>&amp;lt;/span>ong\"}]}&apos; data-parsoid=&apos;{\"fl\":[],\"tSp\":[7],\"dsr\":[68,109,null,2]}&apos;>&lt;/span>"}]}'></span>!</p>
23574 !! end
23575
23576 !! test
23577 HTML markups with conversion syntax in attribs, nested in other conversion blocks
23578 !! options
23579 language=zh variant=zh-cn
23580 !! wikitext
23581 -{zh;zh-hans;zh-hant|<span title="-{X}-">A</span>}-
23582 !! html/php
23583 <p><span title="X">A</span>
23584 </p>
23585 !! html/parsoid
23586 <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;apos;{\\\"disabled\\\":{\\\"t\\\":\\\"X\\\"}}&amp;apos; data-parsoid=&amp;apos;{\\\"fl\\\":[],\\\"dsr\\\":[34,39,null,2]}&amp;apos;>&amp;lt;/span>\"}]]}&#39;>A&lt;/span>"}}'></span></p>
23587 !! end
23588
23589 !! test
23590 HTML markups with conversion syntax in attribs, nested in other conversion blocks (not working yet in PHP parser)
23591 !! options
23592 language=zh variant=zh-cn
23593 !! wikitext
23594 -{<span title="-{X}-">A</span>}-
23595 !! html/php+disabled
23596 <p><span title="X">A</span>
23597 </p>
23598 !! html/parsoid
23599 <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;apos;{\\\"disabled\\\":{\\\"t\\\":\\\"X\\\"}}&amp;apos; data-parsoid=&amp;apos;{\\\"fl\\\":[],\\\"dsr\\\":[15,20,null,2]}&amp;apos;>&amp;lt;/span>\"}]]}&#39;>A&lt;/span>"}}'></span></p>
23600 !! end
23601
23602 # Parsoid and PHP disagree on how to parse this example: Parsoid
23603 # insists that the content of a language converter element be a valid
23604 # DOM fragment or attribute string
23605 !! test
23606 Language converter markup with block content
23607 !! options
23608 language=zh variant=zh-cn
23609 !! wikitext
23610 <span>a-{b<div>c}-d
23611
23612 <span>a-{zh;zh-hans;zh-hant|b<div>c}-d
23613
23614 <span>a-{H|0=>zh-cn:x<span>y;0=>zh-tw:b<div>c}-d
23615 !! html/php+tidy
23616 <span>ab<div>cd
23617 <span>ab<div>cd
23618 <span>ad
23619 </span></div></span></div></span>
23620 !! html/parsoid
23621 <span data-parsoid='{"stx":"html","autoInsertedEnd":true}'>a<div typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"b&lt;div data-parsoid=&apos;{\"stx\":\"html\",\"autoInsertedEnd\":true,\"dsr\":[10,16,5,0]}&apos;>c&lt;/div>"}}'></div>d
23622
23623 <span data-parsoid='{"stx":"html","autoInsertedEnd":true}'>a<div typeof="mw:LanguageVariant" data-mw-variant='{"filter":{"l":["zh","zh-hans","zh-hant"],"t":"b&lt;div data-parsoid=&apos;{\"stx\":\"html\",\"autoInsertedEnd\":true,\"dsr\":[50,56,5,0]}&apos;>c&lt;/div>"}}'></div>d
23624
23625 <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=&apos;{\"stx\":\"html\",\"autoInsertedEnd\":true,\"dsr\":[82,89,6,0]}&apos;>y&lt;/span>"},{"f":"0","l":"zh-tw","t":"b&lt;div data-parsoid=&apos;{\"stx\":\"html\",\"autoInsertedEnd\":true,\"dsr\":[100,106,5,0]}&apos;>c&lt;/div>"}]}'/>d</span></p></span></span>
23626 !! end
23627
23628 !! test
23629 LanguageConverter selser (1)
23630 !! options
23631 language=zh variant=zh-cn
23632 parsoid={
23633 "modes": ["wt2wt", "selser"],
23634 "changes": [
23635 ["span[typeof]", "attr", "data-mw-variant", "{\"disabled\":{\"t\":\"edited\"}}"]
23636 ]
23637 }
23638 !! wikitext
23639 -{raw}-
23640 !! wikitext/edited
23641 -{edited}-
23642 !! end
23643
23644 !! test
23645 LanguageConverter selser (2)
23646 !! options
23647 language=zh variant=zh-cn
23648 parsoid={
23649 "modes": ["wt2wt", "selser"],
23650 "changes": [
23651 ["span[class='x']", "contents", "text", "-{foo}-"],
23652 ["a", "contents", "text", "-{"],
23653 ["span[typeof]", "attr", "data-mw", "{\"parts\":[{\"template\":{\"target\":{\"wt\":\"1x\",\"href\":\"./Template:1x\"},\"params\":{\"1\":{\"wt\":\"-{\"}},\"i\":0}}]}"]
23654 ]
23655 }
23656 !! wikitext
23657 <span class="x">TEXT1</span>
23658 [http://example.com TEXT2]
23659 [[Foo|TEXT3]]
23660 {{echo|TEXT4}}
23661 !! wikitext/edited
23662 <span class="x"><nowiki>-{foo}-</nowiki></span>
23663 [http://example.com -{]
23664 [[Foo|<nowiki>-{</nowiki>]]
23665 {{1x|<nowiki>-{</nowiki>}}
23666 !! end
23667
23668 # Tests LanguageVariantText in ConstrainedText
23669 !! test
23670 LanguageConverter selser (3)
23671 !! options
23672 language=zh variant=zh-cn
23673 parsoid={
23674 "modes": ["wt2wt", "selser"],
23675 "changes": [
23676 ["td > span", "attr", "typeof", "mw:LanguageVariant"],
23677 ["td > span", "attr", "data-mw-variant", "{\"disabled\":{\"t\":\"edited\"}}"]
23678 ]
23679 }
23680 !! wikitext
23681 {|
23682 |-
23683 |<span>Foo</span>
23684 |}
23685 !! wikitext/edited
23686 {|
23687 |-
23688 |<nowiki/>-{edited}-
23689 |}
23690 !! end
23691
23692 # Tests LanguageVariantText._fromSelSer
23693 !! test
23694 LanguageConverter selser (4)
23695 !! options
23696 language=zh variant=zh-cn
23697 parsoid={
23698 "modes": ["wt2wt", "selser"],
23699 "changes": [
23700 ["td > span.x", "remove"]
23701 ]
23702 }
23703 !! wikitext
23704 {|
23705 |-
23706 |<span class="x">Foo</span>-{Bar}-
23707 ||<span class="x">Foo</span>-{Bar}-
23708 |}
23709 !! wikitext/edited
23710 {|
23711 |-
23712 |<nowiki/>-{Bar}-
23713 ||-{Bar}-
23714 |}
23715 !! end
23716
23717 # Since Parsoid is starting to emit canonical wikitext for links,
23718 # [http://example.com http://example.com] will not RT back to that
23719 # form anymore.
23720 # Parsoid does not language-convert links (it is done in a
23721 # post-processing step)
23722 !! test
23723 Proper conversion of text in external links
23724 !! options
23725 language=sr variant=sr-ec
23726 parsoid=wt2html
23727 !! wikitext
23728 http://www.google.com
23729 gopher://www.google.com
23730 [http://www.google.com http://www.google.com]
23731 [gopher://www.google.com gopher://www.google.com]
23732 [https://www.google.com irc://www.google.com]
23733 [ftp://www.google.com www.google.com/ftp://dir]
23734 [//www.google.com www.google.com]
23735 !! html/php
23736 <p><a rel="nofollow" class="external free" href="http://www.google.com">http://www.google.com</a>
23737 <a rel="nofollow" class="external free" href="gopher://www.google.com">gopher://www.google.com</a>
23738 <a rel="nofollow" class="external text" href="http://www.google.com">http://www.google.com</a>
23739 <a rel="nofollow" class="external text" href="gopher://www.google.com">gopher://www.google.com</a>
23740 <a rel="nofollow" class="external text" href="https://www.google.com">irc://www.google.com</a>
23741 <a rel="nofollow" class="external text" href="ftp://www.google.com">www.гоогле.цом/фтп://дир</a>
23742 <a rel="nofollow" class="external text" href="//www.google.com">www.гоогле.цом</a>
23743 </p>
23744 !! html/parsoid
23745 <p><a rel="mw:ExtLink" class="external free" href="http://www.google.com">http://www.google.com</a>
23746 <a rel="mw:ExtLink" class="external free" href="gopher://www.google.com">gopher://www.google.com</a>
23747 <a rel="mw:ExtLink" class="external text" href="http://www.google.com">http://www.google.com</a>
23748 <a rel="mw:ExtLink" class="external text" href="gopher://www.google.com">gopher://www.google.com</a>
23749 <a rel="mw:ExtLink" class="external text" href="https://www.google.com">irc://www.google.com</a>
23750 <a rel="mw:ExtLink" class="external text" href="ftp://www.google.com">www.google.com/ftp://dir</a>
23751 <a rel="mw:ExtLink" class="external text" href="//www.google.com">www.google.com</a></p>
23752 !! end
23753
23754 !! test
23755 Do not convert roman numbers to language variants
23756 !! options
23757 language=sr variant=sr-ec
23758 !! wikitext
23759 Fridrih IV je car.
23760 !! html/php
23761 <p>Фридрих IV је цар.
23762 </p>
23763 !! html/parsoid
23764 <p>Fridrih IV je car.</p>
23765 !! end
23766
23767 !! test
23768 Unclosed language converter markup "-{"
23769 !! options
23770 language=sr
23771 !! wikitext
23772 -{T|hello
23773 !! html
23774 <p>-{T|hello
23775 </p>
23776 !! end
23777
23778 !! test
23779 Don't convert raw rule "-{R|=&gt;}-" to "=>"
23780 !! options
23781 language=sr
23782 !! wikitext
23783 -{R|=&gt;}-
23784 !! html/php
23785 <p>=&gt;
23786 </p>
23787 !! html/parsoid
23788 <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>
23789 !!end
23790
23791 !! test
23792 Don't break link parsing if language converter markup is in the caption.
23793 !! options
23794 language=sr variant=sr-ec
23795 !! wikitext
23796 [[Main Page|-{R|main page}-]]
23797 !! html/php
23798 <p><a href="/wiki/Main_Page" title="Маин Паге">main page</a>
23799 </p>
23800 !! html/parsoid
23801 <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>
23802 !! end
23803
23804 !! test
23805 T146304: Don't break template parsing if language converter markup is in the parameter.
23806 !! options
23807 language=sr variant=sr-ec
23808 !! wikitext
23809 {{echo|-{R|foo}-}}
23810 !! html/php
23811 <p>foo
23812 </p>
23813 !! html/parsoid
23814 <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>
23815 !! end
23816
23817 !! test
23818 T146305: Don't break image parsing if language converter markup is in the caption.
23819 !! options
23820 language=sr
23821 !! wikitext
23822 [[Датотека:Foobar.jpg|thumb|-{R|caption:}-]]
23823 !! html/php
23824 <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" decoding="async" 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>
23825
23826 !! html/parsoid
23827 <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>
23828 !! end
23829
23830 !! test
23831 T146305: Don't break image parsing if nested language converter markup is in the caption.
23832 !! options
23833 language=zh variant=zh-cn
23834 !! wikitext
23835 [[File:Foobar.jpg|thumb|-{|zh-cn:blog (hk: -{zh-hans|WEBJOURNAL}-, tw: -{zh-hans|WEBLOG}-)}-]]
23836 !! html/php
23837 <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" decoding="async" 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>
23838
23839 !! html/parsoid
23840 <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>
23841 !! end
23842
23843 # XXX html2wt disabled because rich markup in alt is not preserved.
23844 !! test
23845 Don't break gallery if language converter markup is inside.
23846 !! options
23847 language=zh
23848 !! wikitext
23849 <gallery>
23850 File:foobar.jpg|[[File:foobar.jpg|20px|desc|alt=-{R|foo}-|-{R|bar}-]]|alt=-{R|bat}-
23851 File:foobar.jpg|{{Test|unamedParam|alt=-{R|param}-}}|alt=galleryalt
23852 </gallery>
23853 !! html/php
23854 <ul class="gallery mw-gallery-traditional">
23855 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
23856 <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" decoding="async" 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>
23857 <div class="gallerytext">
23858 <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" decoding="async" 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>
23859 </p>
23860 </div>
23861 </div></li>
23862 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
23863 <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" decoding="async" 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>
23864 <div class="gallerytext">
23865 <p>This is a test template
23866 </p>
23867 </div>
23868 </div></li>
23869 </ul>
23870
23871 !! html/parsoid
23872 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt6" 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"}}'>
23873 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline 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></figure-inline></div><div class="gallerytext"><figure-inline 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></figure-inline></div></li>
23874 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline 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></figure-inline></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":"-{R|param}-"}},"i":0}}]}'>This is a test template</span></div></li>
23875 </ul>
23876 !! end
23877
23878 !! test
23879 T153135: Don't break list handling if language converter markup is in the item.
23880 !! options
23881 language=zh variant=zh-cn
23882 !! wikitext
23883 ;-{zh-cn:AAA;zh-tw:BBB}-
23884 ;-{R|foo:bar}-
23885 !! html/php
23886 <dl><dt>AAA</dt>
23887 <dt>foo:bar</dt></dl>
23888
23889 !! html/parsoid
23890 <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>
23891 <dt data-parsoid='{"dsr":[25,39,1,0]}'><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"foo:bar"}}'></span></dt>
23892 </dl>
23893 !! end
23894
23895 // Note that parsoid does not protect colons unless language converter
23896 // markup is properly nested, because it is a backtracking parser.
23897 !! test
23898 T153135: Unclosed markup in definition list (code coverage)
23899 !! options
23900 language=zh variant=zh-cn
23901 !! wikitext
23902 ;<b>foo:bar
23903 ;-{zh-cn:AAA
23904 !! html/php+tidy
23905 <dl><dt><b>foo:bar</b></dt><b>
23906 <dt>-{zh-cn:AAA</dt></b></dl><p><b>
23907 </b></p>
23908 !! html/parsoid
23909 <dl><dt data-parsoid='{}'><b data-parsoid='{"stx":"html","autoInsertedEnd":true}'>foo:bar</b></dt><b data-parsoid='{"stx":"html","autoInsertedEnd":true,"autoInsertedStart":true}'>
23910 <dt data-parsoid='{}'>-{zh-cn</dt><dd data-parsoid='{"stx":"row"}'>AAA</dd></b></dl>
23911 !! end
23912
23913 !! test
23914 T153135: Nested language converter markup in definition list (code coverage)
23915 !! options
23916 language=zh variant=zh-cn
23917 !! wikitext
23918 ;-{|zh-cn:AAA -{zh-hans|foo:bar}- -{R|bat:baz}-}-:def
23919 !! html/php
23920 <dl><dt>AAA foo:bar bat:baz</dt>
23921 <dd>def</dd></dl>
23922
23923 !! html/parsoid
23924 <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>
23925 <dd data-parsoid='{"stx":"row","dsr":[49,53,1,0]}'>def</dd>
23926 </dl>
23927 !! end
23928
23929 # html2wt mode disabled due to <nowiki> insertion.
23930 !! test
23931 T153140: Don't break table handling if language converter markup is in the cell.
23932 !! options
23933 language=sr variant=sr-ec
23934 parsoid=wt2html,wt2wt,html2html
23935 !! wikitext
23936 {|
23937 |-
23938 | -{R|B}-
23939 |}
23940 !! html/php
23941 <table>
23942
23943 <tr>
23944 <td>B
23945 </td></tr></table>
23946
23947 !! html/parsoid
23948 <table>
23949 <tbody>
23950 <tr>
23951 <td><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"B"}}'></span></td>
23952 </tr>
23953 </tbody>
23954 </table>
23955 !! end
23956
23957 !! test
23958 Language converter tricky html2wt cases (1)
23959 !! options
23960 language=sr
23961 parsoid=html2wt,wt2wt
23962 !! html/parsoid
23963 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"}-"}}'></span></p>
23964 !! wikitext
23965 -{<nowiki>}-</nowiki>}-
23966 !! html/php
23967 <p>&#125;-
23968 </p>
23969 !! end
23970
23971 !! test
23972 Language converter tricky html2wt cases (2)
23973 !! options
23974 language=sr
23975 parsoid=html2wt,wt2wt
23976 !! html/parsoid
23977 <p>-{foo}-</p>
23978 !! wikitext
23979 <nowiki>-{foo}-</nowiki>
23980 !! html/php
23981 <p>-&#123;foo&#125;-
23982 </p>
23983 !! end
23984
23985 !! test
23986 Language converter tricky html2wt cases (3)
23987 !! options
23988 language=sr
23989 parsoid=html2wt,wt2wt
23990 !! html/parsoid
23991 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"|"}}'></span></p>
23992 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"R|raw"}}'></span></p>
23993 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"-{foo}-"}}'></span></p>
23994 !! wikitext
23995 -{R||}-
23996
23997 -{R|R|raw}-
23998
23999 -{<nowiki>-{foo}-</nowiki>}-
24000 !! html/php
24001 <p>|
24002 </p><p>R|raw
24003 </p><p>-&#123;foo&#125;-
24004 </p>
24005 !! end
24006
24007 !! test
24008 Language converter tricky html2wt cases (4)
24009 !! options
24010 language=sr
24011 parsoid=html2wt,wt2wt
24012 !! html/parsoid
24013 <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>
24014 !! wikitext
24015 -{R|{{echo|hey}}}-
24016 !! html/php
24017 <p>hey
24018 </p>
24019 !! end
24020
24021 # Note that the <nowiki> escaping added by parsoid for source text,
24022 # destination text, and language names only works on the PHP side
24023 # for *destination text*. (HTML entity escaping wouldn't work
24024 # any better.) This is probably a bug, at least for source texts.
24025 # (For language names PHP uses a precise regexp based on the languages
24026 # it currently knows have variants, which is fragile since this set
24027 # can grow/shrink over time.)
24028 !! test
24029 Language converter tricky html2wt cases (5)
24030 !! options
24031 language=zh variant=zh-cn
24032 !! html/parsoid
24033 <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>
24034 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"A","l":"bo:g;us","t":"B"}]}'/></p>
24035 <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>
24036 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"twoway":[{"l":"bo:g;us","t":"xyz"},{"l":"zh-cn","t":"abc"}]}'></span></p>
24037 <p>a:b=>c xyz</p>
24038 !! wikitext
24039 -{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
24040
24041 -{H|A=><nowiki>bo:g;us</nowiki>:B}-
24042
24043 -{A|zh-tw:xyz; zh-cn:<nowiki>0;zh-tw:bar</nowiki>}-
24044
24045 -{<nowiki>bo:g;us</nowiki>:xyz; zh-cn:abc}-
24046
24047 a:b=>c xyz
24048 !! html/php+disabled
24049 <p>foobat;xyz=&gt;zh-cn:abc
24050 </p><p>A
24051 </p><p>0;zh-tw:bar
24052 </p><p>abc
24053 </p><p>a:b=&gt;c 0;zh-tw:bar
24054 </p>
24055 !! end
24056
24057 !! test
24058 T179579: Nowiki and lc interaction
24059 !! options
24060 parsoid=wt2html
24061 language=sr
24062 !! wikitext
24063 -{</nowiki>123}-
24064
24065 -{123<nowiki>|</nowiki>456}-
24066 !! html/parsoid
24067 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"&amp;lt;/nowiki>123"}}' data-parsoid='{"fl":[],"src":"-{&lt;/nowiki>123}-"}'></span></p>
24068
24069 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"123&lt;span typeof=\"mw:Nowiki\" data-parsoid=&#39;{\"dsr\":[23,41,8,9]}&#39;>|&lt;/span>456"}}' data-parsoid='{"fl":[],"src":"-{123&lt;nowiki>|&lt;/nowiki>456}-"}'></span></p>
24070 !! end
24071
24072 !! test
24073 T2529: Uncovered bullet
24074 !! wikitext
24075 *Foo {{bullet}}
24076 !! html
24077 <ul><li>Foo</li>
24078 <li>Bar</li></ul>
24079
24080 !! end
24081
24082 !! test
24083 T2529: Uncovered bullet in a deeply nested list
24084 !! wikitext
24085 *******Foo {{bullet}}
24086 !! html
24087 <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>
24088 <li>Bar</li></ul>
24089
24090 !! end
24091
24092 !! test
24093 T2529: Uncovered table already at line-start
24094 !! wikitext
24095 x
24096
24097 {{table}}
24098 y
24099 !! html
24100 <p>x
24101 </p>
24102 <table>
24103 <tr>
24104 <td>1</td>
24105 <td>2
24106 </td></tr>
24107 <tr>
24108 <td>3</td>
24109 <td>4
24110 </td></tr></table>
24111 <p>y
24112 </p>
24113 !! end
24114
24115 !! test
24116 T2529: Uncovered bullet in parser function result
24117 !! wikitext
24118 *Foo {{lc:{{bullet}} }}
24119 !! html
24120 <ul><li>Foo</li>
24121 <li>bar</li></ul>
24122
24123 !! end
24124
24125 !! test
24126 T7678: Double-parsed template argument
24127 !! wikitext
24128 {{lc:{{{1}}}|hello}}
24129 !! html
24130 <p>{{{1}}}
24131 </p>
24132 !! end
24133
24134 !! test
24135 T7678: Double-parsed template invocation
24136 !! wikitext
24137 {{lc:{{paramtest {{!}} param = hello }} }}
24138 !! html
24139 <p>{{paramtest | param = hello }}
24140 </p>
24141 !! end
24142
24143 !! test
24144 Case insensitivity of parser functions for non-ASCII characters (T10143)
24145 !! options
24146 language=cs
24147 title=[[Main Page]]
24148 !! wikitext
24149 {{PRVNÍVELKÉ:ěščř}}
24150 {{prvnívelké:ěščř}}
24151 {{PRVNÍMALÉ:ěščř}}
24152 {{prvnímalé:ěščř}}
24153 {{MALÁ:ěščř}}
24154 {{malá:ěščř}}
24155 {{VELKÁ:ěščř}}
24156 {{velká:ěščř}}
24157 !! html
24158 <p>Ěščř
24159 Ěščř
24160 ěščř
24161 ěščř
24162 ěščř
24163 ěščř
24164 ĚŠČŘ
24165 ĚŠČŘ
24166 </p>
24167 !! end
24168
24169 !! test
24170 Morwen/13: Unclosed link followed by heading
24171 !! wikitext
24172 [[link
24173 ==heading==
24174 !! html
24175 <p>[[link
24176 </p>
24177 <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>
24178
24179 !! end
24180
24181 !! test
24182 HHP2.1: Heuristics for headings in preprocessor parenthetical structures
24183 !! wikitext
24184 {{foo|
24185 =heading=
24186 !! html
24187 <p>{{foo|
24188 </p>
24189 <h1><span class="mw-headline" id="heading">heading</span></h1>
24190
24191 !! end
24192
24193 !! test
24194 HHP2.2: Heuristics for headings in preprocessor parenthetical structures
24195 !! wikitext
24196 {{foo|
24197 ==heading==
24198 !! html
24199 <p>{{foo|
24200 </p>
24201 <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>
24202
24203 !! end
24204
24205 !! test
24206 Tildes in comments
24207 !! options
24208 pst
24209 !! wikitext
24210 <!-- ~~~~ -->
24211 !! html/php
24212 <!-- ~~~~ -->
24213 !! end
24214
24215 !! test
24216 Paragraphs inside divs (no extra line breaks)
24217 !! wikitext
24218 <div>Line one
24219
24220 Line two</div>
24221 !! html
24222 <div>Line one
24223 Line two</div>
24224
24225 !! end
24226
24227 !! test
24228 Paragraphs inside divs (extra line break on open)
24229 !! wikitext
24230 <div>
24231 Line one
24232
24233 Line two</div>
24234 !! html
24235 <div>
24236 <p>Line one
24237 </p>
24238 Line two</div>
24239
24240 !! end
24241
24242 !! test
24243 Paragraphs inside divs (extra line break on close)
24244 !! wikitext
24245 <div>Line one
24246
24247 Line two
24248 </div>
24249 !! html
24250 <div>Line one
24251 <p>Line two
24252 </p>
24253 </div>
24254
24255 !! end
24256
24257 !! test
24258 Paragraphs inside divs (extra line break on open and close)
24259 !! wikitext
24260 <div>
24261 Line one
24262
24263 Line two
24264 </div>
24265 !! html
24266 <div>
24267 <p>Line one
24268 </p><p>Line two
24269 </p>
24270 </div>
24271
24272 !! end
24273
24274 # doBlockLevels screws up this output and Remex cleans up as much as it can.
24275 !! test
24276 Nesting tags, paragraphs on lines which begin with <div>
24277 !! wikitext
24278 <div></div><strong>A
24279 B</strong>
24280 !! html/php+tidy
24281 <div></div><p><strong>A
24282 </strong></p><strong></strong><p><strong>B</strong>
24283 </p>
24284 !! html/parsoid
24285 <div data-parsoid='{"stx":"html"}'></div><p><strong data-parsoid='{"stx":"html","autoInsertedEnd":true}'>A</strong></p>
24286 <p><strong data-parsoid='{"stx":"html","autoInsertedStart":true}'>B</strong></p>
24287 !! end
24288
24289 # T8200: <blockquote> should behave like <div> with respect to line breaks
24290 !! test
24291 T8200: paragraphs inside blockquotes (no extra line breaks)
24292 !! wikitext
24293 <blockquote>Line one
24294
24295 Line two</blockquote>
24296 !! html
24297 <blockquote>Line one
24298 Line two</blockquote>
24299
24300 !! html+tidy
24301 <blockquote><p>Line one
24302 Line two</p></blockquote>
24303 !! end
24304
24305 !! test
24306 T8200: paragraphs inside blockquotes (extra line break on open)
24307 !! wikitext
24308 <blockquote>
24309 Line one
24310
24311 Line two</blockquote>
24312 !! html
24313 <blockquote>
24314 <p>Line one
24315 </p>
24316 Line two</blockquote>
24317
24318 !! html+tidy
24319 <blockquote>
24320 <p>Line one
24321 </p><p>
24322 Line two</p></blockquote>
24323 !! end
24324
24325 !! test
24326 T8200: paragraphs inside blockquotes (extra line break on close)
24327 !! wikitext
24328 <blockquote>Line one
24329
24330 Line two
24331 </blockquote>
24332 !! html
24333 <blockquote>Line one
24334 <p>Line two
24335 </p>
24336 </blockquote>
24337
24338 !! html+tidy
24339 <blockquote><p>Line one
24340 </p><p>Line two
24341 </p>
24342 </blockquote>
24343 !! end
24344
24345 !! test
24346 T8200: paragraphs inside blockquotes (extra line break on open and close)
24347 !! wikitext
24348 <blockquote>
24349 Line one
24350
24351 Line two
24352 </blockquote>
24353 !! html
24354 <blockquote>
24355 <p>Line one
24356 </p><p>Line two
24357 </p>
24358 </blockquote>
24359
24360 !! end
24361
24362 ## This is a corner case interaction between the paragraph wrapping in the
24363 ## php parser's BlockLevelPass and Remex. `doBlockLevels` has a notion of
24364 ## some tags which close paragraphs (and thus prevent wrapping on their line),
24365 ## of which "div" is one, but do p-wrapping inside them. These are referred
24366 ## to as "never suppressing". Remex, for its part, doesn't traverse into
24367 ## "div"s to p-wrap. Hence, we only get this partial wrapping.
24368 !! test
24369 Paragraphs inside blockquotes/divs (no extra line breaks)
24370 !! wikitext
24371 <blockquote><div>Line one
24372
24373 Line two</div></blockquote>
24374 !! html
24375 <blockquote><div>Line one
24376 Line two</div></blockquote>
24377
24378 !! end
24379
24380 !! test
24381 Paragraphs inside blockquotes/divs (extra line break on open)
24382 !! wikitext
24383 <blockquote><div>
24384 Line one
24385
24386 Line two</div></blockquote>
24387 !! html
24388 <blockquote><div>
24389 <p>Line one
24390 </p>
24391 Line two</div></blockquote>
24392
24393 !! end
24394
24395 !! test
24396 Paragraphs inside blockquotes/divs (extra line break on close)
24397 !! wikitext
24398 <blockquote><div>Line one
24399
24400 Line two
24401 </div></blockquote>
24402 !! html
24403 <blockquote><div>Line one
24404 <p>Line two
24405 </p>
24406 </div></blockquote>
24407
24408 !! end
24409
24410 !! test
24411 Paragraphs inside blockquotes/divs (extra line break on open and close)
24412 !! wikitext
24413 <blockquote><div>
24414 Line one
24415
24416 Line two
24417 </div></blockquote>
24418 !! html
24419 <blockquote><div>
24420 <p>Line one
24421 </p><p>Line two
24422 </p>
24423 </div></blockquote>
24424
24425 !! end
24426
24427 !! test
24428 Interwiki links trounced by replaceExternalLinks after early LinkHolderArray expansion
24429 !! options
24430 wgLinkHolderBatchSize=0
24431 !! wikitext
24432 [[meatball:1]]
24433 [[meatball:2]]
24434 [[meatball:3]]
24435 !! html
24436 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?1" class="extiw" title="meatball:1">meatball:1</a>
24437 <a href="http://www.usemod.com/cgi-bin/mb.pl?2" class="extiw" title="meatball:2">meatball:2</a>
24438 <a href="http://www.usemod.com/cgi-bin/mb.pl?3" class="extiw" title="meatball:3">meatball:3</a>
24439 </p>
24440 !! end
24441
24442 !! test
24443 Free external link invading image caption
24444 !! wikitext
24445 [[Image:Foobar.jpg|thumb|http://x|hello]]
24446 !! html/php
24447 <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" decoding="async" 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>
24448
24449 !! html/parsoid
24450 <figure class="mw-default-size" typeof="mw:Image/Thumb" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"},{"ck":"bogus","ak":"http://x"},{"ck":"caption","ak":"hello"}]}'><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":"Image:Foobar.jpg"}}'/></a><figcaption>hello</figcaption></figure>
24451 !! end
24452
24453 !! test
24454 T17196: localised external link numbers
24455 !! options
24456 language=fa
24457 !! wikitext
24458 [http://en.wikipedia.org/]
24459 !! html/php
24460 <p><a rel="nofollow" class="external autonumber" href="http://en.wikipedia.org/">[۱]</a>
24461 </p>
24462 !! html/parsoid
24463 <p><a rel="mw:ExtLink" class="external autonumber" href="http://en.wikipedia.org/"></a></p>
24464 !! end
24465
24466 !! test
24467 Multibyte character in padleft
24468 !! wikitext
24469 {{padleft:-Hello|7|Æ}}
24470 !! html/php
24471 <p>Æ-Hello
24472 </p>
24473 !! html/parsoid
24474 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padleft:-Hello","function":"padleft"},"params":{"1":{"wt":"7"},"2":{"wt":"Æ"}},"i":0}}]}'>Æ-Hello</p>
24475 !! end
24476
24477 !! test
24478 Multibyte character in padright
24479 !! wikitext
24480 {{padright:Hello-|7|Æ}}
24481 !! html/php
24482 <p>Hello-Æ
24483 </p>
24484 !! html/parsoid
24485 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padright:Hello-","function":"padright"},"params":{"1":{"wt":"7"},"2":{"wt":"Æ"}},"i":0}}]}'>Hello-Æ</p>
24486 !! end
24487
24488 !!test
24489 formatdate parser function
24490 !! wikitext
24491 {{#formatdate:2009-03-24}}
24492 !! html
24493 <p><span class="mw-formatted-date" title="2009-03-24">2009-03-24</span>
24494 </p>
24495 !! end
24496
24497 !!test
24498 formatdate parser function, with default format
24499 !! wikitext
24500 {{#formatdate:2009-03-24|mdy}}
24501 !! html
24502 <p><span class="mw-formatted-date" title="2009-03-24">March 24, 2009</span>
24503 </p>
24504 !! end
24505
24506 !! test
24507 Spacing of numbers in formatted dates
24508 !! wikitext
24509 {{#formatdate:January 15}}
24510 !! html
24511 <p><span class="mw-formatted-date" title="01-15">January 15</span>
24512 </p>
24513 !! end
24514
24515 !! test
24516 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
24517 !! options
24518 language=nl title=[[MediaWiki:Common.css]]
24519 !! wikitext
24520 {{#formatdate:2009-03-24|dmy}}
24521 !! html
24522 <p><span class="mw-formatted-date" title="2009-03-24">24 March 2009</span>
24523 </p>
24524 !! end
24525
24526 #
24527 #
24528 #
24529
24530 #
24531 # Edit comments
24532 #
24533
24534 !! test
24535 Edit comment with link
24536 !! options
24537 comment
24538 !! wikitext
24539 I like the [[Main Page]] a lot
24540 !! html/php
24541 I like the <a href="/wiki/Main_Page" title="Main Page">Main Page</a> a lot
24542 !!end
24543
24544 !! test
24545 Edit comment with link and link text
24546 !! options
24547 comment
24548 !! wikitext
24549 I like the [[Main Page|best pages]] a lot
24550 !! html/php
24551 I like the <a href="/wiki/Main_Page" title="Main Page">best pages</a> a lot
24552 !!end
24553
24554 !! test
24555 Edit comment with link and link text with suffix
24556 !! options
24557 comment
24558 !! wikitext
24559 I like the [[Main Page|best page]]s a lot
24560 !! html/php
24561 I like the <a href="/wiki/Main_Page" title="Main Page">best pages</a> a lot
24562 !!end
24563
24564 !! test
24565 Edit comment with section link (non-local, eg in history list)
24566 !! options
24567 comment title=[[Main Page]]
24568 !! wikitext
24569 /* External links */ removed bogus entries
24570 !! html/php
24571 <span dir="auto"><span class="autocomment"><a href="/wiki/Main_Page#External_links" title="Main Page">→‎External links</a>: </span> removed bogus entries</span>
24572 !!end
24573
24574 !! test
24575 Edit comment with section link and text before it (non-local, eg in history list)
24576 !! options
24577 comment title=[[Main Page]]
24578 !! wikitext
24579 pre-comment text /* External links */ removed bogus entries
24580 !! html/php
24581 pre-comment text <span dir="auto"><span class="autocomment"><a href="/wiki/Main_Page#External_links" title="Main Page">→‎External links</a>: </span> removed bogus entries</span>
24582 !!end
24583
24584 !! test
24585 Edit comment with section link (local, eg in diff view)
24586 !! options
24587 comment local title=[[Main Page]]
24588 !! wikitext
24589 /* External links */ removed bogus entries
24590 !! html/php
24591 <span dir="auto"><span class="autocomment"><a href="#External_links">→‎External links</a>: </span> removed bogus entries</span>
24592 !!end
24593
24594 !! test
24595 Edit comment with section link that has a link in it
24596 !! options
24597 comment local title=[[Main Page]]
24598 !! wikitext
24599 /* [[A link]] */
24600 !! html/php
24601 <span dir="auto"><span class="autocomment"><a href="#A_link">→‎&#91;[A link]]</a></span></span>
24602 !! end
24603
24604 !! test
24605 Edit comment with section link that has a template in it
24606 !! options
24607 comment local title=[[Main Page]]
24608 !! wikitext
24609 /* {{foobar|param}} */
24610 !! html/php
24611 <span dir="auto"><span class="autocomment"><a href="#.7B.7Bfoobar.7Cparam.7D.7D">→‎{{foobar|param}}</a></span></span>
24612 !! end
24613
24614 !! test
24615 Edit comment with subpage link (T16080)
24616 !! options
24617 comment
24618 subpage
24619 title=[[Subpage test]]
24620 !! wikitext
24621 Poked at a [[/subpage]] here...
24622 !! html/php
24623 Poked at a <a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a> here...
24624 !!end
24625
24626 !! test
24627 Edit comment with subpage link and link text (T16080)
24628 !! options
24629 comment
24630 subpage
24631 title=[[Subpage test]]
24632 !! wikitext
24633 Poked at a [[/subpage|neat little page]] here...
24634 !! html/php
24635 Poked at a <a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">neat little page</a> here...
24636 !!end
24637
24638 !! test
24639 Edit comment with bogus subpage link in non-subpage NS (T16080)
24640 !! options
24641 comment
24642 title=[[Subpage test]]
24643 !! wikitext
24644 Poked at a [[/subpage]] here...
24645 !! html/php
24646 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...
24647 !!end
24648
24649 !! test
24650 Edit comment with bare anchor link (local, as on diff)
24651 !! options
24652 comment
24653 local
24654 title=[[Main Page]]
24655 !! wikitext
24656 [[#section]]
24657 !! html/php
24658 <a href="#section">#section</a>
24659 !! end
24660
24661 !! test
24662 Edit comment with bare anchor link (non-local, as on history)
24663 !! options
24664 comment
24665 title=[[Main Page]]
24666 !! wikitext
24667 [[#section]]
24668 !! html/php
24669 <a href="/wiki/Main_Page#section" title="Main Page">#section</a>
24670 !! end
24671
24672 !! test
24673 Anchor starting with underscore
24674 !! options
24675 title=[[Foo]]
24676 !! wikitext
24677 [[#_ref|One]]
24678 !! html/php
24679 <p><a href="#_ref">One</a>
24680 </p>
24681 !! html/parsoid
24682 <p><a rel="mw:WikiLink" href="./Foo#_ref" data-parsoid='{"stx":"piped","a":{"href":"./Foo#_ref"},"sa":{"href":"#_ref"}}'>One</a></p>
24683 !! end
24684
24685 !! test
24686 Id starting with underscore
24687 !! wikitext
24688 <div id="_ref"></div>
24689 !! html/*
24690 <div id="_ref"></div>
24691
24692 !! end
24693
24694 !! test
24695 Edit comment with link with more than one pipe (T99346)
24696 !! options
24697 comment
24698 !! wikitext
24699 [[Main Page|Many|pipes]]
24700 !! html/php
24701 <a href="/wiki/Main_Page" title="Main Page">Many|pipes</a>
24702 !! end
24703
24704 !! test
24705 Complex edit comment with link with more than one pipe (T99346)
24706 !! options
24707 comment
24708 !! wikitext
24709 Created page with "<noinclude>[[Category:Requests for permissions/Bot|{{subst:#titleparts:{{subst:PAGENAME}}|1|3}}]]</noinclude> === [[User:MineoBot|]] 8=== {{Request for permissions/links|Mineo..."
24710 !! html/php
24711 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;
24712 !! end
24713
24714 !! test
24715 Space normalisation on autocomment (T24784)
24716 !! options
24717 comment
24718 title=[[Main Page]]
24719 !! wikitext
24720 /* __hello__world__ */
24721 !! html/php
24722 <span dir="auto"><span class="autocomment"><a href="/wiki/Main_Page#hello_world" title="Main Page">→‎__hello__world__</a></span></span>
24723 !! end
24724
24725 !! test
24726 percent-encoding and + signs in comments (T28410)
24727 !! options
24728 comment
24729 !! wikitext
24730 [[ABC%33D% ++]] [[ABC%33D% ++|+%20]]
24731 !! html/php
24732 <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>
24733 !! end
24734
24735 # Parsoid doesn't support this yet: see T75581
24736 # but it *should* omit the 'src' attribute if the image is bad.
24737 # PHP side of tests was disabled in
24738 # mediawiki/core:6bd31e7d95161a6e88fa86df60871051da997c3c
24739 # because of issues in the PHP parserTests infrastructure
24740 # (but the output below is indeed what the PHP side emits)
24741 !! test
24742 Bad images - basic functionality
24743 !! wikitext
24744 [[File:Bad.jpg]]
24745 !! html/php+disabled
24746 !! html/parsoid
24747 <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>
24748 !! end
24749
24750 !! test
24751 Bad images - T18039: text after bad image disappears
24752 !! wikitext
24753 Foo bar
24754 [[File:Bad.jpg]]
24755 Bar foo
24756 !! html/php+disabled
24757 <p>Foo bar
24758 </p><p>Bar foo
24759 </p>
24760 !! html/parsoid
24761 <p>Foo bar
24762 <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>
24763 Bar foo</p>
24764 !! end
24765
24766 !! test
24767 Verify that displaytitle works (T24501) no displaytitle
24768 !! options
24769 showtitle
24770 !! config
24771 wgAllowDisplayTitle=true
24772 wgRestrictDisplayTitle=false
24773 !! wikitext
24774 this is not the the title
24775 !! html/php
24776 Parser test
24777 <p>this is not the the title
24778 </p>
24779 !! end
24780
24781 !! test
24782 Verify that displaytitle works (T24501) RestrictDisplayTitle=false
24783 !! options
24784 showtitle
24785 title=[[Screen]]
24786 !! config
24787 wgAllowDisplayTitle=true
24788 wgRestrictDisplayTitle=false
24789 !! wikitext
24790 this is not the the title
24791 {{DISPLAYTITLE:whatever}}
24792 !! html/php
24793 whatever
24794 <p>this is not the the title
24795 </p>
24796 !! end
24797
24798 !! test
24799 Verify that displaytitle works (T24501) RestrictDisplayTitle=true mismatch
24800 !! options
24801 showtitle
24802 title=[[Screen]]
24803 !! config
24804 wgAllowDisplayTitle=true
24805 wgRestrictDisplayTitle=true
24806 !! wikitext
24807 this is not the the title
24808 {{DISPLAYTITLE:whatever}}
24809 !! html/php
24810 Screen
24811 <p>this is not the the title
24812 </p>
24813 !! end
24814
24815 !! test
24816 Verify that displaytitle works (T24501) RestrictDisplayTitle=true matching
24817 !! options
24818 showtitle
24819 title=[[Screen]]
24820 !! config
24821 wgAllowDisplayTitle=true
24822 wgRestrictDisplayTitle=true
24823 !! wikitext
24824 this is not the the title
24825 {{DISPLAYTITLE:screen}}
24826 !! html/php
24827 screen
24828 <p>this is not the the title
24829 </p>
24830 !! end
24831
24832 !! test
24833 Verify that displaytitle works (T24501) AllowDisplayTitle=false
24834 !! options
24835 showtitle
24836 title=[[Screen]]
24837 !! config
24838 wgAllowDisplayTitle=false
24839 !! wikitext
24840 this is not the the title
24841 {{DISPLAYTITLE:screen}}
24842 !! html/php
24843 Screen
24844 <p>this is not the the title
24845 <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>
24846 </p>
24847 !! end
24848
24849 !! test
24850 Verify that displaytitle works (T24501) AllowDisplayTitle=false no DISPLAYTITLE
24851 !! options
24852 showtitle
24853 title=[[Screen]]
24854 !! config
24855 wgAllowDisplayTitle=false
24856 !! wikitext
24857 this is not the the title
24858 !! html/php
24859 Screen
24860 <p>this is not the the title
24861 </p>
24862 !! end
24863
24864 !! test
24865 Verify that displaytitle handles inline CSS styles (T28547) - rejected value
24866 !! options
24867 showtitle
24868 title=[[Screen]]
24869 !! config
24870 wgAllowDisplayTitle=true
24871 wgRestrictDisplayTitle=true
24872 !! wikitext
24873 this is not the the title
24874 {{DISPLAYTITLE:<span style="display: none;">s</span>creen}}
24875 !! html/php
24876 <span style="/* attempt to bypass $wgRestrictDisplayTitle */">s</span>creen
24877 <p>this is not the the title
24878 </p>
24879 !! end
24880
24881 !! test
24882 Verify that displaytitle handles inline CSS styles (T28547) - accepted value
24883 !! options
24884 showtitle
24885 title=[[Screen]]
24886 !! config
24887 wgAllowDisplayTitle=true
24888 wgRestrictDisplayTitle=true
24889 !! wikitext
24890 this is not the the title
24891 {{DISPLAYTITLE:<span style="color: red;">s</span>creen}}
24892 !! html/php
24893 <span style="color: red;">s</span>creen
24894 <p>this is not the the title
24895 </p>
24896 !! end
24897
24898 !! test
24899 Page status indicators: Empty name is invalid
24900 !! options
24901 showindicators
24902 !! wikitext
24903 <indicator name=" "></indicator>
24904 <indicator></indicator>
24905 !! html/php
24906 <p><span class="error"><strong>Error:</strong> Page status indicators' <code>name</code> attribute must not be empty.</span>
24907 <span class="error"><strong>Error:</strong> Page status indicators' <code>name</code> attribute must not be empty.</span>
24908 </p>
24909 !! end
24910
24911 !! test
24912 Page status indicators: Weird syntaxes that are okay
24913 !! options
24914 showindicators
24915 !! wikitext
24916 <indicator name="empty" />
24917 <indicator name="name"></indicator>
24918 !! html/php
24919 empty=
24920 name=
24921 <p><br />
24922 </p>
24923 !! end
24924
24925 !! test
24926 Page status indicators: Torture test
24927 !! options
24928 showindicators
24929 !! wikitext
24930 <indicator name="01">hello world</indicator>
24931 <indicator name="02">[[Main Page]]</indicator>
24932 <indicator name="03">[[File:Foobar.jpg|25px|link=]]</indicator>
24933 <indicator name="04">[[File:Foobar.jpg|25px]]</indicator>
24934 <indicator name="05">*foo
24935 *bar</indicator>
24936 <indicator name="06"><nowiki>foo</nowiki></indicator>
24937 <indicator name="07"> Preformatted</indicator>
24938 <indicator name="08"><div>Broken tag</indicator>
24939 <indicator name="09">{| class=wikitable
24940 |cell
24941 |}</indicator>
24942 <indicator name="10">Two
24943
24944 paragraphs</indicator>
24945 !! html/php
24946 01=hello world
24947 02=<a href="/wiki/Main_Page" title="Main Page">Main Page</a>
24948 03=<img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/25px-Foobar.jpg" decoding="async" 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" />
24949 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" decoding="async" 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>
24950 05=<ul><li>foo</li>
24951 <li>bar</li></ul>
24952
24953 06=foo
24954 07=<pre>Preformatted
24955 </pre>
24956 08=<div>Broken tag</div>
24957
24958 09=<table class="wikitable">
24959 <tr>
24960 <td>cell
24961 </td></tr></table>
24962
24963 10=<p>Two
24964 </p><p>paragraphs
24965 </p>
24966 <p><br />
24967 </p><p><br />
24968 </p><p><br />
24969 </p><p><br />
24970 </p><p><br />
24971 </p>
24972 !! end
24973
24974 !! test
24975 preload: check <noinclude> and <includeonly>
24976 !! options
24977 preload
24978 !! wikitext
24979 Hello <noinclude>cruel</noinclude><includeonly>kind</includeonly> world.
24980 !! html/php
24981 Hello kind world.
24982 !! end
24983
24984 !! test
24985 preload: check <onlyinclude>
24986 !! options
24987 preload
24988 !! wikitext
24989 Goodbye <onlyinclude>Hello world</onlyinclude>
24990 !! html/php
24991 Hello world
24992 !! end
24993
24994 !! test
24995 preload: can pass tags through if we want to
24996 !! options
24997 preload
24998 !! wikitext
24999 <includeonly><</includeonly>includeonly>Hello world<includeonly><</includeonly>/includeonly>
25000 !! html/php
25001 <includeonly>Hello world</includeonly>
25002 !! end
25003
25004 !! test
25005 preload: check that it doesn't try to do tricks
25006 !! options
25007 preload
25008 !! wikitext
25009 * <!-- Hello --> ''{{world}}'' {{<includeonly>subst:</includeonly>How are you}}{{ {{{|safesubst:}}} #if:1|2|3}}
25010 !! html/php
25011 * <!-- Hello --> ''{{world}}'' {{subst:How are you}}{{ {{{|safesubst:}}} #if:1|2|3}}
25012 !! end
25013
25014 !! test
25015 Play a bit with r67090 and T5158
25016 !! wikitext
25017 <div style="width:50% !important">&nbsp;</div>
25018 <div style="width:50%&nbsp;!important">&nbsp;</div>
25019 <div style="width:50%&#160;!important">&nbsp;</div>
25020 <div style="border : solid;">&nbsp;</div>
25021 !! html/php
25022 <div style="width:50% !important">&#160;</div>
25023 <div style="width:50% !important">&#160;</div>
25024 <div style="width:50% !important">&#160;</div>
25025 <div style="border&#32;: solid;">&#160;</div>
25026
25027 !! html/parsoid
25028 <div style="width:50% !important" data-parsoid='{"stx":"html"}'><span typeof="mw:Entity" data-parsoid='{"srcContent":" "}'> </span></div>
25029 <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>
25030 <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>
25031 <div style="border : solid;" data-parsoid='{"stx":"html"}'><span typeof="mw:Entity" data-parsoid='{"srcContent":" "}'> </span></div>
25032
25033 !! end
25034
25035 !! test
25036 French spaces in wikitext
25037 !! wikitext
25038 foo ! bar ? bat 50 % is less than 75 %.
25039
25040 Hello : this ; is « something ‹ else › again »
25041 !! html
25042 <p>foo&#160;! bar&#160;? bat 50&#160;% is less than 75&#160;%.
25043 </p><p>Hello&#160;: this&#160;; is «&#160;something ‹&#160;else&#160;› again&#160;»
25044 </p>
25045 !! end
25046
25047 # It would be reasonable for Parsoid and PHP to differ here.
25048 # The PHP behavior is arguably a bug.
25049 !! test
25050 Corner case: french spaces in definition list
25051 !! wikitext
25052 ;foo : bar
25053 !! html+tidy
25054 <dl><dt>foo&#160;</dt>
25055 <dd>bar</dd></dl>
25056 !! end
25057
25058 !! test
25059 T5158: Test for French spaces in attributes
25060 !! wikitext
25061 <br style=" clear : both ; " />
25062 !! html/php
25063 <p><br style="clear&#32;: both&#32;;" />
25064 </p>
25065 !! end
25066
25067 !! test
25068 HTML5 data attributes
25069 !! wikitext
25070 <span data-foo="bar">Baz</span>
25071 <p data-abc-def_hij="">Quuz</p>
25072 !! html/php
25073 <p><span data-foo="bar">Baz</span>
25074 </p>
25075 <p data-abc-def_hij="">Quuz</p>
25076
25077 !! html/parsoid
25078 <p><span data-foo="bar" data-parsoid='{"stx":"html"}'>Baz</span></p>
25079 <p data-abc-def_hij="" data-parsoid='{"stx":"html"}'>Quuz</p>
25080 !! end
25081
25082 !! test
25083 Strip reserved data attributes
25084 !! wikitext
25085 <div data-mw="foo" data-parsoid="bar" data-mw-someext="baz" data-ok="fred" data-ooui="xyzzy" data-bad:ns="ns">d</div>
25086 !! html/php
25087 <div data-ok="fred">d</div>
25088
25089 !! html/parsoid
25090 <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>
25091 !! end
25092
25093 !! test
25094 percent-encoding and + signs in internal links (T28410)
25095 !! wikitext
25096 [[User:+%]] [[Page+title%]]
25097 [[%+]] [[%+|%20]] [[%+ ]] [[%+r]]
25098 [[%]] [[+]] [[File:%+abc%39|foo|[[bar]]]]
25099 [[%33%45]] [[%33%45+]]
25100 !! html/php
25101 <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>
25102 <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>
25103 <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>
25104 <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>
25105 </p>
25106 !! html/parsoid
25107 <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>
25108 <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>
25109 <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> <figure-inline 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></figure-inline>
25110 <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>
25111 !! end
25112
25113 !! test
25114 Special characters in embedded file links (T29679)
25115 !! wikitext
25116 [[File:Contains & ampersand.jpg]]
25117 [[File:Does not exist.jpg|Title with & ampersand]]
25118 !! html/php
25119 <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>
25120 <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>
25121 </p>
25122 !! html/parsoid
25123 <p><figure-inline 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></figure-inline>
25124 <figure-inline 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></figure-inline></p>
25125 !! end
25126
25127 !! test
25128 Confirm that 'apos' named character reference doesn't make it to output (not legal in HTML 4)
25129 !! wikitext
25130 Text&apos;s been normalized?
25131 !! html
25132 <p>Text&#39;s been normalized?
25133 </p>
25134 !! end
25135
25136 !! test
25137 T21052 U+3000 IDEOGRAPHIC SPACE should terminate free external links
25138 !! wikitext
25139 http://www.example.org/ <-- U+3000 (vim: ^Vu3000)
25140 !! html
25141 <p><a rel="nofollow" class="external free" href="http://www.example.org/">http://www.example.org/</a> &lt;-- U+3000 (vim: ^Vu3000)
25142 </p>
25143 !! end
25144
25145 !! test
25146 T21052 U+3000 IDEOGRAPHIC SPACE should terminate bracketed external links
25147 !! wikitext
25148 [http://www.example.org/ ideograms]
25149 !! html
25150 <p><a rel="nofollow" class="external text" href="http://www.example.org/">ideograms</a>
25151 </p>
25152 !! end
25153
25154 !! test
25155 T21052 U+3000 IDEOGRAPHIC SPACE should terminate external images links
25156 !! wikitext
25157 http://www.example.org/pic.png <-- U+3000 (vim: ^Vu3000)
25158 !! html
25159 <p><img src="http://www.example.org/pic.png" alt="pic.png"/> &lt;-- U+3000 (vim: ^Vu3000)
25160 </p>
25161 !! end
25162
25163 !! article
25164 Mediawiki:loop1
25165 !! text
25166 {{Identical|A}}
25167 !! endarticle
25168
25169 !! article
25170 Mediawiki:loop2
25171 !! text
25172 {{Identical|B}}
25173 !! endarticle
25174
25175 !! article
25176 Template:Identical
25177 !! text
25178 {{int:loop1}}
25179 {{int:loop2}}
25180 !! endarticle
25181
25182 !! test
25183 T33098 Template which includes system messages which includes the template
25184 !! wikitext
25185 {{Identical}}
25186 !! html
25187 <p><span class="error">Template loop detected: <a href="/wiki/Template:Identical" title="Template:Identical">Template:Identical</a></span>
25188 <span class="error">Template loop detected: <a href="/wiki/Template:Identical" title="Template:Identical">Template:Identical</a></span>
25189 </p>
25190 !! end
25191
25192 !! test
25193 T33490 Turkish: ucfirst 'blah'
25194 !! options
25195 language=tr
25196 !! wikitext
25197 {{ucfirst:blah}}
25198 !! html
25199 <p>Blah
25200 </p>
25201 !! end
25202
25203 !! test
25204 T33490 Turkish: ucfirst 'ix'
25205 !! options
25206 language=tr
25207 !! wikitext
25208 {{ucfirst:ix}}
25209 !! html
25210 <p>İx
25211 </p>
25212 !! end
25213
25214 !! test
25215 T33490 Turkish: lcfirst 'BLAH'
25216 !! options
25217 language=tr
25218 !! wikitext
25219 {{lcfirst:BLAH}}
25220 !! html
25221 <p>bLAH
25222 </p>
25223 !! end
25224
25225 !! test
25226 T33490 Turkish: ucfırst (with a dotless i)
25227 !! options
25228 language=tr
25229 !! wikitext
25230 {{ucfırst:blah}}
25231 !! html
25232 <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>
25233 </p>
25234 !! end
25235
25236 !! test
25237 T33490 ucfırst (with a dotless i) with English language
25238 !! options
25239 language=en
25240 !! wikitext
25241 {{ucfırst:blah}}
25242 !! html
25243 <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>
25244 </p>
25245 !! end
25246
25247 # Note that Parsoid doesn't emit an explicit TOC.
25248 # Note also that the html2wt direction tends to emit an extra newline
25249 # between the __TOC__ magicword and the first heading unless *both*
25250 # the <meta> and the <h2> have a data-parsoid attribute set (even if
25251 # it's "{}").
25252
25253 !! test
25254 T28375: TOC with italics
25255 !! options
25256 title=[[Main Page]]
25257 !! wikitext
25258 __TOC__
25259 ==''Lost'' episodes==
25260 !! html/php
25261 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
25262 <ul>
25263 <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>
25264 </ul>
25265 </div>
25266
25267 <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>
25268
25269 !! html/parsoid
25270 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25271 <h2 id="Lost_episodes" data-parsoid='{}'><i>Lost</i> episodes</h2>
25272 !! end
25273
25274 !! test
25275 T28375: TOC with bold
25276 !! options
25277 title=[[Main Page]]
25278 !! wikitext
25279 __TOC__
25280 =='''should be bold''' then normal text==
25281 !! html/php
25282 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
25283 <ul>
25284 <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>
25285 </ul>
25286 </div>
25287
25288 <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>
25289
25290 !! html/parsoid
25291 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25292 <h2 id="should_be_bold_then_normal_text" data-parsoid='{}'><b>should be bold</b> then normal text</h2>
25293 !! end
25294
25295 !! test
25296 T35845: Headings become cursive in TOC when they contain an image
25297 !! options
25298 title=[[Main Page]]
25299 !! wikitext
25300 __TOC__
25301 ==Image [[Image:foobar.jpg]]==
25302 !! html/php
25303 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
25304 <ul>
25305 <li class="toclevel-1 tocsection-1"><a href="#Image"><span class="tocnumber">1</span> <span class="toctext">Image</span></a></li>
25306 </ul>
25307 </div>
25308
25309 <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" decoding="async" 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>
25310
25311 !! html/parsoid
25312 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25313 <h2 id="Image" data-parsoid='{}'>Image <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" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"Image:foobar.jpg"}}'/></a></figure-inline></h2>
25314 !! end
25315
25316 !! test
25317 T35845 (2): Headings become bold in TOC when they contain a blockquote
25318 !! options
25319 title=[[Main Page]]
25320 !! wikitext
25321 __TOC__
25322 ==<blockquote>Quote</blockquote>==
25323 !! html/php
25324 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
25325 <ul>
25326 <li class="toclevel-1 tocsection-1"><a href="#Quote"><span class="tocnumber">1</span> <span class="toctext">Quote</span></a></li>
25327 </ul>
25328 </div>
25329
25330 <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>
25331
25332 !! html/php+tidy
25333 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none" /><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
25334 <ul>
25335 <li class="toclevel-1 tocsection-1"><a href="#Quote"><span class="tocnumber">1</span> <span class="toctext">Quote</span></a></li>
25336 </ul>
25337 </div>
25338
25339 <h2><span class="mw-headline" id="Quote"><blockquote><p>Quote</p></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>
25340 !! html/parsoid
25341 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25342 <h2 id="Quote" data-parsoid='{}'><blockquote><p>Quote</p></blockquote></h2>
25343 !! end
25344
25345 !! test
25346 Unclosed tags in TOC
25347 !! config
25348 wgFragmentMode=[ 'html5', 'legacy' ]
25349 !! options
25350 title=[[Main Page]]
25351 !! wikitext
25352 __TOC__
25353 ==Proof: 2 < 3==
25354 <small>Hanc marginis exiguitas non caperet.</small>
25355 QED
25356 !! html/php
25357 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
25358 <ul>
25359 <li class="toclevel-1 tocsection-1"><a href="#Proof:_2_&lt;_3"><span class="tocnumber">1</span> <span class="toctext">Proof: 2 &lt; 3</span></a></li>
25360 </ul>
25361 </div>
25362
25363 <h2><span id="Proof:_2_.3C_3"></span><span class="mw-headline" id="Proof:_2_&lt;_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>
25364 <p><small>Hanc marginis exiguitas non caperet.</small>
25365 QED
25366 </p>
25367 !! html/parsoid
25368 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25369 <h2 id="Proof:_2_&lt;_3" data-parsoid='{}'><span id="Proof:_2_.3C_3" typeof="mw:FallbackId"></span>Proof: 2 &lt; 3</h2>
25370 <p><small>Hanc marginis exiguitas non caperet.</small>
25371 QED</p>
25372 !! end
25373
25374 !! test
25375 Multiple tags in TOC
25376 !! wikitext
25377 __TOC__
25378 ==<i>Foo</i> <b>Bar</b>==
25379
25380 ==<i>Foo</i> <blockquote>Bar</blockquote>==
25381 !! html/php
25382 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
25383 <ul>
25384 <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>
25385 <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>
25386 </ul>
25387 </div>
25388
25389 <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>
25390 <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>
25391
25392 !! html/php+tidy
25393 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none" /><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
25394 <ul>
25395 <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>
25396 <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>
25397 </ul>
25398 </div>
25399
25400 <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>
25401 <h2><span class="mw-headline" id="Foo_Bar_2"><i>Foo</i> <blockquote><p>Bar</p></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>
25402 !! html/parsoid
25403 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25404 <h2 id="Foo_Bar" data-parsoid='{}'><i data-parsoid='{"stx":"html"}'>Foo</i> <b data-parsoid='{"stx":"html"}'>Bar</b></h2>
25405
25406 <h2 id="Foo_Bar_2" data-parsoid='{}'><i data-parsoid='{"stx":"html"}'>Foo</i> <blockquote><p>Bar</p></blockquote></h2>
25407 !! end
25408
25409 # Don't expect Parsoid to roundtrip this until the php parser comes closer to
25410 # html5 tag parsing.
25411 !! test
25412 Tags with parameters in TOC
25413 !! options
25414 parsoid=wt2html
25415 !! wikitext
25416 __TOC__
25417 ==<sup class="in-h2">Hello</sup>==
25418
25419 ==<sup class="a > b">Evilbye</sup>==
25420 !! html/php
25421 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
25422 <ul>
25423 <li class="toclevel-1 tocsection-1"><a href="#Hello"><span class="tocnumber">1</span> <span class="toctext"><sup>Hello</sup></span></a></li>
25424 <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>
25425 </ul>
25426 </div>
25427
25428 <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>
25429 <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>
25430
25431 !! html/parsoid
25432 <meta property="mw:PageProp/toc" />
25433 <h2 id="Hello"><sup class="in-h2" data-parsoid='{"stx":"html"}'>Hello</sup></h2>
25434
25435 <h2 id='b">Evilbye'><span id="b.22.3EEvilbye" typeof="mw:FallbackId"></span><sup class="a " data-parsoid='{"stx":"html"}'> b">Evilbye</sup></h2>
25436 !! end
25437
25438 !! test
25439 span tags with directionality in TOC
25440 !! wikitext
25441 __TOC__
25442 ==<span dir="ltr">C++</span>==
25443
25444 ==<span dir="rtl">זבנג!</span>==
25445
25446 ==<span style="font-style: italic">The attributes on these span tags must be deleted from the TOC</span>==
25447
25448 ==<span style="font-style: italic" dir="ltr">All attributes on these span tags must be deleted from the TOC</span>==
25449
25450 ==<span dir="ltr" style="font-style: italic">Attributes after dir on these span tags must be deleted from the TOC</span>==
25451 !! html/php
25452 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
25453 <ul>
25454 <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>
25455 <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>
25456 <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>
25457 <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>
25458 <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>
25459 </ul>
25460 </div>
25461
25462 <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>
25463 <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>
25464 <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>
25465 <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>
25466 <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>
25467
25468 !! html/parsoid
25469 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25470 <h2 id="C++" data-parsoid='{}'><span id="C.2B.2B" typeof="mw:FallbackId"></span><span dir="ltr">C++</span></h2>
25471 <h2 id="זבנג!"><span id=".D7.96.D7.91.D7.A0.D7.92.21" typeof="mw:FallbackId"></span><span dir="rtl">זבנג!</span></h2>
25472 <h2 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></h2>
25473 <h2 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></h2>
25474 <h2 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></h2>
25475 !! end
25476
25477 !! test
25478 T74884: bdi element in ToC
25479 !! wikitext
25480 __TOC__
25481 ==<bdi>test</bdi>==
25482 !! html/php
25483 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
25484 <ul>
25485 <li class="toclevel-1 tocsection-1"><a href="#test"><span class="tocnumber">1</span> <span class="toctext"><bdi>test</bdi></span></a></li>
25486 </ul>
25487 </div>
25488
25489 <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>
25490
25491 !! html/parsoid
25492 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25493 <h2 id="test" data-parsoid='{}'><bdi>test</bdi></h2>
25494 !! end
25495
25496 !! test
25497 T35715: s/strike element in ToC
25498 !! wikitext
25499 __TOC__
25500 ==<s>test</s> test <strike>test</strike>==
25501 !! html/php
25502 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
25503 <ul>
25504 <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>
25505 </ul>
25506 </div>
25507
25508 <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>
25509
25510 !! html/parsoid
25511 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25512 <h2 id="test_test_test" data-parsoid='{}'><s>test</s> test <strike>test</strike></h2>
25513 !! end
25514
25515 !! test
25516 T198618: style element in ToC
25517 !! options
25518 styletag=1
25519 !! wikitext
25520 __TOC__
25521 ==<style>.foo {}</style>Style<style>.bar {}</style>==
25522 !! html/php
25523 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
25524 <ul>
25525 <li class="toclevel-1 tocsection-1"><a href="#Style"><span class="tocnumber">1</span> <span class="toctext">Style</span></a></li>
25526 </ul>
25527 </div>
25528
25529 <h2><span class="mw-headline" id="Style"><style>.foo {}</style>Style<style>.bar {}</style></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: Style">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
25530
25531 !! html/parsoid
25532 <meta property="mw:PageProp/toc" data-parsoid="{}"/>
25533 <h2 id="Style" data-parsoid="{}"><style typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{},"body":{"extsrc":".foo {}"}}'>.foo {}</style>Style<style typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{},"body":{"extsrc":".bar {}"}}'>.bar {}</style></h2>
25534 !! end
25535
25536 !! test
25537 T198618: script element in ToC
25538 !! options
25539 wgRawHtml=1
25540 !! wikitext
25541 __TOC__
25542 ==<html><script>alert(1);</script></html>Script<html><script>alert(1);</script></html>==
25543 !! html/php
25544 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
25545 <ul>
25546 <li class="toclevel-1 tocsection-1"><a href="#Script"><span class="tocnumber">1</span> <span class="toctext">Script</span></a></li>
25547 </ul>
25548 </div>
25549
25550 <h2><span class="mw-headline" id="Script"><script>alert(1);</script>Script<script>alert(1);</script></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: Script">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
25551
25552 !! html/parsoid
25553 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25554 <h2 id="Script" data-parsoid='{}'><script typeof="mw:Extension/html" about="#mwt4" data-mw='{"name":"html","attrs":{},"body":{"extsrc":"&lt;script>alert(1);&lt;/script>"}}'>alert(1);</script>Script<script typeof="mw:Extension/html" about="#mwt6" data-mw='{"name":"html","attrs":{},"body":{"extsrc":"&lt;script>alert(1);&lt;/script>"}}'>alert(1);</script></h2>
25555 !! end
25556
25557 !! test
25558 Empty <p> tag in TOC, removed by Sanitizer (T92892)
25559 !! wikitext
25560 __TOC__
25561 ==x==
25562 !! html/php
25563 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
25564 <ul>
25565 <li class="toclevel-1 tocsection-1"><a href="#x"><span class="tocnumber">1</span> <span class="toctext">x</span></a></li>
25566 </ul>
25567 </div>
25568
25569 <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>
25570
25571 !! html/parsoid
25572 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25573 <h2 id="x" data-parsoid='{}'>x</h2>
25574 !! end
25575
25576 !! article
25577 MediaWiki:T34057
25578 !! text
25579 == {{int:headline_sample}} ==
25580 !! endarticle
25581
25582 !! test
25583 T34057: Title needed when expanding <h> nodes.
25584 !! options
25585 title=[[Main Page]]
25586 !! wikitext
25587 {{int:T34057}}
25588 !! html
25589 <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>
25590
25591 !! end
25592
25593 !! test
25594 Strip marker in urlencode
25595 !! wikitext
25596 {{urlencode:x<nowiki/>y}}
25597 {{urlencode:x<nowiki/>y|wiki}}
25598 {{urlencode:x<nowiki/>y|path}}
25599 {{urlencode:x<pre id="one">two</pre>y}}
25600 !! html/php
25601 <p>xy
25602 xy
25603 xy
25604 xy
25605 </p>
25606 !! end
25607
25608 !! test
25609 Strip marker in lc
25610 !! wikitext
25611 {{lc:x<nowiki/>y}}
25612 !! html
25613 <p>xy
25614 </p>
25615 !! end
25616
25617 !! test
25618 Strip marker in uc
25619 !! wikitext
25620 {{uc:x<nowiki/>y}}
25621 !! html
25622 <p>XY
25623 </p>
25624 !! end
25625
25626 !! test
25627 Strip marker in formatNum
25628 !! wikitext
25629 {{formatnum:1<nowiki/>2}}
25630 {{formatnum:1<nowiki/>2|R}}
25631 !! html
25632 <p>12
25633 12
25634 </p>
25635 !! end
25636
25637 !! test
25638 Check noCommafy in formatNum
25639 !! options
25640 language=be-tarask
25641 !! wikitext
25642 {{formatnum:123456.78}}
25643 {{formatnum:123456.78|NOSEP}}
25644 !! html
25645 <p>123 456,78
25646 123456.78
25647 </p>
25648 !! end
25649
25650 !! test
25651 Wrong option for formatNum (T58199)
25652 !! wikitext
25653 {{formatnum:1,234.56|Random}}
25654 {{formatnum:1,234.56|EVERYTHING}}
25655 {{formatnum:1234.56|any argument that has the string 'NOSEP'}}
25656 !! html
25657 <p>1,234.56
25658 1,234.56
25659 1,234.56
25660 </p>
25661 !! end
25662
25663 !! test
25664 Strip marker in grammar
25665 !! options
25666 language=fi
25667 !! wikitext
25668 {{grammar:elative|foo<nowiki/>bar}}
25669 !! html
25670 <p>foobarista
25671 </p>
25672 !! end
25673
25674 !! test
25675 Strip marker in padleft
25676 !! wikitext
25677 {{padleft:|2|x<nowiki/>y}}
25678 !! html
25679 <p>xy
25680 </p>
25681 !! end
25682
25683 !! test
25684 Strip marker in padright
25685 !! wikitext
25686 {{padright:|2|x<nowiki/>y}}
25687 !! html
25688 <p>xy
25689 </p>
25690 !! end
25691
25692 !! test
25693 Strip marker in anchorencode
25694 !! wikitext
25695 {{anchorencode:x<nowiki/>y}}
25696 !! html/php
25697 <p>xy
25698 </p>
25699 !! html/parsoid
25700 <p about="#mwt2" typeof="mw:Transclusion" data-parsoid='{"pi":[[]]}' data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode:x&lt;nowiki/>y","function":"anchorencode"},"params":{},"i":0}}]}'>xy</p>
25701 !! end
25702
25703 !! test
25704 nowiki inside link inside heading (T20295)
25705 !! wikitext
25706 ==[[foo|x<nowiki>y</nowiki>z]]==
25707 !! html
25708 <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>
25709
25710 !! end
25711
25712 !! test
25713 new support for bdi element (T33817)
25714 !! wikitext
25715 <p dir="rtl" lang="he">ולדימיר לנין (ברוסית: <bdi lang="ru">Владимир Ленин</bdi>, 24 באפריל 1870–22 בינואר 1924) הוא מנהיג פוליטי קומוניסטי רוסי.</p>
25716 !! html
25717 <p dir="rtl" lang="he">ולדימיר לנין (ברוסית: <bdi lang="ru">Владимир Ленин</bdi>, 24 באפריל 1870–22 בינואר 1924) הוא מנהיג פוליטי קומוניסטי רוסי.</p>
25718
25719 !!end
25720
25721 !! test
25722 Ignore pipe between table row attributes
25723 !! wikitext
25724 {|
25725 |quux
25726 |- id=foo | style='color: red'
25727 |bar
25728 |}
25729 !! html
25730 <table>
25731 <tr>
25732 <td>quux
25733 </td></tr>
25734 <tr id="foo" style="color: red">
25735 <td>bar
25736 </td></tr></table>
25737
25738 !! end
25739
25740 !!test
25741 Language parser function
25742 !! wikitext
25743 {{#language:ar}}
25744 !! html
25745 <p>العربية
25746 </p>
25747 !! end
25748
25749 !!test
25750 Padleft and padright (default 0-padding)
25751 !! wikitext
25752 {{padleft:xyz|5}}
25753 {{padright:xyz|5}}
25754 !! html/php
25755 <p>00xyz
25756 xyz00
25757 </p>
25758 !! html/parsoid
25759 <p><span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padleft:xyz","function":"padleft"},"params":{"1":{"wt":"5"}},"i":0}}]}'>00xyz</span>
25760 <span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padright:xyz","function":"padright"},"params":{"1":{"wt":"5"}},"i":0}}]}'>xyz00</span></p>
25761 !! end
25762
25763 !!test
25764 Padleft and padright (partial fill)
25765 !! wikitext
25766 {{padleft:xyz|6|ab}}
25767 {{padright:xyz|6|ab}}
25768 !! html/php
25769 <p>abaxyz
25770 xyzaba
25771 </p>
25772 !! html/parsoid
25773 <p><span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padleft:xyz","function":"padleft"},"params":{"1":{"wt":"6"},"2":{"wt":"ab"}},"i":0}}]}'>abaxyz</span>
25774 <span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padright:xyz","function":"padright"},"params":{"1":{"wt":"6"},"2":{"wt":"ab"}},"i":0}}]}'>xyzaba</span></p>
25775 !! end
25776
25777 !!test
25778 Padleft and padright as substr
25779 !! wikitext
25780 {{padleft:|3|abcde}}
25781 {{padright:|3|abcde}}
25782 !! html/php
25783 <p>abc
25784 abc
25785 </p>
25786 !! html/parsoid
25787 <p><span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padleft:","function":"padleft"},"params":{"1":{"wt":"3"},"2":{"wt":"abcde"}},"i":0}}]}'>abc</span>
25788 <span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padright:","function":"padright"},"params":{"1":{"wt":"3"},"2":{"wt":"abcde"}},"i":0}}]}'>abc</span></p>
25789 !! end
25790
25791 !! test
25792 Padleft and padright with non-numerical length (T180403)
25793 !! wikitext
25794 {{padleft:abcdef|junk}}
25795 {{padright:abcdef|junk}}
25796 !! html/php
25797 <p>abcdef
25798 abcdef
25799 </p>
25800 !! end
25801
25802 !!test
25803 Special parser function
25804 !! wikitext
25805 {{#special:RandomPage}}
25806 {{#special:BaDtItLe}}
25807 {{#special:Foobar}}
25808 !! html
25809 <p>Special:Random
25810 Special:Badtitle
25811 Special:Foobar
25812 </p>
25813 !! end
25814
25815 !!test
25816 T36939 - Case insensitive link parsing ([HttP://])
25817 !! wikitext
25818 [HttP://MediaWiki.Org/]
25819 !! html/php
25820 <p><a rel="nofollow" class="external autonumber" href="HttP://MediaWiki.Org/">[1]</a>
25821 </p>
25822 !! html/parsoid
25823 <p><a rel="mw:ExtLink" class="external autonumber" href="HttP://MediaWiki.Org/"></a></p>
25824 !! end
25825
25826 !!test
25827 T36939 - Case insensitive link parsing ([HttP:// title])
25828 !! wikitext
25829 [HttP://MediaWiki.Org/ MediaWiki]
25830 !! html
25831 <p><a rel="nofollow" class="external text" href="HttP://MediaWiki.Org/">MediaWiki</a>
25832 </p>
25833 !! end
25834
25835 !!test
25836 T36939 - Case insensitive link parsing (HttP://)
25837 !! wikitext
25838 HttP://MediaWiki.Org/
25839 !! html/php
25840 <p><a rel="nofollow" class="external free" href="HttP://MediaWiki.Org/">HttP://MediaWiki.Org/</a>
25841 </p>
25842 !! html/parsoid
25843 <p><a rel="mw:ExtLink" class="external free" href="HttP://MediaWiki.Org/">HttP://MediaWiki.Org/</a></p>
25844 !! end
25845
25846 !!test
25847 Disable TOC
25848 !! options
25849 notoc
25850 !! wikitext
25851 Lead
25852 ==Section 1==
25853 ==Section 2==
25854 ==Section 3==
25855 ==Section 4==
25856 ==Section 5==
25857 !! html
25858 <p>Lead
25859 </p>
25860
25861 <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>
25862 <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>
25863 <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>
25864 <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>
25865 <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>
25866
25867 !! end
25868
25869
25870 ###
25871 ### Parsoid-specific tests
25872 ### Parsoid-PHP parser incompatibilities
25873 ###
25874 !!test
25875 1. SOL-sensitive wikitext tokens as template-args
25876 !! options
25877 parsoid=wt2html,wt2wt
25878 !! wikitext
25879 {{echo|*a}}
25880 {{echo|#a}}
25881 {{echo|:a}}
25882 !! html/php+tidy
25883 <ul><li>a</li></ul>
25884 <ol><li>a</li></ol>
25885 <dl><dd>a</dd></dl>
25886 !! html/parsoid
25887 <span about="#mwt1" typeof="mw:Transclusion">
25888 </span><ul about="#mwt1"><li>a</li>
25889 </ul>
25890 <span about="#mwt2" typeof="mw:Transclusion">
25891 </span><ol about="#mwt2"><li>a</li>
25892 </ol>
25893 <span about="#mwt3" typeof="mw:Transclusion">
25894 </span><dl about="#mwt3"><dd>a</dd>
25895 </dl>
25896 !!end
25897
25898 #### -----------------------------------------------------------------
25899 #### Parsoid-specific functionality tests
25900 #### -----------------------------------------------------------------
25901
25902 # T65642/T68749: Formatting elt fixup around images.
25903 # We know wt2wt will fail, but we expect selser to pass.
25904 # Due to the nature of our testing, wt2wt and selser tests will enter the
25905 # blacklist and we'll catch selser regressions based on changes to the
25906 # blacklist entries for selser tests.
25907 !! test
25908 1. Treebuilder fixup of formatting elt
25909 !! options
25910 parsoid=wt2html,wt2wt
25911 !! wikitext
25912 {|
25913 |
25914 <small>
25915 [[Image:Foobar.jpg|right|Test]]
25916 </small>
25917 |}
25918 !! html/php+tidy
25919 <table>
25920 <tbody><tr>
25921 <td>
25922 <p><small>
25923 </small></p><small>
25924 <div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image" title="Test"><img alt="Test" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" /></a></div>
25925 </small><p><small></small>
25926 </p>
25927 </td></tr></tbody></table>
25928 !! html/parsoid
25929 <table>
25930 <tbody><tr><td>
25931 <p><small data-parsoid='{"stx":"html","autoInsertedEnd":true}'></small></p><small data-parsoid='{"stx":"html","autoInsertedEnd":true,"autoInsertedStart":true}'>
25932 <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></small>
25933 <p><small data-parsoid='{"stx":"html","autoInsertedStart":true}'></small></p></td></tr>
25934 </tbody></table>
25935 !! end
25936
25937 !! test
25938 2. Treebuilder fixup of formatting elt
25939 !! options
25940 parsoid=wt2html,wt2wt
25941 !! wikitext
25942 '''foo[[File:Foobar.jpg|thumb|caption]]bar'''
25943
25944 <small>[[Image:Foobar.jpg|right|300px]]</small>
25945 !! html/php+tidy
25946 <p><b>foo</b></p><b><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" decoding="async" 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></b><p><b>bar</b>
25947 </p><small><div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg" decoding="async" 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></div></small>
25948 !! html/parsoid
25949 <p><b>foo</b></p><b><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></b><p><b>bar</b></p>
25950
25951 <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>
25952 !! end
25953
25954 !! test
25955 3. Treebuilder fixup of formatting elt
25956 !! options
25957 parsoid=wt2html,wt2wt
25958 !! wikitext
25959 <small>'''foo[[File:Foobar.jpg|thumb|caption]]bar'''</small>
25960 !! html/php+tidy
25961 <p><small><b>foo</b></small></p><small><b><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" decoding="async" 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></b></small><p><small><b>bar</b></small>
25962 </p>
25963 !! html/parsoid
25964 <p><small><b>foo</b></small></p><small><b><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></b></small><p><small><b>bar</b></small></p>
25965 !! end
25966
25967 !! test
25968 4. Treebuilder fixup of formatting elt: formatting tags around captionless images
25969 !! options
25970 parsoid=wt2html,wt2wt
25971 !! wikitext
25972 '''<small>[[Image:Foobar.jpg|right|300px]]</small>'''
25973 !! html/php+tidy
25974 <b><small><div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg" decoding="async" 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></div></small></b>
25975 !! html/parsoid
25976 <b><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></b>
25977 !! end
25978
25979 #### ----------------------------------------------------------------
25980 #### Parsoid-only testing of Parsoid's impl of LST
25981 #### Not implemented yet, see
25982 #### https://www.mediawiki.org/wiki/Parsoid/HTML_based_LST
25983 #### ----------------------------------------------------------------
25984
25985 ## We still need to support serializing the older format while content is stored.
25986 !! test
25987 LST Sections: Backwards compatibility
25988 !! options
25989 parsoid={
25990 "suppressErrors": true,
25991 "modes": ["html2wt"]
25992 }
25993 !! wikitext
25994 <section begin="2011-05-16" />
25995 <section end="2014-04-10 (MW 1.23wmf22)" />
25996 !! html/parsoid
25997 <p><meta typeof="mw:Extension/LabeledSectionTransclusion/begin" content="2011-05-16"/>
25998 <meta typeof="mw:Extension/LabeledSectionTransclusion/end" content="2014-04-10 (MW 1.23wmf22)"/></p>
25999 !! end
26000
26001 !! test
26002 LST Sections: Newfangled approach
26003 !! wikitext
26004 <section begin="2011-05-16" />
26005 <section end="2014-04-10 (MW 1.23wmf22)" />
26006 !! html/parsoid
26007 <p><span typeof="mw:Extension/section" about="#mwt4" data-mw='{"name":"section","attrs":{"begin":"2011-05-16"}}'>
26008 </span>
26009 <span typeof="mw:Extension/section" about="#mwt6" data-mw='{"name":"section","attrs":{"end":"2014-04-10 (MW 1.23wmf22)"}}'>
26010 </span></p>
26011 !! end
26012
26013 #--------- Test stripping of empty nodes in template content ----------
26014
26015 !! test
26016 Empty LI and TR nodes should be stripped from template content
26017 !! wikitext
26018 {{EmptyLITest}}
26019 {{EmptyTRTest}}
26020 !! html/parsoid
26021 <ul about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyLITest","href":"./Template:EmptyLITest"},"params":{},"i":0}}]}'>
26022 <li>a</li>
26023 <li>b</li>
26024 </ul>
26025 <table about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyTRTest","href":"./Template:EmptyTRTest"},"params":{},"i":0}}]}'>
26026 <tbody>
26027 <tr>
26028 <td>foo</td>
26029 </tr>
26030 <tr>
26031 <td>bar</td>
26032 </tr>
26033 </tbody>
26034 </table>
26035 !! end
26036
26037 !! test
26038 Empty LI and TR nodes should not be stripped from top-level content
26039 !! wikitext
26040 *a
26041 *
26042 *b
26043
26044 {|
26045 |-
26046 |-
26047 |foo
26048 |}
26049 !! html/parsoid
26050 <ul>
26051 <li>a</li>
26052 <li class='mw-empty-elt'></li>
26053 <li>b</li>
26054 </ul>
26055 <table>
26056 <tbody>
26057 <tr class='mw-empty-elt'></tr>
26058 <tr>
26059 <td>foo</td>
26060 </tr>
26061 </tbody>
26062 </table>
26063 !! end
26064
26065 !! test
26066 Empty TR nodes should not be stripped if they have any attributes set
26067 !! wikitext
26068 {{EmptyTRWithHTMLAttrTest}}
26069 !! html/parsoid
26070 <table about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyTRWithHTMLAttrTest","href":"./Template:EmptyTRWithHTMLAttrTest"},"params":{},"i":0}}]}'>
26071 <tr align='center'></tr>
26072 <tr><td>foo</td></tr>
26073 <tr align='center'></tr>
26074 <tr><td>bar</td></tr>
26075 </table>
26076 !! end
26077
26078 #### ----------------------------------------------------------------
26079 #### The following section of tests are primarily to test
26080 #### wikitext escaping capabilities of Parsoid. Given that
26081 #### escaping can be done any number of ways, the wikitext (input)
26082 #### is always adjusted to reflect how Parsoid adds nowiki
26083 #### escape tags.
26084 ####
26085 #### We are marking several tests as parsoid-only since the
26086 #### HTML in the result section is different from what the
26087 #### PHP parser generates for it.
26088 #### ----------------------------------------------------------------
26089
26090
26091 #### --------------- Headings ---------------
26092 #### 0. Unnested
26093 #### 1. Nested inside html <h1>=foo=</h1>
26094 #### 2. Outside heading nest on a single line <h1>foo</h1>*bar
26095 #### 3. Nested inside html with wikitext split by html tags
26096 #### 4. No escape needed
26097 #### 5. Empty headings <h1></h1>
26098 #### 6. Heading chars in SOL context
26099 #### ----------------------------------------
26100 !! test
26101 Headings: 0. Unnested
26102 !! options
26103 parsoid=html2wt
26104 !! html/parsoid
26105 <p>=foo=</p>
26106
26107 <p> =foo=
26108 <!--cmt-->
26109 =foo=</p>
26110
26111 <p>=foo<i>a</i>=</p>
26112 !! wikitext
26113 <nowiki>=foo=</nowiki>
26114
26115 <nowiki> </nowiki>=foo=
26116 <!--cmt-->
26117 <nowiki>=foo=</nowiki>
26118
26119 =foo''a''<nowiki>=</nowiki>
26120 !!end
26121
26122 # New headings and existing headings are handled differently
26123 !! test
26124 Headings: 1. Nested inside html
26125 !! options
26126 parsoid=html2wt
26127 !! html/parsoid
26128 <h1>=foo=</h1>
26129 <h2>=foo=</h2>
26130 <h3>=foo=</h3>
26131
26132 <h1 data-parsoid=''>=foo=</h1>
26133 <h2 data-parsoid=''>=foo=</h2>
26134 <h3 data-parsoid=''>=foo=</h3>
26135 <h4 data-parsoid=''>=foo=</h4>
26136 <h5 data-parsoid=''>=foo=</h5>
26137 <h6 data-parsoid=''>=foo=</h6>
26138 !! wikitext
26139 = =foo= =
26140
26141 == =foo= ==
26142
26143 === =foo= ===
26144
26145 =<nowiki>=foo=</nowiki>=
26146 ==<nowiki>=foo=</nowiki>==
26147 ===<nowiki>=foo=</nowiki>===
26148 ====<nowiki>=foo=</nowiki>====
26149 =====<nowiki>=foo=</nowiki>=====
26150 ======<nowiki>=foo=</nowiki>======
26151
26152 !!end
26153
26154 !! test
26155 Headings: 2. Outside heading nest on a single line <h1>foo</h1>*bar
26156 !! options
26157 parsoid=html2wt
26158 !! html/parsoid
26159 <h1>foo</h1>*bar
26160 <h1>foo</h1>=bar
26161 <h1>foo</h1>=bar=
26162 !! wikitext
26163 = foo =
26164 <nowiki>*</nowiki>bar
26165
26166 = foo =
26167 =bar
26168
26169 = foo =
26170 <nowiki>=bar=</nowiki>
26171 !!end
26172
26173 !! test
26174 Headings: 3. Nested inside html with wikitext split by html tags
26175 !! options
26176 parsoid=html2wt
26177 !! html/parsoid
26178 <h1>=<b>bold</b>foo=</h1>
26179 !! wikitext
26180 = ='''bold'''foo= =
26181 !!end
26182
26183 !! test
26184 Headings: 4a. No escaping needed (testing just h1 and h2)
26185 !! options
26186 parsoid=html2wt
26187 !! html/parsoid
26188 <h1>=foo</h1>
26189 <h1>foo=</h1>
26190 <h1> =foo= </h1>
26191 <h1>=foo= bar</h1>
26192 <h2>=foo</h2>
26193 <h2>foo=</h2>
26194 <h1>=</h1>
26195 <h1><i>=</i>foo=</h1>
26196 !! wikitext
26197 = =foo =
26198
26199 = foo= =
26200
26201 = =foo= =
26202
26203 = =foo= bar =
26204
26205 == =foo ==
26206
26207 == foo= ==
26208
26209 = = =
26210
26211 = ''=''foo= =
26212 !!end
26213
26214 !! test
26215 Headings: 4b. No escaping needed (inside p-tags)
26216 !! options
26217 parsoid=html2wt
26218 !! html/parsoid
26219 <p>=foo= x
26220 =foo= <s></s>
26221 </p>
26222 !! wikitext
26223 =foo= x
26224 =foo= <s></s>
26225 !! html/php
26226 <p>=foo= x
26227 =foo= <s></s>
26228 </p>
26229 !!end
26230
26231 !! test
26232 Headings: 4c. Short headings (1)
26233 !! options
26234 parsoid=html2wt
26235 !! html/parsoid
26236 <p>===
26237 </p>
26238 !! wikitext
26239 <nowiki>===</nowiki>
26240 !! html/php
26241 <p>===
26242 </p>
26243 !! end
26244
26245 # in the html2wt direction we emit '= = =' or '=<nowiki>=</nowiki>='
26246 !! test
26247 Headings: 4d. Short headings (2)
26248 !! options
26249 parsoid=wt2html,html2html
26250 !! wikitext
26251 =
26252 ==
26253 ===
26254 ====
26255 =====
26256 !! html/php
26257 <p>=
26258 ==
26259 </p>
26260 <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>
26261 <h1><span class="mw-headline" id=".3D.3D">==</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>
26262 <h2><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=3" title="Edit section: =">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
26263
26264 !! html/parsoid
26265 <p>=
26266 ==</p>
26267 <h1 id="="><span id=".3D" typeof="mw:FallbackId"></span>=</h1>
26268 <h1 id="=="><span id=".3D.3D" typeof="mw:FallbackId"></span>==</h1>
26269 <h2 id="=_2"><span id=".3D_2" typeof="mw:FallbackId"></span>=</h2>
26270 !! end
26271
26272 !! test
26273 Headings: 5. Empty headings
26274 !! options
26275 parsoid=html2wt
26276 !! html/parsoid
26277 <h1 data-parsoid='{}'></h1>
26278
26279 <h2 data-parsoid='{}'></h2>
26280
26281 <h3 data-parsoid='{}'></h3>
26282
26283 <h4 data-parsoid='{}'></h4>
26284
26285 <h5 data-parsoid='{}'></h5>
26286
26287 <h6 data-parsoid='{}'></h6>
26288 !! wikitext
26289 =<nowiki/>=
26290
26291 ==<nowiki/>==
26292
26293 ===<nowiki/>===
26294
26295 ====<nowiki/>====
26296
26297 =====<nowiki/>=====
26298
26299 ======<nowiki/>======
26300 !!end
26301
26302 !! test
26303 Headings: 6a. Heading chars in SOL context (with trailing spaces)
26304 !! options
26305 parsoid=html2wt
26306 !! html/parsoid
26307 <p>=a=</p>
26308
26309 <p>=a=</p>
26310
26311 <p>=a=</p>
26312 !! wikitext
26313 <nowiki>=a=</nowiki>
26314
26315 <nowiki>=a=</nowiki>
26316
26317 <nowiki>=a=</nowiki>
26318 !!end
26319
26320 !! test
26321 Headings: 6b. Heading chars in SOL context (with trailing newlines)
26322 !! options
26323 parsoid=html2wt
26324 !! html/parsoid
26325 <p>=a=
26326 b</p>
26327
26328 <p>=a=
26329 b</p>
26330
26331 <p>=a=
26332 b</p>
26333 !! wikitext
26334 <nowiki>=a=</nowiki>
26335 b
26336
26337 <nowiki>=a=</nowiki>
26338 b
26339
26340 <nowiki>=a=</nowiki>
26341 b
26342 !!end
26343
26344 !! test
26345 Headings: 6c. Heading chars in SOL context (leading newline break)
26346 !! options
26347 parsoid=html2wt
26348 !! html/parsoid
26349 <p>a
26350 =b=</p>
26351 !! wikitext
26352 a
26353 <nowiki>=b=</nowiki>
26354 !!end
26355
26356 !! test
26357 Headings: 6d. Heading chars in SOL context (with interspersed comments)
26358 !! options
26359 parsoid=html2wt
26360 !! html/parsoid
26361 <!--c0--><p>=a=</p>
26362
26363 <!--c1--><p>=a=</p> <!--c2--> <!--c3-->
26364 !! wikitext
26365 <!--c0--><nowiki>=a=</nowiki>
26366
26367 <!--c1--><nowiki>=a=</nowiki> <!--c2--> <!--c3-->
26368 !!end
26369
26370 !! test
26371 Headings: 6d. Heading chars in SOL context (No escaping needed)
26372 !! options
26373 parsoid=html2wt
26374 !! html/parsoid
26375 =a=<div>b</div>
26376 !! wikitext
26377 =a=<div>b</div>
26378 !!end
26379
26380 !! test
26381 Headings: 7. Insert a newline between new content and headings
26382 !! options
26383 parsoid=html2wt
26384 !! html/parsoid
26385 <h2>NEW</h2>
26386 <p>new</p>
26387 <h2 data-parsoid='{}'>A</h2>
26388 <p data-parsoid='{}'>a</p>
26389 !! wikitext
26390 == NEW ==
26391 new
26392
26393 ==A==
26394 a
26395
26396 !! end
26397
26398 !! test
26399 Headings: Used as horizontal rule
26400 !! config
26401 wgFragmentMode=[ 'html5', 'legacy' ]
26402 !! options
26403 parsoid=wt2html
26404 !! wikitext
26405 ===============
26406 !! html/php
26407 <h6><span id=".3D.3D.3D"></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=1" title="Edit section: ===">edit</a><span class="mw-editsection-bracket">]</span></span></h6>
26408
26409 !! html/parsoid
26410 <h6 id="==="><span id=".3D.3D.3D" typeof="mw:FallbackId"></span>===</h6>
26411 !! end
26412
26413 #### --------------- Lists ---------------
26414 #### 0. Outside nests (*foo, etc.)
26415 #### 1. Nested inside html <ul><li>*foo</li></ul>
26416 #### 2. Inside definition lists
26417 #### 3. Only bullets at start should be escaped
26418 #### 4. No escapes needed
26419 #### 5. No unnecessary escapes
26420 #### 6. Escape bullets in SOL position
26421 #### 7. Escape bullets in a multi-line context
26422 #### ----------------------------------------
26423
26424 !! test
26425 Lists: 0. Outside nests
26426 !! options
26427 parsoid=html2wt
26428 !! html/parsoid
26429 <p>*foo</p>
26430
26431 <p>#foo</p>
26432
26433 <p>;Foo:bar</p>
26434 !! wikitext
26435 <nowiki>*</nowiki>foo
26436
26437 <nowiki>#</nowiki>foo
26438
26439 <nowiki>;</nowiki>Foo<nowiki>:</nowiki>bar
26440 !!end
26441
26442 ## Making these next 3 tests Parsoid-only since they are html2wt tests
26443 ## to test wikitext escaping, and insignificant whitespace diffs
26444 ## cause PHP parser tests to barf
26445 !! test
26446 Lists: 1. Nested inside html (No unnecessary escapes)
26447 !! options
26448 parsoid=html2wt
26449 !! html/parsoid
26450 <ul>
26451 <li>*foo</li>
26452 <li>#foo</li>
26453 <li>:foo</li>
26454 <li>;foo</li>
26455 <li data-parsoid='{}'>*foo</li>
26456 <li data-parsoid='{}'>#foo</li>
26457 <li data-parsoid='{}'>:foo</li>
26458 <li data-parsoid='{}'>;foo</li>
26459 </ul>
26460
26461 <ol>
26462 <li>*foo</li>
26463 <li>#foo</li>
26464 <li>:foo</li>
26465 <li>;foo</li>
26466 <li data-parsoid='{}'>*foo</li>
26467 <li data-parsoid='{}'>#foo</li>
26468 <li data-parsoid='{}'>:foo</li>
26469 <li data-parsoid='{}'>;foo</li>
26470 </ol>
26471 !! wikitext
26472 * *foo
26473 * #foo
26474 * :foo
26475 * ;foo
26476 *<nowiki>*foo</nowiki>
26477 *<nowiki>#foo</nowiki>
26478 *<nowiki>:foo</nowiki>
26479 *<nowiki>;foo</nowiki>
26480
26481 # *foo
26482 # #foo
26483 # :foo
26484 # ;foo
26485 #<nowiki>*foo</nowiki>
26486 #<nowiki>#foo</nowiki>
26487 #<nowiki>:foo</nowiki>
26488 #<nowiki>;foo</nowiki>
26489 !!end
26490
26491 !! test
26492 Lists: 2. Inside definition lists
26493 !! options
26494 parsoid=html2wt
26495 !! html/parsoid
26496 <dl><dt>;foo</dt></dl>
26497 <dl><dt>:foo</dt></dl>
26498 <dl><dt>:foo</dt>
26499 <dd>bar</dd></dl>
26500 <dl><dd>:foo</dd></dl>
26501 !! wikitext
26502 ; ;foo
26503
26504 ; <nowiki>:foo</nowiki>
26505
26506 ; <nowiki>:foo</nowiki>
26507 : bar
26508
26509 : :foo
26510 !!end
26511
26512 !! test
26513 Lists: 3. Only bullets at start of text in wikitext-generated HTML should be escaped
26514 !! options
26515 parsoid=html2wt
26516 !! html/parsoid
26517 <ul>
26518 <li>*foo*bar</li>
26519 <li data-parsoid='{}'>*foo<i>it</i>*bar</li>
26520 </ul>
26521 !! wikitext
26522 * *foo*bar
26523 *<nowiki>*foo</nowiki>''it''*bar
26524 !!end
26525
26526 !! test
26527 Lists: 4. No escapes needed
26528 !! options
26529 parsoid=html2wt
26530 !! html/parsoid
26531 <ul>
26532 <li>foo*bar
26533 </li>
26534 </ul>
26535 <ul>
26536 <li><i>foo</i>*bar
26537 </li>
26538 </ul>
26539 <ul>
26540 <li><a rel="mw:WikiLink" href="Foo" title="Foo">Foo</a>: bar
26541 </li>
26542 </ul>
26543 <ul>
26544 <li><a rel="mw:WikiLink" href="Foo" title="Foo">Foo</a>*bar
26545 </li>
26546 </ul>
26547 !! wikitext
26548 *foo*bar
26549
26550 *''foo''*bar
26551
26552 *[[Foo]]: bar
26553
26554 *[[Foo]]*bar
26555 !!end
26556
26557 !! test
26558 Lists: 5. No unnecessary escapes
26559 !! options
26560 parsoid=html2wt
26561 !! html/parsoid
26562 <ul><li> bar <span>[[foo]]</span></li></ul>
26563 <ul><li> =bar <span>[[foo]]</span></li></ul>
26564 <ul><li> [[bar <span>[[foo]]</span></li></ul>
26565 <ul><li> ]]bar <span>[[foo]]</span></li></ul>
26566 <ul><li> =bar <span>foo]]</span>=</li></ul>
26567 <ul><li> <s></s>: a</li></ul>
26568 <ul><li> <i>* foo</i></li></ul>
26569
26570 !! wikitext
26571 * bar <span><nowiki>[[foo]]</nowiki></span>
26572
26573 * =bar <span><nowiki>[[foo]]</nowiki></span>
26574
26575 * [[bar <span><nowiki>[[foo]]</nowiki></span>
26576
26577 * ]]bar <span><nowiki>[[foo]]</nowiki></span>
26578
26579 * =bar <span>foo]]</span>=
26580
26581 * <s></s>: a
26582
26583 * ''* foo''
26584 !!end
26585
26586 !! test
26587 Lists: 6. Escape bullets in SOL position
26588 !! options
26589 parsoid=html2wt
26590 !! html/parsoid
26591 <p><!--cmt-->*foo</p>
26592 !! wikitext
26593 <!--cmt--><nowiki>*</nowiki>foo
26594 !!end
26595
26596 !! test
26597 Lists: 7. Escape bullets in a multi-line context
26598 !! options
26599 parsoid=html2wt
26600 !! html/parsoid
26601 <p>a
26602 *b
26603 </p>
26604 !! wikitext
26605 a
26606 <nowiki>*</nowiki>b
26607 !!end
26608
26609 !! test
26610 Lists: 8. Escape colons only if not present in tags
26611 !! options
26612 parsoid=html2wt
26613 !! html/parsoid
26614 <dl><dt>a:b<i>c:d</i></dt></dl>
26615 !! wikitext
26616 ; <nowiki>a:b</nowiki>''c:d''
26617 !! end
26618
26619 #### --------------- HRs ---------------
26620 #### 1. Single line
26621 #### -----------------------------------
26622
26623 !! test
26624 HRs: 1. Single line
26625 !! options
26626 parsoid=html2wt
26627 !! html/parsoid
26628 <hr />----
26629 <hr />=foo=
26630 <hr />*foo
26631 !! wikitext
26632 ----<nowiki>----</nowiki>
26633 ----=foo=
26634 ----*foo
26635 !! end
26636
26637 #### --------------- Tables ---------------
26638 #### 1a. Simple example
26639 #### 1b. No escaping needed (!foo)
26640 #### 1c. No escaping needed (|foo)
26641 #### 1d. No escaping needed (|}foo)
26642 ####
26643 #### 2a. Nested in td (<td>foo|bar</td>)
26644 #### 2b. Nested in td (<td>foo||bar</td>)
26645 #### 2c. Nested in td -- no escaping needed(<td>foo!!bar</td>)
26646 ####
26647 #### 3a. Nested in th (<th>foo!bar</th>)
26648 #### 3b. Nested in th (<th>foo!!bar</th>)
26649 #### 3c. Nested in th -- no escaping needed(<th>foo||bar</th>)
26650 ####
26651 #### 4a. Escape -
26652 #### 4b. Escape +
26653 #### 4c. No escaping needed
26654 #### --------------------------------------
26655
26656 !! test
26657 Tables: 1a. Simple example
26658 !! options
26659 parsoid=html2wt
26660 !! html/parsoid
26661 <p>{|
26662 |}
26663 </p>
26664 !! wikitext
26665 <nowiki>{|</nowiki>
26666 |}
26667 !! end
26668
26669 !! test
26670 Tables: 1b. No escaping needed
26671 !! options
26672 parsoid=html2wt
26673 !! html/parsoid
26674 <p>!foo
26675 </p>
26676 !! wikitext
26677 !foo
26678 !! end
26679
26680 !! test
26681 Tables: 1c. No escaping needed
26682 !! options
26683 parsoid=html2wt
26684 !! html/parsoid
26685 <p>|foo
26686 </p>
26687 !! wikitext
26688 |foo
26689 !! end
26690
26691 !! test
26692 Tables: 1d. No escaping needed
26693 !! options
26694 parsoid=html2wt
26695 !! html/parsoid
26696 <p>|}foo
26697 </p>
26698 !! wikitext
26699 |}foo
26700 !! end
26701
26702 !! test
26703 Tables: 2a. Nested in td
26704 !! options
26705 parsoid=html2wt
26706 !! html/parsoid
26707 <table><tbody><tr>
26708 <td>foo|bar</td></tr>
26709 <tr><td>x<div>a|b</div></td>
26710 </tbody></table>
26711 !! wikitext
26712 {|
26713 |<nowiki>foo|bar</nowiki>
26714 |-
26715 |x<div><nowiki>a|b</nowiki></div>
26716 |}
26717 !! html/php+tidy
26718 <table>
26719 <tbody><tr>
26720 <td>foo|bar
26721 </td></tr>
26722 <tr>
26723 <td>x<div>a|b</div>
26724 </td></tr></tbody></table>
26725 !! end
26726
26727 !! test
26728 Tables: 2b. Nested in td
26729 !! options
26730 parsoid=html2wt
26731 !! html/parsoid
26732 <table><tbody><tr>
26733 <td>foo||bar</td>
26734 <td>a<i>b||c</i></td>
26735 <td>a<i><div>b||c</div></i></td>
26736 </tr></tbody></table>
26737 !! wikitext
26738 {|
26739 |<nowiki>foo||bar</nowiki>
26740 |a''<nowiki>b||c</nowiki>''
26741 |a''<div><nowiki>b||c</nowiki></div>''
26742 |}
26743 !! html/php
26744 <table>
26745 <tr>
26746 <td>foo||bar
26747 </td>
26748 <td>a<i>b||c</i>
26749 </td>
26750 <td>a<i><div>b||c</div></i>
26751 </td></tr></table>
26752
26753 !! end
26754
26755 !! test
26756 Tables: 2c. Nested in td -- no escaping needed
26757 !! options
26758 parsoid=html2wt
26759 !! html/*
26760 <table>
26761 <tr>
26762 <td>foo!!bar
26763 </td></tr></table>
26764
26765 !! wikitext
26766 {|
26767 |foo!!bar
26768 |}
26769 !! end
26770
26771 !! test
26772 Tables: 3a. Nested in th
26773 !! options
26774 parsoid=html2wt
26775 !! html/*
26776 <table>
26777 <tr>
26778 <th>foo!bar
26779 </th></tr></table>
26780
26781 !! wikitext
26782 {|
26783 !foo!bar
26784 |}
26785 !! end
26786
26787 !! test
26788 Tables: 3b. Nested in th
26789 !! options
26790 parsoid=html2wt
26791 !! html/parsoid
26792 <table><tbody>
26793 <tr><th>foo!!bar</th>
26794 <th><i>foo|bar</i></th>
26795 <th><i>foo!!bar</i></th>
26796 <th><i><span>foo!!bar</span></i></th>
26797 </tr></tbody></table>
26798 !! wikitext
26799 {|
26800 !<nowiki>foo!!bar</nowiki>
26801 !''<nowiki>foo|bar</nowiki>''
26802 !''<nowiki>foo!!bar</nowiki>''
26803 !''<span><nowiki>foo!!bar</nowiki></span>''
26804 |}
26805 !! html/php
26806 <table>
26807 <tr>
26808 <th>foo!!bar
26809 </th>
26810 <th><i>foo|bar</i>
26811 </th>
26812 <th><i>foo!!bar</i>
26813 </th>
26814 <th><i><span>foo!!bar</span></i>
26815 </th></tr></table>
26816
26817 !! end
26818
26819 !! test
26820 Tables: 3c. Nested in th
26821 !! options
26822 parsoid=html2wt
26823 !! html/parsoid
26824 <table><tbody>
26825 <tr><th>foo||bar</th>
26826 <th><span typeof="mw:Nowiki">foo||bar</span></th>
26827 </tr></tbody></table>
26828 !! wikitext
26829 {|
26830 !<nowiki>foo||bar</nowiki>
26831 !<nowiki>foo||bar</nowiki>
26832 |}
26833 !! html/php
26834 <table>
26835 <tr>
26836 <th>foo||bar
26837 </th>
26838 <th>foo||bar
26839 </th></tr></table>
26840
26841 !! end
26842
26843 !! test
26844 Tables: 4a. Escape -
26845 !! options
26846 parsoid=html2wt
26847 !! html/*
26848 <table>
26849 <tr>
26850 <th>-bar
26851 </th></tr>
26852 <tr>
26853 <td>-bar
26854 </td></tr></table>
26855
26856 !! wikitext
26857 {|
26858 !-bar
26859 |-
26860 |<nowiki>-bar</nowiki>
26861 |}
26862 !! end
26863
26864 !! test
26865 Tables: 4b. Escape +
26866 !! options
26867 parsoid=html2wt
26868 !! html/*
26869 <table>
26870 <tr>
26871 <th>+bar
26872 </th></tr>
26873 <tr>
26874 <td>+bar
26875 </td></tr></table>
26876
26877 !! wikitext
26878 {|
26879 !+bar
26880 |-
26881 |<nowiki>+bar</nowiki>
26882 |}
26883 !! end
26884
26885 !! test
26886 Tables: 4c. No escaping needed
26887 !! options
26888 parsoid=html2wt
26889 !! html/parsoid
26890 <table><tbody>
26891 <tr><td>foo-bar</td><td>foo+bar</td></tr>
26892 <tr><td><i>foo</i>-bar</td><td><i>foo</i>+bar</td></tr>
26893 <tr><td>foo
26894 <p>bar|baz
26895 +bar
26896 -bar</p></td></tr>
26897 <tr><td>x
26898 <div>a|b</div></td>
26899 </tbody></table>
26900 !! wikitext
26901 {|
26902 |foo-bar
26903 |foo+bar
26904 |-
26905 |''foo''-bar
26906 |''foo''+bar
26907 |-
26908 |foo
26909 bar|baz
26910 +bar
26911 -bar
26912 |-
26913 |x
26914 <div>a|b</div>
26915 |}
26916 !! html/php
26917 <table>
26918 <tr>
26919 <td>foo-bar
26920 </td>
26921 <td>foo+bar
26922 </td></tr>
26923 <tr>
26924 <td><i>foo</i>-bar
26925 </td>
26926 <td><i>foo</i>+bar
26927 </td></tr>
26928 <tr>
26929 <td>foo
26930 <p>bar|baz
26931 +bar
26932 -bar
26933 </p>
26934 </td></tr>
26935 <tr>
26936 <td>x
26937 <div>a|b</div>
26938 </td></tr></table>
26939
26940 !! end
26941
26942 !! test
26943 Tables: 4d. No escaping needed
26944 !! options
26945 parsoid=html2wt
26946 !! html/parsoid
26947 <table>
26948 <tbody><tr><td><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a>-bar</td>
26949 <td data-parsoid='{"startTagSrc":"|","attrSepSrc":"|"}'>+1</td>
26950 <td data-parsoid='{"startTagSrc":"|","attrSepSrc":"|"}'>-2</td></tr>
26951 </tbody></table>
26952 !! wikitext
26953 {|
26954 |[[Foo]]-bar
26955 ||+1
26956 ||-2
26957 |}
26958 !! html/php
26959 <table>
26960 <tr>
26961 <td><a href="/wiki/Foo" title="Foo">Foo</a>-bar
26962 </td>
26963 <td>+1
26964 </td>
26965 <td>-2
26966 </td></tr></table>
26967
26968 !! end
26969
26970 !! test
26971 Tables: 4e. Escape }
26972 !! options
26973 parsoid=html2wt
26974 !! html/parsoid
26975 <table>
26976 <tr><td>}</td></tr>
26977 <tr><td>x</td><td data-parsoid='{"stx":"row"}'>}</td></tr></table>
26978 </table>
26979 !! wikitext
26980 {|
26981 |<nowiki>}</nowiki>
26982 |-
26983 |x||}
26984 |}
26985 !! html/php
26986 <table>
26987 <tr>
26988 <td>}
26989 </td></tr>
26990 <tr>
26991 <td>x</td>
26992 <td>}
26993 </td></tr></table>
26994
26995 !! end
26996
26997 !! test
26998 Tables: 5. Empty table cells should get whitespace to avoid need for nowikis
26999 !! options
27000 parsoid=html2wt
27001 !! html/parsoid
27002 <table><tr><td></td><td align="center" data-parsoid='{"stx":"row"}'></td><td data-parsoid='{"stx":"row"}'></td></tr></table>
27003
27004 <table><tr><td></td><td align="center"></td><td></td></tr></table>
27005
27006 <table><tr><td></td><td align="center" data-parsoid='{"stx":"row", "startTagSrc":"{{!}}{{!}}"}'></td><td data-parsoid='{"stx":"row"}'></td></tr></table>
27007
27008 <table><tr><th></th><th align="center" data-parsoid='{"stx":"row"}'></th><th data-parsoid='{"stx":"row"}'></th></tr></table>
27009 !! wikitext
27010 {|
27011 | || align="center" | ||
27012 |}
27013
27014 {|
27015 |
27016 | align="center" |
27017 |
27018 |}
27019
27020 {|
27021 | {{!}}{{!}} align="center" | ||
27022 |}
27023
27024 {|
27025 ! !! align="center" | !!
27026 |}
27027 !! html/php+tidy
27028 <table>
27029 <tbody><tr>
27030 <td></td>
27031 <td align="center"></td>
27032 <td>
27033 </td></tr></tbody></table>
27034 <table>
27035 <tbody><tr>
27036 <td>
27037 </td>
27038 <td align="center">
27039 </td>
27040 <td>
27041 </td></tr></tbody></table>
27042 <table>
27043 <tbody><tr>
27044 <td></td>
27045 <td align="center"></td>
27046 <td>
27047 </td></tr></tbody></table>
27048 <table>
27049 <tbody><tr>
27050 <th></th>
27051 <th align="center"></th>
27052 <th>
27053 </th></tr></tbody></table>
27054 !! end
27055
27056 !! test
27057 T97430: Don't emit empty nowiki pairs around marker meta tags
27058 !! options
27059 parsoid=html2wt
27060 !! html/parsoid
27061 <p>*This is a long sentence here that will make the nowiki algo split up the nowikis into multiple pairs
27062 |** Make this another long long long sentence forcing the nowiki algo to split up the nowikis.</p>
27063 !! wikitext
27064 <nowiki>*</nowiki>This is a long sentence here that will make the nowiki algo split up the nowikis into multiple pairs
27065 |** Make this another long long long sentence forcing the nowiki algo to split up the nowikis.
27066 !! end
27067
27068 !! test
27069 Unclosed xmlish element in table line shouldn't eat end delimiters
27070 !! options
27071 parsoid=html2wt
27072 !! html/parsoid
27073 <table>
27074 <tbody><tr><td> &lt;foo</td>
27075 <td> bar></td></tr>
27076 </tbody></table>
27077 !! wikitext
27078 {|
27079 | <foo
27080 | bar>
27081 |}
27082 !! html/php
27083 <table>
27084 <tr>
27085 <td>&lt;foo
27086 </td>
27087 <td>bar&gt;
27088 </td></tr></table>
27089
27090 !! end
27091
27092 #### --------------- Links ----------------
27093 #### 1. Quote marks in link text
27094 #### 2. Wikilinks: Escapes needed
27095 #### 3. Wikilinks: No escapes needed
27096 #### 4. Extlinks: Escapes needed
27097 #### 5. Extlinks: No escapes needed
27098 #### --------------------------------------
27099 !! test
27100 Links 1. WikiLinks: No escapes needed
27101 !! options
27102 parsoid=html2wt
27103 !! html/parsoid
27104 <p><a rel="mw:WikiLink" href="Foo" title="Foo">Foo<i>boo</i></a>
27105 <a rel="mw:WikiLink" href="Foo" title="Foo">[Foobar]</a>
27106 <a rel="mw:WikiLink" href="Foo" title="Foo">x [Foobar] x</a></p>
27107 !! wikitext
27108 [[Foo|Foo''boo'']]
27109 [[Foo|[Foobar]]]
27110 [[Foo|x [Foobar] x]]
27111 !! html/php
27112 <p><a href="/wiki/Foo" title="Foo">Foo<i>boo</i></a>
27113 <a href="/wiki/Foo" title="Foo">[Foobar]</a>
27114 <a href="/wiki/Foo" title="Foo">x [Foobar] x</a>
27115 </p>
27116 !! end
27117
27118 !! test
27119 Links 2. WikiLinks: Escapes needed
27120 !! options
27121 parsoid=html2wt
27122 !! html/parsoid
27123 <a href="Foo" rel="mw:WikiLink">Foobar]</a>
27124 <a href="Foo" rel="mw:WikiLink">x [http://google.com g] x</a>
27125 <a href="Foo" rel="mw:WikiLink">[[Bar]]</a>
27126 <a href="Foo" rel="mw:WikiLink">x [[Bar]] x</a>
27127 <a href="Foo" rel="mw:WikiLink">|Bar</a>
27128 <a href="Foo" rel="mw:WikiLink">]]bar</a>
27129 <a href="Foo" rel="mw:WikiLink">[[bar</a>
27130 <a href="Foo" rel="mw:WikiLink">x [[ y</a>
27131 <a href="Foo" rel="mw:WikiLink">x ]] y</a>
27132 <a href="Foo" rel="mw:WikiLink">x ]] y [[ z</a>
27133 !! wikitext
27134 [[Foo|<nowiki>Foobar]</nowiki>]]
27135 [[Foo|x <nowiki>[http://google.com g]</nowiki> x]]
27136 [[Foo|<nowiki>[[Bar]]</nowiki>]]
27137 [[Foo|<nowiki>x [[Bar]] x</nowiki>]]
27138 [[Foo|<nowiki>|Bar</nowiki>]]
27139 [[Foo|<nowiki>]]bar</nowiki>]]
27140 [[Foo|<nowiki>[[bar</nowiki>]]
27141 [[Foo|<nowiki>x [[ y</nowiki>]]
27142 [[Foo|<nowiki>x ]] y</nowiki>]]
27143 [[Foo|<nowiki>x ]] y [[ z</nowiki>]]
27144 !! html/php
27145 <p><a href="/wiki/Foo" title="Foo">Foobar]</a>
27146 <a href="/wiki/Foo" title="Foo">x [http://google.com g] x</a>
27147 <a href="/wiki/Foo" title="Foo">[[Bar]]</a>
27148 <a href="/wiki/Foo" title="Foo">x [[Bar]] x</a>
27149 <a href="/wiki/Foo" title="Foo">|Bar</a>
27150 <a href="/wiki/Foo" title="Foo">]]bar</a>
27151 <a href="/wiki/Foo" title="Foo">[[bar</a>
27152 <a href="/wiki/Foo" title="Foo">x [[ y</a>
27153 <a href="/wiki/Foo" title="Foo">x ]] y</a>
27154 <a href="/wiki/Foo" title="Foo">x ]] y [[ z</a>
27155 </p>
27156 !! end
27157
27158 !! test
27159 Links 3. WikiLinks: No escapes needed
27160 !! options
27161 parsoid=html2wt
27162 !! html/parsoid
27163 <p><a rel="mw:WikiLink" href="Foo">[Foobar</a>
27164 <a rel="mw:WikiLink" href="Foo" title="Foo">foo|bar</a></p>
27165 !! wikitext
27166 [[Foo|[Foobar]]
27167 [[Foo|foo|bar]]
27168 !! html/php
27169 <p><a href="/wiki/Foo" title="Foo">[Foobar</a>
27170 <a href="/wiki/Foo" title="Foo">foo|bar</a>
27171 </p>
27172 !! end
27173
27174 !! test
27175 Links 4. ExtLinks: Escapes needed
27176 !! options
27177 parsoid=html2wt
27178 !! html/parsoid
27179 <p><a rel="mw:ExtLink" href="http://google.com">[google]</a>
27180 <a rel="mw:ExtLink" href="http://google.com">google]</a>
27181 <a rel="mw:ExtLink" href="http://google.com">goog] le</a></p>
27182 <p>[http://google.com]</p>
27183 <p>[http://google.com google]</p>
27184 <p>[<a rel="mw:ExtLink" href="http://google.com">http://google.com</a>]</p>
27185 <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>
27186 !! wikitext
27187 [http://google.com <nowiki>[google]</nowiki>]
27188 [http://google.com <nowiki>google]</nowiki>]
27189 [http://google.com <nowiki>goog] le</nowiki>]
27190
27191 <nowiki>[http://google.com]</nowiki>
27192
27193 <nowiki>[http://google.com google]</nowiki>
27194
27195 [http://google.com<nowiki>]</nowiki>
27196
27197 [{{echo|http://google.com}}<nowiki>]</nowiki>
27198 !! html/php
27199 <p><a rel="nofollow" class="external text" href="http://google.com">[google]</a>
27200 <a rel="nofollow" class="external text" href="http://google.com">google]</a>
27201 <a rel="nofollow" class="external text" href="http://google.com">goog] le</a>
27202 </p><p>[http://google.com]
27203 </p><p>[http://google.com google]
27204 </p><p>[<a rel="nofollow" class="external free" href="http://google.com">http://google.com</a>]
27205 </p><p>[<a rel="nofollow" class="external free" href="http://google.com">http://google.com</a>]
27206 </p>
27207 !! end
27208
27209 !! test
27210 Links 5. ExtLinks: No escapes needed
27211 !! options
27212 parsoid=html2wt
27213 !! html/parsoid
27214 <p><a rel="mw:ExtLink" href="http://google.com">[google</a></p>
27215 <p>[<a ref="mw:ExtLink" href="http://google.com"></a>]</p>
27216 !! wikitext
27217 [http://google.com [google]
27218
27219 [[http://google.com]]
27220 !! html/php
27221 <p><a rel="nofollow" class="external text" href="http://google.com">[google</a>
27222 </p><p>[<a rel="nofollow" class="external autonumber" href="http://google.com">[1]</a>]
27223 </p>
27224 !! end
27225
27226 !! test
27227 Links 6. Add <nowiki/>s between text-nodes and url-links when required (T66300)
27228 !! options
27229 parsoid=html2wt
27230 !! html/parsoid
27231 <p>x<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>y
27232 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>?x
27233 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>&amp;x
27234 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>'x
27235 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>,x
27236 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>.x
27237 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>;x
27238 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>:x
27239 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>;x
27240 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>!x
27241 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>=x
27242 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>(x)
27243 <a rel="mw:ExtLink" href="http://example.com(x" data-parsoid='{"stx":"url"}'>http://example.com(x</a>)
27244 </p>
27245 !! wikitext
27246 x<nowiki/>http://example.com<nowiki/>y
27247 http://example.com<nowiki/>?x
27248 http://example.com<nowiki/>&x
27249 http://example.com<nowiki/>'x
27250 http://example.com<nowiki/>,x
27251 http://example.com<nowiki/>.x
27252 http://example.com<nowiki/>;x
27253 http://example.com<nowiki/>:x
27254 http://example.com<nowiki/>;x
27255 http://example.com<nowiki/>!x
27256 http://example.com<nowiki/>=x
27257 http://example.com<nowiki/>(x)
27258 http://example.com(x<nowiki/>)
27259 !! end
27260
27261 !! test
27262 Links 7a. Don't add spurious <nowiki/>s between text-nodes and url-links (T66300)
27263 !! options
27264 parsoid=html2wt
27265 !! html/parsoid
27266 <p>x
27267 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>
27268 y
27269 "<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>"
27270 (<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>)
27271 (<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>) foo
27272 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>,
27273 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>, foo
27274 </p>
27275 !! wikitext
27276 x
27277 http://example.com
27278 y
27279 "http://example.com"
27280 (http://example.com)
27281 (http://example.com) foo
27282 http://example.com,
27283 http://example.com, foo
27284 !! html/php
27285 <p>x
27286 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
27287 y
27288 "<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>"
27289 (<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
27290 (<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>) foo
27291 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>,
27292 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>, foo
27293 </p>
27294 !! end
27295
27296 !! test
27297 Links 7b. Don't add spurious <nowiki/>s between text-nodes and url-links (T66300)
27298 !! options
27299 parsoid=html2wt
27300 !! html/parsoid
27301 <p><a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>.,;:!?\
27302 -<a rel="mw:ExtLink" href="http://example.com">http://example.com</a>:</p>
27303 !! wikitext
27304 http://example.com.,;:!?\
27305 -http://example.com:
27306 !! html/php
27307 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>.,;:!?\
27308 -<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>:
27309 </p>
27310 !! end
27311
27312 !! test
27313 Links 8. Add <nowiki/>s between text-nodes and RFC-links when required (T66300)
27314 !! options
27315 parsoid=html2wt
27316 !! html/parsoid
27317 <p><a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>4
27318 <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y
27319 X<a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y</p>
27320 !! wikitext
27321 RFC 123<nowiki/>4
27322 RFC 123<nowiki/>y
27323 X<nowiki/>RFC 123<nowiki/>y
27324 !! end
27325
27326 !! test
27327 Links 9. Don't add spurious <nowiki/>s between text-nodes and RFC-links (T66300)
27328 !! options
27329 parsoid=html2wt
27330 !! html/parsoid
27331 <p><a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>?foo
27332 <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>&amp;foo
27333 -<a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>-
27334 </p>
27335 !! wikitext
27336 RFC 123?foo
27337 RFC 123&foo
27338 -RFC 123-
27339 !! html/php
27340 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>?foo
27341 <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>&amp;foo
27342 -<a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>-
27343 </p>
27344 !! end
27345
27346 !! test
27347 Links 10. Add <nowiki/>s between text-nodes and PMID-links when required (T66300)
27348 !! options
27349 parsoid=html2wt
27350 !! html/parsoid
27351 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>4
27352 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>y
27353 X<a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>y
27354 !! wikitext
27355 PMID 123<nowiki/>4
27356 PMID 123<nowiki/>y
27357 X<nowiki/>PMID 123<nowiki/>y
27358 !! end
27359
27360 !! test
27361 Links 11. Don't add spurious <nowiki/>s between text-nodes and PMID-links (T66300)
27362 !! options
27363 parsoid=html2wt
27364 !! html/parsoid
27365 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>?foo
27366 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>&foo
27367 -<a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>-
27368 </p>
27369 !! wikitext
27370 PMID 123?foo
27371 PMID 123&foo
27372 -PMID 123-
27373 !! html/php
27374 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>?foo
27375 <a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>&amp;foo
27376 -<a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>-
27377 </p>
27378 !! end
27379
27380 !! test
27381 Links 12. Add <nowiki/>s between text-nodes and ISBN-links when required (T66300)
27382 !! options
27383 parsoid=html2wt
27384 !! html/parsoid
27385 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>1
27386 <a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>x
27387 a<a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>b
27388 </p>
27389 !! wikitext
27390 ISBN 1234567890<nowiki/>1
27391 ISBN 1234567890<nowiki/>x
27392 a<nowiki/>ISBN 1234567890<nowiki/>b
27393 !! end
27394
27395 !! test
27396 Links 13. Don't add spurious <nowiki/>s between text-nodes and ISBN-links (T66300)
27397 !! options
27398 parsoid=html2wt
27399 !! html/parsoid
27400 <p>-<a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>'s
27401 !! wikitext
27402 -ISBN 1234567890's
27403 !! html/php
27404 <p>-<a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>'s
27405 </p>
27406 !! end
27407
27408 !! test
27409 Links 14. Protect link-like plain text. (Parsoid bug T78425)
27410 !! options
27411 parsoid=html2wt
27412 !! html/*
27413 <p>this is not a link: http://example.com
27414 </p>
27415 !! wikitext
27416 this is not a link: <nowiki>http://example.com</nowiki>
27417 !! end
27418
27419 !! test
27420 Links 15. Link trails can't become link prefixes.
27421 !! options
27422 language=is
27423 parsoid=html2wt
27424 !! html/parsoid
27425 <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>
27426 !! wikitext
27427 [[Söfnuður]]-[[00]]
27428 !! html/php
27429 <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>
27430 </p>
27431 !! end
27432
27433 #### --------------- Quotes ---------------
27434 #### 1. Quotes inside <b> and <i>
27435 #### 2. Link fragments separated by <i> and <b> tags
27436 #### 3. Link fragments inside <i> and <b>
27437 #### 4. No escaping needed
27438 #### --------------------------------------
27439 !! test
27440 1a. Quotes inside <b> and <i>
27441 !! options
27442 parsoid=html2wt
27443 !! html/*
27444 <p><i>'foo'</i>
27445 <i>''foo''</i>
27446 <i>'''foo'''</i>
27447 <i>foo</i>'s
27448 <b>'foo'</b>
27449 <b>''foo''</b>
27450 <b>'''foo'''</b>
27451 <b>foo'<i>bar'</i>baz</b>
27452 <b>foo</b>'s
27453 '<i>foo</i>
27454 <i>foo</i>'
27455 <i>foo'</i>'
27456 '<i>foo</i>'
27457 '<b>foo</b>
27458 <b>foo</b>'
27459 '<b>foo</b>'
27460 <i>fools'<span> errand</span></i>
27461 <i><span>fool</span>'s errand</i>
27462 '<i>foo</i> bar '<i>baz</i>
27463 a|!*#-:;+-~[]{}b'<i>x</i>
27464 </p>
27465 !! wikitext
27466 ''<nowiki/>'foo'''
27467 ''<nowiki>''foo''</nowiki>''
27468 ''<nowiki>'''foo'''</nowiki>''
27469 ''foo''<nowiki/>'s
27470 '''<nowiki/>'foo''''
27471 '''<nowiki>''foo''</nowiki>'''
27472 '''<nowiki>'''foo'''</nowiki>'''
27473 '''foo'<nowiki/>''bar'<nowiki/>''baz'''
27474 '''foo'''<nowiki/>'s
27475 '''foo''
27476 ''foo''<nowiki/>'
27477 ''foo'''<nowiki/>'
27478 '''foo''<nowiki/>'
27479 ''''foo'''
27480 '''foo'''<nowiki/>'
27481 ''''foo'''<nowiki/>'
27482 ''fools'<span> errand</span>''
27483 ''<span>fool</span>'s errand''
27484 '<nowiki/>''foo'' bar '''baz''
27485 a|!*#-:;+-~[]{}b'''x''
27486 !! end
27487
27488 !! test
27489 1b. Quotes inside <b> and <i> with other tags on same line
27490 !! options
27491 parsoid=html2wt
27492 !! html/parsoid
27493 '<i>a</i> foo <i><a rel="mw:WikiLink" href="Bar" title="Bar">bar</a></i>
27494 <i>a'</i> foo <i><a rel="mw:WikiLink" href="Bar" title="Bar">bar</a></i>
27495 <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>
27496 <a rel="mw:WikiLink" href="Foo" title="Foo">foo</a> x'<i><a href="Bar" rel="mw:WikiLink" title="Bar">bar</a></i>
27497 '<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>
27498 '<i>foo</i> <div title="name">test</div>
27499 '<i>foo</i> and <br data-parsoid='{"stx":"html","noClose":true}'/> bar
27500 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt5" data-mw='{"name":"references","attrs":{}}'>
27501 <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>
27502 </ol>
27503 !! wikitext
27504 '''a'' foo ''[[bar]]''
27505 ''a''' foo ''[[bar]]''
27506 ''a''' foo '''{{echo|[[bar]]}}'''
27507 [[foo]] x'''[[bar]]''
27508 '''foo'' <ref>test</ref>
27509 '''foo'' <div title="name">test</div>
27510 '''foo'' and <br> bar
27511 <references />
27512 !! end
27513
27514 !! test
27515 2. Link fragments separated by <i> and <b> tags
27516 !! options
27517 parsoid=html2wt
27518 !! html/parsoid
27519 <p>[[<i>foo</i>hello]]</p>
27520 <p>[[<b>foo</b>hello]]</p>
27521 !! wikitext
27522 [[''foo''<nowiki>hello]]</nowiki>
27523
27524 [['''foo'''<nowiki>hello]]</nowiki>
27525 !! end
27526
27527 # FIXME: Escaping one or both of [[ and ]] is also acceptable --
27528 # this is one of the shortcomings of this format
27529 !! test
27530 3. Link fragments inside <i> and <b>
27531 !! options
27532 parsoid=html2wt
27533 !! html/parsoid
27534 <p><i>[[foo</i>]]</p>
27535 <p><b>[[foo</b>]]</p>
27536 !! wikitext
27537 ''[[foo''<nowiki>]]</nowiki>
27538
27539 '''[[foo'''<nowiki>]]</nowiki>
27540 !! end
27541
27542 !! test
27543 4. No escaping needed
27544 !! options
27545 parsoid=html2wt
27546 !! html/parsoid
27547 <p>'<span><i>bar</i></span>'
27548 '<span><b>bar</b></span>'
27549 'a:b'foo
27550 </p>
27551 !! wikitext
27552 '<span>''bar''</span>'
27553 '<span>'''bar'''</span>'
27554 'a:b'foo
27555 !! end
27556
27557 #### ----------- Paragraphs ---------------
27558 #### 1. No unnecessary escapes
27559 #### --------------------------------------
27560
27561 !! test
27562 1. No unnecessary escapes
27563 !! options
27564 parsoid=html2wt
27565 !! html/parsoid
27566 <p>bar <span>[[foo]]</span>
27567 </p><p>=bar <span>[[foo]]</span>
27568 </p><p>[[bar <span>[[foo]]</span>
27569 </p><p>]]bar <span>[[foo]]</span>
27570 </p><p>=bar <span>foo]]</span>=
27571 </p>
27572 !! wikitext
27573 bar <span><nowiki>[[foo]]</nowiki></span>
27574
27575 =bar <span><nowiki>[[foo]]</nowiki></span>
27576
27577 [[bar <span><nowiki>[[foo]]</nowiki></span>
27578
27579 ]]bar <span><nowiki>[[foo]]</nowiki></span>
27580
27581 =bar <span>foo]]</span><nowiki>=</nowiki>
27582 !!end
27583
27584 #### ----------------------- PRE --------------------------
27585 !! test
27586 1. Leading whitespace in SOL context should be escaped
27587 !! options
27588 parsoid=html2wt
27589 !! html/parsoid
27590 <p> a</p>
27591
27592 <p> a</p>
27593
27594 <p> a(tab)</p>
27595
27596 <p> a
27597 <!--cmt-->
27598 a</p>
27599
27600 <p>a
27601 b</p>
27602
27603 <p>a
27604 b</p>
27605
27606 <p>a
27607 b</p>
27608 !! wikitext
27609 <nowiki> </nowiki>a
27610
27611 <nowiki> </nowiki> a
27612
27613 a(tab)
27614
27615 <nowiki> </nowiki> a
27616 <!--cmt-->
27617 <nowiki> </nowiki>a
27618
27619 a
27620 <nowiki> </nowiki>b
27621
27622 a
27623 b
27624
27625 a
27626 b
27627 !! html/php
27628 <p> a
27629 </p><p> a
27630 </p><p> a(tab)
27631 </p><p> a
27632 a
27633 </p><p>a
27634 b
27635 </p><p>a
27636 b
27637 </p><p>a
27638 b
27639 </p>
27640 !! end
27641
27642 !! test
27643 2. Leading whitespace in non-indent-pre contexts should not be escaped
27644 !! options
27645 parsoid=html2wt
27646 !! html/parsoid
27647 <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>
27648 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt4" data-mw='{"name":"references","attrs":{}}'>
27649 <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>
27650 b</span></li>
27651 </ol>
27652 !! wikitext
27653 foo <ref>''a''
27654 b</ref>
27655 <references />
27656 !! end
27657
27658 !! test
27659 3. Leading whitespace in indent-pre suppressing contexts should not be escaped
27660 !! options
27661 parsoid=html2wt
27662 !! html/parsoid
27663 <blockquote>
27664 <p>
27665 a
27666 <span>b</span>
27667 c</p>
27668 </blockquote>
27669 !! wikitext
27670 <blockquote>
27671 a
27672 <span>b</span>
27673 c
27674 </blockquote>
27675 !! end
27676
27677 !! test
27678 4. Leading whitespace in indent-pre suppressing contexts should not be escaped
27679 !! options
27680 parsoid=html2wt
27681 !! html/parsoid
27682 <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>
27683 !! wikitext
27684 [[File:Foobar.jpg|thumb|caption]]
27685 !! end
27686
27687 !! test
27688 5. Nowiki escaping should account for indent-pres
27689 !! options
27690 parsoid=html2wt
27691 !! html/parsoid
27692 <pre>==foo==</pre>
27693 !! wikitext
27694 ==foo==
27695 !! end
27696
27697 !! test
27698 T95794: nowiki escaping should account for leading space at start-of-line in an indent-pre block
27699 !! options
27700 parsoid=html2wt
27701 !! html/parsoid
27702 <pre>
27703 * foo
27704 * bar
27705 </pre>
27706 !! wikitext
27707 * foo
27708 * bar
27709 !! end
27710
27711 !! test
27712 Whitespace scrubbing in SOL position should account for SOL-sensitive wikitext markup
27713 !! options
27714 parsoid = {
27715 "modes": ["html2wt"],
27716 "scrubWikitext": true
27717 }
27718 !! html/parsoid
27719 <p> foo</p>
27720 <p> %foo</p>
27721 <p> *foo</p>
27722 <p> #foo</p>
27723 <p> =foo=</p>
27724 <p><link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid="{}"> *foo</p>
27725 <p> <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid="{}">*foo</p>
27726 <p> <!--boo-->*foo</p>
27727 <p><!--boo--> *foo</p>
27728 <p><!--a--> <!--b--> <!--c--> <!--d--> <!--e--> foo</p>
27729 <p><!--a--> <!--b--> <!--c--> <!--d--> <!--e--> *foo</p>
27730 !! wikitext
27731 foo
27732
27733 %foo
27734
27735 <nowiki/>*foo
27736
27737 <nowiki/>#foo
27738
27739 <nowiki/>=foo=
27740
27741 [[Category:Foo]]
27742 <nowiki/>*foo
27743
27744 [[Category:Foo]]
27745 <nowiki>*</nowiki>foo
27746
27747 <nowiki/><!--boo-->*foo
27748
27749 <!--boo--><nowiki/>*foo
27750
27751 <!--a--><!--b--><!--c--><!--d--><!--e-->foo
27752
27753 <!--a--><nowiki/><!--b--><!--c--><!--d--><!--e-->*foo
27754 !! end
27755
27756 #### --------------- Behavior Switches --------------------
27757
27758 !! test
27759 1. Valid behavior switches should be escaped
27760 !! options
27761 parsoid=html2wt
27762 !! html/parsoid
27763 __TOC__
27764 <i>__TOC__</i>
27765 !! wikitext
27766 <nowiki>__TOC__</nowiki>
27767 ''<nowiki>__TOC__</nowiki>''
27768 !! end
27769
27770 !! test
27771 2. Invalid behavior switches should not be escaped
27772 !! options
27773 parsoid=html2wt
27774 !! html/parsoid
27775 __TOO__
27776 __|__
27777 !! wikitext
27778 __TOO__
27779 __|__
27780 !! end
27781
27782 # We use indent-pre as an indirect way to test for sol-transparent behavior.
27783 !! test
27784 Behavior switches should be SOL-transparent
27785 !! options
27786 parsoid=html2wt
27787 !! html/parsoid
27788 <meta property="mw:PageProp/toc" />
27789
27790 <!-- this one's bogus -->
27791 <pre>__TOO__</pre>
27792
27793 <pre data-parsoid='{}'><meta property="mw:PageProp/toc" data-parsoid='{"src":"__TOC__","magicSrc":"__TOC__"}'/> foo</pre>
27794
27795 <meta property="mw:PageProp/toc" data-parsoid='{"src":"__TOC__","magicSrc":"__TOC__"}'/><pre data-parsoid='{}'>bar</pre>
27796 !! wikitext
27797 __TOC__
27798
27799 <!-- this one's bogus -->
27800 __TOO__
27801
27802 __TOC__ foo
27803
27804 __TOC__
27805 bar
27806 !! end
27807
27808 #### --------------- HTML tags ---------------
27809 #### 1. a tags
27810 #### 2. other tags
27811 #### 3. multi-line html tag
27812 #### 4. extension tags
27813 #### -----------------------------------------
27814 !! test
27815 1. a tags
27816 !! options
27817 parsoid=html2wt
27818 !! html/parsoid
27819 &lt;a href=&quot;http://google.com&quot;&gt;google&lt;/a&gt;
27820 !! wikitext
27821 <a href="http://google.com">google</a>
27822 !! end
27823
27824 !! test
27825 2. other tags
27826 !! options
27827 parsoid=html2wt
27828 !! html/parsoid
27829 <ul><li> &lt;div&gt;foo&lt;/div&gt;</li>
27830 <li> &lt;div style=&quot;color:red&quot;&gt;foo&lt;/div&gt;</li>
27831 <li> &lt;td&gt;</li></ul>
27832
27833 !! wikitext
27834 * <nowiki><div>foo</div></nowiki>
27835 * <nowiki><div style="color:red">foo</div></nowiki>
27836 * <nowiki><td></nowiki>
27837 !! end
27838
27839 !! test
27840 3. multi-line html tag
27841 !! options
27842 parsoid=html2wt
27843 !! html/parsoid
27844 <p>&lt;div
27845 &gt;foo&lt;/div
27846 &gt;
27847 </p>
27848 !! wikitext
27849 <nowiki><div
27850 >foo</div
27851 ></nowiki>
27852 !! end
27853
27854 !! test
27855 4. extension tags
27856 !! options
27857 parsoid=html2wt
27858 !! html/parsoid
27859 <p>&lt;ref&gt;foo&lt;/ref&gt;
27860 </p><p>&lt;ref&gt;bar
27861 </p><p>baz&lt;/ref&gt;
27862 </p>
27863 !! wikitext
27864 <nowiki><ref>foo</ref></nowiki>
27865
27866 <nowiki><ref>bar</nowiki>
27867
27868 baz<nowiki></ref></nowiki>
27869 !! end
27870
27871 !! test
27872 Parsoid: newline inducing block nodes don't suppress <nowiki>
27873 !! options
27874 parsoid=html2wt
27875 !! html/parsoid
27876 a<h1>foo</h1>
27877 !! wikitext
27878 <nowiki> </nowiki>a
27879
27880 = foo =
27881 !! end
27882
27883 #### --------------- Others ---------------
27884 !! test
27885 Escaping nowikis
27886 !! options
27887 parsoid=html2wt
27888 !! html/parsoid
27889 <p>&lt;nowiki&gt;foo&lt;/nowiki&gt;
27890 </p>
27891 !! wikitext
27892 &lt;nowiki&gt;foo&lt;/nowiki&gt;
27893 !! end
27894
27895 ## The quote-char in the input is necessary for triggering the bug
27896 !! test
27897 (T54035) Nowiki-escaping should not get tripped by " :" in text
27898 !! options
27899 parsoid=html2wt
27900 !! html/parsoid
27901 <p>foo's bar :</p>
27902 !! wikitext
27903 foo's bar :
27904 !! end
27905
27906 #----------- End of wikitext escaping tests --------------
27907
27908 !! test
27909
27910 Tag-like HTML structures are passed through as text
27911 !! wikitext
27912 <x y>
27913
27914 <x.y>
27915
27916 <x-y>
27917
27918 1>2
27919
27920 x<y
27921
27922 a>b
27923
27924 1<d e>f
27925 !! html
27926 <p>&lt;x y&gt;
27927 </p><p>&lt;x.y&gt;
27928 </p><p>&lt;x-y&gt;
27929 </p><p>1&gt;2
27930 </p><p>x&lt;y
27931 </p><p>a&gt;b
27932 </p><p>1&lt;d e&gt;f
27933 </p>
27934 !! end
27935
27936 !! test
27937 HTML tag with necessary entities in attributes
27938 !! wikitext
27939 <span title="&amp;amp;">foo</span>
27940 !! html
27941 <p><span title="&amp;amp;">foo</span>
27942 </p>
27943 !! end
27944
27945 !! test
27946 HTML tag with 'unnecessary' entity encoding in attributes
27947 !! wikitext
27948 <span title="&amp;">foo</span>
27949 !! html
27950 <p><span title="&amp;">foo</span>
27951 </p>
27952 !! end
27953
27954 !! test
27955 HTML tag with broken attribute value quoting
27956 !! options
27957 parsoid=wt2html,html2html
27958 !! wikitext
27959 <span title="Hello world>Foo</span>
27960 !! html/php
27961 <p><span title="Hello world">Foo</span>
27962 </p>
27963 !! html/parsoid
27964 <p><span title="Hello world">Foo</span></p>
27965 !! end
27966
27967 !! test
27968 Self-closed tag with broken attribute value quoting
27969 !! options
27970 parsoid=wt2html,html2html
27971 !! wikitext
27972 <div title="Hello world />Foo
27973 !! html/php+tidy
27974 <div title="Hello world"></div><p>Foo
27975 </p>
27976 !! html/parsoid
27977 <div title="Hello world " data-parsoid='{"stx":"html","selfClose":true}'></div><p>Foo</p>
27978 !! end
27979
27980 !! test
27981 Table with broken attribute value quoting
27982 !! options
27983 parsoid=wt2html,html2html
27984 !! wikitext
27985 {|
27986 | title="Hello world|Foo
27987 |}
27988 !! html/php
27989 <table>
27990 <tr>
27991 <td title="Hello world">Foo
27992 </td></tr></table>
27993
27994 !! html/parsoid
27995 <table>
27996 <tr>
27997 <td title="Hello world">Foo
27998 </td></tr></table>
27999
28000 !! end
28001
28002 !! test
28003 Table with broken attribute value quoting on consecutive lines
28004 !! options
28005 parsoid=wt2html,html2html
28006 !! wikitext
28007 {|
28008 | title="Hello world|Foo
28009 | style="color:red|Bar
28010 |}
28011 !! html/php
28012 <table>
28013 <tr>
28014 <td title="Hello world">Foo
28015 </td>
28016 <td style="color:red">Bar
28017 </td></tr></table>
28018
28019 !! html/parsoid
28020 <table><tbody>
28021 <tr>
28022 <td title="Hello world">Foo
28023 </td><td style="color: red">Bar
28024 </td></tr></tbody></table>
28025
28026 !! end
28027
28028 !!test
28029 Accept empty td cell attribute
28030 !! wikitext
28031 {|
28032 | align="center" |foo|| |
28033 |}
28034 !! html
28035 <table>
28036 <tr>
28037 <td align="center">foo</td>
28038 <td>
28039 </td></tr></table>
28040
28041 !!end
28042
28043 !!test
28044 Non-empty attributes in th-cells
28045 !! wikitext
28046 {|
28047 !Foo!! style="color: red" |Bar
28048 |}
28049 !! html
28050 <table>
28051 <tr>
28052 <th>Foo</th>
28053 <th style="color: red">Bar
28054 </th></tr></table>
28055
28056 !!end
28057
28058 !!test
28059 Accept empty attributes in th-cells
28060 !! wikitext
28061 {|
28062 !|foo!!|bar
28063 |}
28064 !! html
28065 <table>
28066 <tr>
28067 <th>foo</th>
28068 <th>bar
28069 </th></tr></table>
28070
28071 !!end
28072
28073 !!test
28074 Empty table rows go away
28075 !! wikitext
28076 {|
28077 |Hello
28078 |there
28079 |- class="foo"
28080 |-
28081 |}
28082 !! html
28083 <table>
28084 <tr>
28085 <td>Hello
28086 </td>
28087 <td>there
28088 </td></tr>
28089
28090 </table>
28091
28092 !! end
28093
28094 ###
28095 ### Parsoid-centric tests for testing RTing of inter-element separators
28096 ### Edge cases not tested by existing parser tests and specific to
28097 ### Parsoid-specific serialization strategies.
28098 ###
28099
28100 !!test
28101 RT-ed inter-element separators should be valid separators
28102 !! wikitext
28103 {|
28104 |- [[foo]]
28105 |}
28106 !! html/php
28107 <table>
28108
28109 </table>
28110
28111 !! html/parsoid
28112 <table>
28113 <tbody><tr class='mw-empty-elt' data-parsoid='{"startTagSrc":"|-","a":{"[[foo]]":null},"sa":{"[[foo]]":""},"autoInsertedEnd":true}'></tr>
28114 </tbody></table>
28115 !!end
28116
28117 # Parsoid-only test of a DOM pass
28118 !!test
28119 Trailing newlines in a deep dom-subtree that ends a wikitext line should be migrated out
28120 !! wikitext
28121 {|
28122 |<small>foo
28123 bar
28124 |}
28125
28126 {|
28127 |<small>foo<small>
28128 |}
28129 !! html/parsoid
28130 <table>
28131 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'><small data-parsoid='{"stx":"html","autoInsertedEnd":true}'>foo
28132 <p>bar</p></small></td></tr>
28133 </tbody></table>
28134
28135 <table>
28136 <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>
28137 </tbody></table>
28138 !!end
28139
28140 # Note that the "style" attribute is really a template parameter here.
28141 # The = would have to be {{=}} if you wanted the literal.
28142 !!test
28143 Empty TD followed by TD with tpl-generated attribute
28144 !! wikitext
28145 {|
28146 |-
28147 |
28148 |{{echo|style='color:red'}}|foo
28149 |}
28150 !! html
28151 <table>
28152
28153 <tr>
28154 <td>
28155 </td>
28156 <td>foo
28157 </td></tr></table>
28158
28159 !!end
28160
28161 !!test
28162 Indented table with an empty td
28163 !! wikitext
28164 {|
28165 |-
28166 |
28167 |foo
28168 |}
28169 !! html
28170 <table>
28171
28172 <tr>
28173 <td>
28174 </td>
28175 <td>foo
28176 </td></tr></table>
28177
28178 !!end
28179
28180 !! test
28181 Indented table with blank lines in between (T85627)
28182 !! wikitext
28183 {|
28184 |foo
28185
28186
28187 |}
28188 !! html/php
28189 <table>
28190 <tr>
28191 <td>foo
28192 <p><br />
28193 </p>
28194 </td></tr></table>
28195
28196 !! html/parsoid
28197 <table>
28198 <tbody><tr><td>foo
28199 <p>
28200 <br /></p></td></tr>
28201 </tbody></table>
28202 !! end
28203
28204 !!test
28205 Indented block & table
28206 !! wikitext
28207 <div>foo</div>
28208 {|
28209 |foo
28210 |}
28211 !! html/php
28212 <div>foo</div>
28213 <table>
28214 <tr>
28215 <td>foo
28216 </td></tr></table>
28217
28218 !! html/parsoid
28219 <div data-parsoid='{"stx":"html"}'>foo</div>
28220 <table><tbody>
28221 <tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'>foo</td></tr>
28222 </tbody></table>
28223 !!end
28224
28225 !! test
28226 Indent and comment before table row
28227 !! wikitext
28228 {|
28229 <!--hi-->|-
28230 |there
28231 |}
28232 !! html/php
28233 <table>
28234
28235 <tr>
28236 <td>there
28237 </td></tr></table>
28238
28239 !! html/parsoid
28240 <table>
28241 <!--hi--><tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
28242 <td data-parsoid='{"autoInsertedEnd":true}'> there</td></tr>
28243 </tbody></table>
28244 !! end
28245
28246 # PHP parser omits empty TR
28247 !!test
28248 Empty TR followed by a template-generated TR
28249 !! wikitext
28250 {|
28251 |-
28252 {{echo|<tr><td>foo</td></tr>}}
28253 |}
28254 !! html/php+tidy
28255 <table>
28256
28257 <tbody><tr><td>foo</td></tr>
28258 </tbody></table>
28259 !! html/parsoid
28260 <table>
28261 <tbody>
28262 <tr class='mw-empty-elt'></tr>
28263 <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}}]}'>
28264 <td>foo</td></tr>
28265 </tbody></table>
28266 !!end
28267
28268 ## PHP and parsoid output differ for this; as usual PHP omits empty
28269 ## elements, and since it strips the comments the TR is empty.
28270 !!test
28271 Empty TR followed by mixed-ws-comment line should RT correctly
28272 !! wikitext
28273 {|
28274 |-
28275 <!--c-->
28276 |-
28277 <!--c--> <!--d-->
28278 |}
28279 !! html/php+tidy
28280 <table>
28281
28282
28283 </table>
28284 !! html/parsoid
28285 <table>
28286 <tbody>
28287 <tr class='mw-empty-elt'></tr>
28288 <!--c-->
28289 <tr>
28290 <!--c--> </tr><!--d-->
28291 </tbody></table>
28292
28293 !!end
28294
28295 !!test
28296 Multi-line image caption generated by templates with/without trailing newlines
28297 !! wikitext
28298 [[File:Foobar.jpg|thumb|300x300px|foo\n{{echo|A}}\n{{echo|B}}\n{{echo|C}}]]
28299 [[File:Foobar.jpg|thumb|300x300px|foo\n{{echo|A}}\n{{echo|B}}\n{{echo|C}}\n\n]]
28300 !! html/parsoid
28301 <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>
28302 <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>
28303 !!end
28304
28305 !! test
28306 New element inserted (without intervening newlines) after an old sol-transparent node should serialize correctly
28307 !! options
28308 parsoid=html2wt
28309 !! html/parsoid
28310 <meta typeof="mw:Includes/IncludeOnly" data-parsoid='{"src":"&lt;includeonly>foo&lt;/includeonly>"}' data-mw='{"src":"&lt;includeonly>foo&lt;/includeonly>"}'/><meta typeof="mw:Includes/IncludeOnly/End" data-parsoid='{"src":""}'/><p>new para</p>
28311
28312 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{}'/><h1>new heading</h1>
28313 !! wikitext
28314 <includeonly>foo</includeonly>
28315 new para
28316
28317 [[Category:Foo]]
28318
28319 = new heading =
28320 !! end
28321
28322 ## PHP emits broken html for this, and since this is primarily
28323 ## a Parsoid serializer test, marking this Parsoid only
28324 !!test
28325 Improperly nested inline or quotes tags with whitespace in between
28326 !! wikitext
28327 <span> <s>x</span> </s>
28328 ''' ''x''' ''
28329 !! html/parsoid
28330 <p><span> <s>x</s></span><s> </s>
28331 <b> <i>x</i></b><i> </i>
28332 </p>
28333 !!end
28334
28335 !!test
28336 Encapsulate protected attributes from wt
28337 !! wikitext
28338 <div typeof="mw:placeholder stuff" data-mw="whoo" data-parsoid="weird" data-parsoid-other="no" about="time" rel="mw:true">foo</div>
28339
28340 {| typeof="mw:placeholder stuff" data-mw="whoo" data-parsoid="weird" data-parsoid-other="no" about="time" rel="mw:true"
28341 |ok
28342 |}
28343 !! html/parsoid
28344 <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>
28345
28346 <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">
28347 <tbody><tr><td data-parsoid='{"autoInsertedEnd":true}'>ok</td></tr>
28348 </tbody></table>
28349 !!end
28350
28351 ## Currently the p-wrapper is fragile in how it adds / removes transformations.
28352 ## Having nested or stray pre tags results in the attempt to add duplicates,
28353 ## causing an assertion fail. This test tries to prevent that situation.
28354 !! test
28355 Ensure ParagraphWrapper can deal with stray closing pre tags
28356 !! options
28357 parsoid=wt2html
28358 !! wikitext
28359 plain text</pre>
28360 !! html/parsoid
28361 <p>plain text</p>
28362 !! end
28363
28364 ## Remex doesn't account for fostered content.
28365 !! test
28366 1. Ensure fostered text content is wrapped in element nodes
28367 !! options
28368 parsoid=wt2html
28369 !! wikitext
28370 <table>hi</table><table>ho</table>
28371 !! html/php+tidy
28372 hi<table></table>ho<table></table>
28373 !! html/parsoid
28374 <p data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true}'>hi</p><table data-parsoid='{"stx":"html"}'></table><p data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true}'>ho</p><table data-parsoid='{"stx":"html"}'></table>
28375 !! end
28376
28377 ## Remex doesn't account for fostered content.
28378 !! test
28379 2. Ensure fostered text content is wrapped in element nodes (traps regressions around fostered marker on the element getting lost)
28380 !! options
28381 parsoid=wt2html,wt2wt
28382 !! wikitext
28383 <table>
28384 <tr> || ||
28385 <td> a
28386 </table>
28387 !! html/php+tidy
28388 || ||
28389 <table>
28390 <tbody><tr><td> a
28391 </td></tr></tbody></table>
28392 !! html/parsoid
28393 <p data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true}'> || ||</p>
28394 <table data-parsoid='{"stx":"html"}'>
28395 <tbody><tr data-parsoid='{"stx":"html","autoInsertedEnd":true}'><td data-parsoid='{"stx":"html","autoInsertedEnd":true}'> a
28396 </td></tr></tbody></table>
28397 !! end
28398
28399 ## Remex doesn't account for fostered content.
28400 !! test
28401 Encapsulation properly handles null DSR information from foster box
28402 !! options
28403 parsoid=wt2html,wt2wt
28404 !! wikitext
28405 {{echo|<table>foo<tr><td>bar</td></tr></table>}}
28406 !! html/parsoid
28407 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;table>foo&lt;tr>&lt;td>bar&lt;/td>&lt;/tr>&lt;/table>"}},"i":0}}]}'>foo</p><table about="#mwt1" data-parsoid='{"stx":"html"}'><tbody><tr><td>bar</td></tr></tbody></table>
28408 !! end
28409
28410 ## Remex doesn't account for fostered content.
28411 !! test
28412 1. Encapsulate foster-parented transclusion content
28413 !! options
28414 parsoid=wt2wt,wt2html
28415 !! wikitext
28416 <table>{{echo|foo<tr><td>bar</td></tr>}}</table>
28417 !! html/php+tidy
28418 foo<table><tbody><tr><td>bar</td></tr></tbody></table>
28419 !! html/parsoid
28420 <p about="#mwt2" typeof="mw:Transclusion" data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true,"firstWikitextNode":"TABLE_html","pi":[[{"k":"1"}]]}' data-mw='{"parts":["&lt;table>",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo&lt;tr>&lt;td>bar&lt;/td>&lt;/tr>"}},"i":0}},"&lt;/table>"]}'>foo</p><table about="#mwt2" data-parsoid='{"stx":"html"}'><tbody><tr><td>bar</td></tr></tbody></table>
28421 !! end
28422
28423 !! test
28424 2. Encapsulate foster-parented transclusion content
28425 !! options
28426 parsoid=wt2wt,wt2html
28427 !! wikitext
28428 <table><div>{{echo|foo}}</div><tr><td>bar</td></tr></table>
28429 !! html/parsoid
28430 <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>
28431 <table>
28432 <tbody>
28433 <tr>
28434 <td>bar</td>
28435 </tr>
28436 </tbody>
28437 </table>
28438 !! end
28439
28440 !! test
28441 3. Encapsulate foster-parented transclusion content
28442 !! options
28443 parsoid=wt2wt,wt2html
28444 !! wikitext
28445 <table><div><p>{{echo|foo</p></div><tr><td>}}bar</td></tr></table>
28446 !! html/parsoid
28447 <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;]}">
28448 <p>foo</p>
28449 </div>
28450 <table>
28451 <tbody>
28452 <tr>
28453 <td>bar</td>
28454 </tr>
28455 </tbody>
28456 </table>
28457 !! end
28458
28459 !! test
28460 4. Encapsulate foster-parented transclusion content
28461 !! options
28462 parsoid=wt2wt,wt2html
28463 !! wikitext
28464 <table><div><p>{{echo|foo</p></div><tr><td>}}bar</td></tr></table>
28465 !! html/parsoid
28466 <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;]}">
28467 <p>foo</p>
28468 </div>
28469 <table>
28470 <tbody>
28471 <tr>
28472 <td>bar</td>
28473 </tr>
28474 </tbody>
28475 </table>
28476 !! end
28477
28478 ## Remex doesn't account for fostered content.
28479 !! test
28480 5. Encapsulate foster-parented transclusion content
28481 !!options
28482 parsoid=wt2wt,wt2html
28483 !! wikitext
28484 <table><tr><td><div><p>{{echo|foo</p></div></td>foo}}</tr></table>
28485 !! html/php+tidy
28486 foo<table><tbody><tr><td><div><p>foo</p></div></td></tr></tbody></table>
28487 !! html/parsoid
28488 <p about="#mwt2" typeof="mw:Transclusion" data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true,"firstWikitextNode":"TABLE_html","pi":[[{"k":"1"}]]}' data-mw='{"parts":["&lt;table>&lt;tr>&lt;td>&lt;div>&lt;p>",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo&lt;/p>&lt;/div>&lt;/td>foo"}},"i":0}},"&lt;/tr>&lt;/table>"]}'>foo</p><table about="#mwt2" data-parsoid='{"stx":"html"}'><tbody><tr><td><div><p>foo</p></div></td></tr></tbody></table>
28489 !! end
28490
28491 ## Remex doesn't account for fostered content.
28492 !! test
28493 6. Encapsulate foster-parented transclusion content
28494 !! options
28495 parsoid=wt2wt,wt2html
28496 !! wikitext
28497 <table><tr><td><div><p>{{echo|foo</p></div></td>foo</tr></table>}}<p>ok</p>
28498 !! html/php+tidy
28499 foo<table><tbody><tr><td><div><p>foo</p></div></td></tr></tbody></table><p>ok</p>
28500 !! html/parsoid
28501 <p about="#mwt2" typeof="mw:Transclusion" data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true,"firstWikitextNode":"TABLE_html","pi":[[{"k":"1"}]]}' data-mw='{"parts":["&lt;table>&lt;tr>&lt;td>&lt;div>&lt;p>",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo&lt;/p>&lt;/div>&lt;/td>foo&lt;/tr>&lt;/table>"}},"i":0}}]}'>foo</p><table about="#mwt2" data-parsoid='{"stx":"html"}'><tbody><tr><td><div><p>foo</p></div></td></tr></tbody></table><p data-parsoid='{"stx":"html"}'>ok</p>
28502 !! end
28503
28504 !! test
28505 7. Encapsulate foster-parented transclusion content
28506 !!options
28507 parsoid=wt2wt,wt2html
28508 !! wikitext
28509 <table>{{echo|<p>foo</p>}}<td>bar</td></table>
28510 !! html/parsoid
28511 <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>
28512 <table>
28513 <tbody>
28514 <tr>
28515 <td>bar</td>
28516 </tr>
28517 </tbody>
28518 </table>
28519 !! end
28520
28521 ## Remex doesn't account for fostered content.
28522 # Note that the wt is broken on purpose: the = should be {{=}} if you
28523 # don't want it to be a template parameter key.
28524 !! test
28525 8. Encapsulate foster-parented transclusion content
28526 !! options
28527 parsoid=wt2wt,wt2html
28528 !! wikitext
28529 {{echo|a
28530 }}{|{{echo|style='color:red'}}
28531 |-
28532 |b
28533 |}
28534 !! html/php+tidy
28535 <p>a
28536 </p>
28537 <table>
28538
28539 <tbody><tr>
28540 <td>b
28541 </td></tr></tbody></table>
28542 !! html/parsoid
28543 <p 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"}},"i":0}}]}'>a</p><span about="#mwt1">
28544 </span><p about="#mwt3" typeof="mw:Transclusion" data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true,"firstWikitextNode":"TABLE","pi":[[{"k":"style","named":true}]]}' data-mw='{"parts":["{|",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"style":{"wt":"&apos;color:red&apos;"}},"i":0}},"\n|-\n|b\n|}"]}'>{{{1}}}</p><table about="#mwt3">
28545 <tbody><tr>
28546 <td>b
28547 </td></tr></tbody></table>
28548 !! end
28549
28550 ## Remex doesn't account for fostered content.
28551 !! test
28552 9. Encapsulate foster-parented transclusion content
28553 !!options
28554 parsoid=wt2wt,wt2html
28555 !! wikitext
28556 <table>{{echo|hi</table>hello}}
28557 !! html/php+tidy
28558 hi<table></table><p>hello
28559 </p>
28560 !! html/parsoid
28561 <p about="#mwt2" typeof="mw:Transclusion" data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true,"firstWikitextNode":"TABLE_html","pi":[[{"k":"1"}]]}' data-mw='{"parts":["&lt;table>",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi&lt;/table>hello"}},"i":0}}]}'>hi</p><table about="#mwt2"></table><p about="#mwt2">hello</p>
28562 !! end
28563
28564 !! test
28565 Table in fosterable position
28566 !!options
28567 parsoid=wt2html
28568 !! wikitext
28569 {{OpenTable}}
28570 <div>
28571 {|
28572 |}
28573 </div>
28574 |}
28575 !! html/parsoid
28576 <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">
28577 </span>
28578 <table about="#mwt1" data-parsoid='{"autoInsertedEnd":true}'></table>
28579
28580 <table>
28581 </table>
28582 !! end
28583
28584 # Parsoid only for T66747
28585 !! test
28586 Properly encapsulate empty-content transclusions in fosterable positions
28587 !! wikitext
28588 <table>
28589 {{#if:|
28590 <td>foo</td>
28591 }}
28592 </table>
28593 !! html/parsoid
28594 <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"}]]}'>
28595
28596 </table>
28597 !! end
28598
28599 ## No longer captures its original intention
28600 !! test
28601 Always encapsulate foster box when template range is expanded to table
28602 !! options
28603 disabled
28604 parsoid=wt2wt
28605 !! wikitext
28606 {|
28607 hello
28608 {{OpenTable}}
28609 |}
28610 !! html/parsoid
28611
28612 !! end
28613
28614 !! test
28615 T115289: Unclosed table
28616 !! wikitext
28617 {{echo|<table>}}<!--c-->[[Category:Two]]
28618 !! html/parsoid
28619 <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>
28620 !! end
28621
28622 !! test
28623 T115289: Don't migrate newlines out of tables with fostered content
28624 !! wikitext
28625 <table><td></td>{{echo|<tr>[[Category:One]]}}<!--c-->[[Category:Two]]
28626 !! html/parsoid
28627 <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>
28628 !! end
28629
28630 !! test
28631 T73074: More fostering fun
28632 !! wikitext
28633 <table><td></td>{{echo|<tr>}}<!--c-->[[Category:Two]]
28634 !! html/parsoid
28635 <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>
28636 !! end
28637
28638 !!test
28639 Support <object> element with .data attribute
28640 !!options
28641 parsoid=html2wt
28642 !! html/parsoid
28643 <object data="test.swf"></object>
28644 !! wikitext
28645 <object data="test.swf"></object>
28646 !!end
28647
28648 !! test
28649 Don't block XML namespace declaration
28650 !! wikitext
28651 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">MediaWiki</span>
28652 !! html/php
28653 <p><span xmlns:dct="http&#58;//purl.org/dc/terms/" property="dct:title">MediaWiki</span>
28654 </p>
28655 !! html/parsoid
28656 <p><span xmlns:dct="http://purl.org/dc/terms/" data-x-property="dct:title" data-parsoid='{"stx":"html"}'>MediaWiki</span></p>
28657 !! end
28658
28659 # -----------------------------------------------------------------
28660 # The following section of tests are primarily to spec requirements
28661 # around Parsoid's serialization (old, new, edited content)
28662 #
28663 # All these tests are marked Parsoid html2wt and html2html only
28664 # ----------------------------------------------------------------
28665
28666 !! test
28667 Ignore rel attribute in a-tags during serialization to url-links
28668 !! options
28669 parsoid=html2wt
28670 !! html/parsoid
28671 <a href='http://en.wikipedia.org/wiki/Foobar'>http://en.wikipedia.org/wiki/Foobar</a>
28672 <a href='http://en.wikipedia.org/wiki/Foobar' rel='mw:ExtLink'>http://en.wikipedia.org/wiki/Foobar</a>
28673 <a href='http://en.wikipedia.org/wiki/Foobar' rel='mw:WikiLink'>http://en.wikipedia.org/wiki/Foobar</a>
28674 !! wikitext
28675 http://en.wikipedia.org/wiki/Foobar
28676 http://en.wikipedia.org/wiki/Foobar
28677 http://en.wikipedia.org/wiki/Foobar
28678 !! end
28679
28680 # 'mi' is a localinterwiki prefix as well as a language
28681 !! test
28682 Serialize interwiki links pointing to the current wiki as plain wiki links (T67869)
28683 !! options
28684 parsoid=html2wt
28685 !! html/parsoid
28686 <p><a rel="mw:ExtLink" href="http://mi.wikipedia.org/wiki/Foo">Foo</a></p>
28687 !! wikitext
28688 [[Foo]]
28689 !! end
28690
28691 !! test
28692 Parsoid should accept interwiki shortcuts
28693 !! options
28694 parsoid=html2wt
28695 !! html/parsoid
28696 <p><a rel='mw:WikiLink' href='./fr:Foo'>Foo</a>
28697 <a rel='mw:ExtLink' href='./fr:Foo'>Foo</a>
28698 <a href='./fr:Foo'>Foo</a></p>
28699 <p><a rel='mw:WikiLink' href='fr%3AFoo'>Foo</a>
28700 <a rel='mw:ExtLink' href='fr%3AFoo'>Foo</a>
28701 <a href='fr%3AFoo'>Foo</a></p>
28702 <p><a href='FR%3AFoo'>Foo</a>
28703 <a href='./FR:Foo'>Foo</a></p>
28704 !! wikitext
28705 [[:fr:Foo|Foo]]
28706 [[:fr:Foo|Foo]]
28707 [[:fr:Foo|Foo]]
28708
28709 [[:fr:Foo|Foo]]
28710 [[:fr:Foo|Foo]]
28711 [[:fr:Foo|Foo]]
28712
28713 [[:fr:Foo|Foo]]
28714 [[:fr:Foo|Foo]]
28715 !! end
28716
28717 !! test
28718 Parsoid should not accept invalid interwiki shortcuts
28719 !! options
28720 parsoid=html2wt
28721 !! html/parsoid
28722 <p><a rel='mw:WikiLink' href='news:Foo'>Foo</a>
28723 <a rel='mw:ExtLink' href='news:Foo'>Foo</a>
28724 <a href='news:Foo'>Foo</a></p>
28725 !! wikitext
28726 [news:Foo Foo]
28727 [news:Foo Foo]
28728 [news:Foo Foo]
28729 !! end
28730
28731 # See T93839
28732 !! test
28733 New wikilinks should be serialized properly
28734 !! options
28735 parsoid=html2wt
28736 !! html/parsoid
28737 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{}'>Foo</a>
28738 <a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a>
28739 <a href="//en.wikipedia.org/wiki/Foo">//en.wikipedia.org/wiki/Foo</a>
28740 <a href="http://en.wikipedia.org/wiki/Foo">http://en.wikipedia.org/wiki/Foo</a>
28741 <a href="//en.wikipedia.org/wiki/Foo_bar">//en.wikipedia.org/wiki/Foo bar</a>
28742 !! wikitext
28743 [[Foo]]
28744 [[Foo]]
28745 [[:en:Foo|//en.wikipedia.org/wiki/Foo]]
28746 http://en.wikipedia.org/wiki/Foo
28747 [[:en:Foo_bar|//en.wikipedia.org/wiki/Foo bar]]
28748 !! end
28749
28750 !! test
28751 New wiki links (href variations)
28752 !! options
28753 parsoid=html2wt
28754 !! html/parsoid
28755 <a rel="mw:WikiLink" href="./Foo_bar">Foo_bar</a>
28756 <a rel="mw:WikiLink" href="Foo_bar">Foo_bar</a>
28757 <a rel="mw:WikiLink" href="Foo bar">Foo_bar</a>
28758 <a rel="mw:WikiLink" href="./Toxine_bact%C3%A9rienne">Toxine bactérienne</a>
28759 !! wikitext
28760 [[Foo_bar]]
28761 [[Foo_bar]]
28762 [[Foo_bar]]
28763 [[Toxine bactérienne]]
28764 !! end
28765
28766 !! test
28767 New wiki links (content string variations)
28768 !! options
28769 parsoid=html2wt
28770 !! html/parsoid
28771 <a rel="mw:WikiLink" href="./Foo_bar">Foo_bar</a>
28772 <a rel="mw:WikiLink" href="./Foo_bar">Foo bar</a>
28773 <a rel="mw:WikiLink" href="./Foo_bar">./Foo_bar</a>
28774 !! wikitext
28775 [[Foo_bar]]
28776 [[Foo bar]]
28777 [[Foo_bar|./Foo_bar]]
28778 !! end
28779
28780 !! test
28781 New category links (href variations)
28782 !! options
28783 parsoid=html2wt
28784 !! html/parsoid
28785 <link rel="mw:PageProp/Category" href="./Category:Toxine_bactérienne" />
28786 <link rel="mw:PageProp/Category" href="./Category:Toxine_bact%C3%A9rienne" />
28787 <link rel="mw:PageProp/Category" href="Category:Toxine_bact%C3%A9rienne" />
28788 !! wikitext
28789 [[Category:Toxine bactérienne]]
28790 [[Category:Toxine bactérienne]]
28791 [[Category:Toxine bactérienne]]
28792 !! end
28793
28794 !! test
28795 New sol transparent links don't need indent-pre nowiki protection
28796 !! options
28797 parsoid=html2wt
28798 language=de
28799 !! html/parsoid
28800 <link rel="mw:PageProp/redirect" href="./Main_Page">
28801 <!-- this is good --> <link rel="mw:PageProp/Category" href="./Category:Good" />
28802 <!-- this is great --> <link rel="mw:PageProp/Category" href="./Kategorie:Great" />
28803 !! wikitext
28804 #WEITERLEITUNG [[Main Page]]
28805 <!-- this is good --> [[Category:Good]]
28806 <!-- this is great --> [[Kategorie:Great]]
28807 !! end
28808
28809 !! test
28810 New interlanguage links (href variations)
28811 !! options
28812 parsoid=html2wt
28813 !! html/parsoid
28814 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine bactérienne" />
28815 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine_bactérienne" />
28816 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine_bact%C3%A9rienne" />
28817 !! wikitext
28818 [[es:Toxine bactérienne]]
28819 [[es:Toxine_bactérienne]]
28820 [[es:Toxine_bactérienne]]
28821 !! end
28822
28823 !! test
28824 Image: Modifying size of an image (1)
28825 !! options
28826 parsoid={
28827 "modes": ["wt2wt"],
28828 "changes": [
28829 ["img[height]", "attr", "height", "22"],
28830 ["img[width]", "attr", "width", "200"]
28831 ]
28832 }
28833 !! wikitext
28834 [[Image:Foobar.jpg|230x230px]]
28835 !! wikitext/edited
28836 [[Image:Foobar.jpg|200x200px]]
28837 !!end
28838
28839 !! test
28840 Image: Modifying size of an image (2)
28841 !! options
28842 parsoid={
28843 "modes": ["wt2wt"],
28844 "changes": [
28845 ["img[height]", "attr", "height", "100"],
28846 ["img[width]", "attr", "width", "500"]
28847 ]
28848 }
28849 !! wikitext
28850 [[Image:Foobar.jpg|230x230px]]
28851 !! wikitext/edited
28852 [[Image:Foobar.jpg|500x500px]]
28853 !!end
28854
28855 # Change in size is ignored so long as class='mw-default-size'
28856 !! test
28857 Image: Modifying size of an image (3)
28858 !! options
28859 parsoid={
28860 "modes": ["wt2wt"],
28861 "changes": [
28862 ["figure[class]", "removeClass", "mw-default-size"],
28863 ["figure img", "attr", "height", "19"],
28864 ["figure img", "attr", "width", "170"]
28865 ]
28866 }
28867 !! wikitext
28868 [[Image:Foobar.jpg|thumb]]
28869 !! wikitext/edited
28870 [[Image:Foobar.jpg|thumb|170x170px]]
28871 !!end
28872
28873 !! test
28874 Image: Modifying alignment of an image (T50665)
28875 !! options
28876 parsoid={
28877 "modes": ["wt2wt"],
28878 "changes": [
28879 ["figure[class]", "removeClass", "mw-halign-right"],
28880 ["figure[class]", "addClass", "mw-halign-left"]
28881 ]
28882 }
28883 !! wikitext
28884 [[Image:Foobar.jpg|thumb|caption|right]]
28885 !! wikitext/edited
28886 [[Image:Foobar.jpg|thumb|caption|left]]
28887 !! end
28888
28889 !! test
28890 Image: Modifying mw-default-size of an frameless image (T64805)
28891 !! options
28892 parsoid={
28893 "modes": ["wt2wt"],
28894 "changes": [
28895 ["figure.mw-default-size", "removeClass", "mw-default-size"]
28896 ]
28897 }
28898 !! wikitext
28899 [[Image:Foobar.jpg|frameless|right]]
28900 !! wikitext/edited
28901 [[Image:Foobar.jpg|frameless|right|220x220px]]
28902 !! end
28903
28904 !! test
28905 Image: Modifying valign of an image (T51221)
28906 !! options
28907 parsoid={
28908 "modes": ["wt2wt"],
28909 "changes": [
28910 ["*[typeof=\"mw:Image\"]", "removeClass", "mw-valign-middle"],
28911 ["*[typeof=\"mw:Image\"]", "addClass", "mw-valign-text-top"]
28912 ]
28913 }
28914 !! wikitext
28915 [[File:Foobar.jpg|20px|middle]]
28916 !! wikitext/edited
28917 [[File:Foobar.jpg|20px|text-top]]
28918 !! end
28919
28920 !! test
28921 Image: Modifying alt attribute of an image (T58400)
28922 !! options
28923 parsoid={
28924 "modes": ["wt2wt"],
28925 "changes": [
28926 ["img[alt]", "attr", "alt", "some alternate edited text"]
28927 ]
28928 }
28929 !! wikitext
28930 [[File:Foobar.jpg|thumb|some caption|alt=some alternate text]]
28931 !! wikitext/edited
28932 [[File:Foobar.jpg|thumb|some caption|alt=some alternate edited text]]
28933 !!end
28934
28935 !! test
28936 Image: Modifying caption of an image
28937 !! options
28938 parsoid={
28939 "modes": ["wt2wt"],
28940 "changes": [
28941 ["figcaption", "text", "new caption"]
28942 ]
28943 }
28944 !! wikitext
28945 [[Image:Foobar.jpg|thumb|original caption]]
28946 !! wikitext/edited
28947 [[Image:Foobar.jpg|thumb|new caption]]
28948 !!end
28949
28950 !! test
28951 Image: empty alt attribute (T50924)
28952 !! wikitext
28953 [[File:Foobar.jpg|thumb|alt=|bar]]
28954 !! html/php+tidy
28955 <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" decoding="async" 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>
28956 !! html/parsoid
28957 <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>
28958 !! end
28959
28960 !! test
28961 Image: new attributes should be serialized in wiki's language for RTL languages (T53852)
28962 !! options
28963 parsoid=html2wt
28964 language=ar
28965 disabled
28966 !! html/parsoid
28967 <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>
28968 !! wikitext
28969 [[Imagen:Foobar.jpg|derecha|miniaturadeimagen]]
28970 !! end
28971
28972 !! test
28973 Image: Block level image should have \n before and after
28974 !! wikitext
28975 123
28976 [[File:Foobar.jpg|right|thumb|150x150px]]
28977 456
28978 !! html/parsoid
28979 <p>123</p>
28980 <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>
28981 <p>456</p>
28982 !! end
28983
28984 !! test
28985 Image: New block level image should have \n before and after (existing content)
28986 !! wikitext
28987 123
28988 [[File:Foobar.jpg|right|thumb|150x150px]]
28989 456
28990 !! html/parsoid
28991 <p>123</p>
28992 <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>
28993 <p>456</p>
28994 !! end
28995
28996 !! test
28997 Image: upright option (parsoid)
28998 !! wikitext
28999 [[File:Foobar.jpg|thumb|upright|caption]]
29000 [[File:Foobar.jpg|thumb|upright=0.5|caption]]
29001 [[File:Foobar.jpg|thumb|500x500px|upright=0.5|caption]]
29002 !! html/parsoid
29003 <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>
29004 <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>
29005 <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>
29006 !! end
29007
29008 !! test
29009 Image: upright option is ignored on inline and frame images (parsoid)
29010 !! wikitext
29011 [[File:Foobar.jpg|500x500px|upright=0.5|caption]]
29012 !! html/parsoid
29013 <p><figure-inline 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></figure-inline></p>
29014 !! end
29015
29016 !! test
29017 Image: in template parameter with empty parameter
29018 !! wikitext
29019 {{echo|[[File:Foobar.jpg|link=]]}}
29020 !! html/parsoid
29021 <p><figure-inline 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></figure-inline></p>
29022 !! end
29023
29024 !! test
29025 Image: from basic HTML (1)
29026 !! options
29027 parsoid=html2wt
29028 !! html/parsoid
29029 <span typeof="mw:Image">
29030 <img src="./File:Foobar.jpg" width=100 height=100 alt="Alt">
29031 </span>
29032 !! wikitext
29033 [[File:Foobar.jpg|link=|alt=Alt|100x100px]]
29034 !! end
29035
29036 !! test
29037 Image: from basic HTML (2)
29038 !! options
29039 parsoid=html2wt
29040 !! html/parsoid
29041 <img src="./File:Foobar.jpg" width=100 height=100 alt="Alt">
29042 !! wikitext
29043 [[File:Foobar.jpg|link=|alt=Alt|100x100px]]
29044 !! end
29045
29046 !! test
29047 Image: from basic HTML (3)
29048 !! options
29049 parsoid=html2wt
29050 !! html/parsoid
29051 <a href="Main"><img src="./File:Foobar.jpg" width=100 height=100 alt="Alt"></a>
29052 !! wikitext
29053 [[File:Foobar.jpg|link=Main|alt=Alt|100x100px]]
29054 !! end
29055
29056 !! test
29057 Image: from basic HTML (4)
29058 !! options
29059 parsoid=html2wt
29060 !! html/parsoid
29061 <img src="./File:Foobar.jpg">
29062 !! wikitext
29063 [[File:Foobar.jpg|link=]]
29064 !! end
29065
29066 !! test
29067 Image: Invalid title as link
29068 !! wikitext
29069 [[File:Foobar.jpg|link=<]]
29070 !! html/php
29071 <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" decoding="async" width="1941" height="220" /></a>
29072 </p>
29073 !! html/parsoid
29074 <p><figure-inline 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></figure-inline></p>
29075 !! end
29076
29077 !! test
29078 Various link types in alt and link options
29079 !! wikitext
29080 [[File:Foobar.jpg|link=[[Main Page]]|alt=[[Main Page]]|caption]]
29081
29082 [[File:Foobar.jpg|link=[[Media:Thumb.png]]|alt=[[Media:Thumb.png]]|caption]]
29083
29084 [[File:Foobar.jpg|link=[[wikipedia:Foo]]|alt=[[wikipedia:Foo]]|caption]]
29085 !! html/php+tidy
29086 <p><a href="/wiki/Main_Page" title="caption"><img alt="Main Page" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" /></a>
29087 </p><p><a href="/wiki/Media:Thumb.png" title="caption"><img alt="Media:Thumb.png" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" /></a>
29088 </p><p><a href="http://en.wikipedia.org/wiki/Foo" title="caption"><img alt="wikipedia:Foo" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" /></a>
29089 </p>
29090 !! html/parsoid
29091 <p><figure-inline class="mw-default-size" typeof="mw:Image" data-mw='{"caption":"caption"}'><a href="./Main_Page" data-parsoid='{"a":{"href":"./Main_Page"},"sa":{"href":"link=[[Main Page]]"}}'><img alt="Main Page" 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":"Main Page","resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"alt":"alt=[[Main Page]]","resource":"File:Foobar.jpg"}}'/></a></figure-inline></p>
29092
29093 <p><figure-inline class="mw-default-size" typeof="mw:Image" data-mw='{"caption":"caption"}'><a href="./Media:Thumb.png" data-parsoid='{"a":{"href":"./Media:Thumb.png"},"sa":{"href":"link=[[Media:Thumb.png]]"}}'><img alt="Media:Thumb.png" 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":"Media:Thumb.png","resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"alt":"alt=[[Media:Thumb.png]]","resource":"File:Foobar.jpg"}}'/></a></figure-inline></p>
29094
29095 <p><figure-inline class="mw-default-size" typeof="mw:Image" data-mw='{"caption":"caption"}'><a href="http://en.wikipedia.org/wiki/Foo" data-parsoid='{"a":{"href":"http://en.wikipedia.org/wiki/Foo"},"sa":{"href":"link=[[wikipedia:Foo]]"}}'><img alt="wikipedia:Foo" 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":"wikipedia:Foo","resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"alt":"alt=[[wikipedia:Foo]]","resource":"File:Foobar.jpg"}}'/></a></figure-inline></p>
29096 !! end
29097
29098 !! test
29099 Lists: Serialize correctly even when list content is wrapped in p-tags (like VE does)
29100 !! options
29101 parsoid=html2wt
29102 !! html/parsoid
29103 <ul>
29104 <li><p>foo</p></li>
29105 </ul>
29106 !! wikitext
29107 * foo
29108 !! end
29109
29110 !! test
29111 Lists: Serialize correctly even when list tags has unneeded whitespace between tags
29112 !! options
29113 parsoid=html2wt
29114 !! html/parsoid
29115 <ul> <li>foo</li></ul>
29116 !! wikitext
29117 * foo
29118 !! end
29119
29120 !! test
29121 Don't strip leading whitespace when handling indent-pre suppressing tags
29122 !! options
29123 parsoid=html2wt
29124 !! html/parsoid
29125 <table>
29126 <tr><td> indented row</td></tr>
29127 </table>
29128 <blockquote><p>
29129 <b>This is very bold of you!</b>
29130 </p>
29131 <table><tr><td>
29132 indented cell (no pre-wrapping!)
29133 </td></tr></table>
29134 </blockquote>
29135 <p>foo</p>
29136 <div>bar</div>
29137 !! wikitext
29138 {|
29139 | indented row
29140 |}
29141 <blockquote>
29142 '''This is very bold of you!'''
29143
29144 {|
29145 |
29146 indented cell (no pre-wrapping!)
29147 |}
29148 </blockquote>
29149 foo
29150 <div>bar</div>
29151 !! end
29152
29153 !! test
29154 Nowiki-wrap leading whitespace when handling indent-pre inducing tags
29155 !! options
29156 parsoid=html2wt
29157 !! html/parsoid
29158 <p>foo</p>
29159 <span>bar</span>
29160
29161 <span>foo2
29162 </span>bar2
29163
29164 <div>foo</div>
29165 <span>bar</span>
29166
29167 <div>
29168 <span>foo</span>
29169 </div>
29170 !! wikitext
29171 foo
29172
29173 <span>bar</span>
29174
29175 <span>foo2
29176 <nowiki> </nowiki></span>bar2
29177
29178 <div>foo</div>
29179 <nowiki> </nowiki><span>bar</span>
29180
29181 <div>
29182 <nowiki> </nowiki><span>foo</span>
29183 </div>
29184 !! end
29185
29186 !! test
29187 Lists: Dont insert newlines in a serialized list item.
29188 !! options
29189 parsoid=html2wt
29190 !! html/parsoid
29191 <ul><li>a<br>b</li><li>c</li></ul>
29192 !! wikitext
29193 * a<br />b
29194 * c
29195 !! end
29196
29197 !! test
29198 1. Headings: Force sol-transparent links and behavior switches to serialize before/after
29199 !! options
29200 parsoid={
29201 "modes": ["html2wt"],
29202 "scrubWikitext": false
29203 }
29204 !! html/parsoid
29205 <h2>hello there<link href="./Category:A1" rel="mw:PageProp/Category" /></h2>
29206 <h2><link href="./Category:A2" rel="mw:PageProp/Category" />hi pal</h2>
29207
29208 <h2><!--foo--> <link href="./Category:A3" rel="mw:PageProp/Category" /> how goes it</h2>
29209 <h2>it goes well <link href="./Category:A4" rel="mw:PageProp/Category" /> <!--bar--></h2>
29210
29211 <h2 data-parsoid='{}'>howdy<link href="./Category:A5" rel="mw:PageProp/Category" /></h2>
29212
29213 <h2><meta property="mw:PageProp/toc" /> ok</h2>
29214 !! wikitext
29215 == hello there [[Category:A1]] ==
29216
29217 == [[Category:A2]] hi pal ==
29218
29219 == <!--foo--> [[Category:A3]] how goes it ==
29220
29221 == it goes well [[Category:A4]] <!--bar--> ==
29222
29223 ==howdy [[Category:A5]]==
29224
29225 == __TOC__ ok ==
29226 !! end
29227
29228 !! test
29229 2. Headings: Force sol-transparent links and behavior switches to serialize before/after
29230 !! options
29231 parsoid={
29232 "modes": ["html2wt"],
29233 "scrubWikitext": true
29234 }
29235 !! html/parsoid
29236 <h2>hello there<link href="./Category:A1" rel="mw:PageProp/Category" /></h2>
29237 <h2><link href="./Category:A2" rel="mw:PageProp/Category" />hi pal</h2>
29238
29239 <h2><!--foo--> <link href="./Category:A3" rel="mw:PageProp/Category" /> how goes it</h2>
29240 <h2>it goes well <link href="./Category:A4" rel="mw:PageProp/Category" /> <!--bar--></h2>
29241
29242 <h2><meta property="mw:PageProp/toc" /> ok</h2>
29243 !! wikitext
29244 == hello there ==
29245 [[Category:A1]]
29246 [[Category:A2]]
29247
29248 == hi pal ==
29249
29250 <!--foo-->[[Category:A3]]
29251
29252 == how goes it ==
29253
29254 == it goes well ==
29255 [[Category:A4]] <!--bar-->
29256
29257 __TOC__
29258
29259 == ok ==
29260 !! end
29261
29262 !! test
29263 Headings: Don't hoist metas that come from templates
29264 !! options
29265 parsoid={
29266 "modes": ["html2wt"],
29267 "scrubWikitext": true
29268 }
29269 !! html/parsoid
29270 <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>
29271 !! wikitext
29272 == {{echo|foo [[Category:Foo]]}} ==
29273 !! end
29274
29275 !! test
29276 Headings: Category in ref isn't hoisted
29277 !! options
29278 parsoid={
29279 "modes": ["html2wt"],
29280 "scrubWikitext": true
29281 }
29282 !! html/parsoid
29283 <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>
29284
29285 <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>
29286 !! wikitext
29287 == foo <ref>bar
29288 [[Category:Baz]] </ref> ==
29289
29290 <references />
29291 !! end
29292
29293 !! test
29294 Parsoid: Serialize positional parameters with = in them as named parameter
29295 !! options
29296 parsoid=html2wt
29297 !! html/parsoid
29298 <p about="#mwt1" typeof="mw:Transclusion"
29299 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"f=oo"}},"i":0}}]}'>foo</p>
29300
29301 <p about="#mwt1" typeof="mw:Transclusion"
29302 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"f=oo"}, "2":{"wt":"bar"}},"i":0}}]}'>foo</p>
29303
29304 <!--Orig params with data-parsoid has heuristics for handling = chars-->
29305 <!--FIXME: But maybe the heuristic needs fixing to apply to new params as well-->
29306 <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>
29307 !! wikitext
29308 {{echo|1=f=oo}}
29309
29310 {{echo|1=f=oo|2=bar}}
29311
29312 <!--Orig params with data-parsoid has heuristics for handling = chars-->
29313 <!--FIXME: But maybe the heuristic needs fixing to apply to new params as well-->
29314 {{echo|<nowiki>f=oo</nowiki>|bar}}
29315 !! end
29316
29317 !! test
29318 Parsoid: Serialize positional parameters with = in extlink as named parameter
29319 !! options
29320 parsoid=html2wt
29321 !! html/parsoid
29322 <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>
29323 !! wikitext
29324 {{echo|1=http://stuff?is=ok}}
29325 !! end
29326
29327 !! test
29328 Parsoid: Correctly serialize block-node children when they are a combination of text and p-nodes
29329 !! options
29330 parsoid=html2wt
29331 !! html/parsoid
29332 <div>a<p>b</p></div>
29333 <div>a
29334 <p>b</p></div>
29335 <div>
29336 a
29337 <p>b</p></div>
29338 !! wikitext
29339 <div>a
29340 b
29341 </div>
29342 <div>a
29343 b
29344 </div>
29345 <div>
29346 a
29347
29348 b
29349 </div>
29350 !! end
29351
29352 !! test
29353 Substrings resembling wikitext in hrefs should not get nowiki escapes
29354 !! options
29355 parsoid=html2wt
29356 !! html/parsoid
29357 <a rel="mw:WikiLink" href="./Foo''bar''baz">Foo''bar''baz</a>
29358 !! wikitext
29359 [[Foo''bar''baz]]
29360 !! end
29361
29362 !! test
29363 Enforce single-line context in the serializer
29364 !! options
29365 parsoid=html2wt
29366 !! html/parsoid
29367 <h2>testing
29368 123</h2>
29369
29370 <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">
29371 </span><span about="#mwt1">you</span> </h2>
29372
29373 <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>
29374
29375 <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
29376 there</span></li></ol>
29377
29378 <ul><li>asd
29379 sdf</li></ul>
29380
29381 <ul><li>foo
29382 bar
29383 baz</li>
29384 <li>foo <b>bar</b>
29385 baz</li></ul>
29386
29387 <dl><dt>hi
29388 ho </dt><dd data-parsoid='{"stx":"row"}'> hi
29389 ho</dd></dl>
29390
29391 <dl><dd> <table>
29392 <tbody><tr><td> ha
29393 ha
29394 ha</td></tr>
29395 </tbody></table></dd></dl>
29396 !! wikitext
29397 == testing 123 ==
29398
29399 == hi {{bogus|there
29400 you}} ==
29401
29402 == foo <ref>hello
29403 there</ref> ==
29404
29405 <references />
29406
29407 * asd sdf
29408
29409 * foo bar baz
29410 * foo '''bar''' baz
29411
29412 ; hi ho : hi ho
29413
29414 : {|
29415 | ha
29416 ha
29417 ha
29418 |}
29419 !! end
29420
29421 !! test
29422 Serialize new placeholder space without spans
29423 !! options
29424 parsoid=html2wt
29425 !! html/parsoid
29426 <p>foo<span typeof="mw:Placeholder"> </span>: bar</p>
29427
29428 <p>foo<span typeof="mw:DisplaySpace mw:Placeholder" data-parsoid='{"src":" ","isDisplayHack":true}'> </span>: bar</p>
29429
29430 <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>
29431 !! wikitext
29432 foo : bar
29433
29434 foo : bar
29435
29436 <ref>foo : bar</ref>ok
29437 !! end
29438
29439
29440 #-----------------------
29441 # Tag minimization tests
29442 #-----------------------
29443
29444 !! test
29445 1. I/B quote minimization: wikitext-only tags should be combined
29446 !! options
29447 parsoid=html2wt
29448 !! html/parsoid
29449 <p><i>A</i><i>B</i></p>
29450 <p><b>A</b><b>B</b></p>
29451 <p><i>A</i><b><i>B</i></b></p>
29452 <p><b>A</b><i><b>B</b></i></p>
29453 <p><b>A</b><i><b>B</b><b>C</b></i><b>D</b></p>
29454 <p><i><b>A</b></i><i><b>B</b></i></p>
29455 <p><i><b>A</b></i><b><i>B</i></b></p>
29456 <p><b><i>A</i></b><i><b>B</b></i></p>
29457 !! wikitext
29458 ''AB''
29459
29460 '''AB'''
29461
29462 ''A'''B'''''
29463
29464 '''A''B'''''
29465
29466 '''A''BC''D'''
29467
29468 '''''AB'''''
29469
29470 '''''AB'''''
29471
29472 '''''AB'''''
29473 !! end
29474
29475 !! test
29476 2. I/B quote minimization: wikitext and html tags should not be combined
29477 !! options
29478 parsoid=html2wt
29479 !! html/parsoid
29480 <p><i>A</i><i data-parsoid='{"stx":"html"}'>B</i></p>
29481 <p><i>A</i><b><i data-parsoid='{"stx":"html"}'>B</i></b></p>
29482 !! wikitext
29483 ''A''<i>B</i>
29484
29485 ''A''<nowiki/>'''<i>B</i>'''
29486 !! end
29487
29488 !! test
29489 3. I/B quote minimization: templated content stops minimization
29490 !! options
29491 parsoid=html2wt
29492 !! html/parsoid
29493 <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>
29494 <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>
29495 !! wikitext
29496 ''A''{{echo|''B''}}
29497
29498 ''A''{{echo|'''''B'''''}}
29499 !! end
29500
29501 !! test
29502 4. I/B quote minimization: new content should be mimimized with adjacent old content
29503 !! options
29504 parsoid=html2wt
29505 !! html/parsoid
29506 <p><i>A</i><i>B</i></p>
29507 <p><b>A</b><b>B</b></p>
29508 <p><i>A</i><b><i>B</i></b></p>
29509 !! wikitext
29510 ''AB''
29511
29512 '''AB'''
29513
29514 ''A'''B'''''
29515 !! end
29516
29517 !! test
29518 5a. Merge adjacent quote nodes if they've been edited
29519 !! options
29520 parsoid={
29521 "modes": ["wt2wt", "selser"],
29522 "changes": [
29523 ["p", "contents", "remove", ":contains('b')"]
29524 ]
29525 }
29526 !! wikitext
29527 ''a''b''c''
29528 !! wikitext/edited
29529 ''ac''
29530 !! end
29531
29532 !! test
29533 5b. Merge adjacent quote nodes if they've been edited
29534 !! options
29535 parsoid={
29536 "modes": ["wt2wt", "selser"],
29537 "changes": [
29538 ["#x", "remove"]
29539 ]
29540 }
29541 !! wikitext
29542 ''a''<span id="x">b</span>''c''
29543 !! wikitext/edited
29544 ''ac''
29545 !! end
29546
29547 !! test
29548 1. Merge adjacent link nodes as long as at least one element is new
29549 !! options
29550 parsoid={
29551 "modes": ["html2wt"],
29552 "scrubWikitext": true
29553 }
29554 !! html/parsoid
29555 <a rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
29556 <a data-parsoid="{}" rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
29557 <a data-parsoid="{}" rel="mw:WikiLink" href="./Football">Foot</a><a data-parsoid="{}" rel="mw:WikiLink" href="./Football">ball</a>
29558 !! wikitext
29559 [[Football]]
29560 [[Football]]
29561 [[Football|Foot]][[Football|ball]]
29562 !! end
29563
29564 !! test
29565 2. Merge adjacent link nodes and enable additional normalizations
29566 !! options
29567 parsoid={
29568 "modes": ["html2wt"],
29569 "scrubWikitext": true
29570 }
29571 !! html/parsoid
29572 <a rel="mw:WikiLink" href="./Football"><i>Foot</i></a><a rel="mw:WikiLink" href="./Football"><i>ball</i></a>
29573 !! wikitext
29574 ''[[Football]]''
29575 !! end
29576
29577 !! test
29578 3. Don't merge adjacent link nodes if scrubWikitext is false
29579 !! options
29580 parsoid={
29581 "modes": ["html2wt"],
29582 "scrubWikitext": false
29583 }
29584 !! html/parsoid
29585 <a rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
29586 !! wikitext
29587 [[Football|Foot]][[Football|ball]]
29588 !! end
29589
29590 !! test
29591 1. Move format tags outside of WikiLink
29592 !! options
29593 parsoid={
29594 "modes": ["html2wt"],
29595 "scrubWikitext": true
29596 }
29597 !! html/parsoid
29598 <a rel="mw:WikiLink" href="./Football"><i>Football</i></a>
29599 <a rel="mw:WikiLink" href="./Football"><i><b>Football</b></i></a>
29600 <a rel="mw:WikiLink" href="./Football"><u><i><b>Football</b></i></u></a>
29601 !! wikitext
29602 ''[[Football]]''
29603 '''''[[Football]]'''''
29604 <u>'''''[[Football]]'''''</u>
29605 !! end
29606
29607 !! test
29608 2. Move format tags outside of WikiLink with mergable A tags
29609 !! options
29610 parsoid={
29611 "modes": ["html2wt"],
29612 "scrubWikitext": true
29613 }
29614 !! html/parsoid
29615 <a rel="mw:WikiLink" href="./Football"><i><b>Foot</b></i></a><a rel="mw:WikiLink" href="./Football"><i><b>ball</b></i></a>
29616 !! wikitext
29617 '''''[[Football]]'''''
29618 !! end
29619
29620 !! test
29621 3. Move format tags outside of WikiLink while preserving formats already outside WikiLink
29622 !! options
29623 parsoid={
29624 "modes": ["html2wt"],
29625 "scrubWikitext": true
29626 }
29627 !! html/parsoid
29628 <font color="red"><a rel="mw:WikiLink" href="./Foo" title="Foo" class="mw-redirect"><u><b>Foo</b></u></a></font>
29629 !! wikitext
29630 <font color="red"><u>'''[[Foo]]'''</u></font>
29631 !! end
29632
29633 !! test
29634 4. Do not move format tags outside of WikiLink which includes attributes color, style and class
29635 !! options
29636 parsoid={
29637 "modes": ["html2wt"],
29638 "scrubWikitext": true
29639 }
29640 !! html/parsoid
29641 <a rel="mw:WikiLink" href="./Foo" title="Foo" class="mw-redirect"><font color="red">Foo</font></a>
29642 <a rel="mw:WikiLink" href="./Foo" title="Foo" class="mw-redirect"><span style="color: blue; font-size: 46px;">Foo></span></a>
29643 <a rel="mw:WikiLink" href="./Foo" title="Foo" class="mw-redirect"><span class="Bar">Foo</span></a>
29644 !! wikitext
29645 [[Foo|<font color="red">Foo</font>]]
29646 [[Foo|<span style="color: blue; font-size: 46px;">Foo></span>]]
29647 [[Foo|<span class="Bar">Foo</span>]]
29648 !! end
29649
29650 !! test
29651 5. T194083 Regression test: Manual edit test that also enables scrubWikitext to move format tags outside wikilinks
29652 !! options
29653 parsoid={
29654 "modes": ["selser"],
29655 "scrubWikitext": true,
29656 "changes": [
29657 ["a", "html", "<i>Foo</i>"]
29658 ]
29659 }
29660 !! wikitext
29661 [[Foo]]
29662 !! wikitext/edited
29663 ''[[Foo]]''
29664 !! end
29665
29666 !! test
29667 6. Regression test: Manual edit test to ensure diff markers are not lost
29668 !! options
29669 parsoid={
29670 "modes": ["selser"],
29671 "scrubWikitext": true,
29672 "changes": [
29673 ["i", "wrap", "<a href='./Foo' rel='mw:WikiLink'></a>"]
29674 ]
29675 }
29676 !! wikitext
29677 ''Foo''
29678 !! wikitext/edited
29679 ''[[Foo]]''
29680 !! end
29681
29682 !! test
29683 7. T194083 Regression test: Manual edit test to ensure nested diff markers aren't inserted
29684 !! options
29685 parsoid={
29686 "modes": ["selser"],
29687 "scrubWikitext": true,
29688 "changes": [
29689 ["div", "after", "\n<p><a href='./Foo' rel='mw:WikiLink'>Foo </a>, placeholder</p>"]
29690 ]
29691 }
29692 !! wikitext
29693 <div>placeholder</div>
29694 !! wikitext/edited
29695 <div>placeholder</div>
29696 [[Foo]] , placeholder
29697 !! end
29698
29699 #------------------------------
29700 # End of tag minimization tests
29701 #------------------------------
29702
29703 !!test
29704 T56262: New entities
29705 !! options
29706 parsoid=html2wt
29707 !! html/parsoid
29708 <span typeof="mw:Entity">&nbsp;</span>
29709 !! wikitext
29710 &nbsp;
29711 !! end
29712
29713 ## Note that there is no wikitext output for 'unknownproperty' ##
29714 ## Unknown magic words are silently dropped ##
29715
29716 !! test
29717 Magic words
29718 !! options
29719 parsoid=html2wt
29720 !! html/parsoid
29721 <meta property='mw:PageProp/toc' />
29722 <meta property='mw:PageProp/notoc' />
29723 <meta property='mw:PageProp/forcetoc' />
29724 <meta property='mw:PageProp/index' />
29725 <meta property='mw:PageProp/noindex' />
29726 <meta property='mw:PageProp/nogallery' />
29727 <meta property='mw:PageProp/noeditsection' />
29728 <meta property='mw:PageProp/notitleconvert' />
29729 <meta property='mw:PageProp/nocontentconvert' />
29730 <meta property='mw:PageProp/unknownproperty' />
29731 !! wikitext
29732 __TOC__
29733 __NOTOC__
29734 __FORCETOC__
29735 __INDEX__
29736 __NOINDEX__
29737 __NOGALLERY__
29738 __NOEDITSECTION__
29739 __NOTITLECONVERT__
29740 __NOCONTENTCONVERT__
29741 !! end
29742
29743 !! test
29744 Consecutive <pre>s should not get merged
29745 !! options
29746 parsoid=html2wt,html2html
29747 !! html/parsoid
29748 <pre>a</pre><pre>b</pre>
29749
29750 <pre>c
29751 </pre><pre>
29752 d</pre>
29753
29754 <pre>e
29755
29756 </pre><pre>
29757
29758 f</pre>
29759 !! wikitext
29760 a
29761
29762 b
29763
29764 c
29765
29766 d
29767
29768 e
29769
29770
29771
29772 f
29773 !! end
29774
29775 !! test
29776 Edited ISBN links not serializable as ISBN links should serialize as wikilinks
29777 !! options
29778 parsoid=html2wt
29779 !! html/parsoid
29780 <a href="./Special:BookSources/1234567890" rel="mw:ExtLink">ISBN 1234567895</a>
29781 !! wikitext
29782 [[Special:BookSources/1234567890|ISBN 1234567895]]
29783 !! end
29784
29785 !! test
29786 Edited RFC links not serializable as RFC links should serialize as extlinks
29787 !! options
29788 parsoid=html2wt
29789 !! html/parsoid
29790 <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink">New RFC</a>
29791 !! wikitext
29792 [https://tools.ietf.org/html/rfc123 New RFC]
29793 !! end
29794
29795 !! test
29796 Edited PMID links not serializable as PMID links should serialize as extlinks
29797 !! options
29798 parsoid=html2wt
29799 !! html/parsoid
29800 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink">New PMID</a>
29801 !! wikitext
29802 [//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract New PMID]
29803 !! end
29804
29805 !! test
29806 WTS of autolinks with trailing/surrounding context
29807 !! options
29808 parsoid=html2wt
29809 !! html/parsoid
29810 <p><a href="http://cscott.net">http://cscott.net</a><b>foo</b></p>
29811 <p><a href="http://cscott.net">http://cscott.net</a><b data-parsoid='{"stx":"html"}'>foo</b></p>
29812 <p><b><a href="http://cscott.net">http://cscott.net</a></b></p>
29813 <p><b><a href="http://cscott.net">http://cscott.net</a> </b></p>
29814 <p><b><a href="http://cscott.net">http://cscott.net</a>x</b></p>
29815 <p><a href="http://cscott.net">http://cscott.net</a>x</p>
29816 !! wikitext
29817 http://cscott.net'''foo'''
29818
29819 http://cscott.net<b>foo</b>
29820
29821 '''http://cscott.net'''
29822
29823 '''http://cscott.net '''
29824
29825 '''http://cscott.net<nowiki/>x'''
29826
29827 http://cscott.net<nowiki/>x
29828 !! end
29829
29830 !! test
29831 WTS of autolinks with nowikis (round-trip)
29832 !! wikitext
29833 x<nowiki/>http://cscott.net<nowiki/>x
29834 !! html/parsoid
29835 <p>x<a rel="mw:ExtLink" class="external free" href="http://cscott.net">http://cscott.net</a>x</p>
29836 !! end
29837
29838 # this is the "easy" test because it leaves in place all the
29839 # data-parsoid information indicating this is an autolink
29840 !! test
29841 WTS of autolinks with escapes (editing)
29842 !! options
29843 parsoid={
29844 "modes": ["wt2wt"],
29845 "changes": [
29846 [ "span", "remove" ]
29847 ]
29848 }
29849 !! wikitext
29850 x<nowiki/>http://cscott.net<nowiki/>x
29851 !! wikitext/edited
29852 x<nowiki/>http://cscott.net<nowiki/>x
29853 !! end
29854
29855 !! test
29856 WTS of edited autolink-like text (T103364)
29857 !! options
29858 parsoid={
29859 "modes": ["wt2wt"],
29860 "changes": [
29861 [ "span[typeof]", "removeAttr", "typeof" ]
29862 ]
29863 }
29864 !! wikitext
29865 Not a link: <nowiki>http://example.com</nowiki>.
29866 !! wikitext/edited
29867 Not a link: <span><nowiki>http://example.com</nowiki></span>.
29868 !! end
29869
29870 !! test
29871 WTS of newly-authored autolink-like text (T103364)
29872 !! options
29873 parsoid=html2wt
29874 !! html/parsoid
29875 <p>http://example.com is not a link.</p>
29876 !! wikitext
29877 <nowiki>http://example.com</nowiki> is not a link.
29878 !! end
29879
29880 !! test
29881 WTS of autolink-like text after an autolink (T108563)
29882 !! options
29883 parsoid=html2wt
29884 !! html/parsoid
29885 <p><a rel="mw:ExtLink" href="http://example.com">http://example.com</a> http://example.com is not a link.</p>
29886 !! wikitext
29887 http://example.com <nowiki>http://example.com</nowiki> is not a link.
29888 !! end
29889
29890 !! test
29891 Magic links inside links (not autolinked)
29892 !! wikitext
29893 [[Foo|http://example.com]]
29894 [[Foo|RFC 1234]]
29895 [[Foo|PMID 1234]]
29896 [[Foo|ISBN 123456789x]]
29897
29898 [http://foo.com http://example.com]
29899 [http://foo.com RFC 1234]
29900 [http://foo.com PMID 1234]
29901 [http://foo.com ISBN 123456789x]
29902 !! html+tidy
29903 <p><a href="/wiki/Foo" title="Foo">http://example.com</a>
29904 <a href="/wiki/Foo" title="Foo">RFC 1234</a>
29905 <a href="/wiki/Foo" title="Foo">PMID 1234</a>
29906 <a href="/wiki/Foo" title="Foo">ISBN 123456789x</a>
29907 </p><p><a rel="nofollow" class="external text" href="http://foo.com">http://example.com</a>
29908 <a rel="nofollow" class="external text" href="http://foo.com">RFC 1234</a>
29909 <a rel="nofollow" class="external text" href="http://foo.com">PMID 1234</a>
29910 <a rel="nofollow" class="external text" href="http://foo.com">ISBN 123456789x</a>
29911 </p>
29912 !! html/parsoid
29913 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">http://example.com</a>
29914 <a rel="mw:WikiLink" href="./Foo" title="Foo">RFC 1234</a>
29915 <a rel="mw:WikiLink" href="./Foo" title="Foo">PMID 1234</a>
29916 <a rel="mw:WikiLink" href="./Foo" title="Foo">ISBN 123456789x</a></p>
29917
29918 <p><a rel="mw:ExtLink" class="external text" href="http://foo.com">http://example.com</a>
29919 <a rel="mw:ExtLink" class="external text" href="http://foo.com">RFC 1234</a>
29920 <a rel="mw:ExtLink" class="external text" href="http://foo.com">PMID 1234</a>
29921 <a rel="mw:ExtLink" class="external text" href="http://foo.com">ISBN 123456789x</a></p>
29922 !! end
29923
29924 !! test
29925 Magic links inside image captions (autolinked)
29926 !! wikitext
29927 [[File:Foobar.jpg|thumb|http://example.com]]
29928 [[File:Foobar.jpg|thumb|RFC 1234]]
29929 [[File:Foobar.jpg|thumb|PMID 1234]]
29930 [[File:Foobar.jpg|thumb|ISBN 123456789x]]
29931 !! html+tidy
29932 <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" decoding="async" 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 rel="nofollow" class="external free" href="http://example.com">http://example.com</a></div></div></div>
29933 <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" decoding="async" 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 class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc1234">RFC 1234</a></div></div></div>
29934 <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" decoding="async" 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 class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a></div></div></div>
29935 <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" decoding="async" 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/123456789X" class="internal mw-magiclink-isbn">ISBN 123456789x</a></div></div></div>
29936 !! html/parsoid
29937 <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" class="external free" href="http://example.com">http://example.com</a></figcaption></figure>
29938 <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="https://tools.ietf.org/html/rfc1234" rel="mw:ExtLink" class="external mw-magiclink">RFC 1234</a></figcaption></figure>
29939 <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" class="external mw-magiclink">PMID 1234</a></figcaption></figure>
29940 <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>
29941 !! end
29942
29943 !! test
29944 WTS of magic word text (T109371)
29945 !! options
29946 parsoid=html2wt
29947 !! html/parsoid
29948 <p>RFC 1234</p>
29949 <p><a href="http://foo.com" rel="mw:ExtLink">RFC 1234</a></p>
29950 <p><a href="./Foo" rel="mw:WikiLink">RFC 1234</a></p>
29951 !! wikitext
29952 <nowiki>RFC 1234</nowiki>
29953
29954 [http://foo.com RFC 1234]
29955
29956 [[Foo|RFC 1234]]
29957 !! end
29958
29959 !! test
29960 Edited Redirect link should emit a non-piped wikitext link
29961 !! options
29962 parsoid=html2wt
29963 !! html/parsoid
29964 <link rel="mw:PageProp/redirect" href="Bar" data-parsoid='{"a":{"href":"./Foo"},"sa":{"href":"Foo"}}'>
29965 !! wikitext
29966 #REDIRECT [[Bar]]
29967 !! end
29968
29969 !! test
29970 T75121: Infer extension name from typeOf if data-mw is not present
29971 !! options
29972 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
29973 !! html/parsoid
29974 <div typeOf="mw:Extension/foo"></div>
29975 !! wikitext
29976 <foo />
29977 !! end
29978
29979 # Note that the <p> wrapping isn't present in PHP parser output
29980 # The important thing for this test is that P-wrapping doesn't
29981 # interfere with the <nowiki> protection for leading - in <td>
29982 # (which isn't necessary for <th>).
29983 !! test
29984 T88318: p-wrapped dash in table.
29985 !! options
29986 parsoid=html2wt,wt2wt
29987 !! html/parsoid
29988 <table><tbody>
29989 <tr><th><p>-</p></th><th><p>- </p></th></tr>
29990 <tr><td><p>-</p></td><td><p>- </p></td></tr>
29991 <tr><td><small>-</small></td><td><br/><p>-</p></td><td><br/>-</td></tr>
29992 </tbody></table>
29993 !! wikitext
29994 {|
29995 !-
29996 !-
29997 |-
29998 |<nowiki>-</nowiki>
29999 |<nowiki>- </nowiki>
30000 |-
30001 |<small>-</small>
30002 |<br />
30003 -
30004 |<br />-
30005 |}
30006 !! html/php+tidy
30007 <table>
30008 <tbody><tr>
30009 <th>-
30010 </th>
30011 <th>-
30012 </th></tr>
30013 <tr>
30014 <td>-
30015 </td>
30016 <td>-
30017 </td></tr>
30018 <tr>
30019 <td><small>-</small>
30020 </td>
30021 <td><br />
30022 <p>-
30023 </p>
30024 </td>
30025 <td><br />-
30026 </td></tr></tbody></table>
30027 !! end
30028
30029 !! test
30030 T149209: WTS: Handle newlines in table cells properly
30031 !! options
30032 parsoid=html2wt
30033 !! html/parsoid
30034 <table>
30035 <tbody>
30036 <tr><td>a
30037 b
30038 </td><td data-parsoid='{"stx":"row"}'>c</td></tr>
30039 <tr><td><p>x</p>
30040 </td><td data-parsoid='{"stx":"row", "startTagSrc": "{{!}}{{!}}"}'>y</td></tr>
30041 </tbody></table>
30042 <table>
30043 <tbody>
30044 <tr><th>a
30045 b
30046 </th><th data-parsoid='{"stx":"row"}'>c</th></tr>
30047 <tr><th><p>x</h>
30048 </th><th data-parsoid='{"stx":"row"}'>y</th></tr>
30049 </tbody></table>
30050 !! wikitext
30051 {|
30052 |a
30053 b
30054 |c
30055 |-
30056 |x
30057 {{!}}y
30058 |}
30059 {|
30060 !a
30061 b
30062 !c
30063 |-
30064 !x
30065 !y
30066 |}
30067 !! end
30068
30069 !! test
30070 T149209: Selser: Handle newlines in table cells properly
30071 !! options
30072 parsoid={
30073 "modes": ["selser"],
30074 "changes": [
30075 [ "#h1", "html", "a\nb\n" ],
30076 [ "#h2", "html", "a\nb\n" ],
30077 [ "#c1", "html", "a\nb\n" ],
30078 [ "#c2", "html", "<p>a</p>" ],
30079 [ "#c3", "html", "<p>a</p>" ],
30080 [ "#c4", "html", "edit-me<p>a</p>" ]
30081 ]
30082 }
30083 !! wikitext
30084 {|
30085 ! id="h1" |edit-me!!1
30086 |-
30087 ! id="h2" |edit-me||2
30088 |-
30089 | id="c1" |edit-me||3
30090 |-
30091 | id="c2" |edit-me||4
30092 |-
30093 | id="c3" |edit-me||p||q||r
30094 |-
30095 | id="c4" |edit-me||p||q||r
30096 |}
30097 !! wikitext/edited
30098 {|
30099 ! id="h1" |a
30100 b
30101 !1
30102 |-
30103 ! id="h2" |a
30104 b
30105 !2
30106 |-
30107 | id="c1" |a
30108 b
30109 |3
30110 |-
30111 | id="c2" |a
30112 |4
30113 |-
30114 | id="c3" |a
30115 |p||q||r
30116 |-
30117 | id="c4" |edit-me
30118 a
30119 |p||q||r
30120 |}
30121 !! end
30122
30123 !! test
30124 HTML id attribute with Parsoid-like element ids should not be serialized to wikitext
30125 !! options
30126 parsoid=html2wt
30127 !! html/parsoid
30128 <table id='mwAb'>
30129 <td id='mwAc'>foo</td>
30130 <td id='serialize-this'>bar</td>
30131 </table>
30132 !! wikitext
30133 {|
30134 |foo
30135 | id="serialize-this" |bar
30136 |}
30137 !! end
30138
30139 !! test
30140 Parsoid-like element ids should not be serialized to wikitext unless shadowed
30141 !! options
30142 parsoid=html2wt
30143 !! html/parsoid
30144 <div id="mwAQ" data-parsoid='{"stx":"html","a":{"id":"mwAQ"},"sa":{"id":"hello"}}'>ok</div>
30145 !! wikitext
30146 <div id="hello">ok</div>
30147 !! end
30148
30149 !! test
30150 Testing serialization after deletion in references
30151 !! options
30152 parsoid={
30153 "modes": ["wt2wt"],
30154 "changes": [
30155 ["#x", "remove"]
30156 ]
30157 }
30158 !! wikitext
30159 hi <ref><div id="x">ho</div></ref>
30160
30161 <references />
30162 !! wikitext/edited
30163 hi <ref></ref>
30164
30165 <references />
30166 !! end
30167
30168 !!test
30169 Testing serialization after deletion of table cells
30170 !!options
30171 parsoid={
30172 "modes": ["wt2wt", "selser"],
30173 "changes": [
30174 ["#x", "remove"]
30175 ]
30176 }
30177 !!wikitext
30178 {|
30179 !h1 !!h2 !!h3
30180 | id="x" |c1 {{!}}{{!}}{{!}}c2 |||c3
30181 |}
30182 !! wikitext/edited
30183 {|
30184 !h1!!h2!!h3
30185 |c2|||c3
30186 |}
30187 !!end
30188
30189 !! test
30190 Testing selser after addition of new row before first row (T125419)
30191 !! options
30192 parsoid={
30193 "modes": ["wt2wt", "selser"],
30194 "changes": [
30195 [ "tr", "before", "<tr><td>X</td></tr>" ]
30196 ]
30197 }
30198 !! wikitext
30199 {|
30200 |a
30201 |}
30202 !! wikitext/edited
30203 {|
30204 |X
30205 |-
30206 |a
30207 |}
30208 !! end
30209
30210 !! test
30211 Serialize new table rows in a HTML table using HTML tags
30212 !! options
30213 parsoid={
30214 "modes": ["wt2wt", "selser"],
30215 "changes": [
30216 [ "tr", "before", "<tr><td>X</td></tr>" ]
30217 ]
30218 }
30219 !! wikitext
30220 <table><tr><td>a</td></tr></table>
30221 !! wikitext/edited
30222 <table><tr><td>X</td></tr><tr><td>a</td></tr></table>
30223 !! end
30224
30225 !! test
30226 Serialize new table cells in a HTML row using HTML tags
30227 !! options
30228 parsoid={
30229 "modes": ["wt2wt", "selser"],
30230 "changes": [
30231 [ "td", "before", "<td>X</td>" ]
30232 ]
30233 }
30234 !! wikitext
30235 <table><tr><td>a</td></tr></table>
30236 !! wikitext/edited
30237 <table><tr><td>X</td><td>a</td></tr></table>
30238 !! end
30239
30240 !! test
30241 Serialize wikitext list items as HTML list items when embedded in a HTML list
30242 !! options
30243 parsoid=html2wt
30244 !! html/parsoid
30245 <ul data-parsoid='{"stx": "html"}'>
30246 <li data-parsoid='{}'>a</li>
30247 <li>b</li>
30248 </ul>
30249 !! wikitext
30250 <ul>
30251 <li>a</li>
30252 <li>b</li>
30253 </ul>
30254 !! html/php+tidy
30255 <ul>
30256 <li>a</li>
30257 <li>b</li>
30258 </ul>
30259 !! end
30260
30261 # Nested list should be inside <li>, that is
30262 # <ul><li>foo<ul>..</ul></li></ul> instead of
30263 # <ul><li>foo</li><ul>..</ul></ul>
30264 # See https://stackoverflow.com/questions/5899337/proper-way-to-make-html-nested-list
30265 !! test
30266 Wikitext lists can be nested inside HTML lists
30267 !! options
30268 parsoid=html2wt
30269 !! html/parsoid
30270 <ul data-parsoid='{"stx": "html"}'>
30271 <li data-parsoid='{"stx": "html"}'>a
30272 <ul><li>b</li></ul>
30273 </li>
30274 </ul>
30275
30276 <ul data-parsoid='{"stx": "html"}'>
30277 <li>x
30278 <ul><li>y</li></ul>
30279 </li>
30280 </ul>
30281 !! wikitext
30282 <ul>
30283 <li>a
30284 * b
30285 </li>
30286 </ul>
30287
30288 <ul>
30289 <li>x
30290 * y
30291 </li>
30292 </ul>
30293 !! html/php+tidy
30294 <ul>
30295 <li>a
30296 <ul><li>b</li></ul>
30297 </li>
30298 </ul>
30299 <ul>
30300 <li>x
30301 <ul><li>y</li></ul>
30302 </li>
30303 </ul>
30304 !! end
30305
30306 !! test
30307 WTS change modes
30308 !! options
30309 parsoid={
30310 "modes": ["wt2wt"],
30311 "changes": [
30312 [ "#xyz", "before", "<b>before</b> stuff " ],
30313 [ "#xyz", "after", " stuff <i>after</i>" ],
30314 [ "#xyz", "html", "x <b>y</b> z" ]
30315 ]
30316 }
30317 !! wikitext
30318 <span id="xyz">hello</span>
30319 !! wikitext/edited
30320 '''before''' stuff <span id="xyz">x '''y''' z</span> stuff ''after''
30321 !! end
30322
30323 !! test
30324 Never serialize a-tag as html, regardless of what data-parsoid has to say
30325 !! options
30326 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
30327 !! html/parsoid
30328 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"html"}'>Foo</a>
30329 !! wikitext
30330 [[Foo]]
30331 !! end
30332
30333 ## SSS FIXME: This is broken output nevertheless.
30334 ## What might be a reasonable non-broken output for this?
30335 ## This is an edge case unlikely to be seen in production
30336 ## that I am not wasting more time on this right now.
30337 !! test
30338 Never serialize a-tag as html, no matter what attributes it has
30339 !! options
30340 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
30341 !! html/parsoid
30342 <a bad='true' href='http://boo.org'><img src='http://boohoo.org' /></a>
30343 !! wikitext
30344 [http://boo.org http://boohoo.org]
30345 !! end
30346
30347 # Misnested is an indication that selser can reuse the source but these have
30348 # shown to sneak through on occasion. See T101768.
30349 # The original wikitext here is: [http://test.com [[one]] two three]
30350 !! test
30351 Strip span tags added to mark misnested links
30352 !! options
30353 parsoid=html2wt
30354 !! html/parsoid
30355 <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>
30356 !! wikitext
30357 [http://test.com][[one]] two three
30358 !! end
30359
30360 !! test
30361 Catch regression when unpacking misnested links
30362 !! options
30363 parsoid=wt2html
30364 !! wikitext
30365 {{echo|hi}}[http://example.com [[ho]]]
30366 !! html/parsoid
30367 <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" class="external autonumber" href="http://example.com"></a><a rel="mw:WikiLink" href="./Ho" title="Ho" data-parsoid='{"misnested":true}'>ho</a></p>
30368 !! end
30369
30370 !! test
30371 Catch regression when unpacking with trailing content
30372 !! wikitext
30373 {{echo|Foo <references/> bar}}
30374 !! html/parsoid
30375 <p about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"Foo &lt;references/> bar"}},"i":0}}]}'>Foo </p><ol class="mw-references references" typeof="mw:Extension/references" about="#mwt2" data-mw='{"name":"references","attrs":{}}'></ol><p about="#mwt2"> bar</p>
30376 !! end
30377
30378 !! test
30379 Use data-parsoid.firstWikitextNode to compute newline constraints for template content
30380 !! options
30381 parsoid=html2wt
30382 !! html/parsoid
30383 <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|}"]}'>
30384 <tbody><tr><td>d
30385 </td></tr>
30386 </tbody></table>
30387 !! wikitext
30388 {{echo|a}}
30389 {|{{echo|c
30390 {{!}}d
30391 }}
30392 |}
30393 !! end
30394
30395 ## This test verifies the presence and computation of this attribute indirectly
30396 ## by making an edit and ensuring that the serialization is correct (which it would be
30397 ## only if firstWikitextNode is properly set).
30398 !! test
30399 data-parsoid.firstWikitextNode should be computed properly in the presence of fostered content
30400 !! options
30401 parsoid= {
30402 "modes": ["wt2wt"],
30403 "changes": [
30404 [ "div#x", "remove" ],
30405 [ "div", "before", "<div>new</div>" ]
30406 ]
30407 }
30408 !! wikitext
30409 <div id="x">foo</div>
30410 {|
30411 {{echo|<div>boo</div>
30412 {{!}}b}}
30413 |c
30414 |}
30415 !! wikitext/edited
30416
30417 <div>new</div>
30418 {|
30419 {{echo|<div>boo</div>
30420 {{!}}b}}
30421 |c
30422 |}
30423 !! end
30424
30425 # --------------------------------------------
30426 # Tests spec'ing wikitext serialization norms |
30427 # --------------------------------------------
30428
30429 !! test
30430 Serialize multi-line indent-pre starting with wikitext syntax
30431 !! options
30432 parsoid=html2wt
30433 !! html/parsoid
30434 <pre>* 1
30435 ** 2
30436 * 3</pre>
30437 !! wikitext
30438 * 1
30439 ** 2
30440 * 3
30441 !! end
30442
30443 !! test
30444 1. Categories should always be serialized on their own line
30445 !! options
30446 parsoid=html2wt
30447 !! html/parsoid
30448 foo<link rel="mw:PageProp/Category" href="./Category:Foo">bar
30449 !! wikitext
30450 foo
30451 [[Category:Foo]]
30452 bar
30453 !! end
30454
30455 !! test
30456 2. Categories that are part of templates should not introduce a line break
30457 !! wikitext
30458 foo {{echo|<span>bar</span> [[Category:baz]]}} bar
30459 !! html/parsoid
30460 <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>
30461 !! end
30462
30463 # Careful while editing these next 2 tests. There are \u200f characters
30464 # before and after the <link> tags in the HTML and following some
30465 # of the categories in wikitext
30466 # Do not remove these characters in edits.
30467 #
30468 # As part of the serialization, these bidi characters will get stripped.
30469 !! test
30470 RTL (\u200f) and LTR (\u200e) markers around category tags should be stripped
30471 !! options
30472 parsoid={
30473 "modes": ["html2wt"],
30474 "scrubWikitext": true
30475 }
30476 !! html/parsoid
30477 <p>‏<link rel="mw:PageProp/Category" href="./קטגוריה:טקסים" />‏
30478 ‏<link rel="mw:PageProp/Category" href="./קטגוריה:_שיטות_משפט" />‏</p>
30479 !! wikitext
30480 [[קטגוריה:טקסים]]
30481 [[קטגוריה: שיטות משפט]]
30482 !! end
30483
30484 !! test
30485 RTL (\u200f) and LTR (\u200e) markers should not be stripped if followed by a text node
30486 !! options
30487 parsoid={
30488 "modes": ["html2wt"],
30489 "scrubWikitext": true
30490 }
30491 !! html/parsoid
30492 <p>‏<link rel="mw:PageProp/Category" href="./קטגוריה:טקסים" />‏y</p>
30493 !! wikitext
30494 [[קטגוריה:טקסים]]
30495 ‏y
30496 !! end
30497
30498 !! test
30499 Lists: Add space after bullets
30500 !! options
30501 parsoid=html2wt
30502 !! html/parsoid
30503 <ul>
30504 <li>foo</li>
30505 <li> bar</li>
30506 <li><span> baz</span></li>
30507 </ul>
30508 !! wikitext
30509 * foo
30510 * bar
30511 * <span> baz</span>
30512 !! end
30513
30514 !! test
30515 1. Headings: Add space before/after == (T53744)
30516 !! options
30517 parsoid=html2wt
30518 !! html/parsoid
30519 <h2>foo</h2>
30520 <h2> bar</h2>
30521 <h2>baz </h2>
30522 <h2><span> baz</span></h2>
30523 !! wikitext
30524 == foo ==
30525
30526 == bar ==
30527
30528 == baz ==
30529
30530 == <span> baz</span> ==
30531 !! end
30532
30533 !! test
30534 2. Headings: Add space before/after == even after hoisted content
30535 !! options
30536 parsoid={
30537 "modes": ["html2wt"],
30538 "scrubWikitext": true
30539 }
30540 !! html/parsoid
30541 <h2> <link href="./Category:A2" rel="mw:PageProp/Category" />ok</h2>
30542 !! wikitext
30543 [[Category:A2]]
30544
30545 == ok ==
30546 !! end
30547
30548 !! test
30549 1. Headings: suppress newly created empty headings
30550 !! options
30551 parsoid={
30552 "modes": ["html2wt"],
30553 "scrubWikitext": true
30554 }
30555 !! html/parsoid
30556 <h2></h2>
30557 !! wikitext
30558 !! end
30559
30560 !! test
30561 2. Headings: don't suppress empty headings if scrubWikitext is false
30562 !! options
30563 parsoid=html2wt
30564 !! html/parsoid
30565 <h2></h2>
30566 !! wikitext
30567 ==<nowiki/>==
30568 !! end
30569
30570 !! test
30571 3. Headings: suppress empty headings on edits
30572 !! options
30573 parsoid={
30574 "modes": ["selser"],
30575 "scrubWikitext": true,
30576 "changes": [
30577 [ "#x", "remove"]
30578 ]
30579 }
30580 !! wikitext
30581 ==<span id="x">foo</span>==
30582 !! wikitext/edited
30583 !! end
30584
30585 !! test
30586 Headings: Replace <br/> with a single whitespace char (when scrubWikitext = true)
30587 !! options
30588 parsoid={
30589 "modes": ["html2wt"],
30590 "scrubWikitext": true
30591 }
30592 !! html/parsoid
30593 <h2>foo<br/>bar</h2>
30594 <h2>foo <span><br/>bar</span> baz</h2>
30595 !! wikitext
30596 == foo bar ==
30597
30598 == foo <span> bar</span> baz ==
30599 !! end
30600
30601 !! test
30602 Headings: Replace <br/> with a single whitespace char (when scrubWikitext = false)
30603 !! options
30604 parsoid={
30605 "modes": ["html2wt"],
30606 "scrubWikitext": false
30607 }
30608 !! html/parsoid
30609 <h2>foo<br/>bar</h2>
30610 !! wikitext
30611 == foo<br />bar ==
30612 !! end
30613
30614 !! test
30615 1. WT Quote Tags: suppress newly created empty style tags
30616 !! options
30617 parsoid={
30618 "modes": ["html2wt"],
30619 "scrubWikitext": true
30620 }
30621 !! html/parsoid
30622 <i></i><b></b>
30623 !! wikitext
30624 !! end
30625
30626 !! test
30627 2. WT Quote Tags: don't suppress empty style tags if scrubWikitext is false
30628 !! options
30629 parsoid=html2wt
30630 !! html/parsoid
30631 <i></i><b></b>
30632 !! wikitext
30633 ''<nowiki/>'''''<nowiki/>'''
30634 !! end
30635
30636 !! test
30637 3. WT Quote Tags: suppress empty style tags on edits
30638 !! options
30639 parsoid={
30640 "modes": ["selser"],
30641 "scrubWikitext": true,
30642 "changes": [
30643 [ "#x", "remove"]
30644 ]
30645 }
30646 !! wikitext
30647 '''<span id="x">foo</span>'''
30648 !! wikitext/edited
30649 !! end
30650
30651 !! test
30652 1. Anchors: suppress newly created empty anchors
30653 !! options
30654 parsoid={
30655 "modes": ["html2wt"],
30656 "scrubWikitext": true
30657 }
30658 !! html/parsoid
30659 <a rel="mw:WikiLink" href="./Test" title="Test"></a>
30660 !! wikitext
30661 !! end
30662
30663 !! test
30664 2. Anchors: don't suppress empty anchors if scrubWikitext is false
30665 !! options
30666 parsoid={
30667 "modes": ["html2wt"],
30668 "scrubWikitext": false
30669 }
30670 !! html/parsoid
30671 <a rel="mw:WikiLink" href="./Test" title="Test"></a>
30672 !! wikitext
30673 [[Test|<nowiki/>]]
30674 !! end
30675
30676 !! test
30677 3. Anchors: suppress empty anchors on edits
30678 !! options
30679 parsoid={
30680 "modes": ["selser"],
30681 "scrubWikitext": true,
30682 "changes": [
30683 [ "#x", "remove"]
30684 ]
30685 }
30686 !! wikitext
30687 [[Test|<span id="x">foo</span>]]
30688 !! wikitext/edited
30689 !! end
30690
30691 !! test
30692 3a. Anchors: do not suppress numbered extlinks
30693 !! options
30694 parsoid={
30695 "modes": ["wt2wt"],
30696 "scrubWikitext": true
30697 }
30698 !! wikitext
30699 [http://foo.com]
30700 !! html/parsoid
30701 <a rel="mw:ExtLink" href="http://foo.com"></a>
30702 !! end
30703
30704 !! test
30705 3b. Anchors: do not suppress numbered extlinks
30706 !! options
30707 parsoid={
30708 "modes": ["wt2wt"],
30709 "scrubWikitext": true,
30710 "changes": [
30711 [ "#x", "remove"]
30712 ]
30713 }
30714 !! wikitext
30715 [http://foo.com <span id="x">foo</span>]
30716 !! wikitext/edited
30717 [http://foo.com]
30718 !! end
30719
30720 !!test
30721 Normalizations should be restricted to edited content
30722 !!options
30723 parsoid={
30724 "modes": ["selser"],
30725 "scrubWikitext": true,
30726 "changes": [
30727 [ "h1", "before", "<i></i>"]
30728 ]
30729 }
30730 !!wikitext
30731 a
30732 = =
30733 b
30734 !!wikitext/edited
30735 a
30736 = =
30737 b
30738 !!end
30739
30740 !! test
30741 1. Multiple normalizations (html2wt)
30742 !! options
30743 parsoid={
30744 "modes": ["html2wt"],
30745 "scrubWikitext": true
30746 }
30747 !! html/parsoid
30748 <h2><i></i></h2>
30749 <p><a href='Foo' rel='mw:WikiLink'>foo<i></i>
30750 </a><b><i></i></b>x</p>
30751 !! wikitext
30752
30753 [[foo]]
30754 x
30755
30756 !! end
30757
30758 !! test
30759 2. Multiple normalizations (selser)
30760 !! options
30761 parsoid={
30762 "modes": ["selser"],
30763 "scrubWikitext": true,
30764 "changes": [
30765 [ "#x", "after", "<h1><i></i></h1>\n<p> bar<b></b></p>"]
30766 ]
30767 }
30768 !! wikitext
30769 <div id="x">foo</div>
30770 !! wikitext/edited
30771 <div id="x">foo</div>
30772 bar
30773 !! end
30774
30775 !! test
30776 1. Indent Pre Nowiki: suppress whitespace at the start of new paragraph
30777 !! options
30778 parsoid={
30779 "modes": ["html2wt"],
30780 "scrubWikitext": true
30781 }
30782 !! html/parsoid
30783 <p> hi</p>
30784 <p> hello</p>
30785 !! wikitext
30786 hi
30787
30788 hello
30789 !! end
30790
30791 !! test
30792 2. Indent Pre Nowiki: don't suppress whitespace at the start of new paragraph if scrubWikitext is false
30793 !! options
30794 parsoid=html2wt
30795 !! html/parsoid
30796 <p> hi</p>
30797 <p> hello</p>
30798 !! wikitext
30799 <nowiki> </nowiki>hi
30800
30801 <nowiki> </nowiki> hello
30802 !! end
30803
30804 !! test
30805 3. Indent Pre Nowiki: suppress whitespace after newlines in new paragraph or table cell
30806 !! options
30807 parsoid={
30808 "modes": ["html2wt"],
30809 "scrubWikitext": true
30810 }
30811 !! html/parsoid
30812 <p>Foo
30813 bar
30814 baz</p>
30815
30816 <table><tr><td>Foo
30817 bar
30818 baz bang</td></tr></table>
30819
30820 <p><!--boo--> foo
30821 bar</p>
30822
30823 <p> foo
30824 bar<span>boo</span></p>
30825 !! wikitext
30826 Foo
30827 bar
30828 baz
30829
30830 {|
30831 |Foo
30832 bar
30833 baz bang
30834 |}
30835
30836 <!--boo-->foo
30837 bar
30838
30839 foo
30840 bar<span>boo</span>
30841 !! end
30842
30843 !! test
30844 4. Indent Pre Nowiki: suppress leading whitespace in edited paragraphs
30845 !! options
30846 parsoid={
30847 "modes": ["selser"],
30848 "scrubWikitext": true,
30849 "changes": [
30850 [ "p", "html", " a\n b" ]
30851 ]
30852 }
30853 !! wikitext
30854 xyz
30855 !! wikitext/edited
30856 a
30857 b
30858 !! end
30859
30860 !! test
30861 1. New links that end in spaces
30862 !! options
30863 parsoid={
30864 "modes": ["html2wt"],
30865 "scrubWikitext": false
30866 }
30867 !! html/parsoid
30868 <p><a rel="mw:WikiLink" href="./Berlin" title="Berlin">Berlin </a>is the capital of Germany.</p>
30869 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo </a><b>bar</b></p>
30870 <p><a rel="mw:WikiLink" href="./Boston" title="Boston">Boston </a> is a city.</p>
30871 !! wikitext
30872 [[Berlin ]]<nowiki/>is the capital of Germany.
30873
30874 [[Foo ]]'''bar'''
30875
30876 [[Boston ]] is a city.
30877 !! end
30878
30879 !! test
30880 2. New links that end in spaces
30881 !! options
30882 parsoid={
30883 "modes": ["html2wt"],
30884 "scrubWikitext": true
30885 }
30886 !! html/parsoid
30887 <p><a rel="mw:WikiLink" href="./Berlin" title="Berlin">Berlin </a>is the capital of Germany.</p>
30888 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo </a><b>bar</b></p>
30889 <p><a rel="mw:WikiLink" href="./Boston" title="Boston">Boston </a> is a city.</p>
30890 !! wikitext
30891 [[Berlin]] is the capital of Germany.
30892
30893 [[Foo]] '''bar'''
30894
30895 [[Boston]] is a city.
30896 !! end
30897
30898 !! test
30899 1. Table cells with escapable prefixes
30900 !! options
30901 parsoid={
30902 "modes": ["html2wt"],
30903 "scrubWikitext": false
30904 }
30905 !! html/parsoid
30906 <table>
30907 <tr><td>a</td></tr>
30908 <tr><td>-</td></tr>
30909 <tr><td>+</td></tr>
30910 <tr><td>}</td></tr>
30911 </table>
30912 !! wikitext
30913 {|
30914 |a
30915 |-
30916 |<nowiki>-</nowiki>
30917 |-
30918 |<nowiki>+</nowiki>
30919 |-
30920 |<nowiki>}</nowiki>
30921 |}
30922 !! end
30923
30924 !! test
30925 2. Table cells with escapable prefixes
30926 !! options
30927 parsoid={
30928 "modes": ["html2wt"],
30929 "scrubWikitext": true
30930 }
30931 !! html/parsoid
30932 <table>
30933 <tr><td>a</td></tr>
30934 <tr><td>-</td></tr>
30935 <tr><td>+</td></tr>
30936 <tr><td>}</td></tr>
30937 </table>
30938 !! wikitext
30939 {|
30940 |a
30941 |-
30942 | -
30943 |-
30944 | +
30945 |-
30946 | }
30947 |}
30948 !! end
30949
30950 !! test
30951 3a. Table cells with escapable prefixes after edits
30952 !! options
30953 parsoid={
30954 "modes": ["selser"],
30955 "scrubWikitext": true,
30956 "changes": [
30957 [ "table tbody tr:first-child td:first-child", "remove"]
30958 ]
30959 }
30960 !! wikitext
30961 {|
30962 |a||-
30963 |}
30964 !! wikitext/edited
30965 {|
30966 | -
30967 |}
30968 !! end
30969
30970 !! test
30971 3b. Table cells with escapable prefixes after edits
30972 !! options
30973 parsoid={
30974 "modes": ["selser"],
30975 "scrubWikitext": true,
30976 "changes": [
30977 [ "table tbody tr:first-child td:first-child", "html", "-" ],
30978 [ "#x", "remove" ]
30979 ]
30980 }
30981 !! wikitext
30982 {|
30983 |pqr
30984 |<span id="x">foo</span>+
30985 |}
30986 !! wikitext/edited
30987 {|
30988 | -
30989 | +
30990 |}
30991 !! end
30992
30993 # FIXME: This test will fail because
30994 # normalization doesn't realize that the id attribute
30995 # will eliminate the escapable scenario
30996 !! test
30997 4a. Table cells without escapable prefixes after edits
30998 !! options
30999 parsoid={
31000 "modes": ["selser"],
31001 "scrubWikitext": true,
31002 "changes": [
31003 [ "#x", "html", "-" ]
31004 ]
31005 }
31006 !! wikitext
31007 {|
31008 | id="x" |abcd
31009 |}
31010 !! wikitext/edited
31011 {|
31012 | id="x" |-
31013 |}
31014 !! end
31015
31016 ## This tests normalizer's ability to discriminate between
31017 ## cells having identical content.
31018 !! test
31019 4b. Table cells without escapable prefixes after edits
31020 !! options
31021 parsoid={
31022 "modes": ["selser"],
31023 "scrubWikitext": true,
31024 "changes": [
31025 [ "td", "html", "-" ]
31026 ]
31027 }
31028 !! wikitext
31029 {|
31030 |a||b
31031 |}
31032 !! wikitext/edited
31033 {|
31034 | -||-
31035 |}
31036 !! end
31037
31038 ## This tests normalizer's ability to not be tripped by
31039 ## comments (and whitespace)
31040 !! test
31041 4c. Table cells without escapable prefixes after edits
31042 !! options
31043 parsoid={
31044 "modes": ["selser"],
31045 "scrubWikitext": true,
31046 "changes": [
31047 [ "table tbody tr td:first-child", "remove" ]
31048 ]
31049 }
31050 !! wikitext
31051 {|
31052 |-
31053 <!--foo--> |a||-
31054 |}
31055 !! wikitext/edited
31056 {|
31057 |-
31058 <!--foo--> | -
31059 |}
31060 !! end
31061
31062 ## This tests normalizer's ability to handle HTML cells
31063 !! test
31064 4d. Table cells without escapable prefixes after edits
31065 !! options
31066 parsoid={
31067 "modes": ["selser"],
31068 "scrubWikitext": true,
31069 "changes": [
31070 [ "td", "html", "-" ]
31071 ]
31072 }
31073 !! wikitext
31074 <table>
31075 <tr><td>a</td></tr>
31076 </table>
31077 !! wikitext/edited
31078 <table>
31079 <tr><td>-</td></tr>
31080 </table>
31081 !! end
31082
31083 ## T111151 Remove font elements without attributes
31084 !! test
31085 5a. font tags without attributes should be dropped in scrubWikitext mode
31086 !! options
31087 parsoid={
31088 "modes": ["html2wt"],
31089 "scrubWikitext": true
31090 }
31091 !! html/parsoid
31092 <font>foo</font>
31093 <font><font>bar</font></font>
31094 <font class="x">boo</font>
31095 !! wikitext
31096 foo
31097 bar
31098 <font class="x">boo</font>
31099 !! end
31100
31101 !! test
31102 5b. font tags should not be dropped without scrubWikitext being enabled
31103 !! options
31104 parsoid={
31105 "modes": ["html2wt"],
31106 "scrubWikitext": false
31107 }
31108 !! html/parsoid
31109 <font>foo</font>
31110 !! wikitext
31111 <font>foo</font>
31112 !! end
31113
31114 !! test
31115 Ignore empty <p></p> when scrubWikitext is false
31116 !! options
31117 parsoid={
31118 "modes": ["html2wt"],
31119 "scrubWikitext": false
31120 }
31121 !! html/parsoid
31122 <div>1</div>
31123 <p>a</p><p></p><p>b</p>
31124 <div>2</div>
31125 <p>a</p>
31126 <p></p>
31127 <p>b</p>
31128 <div>3</div>
31129 <p>a</p>
31130 <p></p>
31131 <p></p>
31132 <p></p>
31133 <p></p>
31134 <p>b</p>
31135 !! wikitext
31136 <div>1</div>
31137 a
31138
31139 b
31140 <div>2</div>
31141 a
31142
31143 b
31144 <div>3</div>
31145 a
31146
31147 b
31148 !! html/php+tidy
31149 <div>1</div>
31150 <p>a
31151 </p><p>b
31152 </p>
31153 <div>2</div>
31154 <p>a
31155 </p><p>b
31156 </p>
31157 <div>3</div>
31158 <p>a
31159 </p><p>b
31160 </p>
31161 !! end
31162
31163 !! test
31164 Normalize empty paragraphs to HTML form that html2wt expects
31165 !! options
31166 parsoid={
31167 "modes": ["html2wt"],
31168 "scrubWikitext": true
31169 }
31170 !! html/parsoid
31171 <div>1</div>
31172 <p>a</p><p></p><p>b</p>
31173 <div>2</div>
31174 <p>a</p>
31175 <p></p>
31176 <p>b</p>
31177 <div>3</div>
31178 <p>a</p>
31179 <p></p>
31180 <p></p>
31181 <p></p>
31182 <p></p>
31183 <p>b</p>
31184 <div>4</div>
31185 <p>a</p>
31186 <p></p>
31187 <div>foo</div>
31188 !! wikitext
31189 <div>1</div>
31190 a
31191
31192
31193 b
31194 <div>2</div>
31195 a
31196
31197
31198 b
31199 <div>3</div>
31200 a
31201
31202
31203
31204
31205
31206 b
31207 <div>4</div>
31208 a
31209
31210 <br />
31211 <div>foo</div>
31212 !! html/php+tidy
31213 <div>1</div>
31214 <p>a
31215 </p><p><br />
31216 b
31217 </p>
31218 <div>2</div>
31219 <p>a
31220 </p><p><br />
31221 b
31222 </p>
31223 <div>3</div>
31224 <p>a
31225 </p><p><br />
31226 </p><p><br />
31227 </p><p>b
31228 </p>
31229 <div>4</div>
31230 <p>a
31231 </p><p><br />
31232 </p>
31233 <div>foo</div>
31234 !! end
31235
31236 !! test
31237 Empty paragraphs (marked with mw-empty-elt) found in source should not be normalized away
31238 !! options
31239 parsoid={
31240 "modes": ["html2wt"],
31241 "scrubWikitext": true
31242 }
31243 !! html/parsoid
31244 <table>
31245 <tbody>
31246 <tr>
31247 <td><div>foo
31248 </div>
31249 <p class="mw-empty-elt"></p>
31250 </td>
31251 </tr>
31252 </tbody>
31253 <caption></caption>
31254 </table>
31255 !! wikitext
31256 {|
31257 |<div>foo
31258 </div>
31259 |+
31260 |}
31261 !! end
31262
31263 !! test
31264 Templated content should be skipped over by normalization
31265 !! options
31266 parsoid={
31267 "modes": ["html2wt"],
31268 "scrubWikitext": true
31269 }
31270 !! html/parsoid
31271 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"SomeTemplate1","href":"./Template:SomeTemplate1"},"params":{"1":{"wt":"boo"}},"i":0}}]}'>foobar</p><p about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"SomeTemplate2","href":"./Template:SomeTemplate2"},"params":{"1":{"wt":"booboo"}},"i":0}}]}'>foobar</p><span about="#mwt2">
31272 </span><p about="#mwt2"></p><span about="#mwt2">
31273 </span>
31274 !! wikitext
31275 {{SomeTemplate1|boo}}{{SomeTemplate2|booboo}}
31276 !! end
31277
31278 !! test
31279 Escape nowiki DOM elements
31280 !! options
31281 parsoid=html2wt
31282 !! html/parsoid
31283 <nowiki><i>foo</i></nowiki>
31284 !! wikitext
31285 &lt;nowiki&gt;''foo''&lt;/nowiki&gt;
31286 !! end
31287
31288 # This is meant to be an interim fix while we go about figuring out
31289 # how to not introduce these trailing <nowiki/>s in the first place.
31290 !! test
31291 T115717: Strip trailing <nowiki/>s (without affecting valid uses)
31292 !! options
31293 parsoid=html2wt
31294 !! html/parsoid
31295 <p>x<meta typeof="mw:Placeholder" data-parsoid='{"src":"&lt;nowiki/>"}'/><meta typeof="mw:Placeholder" data-parsoid='{"src":"&lt;nowiki/>"}'/>
31296 y</p>
31297 <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>
31298 <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>
31299 !! wikitext
31300 x
31301 y
31302
31303 {{echo|
31304 1 = <nowiki/>}}
31305
31306 {{echo|
31307 1 = <nowiki/>
31308 }}
31309 !! end
31310
31311 !! test
31312 New list is serialized on newlines
31313 !! options
31314 parsoid=html2wt
31315 !! html/parsoid
31316 <p>The quick brown fox jumps over the lazy dog.</p><ul>
31317 <li>Yesterday</li>
31318 <li>Today</li>
31319 <li>Tomorrow</li>
31320 </ul><p>The quick onyx goblin jumps over the lazy dwarf.</p>
31321 !! wikitext
31322 The quick brown fox jumps over the lazy dog.
31323
31324 * Yesterday
31325 * Today
31326 * Tomorrow
31327
31328 The quick onyx goblin jumps over the lazy dwarf.
31329 !! end
31330
31331 !! test
31332 New lists in formatting elements serialized w/o newlines
31333 !! options
31334 parsoid=html2wt
31335 !! html/parsoid
31336 <small>
31337
31338 <ul>
31339 <li>123</li>
31340 </ul>
31341
31342 </small>
31343
31344 <small><ul><li>hi</li></ul></small>
31345 !! wikitext
31346 <small>
31347 * 123
31348 </small>
31349
31350 <small>
31351 * hi
31352 </small>
31353 !! end
31354
31355 !! test
31356 New list in table doesn't need newlines
31357 !! options
31358 parsoid=html2wt
31359 !! html/parsoid
31360 <table><tr><td><ul><li>test</li><li>123</li></td></tr></table>
31361 !! wikitext
31362 {|
31363 |
31364 * test
31365 * 123
31366 |}
31367 !! end
31368
31369 # ---------------------------------------------------
31370 # End of tests spec'ing wikitext serialization norms |
31371 # ---------------------------------------------------
31372
31373 # T104032
31374 !! test
31375 Bare inline nodes not wrapped inside p-tags should be treated as p-wrapped
31376 !! options
31377 parsoid=html2wt
31378 !! html/parsoid
31379 a<p>b</p>
31380 <b>c</b><p>d</p>
31381 <table><tr>
31382 <td>a<p>b</p></td>
31383 <td><b>c</b><p>d</p></td>
31384 </tr></table>
31385 !! wikitext
31386 a
31387
31388 b
31389
31390 '''c'''
31391
31392 d
31393 {|
31394 |a
31395 b
31396 |'''c'''
31397 d
31398 |}
31399 !! end
31400
31401 !! test
31402 Anchor without href scenarios
31403 !! options
31404 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
31405 !! html/parsoid
31406 <a class="bc"></a>
31407 <a class="no">dice</a>
31408 <a name="foo"></a>
31409 !! wikitext
31410
31411 dice
31412 <span name="foo"></span>
31413 !! end
31414
31415 !! test
31416 New transclusion added after a list should be serialized after the list
31417 !! options
31418 parsoid=html2wt
31419 !! html/parsoid
31420 <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>
31421 !! wikitext
31422 * a
31423 {{echo|foo}}
31424 !! end
31425
31426 # -----------------------------------------------------------------
31427 # End of section for Parsoid-only html2wt tests for serialization
31428 # of new content
31429 # -----------------------------------------------------------------
31430
31431 # -----------------------------------------------------------------
31432 # The following section of tests are primarily to spec behavior of
31433 # the selective serializer. All these tests have manual selser
31434 # changes. The automated selser changes for all tests handle the
31435 # wide variation of changes, but these tests here capture specs
31436 # deterministically.
31437 # ----------------------------------------------------------------
31438
31439 ## T90517
31440 !! test
31441 Selser: New comments should not be lost
31442 !! options
31443 parsoid={
31444 "modes": ["selser"],
31445 "changes": [
31446 [ "#a", "after", "<!--c1-->" ],
31447 [ "#b", "before", "<!--c2-->" ]
31448 ]
31449 }
31450 !! wikitext
31451 <span id="a">a</span>
31452
31453 <span id="b">b</span>
31454 !! wikitext/edited
31455 <span id="a">a</span><!--c1-->
31456
31457 <!--c2--><span id="b">b</span>
31458 !! end
31459
31460 ## T89383
31461 !! test
31462 Selser: Check for validity of DSR before using it
31463 !! options
31464 parsoid={
31465 "modes": ["selser"],
31466 "changes": [
31467 [ "#a", "before", "<meta property='mw:PageProp/displaytitle' content='foo'>" ]
31468 ]
31469 }
31470 !! wikitext
31471 <span id="a">a</span>
31472 !! wikitext/edited
31473 {{DISPLAYTITLE:foo}}
31474 <span id="a">a</span>
31475 !! end
31476
31477 !! test
31478 1. DOMDiff: Changes to <ref> content should be looked up using id
31479 !! options
31480 parsoid={
31481 "modes": ["selser"],
31482 "changes": [
31483 ["#X", "after", "bar"],
31484 ["#Y", "after", "baz"]
31485 ]
31486 }
31487 !! wikitext
31488 X <ref><span id="X">foo</span></ref>
31489 Y <ref name="a" />
31490 <references>
31491 <ref name="a"><span id="Y">foo</span></ref>
31492 </references>
31493 !! wikitext/edited
31494 X <ref><span id="X">foo</span>bar</ref>
31495 Y <ref name="a" />
31496 <references>
31497 <ref name="a"><span id="Y">foo</span>baz</ref>
31498 </references>
31499 !! end
31500
31501 !! test
31502 2. DOMDiff: Changes to <ref> content should be looked up using id
31503 !! options
31504 parsoid={
31505 "modes": ["selser"],
31506 "changes": [
31507 ["#Z", "after", "bar"]
31508 ]
31509 }
31510 !! wikitext
31511 A <ref>foo bar for a</ref>
31512 B <ref group="X" name="b" />
31513
31514 <references />
31515
31516 <references group="X">
31517 <ref name="b"><span id="Z">foo</span></ref>
31518 </references>
31519 !! wikitext/edited
31520 A <ref>foo bar for a</ref>
31521 B <ref group="X" name="b" />
31522
31523 <references />
31524
31525 <references group="X">
31526 <ref name="b"><span id="Z">foo</span>bar</ref>
31527 </references>
31528 !! end
31529
31530 !! test
31531 DOMDiff: Edits to content nested in elements with templated attributes should not be lost (T139388)
31532 !! options
31533 parsoid={
31534 "modes": ["selser"],
31535 "changes": [
31536 [ "div:first-child", "text", "bar" ]
31537 ]
31538 }
31539 !! wikitext
31540 <div style="{{1x|color:red;}}%">foo</div>
31541 !! wikitext/edited
31542 <div style="{{1x|color:red;}}%">bar</div>
31543 !! end
31544
31545 !! test
31546 Empty LI (T49673)
31547 !! wikitext
31548 *a
31549 *
31550 *
31551 *b
31552 !! html+tidy
31553 <ul><li>a</li>
31554 <li class="mw-empty-elt"></li>
31555 <li class="mw-empty-elt"></li>
31556 <li>b</li></ul>
31557 !! end
31558
31559 !! test
31560 Thumbnail output
31561 !! wikitext
31562 [[File:Thumb.png|thumb]]
31563 !! html/php+tidy
31564 <div class="thumb tright"><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" decoding="async" width="135" height="135" class="thumbimage" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Thumb.png" class="internal" title="Enlarge"></a></div></div></div></div>
31565 !! html/parsoid
31566 <figure class="mw-default-size" typeof="mw:Image/Thumb"><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></figure>
31567 !! end
31568
31569 !! test
31570 unclosed internal link XSS (T137264)
31571 !! wikitext
31572 [[#%3Cscript%3Ealert(1)%3C/script%3E|
31573 !! html/php
31574 <p>[[#&lt;script&gt;alert(1)&lt;/script&gt;|
31575 </p>
31576 !! html/parsoid
31577 <p>[[#%3Cscript%3Ealert(1)%3C/script%3E|</p>
31578 !! end
31579
31580 !! test
31581 Validating that <style> isn't eaten by tidy (T167349)
31582 !! options
31583 styletag=1
31584 !! wikitext
31585 <div class="foo">
31586 <style>.foo::before { content: "<foo>"; }</style>
31587 <style data-mw-foobar="baz">.foo::after { content: "<bar>"; }</style>
31588 </div>
31589 !! html/php+tidy
31590 <div class="foo">
31591 <style>.foo::before { content: "<foo>"; }</style>
31592 <style data-mw-foobar="baz">.foo::after { content: "<bar>"; }</style>
31593 </div>
31594 !! html/parsoid
31595 <div class="foo">
31596 <style typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{},"body":{"extsrc":".foo::before { content: \"&lt;foo>\"; }"}}'>.foo::before { content: "<foo>"; }</style>
31597 <style data-x-data-mw-foobar="baz" typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{"data-x-data-mw-foobar":"baz"},"body":{"extsrc":".foo::after { content: \"&lt;bar>\"; }"}}'>.foo::after { content: "<bar>"; }</style>
31598 </div>
31599 !! end
31600
31601 ## Right now, Parsoid doesn't de-duplicate style tags.
31602 ## So, we shouldn't see link tags that need to bypass the sanitizer.
31603 ## In a followup patch, when we de-duplicate style tags and
31604 ## introduce link tags, we'll add a hook for link tags in
31605 ## the parser test runner script.
31606 !! test
31607 Validating that <style> isn't wrapped in a paragraph (T186965)
31608 !! options
31609 styletag=1
31610 !! wikitext
31611 A style tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
31612
31613 <style>.foo::before { content: "<foo>"; }</style>
31614
31615 <style>.foo::before { content: "<foo>"; }</style> <link rel="foo" href="bar"/><style>.foo::before { content: "<foo>"; }</style>
31616
31617 But if it's on a line with other content, let it be wrapped.
31618
31619 <style>.foo::before { content: "<foo>"; }</style> bar
31620
31621 foo <style>.foo::before { content: "<foo>"; }</style>
31622
31623 foo <style>.foo::before { content: "<foo>"; }</style> bar
31624
31625 And the same if we have non-paragraph-breaking whitespace
31626
31627 foo
31628 <style>.foo::before { content: "<foo>"; }</style>
31629 bar
31630 !! html/php
31631 <p>A style tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
31632 </p>
31633 <style>.foo::before { content: "<foo>"; }</style>
31634 <style>.foo::before { content: "<foo>"; }</style> <link rel="foo" href="bar"/><style>.foo::before { content: "<foo>"; }</style>
31635 <p>But if it's on a line with other content, let it be wrapped.
31636 </p><p><style>.foo::before { content: "<foo>"; }</style> bar
31637 </p><p>foo <style>.foo::before { content: "<foo>"; }</style>
31638 </p><p>foo <style>.foo::before { content: "<foo>"; }</style> bar
31639 </p><p>And the same if we have non-paragraph-breaking whitespace
31640 </p><p>foo
31641 <style>.foo::before { content: "<foo>"; }</style>
31642 bar
31643 </p>
31644 !! html/parsoid
31645 <p>A style tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph</p>
31646
31647 <style typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{},"body":{"extsrc":".foo::before { content: \"&lt;foo>\"; }"}}'>.foo::before { content: "<foo>"; }</style>
31648
31649 <p><style typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{},"body":{"extsrc":".foo::before { content: \"&lt;foo>\"; }"}}'>.foo::before { content: "<foo>"; }</style> &lt;link rel="foo" href="bar"/><style typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{},"body":{"extsrc":".foo::before { content: \"&lt;foo>\"; }"}}'>.foo::before { content: "<foo>"; }</style></p>
31650
31651 <p>But if it's on a line with other content, let it be wrapped.</p>
31652
31653 <p><style typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{},"body":{"extsrc":".foo::before { content: \"&lt;foo>\"; }"}}'>.foo::before { content: "<foo>"; }</style> bar</p>
31654
31655 <p>foo <style typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{},"body":{"extsrc":".foo::before { content: \"&lt;foo>\"; }"}}'>.foo::before { content: "<foo>"; }</style></p>
31656
31657 <p>foo <style typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{},"body":{"extsrc":".foo::before { content: \"&lt;foo>\"; }"}}'>.foo::before { content: "<foo>"; }</style> bar</p>
31658
31659 <p>And the same if we have non-paragraph-breaking whitespace</p>
31660
31661 <p>foo
31662 <style typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{},"body":{"extsrc":".foo::before { content: \"&lt;foo>\"; }"}}'>.foo::before { content: "<foo>"; }</style>
31663 bar</p>
31664 !! end
31665
31666 !! test
31667 Validating that <link> isn't wrapped in a paragraph (T186965)
31668 !! options
31669 styletag=1
31670 !! wikitext
31671 A link tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
31672
31673 <link rel="foo" href="bar"/>
31674
31675 <link rel="foo" href="bar"/> <style>.foo::before { content: "<foo>"; }</style><link rel="foo" href="bar"/>
31676
31677 But if it's on a line with other content, let it be wrapped.
31678
31679 <link rel="foo" href="bar"/> bar
31680
31681 foo <link rel="foo" href="bar"/>
31682
31683 foo <link rel="foo" href="bar"/> bar
31684
31685 And the same if we have non-paragraph-breaking whitespace
31686
31687 foo
31688 <link rel="foo" href="bar"/>
31689 bar
31690 !! html/php
31691 <p>A link tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
31692 </p>
31693 <link rel="foo" href="bar"/>
31694 <link rel="foo" href="bar"/> <style>.foo::before { content: "<foo>"; }</style><link rel="foo" href="bar"/>
31695 <p>But if it's on a line with other content, let it be wrapped.
31696 </p><p><link rel="foo" href="bar"/> bar
31697 </p><p>foo <link rel="foo" href="bar"/>
31698 </p><p>foo <link rel="foo" href="bar"/> bar
31699 </p><p>And the same if we have non-paragraph-breaking whitespace
31700 </p><p>foo
31701 <link rel="foo" href="bar"/>
31702 bar
31703 </p>
31704 !! end
31705
31706 !! test
31707 Extension returning multiple nodes starting with a style tag roundtrips
31708 !! options
31709 wgRawHtml=1
31710 !! wikitext
31711 <table>
31712 {{echo|<html><style>.hi { color: red; }</style>
31713 </html>}}
31714 <tr><td class="hi">ho</td></tr>
31715 </table>
31716 !! html/parsoid
31717 <p about="#mwt5" typeof="mw:Transclusion" data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true,"firstWikitextNode":"TABLE_html","pi":[[{"k":"1"}]]}' data-mw='{"parts":["&lt;table>\n",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;html>&lt;style>.hi { color: red; }&lt;/style>\n&lt;/html>"}},"i":0}},"\n&lt;tr>&lt;td class=\"hi\">ho&lt;/td>&lt;/tr>\n&lt;/table>"]}'><style typeof="mw:Extension/html" about="#mwt4" data-mw='{"name":"html","attrs":{},"body":{"extsrc":"&lt;style>.hi { color: red; }&lt;/style>\n"}}'>.hi { color: red; }</style><span about="#mwt4">
31718 </span></p><table about="#mwt5" data-parsoid='{"stx":"html"}'>
31719
31720 <tbody><tr><td class="hi">ho</td></tr>
31721 </tbody></table>
31722 !! end
31723
31724 !! test
31725 Decoding of HTML entities in headings and links for IDs and link fragments (T103714)
31726 !! config
31727 wgFragmentMode=[ 'html5', 'legacy' ]
31728 !! wikitext
31729 ==A&B&amp;C&amp;amp;D&amp;amp;amp;E==
31730 [[#A&B&amp;C&amp;amp;D&amp;amp;amp;E]]
31731 !! html/php
31732 <h2><span id="A.26B.26C.26amp.3BD.26amp.3Bamp.3BE"></span><span class="mw-headline" id="A&amp;B&amp;C&amp;amp;D&amp;amp;amp;E">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>
31733 <p><a href="#A&amp;B&amp;C&amp;amp;D&amp;amp;amp;E">#A&amp;B&amp;C&amp;amp;D&amp;amp;amp;E</a>
31734 </p>
31735 !! html/parsoid
31736 <h2 id="A&amp;B&amp;C&amp;amp;D&amp;amp;amp;E"><span id="A.26B.26C.26amp.3BD.26amp.3Bamp.3BE" typeof="mw:FallbackId" data-parsoid="{}"></span>A&amp;B<span typeof="mw:Entity" data-parsoid='{"src":"&amp;amp;","srcContent":"&amp;"}'>&amp;</span>C<span typeof="mw:Entity" data-parsoid='{"src":"&amp;amp;","srcContent":"&amp;"}'>&amp;</span>amp;D<span typeof="mw:Entity" data-parsoid='{"src":"&amp;amp;","srcContent":"&amp;"}'>&amp;</span>amp;amp;E</h2>
31737 <p><a rel="mw:WikiLink" href="./Parser_test#A&amp;B&amp;C&amp;amp;D&amp;amp;amp;E" data-parsoid='{"stx":"simple","a":{"href":"./Parser_test#A&amp;B&amp;C&amp;amp;D&amp;amp;amp;E"},"sa":{"href":"#A&amp;B&amp;amp;C&amp;amp;amp;D&amp;amp;amp;amp;E"}}'>#A&amp;B&amp;C&amp;amp;D&amp;amp;amp;E</a></p>
31738 !! end
31739
31740 !! test
31741 Decoding of HTML entities in headings and links for IDs and link fragments (T103714) (legacy)
31742 !! config
31743 wgFragmentMode=[ 'legacy' ]
31744 !! wikitext
31745 ==A&B&amp;C&amp;amp;D&amp;amp;amp;E==
31746 [[#A&B&amp;C&amp;amp;D&amp;amp;amp;E]]
31747 !! html/php
31748 <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>
31749 <p><a href="#A.26B.26C.26amp.3BD.26amp.3Bamp.3BE">#A&amp;B&amp;C&amp;amp;D&amp;amp;amp;E</a>
31750 </p>
31751 !! end
31752
31753 !! test
31754 Decoding of HTML entities in embedded HTML tags
31755 !! wikitext
31756 <table class="1&2&amp;3&amp;amp;4&amp;amp;amp;5"><tr><td>x</td></tr></table>
31757 !! html/php
31758 <table class="1&amp;2&amp;3&amp;amp;4&amp;amp;amp;5"><tr><td>x</td></tr></table>
31759
31760 !! html/parsoid
31761 <table class="1&amp;2&amp;3&amp;amp;4&amp;amp;amp;5" data-parsoid='{"stx":"html","a":{"class":"1&amp;2&amp;3&amp;amp;4&amp;amp;amp;5"},"sa":{"class":"1&amp;2&amp;amp;3&amp;amp;amp;4&amp;amp;amp;amp;5"}}'><tbody><tr data-parsoid='{"stx":"html"}'><td data-parsoid='{"stx":"html"}'>x</td></tr></tbody></table>
31762 !! end
31763
31764 !! test
31765 Decoding of HTML entities in indicator names for IDs (T104196)
31766 !! options
31767 parsoid=wt2html,html2html
31768 showindicators
31769 !! wikitext
31770 <indicator name="1&2&amp;3&amp;amp;4&amp;amp;amp;5">Indicator</indicator>
31771 !! html/php
31772 1&2&3&amp;4&amp;amp;5=Indicator
31773
31774 !! html/parsoid
31775 <p><span typeof="mw:Extension/indicator" about="#mwt3" data-mw='{"name":"indicator","attrs":{"name":"1&amp;2&amp;3&amp;amp;4&amp;amp;amp;5"},"body":{"extsrc":"Indicator"}}'></span></p>
31776 !! end
31777
31778 # this version of the test strips out the ambiguity so Parsoid rts cleanly
31779 !! test
31780 Decoding of HTML entities in indicator names for IDs (unambiguous) (T104196)
31781 !! options
31782 showindicators
31783 !! wikitext
31784 <indicator name="1&2&3&amp;amp;4&amp;amp;amp;5">Indicator</indicator>
31785 !! html/php
31786 1&2&3&amp;4&amp;amp;5=Indicator
31787
31788 !! html/parsoid
31789 <p><span typeof="mw:Extension/indicator" about="#mwt3" data-mw='{"name":"indicator","attrs":{"name":"1&amp;2&amp;3&amp;amp;4&amp;amp;amp;5"},"body":{"extsrc":"Indicator"}}'></span></p>
31790 !! end
31791
31792 # This fragment mode is what Parsoid supports.
31793 !! test
31794 HTML5 ids: fallback to legacy
31795 !! config
31796 wgFragmentMode=[ 'html5', 'legacy' ]
31797 !! wikitext
31798 ==Foo bar==
31799
31800 ==foo Bar==
31801
31802 ==Тест==
31803
31804 ==Тест==
31805
31806 ==тест==
31807
31808 ==Hey < # " > % : '==
31809 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
31810
31811 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
31812
31813 <!-- These two links should produce identical HTML -->
31814 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
31815
31816 !! html/php
31817 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
31818 <ul>
31819 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
31820 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
31821 <li class="toclevel-1 tocsection-3"><a href="#Тест"><span class="tocnumber">3</span> <span class="toctext">Тест</span></a></li>
31822 <li class="toclevel-1 tocsection-4"><a href="#Тест_2"><span class="tocnumber">4</span> <span class="toctext">Тест</span></a></li>
31823 <li class="toclevel-1 tocsection-5"><a href="#тест"><span class="tocnumber">5</span> <span class="toctext">тест</span></a></li>
31824 <li class="toclevel-1 tocsection-6"><a href="#Hey_&lt;_#_&quot;_&gt;_%_:_&#39;"><span class="tocnumber">6</span> <span class="toctext">Hey &lt; # " &gt;&#160;%&#160;: '</span></a></li>
31825 </ul>
31826 </div>
31827
31828 <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>
31829 <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>
31830 <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>
31831 <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>
31832 <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>
31833 <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; % : &#039;">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
31834 <p><a href="#Foo_bar">#Foo bar</a> <a href="#foo_Bar">#foo Bar</a> <a href="#Тест">#Тест</a> <a href="#тест">#тест</a> <a href="#Hey_&lt;_#_&quot;_&gt;_%_:_&#39;">#Hey &lt; # " &gt;&#160;%&#160;: '</a>
31835 </p><p>💩 <span id="💩"></span>
31836 </p><p><a href="#啤酒">#啤酒</a> <a href="#啤酒">#啤酒</a>
31837 </p>
31838 !! html/parsoid
31839 <h2 id="Foo_bar">Foo bar</h2>
31840
31841 <h2 id="foo_Bar_2">foo Bar</h2>
31842
31843 <h2 id="Тест"><span id=".D0.A2.D0.B5.D1.81.D1.82" typeof="mw:FallbackId"></span>Тест</h2>
31844
31845 <h2 id="Тест_2"><span id=".D0.A2.D0.B5.D1.81.D1.82_2" typeof="mw:FallbackId"></span>Тест</h2>
31846
31847 <h2 id="тест"><span id=".D1.82.D0.B5.D1.81.D1.82" typeof="mw:FallbackId"></span>тест</h2>
31848
31849 <h2 id="Hey_&lt;_#_&quot;_>_%_:_'"><span id="Hey_.3C_.23_.22_.3E_.25_:_.27" typeof="mw:FallbackId"></span>Hey &lt; # " > %<span typeof="mw:DisplaySpace mw:Placeholder" data-parsoid='{"src":" ","isDisplayHack":true}'> </span>: '</h2>
31850 <p><a rel="mw:WikiLink" href="./Parser_test#Foo_bar">#Foo bar</a> <a rel="mw:WikiLink" href="./Parser_test#foo_Bar">#foo Bar</a> <a rel="mw:WikiLink" href="./Parser_test#Тест">#Тест</a> <a rel="mw:WikiLink" href="./Parser_test#тест">#тест</a> <a rel="mw:WikiLink" href="./Parser_test#Hey_&lt;_#_&quot;_>_%_:_'" data-parsoid='{"stx":"simple","a":{"href":"./Parser_test#Hey_&lt;_#_\"_>_%_:_&#39;"},"sa":{"href":"#Hey &lt; # \" > % : &#39;"}}'>#Hey &lt; # " > % : '</a></p>
31851
31852 <p><span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode:💩","function":"anchorencode"},"params":{},"i":0}}]}'>💩</span> <span id="💩" about="#mwt3" typeof="mw:ExpandedAttrs" data-mw='{"attribs":[[{"txt":"id"},{"html":"&lt;span about=\"#mwt2\" typeof=\"mw:Transclusion\" data-parsoid=&#39;{\"pi\":[[]],\"dsr\":[178,197,null,null]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"anchorencode:💩\",\"function\":\"anchorencode\"},\"params\":{},\"i\":0}}]}&#39;>💩&lt;/span>"}]]}'></span></p>
31853
31854 <!-- These two links should produce identical HTML -->
31855 <p><a rel="mw:WikiLink" href="./Parser_test#啤酒">#啤酒</a> <a rel="mw:WikiLink" href="./Parser_test#啤酒" data-parsoid='{"stx":"simple","a":{"href":"./Parser_test#啤酒"},"sa":{"href":"#%E5%95%A4%E9%85%92"}}'>#啤酒</a></p>
31856 !! end
31857
31858 # Parsoid doesn't support this mode
31859 !! test
31860 HTML5 ids: legacy with a fallback to modern
31861 !! config
31862 wgFragmentMode=[ 'legacy', 'html5' ]
31863 !! wikitext
31864 ==Foo bar==
31865
31866 ==foo Bar==
31867
31868 ==Тест==
31869
31870 ==Тест==
31871
31872 ==тест==
31873
31874 ==Hey < # " > % : '==
31875 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
31876
31877 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
31878
31879 <!-- These two links should produce identical HTML -->
31880 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
31881
31882 !! html/php
31883 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
31884 <ul>
31885 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
31886 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
31887 <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>
31888 <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>
31889 <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>
31890 <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>
31891 </ul>
31892 </div>
31893
31894 <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>
31895 <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>
31896 <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>
31897 <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>
31898 <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>
31899 <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; % : &#039;">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
31900 <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>
31901 </p><p>.F0.9F.92.A9 <span id=".F0.9F.92.A9"></span>
31902 </p><p><a href="#.E5.95.A4.E9.85.92">#啤酒</a> <a href="#.E5.95.A4.E9.85.92">#啤酒</a>
31903 </p>
31904 !! end
31905
31906 # Parsoid doesn't support this mode.
31907 !! test
31908 HTML5 ids: no legacy
31909 !! config
31910 wgFragmentMode=[ 'html5' ]
31911 !! wikitext
31912 ==Foo bar==
31913
31914 ==foo Bar==
31915
31916 ==Тест==
31917
31918 ==Тест==
31919
31920 ==тест==
31921
31922 ==Hey < # " > % : '==
31923 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
31924
31925 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
31926
31927 <!-- These two links should produce identical HTML -->
31928 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
31929
31930 !! html/php
31931 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
31932 <ul>
31933 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
31934 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
31935 <li class="toclevel-1 tocsection-3"><a href="#Тест"><span class="tocnumber">3</span> <span class="toctext">Тест</span></a></li>
31936 <li class="toclevel-1 tocsection-4"><a href="#Тест_2"><span class="tocnumber">4</span> <span class="toctext">Тест</span></a></li>
31937 <li class="toclevel-1 tocsection-5"><a href="#тест"><span class="tocnumber">5</span> <span class="toctext">тест</span></a></li>
31938 <li class="toclevel-1 tocsection-6"><a href="#Hey_&lt;_#_&quot;_&gt;_%_:_&#39;"><span class="tocnumber">6</span> <span class="toctext">Hey &lt; # " &gt;&#160;%&#160;: '</span></a></li>
31939 </ul>
31940 </div>
31941
31942 <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>
31943 <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>
31944 <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>
31945 <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>
31946 <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>
31947 <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; % : &#039;">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
31948 <p><a href="#Foo_bar">#Foo bar</a> <a href="#foo_Bar">#foo Bar</a> <a href="#Тест">#Тест</a> <a href="#тест">#тест</a> <a href="#Hey_&lt;_#_&quot;_&gt;_%_:_&#39;">#Hey &lt; # " &gt;&#160;%&#160;: '</a>
31949 </p><p>💩 <span id="💩"></span>
31950 </p><p><a href="#啤酒">#啤酒</a> <a href="#啤酒">#啤酒</a>
31951 </p>
31952 !! end
31953
31954 !! test
31955 T90902: Normalize weird characters in section IDs
31956 !! config
31957 wgFragmentMode=[ 'html5', 'legacy' ]
31958 !! wikitext
31959 ==Foo&nbsp;bar==
31960 [[#Foo&nbsp;bar]]
31961
31962 !! html/php
31963 <h2><span class="mw-headline" id="Foo_bar">Foo&#160;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>
31964 <p><a href="#Foo_bar">#Foo&#160;bar</a>
31965 </p>
31966 !! html/parsoid
31967 <h2 id="Foo_bar"> Foo<span typeof="mw:Entity" data-parsoid='{"src":"&amp;nbsp;","srcContent":" "}'> </span>bar </h2>
31968 <p><a rel="mw:WikiLink" href="./Parser_test#Foo_bar" data-parsoid='{"stx":"simple","a":{"href":"./Parser_test#Foo_bar"},"sa":{"href":"#Foo&amp;nbsp;bar"}}'>#Foo bar</a></p>
31969 !! end
31970
31971 !! test
31972 T51672: Test for brackets in attributes of elements in external link texts
31973 !! wikitext
31974 [http://example.com/ link <span title="title with [brackets]">span</span>]
31975 [http://example.com/ link <span title="title with &#91;brackets&#93;">span</span>]
31976
31977 !! html/php
31978 <p><a rel="nofollow" class="external text" href="http://example.com/">link <span title="title with &#91;brackets&#93;">span</span></a>
31979 <a rel="nofollow" class="external text" href="http://example.com/">link <span title="title with &#91;brackets&#93;">span</span></a>
31980 </p>
31981 !! html/parsoid
31982 <p><a rel="mw:ExtLink" class="external text" href="http://example.com/">link <span title="title with [brackets]">span</span></a>
31983 <a rel="mw:ExtLink" class="external text" href="http://example.com/">link <span title="title with [brackets]" data-parsoid='{"stx":"html","a":{"title":"title with [brackets]"},"sa":{"title":"title with &amp;#91;brackets&amp;#93;"}}'>span</span></a></p>
31984 !! end
31985
31986 !! test
31987 T72875: Test for brackets in attributes of elements in internal link texts
31988 !! wikitext
31989 [[Foo|link <span title="title with [[double brackets]]">span</span>]]
31990 [[Foo|link <span title="title with &#91;&#91;double brackets&#93;&#93;">span</span>]]
31991
31992 !! html/php
31993 <p><a href="/wiki/Foo" title="Foo">link <span title="title with &#91;&#91;double brackets&#93;&#93;">span</span></a>
31994 <a href="/wiki/Foo" title="Foo">link <span title="title with &#91;&#91;double brackets&#93;&#93;">span</span></a>
31995 </p>
31996 !! html/parsoid
31997 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">link <span title="title with [[double brackets]]">span</span></a>
31998 <a rel="mw:WikiLink" href="./Foo" title="Foo">link <span title="title with [[double brackets]]" data-parsoid='{"stx":"html","a":{"title":"title with [[double brackets]]"},"sa":{"title":"title with &amp;#91;&amp;#91;double brackets&amp;#93;&amp;#93;"}}'>span</span></a></p>
31999 !! end
32000
32001 !! test
32002 T199926: html arrow wt: Parsoid sometimes trips up on verticalbar chars in hrefs
32003 !! options
32004 parsoid={
32005 "modes": ["html2wt"]
32006 }
32007 !! html/parsoid
32008 <a href="https://stats.wikimedia.org/v2/#/fr.wikipedia.org/reading/page-views-by-country/normal|map|2-Year~2016060100~2018071100|~total">9</a>
32009 <a href="https://stats.wikimedia.org/v2/#/fr.wikipedia.org/reading/page-views-by-country/normal%7Cmap%7C2-Year~2016060100~2018071100%7C~total">10</a>
32010 !! wikitext
32011 [https://stats.wikimedia.org/v2/#/fr.wikipedia.org/reading/page-views-by-country/normal|map|2-Year~2016060100~2018071100|~total 9]
32012 [[stats:v2/#/fr.wikipedia.org/reading/page-views-by-country/normal%7Cmap%7C2-Year~2016060100~2018071100%7C~total|10]]
32013 !! end
32014
32015 !! test
32016 T179544: {{anchorencode:}} output should be always usable in links
32017 !! config
32018 wgFragmentMode=[ 'html5' ]
32019 !! wikitext
32020 <span id="{{anchorencode:[foo]}}"></span>[[#{{anchorencode:[foo]}}]]
32021 !! html/php
32022 <p><span id="&#91;foo&#93;"></span><a href="#[foo]">#&#91;foo&#93;</a>
32023 </p>
32024 !! html/parsoid
32025 <p><span id="[foo]" about="#mwt3" typeof="mw:ExpandedAttrs" data-parsoid='{"stx":"html","a":{"id":"[foo]"},"sa":{"id":"{{anchorencode:[foo]}}"}}' data-mw='{"attribs":[[{"txt":"id"},{"html":"&lt;span typeof=\"mw:Transclusion mw:Entity\" about=\"#mwt1\" data-parsoid=&apos;{\"srcContent\":\"[\",\"dsr\":[10,32,null,null],\"pi\":[[]]}&apos; data-mw=&apos;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"anchorencode:[foo]\",\"function\":\"anchorencode\"},\"params\":{},\"i\":0}}]}&apos;>[&lt;/span>&lt;span about=\"#mwt1\" data-parsoid=\"{}\">foo&lt;/span>&lt;span typeof=\"mw:Entity\" about=\"#mwt1\" data-parsoid=&apos;{\"src\":\"&amp;amp;#x5D;\",\"srcContent\":\"]\"}&apos;>]&lt;/span>"}]]}'></span><a typeof="mw:ExpandedAttrs" about="#mwt4" rel="mw:WikiLink" href="./Parser_test#[foo]" data-parsoid='{"stx":"simple","a":{"href":"./Parser_test#[foo]"},"sa":{"href":"#{{anchorencode:[foo]}}"}}' data-mw='{"attribs":[[{"txt":"href"},{"html":"#&lt;span typeof=\"mw:Transclusion mw:Entity\" about=\"#mwt2\" data-parsoid=&apos;{\"srcContent\":\"[\",\"dsr\":[44,66,null,null],\"pi\":[[]]}&apos; data-mw=&apos;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"anchorencode:[foo]\",\"function\":\"anchorencode\"},\"params\":{},\"i\":0}}]}&apos;>[&lt;/span>&lt;span about=\"#mwt2\" data-parsoid=\"{}\">foo&lt;/span>&lt;span typeof=\"mw:Entity\" about=\"#mwt2\" data-parsoid=&apos;{\"src\":\"&amp;amp;#x5D;\",\"srcContent\":\"]\"}&apos;>]&lt;/span>"}]]}'>#[foo]</a></p>
32026 !! end
32027
32028 ## ------------------------------
32029 ## Parsoid section-wrapping tests
32030 ## ------------------------------
32031 !! test
32032 Section wrapping for well-nested sections (no leading content)
32033 !! options
32034 parsoid={
32035 "wrapSections": true
32036 }
32037 !! wikitext
32038 =1=
32039 a
32040
32041 =2=
32042 b
32043
32044 ==2.1==
32045 c
32046
32047 ==2.2==
32048 d
32049
32050 ===2.2.1===
32051 e
32052
32053 =3=
32054 f
32055 !! html/parsoid
32056 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1>
32057 <p>a</p>
32058
32059 </section><section data-mw-section-id="2"><h1 id="2">2</h1>
32060 <p>b</p>
32061
32062 <section data-mw-section-id="3"><h2 id="2.1">2.1</h2>
32063 <p>c</p>
32064
32065 </section><section data-mw-section-id="4"><h2 id="2.2">2.2</h2>
32066 <p>d</p>
32067
32068 <section data-mw-section-id="5"><h3 id="2.2.1">2.2.1</h3>
32069 <p>e</p>
32070
32071 </section></section></section><section data-mw-section-id="6"><h1 id="3">3</h1>
32072 <p>f</p>
32073
32074 </section>
32075 !! end
32076
32077 !! test
32078 Section wrapping for well-nested sections (with leading content)
32079 !! options
32080 parsoid={
32081 "wrapSections": true
32082 }
32083 !! wikitext
32084 Para 1.
32085
32086 Para 2 with a <div>nested in it</div>
32087
32088 Para 3.
32089
32090 =1=
32091 a
32092
32093 =2=
32094 b
32095
32096 ==2.1==
32097 c
32098 !! html/parsoid
32099 <section data-mw-section-id="0"><p>Para 1.</p>
32100
32101 <p>Para 2 with a </p><div>nested in it</div>
32102
32103 <p>Para 3.</p>
32104
32105 </section><section data-mw-section-id="1"><h1 id="1">1</h1>
32106 <p>a</p>
32107
32108 </section><section data-mw-section-id="2"><h1 id="2">2</h1>
32109 <p>b</p>
32110
32111 <section data-mw-section-id="3"><h2 id="2.1">2.1</h2>
32112 <p>c</p>
32113
32114 </section></section>
32115 !! end
32116
32117 !! test
32118 Section wrapping with template-generated sections (good nesting 1)
32119 !! options
32120 parsoid={
32121 "wrapSections": true
32122 }
32123 !! wikitext
32124 =1=
32125 a
32126
32127 {{echo|1=
32128 ==1.1==
32129 b
32130 }}
32131
32132 ==1.2==
32133 c
32134
32135 =2=
32136 d
32137 !! html/parsoid
32138 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1>
32139 <p>a</p>
32140
32141 <section data-mw-section-id="-1"><h2 about="#mwt1" typeof="mw:Transclusion" id="1.1" data-parsoid='{"dsr":[9,33,null,null],"pi":[[{"k":"1","named":true,"spc":["","","\n","\n"]}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"==1.1==\nb"}},"i":0}}]}'>1.1</h2><span about="#mwt1">
32142 </span><p about="#mwt1">b</p>
32143 </section><section data-mw-section-id="3"><h2 id="1.2">1.2</h2>
32144 <p>c</p>
32145
32146 </section></section><section data-mw-section-id="4"><h1 id="2">2</h1>
32147 <p>d</p></section>
32148 !! end
32149
32150 # In this example, the template scope is mildly expanded to incorporate the
32151 # trailing newline after the transclusion since that is part of section 1.1.1
32152 !! test
32153 Section wrapping with template-generated sections (good nesting 2)
32154 !! options
32155 parsoid={
32156 "wrapSections": true,
32157 "modes": ["wt2html", "wt2wt"]
32158 }
32159 !! wikitext
32160 =1=
32161 a
32162
32163 {{echo|1=
32164 ==1.1==
32165 b
32166 ===1.1.1===
32167 d
32168 }}
32169 =2=
32170 e
32171 !! html/parsoid
32172 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1>
32173 <p>a</p>
32174
32175 <section data-mw-section-id="-1"><h2 about="#mwt1" typeof="mw:Transclusion" id="1.1" data-parsoid='{"dsr":[9,50,null,null],"pi":[[{"k":"1","named":true,"spc":["","","\n","\n"]}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"==1.1==\nb\n===1.1.1===\nd"}},"i":0}},"\n"]}'>1.1</h2><span about="#mwt1">
32176 </span><p about="#mwt1">b</p><span about="#mwt1">
32177 </span><section data-mw-section-id="-1" about="#mwt1"><h3 about="#mwt1" id="1.1.1">1.1.1</h3><span about="#mwt1">
32178 </span><p about="#mwt1">d</p><span about="#mwt1">
32179 </span></section></section></section><section data-mw-section-id="4" data-parsoid="{}"><h1 id="2">2</h1>
32180 <p>e</p></section>
32181 !! end
32182
32183 # In this example, the template scope is mildly expanded to incorporate the
32184 # trailing newline after the transclusion since that is part of section 1.2.1
32185 !! test
32186 Section wrapping with template-generated sections (good nesting 3)
32187 !! options
32188 parsoid={
32189 "wrapSections": true,
32190 "modes": ["wt2html", "wt2wt"]
32191 }
32192 !! wikitext
32193 =1=
32194 a
32195
32196 {{echo|1=
32197 x
32198 ==1.1==
32199 b
32200 ==1.2==
32201 c
32202 ===1.2.1===
32203 d
32204 }}
32205 =2=
32206 e
32207 !! html/parsoid
32208 <section data-mw-section-id="0"></section><section data-mw-section-id="1" data-parsoid="{}"><h1 id="1"> 1 </h1>
32209 <p>a</p>
32210
32211 <p about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"dsr":[9,60,0,0],"pi":[[{"k":"1","named":true,"spc":["","","\n","\n"]}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"x\n==1.1==\nb\n==1.2==\nc\n===1.2.1===\nd"}},"i":0}},"\n"]}'>x</p><span about="#mwt1">
32212 </span><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="1.1">1.1</h2><span about="#mwt1">
32213 </span><p about="#mwt1">b</p><span about="#mwt1">
32214 </span></section><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="1.2">1.2</h2><span about="#mwt1">
32215 </span><p about="#mwt1">c</p><span about="#mwt1">
32216 </span><section data-mw-section-id="-1" about="#mwt1"><h3 about="#mwt1" id="1.2.1">1.2.1</h3><span about="#mwt1">
32217 </span><p about="#mwt1">d</p><span about="#mwt1">
32218 </span></section></section></section><section data-mw-section-id="5"><h1 id="2">2</h1>
32219 <p>e</p></section>
32220 !! end
32221
32222 # Because of section-wrapping and template-wrapping interactions,
32223 # the scope of the template is expanded so that the template markup
32224 # is valid in the presence of <section> tags.
32225 # This exercises the s1 is null scenario in the wrapSections code
32226 !! test
32227 Section wrapping with template-generated sections (bad nesting 1)
32228 !! options
32229 parsoid={
32230 "wrapSections": true
32231 }
32232 !! wikitext
32233 <div>
32234 a
32235
32236 {{echo|
32237 =1=
32238 b
32239 }}
32240
32241 c
32242 </div>
32243 !! html/parsoid
32244 <section data-mw-section-id="-1"></section><section data-mw-section-id="-2"><div data-parsoid='{"stx":"html"}'>
32245 <p>a</p>
32246
32247 <span about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"\n=1=\nb\n"}},"i":0}},"\n\nc\n"]}'>
32248 </span><section data-mw-section-id="-1" about="#mwt1"><h1 about="#mwt1" id="1">1</h1><span about="#mwt1">
32249 </span><p about="#mwt1">b
32250 </p><span about="#mwt1">
32251
32252 </span><p about="#mwt1">c</p><span about="#mwt1">
32253 </span></section></div></section>
32254 !! end
32255
32256 # Because of section-wrapping and template-wrapping interactions,
32257 # the scope of the template is expanded so that the template markup
32258 # is valid in the presence of <section> tags.
32259 # This exercises the s1 is ancestor of s2 scenario in the wrapSections code
32260 !! test
32261 Section wrapping with template-generated sections (bad nesting 2)
32262 !! options
32263 parsoid={
32264 "wrapSections": true
32265 }
32266 !! wikitext
32267 =1=
32268 a
32269
32270 {{echo|1=
32271 =2=
32272 b
32273 ==2.1==
32274 c
32275 }}
32276
32277 d
32278
32279 =3=
32280 e
32281 !! html/parsoid
32282 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1>
32283 <p>a</p>
32284
32285 </section><section data-mw-section-id="-1"><h1 about="#mwt1" typeof="mw:Transclusion" id="2" data-parsoid='{"dsr":[9,45,null,null],"pi":[[{"k":"1","named":true,"spc":["","","\n","\n"]}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"=2=\nb\n==2.1==\nc"}},"i":0}},"\n\nd\n\n"]}'>2</h1><span about="#mwt1">
32286 </span><p about="#mwt1">b</p><span about="#mwt1">
32287 </span><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="2.1">2.1</h2><span about="#mwt1">
32288 </span><p about="#mwt1">c</p><span about="#mwt1">
32289
32290 </span><p about="#mwt1">d</p><span about="#mwt1">
32291
32292 </span></section></section><section data-mw-section-id="4"><h1 id="3">3</h1>
32293 <p>e</p></section>
32294 !! end
32295
32296 # Because of section-wrapping and template-wrapping interactions,
32297 # additional template wrappers are added to <section> tags
32298 # so that template wrapping semantics are valid whether section
32299 # tags are retained or stripped. But, the template scope can expand
32300 # greatly when accounting for section tags.
32301 # This exercises the s1 and s2 are in different subtrees scenario
32302 !! test
32303 Section wrapping with template-generated sections (bad nesting 3)
32304 !! options
32305 parsoid={
32306 "wrapSections": true,
32307 "modes": ["wt2html", "wt2wt"]
32308 }
32309 !! wikitext
32310 =1=
32311 a
32312
32313 {{echo|1=
32314 ==1.2==
32315 b
32316 =2=
32317 c
32318 }}
32319
32320 d
32321
32322 =3=
32323 e
32324 !! html/parsoid
32325 <section data-mw-section-id="0"></section><section data-mw-section-id="1" about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":["=1=\na\n\n",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"==1.2==\nb\n=2=\nc"}},"i":0}},"\n\nd\n\n"]}'><h1 id="1">1</h1>
32326 <p>a</p>
32327
32328 <section data-mw-section-id="-1"><h2 about="#mwt1" typeof="mw:Transclusion" id="1.2" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"==1.2==\nb\n=2=\nc"}},"i":0}}]}'>1.2</h2><span about="#mwt1">
32329 </span><p about="#mwt1">b</p><span about="#mwt1">
32330 </span></section></section><section data-mw-section-id="-1" about="#mwt1"><h1 about="#mwt1" id="2">2</h1><span about="#mwt1">
32331 </span><p about="#mwt1">c</p>
32332
32333 <p>d</p>
32334 </section><section data-mw-section-id="4" data-parsoid="{}"><h1 id="3">3</h1>
32335 <p>e</p></section>
32336 !! end
32337
32338 !! test
32339 Section wrapping with uneditable lead section + div wrapping multiple sections
32340 !! options
32341 parsoid={
32342 "wrapSections": true
32343 }
32344 !! wikitext
32345 foo
32346
32347 <div style="border:1px solid red;">
32348 =1=
32349 a
32350
32351 ==1.1==
32352 b
32353
32354 =2=
32355 c
32356 </div>
32357
32358 =3=
32359 d
32360
32361 ==3.1==
32362 e
32363 !! html/parsoid
32364 <section data-mw-section-id="-1"><p>foo</p>
32365
32366 </section><section data-mw-section-id="-2"><div style="border:1px solid red;">
32367 <section data-mw-section-id="1"><h1 id="1">1</h1>
32368 <p>a</p>
32369
32370 <section data-mw-section-id="2"><h2 id="1.1">1.1</h2>
32371 <p>b</p>
32372
32373 </section></section><section data-mw-section-id="-1"><h1 id="2">2</h1>
32374 <p>c</p>
32375 </section></div>
32376
32377 </section><section data-mw-section-id="4"><h1 id="3">3</h1>
32378 <p>d</p>
32379
32380 <section data-mw-section-id="5"><h2 id="3.1">3.1</h2>
32381 <p>e</p>
32382 </section></section>
32383 !! end
32384
32385 !! test
32386 Section wrapping with editable lead section + div overlapping multiple sections
32387 !! options
32388 parsoid={
32389 "wrapSections": true
32390 }
32391 !! wikitext
32392 foo
32393
32394 =1=
32395 a
32396 <div style="border:1px solid red;">
32397 b
32398
32399 ==1.1==
32400 c
32401
32402 =2=
32403 d
32404 </div>
32405 e
32406
32407 =3=
32408 f
32409
32410 ==3.1==
32411 g
32412 !! html/parsoid
32413 <section data-mw-section-id="0"><p>foo</p>
32414
32415 </section><section data-mw-section-id="-1"><h1 id="1">1</h1>
32416 <p>a</p>
32417 </section><section data-mw-section-id="-2"><div style="border:1px solid red;">
32418 <p>b</p>
32419
32420 <section data-mw-section-id="2"><h2 id="1.1">1.1</h2>
32421 <p>c</p>
32422
32423 </section><section data-mw-section-id="-1"><h1 id="2">2</h1>
32424 <p>d</p>
32425 </section></div>
32426 <p>e</p>
32427
32428 </section><section data-mw-section-id="4"><h1 id="3">3</h1>
32429 <p>f</p>
32430
32431 <section data-mw-section-id="5"><h2 id="3.1">3.1</h2>
32432 <p>g</p>
32433 </section></section>
32434 !! end
32435
32436 !! test
32437 HTML header tags should not be wrapped in section tags
32438 !! options
32439 parsoid={
32440 "wrapSections": true
32441 }
32442 !! wikitext
32443 foo
32444
32445 <h1>a</h1>
32446
32447 =b=
32448
32449 <h1>c</h1>
32450
32451 =d=
32452 !! html/parsoid
32453 <section data-mw-section-id="0"><p>foo</p>
32454
32455 <h1 id="a" data-parsoid='{"stx":"html"}'>a</h1>
32456
32457 </section><section data-mw-section-id="1"><h1 id="b">b</h1>
32458
32459 <h1 id="c" data-parsoid='{"stx":"html"}'>c</h1>
32460
32461 </section><section data-mw-section-id="2"><h1 id="d">d</h1></section>
32462 !! end
32463
32464 !! test
32465 Lead section containing only whitespace and comments.
32466 !! options
32467 parsoid={
32468 "wrapSections": true
32469 }
32470 !! wikitext
32471
32472 <!-- this is a comment, presumably significant to editors -->
32473 =1=
32474 a
32475
32476 =2=
32477 b
32478 !! html/parsoid
32479 <section data-mw-section-id="0" data-parsoid="{}">
32480 <!-- this is a comment, presumably significant to editors -->
32481 </section><section data-mw-section-id="1"><h1 id="1">1</h1>
32482 <p>a</p>
32483
32484 </section><section data-mw-section-id="2"><h1 id="2">2</h1>
32485 <p>b</p></section>
32486 !! end
32487
32488 !! test
32489 Pseudo-sections emitted by templates should have id -2
32490 !! options
32491 parsoid={
32492 "wrapSections": true
32493 }
32494 !! wikitext
32495 foo
32496 {{echo|<div>
32497 ==a==
32498 ==b==
32499 </div>
32500 }}
32501 !! html/parsoid
32502 <section data-mw-section-id="-1"><p>foo</p>
32503 </section><section data-mw-section-id="-2"><div 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;div>\n==a==\n==b==\n&lt;/div>\n"}},"i":0}}]}'>
32504 <section data-mw-section-id="-1"><h2 id="a">a</h2>
32505 </section><section data-mw-section-id="-1"><h2 id="b">b</h2>
32506 </section></div><span about="#mwt1">
32507 </span></section>
32508 !! end
32509
32510 ##########################################################################
32511 Tests demonstrating white-space insensitivity in input wikitext
32512 for wikitext headings, wikitext list items, and wikitext table captions,
32513 headings, and cells. HTML versions of the same should preserve whitespace.
32514 ##########################################################################
32515 !! test
32516 Trim whitespace in wikitext headings, list items, table captions, headings, and cells
32517 !! options
32518 parsoid={
32519 "modes": ["wt2html"],
32520 "preserveIEW": true
32521 }
32522 !! wikitext
32523 __NOTOC__
32524 == <!--c1--> <!--c2--> Spaces <!--c3--> <!--c4--> ==
32525 == <!--c1--> <!--c2--> Tabs <!--c3--><!--c4--> ==
32526 == <!--Headings with fallback ids--> Личная жизнь ==
32527 * <!--c1--> <!--c2--> List item <!--c3--> <!--c4-->
32528 ; <!--term to define--> term : <!--term's definition--> definition
32529 {|
32530 |+ <!--c1--> <!--c2--> Table Caption <!--c3--> <!--c4-->
32531 |-
32532 ! <!--c1--> <!--c2--> Table Heading 1 <!--c3--> <!--c4--> !! Table Heading 2 <!--c5-->
32533 |-
32534 | <!--c1--> <!--c2--> Table Cell 1 <!--c3--> <!--c4--> || Table Cell 2 <!--c5-->
32535 |-
32536 | class="foo" || <!--c1--> <!--c2--> Table Cell 3 <!--c3--> <!--c4-->
32537 |-
32538 | <!--c1--> testing [[one|two]] <!--c2--> | <!--c3--> some content
32539 |}
32540 : {|
32541 | <!--c1--> <!--c2--> Table Cell 1 <!--c3--> <!--c4--> || Table Cell 2 <!--c5-->
32542 |} foo <!--c1-->
32543 !! html/php+tidy
32544 <h2><span class="mw-headline" id="Spaces">Spaces</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: Spaces">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
32545 <h2><span class="mw-headline" id="Tabs">Tabs</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: Tabs">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
32546 <h2><span class="mw-headline" id=".D0.9B.D0.B8.D1.87.D0.BD.D0.B0.D1.8F_.D0.B6.D0.B8.D0.B7.D0.BD.D1.8C">Личная жизнь</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>
32547 <ul><li>List item</li></ul>
32548 <dl><dt>term&#160;</dt>
32549 <dd>definition</dd></dl>
32550 <table>
32551 <caption>Table Caption
32552 </caption>
32553 <tbody><tr>
32554 <th>Table Heading 1</th>
32555 <th>Table Heading 2
32556 </th></tr>
32557 <tr>
32558 <td>Table Cell 1</td>
32559 <td>Table Cell 2
32560 </td></tr>
32561 <tr>
32562 <td>class="foo"</td>
32563 <td>Table Cell 3
32564 </td></tr>
32565 <tr>
32566 <td>testing <a href="/index.php?title=One&amp;action=edit&amp;redlink=1" class="new" title="One (page does not exist)">two</a> | some content
32567 </td></tr></tbody></table>
32568 <dl><dd><table>
32569 <tbody><tr>
32570 <td>Table Cell 1</td>
32571 <td>Table Cell 2
32572 </td></tr></tbody></table> foo</dd></dl>
32573 !! html/parsoid
32574 <meta property="mw:PageProp/notoc">
32575 <h2 id="Spaces"><!--c1--><!--c2-->Spaces<!--c3--><!--c4--></h2>
32576 <h2 id="Tabs"><!--c1--><!--c2-->Tabs<!--c3--><!--c4--></h2>
32577 <h2 id="Личная_жизнь"><span id=".D0.9B.D0.B8.D1.87.D0.BD.D0.B0.D1.8F_.D0.B6.D0.B8.D0.B7.D0.BD.D1.8C" typeof="mw:FallbackId"></span><!--Headings with fallback ids-->Личная жизнь</h2>
32578 <ul><li><!--c1--><!--c2-->List item<!--c3--><!--c4--></li></ul>
32579 <dl><dt><!--term to define-->term&nbsp;</dt><dd><!--term's definition-->definition</dd></dl>
32580 <table>
32581 <caption><!--c1--><!--c2-->Table Caption<!--c3--><!--c4--></caption>
32582 <tbody><tr>
32583 <th><!--c1--><!--c2-->Table Heading 1<!--c3--><!--c4--></th><th>Table Heading 2<!--c5--></th></tr>
32584 <tr>
32585 <td><!--c1--><!--c2-->Table Cell 1<!--c3--><!--c4--></td><td>Table Cell 2<!--c5--></td></tr>
32586 <tr>
32587 <td>class="foo"</td><td><!--c1--><!--c2-->Table Cell 3<!--c3--><!--c4--></td></tr>
32588 <tr>
32589 <td><!--c1-->testing <a rel="mw:WikiLink" href="./One" title="One">two</a> <!--c2--> | <!--c3--> some content</td></tr>
32590 </tbody></table>
32591 <dl><dd><table>
32592 <tbody><tr><td><!--c1--><!--c2-->Table Cell 1<!--c3--><!--c4--></td><td>Table Cell 2<!--c5--></td></tr>
32593 </tbody></table> foo<!--c1--></dd></dl>
32594 !! end
32595
32596 # Looks like <caption> is not accepted in HTML
32597 !! test
32598 Do not trim whitespace in HTML headings, list items, table captions, headings, and cells
32599 !! options
32600 parsoid={
32601 "modes": ["wt2html"],
32602 "preserveIEW": true
32603 }
32604 !! wikitext
32605 __NOTOC__
32606 <h2> <!--c1--> <!--c2--> Heading <!--c3--> <!--c4--> </h2>
32607 <ul><li> <!--c1--> <!--c2--> List item <!--c3--> <!--c4--> </li></ul>
32608 <table>
32609 <tr><th> <!--c1--> <!--c2--> Table Heading <!--c3--> <!--c4--> <th></tr>
32610 <tr><td> <!--c1--> <!--c2--> Table Cell <!--c3--> <!--c4--> <th></tr>
32611 </table>
32612 !! html/php+tidy
32613 <h2><span class="mw-headline" id="Heading"> Heading </span></h2>
32614 <ul><li> List item </li></ul>
32615 <table>
32616 <tbody><tr><th> Table Heading </th><th></th></tr>
32617 <tr><td> Table Cell </td><th></th></tr>
32618 </tbody></table>
32619 !! html/parsoid
32620 <meta property="mw:PageProp/notoc"/>
32621 <h2 id="Heading"> <!--c1--> <!--c2--> Heading <!--c3--> <!--c4--> </h2>
32622 <ul><li> <!--c1--> <!--c2--> List item <!--c3--> <!--c4--> </li></ul>
32623 <table>
32624 <tbody><tr><th> <!--c1--> <!--c2--> Table Heading <!--c3--> <!--c4--> </th><th></th></tr>
32625 <tr><td> <!--c1--> <!--c2--> Table Cell <!--c3--> <!--c4--> </td><th></th></tr>
32626 </tbody></table>
32627 !! end
32628
32629 !! test
32630 Do not trim whitespace in links and quotes
32631 !! options
32632 parsoid={
32633 "modes": ["wt2html"],
32634 "preserveIEW": true
32635 }
32636 !! wikitext
32637 foo '' <!--c1--> italic <!--c2--> '' and ''' <!--c3--> bold <!--c4--> '''
32638 [[Foo| some text ]]
32639 !! html/php+tidy
32640 <p>foo <i> italic </i> and <b> bold </b>
32641 <a href="/wiki/Foo" title="Foo"> some text </a>
32642 </p>
32643 !! html/parsoid
32644 <p>foo <i> <!--c1--> italic <!--c2--> </i> and <b> <!--c3--> bold <!--c4--> </b>
32645 <a rel="mw:WikiLink" href="./Foo" title="Foo"> some text </a></p>
32646 !! end
32647
32648 !! test
32649 Remove p tags surrounding a single element in a figcaption
32650 !! options
32651 parsoid=html2wt
32652 !! wikitext
32653 [[File:Foobar.jpg|right|200x200px|Caption]]
32654 !! html/parsoid
32655 <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><p>Caption</p></figcaption></figure>
32656 !! end
32657
32658 !! test
32659 Selser preserves lack of newline before list and allows newline after the list
32660 !! options
32661 parsoid={
32662 "modes": ["selser"],
32663 "scrubWikitext": true,
32664 "changes": [
32665 [ "ul", "after", "<p>footer</p>" ]
32666 ]
32667 }
32668 !! wikitext
32669 header
32670 *foo
32671 *bar
32672 !! wikitext/edited
32673 header
32674 *foo
32675 *bar
32676
32677 footer
32678 !! end
32679
32680
32681 !! test
32682 Selser does not introduce newlines between unedited paragraph preceding the list
32683 !! options
32684 parsoid={
32685 "modes": ["selser"],
32686 "changes": [
32687 [ "table tbody tr td p:last-child", "empty" ]
32688 ]
32689 }
32690 !! wikitext
32691 {|
32692 |
32693 header
32694 *foo
32695 *bar
32696 footer
32697 |}
32698 !! wikitext/edited
32699 {|
32700 |
32701 header
32702 *foo
32703 *bar
32704
32705 |}
32706 !! end
32707
32708 !! test
32709 Selser does not introduce newlines between unedited paragraph following the list
32710 !! options
32711 parsoid={
32712 "modes": ["selser"],
32713 "changes": [
32714 [ "table tbody tr td p:first-child", "empty" ]
32715 ]
32716 }
32717 !! wikitext
32718 {|
32719 |
32720 header
32721 *foo
32722 *bar
32723 footer
32724 |}
32725 !! wikitext/edited
32726 {|
32727 |
32728
32729 *foo
32730 *bar
32731 footer
32732 |}
32733 !! end
32734
32735 !! test
32736 Remove a list item but do not insert newline above list
32737 !! options
32738 parsoid={
32739 "modes": ["selser"],
32740 "changes": [
32741 [ "ul li:last-child", "remove" ]
32742 ]
32743 }
32744 !! wikitext
32745 header
32746 *foo
32747 *bar
32748 footer
32749 !! wikitext/edited
32750 header
32751 *foo
32752 footer
32753 !! end