a73d036b48ac9836a47bdd43efcf18c31d27526b
[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, wgMediaInTargetLanguage
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 wgMediaInTargetLanguage = true
15959 !! wikitext
15960 [[File:Foobar.svg]] [[File:Foobar.svg|lang=en]]
15961 !! html/php
15962 <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>
15963 </p>
15964 !! end
15965
15966 !! test
15967 SVG thumbnails in page language not present in the file
15968 !! options
15969 language=de
15970 wgMediaInTargetLanguage = true
15971 !! wikitext
15972 [[File:Foobar.svg]] [[File:Foobar.svg|lang=ru]]
15973 !! html/php
15974 <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>
15975 </p>
15976 !! end
15977
15978 !! test
15979 T3887: A ISBN with a thumbnail
15980 !! wikitext
15981 [[File:Foobar.jpg|thumb|ISBN 1235467890]]
15982 !! html/php
15983 <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>
15984
15985 !! html/parsoid
15986 <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>
15987 !! end
15988
15989 !! test
15990 T3887: A RFC with a thumbnail
15991 !! wikitext
15992 [[File:Foobar.jpg|thumb|This is RFC 12354]]
15993 !! html/php
15994 <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>
15995
15996 !! html/parsoid
15997 <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>
15998 !! end
15999
16000 !! test
16001 T3887: A mailto link with a thumbnail
16002 !! wikitext
16003 [[File:Foobar.jpg|thumb|Please mailto:nobody@example.com]]
16004 !! html/php
16005 <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>
16006
16007 !! html/parsoid
16008 <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>
16009 !! end
16010
16011 # Pending resolution to T2368
16012 !! test
16013 T2648: Frameless image caption with a link
16014 !! wikitext
16015 [[File:Foobar.jpg|text with a [[link]] in it]]
16016 !! html/php
16017 <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>
16018 </p>
16019 !! html/parsoid
16020 <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>
16021 !! end
16022
16023 !! test
16024 T2648: Frameless image caption with a link (suffix)
16025 !! wikitext
16026 [[File:Foobar.jpg|text with a [[link]]foo in it]]
16027 !! html/php
16028 <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>
16029 </p>
16030 !! html/parsoid
16031 <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>
16032 !! end
16033
16034 !! test
16035 T2648: Frameless image caption with an interwiki link
16036 !! wikitext
16037 [[File:Foobar.jpg|text with a [[MeatBall:Link]] in it]]
16038 !! html/php
16039 <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>
16040 </p>
16041 !! html/parsoid
16042 <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>
16043 !! end
16044
16045 !! test
16046 T2648: Frameless image caption with a piped interwiki link
16047 !! wikitext
16048 [[File:Foobar.jpg|text with a [[MeatBall:Link|link]] in it]]
16049 !! html/php
16050 <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>
16051 </p>
16052 !! html/parsoid
16053 <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>
16054 !! end
16055
16056 !! test
16057 T107474: Frameless image caption with <nowiki>
16058 !! wikitext
16059 [[File:Foobar.jpg|<nowiki>text with a [[MeatBall:Link|link]] in it</nowiki>]]
16060 !! html/parsoid
16061 <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>
16062 !! end
16063
16064 !! test
16065 Escape HTML special chars in image alt text
16066 !! wikitext
16067 [[File:Foobar.jpg|& < > "]]
16068 !! html/php
16069 <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>
16070 </p>
16071 !! html/parsoid
16072 <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>
16073 !! end
16074
16075 !! test
16076 Escape HTML special chars in image alt text with LanguageConverter
16077 !! options
16078 language=zh
16079 !! wikitext
16080 [[File:Foobar.jpg|& < > "]]
16081 !! html/php
16082 <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>
16083 </p>
16084 !! html/parsoid
16085 <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>
16086 !! end
16087
16088 !! test
16089 Entities in file name and attributes
16090 !! wikitext
16091 [[File:7%25 solution.gif|manualthumb=7%25 solution.gif|link=7%25 solution|[[7%25 solution]]]]
16092 !! html/php
16093 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=7%25_solution.gif" class="new" title="File:7% solution.gif">7% solution</a>
16094 </p>
16095 !! html/parsoid
16096 <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>
16097 !! end
16098
16099 !! test
16100 T2499: Alt text should have &#1234;, not &amp;1234;
16101 !! wikitext
16102 [[File:Foobar.jpg|&#9792;]]
16103 !! html/php
16104 <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>
16105 </p>
16106 !! html/parsoid
16107 <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>
16108 !! end
16109
16110 !! test
16111 Broken image caption with link
16112 !! options
16113 parsoid=wt2html,wt2wt,html2html
16114 !! wikitext
16115 [[Image:Foobar.jpg|thumb|This is a broken caption. But [[Main Page|this]] is just an ordinary link.
16116 !! html/php
16117 <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.
16118 </p>
16119 !! html/parsoid
16120 <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>
16121 !! end
16122
16123 !! test
16124 Image caption containing another image
16125 !! wikitext
16126 [[File:Foobar.jpg|thumb|This is a caption with another [[File:Thumb.png|image]] inside it!]]
16127 !! html/php
16128 <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>
16129
16130 !! html/parsoid
16131 <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>
16132 !! end
16133
16134 !! test
16135 Image: caption containing a newline
16136 !! wikitext
16137 [[File:Foobar.jpg|This
16138 *is some text]]
16139 !! html/php
16140 <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>
16141 </p>
16142 !! html/parsoid
16143 <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>
16144 !!end
16145
16146 !!test
16147 Image: caption containing leading space
16148 (The leading space should not trigger nowiki escaping in wt2wt mode)
16149 !! wikitext
16150 [[File:Foobar.jpg|thumb| bar]]
16151 !! html/php
16152 <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>
16153
16154 !! html/parsoid
16155 <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>
16156 !!end
16157
16158 # html/php output not have newlines after table, td, th, etc. because
16159 # Linker::makeThumbLink2() replaces the newlines with spaces since
16160 # the table is inside a caption.
16161 # FIXME: Verify if that circa 2004 fix is still required.
16162 !! test
16163 Image: caption containing a table
16164 !! options
16165 parsoid=wt2html,wt2wt,html2html
16166 !! wikitext
16167 [[Image:Foobar.jpg|thumb|200px|This is an example image thumbnail caption with a table
16168 {|
16169 !Foo!!Bar
16170 |-
16171 |Foo1||Bar1
16172 |}
16173 and some more text.]]
16174 !! html/php
16175 <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>
16176
16177 !! html/parsoid
16178 <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
16179 <table>
16180 <tbody>
16181 <tr><th>Foo</th><th>Bar</th></tr>
16182 <tr>
16183 <td>Foo1</td>
16184 <td>Bar1</td></tr></tbody></table>and some more text.</figcaption></figure>
16185 !! end
16186
16187 !! test
16188 T5090: External links other than http: in image captions
16189 !! wikitext
16190 [[File:Foobar.jpg|thumb|200x200px|This caption has [irc://example.net irc] and [https://example.com Secure] ext links in it.]]
16191 !! html/php
16192 <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>
16193
16194 !! html/parsoid
16195 <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>
16196 !! end
16197
16198 !! test
16199 Custom class
16200 !! options
16201 parsoid=wt2html,wt2wt,html2html
16202 !! wikitext
16203 [[Image:foobar.jpg|a|class=b]]
16204 !! html/php
16205 <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>
16206 </p>
16207 !! html/parsoid
16208 <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>
16209 !! end
16210
16211 !! test
16212 Localized image handling (1).
16213 !! options
16214 parsoid=wt2html,wt2wt,html2html
16215 language=es
16216 !! wikitext
16217 [[Archivo:Foobar.jpg|izquierda|enlace=foo|caption]]
16218 !! html/php
16219 <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>
16220
16221 !! html/parsoid
16222 <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>
16223 !! end
16224
16225 !! test
16226 Localized image handling (2).
16227 !! options
16228 thumbsize=220
16229 parsoid=wt2html,wt2wt,html2html
16230 language=es
16231 !! wikitext
16232 [[Archivo:Foobar.jpg|miniatura|izquierda|enlace=foo|caption]]
16233 !! html/php
16234 <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>
16235
16236 !! html/parsoid
16237 <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>
16238 !! end
16239
16240 !! test
16241 Localized image handling (3).
16242 !! options
16243 language=fa
16244 parsoid=html2wt
16245 !! html/parsoid
16246 <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>
16247 !! wikitext
16248 [[File:Foobar.jpg|بندانگشتی]]
16249 !! end
16250
16251 !! test
16252 "border", "frameless" and "class" attributes on an image.
16253 !! options
16254 thumbsize=220
16255 parsoid=wt2html,wt2wt,html2html
16256 !! wikitext
16257 [[File:Foobar.jpg|frameless|border|class=extra|caption]]
16258 !! html/php
16259 <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>
16260 </p>
16261 !! html/parsoid
16262 <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>
16263 !! end
16264
16265 # Note that 'right' is the default alignment, despite the misspelled 'righ' below
16266 !! test
16267 Invalid image attributes (T64500)
16268 !! options
16269 thumbsize=220
16270 parsoid=wt2html,wt2wt,html2html
16271 !! wikitext
16272 [[File:Foobar.jpg|thumb|float|left|caption]]
16273
16274 [[File:Foobar.jpg|thumb|righ|caption]]
16275
16276 [[File:Foobar.jpg|bogus1|thumb|bogus2|left|bogus3|caption]]
16277 !! html/php
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 <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>
16280 <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>
16281
16282 !! html/parsoid
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 <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>
16285 <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>
16286 !! end
16287
16288 !! article
16289 File:Barfoo.jpg
16290 !! text
16291 #REDIRECT [[File:Barfoo.jpg]]
16292 !! endarticle
16293
16294 # FIXME: Parsoid should run this test -- but we'd need to teach the
16295 # mockAPI about the redirected Barfoo.jpg image.
16296 !! test
16297 Redirected image
16298 !! wikitext
16299 [[Image:Barfoo.jpg]]
16300 !! html/php
16301 <p><a href="/wiki/File:Barfoo.jpg" class="mw-redirect" title="File:Barfoo.jpg">File:Barfoo.jpg</a>
16302 </p>
16303 !! end
16304
16305 !! test
16306 Missing image with uploads disabled
16307 !! options
16308 wgEnableUploads=0
16309 !! wikitext
16310 [[File:Foobaz.jpg]]
16311 !! html/php
16312 <p><a href="/wiki/File:Foobaz.jpg" title="File:Foobaz.jpg">File:Foobaz.jpg</a>
16313 </p>
16314 !! html/parsoid
16315 <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>
16316 !! end
16317
16318 # Parsoid-specific testing for images
16319 # https://www.mediawiki.org/wiki/Parsoid/MediaWiki_DOM_spec#Images
16320 # Currently imperfect due to a flaw in the Parsoid testrunner
16321 # Work in progress
16322 # THESE TESTS SHOULD BE MOVED UP and merged with the php-specific
16323 # image tests.
16324
16325 !! test
16326 Parsoid-specific image handling - simple image with size and middle alignment
16327 !! wikitext
16328 [[File:Foobar.jpg|middle|50px]]
16329 !! html/parsoid
16330 <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>
16331 !! end
16332
16333 !! test
16334 Parsoid-specific image handling - simple image with size, middle alignment, non-standard namespace alias
16335 !! options
16336 parsoid=wt2wt,wt2html,html2html
16337 !! wikitext
16338 [[Image:Foobar.jpg|middle|50px]]
16339 !! html/parsoid
16340 <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>
16341 !! end
16342
16343 !! test
16344 Parsoid-specific image handling - simple image with size and middle alignment (existing content)
16345 !! wikitext
16346 [[File:Foobar.jpg|50px|middle]]
16347 !! html/parsoid
16348 <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>
16349 !! end
16350
16351 !! test
16352 Parsoid-specific image handling - simple image with size and middle alignment and non-standard namespace name
16353 !! options
16354 parsoid=wt2html,wt2wt,html2html
16355 !! wikitext
16356 [[Image:Foobar.jpg|50px|middle]]
16357 !! html/parsoid
16358 <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>
16359 !! end
16360
16361 !! test
16362 Parsoid-specific image handling - simple image with both sizes, a baseline alignment, and a caption
16363 !! wikitext
16364 [[File:Foobar.jpg|500x10px|baseline|caption]]
16365 !! html/parsoid
16366 <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>
16367 !! end
16368
16369 !! test
16370 Parsoid-specific image handling - simple image with border and size spec
16371 !! wikitext
16372 [[File:Foobar.jpg|50px|border|caption]]
16373 !! html/parsoid
16374 <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>
16375 !! end
16376
16377 !! test
16378 Parsoid-specific image handling - thumbnail with halign, valign, and caption
16379 !! options
16380 parsoid=wt2html,html2html
16381 !! wikitext
16382 [[File:Foobar.jpg|left|baseline|thumb|caption content]]
16383 !! html/parsoid
16384 <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>
16385 !! end
16386
16387 !! test
16388 Parsoid-specific image handling - thumbnail with halign, valign, and caption (existing content)
16389 !! options
16390 parsoid=wt2html,html2html
16391 !! wikitext
16392 [[File:Foobar.jpg|thumb|left|baseline|caption content]]
16393 !! html/parsoid
16394 <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>
16395 !! end
16396
16397 !! test
16398 Parsoid-specific image handling - thumbnail with specific size, halign, valign, and caption
16399 !! options
16400 parsoid=wt2html,html2html
16401 !! wikitext
16402 [[Image:Foobar.jpg|right|middle|thumb|50x50px|caption]]
16403 !! html/parsoid
16404 <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>
16405 !! end
16406
16407 !! test
16408 Parsoid-specific image handling - thumbnail with specific size, halign, valign, and caption (existing content)
16409 !! options
16410 parsoid=wt2html,html2html
16411 !! wikitext
16412 [[File:Foobar.jpg|thumb|50x50px|right|middle|caption]]
16413 !! html/parsoid
16414 <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>
16415 !! end
16416
16417 !! test
16418 Parsoid-specific image handling - framed image with specific size and caption (size is ignored)
16419 !! options
16420 parsoid=wt2html,wt2wt,html2html
16421 !! wikitext
16422 [[File:Foobar.jpg|frame|500x50px|caption]]
16423 !! html/parsoid
16424 <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>
16425 !! end
16426
16427 !! test
16428 Parsoid-specific image handling - framed image with specific size, halign, valign, and caption (size is ignored)
16429 !! options
16430 parsoid=wt2html,html2html
16431 !! wikitext
16432 [[File:Foobar.jpg|left|baseline|frame|500x50px|caption]]
16433 !! html/parsoid
16434 <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>
16435 !! end
16436
16437 !! test
16438 Parsoid-specific image handling - frameless image with specific size, border, and caption
16439 !! wikitext
16440 [[File:Foobar.jpg|frameless|442x50px|border|caption]]
16441 !! html/parsoid
16442 <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>
16443 !! end
16444
16445 !! test
16446 Parsoid-specific image handling - simple image with a formatted caption
16447 !! wikitext
16448 [[File:Foobar.jpg|<table><tr><td>a</td><td>b</td></tr><tr><td>c</td></tr></table>]]
16449 !! html/parsoid
16450 <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>
16451 !! end
16452
16453 !! test
16454 Parsoid-specific image handling - caption with a template in it
16455 !! wikitext
16456 [[File:Foobar.jpg|thumb|200x23px|This caption has a {{echo|transclusion}} in it.]]
16457 !! html/parsoid
16458 <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>
16459 !! end
16460
16461 !! test
16462 Parsoid-specific image handling - caption with unbalanced tags in it
16463 !! options
16464 parsoid=wt2html,wt2wt,html2html
16465 !! wikitext
16466 foo
16467 [[File:Foobar.jpg|thumb|200x200px|This caption has a <center>unbalanced tag in it.]]
16468 bar
16469 !! html/parsoid
16470 <p>foo</p>
16471 <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>
16472 <p>bar</p>
16473 !! end
16474
16475 !! test
16476 Parsoid-specific image handling - empty caption (1)
16477 !! options
16478 parsoid=wt2html,wt2wt
16479 !! wikitext
16480 [[File:Foobar.jpg|thumb|]]
16481 !! html/parsoid
16482 <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>
16483 !! end
16484
16485 # empty captions don't get serialized unless we're in the "round trip" case
16486 !! test
16487 Parsoid-specific image handling - empty caption (2)
16488 !! options
16489 parsoid=html2wt
16490 !! html/parsoid
16491 <figure class="mw-default-size" typeof="mw:Image/Thumb">
16492 <a href="./File:Foobar.jpg">
16493 <img resource="./File:Foobar.jpg"
16494 src="//example.com/images/3/3a/Foobar.jpg"
16495 data-file-width="1941" data-file-height="220" data-file-type="bitmap"
16496 height="25" width="220"/>
16497 </a>
16498 <figcaption></figcaption>
16499 </figure>
16500 !! wikitext
16501 [[File:Foobar.jpg|thumb]]
16502 !! end
16503
16504 !! test
16505 Parsoid-specific image handling - whitespace caption
16506 !! wikitext
16507 [[File:Foobar.jpg|thumb| ]]
16508 !! html/parsoid
16509 <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>
16510 !! end
16511
16512 !! test
16513 Parsoid-specific image handling - lang option
16514 !! wikitext
16515 foo
16516 [[File:Foobar.svg|lang=de|caption]]
16517 bar
16518 !! html/parsoid
16519 <p>foo
16520 <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>
16521 bar</p>
16522 !! end
16523
16524 ## Edge case bugs in Parsoid from T93580
16525 !! test
16526 T93580: 1. Templated <ref> inside block images
16527 !! wikitext
16528 [[File:Foobar.jpg|thumb|Caption with templated ref: {{echo|<ref>foo</ref>}}]]
16529
16530 <references />
16531 !! html/parsoid
16532 <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>
16533
16534 <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>
16535 !! end
16536
16537 !! test
16538 T93580: 2. <ref> inside inline images
16539 !! wikitext
16540 [[File:Foobar.jpg|Undisplayed caption in inline image with ref: <ref>foo</ref>]]
16541
16542 <references />
16543 !! html/parsoid
16544 <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>
16545
16546 <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>
16547 !! end
16548
16549 !! test
16550 T93580: 3. Templated <ref> inside inline images
16551 !! wikitext
16552 [[File:Foobar.jpg|Undisplayed caption in inline image with ref: {{echo|<ref>{{echo|foo}}</ref>}}]]
16553
16554 <references />
16555 !! html/parsoid
16556 <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>
16557
16558 <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>
16559 !! end
16560
16561 ###
16562 ### Subpages
16563 ###
16564 !! article
16565 Subpage test/subpage
16566 !! text
16567 foo
16568 !! endarticle
16569
16570 !! test
16571 Subpage link
16572 !! options
16573 subpage title=[[Subpage test]]
16574 !! wikitext
16575 [[/subpage]]
16576 !! html
16577 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a>
16578 </p>
16579 !! end
16580
16581 !! test
16582 Subpage noslash link
16583 !! options
16584 subpage title=[[Subpage test]]
16585 !! wikitext
16586 [[/subpage/]]
16587 !! html
16588 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">subpage</a>
16589 </p>
16590 !! end
16591
16592 !! article
16593 Subpage test/1/2/subpage
16594 !! text
16595 blah
16596 !! endarticle
16597
16598 !! test
16599 Relative subpage noslash link
16600 !! options
16601 parsoid=wt2wt,wt2html,html2html
16602 subpage title=[[Subpage test/1/2/3/4]]
16603 !! wikitext
16604 [[../../subpage/]]
16605
16606 [[../../subpage]]
16607 !! html/php
16608 <p><a href="/wiki/Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">subpage</a>
16609 </p><p><a href="/wiki/Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">Subpage test/1/2/subpage</a>
16610 </p>
16611 !! html/parsoid
16612 <p><a rel="mw:WikiLink" href="./Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">subpage</a></p>
16613 <p><a rel="mw:WikiLink" href="./Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">Subpage_test/1/2/subpage</a></p>
16614 !! end
16615
16616 !! test
16617 Parsoid: dot-slash prefixed wikilinks
16618 !! wikitext
16619 [[./foo]]
16620
16621 [[././bar]]
16622
16623 [[././baz/]]
16624 !! html/php
16625 <p>[[./foo]]
16626 </p><p>[[././bar]]
16627 </p><p>[[././baz/]]
16628 </p>
16629 !! html/parsoid
16630 <p>[[./foo]]
16631 </p><p>[[././bar]]
16632 </p><p>[[././baz/]]
16633 </p>
16634 !! end
16635
16636 !! test
16637 Render invalid page names as plain text (T53090)
16638 !! wikitext
16639 [[./../foo|bar]]
16640 [[foo�|bar]]
16641 [[foo/.|bar]]
16642 [[foo/..|bar]]
16643 [[foo~~~bar]]
16644 [[foo>bar]]
16645 [[foo[bar]]
16646 [[.]]
16647 [[..]]
16648 [[foo././bar]]
16649 [[foo[http://example.com]xyz]]
16650
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 [[{{echo|foo]bar}}]]
16661 [[{{echo|foo<bar}}]]
16662 !!html/php
16663 <p>[[./../foo|bar]]
16664 [[foo�|bar]]
16665 [[foo/.|bar]]
16666 [[foo/..|bar]]
16667 [[foo~~~bar]]
16668 [[foo&gt;bar]]
16669 [[foo[bar]]
16670 [[.]]
16671 [[..]]
16672 [[foo././bar]]
16673 [[foo<a rel="nofollow" class="external autonumber" href="http://example.com">[1]</a>xyz]]
16674 </p><p>[[./../foo|bar]]
16675 [[foo/.|bar]]
16676 [[foo/..|bar]]
16677 [[foo~~~~bar]]
16678 [[foo&gt;bar]]
16679 [[foo././bar]]
16680 [[foo{bar]]
16681 [[foo}bar]]
16682 [[foo[bar]]
16683 [[foo]bar]]
16684 [[foo&lt;bar]]
16685 </p>
16686 !!html/parsoid
16687 <p>[[./../foo|bar]]
16688 [[foo�|bar]]
16689 [[foo/.|bar]]
16690 [[foo/..|bar]]
16691 [[foo~~~bar]]
16692 [[foo>bar]]
16693 [[foo[bar]]
16694 [[.]]
16695 [[..]]
16696 [[foo././bar]]
16697 [[foo<a rel="mw:ExtLink" class="external autonumber" href="http://example.com"></a>xyz]]</p>
16698
16699 <p>[[<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/."}},"i":0}}]}'>foo/.</span>|bar]]
16701 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo/.."}},"i":0}}]}'>foo/..</span>|bar]]
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[bar"}},"i":0}}]}'>foo[bar</span>]]
16708 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo]bar"}},"i":0}}]}'>foo]bar</span>]]
16709 [[<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>
16710 !!end
16711
16712 !! test
16713 Disabled subpages
16714 !! wikitext
16715 [[/subpage]]
16716 !! html
16717 <p><a href="/index.php?title=/subpage&amp;action=edit&amp;redlink=1" class="new" title="/subpage (page does not exist)">/subpage</a>
16718 </p>
16719 !! end
16720
16721 !! test
16722 T2561: {{/Subpage}}
16723 !! options
16724 subpage title=[[Page]]
16725 !! wikitext
16726 {{/Subpage}}
16727 !! html
16728 <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>
16729 </p>
16730 !! end
16731
16732 ###
16733 ### Categories
16734 ###
16735 !! article
16736 Category:MediaWiki User's Guide
16737 !! text
16738 blah
16739 !! endarticle
16740
16741 !! test
16742 Link to category
16743 !! wikitext
16744 [[:Category:MediaWiki User's Guide]]
16745 !! html
16746 <p><a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User&#39;s Guide">Category:MediaWiki User's Guide</a>
16747 </p>
16748 !! end
16749
16750 !! test
16751 Simple category
16752 !! options
16753 cat
16754 !! wikitext
16755 [[Category:MediaWiki User's Guide]]
16756 !! html/php
16757 cat=MediaWiki_User's_Guide sort=
16758 !! html/parsoid
16759 <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"}}'/>
16760 !! end
16761
16762 !! test
16763 PAGESINCATEGORY invalid title fatal (r33546 fix)
16764 !! wikitext
16765 {{PAGESINCATEGORY:<bogus>}}
16766 !! html
16767 <p>0
16768 </p>
16769 !! end
16770
16771 !! test
16772 Category with different sort key
16773 !! options
16774 cat
16775 !! wikitext
16776 [[Category:MediaWiki User's Guide|Foo]]
16777 !! html/php
16778 cat=MediaWiki_User's_Guide sort=Foo
16779 !! html/parsoid
16780 <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"}}'/>
16781 !! end
16782
16783 !! test
16784 Category with identical sort key
16785 !! options
16786 cat
16787 !! wikitext
16788 [[Category:MediaWiki User's Guide|MediaWiki User's Guide]]
16789 !! html/php
16790 cat=MediaWiki_User's_Guide sort=MediaWiki User's Guide
16791 !! html/parsoid
16792 <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"}}'/>
16793 !! end
16794
16795 !! test
16796 Category with empty sort key
16797 !! options
16798 cat
16799 pst
16800 !! wikitext
16801 [[Category:MediaWiki User's Guide|]]
16802 !! html/php
16803 [[Category:MediaWiki User's Guide|MediaWiki User's Guide]]
16804 !! end
16805
16806 !! test
16807 Category with empty sort key and parentheses
16808 !! options
16809 cat
16810 pst
16811 !! wikitext
16812 [[Category:Foo (bar)|]]
16813 !! html/php
16814 [[Category:Foo (bar)|Foo]]
16815 !! end
16816
16817 !! test
16818 Category with link tail
16819 !! options
16820 cat
16821 pst
16822 !! wikitext
16823 123[[Category:Foo]]456
16824 !! html/php
16825 123[[Category:Foo]]456
16826 !! end
16827
16828 !! test
16829 Category with template
16830 !! options
16831 cat
16832 pst
16833 !! wikitext
16834 [[Category:{{echo|Foo}}]]
16835 !! html/php
16836 [[Category:{{echo|Foo}}]]
16837 !! end
16838
16839 !! test
16840 Category with template in sort key
16841 !! options
16842 cat
16843 pst
16844 !! wikitext
16845 [[Category:Foo|{{echo|Bar}}]]
16846 !! html/php
16847 [[Category:Foo|{{echo|Bar}}]]
16848 !! end
16849
16850 !! test
16851 Category with template in sort key and title
16852 !! options
16853 cat
16854 pst
16855 !! wikitext
16856 [[Category:{{echo|Foo}}|{{echo|Bar}}]]
16857 !! html/php
16858 [[Category:{{echo|Foo}}|{{echo|Bar}}]]
16859 !! end
16860
16861 ## We used to, but no longer wt2wt this test since the default serializer
16862 ## will normalize all categories to serialize on their own line.
16863 ## This wikitext usage is going to be fairly uncommon in production and
16864 ## selser will take care of preserving formatting in those scenarios.
16865 !! test
16866 Category / paragraph interactions
16867 !! options
16868 parsoid=wt2html
16869 !! wikitext
16870 Foo [[Category:Baz]] Bar
16871
16872 Foo [[Category:Baz]]
16873 Bar
16874
16875 Foo
16876 [[Category:Baz]]
16877 Bar
16878
16879 Foo
16880 [[Category:Baz]] Bar
16881
16882 Foo
16883 [[Category:Baz]]
16884 [[Category:Baz]]
16885 [[Category:Baz]]
16886 Bar
16887
16888 [[Category:Baz]]
16889 [[Category:Baz]]
16890 [[Category:Baz]]
16891
16892 [[Category:Baz]]
16893 {{echo|[[Category:Baz]]}}
16894 [[Category:Baz]]
16895 !! html/php
16896 <p>Foo Bar
16897 </p><p>Foo
16898 Bar
16899 </p><p>Foo
16900 Bar
16901 </p><p>Foo Bar
16902 </p><p>Foo
16903 Bar
16904 </p>
16905 !! html/parsoid
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"/> Bar</p>
16909 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16910 <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>
16911 <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}}]}'/>
16912 <link rel="mw:PageProp/Category" href="./Category:Baz"/>
16913 !! end
16914
16915 ## We used to, but no longer wt2wt this test since the default serializer
16916 ## will normalize all categories to serialize on their own line.
16917 ## This wikitext usage is going to be fairly uncommon in production and
16918 ## selser will take care of preserving formatting in those scenarios.
16919 ##
16920 ## The whitespace on the empty line is part of the test. Please do not delete
16921 !! test
16922 1. Categories and newlines: All preceding newlines should be suppressed (courtesy T2087)
16923 !! options
16924 parsoid=wt2html
16925 !! wikitext
16926 This
16927
16928 [[Category:Foo]] and this should be part of same paragraph (not an indent-pre)
16929
16930 {{echo|[[Category:Foo]] and so should this!}}
16931 !! html/php
16932 <p>This and this should be part of same paragraph (not an indent-pre) and so should this!
16933 </p>
16934 !! html/parsoid
16935 <p>This
16936
16937 <link rel="mw:PageProp/Category" href="./Category:Foo"/> and this should be part of same paragraph (not an indent-pre)
16938
16939 <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>
16940 !! end
16941
16942 ## Parsoid will not try to wt2wt this while preserving newlines because
16943 ## it suppresses excess newlines within list items -- and we don't want to
16944 ## introduce a special case just for categories, which is, in reality somewhat
16945 ## odd behavior -- categories are unlikely to be used in list items like this
16946 ## in top-level pages and are only likely to show up in template-generated
16947 ## list items where this RT-ing is a non-issue.
16948 ##
16949 ## The whitespace on the empty line is part of the test. Please do not delete
16950 !! test
16951 2. Categories and newlines: All preceding newlines should be suppressed (courtesy T2087)
16952 !! options
16953 parsoid=wt2html
16954 !! wikitext
16955 * This
16956
16957 [[Category:Foo]] and this should be part of the same list item
16958 * So should this
16959
16960 {{echo|[[Category:Foo]] and this should be part of the same list item}}
16961 !! html/php+tidy
16962 <ul><li>This and this should be part of the same list item</li>
16963 <li>So should this and this should be part of the same list item</li></ul>
16964 !! html/parsoid
16965 <ul>
16966 <li>This <link rel="mw:PageProp/Category" href="./Category:Foo"/> and this should be part of the same list item</li>
16967 <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>
16968 </ul>
16969 !! end
16970
16971 ## Newlines and categories that follow the last item of a list
16972 ## are treated differently because this (list followed by categories)
16973 ## is an extremely common pattern on wikis.
16974 !! test
16975 3. Categories and newlines: newline suppression for last list item should RT properly
16976 !! wikitext
16977 *a
16978 *b
16979
16980 [[Category:Foo]]
16981
16982 [[Category:Bar]]
16983 [[Category:Baz]]
16984
16985 :c
16986
16987 [[Category:C]]
16988
16989 ;d
16990
16991 [[Category:D]]
16992 !! html/parsoid
16993 <ul><li>a</li>
16994 <li>b</li></ul>
16995
16996 <link rel="mw:PageProp/Category" href="./Category:Foo"/>
16997
16998 <link rel="mw:PageProp/Category" href="./Category:Bar"/>
16999 <link rel="mw:PageProp/Category" href="./Category:Baz"/>
17000
17001 <dl><dd>c</dd></dl>
17002
17003 <link rel="mw:PageProp/Category" href="./Category:C"/>
17004
17005 <dl><dt>d</dt></dl>
17006
17007 <link rel="mw:PageProp/Category" href="./Category:D"/>
17008 !! end
17009
17010 !! test
17011 4. Categories and newlines: newline suppression for last list item should RT properly
17012 !! wikitext
17013 *a
17014 ****b
17015
17016 [[Category:Foo]]
17017 !! html/parsoid
17018 <ul><li>a
17019 <ul><li><ul><li><ul><li>b</li></ul></li></ul></li></ul></li></ul>
17020
17021 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
17022 !! end
17023
17024 ## only wt2html for this to make sure the algo only applies to the rightmost path
17025 !! test
17026 5. Categories and newlines: migrateTrailingCategories dom pass should only run on the rightmost path of nested lists
17027 !! options
17028 parsoid=wt2html
17029 !! wikitext
17030 *a
17031 **b
17032 [[Category:Foo]]
17033 *c
17034 **d
17035 [[Category:Foo]]
17036 !! html/parsoid
17037 <ul><li>a
17038 <ul><li>b
17039 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/></li></ul></li>
17040 <li>c
17041 <ul><li>d</li></ul></li></ul>
17042 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
17043 !! end
17044
17045 ## We used to, but no longer wt2wt this test since the default serializer
17046 ## will normalize all categories to serialize on their own line.
17047 ## This wikitext usage is going to be fairly uncommon in production and
17048 ## selser will take care of preserving formatting in those scenarios.
17049 !! test
17050 6. Categories and newlines: migrateTrailingCategories dom pass should not migrate categories not preceded by newlines
17051 !! options
17052 parsoid=wt2html
17053 !! wikitext
17054 *a [[Category:Foo]]
17055 !! html/parsoid
17056 <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>
17057 !! end
17058
17059 # This test also demonstrates because of newline+category tunneling
17060 # through the list hander, template wrapping doesn't expand to the
17061 # containing list when the list item swallows the category.
17062 !! test
17063 7. Categories and newlines: migrateTrailingCategories dom pass should leave template content alone
17064 !! wikitext
17065 *{{echo|a
17066 [[Category:Foo]]}}
17067 !! html/parsoid
17068 <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
17069 </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>
17070 !! end
17071
17072 !! test
17073 8. Categories and newlines: migrateTrailingCategories dom pass should not get tripped by intervening templates
17074 !! wikitext
17075 *a
17076
17077 {{echo|[[Category:Foo]]
17078 [[Category:Bar]]}}
17079 [[Category:Baz]]
17080 !! html/parsoid
17081 <ul><li>a</li></ul>
17082
17083 <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">
17084 </span><link rel="mw:PageProp/Category" href="./Category:Bar" about="#mwt1" data-parsoid='{"stx":"simple","a":{"href":"./Category:Bar"},"sa":{"href":"Category:Bar"}}'/>
17085 <link rel="mw:PageProp/Category" href="./Category:Baz" data-parsoid='{"stx":"simple","a":{"href":"./Category:Baz"},"sa":{"href":"Category:Baz"}}'/>
17086 !! end
17087
17088 !! test
17089 Categories and newlines: migrateTrailingCategories dom pass should not get tripped by comments and whitespace
17090 !! wikitext
17091 *a
17092
17093 [[Category:Bar]]<!--boo1--> <!--boo2-->
17094 [[Category:Baz]]<!--boo3--> <!--boo4-->
17095 !! html/parsoid
17096 <ul><li>a</li></ul>
17097
17098 <link rel="mw:PageProp/Category" href="./Category:Bar"/><!--boo1--> <!--boo2-->
17099 <link rel="mw:PageProp/Category" href="./Category:Baz"/><!--boo3--> <!--boo4-->
17100 !! end
17101
17102 !! test
17103 Categories and newlines: should behave properly with linkprefix (T87753)
17104 !! options
17105 language=ar
17106 !! wikitext
17107 foo bar
17108 foo bar
17109 [[تصنيف:Foo]]
17110 [[تصنيف:Bar]]
17111 !! html/php
17112 <p>foo bar
17113 foo bar
17114 </p>
17115 !! html/parsoid
17116 <p>foo bar
17117 foo bar</p>
17118 <link rel="mw:PageProp/Category" href="./تصنيف:Foo"/>
17119 <link rel="mw:PageProp/Category" href="./تصنيف:Bar"/>
17120 !! end
17121
17122 !! test
17123 No regressions on internal links following category (T174639)
17124 !! options
17125 parsoid=wt2html,html2html
17126 !! wikitext
17127 [[Category:Foo]]<div>a
17128
17129 [[Foo]]</div>
17130 !! html/php
17131 <div>a
17132 <a href="/wiki/Foo" title="Foo">Foo</a></div>
17133
17134 !! html/parsoid
17135 <link rel="mw:PageProp/Category" href="./Category:Foo"/><div>a
17136
17137 <a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></div>
17138 !! end
17139
17140 # Note that Parsoid differs slightly from PHP due to T175421
17141 !! test
17142 11. Special case where only newlines separate links (T175416)
17143 !! options
17144 parsoid=wt2html,html2html
17145 !! wikitext
17146 [[Category:Foo]]
17147
17148 [[Foo]][[es:Alimento]]
17149
17150 [[Foo]]
17151 !! html/php
17152 <p><br />
17153 <a href="/wiki/Foo" title="Foo">Foo</a>
17154 </p><p><a href="/wiki/Foo" title="Foo">Foo</a>
17155 </p>
17156 !! html/parsoid
17157 <link rel="mw:PageProp/Category" href="./Category:Foo"/>
17158
17159 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></p><link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Alimento"/>
17160
17161 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></p>
17162 !! end
17163
17164 !! test
17165 Category links with multiple namespaces
17166 !! wikitext
17167 [[Category:Project:Foo]]
17168 !! html/parsoid
17169 <link rel="mw:PageProp/Category" href="./Category:Project:Foo" />
17170 !! end
17171
17172 !! test
17173 Parsoid: Serialize link to category page with colon escape
17174 !! wikitext
17175
17176 [[:Category:Foo]]
17177 [[:Category:Foo|Bar]]
17178 !! html/php+tidy
17179 <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>
17180 <a href="/index.php?title=Category:Foo&amp;action=edit&amp;redlink=1" class="new" title="Category:Foo (page does not exist)">Bar</a>
17181 </p>
17182 !! html/parsoid
17183 <p>
17184 <a rel="mw:WikiLink" href="./Category:Foo" title="Category:Foo">Category:Foo</a>
17185 <a rel="mw:WikiLink" href="./Category:Foo" title="Category:Foo">Bar</a>
17186 </p>
17187 !! end
17188
17189 # We used to, but no longer wt2wt this test since the default serializer
17190 # will normalize all categories to serialize on their own line.
17191 # This wikitext usage is going to be fairly uncommon in production and
17192 # selser will take care of preventing whitespace insertion if this
17193 # occurs in an article.
17194 #
17195 # html2html disabled for the same reason (whitespace insertion between
17196 # x and y).
17197 #
17198 # html2wt disabled because it localizes the "Category" namespace.
17199 !! test
17200 Link prefix/suffixes aren't applied to category links
17201 !! options
17202 parsoid=wt2html
17203 language=is
17204 !! wikitext
17205 x[[Category:Foo]]y
17206 !! html/php
17207 <p>xy
17208 </p>
17209 !! html/parsoid
17210 <p>x<link rel="mw:PageProp/Category" href="./Flokkur:Foo" data-parsoid=""/>y</p>
17211 !! end
17212
17213 !! test
17214 Link prefix/suffixes aren't applied to language links
17215 !! options
17216 parsoid=wt2html
17217 language=is
17218 !! wikitext
17219 x[[es:Foo]]y
17220 !! html/php
17221 <p>xy
17222 </p>
17223 !! html/parsoid
17224 <p>x<link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo" data-parsoid=""/>y</p>
17225 !! end
17226
17227 !! test
17228 Parsoid: Serialize link to file page with colon escape
17229 !! wikitext
17230
17231 [[:File:Foo.png]]
17232 [[:File:Foo.png|Bar]]
17233 !! html/php+tidy
17234 <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>
17235 <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>
17236 </p>
17237 !! html/parsoid
17238 <p>
17239 <a rel="mw:WikiLink" href="./File:Foo.png" title="File:Foo.png">File:Foo.png</a>
17240 <a rel="mw:WikiLink" href="./File:Foo.png" title="File:Foo.png">Bar</a>
17241 </p>
17242 !! end
17243
17244 !! test
17245 Parsoid: Serialize a genuine category link without colon escape
17246 !! wikitext
17247 [[Category:Foo]]
17248 [[Category:Foo|Bar]]
17249 !! html/php+tidy
17250 !! html/parsoid
17251 <link rel="mw:PageProp/Category" href="./Category:Foo">
17252 <link rel="mw:PageProp/Category" href="./Category:Foo#Bar">
17253 !! end
17254
17255 !! test
17256 Normalize hrefs properly before testing for invalid link targets (T72894)
17257 !! options
17258 parsoid=html2wt
17259 !! html/parsoid
17260 <link rel="mw:PageProp/Category" href="./Category:Toxine_bactérienne"/>
17261 !! wikitext
17262 [[Category:Toxine bactérienne]]
17263 !! end
17264
17265 !! test
17266 Parsoid: Defaultsort
17267 !! wikitext
17268 {{DEFAULTSORT:Foo}}
17269 !! html/parsoid
17270 <meta property="mw:PageProp/categorydefaultsort" content="Foo"/>
17271 !! end
17272
17273 # NOTE: mw:ExpandedAttrs is not the best typeof here. mw:Transclusion is better.
17274 # But, this is a limitation of our representation and is documented in
17275 # TemplateHandler.js in processSpecialMagicWord
17276 !! test
17277 Parsoid: Defaultsort (template-generated)
17278 !! wikitext
17279 {{{{echo|DEFAULTSORT}}:Foo}}
17280 !! html/parsoid
17281 <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"}]]}'/>
17282 !! end
17283
17284 ###
17285 ### Inter-language links
17286 ###
17287 !! test
17288 Interlanguage links
17289 !! options
17290 ill
17291 !! wikitext
17292 [[es:Alimento]]
17293 [[fr:Nourriture]]
17294 [[zh:食品]]
17295 !! html/php
17296 es:Alimento fr:Nourriture zh:食品
17297 !! html/parsoid
17298 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Alimento"/>
17299 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/Nourriture"/>
17300 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/食品"/>
17301 !! end
17302
17303 !! test
17304 Duplicate interlanguage links (T26502)
17305 !! options
17306 ill
17307 !! wikitext
17308 [[es:1]]
17309 [[es:2]]
17310 [[fr:1]]
17311 [[fr:2]]
17312 !! html/php
17313 es:1 fr:1
17314 !! html/parsoid
17315 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/1"/>
17316 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/2"/>
17317 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/1"/>
17318 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/2"/>
17319 !! end
17320
17321 ###
17322 ### Sections
17323 ###
17324 !! test
17325 Basic section headings
17326 !! wikitext
17327 ==Headline 1==
17328 Some text
17329
17330 ==Headline 2==
17331 More
17332 ===Smaller headline===
17333 Blah blah
17334 !! html
17335 <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>
17336 <p>Some text
17337 </p>
17338 <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>
17339 <p>More
17340 </p>
17341 <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>
17342 <p>Blah blah
17343 </p>
17344 !! end
17345
17346 !! test
17347 Section headings with TOC
17348 !! wikitext
17349 ==Headline 1==
17350 ===Subheadline 1===
17351 =====Skipping a level=====
17352 ======Skipping a level======
17353
17354 ==Headline 2==
17355 Some text
17356 ===Another headline===
17357 !! html
17358 <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>
17359 <ul>
17360 <li class="toclevel-1 tocsection-1"><a href="#Headline_1"><span class="tocnumber">1</span> <span class="toctext">Headline 1</span></a>
17361 <ul>
17362 <li class="toclevel-2 tocsection-2"><a href="#Subheadline_1"><span class="tocnumber">1.1</span> <span class="toctext">Subheadline 1</span></a>
17363 <ul>
17364 <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>
17365 <ul>
17366 <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>
17367 </ul>
17368 </li>
17369 </ul>
17370 </li>
17371 </ul>
17372 </li>
17373 <li class="toclevel-1 tocsection-5"><a href="#Headline_2"><span class="tocnumber">2</span> <span class="toctext">Headline 2</span></a>
17374 <ul>
17375 <li class="toclevel-2 tocsection-6"><a href="#Another_headline"><span class="tocnumber">2.1</span> <span class="toctext">Another headline</span></a></li>
17376 </ul>
17377 </li>
17378 </ul>
17379 </div>
17380
17381 <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>
17382 <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>
17383 <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>
17384 <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>
17385 <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>
17386 <p>Some text
17387 </p>
17388 <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>
17389
17390 !! end
17391
17392 !! test
17393 TOC anchors don't collide
17394 !! wikitext
17395 __FORCETOC__
17396 ==Headline 2==
17397 ==Headline==
17398 ==Headline 2==
17399 ==Headline==
17400 !! html/php
17401 <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>
17402 <ul>
17403 <li class="toclevel-1 tocsection-1"><a href="#Headline_2"><span class="tocnumber">1</span> <span class="toctext">Headline 2</span></a></li>
17404 <li class="toclevel-1 tocsection-2"><a href="#Headline"><span class="tocnumber">2</span> <span class="toctext">Headline</span></a></li>
17405 <li class="toclevel-1 tocsection-3"><a href="#Headline_2_2"><span class="tocnumber">3</span> <span class="toctext">Headline 2</span></a></li>
17406 <li class="toclevel-1 tocsection-4"><a href="#Headline_3"><span class="tocnumber">4</span> <span class="toctext">Headline</span></a></li>
17407 </ul>
17408 </div>
17409
17410 <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>
17411 <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>
17412 <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>
17413 <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>
17414
17415 !! end
17416
17417 # perl -e 'print "="x$_," Level $_ heading","="x$_,"\n" for 1..10'
17418 # Parsoid html2wt direction adds <nowiki> for level 7 and up.
17419 !! test
17420 Handling of sections up to level 6 and beyond
17421 !! options
17422 parsoid=wt2html
17423 !! wikitext
17424 =Level 1 Heading=
17425 ==Level 2 Heading==
17426 ===Level 3 Heading===
17427 ====Level 4 Heading====
17428 =====Level 5 Heading=====
17429 ======Level 6 Heading======
17430 =======Level 7 Heading=======
17431 ========Level 8 Heading========
17432 =========Level 9 Heading=========
17433 ==========Level 10 Heading==========
17434 !! html/php
17435 <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>
17436 <ul>
17437 <li class="toclevel-1 tocsection-1"><a href="#Level_1_Heading"><span class="tocnumber">1</span> <span class="toctext">Level 1 Heading</span></a>
17438 <ul>
17439 <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>
17440 <ul>
17441 <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>
17442 <ul>
17443 <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>
17444 <ul>
17445 <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>
17446 <ul>
17447 <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>
17448 <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>
17449 <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>
17450 <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>
17451 <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>
17452 </ul>
17453 </li>
17454 </ul>
17455 </li>
17456 </ul>
17457 </li>
17458 </ul>
17459 </li>
17460 </ul>
17461 </li>
17462 </ul>
17463 </div>
17464
17465 <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>
17466 <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>
17467 <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>
17468 <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>
17469 <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>
17470 <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>
17471 <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>
17472 <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>
17473 <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>
17474 <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>
17475
17476 !! html/parsoid
17477 <h1 id="Level_1_Heading" data-parsoid='{}'>Level 1 Heading</h1>
17478 <h2 id="Level_2_Heading" data-parsoid='{}'>Level 2 Heading</h2>
17479 <h3 id="Level_3_Heading" data-parsoid='{}'>Level 3 Heading</h3>
17480 <h4 id="Level_4_Heading" data-parsoid='{}'>Level 4 Heading</h4>
17481 <h5 id="Level_5_Heading" data-parsoid='{}'>Level 5 Heading</h5>
17482 <h6 id="Level_6_Heading" data-parsoid='{}'>Level 6 Heading</h6>
17483 <h6 id="=Level_7_Heading=" data-parsoid='{}'><span id=".3DLevel_7_Heading.3D" typeof="mw:FallbackId"></span>=Level 7 Heading=</h6>
17484 <h6 id="==Level_8_Heading==" data-parsoid='{}'><span id=".3D.3DLevel_8_Heading.3D.3D" typeof="mw:FallbackId"></span>==Level 8 Heading==</h6>
17485 <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>
17486 <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>
17487 !! end
17488
17489 !! test
17490 TOC regression (T11764)
17491 !! wikitext
17492 ==title 1==
17493 ===title 1.1===
17494 ====title 1.1.1====
17495 ===title 1.2===
17496 ==title 2==
17497 ===title 2.1===
17498 !! html
17499 <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>
17500 <ul>
17501 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
17502 <ul>
17503 <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>
17504 <ul>
17505 <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>
17506 </ul>
17507 </li>
17508 <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>
17509 </ul>
17510 </li>
17511 <li class="toclevel-1 tocsection-5"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a>
17512 <ul>
17513 <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>
17514 </ul>
17515 </li>
17516 </ul>
17517 </div>
17518
17519 <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>
17520 <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>
17521 <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>
17522 <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>
17523 <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>
17524 <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>
17525
17526 !! end
17527
17528 !! test
17529 TOC for heading containing <span id="..."></span> (T96153)
17530 !! wikitext
17531 __FORCETOC__
17532 ==<span id="old-anchor"></span>New title==
17533 !! html/php
17534 <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>
17535 <ul>
17536 <li class="toclevel-1 tocsection-1"><a href="#New_title"><span class="tocnumber">1</span> <span class="toctext">New title</span></a></li>
17537 </ul>
17538 </div>
17539
17540 <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>
17541
17542 !! end
17543
17544 !! test
17545 TOC with wgMaxTocLevel=3 (T8204)
17546 !! options
17547 wgMaxTocLevel=3
17548 !! wikitext
17549 ==title 1==
17550 ===title 1.1===
17551 ====title 1.1.1====
17552 ===title 1.2===
17553 ==title 2==
17554 ===title 2.1===
17555 !! html
17556 <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>
17557 <ul>
17558 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
17559 <ul>
17560 <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>
17561 <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>
17562 </ul>
17563 </li>
17564 <li class="toclevel-1 tocsection-5"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a>
17565 <ul>
17566 <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>
17567 </ul>
17568 </li>
17569 </ul>
17570 </div>
17571
17572 <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>
17573 <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>
17574 <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>
17575 <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>
17576 <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>
17577 <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>
17578
17579 !! end
17580
17581 !! test
17582 TOC with wgMaxTocLevel=3 and two level four headings (T8204)
17583 !! options
17584 wgMaxTocLevel=3
17585 !! wikitext
17586 ==Section 1==
17587 ===Section 1.1===
17588 ====Section 1.1.1====
17589 ====Section 1.1.1.1====
17590 ==Section 2==
17591 !! html
17592 <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>
17593 <ul>
17594 <li class="toclevel-1 tocsection-1"><a href="#Section_1"><span class="tocnumber">1</span> <span class="toctext">Section 1</span></a>
17595 <ul>
17596 <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>
17597 </ul>
17598 </li>
17599 <li class="toclevel-1 tocsection-5"><a href="#Section_2"><span class="tocnumber">2</span> <span class="toctext">Section 2</span></a></li>
17600 </ul>
17601 </div>
17602
17603 <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>
17604 <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>
17605 <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>
17606 <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>
17607 <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>
17608
17609 !! end
17610
17611
17612 !! test
17613 Resolving duplicate section names
17614 !! wikitext
17615 ==Foo bar==
17616 ==Foo bar==
17617 !! html
17618 <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>
17619 <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>
17620
17621 !! end
17622
17623 !! test
17624 Resolving duplicate section names with differing case (T12721)
17625 !! wikitext
17626 ==Foo bar==
17627 ==Foo Bar==
17628 !! html
17629 <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>
17630 <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>
17631
17632 !! end
17633
17634 !! article
17635 Template:sections
17636 !! text
17637 ===Section 1===
17638 ==Section 2==
17639 !! endarticle
17640
17641 !! test
17642 Template with sections, __NOTOC__
17643 !! wikitext
17644 __NOTOC__
17645 ==Section 0==
17646 {{sections}}
17647 ==Section 4==
17648 !! html
17649 <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>
17650 <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>
17651 <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>
17652 <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>
17653
17654 !! end
17655
17656 !! test
17657 __NOEDITSECTION__ keyword
17658 !! wikitext
17659 __NOEDITSECTION__
17660 ==Section 1==
17661 ==Section 2==
17662 !! html
17663 <h2><span class="mw-headline" id="Section_1">Section 1</span></h2>
17664 <h2><span class="mw-headline" id="Section_2">Section 2</span></h2>
17665
17666 !! end
17667
17668 !! test
17669 Link inside a section heading
17670 !! wikitext
17671 ==Section with a [[Main Page|link]] in it==
17672 !! html
17673 <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>
17674
17675 !! end
17676
17677 !! test
17678 TOC regression (T14077)
17679 !! wikitext
17680 __TOC__
17681 ==title 1==
17682 ===title 1.1===
17683 ==title 2==
17684 !! html
17685 <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>
17686 <ul>
17687 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
17688 <ul>
17689 <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>
17690 </ul>
17691 </li>
17692 <li class="toclevel-1 tocsection-3"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a></li>
17693 </ul>
17694 </div>
17695
17696 <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>
17697 <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>
17698 <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>
17699
17700 !! end
17701
17702 !! test
17703 T3219 URL next to image (good)
17704 !! wikitext
17705 http://example.com [[File:Foobar.jpg]]
17706 !! html/php
17707 <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>
17708 </p>
17709 !! html/parsoid
17710 <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>
17711 !!end
17712
17713 # Parsoid doesn't wt2wt this cleanly because it adds <nowiki>s.
17714 !! test
17715 Short headings with trailing space should match behavior of Parser::doHeadings (T21910)
17716 !! options
17717 parsoid=wt2html,html2html
17718 !! wikitext
17719 ===
17720 The line above must have a trailing space!
17721 === <!--
17722 --> <!-- -->
17723 But just in case it doesn't...
17724 !! html/php
17725 <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>
17726 <p>The line above must have a trailing space!
17727 </p>
17728 <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>
17729 <p>But just in case it doesn't...
17730 </p>
17731 !! html/parsoid
17732 <h1 id="="><span id=".3D" typeof="mw:FallbackId"></span>=</h1>
17733 <p>The line above must have a trailing space!</p>
17734 <h1 id="=_2"><span id=".3D_2" typeof="mw:FallbackId"></span>=</h1> <!--
17735 --> <!-- -->
17736 <p>But just in case it doesn't...</p>
17737 !! end
17738
17739 !! test
17740 Header with special characters (T27462)
17741 !! wikitext
17742 The tooltips shall not show entities to the user (ie. be double escaped)
17743
17744 ==text > text==
17745 section 1
17746
17747 ==text < text==
17748 section 2
17749
17750 ==text & text==
17751 section 3
17752
17753 ==text ' text==
17754 section 4
17755
17756 ==text " text==
17757 section 5
17758 !! html/php
17759 <p>The tooltips shall not show entities to the user (ie. be double escaped)
17760 </p>
17761 <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>
17762 <ul>
17763 <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>
17764 <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>
17765 <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>
17766 <li class="toclevel-1 tocsection-4"><a href="#text_.27_text"><span class="tocnumber">4</span> <span class="toctext">text ' text</span></a></li>
17767 <li class="toclevel-1 tocsection-5"><a href="#text_.22_text"><span class="tocnumber">5</span> <span class="toctext">text " text</span></a></li>
17768 </ul>
17769 </div>
17770
17771 <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>
17772 <p>section 1
17773 </p>
17774 <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>
17775 <p>section 2
17776 </p>
17777 <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>
17778 <p>section 3
17779 </p>
17780 <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>
17781 <p>section 4
17782 </p>
17783 <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>
17784 <p>section 5
17785 </p>
17786 !! html/parsoid
17787 <p>The tooltips shall not show entities to the user (ie. be double escaped)</p>
17788
17789 <h2 id="text_>_text"><span id="text_.3E_text" typeof="mw:FallbackId"></span>text > text</h2>
17790 <p>section 1</p>
17791
17792 <h2 id="text_&lt;_text"><span id="text_.3C_text" typeof="mw:FallbackId"></span>text &lt; text</h2>
17793 <p>section 2</p>
17794
17795 <h2 id="text_&amp;_text"><span id="text_.26_text" typeof="mw:FallbackId"></span>text &amp; text</h2>
17796 <p>section 3</p>
17797
17798 <h2 id="text_'_text"><span id="text_.27_text" typeof="mw:FallbackId"></span>text ' text</h2>
17799 <p>section 4</p>
17800
17801 <h2 id='text_"_text'><span id="text_.22_text" typeof="mw:FallbackId"></span>text " text</h2>
17802 <p>section 5</p>
17803 !! end
17804
17805 !! test
17806 Header with space, plus and underscore as entity
17807 !! wikitext
17808 Id should not contain + for spaces
17809
17810 ==Space between Text==
17811 section 1
17812
17813 ==Space-Entity&#32;between&#32;Text==
17814 section 2
17815
17816 ==Plus+between+Text==
17817 section 3
17818
17819 ==Plus-Entity&#43;between&#43;Text==
17820 section 4
17821
17822 ==Underscore_between_Text==
17823 section 5
17824
17825 ==Underscore-Entity&#95;between&#95;Text==
17826 section 6
17827
17828 [[#Space between Text]]
17829 [[#Space-Entity&#32;between&#32;Text]]
17830 [[#Plus+between+Text]]
17831 [[#Plus-Entity&#43;between&#43;Text]]
17832 [[#Underscore_between_Text]]
17833 [[#Underscore-Entity&#95;between&#95;Text]]
17834 !! html/php
17835 <p>Id should not contain + for spaces
17836 </p>
17837 <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>
17838 <ul>
17839 <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>
17840 <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>
17841 <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>
17842 <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>
17843 <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>
17844 <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>
17845 </ul>
17846 </div>
17847
17848 <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>
17849 <p>section 1
17850 </p>
17851 <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>
17852 <p>section 2
17853 </p>
17854 <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>
17855 <p>section 3
17856 </p>
17857 <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>
17858 <p>section 4
17859 </p>
17860 <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>
17861 <p>section 5
17862 </p>
17863 <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>
17864 <p>section 6
17865 </p><p><a href="#Space_between_Text">#Space between Text</a>
17866 <a href="#Space-Entity_between_Text">#Space-Entity&#32;between&#32;Text</a>
17867 <a href="#Plus.2Bbetween.2BText">#Plus+between+Text</a>
17868 <a href="#Plus-Entity.2Bbetween.2BText">#Plus-Entity&#43;between&#43;Text</a>
17869 <a href="#Underscore_between_Text">#Underscore_between_Text</a>
17870 <a href="#Underscore-Entity_between_Text">#Underscore-Entity&#95;between&#95;Text</a>
17871 </p>
17872 !! html/parsoid
17873 <p>Id should not contain + for spaces</p>
17874
17875 <h2 id="Space_between_Text">Space between Text</h2>
17876 <p>section 1</p>
17877
17878 <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>
17879 <p>section 2</p>
17880
17881 <h2 id="Plus+between+Text"><span id="Plus.2Bbetween.2BText" typeof="mw:FallbackId"></span>Plus+between+Text</h2>
17882 <p>section 3</p>
17883
17884 <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>
17885 <p>section 4</p>
17886
17887 <h2 id="Underscore_between_Text">Underscore_between_Text</h2>
17888 <p>section 5</p>
17889
17890 <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>
17891 <p>section 6</p>
17892
17893 <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>
17894 <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>
17895 <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>
17896 <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>
17897 <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>
17898 <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>
17899 !! end
17900
17901 # Parsoid html2wt disabled because it adds padding spaces around =
17902 !! test
17903 Headers with excess '=' characters
17904 (Are similar tests necessary beyond the 1st level?)
17905 !! options
17906 parsoid=wt2html,wt2wt,html2html
17907 !! wikitext
17908 =foo==
17909 ==foo=
17910 =''italic'' heading==
17911 ==''italic'' heading=
17912 !! html/php
17913 <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>
17914 <ul>
17915 <li class="toclevel-1 tocsection-1"><a href="#foo.3D"><span class="tocnumber">1</span> <span class="toctext">foo=</span></a></li>
17916 <li class="toclevel-1 tocsection-2"><a href="#.3Dfoo"><span class="tocnumber">2</span> <span class="toctext">=foo</span></a></li>
17917 <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>
17918 <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>
17919 </ul>
17920 </div>
17921
17922 <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>
17923 <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>
17924 <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>
17925 <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>
17926
17927 !! html/parsoid
17928 <h1 id="foo="><span id="foo.3D" typeof="mw:FallbackId"></span>foo=</h1>
17929 <h1 id="=foo"><span id=".3Dfoo" typeof="mw:FallbackId"></span>=foo</h1>
17930 <h1 id="italic_heading="><span id="italic_heading.3D" typeof="mw:FallbackId"></span><i>italic</i> heading=</h1>
17931 <h1 id="=italic_heading"><span id=".3Ditalic_heading" typeof="mw:FallbackId"></span>=<i>italic</i> heading</h1>
17932 !! end
17933
17934 !! test
17935 HTML headers vs TOC (T25393)
17936 (__NOEDITSECTION__ for clearer output, doesn't matter here)
17937 !! wikitext
17938 <h1>Header 1</h1>
17939 ==Header 1.1==
17940 ==Header 1.2==
17941
17942 <h1>Header 2
17943 </h1>
17944 ==Header 2.1==
17945 ==Header 2.2==
17946 __NOEDITSECTION__
17947 !! html/php
17948 <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>
17949 <ul>
17950 <li class="toclevel-1"><a href="#Header_1"><span class="tocnumber">1</span> <span class="toctext">Header 1</span></a>
17951 <ul>
17952 <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>
17953 <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>
17954 </ul>
17955 </li>
17956 <li class="toclevel-1"><a href="#Header_2"><span class="tocnumber">2</span> <span class="toctext">Header 2</span></a>
17957 <ul>
17958 <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>
17959 <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>
17960 </ul>
17961 </li>
17962 </ul>
17963 </div>
17964
17965 <h1><span class="mw-headline" id="Header_1">Header 1</span></h1>
17966 <h2><span class="mw-headline" id="Header_1.1">Header 1.1</span></h2>
17967 <h2><span class="mw-headline" id="Header_1.2">Header 1.2</span></h2>
17968 <h1><span class="mw-headline" id="Header_2">Header 2
17969 </span></h1>
17970 <h2><span class="mw-headline" id="Header_2.1">Header 2.1</span></h2>
17971 <h2><span class="mw-headline" id="Header_2.2">Header 2.2</span></h2>
17972
17973 !! html/parsoid
17974 <h1 id="Header_1" data-parsoid='{"stx":"html"}'>Header 1</h1>
17975 <h2 id="Header_1.1" data-parsoid='{}'>Header 1.1</h2>
17976 <h2 id="Header_1.2" data-parsoid='{}'>Header 1.2</h2>
17977
17978 <h1 id="Header_2" data-parsoid='{"stx":"html"}'>Header 2
17979 </h1>
17980 <h2 id="Header_2.1" data-parsoid='{}'>Header 2.1</h2>
17981 <h2 id="Header_2.2" data-parsoid='{}'>Header 2.2</h2>
17982 <meta property="mw:PageProp/noeditsection"/>
17983 !! end
17984
17985 !! test
17986 Single-line or multiline-comments can follow headings
17987 !! options
17988 parsoid=wt2html,wt2wt
17989 !! wikitext
17990 ==foo==<!---->
17991 ==bar==<!--c1-->
17992 ==baz==<!--
17993 c2
17994 c3-->
17995 !! html/php
17996 <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>
17997 <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>
17998 <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>
17999
18000 !! html/parsoid
18001 <h2 id="foo">foo</h2><!---->
18002 <h2 id="bar">bar</h2><!--c1-->
18003 <h2 id="baz">baz</h2><!--
18004 c2
18005 c3-->
18006 !! end
18007
18008 !! test
18009 T3219 URL next to image (broken)
18010 !! wikitext
18011 http://example.com[[File:Foobar.jpg]]
18012 !! html/php
18013 <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>
18014 </p>
18015 !! html/parsoid
18016 <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>
18017 !!end
18018
18019 !! test
18020 T3186 news: in the middle of text
18021 !! wikitext
18022 http://en.wikinews.org/wiki/Wikinews:Workplace
18023 !! html
18024 <p><a rel="nofollow" class="external free" href="http://en.wikinews.org/wiki/Wikinews:Workplace">http://en.wikinews.org/wiki/Wikinews:Workplace</a>
18025 </p>
18026 !!end
18027
18028
18029 !! test
18030 Namespaced link must have a title
18031 !! wikitext
18032 [[Project:]]
18033 !! html
18034 <p>[[Project:]]
18035 </p>
18036 !!end
18037
18038 !! test
18039 Namespaced link must have a title (bad fragment version)
18040 !! wikitext
18041 [[Project:#fragment]]
18042 !! html
18043 <p>[[Project:#fragment]]
18044 </p>
18045 !!end
18046
18047
18048 ###
18049 ### HTML tags and HTML attributes
18050 ###
18051
18052 !! test
18053 div with no attributes
18054 !! wikitext
18055 <div>HTML rocks</div>
18056 !! html
18057 <div>HTML rocks</div>
18058
18059 !! end
18060
18061 !! test
18062 div with double-quoted attribute
18063 !! wikitext
18064 <div id="rock">HTML rocks</div>
18065 !! html
18066 <div id="rock">HTML rocks</div>
18067
18068 !! end
18069
18070 !! test
18071 div with single-quoted attribute
18072 !! wikitext
18073 <div id='rock'>HTML rocks</div>
18074 !! html
18075 <div id="rock">HTML rocks</div>
18076
18077 !! end
18078
18079 !! test
18080 div with unquoted attribute
18081 !! wikitext
18082 <div id=rock>HTML rocks</div>
18083 !! html
18084 <div id="rock">HTML rocks</div>
18085
18086 !! end
18087
18088 !! test
18089 div with illegal double attributes
18090 !! wikitext
18091 <div id="a" id="b">HTML rocks</div>
18092 !! html
18093 <div id="b">HTML rocks</div>
18094
18095 !!end
18096
18097 !! test
18098 div with empty attribute value, space before equals
18099 !! options
18100 parsoid=wt2html,html2html
18101 !! wikitext
18102 <div class =>HTML rocks</div>
18103 !! html/php
18104 <div class="">HTML rocks</div>
18105
18106 !! html/parsoid
18107 <div class="" data-parsoid='{"stx":"html"}'>HTML rocks</div>
18108 !! end
18109
18110 !! test
18111 div with multiple empty attribute values
18112 !! config
18113 wgFragmentMode=[ 'html5', 'legacy' ]
18114 !! options
18115 parsoid=wt2html,html2html
18116 !! wikitext
18117 <div id= title=>HTML rocks</div>
18118 !! html/php
18119 <div id="title=">HTML rocks</div>
18120
18121 !! html/parsoid
18122 <div id="title=" data-parsoid='{"stx":"html"}'>HTML rocks</div>
18123 !! end
18124
18125 # FIXME Parsoid doesn't actually match PHP here.
18126 !! test
18127 Extension tag in attribute value
18128 !! options
18129 wgRawHtml=1
18130 !! wikitext
18131 <span title="<html><div>123</div></html>">ok</span>
18132 !! html/php+tidy
18133 <p><span title="&lt;div&gt;123&lt;/div&gt;">ok</span>
18134 </p>
18135 !! html/parsoid
18136 <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>
18137 !! end
18138
18139 !! test
18140 table with multiple empty attribute values
18141 !! options
18142 parsoid=wt2html,html2html
18143 !! wikitext
18144 {| title= id=
18145 |hi
18146 |}
18147 !! html/php
18148 <table title="id=">
18149 <tr>
18150 <td>hi
18151 </td></tr></table>
18152
18153 !! html/parsoid
18154 <table title="id=">
18155 <tbody><tr><td>hi</td></tr>
18156 </tbody></table>
18157 !! end
18158
18159 !! test
18160 div with braces in attribute value
18161 !! wikitext
18162 <div title="{}">Foo</div>
18163 !! html/php
18164 <div title="&#123;&#125;">Foo</div>
18165
18166 !! html/parsoid
18167 <div title="{}">Foo</div>
18168 !! end
18169
18170 !! test
18171 div with empty attribute value, no space before equals
18172 !! options
18173 parsoid=wt2html,html2html
18174 !! wikitext
18175 <div class=>HTML rocks</div>
18176 !! html/php
18177 <div class="">HTML rocks</div>
18178
18179 !! html/parsoid
18180 <div class="">HTML rocks</div>
18181 !! end
18182
18183 !! test
18184 HTML multiple attributes correction
18185 !! wikitext
18186 <p class="error" class="awesome">Awesome!</p>
18187 !! html
18188 <p class="awesome">Awesome!</p>
18189
18190 !!end
18191
18192 !! test
18193 Table multiple attributes correction
18194 !! wikitext
18195 {|
18196 !+ class="error" class="awesome"|status
18197 |}
18198 !! html
18199 <table>
18200 <tr>
18201 <th class="awesome">status
18202 </th></tr></table>
18203
18204 !!end
18205
18206 !! test
18207 DIV IN UPPERCASE
18208 !! wikitext
18209 <DIV ID="x">HTML ROCKS</DIV>
18210 !! html
18211 <div id="x">HTML ROCKS</div>
18212
18213 !!end
18214
18215 !! test
18216 Non-ASCII pseudo-tags are rendered as text
18217 !! wikitext
18218 <khyô>
18219 !! html
18220 <p>&lt;khyô&gt;
18221 </p>
18222 !! end
18223
18224 !! test
18225 Pseudo-tag with URL 'name' renders as url link
18226 !! wikitext
18227 <http://example.com/>
18228 !! html
18229 <p>&lt;<a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a>&gt;
18230 </p>
18231 !! end
18232
18233 !! test
18234 text with amp in the middle of nowhere
18235 !! wikitext
18236 Remember AT&T?
18237 !! html
18238 <p>Remember AT&amp;T?
18239 </p>
18240 !! end
18241
18242 !! test
18243 text with character entity: eacute
18244 !! wikitext
18245 I always thought &eacute; was a cute letter.
18246 !! html+tidy
18247 <p>I always thought &#233; was a cute letter.
18248 </p>
18249 !! end
18250
18251 !! test
18252 text with entity-escaped character entity-like string: eacute
18253 !! wikitext
18254 I always thought &amp;eacute; was a cute letter.
18255 !! html
18256 <p>I always thought &amp;eacute; was a cute letter.
18257 </p>
18258 !! end
18259
18260 !! test
18261 text with undefined character entity: xacute
18262 !! wikitext
18263 I always thought &xacute; was a cute letter.
18264 !! html
18265 <p>I always thought &amp;xacute; was a cute letter.
18266 </p>
18267 !! end
18268
18269 !! test
18270 HTML5 tags
18271 !! wikitext
18272 <data value="5">five</data>
18273 <time datetime="2000-01-01T00:00Z">The new millenium started</time>
18274 <mark>This highlighted text</mark>
18275 !! html
18276 <p><data value="5">five</data>
18277 <time datetime="2000-01-01T00:00Z">The new millenium started</time>
18278 <mark>This highlighted text</mark>
18279 </p>
18280 !! end
18281
18282 !! test
18283 HTML tag with leading space is parsed as text
18284 !! wikitext
18285 < div>foo< /div>
18286 !! html
18287 <p>&lt; div&gt;foo&lt; /div&gt;
18288 </p>
18289 !! end
18290
18291 ## FIXME: The untrimmed attribute in Parsoid is T205737
18292 !! test
18293 Element with broken attribute syntax
18294 !! options
18295 parsoid=wt2html
18296 !! wikitext
18297 <div style=" style="123">hi</div>
18298 <div =>ho</div>
18299 !! html/php
18300 <div style="style=">hi</div>
18301 <div>ho</div>
18302
18303 !! html/parsoid
18304 <div style=" style=" data-parsoid='{"stx":"html","a":{"123\"":null},"sa":{"123\"":""}}'>hi</div>
18305 <div data-parsoid='{"stx":"html","a":{"=":null},"sa":{"=":""}}'>ho</div>
18306 !! end
18307
18308 ###
18309 ### Nesting tests (see T43545, T52604, T53081)
18310 ###
18311
18312 # This test case is fixed in Parsoid by domino 1.0.12. (T52604)
18313 # Note that html2wt is considerably more difficult if we use <b> in
18314 # the test case, instead of <small>
18315 !! test
18316 Ensure that HTML adoption agency algorithm is properly implemented.
18317 !! wikitext
18318 <small>X<small>Y</small>Z</small>
18319 !! html
18320 <p><small>X<small>Y</small>Z</small>
18321 </p>
18322 !! end
18323
18324 # This was T43545 in the PHP parser.
18325 !! test
18326 Nesting of <kbd>
18327 !! wikitext
18328 <kbd>X<kbd>Y</kbd>Z</kbd>
18329 !! html+tidy
18330 <p><kbd>X<kbd>Y</kbd>Z</kbd>
18331 </p>
18332 !! end
18333
18334 # The following cases were T53081 in the PHP parser.
18335 # Note that there are some other nestable tags (b, i, etc) which are
18336 # not covered; see T53081 for discussion.
18337
18338 !! test
18339 Nesting of <em>
18340 !! wikitext
18341 <em>X<em>Y</em>Z</em>
18342 !! html+tidy
18343 <p><em>X<em>Y</em>Z</em>
18344 </p>
18345 !! end
18346
18347 !! test
18348 Nesting of <strong>
18349 !! wikitext
18350 <strong>X<strong>Y</strong>Z</strong>
18351 !! html+tidy
18352 <p><strong>X<strong>Y</strong>Z</strong>
18353 </p>
18354 !! end
18355
18356 !! test
18357 Nesting of <q>
18358 !! wikitext
18359 <q>X<q>Y</q>Z</q>
18360 !! html+tidy
18361 <p><q>X<q>Y</q>Z</q>
18362 </p>
18363 !! end
18364
18365 !! test
18366 Nesting of <ruby>
18367 !! wikitext
18368 <ruby>X<ruby>Y</ruby>Z</ruby>
18369 !! html
18370 <p><ruby>X<ruby>Y</ruby>Z</ruby>
18371 </p>
18372 !! end
18373
18374 !! test
18375 Nesting of <bdo>
18376 !! wikitext
18377 <bdo>X<bdo>Y</bdo>Z</bdo>
18378 !! html
18379 <p><bdo>X<bdo>Y</bdo>Z</bdo>
18380 </p>
18381 !! end
18382
18383
18384 ###
18385 ### Media links
18386 ###
18387
18388 !! test
18389 Media link
18390 !! wikitext
18391 [[Media:Foobar.jpg]]
18392 [[Media:Video.ogv]]
18393 [[:Media:Video.ogv]]
18394 !! html/php
18395 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Media:Foobar.jpg</a>
18396 <a href="http://example.com/images/0/00/Video.ogv" class="internal" title="Video.ogv">Media:Video.ogv</a>
18397 <a href="http://example.com/images/0/00/Video.ogv" class="internal" title="Video.ogv">Media:Video.ogv</a>
18398 </p>
18399 !! html/parsoid
18400 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" resource="./Media:Foobar.jpg" title="Foobar.jpg">Media:Foobar.jpg</a>
18401 <a rel="mw:MediaLink" href="//example.com/images/0/00/Video.ogv" resource="./Media:Video.ogv" title="Video.ogv">Media:Video.ogv</a>
18402 <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>
18403 !! end
18404
18405 !! test
18406 Media link with text
18407 !! wikitext
18408 [[Media:Foobar.jpg|A neat file to look at]]
18409 !! html/php
18410 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">A neat file to look at</a>
18411 </p>
18412 !! html/parsoid
18413 <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>
18414 !! end
18415
18416 !! test
18417 Localized media link
18418 !! options
18419 language=is
18420 !! wikitext
18421 [[Miðill:Foobar.jpg]]
18422
18423 [[Miðill:Foobar.jpg|Icelandic]]
18424 !! html/php
18425 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Miðill:Foobar.jpg</a>
18426 </p><p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Icelandic</a>
18427 </p>
18428 !! html/parsoid
18429 <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>
18430 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" resource="./Miðill:Foobar.jpg" title="Foobar.jpg">Icelandic</a></p>
18431 !! end
18432
18433 # FIXME: this is still bad HTML tag nesting
18434 # FIXME: doBlockLevels won't wrap this in a paragraph because it contains a div
18435 # Parsoid & Remex fix the p-wrapping since they operate on the DOM.
18436 !! test
18437 Media link with nasty text
18438 !! options
18439 parsoid=wt2html,html2html
18440 !! wikitext
18441 [[Media:Foobar.jpg|Safe Link<div style=display:none>" onmouseover="alert(document.cookie)" onfoo="</div>]]
18442 !! html/php
18443 <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>
18444
18445 !! html/php+tidy
18446 <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>
18447 !! html/parsoid
18448 <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>
18449 !! end
18450
18451 !! test
18452 Media link from missing resource (parsoid-only)
18453 !! options
18454 parsoid=html2wt
18455 !! html/parsoid
18456 <a rel="mw:MediaLink" href="http://example.com/images/3/3a/Foobar.jpg">Bat!</a>
18457 !! wikitext
18458 [[Media:Foobar.jpg|Bat!]]
18459 !! end
18460
18461 !! test
18462 Media link from missing resource, localized (parsoid-only)
18463 !! options
18464 parsoid=html2wt
18465 language=is
18466 !! html/parsoid
18467 <a rel="mw:MediaLink" href="http://example.com/images/3/3a/Foobar.jpg">Bat!</a>
18468 !! wikitext
18469 [[Miðill:Foobar.jpg|Bat!]]
18470 !! end
18471
18472 # This is a sanity test to ensure we don't crash or choke when given
18473 # old cached 1.7.0 HTML for media links; we don't require that the
18474 # result be "valid" because wt2wt was completely broken in 1.7.0
18475 !! test
18476 Media link from old 1.7.0 DOM spec (crash test, parsoid-only) T198511
18477 !! options
18478 parsoid=html2wt
18479 !! html/parsoid
18480 <p>This is what Parsoid would emit (and we still handle this HTML fine):</p>
18481 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg">A neat file to look at</a></p>
18482 <p>But VisualEditor would mangle the rel attribute, and give us back this:</p>
18483 <p><a rel="mw:ExtLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg">A neat file to look at</a></p>
18484 <p>But at least we don't crash when trying to handle the mangled HTML!</p>
18485 !! wikitext
18486 This is what Parsoid would emit (and we still handle this HTML fine):
18487
18488 [[Media:Foobar.jpg|A neat file to look at]]
18489
18490 But VisualEditor would mangle the rel attribute, and give us back this:
18491
18492 [//example.com/images/3/3a/Foobar.jpg A neat file to look at]
18493
18494 But at least we don't crash when trying to handle the mangled HTML!
18495 !! end
18496
18497 !! test
18498 Media link to nonexistent file (T3702)
18499 !! wikitext
18500 [[Media:No such.jpg]]
18501 [[Media:No_such file.jpg]]
18502 !! html/php
18503 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=No_such.jpg" class="new" title="No such.jpg">Media:No such.jpg</a>
18504 <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>
18505 </p>
18506 !! html/parsoid
18507 <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>
18508 <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>
18509 !! end
18510
18511 !! test
18512 Image link to nonexistent file (T3850 - good)
18513 !! wikitext
18514 [[File:No_such.jpg]]
18515 !! html/php
18516 <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>
18517 </p>
18518 !! html/parsoid
18519 <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>
18520 !! end
18521
18522 !! test
18523 :Image link to nonexistent file (T3850 - bad)
18524 !! wikitext
18525 [[:Image:No such.jpg]]
18526 !! html/php
18527 <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>
18528 </p>
18529 !! html/parsoid
18530 <p><a rel="mw:WikiLink" href="./File:No_such.jpg" title="File:No such.jpg">Image:No such.jpg</a></p>
18531 !! end
18532
18533 !! test
18534 Character reference normalization in link text (T3938)
18535 !! wikitext
18536 [[Main Page|this&that]]
18537 !! html
18538 <p><a href="/wiki/Main_Page" title="Main Page">this&amp;that</a>
18539 </p>
18540 !!end
18541
18542 !! article
18543 אַ
18544 !! text
18545 Test for unicode normalization
18546
18547 The page's name is U+05d0 U+05b7, with non-canonical form U+FB2E
18548 !! endarticle
18549
18550 !! test
18551 (T21451) Links should refer to the normalized form.
18552 !! wikitext
18553 [[&#xFB2E;]]
18554 [[&#x5d0;&#x5b7;]]
18555 [[&#x5d0;ַ]]
18556 [[א&#x5b7;]]
18557 [[אַ]]
18558 !! html
18559 <p><a href="/wiki/%D7%90%D6%B7" title="אַ">&#xfb2e;</a>
18560 <a href="/wiki/%D7%90%D6%B7" title="אַ">&#x5d0;&#x5b7;</a>
18561 <a href="/wiki/%D7%90%D6%B7" title="אַ">&#x5d0;ַ</a>
18562 <a href="/wiki/%D7%90%D6%B7" title="אַ">א&#x5b7;</a>
18563 <a href="/wiki/%D7%90%D6%B7" title="אַ">אַ</a>
18564 </p>
18565 !! end
18566
18567 !! test
18568 Empty attribute crash test (T4067)
18569 !! wikitext
18570 <font color="">foo</font>
18571 !! html
18572 <p><font color="">foo</font>
18573 </p>
18574 !! end
18575
18576 !! test
18577 Empty attribute crash test single-quotes (T4067)
18578 !! wikitext
18579 <font color=''>foo</font>
18580 !! html
18581 <p><font color="">foo</font>
18582 </p>
18583 !! end
18584
18585 !! test
18586 Attribute test: equals, then nothing
18587 !! options
18588 parsoid=wt2html,html2html
18589 !! wikitext
18590 <font color=>foo</font>
18591 !! html/php
18592 <p><font color="">foo</font>
18593 </p>
18594 !! html/parsoid
18595 <p><font color="" data-parsoid='{"stx":"html"}'>foo</font></p>
18596 !! end
18597
18598 !! test
18599 Attribute test: unquoted value
18600 !! options
18601 parsoid=wt2html,html2html
18602 !! wikitext
18603 <font color=x>foo</font>
18604 !! html/php
18605 <p><font color="x">foo</font>
18606 </p>
18607 !! html/parsoid
18608 <p><font color="x" data-parsoid='{"stx":"html"}'>foo</font></p>
18609 !! end
18610
18611 !! test
18612 Attribute test: unquoted but illegal value (hash)
18613 !! wikitext
18614 <font color=#x>foo</font>
18615 !! html
18616 <p><font color="#x">foo</font>
18617 </p>
18618 !! end
18619
18620 # Parsoid does not serialize to empty attribute syntax,
18621 # so wt2wt and html2wt cases are skipped
18622 !! test
18623 Attribute test: no value (T54330)
18624 !! options
18625 parsoid=wt2html,html2html
18626 !! wikitext
18627 <font color>foo</font>
18628 !! html/php
18629 <p><font color="">foo</font>
18630 </p>
18631 !! html/parsoid
18632 <p><font color="">foo</font></p>
18633 !! end
18634
18635 !! test
18636 T4095: link with three closing brackets
18637 !! wikitext
18638 [[Main Page]]]
18639 !! html/php
18640 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>]
18641 </p>
18642 !! html/parsoid
18643 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a>]</p>
18644 !! end
18645
18646 !! test
18647 T4095: link with pipe and three closing brackets
18648 !! wikitext
18649 [[Main Page|link]]]
18650 !! html/php
18651 <p><a href="/wiki/Main_Page" title="Main Page">link</a>]
18652 </p>
18653 !! html/parsoid
18654 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">link</a>]</p>
18655 !! end
18656
18657 !! test
18658 T4095: link with pipe and three closing brackets, version 2
18659 !! wikitext
18660 [[Main Page|[http://example.com/]]]
18661 !! html/php
18662 <p><a href="/wiki/Main_Page" title="Main Page">[http://example.com/]</a>
18663 </p>
18664 !! html/parsoid
18665 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">[http://example.com/]</a></p>
18666 !! end
18667
18668
18669 ###
18670 ### Safety
18671 ###
18672
18673 !! article
18674 Template:Dangerous attribute
18675 !! text
18676 " onmouseover="alert(document.cookie)
18677 !! endarticle
18678
18679 !! article
18680 Template:Dangerous style attribute
18681 !! text
18682 border-size: expression(alert(document.cookie))
18683 !! endarticle
18684
18685 !! article
18686 Template:Div style
18687 !! text
18688 <div style="float: right; {{{1}}}">Magic div</div>
18689 !! endarticle
18690
18691 !! test
18692 T4304: HTML attribute safety (safe template; regression T4309)
18693 !! wikitext
18694 <div title="{{test}}"></div>
18695 !! html/php
18696 <div title="This is a test template"></div>
18697
18698 !! html/parsoid
18699 <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>
18700 !! end
18701
18702 # Parsoid has enough context to handle this case
18703 !! test
18704 T4304: HTML attribute safety (dangerous template; 2309)
18705 !! wikitext
18706 <div title="{{dangerous attribute}}"></div>
18707 !! html/php
18708 <div title=""></div>
18709
18710 !! html/parsoid
18711 <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>
18712 !! end
18713
18714 !! test
18715 T4304: HTML attribute safety (dangerous style template; 2309)
18716 !! wikitext
18717 <div style="{{dangerous style attribute}}"></div>
18718 !! html/php
18719 <div style="/* insecure input */"></div>
18720
18721 !! html/parsoid
18722 <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>
18723 !! end
18724
18725 !! test
18726 T4304: HTML attribute safety (safe parameter; 2309)
18727 !! wikitext
18728 {{div style|width: 200px}}
18729 !! html/php
18730 <div style="float: right; width: 200px">Magic div</div>
18731
18732 !! html/parsoid
18733 <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>
18734 !! end
18735
18736 !! test
18737 T4304: HTML attribute safety (unsafe parameter; 2309)
18738 !! wikitext
18739 {{div style|width: expression(alert(document.cookie))}}
18740 !! html/php
18741 <div style="/* insecure input */">Magic div</div>
18742
18743 !! html/parsoid
18744 <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>
18745 !! end
18746
18747 ## Parsoid output here differs; needs investigation.
18748 !! test
18749 T4304: HTML attribute safety (unsafe breakout parameter; 2309)
18750 !! wikitext
18751 {{div style|"><script>alert(document.cookie)</script>}}
18752 !! html
18753 <div style="float: right;">&lt;script&gt;alert(document.cookie)&lt;/script&gt;"&gt;Magic div</div>
18754
18755 !! end
18756
18757 ## Parsoid output here differs; needs investigation.
18758 !! test
18759 T4304: HTML attribute safety (unsafe breakout parameter 2; 2309)
18760 !! wikitext
18761 {{div style|" ><script>alert(document.cookie)</script>}}
18762 !! html
18763 <div style="float: right;">&lt;script&gt;alert(document.cookie)&lt;/script&gt;"&gt;Magic div</div>
18764
18765 !! end
18766
18767 !! test
18768 T4304: HTML attribute safety (link)
18769 !! wikitext
18770 <div title="[[Main Page]]"></div>
18771 !! html/php
18772 <div title="&#91;&#91;Main Page&#93;&#93;"></div>
18773
18774 !! html/parsoid
18775 <div title="[[Main Page]]"></div>
18776 !! end
18777
18778 !! test
18779 T4304: HTML attribute safety (italics)
18780 !! wikitext
18781 <div title="''foobar''"></div>
18782 !! html
18783 <div title="&#39;&#39;foobar&#39;&#39;"></div>
18784
18785 !! end
18786
18787 !! test
18788 T4304: HTML attribute safety (bold)
18789 !! wikitext
18790 <div title="'''foobar'''"></div>
18791 !! html
18792 <div title="&#39;&#39;&#39;foobar&#39;&#39;&#39;"></div>
18793
18794 !! end
18795
18796 !! test
18797 T4304: HTML attribute safety (ISBN)
18798 !! wikitext
18799 <div title="ISBN 1234567890"></div>
18800 !! html
18801 <div title="&#73;SBN 1234567890"></div>
18802
18803 !! end
18804
18805 !! test
18806 T4304: HTML attribute safety (RFC)
18807 !! wikitext
18808 <div title="RFC 1234"></div>
18809 !! html
18810 <div title="&#82;FC 1234"></div>
18811
18812 !! end
18813
18814 !! test
18815 T4304: HTML attribute safety (PMID)
18816 !! wikitext
18817 <div title="PMID 1234567890"></div>
18818 !! html
18819 <div title="&#80;MID 1234567890"></div>
18820
18821 !! end
18822
18823 !! test
18824 T4304: HTML attribute safety (web link)
18825 !! wikitext
18826 <div title="http://example.com/"></div>
18827 !! html
18828 <div title="http&#58;//example.com/"></div>
18829
18830 !! end
18831
18832 !! test
18833 T4304: HTML attribute safety (named web link)
18834 !! wikitext
18835 <div title="[http://example.com/ link]"></div>
18836 !! html/php
18837 <div title="&#91;http&#58;//example.com/ link&#93;"></div>
18838
18839 !! html/parsoid
18840 <div title="[http://example.com/ link]"></div>
18841 !! end
18842
18843 !! test
18844 T5244: HTML attribute safety (extension; safe)
18845 !! wikitext
18846 <div style="<nowiki>background:blue</nowiki>"></div>
18847 !! html/php
18848 <div style="background:blue"></div>
18849
18850 !! html/parsoid
18851 <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>
18852 !! end
18853
18854 !! test
18855 T5244: HTML attribute safety (extension; unsafe)
18856 !! wikitext
18857 <div style="<nowiki>border-left:expression(alert(document.cookie))</nowiki>"></div>
18858 !! html/php
18859 <div style="/* insecure input */"></div>
18860
18861 !! html/parsoid
18862 <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>
18863 !! end
18864
18865 # More MSIE fun discovered by Tom Gilder
18866
18867 !! test
18868 MSIE CSS safety test: spurious slash
18869 !! wikitext
18870 <div style="background-image:u\rl(javascript:alert('boo'))">evil</div>
18871 !! html/php
18872 <div style="/* insecure input */">evil</div>
18873
18874 !! html/parsoid
18875 <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>
18876 !! end
18877
18878 !! test
18879 MSIE CSS safety test: hex code
18880 !! wikitext
18881 <div style="background-image:u\72l(javascript:alert('boo'))">evil</div>
18882 !! html/php
18883 <div style="/* insecure input */">evil</div>
18884
18885 !! html/parsoid
18886 <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>
18887 !! end
18888
18889 !! test
18890 MSIE CSS safety test: comment in url
18891 !! wikitext
18892 <div style="background-image:u/**/rl(javascript:alert('boo'))">evil</div>
18893 !! html/php
18894 <div style="background-image:u rl(javascript:alert(&#39;boo&#39;))">evil</div>
18895
18896 !! html/parsoid
18897 <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>
18898 !! end
18899
18900 !! test
18901 MSIE CSS safety test: comment in expression
18902 !! wikitext
18903 <div style="background-image:expres/**/sion(alert('boo4'))">evil4</div>
18904 !! html/php
18905 <div style="background-image:expres sion(alert(&#39;boo4&#39;))">evil4</div>
18906
18907 !! html/parsoid
18908 <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>
18909 !! end
18910
18911 !! test
18912 CSS safety test (all browsers): vertical tab (T57332 / CVE-2013-4567)
18913 !! wikitext
18914 <p style="font-size: 100px; background-image:url\b(https://www.google.com/images/srpr/logo6w.png)">A</p>
18915 !! html/php
18916 <p style="/* invalid control char */">A</p>
18917
18918 !! html/parsoid
18919 <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>
18920 !! end
18921
18922 !! test
18923 MSIE 6 CSS safety test: Fullwidth (T57332)
18924 !! wikitext
18925 <p style="font-size: 100px; color: expression((title='XSSed'),'red')">A</p>
18926 <div style="top:EXPRESSION(alert())">B</div>
18927 !! html/php
18928 <p style="/* insecure input */">A</p>
18929 <div style="/* insecure input */">B</div>
18930
18931 !! html/parsoid
18932 <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>
18933 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"top:EXPRESSION(alert())"}}'>B</div>
18934 !! end
18935
18936 !! test
18937 MSIE 6 CSS safety test: IPA extensions (T57332)
18938 !! wikitext
18939 <div style="background-image:uʀʟ(javascript:alert())">A</div>
18940 <p style="font-size: 100px; color: expʀessɪoɴ((title='XSSed'),'red')">B</p>
18941 !! html/php
18942 <div style="/* insecure input */">A</div>
18943 <p style="/* insecure input */">B</p>
18944
18945 !! html/parsoid
18946 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:uʀʟ(javascript:alert())"}}'>A</div>
18947 <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>
18948 !! end
18949
18950 !! test
18951 MSIE 6 CSS safety test: sup/sub script (T57332)
18952 !! wikitext
18953 <div style="background-image:url⁽javascript:alert())">A</div>
18954 <div style="background-image:url₍javascript:alert())">B</div>
18955 <p style="font-size: 100px; color: expressioⁿ((title='XSSed'),'red')">C</p>
18956 !! html/php
18957 <div style="/* insecure input */">A</div>
18958 <div style="/* insecure input */">B</div>
18959 <p style="/* insecure input */">C</p>
18960
18961 !! html/parsoid
18962 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:url⁽javascript:alert())"}}'>A</div>
18963 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:url₍javascript:alert())"}}'>B</div>
18964 <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>
18965 !! end
18966
18967 !! test
18968 Opera -o-link CSS
18969 !! options
18970 parsoid=wt2html,html2html
18971 !! wikitext
18972 <div
18973 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;"
18974 style="-o-link:attr(title);-o-link-source:current">X</div>
18975 !! html/php
18976 <div title="data:text/html,&lt;img src=1 onerror=alert(1)&gt;" style="/* insecure input */">X</div>
18977
18978 !! html/parsoid
18979 <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>
18980 !! end
18981
18982 !! test
18983 MSIE 6 CSS safety test: Repetition markers (T57332)
18984 !! wikitext
18985 <p style="font-size: 100px; color: expres〱ion((title='XSSed'),'red')">A</p>
18986 <p style="font-size: 100px; color: expresゝion((title='XSSed'),'red')">B</p>
18987 <p style="font-size: 100px; color: expresーion((title='XSSed'),'red')">C</p>
18988 <p style="font-size: 100px; color: expresヽion((title='XSSed'),'red')">D</p>
18989 <p style="font-size: 100px; color: expresﹽion((title='XSSed'),'red')">E</p>
18990 <p style="font-size: 100px; color: expresﹼion((title='XSSed'),'red')">F</p>
18991 <p style="font-size: 100px; color: expresーion((title='XSSed'),'red')">G</p>
18992 !! html/php
18993 <p style="/* insecure input */">A</p>
18994 <p style="/* insecure input */">B</p>
18995 <p style="/* insecure input */">C</p>
18996 <p style="/* insecure input */">D</p>
18997 <p style="/* insecure input */">E</p>
18998 <p style="/* insecure input */">F</p>
18999 <p style="/* insecure input */">G</p>
19000
19001 !! html/parsoid
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;)"}}'>A</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;)"}}'>B</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;)"}}'>C</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;)"}}'>D</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;)"}}'>E</p>
19007 <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>
19008 <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>
19009 !! end
19010
19011 !! test
19012 Table attribute legitimate extension
19013 !! wikitext
19014 {|
19015 !+ style="<nowiki>color:blue</nowiki>"|status
19016 |}
19017 !! html
19018 <table>
19019 <tr>
19020 <th style="color:blue">status
19021 </th></tr></table>
19022
19023 !!end
19024
19025 !! test
19026 Table attribute safety
19027 !! wikitext
19028 {|
19029 !+ style="<nowiki>border-width:expression(0+alert(document.cookie))</nowiki>"|status
19030 |}
19031 !! html
19032 <table>
19033 <tr>
19034 <th style="/* insecure input */">status
19035 </th></tr></table>
19036
19037 !! end
19038
19039 !! test
19040 CSS line continuation 1
19041 !! wikitext
19042 <div style="background-image: u\&#10;rl(test.jpg);"></div>
19043 !! html
19044 <div style="/* insecure input */"></div>
19045
19046 !! end
19047
19048 !! test
19049 CSS line continuation 2
19050 !! wikitext
19051 <div style="background-image: u\&#13;rl(test.jpg); "></div>
19052 !! html
19053 <div style="/* invalid control char */"></div>
19054
19055 !! end
19056
19057 !! article
19058 Template:Identity
19059 !! text
19060 {{{1}}}
19061 !! endarticle
19062
19063 !! test
19064 Expansion of multi-line templates in attribute values (T8255)
19065 !! wikitext
19066 <div style="background: {{identity|#00FF00}}">-</div>
19067 !! html
19068 <div style="background: #00FF00">-</div>
19069
19070 !! end
19071
19072 !! test
19073 Expansion of multi-line templates in attribute values (T8255 sanity check)
19074 !! wikitext
19075 <div style="background:
19076 #00FF00">-</div>
19077 !! html/php
19078 <div style="background: #00FF00">-</div>
19079
19080 !! html/parsoid
19081 <div style="background:
19082 #00FF00">-</div>
19083 !! end
19084
19085 !! test
19086 Expansion of multi-line templates in attribute values (T8255 sanity check 2)
19087 !! wikitext
19088 <div style="background: &#10;#00FF00">-</div>
19089 !! html
19090 <div style="background: &#10;#00FF00">-</div>
19091
19092 !! end
19093
19094 !! test
19095 Tags which are hidden from tidiers cannot pass through the Sanitizer
19096 !! wikitext
19097 <mw:toc><script>alert();</script></mw:toc>
19098 !! html+tidy
19099 <p>&lt;mw:toc&gt;&lt;script&gt;alert();&lt;/script&gt;&lt;/mw:toc&gt;
19100 </p>
19101 !! end
19102
19103 ###
19104 ### Parser hooks (see tests/parser/ParserTestParserHook.php for the <tag> extension)
19105 ###
19106
19107 !! test
19108 Parser hook: empty input
19109 !! wikitext
19110 <tag></tag>
19111 !! html/php
19112 <pre>
19113 ''
19114 array (
19115 )
19116 </pre>
19117
19118 !! html/parsoid
19119 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
19120 !! end
19121
19122 ## Don't expect parsoid to rt this form.
19123 !! test
19124 Parser hook: empty input using terminated empty elements
19125 !! options
19126 parsoid=wt2html,html2html
19127 !! wikitext
19128 <tag/>
19129 !! html/php
19130 <pre>
19131 NULL
19132 array (
19133 )
19134 </pre>
19135
19136 !! html/parsoid
19137 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{}}' data-parsoid='{}' about="#mwt2"></pre>
19138 !! end
19139
19140 !! test
19141 Parser hook: empty input using terminated empty elements (space before)
19142 !! wikitext
19143 <tag />
19144 !! html/php
19145 <pre>
19146 NULL
19147 array (
19148 )
19149 </pre>
19150
19151 !! html/parsoid
19152 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{}}' data-parsoid='{}' about="#mwt2"></pre>
19153 !! end
19154
19155 !! test
19156 Parser hook: basic input
19157 !! wikitext
19158 <tag>input</tag>
19159 !! html/php
19160 <pre>
19161 'input'
19162 array (
19163 )
19164 </pre>
19165
19166 !! html/parsoid
19167 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
19168 !! end
19169
19170 ## Don't expect parsoid to rt this form.
19171 !! test
19172 Parser hook: case insensitive
19173 !! options
19174 parsoid=wt2html,html2html
19175 !! wikitext
19176 <TAG>input</TAG>
19177 !! html/php
19178 <pre>
19179 'input'
19180 array (
19181 )
19182 </pre>
19183
19184 !! html/parsoid
19185 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
19186 !! end
19187
19188 ## Don't expect parsoid to rt this form.
19189 !! test
19190 Parser hook: case insensitive, redux
19191 !! options
19192 parsoid=wt2html,html2html
19193 !! wikitext
19194 <TaG>input</TAg>
19195 !! html/php
19196 <pre>
19197 'input'
19198 array (
19199 )
19200 </pre>
19201
19202 !! html/parsoid
19203 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
19204 !! end
19205
19206 !! test
19207 Parser hook: nested tags
19208 !! options
19209 parsoid=wt2html
19210 !! wikitext
19211 <tag><tag></tag></tag>
19212 !! html/php
19213 <pre>
19214 '<tag>'
19215 array (
19216 )
19217 </pre>&lt;/tag&gt;
19218
19219 !! html/php+tidy
19220 <pre>'<tag>'
19221 array (
19222 )
19223 </tag></pre><p>&lt;/tag&gt;
19224 </p>
19225 !! html/parsoid
19226 <pre typeof="mw:Extension/tag" about="#mwt2" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"&lt;tag>"}}'></pre><p>&lt;/tag></p>
19227 !! end
19228
19229 !! test
19230 Parser hook: basic arguments
19231 !! wikitext
19232 <tag width="200" height="100" depth="50" square=""></tag>
19233 !! html/php
19234 <pre>
19235 ''
19236 array (
19237 'width' => '200',
19238 'height' => '100',
19239 'depth' => '50',
19240 'square' => '',
19241 )
19242 </pre>
19243
19244 !! html/parsoid
19245 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
19246 !! end
19247
19248 ## Don't expect parsoid to rt this form.
19249 !! test
19250 Parser hook: basic arguments, variations
19251 !! options
19252 parsoid=wt2html,html2html
19253 !! wikitext
19254 <tag width=200 height = "100" depth = '50' square></tag>
19255 !! html/php
19256 <pre>
19257 ''
19258 array (
19259 'width' => '200',
19260 'height' => '100',
19261 'depth' => '50',
19262 'square' => '',
19263 )
19264 </pre>
19265
19266 !! html/parsoid
19267 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
19268 !! end
19269
19270 !! test
19271 Parser hook: argument containing a forward slash (T7344)
19272 !! wikitext
19273 <tag filename="/tmp/bla"></tag>
19274 !! html/php
19275 <pre>
19276 ''
19277 array (
19278 'filename' => '/tmp/bla',
19279 )
19280 </pre>
19281
19282 !! html/parsoid
19283 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"filename":"/tmp/bla"},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
19284 !! end
19285
19286 ## Don't expect parsoid to rt this form.
19287 !! test
19288 Parser hook: empty input using terminated empty elements (T4374)
19289 !! options
19290 parsoid=wt2html,html2html
19291 !! wikitext
19292 <tag foo=bar/>text
19293 !! html/php
19294 <pre>
19295 NULL
19296 array (
19297 'foo' => 'bar',
19298 )
19299 </pre>text
19300
19301 !! html/parsoid
19302 <pre typeof="mw:Extension/tag" about="#mwt2" data-mw='{"name":"tag","attrs":{"foo":"bar"}}'></pre><p>text</p>
19303 !! end
19304
19305 ## </tag> should be output literally since there is no matching tag that begins it
19306 ## Don't expect parsoid to rt this form.
19307 !! test
19308 Parser hook: basic arguments using terminated empty elements (T4374)
19309 !! options
19310 parsoid=wt2html
19311 !! wikitext
19312 <tag width=200 height = "100" depth = '50' square/>
19313 other stuff
19314 </tag>
19315 !! html/php
19316 <pre>
19317 NULL
19318 array (
19319 'width' => '200',
19320 'height' => '100',
19321 'depth' => '50',
19322 'square' => '',
19323 )
19324 </pre>
19325 <p>other stuff
19326 &lt;/tag&gt;
19327 </p>
19328 !! html/parsoid
19329 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""}}' about="#mwt2"></pre><p>other stuff
19330 &lt;/tag></p>
19331 !! end
19332
19333 ## Don't expect parsoid to rt this form.
19334 !! test
19335 Parser hook: Don't allow unclosed extension tags
19336 !! options
19337 parsoid=wt2html
19338 !! wikitext
19339 test <tag>123
19340
19341 this is a '''test'''
19342 !! html/php
19343 <p>test &lt;tag&gt;123
19344 </p><p>this is a <b>test</b>
19345 </p>
19346 !! html/parsoid
19347 <p>test &lt;tag>123</p>
19348
19349 <p>this is a <b>test</b></p>
19350 !! end
19351
19352 !! test
19353 Parser hook: horizontal rule inside extension tag that outputs <pre>
19354 !! wikitext
19355 <tag>
19356 Hello
19357 <hr/>
19358 Goodbye
19359 </tag>
19360 !! html/php
19361 <pre>
19362 '
19363 Hello
19364 <hr/>
19365 Goodbye
19366 '
19367 array (
19368 )
19369 </pre>
19370
19371 !! end
19372
19373 ###
19374 ### (see tests/parser/ParserTestParserHook.php for the <statictag> extension)
19375 ###
19376
19377 !! test
19378 Parser hook: static parser hook not inside a comment
19379 !! wikitext
19380 <statictag>hello, world</statictag>
19381
19382 <statictag action="flush" />
19383 !! html/php
19384 <p><br />
19385 hello, world
19386 </p>
19387 !! html/parsoid
19388 <p><span typeof="mw:Extension/statictag" data-mw='{"name":"statictag","attrs":{},"body":{"extsrc":"hello, world"}}' about="#mwt2"></span></p>
19389 <p><span typeof="mw:Extension/statictag" data-mw='{"name":"statictag","attrs":{"action":"flush"}}' about="#mwt4">hello, world</span></p>
19390 !! end
19391
19392 !! test
19393 Parser hook: static parser hook inside a comment
19394 !! wikitext
19395 <!-- <statictag>hello, world</statictag> -->
19396 <statictag action="flush" />
19397 !! html/php
19398 <p><br />
19399 </p>
19400 !! html/parsoid
19401 <!-- <statictag&#x3E;hello, world</statictag&#x3E; -->
19402 <p><span typeof='mw:Extension/statictag' data-mw='{"name":"statictag","attrs":{"action":"flush"}}' data-parsoid='{}' about='#mwt2'></span></p>
19403 !! end
19404
19405 # Nested template calls; this case was broken by Parser.php rev 1.506,
19406 # since reverted.
19407
19408 !! article
19409 Template:One-parameter
19410 !! text
19411 (My parameter is: {{{1}}})
19412 !! endarticle
19413
19414 !! article
19415 Template:Map-one-parameter
19416 !! text
19417 {{{{{1}}}|{{{2}}}}}
19418 !! endarticle
19419
19420 !! test
19421 Nested template calls
19422 !! wikitext
19423 {{Map-one-parameter|One-parameter|param}}
19424 !! html
19425 <p>(My parameter is: param)
19426 </p>
19427 !! end
19428
19429
19430 ###
19431 ### Sanitizer
19432 ###
19433
19434 !! test
19435 Sanitizer: Closing of open tags
19436 !! wikitext
19437 <s></s><table></table>
19438 !! html/php+tidy
19439 <p><s></s></p><table></table>
19440 !! html/parsoid
19441 <p><s data-parsoid='{"stx":"html"}'></s></p><table data-parsoid='{"stx":"html"}'></table>
19442 !! end
19443
19444 !! test
19445 Sanitizer: Closing of open but not closed tags
19446 !! wikitext
19447 <s>foo
19448 !! html
19449 <p><s>foo</s>
19450 </p>
19451 !! end
19452
19453 !! test
19454 Sanitizer: Closing of closed but not open tags
19455 !! options
19456 parsoid=wt2html
19457 !! wikitext
19458 </s>
19459 !! html+tidy
19460 <p class="mw-empty-elt">
19461 </p>
19462 !! end
19463
19464 !! test
19465 Sanitizer: Closing of closed but not open table tags
19466 !! options
19467 parsoid=wt2html
19468 !! wikitext
19469 Table not started</td></tr></table>
19470 !! html+tidy
19471 <p>Table not started
19472 </p>
19473 !! end
19474
19475 !! test
19476 Sanitizer: Escaping of spaces, multibyte characters, colons & other stuff in id=""
19477 !! options
19478 title=[[Main Page]]
19479 !! config
19480 wgFragmentMode=[ 'html5', 'legacy' ]
19481 !! wikitext
19482 <span id="æ: v">byte</span>[[#æ: v|backlink]]
19483 !! html/php
19484 <p><span id="æ:_v">byte</span><a href="#æ:_v">backlink</a>
19485 </p>
19486 !! html/parsoid
19487 <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>
19488 !! end
19489
19490 !! test
19491 Sanitizer: Escaping of spaces, multibyte characters, colons & other stuff in id="" (legacy)
19492 !! config
19493 wgFragmentMode=[ 'legacy' ]
19494 !! wikitext
19495 <span id="æ: v">byte</span>[[#æ: v|backlink]]
19496 !! html/php
19497 <p><span id=".C3.A6:_v">byte</span><a href="#.C3.A6:_v">backlink</a>
19498 </p>
19499 !! end
19500
19501 # In HTML5, the restrictions are that id must contain at least one character,
19502 # and must not contain any space characters.
19503 !! test
19504 Sanitizer: Validating the contents of the id attribute (T6515)
19505 !! options
19506 disabled
19507 !! wikitext
19508 <br id="" /><br id="a space" />
19509 !! html
19510 Something ...
19511 !! end
19512
19513 # In HTML5, id must be unique amongst all the ids in the element's home subtree.
19514 !! test
19515 Sanitizer: Validating id attribute uniqueness (T6515, T8301)
19516 !! options
19517 disabled
19518 !! wikitext
19519 <br id="foo" /><br id="foo" />
19520 !! html
19521 Something need to be done. foo-2 ?
19522 !! end
19523
19524 !! test
19525 Sanitizer: Validating that <meta> and <link> work, but only for Microdata
19526 !! wikitext
19527 <div itemscope>
19528 <meta itemprop="hello" content="world">
19529 <meta http-equiv="refresh" content="5">
19530 <meta itemprop="hello" http-equiv="refresh" content="5">
19531 <link itemprop="hello" href="{{SERVER}}">
19532 <link rel="stylesheet" href="{{SERVER}}">
19533 <link rel="stylesheet" itemprop="hello" href="{{SERVER}}">
19534 </div>
19535 !! html
19536 <div itemscope="">
19537 <p> <meta itemprop="hello" content="world" />
19538 &lt;meta http-equiv="refresh" content="5"&gt;
19539 <meta itemprop="hello" content="5" />
19540 <link itemprop="hello" href="http&#58;//example.org" />
19541 &lt;link rel="stylesheet" href="<a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>"&gt;
19542 <link itemprop="hello" href="http&#58;//example.org" />
19543 </p>
19544 </div>
19545
19546 !! end
19547
19548 !! test
19549 Sanitizer: Strip comments from CSS attributes
19550 !! options
19551 parsoid=wt2html,wt2wt
19552 !! wikitext
19553 <span style="margin:/*negate mbox-text padding */-0.125em -0.45em; /*rainbow*/rgba(255, 0, 0, 0.3)">2013</span>
19554 !! html/php
19555 <p><span style="margin: -0.125em -0.45em; rgba(255, 0, 0, 0.3)">2013</span>
19556 </p>
19557 !! html/parsoid
19558 <p><span style="margin: -0.125em -0.45em; rgba(255, 0, 0, 0.3)">2013</span></p>
19559 !! end
19560
19561 !! test
19562 Sanitizer: Avoid unnecessary percent encoded characters in interwiki links
19563 !! wikitext
19564 [[meatball:Soft"Security]]
19565 !! html/php
19566 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?Soft%22Security" class="extiw" title="meatball:Soft&quot;Security">meatball:Soft"Security</a>
19567 </p>
19568 !! html/parsoid
19569 <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>
19570 !! end
19571
19572 !! test
19573 Sanitizer: angle brackets are invalid, even in interwiki links (T182338)
19574 !! wikitext
19575 [[meatball:Foo<Bar]]
19576 [[meatball:Foo>Bar]]
19577 [[meatball:Foo&lt;bar]]
19578 [[meatball:Foo&gt;bar]]
19579 !! html/php
19580 <p>[[meatball:Foo&lt;Bar]]
19581 [[meatball:Foo&gt;Bar]]
19582 [[meatball:Foo&lt;bar]]
19583 [[meatball:Foo&gt;bar]]
19584 </p>
19585 !! html/parsoid
19586 <p>[[meatball:Foo&lt;Bar]]
19587 [[meatball:Foo>Bar]]
19588 [[meatball:Foo<span typeof="mw:Entity" data-parsoid='{"src":"&amp;lt;","srcContent":"&lt;"}'>&lt;</span>bar]]
19589 [[meatball:Foo<span typeof="mw:Entity" data-parsoid='{"src":"&amp;gt;","srcContent":">"}'>></span>bar]]</p>
19590 !! end
19591
19592 !! test
19593 Language converter: output gets cut off unexpectedly (T7757)
19594 !! options
19595 language=zh
19596 !! wikitext
19597 this bit is safe: }-
19598
19599 but if we add a conversion instance: -{zh-cn:xxx;zh-tw:yyy}-
19600
19601 then we get cut off here: }-
19602
19603 all additional text is vanished
19604 !! html/php
19605 <p>this bit is safe: }-
19606 </p><p>but if we add a conversion instance: xxx
19607 </p><p>then we get cut off here: }-
19608 </p><p>all additional text is vanished
19609 </p>
19610 !! html/parsoid
19611 <p>this bit is safe: }-</p>
19612 <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>
19613 <p>then we get cut off here: }-</p>
19614 <p>all additional text is vanished</p>
19615 !! end
19616
19617 !! test
19618 Language converter glossary rules inside attributes (T119158)
19619 !! options
19620 language=sr variant=sr-el
19621 !! wikitext
19622 -{H|foAjrjvi=>sr-el:" onload="alert(1)" data-foo="}-
19623
19624 [[File:Foobar.jpg|alt=-{}-foAjrjvi-{}-]]
19625 !! html/php
19626 <p>
19627 </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>
19628 </p>
19629 !! html/parsoid
19630 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"foAjrjvi","l":"sr-el","t":"\" onload=\"alert(1)\" data-foo=\""}]}'/></p>
19631
19632 <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>
19633 !! end
19634
19635 !! test
19636 Self closed html pairs (T7487)
19637 !! wikitext
19638 <center><font id="bug" />Centered text</center>
19639 <div><font id="bug2" />In div text</div>
19640 !! html+tidy
19641 <center><font id="bug"></font>Centered text</center>
19642 <div><font id="bug2"></font>In div text</div>
19643 !! end
19644
19645 !! test
19646 Punctuation: nbsp before exclamation
19647 !! wikitext
19648 C'est grave !
19649 !! html
19650 <p>C'est grave&#160;!
19651 </p>
19652 !! end
19653
19654 !! test
19655 Punctuation: CSS !important (T13874)
19656 !! wikitext
19657 <div style="width:50% !important">important</div>
19658 !! html
19659 <div style="width:50% !important">important</div>
19660
19661 !!end
19662
19663 !! test
19664 Punctuation: CSS ! important (T13874; with space after)
19665 !! wikitext
19666 <div style="width:50% ! important">important</div>
19667 !! html
19668 <div style="width:50%&#32;! important">important</div>
19669
19670 !!end
19671
19672 !! test
19673 HTML bullet list, closed tags (T7497)
19674 !! wikitext
19675 <ul>
19676 <li>One</li>
19677 <li>Two</li>
19678 </ul>
19679 !! html/php
19680 <ul>
19681 <li>One</li>
19682 <li>Two</li>
19683 </ul>
19684
19685 !! html/parsoid
19686 <ul data-parsoid='{"stx":"html"}'>
19687 <li data-parsoid='{"stx":"html"}'>One</li>
19688 <li data-parsoid='{"stx":"html"}'>Two</li>
19689 </ul>
19690
19691 !! end
19692
19693 !! test
19694 HTML bullet list, unclosed tags (T7497)
19695 !! wikitext
19696 <ul>
19697 <li>One
19698 <li>Two
19699 </ul>
19700 !! html/php+tidy
19701 <ul>
19702 <li>One
19703 </li><li>Two
19704 </li></ul>
19705 !! html/parsoid
19706 <ul data-parsoid='{"stx":"html"}'>
19707 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>One</li>
19708 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>Two</li>
19709 </ul>
19710
19711 !! end
19712
19713 !! test
19714 HTML ordered list, closed tags (T7497)
19715 !! wikitext
19716 <ol>
19717 <li>One</li>
19718 <li>Two</li>
19719 </ol>
19720 !! html/php
19721 <ol>
19722 <li>One</li>
19723 <li>Two</li>
19724 </ol>
19725
19726 !! html/parsoid
19727 <ol data-parsoid='{"stx":"html"}'>
19728 <li data-parsoid='{"stx":"html"}'>One</li>
19729 <li data-parsoid='{"stx":"html"}'>Two</li>
19730 </ol>
19731
19732 !! end
19733
19734 !! test
19735 HTML ordered list, unclosed tags (T7497)
19736 !! options
19737 !! wikitext
19738 <ol>
19739 <li>One
19740 <li>Two
19741 </ol>
19742 !! html/php+tidy
19743 <ol>
19744 <li>One
19745 </li><li>Two
19746 </li></ol>
19747 !! html/parsoid
19748 <ol data-parsoid='{"stx":"html"}'>
19749 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>One</li>
19750 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>Two</li>
19751 </ol>
19752
19753 !! end
19754
19755 !! test
19756 HTML nested bullet list, closed tags (T7497)
19757 !! wikitext
19758 <ul>
19759 <li>One</li>
19760 <li>Two:
19761 <ul>
19762 <li>Sub-one</li>
19763 <li>Sub-two</li>
19764 </ul>
19765 </li>
19766 </ul>
19767 !! html/php
19768 <ul>
19769 <li>One</li>
19770 <li>Two:
19771 <ul>
19772 <li>Sub-one</li>
19773 <li>Sub-two</li>
19774 </ul>
19775 </li>
19776 </ul>
19777
19778 !! html/parsoid
19779 <ul data-parsoid='{"stx":"html"}'>
19780 <li data-parsoid='{"stx":"html"}'>One</li>
19781 <li data-parsoid='{"stx":"html"}'>Two:
19782 <ul data-parsoid='{"stx":"html"}'>
19783 <li data-parsoid='{"stx":"html"}'>Sub-one</li>
19784 <li data-parsoid='{"stx":"html"}'>Sub-two</li>
19785 </ul>
19786 </li>
19787 </ul>
19788 !! end
19789
19790 !! test
19791 HTML nested bullet list, open tags (T7497)
19792 !! wikitext
19793 <ul>
19794 <li>One
19795 <li>Two:
19796 <ul>
19797 <li>Sub-one
19798 <li>Sub-two
19799 </ul>
19800 </ul>
19801 !! html+tidy
19802 <ul>
19803 <li>One
19804 </li><li>Two:
19805 <ul>
19806 <li>Sub-one
19807 </li><li>Sub-two
19808 </li></ul>
19809 </li></ul>
19810 !! end
19811
19812 !! test
19813 HTML nested ordered list, closed tags (T7497)
19814 !! wikitext
19815 <ol>
19816 <li>One</li>
19817 <li>Two:
19818 <ol>
19819 <li>Sub-one</li>
19820 <li>Sub-two</li>
19821 </ol>
19822 </li>
19823 </ol>
19824 !! html
19825 <ol>
19826 <li>One</li>
19827 <li>Two:
19828 <ol>
19829 <li>Sub-one</li>
19830 <li>Sub-two</li>
19831 </ol>
19832 </li>
19833 </ol>
19834
19835 !! end
19836
19837 !! test
19838 HTML nested ordered list, open tags (T7497)
19839 !! wikitext
19840 <ol>
19841 <li>One
19842 <li>Two:
19843 <ol>
19844 <li>Sub-one
19845 <li>Sub-two
19846 </ol>
19847 </ol>
19848 !! html/php
19849 <ol>
19850 <li>One
19851 <li>Two:
19852 <ol>
19853 <li>Sub-one
19854 <li>Sub-two
19855 </ol>
19856 </ol>
19857
19858 !! html/parsoid
19859 <ol>
19860 <li>One
19861 </li>
19862 <li>Two:
19863 <ol>
19864 <li>Sub-one
19865 </li>
19866 <li>Sub-two
19867 </li>
19868 </ol>
19869 </li>
19870 </ol>
19871
19872 !! end
19873
19874 !! test
19875 HTML ordered list item with parameters oddity
19876 !! wikitext
19877 <ol><li id="fragment">One</li>
19878 </ol>
19879 !! html
19880 <ol><li id="fragment">One</li>
19881 </ol>
19882
19883 !! end
19884
19885 # parsoid doesn't explicitly mark autonumbered links, see T55505
19886 !!test
19887 T7918: autonumbering
19888 !! wikitext
19889 [http://first/] [http://second] [ftp://ftp]
19890
19891 ftp://inlineftp
19892
19893 [mailto:enclosed@mail.tld With target]
19894
19895 [mailto:enclosed@mail.tld]
19896
19897 mailto:inline@mail.tld
19898 !! html/php
19899 <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>
19900 </p><p><a rel="nofollow" class="external free" href="ftp://inlineftp">ftp://inlineftp</a>
19901 </p><p><a rel="nofollow" class="external text" href="mailto:enclosed@mail.tld">With target</a>
19902 </p><p><a rel="nofollow" class="external autonumber" href="mailto:enclosed@mail.tld">[4]</a>
19903 </p><p><a rel="nofollow" class="external free" href="mailto:inline@mail.tld">mailto:inline@mail.tld</a>
19904 </p>
19905 !! html/parsoid
19906 <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>
19907 <p><a rel="mw:ExtLink" class="external free" href="ftp://inlineftp">ftp://inlineftp</a></p>
19908 <p><a rel="mw:ExtLink" class="external text" href="mailto:enclosed@mail.tld">With target</a></p>
19909 <p><a rel="mw:ExtLink" class="external autonumber" href="mailto:enclosed@mail.tld"></a></p>
19910 <p><a rel="mw:ExtLink" class="external free" href="mailto:inline@mail.tld">mailto:inline@mail.tld</a></p>
19911 !! end
19912
19913
19914 #
19915 # Security and HTML correctness
19916 # From Nick Jenkins' fuzz testing
19917 #
19918
19919 !! test
19920 Fuzz testing: Parser13
19921 !! wikitext
19922 {|
19923 | http://a|
19924 !! html
19925 <table>
19926 <tr>
19927 <td>
19928 </td>
19929 </tr>
19930 </table>
19931
19932 !! end
19933
19934 # Note that Parsoid output differs from the PHP parser here: the PHP
19935 # parser breaks the URL for the magic word, while in Parsoid the URL
19936 # production takes precedence.
19937 !! test
19938 Fuzz testing: Parser14
19939 !! wikitext
19940 ==onmouseover===
19941 http://__TOC__
19942 !! html/php
19943 <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>
19944 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>
19945 <ul>
19946 <li class="toclevel-1 tocsection-1"><a href="#onmouseover.3D"><span class="tocnumber">1</span> <span class="toctext">onmouseover=</span></a></li>
19947 </ul>
19948 </div>
19949
19950
19951 !! html/php+tidy
19952 <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>
19953 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>
19954 <ul>
19955 <li class="toclevel-1 tocsection-1"><a href="#onmouseover.3D"><span class="tocnumber">1</span> <span class="toctext">onmouseover=</span></a></li>
19956 </ul>
19957 </div>
19958 !! html/parsoid
19959 <h2 id="onmouseover="><span id="onmouseover.3D" typeof="mw:FallbackId"></span>onmouseover=</h2>
19960 <p><a rel="mw:ExtLink" class="external free" href="http://__TOC__" data-parsoid='{"stx":"url"}'>http://__TOC__</a></p>
19961 !! end
19962
19963 !! test
19964 Fuzz testing: Parser14-table
19965 !! options
19966 parsoid=wt2html,html2html
19967 !! wikitext
19968 ==a==
19969 {| STYLE=__TOC__
19970 !! html/php
19971 <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>
19972 <table style="&#95;_TOC&#95;_">
19973 <tr><td></td></tr>
19974 </table>
19975
19976 !! html/php+tidy
19977 <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>
19978 <table style="&#95;_TOC&#95;_">
19979 <tbody><tr><td></td></tr>
19980 </tbody></table>
19981 !! html/parsoid
19982 <h2 id="a">a</h2>
19983 <table style="__TOC__"></table>
19984 !! end
19985
19986 # Known to produce bogus xml (extra </td>)
19987 # Don't add the html/php section since it generates broken HTML
19988 !! test
19989 Fuzz testing: Parser16
19990 !! wikitext
19991 {|
19992 !https://||||||
19993 !! html+tidy
19994 <table>
19995 <tbody><tr>
19996 <th>https://</th>
19997 <th></th>
19998 <th></th>
19999 <th>
20000
20001 </th></tr>
20002 </tbody></table>
20003 !! end
20004
20005 !! test
20006 Fuzz testing: Parser21
20007 !! wikitext
20008 {|
20009 !irc://{{ftp://a" onmouseover="alert('hello world');"
20010 |
20011 !! html
20012 <table>
20013 <tr>
20014 <th><a rel="nofollow" class="external free" href="irc://{{ftp://a">irc://{{ftp://a</a>" onmouseover="alert('hello world');"
20015 </th>
20016 <td>
20017 </td>
20018 </tr>
20019 </table>
20020
20021 !! end
20022
20023 !! test
20024 Fuzz testing: Parser22
20025 !! wikitext
20026 http://===r:::https://b
20027
20028 {|
20029 !! html
20030 <p><a rel="nofollow" class="external free" href="http://===r:::https://b">http://===r:::https://b</a>
20031 </p>
20032 <table>
20033 <tr><td></td></tr>
20034 </table>
20035
20036 !! end
20037
20038 ## Remex doesn't account for fostered content.
20039 ## Known to produce bad XML for now
20040 !! test
20041 Fuzz testing: Parser24
20042 !! options
20043 parsoid=wt2html
20044 !! wikitext
20045 {|
20046 {{{|
20047 <u CLASS=
20048 | {{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx--><noinclude>}}}} >
20049 <br style="onmouseover='alert(document.cookie);' " />
20050
20051 MOVE YOUR MOUSE CURSOR OVER THIS TEXT
20052 |
20053 !! html/php
20054 <table>
20055 {{{|
20056 <u class="&#124;">}}}} &gt;
20057 <br style="onmouseover=&#39;alert(document.cookie);&#39;" />
20058
20059 MOVE YOUR MOUSE CURSOR OVER THIS TEXT
20060 <tr>
20061 <td></u>
20062 </td>
20063 </tr>
20064 </table>
20065
20066 !! html/php+tidy
20067
20068 {{{|
20069 <u class="&#124;">}}}} &gt;
20070 <br style="onmouseover=&#39;alert(document.cookie);&#39;" />
20071
20072 MOVE YOUR MOUSE CURSOR OVER THIS TEXT
20073 </u><table><tbody><tr>
20074 <td>
20075 </td>
20076 </tr>
20077 </tbody></table><p><u class="&#124;">
20078 </u></p>
20079 !! html/parsoid
20080 <p data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true}'>
20081 {{{|
20082 <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>"}'/>}}}} >
20083 <br style="onmouseover='alert(document.cookie);' " data-parsoid='{"stx":"html","selfClose":true}'/>
20084
20085 MOVE YOUR MOUSE CURSOR OVER THIS TEXT</u></p>
20086 <table data-parsoid='{"autoInsertedEnd":true}'><tbody><tr data-parsoid='{"autoInsertedStart":true}'><td></td></tr></tbody></table>
20087 !! end
20088
20089 # Note: the current result listed for this is not what the original one was,
20090 # but the original bug was JavaScript injection, which is fixed in any case.
20091 # It's not clear that the original result listed was any more correct than the
20092 # current one. Original result:
20093 # <p>{{{|
20094 # </p>
20095 # <li class="&#124;&#124;">
20096 # }}}blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b>
20097 !!test
20098 Fuzz testing: Parser25 (T8055)
20099 !! wikitext
20100 {{{
20101 |
20102 <LI CLASS=||
20103 >
20104 }}}blah" onmouseover="alert('hello world');" align="left"'''MOVE MOUSE CURSOR OVER HERE
20105 !! html/php
20106 <p>&lt;LI CLASS=blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b>
20107 </p>
20108 !! html/parsoid
20109 <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"]}'>
20110 </span><p about="#mwt1">&lt;LI CLASS=blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b></p>
20111 !! end
20112
20113 !!test
20114 Fuzz testing: URL adjacent extension (with space, clean)
20115 !! wikitext
20116 http://example.com <nowiki>junk</nowiki>
20117 !! html/php
20118 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> junk
20119 </p>
20120 !! html/parsoid
20121 <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>
20122 !! end
20123
20124 !!test
20125 Fuzz testing: URL adjacent extension (no space, dirty; nowiki)
20126 !! wikitext
20127 http://example.com<nowiki>junk</nowiki>
20128 !! html/php
20129 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>junk
20130 </p>
20131 !! html/parsoid
20132 <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>
20133 !! end
20134
20135 !! test
20136 Fuzz testing: URL adjacent extension (no space, dirty; pre)
20137 !! wikitext
20138 http://example.com<pre>junk</pre>
20139 !! html/php
20140 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a><pre>junk</pre>
20141
20142 !! html/php+tidy
20143 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a></p><pre>junk</pre>
20144 !! html/parsoid
20145 <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>
20146 !! end
20147
20148 !! test
20149 Fuzz testing: image with bogus manual thumbnail
20150 !! wikitext
20151 [[Image:foobar.jpg|thumbnail= ]]
20152 !! html/php
20153 <div class="thumb tright"><div class="thumbinner" style="width:182px;">Error creating thumbnail: <div class="thumbcaption"></div></div></div>
20154
20155 !! html/parsoid
20156 <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>
20157 !! end
20158
20159 # Parsoid will emit the newline literally in wt2wt; see next test case.
20160 !! test
20161 Fuzz testing: encoded newline in generated HTML replacements (T8577)
20162 !! options
20163 parsoid=wt2html
20164 !! wikitext
20165 <pre dir="&#10;"></pre>
20166 !! html/php
20167 <pre dir="&#10;"></pre>
20168
20169 !! html/parsoid
20170 <pre dir="
20171 " typeof="mw:Extension/pre" about="#mwt2"data-mw='{"name":"pre","attrs":{"dir":"\n"},"body":{"extsrc":""}}'></pre>
20172 !! end
20173
20174 !! test
20175 Fuzz testing: encoded newline in generated HTML replacements, html2wt (T8577)
20176 !! options
20177 parsoid=html2wt
20178 !! html/parsoid
20179 <pre typeof="mw:Extension/pre" about="#mwt2" dir="
20180 " data-mw='{"name":"pre","attrs":{"dir":"\n"},"body":{"extsrc":""}}'></pre>
20181 !! wikitext
20182 <pre dir="
20183 "></pre>
20184 !! html/php
20185 <pre dir=""></pre>
20186
20187 !! end
20188
20189 !! test
20190 Templates in extension attributes are not expanded
20191 !! wikitext
20192 <pre dir="{{echo|ltr}}"></pre>
20193 !! html/php
20194 <pre dir="{{echo|ltr}}"></pre>
20195
20196 !! html/parsoid
20197 <pre dir="{{echo|ltr}}" typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{"dir":"{{echo|ltr}}"},"body":{"extsrc":""}}'></pre>
20198 !! end
20199
20200 !! test
20201 Parsing optional HTML elements (T8171)
20202 !! options
20203 !! wikitext
20204 <table>
20205 <tr>
20206 <td> Some tabular data</td>
20207 <td> More tabular data ...
20208 <td> And yet som tabular data</td>
20209 </tr>
20210 </table>
20211 !! html
20212 <table>
20213 <tr>
20214 <td> Some tabular data</td>
20215 <td> More tabular data ...
20216 </td><td> And yet som tabular data</td>
20217 </tr>
20218 </table>
20219
20220 !! end
20221
20222 !! test
20223 Correct handling of <td>, <tr> (T8171)
20224 !! options
20225 !! wikitext
20226 <table>
20227 <tr>
20228 <td> Some tabular data</td>
20229 <td> More tabular data ...</td>
20230 <td> And yet som tabular data</td>
20231 </tr>
20232 </table>
20233 !! html
20234 <table>
20235 <tr>
20236 <td> Some tabular data</td>
20237 <td> More tabular data ...</td>
20238 <td> And yet som tabular data</td>
20239 </tr>
20240 </table>
20241
20242 !! end
20243
20244
20245 !! test
20246 Parsing crashing regression (fr:JavaScript)
20247 !! wikitext
20248 </body></x>
20249 !! html
20250 <p>&lt;/body&gt;&lt;/x&gt;
20251 </p>
20252 !! end
20253
20254 !! test
20255 Inline wiki vs wiki block nesting
20256 !! wikitext
20257 '''Bold paragraph
20258
20259 New wiki paragraph
20260 !! html
20261 <p><b>Bold paragraph</b>
20262 </p><p>New wiki paragraph
20263 </p>
20264 !! end
20265
20266 # FIXME: The current php output is documented
20267 # and desired output is the parsoid target.
20268 !! test
20269 Inline HTML vs wiki block nesting
20270 !! wikitext
20271 <b>Bold paragraph
20272
20273 New wiki paragraph
20274 !! html/php
20275 <p><b>Bold paragraph
20276 </p><p>New wiki paragraph</b>
20277 </p>
20278 !! html/php+tidy
20279 <p><b>Bold paragraph
20280 </b></p><p><b>New wiki paragraph
20281 </b></p>
20282 !! html/parsoid
20283 <p><b>Bold paragraph</b>
20284 </p><p>New wiki paragraph
20285 </p>
20286 !! end
20287
20288 # Original result was this:
20289 # <p><b>bold</b><b>bold<i>bolditalics</i></b>
20290 # </p>
20291 # While that might be marginally more intuitive, maybe, the six-apostrophe
20292 # construct is clearly pathological and the result stated here (which is what
20293 # the parser actually does) is about as reasonable as anything.
20294 !!test
20295 Mixing markup for italics and bold
20296 !! options
20297 !! wikitext
20298 '''bold''''''bold''bolditalics'''''
20299 !! html
20300 <p>'<i>bold'</i><b>bold<i>bolditalics</i></b>
20301 </p>
20302 !! end
20303
20304
20305 !! article
20306 Xyzzyx
20307 !! text
20308 Article for special page transclusion test
20309 !! endarticle
20310
20311 !! test
20312 Special page transclusion
20313 !! options
20314 !! wikitext
20315 {{Special:Prefixindex/Xyzzyx}}
20316 !! html
20317 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
20318 </ul>
20319
20320 !! end
20321
20322 !! test
20323 Special page transclusion twice (T7021)
20324 !! options
20325 !! wikitext
20326 {{Special:Prefixindex/Xyzzyx}}
20327 {{Special:Prefixindex/Xyzzyx}}
20328 !! html
20329 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
20330 </ul>
20331 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
20332 </ul>
20333
20334 !! end
20335
20336 !! test
20337 Transclusion of default MediaWiki message
20338 !! wikitext
20339 {{MediaWiki:Mainpage}}
20340 !! html
20341 <p>Main Page
20342 </p>
20343 !! end
20344
20345 !! test
20346 Transclusion of nonexistent MediaWiki message
20347 !! wikitext
20348 {{MediaWiki:Mainpagexxx}}
20349 !! html
20350 <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>
20351 </p>
20352 !! end
20353
20354 !! test
20355 Transclusion of MediaWiki message with underscore
20356 !! wikitext
20357 {{MediaWiki:history_short}}
20358 !! html
20359 <p>History
20360 </p>
20361 !! end
20362
20363 !! test
20364 Transclusion of MediaWiki message with space
20365 !! wikitext
20366 {{MediaWiki:history short}}
20367 !! html
20368 <p>History
20369 </p>
20370 !! end
20371
20372 !! test
20373 Invalid header with following text
20374 !! wikitext
20375 = x = y
20376 !! html
20377 <p>= x = y
20378 </p>
20379 !! end
20380
20381
20382 !! test
20383 Section extraction test (section 0)
20384 !! options
20385 section=0
20386 !! wikitext
20387 start
20388 ==a==
20389 ===aa===
20390 ====aaa====
20391 ==b==
20392 ===ba===
20393 ===bb===
20394 ====bba====
20395 ===bc===
20396 ==c==
20397 ===ca===
20398 !! html/php
20399 start
20400 !! end
20401
20402 !! test
20403 Section extraction test (section 1)
20404 !! options
20405 section=1
20406 !! wikitext
20407 start
20408 ==a==
20409 ===aa===
20410 ====aaa====
20411 ==b==
20412 ===ba===
20413 ===bb===
20414 ====bba====
20415 ===bc===
20416 ==c==
20417 ===ca===
20418 !! html/php
20419 ==a==
20420 ===aa===
20421 ====aaa====
20422 !! end
20423
20424 !! test
20425 Section extraction test (section 2)
20426 !! options
20427 section=2
20428 !! wikitext
20429 start
20430 ==a==
20431 ===aa===
20432 ====aaa====
20433 ==b==
20434 ===ba===
20435 ===bb===
20436 ====bba====
20437 ===bc===
20438 ==c==
20439 ===ca===
20440 !! html/php
20441 ===aa===
20442 ====aaa====
20443 !! end
20444
20445 !! test
20446 Section extraction test (section 3)
20447 !! options
20448 section=3
20449 !! wikitext
20450 start
20451 ==a==
20452 ===aa===
20453 ====aaa====
20454 ==b==
20455 ===ba===
20456 ===bb===
20457 ====bba====
20458 ===bc===
20459 ==c==
20460 ===ca===
20461 !! html/php
20462 ====aaa====
20463 !! end
20464
20465 !! test
20466 Section extraction test (section 4)
20467 !! options
20468 section=4
20469 !! wikitext
20470 start
20471 ==a==
20472 ===aa===
20473 ====aaa====
20474 ==b==
20475 ===ba===
20476 ===bb===
20477 ====bba====
20478 ===bc===
20479 ==c==
20480 ===ca===
20481 !! html/php
20482 ==b==
20483 ===ba===
20484 ===bb===
20485 ====bba====
20486 ===bc===
20487 !! end
20488
20489 !! test
20490 Section extraction test (section 5)
20491 !! options
20492 section=5
20493 !! wikitext
20494 start
20495 ==a==
20496 ===aa===
20497 ====aaa====
20498 ==b==
20499 ===ba===
20500 ===bb===
20501 ====bba====
20502 ===bc===
20503 ==c==
20504 ===ca===
20505 !! html/php
20506 ===ba===
20507 !! end
20508
20509 !! test
20510 Section extraction test (section 6)
20511 !! options
20512 section=6
20513 !! wikitext
20514 start
20515 ==a==
20516 ===aa===
20517 ====aaa====
20518 ==b==
20519 ===ba===
20520 ===bb===
20521 ====bba====
20522 ===bc===
20523 ==c==
20524 ===ca===
20525 !! html/php
20526 ===bb===
20527 ====bba====
20528 !! end
20529
20530 !! test
20531 Section extraction test (section 7)
20532 !! options
20533 section=7
20534 !! wikitext
20535 start
20536 ==a==
20537 ===aa===
20538 ====aaa====
20539 ==b==
20540 ===ba===
20541 ===bb===
20542 ====bba====
20543 ===bc===
20544 ==c==
20545 ===ca===
20546 !! html/php
20547 ====bba====
20548 !! end
20549
20550 !! test
20551 Section extraction test (section 8)
20552 !! options
20553 section=8
20554 !! wikitext
20555 start
20556 ==a==
20557 ===aa===
20558 ====aaa====
20559 ==b==
20560 ===ba===
20561 ===bb===
20562 ====bba====
20563 ===bc===
20564 ==c==
20565 ===ca===
20566 !! html/php
20567 ===bc===
20568 !! end
20569
20570 !! test
20571 Section extraction test (section 9)
20572 !! options
20573 section=9
20574 !! wikitext
20575 start
20576 ==a==
20577 ===aa===
20578 ====aaa====
20579 ==b==
20580 ===ba===
20581 ===bb===
20582 ====bba====
20583 ===bc===
20584 ==c==
20585 ===ca===
20586 !! html/php
20587 ==c==
20588 ===ca===
20589 !! end
20590
20591 !! test
20592 Section extraction test (section 10)
20593 !! options
20594 section=10
20595 !! wikitext
20596 start
20597 ==a==
20598 ===aa===
20599 ====aaa====
20600 ==b==
20601 ===ba===
20602 ===bb===
20603 ====bba====
20604 ===bc===
20605 ==c==
20606 ===ca===
20607 !! html/php
20608 ===ca===
20609 !! end
20610
20611 !! test
20612 Section extraction test (nonexistent section 11)
20613 !! options
20614 section=11
20615 !! wikitext
20616 start
20617 ==a==
20618 ===aa===
20619 ====aaa====
20620 ==b==
20621 ===ba===
20622 ===bb===
20623 ====bba====
20624 ===bc===
20625 ==c==
20626 ===ca===
20627 !! html/php
20628 !! end
20629
20630 !! test
20631 Section extraction test with bogus heading (section 1)
20632 !! options
20633 section=1
20634 !! wikitext
20635 ==a==
20636 ==bogus== not a legal section
20637 ==b==
20638 !! html/php
20639 ==a==
20640 ==bogus== not a legal section
20641 !! end
20642
20643 !! test
20644 Section extraction test with bogus heading (section 2)
20645 !! options
20646 section=2
20647 !! wikitext
20648 ==a==
20649 ==bogus== not a legal section
20650 ==b==
20651 !! html/php
20652 ==b==
20653 !! end
20654
20655 !! test
20656 Section extraction test with comment after heading (section 1)
20657 !! options
20658 section=1
20659 !! wikitext
20660 ==a==
20661 ==b== <!-- -->
20662 ==c==
20663 !! html/php
20664 ==a==
20665 !! end
20666
20667 !! test
20668 Section extraction test with comment after heading (section 2)
20669 !! options
20670 section=2
20671 !! wikitext
20672 ==a==
20673 ==b== <!-- -->
20674 ==c==
20675 !! html/php
20676 ==b== <!-- -->
20677 !! end
20678
20679 !! test
20680 Section extraction test with bogus <nowiki> heading (section 1)
20681 !! options
20682 section=1
20683 !! wikitext
20684 ==a==
20685 ==bogus== <nowiki>not a legal section</nowiki>
20686 ==b==
20687 !! html/php
20688 ==a==
20689 ==bogus== <nowiki>not a legal section</nowiki>
20690 !! end
20691
20692 !! test
20693 Section extraction test with bogus <nowiki> heading (section 2)
20694 !! options
20695 section=2
20696 !! wikitext
20697 ==a==
20698 ==bogus== <nowiki>not a legal section</nowiki>
20699 ==b==
20700 !! html/php
20701 ==b==
20702 !! end
20703
20704 # Formerly testing for T4587, now resolved by the use of unmarked sections
20705 # instead of respecting commented sections
20706 !! test
20707 Section extraction prefixed by comment (section 1)
20708 !! options
20709 section=1
20710 !! wikitext
20711 <!-- -->==sec1==
20712 ==sec2==
20713 !! html/php
20714 ==sec2==
20715 !!end
20716
20717 !! test
20718 Section extraction prefixed by comment (section 2)
20719 !! options
20720 section=2
20721 !! wikitext
20722 <!-- -->==sec1==
20723 ==sec2==
20724 !! html/php
20725
20726 !!end
20727
20728 # Formerly testing for T4607, now resolved by the use of unmarked sections
20729 # instead of respecting HTML-style headings
20730 !! test
20731 Section extraction, mixed wiki and html (section 1)
20732 !! options
20733 section=1
20734 !! wikitext
20735 <h2>unmarked</h2>
20736 unmarked
20737 ==1==
20738 one
20739 ==2==
20740 two
20741 !! html/php
20742 ==1==
20743 one
20744 !! end
20745
20746 !! test
20747 Section extraction, mixed wiki and html (section 2)
20748 !! options
20749 section=2
20750 !! wikitext
20751 <h2>unmarked</h2>
20752 unmarked
20753 ==1==
20754 one
20755 ==2==
20756 two
20757 !! html/php
20758 ==2==
20759 two
20760 !! end
20761
20762
20763 # Formerly testing for T5342
20764 !! test
20765 Section extraction, heading surrounded by <noinclude>
20766 !! options
20767 section=1
20768 !! wikitext
20769 <noinclude>==unmarked==</noinclude>
20770 ==marked==
20771 !! html/php
20772 ==marked==
20773 !!end
20774
20775 # Test behavior of T21910
20776 !! test
20777 Sectiion with all-equals
20778 !! options
20779 section=2
20780 !! wikitext
20781 ===
20782 The line above must have a trailing space
20783 === <!--
20784 --> <!-- -->
20785 But just in case it doesn't...
20786 !! html/php
20787 === <!--
20788 --> <!-- -->
20789 But just in case it doesn't...
20790 !! end
20791
20792 !! test
20793 Section replacement test (section 0)
20794 !! options
20795 replace=0,"xxx"
20796 !! wikitext
20797 start
20798 ==a==
20799 ===aa===
20800 ====aaa====
20801 ==b==
20802 ===ba===
20803 ===bb===
20804 ====bba====
20805 ===bc===
20806 ==c==
20807 ===ca===
20808 !! html/php
20809 xxx
20810
20811 ==a==
20812 ===aa===
20813 ====aaa====
20814 ==b==
20815 ===ba===
20816 ===bb===
20817 ====bba====
20818 ===bc===
20819 ==c==
20820 ===ca===
20821 !! end
20822
20823 !! test
20824 Section replacement test (section 1)
20825 !! options
20826 replace=1,"xxx"
20827 !! wikitext
20828 start
20829 ==a==
20830 ===aa===
20831 ====aaa====
20832 ==b==
20833 ===ba===
20834 ===bb===
20835 ====bba====
20836 ===bc===
20837 ==c==
20838 ===ca===
20839 !! html/php
20840 start
20841 xxx
20842
20843 ==b==
20844 ===ba===
20845 ===bb===
20846 ====bba====
20847 ===bc===
20848 ==c==
20849 ===ca===
20850 !! end
20851
20852 !! test
20853 Section replacement test (section 2)
20854 !! options
20855 replace=2,"xxx"
20856 !! wikitext
20857 start
20858 ==a==
20859 ===aa===
20860 ====aaa====
20861 ==b==
20862 ===ba===
20863 ===bb===
20864 ====bba====
20865 ===bc===
20866 ==c==
20867 ===ca===
20868 !! html/php
20869 start
20870 ==a==
20871 xxx
20872
20873 ==b==
20874 ===ba===
20875 ===bb===
20876 ====bba====
20877 ===bc===
20878 ==c==
20879 ===ca===
20880 !! end
20881
20882 !! test
20883 Section replacement test (section 3)
20884 !! options
20885 replace=3,"xxx"
20886 !! wikitext
20887 start
20888 ==a==
20889 ===aa===
20890 ====aaa====
20891 ==b==
20892 ===ba===
20893 ===bb===
20894 ====bba====
20895 ===bc===
20896 ==c==
20897 ===ca===
20898 !! html/php
20899 start
20900 ==a==
20901 ===aa===
20902 xxx
20903
20904 ==b==
20905 ===ba===
20906 ===bb===
20907 ====bba====
20908 ===bc===
20909 ==c==
20910 ===ca===
20911 !! end
20912
20913 !! test
20914 Section replacement test (section 4)
20915 !! options
20916 replace=4,"xxx"
20917 !! wikitext
20918 start
20919 ==a==
20920 ===aa===
20921 ====aaa====
20922 ==b==
20923 ===ba===
20924 ===bb===
20925 ====bba====
20926 ===bc===
20927 ==c==
20928 ===ca===
20929 !! html/php
20930 start
20931 ==a==
20932 ===aa===
20933 ====aaa====
20934 xxx
20935
20936 ==c==
20937 ===ca===
20938 !! end
20939
20940 !! test
20941 Section replacement test (section 5)
20942 !! options
20943 replace=5,"xxx"
20944 !! wikitext
20945 start
20946 ==a==
20947 ===aa===
20948 ====aaa====
20949 ==b==
20950 ===ba===
20951 ===bb===
20952 ====bba====
20953 ===bc===
20954 ==c==
20955 ===ca===
20956 !! html/php
20957 start
20958 ==a==
20959 ===aa===
20960 ====aaa====
20961 ==b==
20962 xxx
20963
20964 ===bb===
20965 ====bba====
20966 ===bc===
20967 ==c==
20968 ===ca===
20969 !! end
20970
20971 !! test
20972 Section replacement test (section 6)
20973 !! options
20974 replace=6,"xxx"
20975 !! wikitext
20976 start
20977 ==a==
20978 ===aa===
20979 ====aaa====
20980 ==b==
20981 ===ba===
20982 ===bb===
20983 ====bba====
20984 ===bc===
20985 ==c==
20986 ===ca===
20987 !! html/php
20988 start
20989 ==a==
20990 ===aa===
20991 ====aaa====
20992 ==b==
20993 ===ba===
20994 xxx
20995
20996 ===bc===
20997 ==c==
20998 ===ca===
20999 !! end
21000
21001 !! test
21002 Section replacement test (section 7)
21003 !! options
21004 replace=7,"xxx"
21005 !! wikitext
21006 start
21007 ==a==
21008 ===aa===
21009 ====aaa====
21010 ==b==
21011 ===ba===
21012 ===bb===
21013 ====bba====
21014 ===bc===
21015 ==c==
21016 ===ca===
21017 !! html/php
21018 start
21019 ==a==
21020 ===aa===
21021 ====aaa====
21022 ==b==
21023 ===ba===
21024 ===bb===
21025 xxx
21026
21027 ===bc===
21028 ==c==
21029 ===ca===
21030 !! end
21031
21032 !! test
21033 Section replacement test (section 8)
21034 !! options
21035 replace=8,"xxx"
21036 !! wikitext
21037 start
21038 ==a==
21039 ===aa===
21040 ====aaa====
21041 ==b==
21042 ===ba===
21043 ===bb===
21044 ====bba====
21045 ===bc===
21046 ==c==
21047 ===ca===
21048 !! html/php
21049 start
21050 ==a==
21051 ===aa===
21052 ====aaa====
21053 ==b==
21054 ===ba===
21055 ===bb===
21056 ====bba====
21057 xxx
21058
21059 ==c==
21060 ===ca===
21061 !!end
21062
21063 !! test
21064 Section replacement test (section 9)
21065 !! options
21066 replace=9,"xxx"
21067 !! wikitext
21068 start
21069 ==a==
21070 ===aa===
21071 ====aaa====
21072 ==b==
21073 ===ba===
21074 ===bb===
21075 ====bba====
21076 ===bc===
21077 ==c==
21078 ===ca===
21079 !! html/php
21080 start
21081 ==a==
21082 ===aa===
21083 ====aaa====
21084 ==b==
21085 ===ba===
21086 ===bb===
21087 ====bba====
21088 ===bc===
21089 xxx
21090 !! end
21091
21092 !! test
21093 Section replacement test (section 10)
21094 !! options
21095 replace=10,"xxx"
21096 !! wikitext
21097 start
21098 ==a==
21099 ===aa===
21100 ====aaa====
21101 ==b==
21102 ===ba===
21103 ===bb===
21104 ====bba====
21105 ===bc===
21106 ==c==
21107 ===ca===
21108 !! html/php
21109 start
21110 ==a==
21111 ===aa===
21112 ====aaa====
21113 ==b==
21114 ===ba===
21115 ===bb===
21116 ====bba====
21117 ===bc===
21118 ==c==
21119 xxx
21120 !! end
21121
21122 !! test
21123 Section replacement test with initial whitespace (T15728)
21124 !! options
21125 replace=2,"xxx"
21126 !! wikitext
21127 Preformatted initial line
21128 ==a==
21129 ===a===
21130 !! html/php
21131 Preformatted initial line
21132 ==a==
21133 xxx
21134 !! end
21135
21136
21137 !! test
21138 Section extraction, heading followed by pre with 20 spaces (T8398)
21139 !! options
21140 section=1
21141 !! wikitext
21142 ==a==
21143 a
21144 !! html/php
21145 ==a==
21146 a
21147 !! end
21148
21149 !! test
21150 Section extraction, heading followed by pre with 19 spaces (T8398 sanity check)
21151 !! options
21152 section=1
21153 !! wikitext
21154 ==a==
21155 a
21156 !! html/php
21157 ==a==
21158 a
21159 !! end
21160
21161
21162 !! test
21163 Section extraction, <pre> around bogus header (T12309)
21164 !! options
21165 section=2
21166 !! wikitext
21167 == Section One ==
21168 <pre>
21169 =======
21170 </pre>
21171
21172 == Section Two ==
21173 stuff
21174 !! html/php
21175 == Section Two ==
21176 stuff
21177 !! end
21178
21179 !! test
21180 Section replacement, <pre> around bogus header (T12309)
21181 !! options
21182 replace=2,"xxx"
21183 !! wikitext
21184 == Section One ==
21185 <pre>
21186 =======
21187 </pre>
21188
21189 == Section Two ==
21190 stuff
21191 !! html/php
21192 == Section One ==
21193 <pre>
21194 =======
21195 </pre>
21196
21197 xxx
21198 !! end
21199
21200 !! test
21201 Handling of &#x0A; in URLs
21202 !! wikitext
21203 *irc://&#x0A;a
21204 !! html/php
21205 <ul><li><a rel="nofollow" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul>
21206
21207 !! html/parsoid
21208 <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>
21209 !! end
21210
21211 !! test
21212 Handling of %0A in URLs
21213 !! wikitext
21214 *irc://%0Aa
21215 !! html/php
21216 <ul><li><a rel="nofollow" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul>
21217
21218 !! html/parsoid
21219 <ul><li><a rel="mw:ExtLink" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul>
21220 !! end
21221
21222 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
21223 !! test
21224 5 quotes, code coverage +1 line
21225 !! options
21226 parsoid=wt2html
21227 !! wikitext
21228 '''''
21229 !! html/php
21230 !! html/parsoid
21231 <p><b><i></i></b></p>
21232 !! end
21233
21234 # same html as previous, but wikitext adjusted to match parsoid html2wt
21235 # note that wt2html and html2html will put the <i> before the <b>
21236 !! test
21237 5 quotes, code coverage +1 line w/ nowiki (1)
21238 !! options
21239 parsoid=wt2wt,html2wt
21240 !! wikitext
21241 '''''<nowiki/>'''''
21242 !! html/php
21243 <p><i></i>
21244 </p>
21245 !! html/parsoid
21246 <p><b><i></i></b></p>
21247 !! end
21248
21249 # same as previous, just swapping the <i> and <b>
21250 !! test
21251 5 quotes, code coverage +1 line w/ nowiki (2)
21252 !! wikitext
21253 '''''<nowiki/>'''''
21254 !! html/php
21255 <p><i></i>
21256 </p>
21257 !! html/parsoid
21258 <p><i><b></b></i></p>
21259 !! end
21260
21261 !! test
21262 Special:Search page linking.
21263 !! wikitext
21264 {{Special:search}}
21265 !! html
21266 <p><a href="/wiki/Special:Search" title="Special:Search">Special:Search</a>
21267 </p>
21268 !! end
21269
21270 !! test
21271 {{!}} is a magic word
21272 !! wikitext
21273 {{!}} is a magic word there and {{!}} is still a magic word here
21274 | is not a magic word here but {{!}} is still a magic word here
21275 !! html/php
21276 <p>| is a magic word there and | is still a magic word here
21277 | is not a magic word here but | is still a magic word here
21278 </p>
21279 !! html/parsoid
21280 <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
21281 | 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>
21282 !! end
21283
21284 !! test
21285 Say the magic word
21286 !! options
21287 title=[[Parser test]]
21288 !! wikitext
21289 *{{PAGENAME}}
21290 *{{PAGENAMEE}}
21291 *{{FULLPAGENAME}}
21292 *{{FULLPAGENAMEE}}
21293 *{{BASEPAGENAME}}
21294 *{{BASEPAGENAMEE}}
21295 *{{SUBPAGENAME}}
21296 *{{SUBPAGENAMEE}}
21297 *{{ROOTPAGENAME}}
21298 *{{ROOTPAGENAMEE}}
21299 *{{TALKPAGENAME}}
21300 *{{TALKPAGENAMEE}}
21301 *{{SUBJECTPAGENAME}}
21302 *{{SUBJECTPAGENAMEE}}
21303 *{{NAMESPACEE}}
21304 *{{NAMESPACE}}
21305 *{{NAMESPACENUMBER}}
21306 *{{TALKSPACE}}
21307 *{{TALKSPACEE}}
21308 *{{SUBJECTSPACE}}
21309 *{{SUBJECTSPACEE}}
21310 *{{Dynamic|{{NUMBEROFUSERS}}|{{NUMBEROFPAGES}}|{{CURRENTVERSION}}|{{CONTENTLANGUAGE}}|{{DIRECTIONMARK}}|{{CURRENTTIMESTAMP}}|{{NUMBEROFARTICLES}}}}
21311 !! html
21312 <ul><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>Parser test</li>
21321 <li>Parser_test</li>
21322 <li>Talk:Parser test</li>
21323 <li>Talk:Parser_test</li>
21324 <li>Parser test</li>
21325 <li>Parser_test</li>
21326 <li></li>
21327 <li></li>
21328 <li>0</li>
21329 <li>Talk</li>
21330 <li>Talk</li>
21331 <li></li>
21332 <li></li>
21333 <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>
21334
21335 !! end
21336 ### Note: Above tests excludes the "{{NUMBEROFADMINS}}" magic word because it generates a MySQL error when included.
21337
21338 !! test
21339 Gallery with valid attributes
21340 !! wikitext
21341 <gallery type="123" summary="345">
21342 File:File:Foobar.jpg
21343 </gallery>
21344 !! html/php
21345 <ul class="gallery mw-gallery-traditional" type="123">
21346 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21347 <div class="thumb" style="height: 150px;">File:Foobar.jpg</div>
21348 <div class="gallerytext">
21349 </div>
21350 </div></li>
21351 </ul>
21352
21353 !! html/parsoid
21354 <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"}}'>
21355 <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>
21356 </ul>
21357 !! end
21358
21359 ## Parsoid thinks the "centre" here is a property, not a caption.
21360 !! test
21361 Gallery
21362 !! options
21363 parsoid={
21364 "modes": ["wt2html"],
21365 "nativeGallery": true
21366 }
21367 !! wikitext
21368 <gallery>
21369 image1.png |
21370 image2.gif|||||
21371
21372 image3|
21373 image4 |300px| centre
21374 image5.svg| http://///////
21375 [[x|xx]]]]
21376 * image6
21377 </gallery>
21378 !! html/php
21379 <ul class="gallery mw-gallery-traditional">
21380 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21381 <div class="thumb" style="height: 150px;">Image1.png</div>
21382 <div class="gallerytext">
21383 </div>
21384 </div></li>
21385 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21386 <div class="thumb" style="height: 150px;">Image2.gif</div>
21387 <div class="gallerytext">
21388 </div>
21389 </div></li>
21390 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21391 <div class="thumb" style="height: 150px;">Image3</div>
21392 <div class="gallerytext">
21393 </div>
21394 </div></li>
21395 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21396 <div class="thumb" style="height: 150px;">Image4</div>
21397 <div class="gallerytext">
21398 <pre>centre
21399 </pre>
21400 </div>
21401 </div></li>
21402 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21403 <div class="thumb" style="height: 150px;">Image5.svg</div>
21404 <div class="gallerytext">
21405 <p><a rel="nofollow" class="external free" href="http://///////">http://///////</a>
21406 </p>
21407 </div>
21408 </div></li>
21409 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21410 <div class="thumb" style="height: 150px;">* image6</div>
21411 <div class="gallerytext">
21412 </div>
21413 </div></li>
21414 </ul>
21415
21416 !! html/parsoid
21417 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
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: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>
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: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>
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:Image3"><img resource="./File:Image3" src="./Special:FilePath/Image3" height="120" width="120"/></a></figure-inline></div><div class="gallerytext"></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:Image4"><img resource="./File:Image4" src="./Special:FilePath/Image4" height="300" width="300"/></a></figure-inline></div><div class="gallerytext"></div></li>
21422 <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>
21423 <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>
21424 </ul>
21425 !! end
21426
21427 !! test
21428 Gallery (with options, html)
21429 !! options
21430 parsoid={
21431 "modes": ["wt2html", "html2html"],
21432 "nativeGallery": true
21433 }
21434 !! wikitext
21435 <gallery widths="70px" heights="40px" perrow="2" caption="Foo [[Main Page]]">
21436 File:Nonexistent.jpg|caption
21437 File:Nonexistent.jpg
21438 image:foobar.jpg|some '''caption''' [[Main Page]]
21439 image:foobar.jpg
21440 image:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla.
21441 </gallery>
21442 !! html/php
21443 <ul class="gallery mw-gallery-traditional" style="max-width: 226px;_width: 226px;">
21444 <li class='gallerycaption'>Foo <a href="/wiki/Main_Page" title="Main Page">Main Page</a></li>
21445 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21446 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
21447 <div class="gallerytext">
21448 <p>caption
21449 </p>
21450 </div>
21451 </div></li>
21452 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21453 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
21454 <div class="gallerytext">
21455 </div>
21456 </div></li>
21457 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21458 <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>
21459 <div class="gallerytext">
21460 <p>some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
21461 </p>
21462 </div>
21463 </div></li>
21464 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21465 <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>
21466 <div class="gallerytext">
21467 </div>
21468 </div></li>
21469 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21470 <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>
21471 <div class="gallerytext">
21472 <p>blabla.
21473 </p>
21474 </div>
21475 </div></li>
21476 </ul>
21477
21478 !! html/parsoid
21479 <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":{}}'>
21480 <li class="gallerycaption">Foo <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></li>
21481 <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>
21482 <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>
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 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>
21484 <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>
21485 <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>
21486 </ul>
21487 !! end
21488
21489 !! test
21490 Gallery (with options, extsrc)
21491 !! options
21492 parsoid={
21493 "nativeGallery": false
21494 }
21495 !! wikitext
21496 <gallery widths="70px" heights="40px" perrow="2" caption="Foo [[Main Page]]">
21497 File:Nonexistent.jpg|caption
21498 File:Nonexistent.jpg
21499 image:foobar.jpg|some '''caption''' [[Main Page]]
21500 image:foobar.jpg
21501 image:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla.
21502 </gallery>
21503 !! html/php
21504 <ul class="gallery mw-gallery-traditional" style="max-width: 226px;_width: 226px;">
21505 <li class='gallerycaption'>Foo <a href="/wiki/Main_Page" title="Main Page">Main Page</a></li>
21506 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21507 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
21508 <div class="gallerytext">
21509 <p>caption
21510 </p>
21511 </div>
21512 </div></li>
21513 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21514 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
21515 <div class="gallerytext">
21516 </div>
21517 </div></li>
21518 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21519 <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>
21520 <div class="gallerytext">
21521 <p>some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
21522 </p>
21523 </div>
21524 </div></li>
21525 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21526 <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>
21527 <div class="gallerytext">
21528 </div>
21529 </div></li>
21530 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21531 <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>
21532 <div class="gallerytext">
21533 <p>blabla.
21534 </p>
21535 </div>
21536 </div></li>
21537 </ul>
21538
21539 !! html/parsoid
21540 <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"}}'>
21541 <li class="gallerycaption">Foo <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></li>
21542 <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>
21543 <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>
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 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>
21545 <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>
21546 <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>
21547 </ul>
21548 !! end
21549
21550 !! test
21551 Gallery (without px units)
21552 !! wikitext
21553 <gallery widths="70" heights="40">
21554 File:Foobar.jpg
21555 </gallery>
21556 !! html/php
21557 <ul class="gallery mw-gallery-traditional">
21558 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21559 <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>
21560 <div class="gallerytext">
21561 </div>
21562 </div></li>
21563 </ul>
21564
21565 !! html/parsoid
21566 <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"}}'>
21567 <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>
21568 </ul>
21569 !! end
21570
21571 !! test
21572 Gallery (with invalid units)
21573 !! wikitext
21574 <gallery widths="70em" heights="40em">
21575 File:Foobar.jpg
21576 </gallery>
21577 !! html/php
21578 <ul class="gallery mw-gallery-traditional">
21579 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21580 <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>
21581 <div class="gallerytext">
21582 </div>
21583 </div></li>
21584 </ul>
21585
21586 !! html/parsoid
21587 <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"}}'>
21588 <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>
21589 </ul>
21590 !! end
21591
21592 !! test
21593 Gallery with link that has fragment
21594 !! options
21595 parsoid={
21596 "modes": ["wt2html", "html2html"],
21597 "nativeGallery": true
21598 }
21599 !! wikitext
21600 <gallery>
21601 image:foobar.jpg|link=Main_Page
21602 image:foobar.jpg|link=Main_Page#section
21603 image:foobar.jpg|link=Main Page#section|caption
21604 </gallery>
21605 !! html/php
21606 <ul class="gallery mw-gallery-traditional">
21607 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21608 <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>
21609 <div class="gallerytext">
21610 </div>
21611 </div></li>
21612 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21613 <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>
21614 <div class="gallerytext">
21615 </div>
21616 </div></li>
21617 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21618 <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>
21619 <div class="gallerytext">
21620 <p>caption
21621 </p>
21622 </div>
21623 </div></li>
21624 </ul>
21625
21626 !! html/parsoid
21627 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21628 <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>
21629 <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>
21630 <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>
21631 </ul>
21632 !! end
21633
21634 !! test
21635 Gallery with template inside caption
21636 !! options
21637 parsoid={
21638 "nativeGallery": true
21639 }
21640 !! wikitext
21641 <gallery caption="{{echo|hi}}">
21642 File:Foobar.jpg|{{echo|ho}}
21643 </gallery>
21644 !! html/php
21645 <ul class="gallery mw-gallery-traditional">
21646 <li class='gallerycaption'>hi</li>
21647 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21648 <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>
21649 <div class="gallerytext">
21650 <p>ho
21651 </p>
21652 </div>
21653 </div></li>
21654 </ul>
21655
21656 !! html/parsoid
21657 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt6" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21658 <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>
21659 <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>
21660 </ul>
21661 !! end
21662
21663 !! test
21664 Gallery with wikitext inside gallery caption
21665 !! wikitext
21666 <gallery caption="# List item
21667
21668 Text '''bold''' [[link]] {{ns:-1}}
21669
21670 [[File:Foobar.jpg|thumb|File in gallery caption]]">
21671 File:Foobar.jpg|Image caption
21672 </gallery>
21673 !! html/php
21674 <ul class="gallery mw-gallery-traditional">
21675 <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>
21676 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21677 <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>
21678 <div class="gallerytext">
21679 <p>Image caption
21680 </p>
21681 </div>
21682 </div></li>
21683 </ul>
21684
21685 !! end
21686
21687 !! test
21688 Gallery with wikitext inside caption
21689 !! options
21690 parsoid={
21691 "nativeGallery": true
21692 }
21693 !! wikitext
21694 <gallery>
21695 File:Foobar.jpg|alt=galleryalt|[[File:Foobar.jpg|alt=inneralt|20x20px|desc]]
21696 File:Foobar.jpg|alt=galleryalt|{{Test|unamedParam|alt=param}}
21697 </gallery>
21698 !! html/php
21699 <ul class="gallery mw-gallery-traditional">
21700 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21701 <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>
21702 <div class="gallerytext">
21703 <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>
21704 </p>
21705 </div>
21706 </div></li>
21707 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21708 <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>
21709 <div class="gallerytext">
21710 <p>This is a test template
21711 </p>
21712 </div>
21713 </div></li>
21714 </ul>
21715
21716 !! html/parsoid
21717 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt6" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21718 <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>
21719 <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>
21720 </ul>
21721 !! end
21722
21723 !! test
21724 Gallery (with showfilename option)
21725 !! options
21726 parsoid={
21727 "nativeGallery": true
21728 }
21729 !! wikitext
21730 <gallery showfilename="">
21731 File:Nonexistent.jpg|caption
21732 File:Nonexistent.jpg
21733 File:Foobar.jpg|some '''caption''' [[Main Page]]
21734 File:Foobar.jpg
21735 </gallery>
21736 !! html/php
21737 <ul class="gallery mw-gallery-traditional">
21738 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21739 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
21740 <div class="gallerytext">
21741 <p><a href="/wiki/File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">Nonexistent.jpg</a>
21742 caption
21743 </p>
21744 </div>
21745 </div></li>
21746 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21747 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
21748 <div class="gallerytext">
21749 <p><a href="/wiki/File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">Nonexistent.jpg</a>
21750 </p>
21751 </div>
21752 </div></li>
21753 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21754 <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>
21755 <div class="gallerytext">
21756 <p><a href="/wiki/File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">Foobar.jpg</a>
21757 some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
21758 </p>
21759 </div>
21760 </div></li>
21761 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21762 <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>
21763 <div class="gallerytext">
21764 <p><a href="/wiki/File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">Foobar.jpg</a>
21765 </p>
21766 </div>
21767 </div></li>
21768 </ul>
21769
21770 !! html/parsoid
21771 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{"showfilename":""},"body":{}}'>
21772 <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>
21773 <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>
21774 <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>
21775 <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>
21776 </ul>
21777 !! end
21778
21779 ## Should Parsoid be preserving these variations? See T151367
21780 !! test
21781 Gallery (with namespace-less filenames)
21782 !! options
21783 parsoid={
21784 "modes": ["wt2html", "html2html"],
21785 "nativeGallery": true
21786 }
21787 !! wikitext
21788 <gallery>
21789 File:Nonexistent.jpg
21790 Nonexistent.jpg
21791 image:foobar.jpg
21792 foobar.jpg
21793 </gallery>
21794 !! html/php
21795 <ul class="gallery mw-gallery-traditional">
21796 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21797 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
21798 <div class="gallerytext">
21799 </div>
21800 </div></li>
21801 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21802 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
21803 <div class="gallerytext">
21804 </div>
21805 </div></li>
21806 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21807 <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>
21808 <div class="gallerytext">
21809 </div>
21810 </div></li>
21811 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21812 <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>
21813 <div class="gallerytext">
21814 </div>
21815 </div></li>
21816 </ul>
21817
21818 !! html/parsoid
21819 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21820 <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>
21821 <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>
21822 <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>
21823 <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>
21824 </ul>
21825 !! end
21826
21827 !! test
21828 Gallery override link with wikilink (T36852)
21829 !! options
21830 parsoid={
21831 "nativeGallery": true
21832 }
21833 !! wikitext
21834 <gallery>
21835 File:Foobar.jpg|alt=galleryalt|link=Wikilink
21836 </gallery>
21837 !! html/php
21838 <ul class="gallery mw-gallery-traditional">
21839 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21840 <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>
21841 <div class="gallerytext">
21842 </div>
21843 </div></li>
21844 </ul>
21845
21846 !! html/parsoid
21847 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21848 <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>
21849 </ul>
21850 !! end
21851
21852 !! test
21853 Gallery override link with absolute external link (T36852)
21854 !! options
21855 parsoid={
21856 "nativeGallery": true
21857 }
21858 !! wikitext
21859 <gallery>
21860 File:Foobar.jpg|alt=galleryalt|link=http://www.example.org
21861 </gallery>
21862 !! html/php
21863 <ul class="gallery mw-gallery-traditional">
21864 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21865 <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>
21866 <div class="gallerytext">
21867 </div>
21868 </div></li>
21869 </ul>
21870
21871 !! html/parsoid
21872 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21873 <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>
21874 </ul>
21875 !! end
21876
21877 !! test
21878 Gallery override link with absolute external link with LanguageConverter
21879 !! options
21880 language=zh
21881 !! wikitext
21882 <gallery>
21883 File:foobar.jpg|caption|alt=galleryalt|link=http://www.example.org
21884 </gallery>
21885 !! html/php
21886 <ul class="gallery mw-gallery-traditional">
21887 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21888 <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>
21889 <div class="gallerytext">
21890 <p>caption
21891 </p>
21892 </div>
21893 </div></li>
21894 </ul>
21895
21896 !! html/parsoid
21897 <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"}}'>
21898 <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>
21899 </ul>
21900 !! end
21901
21902 !! test
21903 Gallery override link with malicious javascript (T36852)
21904 !! options
21905 parsoid={
21906 "modes": ["wt2html", "html2html"],
21907 "nativeGallery": true
21908 }
21909 !! wikitext
21910 <gallery>
21911 File:Foobar.jpg|alt=galleryalt|link=" onclick="alert('malicious javascript code!');
21912 </gallery>
21913 !! html/php
21914 <ul class="gallery mw-gallery-traditional">
21915 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21916 <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>
21917 <div class="gallerytext">
21918 </div>
21919 </div></li>
21920 </ul>
21921
21922 !! html/parsoid
21923 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21924 <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>
21925 </ul>
21926 !! end
21927
21928 # Note that parsoid uses the invalid link as a caption, PHP does not.
21929 !! test
21930 Gallery with invalid title as link (T45964)
21931 !! options
21932 parsoid={
21933 "modes": ["wt2html", "html2html"],
21934 "nativeGallery": true
21935 }
21936 !! wikitext
21937 <gallery>
21938 File:Foobar.jpg|link=<
21939 </gallery>
21940 !! html/php
21941 <ul class="gallery mw-gallery-traditional">
21942 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21943 <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>
21944 <div class="gallerytext">
21945 </div>
21946 </div></li>
21947 </ul>
21948
21949 !! html/parsoid
21950 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21951 <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>
21952 </ul>
21953 !! end
21954
21955 !! test
21956 Serialize gallery without attrs in data-mw
21957 !! options
21958 parsoid={
21959 "modes": ["html2wt"],
21960 "nativeGallery": true
21961 }
21962 !! html/parsoid
21963 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","body":{}}'>
21964 <li class="gallerycaption">123</li>
21965 <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>
21966 </ul>
21967 !! wikitext
21968 <gallery caption="123">
21969 File:Test.png
21970 </gallery>
21971 !! end
21972
21973 !! test
21974 Gallery with class and style attributes
21975 !! options
21976 parsoid={
21977 "nativeGallery": true
21978 }
21979 !! wikitext
21980 <gallery class="center" style="text-align: center;">
21981 File:Foobar.jpg
21982 </gallery>
21983 !! html/php
21984 <ul class="gallery mw-gallery-traditional center" style="text-align: center;">
21985 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21986 <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>
21987 <div class="gallerytext">
21988 </div>
21989 </div></li>
21990 </ul>
21991
21992 !! html/parsoid
21993 <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":{}}'>
21994 <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>
21995 </ul>
21996 !! end
21997
21998 !! test
21999 Gallery in slideshow mode
22000 !! options
22001 parsoid={
22002 "nativeGallery": true
22003 }
22004 !! wikitext
22005 <gallery mode="slideshow" showthumbnails="">
22006 File:Foobar.jpg
22007 </gallery>
22008 !! html/php
22009 <ul class="gallery mw-gallery-slideshow" data-showthumbnails="1">
22010 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
22011 <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>
22012 <div class="gallerytext">
22013 </div>
22014 </div></li>
22015 </ul>
22016
22017 !! html/parsoid
22018 <ul class="gallery mw-gallery-slideshow" data-showthumbnails="1" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{"mode":"slideshow","showthumbnails":""},"body":{}}'>
22019 <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>
22020 </ul>
22021 !! end
22022
22023 !! test
22024 Serialize gallery image captions on a line
22025 !! options
22026 parsoid={
22027 "modes": ["html2wt"],
22028 "nativeGallery": true
22029 }
22030 !! html/parsoid
22031 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
22032 <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>
22033 <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>
22034 </ul>
22035 !! wikitext
22036 <gallery>
22037 File:Foobar.jpg| hi ho
22038 File:Foobar.jpg|hi<br />ho
22039 </gallery>
22040 !! end
22041
22042 !! test
22043 HTML Hex character encoding (spells the word "JavaScript")
22044 !! options
22045 parsoid=wt2html,wt2wt,html2html
22046 !! wikitext
22047 &#x4A;&#x061;&#x0076;&#x00061;&#x000053;&#x0000063;&#114;&#x0000069;&#00000112;&#x0000000074;
22048 !! html/php
22049 <p>&#x4a;&#x61;&#x76;&#x61;&#x53;&#x63;&#114;&#x69;&#112;&#x74;
22050 </p>
22051 !! html/parsoid
22052 <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>
22053 !! end
22054
22055 !! test
22056 HTML Hex character encoding bogus encoding (T28437 regression check)
22057 !! wikitext
22058 &#xsee;&#XSEE;
22059 !! html
22060 <p>&amp;#xsee;&amp;#XSEE;
22061 </p>
22062 !! end
22063
22064 !! test
22065 HTML Hex character encoding mixed case
22066 !! options
22067 parsoid=wt2html,wt2wt,html2html
22068 !! wikitext
22069 &#xEE;&#Xee;
22070 !! html/php
22071 <p>&#xee;&#xee;
22072 </p>
22073 !! html/parsoid
22074 <p><span typeof="mw:Entity">î</span><span typeof="mw:Entity">î</span></p>
22075 !! end
22076
22077 # See: https://www.w3.org/TR/html5/syntax.html#character-references
22078 # Note that U+000C (form feed) is not a valid XML character, so
22079 # it is banned even though allowed in HTML5.
22080 !! test
22081 Illegal character references (T106578)
22082 !! wikitext
22083 ; Null: &#00;
22084 ; FF: &#xC;
22085 ; CR: &#xD;
22086 ; Control (low): &#8;
22087 ; Control (high): &#x7F; &#x9F;
22088 ; Surrogate: &#xD83D;&#xDCA9;
22089 ; This is an okay astral character: &#x1F4A9;
22090 !! html+tidy
22091 <dl><dt>Null</dt>
22092 <dd>&amp;#00;</dd>
22093 <dt>FF</dt>
22094 <dd>&amp;#xC;</dd>
22095 <dt>CR</dt>
22096 <dd>&amp;#xD;</dd>
22097 <dt>Control (low)</dt>
22098 <dd>&amp;#8;</dd>
22099 <dt>Control (high)</dt>
22100 <dd>&amp;#x7F; &amp;#x9F;</dd>
22101 <dt>Surrogate</dt>
22102 <dd>&amp;#xD83D;&amp;#xDCA9;</dd>
22103 <dt>This is an okay astral character</dt>
22104 <dd>&#x1f4a9;</dd></dl>
22105 !! end
22106
22107 !! test
22108 __FORCETOC__ override
22109 !! wikitext
22110 __NEWSECTIONLINK__
22111 __FORCETOC__
22112 !! html/php
22113 <p><br />
22114 </p>
22115 !! end
22116
22117 !! test
22118 ISBN code coverage
22119 !! wikitext
22120 ISBN 978-0-1234-56&#x20;789
22121 !! html/php
22122 <p><a href="/wiki/Special:BookSources/9780123456" class="internal mw-magiclink-isbn">ISBN 978-0-1234-56</a>&#x20;789
22123 </p>
22124 !! html/parsoid
22125 <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>
22126 !! end
22127
22128 !! test
22129 ISBN followed by 5 spaces
22130 !! wikitext
22131 ISBN
22132 !! html
22133 <p>ISBN
22134 </p>
22135 !! end
22136
22137 !! test
22138 Double ISBN
22139 !! wikitext
22140 ISBN ISBN 1234567890
22141 !! html/php
22142 <p>ISBN <a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
22143 </p>
22144 !! html/parsoid
22145 <p>ISBN <a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a></p>
22146 !! end
22147
22148 # Uppercase X and lowercase x as well
22149 !! test
22150 ISBN with an X
22151 !! wikitext
22152 ISBN 3-462-04561-X
22153 ISBN 3-462-04561-x
22154 ISBN 080442957X
22155 ISBN 080442957x
22156 ISBN 978080442957X
22157 ISBN 978080442957x
22158 !! html/php
22159 <p><a href="/wiki/Special:BookSources/346204561X" class="internal mw-magiclink-isbn">ISBN 3-462-04561-X</a>
22160 <a href="/wiki/Special:BookSources/346204561X" class="internal mw-magiclink-isbn">ISBN 3-462-04561-x</a>
22161 <a href="/wiki/Special:BookSources/080442957X" class="internal mw-magiclink-isbn">ISBN 080442957X</a>
22162 <a href="/wiki/Special:BookSources/080442957X" class="internal mw-magiclink-isbn">ISBN 080442957x</a>
22163 <a href="/wiki/Special:BookSources/978080442957X" class="internal mw-magiclink-isbn">ISBN 978080442957X</a>
22164 <a href="/wiki/Special:BookSources/978080442957X" class="internal mw-magiclink-isbn">ISBN 978080442957x</a>
22165 </p>
22166 !! html/parsoid
22167 <p><a href="./Special:BookSources/346204561X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 3-462-04561-X</a>
22168 <a href="./Special:BookSources/346204561X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 3-462-04561-x</a>
22169 <a href="./Special:BookSources/080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 080442957X</a>
22170 <a href="./Special:BookSources/080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 080442957x</a>
22171 <a href="./Special:BookSources/978080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978080442957X</a>
22172 <a href="./Special:BookSources/978080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978080442957x</a></p>
22173 !! end
22174
22175 !! test
22176 ISBN with empty prefix (parsoid test)
22177 !! wikitext
22178 ISBN 1234567890
22179 !! html/php
22180 <p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
22181 </p>
22182 !! html/parsoid
22183 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink">ISBN 1234567890</a></p>
22184 !! end
22185
22186 !! test
22187 T24905: <abbr> followed by ISBN followed by </a>
22188 !! wikitext
22189 <abbr>(fr)</abbr> ISBN 2753300917 [http://www.example.com example.com]
22190 !! html/php
22191 <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>
22192 </p>
22193 !! html/parsoid
22194 <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>
22195 !! end
22196
22197 !! test
22198 Double RFC
22199 !! wikitext
22200 RFC RFC 1234
22201 !! html/php
22202 <p>RFC <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc1234">RFC 1234</a>
22203 </p>
22204 !! html/parsoid
22205 <p>RFC <a href="https://tools.ietf.org/html/rfc1234" rel="mw:ExtLink" class="external mw-magiclink">RFC 1234</a></p>
22206 !! end
22207
22208 !! test
22209 Double RFC with a wiki link
22210 !! wikitext
22211 RFC [[RFC 1234]]
22212 !! html/php
22213 <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>
22214 </p>
22215 !! html/parsoid
22216 <p>RFC <a rel="mw:WikiLink" href="./RFC_1234" title="RFC 1234">RFC 1234</a></p>
22217 !! end
22218
22219 !! test
22220 RFC code coverage
22221 !! wikitext
22222 RFC 983&#x20;987
22223 !! html/php
22224 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc983">RFC 983</a>&#x20;987
22225 </p>
22226 !! html/parsoid
22227 <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>
22228 !! end
22229
22230 !! test
22231 Centre-aligned image
22232 !! wikitext
22233 [[Image:foobar.jpg|centre]]
22234 !! html/php
22235 <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>
22236
22237 !! html/parsoid
22238 <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>
22239 !! end
22240
22241 !! test
22242 None-aligned image
22243 !! wikitext
22244 [[Image:foobar.jpg|none]]
22245 !! html/php
22246 <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>
22247
22248 !! html/parsoid
22249 <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>
22250 !! end
22251
22252 !! test
22253 Width + Height sized image (using px) (height is ignored)
22254 !! wikitext
22255 [[Image:foobar.jpg|640x480px]]
22256 !! html/php
22257 <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>
22258 </p>
22259 !! html/parsoid
22260 <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>
22261 !! end
22262
22263 !! test
22264 Width-sized image (using px, no following whitespace)
22265 !! wikitext
22266 [[Image:foobar.jpg|640px]]
22267 !! html/php
22268 <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>
22269 </p>
22270 !! html/parsoid
22271 <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>
22272 !! end
22273
22274 !! test
22275 Width-sized image (using px, with following whitespace - test regression from r39467)
22276 !! wikitext
22277 [[Image:foobar.jpg|640px ]]
22278 !! html/php
22279 <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>
22280 </p>
22281 !! html/parsoid
22282 <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>
22283 !!end
22284
22285 !! test
22286 Width-sized image (using px, with preceding whitespace - test regression from r39467)
22287 !! wikitext
22288 [[Image:foobar.jpg| 640px]]
22289 !! html/php
22290 <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>
22291 </p>
22292 !! html/parsoid
22293 <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>
22294 !! end
22295
22296 !! test
22297 Image with page parameter
22298 !! options
22299 djvu
22300 !! wikitext
22301 [[File:LoremIpsum.djvu|page=2]]
22302 !! html/php
22303 <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>
22304 </p>
22305 !! html/parsoid
22306 <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>
22307 !! end
22308
22309 !! test
22310 Another italics / bold test
22311 !! wikitext
22312 ''' ''x'
22313 !! html
22314 <pre>'<i> </i>x'
22315 </pre>
22316 !!end
22317
22318 # FIXME: The php output seems broken. It's interleaving some open/close tags.
22319 !! test
22320 dt/dd/dl test
22321 !! wikitext
22322 :;;;::
22323 !! html/php
22324 <dl><dd><dl><dt><dl><dt><dl><dt><dl><dd><dl><dd></dt></dl></dd></dl></dd></dl></dd></dl></dd></dl></dd></dl>
22325
22326 !! html/parsoid
22327 <dl><dd><dl><dt><dl><dt><dl><dt><dl><dd><dl><dd></dd></dl></dd></dl></dt></dl></dt></dl></dt></dl></dd></dl>
22328
22329 !!end
22330
22331 # Images with the "|" character in external URLs in comment tags; Eats half the comment, leaves unmatched "</a>" tag.
22332 !! test
22333 Images with the "|" character in the comment
22334 !! wikitext
22335 [[File:Foobar.jpg|thumb|An [http://test/?param1=|left|&param2=|x external] URL]]
22336 !! html/php
22337 <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>
22338
22339 !! html/parsoid
22340 <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>
22341 !! end
22342
22343 !! test
22344 [Before] HTML without raw HTML enabled ($wgRawHtml==false)
22345 !! wikitext
22346 <html><script>alert(1);</script></html>
22347 !! html
22348 <p>&lt;html&gt;&lt;script&gt;alert(1);&lt;/script&gt;&lt;/html&gt;
22349 </p>
22350 !! end
22351
22352 !! test
22353 HTML with raw HTML ($wgRawHtml==true)
22354 !! options
22355 wgRawHtml=1
22356 !! wikitext
22357 <html><script>alert(1);</script></html>
22358 !! html/php
22359 <p><script>alert(1);</script>
22360 </p>
22361 !! html/parsoid
22362 <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>
22363 !! end
22364
22365 !! test
22366 Parents of subpages, one level up
22367 !! options
22368 subpage title=[[Subpage test/L1/L2/L3]]
22369 !! wikitext
22370 [[../|L2]]
22371 !! html
22372 <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>
22373 </p>
22374 !! end
22375
22376
22377 !! test
22378 Parents of subpages, one level up, not named
22379 !! options
22380 subpage title=[[Subpage test/L1/L2/L3]]
22381 !! wikitext
22382 [[../]]
22383 !! html
22384 <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>
22385 </p>
22386 !! end
22387
22388
22389
22390 !! test
22391 Parents of subpages, two levels up
22392 !! options
22393 subpage title=[[Subpage test/L1/L2/L3]]
22394 !! wikitext
22395 [[../../|L1]]2
22396
22397 [[../../|L1]]l
22398 !! html
22399 <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
22400 </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>
22401 </p>
22402 !! end
22403
22404 !! test
22405 Parents of subpages, two levels up, without trailing slash or name.
22406 !! options
22407 subpage title=[[Subpage test/L1/L2/L3]]
22408 !! wikitext
22409 [[../..]]
22410 !! html
22411 <p>[[../..]]
22412 </p>
22413 !! end
22414
22415 !! test
22416 Parents of subpages, two levels up, with lots of extra trailing slashes.
22417 !! options
22418 subpage title=[[Subpage test/L1/L2/L3]]
22419 !! wikitext
22420 [[../../////]]
22421 !! html
22422 <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>
22423 </p>
22424 !! end
22425
22426 !! article
22427 Subpage test/L1/L2/L3Sibling
22428 !! text
22429 Sibling article
22430 !! endarticle
22431
22432 !! test
22433 Transclusion of a sibling page (one level up)
22434 !! options
22435 subpage title=[[Subpage test/L1/L2/L3]]
22436 !! wikitext
22437 {{../L3Sibling}}
22438 !! html
22439 <p>Sibling article
22440 </p>
22441 !! end
22442
22443 !! test
22444 Transclusion of a child page
22445 !! options
22446 subpage title=[[Subpage test/L1/L2]]
22447 !! wikitext
22448 {{/L3Sibling}}
22449 !! html
22450 <p>Sibling article
22451 </p>
22452 !! end
22453
22454 # This is wt2html only in Parsoid because we add <nowiki>
22455 # because of {{..}} and we don't expect to fix that to
22456 # eliminate the nowikis selective for {{..}} markup.
22457 !! test
22458 Non-transclusion because of too many up levels
22459 !! options
22460 subpage title=[[Subpage test/L1/L2/L3]]
22461 parsoid=wt2html
22462 !! wikitext
22463 {{../../../../More than parent}}
22464 !! html/php
22465 <p>{{../../../../More than parent}}
22466 </p>
22467 !! html/parsoid
22468 <p>{{../../../../More than parent}}</p>
22469 !! end
22470
22471 !! test
22472 Definition list code coverage
22473 !! wikitext
22474 ;title :def
22475 ;title :def
22476 ;title:def
22477 !! html/php
22478 <dl><dt>title</dt>
22479 <dd>def</dd>
22480 <dt>title</dt>
22481 <dd>def</dd>
22482 <dt>title</dt>
22483 <dd>def</dd></dl>
22484
22485 !! html/parsoid
22486 <dl><dt>title </dt><dd>def</dd>
22487 <dt>title </dt><dd>def</dd>
22488 <dt>title</dt><dd>def</dd></dl>
22489 !! end
22490
22491 !! test
22492 Don't fall for the self-closing div
22493 !! wikitext
22494 <div>hello world</div/>
22495 !! html
22496 <div>hello world</div>
22497
22498 !! end
22499
22500 !! test
22501 MSGNW magic word
22502 !! wikitext
22503 {{MSGNW:msg}}
22504 !! html/php
22505 <p>&#91;&#91;:Template:Msg&#93;&#93;
22506 </p>
22507 !! end
22508
22509 !! test
22510 RAW magic word
22511 !! wikitext
22512 {{RAW:QUERTY}}
22513 !! html
22514 <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>
22515 </p>
22516 !! end
22517
22518 # This isn't needed for XHTML conformance, but would be handy as a fallback security measure
22519 !! test
22520 Always escape literal '>' in output, not just after '<'
22521 !! wikitext
22522 ><>
22523 !! html
22524 <p>&gt;&lt;&gt;
22525 </p>
22526 !! end
22527
22528 !! test
22529 Template caching
22530 !! wikitext
22531 {{Test}}
22532 {{Test}}
22533 !! html
22534 <p>This is a test template
22535 This is a test template
22536 </p>
22537 !! end
22538
22539
22540 !! article
22541 MediaWiki:Fake
22542 !! text
22543 ==header==
22544 !! endarticle
22545
22546 !! test
22547 Inclusion of !userCanEdit() content
22548 !! wikitext
22549 {{MediaWiki:Fake}}
22550 !! html
22551 <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>
22552
22553 !! end
22554
22555
22556 !! test
22557 Out-of-order TOC heading levels
22558 !! wikitext
22559 ==2==
22560 ======6======
22561 ===3===
22562 =1=
22563 =====5=====
22564 ==2==
22565 !! html
22566 <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>
22567 <ul>
22568 <li class="toclevel-1 tocsection-1"><a href="#2"><span class="tocnumber">1</span> <span class="toctext">2</span></a>
22569 <ul>
22570 <li class="toclevel-2 tocsection-2"><a href="#6"><span class="tocnumber">1.1</span> <span class="toctext">6</span></a></li>
22571 <li class="toclevel-2 tocsection-3"><a href="#3"><span class="tocnumber">1.2</span> <span class="toctext">3</span></a></li>
22572 </ul>
22573 </li>
22574 <li class="toclevel-1 tocsection-4"><a href="#1"><span class="tocnumber">2</span> <span class="toctext">1</span></a>
22575 <ul>
22576 <li class="toclevel-2 tocsection-5"><a href="#5"><span class="tocnumber">2.1</span> <span class="toctext">5</span></a></li>
22577 <li class="toclevel-2 tocsection-6"><a href="#2_2"><span class="tocnumber">2.2</span> <span class="toctext">2</span></a></li>
22578 </ul>
22579 </li>
22580 </ul>
22581 </div>
22582
22583 <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>
22584 <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>
22585 <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>
22586 <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>
22587 <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>
22588 <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>
22589
22590 !! end
22591
22592
22593 !! test
22594 ISBN with a dummy number
22595 !! wikitext
22596 ISBN ---
22597 !! html
22598 <p>ISBN ---
22599 </p>
22600 !! end
22601
22602
22603 !! test
22604 ISBN with space-delimited number
22605 !! wikitext
22606 ISBN 92 9017 032 8
22607 !! html/php
22608 <p><a href="/wiki/Special:BookSources/9290170328" class="internal mw-magiclink-isbn">ISBN 92 9017 032 8</a>
22609 </p>
22610 !! html/parsoid
22611 <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>
22612 !! end
22613
22614
22615 !! test
22616 ISBN with multiple spaces, no number
22617 !! wikitext
22618 ISBN foo
22619 !! html
22620 <p>ISBN foo
22621 </p>
22622 !! end
22623
22624
22625 !! test
22626 ISBN length
22627 !! wikitext
22628 ISBN 123456789
22629
22630 ISBN 1234567890
22631
22632 ISBN 12345678901
22633 !! html/php
22634 <p>ISBN 123456789
22635 </p><p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
22636 </p><p>ISBN 12345678901
22637 </p>
22638 !! html/parsoid
22639 <p>ISBN 123456789</p>
22640
22641 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a></p>
22642
22643 <p>ISBN 12345678901</p>
22644 !! end
22645
22646
22647 !! test
22648 ISBN with trailing year (T9110)
22649 !! wikitext
22650 ISBN 1-234-56789-0 - 2006
22651
22652 ISBN 1 234 56789 0 - 2006
22653 !! html/php
22654 <p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1-234-56789-0</a> - 2006
22655 </p><p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1 234 56789 0</a> - 2006
22656 </p>
22657 !! html/parsoid
22658 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1-234-56789-0</a> - 2006</p>
22659
22660 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1 234 56789 0</a> - 2006</p>
22661 !! end
22662
22663
22664 !! test
22665 anchorencode
22666 !! config
22667 wgFragmentMode=[ 'html5', 'legacy' ]
22668 !! wikitext
22669 {{anchorencode:foo bar©#%n}}
22670 !! html/php
22671 <p>foo_bar©#%n
22672 </p>
22673 !! html/parsoid
22674 <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>
22675 !! end
22676
22677 !! test
22678 anchorencode (legacy)
22679 !! config
22680 wgFragmentMode=[ 'legacy' ]
22681 !! wikitext
22682 {{anchorencode:foo bar©#%n}}
22683 !! html/php
22684 <p>foo_bar.C2.A9.23.25n
22685 </p>
22686 !! end
22687
22688 !! test
22689 anchorencode trims spaces
22690 !! config
22691 wgFragmentMode=[ 'html5', 'legacy' ]
22692 !! wikitext
22693 {{anchorencode: __pretty__please__}}
22694 !! html/php
22695 <p>pretty_please
22696 </p>
22697 !! html/parsoid
22698 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: __pretty__please__","function":"anchorencode"},"params":{},"i":0}}]}'>pretty_please</p>
22699 !! end
22700
22701 !! test
22702 anchorencode deals with links
22703 !! config
22704 wgFragmentMode=[ 'html5', 'legacy' ]
22705 !! wikitext
22706 {{anchorencode: [[hello|world]] [[hi]]}}
22707 !! html/php
22708 <p>world_hi
22709 </p>
22710 !! html/parsoid
22711 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: [[hello|world]] [[hi]]","function":"anchorencode"},"params":{},"i":0}}]}'>world_hi</p>
22712 !! end
22713
22714 !! test
22715 anchorencode deals with templates
22716 !! config
22717 wgFragmentMode=[ 'html5', 'legacy' ]
22718 !! wikitext
22719 {{anchorencode: {{Foo}} x}}
22720 !! html/php
22721 <p>FOO_x
22722 </p>
22723 !! html/parsoid
22724 <p about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: {{Foo}} x","function":"anchorencode"},"params":{},"i":0}}]}'>FOO_x</p>
22725 !! end
22726
22727 !! test
22728 anchorencode encodes like the TOC generator: (T20431)
22729 !! config
22730 wgFragmentMode=[ 'html5', 'legacy' ]
22731 !! wikitext
22732 ===_ +:.3A%3A _ &&amp;]] x===
22733 {{anchorencode: _ +:.3A%3A _ &&amp;]] x}}
22734 __NOEDITSECTION__
22735 !! html/php
22736 <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>
22737 <p>+:.3A%3A_&amp;&amp;&#93;&#93;_x
22738 </p>
22739 !! html/parsoid
22740 <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>
22741 <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>
22742 <meta property="mw:PageProp/noeditsection"/>
22743 !! end
22744
22745 !! test
22746 anchorencode encodes like the TOC generator: (T20431) (legacy)
22747 !! config
22748 wgFragmentMode=[ 'legacy' ]
22749 !! wikitext
22750 ===_ +:.3A%3A&&amp;]]===
22751 {{anchorencode: _ +:.3A%3A&&amp;]] }}
22752 __NOEDITSECTION__
22753 !! html/php
22754 <h3><span class="mw-headline" id=".2B:.3A.253A.26.26.5D.5D">_ +:.3A%3A&amp;&amp;]]</span></h3>
22755 <p>.2B:.3A.253A.26.26.5D.5D
22756 </p>
22757 !! end
22758
22759 !! test
22760 T8200: blockquotes and paragraph formatting
22761 !! wikitext
22762 <blockquote>
22763 foo
22764 </blockquote>
22765
22766 bar
22767
22768 baz
22769 !! html
22770 <blockquote>
22771 <p>foo
22772 </p>
22773 </blockquote>
22774 <p>bar
22775 </p>
22776 <pre>baz
22777 </pre>
22778 !! end
22779
22780 !! test
22781 T10293: Use of center tag ruins paragraph formatting
22782 !! wikitext
22783 <center>
22784 foo
22785 </center>
22786
22787 bar
22788
22789 baz
22790 !! html
22791 <center>
22792 <p>foo
22793 </p>
22794 </center>
22795 <p>bar
22796 </p>
22797 <pre>baz
22798 </pre>
22799 !! end
22800
22801 !!test
22802 Parsing of overlapping (improperly nested) inline html tags
22803 !! wikitext
22804 <span><s>x</span></s>
22805 !! html/php
22806 <p><span><s>x&lt;/span&gt;</s></span>
22807 </p>
22808 !! html/parsoid
22809 <p><span><s>x</s></span>
22810 </p>
22811 !!end
22812
22813 ###
22814 ### Language variants related tests
22815 ###
22816
22817 # Parsoid does not mark self-links.
22818 # Parsoid does not convert links; PHP will do any necessary redirects.
22819
22820 !! test
22821 Self-link in language variants
22822 !! options
22823 title=[[Dunav]] language=sr
22824 !! wikitext
22825 Both [[Dunav]] and [[Дунав]] are names for this river.
22826 !! html/php
22827 <p>Both <a class="mw-selflink selflink">Dunav</a> and <a class="mw-selflink selflink">Дунав</a> are names for this river.
22828 </p>
22829 !! html/parsoid
22830 <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>
22831 !! end
22832
22833 !! article
22834 Дуна
22835 !! text
22836 content
22837 !! endarticle
22838
22839 !! test
22840 Link to another existing title shouldn't be parsed as self-link even if it's a variant of this title
22841 !! options
22842 title=[[Duna]] language=sr
22843 !! wikitext
22844 [[Дуна]] is not a self-link while [[Duna]] and [[Dуна]] are still self-links.
22845 !! html/php
22846 <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.
22847 </p>
22848 !! html/parsoid
22849 <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>
22850 !! end
22851
22852 !! test
22853 Link to a section of a variant of this title shouldn't be parsed as self-link
22854 !! options
22855 title=[[Duna]] language=sr
22856 !! wikitext
22857 [[Dуна]] is a self-link while [[Dunа#Foo]] and [[Dуна#Foo]] are not self-links.
22858 !! html/php
22859 <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.
22860 </p>
22861 !! html/parsoid
22862 <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>
22863 !! end
22864
22865 !! test
22866 Link to pages in language variants
22867 !! options
22868 language=sr
22869 !! wikitext
22870 Main Page can be written as [[Маин Паге]]
22871 !! html/php
22872 <p>Main Page can be written as <a href="/wiki/Main_Page" title="Main Page">Маин Паге</a>
22873 </p>
22874 !! html/parsoid
22875 <p>Main Page can be written as <a rel="mw:WikiLink" href="./Маин_Паге" title="Маин Паге">Маин Паге</a></p>
22876 !! end
22877
22878
22879 !! test
22880 Multiple links to pages in language variants
22881 !! options
22882 language=sr
22883 !! wikitext
22884 [[Main Page]] can be written as [[Маин Паге]] same as [[Маин Паге]].
22885 !! html/php
22886 <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>.
22887 </p>
22888 !! html/parsoid
22889 <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>
22890 !! end
22891
22892
22893 !! test
22894 Simple template in language variants
22895 !! options
22896 language=sr
22897 !! wikitext
22898 {{тест}}
22899 !! html/php
22900 <p>This is a test template
22901 </p>
22902 !! end
22903
22904
22905 !! test
22906 Template with explicit namespace in language variants
22907 !! options
22908 language=sr
22909 !! wikitext
22910 {{Template:тест}}
22911 !! html/php
22912 <p>This is a test template
22913 </p>
22914 !! end
22915
22916
22917 !! test
22918 Basic test for template parameter in language variants
22919 !! options
22920 language=sr
22921 !! wikitext
22922 {{парамтест|param=foo}}
22923 !! html/php
22924 <p>This is a test template with parameter foo
22925 </p>
22926 !! end
22927
22928 !! test
22929 Simple category in language variants
22930 !! options
22931 language=sr cat
22932 !! wikitext
22933 [[Category:МедиаWики Усер'с Гуиде]]
22934 !! html/php
22935 cat=МедиаWики_Усер'с_Гуиде sort=
22936 !! html/parsoid
22937 <link rel="mw:PageProp/Category" href="./Категорија:МедиаWики_Усер'с_Гуиде" data-parsoid='{"stx":"simple","a":{"href":"./Категорија:МедиаWики_Усер&#39;с_Гуиде"},"sa":{"href":"Category:МедиаWики Усер&#39;с Гуиде"}}'/>
22938 !! end
22939
22940 !! article
22941 Category:分类
22942 !! text
22943 blah
22944 !! endarticle
22945
22946 !! article
22947 Category:分類
22948 !! text
22949 blah
22950 !! endarticle
22951
22952 ## We used to, but no longer wt2wt this test since the default serializer
22953 ## will normalize all categories to serialize on their own line.
22954 ## This wikitext usage is going to be fairly uncommon in production and
22955 ## selser will take care of preserving formatting in those scenarios.
22956 !! test
22957 Don't convert blue categorylinks to another variant (T35210)
22958 !! options
22959 cat
22960 language=zh
22961 parsoid=wt2html
22962 !! wikitext
22963 [[A]][[Category:分类]]
22964 !! html/php
22965 cat=分类 sort=
22966 !! html/parsoid
22967 <p><a rel="mw:WikiLink" href="./A" title="A">A</a></p>
22968 <link rel="mw:PageProp/Category" href="./Category:分类"/>
22969 !! end
22970
22971 !! test
22972 Stripping -{}- tags (language variants)
22973 !! options
22974 language=sr
22975 !! wikitext
22976 Latin proverb: -{Ne nuntium necare}-
22977 !! html/php
22978 <p>Latin proverb: Ne nuntium necare
22979 </p>
22980 !! html/parsoid
22981 <p>Latin proverb: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
22982 !! end
22983
22984
22985 !! test
22986 Prevent conversion with -{}- tags (language variants)
22987 !! options
22988 language=sr variant=sr-ec
22989 !! wikitext
22990 Latinski: -{Ne nuntium necare}-
22991 !! html/php
22992 <p>Латински: Ne nuntium necare
22993 </p>
22994 !! html/parsoid
22995 <p>Latinski: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
22996 !! end
22997
22998
22999 !! test
23000 Prevent conversion of text with -{}- tags (language variants)
23001 !! options
23002 language=sr variant=sr-ec
23003 !! wikitext
23004 Latinski: -{Ne nuntium necare}-
23005 !! html/php
23006 <p>Латински: Ne nuntium necare
23007 </p>
23008 !! html/parsoid
23009 <p>Latinski: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
23010 !! end
23011
23012
23013 !! test
23014 Prevent conversion of links with -{}- tags (language variants)
23015 !! options
23016 language=sr variant=sr-ec
23017 !! wikitext
23018 -{[[Main Page]]}-
23019 !! html/php
23020 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
23021 </p>
23022 !! html/parsoid
23023 <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>
23024 !! end
23025
23026
23027 !! test
23028 -{}- tags within headlines (within html for parserConvert())
23029 !! config
23030 wgFragmentMode=[ 'html5', 'legacy' ]
23031 !! options
23032 language=sr variant=sr-ec
23033 !! wikitext
23034 ==-{Naslov}-==
23035
23036 Note that even an unprotected headline ID is not affected by language
23037 conversion:
23038
23039 ==Latinski==
23040 !! html/php
23041 <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>
23042 <p>Ноте тхат евен ан унпротецтед хеадлине ИД ис нот аффецтед бy лангуаге
23043 цонверсион:
23044 </p>
23045 <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>
23046
23047 !! html/parsoid
23048 <h2 id="-{Naslov}-"><span id="-.7BNaslov.7D-" typeof="mw:FallbackId"></span><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Naslov"}}'></span></h2>
23049
23050 <p>Note that even an unprotected headline ID is not affected by language
23051 conversion:</p>
23052
23053 <h2 id="Latinski">Latinski</h2>
23054 !! end
23055
23056 !! test
23057 Explicit definition of language variant alternatives
23058 !! options
23059 language=zh variant=zh-tw
23060 !! wikitext
23061 -{zh:China;zh-tw:Taiwan}-, not China
23062 !! html/php
23063 <p>Taiwan, not China
23064 </p>
23065 !! html/parsoid
23066 <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>
23067 !! end
23068
23069 !! test
23070 Explicit definition of language variant alternatives (BCP 47 codes)
23071 !! options
23072 language=zh variant=zh-tw
23073 !! wikitext
23074 -{zh:China;zh-Hant-TW:Taiwan}-, not China
23075 !! html/php
23076 <p>Taiwan, not China
23077 </p>
23078 !! html/parsoid
23079 <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>
23080 !! end
23081
23082 !! test
23083 Filter syntax for language variants
23084 !! options
23085 language=zh variant=zh-tw
23086 !! wikitext
23087 foo-{zh;zh-hans;zh-hant|blog, WEBJOURNAL, WEBLOG}-quux
23088 !! html/php
23089 <p>fooblog, WEBJOURNAL, WEBLOGquux
23090 </p>
23091 !! html/parsoid
23092 <p>foo<span typeof="mw:LanguageVariant" data-mw-variant='{"filter":{"l":["zh","zh-hans","zh-hant"],"t":"blog, WEBJOURNAL, WEBLOG"}}'></span>quux</p>
23093 !! end
23094
23095 # Note that Parsoid post-processing for language variants needs to
23096 # update the `title` attribute here, based on the mw:ExpandedAttrs property
23097 !! test
23098 Conversion around HTML tags
23099 !! options
23100 language=sr variant=sr-ec
23101 !! wikitext
23102 -{H|span=>sr-ec:script;title=>sr-ec:src}-
23103 <span title="La-{sr-el:L;sr-ec:C}-tin">ski</span>
23104 !! html/php
23105 <p>
23106 <span title="ЛаCтин">ски</span>
23107 </p>
23108 !! html/parsoid
23109 <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"}]}'/>
23110 <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>
23111 !! end
23112
23113 !! test
23114 Explicit session-wise two-way language variant mapping (A flag and - flag)
23115 !! options
23116 language=zh variant=zh-tw
23117 !! wikitext
23118 This is -{zh:China; zh-tw:Taiwan}-, but we'll forget that now.
23119
23120 Taiwan is not China.
23121
23122 But -{A|zh:China; zh-tw:Taiwan}- is China,
23123
23124 (This-{-|zh:China; zh-tw:Taiwan}- should be stripped!)
23125
23126 and -{China}- is China.
23127 !! html/php
23128 <p>This is Taiwan, but we'll forget that now.
23129 </p><p>Taiwan is not China.
23130 </p><p>But Taiwan is Taiwan,
23131 </p><p>(This should be stripped!)
23132 </p><p>and China is China.
23133 </p>
23134 !! html/parsoid
23135 <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>
23136 <p>Taiwan is not China.</p>
23137 <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>
23138 <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>
23139 <p>and <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"China"}}'></span> is China.</p>
23140 !! end
23141
23142 !! test
23143 Explicit session-wise one-way language variant mapping (A flag and - flag)
23144 !! options
23145 language=zh variant=zh-tw
23146 !! wikitext
23147 This is -{COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}-, but we'll forget that now.
23148
23149 COUNTRY is China or Taiwan.
23150
23151 But -{A|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- is COUNTRY,
23152
23153 (This-{-|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- should be stripped!)
23154
23155 and -{COUNTRY}- is COUNTRY.
23156 !! html/php
23157 <p>This is Taiwan, but we'll forget that now.
23158 </p><p>COUNTRY is China or Taiwan.
23159 </p><p>But Taiwan is Taiwan,
23160 </p><p>(This should be stripped!)
23161 </p><p>and COUNTRY is COUNTRY.
23162 </p>
23163 !! html/parsoid
23164 <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>
23165 <p>COUNTRY is China or Taiwan.</p>
23166 <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>
23167 <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>
23168 <p>and <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"COUNTRY"}}'></span> is COUNTRY.</p>
23169 !! end
23170
23171 !! test
23172 Explicit session-wise two-way language variant mapping (H flag for hide)
23173 !! options
23174 language=zh variant=zh-tw
23175 !! wikitext
23176 (This-{H|zh:China;zh-tw:Taiwan}- should be stripped!)
23177
23178 Taiwan is China.
23179 !! html/php
23180 <p>(This should be stripped!)
23181 </p><p>Taiwan is Taiwan.
23182 </p>
23183 !! html/parsoid
23184 <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>
23185 <p>Taiwan is China.</p>
23186 !! end
23187
23188 !! test
23189 Explicit session-wise one-way language variant mapping (H flag for hide)
23190 !! options
23191 language=zh variant=zh-tw
23192 !! wikitext
23193 (This-{H|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- should be stripped!)
23194
23195 COUNTRY is Taiwan or China.
23196 !! html/php
23197 <p>(This should be stripped!)
23198 </p><p>Taiwan is Taiwan or China.
23199 </p>
23200 !! html/parsoid
23201 <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>
23202 <p>COUNTRY is Taiwan or China.</p>
23203 !! end
23204
23205 ## Note that parsoid test runner does not support 'showtitle' option.
23206 !! test
23207 Adding explicit conversion rule for title (T flag)
23208 !! options
23209 language=zh variant=zh-tw showtitle
23210 !! wikitext
23211 Should be stripped-{T|zh:China;zh-tw:Taiwan}-!
23212
23213 Taiwan is China.
23214 !! html/php
23215 Taiwan
23216 <p>Should be stripped!
23217 </p><p>Taiwan is China.
23218 </p>
23219 !! html/parsoid
23220 <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>
23221 <p>Taiwan is China.</p>
23222 !! end
23223
23224 !! test
23225 Code coverage: T combined with H flag
23226 !! options
23227 language=zh variant=zh-tw showtitle
23228 !! wikitext
23229 Should be stripped-{T;H|zh:China; zh-tw:Taiwan}-!
23230
23231 Taiwan is China.
23232 !! html/php
23233 Taiwan
23234 <p>Should be stripped!
23235 </p><p>Taiwan is Taiwan.
23236 </p>
23237 !! html/parsoid
23238 <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>
23239 <p>Taiwan is China.</p>
23240 !! end
23241
23242 !! test
23243 Code coverage: T with no variants
23244 !! options
23245 language=zh variant=zh-tw showtitle
23246 !! wikitext
23247 -{H|zh:China; zh-tw:Taiwan}-
23248 Taiwan is China.-{T|Taiwan is China}-
23249 !! html/php
23250 Taiwan is China
23251 <p>
23252 Taiwan is Taiwan.
23253 </p>
23254 !! html/parsoid
23255 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>
23256 Taiwan is China.<meta typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Taiwan is China"},"title":true}'/></p>
23257 !! end
23258
23259 !! test
23260 Code coverage: rules with no variants
23261 !! options
23262 language=zh variant=zh-tw
23263 !! wikitext
23264 -{H|zh:China; zh-tw:Taiwan}-
23265 Taiwan is China.
23266 -{H|China}-
23267 Taiwan is China.
23268 !! html/php
23269 <p>
23270 Taiwan is Taiwan.
23271
23272 Taiwan is China.
23273 </p>
23274 !! html/parsoid
23275 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>
23276 Taiwan is China.
23277 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"*","t":"China"}]}'/>
23278 Taiwan is China.</p>
23279 !! end
23280
23281
23282 !! test
23283 Code coverage: D flag for conversion rule
23284 !! options
23285 language=zh variant=zh-tw
23286 !! wikitext
23287 -{D|zh-cn:XA; zh-tw:YA}-
23288 -{A;D|zh-cn:XB; zh-tw:YB}-
23289 -{D;H|zh-cn:XC; zh-tw:YC}-
23290
23291 -{D;H|FOO=>zh-tw:BAR;FOO=>zh-cn:BAT}-
23292
23293 -{D|0=>zh-tw:1}-
23294 -{A;D|2=>zh-tw:3}-
23295 -{D;H|4=>zh-tw:5}-
23296
23297 XA XB XC YA YB YC FOO BAR BAT 012345
23298 !! html/php
23299 <p>大陆:XA;台灣:YA;
23300
23301 大陆:XC;台灣:YC;
23302 </p><p>FOO⇒台灣:BAR;FOO⇒大陆:BAT;
23303 </p><p>0⇒台灣:1;
23304
23305 4⇒台灣:5;
23306 </p><p>XA YB YC YA YB YC BAR BAR BAT 013355
23307 </p>
23308 !! html/parsoid
23309 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"describe":true,"twoway":[{"l":"zh-cn","t":"XA"},{"l":"zh-tw","t":"YA"}]}'></span>
23310 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"twoway":[{"l":"zh-cn","t":"XB"},{"l":"zh-tw","t":"YB"}]}'/>
23311 <span typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"twoway":[{"l":"zh-cn","t":"XC"},{"l":"zh-tw","t":"YC"}]}'></span></p>
23312 <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>
23313 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"describe":true,"oneway":[{"f":"0","l":"zh-tw","t":"1"}]}'></span>
23314 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"oneway":[{"f":"2","l":"zh-tw","t":"3"}]}'/>
23315 <span typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"oneway":[{"f":"4","l":"zh-tw","t":"5"}]}'></span></p>
23316 <p>XA XB XC YA YB YC FOO BAR BAT 012345</p>
23317 !! end
23318
23319 !! test
23320 Code coverage: N flag for conversion rule
23321 !! options
23322 language=zh variant=zh-cn
23323 !! wikitext
23324 -{N|zh-cn}-
23325
23326 -{N|zh-tw}-
23327
23328 -{N|sr-ec}-
23329 !! html/php
23330 <p>大陆
23331 </p><p>台灣
23332 </p><p>српски (ћирилица)‎
23333 </p>
23334 !! html/parsoid
23335 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"zh-cn"}}'></span></p>
23336 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"zh-tw"}}'></span></p>
23337 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"sr-ec"}}'></span></p>
23338 !! end
23339
23340 # html2wt suppresses the bogus 'D' flag, so this is wt2html only
23341 !! test
23342 Code coverage: N flag for conversion rule (wt2html only)
23343 !! options
23344 language=zh variant=zh-cn
23345 parsoid=wt2html,html2html
23346 !! wikitext
23347 -{D;N|en}-
23348 !! html/php
23349 <p>English
23350 </p>
23351 !! html/parsoid
23352 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"en"}}' data-parsoid='{"fl":["D","N"]}'></span></p>
23353 !! end
23354
23355 !! test
23356 Testing that changing the language variant here in the tests actually works
23357 !! options
23358 language=zh variant=zh showtitle
23359 !! wikitext
23360 Should be stripped-{T|zh:China; zh-tw:Taiwan}-!
23361 !! html/php
23362 China
23363 <p>Should be stripped!
23364 </p>
23365 !! html/parsoid
23366 <p>Should be stripped<meta typeof="mw:LanguageVariant" data-mw-variant='{"title":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>!</p>
23367 !! end
23368
23369 !! test
23370 Recursive conversion of alt and title attrs shouldn't clear converter state
23371 !! options
23372 language=zh variant=zh-cn
23373 showtitle
23374 !! wikitext
23375 -{H|zh-cn:Exclamation; zh-tw:exclamation}-
23376 Should be stripped-{T|zh-cn:China; zh-tw:Taiwan}-<span title="exclamation">!</span>
23377 !! html/php
23378 China
23379 <p>
23380 Should be stripped<span title="Exclamation">!</span>
23381 </p>
23382 !! html/parsoid
23383 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh-cn","t":"Exclamation"},{"l":"zh-tw","t":"exclamation"}]}'/>
23384 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>
23385 !! end
23386
23387 !! test
23388 T26072: more test on conversion rule for title
23389 !! options
23390 language=zh variant=zh-tw showtitle
23391 !! wikitext
23392 This should be stripped-{T|zh:China; zh-tw:Taiwan}-!
23393
23394 This won't take interferes with the title rule-{H|zh:Beijing; zh-tw:Taipei}-.
23395 !! html/php
23396 Taiwan
23397 <p>This should be stripped!
23398 </p><p>This won't take interferes with the title rule.
23399 </p>
23400 !! html/parsoid
23401 <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>
23402 <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>
23403 !! end
23404
23405 !! test
23406 Partly disable title conversion if variant == main language code
23407 !! options
23408 language=zh variant=zh title=[[ZH]] showtitle
23409 !! wikitext
23410 -{T|zh-cn:CN;zh-tw:TW}-
23411 !! html/php
23412 ZH
23413 <p>
23414 </p>
23415 !! html/parsoid
23416 <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>
23417 !! end
23418
23419 !! test
23420 Partly disable title conversion if variant == main language code, more
23421 !! options
23422 language=zh variant=zh title=[[ZH]] showtitle
23423 !! wikitext
23424 -{T|TW}-
23425 !! html/php
23426 ZH
23427 <p>
23428 </p>
23429 !! html/parsoid
23430 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"TW"},"title":true}'/></p>
23431 !! end
23432
23433 !! test
23434 Raw output of variant escape tags (R flag)
23435 !! options
23436 language=zh variant=zh-tw
23437 !! wikitext
23438 Raw: -{R|zh:China;zh-tw:Taiwan}-
23439 !! html/php
23440 <p>Raw: zh:China;zh-tw:Taiwan
23441 </p>
23442 !! html/parsoid
23443 <p>Raw: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"zh:China;zh-tw:Taiwan"}}'></span></p>
23444 !! end
23445
23446 # html2wt suppresses the bogus 'D' flags, so this is wt2html only
23447 !! test
23448 Raw output of variant escape tags (R flag) (wt2html only)
23449 !! options
23450 language=zh variant=zh-tw
23451 parsoid=wt2html,html2html
23452 !! wikitext
23453 -{Variant}- -{D|syntax}- -{D;R|options}-
23454 !! html/php
23455 <p>Variant syntax options
23456 </p>
23457 !! html/parsoid
23458 <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>
23459 !! end
23460
23461 !! test
23462 Nested markup inside raw output of variant escape tags (R flag)
23463 !! options
23464 language=zh variant=zh-tw
23465 !! wikitext
23466 Nested raw: -{R|nested -{zh:China;zh-tw:Taiwan}- nested}-
23467 !! html/php
23468 <p>Nested raw: nested Taiwan nested
23469 </p>
23470 !! html/parsoid
23471 <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>
23472 !! end
23473
23474 !! test
23475 Nested markup and spaces inside raw output of variant escape tags (R flag)
23476 !! options
23477 language=zh variant=zh-tw
23478 !! wikitext
23479 X-{ outer -{ inner }- outer }-X
23480 !! html/php
23481 <p>X outer inner outer X
23482 </p>
23483 !! html/parsoid
23484 <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>
23485 !! end
23486
23487 !! test
23488 Templates inside raw output of variant escape tags (R flag)
23489 !! options
23490 language=zh variant=zh-tw
23491 !! wikitext
23492 Nested raw: -{R|nested {{echo|hi}} templates}-
23493 !! html/php
23494 <p>Nested raw: nested hi templates
23495 </p>
23496 !! html/parsoid
23497 <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>
23498 !! end
23499
23500 !! test
23501 Strings evaluating false shouldn't be ignored by Language converter (T51072)
23502 !! options
23503 language=zh variant=zh-cn
23504 !! wikitext
23505 -{zh-cn:0;zh-sg:1;zh-tw:2;zh-hk:3}-
23506 !! html/php
23507 <p>0
23508 </p>
23509 !! html/parsoid
23510 <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>
23511 !! end
23512
23513 !! test
23514 Conversion rules from [numeric-only string] to [something else] (T48634)
23515 !! options
23516 language=zh variant=zh-cn
23517 !! wikitext
23518 -{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
23519 !! html/php
23520 <p>D12345EE12345
23521 </p>
23522 !! html/parsoid
23523 <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>
23524 !! end
23525
23526 !! test
23527 Two-way converter rule entries with an empty value should be ignored (T53551)
23528 !! options
23529 language=zh variant=zh-cn
23530 !! wikitext
23531 -{H|zh-cn:foo;zh-tw:;}-foobar
23532 !! html/php
23533 <p>foobar
23534 </p>
23535 !! html/parsoid
23536 <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>
23537 !! end
23538
23539 !! test
23540 One-way converter rule entries with an empty "from" string should be ignored (T53551)
23541 !! options
23542 language=zh variant=zh-cn
23543 !! wikitext
23544 -{H|=>zh-cn:foo;}-foobar
23545 !! html/php
23546 <p>foobar
23547 </p>
23548 !! html/parsoid
23549 <p><meta typeof="mw:LanguageVariant" data-parsoid='{"tSp":[5]}' data-mw-variant='{"add":true,"oneway":[{"f":"","l":"zh-cn","t":"foo"}]}'/>foobar</p>
23550 !! end
23551
23552 !! test
23553 Empty converter rule entries shouldn't be inserted into the conversion table (T53551)
23554 !! options
23555 language=zh variant=zh-cn
23556 !! wikitext
23557 -{H|}-foobar
23558 !! html/php
23559 <p>foobar
23560 </p>
23561 !! html/parsoid
23562 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"*","t":""}]}'/>foobar</p>
23563 !! end
23564
23565 !! test
23566 Nested using of manual convert syntax
23567 !! options
23568 language=zh variant=zh-hk
23569 !! wikitext
23570 Nested: -{zh-hans:Hi -{zh-cn:China;zh-sg:Singapore;}-;zh-hant:Hello -{zh-tw:Taiwan;zh-hk:H-{ong}- K-{}-ong;}-;}-!
23571 !! html/php
23572 <p>Nested: Hello Hong Kong!
23573 </p>
23574 !! html/parsoid
23575 <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>
23576 !! end
23577
23578 !! test
23579 HTML markups with conversion syntax in attribs, nested in other conversion blocks
23580 !! options
23581 language=zh variant=zh-cn
23582 !! wikitext
23583 -{zh;zh-hans;zh-hant|<span title="-{X}-">A</span>}-
23584 !! html/php
23585 <p><span title="X">A</span>
23586 </p>
23587 !! html/parsoid
23588 <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>
23589 !! end
23590
23591 !! test
23592 HTML markups with conversion syntax in attribs, nested in other conversion blocks (not working yet in PHP parser)
23593 !! options
23594 language=zh variant=zh-cn
23595 !! wikitext
23596 -{<span title="-{X}-">A</span>}-
23597 !! html/php+disabled
23598 <p><span title="X">A</span>
23599 </p>
23600 !! html/parsoid
23601 <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>
23602 !! end
23603
23604 # Parsoid and PHP disagree on how to parse this example: Parsoid
23605 # insists that the content of a language converter element be a valid
23606 # DOM fragment or attribute string
23607 !! test
23608 Language converter markup with block content
23609 !! options
23610 language=zh variant=zh-cn
23611 !! wikitext
23612 <span>a-{b<div>c}-d
23613
23614 <span>a-{zh;zh-hans;zh-hant|b<div>c}-d
23615
23616 <span>a-{H|0=>zh-cn:x<span>y;0=>zh-tw:b<div>c}-d
23617 !! html/php+tidy
23618 <span>ab<div>cd
23619 <span>ab<div>cd
23620 <span>ad
23621 </span></div></span></div></span>
23622 !! html/parsoid
23623 <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
23624
23625 <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
23626
23627 <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>
23628 !! end
23629
23630 !! test
23631 LanguageConverter selser (1)
23632 !! options
23633 language=zh variant=zh-cn
23634 parsoid={
23635 "modes": ["wt2wt", "selser"],
23636 "changes": [
23637 ["span[typeof]", "attr", "data-mw-variant", "{\"disabled\":{\"t\":\"edited\"}}"]
23638 ]
23639 }
23640 !! wikitext
23641 -{raw}-
23642 !! wikitext/edited
23643 -{edited}-
23644 !! end
23645
23646 !! test
23647 LanguageConverter selser (2)
23648 !! options
23649 language=zh variant=zh-cn
23650 parsoid={
23651 "modes": ["wt2wt", "selser"],
23652 "changes": [
23653 ["span[class='x']", "contents", "text", "-{foo}-"],
23654 ["a", "contents", "text", "-{"],
23655 ["span[typeof]", "attr", "data-mw", "{\"parts\":[{\"template\":{\"target\":{\"wt\":\"1x\",\"href\":\"./Template:1x\"},\"params\":{\"1\":{\"wt\":\"-{\"}},\"i\":0}}]}"]
23656 ]
23657 }
23658 !! wikitext
23659 <span class="x">TEXT1</span>
23660 [http://example.com TEXT2]
23661 [[Foo|TEXT3]]
23662 {{echo|TEXT4}}
23663 !! wikitext/edited
23664 <span class="x"><nowiki>-{foo}-</nowiki></span>
23665 [http://example.com -{]
23666 [[Foo|<nowiki>-{</nowiki>]]
23667 {{1x|<nowiki>-{</nowiki>}}
23668 !! end
23669
23670 # Tests LanguageVariantText in ConstrainedText
23671 !! test
23672 LanguageConverter selser (3)
23673 !! options
23674 language=zh variant=zh-cn
23675 parsoid={
23676 "modes": ["wt2wt", "selser"],
23677 "changes": [
23678 ["td > span", "attr", "typeof", "mw:LanguageVariant"],
23679 ["td > span", "attr", "data-mw-variant", "{\"disabled\":{\"t\":\"edited\"}}"]
23680 ]
23681 }
23682 !! wikitext
23683 {|
23684 |-
23685 |<span>Foo</span>
23686 |}
23687 !! wikitext/edited
23688 {|
23689 |-
23690 |<nowiki/>-{edited}-
23691 |}
23692 !! end
23693
23694 # Tests LanguageVariantText._fromSelSer
23695 !! test
23696 LanguageConverter selser (4)
23697 !! options
23698 language=zh variant=zh-cn
23699 parsoid={
23700 "modes": ["wt2wt", "selser"],
23701 "changes": [
23702 ["td > span.x", "remove"]
23703 ]
23704 }
23705 !! wikitext
23706 {|
23707 |-
23708 |<span class="x">Foo</span>-{Bar}-
23709 ||<span class="x">Foo</span>-{Bar}-
23710 |}
23711 !! wikitext/edited
23712 {|
23713 |-
23714 |<nowiki/>-{Bar}-
23715 ||-{Bar}-
23716 |}
23717 !! end
23718
23719 # Since Parsoid is starting to emit canonical wikitext for links,
23720 # [http://example.com http://example.com] will not RT back to that
23721 # form anymore.
23722 # Parsoid does not language-convert links (it is done in a
23723 # post-processing step)
23724 !! test
23725 Proper conversion of text in external links
23726 !! options
23727 language=sr variant=sr-ec
23728 parsoid=wt2html
23729 !! wikitext
23730 http://www.google.com
23731 gopher://www.google.com
23732 [http://www.google.com http://www.google.com]
23733 [gopher://www.google.com gopher://www.google.com]
23734 [https://www.google.com irc://www.google.com]
23735 [ftp://www.google.com www.google.com/ftp://dir]
23736 [//www.google.com www.google.com]
23737 !! html/php
23738 <p><a rel="nofollow" class="external free" href="http://www.google.com">http://www.google.com</a>
23739 <a rel="nofollow" class="external free" href="gopher://www.google.com">gopher://www.google.com</a>
23740 <a rel="nofollow" class="external text" href="http://www.google.com">http://www.google.com</a>
23741 <a rel="nofollow" class="external text" href="gopher://www.google.com">gopher://www.google.com</a>
23742 <a rel="nofollow" class="external text" href="https://www.google.com">irc://www.google.com</a>
23743 <a rel="nofollow" class="external text" href="ftp://www.google.com">www.гоогле.цом/фтп://дир</a>
23744 <a rel="nofollow" class="external text" href="//www.google.com">www.гоогле.цом</a>
23745 </p>
23746 !! html/parsoid
23747 <p><a rel="mw:ExtLink" class="external free" href="http://www.google.com">http://www.google.com</a>
23748 <a rel="mw:ExtLink" class="external free" href="gopher://www.google.com">gopher://www.google.com</a>
23749 <a rel="mw:ExtLink" class="external text" href="http://www.google.com">http://www.google.com</a>
23750 <a rel="mw:ExtLink" class="external text" href="gopher://www.google.com">gopher://www.google.com</a>
23751 <a rel="mw:ExtLink" class="external text" href="https://www.google.com">irc://www.google.com</a>
23752 <a rel="mw:ExtLink" class="external text" href="ftp://www.google.com">www.google.com/ftp://dir</a>
23753 <a rel="mw:ExtLink" class="external text" href="//www.google.com">www.google.com</a></p>
23754 !! end
23755
23756 !! test
23757 Do not convert roman numbers to language variants
23758 !! options
23759 language=sr variant=sr-ec
23760 !! wikitext
23761 Fridrih IV je car.
23762 !! html/php
23763 <p>Фридрих IV је цар.
23764 </p>
23765 !! html/parsoid
23766 <p>Fridrih IV je car.</p>
23767 !! end
23768
23769 !! test
23770 Unclosed language converter markup "-{"
23771 !! options
23772 language=sr
23773 !! wikitext
23774 -{T|hello
23775 !! html
23776 <p>-{T|hello
23777 </p>
23778 !! end
23779
23780 !! test
23781 Don't convert raw rule "-{R|=&gt;}-" to "=>"
23782 !! options
23783 language=sr
23784 !! wikitext
23785 -{R|=&gt;}-
23786 !! html/php
23787 <p>=&gt;
23788 </p>
23789 !! html/parsoid
23790 <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>
23791 !!end
23792
23793 !! test
23794 Don't break link parsing if language converter markup is in the caption.
23795 !! options
23796 language=sr variant=sr-ec
23797 !! wikitext
23798 [[Main Page|-{R|main page}-]]
23799 !! html/php
23800 <p><a href="/wiki/Main_Page" title="Маин Паге">main page</a>
23801 </p>
23802 !! html/parsoid
23803 <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>
23804 !! end
23805
23806 !! test
23807 T146304: Don't break template parsing if language converter markup is in the parameter.
23808 !! options
23809 language=sr variant=sr-ec
23810 !! wikitext
23811 {{echo|-{R|foo}-}}
23812 !! html/php
23813 <p>foo
23814 </p>
23815 !! html/parsoid
23816 <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>
23817 !! end
23818
23819 !! test
23820 T146305: Don't break image parsing if language converter markup is in the caption.
23821 !! options
23822 language=sr
23823 !! wikitext
23824 [[Датотека:Foobar.jpg|thumb|-{R|caption:}-]]
23825 !! html/php
23826 <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>
23827
23828 !! html/parsoid
23829 <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>
23830 !! end
23831
23832 !! test
23833 T146305: Don't break image parsing if nested language converter markup is in the caption.
23834 !! options
23835 language=zh variant=zh-cn
23836 !! wikitext
23837 [[File:Foobar.jpg|thumb|-{|zh-cn:blog (hk: -{zh-hans|WEBJOURNAL}-, tw: -{zh-hans|WEBLOG}-)}-]]
23838 !! html/php
23839 <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>
23840
23841 !! html/parsoid
23842 <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>
23843 !! end
23844
23845 # XXX html2wt disabled because rich markup in alt is not preserved.
23846 !! test
23847 Don't break gallery if language converter markup is inside.
23848 !! options
23849 language=zh
23850 !! wikitext
23851 <gallery>
23852 File:foobar.jpg|[[File:foobar.jpg|20px|desc|alt=-{R|foo}-|-{R|bar}-]]|alt=-{R|bat}-
23853 File:foobar.jpg|{{Test|unamedParam|alt=-{R|param}-}}|alt=galleryalt
23854 </gallery>
23855 !! html/php
23856 <ul class="gallery mw-gallery-traditional">
23857 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
23858 <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>
23859 <div class="gallerytext">
23860 <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>
23861 </p>
23862 </div>
23863 </div></li>
23864 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
23865 <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>
23866 <div class="gallerytext">
23867 <p>This is a test template
23868 </p>
23869 </div>
23870 </div></li>
23871 </ul>
23872
23873 !! html/parsoid
23874 <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"}}'>
23875 <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>
23876 <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>
23877 </ul>
23878 !! end
23879
23880 !! test
23881 T153135: Don't break list handling if language converter markup is in the item.
23882 !! options
23883 language=zh variant=zh-cn
23884 !! wikitext
23885 ;-{zh-cn:AAA;zh-tw:BBB}-
23886 ;-{R|foo:bar}-
23887 !! html/php
23888 <dl><dt>AAA</dt>
23889 <dt>foo:bar</dt></dl>
23890
23891 !! html/parsoid
23892 <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>
23893 <dt data-parsoid='{"dsr":[25,39,1,0]}'><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"foo:bar"}}'></span></dt>
23894 </dl>
23895 !! end
23896
23897 // Note that parsoid does not protect colons unless language converter
23898 // markup is properly nested, because it is a backtracking parser.
23899 !! test
23900 T153135: Unclosed markup in definition list (code coverage)
23901 !! options
23902 language=zh variant=zh-cn
23903 !! wikitext
23904 ;<b>foo:bar
23905 ;-{zh-cn:AAA
23906 !! html/php+tidy
23907 <dl><dt><b>foo:bar</b></dt><b>
23908 <dt>-{zh-cn:AAA</dt></b></dl><p><b>
23909 </b></p>
23910 !! html/parsoid
23911 <dl><dt data-parsoid='{}'><b data-parsoid='{"stx":"html","autoInsertedEnd":true}'>foo:bar</b></dt><b data-parsoid='{"stx":"html","autoInsertedEnd":true,"autoInsertedStart":true}'>
23912 <dt data-parsoid='{}'>-{zh-cn</dt><dd data-parsoid='{"stx":"row"}'>AAA</dd></b></dl>
23913 !! end
23914
23915 !! test
23916 T153135: Nested language converter markup in definition list (code coverage)
23917 !! options
23918 language=zh variant=zh-cn
23919 !! wikitext
23920 ;-{|zh-cn:AAA -{zh-hans|foo:bar}- -{R|bat:baz}-}-:def
23921 !! html/php
23922 <dl><dt>AAA foo:bar bat:baz</dt>
23923 <dd>def</dd></dl>
23924
23925 !! html/parsoid
23926 <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>
23927 <dd data-parsoid='{"stx":"row","dsr":[49,53,1,0]}'>def</dd>
23928 </dl>
23929 !! end
23930
23931 # html2wt mode disabled due to <nowiki> insertion.
23932 !! test
23933 T153140: Don't break table handling if language converter markup is in the cell.
23934 !! options
23935 language=sr variant=sr-ec
23936 parsoid=wt2html,wt2wt,html2html
23937 !! wikitext
23938 {|
23939 |-
23940 | -{R|B}-
23941 |}
23942 !! html/php
23943 <table>
23944
23945 <tr>
23946 <td>B
23947 </td></tr></table>
23948
23949 !! html/parsoid
23950 <table>
23951 <tbody>
23952 <tr>
23953 <td><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"B"}}'></span></td>
23954 </tr>
23955 </tbody>
23956 </table>
23957 !! end
23958
23959 !! test
23960 Language converter tricky html2wt cases (1)
23961 !! options
23962 language=sr
23963 parsoid=html2wt,wt2wt
23964 !! html/parsoid
23965 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"}-"}}'></span></p>
23966 !! wikitext
23967 -{<nowiki>}-</nowiki>}-
23968 !! html/php
23969 <p>&#125;-
23970 </p>
23971 !! end
23972
23973 !! test
23974 Language converter tricky html2wt cases (2)
23975 !! options
23976 language=sr
23977 parsoid=html2wt,wt2wt
23978 !! html/parsoid
23979 <p>-{foo}-</p>
23980 !! wikitext
23981 <nowiki>-{foo}-</nowiki>
23982 !! html/php
23983 <p>-&#123;foo&#125;-
23984 </p>
23985 !! end
23986
23987 !! test
23988 Language converter tricky html2wt cases (3)
23989 !! options
23990 language=sr
23991 parsoid=html2wt,wt2wt
23992 !! html/parsoid
23993 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"|"}}'></span></p>
23994 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"R|raw"}}'></span></p>
23995 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"-{foo}-"}}'></span></p>
23996 !! wikitext
23997 -{R||}-
23998
23999 -{R|R|raw}-
24000
24001 -{<nowiki>-{foo}-</nowiki>}-
24002 !! html/php
24003 <p>|
24004 </p><p>R|raw
24005 </p><p>-&#123;foo&#125;-
24006 </p>
24007 !! end
24008
24009 !! test
24010 Language converter tricky html2wt cases (4)
24011 !! options
24012 language=sr
24013 parsoid=html2wt,wt2wt
24014 !! html/parsoid
24015 <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>
24016 !! wikitext
24017 -{R|{{echo|hey}}}-
24018 !! html/php
24019 <p>hey
24020 </p>
24021 !! end
24022
24023 # Note that the <nowiki> escaping added by parsoid for source text,
24024 # destination text, and language names only works on the PHP side
24025 # for *destination text*. (HTML entity escaping wouldn't work
24026 # any better.) This is probably a bug, at least for source texts.
24027 # (For language names PHP uses a precise regexp based on the languages
24028 # it currently knows have variants, which is fragile since this set
24029 # can grow/shrink over time.)
24030 !! test
24031 Language converter tricky html2wt cases (5)
24032 !! options
24033 language=zh variant=zh-cn
24034 !! html/parsoid
24035 <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>
24036 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"A","l":"bo:g;us","t":"B"}]}'/></p>
24037 <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>
24038 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"twoway":[{"l":"bo:g;us","t":"xyz"},{"l":"zh-cn","t":"abc"}]}'></span></p>
24039 <p>a:b=>c xyz</p>
24040 !! wikitext
24041 -{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
24042
24043 -{H|A=><nowiki>bo:g;us</nowiki>:B}-
24044
24045 -{A|zh-tw:xyz; zh-cn:<nowiki>0;zh-tw:bar</nowiki>}-
24046
24047 -{<nowiki>bo:g;us</nowiki>:xyz; zh-cn:abc}-
24048
24049 a:b=>c xyz
24050 !! html/php+disabled
24051 <p>foobat;xyz=&gt;zh-cn:abc
24052 </p><p>A
24053 </p><p>0;zh-tw:bar
24054 </p><p>abc
24055 </p><p>a:b=&gt;c 0;zh-tw:bar
24056 </p>
24057 !! end
24058
24059 !! test
24060 T179579: Nowiki and lc interaction
24061 !! options
24062 parsoid=wt2html
24063 language=sr
24064 !! wikitext
24065 -{</nowiki>123}-
24066
24067 -{123<nowiki>|</nowiki>456}-
24068 !! html/parsoid
24069 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"&amp;lt;/nowiki>123"}}' data-parsoid='{"fl":[],"src":"-{&lt;/nowiki>123}-"}'></span></p>
24070
24071 <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>
24072 !! end
24073
24074 !! test
24075 T2529: Uncovered bullet
24076 !! wikitext
24077 *Foo {{bullet}}
24078 !! html
24079 <ul><li>Foo</li>
24080 <li>Bar</li></ul>
24081
24082 !! end
24083
24084 !! test
24085 T2529: Uncovered bullet in a deeply nested list
24086 !! wikitext
24087 *******Foo {{bullet}}
24088 !! html
24089 <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>
24090 <li>Bar</li></ul>
24091
24092 !! end
24093
24094 !! test
24095 T2529: Uncovered table already at line-start
24096 !! wikitext
24097 x
24098
24099 {{table}}
24100 y
24101 !! html
24102 <p>x
24103 </p>
24104 <table>
24105 <tr>
24106 <td>1</td>
24107 <td>2
24108 </td></tr>
24109 <tr>
24110 <td>3</td>
24111 <td>4
24112 </td></tr></table>
24113 <p>y
24114 </p>
24115 !! end
24116
24117 !! test
24118 T2529: Uncovered bullet in parser function result
24119 !! wikitext
24120 *Foo {{lc:{{bullet}} }}
24121 !! html
24122 <ul><li>Foo</li>
24123 <li>bar</li></ul>
24124
24125 !! end
24126
24127 !! test
24128 T7678: Double-parsed template argument
24129 !! wikitext
24130 {{lc:{{{1}}}|hello}}
24131 !! html
24132 <p>{{{1}}}
24133 </p>
24134 !! end
24135
24136 !! test
24137 T7678: Double-parsed template invocation
24138 !! wikitext
24139 {{lc:{{paramtest {{!}} param = hello }} }}
24140 !! html
24141 <p>{{paramtest | param = hello }}
24142 </p>
24143 !! end
24144
24145 !! test
24146 Case insensitivity of parser functions for non-ASCII characters (T10143)
24147 !! options
24148 language=cs
24149 title=[[Main Page]]
24150 !! wikitext
24151 {{PRVNÍVELKÉ:ěščř}}
24152 {{prvnívelké:ěščř}}
24153 {{PRVNÍMALÉ:ěščř}}
24154 {{prvnímalé:ěščř}}
24155 {{MALÁ:ěščř}}
24156 {{malá:ěščř}}
24157 {{VELKÁ:ěščř}}
24158 {{velká:ěščř}}
24159 !! html
24160 <p>Ěščř
24161 Ěščř
24162 ěščř
24163 ěščř
24164 ěščř
24165 ěščř
24166 ĚŠČŘ
24167 ĚŠČŘ
24168 </p>
24169 !! end
24170
24171 !! test
24172 Morwen/13: Unclosed link followed by heading
24173 !! wikitext
24174 [[link
24175 ==heading==
24176 !! html
24177 <p>[[link
24178 </p>
24179 <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>
24180
24181 !! end
24182
24183 !! test
24184 HHP2.1: Heuristics for headings in preprocessor parenthetical structures
24185 !! wikitext
24186 {{foo|
24187 =heading=
24188 !! html
24189 <p>{{foo|
24190 </p>
24191 <h1><span class="mw-headline" id="heading">heading</span></h1>
24192
24193 !! end
24194
24195 !! test
24196 HHP2.2: Heuristics for headings in preprocessor parenthetical structures
24197 !! wikitext
24198 {{foo|
24199 ==heading==
24200 !! html
24201 <p>{{foo|
24202 </p>
24203 <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>
24204
24205 !! end
24206
24207 !! test
24208 Tildes in comments
24209 !! options
24210 pst
24211 !! wikitext
24212 <!-- ~~~~ -->
24213 !! html/php
24214 <!-- ~~~~ -->
24215 !! end
24216
24217 !! test
24218 Paragraphs inside divs (no extra line breaks)
24219 !! wikitext
24220 <div>Line one
24221
24222 Line two</div>
24223 !! html
24224 <div>Line one
24225 Line two</div>
24226
24227 !! end
24228
24229 !! test
24230 Paragraphs inside divs (extra line break on open)
24231 !! wikitext
24232 <div>
24233 Line one
24234
24235 Line two</div>
24236 !! html
24237 <div>
24238 <p>Line one
24239 </p>
24240 Line two</div>
24241
24242 !! end
24243
24244 !! test
24245 Paragraphs inside divs (extra line break on close)
24246 !! wikitext
24247 <div>Line one
24248
24249 Line two
24250 </div>
24251 !! html
24252 <div>Line one
24253 <p>Line two
24254 </p>
24255 </div>
24256
24257 !! end
24258
24259 !! test
24260 Paragraphs inside divs (extra line break on open and close)
24261 !! wikitext
24262 <div>
24263 Line one
24264
24265 Line two
24266 </div>
24267 !! html
24268 <div>
24269 <p>Line one
24270 </p><p>Line two
24271 </p>
24272 </div>
24273
24274 !! end
24275
24276 # doBlockLevels screws up this output and Remex cleans up as much as it can.
24277 !! test
24278 Nesting tags, paragraphs on lines which begin with <div>
24279 !! wikitext
24280 <div></div><strong>A
24281 B</strong>
24282 !! html/php+tidy
24283 <div></div><p><strong>A
24284 </strong></p><strong></strong><p><strong>B</strong>
24285 </p>
24286 !! html/parsoid
24287 <div data-parsoid='{"stx":"html"}'></div><p><strong data-parsoid='{"stx":"html","autoInsertedEnd":true}'>A</strong></p>
24288 <p><strong data-parsoid='{"stx":"html","autoInsertedStart":true}'>B</strong></p>
24289 !! end
24290
24291 # T8200: <blockquote> should behave like <div> with respect to line breaks
24292 !! test
24293 T8200: paragraphs inside blockquotes (no extra line breaks)
24294 !! wikitext
24295 <blockquote>Line one
24296
24297 Line two</blockquote>
24298 !! html
24299 <blockquote>Line one
24300 Line two</blockquote>
24301
24302 !! html+tidy
24303 <blockquote><p>Line one
24304 Line two</p></blockquote>
24305 !! end
24306
24307 !! test
24308 T8200: paragraphs inside blockquotes (extra line break on open)
24309 !! wikitext
24310 <blockquote>
24311 Line one
24312
24313 Line two</blockquote>
24314 !! html
24315 <blockquote>
24316 <p>Line one
24317 </p>
24318 Line two</blockquote>
24319
24320 !! html+tidy
24321 <blockquote>
24322 <p>Line one
24323 </p><p>
24324 Line two</p></blockquote>
24325 !! end
24326
24327 !! test
24328 T8200: paragraphs inside blockquotes (extra line break on close)
24329 !! wikitext
24330 <blockquote>Line one
24331
24332 Line two
24333 </blockquote>
24334 !! html
24335 <blockquote>Line one
24336 <p>Line two
24337 </p>
24338 </blockquote>
24339
24340 !! html+tidy
24341 <blockquote><p>Line one
24342 </p><p>Line two
24343 </p>
24344 </blockquote>
24345 !! end
24346
24347 !! test
24348 T8200: paragraphs inside blockquotes (extra line break on open and close)
24349 !! wikitext
24350 <blockquote>
24351 Line one
24352
24353 Line two
24354 </blockquote>
24355 !! html
24356 <blockquote>
24357 <p>Line one
24358 </p><p>Line two
24359 </p>
24360 </blockquote>
24361
24362 !! end
24363
24364 ## This is a corner case interaction between the paragraph wrapping in the
24365 ## php parser's BlockLevelPass and Remex. `doBlockLevels` has a notion of
24366 ## some tags which close paragraphs (and thus prevent wrapping on their line),
24367 ## of which "div" is one, but do p-wrapping inside them. These are referred
24368 ## to as "never suppressing". Remex, for its part, doesn't traverse into
24369 ## "div"s to p-wrap. Hence, we only get this partial wrapping.
24370 !! test
24371 Paragraphs inside blockquotes/divs (no extra line breaks)
24372 !! wikitext
24373 <blockquote><div>Line one
24374
24375 Line two</div></blockquote>
24376 !! html
24377 <blockquote><div>Line one
24378 Line two</div></blockquote>
24379
24380 !! end
24381
24382 !! test
24383 Paragraphs inside blockquotes/divs (extra line break on open)
24384 !! wikitext
24385 <blockquote><div>
24386 Line one
24387
24388 Line two</div></blockquote>
24389 !! html
24390 <blockquote><div>
24391 <p>Line one
24392 </p>
24393 Line two</div></blockquote>
24394
24395 !! end
24396
24397 !! test
24398 Paragraphs inside blockquotes/divs (extra line break on close)
24399 !! wikitext
24400 <blockquote><div>Line one
24401
24402 Line two
24403 </div></blockquote>
24404 !! html
24405 <blockquote><div>Line one
24406 <p>Line two
24407 </p>
24408 </div></blockquote>
24409
24410 !! end
24411
24412 !! test
24413 Paragraphs inside blockquotes/divs (extra line break on open and close)
24414 !! wikitext
24415 <blockquote><div>
24416 Line one
24417
24418 Line two
24419 </div></blockquote>
24420 !! html
24421 <blockquote><div>
24422 <p>Line one
24423 </p><p>Line two
24424 </p>
24425 </div></blockquote>
24426
24427 !! end
24428
24429 !! test
24430 Interwiki links trounced by replaceExternalLinks after early LinkHolderArray expansion
24431 !! options
24432 wgLinkHolderBatchSize=0
24433 !! wikitext
24434 [[meatball:1]]
24435 [[meatball:2]]
24436 [[meatball:3]]
24437 !! html
24438 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?1" class="extiw" title="meatball:1">meatball:1</a>
24439 <a href="http://www.usemod.com/cgi-bin/mb.pl?2" class="extiw" title="meatball:2">meatball:2</a>
24440 <a href="http://www.usemod.com/cgi-bin/mb.pl?3" class="extiw" title="meatball:3">meatball:3</a>
24441 </p>
24442 !! end
24443
24444 !! test
24445 Free external link invading image caption
24446 !! wikitext
24447 [[Image:Foobar.jpg|thumb|http://x|hello]]
24448 !! html/php
24449 <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>
24450
24451 !! html/parsoid
24452 <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>
24453 !! end
24454
24455 !! test
24456 T17196: localised external link numbers
24457 !! options
24458 language=fa
24459 !! wikitext
24460 [http://en.wikipedia.org/]
24461 !! html/php
24462 <p><a rel="nofollow" class="external autonumber" href="http://en.wikipedia.org/">[۱]</a>
24463 </p>
24464 !! html/parsoid
24465 <p><a rel="mw:ExtLink" class="external autonumber" href="http://en.wikipedia.org/"></a></p>
24466 !! end
24467
24468 !! test
24469 Multibyte character in padleft
24470 !! wikitext
24471 {{padleft:-Hello|7|Æ}}
24472 !! html/php
24473 <p>Æ-Hello
24474 </p>
24475 !! html/parsoid
24476 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padleft:-Hello","function":"padleft"},"params":{"1":{"wt":"7"},"2":{"wt":"Æ"}},"i":0}}]}'>Æ-Hello</p>
24477 !! end
24478
24479 !! test
24480 Multibyte character in padright
24481 !! wikitext
24482 {{padright:Hello-|7|Æ}}
24483 !! html/php
24484 <p>Hello-Æ
24485 </p>
24486 !! html/parsoid
24487 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padright:Hello-","function":"padright"},"params":{"1":{"wt":"7"},"2":{"wt":"Æ"}},"i":0}}]}'>Hello-Æ</p>
24488 !! end
24489
24490 !!test
24491 formatdate parser function
24492 !! wikitext
24493 {{#formatdate:2009-03-24}}
24494 !! html
24495 <p><span class="mw-formatted-date" title="2009-03-24">2009-03-24</span>
24496 </p>
24497 !! end
24498
24499 !!test
24500 formatdate parser function, with default format
24501 !! wikitext
24502 {{#formatdate:2009-03-24|mdy}}
24503 !! html
24504 <p><span class="mw-formatted-date" title="2009-03-24">March 24, 2009</span>
24505 </p>
24506 !! end
24507
24508 !! test
24509 Spacing of numbers in formatted dates
24510 !! wikitext
24511 {{#formatdate:January 15}}
24512 !! html
24513 <p><span class="mw-formatted-date" title="01-15">January 15</span>
24514 </p>
24515 !! end
24516
24517 !! test
24518 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
24519 !! options
24520 language=nl title=[[MediaWiki:Common.css]]
24521 !! wikitext
24522 {{#formatdate:2009-03-24|dmy}}
24523 !! html
24524 <p><span class="mw-formatted-date" title="2009-03-24">24 March 2009</span>
24525 </p>
24526 !! end
24527
24528 #
24529 #
24530 #
24531
24532 #
24533 # Edit comments
24534 #
24535
24536 !! test
24537 Edit comment with link
24538 !! options
24539 comment
24540 !! wikitext
24541 I like the [[Main Page]] a lot
24542 !! html/php
24543 I like the <a href="/wiki/Main_Page" title="Main Page">Main Page</a> a lot
24544 !!end
24545
24546 !! test
24547 Edit comment with link and link text
24548 !! options
24549 comment
24550 !! wikitext
24551 I like the [[Main Page|best pages]] a lot
24552 !! html/php
24553 I like the <a href="/wiki/Main_Page" title="Main Page">best pages</a> a lot
24554 !!end
24555
24556 !! test
24557 Edit comment with link and link text with suffix
24558 !! options
24559 comment
24560 !! wikitext
24561 I like the [[Main Page|best page]]s a lot
24562 !! html/php
24563 I like the <a href="/wiki/Main_Page" title="Main Page">best pages</a> a lot
24564 !!end
24565
24566 !! test
24567 Edit comment with section link (non-local, eg in history list)
24568 !! options
24569 comment title=[[Main Page]]
24570 !! wikitext
24571 /* External links */ removed bogus entries
24572 !! html/php
24573 <span dir="auto"><span class="autocomment"><a href="/wiki/Main_Page#External_links" title="Main Page">→‎External links</a>: </span> removed bogus entries</span>
24574 !!end
24575
24576 !! test
24577 Edit comment with section link and text before it (non-local, eg in history list)
24578 !! options
24579 comment title=[[Main Page]]
24580 !! wikitext
24581 pre-comment text /* External links */ removed bogus entries
24582 !! html/php
24583 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>
24584 !!end
24585
24586 !! test
24587 Edit comment with section link (local, eg in diff view)
24588 !! options
24589 comment local title=[[Main Page]]
24590 !! wikitext
24591 /* External links */ removed bogus entries
24592 !! html/php
24593 <span dir="auto"><span class="autocomment"><a href="#External_links">→‎External links</a>: </span> removed bogus entries</span>
24594 !!end
24595
24596 !! test
24597 Edit comment with section link that has a link in it
24598 !! options
24599 comment local title=[[Main Page]]
24600 !! wikitext
24601 /* [[A link]] */
24602 !! html/php
24603 <span dir="auto"><span class="autocomment"><a href="#A_link">→‎&#91;[A link]]</a></span></span>
24604 !! end
24605
24606 !! test
24607 Edit comment with section link that has a template in it
24608 !! options
24609 comment local title=[[Main Page]]
24610 !! wikitext
24611 /* {{foobar|param}} */
24612 !! html/php
24613 <span dir="auto"><span class="autocomment"><a href="#.7B.7Bfoobar.7Cparam.7D.7D">→‎{{foobar|param}}</a></span></span>
24614 !! end
24615
24616 !! test
24617 Edit comment with subpage link (T16080)
24618 !! options
24619 comment
24620 subpage
24621 title=[[Subpage test]]
24622 !! wikitext
24623 Poked at a [[/subpage]] here...
24624 !! html/php
24625 Poked at a <a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a> here...
24626 !!end
24627
24628 !! test
24629 Edit comment with subpage link and link text (T16080)
24630 !! options
24631 comment
24632 subpage
24633 title=[[Subpage test]]
24634 !! wikitext
24635 Poked at a [[/subpage|neat little page]] here...
24636 !! html/php
24637 Poked at a <a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">neat little page</a> here...
24638 !!end
24639
24640 !! test
24641 Edit comment with bogus subpage link in non-subpage NS (T16080)
24642 !! options
24643 comment
24644 title=[[Subpage test]]
24645 !! wikitext
24646 Poked at a [[/subpage]] here...
24647 !! html/php
24648 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...
24649 !!end
24650
24651 !! test
24652 Edit comment with bare anchor link (local, as on diff)
24653 !! options
24654 comment
24655 local
24656 title=[[Main Page]]
24657 !! wikitext
24658 [[#section]]
24659 !! html/php
24660 <a href="#section">#section</a>
24661 !! end
24662
24663 !! test
24664 Edit comment with bare anchor link (non-local, as on history)
24665 !! options
24666 comment
24667 title=[[Main Page]]
24668 !! wikitext
24669 [[#section]]
24670 !! html/php
24671 <a href="/wiki/Main_Page#section" title="Main Page">#section</a>
24672 !! end
24673
24674 !! test
24675 Anchor starting with underscore
24676 !! options
24677 title=[[Foo]]
24678 !! wikitext
24679 [[#_ref|One]]
24680 !! html/php
24681 <p><a href="#_ref">One</a>
24682 </p>
24683 !! html/parsoid
24684 <p><a rel="mw:WikiLink" href="./Foo#_ref" data-parsoid='{"stx":"piped","a":{"href":"./Foo#_ref"},"sa":{"href":"#_ref"}}'>One</a></p>
24685 !! end
24686
24687 !! test
24688 Id starting with underscore
24689 !! wikitext
24690 <div id="_ref"></div>
24691 !! html/*
24692 <div id="_ref"></div>
24693
24694 !! end
24695
24696 !! test
24697 Edit comment with link with more than one pipe (T99346)
24698 !! options
24699 comment
24700 !! wikitext
24701 [[Main Page|Many|pipes]]
24702 !! html/php
24703 <a href="/wiki/Main_Page" title="Main Page">Many|pipes</a>
24704 !! end
24705
24706 !! test
24707 Complex edit comment with link with more than one pipe (T99346)
24708 !! options
24709 comment
24710 !! wikitext
24711 Created page with "<noinclude>[[Category:Requests for permissions/Bot|{{subst:#titleparts:{{subst:PAGENAME}}|1|3}}]]</noinclude> === [[User:MineoBot|]] 8=== {{Request for permissions/links|Mineo..."
24712 !! html/php
24713 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;
24714 !! end
24715
24716 !! test
24717 Space normalisation on autocomment (T24784)
24718 !! options
24719 comment
24720 title=[[Main Page]]
24721 !! wikitext
24722 /* __hello__world__ */
24723 !! html/php
24724 <span dir="auto"><span class="autocomment"><a href="/wiki/Main_Page#hello_world" title="Main Page">→‎__hello__world__</a></span></span>
24725 !! end
24726
24727 !! test
24728 percent-encoding and + signs in comments (T28410)
24729 !! options
24730 comment
24731 !! wikitext
24732 [[ABC%33D% ++]] [[ABC%33D% ++|+%20]]
24733 !! html/php
24734 <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>
24735 !! end
24736
24737 # Parsoid doesn't support this yet: see T75581
24738 # but it *should* omit the 'src' attribute if the image is bad.
24739 # PHP side of tests was disabled in
24740 # mediawiki/core:6bd31e7d95161a6e88fa86df60871051da997c3c
24741 # because of issues in the PHP parserTests infrastructure
24742 # (but the output below is indeed what the PHP side emits)
24743 !! test
24744 Bad images - basic functionality
24745 !! wikitext
24746 [[File:Bad.jpg]]
24747 !! html/php+disabled
24748 !! html/parsoid
24749 <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>
24750 !! end
24751
24752 !! test
24753 Bad images - T18039: text after bad image disappears
24754 !! wikitext
24755 Foo bar
24756 [[File:Bad.jpg]]
24757 Bar foo
24758 !! html/php+disabled
24759 <p>Foo bar
24760 </p><p>Bar foo
24761 </p>
24762 !! html/parsoid
24763 <p>Foo bar
24764 <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>
24765 Bar foo</p>
24766 !! end
24767
24768 !! test
24769 Verify that displaytitle works (T24501) no displaytitle
24770 !! options
24771 showtitle
24772 !! config
24773 wgAllowDisplayTitle=true
24774 wgRestrictDisplayTitle=false
24775 !! wikitext
24776 this is not the the title
24777 !! html/php
24778 Parser test
24779 <p>this is not the the title
24780 </p>
24781 !! end
24782
24783 !! test
24784 Verify that displaytitle works (T24501) RestrictDisplayTitle=false
24785 !! options
24786 showtitle
24787 title=[[Screen]]
24788 !! config
24789 wgAllowDisplayTitle=true
24790 wgRestrictDisplayTitle=false
24791 !! wikitext
24792 this is not the the title
24793 {{DISPLAYTITLE:whatever}}
24794 !! html/php
24795 whatever
24796 <p>this is not the the title
24797 </p>
24798 !! end
24799
24800 !! test
24801 Verify that displaytitle works (T24501) RestrictDisplayTitle=true mismatch
24802 !! options
24803 showtitle
24804 title=[[Screen]]
24805 !! config
24806 wgAllowDisplayTitle=true
24807 wgRestrictDisplayTitle=true
24808 !! wikitext
24809 this is not the the title
24810 {{DISPLAYTITLE:whatever}}
24811 !! html/php
24812 Screen
24813 <p>this is not the the title
24814 </p>
24815 !! end
24816
24817 !! test
24818 Verify that displaytitle works (T24501) RestrictDisplayTitle=true matching
24819 !! options
24820 showtitle
24821 title=[[Screen]]
24822 !! config
24823 wgAllowDisplayTitle=true
24824 wgRestrictDisplayTitle=true
24825 !! wikitext
24826 this is not the the title
24827 {{DISPLAYTITLE:screen}}
24828 !! html/php
24829 screen
24830 <p>this is not the the title
24831 </p>
24832 !! end
24833
24834 !! test
24835 Verify that displaytitle works (T24501) AllowDisplayTitle=false
24836 !! options
24837 showtitle
24838 title=[[Screen]]
24839 !! config
24840 wgAllowDisplayTitle=false
24841 !! wikitext
24842 this is not the the title
24843 {{DISPLAYTITLE:screen}}
24844 !! html/php
24845 Screen
24846 <p>this is not the the title
24847 <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>
24848 </p>
24849 !! end
24850
24851 !! test
24852 Verify that displaytitle works (T24501) AllowDisplayTitle=false no DISPLAYTITLE
24853 !! options
24854 showtitle
24855 title=[[Screen]]
24856 !! config
24857 wgAllowDisplayTitle=false
24858 !! wikitext
24859 this is not the the title
24860 !! html/php
24861 Screen
24862 <p>this is not the the title
24863 </p>
24864 !! end
24865
24866 !! test
24867 Verify that displaytitle handles inline CSS styles (T28547) - rejected value
24868 !! options
24869 showtitle
24870 title=[[Screen]]
24871 !! config
24872 wgAllowDisplayTitle=true
24873 wgRestrictDisplayTitle=true
24874 !! wikitext
24875 this is not the the title
24876 {{DISPLAYTITLE:<span style="display: none;">s</span>creen}}
24877 !! html/php
24878 <span style="/* attempt to bypass $wgRestrictDisplayTitle */">s</span>creen
24879 <p>this is not the the title
24880 </p>
24881 !! end
24882
24883 !! test
24884 Verify that displaytitle handles inline CSS styles (T28547) - accepted value
24885 !! options
24886 showtitle
24887 title=[[Screen]]
24888 !! config
24889 wgAllowDisplayTitle=true
24890 wgRestrictDisplayTitle=true
24891 !! wikitext
24892 this is not the the title
24893 {{DISPLAYTITLE:<span style="color: red;">s</span>creen}}
24894 !! html/php
24895 <span style="color: red;">s</span>creen
24896 <p>this is not the the title
24897 </p>
24898 !! end
24899
24900 !! test
24901 Page status indicators: Empty name is invalid
24902 !! options
24903 showindicators
24904 !! wikitext
24905 <indicator name=" "></indicator>
24906 <indicator></indicator>
24907 !! html/php
24908 <p><span class="error"><strong>Error:</strong> Page status indicators' <code>name</code> attribute must not be empty.</span>
24909 <span class="error"><strong>Error:</strong> Page status indicators' <code>name</code> attribute must not be empty.</span>
24910 </p>
24911 !! end
24912
24913 !! test
24914 Page status indicators: Weird syntaxes that are okay
24915 !! options
24916 showindicators
24917 !! wikitext
24918 <indicator name="empty" />
24919 <indicator name="name"></indicator>
24920 !! html/php
24921 empty=
24922 name=
24923 <p><br />
24924 </p>
24925 !! end
24926
24927 !! test
24928 Page status indicators: Torture test
24929 !! options
24930 showindicators
24931 !! wikitext
24932 <indicator name="01">hello world</indicator>
24933 <indicator name="02">[[Main Page]]</indicator>
24934 <indicator name="03">[[File:Foobar.jpg|25px|link=]]</indicator>
24935 <indicator name="04">[[File:Foobar.jpg|25px]]</indicator>
24936 <indicator name="05">*foo
24937 *bar</indicator>
24938 <indicator name="06"><nowiki>foo</nowiki></indicator>
24939 <indicator name="07"> Preformatted</indicator>
24940 <indicator name="08"><div>Broken tag</indicator>
24941 <indicator name="09">{| class=wikitable
24942 |cell
24943 |}</indicator>
24944 <indicator name="10">Two
24945
24946 paragraphs</indicator>
24947 !! html/php
24948 01=hello world
24949 02=<a href="/wiki/Main_Page" title="Main Page">Main Page</a>
24950 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" />
24951 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>
24952 05=<ul><li>foo</li>
24953 <li>bar</li></ul>
24954
24955 06=foo
24956 07=<pre>Preformatted
24957 </pre>
24958 08=<div>Broken tag</div>
24959
24960 09=<table class="wikitable">
24961 <tr>
24962 <td>cell
24963 </td></tr></table>
24964
24965 10=<p>Two
24966 </p><p>paragraphs
24967 </p>
24968 <p><br />
24969 </p><p><br />
24970 </p><p><br />
24971 </p><p><br />
24972 </p><p><br />
24973 </p>
24974 !! end
24975
24976 !! test
24977 preload: check <noinclude> and <includeonly>
24978 !! options
24979 preload
24980 !! wikitext
24981 Hello <noinclude>cruel</noinclude><includeonly>kind</includeonly> world.
24982 !! html/php
24983 Hello kind world.
24984 !! end
24985
24986 !! test
24987 preload: check <onlyinclude>
24988 !! options
24989 preload
24990 !! wikitext
24991 Goodbye <onlyinclude>Hello world</onlyinclude>
24992 !! html/php
24993 Hello world
24994 !! end
24995
24996 !! test
24997 preload: can pass tags through if we want to
24998 !! options
24999 preload
25000 !! wikitext
25001 <includeonly><</includeonly>includeonly>Hello world<includeonly><</includeonly>/includeonly>
25002 !! html/php
25003 <includeonly>Hello world</includeonly>
25004 !! end
25005
25006 !! test
25007 preload: check that it doesn't try to do tricks
25008 !! options
25009 preload
25010 !! wikitext
25011 * <!-- Hello --> ''{{world}}'' {{<includeonly>subst:</includeonly>How are you}}{{ {{{|safesubst:}}} #if:1|2|3}}
25012 !! html/php
25013 * <!-- Hello --> ''{{world}}'' {{subst:How are you}}{{ {{{|safesubst:}}} #if:1|2|3}}
25014 !! end
25015
25016 !! test
25017 Play a bit with r67090 and T5158
25018 !! wikitext
25019 <div style="width:50% !important">&nbsp;</div>
25020 <div style="width:50%&nbsp;!important">&nbsp;</div>
25021 <div style="width:50%&#160;!important">&nbsp;</div>
25022 <div style="border : solid;">&nbsp;</div>
25023 !! html/php
25024 <div style="width:50% !important">&#160;</div>
25025 <div style="width:50% !important">&#160;</div>
25026 <div style="width:50% !important">&#160;</div>
25027 <div style="border&#32;: solid;">&#160;</div>
25028
25029 !! html/parsoid
25030 <div style="width:50% !important" data-parsoid='{"stx":"html"}'><span typeof="mw:Entity" data-parsoid='{"srcContent":" "}'> </span></div>
25031 <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>
25032 <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>
25033 <div style="border : solid;" data-parsoid='{"stx":"html"}'><span typeof="mw:Entity" data-parsoid='{"srcContent":" "}'> </span></div>
25034
25035 !! end
25036
25037 !! test
25038 French spaces in wikitext
25039 !! wikitext
25040 foo ! bar ? bat 50 % is less than 75 %.
25041
25042 Hello : this ; is « something ‹ else › again »
25043 !! html
25044 <p>foo&#160;! bar&#160;? bat 50&#160;% is less than 75&#160;%.
25045 </p><p>Hello&#160;: this&#160;; is «&#160;something ‹&#160;else&#160;› again&#160;»
25046 </p>
25047 !! end
25048
25049 # It would be reasonable for Parsoid and PHP to differ here.
25050 # The PHP behavior is arguably a bug.
25051 !! test
25052 Corner case: french spaces in definition list
25053 !! wikitext
25054 ;foo : bar
25055 !! html+tidy
25056 <dl><dt>foo&#160;</dt>
25057 <dd>bar</dd></dl>
25058 !! end
25059
25060 !! test
25061 T5158: Test for French spaces in attributes
25062 !! wikitext
25063 <br style=" clear : both ; " />
25064 !! html/php
25065 <p><br style="clear&#32;: both&#32;;" />
25066 </p>
25067 !! end
25068
25069 !! test
25070 HTML5 data attributes
25071 !! wikitext
25072 <span data-foo="bar">Baz</span>
25073 <p data-abc-def_hij="">Quuz</p>
25074 !! html/php
25075 <p><span data-foo="bar">Baz</span>
25076 </p>
25077 <p data-abc-def_hij="">Quuz</p>
25078
25079 !! html/parsoid
25080 <p><span data-foo="bar" data-parsoid='{"stx":"html"}'>Baz</span></p>
25081 <p data-abc-def_hij="" data-parsoid='{"stx":"html"}'>Quuz</p>
25082 !! end
25083
25084 !! test
25085 Strip reserved data attributes
25086 !! wikitext
25087 <div data-mw="foo" data-parsoid="bar" data-mw-someext="baz" data-ok="fred" data-ooui="xyzzy" data-bad:ns="ns">d</div>
25088 !! html/php
25089 <div data-ok="fred">d</div>
25090
25091 !! html/parsoid
25092 <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>
25093 !! end
25094
25095 !! test
25096 percent-encoding and + signs in internal links (T28410)
25097 !! wikitext
25098 [[User:+%]] [[Page+title%]]
25099 [[%+]] [[%+|%20]] [[%+ ]] [[%+r]]
25100 [[%]] [[+]] [[File:%+abc%39|foo|[[bar]]]]
25101 [[%33%45]] [[%33%45+]]
25102 !! html/php
25103 <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>
25104 <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>
25105 <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>
25106 <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>
25107 </p>
25108 !! html/parsoid
25109 <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>
25110 <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>
25111 <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>
25112 <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>
25113 !! end
25114
25115 !! test
25116 Special characters in embedded file links (T29679)
25117 !! wikitext
25118 [[File:Contains & ampersand.jpg]]
25119 [[File:Does not exist.jpg|Title with & ampersand]]
25120 !! html/php
25121 <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>
25122 <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>
25123 </p>
25124 !! html/parsoid
25125 <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>
25126 <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>
25127 !! end
25128
25129 !! test
25130 Confirm that 'apos' named character reference doesn't make it to output (not legal in HTML 4)
25131 !! wikitext
25132 Text&apos;s been normalized?
25133 !! html
25134 <p>Text&#39;s been normalized?
25135 </p>
25136 !! end
25137
25138 !! test
25139 T21052 U+3000 IDEOGRAPHIC SPACE should terminate free external links
25140 !! wikitext
25141 http://www.example.org/ <-- U+3000 (vim: ^Vu3000)
25142 !! html
25143 <p><a rel="nofollow" class="external free" href="http://www.example.org/">http://www.example.org/</a> &lt;-- U+3000 (vim: ^Vu3000)
25144 </p>
25145 !! end
25146
25147 !! test
25148 T21052 U+3000 IDEOGRAPHIC SPACE should terminate bracketed external links
25149 !! wikitext
25150 [http://www.example.org/ ideograms]
25151 !! html
25152 <p><a rel="nofollow" class="external text" href="http://www.example.org/">ideograms</a>
25153 </p>
25154 !! end
25155
25156 !! test
25157 T21052 U+3000 IDEOGRAPHIC SPACE should terminate external images links
25158 !! wikitext
25159 http://www.example.org/pic.png <-- U+3000 (vim: ^Vu3000)
25160 !! html
25161 <p><img src="http://www.example.org/pic.png" alt="pic.png"/> &lt;-- U+3000 (vim: ^Vu3000)
25162 </p>
25163 !! end
25164
25165 !! article
25166 Mediawiki:loop1
25167 !! text
25168 {{Identical|A}}
25169 !! endarticle
25170
25171 !! article
25172 Mediawiki:loop2
25173 !! text
25174 {{Identical|B}}
25175 !! endarticle
25176
25177 !! article
25178 Template:Identical
25179 !! text
25180 {{int:loop1}}
25181 {{int:loop2}}
25182 !! endarticle
25183
25184 !! test
25185 T33098 Template which includes system messages which includes the template
25186 !! wikitext
25187 {{Identical}}
25188 !! html
25189 <p><span class="error">Template loop detected: <a href="/wiki/Template:Identical" title="Template:Identical">Template:Identical</a></span>
25190 <span class="error">Template loop detected: <a href="/wiki/Template:Identical" title="Template:Identical">Template:Identical</a></span>
25191 </p>
25192 !! end
25193
25194 !! test
25195 T33490 Turkish: ucfirst 'blah'
25196 !! options
25197 language=tr
25198 !! wikitext
25199 {{ucfirst:blah}}
25200 !! html
25201 <p>Blah
25202 </p>
25203 !! end
25204
25205 !! test
25206 T33490 Turkish: ucfirst 'ix'
25207 !! options
25208 language=tr
25209 !! wikitext
25210 {{ucfirst:ix}}
25211 !! html
25212 <p>İx
25213 </p>
25214 !! end
25215
25216 !! test
25217 T33490 Turkish: lcfirst 'BLAH'
25218 !! options
25219 language=tr
25220 !! wikitext
25221 {{lcfirst:BLAH}}
25222 !! html
25223 <p>bLAH
25224 </p>
25225 !! end
25226
25227 !! test
25228 T33490 Turkish: ucfırst (with a dotless i)
25229 !! options
25230 language=tr
25231 !! wikitext
25232 {{ucfırst:blah}}
25233 !! html
25234 <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>
25235 </p>
25236 !! end
25237
25238 !! test
25239 T33490 ucfırst (with a dotless i) with English language
25240 !! options
25241 language=en
25242 !! wikitext
25243 {{ucfırst:blah}}
25244 !! html
25245 <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>
25246 </p>
25247 !! end
25248
25249 # Note that Parsoid doesn't emit an explicit TOC.
25250 # Note also that the html2wt direction tends to emit an extra newline
25251 # between the __TOC__ magicword and the first heading unless *both*
25252 # the <meta> and the <h2> have a data-parsoid attribute set (even if
25253 # it's "{}").
25254
25255 !! test
25256 T28375: TOC with italics
25257 !! options
25258 title=[[Main Page]]
25259 !! wikitext
25260 __TOC__
25261 ==''Lost'' episodes==
25262 !! html/php
25263 <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>
25264 <ul>
25265 <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>
25266 </ul>
25267 </div>
25268
25269 <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>
25270
25271 !! html/parsoid
25272 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25273 <h2 id="Lost_episodes" data-parsoid='{}'><i>Lost</i> episodes</h2>
25274 !! end
25275
25276 !! test
25277 T28375: TOC with bold
25278 !! options
25279 title=[[Main Page]]
25280 !! wikitext
25281 __TOC__
25282 =='''should be bold''' then normal text==
25283 !! html/php
25284 <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>
25285 <ul>
25286 <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>
25287 </ul>
25288 </div>
25289
25290 <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>
25291
25292 !! html/parsoid
25293 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25294 <h2 id="should_be_bold_then_normal_text" data-parsoid='{}'><b>should be bold</b> then normal text</h2>
25295 !! end
25296
25297 !! test
25298 T35845: Headings become cursive in TOC when they contain an image
25299 !! options
25300 title=[[Main Page]]
25301 !! wikitext
25302 __TOC__
25303 ==Image [[Image:foobar.jpg]]==
25304 !! html/php
25305 <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>
25306 <ul>
25307 <li class="toclevel-1 tocsection-1"><a href="#Image"><span class="tocnumber">1</span> <span class="toctext">Image</span></a></li>
25308 </ul>
25309 </div>
25310
25311 <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>
25312
25313 !! html/parsoid
25314 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25315 <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>
25316 !! end
25317
25318 !! test
25319 T35845 (2): Headings become bold in TOC when they contain a blockquote
25320 !! options
25321 title=[[Main Page]]
25322 !! wikitext
25323 __TOC__
25324 ==<blockquote>Quote</blockquote>==
25325 !! html/php
25326 <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>
25327 <ul>
25328 <li class="toclevel-1 tocsection-1"><a href="#Quote"><span class="tocnumber">1</span> <span class="toctext">Quote</span></a></li>
25329 </ul>
25330 </div>
25331
25332 <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>
25333
25334 !! html/php+tidy
25335 <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>
25336 <ul>
25337 <li class="toclevel-1 tocsection-1"><a href="#Quote"><span class="tocnumber">1</span> <span class="toctext">Quote</span></a></li>
25338 </ul>
25339 </div>
25340
25341 <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>
25342 !! html/parsoid
25343 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25344 <h2 id="Quote" data-parsoid='{}'><blockquote><p>Quote</p></blockquote></h2>
25345 !! end
25346
25347 !! test
25348 Unclosed tags in TOC
25349 !! config
25350 wgFragmentMode=[ 'html5', 'legacy' ]
25351 !! options
25352 title=[[Main Page]]
25353 !! wikitext
25354 __TOC__
25355 ==Proof: 2 < 3==
25356 <small>Hanc marginis exiguitas non caperet.</small>
25357 QED
25358 !! html/php
25359 <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>
25360 <ul>
25361 <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>
25362 </ul>
25363 </div>
25364
25365 <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>
25366 <p><small>Hanc marginis exiguitas non caperet.</small>
25367 QED
25368 </p>
25369 !! html/parsoid
25370 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25371 <h2 id="Proof:_2_&lt;_3" data-parsoid='{}'><span id="Proof:_2_.3C_3" typeof="mw:FallbackId"></span>Proof: 2 &lt; 3</h2>
25372 <p><small>Hanc marginis exiguitas non caperet.</small>
25373 QED</p>
25374 !! end
25375
25376 !! test
25377 Multiple tags in TOC
25378 !! wikitext
25379 __TOC__
25380 ==<i>Foo</i> <b>Bar</b>==
25381
25382 ==<i>Foo</i> <blockquote>Bar</blockquote>==
25383 !! html/php
25384 <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>
25385 <ul>
25386 <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>
25387 <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>
25388 </ul>
25389 </div>
25390
25391 <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>
25392 <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>
25393
25394 !! html/php+tidy
25395 <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>
25396 <ul>
25397 <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>
25398 <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>
25399 </ul>
25400 </div>
25401
25402 <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>
25403 <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>
25404 !! html/parsoid
25405 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25406 <h2 id="Foo_Bar" data-parsoid='{}'><i data-parsoid='{"stx":"html"}'>Foo</i> <b data-parsoid='{"stx":"html"}'>Bar</b></h2>
25407
25408 <h2 id="Foo_Bar_2" data-parsoid='{}'><i data-parsoid='{"stx":"html"}'>Foo</i> <blockquote><p>Bar</p></blockquote></h2>
25409 !! end
25410
25411 # Don't expect Parsoid to roundtrip this until the php parser comes closer to
25412 # html5 tag parsing.
25413 !! test
25414 Tags with parameters in TOC
25415 !! options
25416 parsoid=wt2html
25417 !! wikitext
25418 __TOC__
25419 ==<sup class="in-h2">Hello</sup>==
25420
25421 ==<sup class="a > b">Evilbye</sup>==
25422 !! html/php
25423 <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>
25424 <ul>
25425 <li class="toclevel-1 tocsection-1"><a href="#Hello"><span class="tocnumber">1</span> <span class="toctext"><sup>Hello</sup></span></a></li>
25426 <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>
25427 </ul>
25428 </div>
25429
25430 <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>
25431 <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>
25432
25433 !! html/parsoid
25434 <meta property="mw:PageProp/toc" />
25435 <h2 id="Hello"><sup class="in-h2" data-parsoid='{"stx":"html"}'>Hello</sup></h2>
25436
25437 <h2 id='b">Evilbye'><span id="b.22.3EEvilbye" typeof="mw:FallbackId"></span><sup class="a " data-parsoid='{"stx":"html"}'> b">Evilbye</sup></h2>
25438 !! end
25439
25440 !! test
25441 span tags with directionality in TOC
25442 !! wikitext
25443 __TOC__
25444 ==<span dir="ltr">C++</span>==
25445
25446 ==<span dir="rtl">זבנג!</span>==
25447
25448 ==<span style="font-style: italic">The attributes on these span tags must be deleted from the TOC</span>==
25449
25450 ==<span style="font-style: italic" dir="ltr">All attributes on these span tags must be deleted from the TOC</span>==
25451
25452 ==<span dir="ltr" style="font-style: italic">Attributes after dir on these span tags must be deleted from the TOC</span>==
25453 !! html/php
25454 <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>
25455 <ul>
25456 <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>
25457 <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>
25458 <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>
25459 <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>
25460 <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>
25461 </ul>
25462 </div>
25463
25464 <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>
25465 <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>
25466 <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>
25467 <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>
25468 <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>
25469
25470 !! html/parsoid
25471 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25472 <h2 id="C++" data-parsoid='{}'><span id="C.2B.2B" typeof="mw:FallbackId"></span><span dir="ltr">C++</span></h2>
25473 <h2 id="זבנג!"><span id=".D7.96.D7.91.D7.A0.D7.92.21" typeof="mw:FallbackId"></span><span dir="rtl">זבנג!</span></h2>
25474 <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>
25475 <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>
25476 <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>
25477 !! end
25478
25479 !! test
25480 T74884: bdi element in ToC
25481 !! wikitext
25482 __TOC__
25483 ==<bdi>test</bdi>==
25484 !! html/php
25485 <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>
25486 <ul>
25487 <li class="toclevel-1 tocsection-1"><a href="#test"><span class="tocnumber">1</span> <span class="toctext"><bdi>test</bdi></span></a></li>
25488 </ul>
25489 </div>
25490
25491 <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>
25492
25493 !! html/parsoid
25494 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25495 <h2 id="test" data-parsoid='{}'><bdi>test</bdi></h2>
25496 !! end
25497
25498 !! test
25499 T35715: s/strike element in ToC
25500 !! wikitext
25501 __TOC__
25502 ==<s>test</s> test <strike>test</strike>==
25503 !! html/php
25504 <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>
25505 <ul>
25506 <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>
25507 </ul>
25508 </div>
25509
25510 <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>
25511
25512 !! html/parsoid
25513 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25514 <h2 id="test_test_test" data-parsoid='{}'><s>test</s> test <strike>test</strike></h2>
25515 !! end
25516
25517 !! test
25518 T198618: style element in ToC
25519 !! options
25520 styletag=1
25521 !! wikitext
25522 __TOC__
25523 ==<style>.foo {}</style>Style<style>.bar {}</style>==
25524 !! html/php
25525 <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>
25526 <ul>
25527 <li class="toclevel-1 tocsection-1"><a href="#Style"><span class="tocnumber">1</span> <span class="toctext">Style</span></a></li>
25528 </ul>
25529 </div>
25530
25531 <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>
25532
25533 !! html/parsoid
25534 <meta property="mw:PageProp/toc" data-parsoid="{}"/>
25535 <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>
25536 !! end
25537
25538 !! test
25539 T198618: script element in ToC
25540 !! options
25541 wgRawHtml=1
25542 !! wikitext
25543 __TOC__
25544 ==<html><script>alert(1);</script></html>Script<html><script>alert(1);</script></html>==
25545 !! html/php
25546 <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>
25547 <ul>
25548 <li class="toclevel-1 tocsection-1"><a href="#Script"><span class="tocnumber">1</span> <span class="toctext">Script</span></a></li>
25549 </ul>
25550 </div>
25551
25552 <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>
25553
25554 !! html/parsoid
25555 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25556 <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>
25557 !! end
25558
25559 !! test
25560 Empty <p> tag in TOC, removed by Sanitizer (T92892)
25561 !! wikitext
25562 __TOC__
25563 ==x==
25564 !! html/php
25565 <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>
25566 <ul>
25567 <li class="toclevel-1 tocsection-1"><a href="#x"><span class="tocnumber">1</span> <span class="toctext">x</span></a></li>
25568 </ul>
25569 </div>
25570
25571 <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>
25572
25573 !! html/parsoid
25574 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25575 <h2 id="x" data-parsoid='{}'>x</h2>
25576 !! end
25577
25578 !! article
25579 MediaWiki:T34057
25580 !! text
25581 == {{int:headline_sample}} ==
25582 !! endarticle
25583
25584 !! test
25585 T34057: Title needed when expanding <h> nodes.
25586 !! options
25587 title=[[Main Page]]
25588 !! wikitext
25589 {{int:T34057}}
25590 !! html
25591 <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>
25592
25593 !! end
25594
25595 !! test
25596 Strip marker in urlencode
25597 !! wikitext
25598 {{urlencode:x<nowiki/>y}}
25599 {{urlencode:x<nowiki/>y|wiki}}
25600 {{urlencode:x<nowiki/>y|path}}
25601 {{urlencode:x<pre id="one">two</pre>y}}
25602 !! html/php
25603 <p>xy
25604 xy
25605 xy
25606 xy
25607 </p>
25608 !! end
25609
25610 !! test
25611 Strip marker in lc
25612 !! wikitext
25613 {{lc:x<nowiki/>y}}
25614 !! html
25615 <p>xy
25616 </p>
25617 !! end
25618
25619 !! test
25620 Strip marker in uc
25621 !! wikitext
25622 {{uc:x<nowiki/>y}}
25623 !! html
25624 <p>XY
25625 </p>
25626 !! end
25627
25628 !! test
25629 Strip marker in formatNum
25630 !! wikitext
25631 {{formatnum:1<nowiki/>2}}
25632 {{formatnum:1<nowiki/>2|R}}
25633 !! html
25634 <p>12
25635 12
25636 </p>
25637 !! end
25638
25639 !! test
25640 Check noCommafy in formatNum
25641 !! options
25642 language=be-tarask
25643 !! wikitext
25644 {{formatnum:123456.78}}
25645 {{formatnum:123456.78|NOSEP}}
25646 !! html
25647 <p>123 456,78
25648 123456.78
25649 </p>
25650 !! end
25651
25652 !! test
25653 Wrong option for formatNum (T58199)
25654 !! wikitext
25655 {{formatnum:1,234.56|Random}}
25656 {{formatnum:1,234.56|EVERYTHING}}
25657 {{formatnum:1234.56|any argument that has the string 'NOSEP'}}
25658 !! html
25659 <p>1,234.56
25660 1,234.56
25661 1,234.56
25662 </p>
25663 !! end
25664
25665 !! test
25666 Strip marker in grammar
25667 !! options
25668 language=fi
25669 !! wikitext
25670 {{grammar:elative|foo<nowiki/>bar}}
25671 !! html
25672 <p>foobarista
25673 </p>
25674 !! end
25675
25676 !! test
25677 Strip marker in padleft
25678 !! wikitext
25679 {{padleft:|2|x<nowiki/>y}}
25680 !! html
25681 <p>xy
25682 </p>
25683 !! end
25684
25685 !! test
25686 Strip marker in padright
25687 !! wikitext
25688 {{padright:|2|x<nowiki/>y}}
25689 !! html
25690 <p>xy
25691 </p>
25692 !! end
25693
25694 !! test
25695 Strip marker in anchorencode
25696 !! wikitext
25697 {{anchorencode:x<nowiki/>y}}
25698 !! html/php
25699 <p>xy
25700 </p>
25701 !! html/parsoid
25702 <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>
25703 !! end
25704
25705 !! test
25706 nowiki inside link inside heading (T20295)
25707 !! wikitext
25708 ==[[foo|x<nowiki>y</nowiki>z]]==
25709 !! html
25710 <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>
25711
25712 !! end
25713
25714 !! test
25715 new support for bdi element (T33817)
25716 !! wikitext
25717 <p dir="rtl" lang="he">ולדימיר לנין (ברוסית: <bdi lang="ru">Владимир Ленин</bdi>, 24 באפריל 1870–22 בינואר 1924) הוא מנהיג פוליטי קומוניסטי רוסי.</p>
25718 !! html
25719 <p dir="rtl" lang="he">ולדימיר לנין (ברוסית: <bdi lang="ru">Владимир Ленин</bdi>, 24 באפריל 1870–22 בינואר 1924) הוא מנהיג פוליטי קומוניסטי רוסי.</p>
25720
25721 !!end
25722
25723 !! test
25724 Ignore pipe between table row attributes
25725 !! wikitext
25726 {|
25727 |quux
25728 |- id=foo | style='color: red'
25729 |bar
25730 |}
25731 !! html
25732 <table>
25733 <tr>
25734 <td>quux
25735 </td></tr>
25736 <tr id="foo" style="color: red">
25737 <td>bar
25738 </td></tr></table>
25739
25740 !! end
25741
25742 !!test
25743 Language parser function
25744 !! wikitext
25745 {{#language:ar}}
25746 !! html
25747 <p>العربية
25748 </p>
25749 !! end
25750
25751 !!test
25752 Padleft and padright (default 0-padding)
25753 !! wikitext
25754 {{padleft:xyz|5}}
25755 {{padright:xyz|5}}
25756 !! html/php
25757 <p>00xyz
25758 xyz00
25759 </p>
25760 !! html/parsoid
25761 <p><span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padleft:xyz","function":"padleft"},"params":{"1":{"wt":"5"}},"i":0}}]}'>00xyz</span>
25762 <span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padright:xyz","function":"padright"},"params":{"1":{"wt":"5"}},"i":0}}]}'>xyz00</span></p>
25763 !! end
25764
25765 !!test
25766 Padleft and padright (partial fill)
25767 !! wikitext
25768 {{padleft:xyz|6|ab}}
25769 {{padright:xyz|6|ab}}
25770 !! html/php
25771 <p>abaxyz
25772 xyzaba
25773 </p>
25774 !! html/parsoid
25775 <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>
25776 <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>
25777 !! end
25778
25779 !!test
25780 Padleft and padright as substr
25781 !! wikitext
25782 {{padleft:|3|abcde}}
25783 {{padright:|3|abcde}}
25784 !! html/php
25785 <p>abc
25786 abc
25787 </p>
25788 !! html/parsoid
25789 <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>
25790 <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>
25791 !! end
25792
25793 !! test
25794 Padleft and padright with non-numerical length (T180403)
25795 !! wikitext
25796 {{padleft:abcdef|junk}}
25797 {{padright:abcdef|junk}}
25798 !! html/php
25799 <p>abcdef
25800 abcdef
25801 </p>
25802 !! end
25803
25804 !!test
25805 Special parser function
25806 !! wikitext
25807 {{#special:RandomPage}}
25808 {{#special:BaDtItLe}}
25809 {{#special:Foobar}}
25810 !! html
25811 <p>Special:Random
25812 Special:Badtitle
25813 Special:Foobar
25814 </p>
25815 !! end
25816
25817 !!test
25818 T36939 - Case insensitive link parsing ([HttP://])
25819 !! wikitext
25820 [HttP://MediaWiki.Org/]
25821 !! html/php
25822 <p><a rel="nofollow" class="external autonumber" href="HttP://MediaWiki.Org/">[1]</a>
25823 </p>
25824 !! html/parsoid
25825 <p><a rel="mw:ExtLink" class="external autonumber" href="HttP://MediaWiki.Org/"></a></p>
25826 !! end
25827
25828 !!test
25829 T36939 - Case insensitive link parsing ([HttP:// title])
25830 !! wikitext
25831 [HttP://MediaWiki.Org/ MediaWiki]
25832 !! html
25833 <p><a rel="nofollow" class="external text" href="HttP://MediaWiki.Org/">MediaWiki</a>
25834 </p>
25835 !! end
25836
25837 !!test
25838 T36939 - Case insensitive link parsing (HttP://)
25839 !! wikitext
25840 HttP://MediaWiki.Org/
25841 !! html/php
25842 <p><a rel="nofollow" class="external free" href="HttP://MediaWiki.Org/">HttP://MediaWiki.Org/</a>
25843 </p>
25844 !! html/parsoid
25845 <p><a rel="mw:ExtLink" class="external free" href="HttP://MediaWiki.Org/">HttP://MediaWiki.Org/</a></p>
25846 !! end
25847
25848 !!test
25849 Disable TOC
25850 !! options
25851 notoc
25852 !! wikitext
25853 Lead
25854 ==Section 1==
25855 ==Section 2==
25856 ==Section 3==
25857 ==Section 4==
25858 ==Section 5==
25859 !! html
25860 <p>Lead
25861 </p>
25862
25863 <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>
25864 <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>
25865 <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>
25866 <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>
25867 <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>
25868
25869 !! end
25870
25871
25872 ###
25873 ### Parsoid-specific tests
25874 ### Parsoid-PHP parser incompatibilities
25875 ###
25876 !!test
25877 1. SOL-sensitive wikitext tokens as template-args
25878 !! options
25879 parsoid=wt2html,wt2wt
25880 !! wikitext
25881 {{echo|*a}}
25882 {{echo|#a}}
25883 {{echo|:a}}
25884 !! html/php+tidy
25885 <ul><li>a</li></ul>
25886 <ol><li>a</li></ol>
25887 <dl><dd>a</dd></dl>
25888 !! html/parsoid
25889 <span about="#mwt1" typeof="mw:Transclusion">
25890 </span><ul about="#mwt1"><li>a</li>
25891 </ul>
25892 <span about="#mwt2" typeof="mw:Transclusion">
25893 </span><ol about="#mwt2"><li>a</li>
25894 </ol>
25895 <span about="#mwt3" typeof="mw:Transclusion">
25896 </span><dl about="#mwt3"><dd>a</dd>
25897 </dl>
25898 !!end
25899
25900 #### -----------------------------------------------------------------
25901 #### Parsoid-specific functionality tests
25902 #### -----------------------------------------------------------------
25903
25904 # T65642/T68749: Formatting elt fixup around images.
25905 # We know wt2wt will fail, but we expect selser to pass.
25906 # Due to the nature of our testing, wt2wt and selser tests will enter the
25907 # blacklist and we'll catch selser regressions based on changes to the
25908 # blacklist entries for selser tests.
25909 !! test
25910 1. Treebuilder fixup of formatting elt
25911 !! options
25912 parsoid=wt2html,wt2wt
25913 !! wikitext
25914 {|
25915 |
25916 <small>
25917 [[Image:Foobar.jpg|right|Test]]
25918 </small>
25919 |}
25920 !! html/php+tidy
25921 <table>
25922 <tbody><tr>
25923 <td>
25924 <p><small>
25925 </small></p><small>
25926 <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>
25927 </small><p><small></small>
25928 </p>
25929 </td></tr></tbody></table>
25930 !! html/parsoid
25931 <table>
25932 <tbody><tr><td>
25933 <p><small data-parsoid='{"stx":"html","autoInsertedEnd":true}'></small></p><small data-parsoid='{"stx":"html","autoInsertedEnd":true,"autoInsertedStart":true}'>
25934 <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>
25935 <p><small data-parsoid='{"stx":"html","autoInsertedStart":true}'></small></p></td></tr>
25936 </tbody></table>
25937 !! end
25938
25939 !! test
25940 2. Treebuilder fixup of formatting elt
25941 !! options
25942 parsoid=wt2html,wt2wt
25943 !! wikitext
25944 '''foo[[File:Foobar.jpg|thumb|caption]]bar'''
25945
25946 <small>[[Image:Foobar.jpg|right|300px]]</small>
25947 !! html/php+tidy
25948 <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>
25949 </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>
25950 !! html/parsoid
25951 <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>
25952
25953 <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>
25954 !! end
25955
25956 !! test
25957 3. Treebuilder fixup of formatting elt
25958 !! options
25959 parsoid=wt2html,wt2wt
25960 !! wikitext
25961 <small>'''foo[[File:Foobar.jpg|thumb|caption]]bar'''</small>
25962 !! html/php+tidy
25963 <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>
25964 </p>
25965 !! html/parsoid
25966 <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>
25967 !! end
25968
25969 !! test
25970 4. Treebuilder fixup of formatting elt: formatting tags around captionless images
25971 !! options
25972 parsoid=wt2html,wt2wt
25973 !! wikitext
25974 '''<small>[[Image:Foobar.jpg|right|300px]]</small>'''
25975 !! html/php+tidy
25976 <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>
25977 !! html/parsoid
25978 <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>
25979 !! end
25980
25981 #### ----------------------------------------------------------------
25982 #### Parsoid-only testing of Parsoid's impl of LST
25983 #### Not implemented yet, see
25984 #### https://www.mediawiki.org/wiki/Parsoid/HTML_based_LST
25985 #### ----------------------------------------------------------------
25986
25987 ## We still need to support serializing the older format while content is stored.
25988 !! test
25989 LST Sections: Backwards compatibility
25990 !! options
25991 parsoid={
25992 "suppressErrors": true,
25993 "modes": ["html2wt"]
25994 }
25995 !! wikitext
25996 <section begin="2011-05-16" />
25997 <section end="2014-04-10 (MW 1.23wmf22)" />
25998 !! html/parsoid
25999 <p><meta typeof="mw:Extension/LabeledSectionTransclusion/begin" content="2011-05-16"/>
26000 <meta typeof="mw:Extension/LabeledSectionTransclusion/end" content="2014-04-10 (MW 1.23wmf22)"/></p>
26001 !! end
26002
26003 !! test
26004 LST Sections: Newfangled approach
26005 !! wikitext
26006 <section begin="2011-05-16" />
26007 <section end="2014-04-10 (MW 1.23wmf22)" />
26008 !! html/parsoid
26009 <p><span typeof="mw:Extension/section" about="#mwt4" data-mw='{"name":"section","attrs":{"begin":"2011-05-16"}}'>
26010 </span>
26011 <span typeof="mw:Extension/section" about="#mwt6" data-mw='{"name":"section","attrs":{"end":"2014-04-10 (MW 1.23wmf22)"}}'>
26012 </span></p>
26013 !! end
26014
26015 #--------- Test stripping of empty nodes in template content ----------
26016
26017 !! test
26018 Empty LI and TR nodes should be stripped from template content
26019 !! wikitext
26020 {{EmptyLITest}}
26021 {{EmptyTRTest}}
26022 !! html/parsoid
26023 <ul about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyLITest","href":"./Template:EmptyLITest"},"params":{},"i":0}}]}'>
26024 <li>a</li>
26025 <li>b</li>
26026 </ul>
26027 <table about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyTRTest","href":"./Template:EmptyTRTest"},"params":{},"i":0}}]}'>
26028 <tbody>
26029 <tr>
26030 <td>foo</td>
26031 </tr>
26032 <tr>
26033 <td>bar</td>
26034 </tr>
26035 </tbody>
26036 </table>
26037 !! end
26038
26039 !! test
26040 Empty LI and TR nodes should not be stripped from top-level content
26041 !! wikitext
26042 *a
26043 *
26044 *b
26045
26046 {|
26047 |-
26048 |-
26049 |foo
26050 |}
26051 !! html/parsoid
26052 <ul>
26053 <li>a</li>
26054 <li class='mw-empty-elt'></li>
26055 <li>b</li>
26056 </ul>
26057 <table>
26058 <tbody>
26059 <tr class='mw-empty-elt'></tr>
26060 <tr>
26061 <td>foo</td>
26062 </tr>
26063 </tbody>
26064 </table>
26065 !! end
26066
26067 !! test
26068 Empty TR nodes should not be stripped if they have any attributes set
26069 !! wikitext
26070 {{EmptyTRWithHTMLAttrTest}}
26071 !! html/parsoid
26072 <table about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyTRWithHTMLAttrTest","href":"./Template:EmptyTRWithHTMLAttrTest"},"params":{},"i":0}}]}'>
26073 <tr align='center'></tr>
26074 <tr><td>foo</td></tr>
26075 <tr align='center'></tr>
26076 <tr><td>bar</td></tr>
26077 </table>
26078 !! end
26079
26080 #### ----------------------------------------------------------------
26081 #### The following section of tests are primarily to test
26082 #### wikitext escaping capabilities of Parsoid. Given that
26083 #### escaping can be done any number of ways, the wikitext (input)
26084 #### is always adjusted to reflect how Parsoid adds nowiki
26085 #### escape tags.
26086 ####
26087 #### We are marking several tests as parsoid-only since the
26088 #### HTML in the result section is different from what the
26089 #### PHP parser generates for it.
26090 #### ----------------------------------------------------------------
26091
26092
26093 #### --------------- Headings ---------------
26094 #### 0. Unnested
26095 #### 1. Nested inside html <h1>=foo=</h1>
26096 #### 2. Outside heading nest on a single line <h1>foo</h1>*bar
26097 #### 3. Nested inside html with wikitext split by html tags
26098 #### 4. No escape needed
26099 #### 5. Empty headings <h1></h1>
26100 #### 6. Heading chars in SOL context
26101 #### ----------------------------------------
26102 !! test
26103 Headings: 0. Unnested
26104 !! options
26105 parsoid=html2wt
26106 !! html/parsoid
26107 <p>=foo=</p>
26108
26109 <p> =foo=
26110 <!--cmt-->
26111 =foo=</p>
26112
26113 <p>=foo<i>a</i>=</p>
26114 !! wikitext
26115 <nowiki>=foo=</nowiki>
26116
26117 <nowiki> </nowiki>=foo=
26118 <!--cmt-->
26119 <nowiki>=foo=</nowiki>
26120
26121 =foo''a''<nowiki>=</nowiki>
26122 !!end
26123
26124 # New headings and existing headings are handled differently
26125 !! test
26126 Headings: 1. Nested inside html
26127 !! options
26128 parsoid=html2wt
26129 !! html/parsoid
26130 <h1>=foo=</h1>
26131 <h2>=foo=</h2>
26132 <h3>=foo=</h3>
26133
26134 <h1 data-parsoid=''>=foo=</h1>
26135 <h2 data-parsoid=''>=foo=</h2>
26136 <h3 data-parsoid=''>=foo=</h3>
26137 <h4 data-parsoid=''>=foo=</h4>
26138 <h5 data-parsoid=''>=foo=</h5>
26139 <h6 data-parsoid=''>=foo=</h6>
26140 !! wikitext
26141 = =foo= =
26142
26143 == =foo= ==
26144
26145 === =foo= ===
26146
26147 =<nowiki>=foo=</nowiki>=
26148 ==<nowiki>=foo=</nowiki>==
26149 ===<nowiki>=foo=</nowiki>===
26150 ====<nowiki>=foo=</nowiki>====
26151 =====<nowiki>=foo=</nowiki>=====
26152 ======<nowiki>=foo=</nowiki>======
26153
26154 !!end
26155
26156 !! test
26157 Headings: 2. Outside heading nest on a single line <h1>foo</h1>*bar
26158 !! options
26159 parsoid=html2wt
26160 !! html/parsoid
26161 <h1>foo</h1>*bar
26162 <h1>foo</h1>=bar
26163 <h1>foo</h1>=bar=
26164 !! wikitext
26165 = foo =
26166 <nowiki>*</nowiki>bar
26167
26168 = foo =
26169 =bar
26170
26171 = foo =
26172 <nowiki>=bar=</nowiki>
26173 !!end
26174
26175 !! test
26176 Headings: 3. Nested inside html with wikitext split by html tags
26177 !! options
26178 parsoid=html2wt
26179 !! html/parsoid
26180 <h1>=<b>bold</b>foo=</h1>
26181 !! wikitext
26182 = ='''bold'''foo= =
26183 !!end
26184
26185 !! test
26186 Headings: 4a. No escaping needed (testing just h1 and h2)
26187 !! options
26188 parsoid=html2wt
26189 !! html/parsoid
26190 <h1>=foo</h1>
26191 <h1>foo=</h1>
26192 <h1> =foo= </h1>
26193 <h1>=foo= bar</h1>
26194 <h2>=foo</h2>
26195 <h2>foo=</h2>
26196 <h1>=</h1>
26197 <h1><i>=</i>foo=</h1>
26198 !! wikitext
26199 = =foo =
26200
26201 = foo= =
26202
26203 = =foo= =
26204
26205 = =foo= bar =
26206
26207 == =foo ==
26208
26209 == foo= ==
26210
26211 = = =
26212
26213 = ''=''foo= =
26214 !!end
26215
26216 !! test
26217 Headings: 4b. No escaping needed (inside p-tags)
26218 !! options
26219 parsoid=html2wt
26220 !! html/parsoid
26221 <p>=foo= x
26222 =foo= <s></s>
26223 </p>
26224 !! wikitext
26225 =foo= x
26226 =foo= <s></s>
26227 !! html/php
26228 <p>=foo= x
26229 =foo= <s></s>
26230 </p>
26231 !!end
26232
26233 !! test
26234 Headings: 4c. Short headings (1)
26235 !! options
26236 parsoid=html2wt
26237 !! html/parsoid
26238 <p>===
26239 </p>
26240 !! wikitext
26241 <nowiki>===</nowiki>
26242 !! html/php
26243 <p>===
26244 </p>
26245 !! end
26246
26247 # in the html2wt direction we emit '= = =' or '=<nowiki>=</nowiki>='
26248 !! test
26249 Headings: 4d. Short headings (2)
26250 !! options
26251 parsoid=wt2html,html2html
26252 !! wikitext
26253 =
26254 ==
26255 ===
26256 ====
26257 =====
26258 !! html/php
26259 <p>=
26260 ==
26261 </p>
26262 <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>
26263 <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>
26264 <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>
26265
26266 !! html/parsoid
26267 <p>=
26268 ==</p>
26269 <h1 id="="><span id=".3D" typeof="mw:FallbackId"></span>=</h1>
26270 <h1 id="=="><span id=".3D.3D" typeof="mw:FallbackId"></span>==</h1>
26271 <h2 id="=_2"><span id=".3D_2" typeof="mw:FallbackId"></span>=</h2>
26272 !! end
26273
26274 !! test
26275 Headings: 5. Empty headings
26276 !! options
26277 parsoid=html2wt
26278 !! html/parsoid
26279 <h1 data-parsoid='{}'></h1>
26280
26281 <h2 data-parsoid='{}'></h2>
26282
26283 <h3 data-parsoid='{}'></h3>
26284
26285 <h4 data-parsoid='{}'></h4>
26286
26287 <h5 data-parsoid='{}'></h5>
26288
26289 <h6 data-parsoid='{}'></h6>
26290 !! wikitext
26291 =<nowiki/>=
26292
26293 ==<nowiki/>==
26294
26295 ===<nowiki/>===
26296
26297 ====<nowiki/>====
26298
26299 =====<nowiki/>=====
26300
26301 ======<nowiki/>======
26302 !!end
26303
26304 !! test
26305 Headings: 6a. Heading chars in SOL context (with trailing spaces)
26306 !! options
26307 parsoid=html2wt
26308 !! html/parsoid
26309 <p>=a=</p>
26310
26311 <p>=a=</p>
26312
26313 <p>=a=</p>
26314 !! wikitext
26315 <nowiki>=a=</nowiki>
26316
26317 <nowiki>=a=</nowiki>
26318
26319 <nowiki>=a=</nowiki>
26320 !!end
26321
26322 !! test
26323 Headings: 6b. Heading chars in SOL context (with trailing newlines)
26324 !! options
26325 parsoid=html2wt
26326 !! html/parsoid
26327 <p>=a=
26328 b</p>
26329
26330 <p>=a=
26331 b</p>
26332
26333 <p>=a=
26334 b</p>
26335 !! wikitext
26336 <nowiki>=a=</nowiki>
26337 b
26338
26339 <nowiki>=a=</nowiki>
26340 b
26341
26342 <nowiki>=a=</nowiki>
26343 b
26344 !!end
26345
26346 !! test
26347 Headings: 6c. Heading chars in SOL context (leading newline break)
26348 !! options
26349 parsoid=html2wt
26350 !! html/parsoid
26351 <p>a
26352 =b=</p>
26353 !! wikitext
26354 a
26355 <nowiki>=b=</nowiki>
26356 !!end
26357
26358 !! test
26359 Headings: 6d. Heading chars in SOL context (with interspersed comments)
26360 !! options
26361 parsoid=html2wt
26362 !! html/parsoid
26363 <!--c0--><p>=a=</p>
26364
26365 <!--c1--><p>=a=</p> <!--c2--> <!--c3-->
26366 !! wikitext
26367 <!--c0--><nowiki>=a=</nowiki>
26368
26369 <!--c1--><nowiki>=a=</nowiki> <!--c2--> <!--c3-->
26370 !!end
26371
26372 !! test
26373 Headings: 6d. Heading chars in SOL context (No escaping needed)
26374 !! options
26375 parsoid=html2wt
26376 !! html/parsoid
26377 =a=<div>b</div>
26378 !! wikitext
26379 =a=<div>b</div>
26380 !!end
26381
26382 !! test
26383 Headings: 7. Insert a newline between new content and headings
26384 !! options
26385 parsoid=html2wt
26386 !! html/parsoid
26387 <h2>NEW</h2>
26388 <p>new</p>
26389 <h2 data-parsoid='{}'>A</h2>
26390 <p data-parsoid='{}'>a</p>
26391 !! wikitext
26392 == NEW ==
26393 new
26394
26395 ==A==
26396 a
26397
26398 !! end
26399
26400 !! test
26401 Headings: Used as horizontal rule
26402 !! config
26403 wgFragmentMode=[ 'html5', 'legacy' ]
26404 !! options
26405 parsoid=wt2html
26406 !! wikitext
26407 ===============
26408 !! html/php
26409 <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>
26410
26411 !! html/parsoid
26412 <h6 id="==="><span id=".3D.3D.3D" typeof="mw:FallbackId"></span>===</h6>
26413 !! end
26414
26415 #### --------------- Lists ---------------
26416 #### 0. Outside nests (*foo, etc.)
26417 #### 1. Nested inside html <ul><li>*foo</li></ul>
26418 #### 2. Inside definition lists
26419 #### 3. Only bullets at start should be escaped
26420 #### 4. No escapes needed
26421 #### 5. No unnecessary escapes
26422 #### 6. Escape bullets in SOL position
26423 #### 7. Escape bullets in a multi-line context
26424 #### ----------------------------------------
26425
26426 !! test
26427 Lists: 0. Outside nests
26428 !! options
26429 parsoid=html2wt
26430 !! html/parsoid
26431 <p>*foo</p>
26432
26433 <p>#foo</p>
26434
26435 <p>;Foo:bar</p>
26436 !! wikitext
26437 <nowiki>*</nowiki>foo
26438
26439 <nowiki>#</nowiki>foo
26440
26441 <nowiki>;</nowiki>Foo<nowiki>:</nowiki>bar
26442 !!end
26443
26444 ## Making these next 3 tests Parsoid-only since they are html2wt tests
26445 ## to test wikitext escaping, and insignificant whitespace diffs
26446 ## cause PHP parser tests to barf
26447 !! test
26448 Lists: 1. Nested inside html (No unnecessary escapes)
26449 !! options
26450 parsoid=html2wt
26451 !! html/parsoid
26452 <ul>
26453 <li>*foo</li>
26454 <li>#foo</li>
26455 <li>:foo</li>
26456 <li>;foo</li>
26457 <li data-parsoid='{}'>*foo</li>
26458 <li data-parsoid='{}'>#foo</li>
26459 <li data-parsoid='{}'>:foo</li>
26460 <li data-parsoid='{}'>;foo</li>
26461 </ul>
26462
26463 <ol>
26464 <li>*foo</li>
26465 <li>#foo</li>
26466 <li>:foo</li>
26467 <li>;foo</li>
26468 <li data-parsoid='{}'>*foo</li>
26469 <li data-parsoid='{}'>#foo</li>
26470 <li data-parsoid='{}'>:foo</li>
26471 <li data-parsoid='{}'>;foo</li>
26472 </ol>
26473 !! wikitext
26474 * *foo
26475 * #foo
26476 * :foo
26477 * ;foo
26478 *<nowiki>*foo</nowiki>
26479 *<nowiki>#foo</nowiki>
26480 *<nowiki>:foo</nowiki>
26481 *<nowiki>;foo</nowiki>
26482
26483 # *foo
26484 # #foo
26485 # :foo
26486 # ;foo
26487 #<nowiki>*foo</nowiki>
26488 #<nowiki>#foo</nowiki>
26489 #<nowiki>:foo</nowiki>
26490 #<nowiki>;foo</nowiki>
26491 !!end
26492
26493 !! test
26494 Lists: 2. Inside definition lists
26495 !! options
26496 parsoid=html2wt
26497 !! html/parsoid
26498 <dl><dt>;foo</dt></dl>
26499 <dl><dt>:foo</dt></dl>
26500 <dl><dt>:foo</dt>
26501 <dd>bar</dd></dl>
26502 <dl><dd>:foo</dd></dl>
26503 !! wikitext
26504 ; ;foo
26505
26506 ; <nowiki>:foo</nowiki>
26507
26508 ; <nowiki>:foo</nowiki>
26509 : bar
26510
26511 : :foo
26512 !!end
26513
26514 !! test
26515 Lists: 3. Only bullets at start of text in wikitext-generated HTML should be escaped
26516 !! options
26517 parsoid=html2wt
26518 !! html/parsoid
26519 <ul>
26520 <li>*foo*bar</li>
26521 <li data-parsoid='{}'>*foo<i>it</i>*bar</li>
26522 </ul>
26523 !! wikitext
26524 * *foo*bar
26525 *<nowiki>*foo</nowiki>''it''*bar
26526 !!end
26527
26528 !! test
26529 Lists: 4. No escapes needed
26530 !! options
26531 parsoid=html2wt
26532 !! html/parsoid
26533 <ul>
26534 <li>foo*bar
26535 </li>
26536 </ul>
26537 <ul>
26538 <li><i>foo</i>*bar
26539 </li>
26540 </ul>
26541 <ul>
26542 <li><a rel="mw:WikiLink" href="Foo" title="Foo">Foo</a>: bar
26543 </li>
26544 </ul>
26545 <ul>
26546 <li><a rel="mw:WikiLink" href="Foo" title="Foo">Foo</a>*bar
26547 </li>
26548 </ul>
26549 !! wikitext
26550 *foo*bar
26551
26552 *''foo''*bar
26553
26554 *[[Foo]]: bar
26555
26556 *[[Foo]]*bar
26557 !!end
26558
26559 !! test
26560 Lists: 5. No unnecessary escapes
26561 !! options
26562 parsoid=html2wt
26563 !! html/parsoid
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> ]]bar <span>[[foo]]</span></li></ul>
26568 <ul><li> =bar <span>foo]]</span>=</li></ul>
26569 <ul><li> <s></s>: a</li></ul>
26570 <ul><li> <i>* foo</i></li></ul>
26571
26572 !! wikitext
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><nowiki>[[foo]]</nowiki></span>
26580
26581 * =bar <span>foo]]</span>=
26582
26583 * <s></s>: a
26584
26585 * ''* foo''
26586 !!end
26587
26588 !! test
26589 Lists: 6. Escape bullets in SOL position
26590 !! options
26591 parsoid=html2wt
26592 !! html/parsoid
26593 <p><!--cmt-->*foo</p>
26594 !! wikitext
26595 <!--cmt--><nowiki>*</nowiki>foo
26596 !!end
26597
26598 !! test
26599 Lists: 7. Escape bullets in a multi-line context
26600 !! options
26601 parsoid=html2wt
26602 !! html/parsoid
26603 <p>a
26604 *b
26605 </p>
26606 !! wikitext
26607 a
26608 <nowiki>*</nowiki>b
26609 !!end
26610
26611 !! test
26612 Lists: 8. Escape colons only if not present in tags
26613 !! options
26614 parsoid=html2wt
26615 !! html/parsoid
26616 <dl><dt>a:b<i>c:d</i></dt></dl>
26617 !! wikitext
26618 ; <nowiki>a:b</nowiki>''c:d''
26619 !! end
26620
26621 #### --------------- HRs ---------------
26622 #### 1. Single line
26623 #### -----------------------------------
26624
26625 !! test
26626 HRs: 1. Single line
26627 !! options
26628 parsoid=html2wt
26629 !! html/parsoid
26630 <hr />----
26631 <hr />=foo=
26632 <hr />*foo
26633 !! wikitext
26634 ----<nowiki>----</nowiki>
26635 ----=foo=
26636 ----*foo
26637 !! end
26638
26639 #### --------------- Tables ---------------
26640 #### 1a. Simple example
26641 #### 1b. No escaping needed (!foo)
26642 #### 1c. No escaping needed (|foo)
26643 #### 1d. No escaping needed (|}foo)
26644 ####
26645 #### 2a. Nested in td (<td>foo|bar</td>)
26646 #### 2b. Nested in td (<td>foo||bar</td>)
26647 #### 2c. Nested in td -- no escaping needed(<td>foo!!bar</td>)
26648 ####
26649 #### 3a. Nested in th (<th>foo!bar</th>)
26650 #### 3b. Nested in th (<th>foo!!bar</th>)
26651 #### 3c. Nested in th -- no escaping needed(<th>foo||bar</th>)
26652 ####
26653 #### 4a. Escape -
26654 #### 4b. Escape +
26655 #### 4c. No escaping needed
26656 #### --------------------------------------
26657
26658 !! test
26659 Tables: 1a. Simple example
26660 !! options
26661 parsoid=html2wt
26662 !! html/parsoid
26663 <p>{|
26664 |}
26665 </p>
26666 !! wikitext
26667 <nowiki>{|</nowiki>
26668 |}
26669 !! end
26670
26671 !! test
26672 Tables: 1b. No escaping needed
26673 !! options
26674 parsoid=html2wt
26675 !! html/parsoid
26676 <p>!foo
26677 </p>
26678 !! wikitext
26679 !foo
26680 !! end
26681
26682 !! test
26683 Tables: 1c. No escaping needed
26684 !! options
26685 parsoid=html2wt
26686 !! html/parsoid
26687 <p>|foo
26688 </p>
26689 !! wikitext
26690 |foo
26691 !! end
26692
26693 !! test
26694 Tables: 1d. No escaping needed
26695 !! options
26696 parsoid=html2wt
26697 !! html/parsoid
26698 <p>|}foo
26699 </p>
26700 !! wikitext
26701 |}foo
26702 !! end
26703
26704 !! test
26705 Tables: 2a. Nested in td
26706 !! options
26707 parsoid=html2wt
26708 !! html/parsoid
26709 <table><tbody><tr>
26710 <td>foo|bar</td></tr>
26711 <tr><td>x<div>a|b</div></td>
26712 </tbody></table>
26713 !! wikitext
26714 {|
26715 |<nowiki>foo|bar</nowiki>
26716 |-
26717 |x<div><nowiki>a|b</nowiki></div>
26718 |}
26719 !! html/php+tidy
26720 <table>
26721 <tbody><tr>
26722 <td>foo|bar
26723 </td></tr>
26724 <tr>
26725 <td>x<div>a|b</div>
26726 </td></tr></tbody></table>
26727 !! end
26728
26729 !! test
26730 Tables: 2b. Nested in td
26731 !! options
26732 parsoid=html2wt
26733 !! html/parsoid
26734 <table><tbody><tr>
26735 <td>foo||bar</td>
26736 <td>a<i>b||c</i></td>
26737 <td>a<i><div>b||c</div></i></td>
26738 </tr></tbody></table>
26739 !! wikitext
26740 {|
26741 |<nowiki>foo||bar</nowiki>
26742 |a''<nowiki>b||c</nowiki>''
26743 |a''<div><nowiki>b||c</nowiki></div>''
26744 |}
26745 !! html/php
26746 <table>
26747 <tr>
26748 <td>foo||bar
26749 </td>
26750 <td>a<i>b||c</i>
26751 </td>
26752 <td>a<i><div>b||c</div></i>
26753 </td></tr></table>
26754
26755 !! end
26756
26757 !! test
26758 Tables: 2c. Nested in td -- no escaping needed
26759 !! options
26760 parsoid=html2wt
26761 !! html/*
26762 <table>
26763 <tr>
26764 <td>foo!!bar
26765 </td></tr></table>
26766
26767 !! wikitext
26768 {|
26769 |foo!!bar
26770 |}
26771 !! end
26772
26773 !! test
26774 Tables: 3a. Nested in th
26775 !! options
26776 parsoid=html2wt
26777 !! html/*
26778 <table>
26779 <tr>
26780 <th>foo!bar
26781 </th></tr></table>
26782
26783 !! wikitext
26784 {|
26785 !foo!bar
26786 |}
26787 !! end
26788
26789 !! test
26790 Tables: 3b. Nested in th
26791 !! options
26792 parsoid=html2wt
26793 !! html/parsoid
26794 <table><tbody>
26795 <tr><th>foo!!bar</th>
26796 <th><i>foo|bar</i></th>
26797 <th><i>foo!!bar</i></th>
26798 <th><i><span>foo!!bar</span></i></th>
26799 </tr></tbody></table>
26800 !! wikitext
26801 {|
26802 !<nowiki>foo!!bar</nowiki>
26803 !''<nowiki>foo|bar</nowiki>''
26804 !''<nowiki>foo!!bar</nowiki>''
26805 !''<span><nowiki>foo!!bar</nowiki></span>''
26806 |}
26807 !! html/php
26808 <table>
26809 <tr>
26810 <th>foo!!bar
26811 </th>
26812 <th><i>foo|bar</i>
26813 </th>
26814 <th><i>foo!!bar</i>
26815 </th>
26816 <th><i><span>foo!!bar</span></i>
26817 </th></tr></table>
26818
26819 !! end
26820
26821 !! test
26822 Tables: 3c. Nested in th
26823 !! options
26824 parsoid=html2wt
26825 !! html/parsoid
26826 <table><tbody>
26827 <tr><th>foo||bar</th>
26828 <th><span typeof="mw:Nowiki">foo||bar</span></th>
26829 </tr></tbody></table>
26830 !! wikitext
26831 {|
26832 !<nowiki>foo||bar</nowiki>
26833 !<nowiki>foo||bar</nowiki>
26834 |}
26835 !! html/php
26836 <table>
26837 <tr>
26838 <th>foo||bar
26839 </th>
26840 <th>foo||bar
26841 </th></tr></table>
26842
26843 !! end
26844
26845 !! test
26846 Tables: 4a. Escape -
26847 !! options
26848 parsoid=html2wt
26849 !! html/*
26850 <table>
26851 <tr>
26852 <th>-bar
26853 </th></tr>
26854 <tr>
26855 <td>-bar
26856 </td></tr></table>
26857
26858 !! wikitext
26859 {|
26860 !-bar
26861 |-
26862 |<nowiki>-bar</nowiki>
26863 |}
26864 !! end
26865
26866 !! test
26867 Tables: 4b. Escape +
26868 !! options
26869 parsoid=html2wt
26870 !! html/*
26871 <table>
26872 <tr>
26873 <th>+bar
26874 </th></tr>
26875 <tr>
26876 <td>+bar
26877 </td></tr></table>
26878
26879 !! wikitext
26880 {|
26881 !+bar
26882 |-
26883 |<nowiki>+bar</nowiki>
26884 |}
26885 !! end
26886
26887 !! test
26888 Tables: 4c. No escaping needed
26889 !! options
26890 parsoid=html2wt
26891 !! html/parsoid
26892 <table><tbody>
26893 <tr><td>foo-bar</td><td>foo+bar</td></tr>
26894 <tr><td><i>foo</i>-bar</td><td><i>foo</i>+bar</td></tr>
26895 <tr><td>foo
26896 <p>bar|baz
26897 +bar
26898 -bar</p></td></tr>
26899 <tr><td>x
26900 <div>a|b</div></td>
26901 </tbody></table>
26902 !! wikitext
26903 {|
26904 |foo-bar
26905 |foo+bar
26906 |-
26907 |''foo''-bar
26908 |''foo''+bar
26909 |-
26910 |foo
26911 bar|baz
26912 +bar
26913 -bar
26914 |-
26915 |x
26916 <div>a|b</div>
26917 |}
26918 !! html/php
26919 <table>
26920 <tr>
26921 <td>foo-bar
26922 </td>
26923 <td>foo+bar
26924 </td></tr>
26925 <tr>
26926 <td><i>foo</i>-bar
26927 </td>
26928 <td><i>foo</i>+bar
26929 </td></tr>
26930 <tr>
26931 <td>foo
26932 <p>bar|baz
26933 +bar
26934 -bar
26935 </p>
26936 </td></tr>
26937 <tr>
26938 <td>x
26939 <div>a|b</div>
26940 </td></tr></table>
26941
26942 !! end
26943
26944 !! test
26945 Tables: 4d. No escaping needed
26946 !! options
26947 parsoid=html2wt
26948 !! html/parsoid
26949 <table>
26950 <tbody><tr><td><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a>-bar</td>
26951 <td data-parsoid='{"startTagSrc":"|","attrSepSrc":"|"}'>+1</td>
26952 <td data-parsoid='{"startTagSrc":"|","attrSepSrc":"|"}'>-2</td></tr>
26953 </tbody></table>
26954 !! wikitext
26955 {|
26956 |[[Foo]]-bar
26957 ||+1
26958 ||-2
26959 |}
26960 !! html/php
26961 <table>
26962 <tr>
26963 <td><a href="/wiki/Foo" title="Foo">Foo</a>-bar
26964 </td>
26965 <td>+1
26966 </td>
26967 <td>-2
26968 </td></tr></table>
26969
26970 !! end
26971
26972 !! test
26973 Tables: 4e. Escape }
26974 !! options
26975 parsoid=html2wt
26976 !! html/parsoid
26977 <table>
26978 <tr><td>}</td></tr>
26979 <tr><td>x</td><td data-parsoid='{"stx":"row"}'>}</td></tr></table>
26980 </table>
26981 !! wikitext
26982 {|
26983 |<nowiki>}</nowiki>
26984 |-
26985 |x||}
26986 |}
26987 !! html/php
26988 <table>
26989 <tr>
26990 <td>}
26991 </td></tr>
26992 <tr>
26993 <td>x</td>
26994 <td>}
26995 </td></tr></table>
26996
26997 !! end
26998
26999 !! test
27000 Tables: 5. Empty table cells should get whitespace to avoid need for nowikis
27001 !! options
27002 parsoid=html2wt
27003 !! html/parsoid
27004 <table><tr><td></td><td align="center" data-parsoid='{"stx":"row"}'></td><td data-parsoid='{"stx":"row"}'></td></tr></table>
27005
27006 <table><tr><td></td><td align="center"></td><td></td></tr></table>
27007
27008 <table><tr><td></td><td align="center" data-parsoid='{"stx":"row", "startTagSrc":"{{!}}{{!}}"}'></td><td data-parsoid='{"stx":"row"}'></td></tr></table>
27009
27010 <table><tr><th></th><th align="center" data-parsoid='{"stx":"row"}'></th><th data-parsoid='{"stx":"row"}'></th></tr></table>
27011 !! wikitext
27012 {|
27013 | || align="center" | ||
27014 |}
27015
27016 {|
27017 |
27018 | align="center" |
27019 |
27020 |}
27021
27022 {|
27023 | {{!}}{{!}} align="center" | ||
27024 |}
27025
27026 {|
27027 ! !! align="center" | !!
27028 |}
27029 !! html/php+tidy
27030 <table>
27031 <tbody><tr>
27032 <td></td>
27033 <td align="center"></td>
27034 <td>
27035 </td></tr></tbody></table>
27036 <table>
27037 <tbody><tr>
27038 <td>
27039 </td>
27040 <td align="center">
27041 </td>
27042 <td>
27043 </td></tr></tbody></table>
27044 <table>
27045 <tbody><tr>
27046 <td></td>
27047 <td align="center"></td>
27048 <td>
27049 </td></tr></tbody></table>
27050 <table>
27051 <tbody><tr>
27052 <th></th>
27053 <th align="center"></th>
27054 <th>
27055 </th></tr></tbody></table>
27056 !! end
27057
27058 !! test
27059 T97430: Don't emit empty nowiki pairs around marker meta tags
27060 !! options
27061 parsoid=html2wt
27062 !! html/parsoid
27063 <p>*This is a long sentence here that will make the nowiki algo split up the nowikis into multiple pairs
27064 |** Make this another long long long sentence forcing the nowiki algo to split up the nowikis.</p>
27065 !! wikitext
27066 <nowiki>*</nowiki>This is a long sentence here that will make the nowiki algo split up the nowikis into multiple pairs
27067 |** Make this another long long long sentence forcing the nowiki algo to split up the nowikis.
27068 !! end
27069
27070 !! test
27071 Unclosed xmlish element in table line shouldn't eat end delimiters
27072 !! options
27073 parsoid=html2wt
27074 !! html/parsoid
27075 <table>
27076 <tbody><tr><td> &lt;foo</td>
27077 <td> bar></td></tr>
27078 </tbody></table>
27079 !! wikitext
27080 {|
27081 | <foo
27082 | bar>
27083 |}
27084 !! html/php
27085 <table>
27086 <tr>
27087 <td>&lt;foo
27088 </td>
27089 <td>bar&gt;
27090 </td></tr></table>
27091
27092 !! end
27093
27094 #### --------------- Links ----------------
27095 #### 1. Quote marks in link text
27096 #### 2. Wikilinks: Escapes needed
27097 #### 3. Wikilinks: No escapes needed
27098 #### 4. Extlinks: Escapes needed
27099 #### 5. Extlinks: No escapes needed
27100 #### --------------------------------------
27101 !! test
27102 Links 1. WikiLinks: No escapes needed
27103 !! options
27104 parsoid=html2wt
27105 !! html/parsoid
27106 <p><a rel="mw:WikiLink" href="Foo" title="Foo">Foo<i>boo</i></a>
27107 <a rel="mw:WikiLink" href="Foo" title="Foo">[Foobar]</a>
27108 <a rel="mw:WikiLink" href="Foo" title="Foo">x [Foobar] x</a></p>
27109 !! wikitext
27110 [[Foo|Foo''boo'']]
27111 [[Foo|[Foobar]]]
27112 [[Foo|x [Foobar] x]]
27113 !! html/php
27114 <p><a href="/wiki/Foo" title="Foo">Foo<i>boo</i></a>
27115 <a href="/wiki/Foo" title="Foo">[Foobar]</a>
27116 <a href="/wiki/Foo" title="Foo">x [Foobar] x</a>
27117 </p>
27118 !! end
27119
27120 !! test
27121 Links 2. WikiLinks: Escapes needed
27122 !! options
27123 parsoid=html2wt
27124 !! html/parsoid
27125 <a href="Foo" rel="mw:WikiLink">Foobar]</a>
27126 <a href="Foo" rel="mw:WikiLink">x [http://google.com g] x</a>
27127 <a href="Foo" rel="mw:WikiLink">[[Bar]]</a>
27128 <a href="Foo" rel="mw:WikiLink">x [[Bar]] x</a>
27129 <a href="Foo" rel="mw:WikiLink">|Bar</a>
27130 <a href="Foo" rel="mw:WikiLink">]]bar</a>
27131 <a href="Foo" rel="mw:WikiLink">[[bar</a>
27132 <a href="Foo" rel="mw:WikiLink">x [[ y</a>
27133 <a href="Foo" rel="mw:WikiLink">x ]] y</a>
27134 <a href="Foo" rel="mw:WikiLink">x ]] y [[ z</a>
27135 !! wikitext
27136 [[Foo|<nowiki>Foobar]</nowiki>]]
27137 [[Foo|x <nowiki>[http://google.com g]</nowiki> x]]
27138 [[Foo|<nowiki>[[Bar]]</nowiki>]]
27139 [[Foo|<nowiki>x [[Bar]] x</nowiki>]]
27140 [[Foo|<nowiki>|Bar</nowiki>]]
27141 [[Foo|<nowiki>]]bar</nowiki>]]
27142 [[Foo|<nowiki>[[bar</nowiki>]]
27143 [[Foo|<nowiki>x [[ y</nowiki>]]
27144 [[Foo|<nowiki>x ]] y</nowiki>]]
27145 [[Foo|<nowiki>x ]] y [[ z</nowiki>]]
27146 !! html/php
27147 <p><a href="/wiki/Foo" title="Foo">Foobar]</a>
27148 <a href="/wiki/Foo" title="Foo">x [http://google.com g] x</a>
27149 <a href="/wiki/Foo" title="Foo">[[Bar]]</a>
27150 <a href="/wiki/Foo" title="Foo">x [[Bar]] x</a>
27151 <a href="/wiki/Foo" title="Foo">|Bar</a>
27152 <a href="/wiki/Foo" title="Foo">]]bar</a>
27153 <a href="/wiki/Foo" title="Foo">[[bar</a>
27154 <a href="/wiki/Foo" title="Foo">x [[ y</a>
27155 <a href="/wiki/Foo" title="Foo">x ]] y</a>
27156 <a href="/wiki/Foo" title="Foo">x ]] y [[ z</a>
27157 </p>
27158 !! end
27159
27160 !! test
27161 Links 3. WikiLinks: No escapes needed
27162 !! options
27163 parsoid=html2wt
27164 !! html/parsoid
27165 <p><a rel="mw:WikiLink" href="Foo">[Foobar</a>
27166 <a rel="mw:WikiLink" href="Foo" title="Foo">foo|bar</a></p>
27167 !! wikitext
27168 [[Foo|[Foobar]]
27169 [[Foo|foo|bar]]
27170 !! html/php
27171 <p><a href="/wiki/Foo" title="Foo">[Foobar</a>
27172 <a href="/wiki/Foo" title="Foo">foo|bar</a>
27173 </p>
27174 !! end
27175
27176 !! test
27177 Links 4. ExtLinks: Escapes needed
27178 !! options
27179 parsoid=html2wt
27180 !! html/parsoid
27181 <p><a rel="mw:ExtLink" href="http://google.com">[google]</a>
27182 <a rel="mw:ExtLink" href="http://google.com">google]</a>
27183 <a rel="mw:ExtLink" href="http://google.com">goog] le</a></p>
27184 <p>[http://google.com]</p>
27185 <p>[http://google.com google]</p>
27186 <p>[<a rel="mw:ExtLink" href="http://google.com">http://google.com</a>]</p>
27187 <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>
27188 !! wikitext
27189 [http://google.com <nowiki>[google]</nowiki>]
27190 [http://google.com <nowiki>google]</nowiki>]
27191 [http://google.com <nowiki>goog] le</nowiki>]
27192
27193 <nowiki>[http://google.com]</nowiki>
27194
27195 <nowiki>[http://google.com google]</nowiki>
27196
27197 [http://google.com<nowiki>]</nowiki>
27198
27199 [{{echo|http://google.com}}<nowiki>]</nowiki>
27200 !! html/php
27201 <p><a rel="nofollow" class="external text" href="http://google.com">[google]</a>
27202 <a rel="nofollow" class="external text" href="http://google.com">google]</a>
27203 <a rel="nofollow" class="external text" href="http://google.com">goog] le</a>
27204 </p><p>[http://google.com]
27205 </p><p>[http://google.com google]
27206 </p><p>[<a rel="nofollow" class="external free" href="http://google.com">http://google.com</a>]
27207 </p><p>[<a rel="nofollow" class="external free" href="http://google.com">http://google.com</a>]
27208 </p>
27209 !! end
27210
27211 !! test
27212 Links 5. ExtLinks: No escapes needed
27213 !! options
27214 parsoid=html2wt
27215 !! html/parsoid
27216 <p><a rel="mw:ExtLink" href="http://google.com">[google</a></p>
27217 <p>[<a ref="mw:ExtLink" href="http://google.com"></a>]</p>
27218 !! wikitext
27219 [http://google.com [google]
27220
27221 [[http://google.com]]
27222 !! html/php
27223 <p><a rel="nofollow" class="external text" href="http://google.com">[google</a>
27224 </p><p>[<a rel="nofollow" class="external autonumber" href="http://google.com">[1]</a>]
27225 </p>
27226 !! end
27227
27228 !! test
27229 Links 6. Add <nowiki/>s between text-nodes and url-links when required (T66300)
27230 !! options
27231 parsoid=html2wt
27232 !! html/parsoid
27233 <p>x<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>y
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>&amp;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" data-parsoid='{"stx":"url"}'>http://example.com</a>=x
27244 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>(x)
27245 <a rel="mw:ExtLink" href="http://example.com(x" data-parsoid='{"stx":"url"}'>http://example.com(x</a>)
27246 </p>
27247 !! wikitext
27248 x<nowiki/>http://example.com<nowiki/>y
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<nowiki/>=x
27259 http://example.com<nowiki/>(x)
27260 http://example.com(x<nowiki/>)
27261 !! end
27262
27263 !! test
27264 Links 7a. Don't add spurious <nowiki/>s between text-nodes and url-links (T66300)
27265 !! options
27266 parsoid=html2wt
27267 !! html/parsoid
27268 <p>x
27269 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>
27270 y
27271 "<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>"
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 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>,
27275 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>, foo
27276 </p>
27277 !! wikitext
27278 x
27279 http://example.com
27280 y
27281 "http://example.com"
27282 (http://example.com)
27283 (http://example.com) foo
27284 http://example.com,
27285 http://example.com, foo
27286 !! html/php
27287 <p>x
27288 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
27289 y
27290 "<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>"
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 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>,
27294 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>, foo
27295 </p>
27296 !! end
27297
27298 !! test
27299 Links 7b. Don't add spurious <nowiki/>s between text-nodes and url-links (T66300)
27300 !! options
27301 parsoid=html2wt
27302 !! html/parsoid
27303 <p><a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>.,;:!?\
27304 -<a rel="mw:ExtLink" href="http://example.com">http://example.com</a>:</p>
27305 !! wikitext
27306 http://example.com.,;:!?\
27307 -http://example.com:
27308 !! html/php
27309 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>.,;:!?\
27310 -<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>:
27311 </p>
27312 !! end
27313
27314 !! test
27315 Links 8. Add <nowiki/>s between text-nodes and RFC-links when required (T66300)
27316 !! options
27317 parsoid=html2wt
27318 !! html/parsoid
27319 <p><a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>4
27320 <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y
27321 X<a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y</p>
27322 !! wikitext
27323 RFC 123<nowiki/>4
27324 RFC 123<nowiki/>y
27325 X<nowiki/>RFC 123<nowiki/>y
27326 !! end
27327
27328 !! test
27329 Links 9. Don't add spurious <nowiki/>s between text-nodes and RFC-links (T66300)
27330 !! options
27331 parsoid=html2wt
27332 !! html/parsoid
27333 <p><a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>?foo
27334 <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>&amp;foo
27335 -<a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>-
27336 </p>
27337 !! wikitext
27338 RFC 123?foo
27339 RFC 123&foo
27340 -RFC 123-
27341 !! html/php
27342 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>?foo
27343 <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>&amp;foo
27344 -<a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>-
27345 </p>
27346 !! end
27347
27348 !! test
27349 Links 10. Add <nowiki/>s between text-nodes and PMID-links when required (T66300)
27350 !! options
27351 parsoid=html2wt
27352 !! html/parsoid
27353 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>4
27354 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>y
27355 X<a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>y
27356 !! wikitext
27357 PMID 123<nowiki/>4
27358 PMID 123<nowiki/>y
27359 X<nowiki/>PMID 123<nowiki/>y
27360 !! end
27361
27362 !! test
27363 Links 11. Don't add spurious <nowiki/>s between text-nodes and PMID-links (T66300)
27364 !! options
27365 parsoid=html2wt
27366 !! html/parsoid
27367 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>?foo
27368 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>&foo
27369 -<a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>-
27370 </p>
27371 !! wikitext
27372 PMID 123?foo
27373 PMID 123&foo
27374 -PMID 123-
27375 !! html/php
27376 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>?foo
27377 <a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>&amp;foo
27378 -<a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>-
27379 </p>
27380 !! end
27381
27382 !! test
27383 Links 12. Add <nowiki/>s between text-nodes and ISBN-links when required (T66300)
27384 !! options
27385 parsoid=html2wt
27386 !! html/parsoid
27387 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>1
27388 <a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>x
27389 a<a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>b
27390 </p>
27391 !! wikitext
27392 ISBN 1234567890<nowiki/>1
27393 ISBN 1234567890<nowiki/>x
27394 a<nowiki/>ISBN 1234567890<nowiki/>b
27395 !! end
27396
27397 !! test
27398 Links 13. Don't add spurious <nowiki/>s between text-nodes and ISBN-links (T66300)
27399 !! options
27400 parsoid=html2wt
27401 !! html/parsoid
27402 <p>-<a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>'s
27403 !! wikitext
27404 -ISBN 1234567890's
27405 !! html/php
27406 <p>-<a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>'s
27407 </p>
27408 !! end
27409
27410 !! test
27411 Links 14. Protect link-like plain text. (Parsoid bug T78425)
27412 !! options
27413 parsoid=html2wt
27414 !! html/*
27415 <p>this is not a link: http://example.com
27416 </p>
27417 !! wikitext
27418 this is not a link: <nowiki>http://example.com</nowiki>
27419 !! end
27420
27421 !! test
27422 Links 15. Link trails can't become link prefixes.
27423 !! options
27424 language=is
27425 parsoid=html2wt
27426 !! html/parsoid
27427 <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>
27428 !! wikitext
27429 [[Söfnuður]]-[[00]]
27430 !! html/php
27431 <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>
27432 </p>
27433 !! end
27434
27435 #### --------------- Quotes ---------------
27436 #### 1. Quotes inside <b> and <i>
27437 #### 2. Link fragments separated by <i> and <b> tags
27438 #### 3. Link fragments inside <i> and <b>
27439 #### 4. No escaping needed
27440 #### --------------------------------------
27441 !! test
27442 1a. Quotes inside <b> and <i>
27443 !! options
27444 parsoid=html2wt
27445 !! html/*
27446 <p><i>'foo'</i>
27447 <i>''foo''</i>
27448 <i>'''foo'''</i>
27449 <i>foo</i>'s
27450 <b>'foo'</b>
27451 <b>''foo''</b>
27452 <b>'''foo'''</b>
27453 <b>foo'<i>bar'</i>baz</b>
27454 <b>foo</b>'s
27455 '<i>foo</i>
27456 <i>foo</i>'
27457 <i>foo'</i>'
27458 '<i>foo</i>'
27459 '<b>foo</b>
27460 <b>foo</b>'
27461 '<b>foo</b>'
27462 <i>fools'<span> errand</span></i>
27463 <i><span>fool</span>'s errand</i>
27464 '<i>foo</i> bar '<i>baz</i>
27465 a|!*#-:;+-~[]{}b'<i>x</i>
27466 </p>
27467 !! wikitext
27468 ''<nowiki/>'foo'''
27469 ''<nowiki>''foo''</nowiki>''
27470 ''<nowiki>'''foo'''</nowiki>''
27471 ''foo''<nowiki/>'s
27472 '''<nowiki/>'foo''''
27473 '''<nowiki>''foo''</nowiki>'''
27474 '''<nowiki>'''foo'''</nowiki>'''
27475 '''foo'<nowiki/>''bar'<nowiki/>''baz'''
27476 '''foo'''<nowiki/>'s
27477 '''foo''
27478 ''foo''<nowiki/>'
27479 ''foo'''<nowiki/>'
27480 '''foo''<nowiki/>'
27481 ''''foo'''
27482 '''foo'''<nowiki/>'
27483 ''''foo'''<nowiki/>'
27484 ''fools'<span> errand</span>''
27485 ''<span>fool</span>'s errand''
27486 '<nowiki/>''foo'' bar '''baz''
27487 a|!*#-:;+-~[]{}b'''x''
27488 !! end
27489
27490 !! test
27491 1b. Quotes inside <b> and <i> with other tags on same line
27492 !! options
27493 parsoid=html2wt
27494 !! html/parsoid
27495 '<i>a</i> foo <i><a rel="mw:WikiLink" href="Bar" title="Bar">bar</a></i>
27496 <i>a'</i> foo <i><a rel="mw:WikiLink" href="Bar" title="Bar">bar</a></i>
27497 <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>
27498 <a rel="mw:WikiLink" href="Foo" title="Foo">foo</a> x'<i><a href="Bar" rel="mw:WikiLink" title="Bar">bar</a></i>
27499 '<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>
27500 '<i>foo</i> <div title="name">test</div>
27501 '<i>foo</i> and <br data-parsoid='{"stx":"html","noClose":true}'/> bar
27502 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt5" data-mw='{"name":"references","attrs":{}}'>
27503 <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>
27504 </ol>
27505 !! wikitext
27506 '''a'' foo ''[[bar]]''
27507 ''a''' foo ''[[bar]]''
27508 ''a''' foo '''{{echo|[[bar]]}}'''
27509 [[foo]] x'''[[bar]]''
27510 '''foo'' <ref>test</ref>
27511 '''foo'' <div title="name">test</div>
27512 '''foo'' and <br> bar
27513 <references />
27514 !! end
27515
27516 !! test
27517 2. Link fragments separated by <i> and <b> tags
27518 !! options
27519 parsoid=html2wt
27520 !! html/parsoid
27521 <p>[[<i>foo</i>hello]]</p>
27522 <p>[[<b>foo</b>hello]]</p>
27523 !! wikitext
27524 [[''foo''<nowiki>hello]]</nowiki>
27525
27526 [['''foo'''<nowiki>hello]]</nowiki>
27527 !! end
27528
27529 # FIXME: Escaping one or both of [[ and ]] is also acceptable --
27530 # this is one of the shortcomings of this format
27531 !! test
27532 3. Link fragments inside <i> and <b>
27533 !! options
27534 parsoid=html2wt
27535 !! html/parsoid
27536 <p><i>[[foo</i>]]</p>
27537 <p><b>[[foo</b>]]</p>
27538 !! wikitext
27539 ''[[foo''<nowiki>]]</nowiki>
27540
27541 '''[[foo'''<nowiki>]]</nowiki>
27542 !! end
27543
27544 !! test
27545 4. No escaping needed
27546 !! options
27547 parsoid=html2wt
27548 !! html/parsoid
27549 <p>'<span><i>bar</i></span>'
27550 '<span><b>bar</b></span>'
27551 'a:b'foo
27552 </p>
27553 !! wikitext
27554 '<span>''bar''</span>'
27555 '<span>'''bar'''</span>'
27556 'a:b'foo
27557 !! end
27558
27559 #### ----------- Paragraphs ---------------
27560 #### 1. No unnecessary escapes
27561 #### --------------------------------------
27562
27563 !! test
27564 1. No unnecessary escapes
27565 !! options
27566 parsoid=html2wt
27567 !! html/parsoid
27568 <p>bar <span>[[foo]]</span>
27569 </p><p>=bar <span>[[foo]]</span>
27570 </p><p>[[bar <span>[[foo]]</span>
27571 </p><p>]]bar <span>[[foo]]</span>
27572 </p><p>=bar <span>foo]]</span>=
27573 </p>
27574 !! wikitext
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><nowiki>[[foo]]</nowiki></span>
27582
27583 =bar <span>foo]]</span><nowiki>=</nowiki>
27584 !!end
27585
27586 #### ----------------------- PRE --------------------------
27587 !! test
27588 1. Leading whitespace in SOL context should be escaped
27589 !! options
27590 parsoid=html2wt
27591 !! html/parsoid
27592 <p> a</p>
27593
27594 <p> a</p>
27595
27596 <p> a(tab)</p>
27597
27598 <p> a
27599 <!--cmt-->
27600 a</p>
27601
27602 <p>a
27603 b</p>
27604
27605 <p>a
27606 b</p>
27607
27608 <p>a
27609 b</p>
27610 !! wikitext
27611 <nowiki> </nowiki>a
27612
27613 <nowiki> </nowiki> a
27614
27615 a(tab)
27616
27617 <nowiki> </nowiki> a
27618 <!--cmt-->
27619 <nowiki> </nowiki>a
27620
27621 a
27622 <nowiki> </nowiki>b
27623
27624 a
27625 b
27626
27627 a
27628 b
27629 !! html/php
27630 <p> a
27631 </p><p> a
27632 </p><p> a(tab)
27633 </p><p> a
27634 a
27635 </p><p>a
27636 b
27637 </p><p>a
27638 b
27639 </p><p>a
27640 b
27641 </p>
27642 !! end
27643
27644 !! test
27645 2. Leading whitespace in non-indent-pre contexts should not be escaped
27646 !! options
27647 parsoid=html2wt
27648 !! html/parsoid
27649 <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>
27650 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt4" data-mw='{"name":"references","attrs":{}}'>
27651 <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>
27652 b</span></li>
27653 </ol>
27654 !! wikitext
27655 foo <ref>''a''
27656 b</ref>
27657 <references />
27658 !! end
27659
27660 !! test
27661 3. Leading whitespace in indent-pre suppressing contexts should not be escaped
27662 !! options
27663 parsoid=html2wt
27664 !! html/parsoid
27665 <blockquote>
27666 <p>
27667 a
27668 <span>b</span>
27669 c</p>
27670 </blockquote>
27671 !! wikitext
27672 <blockquote>
27673 a
27674 <span>b</span>
27675 c
27676 </blockquote>
27677 !! end
27678
27679 !! test
27680 4. Leading whitespace in indent-pre suppressing contexts should not be escaped
27681 !! options
27682 parsoid=html2wt
27683 !! html/parsoid
27684 <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>
27685 !! wikitext
27686 [[File:Foobar.jpg|thumb|caption]]
27687 !! end
27688
27689 !! test
27690 5. Nowiki escaping should account for indent-pres
27691 !! options
27692 parsoid=html2wt
27693 !! html/parsoid
27694 <pre>==foo==</pre>
27695 !! wikitext
27696 ==foo==
27697 !! end
27698
27699 !! test
27700 T95794: nowiki escaping should account for leading space at start-of-line in an indent-pre block
27701 !! options
27702 parsoid=html2wt
27703 !! html/parsoid
27704 <pre>
27705 * foo
27706 * bar
27707 </pre>
27708 !! wikitext
27709 * foo
27710 * bar
27711 !! end
27712
27713 !! test
27714 Whitespace scrubbing in SOL position should account for SOL-sensitive wikitext markup
27715 !! options
27716 parsoid = {
27717 "modes": ["html2wt"],
27718 "scrubWikitext": true
27719 }
27720 !! html/parsoid
27721 <p> foo</p>
27722 <p> %foo</p>
27723 <p> *foo</p>
27724 <p> #foo</p>
27725 <p> =foo=</p>
27726 <p><link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid="{}"> *foo</p>
27727 <p> <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid="{}">*foo</p>
27728 <p> <!--boo-->*foo</p>
27729 <p><!--boo--> *foo</p>
27730 <p><!--a--> <!--b--> <!--c--> <!--d--> <!--e--> foo</p>
27731 <p><!--a--> <!--b--> <!--c--> <!--d--> <!--e--> *foo</p>
27732 !! wikitext
27733 foo
27734
27735 %foo
27736
27737 <nowiki/>*foo
27738
27739 <nowiki/>#foo
27740
27741 <nowiki/>=foo=
27742
27743 [[Category:Foo]]
27744 <nowiki/>*foo
27745
27746 [[Category:Foo]]
27747 <nowiki>*</nowiki>foo
27748
27749 <nowiki/><!--boo-->*foo
27750
27751 <!--boo--><nowiki/>*foo
27752
27753 <!--a--><!--b--><!--c--><!--d--><!--e-->foo
27754
27755 <!--a--><nowiki/><!--b--><!--c--><!--d--><!--e-->*foo
27756 !! end
27757
27758 #### --------------- Behavior Switches --------------------
27759
27760 !! test
27761 1. Valid behavior switches should be escaped
27762 !! options
27763 parsoid=html2wt
27764 !! html/parsoid
27765 __TOC__
27766 <i>__TOC__</i>
27767 !! wikitext
27768 <nowiki>__TOC__</nowiki>
27769 ''<nowiki>__TOC__</nowiki>''
27770 !! end
27771
27772 !! test
27773 2. Invalid behavior switches should not be escaped
27774 !! options
27775 parsoid=html2wt
27776 !! html/parsoid
27777 __TOO__
27778 __|__
27779 !! wikitext
27780 __TOO__
27781 __|__
27782 !! end
27783
27784 # We use indent-pre as an indirect way to test for sol-transparent behavior.
27785 !! test
27786 Behavior switches should be SOL-transparent
27787 !! options
27788 parsoid=html2wt
27789 !! html/parsoid
27790 <meta property="mw:PageProp/toc" />
27791
27792 <!-- this one's bogus -->
27793 <pre>__TOO__</pre>
27794
27795 <pre data-parsoid='{}'><meta property="mw:PageProp/toc" data-parsoid='{"src":"__TOC__","magicSrc":"__TOC__"}'/> foo</pre>
27796
27797 <meta property="mw:PageProp/toc" data-parsoid='{"src":"__TOC__","magicSrc":"__TOC__"}'/><pre data-parsoid='{}'>bar</pre>
27798 !! wikitext
27799 __TOC__
27800
27801 <!-- this one's bogus -->
27802 __TOO__
27803
27804 __TOC__ foo
27805
27806 __TOC__
27807 bar
27808 !! end
27809
27810 #### --------------- HTML tags ---------------
27811 #### 1. a tags
27812 #### 2. other tags
27813 #### 3. multi-line html tag
27814 #### 4. extension tags
27815 #### -----------------------------------------
27816 !! test
27817 1. a tags
27818 !! options
27819 parsoid=html2wt
27820 !! html/parsoid
27821 &lt;a href=&quot;http://google.com&quot;&gt;google&lt;/a&gt;
27822 !! wikitext
27823 <a href="http://google.com">google</a>
27824 !! end
27825
27826 !! test
27827 2. other tags
27828 !! options
27829 parsoid=html2wt
27830 !! html/parsoid
27831 <ul><li> &lt;div&gt;foo&lt;/div&gt;</li>
27832 <li> &lt;div style=&quot;color:red&quot;&gt;foo&lt;/div&gt;</li>
27833 <li> &lt;td&gt;</li></ul>
27834
27835 !! wikitext
27836 * <nowiki><div>foo</div></nowiki>
27837 * <nowiki><div style="color:red">foo</div></nowiki>
27838 * <nowiki><td></nowiki>
27839 !! end
27840
27841 !! test
27842 3. multi-line html tag
27843 !! options
27844 parsoid=html2wt
27845 !! html/parsoid
27846 <p>&lt;div
27847 &gt;foo&lt;/div
27848 &gt;
27849 </p>
27850 !! wikitext
27851 <nowiki><div
27852 >foo</div
27853 ></nowiki>
27854 !! end
27855
27856 !! test
27857 4. extension tags
27858 !! options
27859 parsoid=html2wt
27860 !! html/parsoid
27861 <p>&lt;ref&gt;foo&lt;/ref&gt;
27862 </p><p>&lt;ref&gt;bar
27863 </p><p>baz&lt;/ref&gt;
27864 </p>
27865 !! wikitext
27866 <nowiki><ref>foo</ref></nowiki>
27867
27868 <nowiki><ref>bar</nowiki>
27869
27870 baz<nowiki></ref></nowiki>
27871 !! end
27872
27873 !! test
27874 Parsoid: newline inducing block nodes don't suppress <nowiki>
27875 !! options
27876 parsoid=html2wt
27877 !! html/parsoid
27878 a<h1>foo</h1>
27879 !! wikitext
27880 <nowiki> </nowiki>a
27881
27882 = foo =
27883 !! end
27884
27885 #### --------------- Others ---------------
27886 !! test
27887 Escaping nowikis
27888 !! options
27889 parsoid=html2wt
27890 !! html/parsoid
27891 <p>&lt;nowiki&gt;foo&lt;/nowiki&gt;
27892 </p>
27893 !! wikitext
27894 &lt;nowiki&gt;foo&lt;/nowiki&gt;
27895 !! end
27896
27897 ## The quote-char in the input is necessary for triggering the bug
27898 !! test
27899 (T54035) Nowiki-escaping should not get tripped by " :" in text
27900 !! options
27901 parsoid=html2wt
27902 !! html/parsoid
27903 <p>foo's bar :</p>
27904 !! wikitext
27905 foo's bar :
27906 !! end
27907
27908 #----------- End of wikitext escaping tests --------------
27909
27910 !! test
27911
27912 Tag-like HTML structures are passed through as text
27913 !! wikitext
27914 <x y>
27915
27916 <x.y>
27917
27918 <x-y>
27919
27920 1>2
27921
27922 x<y
27923
27924 a>b
27925
27926 1<d e>f
27927 !! html
27928 <p>&lt;x y&gt;
27929 </p><p>&lt;x.y&gt;
27930 </p><p>&lt;x-y&gt;
27931 </p><p>1&gt;2
27932 </p><p>x&lt;y
27933 </p><p>a&gt;b
27934 </p><p>1&lt;d e&gt;f
27935 </p>
27936 !! end
27937
27938 !! test
27939 HTML tag with necessary entities in attributes
27940 !! wikitext
27941 <span title="&amp;amp;">foo</span>
27942 !! html
27943 <p><span title="&amp;amp;">foo</span>
27944 </p>
27945 !! end
27946
27947 !! test
27948 HTML tag with 'unnecessary' entity encoding in attributes
27949 !! wikitext
27950 <span title="&amp;">foo</span>
27951 !! html
27952 <p><span title="&amp;">foo</span>
27953 </p>
27954 !! end
27955
27956 !! test
27957 HTML tag with broken attribute value quoting
27958 !! options
27959 parsoid=wt2html,html2html
27960 !! wikitext
27961 <span title="Hello world>Foo</span>
27962 !! html/php
27963 <p><span title="Hello world">Foo</span>
27964 </p>
27965 !! html/parsoid
27966 <p><span title="Hello world">Foo</span></p>
27967 !! end
27968
27969 !! test
27970 Self-closed tag with broken attribute value quoting
27971 !! options
27972 parsoid=wt2html,html2html
27973 !! wikitext
27974 <div title="Hello world />Foo
27975 !! html/php+tidy
27976 <div title="Hello world"></div><p>Foo
27977 </p>
27978 !! html/parsoid
27979 <div title="Hello world " data-parsoid='{"stx":"html","selfClose":true}'></div><p>Foo</p>
27980 !! end
27981
27982 !! test
27983 Table with broken attribute value quoting
27984 !! options
27985 parsoid=wt2html,html2html
27986 !! wikitext
27987 {|
27988 | title="Hello world|Foo
27989 |}
27990 !! html/php
27991 <table>
27992 <tr>
27993 <td title="Hello world">Foo
27994 </td></tr></table>
27995
27996 !! html/parsoid
27997 <table>
27998 <tr>
27999 <td title="Hello world">Foo
28000 </td></tr></table>
28001
28002 !! end
28003
28004 !! test
28005 Table with broken attribute value quoting on consecutive lines
28006 !! options
28007 parsoid=wt2html,html2html
28008 !! wikitext
28009 {|
28010 | title="Hello world|Foo
28011 | style="color:red|Bar
28012 |}
28013 !! html/php
28014 <table>
28015 <tr>
28016 <td title="Hello world">Foo
28017 </td>
28018 <td style="color:red">Bar
28019 </td></tr></table>
28020
28021 !! html/parsoid
28022 <table><tbody>
28023 <tr>
28024 <td title="Hello world">Foo
28025 </td><td style="color: red">Bar
28026 </td></tr></tbody></table>
28027
28028 !! end
28029
28030 !!test
28031 Accept empty td cell attribute
28032 !! wikitext
28033 {|
28034 | align="center" |foo|| |
28035 |}
28036 !! html
28037 <table>
28038 <tr>
28039 <td align="center">foo</td>
28040 <td>
28041 </td></tr></table>
28042
28043 !!end
28044
28045 !!test
28046 Non-empty attributes in th-cells
28047 !! wikitext
28048 {|
28049 !Foo!! style="color: red" |Bar
28050 |}
28051 !! html
28052 <table>
28053 <tr>
28054 <th>Foo</th>
28055 <th style="color: red">Bar
28056 </th></tr></table>
28057
28058 !!end
28059
28060 !!test
28061 Accept empty attributes in th-cells
28062 !! wikitext
28063 {|
28064 !|foo!!|bar
28065 |}
28066 !! html
28067 <table>
28068 <tr>
28069 <th>foo</th>
28070 <th>bar
28071 </th></tr></table>
28072
28073 !!end
28074
28075 !!test
28076 Empty table rows go away
28077 !! wikitext
28078 {|
28079 |Hello
28080 |there
28081 |- class="foo"
28082 |-
28083 |}
28084 !! html
28085 <table>
28086 <tr>
28087 <td>Hello
28088 </td>
28089 <td>there
28090 </td></tr>
28091
28092 </table>
28093
28094 !! end
28095
28096 ###
28097 ### Parsoid-centric tests for testing RTing of inter-element separators
28098 ### Edge cases not tested by existing parser tests and specific to
28099 ### Parsoid-specific serialization strategies.
28100 ###
28101
28102 !!test
28103 RT-ed inter-element separators should be valid separators
28104 !! wikitext
28105 {|
28106 |- [[foo]]
28107 |}
28108 !! html/php
28109 <table>
28110
28111 </table>
28112
28113 !! html/parsoid
28114 <table>
28115 <tbody><tr class='mw-empty-elt' data-parsoid='{"startTagSrc":"|-","a":{"[[foo]]":null},"sa":{"[[foo]]":""},"autoInsertedEnd":true}'></tr>
28116 </tbody></table>
28117 !!end
28118
28119 # Parsoid-only test of a DOM pass
28120 !!test
28121 Trailing newlines in a deep dom-subtree that ends a wikitext line should be migrated out
28122 !! wikitext
28123 {|
28124 |<small>foo
28125 bar
28126 |}
28127
28128 {|
28129 |<small>foo<small>
28130 |}
28131 !! html/parsoid
28132 <table>
28133 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'><small data-parsoid='{"stx":"html","autoInsertedEnd":true}'>foo
28134 <p>bar</p></small></td></tr>
28135 </tbody></table>
28136
28137 <table>
28138 <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>
28139 </tbody></table>
28140 !!end
28141
28142 # Note that the "style" attribute is really a template parameter here.
28143 # The = would have to be {{=}} if you wanted the literal.
28144 !!test
28145 Empty TD followed by TD with tpl-generated attribute
28146 !! wikitext
28147 {|
28148 |-
28149 |
28150 |{{echo|style='color:red'}}|foo
28151 |}
28152 !! html
28153 <table>
28154
28155 <tr>
28156 <td>
28157 </td>
28158 <td>foo
28159 </td></tr></table>
28160
28161 !!end
28162
28163 !!test
28164 Indented table with an empty td
28165 !! wikitext
28166 {|
28167 |-
28168 |
28169 |foo
28170 |}
28171 !! html
28172 <table>
28173
28174 <tr>
28175 <td>
28176 </td>
28177 <td>foo
28178 </td></tr></table>
28179
28180 !!end
28181
28182 !! test
28183 Indented table with blank lines in between (T85627)
28184 !! wikitext
28185 {|
28186 |foo
28187
28188
28189 |}
28190 !! html/php
28191 <table>
28192 <tr>
28193 <td>foo
28194 <p><br />
28195 </p>
28196 </td></tr></table>
28197
28198 !! html/parsoid
28199 <table>
28200 <tbody><tr><td>foo
28201 <p>
28202 <br /></p></td></tr>
28203 </tbody></table>
28204 !! end
28205
28206 !!test
28207 Indented block & table
28208 !! wikitext
28209 <div>foo</div>
28210 {|
28211 |foo
28212 |}
28213 !! html/php
28214 <div>foo</div>
28215 <table>
28216 <tr>
28217 <td>foo
28218 </td></tr></table>
28219
28220 !! html/parsoid
28221 <div data-parsoid='{"stx":"html"}'>foo</div>
28222 <table><tbody>
28223 <tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'>foo</td></tr>
28224 </tbody></table>
28225 !!end
28226
28227 !! test
28228 Indent and comment before table row
28229 !! wikitext
28230 {|
28231 <!--hi-->|-
28232 |there
28233 |}
28234 !! html/php
28235 <table>
28236
28237 <tr>
28238 <td>there
28239 </td></tr></table>
28240
28241 !! html/parsoid
28242 <table>
28243 <!--hi--><tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
28244 <td data-parsoid='{"autoInsertedEnd":true}'> there</td></tr>
28245 </tbody></table>
28246 !! end
28247
28248 # PHP parser omits empty TR
28249 !!test
28250 Empty TR followed by a template-generated TR
28251 !! wikitext
28252 {|
28253 |-
28254 {{echo|<tr><td>foo</td></tr>}}
28255 |}
28256 !! html/php+tidy
28257 <table>
28258
28259 <tbody><tr><td>foo</td></tr>
28260 </tbody></table>
28261 !! html/parsoid
28262 <table>
28263 <tbody>
28264 <tr class='mw-empty-elt'></tr>
28265 <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}}]}'>
28266 <td>foo</td></tr>
28267 </tbody></table>
28268 !!end
28269
28270 ## PHP and parsoid output differ for this; as usual PHP omits empty
28271 ## elements, and since it strips the comments the TR is empty.
28272 !!test
28273 Empty TR followed by mixed-ws-comment line should RT correctly
28274 !! wikitext
28275 {|
28276 |-
28277 <!--c-->
28278 |-
28279 <!--c--> <!--d-->
28280 |}
28281 !! html/php+tidy
28282 <table>
28283
28284
28285 </table>
28286 !! html/parsoid
28287 <table>
28288 <tbody>
28289 <tr class='mw-empty-elt'></tr>
28290 <!--c-->
28291 <tr>
28292 <!--c--> </tr><!--d-->
28293 </tbody></table>
28294
28295 !!end
28296
28297 !!test
28298 Multi-line image caption generated by templates with/without trailing newlines
28299 !! wikitext
28300 [[File:Foobar.jpg|thumb|300x300px|foo\n{{echo|A}}\n{{echo|B}}\n{{echo|C}}]]
28301 [[File:Foobar.jpg|thumb|300x300px|foo\n{{echo|A}}\n{{echo|B}}\n{{echo|C}}\n\n]]
28302 !! html/parsoid
28303 <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>
28304 <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>
28305 !!end
28306
28307 !! test
28308 New element inserted (without intervening newlines) after an old sol-transparent node should serialize correctly
28309 !! options
28310 parsoid=html2wt
28311 !! html/parsoid
28312 <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>
28313
28314 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{}'/><h1>new heading</h1>
28315 !! wikitext
28316 <includeonly>foo</includeonly>
28317 new para
28318
28319 [[Category:Foo]]
28320
28321 = new heading =
28322 !! end
28323
28324 ## PHP emits broken html for this, and since this is primarily
28325 ## a Parsoid serializer test, marking this Parsoid only
28326 !!test
28327 Improperly nested inline or quotes tags with whitespace in between
28328 !! wikitext
28329 <span> <s>x</span> </s>
28330 ''' ''x''' ''
28331 !! html/parsoid
28332 <p><span> <s>x</s></span><s> </s>
28333 <b> <i>x</i></b><i> </i>
28334 </p>
28335 !!end
28336
28337 !!test
28338 Encapsulate protected attributes from wt
28339 !! wikitext
28340 <div typeof="mw:placeholder stuff" data-mw="whoo" data-parsoid="weird" data-parsoid-other="no" about="time" rel="mw:true">foo</div>
28341
28342 {| typeof="mw:placeholder stuff" data-mw="whoo" data-parsoid="weird" data-parsoid-other="no" about="time" rel="mw:true"
28343 |ok
28344 |}
28345 !! html/parsoid
28346 <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>
28347
28348 <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">
28349 <tbody><tr><td data-parsoid='{"autoInsertedEnd":true}'>ok</td></tr>
28350 </tbody></table>
28351 !!end
28352
28353 ## Currently the p-wrapper is fragile in how it adds / removes transformations.
28354 ## Having nested or stray pre tags results in the attempt to add duplicates,
28355 ## causing an assertion fail. This test tries to prevent that situation.
28356 !! test
28357 Ensure ParagraphWrapper can deal with stray closing pre tags
28358 !! options
28359 parsoid=wt2html
28360 !! wikitext
28361 plain text</pre>
28362 !! html/parsoid
28363 <p>plain text</p>
28364 !! end
28365
28366 ## Remex doesn't account for fostered content.
28367 !! test
28368 1. Ensure fostered text content is wrapped in element nodes
28369 !! options
28370 parsoid=wt2html
28371 !! wikitext
28372 <table>hi</table><table>ho</table>
28373 !! html/php+tidy
28374 hi<table></table>ho<table></table>
28375 !! html/parsoid
28376 <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>
28377 !! end
28378
28379 ## Remex doesn't account for fostered content.
28380 !! test
28381 2. Ensure fostered text content is wrapped in element nodes (traps regressions around fostered marker on the element getting lost)
28382 !! options
28383 parsoid=wt2html,wt2wt
28384 !! wikitext
28385 <table>
28386 <tr> || ||
28387 <td> a
28388 </table>
28389 !! html/php+tidy
28390 || ||
28391 <table>
28392 <tbody><tr><td> a
28393 </td></tr></tbody></table>
28394 !! html/parsoid
28395 <p data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true}'> || ||</p>
28396 <table data-parsoid='{"stx":"html"}'>
28397 <tbody><tr data-parsoid='{"stx":"html","autoInsertedEnd":true}'><td data-parsoid='{"stx":"html","autoInsertedEnd":true}'> a
28398 </td></tr></tbody></table>
28399 !! end
28400
28401 ## Remex doesn't account for fostered content.
28402 !! test
28403 Encapsulation properly handles null DSR information from foster box
28404 !! options
28405 parsoid=wt2html,wt2wt
28406 !! wikitext
28407 {{echo|<table>foo<tr><td>bar</td></tr></table>}}
28408 !! html/parsoid
28409 <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>
28410 !! end
28411
28412 ## Remex doesn't account for fostered content.
28413 !! test
28414 1. Encapsulate foster-parented transclusion content
28415 !! options
28416 parsoid=wt2wt,wt2html
28417 !! wikitext
28418 <table>{{echo|foo<tr><td>bar</td></tr>}}</table>
28419 !! html/php+tidy
28420 foo<table><tbody><tr><td>bar</td></tr></tbody></table>
28421 !! html/parsoid
28422 <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>
28423 !! end
28424
28425 !! test
28426 2. Encapsulate foster-parented transclusion content
28427 !! options
28428 parsoid=wt2wt,wt2html
28429 !! wikitext
28430 <table><div>{{echo|foo}}</div><tr><td>bar</td></tr></table>
28431 !! html/parsoid
28432 <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>
28433 <table>
28434 <tbody>
28435 <tr>
28436 <td>bar</td>
28437 </tr>
28438 </tbody>
28439 </table>
28440 !! end
28441
28442 !! test
28443 3. Encapsulate foster-parented transclusion content
28444 !! options
28445 parsoid=wt2wt,wt2html
28446 !! wikitext
28447 <table><div><p>{{echo|foo</p></div><tr><td>}}bar</td></tr></table>
28448 !! html/parsoid
28449 <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;]}">
28450 <p>foo</p>
28451 </div>
28452 <table>
28453 <tbody>
28454 <tr>
28455 <td>bar</td>
28456 </tr>
28457 </tbody>
28458 </table>
28459 !! end
28460
28461 !! test
28462 4. Encapsulate foster-parented transclusion content
28463 !! options
28464 parsoid=wt2wt,wt2html
28465 !! wikitext
28466 <table><div><p>{{echo|foo</p></div><tr><td>}}bar</td></tr></table>
28467 !! html/parsoid
28468 <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;]}">
28469 <p>foo</p>
28470 </div>
28471 <table>
28472 <tbody>
28473 <tr>
28474 <td>bar</td>
28475 </tr>
28476 </tbody>
28477 </table>
28478 !! end
28479
28480 ## Remex doesn't account for fostered content.
28481 !! test
28482 5. Encapsulate foster-parented transclusion content
28483 !!options
28484 parsoid=wt2wt,wt2html
28485 !! wikitext
28486 <table><tr><td><div><p>{{echo|foo</p></div></td>foo}}</tr></table>
28487 !! html/php+tidy
28488 foo<table><tbody><tr><td><div><p>foo</p></div></td></tr></tbody></table>
28489 !! html/parsoid
28490 <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>
28491 !! end
28492
28493 ## Remex doesn't account for fostered content.
28494 !! test
28495 6. Encapsulate foster-parented transclusion content
28496 !! options
28497 parsoid=wt2wt,wt2html
28498 !! wikitext
28499 <table><tr><td><div><p>{{echo|foo</p></div></td>foo</tr></table>}}<p>ok</p>
28500 !! html/php+tidy
28501 foo<table><tbody><tr><td><div><p>foo</p></div></td></tr></tbody></table><p>ok</p>
28502 !! html/parsoid
28503 <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>
28504 !! end
28505
28506 !! test
28507 7. Encapsulate foster-parented transclusion content
28508 !!options
28509 parsoid=wt2wt,wt2html
28510 !! wikitext
28511 <table>{{echo|<p>foo</p>}}<td>bar</td></table>
28512 !! html/parsoid
28513 <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>
28514 <table>
28515 <tbody>
28516 <tr>
28517 <td>bar</td>
28518 </tr>
28519 </tbody>
28520 </table>
28521 !! end
28522
28523 ## Remex doesn't account for fostered content.
28524 # Note that the wt is broken on purpose: the = should be {{=}} if you
28525 # don't want it to be a template parameter key.
28526 !! test
28527 8. Encapsulate foster-parented transclusion content
28528 !! options
28529 parsoid=wt2wt,wt2html
28530 !! wikitext
28531 {{echo|a
28532 }}{|{{echo|style='color:red'}}
28533 |-
28534 |b
28535 |}
28536 !! html/php+tidy
28537 <p>a
28538 </p>
28539 <table>
28540
28541 <tbody><tr>
28542 <td>b
28543 </td></tr></tbody></table>
28544 !! html/parsoid
28545 <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">
28546 </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">
28547 <tbody><tr>
28548 <td>b
28549 </td></tr></tbody></table>
28550 !! end
28551
28552 ## Remex doesn't account for fostered content.
28553 !! test
28554 9. Encapsulate foster-parented transclusion content
28555 !!options
28556 parsoid=wt2wt,wt2html
28557 !! wikitext
28558 <table>{{echo|hi</table>hello}}
28559 !! html/php+tidy
28560 hi<table></table><p>hello
28561 </p>
28562 !! html/parsoid
28563 <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>
28564 !! end
28565
28566 !! test
28567 Table in fosterable position
28568 !!options
28569 parsoid=wt2html
28570 !! wikitext
28571 {{OpenTable}}
28572 <div>
28573 {|
28574 |}
28575 </div>
28576 |}
28577 !! html/parsoid
28578 <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">
28579 </span>
28580 <table about="#mwt1" data-parsoid='{"autoInsertedEnd":true}'></table>
28581
28582 <table>
28583 </table>
28584 !! end
28585
28586 # Parsoid only for T66747
28587 !! test
28588 Properly encapsulate empty-content transclusions in fosterable positions
28589 !! wikitext
28590 <table>
28591 {{#if:|
28592 <td>foo</td>
28593 }}
28594 </table>
28595 !! html/parsoid
28596 <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"}]]}'>
28597
28598 </table>
28599 !! end
28600
28601 ## No longer captures its original intention
28602 !! test
28603 Always encapsulate foster box when template range is expanded to table
28604 !! options
28605 disabled
28606 parsoid=wt2wt
28607 !! wikitext
28608 {|
28609 hello
28610 {{OpenTable}}
28611 |}
28612 !! html/parsoid
28613
28614 !! end
28615
28616 !! test
28617 T115289: Unclosed table
28618 !! wikitext
28619 {{echo|<table>}}<!--c-->[[Category:Two]]
28620 !! html/parsoid
28621 <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>
28622 !! end
28623
28624 !! test
28625 T115289: Don't migrate newlines out of tables with fostered content
28626 !! wikitext
28627 <table><td></td>{{echo|<tr>[[Category:One]]}}<!--c-->[[Category:Two]]
28628 !! html/parsoid
28629 <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>
28630 !! end
28631
28632 !! test
28633 T73074: More fostering fun
28634 !! wikitext
28635 <table><td></td>{{echo|<tr>}}<!--c-->[[Category:Two]]
28636 !! html/parsoid
28637 <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>
28638 !! end
28639
28640 !!test
28641 Support <object> element with .data attribute
28642 !!options
28643 parsoid=html2wt
28644 !! html/parsoid
28645 <object data="test.swf"></object>
28646 !! wikitext
28647 <object data="test.swf"></object>
28648 !!end
28649
28650 !! test
28651 Don't block XML namespace declaration
28652 !! wikitext
28653 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">MediaWiki</span>
28654 !! html/php
28655 <p><span xmlns:dct="http&#58;//purl.org/dc/terms/" property="dct:title">MediaWiki</span>
28656 </p>
28657 !! html/parsoid
28658 <p><span xmlns:dct="http://purl.org/dc/terms/" data-x-property="dct:title" data-parsoid='{"stx":"html"}'>MediaWiki</span></p>
28659 !! end
28660
28661 # -----------------------------------------------------------------
28662 # The following section of tests are primarily to spec requirements
28663 # around Parsoid's serialization (old, new, edited content)
28664 #
28665 # All these tests are marked Parsoid html2wt and html2html only
28666 # ----------------------------------------------------------------
28667
28668 !! test
28669 Ignore rel attribute in a-tags during serialization to url-links
28670 !! options
28671 parsoid=html2wt
28672 !! html/parsoid
28673 <a href='http://en.wikipedia.org/wiki/Foobar'>http://en.wikipedia.org/wiki/Foobar</a>
28674 <a href='http://en.wikipedia.org/wiki/Foobar' rel='mw:ExtLink'>http://en.wikipedia.org/wiki/Foobar</a>
28675 <a href='http://en.wikipedia.org/wiki/Foobar' rel='mw:WikiLink'>http://en.wikipedia.org/wiki/Foobar</a>
28676 !! wikitext
28677 http://en.wikipedia.org/wiki/Foobar
28678 http://en.wikipedia.org/wiki/Foobar
28679 http://en.wikipedia.org/wiki/Foobar
28680 !! end
28681
28682 # 'mi' is a localinterwiki prefix as well as a language
28683 !! test
28684 Serialize interwiki links pointing to the current wiki as plain wiki links (T67869)
28685 !! options
28686 parsoid=html2wt
28687 !! html/parsoid
28688 <p><a rel="mw:ExtLink" href="http://mi.wikipedia.org/wiki/Foo">Foo</a></p>
28689 !! wikitext
28690 [[Foo]]
28691 !! end
28692
28693 !! test
28694 Parsoid should accept interwiki shortcuts
28695 !! options
28696 parsoid=html2wt
28697 !! html/parsoid
28698 <p><a rel='mw:WikiLink' href='./fr:Foo'>Foo</a>
28699 <a rel='mw:ExtLink' href='./fr:Foo'>Foo</a>
28700 <a href='./fr:Foo'>Foo</a></p>
28701 <p><a rel='mw:WikiLink' href='fr%3AFoo'>Foo</a>
28702 <a rel='mw:ExtLink' href='fr%3AFoo'>Foo</a>
28703 <a href='fr%3AFoo'>Foo</a></p>
28704 <p><a href='FR%3AFoo'>Foo</a>
28705 <a href='./FR:Foo'>Foo</a></p>
28706 !! wikitext
28707 [[:fr:Foo|Foo]]
28708 [[:fr:Foo|Foo]]
28709 [[:fr:Foo|Foo]]
28710
28711 [[:fr:Foo|Foo]]
28712 [[:fr:Foo|Foo]]
28713 [[:fr:Foo|Foo]]
28714
28715 [[:fr:Foo|Foo]]
28716 [[:fr:Foo|Foo]]
28717 !! end
28718
28719 !! test
28720 Parsoid should not accept invalid interwiki shortcuts
28721 !! options
28722 parsoid=html2wt
28723 !! html/parsoid
28724 <p><a rel='mw:WikiLink' href='news:Foo'>Foo</a>
28725 <a rel='mw:ExtLink' href='news:Foo'>Foo</a>
28726 <a href='news:Foo'>Foo</a></p>
28727 !! wikitext
28728 [news:Foo Foo]
28729 [news:Foo Foo]
28730 [news:Foo Foo]
28731 !! end
28732
28733 # See T93839
28734 !! test
28735 New wikilinks should be serialized properly
28736 !! options
28737 parsoid=html2wt
28738 !! html/parsoid
28739 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{}'>Foo</a>
28740 <a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a>
28741 <a href="//en.wikipedia.org/wiki/Foo">//en.wikipedia.org/wiki/Foo</a>
28742 <a href="http://en.wikipedia.org/wiki/Foo">http://en.wikipedia.org/wiki/Foo</a>
28743 <a href="//en.wikipedia.org/wiki/Foo_bar">//en.wikipedia.org/wiki/Foo bar</a>
28744 !! wikitext
28745 [[Foo]]
28746 [[Foo]]
28747 [[:en:Foo|//en.wikipedia.org/wiki/Foo]]
28748 http://en.wikipedia.org/wiki/Foo
28749 [[:en:Foo_bar|//en.wikipedia.org/wiki/Foo bar]]
28750 !! end
28751
28752 !! test
28753 New wiki links (href variations)
28754 !! options
28755 parsoid=html2wt
28756 !! html/parsoid
28757 <a rel="mw:WikiLink" href="./Foo_bar">Foo_bar</a>
28758 <a rel="mw:WikiLink" href="Foo_bar">Foo_bar</a>
28759 <a rel="mw:WikiLink" href="Foo bar">Foo_bar</a>
28760 <a rel="mw:WikiLink" href="./Toxine_bact%C3%A9rienne">Toxine bactérienne</a>
28761 !! wikitext
28762 [[Foo_bar]]
28763 [[Foo_bar]]
28764 [[Foo_bar]]
28765 [[Toxine bactérienne]]
28766 !! end
28767
28768 !! test
28769 New wiki links (content string variations)
28770 !! options
28771 parsoid=html2wt
28772 !! html/parsoid
28773 <a rel="mw:WikiLink" href="./Foo_bar">Foo_bar</a>
28774 <a rel="mw:WikiLink" href="./Foo_bar">Foo bar</a>
28775 <a rel="mw:WikiLink" href="./Foo_bar">./Foo_bar</a>
28776 !! wikitext
28777 [[Foo_bar]]
28778 [[Foo bar]]
28779 [[Foo_bar|./Foo_bar]]
28780 !! end
28781
28782 !! test
28783 New category links (href variations)
28784 !! options
28785 parsoid=html2wt
28786 !! html/parsoid
28787 <link rel="mw:PageProp/Category" href="./Category:Toxine_bactérienne" />
28788 <link rel="mw:PageProp/Category" href="./Category:Toxine_bact%C3%A9rienne" />
28789 <link rel="mw:PageProp/Category" href="Category:Toxine_bact%C3%A9rienne" />
28790 !! wikitext
28791 [[Category:Toxine bactérienne]]
28792 [[Category:Toxine bactérienne]]
28793 [[Category:Toxine bactérienne]]
28794 !! end
28795
28796 !! test
28797 New sol transparent links don't need indent-pre nowiki protection
28798 !! options
28799 parsoid=html2wt
28800 language=de
28801 !! html/parsoid
28802 <link rel="mw:PageProp/redirect" href="./Main_Page">
28803 <!-- this is good --> <link rel="mw:PageProp/Category" href="./Category:Good" />
28804 <!-- this is great --> <link rel="mw:PageProp/Category" href="./Kategorie:Great" />
28805 !! wikitext
28806 #WEITERLEITUNG [[Main Page]]
28807 <!-- this is good --> [[Category:Good]]
28808 <!-- this is great --> [[Kategorie:Great]]
28809 !! end
28810
28811 !! test
28812 New interlanguage links (href variations)
28813 !! options
28814 parsoid=html2wt
28815 !! html/parsoid
28816 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine bactérienne" />
28817 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine_bactérienne" />
28818 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine_bact%C3%A9rienne" />
28819 !! wikitext
28820 [[es:Toxine bactérienne]]
28821 [[es:Toxine_bactérienne]]
28822 [[es:Toxine_bactérienne]]
28823 !! end
28824
28825 !! test
28826 Image: Modifying size of an image (1)
28827 !! options
28828 parsoid={
28829 "modes": ["wt2wt"],
28830 "changes": [
28831 ["img[height]", "attr", "height", "22"],
28832 ["img[width]", "attr", "width", "200"]
28833 ]
28834 }
28835 !! wikitext
28836 [[Image:Foobar.jpg|230x230px]]
28837 !! wikitext/edited
28838 [[Image:Foobar.jpg|200x200px]]
28839 !!end
28840
28841 !! test
28842 Image: Modifying size of an image (2)
28843 !! options
28844 parsoid={
28845 "modes": ["wt2wt"],
28846 "changes": [
28847 ["img[height]", "attr", "height", "100"],
28848 ["img[width]", "attr", "width", "500"]
28849 ]
28850 }
28851 !! wikitext
28852 [[Image:Foobar.jpg|230x230px]]
28853 !! wikitext/edited
28854 [[Image:Foobar.jpg|500x500px]]
28855 !!end
28856
28857 # Change in size is ignored so long as class='mw-default-size'
28858 !! test
28859 Image: Modifying size of an image (3)
28860 !! options
28861 parsoid={
28862 "modes": ["wt2wt"],
28863 "changes": [
28864 ["figure[class]", "removeClass", "mw-default-size"],
28865 ["figure img", "attr", "height", "19"],
28866 ["figure img", "attr", "width", "170"]
28867 ]
28868 }
28869 !! wikitext
28870 [[Image:Foobar.jpg|thumb]]
28871 !! wikitext/edited
28872 [[Image:Foobar.jpg|thumb|170x170px]]
28873 !!end
28874
28875 !! test
28876 Image: Modifying alignment of an image (T50665)
28877 !! options
28878 parsoid={
28879 "modes": ["wt2wt"],
28880 "changes": [
28881 ["figure[class]", "removeClass", "mw-halign-right"],
28882 ["figure[class]", "addClass", "mw-halign-left"]
28883 ]
28884 }
28885 !! wikitext
28886 [[Image:Foobar.jpg|thumb|caption|right]]
28887 !! wikitext/edited
28888 [[Image:Foobar.jpg|thumb|caption|left]]
28889 !! end
28890
28891 !! test
28892 Image: Modifying mw-default-size of an frameless image (T64805)
28893 !! options
28894 parsoid={
28895 "modes": ["wt2wt"],
28896 "changes": [
28897 ["figure.mw-default-size", "removeClass", "mw-default-size"]
28898 ]
28899 }
28900 !! wikitext
28901 [[Image:Foobar.jpg|frameless|right]]
28902 !! wikitext/edited
28903 [[Image:Foobar.jpg|frameless|right|220x220px]]
28904 !! end
28905
28906 !! test
28907 Image: Modifying valign of an image (T51221)
28908 !! options
28909 parsoid={
28910 "modes": ["wt2wt"],
28911 "changes": [
28912 ["*[typeof=\"mw:Image\"]", "removeClass", "mw-valign-middle"],
28913 ["*[typeof=\"mw:Image\"]", "addClass", "mw-valign-text-top"]
28914 ]
28915 }
28916 !! wikitext
28917 [[File:Foobar.jpg|20px|middle]]
28918 !! wikitext/edited
28919 [[File:Foobar.jpg|20px|text-top]]
28920 !! end
28921
28922 !! test
28923 Image: Modifying alt attribute of an image (T58400)
28924 !! options
28925 parsoid={
28926 "modes": ["wt2wt"],
28927 "changes": [
28928 ["img[alt]", "attr", "alt", "some alternate edited text"]
28929 ]
28930 }
28931 !! wikitext
28932 [[File:Foobar.jpg|thumb|some caption|alt=some alternate text]]
28933 !! wikitext/edited
28934 [[File:Foobar.jpg|thumb|some caption|alt=some alternate edited text]]
28935 !!end
28936
28937 !! test
28938 Image: Modifying caption of an image
28939 !! options
28940 parsoid={
28941 "modes": ["wt2wt"],
28942 "changes": [
28943 ["figcaption", "text", "new caption"]
28944 ]
28945 }
28946 !! wikitext
28947 [[Image:Foobar.jpg|thumb|original caption]]
28948 !! wikitext/edited
28949 [[Image:Foobar.jpg|thumb|new caption]]
28950 !!end
28951
28952 !! test
28953 Image: empty alt attribute (T50924)
28954 !! wikitext
28955 [[File:Foobar.jpg|thumb|alt=|bar]]
28956 !! html/php+tidy
28957 <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>
28958 !! html/parsoid
28959 <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>
28960 !! end
28961
28962 !! test
28963 Image: new attributes should be serialized in wiki's language for RTL languages (T53852)
28964 !! options
28965 parsoid=html2wt
28966 language=ar
28967 disabled
28968 !! html/parsoid
28969 <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>
28970 !! wikitext
28971 [[Imagen:Foobar.jpg|derecha|miniaturadeimagen]]
28972 !! end
28973
28974 !! test
28975 Image: Block level image should have \n before and after
28976 !! wikitext
28977 123
28978 [[File:Foobar.jpg|right|thumb|150x150px]]
28979 456
28980 !! html/parsoid
28981 <p>123</p>
28982 <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>
28983 <p>456</p>
28984 !! end
28985
28986 !! test
28987 Image: New block level image should have \n before and after (existing content)
28988 !! wikitext
28989 123
28990 [[File:Foobar.jpg|right|thumb|150x150px]]
28991 456
28992 !! html/parsoid
28993 <p>123</p>
28994 <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>
28995 <p>456</p>
28996 !! end
28997
28998 !! test
28999 Image: upright option (parsoid)
29000 !! wikitext
29001 [[File:Foobar.jpg|thumb|upright|caption]]
29002 [[File:Foobar.jpg|thumb|upright=0.5|caption]]
29003 [[File:Foobar.jpg|thumb|500x500px|upright=0.5|caption]]
29004 !! html/parsoid
29005 <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>
29006 <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>
29007 <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>
29008 !! end
29009
29010 !! test
29011 Image: upright option is ignored on inline and frame images (parsoid)
29012 !! wikitext
29013 [[File:Foobar.jpg|500x500px|upright=0.5|caption]]
29014 !! html/parsoid
29015 <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>
29016 !! end
29017
29018 !! test
29019 Image: in template parameter with empty parameter
29020 !! wikitext
29021 {{echo|[[File:Foobar.jpg|link=]]}}
29022 !! html/parsoid
29023 <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>
29024 !! end
29025
29026 !! test
29027 Image: from basic HTML (1)
29028 !! options
29029 parsoid=html2wt
29030 !! html/parsoid
29031 <span typeof="mw:Image">
29032 <img src="./File:Foobar.jpg" width=100 height=100 alt="Alt">
29033 </span>
29034 !! wikitext
29035 [[File:Foobar.jpg|link=|alt=Alt|100x100px]]
29036 !! end
29037
29038 !! test
29039 Image: from basic HTML (2)
29040 !! options
29041 parsoid=html2wt
29042 !! html/parsoid
29043 <img src="./File:Foobar.jpg" width=100 height=100 alt="Alt">
29044 !! wikitext
29045 [[File:Foobar.jpg|link=|alt=Alt|100x100px]]
29046 !! end
29047
29048 !! test
29049 Image: from basic HTML (3)
29050 !! options
29051 parsoid=html2wt
29052 !! html/parsoid
29053 <a href="Main"><img src="./File:Foobar.jpg" width=100 height=100 alt="Alt"></a>
29054 !! wikitext
29055 [[File:Foobar.jpg|link=Main|alt=Alt|100x100px]]
29056 !! end
29057
29058 !! test
29059 Image: from basic HTML (4)
29060 !! options
29061 parsoid=html2wt
29062 !! html/parsoid
29063 <img src="./File:Foobar.jpg">
29064 !! wikitext
29065 [[File:Foobar.jpg|link=]]
29066 !! end
29067
29068 !! test
29069 Image: Invalid title as link
29070 !! wikitext
29071 [[File:Foobar.jpg|link=<]]
29072 !! html/php
29073 <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>
29074 </p>
29075 !! html/parsoid
29076 <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>
29077 !! end
29078
29079 !! test
29080 Various link types in alt and link options
29081 !! wikitext
29082 [[File:Foobar.jpg|link=[[Main Page]]|alt=[[Main Page]]|caption]]
29083
29084 [[File:Foobar.jpg|link=[[Media:Thumb.png]]|alt=[[Media:Thumb.png]]|caption]]
29085
29086 [[File:Foobar.jpg|link=[[wikipedia:Foo]]|alt=[[wikipedia:Foo]]|caption]]
29087 !! html/php+tidy
29088 <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>
29089 </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>
29090 </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>
29091 </p>
29092 !! html/parsoid
29093 <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>
29094
29095 <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>
29096
29097 <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>
29098 !! end
29099
29100 !! test
29101 Lists: Serialize correctly even when list content is wrapped in p-tags (like VE does)
29102 !! options
29103 parsoid=html2wt
29104 !! html/parsoid
29105 <ul>
29106 <li><p>foo</p></li>
29107 </ul>
29108 !! wikitext
29109 * foo
29110 !! end
29111
29112 !! test
29113 Lists: Serialize correctly even when list tags has unneeded whitespace between tags
29114 !! options
29115 parsoid=html2wt
29116 !! html/parsoid
29117 <ul> <li>foo</li></ul>
29118 !! wikitext
29119 * foo
29120 !! end
29121
29122 !! test
29123 Don't strip leading whitespace when handling indent-pre suppressing tags
29124 !! options
29125 parsoid=html2wt
29126 !! html/parsoid
29127 <table>
29128 <tr><td> indented row</td></tr>
29129 </table>
29130 <blockquote><p>
29131 <b>This is very bold of you!</b>
29132 </p>
29133 <table><tr><td>
29134 indented cell (no pre-wrapping!)
29135 </td></tr></table>
29136 </blockquote>
29137 <p>foo</p>
29138 <div>bar</div>
29139 !! wikitext
29140 {|
29141 | indented row
29142 |}
29143 <blockquote>
29144 '''This is very bold of you!'''
29145
29146 {|
29147 |
29148 indented cell (no pre-wrapping!)
29149 |}
29150 </blockquote>
29151 foo
29152 <div>bar</div>
29153 !! end
29154
29155 !! test
29156 Nowiki-wrap leading whitespace when handling indent-pre inducing tags
29157 !! options
29158 parsoid=html2wt
29159 !! html/parsoid
29160 <p>foo</p>
29161 <span>bar</span>
29162
29163 <span>foo2
29164 </span>bar2
29165
29166 <div>foo</div>
29167 <span>bar</span>
29168
29169 <div>
29170 <span>foo</span>
29171 </div>
29172 !! wikitext
29173 foo
29174
29175 <span>bar</span>
29176
29177 <span>foo2
29178 <nowiki> </nowiki></span>bar2
29179
29180 <div>foo</div>
29181 <nowiki> </nowiki><span>bar</span>
29182
29183 <div>
29184 <nowiki> </nowiki><span>foo</span>
29185 </div>
29186 !! end
29187
29188 !! test
29189 Lists: Dont insert newlines in a serialized list item.
29190 !! options
29191 parsoid=html2wt
29192 !! html/parsoid
29193 <ul><li>a<br>b</li><li>c</li></ul>
29194 !! wikitext
29195 * a<br />b
29196 * c
29197 !! end
29198
29199 !! test
29200 1. Headings: Force sol-transparent links and behavior switches to serialize before/after
29201 !! options
29202 parsoid={
29203 "modes": ["html2wt"],
29204 "scrubWikitext": false
29205 }
29206 !! html/parsoid
29207 <h2>hello there<link href="./Category:A1" rel="mw:PageProp/Category" /></h2>
29208 <h2><link href="./Category:A2" rel="mw:PageProp/Category" />hi pal</h2>
29209
29210 <h2><!--foo--> <link href="./Category:A3" rel="mw:PageProp/Category" /> how goes it</h2>
29211 <h2>it goes well <link href="./Category:A4" rel="mw:PageProp/Category" /> <!--bar--></h2>
29212
29213 <h2 data-parsoid='{}'>howdy<link href="./Category:A5" rel="mw:PageProp/Category" /></h2>
29214
29215 <h2><meta property="mw:PageProp/toc" /> ok</h2>
29216 !! wikitext
29217 == hello there [[Category:A1]] ==
29218
29219 == [[Category:A2]] hi pal ==
29220
29221 == <!--foo--> [[Category:A3]] how goes it ==
29222
29223 == it goes well [[Category:A4]] <!--bar--> ==
29224
29225 ==howdy [[Category:A5]]==
29226
29227 == __TOC__ ok ==
29228 !! end
29229
29230 !! test
29231 2. Headings: Force sol-transparent links and behavior switches to serialize before/after
29232 !! options
29233 parsoid={
29234 "modes": ["html2wt"],
29235 "scrubWikitext": true
29236 }
29237 !! html/parsoid
29238 <h2>hello there<link href="./Category:A1" rel="mw:PageProp/Category" /></h2>
29239 <h2><link href="./Category:A2" rel="mw:PageProp/Category" />hi pal</h2>
29240
29241 <h2><!--foo--> <link href="./Category:A3" rel="mw:PageProp/Category" /> how goes it</h2>
29242 <h2>it goes well <link href="./Category:A4" rel="mw:PageProp/Category" /> <!--bar--></h2>
29243
29244 <h2><meta property="mw:PageProp/toc" /> ok</h2>
29245 !! wikitext
29246 == hello there ==
29247 [[Category:A1]]
29248 [[Category:A2]]
29249
29250 == hi pal ==
29251
29252 <!--foo-->[[Category:A3]]
29253
29254 == how goes it ==
29255
29256 == it goes well ==
29257 [[Category:A4]] <!--bar-->
29258
29259 __TOC__
29260
29261 == ok ==
29262 !! end
29263
29264 !! test
29265 Headings: Don't hoist metas that come from templates
29266 !! options
29267 parsoid={
29268 "modes": ["html2wt"],
29269 "scrubWikitext": true
29270 }
29271 !! html/parsoid
29272 <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>
29273 !! wikitext
29274 == {{echo|foo [[Category:Foo]]}} ==
29275 !! end
29276
29277 !! test
29278 Headings: Category in ref isn't hoisted
29279 !! options
29280 parsoid={
29281 "modes": ["html2wt"],
29282 "scrubWikitext": true
29283 }
29284 !! html/parsoid
29285 <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>
29286
29287 <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>
29288 !! wikitext
29289 == foo <ref>bar
29290 [[Category:Baz]] </ref> ==
29291
29292 <references />
29293 !! end
29294
29295 !! test
29296 Parsoid: Serialize positional parameters with = in them as named parameter
29297 !! options
29298 parsoid=html2wt
29299 !! html/parsoid
29300 <p about="#mwt1" typeof="mw:Transclusion"
29301 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"f=oo"}},"i":0}}]}'>foo</p>
29302
29303 <p about="#mwt1" typeof="mw:Transclusion"
29304 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"f=oo"}, "2":{"wt":"bar"}},"i":0}}]}'>foo</p>
29305
29306 <!--Orig params with data-parsoid has heuristics for handling = chars-->
29307 <!--FIXME: But maybe the heuristic needs fixing to apply to new params as well-->
29308 <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>
29309 !! wikitext
29310 {{echo|1=f=oo}}
29311
29312 {{echo|1=f=oo|2=bar}}
29313
29314 <!--Orig params with data-parsoid has heuristics for handling = chars-->
29315 <!--FIXME: But maybe the heuristic needs fixing to apply to new params as well-->
29316 {{echo|<nowiki>f=oo</nowiki>|bar}}
29317 !! end
29318
29319 !! test
29320 Parsoid: Serialize positional parameters with = in extlink as named parameter
29321 !! options
29322 parsoid=html2wt
29323 !! html/parsoid
29324 <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>
29325 !! wikitext
29326 {{echo|1=http://stuff?is=ok}}
29327 !! end
29328
29329 !! test
29330 Parsoid: Correctly serialize block-node children when they are a combination of text and p-nodes
29331 !! options
29332 parsoid=html2wt
29333 !! html/parsoid
29334 <div>a<p>b</p></div>
29335 <div>a
29336 <p>b</p></div>
29337 <div>
29338 a
29339 <p>b</p></div>
29340 !! wikitext
29341 <div>a
29342 b
29343 </div>
29344 <div>a
29345 b
29346 </div>
29347 <div>
29348 a
29349
29350 b
29351 </div>
29352 !! end
29353
29354 !! test
29355 Substrings resembling wikitext in hrefs should not get nowiki escapes
29356 !! options
29357 parsoid=html2wt
29358 !! html/parsoid
29359 <a rel="mw:WikiLink" href="./Foo''bar''baz">Foo''bar''baz</a>
29360 !! wikitext
29361 [[Foo''bar''baz]]
29362 !! end
29363
29364 !! test
29365 Enforce single-line context in the serializer
29366 !! options
29367 parsoid=html2wt
29368 !! html/parsoid
29369 <h2>testing
29370 123</h2>
29371
29372 <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">
29373 </span><span about="#mwt1">you</span> </h2>
29374
29375 <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>
29376
29377 <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
29378 there</span></li></ol>
29379
29380 <ul><li>asd
29381 sdf</li></ul>
29382
29383 <ul><li>foo
29384 bar
29385 baz</li>
29386 <li>foo <b>bar</b>
29387 baz</li></ul>
29388
29389 <dl><dt>hi
29390 ho </dt><dd data-parsoid='{"stx":"row"}'> hi
29391 ho</dd></dl>
29392
29393 <dl><dd> <table>
29394 <tbody><tr><td> ha
29395 ha
29396 ha</td></tr>
29397 </tbody></table></dd></dl>
29398 !! wikitext
29399 == testing 123 ==
29400
29401 == hi {{bogus|there
29402 you}} ==
29403
29404 == foo <ref>hello
29405 there</ref> ==
29406
29407 <references />
29408
29409 * asd sdf
29410
29411 * foo bar baz
29412 * foo '''bar''' baz
29413
29414 ; hi ho : hi ho
29415
29416 : {|
29417 | ha
29418 ha
29419 ha
29420 |}
29421 !! end
29422
29423 !! test
29424 Serialize new placeholder space without spans
29425 !! options
29426 parsoid=html2wt
29427 !! html/parsoid
29428 <p>foo<span typeof="mw:Placeholder"> </span>: bar</p>
29429
29430 <p>foo<span typeof="mw:DisplaySpace mw:Placeholder" data-parsoid='{"src":" ","isDisplayHack":true}'> </span>: bar</p>
29431
29432 <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>
29433 !! wikitext
29434 foo : bar
29435
29436 foo : bar
29437
29438 <ref>foo : bar</ref>ok
29439 !! end
29440
29441
29442 #-----------------------
29443 # Tag minimization tests
29444 #-----------------------
29445
29446 !! test
29447 1. I/B quote minimization: wikitext-only tags should be combined
29448 !! options
29449 parsoid=html2wt
29450 !! html/parsoid
29451 <p><i>A</i><i>B</i></p>
29452 <p><b>A</b><b>B</b></p>
29453 <p><i>A</i><b><i>B</i></b></p>
29454 <p><b>A</b><i><b>B</b></i></p>
29455 <p><b>A</b><i><b>B</b><b>C</b></i><b>D</b></p>
29456 <p><i><b>A</b></i><i><b>B</b></i></p>
29457 <p><i><b>A</b></i><b><i>B</i></b></p>
29458 <p><b><i>A</i></b><i><b>B</b></i></p>
29459 !! wikitext
29460 ''AB''
29461
29462 '''AB'''
29463
29464 ''A'''B'''''
29465
29466 '''A''B'''''
29467
29468 '''A''BC''D'''
29469
29470 '''''AB'''''
29471
29472 '''''AB'''''
29473
29474 '''''AB'''''
29475 !! end
29476
29477 !! test
29478 2. I/B quote minimization: wikitext and html tags should not be combined
29479 !! options
29480 parsoid=html2wt
29481 !! html/parsoid
29482 <p><i>A</i><i data-parsoid='{"stx":"html"}'>B</i></p>
29483 <p><i>A</i><b><i data-parsoid='{"stx":"html"}'>B</i></b></p>
29484 !! wikitext
29485 ''A''<i>B</i>
29486
29487 ''A''<nowiki/>'''<i>B</i>'''
29488 !! end
29489
29490 !! test
29491 3. I/B quote minimization: templated content stops minimization
29492 !! options
29493 parsoid=html2wt
29494 !! html/parsoid
29495 <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>
29496 <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>
29497 !! wikitext
29498 ''A''{{echo|''B''}}
29499
29500 ''A''{{echo|'''''B'''''}}
29501 !! end
29502
29503 !! test
29504 4. I/B quote minimization: new content should be mimimized with adjacent old content
29505 !! options
29506 parsoid=html2wt
29507 !! html/parsoid
29508 <p><i>A</i><i>B</i></p>
29509 <p><b>A</b><b>B</b></p>
29510 <p><i>A</i><b><i>B</i></b></p>
29511 !! wikitext
29512 ''AB''
29513
29514 '''AB'''
29515
29516 ''A'''B'''''
29517 !! end
29518
29519 !! test
29520 5a. Merge adjacent quote nodes if they've been edited
29521 !! options
29522 parsoid={
29523 "modes": ["wt2wt", "selser"],
29524 "changes": [
29525 ["p", "contents", "remove", ":contains('b')"]
29526 ]
29527 }
29528 !! wikitext
29529 ''a''b''c''
29530 !! wikitext/edited
29531 ''ac''
29532 !! end
29533
29534 !! test
29535 5b. Merge adjacent quote nodes if they've been edited
29536 !! options
29537 parsoid={
29538 "modes": ["wt2wt", "selser"],
29539 "changes": [
29540 ["#x", "remove"]
29541 ]
29542 }
29543 !! wikitext
29544 ''a''<span id="x">b</span>''c''
29545 !! wikitext/edited
29546 ''ac''
29547 !! end
29548
29549 !! test
29550 1. Merge adjacent link nodes as long as at least one element is new
29551 !! options
29552 parsoid={
29553 "modes": ["html2wt"],
29554 "scrubWikitext": true
29555 }
29556 !! html/parsoid
29557 <a rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
29558 <a data-parsoid="{}" rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
29559 <a data-parsoid="{}" rel="mw:WikiLink" href="./Football">Foot</a><a data-parsoid="{}" rel="mw:WikiLink" href="./Football">ball</a>
29560 !! wikitext
29561 [[Football]]
29562 [[Football]]
29563 [[Football|Foot]][[Football|ball]]
29564 !! end
29565
29566 !! test
29567 2. Merge adjacent link nodes and enable additional normalizations
29568 !! options
29569 parsoid={
29570 "modes": ["html2wt"],
29571 "scrubWikitext": true
29572 }
29573 !! html/parsoid
29574 <a rel="mw:WikiLink" href="./Football"><i>Foot</i></a><a rel="mw:WikiLink" href="./Football"><i>ball</i></a>
29575 !! wikitext
29576 ''[[Football]]''
29577 !! end
29578
29579 !! test
29580 3. Don't merge adjacent link nodes if scrubWikitext is false
29581 !! options
29582 parsoid={
29583 "modes": ["html2wt"],
29584 "scrubWikitext": false
29585 }
29586 !! html/parsoid
29587 <a rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
29588 !! wikitext
29589 [[Football|Foot]][[Football|ball]]
29590 !! end
29591
29592 !! test
29593 1. Move format tags outside of WikiLink
29594 !! options
29595 parsoid={
29596 "modes": ["html2wt"],
29597 "scrubWikitext": true
29598 }
29599 !! html/parsoid
29600 <a rel="mw:WikiLink" href="./Football"><i>Football</i></a>
29601 <a rel="mw:WikiLink" href="./Football"><i><b>Football</b></i></a>
29602 <a rel="mw:WikiLink" href="./Football"><u><i><b>Football</b></i></u></a>
29603 !! wikitext
29604 ''[[Football]]''
29605 '''''[[Football]]'''''
29606 <u>'''''[[Football]]'''''</u>
29607 !! end
29608
29609 !! test
29610 2. Move format tags outside of WikiLink with mergable A tags
29611 !! options
29612 parsoid={
29613 "modes": ["html2wt"],
29614 "scrubWikitext": true
29615 }
29616 !! html/parsoid
29617 <a rel="mw:WikiLink" href="./Football"><i><b>Foot</b></i></a><a rel="mw:WikiLink" href="./Football"><i><b>ball</b></i></a>
29618 !! wikitext
29619 '''''[[Football]]'''''
29620 !! end
29621
29622 !! test
29623 3. Move format tags outside of WikiLink while preserving formats already outside WikiLink
29624 !! options
29625 parsoid={
29626 "modes": ["html2wt"],
29627 "scrubWikitext": true
29628 }
29629 !! html/parsoid
29630 <font color="red"><a rel="mw:WikiLink" href="./Foo" title="Foo" class="mw-redirect"><u><b>Foo</b></u></a></font>
29631 !! wikitext
29632 <font color="red"><u>'''[[Foo]]'''</u></font>
29633 !! end
29634
29635 !! test
29636 4. Do not move format tags outside of WikiLink which includes attributes color, style and class
29637 !! options
29638 parsoid={
29639 "modes": ["html2wt"],
29640 "scrubWikitext": true
29641 }
29642 !! html/parsoid
29643 <a rel="mw:WikiLink" href="./Foo" title="Foo" class="mw-redirect"><font color="red">Foo</font></a>
29644 <a rel="mw:WikiLink" href="./Foo" title="Foo" class="mw-redirect"><span style="color: blue; font-size: 46px;">Foo></span></a>
29645 <a rel="mw:WikiLink" href="./Foo" title="Foo" class="mw-redirect"><span class="Bar">Foo</span></a>
29646 !! wikitext
29647 [[Foo|<font color="red">Foo</font>]]
29648 [[Foo|<span style="color: blue; font-size: 46px;">Foo></span>]]
29649 [[Foo|<span class="Bar">Foo</span>]]
29650 !! end
29651
29652 !! test
29653 5. T194083 Regression test: Manual edit test that also enables scrubWikitext to move format tags outside wikilinks
29654 !! options
29655 parsoid={
29656 "modes": ["selser"],
29657 "scrubWikitext": true,
29658 "changes": [
29659 ["a", "html", "<i>Foo</i>"]
29660 ]
29661 }
29662 !! wikitext
29663 [[Foo]]
29664 !! wikitext/edited
29665 ''[[Foo]]''
29666 !! end
29667
29668 !! test
29669 6. Regression test: Manual edit test to ensure diff markers are not lost
29670 !! options
29671 parsoid={
29672 "modes": ["selser"],
29673 "scrubWikitext": true,
29674 "changes": [
29675 ["i", "wrap", "<a href='./Foo' rel='mw:WikiLink'></a>"]
29676 ]
29677 }
29678 !! wikitext
29679 ''Foo''
29680 !! wikitext/edited
29681 ''[[Foo]]''
29682 !! end
29683
29684 !! test
29685 7. T194083 Regression test: Manual edit test to ensure nested diff markers aren't inserted
29686 !! options
29687 parsoid={
29688 "modes": ["selser"],
29689 "scrubWikitext": true,
29690 "changes": [
29691 ["div", "after", "\n<p><a href='./Foo' rel='mw:WikiLink'>Foo </a>, placeholder</p>"]
29692 ]
29693 }
29694 !! wikitext
29695 <div>placeholder</div>
29696 !! wikitext/edited
29697 <div>placeholder</div>
29698 [[Foo]] , placeholder
29699 !! end
29700
29701 #------------------------------
29702 # End of tag minimization tests
29703 #------------------------------
29704
29705 !!test
29706 T56262: New entities
29707 !! options
29708 parsoid=html2wt
29709 !! html/parsoid
29710 <span typeof="mw:Entity">&nbsp;</span>
29711 !! wikitext
29712 &nbsp;
29713 !! end
29714
29715 ## Note that there is no wikitext output for 'unknownproperty' ##
29716 ## Unknown magic words are silently dropped ##
29717
29718 !! test
29719 Magic words
29720 !! options
29721 parsoid=html2wt
29722 !! html/parsoid
29723 <meta property='mw:PageProp/toc' />
29724 <meta property='mw:PageProp/notoc' />
29725 <meta property='mw:PageProp/forcetoc' />
29726 <meta property='mw:PageProp/index' />
29727 <meta property='mw:PageProp/noindex' />
29728 <meta property='mw:PageProp/nogallery' />
29729 <meta property='mw:PageProp/noeditsection' />
29730 <meta property='mw:PageProp/notitleconvert' />
29731 <meta property='mw:PageProp/nocontentconvert' />
29732 <meta property='mw:PageProp/unknownproperty' />
29733 !! wikitext
29734 __TOC__
29735 __NOTOC__
29736 __FORCETOC__
29737 __INDEX__
29738 __NOINDEX__
29739 __NOGALLERY__
29740 __NOEDITSECTION__
29741 __NOTITLECONVERT__
29742 __NOCONTENTCONVERT__
29743 !! end
29744
29745 !! test
29746 Consecutive <pre>s should not get merged
29747 !! options
29748 parsoid=html2wt,html2html
29749 !! html/parsoid
29750 <pre>a</pre><pre>b</pre>
29751
29752 <pre>c
29753 </pre><pre>
29754 d</pre>
29755
29756 <pre>e
29757
29758 </pre><pre>
29759
29760 f</pre>
29761 !! wikitext
29762 a
29763
29764 b
29765
29766 c
29767
29768 d
29769
29770 e
29771
29772
29773
29774 f
29775 !! end
29776
29777 !! test
29778 Edited ISBN links not serializable as ISBN links should serialize as wikilinks
29779 !! options
29780 parsoid=html2wt
29781 !! html/parsoid
29782 <a href="./Special:BookSources/1234567890" rel="mw:ExtLink">ISBN 1234567895</a>
29783 !! wikitext
29784 [[Special:BookSources/1234567890|ISBN 1234567895]]
29785 !! end
29786
29787 !! test
29788 Edited RFC links not serializable as RFC links should serialize as extlinks
29789 !! options
29790 parsoid=html2wt
29791 !! html/parsoid
29792 <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink">New RFC</a>
29793 !! wikitext
29794 [https://tools.ietf.org/html/rfc123 New RFC]
29795 !! end
29796
29797 !! test
29798 Edited PMID links not serializable as PMID links should serialize as extlinks
29799 !! options
29800 parsoid=html2wt
29801 !! html/parsoid
29802 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink">New PMID</a>
29803 !! wikitext
29804 [//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract New PMID]
29805 !! end
29806
29807 !! test
29808 WTS of autolinks with trailing/surrounding context
29809 !! options
29810 parsoid=html2wt
29811 !! html/parsoid
29812 <p><a href="http://cscott.net">http://cscott.net</a><b>foo</b></p>
29813 <p><a href="http://cscott.net">http://cscott.net</a><b data-parsoid='{"stx":"html"}'>foo</b></p>
29814 <p><b><a href="http://cscott.net">http://cscott.net</a></b></p>
29815 <p><b><a href="http://cscott.net">http://cscott.net</a> </b></p>
29816 <p><b><a href="http://cscott.net">http://cscott.net</a>x</b></p>
29817 <p><a href="http://cscott.net">http://cscott.net</a>x</p>
29818 !! wikitext
29819 http://cscott.net'''foo'''
29820
29821 http://cscott.net<b>foo</b>
29822
29823 '''http://cscott.net'''
29824
29825 '''http://cscott.net '''
29826
29827 '''http://cscott.net<nowiki/>x'''
29828
29829 http://cscott.net<nowiki/>x
29830 !! end
29831
29832 !! test
29833 WTS of autolinks with nowikis (round-trip)
29834 !! wikitext
29835 x<nowiki/>http://cscott.net<nowiki/>x
29836 !! html/parsoid
29837 <p>x<a rel="mw:ExtLink" class="external free" href="http://cscott.net">http://cscott.net</a>x</p>
29838 !! end
29839
29840 # this is the "easy" test because it leaves in place all the
29841 # data-parsoid information indicating this is an autolink
29842 !! test
29843 WTS of autolinks with escapes (editing)
29844 !! options
29845 parsoid={
29846 "modes": ["wt2wt"],
29847 "changes": [
29848 [ "span", "remove" ]
29849 ]
29850 }
29851 !! wikitext
29852 x<nowiki/>http://cscott.net<nowiki/>x
29853 !! wikitext/edited
29854 x<nowiki/>http://cscott.net<nowiki/>x
29855 !! end
29856
29857 !! test
29858 WTS of edited autolink-like text (T103364)
29859 !! options
29860 parsoid={
29861 "modes": ["wt2wt"],
29862 "changes": [
29863 [ "span[typeof]", "removeAttr", "typeof" ]
29864 ]
29865 }
29866 !! wikitext
29867 Not a link: <nowiki>http://example.com</nowiki>.
29868 !! wikitext/edited
29869 Not a link: <span><nowiki>http://example.com</nowiki></span>.
29870 !! end
29871
29872 !! test
29873 WTS of newly-authored autolink-like text (T103364)
29874 !! options
29875 parsoid=html2wt
29876 !! html/parsoid
29877 <p>http://example.com is not a link.</p>
29878 !! wikitext
29879 <nowiki>http://example.com</nowiki> is not a link.
29880 !! end
29881
29882 !! test
29883 WTS of autolink-like text after an autolink (T108563)
29884 !! options
29885 parsoid=html2wt
29886 !! html/parsoid
29887 <p><a rel="mw:ExtLink" href="http://example.com">http://example.com</a> http://example.com is not a link.</p>
29888 !! wikitext
29889 http://example.com <nowiki>http://example.com</nowiki> is not a link.
29890 !! end
29891
29892 !! test
29893 Magic links inside links (not autolinked)
29894 !! wikitext
29895 [[Foo|http://example.com]]
29896 [[Foo|RFC 1234]]
29897 [[Foo|PMID 1234]]
29898 [[Foo|ISBN 123456789x]]
29899
29900 [http://foo.com http://example.com]
29901 [http://foo.com RFC 1234]
29902 [http://foo.com PMID 1234]
29903 [http://foo.com ISBN 123456789x]
29904 !! html+tidy
29905 <p><a href="/wiki/Foo" title="Foo">http://example.com</a>
29906 <a href="/wiki/Foo" title="Foo">RFC 1234</a>
29907 <a href="/wiki/Foo" title="Foo">PMID 1234</a>
29908 <a href="/wiki/Foo" title="Foo">ISBN 123456789x</a>
29909 </p><p><a rel="nofollow" class="external text" href="http://foo.com">http://example.com</a>
29910 <a rel="nofollow" class="external text" href="http://foo.com">RFC 1234</a>
29911 <a rel="nofollow" class="external text" href="http://foo.com">PMID 1234</a>
29912 <a rel="nofollow" class="external text" href="http://foo.com">ISBN 123456789x</a>
29913 </p>
29914 !! html/parsoid
29915 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">http://example.com</a>
29916 <a rel="mw:WikiLink" href="./Foo" title="Foo">RFC 1234</a>
29917 <a rel="mw:WikiLink" href="./Foo" title="Foo">PMID 1234</a>
29918 <a rel="mw:WikiLink" href="./Foo" title="Foo">ISBN 123456789x</a></p>
29919
29920 <p><a rel="mw:ExtLink" class="external text" href="http://foo.com">http://example.com</a>
29921 <a rel="mw:ExtLink" class="external text" href="http://foo.com">RFC 1234</a>
29922 <a rel="mw:ExtLink" class="external text" href="http://foo.com">PMID 1234</a>
29923 <a rel="mw:ExtLink" class="external text" href="http://foo.com">ISBN 123456789x</a></p>
29924 !! end
29925
29926 !! test
29927 Magic links inside image captions (autolinked)
29928 !! wikitext
29929 [[File:Foobar.jpg|thumb|http://example.com]]
29930 [[File:Foobar.jpg|thumb|RFC 1234]]
29931 [[File:Foobar.jpg|thumb|PMID 1234]]
29932 [[File:Foobar.jpg|thumb|ISBN 123456789x]]
29933 !! html+tidy
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 rel="nofollow" class="external free" href="http://example.com">http://example.com</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 class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc1234">RFC 1234</a></div></div></div>
29936 <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>
29937 <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>
29938 !! html/parsoid
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 rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</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="https://tools.ietf.org/html/rfc1234" rel="mw:ExtLink" class="external mw-magiclink">RFC 1234</a></figcaption></figure>
29941 <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>
29942 <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>
29943 !! end
29944
29945 !! test
29946 WTS of magic word text (T109371)
29947 !! options
29948 parsoid=html2wt
29949 !! html/parsoid
29950 <p>RFC 1234</p>
29951 <p><a href="http://foo.com" rel="mw:ExtLink">RFC 1234</a></p>
29952 <p><a href="./Foo" rel="mw:WikiLink">RFC 1234</a></p>
29953 !! wikitext
29954 <nowiki>RFC 1234</nowiki>
29955
29956 [http://foo.com RFC 1234]
29957
29958 [[Foo|RFC 1234]]
29959 !! end
29960
29961 !! test
29962 Edited Redirect link should emit a non-piped wikitext link
29963 !! options
29964 parsoid=html2wt
29965 !! html/parsoid
29966 <link rel="mw:PageProp/redirect" href="Bar" data-parsoid='{"a":{"href":"./Foo"},"sa":{"href":"Foo"}}'>
29967 !! wikitext
29968 #REDIRECT [[Bar]]
29969 !! end
29970
29971 !! test
29972 T75121: Infer extension name from typeOf if data-mw is not present
29973 !! options
29974 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
29975 !! html/parsoid
29976 <div typeOf="mw:Extension/foo"></div>
29977 !! wikitext
29978 <foo />
29979 !! end
29980
29981 # Note that the <p> wrapping isn't present in PHP parser output
29982 # The important thing for this test is that P-wrapping doesn't
29983 # interfere with the <nowiki> protection for leading - in <td>
29984 # (which isn't necessary for <th>).
29985 !! test
29986 T88318: p-wrapped dash in table.
29987 !! options
29988 parsoid=html2wt,wt2wt
29989 !! html/parsoid
29990 <table><tbody>
29991 <tr><th><p>-</p></th><th><p>- </p></th></tr>
29992 <tr><td><p>-</p></td><td><p>- </p></td></tr>
29993 <tr><td><small>-</small></td><td><br/><p>-</p></td><td><br/>-</td></tr>
29994 </tbody></table>
29995 !! wikitext
29996 {|
29997 !-
29998 !-
29999 |-
30000 |<nowiki>-</nowiki>
30001 |<nowiki>- </nowiki>
30002 |-
30003 |<small>-</small>
30004 |<br />
30005 -
30006 |<br />-
30007 |}
30008 !! html/php+tidy
30009 <table>
30010 <tbody><tr>
30011 <th>-
30012 </th>
30013 <th>-
30014 </th></tr>
30015 <tr>
30016 <td>-
30017 </td>
30018 <td>-
30019 </td></tr>
30020 <tr>
30021 <td><small>-</small>
30022 </td>
30023 <td><br />
30024 <p>-
30025 </p>
30026 </td>
30027 <td><br />-
30028 </td></tr></tbody></table>
30029 !! end
30030
30031 !! test
30032 T149209: WTS: Handle newlines in table cells properly
30033 !! options
30034 parsoid=html2wt
30035 !! html/parsoid
30036 <table>
30037 <tbody>
30038 <tr><td>a
30039 b
30040 </td><td data-parsoid='{"stx":"row"}'>c</td></tr>
30041 <tr><td><p>x</p>
30042 </td><td data-parsoid='{"stx":"row", "startTagSrc": "{{!}}{{!}}"}'>y</td></tr>
30043 </tbody></table>
30044 <table>
30045 <tbody>
30046 <tr><th>a
30047 b
30048 </th><th data-parsoid='{"stx":"row"}'>c</th></tr>
30049 <tr><th><p>x</h>
30050 </th><th data-parsoid='{"stx":"row"}'>y</th></tr>
30051 </tbody></table>
30052 !! wikitext
30053 {|
30054 |a
30055 b
30056 |c
30057 |-
30058 |x
30059 {{!}}y
30060 |}
30061 {|
30062 !a
30063 b
30064 !c
30065 |-
30066 !x
30067 !y
30068 |}
30069 !! end
30070
30071 !! test
30072 T149209: Selser: Handle newlines in table cells properly
30073 !! options
30074 parsoid={
30075 "modes": ["selser"],
30076 "changes": [
30077 [ "#h1", "html", "a\nb\n" ],
30078 [ "#h2", "html", "a\nb\n" ],
30079 [ "#c1", "html", "a\nb\n" ],
30080 [ "#c2", "html", "<p>a</p>" ],
30081 [ "#c3", "html", "<p>a</p>" ],
30082 [ "#c4", "html", "edit-me<p>a</p>" ]
30083 ]
30084 }
30085 !! wikitext
30086 {|
30087 ! id="h1" |edit-me!!1
30088 |-
30089 ! id="h2" |edit-me||2
30090 |-
30091 | id="c1" |edit-me||3
30092 |-
30093 | id="c2" |edit-me||4
30094 |-
30095 | id="c3" |edit-me||p||q||r
30096 |-
30097 | id="c4" |edit-me||p||q||r
30098 |}
30099 !! wikitext/edited
30100 {|
30101 ! id="h1" |a
30102 b
30103 !1
30104 |-
30105 ! id="h2" |a
30106 b
30107 !2
30108 |-
30109 | id="c1" |a
30110 b
30111 |3
30112 |-
30113 | id="c2" |a
30114 |4
30115 |-
30116 | id="c3" |a
30117 |p||q||r
30118 |-
30119 | id="c4" |edit-me
30120 a
30121 |p||q||r
30122 |}
30123 !! end
30124
30125 !! test
30126 HTML id attribute with Parsoid-like element ids should not be serialized to wikitext
30127 !! options
30128 parsoid=html2wt
30129 !! html/parsoid
30130 <table id='mwAb'>
30131 <td id='mwAc'>foo</td>
30132 <td id='serialize-this'>bar</td>
30133 </table>
30134 !! wikitext
30135 {|
30136 |foo
30137 | id="serialize-this" |bar
30138 |}
30139 !! end
30140
30141 !! test
30142 Parsoid-like element ids should not be serialized to wikitext unless shadowed
30143 !! options
30144 parsoid=html2wt
30145 !! html/parsoid
30146 <div id="mwAQ" data-parsoid='{"stx":"html","a":{"id":"mwAQ"},"sa":{"id":"hello"}}'>ok</div>
30147 !! wikitext
30148 <div id="hello">ok</div>
30149 !! end
30150
30151 !! test
30152 Testing serialization after deletion in references
30153 !! options
30154 parsoid={
30155 "modes": ["wt2wt"],
30156 "changes": [
30157 ["#x", "remove"]
30158 ]
30159 }
30160 !! wikitext
30161 hi <ref><div id="x">ho</div></ref>
30162
30163 <references />
30164 !! wikitext/edited
30165 hi <ref></ref>
30166
30167 <references />
30168 !! end
30169
30170 !!test
30171 Testing serialization after deletion of table cells
30172 !!options
30173 parsoid={
30174 "modes": ["wt2wt", "selser"],
30175 "changes": [
30176 ["#x", "remove"]
30177 ]
30178 }
30179 !!wikitext
30180 {|
30181 !h1 !!h2 !!h3
30182 | id="x" |c1 {{!}}{{!}}{{!}}c2 |||c3
30183 |}
30184 !! wikitext/edited
30185 {|
30186 !h1!!h2!!h3
30187 |c2|||c3
30188 |}
30189 !!end
30190
30191 !! test
30192 Testing selser after addition of new row before first row (T125419)
30193 !! options
30194 parsoid={
30195 "modes": ["wt2wt", "selser"],
30196 "changes": [
30197 [ "tr", "before", "<tr><td>X</td></tr>" ]
30198 ]
30199 }
30200 !! wikitext
30201 {|
30202 |a
30203 |}
30204 !! wikitext/edited
30205 {|
30206 |X
30207 |-
30208 |a
30209 |}
30210 !! end
30211
30212 !! test
30213 Serialize new table rows in a HTML table using HTML tags
30214 !! options
30215 parsoid={
30216 "modes": ["wt2wt", "selser"],
30217 "changes": [
30218 [ "tr", "before", "<tr><td>X</td></tr>" ]
30219 ]
30220 }
30221 !! wikitext
30222 <table><tr><td>a</td></tr></table>
30223 !! wikitext/edited
30224 <table><tr><td>X</td></tr><tr><td>a</td></tr></table>
30225 !! end
30226
30227 !! test
30228 Serialize new table cells in a HTML row using HTML tags
30229 !! options
30230 parsoid={
30231 "modes": ["wt2wt", "selser"],
30232 "changes": [
30233 [ "td", "before", "<td>X</td>" ]
30234 ]
30235 }
30236 !! wikitext
30237 <table><tr><td>a</td></tr></table>
30238 !! wikitext/edited
30239 <table><tr><td>X</td><td>a</td></tr></table>
30240 !! end
30241
30242 !! test
30243 Serialize wikitext list items as HTML list items when embedded in a HTML list
30244 !! options
30245 parsoid=html2wt
30246 !! html/parsoid
30247 <ul data-parsoid='{"stx": "html"}'>
30248 <li data-parsoid='{}'>a</li>
30249 <li>b</li>
30250 </ul>
30251 !! wikitext
30252 <ul>
30253 <li>a</li>
30254 <li>b</li>
30255 </ul>
30256 !! html/php+tidy
30257 <ul>
30258 <li>a</li>
30259 <li>b</li>
30260 </ul>
30261 !! end
30262
30263 # Nested list should be inside <li>, that is
30264 # <ul><li>foo<ul>..</ul></li></ul> instead of
30265 # <ul><li>foo</li><ul>..</ul></ul>
30266 # See https://stackoverflow.com/questions/5899337/proper-way-to-make-html-nested-list
30267 !! test
30268 Wikitext lists can be nested inside HTML lists
30269 !! options
30270 parsoid=html2wt
30271 !! html/parsoid
30272 <ul data-parsoid='{"stx": "html"}'>
30273 <li data-parsoid='{"stx": "html"}'>a
30274 <ul><li>b</li></ul>
30275 </li>
30276 </ul>
30277
30278 <ul data-parsoid='{"stx": "html"}'>
30279 <li>x
30280 <ul><li>y</li></ul>
30281 </li>
30282 </ul>
30283 !! wikitext
30284 <ul>
30285 <li>a
30286 * b
30287 </li>
30288 </ul>
30289
30290 <ul>
30291 <li>x
30292 * y
30293 </li>
30294 </ul>
30295 !! html/php+tidy
30296 <ul>
30297 <li>a
30298 <ul><li>b</li></ul>
30299 </li>
30300 </ul>
30301 <ul>
30302 <li>x
30303 <ul><li>y</li></ul>
30304 </li>
30305 </ul>
30306 !! end
30307
30308 !! test
30309 WTS change modes
30310 !! options
30311 parsoid={
30312 "modes": ["wt2wt"],
30313 "changes": [
30314 [ "#xyz", "before", "<b>before</b> stuff " ],
30315 [ "#xyz", "after", " stuff <i>after</i>" ],
30316 [ "#xyz", "html", "x <b>y</b> z" ]
30317 ]
30318 }
30319 !! wikitext
30320 <span id="xyz">hello</span>
30321 !! wikitext/edited
30322 '''before''' stuff <span id="xyz">x '''y''' z</span> stuff ''after''
30323 !! end
30324
30325 !! test
30326 Never serialize a-tag as html, regardless of what data-parsoid has to say
30327 !! options
30328 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
30329 !! html/parsoid
30330 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"html"}'>Foo</a>
30331 !! wikitext
30332 [[Foo]]
30333 !! end
30334
30335 ## SSS FIXME: This is broken output nevertheless.
30336 ## What might be a reasonable non-broken output for this?
30337 ## This is an edge case unlikely to be seen in production
30338 ## that I am not wasting more time on this right now.
30339 !! test
30340 Never serialize a-tag as html, no matter what attributes it has
30341 !! options
30342 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
30343 !! html/parsoid
30344 <a bad='true' href='http://boo.org'><img src='http://boohoo.org' /></a>
30345 !! wikitext
30346 [http://boo.org http://boohoo.org]
30347 !! end
30348
30349 # Misnested is an indication that selser can reuse the source but these have
30350 # shown to sneak through on occasion. See T101768.
30351 # The original wikitext here is: [http://test.com [[one]] two three]
30352 !! test
30353 Strip span tags added to mark misnested links
30354 !! options
30355 parsoid=html2wt
30356 !! html/parsoid
30357 <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>
30358 !! wikitext
30359 [http://test.com][[one]] two three
30360 !! end
30361
30362 !! test
30363 Catch regression when unpacking misnested links
30364 !! options
30365 parsoid=wt2html
30366 !! wikitext
30367 {{echo|hi}}[http://example.com [[ho]]]
30368 !! html/parsoid
30369 <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>
30370 !! end
30371
30372 !! test
30373 Catch regression when unpacking with trailing content
30374 !! wikitext
30375 {{echo|Foo <references/> bar}}
30376 !! html/parsoid
30377 <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>
30378 !! end
30379
30380 !! test
30381 Use data-parsoid.firstWikitextNode to compute newline constraints for template content
30382 !! options
30383 parsoid=html2wt
30384 !! html/parsoid
30385 <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|}"]}'>
30386 <tbody><tr><td>d
30387 </td></tr>
30388 </tbody></table>
30389 !! wikitext
30390 {{echo|a}}
30391 {|{{echo|c
30392 {{!}}d
30393 }}
30394 |}
30395 !! end
30396
30397 ## This test verifies the presence and computation of this attribute indirectly
30398 ## by making an edit and ensuring that the serialization is correct (which it would be
30399 ## only if firstWikitextNode is properly set).
30400 !! test
30401 data-parsoid.firstWikitextNode should be computed properly in the presence of fostered content
30402 !! options
30403 parsoid= {
30404 "modes": ["wt2wt"],
30405 "changes": [
30406 [ "div#x", "remove" ],
30407 [ "div", "before", "<div>new</div>" ]
30408 ]
30409 }
30410 !! wikitext
30411 <div id="x">foo</div>
30412 {|
30413 {{echo|<div>boo</div>
30414 {{!}}b}}
30415 |c
30416 |}
30417 !! wikitext/edited
30418
30419 <div>new</div>
30420 {|
30421 {{echo|<div>boo</div>
30422 {{!}}b}}
30423 |c
30424 |}
30425 !! end
30426
30427 # --------------------------------------------
30428 # Tests spec'ing wikitext serialization norms |
30429 # --------------------------------------------
30430
30431 !! test
30432 Serialize multi-line indent-pre starting with wikitext syntax
30433 !! options
30434 parsoid=html2wt
30435 !! html/parsoid
30436 <pre>* 1
30437 ** 2
30438 * 3</pre>
30439 !! wikitext
30440 * 1
30441 ** 2
30442 * 3
30443 !! end
30444
30445 !! test
30446 1. Categories should always be serialized on their own line
30447 !! options
30448 parsoid=html2wt
30449 !! html/parsoid
30450 foo<link rel="mw:PageProp/Category" href="./Category:Foo">bar
30451 !! wikitext
30452 foo
30453 [[Category:Foo]]
30454 bar
30455 !! end
30456
30457 !! test
30458 2. Categories that are part of templates should not introduce a line break
30459 !! wikitext
30460 foo {{echo|<span>bar</span> [[Category:baz]]}} bar
30461 !! html/parsoid
30462 <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>
30463 !! end
30464
30465 # Careful while editing these next 2 tests. There are \u200f characters
30466 # before and after the <link> tags in the HTML and following some
30467 # of the categories in wikitext
30468 # Do not remove these characters in edits.
30469 #
30470 # As part of the serialization, these bidi characters will get stripped.
30471 !! test
30472 RTL (\u200f) and LTR (\u200e) markers around category tags should be stripped
30473 !! options
30474 parsoid={
30475 "modes": ["html2wt"],
30476 "scrubWikitext": true
30477 }
30478 !! html/parsoid
30479 <p>‏<link rel="mw:PageProp/Category" href="./קטגוריה:טקסים" />‏
30480 ‏<link rel="mw:PageProp/Category" href="./קטגוריה:_שיטות_משפט" />‏</p>
30481 !! wikitext
30482 [[קטגוריה:טקסים]]
30483 [[קטגוריה: שיטות משפט]]
30484 !! end
30485
30486 !! test
30487 RTL (\u200f) and LTR (\u200e) markers should not be stripped if followed by a text node
30488 !! options
30489 parsoid={
30490 "modes": ["html2wt"],
30491 "scrubWikitext": true
30492 }
30493 !! html/parsoid
30494 <p>‏<link rel="mw:PageProp/Category" href="./קטגוריה:טקסים" />‏y</p>
30495 !! wikitext
30496 [[קטגוריה:טקסים]]
30497 ‏y
30498 !! end
30499
30500 !! test
30501 Lists: Add space after bullets
30502 !! options
30503 parsoid=html2wt
30504 !! html/parsoid
30505 <ul>
30506 <li>foo</li>
30507 <li> bar</li>
30508 <li><span> baz</span></li>
30509 </ul>
30510 !! wikitext
30511 * foo
30512 * bar
30513 * <span> baz</span>
30514 !! end
30515
30516 !! test
30517 1. Headings: Add space before/after == (T53744)
30518 !! options
30519 parsoid=html2wt
30520 !! html/parsoid
30521 <h2>foo</h2>
30522 <h2> bar</h2>
30523 <h2>baz </h2>
30524 <h2><span> baz</span></h2>
30525 !! wikitext
30526 == foo ==
30527
30528 == bar ==
30529
30530 == baz ==
30531
30532 == <span> baz</span> ==
30533 !! end
30534
30535 !! test
30536 2. Headings: Add space before/after == even after hoisted content
30537 !! options
30538 parsoid={
30539 "modes": ["html2wt"],
30540 "scrubWikitext": true
30541 }
30542 !! html/parsoid
30543 <h2> <link href="./Category:A2" rel="mw:PageProp/Category" />ok</h2>
30544 !! wikitext
30545 [[Category:A2]]
30546
30547 == ok ==
30548 !! end
30549
30550 !! test
30551 1. Headings: suppress newly created empty headings
30552 !! options
30553 parsoid={
30554 "modes": ["html2wt"],
30555 "scrubWikitext": true
30556 }
30557 !! html/parsoid
30558 <h2></h2>
30559 !! wikitext
30560 !! end
30561
30562 !! test
30563 2. Headings: don't suppress empty headings if scrubWikitext is false
30564 !! options
30565 parsoid=html2wt
30566 !! html/parsoid
30567 <h2></h2>
30568 !! wikitext
30569 ==<nowiki/>==
30570 !! end
30571
30572 !! test
30573 3. Headings: suppress empty headings on edits
30574 !! options
30575 parsoid={
30576 "modes": ["selser"],
30577 "scrubWikitext": true,
30578 "changes": [
30579 [ "#x", "remove"]
30580 ]
30581 }
30582 !! wikitext
30583 ==<span id="x">foo</span>==
30584 !! wikitext/edited
30585 !! end
30586
30587 !! test
30588 Headings: Replace <br/> with a single whitespace char (when scrubWikitext = true)
30589 !! options
30590 parsoid={
30591 "modes": ["html2wt"],
30592 "scrubWikitext": true
30593 }
30594 !! html/parsoid
30595 <h2>foo<br/>bar</h2>
30596 <h2>foo <span><br/>bar</span> baz</h2>
30597 !! wikitext
30598 == foo bar ==
30599
30600 == foo <span> bar</span> baz ==
30601 !! end
30602
30603 !! test
30604 Headings: Replace <br/> with a single whitespace char (when scrubWikitext = false)
30605 !! options
30606 parsoid={
30607 "modes": ["html2wt"],
30608 "scrubWikitext": false
30609 }
30610 !! html/parsoid
30611 <h2>foo<br/>bar</h2>
30612 !! wikitext
30613 == foo<br />bar ==
30614 !! end
30615
30616 !! test
30617 1. WT Quote Tags: suppress newly created empty style tags
30618 !! options
30619 parsoid={
30620 "modes": ["html2wt"],
30621 "scrubWikitext": true
30622 }
30623 !! html/parsoid
30624 <i></i><b></b>
30625 !! wikitext
30626 !! end
30627
30628 !! test
30629 2. WT Quote Tags: don't suppress empty style tags if scrubWikitext is false
30630 !! options
30631 parsoid=html2wt
30632 !! html/parsoid
30633 <i></i><b></b>
30634 !! wikitext
30635 ''<nowiki/>'''''<nowiki/>'''
30636 !! end
30637
30638 !! test
30639 3. WT Quote Tags: suppress empty style tags on edits
30640 !! options
30641 parsoid={
30642 "modes": ["selser"],
30643 "scrubWikitext": true,
30644 "changes": [
30645 [ "#x", "remove"]
30646 ]
30647 }
30648 !! wikitext
30649 '''<span id="x">foo</span>'''
30650 !! wikitext/edited
30651 !! end
30652
30653 !! test
30654 1. Anchors: suppress newly created empty anchors
30655 !! options
30656 parsoid={
30657 "modes": ["html2wt"],
30658 "scrubWikitext": true
30659 }
30660 !! html/parsoid
30661 <a rel="mw:WikiLink" href="./Test" title="Test"></a>
30662 !! wikitext
30663 !! end
30664
30665 !! test
30666 2. Anchors: don't suppress empty anchors if scrubWikitext is false
30667 !! options
30668 parsoid={
30669 "modes": ["html2wt"],
30670 "scrubWikitext": false
30671 }
30672 !! html/parsoid
30673 <a rel="mw:WikiLink" href="./Test" title="Test"></a>
30674 !! wikitext
30675 [[Test|<nowiki/>]]
30676 !! end
30677
30678 !! test
30679 3. Anchors: suppress empty anchors on edits
30680 !! options
30681 parsoid={
30682 "modes": ["selser"],
30683 "scrubWikitext": true,
30684 "changes": [
30685 [ "#x", "remove"]
30686 ]
30687 }
30688 !! wikitext
30689 [[Test|<span id="x">foo</span>]]
30690 !! wikitext/edited
30691 !! end
30692
30693 !! test
30694 3a. Anchors: do not suppress numbered extlinks
30695 !! options
30696 parsoid={
30697 "modes": ["wt2wt"],
30698 "scrubWikitext": true
30699 }
30700 !! wikitext
30701 [http://foo.com]
30702 !! html/parsoid
30703 <a rel="mw:ExtLink" href="http://foo.com"></a>
30704 !! end
30705
30706 !! test
30707 3b. Anchors: do not suppress numbered extlinks
30708 !! options
30709 parsoid={
30710 "modes": ["wt2wt"],
30711 "scrubWikitext": true,
30712 "changes": [
30713 [ "#x", "remove"]
30714 ]
30715 }
30716 !! wikitext
30717 [http://foo.com <span id="x">foo</span>]
30718 !! wikitext/edited
30719 [http://foo.com]
30720 !! end
30721
30722 !!test
30723 Normalizations should be restricted to edited content
30724 !!options
30725 parsoid={
30726 "modes": ["selser"],
30727 "scrubWikitext": true,
30728 "changes": [
30729 [ "h1", "before", "<i></i>"]
30730 ]
30731 }
30732 !!wikitext
30733 a
30734 = =
30735 b
30736 !!wikitext/edited
30737 a
30738 = =
30739 b
30740 !!end
30741
30742 !! test
30743 1. Multiple normalizations (html2wt)
30744 !! options
30745 parsoid={
30746 "modes": ["html2wt"],
30747 "scrubWikitext": true
30748 }
30749 !! html/parsoid
30750 <h2><i></i></h2>
30751 <p><a href='Foo' rel='mw:WikiLink'>foo<i></i>
30752 </a><b><i></i></b>x</p>
30753 !! wikitext
30754
30755 [[foo]]
30756 x
30757
30758 !! end
30759
30760 !! test
30761 2. Multiple normalizations (selser)
30762 !! options
30763 parsoid={
30764 "modes": ["selser"],
30765 "scrubWikitext": true,
30766 "changes": [
30767 [ "#x", "after", "<h1><i></i></h1>\n<p> bar<b></b></p>"]
30768 ]
30769 }
30770 !! wikitext
30771 <div id="x">foo</div>
30772 !! wikitext/edited
30773 <div id="x">foo</div>
30774 bar
30775 !! end
30776
30777 !! test
30778 1. Indent Pre Nowiki: suppress whitespace at the start of new paragraph
30779 !! options
30780 parsoid={
30781 "modes": ["html2wt"],
30782 "scrubWikitext": true
30783 }
30784 !! html/parsoid
30785 <p> hi</p>
30786 <p> hello</p>
30787 !! wikitext
30788 hi
30789
30790 hello
30791 !! end
30792
30793 !! test
30794 2. Indent Pre Nowiki: don't suppress whitespace at the start of new paragraph if scrubWikitext is false
30795 !! options
30796 parsoid=html2wt
30797 !! html/parsoid
30798 <p> hi</p>
30799 <p> hello</p>
30800 !! wikitext
30801 <nowiki> </nowiki>hi
30802
30803 <nowiki> </nowiki> hello
30804 !! end
30805
30806 !! test
30807 3. Indent Pre Nowiki: suppress whitespace after newlines in new paragraph or table cell
30808 !! options
30809 parsoid={
30810 "modes": ["html2wt"],
30811 "scrubWikitext": true
30812 }
30813 !! html/parsoid
30814 <p>Foo
30815 bar
30816 baz</p>
30817
30818 <table><tr><td>Foo
30819 bar
30820 baz bang</td></tr></table>
30821
30822 <p><!--boo--> foo
30823 bar</p>
30824
30825 <p> foo
30826 bar<span>boo</span></p>
30827 !! wikitext
30828 Foo
30829 bar
30830 baz
30831
30832 {|
30833 |Foo
30834 bar
30835 baz bang
30836 |}
30837
30838 <!--boo-->foo
30839 bar
30840
30841 foo
30842 bar<span>boo</span>
30843 !! end
30844
30845 !! test
30846 4. Indent Pre Nowiki: suppress leading whitespace in edited paragraphs
30847 !! options
30848 parsoid={
30849 "modes": ["selser"],
30850 "scrubWikitext": true,
30851 "changes": [
30852 [ "p", "html", " a\n b" ]
30853 ]
30854 }
30855 !! wikitext
30856 xyz
30857 !! wikitext/edited
30858 a
30859 b
30860 !! end
30861
30862 !! test
30863 1. New links that end in spaces
30864 !! options
30865 parsoid={
30866 "modes": ["html2wt"],
30867 "scrubWikitext": false
30868 }
30869 !! html/parsoid
30870 <p><a rel="mw:WikiLink" href="./Berlin" title="Berlin">Berlin </a>is the capital of Germany.</p>
30871 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo </a><b>bar</b></p>
30872 <p><a rel="mw:WikiLink" href="./Boston" title="Boston">Boston </a> is a city.</p>
30873 !! wikitext
30874 [[Berlin ]]<nowiki/>is the capital of Germany.
30875
30876 [[Foo ]]'''bar'''
30877
30878 [[Boston ]] is a city.
30879 !! end
30880
30881 !! test
30882 2. New links that end in spaces
30883 !! options
30884 parsoid={
30885 "modes": ["html2wt"],
30886 "scrubWikitext": true
30887 }
30888 !! html/parsoid
30889 <p><a rel="mw:WikiLink" href="./Berlin" title="Berlin">Berlin </a>is the capital of Germany.</p>
30890 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo </a><b>bar</b></p>
30891 <p><a rel="mw:WikiLink" href="./Boston" title="Boston">Boston </a> is a city.</p>
30892 !! wikitext
30893 [[Berlin]] is the capital of Germany.
30894
30895 [[Foo]] '''bar'''
30896
30897 [[Boston]] is a city.
30898 !! end
30899
30900 !! test
30901 1. Table cells with escapable prefixes
30902 !! options
30903 parsoid={
30904 "modes": ["html2wt"],
30905 "scrubWikitext": false
30906 }
30907 !! html/parsoid
30908 <table>
30909 <tr><td>a</td></tr>
30910 <tr><td>-</td></tr>
30911 <tr><td>+</td></tr>
30912 <tr><td>}</td></tr>
30913 </table>
30914 !! wikitext
30915 {|
30916 |a
30917 |-
30918 |<nowiki>-</nowiki>
30919 |-
30920 |<nowiki>+</nowiki>
30921 |-
30922 |<nowiki>}</nowiki>
30923 |}
30924 !! end
30925
30926 !! test
30927 2. Table cells with escapable prefixes
30928 !! options
30929 parsoid={
30930 "modes": ["html2wt"],
30931 "scrubWikitext": true
30932 }
30933 !! html/parsoid
30934 <table>
30935 <tr><td>a</td></tr>
30936 <tr><td>-</td></tr>
30937 <tr><td>+</td></tr>
30938 <tr><td>}</td></tr>
30939 </table>
30940 !! wikitext
30941 {|
30942 |a
30943 |-
30944 | -
30945 |-
30946 | +
30947 |-
30948 | }
30949 |}
30950 !! end
30951
30952 !! test
30953 3a. Table cells with escapable prefixes after edits
30954 !! options
30955 parsoid={
30956 "modes": ["selser"],
30957 "scrubWikitext": true,
30958 "changes": [
30959 [ "table tbody tr:first-child td:first-child", "remove"]
30960 ]
30961 }
30962 !! wikitext
30963 {|
30964 |a||-
30965 |}
30966 !! wikitext/edited
30967 {|
30968 | -
30969 |}
30970 !! end
30971
30972 !! test
30973 3b. Table cells with escapable prefixes after edits
30974 !! options
30975 parsoid={
30976 "modes": ["selser"],
30977 "scrubWikitext": true,
30978 "changes": [
30979 [ "table tbody tr:first-child td:first-child", "html", "-" ],
30980 [ "#x", "remove" ]
30981 ]
30982 }
30983 !! wikitext
30984 {|
30985 |pqr
30986 |<span id="x">foo</span>+
30987 |}
30988 !! wikitext/edited
30989 {|
30990 | -
30991 | +
30992 |}
30993 !! end
30994
30995 # FIXME: This test will fail because
30996 # normalization doesn't realize that the id attribute
30997 # will eliminate the escapable scenario
30998 !! test
30999 4a. Table cells without escapable prefixes after edits
31000 !! options
31001 parsoid={
31002 "modes": ["selser"],
31003 "scrubWikitext": true,
31004 "changes": [
31005 [ "#x", "html", "-" ]
31006 ]
31007 }
31008 !! wikitext
31009 {|
31010 | id="x" |abcd
31011 |}
31012 !! wikitext/edited
31013 {|
31014 | id="x" |-
31015 |}
31016 !! end
31017
31018 ## This tests normalizer's ability to discriminate between
31019 ## cells having identical content.
31020 !! test
31021 4b. Table cells without escapable prefixes after edits
31022 !! options
31023 parsoid={
31024 "modes": ["selser"],
31025 "scrubWikitext": true,
31026 "changes": [
31027 [ "td", "html", "-" ]
31028 ]
31029 }
31030 !! wikitext
31031 {|
31032 |a||b
31033 |}
31034 !! wikitext/edited
31035 {|
31036 | -||-
31037 |}
31038 !! end
31039
31040 ## This tests normalizer's ability to not be tripped by
31041 ## comments (and whitespace)
31042 !! test
31043 4c. Table cells without escapable prefixes after edits
31044 !! options
31045 parsoid={
31046 "modes": ["selser"],
31047 "scrubWikitext": true,
31048 "changes": [
31049 [ "table tbody tr td:first-child", "remove" ]
31050 ]
31051 }
31052 !! wikitext
31053 {|
31054 |-
31055 <!--foo--> |a||-
31056 |}
31057 !! wikitext/edited
31058 {|
31059 |-
31060 <!--foo--> | -
31061 |}
31062 !! end
31063
31064 ## This tests normalizer's ability to handle HTML cells
31065 !! test
31066 4d. Table cells without escapable prefixes after edits
31067 !! options
31068 parsoid={
31069 "modes": ["selser"],
31070 "scrubWikitext": true,
31071 "changes": [
31072 [ "td", "html", "-" ]
31073 ]
31074 }
31075 !! wikitext
31076 <table>
31077 <tr><td>a</td></tr>
31078 </table>
31079 !! wikitext/edited
31080 <table>
31081 <tr><td>-</td></tr>
31082 </table>
31083 !! end
31084
31085 ## T111151 Remove font elements without attributes
31086 !! test
31087 5a. font tags without attributes should be dropped in scrubWikitext mode
31088 !! options
31089 parsoid={
31090 "modes": ["html2wt"],
31091 "scrubWikitext": true
31092 }
31093 !! html/parsoid
31094 <font>foo</font>
31095 <font><font>bar</font></font>
31096 <font class="x">boo</font>
31097 !! wikitext
31098 foo
31099 bar
31100 <font class="x">boo</font>
31101 !! end
31102
31103 !! test
31104 5b. font tags should not be dropped without scrubWikitext being enabled
31105 !! options
31106 parsoid={
31107 "modes": ["html2wt"],
31108 "scrubWikitext": false
31109 }
31110 !! html/parsoid
31111 <font>foo</font>
31112 !! wikitext
31113 <font>foo</font>
31114 !! end
31115
31116 !! test
31117 Ignore empty <p></p> when scrubWikitext is false
31118 !! options
31119 parsoid={
31120 "modes": ["html2wt"],
31121 "scrubWikitext": false
31122 }
31123 !! html/parsoid
31124 <div>1</div>
31125 <p>a</p><p></p><p>b</p>
31126 <div>2</div>
31127 <p>a</p>
31128 <p></p>
31129 <p>b</p>
31130 <div>3</div>
31131 <p>a</p>
31132 <p></p>
31133 <p></p>
31134 <p></p>
31135 <p></p>
31136 <p>b</p>
31137 !! wikitext
31138 <div>1</div>
31139 a
31140
31141 b
31142 <div>2</div>
31143 a
31144
31145 b
31146 <div>3</div>
31147 a
31148
31149 b
31150 !! html/php+tidy
31151 <div>1</div>
31152 <p>a
31153 </p><p>b
31154 </p>
31155 <div>2</div>
31156 <p>a
31157 </p><p>b
31158 </p>
31159 <div>3</div>
31160 <p>a
31161 </p><p>b
31162 </p>
31163 !! end
31164
31165 !! test
31166 Normalize empty paragraphs to HTML form that html2wt expects
31167 !! options
31168 parsoid={
31169 "modes": ["html2wt"],
31170 "scrubWikitext": true
31171 }
31172 !! html/parsoid
31173 <div>1</div>
31174 <p>a</p><p></p><p>b</p>
31175 <div>2</div>
31176 <p>a</p>
31177 <p></p>
31178 <p>b</p>
31179 <div>3</div>
31180 <p>a</p>
31181 <p></p>
31182 <p></p>
31183 <p></p>
31184 <p></p>
31185 <p>b</p>
31186 <div>4</div>
31187 <p>a</p>
31188 <p></p>
31189 <div>foo</div>
31190 !! wikitext
31191 <div>1</div>
31192 a
31193
31194
31195 b
31196 <div>2</div>
31197 a
31198
31199
31200 b
31201 <div>3</div>
31202 a
31203
31204
31205
31206
31207
31208 b
31209 <div>4</div>
31210 a
31211
31212 <br />
31213 <div>foo</div>
31214 !! html/php+tidy
31215 <div>1</div>
31216 <p>a
31217 </p><p><br />
31218 b
31219 </p>
31220 <div>2</div>
31221 <p>a
31222 </p><p><br />
31223 b
31224 </p>
31225 <div>3</div>
31226 <p>a
31227 </p><p><br />
31228 </p><p><br />
31229 </p><p>b
31230 </p>
31231 <div>4</div>
31232 <p>a
31233 </p><p><br />
31234 </p>
31235 <div>foo</div>
31236 !! end
31237
31238 !! test
31239 Empty paragraphs (marked with mw-empty-elt) found in source should not be normalized away
31240 !! options
31241 parsoid={
31242 "modes": ["html2wt"],
31243 "scrubWikitext": true
31244 }
31245 !! html/parsoid
31246 <table>
31247 <tbody>
31248 <tr>
31249 <td><div>foo
31250 </div>
31251 <p class="mw-empty-elt"></p>
31252 </td>
31253 </tr>
31254 </tbody>
31255 <caption></caption>
31256 </table>
31257 !! wikitext
31258 {|
31259 |<div>foo
31260 </div>
31261 |+
31262 |}
31263 !! end
31264
31265 !! test
31266 Templated content should be skipped over by normalization
31267 !! options
31268 parsoid={
31269 "modes": ["html2wt"],
31270 "scrubWikitext": true
31271 }
31272 !! html/parsoid
31273 <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">
31274 </span><p about="#mwt2"></p><span about="#mwt2">
31275 </span>
31276 !! wikitext
31277 {{SomeTemplate1|boo}}{{SomeTemplate2|booboo}}
31278 !! end
31279
31280 !! test
31281 Escape nowiki DOM elements
31282 !! options
31283 parsoid=html2wt
31284 !! html/parsoid
31285 <nowiki><i>foo</i></nowiki>
31286 !! wikitext
31287 &lt;nowiki&gt;''foo''&lt;/nowiki&gt;
31288 !! end
31289
31290 # This is meant to be an interim fix while we go about figuring out
31291 # how to not introduce these trailing <nowiki/>s in the first place.
31292 !! test
31293 T115717: Strip trailing <nowiki/>s (without affecting valid uses)
31294 !! options
31295 parsoid=html2wt
31296 !! html/parsoid
31297 <p>x<meta typeof="mw:Placeholder" data-parsoid='{"src":"&lt;nowiki/>"}'/><meta typeof="mw:Placeholder" data-parsoid='{"src":"&lt;nowiki/>"}'/>
31298 y</p>
31299 <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>
31300 <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>
31301 !! wikitext
31302 x
31303 y
31304
31305 {{echo|
31306 1 = <nowiki/>}}
31307
31308 {{echo|
31309 1 = <nowiki/>
31310 }}
31311 !! end
31312
31313 !! test
31314 New list is serialized on newlines
31315 !! options
31316 parsoid=html2wt
31317 !! html/parsoid
31318 <p>The quick brown fox jumps over the lazy dog.</p><ul>
31319 <li>Yesterday</li>
31320 <li>Today</li>
31321 <li>Tomorrow</li>
31322 </ul><p>The quick onyx goblin jumps over the lazy dwarf.</p>
31323 !! wikitext
31324 The quick brown fox jumps over the lazy dog.
31325
31326 * Yesterday
31327 * Today
31328 * Tomorrow
31329
31330 The quick onyx goblin jumps over the lazy dwarf.
31331 !! end
31332
31333 !! test
31334 New lists in formatting elements serialized w/o newlines
31335 !! options
31336 parsoid=html2wt
31337 !! html/parsoid
31338 <small>
31339
31340 <ul>
31341 <li>123</li>
31342 </ul>
31343
31344 </small>
31345
31346 <small><ul><li>hi</li></ul></small>
31347 !! wikitext
31348 <small>
31349 * 123
31350 </small>
31351
31352 <small>
31353 * hi
31354 </small>
31355 !! end
31356
31357 !! test
31358 New list in table doesn't need newlines
31359 !! options
31360 parsoid=html2wt
31361 !! html/parsoid
31362 <table><tr><td><ul><li>test</li><li>123</li></td></tr></table>
31363 !! wikitext
31364 {|
31365 |
31366 * test
31367 * 123
31368 |}
31369 !! end
31370
31371 # ---------------------------------------------------
31372 # End of tests spec'ing wikitext serialization norms |
31373 # ---------------------------------------------------
31374
31375 # T104032
31376 !! test
31377 Bare inline nodes not wrapped inside p-tags should be treated as p-wrapped
31378 !! options
31379 parsoid=html2wt
31380 !! html/parsoid
31381 a<p>b</p>
31382 <b>c</b><p>d</p>
31383 <table><tr>
31384 <td>a<p>b</p></td>
31385 <td><b>c</b><p>d</p></td>
31386 </tr></table>
31387 !! wikitext
31388 a
31389
31390 b
31391
31392 '''c'''
31393
31394 d
31395 {|
31396 |a
31397 b
31398 |'''c'''
31399 d
31400 |}
31401 !! end
31402
31403 !! test
31404 Anchor without href scenarios
31405 !! options
31406 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
31407 !! html/parsoid
31408 <a class="bc"></a>
31409 <a class="no">dice</a>
31410 <a name="foo"></a>
31411 !! wikitext
31412
31413 dice
31414 <span name="foo"></span>
31415 !! end
31416
31417 !! test
31418 New transclusion added after a list should be serialized after the list
31419 !! options
31420 parsoid=html2wt
31421 !! html/parsoid
31422 <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>
31423 !! wikitext
31424 * a
31425 {{echo|foo}}
31426 !! end
31427
31428 # -----------------------------------------------------------------
31429 # End of section for Parsoid-only html2wt tests for serialization
31430 # of new content
31431 # -----------------------------------------------------------------
31432
31433 # -----------------------------------------------------------------
31434 # The following section of tests are primarily to spec behavior of
31435 # the selective serializer. All these tests have manual selser
31436 # changes. The automated selser changes for all tests handle the
31437 # wide variation of changes, but these tests here capture specs
31438 # deterministically.
31439 # ----------------------------------------------------------------
31440
31441 ## T90517
31442 !! test
31443 Selser: New comments should not be lost
31444 !! options
31445 parsoid={
31446 "modes": ["selser"],
31447 "changes": [
31448 [ "#a", "after", "<!--c1-->" ],
31449 [ "#b", "before", "<!--c2-->" ]
31450 ]
31451 }
31452 !! wikitext
31453 <span id="a">a</span>
31454
31455 <span id="b">b</span>
31456 !! wikitext/edited
31457 <span id="a">a</span><!--c1-->
31458
31459 <!--c2--><span id="b">b</span>
31460 !! end
31461
31462 ## T89383
31463 !! test
31464 Selser: Check for validity of DSR before using it
31465 !! options
31466 parsoid={
31467 "modes": ["selser"],
31468 "changes": [
31469 [ "#a", "before", "<meta property='mw:PageProp/displaytitle' content='foo'>" ]
31470 ]
31471 }
31472 !! wikitext
31473 <span id="a">a</span>
31474 !! wikitext/edited
31475 {{DISPLAYTITLE:foo}}
31476 <span id="a">a</span>
31477 !! end
31478
31479 !! test
31480 1. DOMDiff: Changes to <ref> content should be looked up using id
31481 !! options
31482 parsoid={
31483 "modes": ["selser"],
31484 "changes": [
31485 ["#X", "after", "bar"],
31486 ["#Y", "after", "baz"]
31487 ]
31488 }
31489 !! wikitext
31490 X <ref><span id="X">foo</span></ref>
31491 Y <ref name="a" />
31492 <references>
31493 <ref name="a"><span id="Y">foo</span></ref>
31494 </references>
31495 !! wikitext/edited
31496 X <ref><span id="X">foo</span>bar</ref>
31497 Y <ref name="a" />
31498 <references>
31499 <ref name="a"><span id="Y">foo</span>baz</ref>
31500 </references>
31501 !! end
31502
31503 !! test
31504 2. DOMDiff: Changes to <ref> content should be looked up using id
31505 !! options
31506 parsoid={
31507 "modes": ["selser"],
31508 "changes": [
31509 ["#Z", "after", "bar"]
31510 ]
31511 }
31512 !! wikitext
31513 A <ref>foo bar for a</ref>
31514 B <ref group="X" name="b" />
31515
31516 <references />
31517
31518 <references group="X">
31519 <ref name="b"><span id="Z">foo</span></ref>
31520 </references>
31521 !! wikitext/edited
31522 A <ref>foo bar for a</ref>
31523 B <ref group="X" name="b" />
31524
31525 <references />
31526
31527 <references group="X">
31528 <ref name="b"><span id="Z">foo</span>bar</ref>
31529 </references>
31530 !! end
31531
31532 !! test
31533 DOMDiff: Edits to content nested in elements with templated attributes should not be lost (T139388)
31534 !! options
31535 parsoid={
31536 "modes": ["selser"],
31537 "changes": [
31538 [ "div:first-child", "text", "bar" ]
31539 ]
31540 }
31541 !! wikitext
31542 <div style="{{1x|color:red;}}%">foo</div>
31543 !! wikitext/edited
31544 <div style="{{1x|color:red;}}%">bar</div>
31545 !! end
31546
31547 !! test
31548 Empty LI (T49673)
31549 !! wikitext
31550 *a
31551 *
31552 *
31553 *b
31554 !! html+tidy
31555 <ul><li>a</li>
31556 <li class="mw-empty-elt"></li>
31557 <li class="mw-empty-elt"></li>
31558 <li>b</li></ul>
31559 !! end
31560
31561 !! test
31562 Thumbnail output
31563 !! wikitext
31564 [[File:Thumb.png|thumb]]
31565 !! html/php+tidy
31566 <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>
31567 !! html/parsoid
31568 <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>
31569 !! end
31570
31571 !! test
31572 unclosed internal link XSS (T137264)
31573 !! wikitext
31574 [[#%3Cscript%3Ealert(1)%3C/script%3E|
31575 !! html/php
31576 <p>[[#&lt;script&gt;alert(1)&lt;/script&gt;|
31577 </p>
31578 !! html/parsoid
31579 <p>[[#%3Cscript%3Ealert(1)%3C/script%3E|</p>
31580 !! end
31581
31582 !! test
31583 Validating that <style> isn't eaten by tidy (T167349)
31584 !! options
31585 styletag=1
31586 !! wikitext
31587 <div class="foo">
31588 <style>.foo::before { content: "<foo>"; }</style>
31589 <style data-mw-foobar="baz">.foo::after { content: "<bar>"; }</style>
31590 </div>
31591 !! html/php+tidy
31592 <div class="foo">
31593 <style>.foo::before { content: "<foo>"; }</style>
31594 <style data-mw-foobar="baz">.foo::after { content: "<bar>"; }</style>
31595 </div>
31596 !! html/parsoid
31597 <div class="foo">
31598 <style typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{},"body":{"extsrc":".foo::before { content: \"&lt;foo>\"; }"}}'>.foo::before { content: "<foo>"; }</style>
31599 <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>
31600 </div>
31601 !! end
31602
31603 ## Right now, Parsoid doesn't de-duplicate style tags.
31604 ## So, we shouldn't see link tags that need to bypass the sanitizer.
31605 ## In a followup patch, when we de-duplicate style tags and
31606 ## introduce link tags, we'll add a hook for link tags in
31607 ## the parser test runner script.
31608 !! test
31609 Validating that <style> isn't wrapped in a paragraph (T186965)
31610 !! options
31611 styletag=1
31612 !! wikitext
31613 A style tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
31614
31615 <style>.foo::before { content: "<foo>"; }</style>
31616
31617 <style>.foo::before { content: "<foo>"; }</style> <link rel="foo" href="bar"/><style>.foo::before { content: "<foo>"; }</style>
31618
31619 But if it's on a line with other content, let it be wrapped.
31620
31621 <style>.foo::before { content: "<foo>"; }</style> bar
31622
31623 foo <style>.foo::before { content: "<foo>"; }</style>
31624
31625 foo <style>.foo::before { content: "<foo>"; }</style> bar
31626
31627 And the same if we have non-paragraph-breaking whitespace
31628
31629 foo
31630 <style>.foo::before { content: "<foo>"; }</style>
31631 bar
31632 !! html/php
31633 <p>A style tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
31634 </p>
31635 <style>.foo::before { content: "<foo>"; }</style>
31636 <style>.foo::before { content: "<foo>"; }</style> <link rel="foo" href="bar"/><style>.foo::before { content: "<foo>"; }</style>
31637 <p>But if it's on a line with other content, let it be wrapped.
31638 </p><p><style>.foo::before { content: "<foo>"; }</style> bar
31639 </p><p>foo <style>.foo::before { content: "<foo>"; }</style>
31640 </p><p>foo <style>.foo::before { content: "<foo>"; }</style> bar
31641 </p><p>And the same if we have non-paragraph-breaking whitespace
31642 </p><p>foo
31643 <style>.foo::before { content: "<foo>"; }</style>
31644 bar
31645 </p>
31646 !! html/parsoid
31647 <p>A style tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph</p>
31648
31649 <style typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{},"body":{"extsrc":".foo::before { content: \"&lt;foo>\"; }"}}'>.foo::before { content: "<foo>"; }</style>
31650
31651 <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>
31652
31653 <p>But if it's on a line with other content, let it be wrapped.</p>
31654
31655 <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>
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></p>
31658
31659 <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>
31660
31661 <p>And the same if we have non-paragraph-breaking whitespace</p>
31662
31663 <p>foo
31664 <style typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{},"body":{"extsrc":".foo::before { content: \"&lt;foo>\"; }"}}'>.foo::before { content: "<foo>"; }</style>
31665 bar</p>
31666 !! end
31667
31668 !! test
31669 Validating that <link> isn't wrapped in a paragraph (T186965)
31670 !! options
31671 styletag=1
31672 !! wikitext
31673 A link tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
31674
31675 <link rel="foo" href="bar"/>
31676
31677 <link rel="foo" href="bar"/> <style>.foo::before { content: "<foo>"; }</style><link rel="foo" href="bar"/>
31678
31679 But if it's on a line with other content, let it be wrapped.
31680
31681 <link rel="foo" href="bar"/> bar
31682
31683 foo <link rel="foo" href="bar"/>
31684
31685 foo <link rel="foo" href="bar"/> bar
31686
31687 And the same if we have non-paragraph-breaking whitespace
31688
31689 foo
31690 <link rel="foo" href="bar"/>
31691 bar
31692 !! html/php
31693 <p>A link tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
31694 </p>
31695 <link rel="foo" href="bar"/>
31696 <link rel="foo" href="bar"/> <style>.foo::before { content: "<foo>"; }</style><link rel="foo" href="bar"/>
31697 <p>But if it's on a line with other content, let it be wrapped.
31698 </p><p><link rel="foo" href="bar"/> bar
31699 </p><p>foo <link rel="foo" href="bar"/>
31700 </p><p>foo <link rel="foo" href="bar"/> bar
31701 </p><p>And the same if we have non-paragraph-breaking whitespace
31702 </p><p>foo
31703 <link rel="foo" href="bar"/>
31704 bar
31705 </p>
31706 !! end
31707
31708 !! test
31709 Extension returning multiple nodes starting with a style tag roundtrips
31710 !! options
31711 wgRawHtml=1
31712 !! wikitext
31713 <table>
31714 {{echo|<html><style>.hi { color: red; }</style>
31715 </html>}}
31716 <tr><td class="hi">ho</td></tr>
31717 </table>
31718 !! html/parsoid
31719 <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">
31720 </span></p><table about="#mwt5" data-parsoid='{"stx":"html"}'>
31721
31722 <tbody><tr><td class="hi">ho</td></tr>
31723 </tbody></table>
31724 !! end
31725
31726 !! test
31727 Decoding of HTML entities in headings and links for IDs and link fragments (T103714)
31728 !! config
31729 wgFragmentMode=[ 'html5', 'legacy' ]
31730 !! wikitext
31731 ==A&B&amp;C&amp;amp;D&amp;amp;amp;E==
31732 [[#A&B&amp;C&amp;amp;D&amp;amp;amp;E]]
31733 !! html/php
31734 <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>
31735 <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>
31736 </p>
31737 !! html/parsoid
31738 <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>
31739 <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>
31740 !! end
31741
31742 !! test
31743 Decoding of HTML entities in headings and links for IDs and link fragments (T103714) (legacy)
31744 !! config
31745 wgFragmentMode=[ 'legacy' ]
31746 !! wikitext
31747 ==A&B&amp;C&amp;amp;D&amp;amp;amp;E==
31748 [[#A&B&amp;C&amp;amp;D&amp;amp;amp;E]]
31749 !! html/php
31750 <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>
31751 <p><a href="#A.26B.26C.26amp.3BD.26amp.3Bamp.3BE">#A&amp;B&amp;C&amp;amp;D&amp;amp;amp;E</a>
31752 </p>
31753 !! end
31754
31755 !! test
31756 Decoding of HTML entities in embedded HTML tags
31757 !! wikitext
31758 <table class="1&2&amp;3&amp;amp;4&amp;amp;amp;5"><tr><td>x</td></tr></table>
31759 !! html/php
31760 <table class="1&amp;2&amp;3&amp;amp;4&amp;amp;amp;5"><tr><td>x</td></tr></table>
31761
31762 !! html/parsoid
31763 <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>
31764 !! end
31765
31766 !! test
31767 Decoding of HTML entities in indicator names for IDs (T104196)
31768 !! options
31769 parsoid=wt2html,html2html
31770 showindicators
31771 !! wikitext
31772 <indicator name="1&2&amp;3&amp;amp;4&amp;amp;amp;5">Indicator</indicator>
31773 !! html/php
31774 1&2&3&amp;4&amp;amp;5=Indicator
31775
31776 !! html/parsoid
31777 <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>
31778 !! end
31779
31780 # this version of the test strips out the ambiguity so Parsoid rts cleanly
31781 !! test
31782 Decoding of HTML entities in indicator names for IDs (unambiguous) (T104196)
31783 !! options
31784 showindicators
31785 !! wikitext
31786 <indicator name="1&2&3&amp;amp;4&amp;amp;amp;5">Indicator</indicator>
31787 !! html/php
31788 1&2&3&amp;4&amp;amp;5=Indicator
31789
31790 !! html/parsoid
31791 <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>
31792 !! end
31793
31794 # This fragment mode is what Parsoid supports.
31795 !! test
31796 HTML5 ids: fallback to legacy
31797 !! config
31798 wgFragmentMode=[ 'html5', 'legacy' ]
31799 !! wikitext
31800 ==Foo bar==
31801
31802 ==foo Bar==
31803
31804 ==Тест==
31805
31806 ==Тест==
31807
31808 ==тест==
31809
31810 ==Hey < # " > % : '==
31811 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
31812
31813 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
31814
31815 <!-- These two links should produce identical HTML -->
31816 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
31817
31818 !! html/php
31819 <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>
31820 <ul>
31821 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
31822 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
31823 <li class="toclevel-1 tocsection-3"><a href="#Тест"><span class="tocnumber">3</span> <span class="toctext">Тест</span></a></li>
31824 <li class="toclevel-1 tocsection-4"><a href="#Тест_2"><span class="tocnumber">4</span> <span class="toctext">Тест</span></a></li>
31825 <li class="toclevel-1 tocsection-5"><a href="#тест"><span class="tocnumber">5</span> <span class="toctext">тест</span></a></li>
31826 <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>
31827 </ul>
31828 </div>
31829
31830 <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>
31831 <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>
31832 <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>
31833 <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>
31834 <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>
31835 <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>
31836 <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>
31837 </p><p>💩 <span id="💩"></span>
31838 </p><p><a href="#啤酒">#啤酒</a> <a href="#啤酒">#啤酒</a>
31839 </p>
31840 !! html/parsoid
31841 <h2 id="Foo_bar">Foo bar</h2>
31842
31843 <h2 id="foo_Bar_2">foo Bar</h2>
31844
31845 <h2 id="Тест"><span id=".D0.A2.D0.B5.D1.81.D1.82" typeof="mw:FallbackId"></span>Тест</h2>
31846
31847 <h2 id="Тест_2"><span id=".D0.A2.D0.B5.D1.81.D1.82_2" typeof="mw:FallbackId"></span>Тест</h2>
31848
31849 <h2 id="тест"><span id=".D1.82.D0.B5.D1.81.D1.82" typeof="mw:FallbackId"></span>тест</h2>
31850
31851 <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>
31852 <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>
31853
31854 <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>
31855
31856 <!-- These two links should produce identical HTML -->
31857 <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>
31858 !! end
31859
31860 # Parsoid doesn't support this mode
31861 !! test
31862 HTML5 ids: legacy with a fallback to modern
31863 !! config
31864 wgFragmentMode=[ 'legacy', 'html5' ]
31865 !! wikitext
31866 ==Foo bar==
31867
31868 ==foo Bar==
31869
31870 ==Тест==
31871
31872 ==Тест==
31873
31874 ==тест==
31875
31876 ==Hey < # " > % : '==
31877 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
31878
31879 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
31880
31881 <!-- These two links should produce identical HTML -->
31882 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
31883
31884 !! html/php
31885 <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>
31886 <ul>
31887 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
31888 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
31889 <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>
31890 <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>
31891 <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>
31892 <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>
31893 </ul>
31894 </div>
31895
31896 <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>
31897 <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>
31898 <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>
31899 <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>
31900 <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>
31901 <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>
31902 <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>
31903 </p><p>.F0.9F.92.A9 <span id=".F0.9F.92.A9"></span>
31904 </p><p><a href="#.E5.95.A4.E9.85.92">#啤酒</a> <a href="#.E5.95.A4.E9.85.92">#啤酒</a>
31905 </p>
31906 !! end
31907
31908 # Parsoid doesn't support this mode.
31909 !! test
31910 HTML5 ids: no legacy
31911 !! config
31912 wgFragmentMode=[ 'html5' ]
31913 !! wikitext
31914 ==Foo bar==
31915
31916 ==foo Bar==
31917
31918 ==Тест==
31919
31920 ==Тест==
31921
31922 ==тест==
31923
31924 ==Hey < # " > % : '==
31925 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
31926
31927 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
31928
31929 <!-- These two links should produce identical HTML -->
31930 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
31931
31932 !! html/php
31933 <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>
31934 <ul>
31935 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
31936 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
31937 <li class="toclevel-1 tocsection-3"><a href="#Тест"><span class="tocnumber">3</span> <span class="toctext">Тест</span></a></li>
31938 <li class="toclevel-1 tocsection-4"><a href="#Тест_2"><span class="tocnumber">4</span> <span class="toctext">Тест</span></a></li>
31939 <li class="toclevel-1 tocsection-5"><a href="#тест"><span class="tocnumber">5</span> <span class="toctext">тест</span></a></li>
31940 <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>
31941 </ul>
31942 </div>
31943
31944 <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>
31945 <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>
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=3" title="Edit section: Тест">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
31947 <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>
31948 <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>
31949 <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>
31950 <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>
31951 </p><p>💩 <span id="💩"></span>
31952 </p><p><a href="#啤酒">#啤酒</a> <a href="#啤酒">#啤酒</a>
31953 </p>
31954 !! end
31955
31956 !! test
31957 T90902: Normalize weird characters in section IDs
31958 !! config
31959 wgFragmentMode=[ 'html5', 'legacy' ]
31960 !! wikitext
31961 ==Foo&nbsp;bar==
31962 [[#Foo&nbsp;bar]]
31963
31964 !! html/php
31965 <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>
31966 <p><a href="#Foo_bar">#Foo&#160;bar</a>
31967 </p>
31968 !! html/parsoid
31969 <h2 id="Foo_bar"> Foo<span typeof="mw:Entity" data-parsoid='{"src":"&amp;nbsp;","srcContent":" "}'> </span>bar </h2>
31970 <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>
31971 !! end
31972
31973 !! test
31974 T51672: Test for brackets in attributes of elements in external link texts
31975 !! wikitext
31976 [http://example.com/ link <span title="title with [brackets]">span</span>]
31977 [http://example.com/ link <span title="title with &#91;brackets&#93;">span</span>]
31978
31979 !! html/php
31980 <p><a rel="nofollow" class="external text" href="http://example.com/">link <span title="title with &#91;brackets&#93;">span</span></a>
31981 <a rel="nofollow" class="external text" href="http://example.com/">link <span title="title with &#91;brackets&#93;">span</span></a>
31982 </p>
31983 !! html/parsoid
31984 <p><a rel="mw:ExtLink" class="external text" href="http://example.com/">link <span title="title with [brackets]">span</span></a>
31985 <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>
31986 !! end
31987
31988 !! test
31989 T72875: Test for brackets in attributes of elements in internal link texts
31990 !! wikitext
31991 [[Foo|link <span title="title with [[double brackets]]">span</span>]]
31992 [[Foo|link <span title="title with &#91;&#91;double brackets&#93;&#93;">span</span>]]
31993
31994 !! html/php
31995 <p><a href="/wiki/Foo" title="Foo">link <span title="title with &#91;&#91;double brackets&#93;&#93;">span</span></a>
31996 <a href="/wiki/Foo" title="Foo">link <span title="title with &#91;&#91;double brackets&#93;&#93;">span</span></a>
31997 </p>
31998 !! html/parsoid
31999 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">link <span title="title with [[double brackets]]">span</span></a>
32000 <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>
32001 !! end
32002
32003 !! test
32004 T199926: html arrow wt: Parsoid sometimes trips up on verticalbar chars in hrefs
32005 !! options
32006 parsoid={
32007 "modes": ["html2wt"]
32008 }
32009 !! html/parsoid
32010 <a href="https://stats.wikimedia.org/v2/#/fr.wikipedia.org/reading/page-views-by-country/normal|map|2-Year~2016060100~2018071100|~total">9</a>
32011 <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>
32012 !! wikitext
32013 [https://stats.wikimedia.org/v2/#/fr.wikipedia.org/reading/page-views-by-country/normal|map|2-Year~2016060100~2018071100|~total 9]
32014 [[stats:v2/#/fr.wikipedia.org/reading/page-views-by-country/normal%7Cmap%7C2-Year~2016060100~2018071100%7C~total|10]]
32015 !! end
32016
32017 !! test
32018 T179544: {{anchorencode:}} output should be always usable in links
32019 !! config
32020 wgFragmentMode=[ 'html5' ]
32021 !! wikitext
32022 <span id="{{anchorencode:[foo]}}"></span>[[#{{anchorencode:[foo]}}]]
32023 !! html/php
32024 <p><span id="&#91;foo&#93;"></span><a href="#[foo]">#&#91;foo&#93;</a>
32025 </p>
32026 !! html/parsoid
32027 <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>
32028 !! end
32029
32030 ## ------------------------------
32031 ## Parsoid section-wrapping tests
32032 ## ------------------------------
32033 !! test
32034 Section wrapping for well-nested sections (no leading content)
32035 !! options
32036 parsoid={
32037 "wrapSections": true
32038 }
32039 !! wikitext
32040 =1=
32041 a
32042
32043 =2=
32044 b
32045
32046 ==2.1==
32047 c
32048
32049 ==2.2==
32050 d
32051
32052 ===2.2.1===
32053 e
32054
32055 =3=
32056 f
32057 !! html/parsoid
32058 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1>
32059 <p>a</p>
32060
32061 </section><section data-mw-section-id="2"><h1 id="2">2</h1>
32062 <p>b</p>
32063
32064 <section data-mw-section-id="3"><h2 id="2.1">2.1</h2>
32065 <p>c</p>
32066
32067 </section><section data-mw-section-id="4"><h2 id="2.2">2.2</h2>
32068 <p>d</p>
32069
32070 <section data-mw-section-id="5"><h3 id="2.2.1">2.2.1</h3>
32071 <p>e</p>
32072
32073 </section></section></section><section data-mw-section-id="6"><h1 id="3">3</h1>
32074 <p>f</p>
32075
32076 </section>
32077 !! end
32078
32079 !! test
32080 Section wrapping for well-nested sections (with leading content)
32081 !! options
32082 parsoid={
32083 "wrapSections": true
32084 }
32085 !! wikitext
32086 Para 1.
32087
32088 Para 2 with a <div>nested in it</div>
32089
32090 Para 3.
32091
32092 =1=
32093 a
32094
32095 =2=
32096 b
32097
32098 ==2.1==
32099 c
32100 !! html/parsoid
32101 <section data-mw-section-id="0"><p>Para 1.</p>
32102
32103 <p>Para 2 with a </p><div>nested in it</div>
32104
32105 <p>Para 3.</p>
32106
32107 </section><section data-mw-section-id="1"><h1 id="1">1</h1>
32108 <p>a</p>
32109
32110 </section><section data-mw-section-id="2"><h1 id="2">2</h1>
32111 <p>b</p>
32112
32113 <section data-mw-section-id="3"><h2 id="2.1">2.1</h2>
32114 <p>c</p>
32115
32116 </section></section>
32117 !! end
32118
32119 !! test
32120 Section wrapping with template-generated sections (good nesting 1)
32121 !! options
32122 parsoid={
32123 "wrapSections": true
32124 }
32125 !! wikitext
32126 =1=
32127 a
32128
32129 {{echo|1=
32130 ==1.1==
32131 b
32132 }}
32133
32134 ==1.2==
32135 c
32136
32137 =2=
32138 d
32139 !! html/parsoid
32140 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1>
32141 <p>a</p>
32142
32143 <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">
32144 </span><p about="#mwt1">b</p>
32145 </section><section data-mw-section-id="3"><h2 id="1.2">1.2</h2>
32146 <p>c</p>
32147
32148 </section></section><section data-mw-section-id="4"><h1 id="2">2</h1>
32149 <p>d</p></section>
32150 !! end
32151
32152 # In this example, the template scope is mildly expanded to incorporate the
32153 # trailing newline after the transclusion since that is part of section 1.1.1
32154 !! test
32155 Section wrapping with template-generated sections (good nesting 2)
32156 !! options
32157 parsoid={
32158 "wrapSections": true,
32159 "modes": ["wt2html", "wt2wt"]
32160 }
32161 !! wikitext
32162 =1=
32163 a
32164
32165 {{echo|1=
32166 ==1.1==
32167 b
32168 ===1.1.1===
32169 d
32170 }}
32171 =2=
32172 e
32173 !! html/parsoid
32174 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1>
32175 <p>a</p>
32176
32177 <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">
32178 </span><p about="#mwt1">b</p><span about="#mwt1">
32179 </span><section data-mw-section-id="-1" about="#mwt1"><h3 about="#mwt1" id="1.1.1">1.1.1</h3><span about="#mwt1">
32180 </span><p about="#mwt1">d</p><span about="#mwt1">
32181 </span></section></section></section><section data-mw-section-id="4" data-parsoid="{}"><h1 id="2">2</h1>
32182 <p>e</p></section>
32183 !! end
32184
32185 # In this example, the template scope is mildly expanded to incorporate the
32186 # trailing newline after the transclusion since that is part of section 1.2.1
32187 !! test
32188 Section wrapping with template-generated sections (good nesting 3)
32189 !! options
32190 parsoid={
32191 "wrapSections": true,
32192 "modes": ["wt2html", "wt2wt"]
32193 }
32194 !! wikitext
32195 =1=
32196 a
32197
32198 {{echo|1=
32199 x
32200 ==1.1==
32201 b
32202 ==1.2==
32203 c
32204 ===1.2.1===
32205 d
32206 }}
32207 =2=
32208 e
32209 !! html/parsoid
32210 <section data-mw-section-id="0"></section><section data-mw-section-id="1" data-parsoid="{}"><h1 id="1"> 1 </h1>
32211 <p>a</p>
32212
32213 <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">
32214 </span><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="1.1">1.1</h2><span about="#mwt1">
32215 </span><p about="#mwt1">b</p><span about="#mwt1">
32216 </span></section><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="1.2">1.2</h2><span about="#mwt1">
32217 </span><p about="#mwt1">c</p><span about="#mwt1">
32218 </span><section data-mw-section-id="-1" about="#mwt1"><h3 about="#mwt1" id="1.2.1">1.2.1</h3><span about="#mwt1">
32219 </span><p about="#mwt1">d</p><span about="#mwt1">
32220 </span></section></section></section><section data-mw-section-id="5"><h1 id="2">2</h1>
32221 <p>e</p></section>
32222 !! end
32223
32224 # Because of section-wrapping and template-wrapping interactions,
32225 # the scope of the template is expanded so that the template markup
32226 # is valid in the presence of <section> tags.
32227 # This exercises the s1 is null scenario in the wrapSections code
32228 !! test
32229 Section wrapping with template-generated sections (bad nesting 1)
32230 !! options
32231 parsoid={
32232 "wrapSections": true
32233 }
32234 !! wikitext
32235 <div>
32236 a
32237
32238 {{echo|
32239 =1=
32240 b
32241 }}
32242
32243 c
32244 </div>
32245 !! html/parsoid
32246 <section data-mw-section-id="-1"></section><section data-mw-section-id="-2"><div data-parsoid='{"stx":"html"}'>
32247 <p>a</p>
32248
32249 <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"]}'>
32250 </span><section data-mw-section-id="-1" about="#mwt1"><h1 about="#mwt1" id="1">1</h1><span about="#mwt1">
32251 </span><p about="#mwt1">b
32252 </p><span about="#mwt1">
32253
32254 </span><p about="#mwt1">c</p><span about="#mwt1">
32255 </span></section></div></section>
32256 !! end
32257
32258 # Because of section-wrapping and template-wrapping interactions,
32259 # the scope of the template is expanded so that the template markup
32260 # is valid in the presence of <section> tags.
32261 # This exercises the s1 is ancestor of s2 scenario in the wrapSections code
32262 !! test
32263 Section wrapping with template-generated sections (bad nesting 2)
32264 !! options
32265 parsoid={
32266 "wrapSections": true
32267 }
32268 !! wikitext
32269 =1=
32270 a
32271
32272 {{echo|1=
32273 =2=
32274 b
32275 ==2.1==
32276 c
32277 }}
32278
32279 d
32280
32281 =3=
32282 e
32283 !! html/parsoid
32284 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1>
32285 <p>a</p>
32286
32287 </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">
32288 </span><p about="#mwt1">b</p><span about="#mwt1">
32289 </span><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="2.1">2.1</h2><span about="#mwt1">
32290 </span><p about="#mwt1">c</p><span about="#mwt1">
32291
32292 </span><p about="#mwt1">d</p><span about="#mwt1">
32293
32294 </span></section></section><section data-mw-section-id="4"><h1 id="3">3</h1>
32295 <p>e</p></section>
32296 !! end
32297
32298 # Because of section-wrapping and template-wrapping interactions,
32299 # additional template wrappers are added to <section> tags
32300 # so that template wrapping semantics are valid whether section
32301 # tags are retained or stripped. But, the template scope can expand
32302 # greatly when accounting for section tags.
32303 # This exercises the s1 and s2 are in different subtrees scenario
32304 !! test
32305 Section wrapping with template-generated sections (bad nesting 3)
32306 !! options
32307 parsoid={
32308 "wrapSections": true,
32309 "modes": ["wt2html", "wt2wt"]
32310 }
32311 !! wikitext
32312 =1=
32313 a
32314
32315 {{echo|1=
32316 ==1.2==
32317 b
32318 =2=
32319 c
32320 }}
32321
32322 d
32323
32324 =3=
32325 e
32326 !! html/parsoid
32327 <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>
32328 <p>a</p>
32329
32330 <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">
32331 </span><p about="#mwt1">b</p><span about="#mwt1">
32332 </span></section></section><section data-mw-section-id="-1" about="#mwt1"><h1 about="#mwt1" id="2">2</h1><span about="#mwt1">
32333 </span><p about="#mwt1">c</p>
32334
32335 <p>d</p>
32336 </section><section data-mw-section-id="4" data-parsoid="{}"><h1 id="3">3</h1>
32337 <p>e</p></section>
32338 !! end
32339
32340 !! test
32341 Section wrapping with uneditable lead section + div wrapping multiple sections
32342 !! options
32343 parsoid={
32344 "wrapSections": true
32345 }
32346 !! wikitext
32347 foo
32348
32349 <div style="border:1px solid red;">
32350 =1=
32351 a
32352
32353 ==1.1==
32354 b
32355
32356 =2=
32357 c
32358 </div>
32359
32360 =3=
32361 d
32362
32363 ==3.1==
32364 e
32365 !! html/parsoid
32366 <section data-mw-section-id="-1"><p>foo</p>
32367
32368 </section><section data-mw-section-id="-2"><div style="border:1px solid red;">
32369 <section data-mw-section-id="1"><h1 id="1">1</h1>
32370 <p>a</p>
32371
32372 <section data-mw-section-id="2"><h2 id="1.1">1.1</h2>
32373 <p>b</p>
32374
32375 </section></section><section data-mw-section-id="-1"><h1 id="2">2</h1>
32376 <p>c</p>
32377 </section></div>
32378
32379 </section><section data-mw-section-id="4"><h1 id="3">3</h1>
32380 <p>d</p>
32381
32382 <section data-mw-section-id="5"><h2 id="3.1">3.1</h2>
32383 <p>e</p>
32384 </section></section>
32385 !! end
32386
32387 !! test
32388 Section wrapping with editable lead section + div overlapping multiple sections
32389 !! options
32390 parsoid={
32391 "wrapSections": true
32392 }
32393 !! wikitext
32394 foo
32395
32396 =1=
32397 a
32398 <div style="border:1px solid red;">
32399 b
32400
32401 ==1.1==
32402 c
32403
32404 =2=
32405 d
32406 </div>
32407 e
32408
32409 =3=
32410 f
32411
32412 ==3.1==
32413 g
32414 !! html/parsoid
32415 <section data-mw-section-id="0"><p>foo</p>
32416
32417 </section><section data-mw-section-id="-1"><h1 id="1">1</h1>
32418 <p>a</p>
32419 </section><section data-mw-section-id="-2"><div style="border:1px solid red;">
32420 <p>b</p>
32421
32422 <section data-mw-section-id="2"><h2 id="1.1">1.1</h2>
32423 <p>c</p>
32424
32425 </section><section data-mw-section-id="-1"><h1 id="2">2</h1>
32426 <p>d</p>
32427 </section></div>
32428 <p>e</p>
32429
32430 </section><section data-mw-section-id="4"><h1 id="3">3</h1>
32431 <p>f</p>
32432
32433 <section data-mw-section-id="5"><h2 id="3.1">3.1</h2>
32434 <p>g</p>
32435 </section></section>
32436 !! end
32437
32438 !! test
32439 HTML header tags should not be wrapped in section tags
32440 !! options
32441 parsoid={
32442 "wrapSections": true
32443 }
32444 !! wikitext
32445 foo
32446
32447 <h1>a</h1>
32448
32449 =b=
32450
32451 <h1>c</h1>
32452
32453 =d=
32454 !! html/parsoid
32455 <section data-mw-section-id="0"><p>foo</p>
32456
32457 <h1 id="a" data-parsoid='{"stx":"html"}'>a</h1>
32458
32459 </section><section data-mw-section-id="1"><h1 id="b">b</h1>
32460
32461 <h1 id="c" data-parsoid='{"stx":"html"}'>c</h1>
32462
32463 </section><section data-mw-section-id="2"><h1 id="d">d</h1></section>
32464 !! end
32465
32466 !! test
32467 Lead section containing only whitespace and comments.
32468 !! options
32469 parsoid={
32470 "wrapSections": true
32471 }
32472 !! wikitext
32473
32474 <!-- this is a comment, presumably significant to editors -->
32475 =1=
32476 a
32477
32478 =2=
32479 b
32480 !! html/parsoid
32481 <section data-mw-section-id="0" data-parsoid="{}">
32482 <!-- this is a comment, presumably significant to editors -->
32483 </section><section data-mw-section-id="1"><h1 id="1">1</h1>
32484 <p>a</p>
32485
32486 </section><section data-mw-section-id="2"><h1 id="2">2</h1>
32487 <p>b</p></section>
32488 !! end
32489
32490 !! test
32491 Pseudo-sections emitted by templates should have id -2
32492 !! options
32493 parsoid={
32494 "wrapSections": true
32495 }
32496 !! wikitext
32497 foo
32498 {{echo|<div>
32499 ==a==
32500 ==b==
32501 </div>
32502 }}
32503 !! html/parsoid
32504 <section data-mw-section-id="-1"><p>foo</p>
32505 </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}}]}'>
32506 <section data-mw-section-id="-1"><h2 id="a">a</h2>
32507 </section><section data-mw-section-id="-1"><h2 id="b">b</h2>
32508 </section></div><span about="#mwt1">
32509 </span></section>
32510 !! end
32511
32512 ##########################################################################
32513 Tests demonstrating white-space insensitivity in input wikitext
32514 for wikitext headings, wikitext list items, and wikitext table captions,
32515 headings, and cells. HTML versions of the same should preserve whitespace.
32516 ##########################################################################
32517 !! test
32518 Trim whitespace in wikitext headings, list items, table captions, headings, and cells
32519 !! options
32520 parsoid={
32521 "modes": ["wt2html"],
32522 "preserveIEW": true
32523 }
32524 !! wikitext
32525 __NOTOC__
32526 == <!--c1--> <!--c2--> Spaces <!--c3--> <!--c4--> ==
32527 == <!--c1--> <!--c2--> Tabs <!--c3--><!--c4--> ==
32528 == <!--Headings with fallback ids--> Личная жизнь ==
32529 * <!--c1--> <!--c2--> List item <!--c3--> <!--c4-->
32530 ; <!--term to define--> term : <!--term's definition--> definition
32531 {|
32532 |+ <!--c1--> <!--c2--> Table Caption <!--c3--> <!--c4-->
32533 |-
32534 ! <!--c1--> <!--c2--> Table Heading 1 <!--c3--> <!--c4--> !! Table Heading 2 <!--c5-->
32535 |-
32536 | <!--c1--> <!--c2--> Table Cell 1 <!--c3--> <!--c4--> || Table Cell 2 <!--c5-->
32537 |-
32538 | class="foo" || <!--c1--> <!--c2--> Table Cell 3 <!--c3--> <!--c4-->
32539 |-
32540 | <!--c1--> testing [[one|two]] <!--c2--> | <!--c3--> some content
32541 |}
32542 : {|
32543 | <!--c1--> <!--c2--> Table Cell 1 <!--c3--> <!--c4--> || Table Cell 2 <!--c5-->
32544 |} foo <!--c1-->
32545 !! html/php+tidy
32546 <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>
32547 <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>
32548 <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>
32549 <ul><li>List item</li></ul>
32550 <dl><dt>term&#160;</dt>
32551 <dd>definition</dd></dl>
32552 <table>
32553 <caption>Table Caption
32554 </caption>
32555 <tbody><tr>
32556 <th>Table Heading 1</th>
32557 <th>Table Heading 2
32558 </th></tr>
32559 <tr>
32560 <td>Table Cell 1</td>
32561 <td>Table Cell 2
32562 </td></tr>
32563 <tr>
32564 <td>class="foo"</td>
32565 <td>Table Cell 3
32566 </td></tr>
32567 <tr>
32568 <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
32569 </td></tr></tbody></table>
32570 <dl><dd><table>
32571 <tbody><tr>
32572 <td>Table Cell 1</td>
32573 <td>Table Cell 2
32574 </td></tr></tbody></table> foo</dd></dl>
32575 !! html/parsoid
32576 <meta property="mw:PageProp/notoc">
32577 <h2 id="Spaces"><!--c1--><!--c2-->Spaces<!--c3--><!--c4--></h2>
32578 <h2 id="Tabs"><!--c1--><!--c2-->Tabs<!--c3--><!--c4--></h2>
32579 <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>
32580 <ul><li><!--c1--><!--c2-->List item<!--c3--><!--c4--></li></ul>
32581 <dl><dt><!--term to define-->term&nbsp;</dt><dd><!--term's definition-->definition</dd></dl>
32582 <table>
32583 <caption><!--c1--><!--c2-->Table Caption<!--c3--><!--c4--></caption>
32584 <tbody><tr>
32585 <th><!--c1--><!--c2-->Table Heading 1<!--c3--><!--c4--></th><th>Table Heading 2<!--c5--></th></tr>
32586 <tr>
32587 <td><!--c1--><!--c2-->Table Cell 1<!--c3--><!--c4--></td><td>Table Cell 2<!--c5--></td></tr>
32588 <tr>
32589 <td>class="foo"</td><td><!--c1--><!--c2-->Table Cell 3<!--c3--><!--c4--></td></tr>
32590 <tr>
32591 <td><!--c1-->testing <a rel="mw:WikiLink" href="./One" title="One">two</a> <!--c2--> | <!--c3--> some content</td></tr>
32592 </tbody></table>
32593 <dl><dd><table>
32594 <tbody><tr><td><!--c1--><!--c2-->Table Cell 1<!--c3--><!--c4--></td><td>Table Cell 2<!--c5--></td></tr>
32595 </tbody></table> foo<!--c1--></dd></dl>
32596 !! end
32597
32598 # Looks like <caption> is not accepted in HTML
32599 !! test
32600 Do not trim whitespace in HTML headings, list items, table captions, headings, and cells
32601 !! options
32602 parsoid={
32603 "modes": ["wt2html"],
32604 "preserveIEW": true
32605 }
32606 !! wikitext
32607 __NOTOC__
32608 <h2> <!--c1--> <!--c2--> Heading <!--c3--> <!--c4--> </h2>
32609 <ul><li> <!--c1--> <!--c2--> List item <!--c3--> <!--c4--> </li></ul>
32610 <table>
32611 <tr><th> <!--c1--> <!--c2--> Table Heading <!--c3--> <!--c4--> <th></tr>
32612 <tr><td> <!--c1--> <!--c2--> Table Cell <!--c3--> <!--c4--> <th></tr>
32613 </table>
32614 !! html/php+tidy
32615 <h2><span class="mw-headline" id="Heading"> Heading </span></h2>
32616 <ul><li> List item </li></ul>
32617 <table>
32618 <tbody><tr><th> Table Heading </th><th></th></tr>
32619 <tr><td> Table Cell </td><th></th></tr>
32620 </tbody></table>
32621 !! html/parsoid
32622 <meta property="mw:PageProp/notoc"/>
32623 <h2 id="Heading"> <!--c1--> <!--c2--> Heading <!--c3--> <!--c4--> </h2>
32624 <ul><li> <!--c1--> <!--c2--> List item <!--c3--> <!--c4--> </li></ul>
32625 <table>
32626 <tbody><tr><th> <!--c1--> <!--c2--> Table Heading <!--c3--> <!--c4--> </th><th></th></tr>
32627 <tr><td> <!--c1--> <!--c2--> Table Cell <!--c3--> <!--c4--> </td><th></th></tr>
32628 </tbody></table>
32629 !! end
32630
32631 !! test
32632 Do not trim whitespace in links and quotes
32633 !! options
32634 parsoid={
32635 "modes": ["wt2html"],
32636 "preserveIEW": true
32637 }
32638 !! wikitext
32639 foo '' <!--c1--> italic <!--c2--> '' and ''' <!--c3--> bold <!--c4--> '''
32640 [[Foo| some text ]]
32641 !! html/php+tidy
32642 <p>foo <i> italic </i> and <b> bold </b>
32643 <a href="/wiki/Foo" title="Foo"> some text </a>
32644 </p>
32645 !! html/parsoid
32646 <p>foo <i> <!--c1--> italic <!--c2--> </i> and <b> <!--c3--> bold <!--c4--> </b>
32647 <a rel="mw:WikiLink" href="./Foo" title="Foo"> some text </a></p>
32648 !! end
32649
32650 !! test
32651 Remove p tags surrounding a single element in a figcaption
32652 !! options
32653 parsoid=html2wt
32654 !! wikitext
32655 [[File:Foobar.jpg|right|200x200px|Caption]]
32656 !! html/parsoid
32657 <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>
32658 !! end
32659
32660 !! test
32661 Selser preserves lack of newline before list and allows newline after the list
32662 !! options
32663 parsoid={
32664 "modes": ["selser"],
32665 "scrubWikitext": true,
32666 "changes": [
32667 [ "ul", "after", "<p>footer</p>" ]
32668 ]
32669 }
32670 !! wikitext
32671 header
32672 *foo
32673 *bar
32674 !! wikitext/edited
32675 header
32676 *foo
32677 *bar
32678
32679 footer
32680 !! end
32681
32682
32683 !! test
32684 Selser does not introduce newlines between unedited paragraph preceding the list
32685 !! options
32686 parsoid={
32687 "modes": ["selser"],
32688 "changes": [
32689 [ "table tbody tr td p:last-child", "empty" ]
32690 ]
32691 }
32692 !! wikitext
32693 {|
32694 |
32695 header
32696 *foo
32697 *bar
32698 footer
32699 |}
32700 !! wikitext/edited
32701 {|
32702 |
32703 header
32704 *foo
32705 *bar
32706
32707 |}
32708 !! end
32709
32710 !! test
32711 Selser does not introduce newlines between unedited paragraph following the list
32712 !! options
32713 parsoid={
32714 "modes": ["selser"],
32715 "changes": [
32716 [ "table tbody tr td p:first-child", "empty" ]
32717 ]
32718 }
32719 !! wikitext
32720 {|
32721 |
32722 header
32723 *foo
32724 *bar
32725 footer
32726 |}
32727 !! wikitext/edited
32728 {|
32729 |
32730
32731 *foo
32732 *bar
32733 footer
32734 |}
32735 !! end
32736
32737 !! test
32738 Remove a list item but do not insert newline above list
32739 !! options
32740 parsoid={
32741 "modes": ["selser"],
32742 "changes": [
32743 [ "ul li:last-child", "remove" ]
32744 ]
32745 }
32746 !! wikitext
32747 header
32748 *foo
32749 *bar
32750 footer
32751 !! wikitext/edited
32752 header
32753 *foo
32754 footer
32755 !! end