Make thumbnail image decoding async
[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 ###
1253 ### Non-html5 tags
1254 ###
1255
1256 !! test
1257 Non-html5 tags should be accepted
1258 !! wikitext
1259 <center>''foo''</center>
1260 <big>''foo''</big>
1261 <font>''foo''</font>
1262 <strike>''foo''</strike>
1263 <tt>''foo''</tt>
1264 !! html
1265 <center><i>foo</i></center>
1266 <p><big><i>foo</i></big>
1267 <font><i>foo</i></font>
1268 <strike><i>foo</i></strike>
1269 <tt><i>foo</i></tt>
1270 </p>
1271 !! end
1272
1273 !! test
1274 <wbr> is valid wikitext (T54468)
1275 !! wikitext
1276 <wbr>
1277 !! html
1278 <p><wbr />
1279 </p>
1280 !! end
1281
1282 # <strike> is HTML4, <s> is HTML4/5.
1283 !! test
1284 <s> or <strike> for strikethrough
1285 !! wikitext
1286 <strike>strike</strike>
1287
1288 <s>s</s>
1289 !! html
1290 <p><strike>strike</strike>
1291 </p><p><s>s</s>
1292 </p>
1293 !! end
1294
1295 ## a not permitted
1296 ## i,b,br omitted
1297 !! test
1298 Text-level semantic html elements in wikitext
1299 !! wikitext
1300 <em>text</em>
1301 <strong>text</strong>
1302 <small>text</small>
1303 <s>text</s>
1304 <cite>text</cite>
1305 <q>text</q>
1306 <dfn>text</dfn>
1307 <abbr>text</abbr>
1308 <data>text</data>
1309 <time>text</time>
1310 <code>text</code>
1311 <var>text</var>
1312 <samp>text</samp>
1313 <kbd>text</kbd>
1314 <sub>text</sub>
1315 <u>text</u>
1316 <mark>text</mark>
1317 <ruby><rb>明日</rb><rp>(</rp><rt>Ashita</rt><rp> </rp><rtc>あした</rtc><rp>)</rp></ruby>
1318 <bdi>text</bdi>
1319 <bdo>text</bdo>
1320 <span>text</span>
1321 <wbr />
1322 !! html
1323 <p><em>text</em>
1324 <strong>text</strong>
1325 <small>text</small>
1326 <s>text</s>
1327 <cite>text</cite>
1328 <q>text</q>
1329 <dfn>text</dfn>
1330 <abbr>text</abbr>
1331 <data>text</data>
1332 <time>text</time>
1333 <code>text</code>
1334 <var>text</var>
1335 <samp>text</samp>
1336 <kbd>text</kbd>
1337 <sub>text</sub>
1338 <u>text</u>
1339 <mark>text</mark>
1340 <ruby><rb>明日</rb><rp>(</rp><rt>Ashita</rt><rp> </rp><rtc>あした</rtc><rp>)</rp></ruby>
1341 <bdi>text</bdi>
1342 <bdo>text</bdo>
1343 <span>text</span>
1344 <wbr />
1345 </p>
1346 !! end
1347
1348 # test cases taken from
1349 # https://www.w3.org/TR/html5/text-level-semantics.html#the-ruby-element
1350 !! test
1351 Ruby markup (W3C-style)
1352 !! wikitext
1353 ;Mono-ruby for individual base characters
1354 :<ruby>日<rt>に</rt>本<rt>ほん</rt>語<rt>ご</rt></ruby>
1355 ;Group ruby
1356 :<ruby>今日<rt>きょう</rt></ruby>
1357 ;Jukugo ruby
1358 :<ruby>法<rb>華</rb><rb>経</rb><rt>ほ</rt><rt>け</rt><rt>きょう</rt></ruby>
1359 ;Inline ruby
1360 :<ruby>東<rb>京</rb><rp>(</rp><rt>とう</rt><rt>きょう</rt><rp>)</rp></ruby>
1361 ;Double-sided ruby
1362 :<ruby><rb>旧</rb><rb>金</rb><rb>山</rb><rt>jiù</rt><rt>jīn</rt><rt>shān</rt><rtc>San Francisco</rtc></ruby>
1363
1364 <ruby>
1365 <rb>♥</rb><rtc><rt>Heart</rt></rtc><rtc lang="fr"><rt>Cœur</rt></rtc>
1366 <rb>☘</rb><rtc><rt>Shamrock</rt></rtc><rtc lang="fr"><rt>Trèfle</rt></rtc>
1367 <rb>✶</rb><rtc><rt>Star</rt></rtc><rtc lang="fr"><rt>Étoile</rt></rtc>
1368 </ruby>
1369 !! html
1370 <dl><dt>Mono-ruby for individual base characters</dt>
1371 <dd><ruby>日<rt>に</rt>本<rt>ほん</rt>語<rt>ご</rt></ruby></dd>
1372 <dt>Group ruby</dt>
1373 <dd><ruby>今日<rt>きょう</rt></ruby></dd>
1374 <dt>Jukugo ruby</dt>
1375 <dd><ruby>法<rb>華</rb><rb>経</rb><rt>ほ</rt><rt>け</rt><rt>きょう</rt></ruby></dd>
1376 <dt>Inline ruby</dt>
1377 <dd><ruby>東<rb>京</rb><rp>(</rp><rt>とう</rt><rt>きょう</rt><rp>)</rp></ruby></dd>
1378 <dt>Double-sided ruby</dt>
1379 <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>
1380 <p><ruby>
1381 <rb>♥</rb><rtc><rt>Heart</rt></rtc><rtc lang="fr"><rt>Cœur</rt></rtc>
1382 <rb>☘</rb><rtc><rt>Shamrock</rt></rtc><rtc lang="fr"><rt>Trèfle</rt></rtc>
1383 <rb>✶</rb><rtc><rt>Star</rt></rtc><rtc lang="fr"><rt>Étoile</rt></rtc>
1384 </ruby>
1385 </p>
1386 !! end
1387
1388 # The next two test different paths in the sanitizer.
1389 !! test
1390 Non-word characters don't terminate tag names (T19663, T42670, T54022)
1391 !! wikitext
1392 <blockquote|>a</blockquote>
1393
1394 <b→> doesn't terminate </b→>
1395
1396 <bä> doesn't terminate </bä>
1397
1398 <boo> doesn't terminate </boo>
1399
1400 <s.foo> doesn't terminate </s.foo>
1401
1402 <sub-ID#1>
1403 !! html/php
1404 <p>&lt;blockquote|&gt;a&lt;/blockquote&gt;
1405 </p><p>&lt;b→&gt; doesn't terminate &lt;/b→&gt;
1406 </p><p>&lt;bä&gt; doesn't terminate &lt;/bä&gt;
1407 </p><p>&lt;boo&gt; doesn't terminate &lt;/boo&gt;
1408 </p><p>&lt;s.foo&gt; doesn't terminate &lt;/s.foo&gt;
1409 </p><p>&lt;sub-ID#1&gt;
1410 </p>
1411 !! end
1412
1413 !! test
1414 Non-word characters don't terminate tag names
1415 !! wikitext
1416 <blockquote|>a</blockquote>
1417
1418 <b→> doesn't terminate </b→>
1419
1420 <bä> doesn't terminate </bä>
1421
1422 <boo> doesn't terminate </boo>
1423
1424 <s.foo> doesn't terminate </s.foo>
1425
1426 <sub-ID#1>
1427 !! html+tidy
1428 <p>&lt;blockquote|&gt;a
1429 </p><p>&lt;b→&gt; doesn't terminate &lt;/b→&gt;
1430 </p><p>&lt;bä&gt; doesn't terminate &lt;/bä&gt;
1431 </p><p>&lt;boo&gt; doesn't terminate &lt;/boo&gt;
1432 </p><p>&lt;s.foo&gt; doesn't terminate &lt;/s.foo&gt;
1433 </p><p>&lt;sub-ID#1&gt;
1434 </p>
1435 !! end
1436
1437 ###
1438 ### See tests/parser/ParserTestParserHook.php for the <tåg> extension)
1439 ### This checks that HTML5 tags (with non-word characters in the tag
1440 ### name) make it safely through the parser -- the Sanitizer will
1441 ### munge them later, as it should.
1442 ###
1443 !! test
1444 Non-word characters are valid in extension tags (T19663)
1445 !! wikitext
1446 <tåg>tåg</tåg>
1447 !! html/php
1448 <pre>
1449 'tåg'
1450 array (
1451 )
1452 </pre>
1453
1454 !! html/parsoid
1455 <pre typeof="mw:Extension/tåg" data-mw='{"name":"tåg","attrs":{},"body":{"extsrc":"tåg"}}' data-parsoid='{}' about="#mwt2"></pre>
1456 !! end
1457
1458 !! test
1459 Isolated close tags should be treated as literal text (T54760)
1460 !! options
1461 parsoid=wt2html
1462 !! wikitext
1463 </b>
1464
1465 <s.foo>s</s>
1466 !! html+tidy
1467 <p class="mw-empty-elt">
1468 </p><p>&lt;s.foo&gt;s
1469 </p>
1470 !! end
1471
1472 ###
1473 ### Special characters
1474 ###
1475
1476 !! test
1477 Bare pipe character (T54363)
1478 !! wikitext
1479 |
1480 !! html
1481 <p>|
1482 </p>
1483 !! end
1484
1485 !! test
1486 Bare pipe character from a template (T54363)
1487 !! wikitext
1488 {{pipe}}
1489 !! html
1490 <p>|
1491 </p>
1492 !! end
1493
1494 ###
1495 ### <nowiki> test cases
1496 ###
1497
1498 !! test
1499 <nowiki> unordered list
1500 !! wikitext
1501 <nowiki>* This is not an unordered list item.</nowiki>
1502 !! html/php
1503 <p>* This is not an unordered list item.
1504 </p>
1505 !! html/parsoid
1506 <p><span typeof="mw:Nowiki">* This is not an unordered list item.</span></p>
1507 !! end
1508
1509 !! test
1510 <nowiki> spacing
1511 !! wikitext
1512 <nowiki>Lorem ipsum dolor
1513
1514 sed abit.
1515 sed nullum.
1516
1517 :and a colon
1518 </nowiki>
1519 !! html/php
1520 <p>Lorem ipsum dolor
1521
1522 sed abit.
1523 sed nullum.
1524
1525 :and a colon
1526
1527 </p>
1528 !! html/parsoid
1529 <p><span typeof="mw:Nowiki">Lorem ipsum dolor
1530
1531 sed abit.
1532 sed nullum.
1533
1534 :and a colon
1535 </span></p>
1536 !! end
1537
1538 !! test
1539 Don't parse <nowiki><span class="error"></nowiki> (T149622)
1540 !! wikitext
1541 <nowiki><span class="error"></nowiki>
1542 !! html/php
1543 <p>&lt;span class="error"&gt;
1544 </p>
1545 !! html/parsoid
1546 <p><span typeof="mw:Nowiki">&lt;span class="error"></span></p>
1547 !! end
1548
1549 !! test
1550 nowiki 3
1551 !! wikitext
1552 :There is not nowiki.
1553 :There is <nowiki>nowiki</nowiki>.
1554
1555 #There is not nowiki.
1556 #There is <nowiki>nowiki</nowiki>.
1557
1558 *There is not nowiki.
1559 *There is <nowiki>nowiki</nowiki>.
1560 !! html/php
1561 <dl><dd>There is not nowiki.</dd>
1562 <dd>There is nowiki.</dd></dl>
1563 <ol><li>There is not nowiki.</li>
1564 <li>There is nowiki.</li></ol>
1565 <ul><li>There is not nowiki.</li>
1566 <li>There is nowiki.</li></ul>
1567
1568 !! html/parsoid
1569 <dl><dd data-parsoid='{}'>There is not nowiki.</dd>
1570 <dd data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</dd></dl>
1571
1572 <ol><li data-parsoid='{}'>There is not nowiki.</li>
1573 <li data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</li></ol>
1574
1575 <ul><li data-parsoid='{}'>There is not nowiki.</li>
1576 <li data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</li></ul>
1577 !! end
1578
1579 !! test
1580 Entities inside <nowiki>
1581 !! wikitext
1582 <nowiki>&lt;</nowiki>
1583 !! html/php
1584 <p>&lt;
1585 </p>
1586 !! html/parsoid
1587 <p><span typeof="mw:Nowiki"><span typeof="mw:Entity" data-parsoid='{"src":"&amp;lt;","srcContent":"&lt;"}'>&lt;</span></span></p>
1588 !! end
1589
1590 !! test
1591 Entities inside template parameters
1592 !! wikitext
1593 {{echo|&ndash;}}
1594 !! html/php+tidy
1595 <p>&#8211;
1596 </p>
1597 !! html/parsoid
1598 <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>
1599 !! end
1600
1601 !! test
1602 Properly escape nowiki when combined with other wiki markup
1603 !! options
1604 parsoid=html2wt
1605 !! html/parsoid
1606 <p>* &lt;/nowiki&gt; tag</p>
1607 !! wikitext
1608 <nowiki>*</nowiki> <nowiki>&lt;/nowiki&gt;</nowiki> tag
1609 !! end
1610
1611 !! test
1612 T93824: Put escaped HTML tags inside nowiki
1613 !! options
1614 parsoid=html2wt
1615 !! html/parsoid
1616 <p>&lt;h2&gt;foo&lt;/h2&gt;</p>
1617 !! wikitext
1618 <nowiki><h2>foo</h2></nowiki>
1619 !! end
1620
1621 !! test
1622 T71950: 1. Put nowiki as close to cause as possible, even with non-quote escapable chars
1623 !! options
1624 parsoid=html2wt
1625 !! html/parsoid
1626 <p>This text: L'<a rel="mw:WikiLink" href="./Foo">Foo</a>
1627 This text: L''<a rel="mw:WikiLink" href="./Foo">Foo</a>
1628 This text: L'''<a rel="mw:WikiLink" href="./Foo">Foo</a>''</p>
1629 !! wikitext
1630 This text: L'[[Foo]]
1631 This text: L<nowiki>''</nowiki>[[Foo]]
1632 This text: L<nowiki>'''</nowiki>[[Foo]]<nowiki>''</nowiki>
1633 !! end
1634
1635 # This test fails because wikitext whitespace is not normalized before comparing.
1636 !! test
1637 T71950: 2. Put nowiki as close to cause as possible, after ' :'
1638 !! options
1639 parsoid=html2wt
1640 !! html/parsoid
1641 <p>This text : L''<a rel="mw:WikiLink" href="./Foo">Foo</a>
1642 </p>
1643 !! wikitext
1644 This text : L<nowiki>''</nowiki>[[Foo]]
1645 !! end
1646
1647 # This test and the next one are html2wt only as they test that incorrect wikitext
1648 # passed in template arguments gets escaped or wrapped in nowikis where required.
1649 !! test
1650 T71482: Use {{!}} instead of nowiki for single pipe in template argument
1651 !! options
1652 parsoid=html2wt
1653 !! html/parsoid
1654 <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>
1655 <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>
1656 !! wikitext
1657 {{echo|foo{{!}}bar}}
1658 {{echo|<nowiki>foo|bar |[[</nowiki>}}
1659 !! end
1660
1661 !! test
1662 T53961: Output correct nowikis in template arguments
1663 !! options
1664 parsoid=html2wt
1665 !! html/parsoid
1666 <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>
1667 <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>
1668 <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>
1669 <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>
1670 <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>
1671 !! wikitext
1672 {{echo|a [ b}}
1673 {{echo|<nowiki>a }} b</nowiki>}}
1674 {{echo|<nowiki>a [[ b</nowiki>}}
1675 {{echo|<nowiki>a | {{ ]]</nowiki>}}
1676 {{echo|a <nowiki>}</nowiki>}}
1677 !! end
1678
1679 !! test
1680 Cases where "!!" needs nowiki protection
1681 !! options
1682 parsoid=html2wt
1683 !! html/parsoid
1684 <table>
1685 <tr><th>this needs protection !! here</th></tr>
1686 </table>
1687
1688 <table>
1689 <tr><th>this does not need
1690 protection !! here</th></tr>
1691 </table>
1692 !! wikitext
1693 {|
1694 !<nowiki>this needs protection !! here</nowiki>
1695 |}
1696
1697 {|
1698 !this does not need
1699 protection !! here
1700 |}
1701 !! end
1702
1703 ###
1704 ### Comments
1705 ###
1706 !! test
1707 Comments and Indent-Pre
1708 !! wikitext
1709 <!-- comment 1 --> asdf
1710
1711 <!-- comment 1 --> asdf
1712 <!-- comment 2 -->
1713
1714 <!-- comment 1 --> asdf
1715 <!-- comment 2 -->xyz
1716
1717 <!-- comment 1 --> asdf
1718 <!-- comment 2 --> xyz
1719 !! html
1720 <pre>asdf
1721 </pre>
1722 <pre>asdf
1723 </pre>
1724 <pre>asdf
1725 </pre>
1726 <p>xyz
1727 </p>
1728 <pre>asdf
1729 xyz
1730 </pre>
1731 !! end
1732
1733 !! test
1734 Comment test 2a
1735 !! wikitext
1736 asdf
1737 <!-- comment 1 -->
1738 jkl
1739 !! html
1740 <p>asdf
1741 jkl
1742 </p>
1743 !! end
1744
1745 !! test
1746 Comment test 2b
1747 !! wikitext
1748 asdf
1749 <!-- comment 1 -->
1750
1751 jkl
1752 !! html
1753 <p>asdf
1754 </p><p>jkl
1755 </p>
1756 !! end
1757
1758 !! test
1759 Comment test 3
1760 !! wikitext
1761 asdf
1762 <!-- comment 1 -->
1763 <!-- comment 2 -->
1764 jkl
1765 !! html
1766 <p>asdf
1767 jkl
1768 </p>
1769 !! end
1770
1771 !! test
1772 Comment test 4
1773 !! wikitext
1774 asdf<!-- comment 1 -->jkl
1775 !! html
1776 <p>asdfjkl
1777 </p>
1778 !! end
1779
1780 !! test
1781 Comment spacing
1782 !! wikitext
1783 a
1784 <!-- foo --> b <!-- bar -->
1785 c
1786 !! html
1787 <p>a
1788 </p>
1789 <pre> b
1790 </pre>
1791 <p>c
1792 </p>
1793 !! end
1794
1795 !! test
1796 Comment whitespace
1797 !! wikitext
1798 <!-- returns a single newline, not nothing, since the newline after > is not stripped -->
1799 !! html
1800
1801 !! end
1802
1803 !! test
1804 Comment semantics and delimiters
1805 !! wikitext
1806 <!-- --><!----><!-----><!------>
1807 !! html/php
1808
1809 !! html/parsoid
1810 <!-- --><!----><!--&#x2D;--><!--&#x2D;&#x2D;-->
1811 !! end
1812
1813 !! test
1814 Comment semantics and delimiters, redux
1815 !! wikitext
1816 <!-- In SGML every "foo" here would actually show up in the text -- foo -- bar
1817 -- foo -- funky huh? ... -->
1818 !! html/php
1819
1820 !! html/parsoid
1821 <!-- In SGML every "foo" here would actually show up in the text &#x2D;&#x2D; foo &#x2D;&#x2D; bar
1822 &#x2D;&#x2D; foo &#x2D;&#x2D; funky huh? ... -->
1823 !! end
1824
1825 !! test
1826 Comment semantics and delimiters: directors cut
1827 !! wikitext
1828 <!-- ... However we like to keep things simple and somewhat XML-ish so we eat
1829 everything starting with < followed by !-- until the first -- and > we see,
1830 that wouldn't be valid XML however, since in XML -- has to terminate a comment
1831 -->-->
1832 !! html/php
1833 <p>--&gt;
1834 </p>
1835 !! html/parsoid
1836 <!-- ... However we like to keep things simple and somewhat XML&#x2D;ish so we eat
1837 everything starting with < followed by !&#x2D;&#x2D; until the first &#x2D;&#x2D; and &#x3E; we see,
1838 that wouldn't be valid XML however, since in XML &#x2D;&#x2D; has to terminate a comment
1839 --><p>--></p>
1840 !! end
1841
1842 !! test
1843 Comment semantics: nesting
1844 !! wikitext
1845 <!--<!-- no, we're not going to do anything fancy here -->-->
1846 !! html/php
1847 <p>--&gt;
1848 </p>
1849 !! html/parsoid
1850 <!--<!&#x2D;&#x2D; no, we're not going to do anything fancy here --><p>--></p>
1851 !! end
1852
1853 # Parsoid closes the unclosed comment, even if it means a slight
1854 # round-trip diff.
1855 !! test
1856 Comment semantics: unclosed comment at end
1857 !! options
1858 parsoid=wt2html,html2html
1859 !! wikitext
1860 <!--This comment will run out to the end of the document
1861 !! html/php
1862
1863 !! html/parsoid
1864 <!--This comment will run out to the end of the document-->
1865 !! end
1866
1867 !! test
1868 Comment semantics: normalize comments to play nice with XML and browsers
1869 !! wikitext
1870 <!-- Browsers --!> think this is closed -->
1871 <!--> This would normally be text -->
1872 <!---> As would this -->
1873 <!-- XML doesn't like trailing dashes -------->
1874 <!-- Nor doubled hyphens -- anywhere in the data -->
1875 But this is not a comment.
1876 !! html/php
1877 <p>But this is not a comment.
1878 </p>
1879 !! html/parsoid
1880 <!-- Browsers &#x2D;&#x2D;!&#x3E; think this is closed -->
1881 <!--&#x3E; This would normally be text -->
1882 <!--&#x2D;&#x3E; As would this -->
1883 <!-- XML doesn't like trailing dashes &#x2D;&#x2D;&#x2D;&#x2D;&#x2D;&#x2D;-->
1884 <!-- Nor doubled hyphens &#x2D;&#x2D; anywhere in the data -->
1885 <p>But this is not a comment.</p>
1886 !! end
1887
1888 !! test
1889 Comment semantics: round-trip even text which contains encoded -->
1890 !! wikitext
1891 <!-- hello & goodbye - > --&gt; --&amp;gt; --&xx -->
1892 !! html/parsoid
1893 <!-- hello &#x26; goodbye &#x2D; &#x3E; &#x2D;&#x2D;&#x3E; &#x2D;&#x2D;&#x26;gt; &#x2D;&#x2D;&#x26;xx -->
1894 !! end
1895
1896 !! test
1897 Comment in template title
1898 !! wikitext
1899 {{f<!---->oo}}
1900 !! html
1901 <p>FOO
1902 </p>
1903 !! end
1904
1905 !! test
1906 Comment on its own line post-expand
1907 !! wikitext
1908 a
1909 {{blank}}<!---->
1910 b
1911 !! html
1912 <p>a
1913 </p><p>b
1914 </p>
1915 !! end
1916
1917 !! test
1918 Comment on its own line post-expand with non-significant whitespace
1919 !! wikitext
1920 a
1921 {{blank}} <!---->
1922 b
1923 !! html
1924 <p>a
1925 </p><p>b
1926 </p>
1927 !! end
1928
1929 !! test
1930 post-expand include size being exceeded
1931 !! options
1932 maxincludesize=20
1933 !! wikitext
1934 {{echo3|1234567890}}
1935 !! html
1936 <p><a href="/wiki/Template:Echo3" title="Template:Echo3">Template:Echo3</a><!-- WARNING: template omitted, post-expand include size too large -->
1937 </p>
1938 !! end
1939
1940 !! test
1941 max template depth being reached
1942 !! options
1943 maxtemplatedepth=1
1944 !! wikitext
1945 {{echo with depth|too deep!}}
1946 !! html
1947 <p><span class="error">Template recursion depth limit exceeded (1)</span>
1948 </p>
1949 !! end
1950
1951 !! test
1952 multiple templates that are redirects
1953 !! wikitext
1954 {{redirect to foo}}
1955 {{redirect to foo}}
1956 !! html
1957 <p>FOO
1958 FOO
1959 </p>
1960 !! end
1961
1962 !! test
1963 Multiple comments should still parse as SOL-transparent
1964 !! options
1965 parsoid=wt2html,wt2wt
1966 !! wikitext
1967 <!--c1-->*a
1968 <!--c2--><!--c3--><!--c4-->*b
1969 !! html/php
1970 <ul><li>a</li>
1971 <li>b</li></ul>
1972
1973 !! html/parsoid
1974 <!--c1--><ul>
1975 <li>a
1976 </li>
1977 <!--c2--><!--c3--><!--c4-->
1978 <li>b
1979 </li>
1980 </ul>
1981 !! end
1982
1983 ## Make sure ">" gets escaped in comments to avoid XSS
1984 !! test
1985 IE conditional comments
1986 !! wikitext
1987 <!--[if lt IE 9]>
1988 <script>alert('hi');</script>
1989 <![endif]-->
1990 !! html/parsoid
1991 <!--[if lt IE 9]&#x3E;
1992 <script&#x3E;alert('hi');</script&#x3E;
1993 <![endif]-->
1994 !! end
1995
1996 ###
1997 ### paragraph wrapping tests
1998 ###
1999
2000 !! test
2001 No block tags
2002 !! wikitext
2003 a
2004
2005 b
2006 !! html
2007 <p>a
2008 </p><p>b
2009 </p>
2010 !! end
2011
2012 !! test
2013 Block tag on one line (<div>)
2014 !! wikitext
2015 a <div>foo</div>
2016
2017 b
2018 !! html
2019 a <div>foo</div>
2020 <p>b
2021 </p>
2022 !! html+tidy
2023 <p>a </p><div>foo</div>
2024 <p>b
2025 </p>
2026 !! end
2027
2028 !! test
2029 No p-wrappable content
2030 !! options
2031 parsoid=wt2html,html2html
2032 !! wikitext
2033 <span><div>x</div></span>
2034 <span><s><div>x</div></s></span>
2035 <small><em></em></small><span><s><div>x</div></s></span>
2036 !! html+tidy
2037 <span><div>x</div></span>
2038 <span><s><div>x</div></s></span>
2039 <p><small><em></em></small></p><span><s><div>x</div></s></span>
2040 !! end
2041
2042 # T177612: Parsoid-only test
2043 !! test
2044 Transclusion meta tags shouldn't trip Parsoid's useless p-wrapper stripping code
2045 !! wikitext
2046 {{echo|<span><div>x</div></span>}}
2047 x
2048 !! html/parsoid
2049 <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>
2050 <p>x</p>
2051 !! end
2052
2053 !! test
2054 Block tag on one line (<blockquote>)
2055 !! wikitext
2056 a <blockquote>foo</blockquote>
2057
2058 b
2059 !! html
2060 a <blockquote>foo</blockquote>
2061 <p>b
2062 </p>
2063 !! html+tidy
2064 <p>a </p><blockquote><p>foo</p></blockquote>
2065 <p>b
2066 </p>
2067 !! end
2068
2069 !! test
2070 Block tag on both lines (<div>)
2071 !! wikitext
2072 a <div>foo</div>
2073
2074 b <div>foo</div>
2075 !! html
2076 a <div>foo</div>
2077 b <div>foo</div>
2078
2079 !! html+tidy
2080 <p>a </p><div>foo</div><p>
2081 b </p><div>foo</div>
2082 !! end
2083
2084 !! test
2085 Block tag on both lines (<blockquote>)
2086 !! wikitext
2087 a <blockquote>foo</blockquote>
2088
2089 b <blockquote>foo</blockquote>
2090 !! html
2091 a <blockquote>foo</blockquote>
2092 b <blockquote>foo</blockquote>
2093
2094 !! html+tidy
2095 <p>a </p><blockquote><p>foo</p></blockquote><p>
2096 b </p><blockquote><p>foo</p></blockquote>
2097 !! end
2098
2099 !! test
2100 Multiple lines without block tags
2101 !! wikitext
2102 <div>foo</div> a
2103 b
2104 c
2105 d<!--foo--> e
2106 x <div>foo</div> z
2107 !! html
2108 <div>foo</div> a
2109 <p>b
2110 c
2111 d e
2112 </p>
2113 x <div>foo</div> z
2114
2115 !! html+tidy
2116 <div>foo</div><p> a
2117 </p><p>b
2118 c
2119 d e
2120 </p><p>
2121 x </p><div>foo</div><p> z
2122 </p>
2123 !! end
2124
2125 !! test
2126 Empty lines between lines with block tags
2127 !! wikitext
2128 <div></div>
2129
2130
2131 <div></div>a
2132
2133 b
2134 <div>a</div>b
2135
2136 <div>b</div>d
2137
2138
2139 <div>e</div>
2140 !! html
2141 <div></div>
2142 <p><br />
2143 </p>
2144 <div></div>a
2145 <p>b
2146 </p>
2147 <div>a</div>b
2148 <div>b</div>d
2149 <p><br />
2150 </p>
2151 <div>e</div>
2152
2153 !! html+tidy
2154 <div></div>
2155 <p><br />
2156 </p>
2157 <div></div><p>a
2158 </p><p>b
2159 </p>
2160 <div>a</div><p>b
2161 </p><div>b</div><p>d
2162 </p><p><br />
2163 </p>
2164 <div>e</div>
2165 !! html/parsoid
2166 <div data-parsoid='{"stx":"html"}'></div>
2167
2168 <p><br /></p>
2169 <div data-parsoid='{"stx":"html"}'></div><p>a</p>
2170
2171 <p>b</p>
2172 <div data-parsoid='{"stx":"html"}'>a</div><p>b</p>
2173
2174 <div data-parsoid='{"stx":"html"}'>b</div><p>d</p>
2175
2176 <p><br /></p>
2177 <div data-parsoid='{"stx":"html"}'>e</div>
2178 !! end
2179
2180 !! test
2181 Unclosed HTML p-tags should be handled properly
2182 !! wikitext
2183 <div><p>foo</div>
2184 a
2185
2186 b
2187 !! html/php+tidy
2188 <div><p>foo</p></div>
2189 <p>a
2190 </p><p>b
2191 </p>
2192 !! html/parsoid
2193 <div data-parsoid='{"stx":"html"}'><p data-parsoid='{"stx":"html", "autoInsertedEnd":true}'>foo</p></div>
2194 <p>a</p>
2195 <p>b</p>
2196 !! end
2197
2198 ## SSS FIXME: I can come up with other scenarios where this doesn't work because
2199 ## of eager output of buffered tokens in the p-wrapper. But, I'm going to ignore
2200 ## them for now.
2201 !! test
2202 1. P-wrapping should leave sol-transparent tags outside p-tags where possible
2203 !! options
2204 parsoid=wt2html
2205 !! wikitext
2206 a [[Category:A1]] [[Category:A2]]
2207 [[Category:A3]]
2208 [[Category:A4]]
2209 !! html/parsoid
2210 <p>a</p>
2211 <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"/>
2212 !! end
2213
2214 !! test
2215 2. P-wrapping should leave sol-transparent tags outside p-tags where possible
2216 !! options
2217 parsoid=wt2html
2218 !! wikitext
2219 [[Category:A1]]a
2220 !! html/parsoid
2221 <link rel="mw:PageProp/Category" href="./Category:A1"/><p>a</p>
2222 !! end
2223
2224 !! test
2225 No paragraph necessary for SOL transparent template
2226 !! wikitext
2227 <span><div>foo</div></span>
2228 [[Category:Foo]]
2229
2230 <span><div>foo</div></span>
2231 {{echo|[[Category:Foo]]}}
2232 !! html/php
2233 <span><div>foo</div></span>
2234 <span><div>foo</div></span>
2235
2236 !! html/parsoid
2237 <span data-parsoid='{"stx":"html"}'><div data-parsoid='{"stx":"html"}'>foo</div></span>
2238 <link rel="mw:PageProp/Category" href="./Category:Foo"/>
2239
2240 <span data-parsoid='{"stx":"html"}'><div data-parsoid='{"stx":"html"}'>foo</div></span>
2241 <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}}]}'/>
2242 !! end
2243
2244 !! test
2245 Avoid expanding multiline sol transparent template ranges unnecessarily
2246 !! wikitext
2247 hi
2248
2249
2250 {{echo|<br/>
2251 }}
2252
2253 [[Category:Ho]]
2254 !! html/php
2255 <p>hi
2256 </p><p><br />
2257 <br />
2258 </p>
2259 !! html/parsoid
2260 <p>hi</p>
2261
2262 <p><br />
2263 <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">
2264 </span></p>
2265
2266 <link rel="mw:PageProp/Category" href="./Category:Ho" />
2267 !! end
2268
2269 !! test
2270 Paragraph wrapping following unclosed table
2271 !! options
2272 parsoid=wt2html,html2html
2273 !! wikitext
2274 {|
2275 |-
2276
2277 {|
2278 | x
2279 |}
2280
2281 a
2282
2283 b
2284
2285 c
2286 !! html/php+tidy
2287 <table>
2288
2289
2290 </table><table>
2291 <tbody><tr>
2292 <td>x
2293 </td></tr></tbody></table>
2294 <p>a
2295 </p><p>b
2296 </p><p>c
2297 </p>
2298 !! html/parsoid
2299 <table data-parsoid='{"autoInsertedEnd":true}'>
2300 <tbody><tr class="mw-empty-elt" data-parsoid='{"startTagSrc":"|-"}'></tr>
2301
2302 </tbody></table><table>
2303 <tbody><tr data-parsoid='{"autoInsertedStart":true}'><td>x</td></tr>
2304 </tbody></table>
2305
2306 <p>a</p>
2307
2308 <p>b</p>
2309
2310 <p>c</p>
2311 !! end
2312
2313 !! test
2314 Paragraph wrapping suppressed in html p
2315 !! options
2316 parsoid=wt2html,html2html
2317 !! wikitext
2318 <p>
2319
2320
2321 hi
2322
2323
2324
2325 </p>
2326 !! html/php+tidy
2327 <p>
2328
2329
2330 hi
2331
2332
2333
2334 </p>
2335 !! html/parsoid
2336 <p data-parsoid='{"stx":"html"}'>
2337
2338
2339 hi
2340
2341
2342
2343 </p>
2344 !! end
2345
2346 !! test
2347 Dangling table row doesn't prevent p-wrapping
2348 !! options
2349 parsoid=wt2html,html2html
2350 !! wikitext
2351 {|
2352 | hi
2353 |-
2354 |} ho
2355 !! html/parsoid
2356 <table>
2357 <tbody><tr><td>hi</td></tr>
2358 <tr class="mw-empty-elt"></tr>
2359 </tbody></table><p> ho</p>
2360 !! end
2361
2362 !! test
2363 P-wrapping non-breaking spaces
2364 !! wikitext
2365  
2366 !! html/php+tidy
2367 <p>&#160;
2368 </p>
2369 !! html/parsoid
2370 <p> </p>
2371 !! end
2372
2373 ###
2374 ### Preformatted text
2375 ###
2376
2377 !! test
2378 Preformatted text
2379 !! wikitext
2380 This is some
2381 Preformatted text
2382 With ''italic''
2383 And '''bold'''
2384 And a [[Main Page|link]]
2385 !! html
2386 <pre>This is some
2387 Preformatted text
2388 With <i>italic</i>
2389 And <b>bold</b>
2390 And a <a href="/wiki/Main_Page" title="Main Page">link</a>
2391 </pre>
2392 !! end
2393
2394 !! test
2395 Tabs don't trigger preformatted text
2396 !! wikitext
2397 This is not
2398 preformatted text.
2399 This is preformatted text.
2400 So is this.
2401 !! html/php
2402 <p> This is not
2403 preformatted text.
2404 </p>
2405 <pre>This is preformatted text.
2406 So is this.
2407 </pre>
2408 !! html/parsoid
2409 <p> This is not
2410 preformatted text.</p>
2411 <pre>This is preformatted text.
2412 So is this.</pre>
2413 !! end
2414
2415 !! test
2416 Space before tab needs nowiki pre protection
2417 !! options
2418 parsoid=html2wt
2419 !! html/parsoid
2420 <p> a</p>
2421 !! wikitext
2422 <nowiki> </nowiki> a
2423 !! end
2424
2425 !! test
2426 Ident preformatting with inline content
2427 !! wikitext
2428 a
2429 ''b''
2430 !! html
2431 <pre>a
2432 <i>b</i>
2433 </pre>
2434 !! end
2435
2436 !! test
2437 <pre> with <nowiki> inside (compatibility with 1.6 and earlier)
2438 !! wikitext
2439 <pre><nowiki>
2440 <b>
2441 <cite>
2442 <em>
2443 </nowiki></pre>
2444 !! html
2445 <pre>
2446 &lt;b&gt;
2447 &lt;cite&gt;
2448 &lt;em&gt;
2449 </pre>
2450
2451 !! end
2452
2453 !! test
2454 Regression with preformatted in <center>
2455 !! wikitext
2456 <center>
2457 Blah
2458 </center>
2459 !! html
2460 <center>
2461 <pre>Blah
2462 </pre>
2463 </center>
2464
2465 !! end
2466
2467 !! test
2468 T54763: Preformatted in <blockquote>
2469 !! wikitext
2470 <blockquote>
2471 Blah
2472 {|
2473 |
2474 indented cell (no pre-wrapping!)
2475 |}
2476 </blockquote>
2477 !! html
2478 <blockquote>
2479 <p> Blah
2480 </p>
2481 <table>
2482 <tr>
2483 <td>
2484 <p> indented cell (no pre-wrapping!)
2485 </p>
2486 </td></tr></table>
2487 </blockquote>
2488
2489 !! end
2490
2491 !! test
2492 T53086: Double newlines in blockquotes should be turned into paragraphs
2493 !! wikitext
2494 <blockquote>
2495 Foo
2496
2497 Bar
2498 </blockquote>
2499 !! html
2500 <blockquote>
2501 <p>Foo
2502 </p><p>Bar
2503 </p>
2504 </blockquote>
2505
2506 !! end
2507
2508 !! test
2509 T17491: <ins>/<del> in blockquote
2510 !! wikitext
2511 <blockquote>
2512 Foo <del>bar</del> <ins>baz</ins> quux
2513 </blockquote>
2514 !! html
2515 <blockquote>
2516 <p>Foo <del>bar</del> <ins>baz</ins> quux
2517 </p>
2518 </blockquote>
2519
2520 !! html+tidy
2521 <blockquote>
2522 <p>Foo <del>bar</del> <ins>baz</ins> quux
2523 </p>
2524 </blockquote>
2525 !! end
2526
2527 !! test
2528 T17491: <ins>/<del> in blockquote (2)
2529 !! wikitext
2530 <blockquote>Foo <del>bar</del> <ins>baz</ins> quux
2531 </blockquote>
2532 !! html
2533 <blockquote>Foo <del>bar</del> <ins>baz</ins> quux
2534 </blockquote>
2535
2536 !! html+tidy
2537 <blockquote><p>Foo <del>bar</del> <ins>baz</ins> quux
2538 </p></blockquote>
2539 !! end
2540
2541 !! test
2542 <pre> with attributes (T5202)
2543 !! wikitext
2544 <pre style="background: blue; color:white">Bluescreen of WikiDeath</pre>
2545 !! html
2546 <pre style="background: blue; color:white">Bluescreen of WikiDeath</pre>
2547
2548 !! end
2549
2550 !! test
2551 <pre> with width attribute (T5202)
2552 !! wikitext
2553 <pre width="8">Narrow screen goodies</pre>
2554 !! html
2555 <pre width="8">Narrow screen goodies</pre>
2556
2557 !! end
2558
2559 !! test
2560 <pre> with forbidden attribute (T5202)
2561 !! wikitext
2562 <pre width="8" onmouseover="alert(document.cookie)">Narrow screen goodies</pre>
2563 !! html
2564 <pre width="8">Narrow screen goodies</pre>
2565
2566 !! end
2567
2568 !! test
2569 Entities inside <pre>
2570 !! wikitext
2571 <pre>&lt;</pre>
2572 !! html
2573 <pre>&lt;</pre>
2574
2575 !! end
2576
2577 !! test
2578 <pre> with forbidden attribute values (T5202)
2579 !! wikitext
2580 <pre width="8" style="border-width: expression(alert(document.cookie))">Narrow screen goodies</pre>
2581 !! html
2582 <pre width="8" style="/* insecure input */">Narrow screen goodies</pre>
2583
2584 !! end
2585
2586 !! test
2587 <nowiki> inside <pre> (T15238)
2588 !! wikitext
2589 <pre>
2590 <nowiki>
2591 </pre>
2592 <pre>
2593 <nowiki></nowiki>
2594 </pre>
2595 <pre><nowiki><nowiki></nowiki>Foo<nowiki></nowiki></nowiki></pre>
2596 !! html
2597 <pre>
2598 &lt;nowiki&gt;
2599 </pre>
2600 <pre>
2601
2602 </pre>
2603 <pre>&lt;nowiki&gt;Foo&lt;/nowiki&gt;</pre>
2604
2605 !! end
2606
2607 !! test
2608 <nowiki> inside of #tag:pre
2609 !! wikitext
2610 {{#tag:pre|Foo <nowiki>&rarr;bar</nowiki>}}
2611 !! html/php
2612 <pre>Foo &#8594;bar</pre>
2613
2614 !! html/parsoid
2615 <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>
2616 !! end
2617
2618 ## Don't expect this to rt, Parsoid drops the unmatched closing pre tags that
2619 ## aren't enclosed in nowikis.
2620 !! test
2621 <nowiki> and <pre> preference (first one wins)
2622 !! options
2623 parsoid=wt2html
2624 !! wikitext
2625 <pre>
2626 <nowiki>
2627 </pre>
2628 </nowiki>
2629 </pre>
2630
2631 <nowiki>
2632 <pre>
2633 <nowiki>
2634 </pre>
2635 </nowiki>
2636 </pre>
2637
2638 !! html/php
2639 <pre>
2640 &lt;nowiki&gt;
2641 </pre>
2642 <p>&lt;/nowiki&gt;
2643 &lt;/pre&gt;
2644 </p><p>
2645 &lt;pre&gt;
2646 &lt;nowiki&gt;
2647 &lt;/pre&gt;
2648
2649 &lt;/pre&gt;
2650 </p>
2651 !! html/parsoid
2652 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n&lt;nowiki>\n"}}'>&lt;nowiki>
2653 </pre>
2654 <p>&lt;/nowiki></p>
2655
2656
2657 <p><span typeof="mw:Nowiki">
2658 &lt;pre>
2659 &lt;nowiki>
2660 &lt;/pre>
2661 </span></p>
2662 !! end
2663
2664 !! test
2665 </pre> inside nowiki
2666 !! wikitext
2667 <nowiki></pre></nowiki>
2668 !! html
2669 <p>&lt;/pre&gt;
2670 </p>
2671 !! end
2672
2673 !! test
2674 Empty pre; pre inside other HTML tags (T56946)
2675 !! wikitext
2676 a
2677
2678 <div><pre>
2679 foo
2680 </pre></div>
2681 <pre></pre>
2682 !! html/php+tidy
2683 <p>a
2684 </p>
2685 <div><pre>foo
2686 </pre></div>
2687 <pre></pre>
2688 !! html/parsoid
2689 <p>a</p>
2690
2691 <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
2692 </pre></div>
2693 <pre typeof="mw:Extension/pre" about="#mwt4" data-parsoid='{"stx":"html"}' data-mw='{"name":"pre","attrs":{},"body":{"extsrc":""}}'></pre>
2694 !! end
2695
2696 !! test
2697 HTML pre followed by indent-pre
2698 !! wikitext
2699 <pre>foo</pre>
2700 bar
2701 !! html
2702 <pre>foo</pre>
2703 <pre>bar
2704 </pre>
2705 !! end
2706
2707 !! test
2708 Block tag pre
2709 !! wikitext
2710 <p><pre>foo</pre></p>
2711 !! html/php+tidy
2712 <p class="mw-empty-elt"></p><pre>foo</pre><p class="mw-empty-elt"></p>
2713 !! html/parsoid
2714 <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>
2715 !! end
2716
2717 !!test
2718 Templates: Indent-Pre: 1a. Templates that break a line should suppress <pre>
2719 !! wikitext
2720 {{echo|}}
2721 !! html
2722
2723 !!end
2724
2725 !!test
2726 Templates: Indent-Pre: 1b. Templates that break a line should suppress <pre>
2727 !! wikitext
2728 {{echo|
2729 foo}}
2730 !! html
2731 <p>foo
2732 </p>
2733 !!end
2734
2735 !! test
2736 Templates: Indent-Pre: 1c: Wrapping should be based on expanded content
2737 !! wikitext
2738 {{echo|a
2739 b}}
2740 !! html
2741 <pre>a
2742 </pre>
2743 <p>b
2744 </p>
2745 !!end
2746
2747 !! test
2748 Templates: Indent-Pre: 1d: Wrapping should be based on expanded content
2749 !! wikitext
2750 {{echo|a
2751 b
2752 c
2753 d
2754 e
2755 }}
2756 !! html
2757 <pre>a
2758 </pre>
2759 <p>b
2760 c
2761 </p>
2762 <pre>d
2763 </pre>
2764 <p>e
2765 </p>
2766 !!end
2767
2768 !!test
2769 Templates: Indent-Pre: 1e. Wrapping should be based on expanded content
2770 !! wikitext
2771 {{echo| foo}}
2772
2773 {{echo| foo}}{{echo| bar}}
2774
2775 {{echo| foo}}
2776 {{echo| bar}}
2777
2778 {{echo|<!--cmt--> foo}}
2779
2780 <!--cmt-->{{echo| foo}}
2781
2782 {{echo|{{echo| }}bar}}
2783 !! html
2784 <pre>foo
2785 </pre>
2786 <pre>foo bar
2787 </pre>
2788 <pre>foo
2789 bar
2790 </pre>
2791 <pre>foo
2792 </pre>
2793 <pre>foo
2794 </pre>
2795 <pre>bar
2796 </pre>
2797 !!end
2798
2799 !! test
2800 Templates: Indent-Pre: 1f: Wrapping should be based on expanded content
2801 !! wikitext
2802 {{echo| }}a
2803
2804 {{echo|
2805 }}a
2806
2807 {{echo|
2808 b}}
2809
2810 {{echo|a
2811 }}b
2812
2813 {{echo|a
2814 }} b
2815 !! html
2816 <pre>a
2817 </pre>
2818 <p><br />
2819 </p>
2820 <pre>a
2821 </pre>
2822 <p><br />
2823 </p>
2824 <pre>b
2825 </pre>
2826 <p>a
2827 </p>
2828 <pre>b
2829 </pre>
2830 <p>a
2831 </p>
2832 <pre>b
2833 </pre>
2834 !!end
2835
2836 ## Hmm, should Parsoid rt this?
2837 !! test
2838 Pres with newline attributes
2839 !! options
2840 parsoid=wt2html,html2html
2841 !! wikitext
2842 <pre class="one
2843 two">hi</pre>
2844 !! html/php
2845 <pre class="one two">hi</pre>
2846
2847 !! html/parsoid
2848 <pre class="one two" typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{"class":"one two"},"body":{"extsrc":"hi"}}'>hi</pre>
2849 !! end
2850
2851 !! test
2852 Things that look like <pre> tags aren't treated as such
2853 !! wikitext
2854 Barack Obama <President> of the United States
2855 <President></President>
2856 !! html
2857 <p>Barack Obama &lt;President&gt; of the United States
2858 &lt;President&gt;&lt;/President&gt;
2859 </p>
2860 !! end
2861
2862 ## Remex doesn't account for fostered content.
2863 ## The difference between Parsoid and the PHP parser can be attributed to core
2864 ## commit 674e8388cba and 710618f89af in Parsoid's repo. Parsoid doesn't
2865 ## tokenize unmatched extension tags that shadow html tags as strings to ease
2866 ## an escaping mechanism. See the comment in `maybeExtensionTag`.
2867 !! test
2868 Handle broken pre-like tags (T66025)
2869 !! options
2870 parsoid=wt2html
2871 !! wikitext
2872 {{echo|<pre <pre>x</pre>}}
2873
2874 <table><pre </table>
2875 !! html/php
2876 <pre>x</pre>
2877 <table>&lt;pre </table>
2878
2879 !! html/php+tidy
2880 <pre>x</pre>
2881 &lt;pre <table></table>
2882 !! html/parsoid
2883 <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>
2884
2885 <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>
2886 !! end
2887
2888 ## Similar to the above, but shows the difference between extension and html tags
2889 !! test
2890 Less than in attribute position
2891 !! wikitext
2892 <pre <pre>123</pre>
2893
2894 <div <div>123</div>
2895 !! html/php+tidy
2896 <pre>123</pre><p>
2897 &lt;div </p><div>123</div>
2898 !! html/parsoid
2899 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{"&lt;pre":""},"body":{"extsrc":"123"}}'>123</pre><p>
2900
2901 &lt;div </p><div>123</div>
2902 !! end
2903
2904 !! test
2905 Parsoid: handle pre with space after attribute
2906 !! options
2907 parsoid=wt2html
2908 !! wikitext
2909 <pre style="width:50%;" >{{echo|foo}}</pre>
2910 !! html/php
2911 <pre style="width:50%;">{{echo|foo}}</pre>
2912
2913 !! html/parsoid
2914 <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>
2915 !! end
2916
2917 !! test
2918 Self-closed pre
2919 !! wikitext
2920 <pre />
2921 !! html/php
2922 <pre></pre>
2923
2924 !! html/parsoid
2925 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{}}'></pre>
2926 !! end
2927
2928 !! test
2929 Newline before table-close generates empty table row: T208619
2930 !! wikitext
2931 {|
2932
2933 |}
2934 !! html/php+tidy
2935 <table>
2936
2937 <tbody><tr><td></td></tr></tbody></table>
2938 !! html/parsoid
2939 <table data-parsoid='{}'>
2940
2941 </table>
2942 !! end
2943
2944 # PHP has one more row in the output than Parsoid does: T208619
2945 !! test
2946 Parsoid: Don't paragraph-wrap fosterable content even if table syntax is unbalanced
2947 !! options
2948 parsoid=wt2html
2949 !! wikitext
2950 {|
2951 <td>
2952 <td>
2953 </td>
2954
2955
2956
2957 |}
2958 !! html/php+tidy
2959 <table>
2960 <tbody><tr><td>
2961 </td><td>
2962 </td>
2963
2964
2965
2966 </tr><tr><td></td></tr></tbody></table>
2967 !! html/parsoid
2968 <table>
2969
2970 <tbody>
2971 <tr>
2972 <td></td>
2973
2974 <td>
2975 </td></tr>
2976
2977
2978
2979 </tbody></table>
2980 !! end
2981
2982
2983 #--------------------------------------------------------------------
2984 # Transclusion parameter whitespace stripping tests
2985 # Behavior is different for positional and named parameters
2986 #--------------------------------------------------------------------
2987 !! test
2988 Templates: Strip leading and trailing whitespace from named-param values
2989 !! wikitext
2990 {{echo|1= a }}
2991
2992 {{echo|1= {{echo|b}} }}
2993
2994 {{echo| 1 =
2995 c }}
2996
2997 {{echo| 1 =
2998 * d
2999 }}
3000 !! html
3001 <p>a
3002 </p><p>b
3003 </p><p>c
3004 </p>
3005 <ul><li>d</li></ul>
3006
3007 !! end
3008
3009 !! test
3010 Templates: Don't strip whitespace from positional-param values
3011 !! wikitext
3012 {{echo|a }}
3013
3014 {{echo|{{echo|b}} }}
3015
3016 {{echo| c
3017 }}
3018
3019 {{echo| {{echo|d}}
3020 }}
3021
3022 {{echo|
3023 e}}
3024
3025 {{echo|
3026 *f}}
3027
3028 {{echo|
3029 }}g
3030 !! html
3031 <p>a
3032 </p><p>b
3033 </p>
3034 <pre>c
3035 </pre>
3036 <p><br />
3037 </p>
3038 <pre>d
3039 </pre>
3040 <p><br />
3041 </p>
3042 <pre>e
3043 </pre>
3044 <p><br />
3045 </p>
3046 <ul><li>f</li></ul>
3047 <p><br />
3048 </p>
3049 <pre>g
3050 </pre>
3051 !! end
3052
3053 !! test
3054 Templates: Don't recognize targets split by newlines
3055 !! options
3056 parsoid=wt2html
3057 !! wikitext
3058 {{ech
3059 o|foo}}
3060 !! html/php
3061 <p>{{ech
3062 o|foo}}
3063 </p>
3064 !! html/parsoid
3065 <p>{{ech
3066 o|foo}}</p>
3067 !! end
3068
3069 !! test
3070 Templates: Recognize targets when newlines and comments don't split the target
3071 !! options
3072 parsoid=wt2html
3073 !! wikitext
3074 {{
3075 <!--X--> ech<!--X-->o<!--X-->
3076 <!--X--> <!--X-->
3077
3078 |foo}}
3079 !! html/php
3080 <p>foo
3081 </p>
3082 !! html/parsoid
3083 <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>
3084 !! end
3085
3086 !! test
3087 Templates: Handle empty comment-and-ws-only lines correctly
3088 !! wikitext
3089 {{echo|foo
3090 <!--should be ignored-->
3091 <!--should be ignored as well-->
3092 bar}}
3093 !! html/php
3094 <p>foo
3095 bar
3096 </p>
3097 !! html/parsoid
3098 <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>
3099 !! end
3100
3101 !! test
3102 Templates: Handle comments in the target
3103 !! wikitext
3104 {{echo
3105 <!-- should be ignored -->
3106 |foo}}
3107
3108 {{echo
3109 <!-- should be ignored and spaces on next line should not trip us up (T147742) -->
3110 |foo}}
3111
3112 {{echo<!-- should be ignored -->
3113 |foo}}
3114
3115 {{echo<!-- should be ignored -->|foo}}
3116
3117 {{<!-- should be ignored -->echo|foo}}
3118 !! html/php
3119 <p>foo
3120 </p><p>foo
3121 </p><p>foo
3122 </p><p>foo
3123 </p><p>foo
3124 </p>
3125 !! html/parsoid
3126 <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>
3127
3128 <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>
3129
3130 <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>
3131
3132 <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>
3133
3134 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</p>
3135 !! end
3136
3137 !! test
3138 Templates: Handle comments in parameter names (T69657)
3139 !! wikitext
3140 {{echo|1
3141 <!-- should be ignored -->
3142 =foo}}
3143
3144 {{echo|
3145 <!-- should be ignored -->
3146 1 = foo}}
3147
3148 {{echo|1<!-- should be ignored -->=foo}}
3149
3150 {{echo|<!-- should be ignored -->1=foo}}
3151 !! html/php
3152 <p>foo
3153 </p><p>foo
3154 </p><p>foo
3155 </p><p>foo
3156 </p>
3157 !! html/parsoid
3158 <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>
3159
3160 <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>
3161
3162 <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>
3163
3164 <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>
3165 !! end
3166
3167 !! test
3168 Templates: Other wikitext in parameter names (T69657)
3169 !! wikitext
3170 {{echo|''1''=foo}}
3171 !! html/php
3172 <p>{{{1}}}
3173 </p>
3174 !! html/parsoid
3175 <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>
3176 !! end
3177
3178 !! test
3179 Templates: With colons
3180 !! wikitext
3181 {{With: Colon}}
3182 !! html/php
3183 <p>Template with colon
3184 </p>
3185 !! html/parsoid
3186 <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>
3187 !! end
3188
3189 #--------------------------------------------------------------------
3190 # Transclusion parameter escaping tests
3191 #--------------------------------------------------------------------
3192
3193 !! test
3194 Templates: Parsoid parameter escaping test 1
3195 !! wikitext
3196 {{echo|[foo]|{{echo|[bar]}}}}
3197 !! html/php+tidy
3198 <p>[foo]
3199 </p>
3200 !! html/parsoid
3201 <p about="#mwt1" typeof="mw:Transclusion"
3202 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[foo]"},"2":{"wt":"{{echo|[bar]}}"}},"i":0}}]}'>[foo]</p>
3203 !! end
3204
3205 !! test
3206 Parsoid: Pipes in external links in template parameter
3207 !! wikitext
3208 {{echo|[{{echo|http://example.com}} link]}}
3209 !! html/php+tidy
3210 <p><a rel="nofollow" class="external text" href="http://example.com">link</a>
3211 </p>
3212 !! html/parsoid
3213 <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>
3214 !! end
3215
3216 !! test
3217 Parsoid: pipe in transclusion parameter
3218 !! wikitext
3219 {{echo|http://foo.com/a&#124;b}}
3220 !! html/php+tidy
3221 <p><a rel="nofollow" class="external free" href="http://foo.com/a%7Cb">http://foo.com/a%7Cb</a>
3222 </p>
3223 !! html/parsoid
3224 <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>
3225 !! end
3226
3227 !! test
3228 Parsoid: Pipe in external link target and content in template parameter
3229 !! options
3230 parsoid=html2wt,wt2wt
3231 !! wikitext
3232 {{echo|[http://foo.com/a&#124;b a&#124;b]}}
3233 !! html/php+tidy
3234 <p><a rel="nofollow" class="external text" href="http://foo.com/a%7Cb">a&#124;b</a>
3235 </p>
3236 !! html/parsoid
3237 <p><a rel="mw:ExtLink" href="http://foo.com/a|b" about="#mwt1"
3238 typeof="mw:Transclusion"
3239 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},
3240 "params":{"1":{"wt":"[http://foo.com/a|b a|b]"}},"i":0}}]}'>a|b</a></p>
3241 !! end
3242
3243 !! test
3244 Parsoid: Pipe in template with nested template in external link target in template parameter (seriously)
3245 !! wikitext
3246 {{echo|[{{fullurl:{{FULLPAGENAME}}|action=edit}} bar]}}
3247 !! html/php+tidy
3248 <p><a rel="nofollow" class="external text" href="http://example.org/index.php?title=Parser_test&amp;action=edit">bar</a>
3249 </p>
3250 !! html/parsoid
3251 <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>
3252 !! end
3253
3254 !! test
3255 Templates: Don't escape already nowiki-escaped text in template parameters
3256 !! options
3257 parsoid=html2wt,wt2wt
3258 !! wikitext
3259 {{echo|foo<nowiki>|</nowiki>bar}}
3260 {{echo|<nowiki>&lt;div&gt;</nowiki>}}
3261 {{echo|<nowiki></nowiki>}}
3262 !! html/php+tidy
3263 <p>foo|bar
3264 &lt;div&gt;
3265
3266 </p>
3267 !! html/parsoid
3268 <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>
3269 <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>
3270 <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>
3271 </p>
3272 !! end
3273
3274 ## T54824
3275 !! test
3276 Templates: '=' char in nested transclusions should not trigger nowiki escapes or conversion to named param
3277 !! options
3278 parsoid=html2wt,wt2wt
3279 !! wikitext
3280 {{echo|{{echo|1=bar}}}}
3281 !! html/php+tidy
3282 <p>bar
3283 </p>
3284 !! html/parsoid
3285 <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>
3286 !! end
3287
3288 ## T58733
3289 !! test
3290 Templates parameters with special tokenizing behavior dont get modified because of arg escaping
3291 !! wikitext
3292 {{echo|a : b}}
3293 !! html/php+tidy
3294 <p>a&#160;: b
3295 </p>
3296 !! html/parsoid
3297 <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>
3298 !! end
3299
3300 ## T73412
3301 !! test
3302 Templates: Preserve blank parameter names
3303 !! wikitext
3304 {{echo|=foo}}
3305 !! html/php+tidy
3306 <p>{{{1}}}
3307 </p>
3308 !! html/parsoid
3309 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"":{"wt":"foo"}},"i":0}}]}'>{{{1}}}</p>
3310 !! end
3311
3312 !! test
3313 Templates: Preserve blank parameter names in other positions
3314 !! wikitext
3315 {{blank_param|bar|=foo}}
3316 !! html/php+tidy
3317 <p>bar
3318 foo
3319 </p>
3320 !! html/parsoid
3321 <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
3322 foo</p>
3323 !! end
3324
3325 ###
3326 ### Parsoid-centric tests for testing RT edge cases for pre
3327 ###
3328
3329 !!test
3330 1a. Indent-Pre and Comments
3331 !! wikitext
3332 a
3333 <!--a-->
3334 c
3335 !! html
3336 <pre>a
3337 </pre>
3338 <p>c
3339 </p>
3340 !!end
3341
3342 !!test
3343 1b. Indent-Pre and Comments
3344 !! wikitext
3345 a
3346 <!--a-->
3347 c
3348 !! html
3349 <pre>a
3350 </pre>
3351 <p>c
3352 </p>
3353 !!end
3354
3355 !!test
3356 1c. Indent-Pre and Comments
3357 !! wikitext
3358 <!--a--> a
3359
3360 <!--a--> a
3361 !! html
3362 <pre> a
3363 </pre>
3364 <pre> a
3365 </pre>
3366 !!end
3367
3368 !!test
3369 1d. Indent-Pre and Comments
3370 (Pre-handler currently cannot distinguish between comment/ws order and normalizes them to [comment,ws] order)
3371 !! wikitext
3372 <!--a--> a
3373
3374 <!--b-->b
3375 !! html
3376 <pre>a
3377 </pre>
3378 <pre>b
3379 </pre>
3380 !!end
3381
3382 !!test
3383 2a. Indent-Pre and tables
3384 !! wikitext
3385 {|
3386 |-
3387 !h1!!h2
3388 |foo||bar
3389 |}
3390 !! html
3391 <table>
3392
3393 <tr>
3394 <th>h1</th>
3395 <th>h2
3396 </th>
3397 <td>foo</td>
3398 <td>bar
3399 </td></tr></table>
3400
3401 !!end
3402
3403 !!test
3404 2b. Indent-Pre and tables
3405 !! wikitext
3406 {|
3407 |-
3408 |foo
3409 |}
3410 !! html
3411 <table>
3412
3413 <tr>
3414 <td>foo
3415 </td></tr></table>
3416
3417 !!end
3418
3419 !!test
3420 2c. Indent-Pre and tables (T44252)
3421 !! wikitext
3422 {|
3423 |+foo
3424 ! |bar
3425 |}
3426 !! html
3427 <table>
3428 <caption>foo
3429 </caption>
3430 <tr>
3431 <th>bar
3432 </th></tr></table>
3433
3434 !!end
3435
3436 !!test
3437 2d. Indent-Pre and tables
3438 !! wikitext
3439 a
3440 {|
3441 |b
3442 |}
3443 !! html/php
3444 <pre>a
3445 </pre>
3446 <table>
3447 <tr>
3448 <td>b
3449 </td></tr></table>
3450
3451 !! html/parsoid
3452 <pre>a</pre>
3453 <table>
3454 <tbody><tr><td> b</td></tr>
3455 </tbody></table>
3456 !!end
3457
3458 !!test
3459 2e. Indent-Pre and table-line syntax
3460 !! wikitext
3461 a
3462 | b
3463 | c
3464 !! html/php
3465 <pre>a
3466 | b
3467 | c
3468 </pre>
3469 !!end
3470
3471 !!test
3472 2f. Indent-pre started by table-line syntax
3473 !! wikitext
3474 a
3475 | b
3476 | c
3477 !! html/php
3478 <p>a
3479 </p>
3480 <pre>| b
3481 | c
3482 </pre>
3483 !! html/parsoid
3484 <p>a</p>
3485 <pre>
3486 | b
3487 | c</pre>
3488 !!end
3489
3490 !! test
3491 2g. Indented table markup mixed with indented pre content (proposed in T8200)
3492 !! wikitext
3493 <table>
3494 <tr>
3495 <td>
3496 Text that should be rendered preformatted
3497 </td>
3498 </tr>
3499 </table>
3500 !! html
3501 <table>
3502 <tr>
3503 <td>
3504 <pre>Text that should be rendered preformatted
3505 </pre>
3506 </td>
3507 </tr>
3508 </table>
3509
3510 !! end
3511
3512 !! test
3513 2h. Indent pre in tables
3514 !! options
3515 parsoid=wt2html,html2html
3516 !! wikitext
3517 {|
3518 !
3519 foo
3520 !
3521 bar
3522 |-
3523 |
3524 baz
3525 {{!}}
3526 bam
3527 |}
3528 !! html/php
3529 <table>
3530 <tr>
3531 <th>
3532 <pre>foo
3533 </pre>
3534 </th>
3535 <th>
3536 <pre>bar
3537 </pre>
3538 </th></tr>
3539 <tr>
3540 <td>
3541 <pre>baz
3542 </pre>
3543 </td>
3544 <td>
3545 <pre>bam
3546 </pre>
3547 </td></tr></table>
3548
3549 !! html/parsoid
3550 <table>
3551 <tbody><tr><th>
3552 <pre>foo</pre>
3553 </th><th>
3554 <pre>bar</pre>
3555 </th></tr><tr>
3556 <td>
3557 <pre>baz</pre>
3558 </td><td data-parsoid='{"startTagSrc":"{{!}}"}'>
3559 <pre>bam</pre>
3560 </td></tr></tbody></table>
3561 !! end
3562
3563 !! test
3564 3a. Indent-Pre and block tags (single-line html)
3565 !! wikitext
3566 a <p> foo </p>
3567 b <div> foo </div>
3568 c <blockquote> foo </blockquote>
3569 <span> foo </span>
3570 !! html
3571 a <p> foo </p>
3572 b <div> foo </div>
3573 c <blockquote> foo </blockquote>
3574 <pre><span> foo </span>
3575 </pre>
3576 !! html/php+tidy
3577 <p> a </p><p> foo </p><p>
3578 b </p><div> foo </div><p>
3579 c </p><blockquote><p> foo </p></blockquote>
3580 <pre><span> foo </span>
3581 </pre>
3582 !! html/parsoid
3583 <p> a </p><p data-parsoid='{"stx":"html"}'> foo </p><p>
3584 b </p><div data-parsoid='{"stx":"html"}'> foo </div><p>
3585 c </p><blockquote data-parsoid='{"stx":"html"}'><p> foo </p></blockquote>
3586 <pre><span data-parsoid='{"stx":"html"}'> foo </span></pre>
3587 !! end
3588
3589 !! test
3590 3b. Indent-Pre and block tags (multi-line html)
3591 !! wikitext
3592 a <span>foo</span>
3593 <!-- comment --> b <div> foo </div>
3594 !! html/php
3595 <pre>a <span>foo</span>
3596 </pre>
3597 b <div> foo </div>
3598
3599 !! html/parsoid
3600 <pre>a <span data-parsoid='{"stx":"html"}'>foo</span></pre>
3601 <!-- comment --> <p>b </p><div data-parsoid='{"stx":"html"}'> foo </div>
3602 !! html/php+tidy
3603 <pre>a <span>foo</span>
3604 </pre><p>
3605 b </p><div> foo </div>
3606 !! end
3607
3608 !!test
3609 3c. Indent-Pre and block tags (pre-content on separate line)
3610 !! wikitext
3611 <p>
3612 foo
3613 </p>
3614
3615 <div>
3616 foo
3617 </div>
3618
3619 <center>
3620 foo
3621 </center>
3622
3623 <blockquote>
3624 foo
3625 </blockquote>
3626
3627 <blockquote>
3628 <pre>
3629 foo
3630 </pre>
3631 </blockquote>
3632
3633 <table><tr><td>
3634 foo
3635 </td></tr></table>
3636
3637 <ul><li>
3638 foo
3639 </li></ul>
3640
3641 !! html
3642 <p>
3643 foo
3644 </p>
3645 <div>
3646 <pre>foo
3647 </pre>
3648 </div>
3649 <center>
3650 <pre>foo
3651 </pre>
3652 </center>
3653 <blockquote>
3654 <p> foo
3655 </p>
3656 </blockquote>
3657 <blockquote>
3658 <pre>
3659 foo
3660 </pre>
3661 </blockquote>
3662 <table><tr><td>
3663 <pre>foo
3664 </pre>
3665 </td></tr></table>
3666 <ul><li>
3667 foo
3668 </li></ul>
3669
3670 !!end
3671
3672 !! test
3673 4. Indent-Pre and extension tags
3674 !! options
3675 parsoid=wt2html,html2html
3676 !! wikitext
3677 a <tag />
3678 !! html/php+tidy
3679 <p> a </p><pre>NULL
3680 array (
3681 )
3682 </pre>
3683 !! html/parsoid
3684 <p> a </p><pre typeof="mw:Extension/tag" about="#mwt2" data-mw='{"name":"tag","attrs":{}}'></pre>
3685 !! end
3686
3687 !! test
3688 5. Indent-Pre and html pre
3689 !! wikitext
3690 <pre class="123">hi</pre>
3691 !! html/php
3692 <pre class="123">hi</pre>
3693
3694 !! html/parsoid
3695 <pre class="123" typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{"class":"123"},"body":{"extsrc":"hi"}}'>hi</pre>
3696 !! end
3697
3698 !!test
3699 Render paragraphs when indent-pre is suppressed in blocklevels
3700 !! wikitext
3701 <blockquote>
3702 foo
3703
3704 bar
3705 </blockquote>
3706 !! html
3707 <blockquote>
3708 <p> foo
3709 </p><p> bar
3710 </p>
3711 </blockquote>
3712
3713 !!end
3714
3715 !!test
3716 4. Multiple spaces at start-of-line
3717 !! wikitext
3718 <p> foo </p>
3719 foo
3720 {|
3721 |foo
3722 |}
3723 !! html
3724 <p> foo </p>
3725 <pre> foo
3726 </pre>
3727 <table>
3728 <tr>
3729 <td>foo
3730 </td></tr></table>
3731
3732 !!end
3733
3734 ## NOTE: the leading white-space chars on empty line are significant
3735 !! test
3736 5a. White-space in indent-pre
3737 !! wikitext
3738 a<br />
3739
3740 b
3741 !! html
3742 <pre>a<br />
3743
3744 b
3745 </pre>
3746 !! end
3747
3748 ## NOTE: the leading white-space chars on empty line are significant
3749 !! test
3750 5b. White-space in indent-pre
3751 !! wikitext
3752 a
3753
3754 b
3755
3756
3757 c
3758 !! html
3759 <pre>a
3760
3761 b
3762
3763
3764 c
3765 </pre>
3766 !! end
3767
3768 !! test
3769 5c. White-space in indent-pre
3770 !! wikitext
3771 ''a''
3772 ''b''
3773 ''c''
3774 !! html
3775 <pre><i>a</i>
3776 <i>b</i>
3777 <i>c</i>
3778 </pre>
3779 !! end
3780
3781 !! test
3782 6. Pre-blocks should extend across lines with leading WS even when there is no wrappable content
3783 !! wikitext
3784 a
3785
3786 <!-- continue -->
3787 b
3788
3789 c
3790
3791 d
3792 !! html
3793 <pre>a
3794
3795 b
3796 </pre>
3797 <pre>c
3798
3799 </pre>
3800 <p>d
3801 </p>
3802 !! end
3803
3804 !! test
3805 7a. Indent-pre and category links
3806 !! options
3807 parsoid=wt2html,wt2wt
3808 !! wikitext
3809 [[Category:foo]] <!-- No pre-wrapping -->
3810 {{echo| [[Category:foo]]}} <!-- No pre-wrapping -->
3811 !! html/php+tidy
3812 !! html/parsoid
3813 <link rel="mw:PageProp/Category" href="./Category:Foo"> <!-- No pre&#x2D;wrapping -->
3814 <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 -->
3815 !! end
3816
3817 ## We used to, but no longer wt2wt this test since the default serializer
3818 ## will normalize all categories to serialize on their own line.
3819 ## This wikitext usage is going to be fairly uncommon in production and
3820 ## selser will take care of preserving formatting in those scenarios.
3821 !! test
3822 7b. Indent-pre and category links
3823 !! options
3824 parsoid=wt2html
3825 !! wikitext
3826 [[Category:foo]] a
3827 [[Category:foo]] {{echo|b}}
3828 !! html/parsoid
3829 <pre><link rel="mw:PageProp/Category" href="./Category:Foo"> a
3830 <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>
3831 !! end
3832
3833 !! test
3834 Indent-Pre: Newlines in comments shouldn't affect sol state
3835 !! wikitext
3836 a <!--
3837 foo
3838 --> b
3839 !! html/php+tidy
3840 <p>a b
3841 </p>
3842 !! html/parsoid
3843 <p>a <!--
3844 foo
3845 --> b</p>
3846 !! end
3847
3848 ###
3849 ### HTML-pre (some to spec PHP parser behavior and some Parsoid-RT-centric)
3850 ###
3851
3852 !!test
3853 HTML-pre: 1. embedded newlines
3854 !! wikitext
3855 <pre>foo</pre>
3856
3857 <pre>
3858 foo
3859 </pre>
3860
3861 <pre>
3862
3863 foo
3864 </pre>
3865
3866 <pre>
3867
3868
3869 foo
3870 </pre>
3871 !! html/php+tidy
3872 <pre>foo</pre>
3873 <pre>foo
3874 </pre>
3875 <pre>
3876
3877 foo
3878 </pre>
3879 <pre>
3880
3881
3882 foo
3883 </pre>
3884 !! html/parsoid
3885 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo"}}'>foo</pre>
3886
3887 <pre typeof="mw:Extension/pre" about="#mwt4" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\nfoo\n"}}'>foo
3888 </pre>
3889
3890 <pre typeof="mw:Extension/pre" about="#mwt6" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n\nfoo\n"}}'>
3891
3892 foo
3893 </pre>
3894
3895 <pre typeof="mw:Extension/pre" about="#mwt8" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n\n\nfoo\n"}}'>
3896
3897
3898 foo
3899 </pre>
3900 !!end
3901
3902 !! test
3903 HTML-pre: big spaces
3904 !! wikitext
3905 <pre>
3906
3907
3908
3909
3910 haha
3911
3912
3913
3914
3915 haha
3916
3917
3918
3919
3920 </pre>
3921 !! html/php+tidy
3922 <pre>
3923
3924
3925
3926
3927 haha
3928
3929
3930
3931
3932 haha
3933
3934
3935
3936
3937 </pre>
3938 !! html/parsoid
3939 <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"}}'>
3940
3941
3942
3943
3944 haha
3945
3946
3947
3948
3949 haha
3950
3951
3952
3953
3954 </pre>
3955 !! end
3956
3957 !!test
3958 HTML-pre: 2: indented text
3959 !! wikitext
3960 <pre>
3961 foo
3962 </pre>
3963 !! html
3964 <pre>
3965 foo
3966 </pre>
3967
3968 !!end
3969
3970 !!test
3971 HTML-pre: 3: other wikitext
3972 !! wikitext
3973 <pre>
3974 * foo
3975 # bar
3976 = no-h =
3977 '' no-italic ''
3978 [[ NoLink ]]
3979 </pre>
3980 !! html/php
3981 <pre>
3982 * foo
3983 # bar
3984 = no-h =
3985 '' no-italic ''
3986 [[ NoLink ]]
3987 </pre>
3988
3989 !! html/parsoid
3990 <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
3991 # bar
3992 = no-h =
3993 '' no-italic ''
3994 [[ NoLink ]]
3995 </pre>
3996 !!end
3997
3998 ###
3999 ### Definition lists
4000 ###
4001 !! test
4002 Simple definition
4003 !! wikitext
4004 ;name :Definition
4005 !! html
4006 <dl><dt>name</dt>
4007 <dd>Definition</dd></dl>
4008
4009 !! end
4010
4011 !! test
4012 Definition list for indentation only
4013 !! wikitext
4014 :Indented text
4015 !! html
4016 <dl><dd>Indented text</dd></dl>
4017
4018 !! end
4019
4020 !! test
4021 Definition list with no space
4022 !! wikitext
4023 ;name:Definition
4024 !! html
4025 <dl><dt>name</dt>
4026 <dd>Definition</dd></dl>
4027
4028 !!end
4029
4030 !! test
4031 Definition list with URL link
4032 !! wikitext
4033 ;http://example.com/ :definition
4034 !! html
4035 <dl><dt><a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a></dt>
4036 <dd>definition</dd></dl>
4037
4038 !! end
4039
4040 !! test
4041 Definition list with bracketed URL link
4042 !! wikitext
4043 ;[http://www.example.com/ Example]:Something about it
4044 !! html
4045 <dl><dt><a rel="nofollow" class="external text" href="http://www.example.com/">Example</a></dt>
4046 <dd>Something about it</dd></dl>
4047
4048 !! end
4049
4050 !! test
4051 Definition list with wikilink containing colon
4052 !! wikitext
4053 ;[[Help:FAQ]]:The least-read page on Wikipedia
4054 !! html
4055 <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>
4056 <dd>The least-read page on Wikipedia</dd></dl>
4057
4058 !! end
4059
4060 # At Brion's and JeLuF's insistence... :)
4061 !! test
4062 Definition list with news link containing colon
4063 !! wikitext
4064 ;news:alt.wikipedia.rox :This isn't even a real newsgroup!
4065 !! html/php
4066 <dl><dt><a rel="nofollow" class="external free" href="news:alt.wikipedia.rox">news:alt.wikipedia.rox</a></dt>
4067 <dd>This isn't even a real newsgroup!</dd></dl>
4068
4069 !! html/parsoid
4070 <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>
4071 !! end
4072
4073 !! test
4074 Malformed definition list with colon
4075 !! wikitext
4076 ;news:alt.wikipedia.rox -- don't crash or enter an infinite loop
4077 !! html
4078 <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>
4079
4080 !! end
4081
4082 !! test
4083 Definition lists: colon in external link text
4084 !! wikitext
4085 ;[http://www.wikipedia2.org/ Wikipedia :The Next Generation] :OK, I made that up
4086 !! html
4087 <dl><dt><a rel="nofollow" class="external text" href="http://www.wikipedia2.org/">Wikipedia :The Next Generation</a></dt>
4088 <dd>OK, I made that up</dd></dl>
4089
4090 !! end
4091
4092 !! test
4093 Definition lists: colon in HTML attribute
4094 !! wikitext
4095 ;<b style="display: inline">bold</b>
4096 !! html
4097 <dl><dt><b style="display: inline">bold</b></dt></dl>
4098
4099 !! end
4100
4101 !! test
4102 Definition lists: self-closed tag
4103 !! wikitext
4104 ;one<br/>two :two-line fun
4105 !! html
4106 <dl><dt>one<br />two</dt>
4107 <dd>two-line fun</dd></dl>
4108
4109 !! end
4110
4111 !! test
4112 Definition lists: ignore colons inside tags
4113 !! wikitext
4114 ;one <b>two : tag <i>fun:</i>:</b>:def
4115 !! html
4116 <dl><dt>one <b>two&#160;: tag <i>fun:</i>:</b></dt>
4117 <dd>def</dd></dl>
4118
4119 !! end
4120
4121 !! test
4122 Definition lists: excess closed tags
4123 !! wikitext
4124 ;one</b>two :bad tag fun
4125 !! html/php+tidy
4126 <dl><dt>onetwo</dt>
4127 <dd>bad tag fun</dd></dl>
4128 !! html/parsoid
4129 <dl>
4130 <dt>onetwo</dt>
4131 <dd>bad tag fun</dd>
4132 </dl>
4133 !! end
4134
4135 !! test
4136 T13748: Literal closing tags
4137 !! wikitext
4138 <dl>
4139 <dt>test 1</dt>
4140 <dd>test test test test test</dd>
4141 <dt>test 2</dt>
4142 <dd>test test test test test</dd>
4143 </dl>
4144 !! html
4145 <dl>
4146 <dt>test 1</dt>
4147 <dd>test test test test test</dd>
4148 <dt>test 2</dt>
4149 <dd>test test test test test</dd>
4150 </dl>
4151
4152 !! end
4153
4154 !! test
4155 Definition and unordered list using wiki syntax nested in unordered list using html tags.
4156 !! wikitext
4157 <ul><li>
4158 ;term :description
4159 *unordered
4160 </li></ul>
4161 !! html
4162 <ul><li>
4163 <dl><dt>term</dt>
4164 <dd>description</dd></dl>
4165 <ul><li>unordered</li></ul>
4166 </li></ul>
4167
4168 !! end
4169
4170 !! test
4171 Definition list with empty definition and following paragraph
4172 !! wikitext
4173 ;term:
4174
4175 Paragraph text
4176 !! html
4177 <dl><dt>term</dt>
4178 <dd></dd></dl>
4179 <p>Paragraph text
4180 </p>
4181 !! end
4182
4183 !! test
4184 Nested definition lists using html syntax
4185 !! wikitext
4186 <dl><dt>x</dt>
4187 <dd>a</dd>
4188 <dd>b</dd></dl>
4189 !! html
4190 <dl><dt>x</dt>
4191 <dd>a</dd>
4192 <dd>b</dd></dl>
4193
4194 !! end
4195
4196 !! test
4197 Definition Lists: No nesting: Multiple dd's
4198 !! wikitext
4199 ;x
4200 :a
4201 :b
4202 !! html
4203 <dl><dt>x</dt>
4204 <dd>a</dd>
4205 <dd>b</dd></dl>
4206
4207 !! end
4208
4209 !! test
4210 Definition Lists: Indentation: Regular
4211 !! wikitext
4212 :i1
4213 ::i2
4214 :::i3
4215 !! html
4216 <dl><dd>i1
4217 <dl><dd>i2
4218 <dl><dd>i3</dd></dl></dd></dl></dd></dl>
4219
4220 !! end
4221
4222 !! test
4223 Definition Lists: Indentation: Missing 1st level
4224 !! wikitext
4225 ::i2
4226 :::i3
4227 !! html
4228 <dl><dd><dl><dd>i2
4229 <dl><dd>i3</dd></dl></dd></dl></dd></dl>
4230
4231 !! end
4232
4233 !! test
4234 Definition Lists: Indentation: Multi-level indent
4235 !! wikitext
4236 :::i3
4237 !! html
4238 <dl><dd><dl><dd><dl><dd>i3</dd></dl></dd></dl></dd></dl>
4239
4240 !! end
4241
4242 !! test
4243 Definition Lists: Hacky use to indent tables
4244 !! wikitext
4245 ::{|
4246 |foo
4247 |bar
4248 |}
4249 this text
4250 should be left alone
4251 !! html
4252 <dl><dd><dl><dd><table>
4253 <tr>
4254 <td>foo
4255 </td>
4256 <td>bar
4257 </td></tr></table></dd></dl></dd></dl>
4258 <p>this text
4259 should be left alone
4260 </p>
4261 !! end
4262
4263 !! test
4264 Definition Lists: Hacky use to indent tables (with content following table)
4265 !! wikitext
4266 :{|
4267 |foo
4268 |bar
4269 |} <!--c1--> this text should be part of the dl
4270 !! html/php+tidy
4271 <dl><dd><table>
4272 <tbody><tr>
4273 <td>foo
4274 </td>
4275 <td>bar
4276 </td></tr></tbody></table> this text should be part of the dl</dd></dl>
4277 !! html/parsoid
4278 <dl><dd><table>
4279 <tbody><tr>
4280 <td>foo
4281 </td>
4282 <td>bar
4283 </td></tr></tbody></table> <!--c1--> this text should be part of the dl</dd></dl>
4284 !! end
4285
4286 !! test
4287 Definition Lists: Hacky use to indent tables, with comments (T65979)
4288 !! wikitext
4289 <!-- foo -->
4290 ::{|
4291 |foo
4292 |bar
4293 |}<!-- bar -->
4294 this text
4295 should be left alone
4296 !! html/parsoid
4297 <!-- foo -->
4298 <dl><dd><dl><dd><table><tr>
4299 <td>foo</td>
4300 <td>bar</td>
4301 </tr></table><!-- bar --></dd></dl></dd></dl>
4302 <p>this text
4303 should be left alone</p>
4304 !! end
4305
4306 !! test
4307 Definition Lists: Hacky use to indent tables, with comment before table
4308 !!options
4309 parsoid=wt2html
4310 !! wikitext
4311 ::<!-- foo -->{|
4312 |foo
4313 |}
4314 !! html/parsoid
4315 <dl><dd><dl><dd><!-- foo --><table><tr>
4316 <td>foo</td>
4317 </tr></table></dd></dl></dd></dl>
4318 !! end
4319
4320 # The trailing whitespace in this test is to catch a regression in
4321 # Parsoid after T54473.
4322 !! test
4323 Definition Lists: Hacky use to indent tables (WS-insensitive)
4324 !! wikitext
4325 :{|
4326 |a
4327 |}
4328 !! html/php
4329 <dl><dd><table>
4330 <tr>
4331 <td>a
4332 </td></tr></table></dd></dl>
4333
4334 !! html/parsoid
4335 <dl><dd><table>
4336 <tbody><tr><td>a</td></tr>
4337 </tbody></table></dd></dl>
4338 !! end
4339
4340 ## The PHP parser treats : items (dd) without a corresponding ; item (dt)
4341 ## as an empty dt item. It also ignores all but the last ";" when followed
4342 ## by ":" later on. So, ";" are not ignored in ";;;t3" but are ignored in
4343 ## ";;;t3 :d1". So, PHP parser behavior is a little inconsistent wrt multiple
4344 ## ";"s.
4345 ##
4346 ## Ex: ";;t2 ::d2" is transformed into:
4347 ##
4348 ## <dl>
4349 ## <dt>t2 </dt>
4350 ## <dd>
4351 ## <dl>
4352 ## <dt></dt>
4353 ## <dd>d2</dd>
4354 ## </dl>
4355 ## </dd>
4356 ## </dl>
4357 ##
4358 ## But, Parsoid treats "; :" as a tight atomic unit and excess ":" as plain text
4359 ## So, the same wikitext above (;;t2 ::d2) is transformed into:
4360 ##
4361 ## <dl>
4362 ## <dt>
4363 ## <dl>
4364 ## <dt>t2 </dt>
4365 ## <dd>:d2</dd>
4366 ## </dl>
4367 ## </dt>
4368 ## </dl>
4369 ##
4370 ## All Parsoid only definition list tests have this difference.
4371 ##
4372 ## See also: https://phabricator.wikimedia.org/T8569
4373 ## and https://lists.wikimedia.org/pipermail/wikitext-l/2011-November/000483.html
4374
4375 !! test
4376 Table / list interaction: indented table with lists in table contents
4377 !! wikitext
4378 :{|
4379 |-
4380 |a
4381
4382 *b
4383 |-
4384 |c
4385
4386 *d
4387 |}
4388 !! html
4389 <dl><dd><table>
4390
4391 <tr>
4392 <td>a
4393 <ul><li>b</li></ul>
4394 </td></tr>
4395 <tr>
4396 <td>c
4397 <ul><li>d</li></ul>
4398 </td></tr></table></dd></dl>
4399
4400 !! end
4401
4402 !!test
4403 Table / list interaction: lists nested in tables nested in indented lists
4404 !! wikitext
4405 :{|
4406 |
4407 :a
4408 :b
4409 |
4410 *c
4411 *d
4412 |}
4413
4414 *e
4415 *f
4416 !! html
4417 <dl><dd><table>
4418 <tr>
4419 <td>
4420 <dl><dd>a</dd>
4421 <dd>b</dd></dl>
4422 </td>
4423 <td>
4424 <ul><li>c</li>
4425 <li>d</li></ul>
4426 </td></tr></table></dd></dl>
4427 <ul><li>e</li>
4428 <li>f</li></ul>
4429
4430 !!end
4431
4432 !! test
4433 Definition Lists: Nesting: Multi-level (Parsoid only)
4434 !! wikitext
4435 ;t1 :d1
4436 ;;t2 ::d2
4437 ;;;t3 :::d3
4438 !! html/parsoid
4439 <dl>
4440 <dt>t1 </dt>
4441 <dd>d1</dd>
4442 <dt>
4443 <dl>
4444 <dt>t2 </dt>
4445 <dd>:d2</dd>
4446 <dt>
4447 <dl>
4448 <dt>t3 </dt>
4449 <dd>::d3</dd>
4450 </dl>
4451 </dt>
4452 </dl>
4453 </dt>
4454 </dl>
4455
4456
4457 !! end
4458
4459
4460 !! test
4461 Definition Lists: Nesting: Test 2
4462 !! wikitext
4463 ;t1
4464 ::d2
4465 !! html+tidy
4466 <dl><dt>t1</dt>
4467 <dd>
4468 <dl><dd>d2</dd></dl></dd></dl>
4469 !! end
4470
4471
4472 !! test
4473 Definition Lists: Nesting: Test 3
4474 !! wikitext
4475 :;t1
4476 ::::d2
4477 !! html+tidy
4478 <dl><dd><dl><dt>t1</dt>
4479 <dd>
4480 <dl><dd><dl><dd>d2</dd></dl></dd></dl></dd></dl></dd></dl>
4481 !! end
4482
4483
4484 !! test
4485 Definition Lists: Nesting: Test 4
4486 !! wikitext
4487 ::;t3
4488 :::d3
4489 !! html
4490 <dl><dd><dl><dd><dl><dt>t3</dt>
4491 <dd>d3</dd></dl></dd></dl></dd></dl>
4492
4493 !! end
4494
4495
4496 ## The Parsoid team believes the following three test exposes a
4497 ## bug in the PHP parser. (Parsoid team thinks the PHP parser is
4498 ## wrong to close the <dl> after the <dt> containing the <ul>.)
4499 ## It also exposes a "misfeature" in tidy, which doesn't like
4500 ## <dl> tags with a single <dt> child; it converts the <dt> into
4501 ## a <dd> in that case. (Parsoid leaves the <dt> alone!)
4502 !! test
4503 Definition Lists: Mixed Lists: Test 1
4504 !! wikitext
4505 :;*foo
4506 ::*bar
4507 :;baz
4508 !! html/php
4509 <dl><dd><dl><dt><ul><li>foo</li>
4510 <li>bar</li></ul></dt></dl>
4511 <dl><dt>baz</dt></dl></dd></dl>
4512
4513 !! html/php+tidy
4514 <dl><dd><dl><dt><ul><li>foo</li>
4515 <li>bar</li></ul></dt></dl>
4516 <dl><dt>baz</dt></dl></dd></dl>
4517 !! html/parsoid
4518 <dl>
4519 <dd><dl>
4520 <dt><ul>
4521 <li>foo
4522 </li>
4523 </ul></dt>
4524 <dd><ul>
4525 <li>bar
4526 </li>
4527 </ul></dd>
4528 <dt>baz</dt>
4529 </dl></dd>
4530 </dl>
4531 !! end
4532
4533 !! test
4534 Definition Lists: Mixed Lists: Test 2
4535 !! wikitext
4536 *:d1
4537 *:d2
4538 !! html
4539 <ul><li><dl><dd>d1</dd>
4540 <dd>d2</dd></dl></li></ul>
4541
4542 !! end
4543
4544
4545 !! test
4546 Definition Lists: Mixed Lists: Test 3
4547 !! wikitext
4548 *:::d1
4549 *:::d2
4550 !! html
4551 <ul><li><dl><dd><dl><dd><dl><dd>d1</dd>
4552 <dd>d2</dd></dl></dd></dl></dd></dl></li></ul>
4553
4554 !! end
4555
4556
4557 !! test
4558 Definition Lists: Mixed Lists: Test 4
4559 !! wikitext
4560 *;d1 :d2
4561 *;d3 :d4
4562 !! html
4563 <ul><li><dl><dt>d1</dt>
4564 <dd>d2</dd>
4565 <dt>d3</dt>
4566 <dd>d4</dd></dl></li></ul>
4567
4568 !! end
4569
4570
4571 !! test
4572 Definition Lists: Mixed Lists: Test 5
4573 !! wikitext
4574 *:d1
4575 *::d2
4576 !! html
4577 <ul><li><dl><dd>d1
4578 <dl><dd>d2</dd></dl></dd></dl></li></ul>
4579
4580 !! end
4581
4582
4583 !! test
4584 Definition Lists: Mixed Lists: Test 6
4585 !! wikitext
4586 #*:d1
4587 #*:::d3
4588 !! html
4589 <ol><li><ul><li><dl><dd>d1
4590 <dl><dd><dl><dd>d3</dd></dl></dd></dl></dd></dl></li></ul></li></ol>
4591
4592 !! end
4593
4594
4595 !! test
4596 Definition Lists: Mixed Lists: Test 7
4597 !! wikitext
4598 :*d1
4599 :*d2
4600 !! html
4601 <dl><dd><ul><li>d1</li>
4602 <li>d2</li></ul></dd></dl>
4603
4604 !! end
4605
4606
4607 !! test
4608 Definition Lists: Mixed Lists: Test 8
4609 !! wikitext
4610 :*d1
4611 ::*d2
4612 !! html
4613 <dl><dd><ul><li>d1</li></ul>
4614 <dl><dd><ul><li>d2</li></ul></dd></dl></dd></dl>
4615
4616 !! end
4617
4618
4619 !! test
4620 Definition Lists: Mixed Lists: Test 9
4621 !! wikitext
4622 *;foo :bar
4623 !! html
4624 <ul><li><dl><dt>foo</dt>
4625 <dd>bar</dd></dl></li></ul>
4626
4627 !! end
4628
4629
4630 !! test
4631 Definition Lists: Mixed Lists: Test 10
4632 !! wikitext
4633 *#;foo :bar
4634 !! html
4635 <ul><li><ol><li><dl><dt>foo</dt>
4636 <dd>bar</dd></dl></li></ol></li></ul>
4637
4638 !! end
4639
4640 # The Parsoid team disagrees with the PHP parser's seemingly-random
4641 # rules regarding dd/dt on the next few tests. Parsoid is more
4642 # consistent, and recognizes the shared nesting and keeps the
4643 # still-open tags around until the nesting is complete.
4644
4645 # This is a regression test for T175099
4646 !! test
4647 Definition Lists: Mixed Lists: Test 11
4648 !! wikitext
4649 ;a
4650 :*b
4651 !! html/php
4652 <dl><dt>a</dt>
4653 <dd>
4654 <ul><li>b</li></ul></dd></dl>
4655
4656 !! html/parsoid
4657 <dl><dt>a
4658 <dd><ul><li>b</li></ul></dd></dl>
4659 !! end
4660
4661 # FIXME: Maybe get rid of this test?
4662 !! test
4663 Definition Lists: Mixed Lists: Test 12
4664 !! wikitext
4665 *#*#;*;;foo :bar
4666 *#*#;boo :baz
4667 !! html/php
4668 <ul><li><ol><li><ul><li><ol><li><dl><dt>foo</dt>
4669 <dd><ul><li><dl><dt><dl><dt>bar</dt></dl></dd></dl></li></ul></dd></dl>
4670 <dl><dt>boo</dt>
4671 <dd>baz</dd></dl></li></ol></li></ul></li></ol></li></ul>
4672
4673 !! html/php+tidy
4674 <ul><li><ol><li><ul><li><ol><li><dl><dt>foo</dt>
4675 <dd><ul><li><dl><dt><dl><dt>bar</dt></dl></dt></dl></li></ul></dd></dl></li></ol></li></ul>
4676 <dl><dt>boo</dt>
4677 <dd>baz</dd></dl></li></ol></li></ul>
4678 !! html/parsoid
4679 <ul>
4680 <li>
4681 <ol>
4682 <li>
4683 <ul>
4684 <li>
4685 <ol>
4686 <li>
4687 <dl>
4688 <dt>
4689 <ul>
4690 <li>
4691 <dl>
4692 <dt>
4693 <dl>
4694 <dt>foo</dt>
4695 <dd data-parsoid='{"stx":"row"}'>bar</dd>
4696 </dl></dt>
4697 </dl></li>
4698 </ul></dt>
4699 <dt>boo</dt>
4700 <dd data-parsoid='{"stx":"row"}'>baz</dd>
4701 </dl></li>
4702 </ol></li>
4703 </ul></li>
4704 </ol></li>
4705 </ul>
4706 !! end
4707
4708 !! test
4709 Definition Lists: Mixed Lists: Test 13
4710 !! wikitext
4711 *#*#;*;;foo : bar
4712 *#*#;boo : baz
4713 !! html+tidy
4714 <ul><li><ol><li><ul><li><ol><li><dl><dt>foo&#160;</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&#160;</dt>
4717 <dd>baz</dd></dl></li></ol></li></ul>
4718 !! end
4719
4720 # FIXME: Maybe get rid of this test?
4721 # From whitelist:
4722 # * The test is wrong, there are two colons where there should be :;
4723 # * The PHP parser is wrong to close the <dl> after the <dt> containing the <ul>.
4724 !! test
4725 Definition Lists: Weird Ones: Test 1
4726 !! wikitext
4727 *#;*::;;foo :bar (who uses this?)
4728 !! html/php+tidy
4729 <ul><li><ol><li><dl><dt>foo</dt>
4730 <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>
4731 !! html/parsoid
4732 <ul>
4733 <li>
4734 <ol>
4735 <li>
4736 <dl>
4737 <dt>
4738 <ul>
4739 <li>
4740 <dl>
4741 <dd>
4742 <dl>
4743 <dd>
4744 <dl>
4745 <dt>
4746 <dl>
4747 <dt>foo</dt>
4748 <dd data-parsoid='{"stx":"row"}'>bar (who uses this?)</dd>
4749 </dl></dt>
4750 </dl></dd>
4751 </dl></dd>
4752 </dl></li>
4753 </ul></dt>
4754 </dl></li>
4755 </ol></li>
4756 </ul>
4757 !! end
4758
4759 !! test
4760 Definition Lists: colons occurring in tags
4761 !! wikitext
4762 ;a:b
4763 ;'''a:b'''
4764 ;<i>a:b</i>
4765 ;<span>a:b</span>
4766 ;<div>a:b</div>
4767 ;<div>a
4768 :b</div>
4769 ;{{echo|a:b}}
4770 ;{{echo|''a:b''}}
4771 ;;;''a:b''
4772 !! html+tidy
4773 <dl><dt>a</dt>
4774 <dd>b</dd>
4775 <dt><b>a:b</b></dt>
4776 <dt><i>a:b</i></dt>
4777 <dt><span>a:b</span></dt>
4778 <dt><div>a:b</div></dt>
4779 <dt><div>a</div></dt>
4780 <dd>b</dd>
4781 <dt>a</dt>
4782 <dd>b</dd>
4783 <dt><i>a:b</i></dt></dl>
4784 <dl><dt><dl><dt><dl><dt><i>a:b</i></dt></dl></dt></dl></dt></dl>
4785 !! html/parsoid
4786 <dl><dt>a</dt><dd data-parsoid='{"stx":"row"}'>b</dd>
4787 <dt><b>a:b</b></dt>
4788 <dt><i data-parsoid='{"stx":"html"}'>a:b</i></dt>
4789 <dt><span data-parsoid='{"stx":"html"}'>a:b</span></dt>
4790 <dt><div data-parsoid='{"stx":"html"}'>a:b</div></dt>
4791 <dt><div data-parsoid='{"stx":"html","autoInsertedEnd":true}'>a</div></dt>
4792 <dd>b</dd>
4793 <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>
4794 <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>
4795 <dl><dt><dl><dt><i>a:b</i></dt></dl></dt></dl></dt></dl>
4796 !! end
4797
4798 # Parsoid's output differs here again because it shares
4799 # nesting between the two lists unlike the PHP parser.
4800 # Unsure which is more desirable.
4801 !! test
4802 Definition Lists: colons and tables 1
4803 !! wikitext
4804 :{|
4805 |x
4806 |}
4807 :{|
4808 |y
4809 |}
4810 !! html/php
4811 <dl><dd><table>
4812 <tr>
4813 <td>x
4814 </td></tr></table></dd></dl>
4815 <dl><dd><table>
4816 <tr>
4817 <td>y
4818 </td></tr></table></dd></dl>
4819
4820 !! html/parsoid
4821 <dl><dd><table>
4822 <tr>
4823 <td>x
4824 </td></tr></table></dd>
4825 <dd><table>
4826 <tr>
4827 <td>y
4828 </td></tr></table></dd></dl>
4829 !! end
4830
4831 # FIXME: Does this need a html/php section?
4832 !! test
4833 Definition Lists: template interaction
4834 !! wikitext
4835 ::{{definition_list}}
4836
4837 :one
4838 ::{{definition_list}}
4839 :::two
4840 :::three
4841 ::four
4842 !! html/parsoid
4843 <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">
4844 </span><dd about="#mwt1">two</dd></dl></dd></dl>
4845
4846 <dl><dd data-parsoid='{}'>one
4847 <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">
4848 </span><dd about="#mwt2">two
4849 <dl><dd>two</dd>
4850 <dd>three</dd></dl></dd>
4851 <dd data-parsoid='{}'>four</dd></dl></dd></dl>
4852 !! end
4853
4854
4855 ###
4856 ### External links
4857 ###
4858 !! test
4859 External links: non-bracketed
4860 !! wikitext
4861 Non-bracketed: http://example.com
4862 !! html
4863 <p>Non-bracketed: <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
4864 </p>
4865 !! end
4866
4867 # parsoid doesn't explicitly mark autonumbered links, see T55505
4868 !! test
4869 External links: numbered
4870 !! wikitext
4871 Numbered: [http://example.com]
4872 Numbered: [http://example.net]
4873 Numbered: [http://example.com]
4874 !! html/php
4875 <p>Numbered: <a rel="nofollow" class="external autonumber" href="http://example.com">[1]</a>
4876 Numbered: <a rel="nofollow" class="external autonumber" href="http://example.net">[2]</a>
4877 Numbered: <a rel="nofollow" class="external autonumber" href="http://example.com">[3]</a>
4878 </p>
4879 !! html/parsoid
4880 <p>Numbered: <a rel="mw:ExtLink" class="external autonumber" href="http://example.com"></a>
4881 Numbered: <a rel="mw:ExtLink" class="external autonumber" href="http://example.net"></a>
4882 Numbered: <a rel="mw:ExtLink" class="external autonumber" href="http://example.com"></a></p>
4883 !!end
4884
4885 !! test
4886 External links: specified text
4887 !! wikitext
4888 Specified text: [http://example.com link]
4889 !! html
4890 <p>Specified text: <a rel="nofollow" class="external text" href="http://example.com">link</a>
4891 </p>
4892 !!end
4893
4894 !! test
4895 External links: trail
4896 !! wikitext
4897 Linktrails should not work for external links: [http://example.com link]s
4898 !! html
4899 <p>Linktrails should not work for external links: <a rel="nofollow" class="external text" href="http://example.com">link</a>s
4900 </p>
4901 !! end
4902
4903 !! test
4904 External links: dollar sign in URL
4905 !! wikitext
4906 http://example.com/1$2345
4907 !! html
4908 <p><a rel="nofollow" class="external free" href="http://example.com/1$2345">http://example.com/1$2345</a>
4909 </p>
4910 !! end
4911
4912 # parsoid doesn't explicitly mark autonumbered links, see T55505
4913 !! test
4914 External links: dollar sign in URL (autonumber)
4915 !! wikitext
4916 [http://example.com/1$2345]
4917 !! html/php
4918 <p><a rel="nofollow" class="external autonumber" href="http://example.com/1$2345">[1]</a>
4919 </p>
4920 !! html/parsoid
4921 <p><a rel="mw:ExtLink" class="external autonumber" href="http://example.com/1$2345"></a></p>
4922 !!end
4923
4924 !! test
4925 External links: open square bracket forbidden in URL (T6377)
4926 !! options
4927 parsoid=wt2html,wt2wt,html2html
4928 !! wikitext
4929 http://example.com/1[2345
4930 !! html/php
4931 <p><a rel="nofollow" class="external free" href="http://example.com/1">http://example.com/1</a>[2345
4932 </p>
4933 !! html/parsoid
4934 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/1">http://example.com/1</a>[2345</p>
4935 !! end
4936
4937 !! test
4938 External links: open square bracket forbidden in URL (named) (T6377)
4939 !! options
4940 parsoid=wt2html,html2html
4941 !! wikitext
4942 [http://example.com/1[2345]
4943 !! html/php
4944 <p><a rel="nofollow" class="external text" href="http://example.com/1">[2345</a>
4945 </p>
4946 !! html/parsoid
4947 <p><a rel="mw:ExtLink" class="external text" href="http://example.com/1">[2345</a></p>
4948 !!end
4949
4950 # parsoid adds a space before the link name
4951 !! test
4952 External links: open square bracket forbidden in URL (named) (T6377)
4953 Parsoid variant.
4954 !! wikitext
4955 [http://example.com/1 [2345]
4956 !! html
4957 <p><a rel="nofollow" class="external text" href="http://example.com/1">[2345</a>
4958 </p>
4959 !!end
4960
4961 !! test
4962 External links: nowiki in URL link text (T8230)
4963 !! wikitext
4964 [http://example.com/ <nowiki>''example site''</nowiki>]
4965 !! html
4966 <p><a rel="nofollow" class="external text" href="http://example.com/">''example site''</a>
4967 </p>
4968 !! end
4969
4970 !! test
4971 External links: newline forbidden in text (T8230 regression check)
4972 !! wikitext
4973 [http://example.com/ first
4974 second]
4975 !! html
4976 <p>[<a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a> first
4977 second]
4978 </p>
4979 !!end
4980
4981 !! test
4982 External links: Pipe char between url and text
4983 !! wikitext
4984 [http://example.com | link]
4985 !! html
4986 <p><a rel="nofollow" class="external text" href="http://example.com">| link</a>
4987 </p>
4988 !!end
4989
4990 !! test
4991 External links: protocol-relative URL in brackets
4992 !! wikitext
4993 [//example.com/ Test]
4994 !! html
4995 <p><a rel="nofollow" class="external text" href="//example.com/">Test</a>
4996 </p>
4997 !! end
4998
4999 # parsoid doesn't explicitly mark autonumbered links, see T55505
5000 !! test
5001 External links: protocol-relative URL in brackets without text
5002 !! wikitext
5003 [//example.com]
5004 !! html/php
5005 <p><a rel="nofollow" class="external autonumber" href="//example.com">[1]</a>
5006 </p>
5007 !! html/parsoid
5008 <p><a rel="mw:ExtLink" class="external autonumber" href="//example.com"></a></p>
5009 !! end
5010
5011 !! test
5012 External links: protocol-relative URL in free text is left alone
5013 !! wikitext
5014 //example.com/Foo
5015 !! html
5016 <p>//example.com/Foo
5017 </p>
5018 !!end
5019
5020 !! test
5021 External links: protocol-relative URL in the middle of a word is left alone (T32269)
5022 !! wikitext
5023 foo//example.com/Foo
5024 !! html
5025 <p>foo//example.com/Foo
5026 </p>
5027 !! end
5028
5029 ## html2wt and html2html will fail because we will prefer the :en: interwiki prefix over wikipedia:
5030 !! test
5031 External links: with no contents
5032 !! options
5033 parsoid=wt2html,wt2wt
5034 !! wikitext
5035 [http://en.wikipedia.org/wiki/Foo]
5036
5037 [[wikipedia:Foo|Bar]]
5038
5039 [[wikipedia:Foo|<span>Bar</span>]]
5040 !! html/php
5041 <p><a rel="nofollow" class="external autonumber" href="http://en.wikipedia.org/wiki/Foo">[1]</a>
5042 </p><p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo">Bar</a>
5043 </p><p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo"><span>Bar</span></a>
5044 </p>
5045 !! html/parsoid
5046 <p><a rel="mw:ExtLink" class="external autonumber" href="http://en.wikipedia.org/wiki/Foo"></a></p>
5047 <p><a rel="mw:WikiLink/Interwiki" href="http://en.wikipedia.org/wiki/Foo" title="wikipedia:Foo">Bar</a></p>
5048 <p><a rel="mw:WikiLink/Interwiki" href="http://en.wikipedia.org/wiki/Foo" title="wikipedia:Foo"><span>Bar</span></a></p>
5049 !! end
5050
5051 !! test
5052 External links: Free with trailing punctuation
5053 !! wikitext
5054 http://example.com,
5055 http://example.com;
5056 http://example.com\
5057 http://example.com.
5058 http://example.com:
5059 http://example.com!
5060 http://example.com?
5061 http://example.com)
5062 http://example.com/url_with_(brackets)
5063 (http://example.com/url_without_brackets)
5064 http://example.com/url_with_entity&amp;
5065 http://example.com/url_with_entity&#x26;
5066 http://example.com/url_with_entity&#038;
5067 http://example.com/url_with_entity&nbsp;
5068 http://example.com/url_with_entity&#xA0;
5069 http://example.com/url_with_entity&#160;
5070 http://example.com/url_with_entity&lt;
5071 http://example.com/url_with_entity&#x3C;
5072 http://example.com/url_with_entity&#60;
5073 !! html/php
5074 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>,
5075 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>;
5076 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>\
5077 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>.
5078 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>:
5079 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>!
5080 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>?
5081 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
5082 <a rel="nofollow" class="external free" href="http://example.com/url_with_(brackets)">http://example.com/url_with_(brackets)</a>
5083 (<a rel="nofollow" class="external free" href="http://example.com/url_without_brackets">http://example.com/url_without_brackets</a>)
5084 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
5085 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
5086 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
5087 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#160;
5088 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#xa0;
5089 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#160;
5090 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&lt;
5091 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#x3c;
5092 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#60;
5093 </p>
5094 !! html/parsoid
5095 <p><a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>,
5096 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>;
5097 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>\
5098 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>.
5099 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>:
5100 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>!
5101 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>?
5102 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>)
5103 <a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_(brackets)">http://example.com/url_with_(brackets)</a>
5104 (<a rel="mw:ExtLink" class="external free" href="http://example.com/url_without_brackets">http://example.com/url_without_brackets</a>)
5105 <a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
5106 <a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
5107 <a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
5108 <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>
5109 <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>
5110 <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>
5111 <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>
5112 <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>
5113 <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>
5114 !! end
5115
5116 !! test
5117 External links: tricky Parsoid html2html case
5118 !! options
5119 parsoid=wt2html,wt2wt,html2html
5120 !! wikitext
5121 http://example.com/url_with_entity&amp;amp;
5122 !! html/php
5123 <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>;
5124 </p>
5125 !! html/parsoid
5126 <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>
5127 !! end
5128
5129 !! test
5130 External links: Free with trailing quotes (T113666)
5131 !! wikitext
5132 '''News:''' Stuff here
5133
5134 news:'a'b''c''d e
5135 !! html/php
5136 <p><b>News:</b> Stuff here
5137 </p><p><a rel="nofollow" class="external free" href="news:&#39;a&#39;b">news:'a'b</a><i>c</i>d e
5138 </p>
5139 !! html/parsoid
5140 <p><b>News:</b> Stuff here</p>
5141 <p><a rel="mw:ExtLink" class="external free" href="news:'a'b">news:'a'b</a><i>c</i>d e</p>
5142 !! end
5143
5144 !! test
5145 External links: with entity
5146 !! wikitext
5147 [http://&#x20;www.librarieswithoutborders.org Libraries without borders]
5148 !! html/php
5149 <p><a rel="nofollow" class="external text" href="http://+www.librarieswithoutborders.org">Libraries without borders</a>
5150 </p>
5151 !! html/parsoid
5152 <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>
5153 !! end
5154
5155 !! test
5156 External links: Lone protocols are never linked (T105697)
5157 !! wikitext
5158 http://
5159 http://;
5160 (http://)
5161 bitcoin:
5162 bitcoin:;
5163 (bitcoin:)
5164 !! html
5165 <p>http://
5166 http://;
5167 (http://)
5168 bitcoin:
5169 bitcoin:;
5170 (bitcoin:)
5171 </p>
5172 !! end
5173
5174 !! test
5175 External links: No preceding word characters allowed (T67278)
5176 !! wikitext
5177 NOPEhttp://example.com
5178 N0http://example.com
5179 ok:http://example.com
5180 ok-http://example.com
5181 !! html
5182 <p>NOPEhttp://example.com
5183 N0http://example.com
5184 ok:<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
5185 ok-<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
5186 </p>
5187 !! end
5188
5189 !! test
5190 External links: nofollow domain exception
5191 !! wikitext
5192 A [https://no-nofollow.org/foobar link], and another [https://example.org link].
5193 !! html
5194 <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>.
5195 </p>
5196 !!end
5197
5198 !! test
5199 External image
5200 !! wikitext
5201 External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
5202 !! html
5203 <p>External image: <img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png"/>
5204 </p>
5205 !! end
5206
5207 !! test
5208 External image from https
5209 !! wikitext
5210 External image from https: https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
5211 !! html
5212 <p>External image from https: <img src="https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png"/>
5213 </p>
5214 !! end
5215
5216 !! test
5217 External image (when not allowed)
5218 !! options
5219 wgAllowExternalImages=0
5220 !! wikitext
5221 External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
5222 !! html
5223 <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>
5224 </p>
5225 !! end
5226
5227 !! test
5228 Link to non-http image, no img tag
5229 !! wikitext
5230 Link to non-http image, no img tag: ftp://example.com/test.jpg
5231 !! html
5232 <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>
5233 </p>
5234 !! end
5235
5236 !! test
5237 External links: terminating separator
5238 !! wikitext
5239 Terminating separator: http://example.com/thing,
5240 !! html
5241 <p>Terminating separator: <a rel="nofollow" class="external free" href="http://example.com/thing">http://example.com/thing</a>,
5242 </p>
5243 !! end
5244
5245 !! test
5246 External links: intervening separator
5247 !! wikitext
5248 Intervening separator: http://example.com/1,2,3
5249 !! html
5250 <p>Intervening separator: <a rel="nofollow" class="external free" href="http://example.com/1,2,3">http://example.com/1,2,3</a>
5251 </p>
5252 !! end
5253
5254 !! test
5255 External links: old bug with URL in query
5256 !! wikitext
5257 Old bug with URL in query: [http://example.com/thing?url=http://example.com link]
5258 !! html
5259 <p>Old bug with URL in query: <a rel="nofollow" class="external text" href="http://example.com/thing?url=http://example.com">link</a>
5260 </p>
5261 !! end
5262
5263 !! test
5264 External links: old URL-in-URL bug, mixed protocols
5265 !! wikitext
5266 And again with mixed protocols: [ftp://example.com?url=http://example.com link]
5267 !! html
5268 <p>And again with mixed protocols: <a rel="nofollow" class="external text" href="ftp://example.com?url=http://example.com">link</a>
5269 </p>
5270 !!end
5271
5272 # Since Parsoid is starting to emit canonical wikitext for links,
5273 # [http://example.com http://example.com] will not RT back to that
5274 # form anymore.
5275 !! test
5276 External links: URL in text
5277 !! options
5278 parsoid=wt2html
5279 !! wikitext
5280 URL in text: [http://example.com http://example.com]
5281 !! html/php
5282 <p>URL in text: <a rel="nofollow" class="external text" href="http://example.com">http://example.com</a>
5283 </p>
5284 !! html/parsoid
5285 <p>URL in text: <a rel="mw:ExtLink" class="external text" href="http://example.com">http://example.com</a></p>
5286 !! end
5287
5288 !! test
5289 External links: Clickable images
5290 !! wikitext
5291 ja-style clickable images: [http://example.com http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png]
5292 !! html/php
5293 <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>
5294 </p>
5295 !! html/parsoid
5296 <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>
5297 !! end
5298
5299 !! test
5300 External links: raw ampersand
5301 !! wikitext
5302 Old &amp; use: http://x&y
5303 !! html
5304 <p>Old &amp; use: <a rel="nofollow" class="external free" href="http://x&amp;y">http://x&amp;y</a>
5305 </p>
5306 !! end
5307
5308 !! test
5309 External links: encoded ampersand
5310 !! wikitext
5311 Old &amp; use: http://x&amp;y
5312 !! html/php
5313 <p>Old &amp; use: <a rel="nofollow" class="external free" href="http://x&amp;y">http://x&amp;y</a>
5314 </p>
5315 !! html/parsoid
5316 <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>
5317 !! end
5318
5319 !! test
5320 External links: encoded equals (T8102)
5321 !! wikitext
5322 http://example.com/?foo&#61;bar
5323 !! html/php
5324 <p><a rel="nofollow" class="external free" href="http://example.com/?foo=bar">http://example.com/?foo=bar</a>
5325 </p>
5326 !! html/parsoid
5327 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/?foo=bar">http://example.com/?foo=bar</a></p>
5328 !! end
5329
5330 ##
5331 ## Note that parsoid doesn't explicit mark autonumbered links, nor
5332 ## does it number them. As discussed in T55505, we can identify
5333 ## autonumbered links via CSS.
5334 ##
5335
5336 !! test
5337 External links: [raw ampersand]
5338 !! wikitext
5339 Old &amp; use: [http://x&y]
5340 !! html/php
5341 <p>Old &amp; use: <a rel="nofollow" class="external autonumber" href="http://x&amp;y">[1]</a>
5342 </p>
5343 !! html/parsoid
5344 <p>Old <span typeof="mw:Entity">&amp;</span> use: <a rel="mw:ExtLink" class="external autonumber" href="http://x&amp;y"></a></p>
5345 !! end
5346
5347 # note that parsoid html is identical to [raw ampersand] case; so html2wt
5348 # mode will return the [raw ampersand] wikitext
5349 !! test
5350 External links: [encoded ampersand]
5351 !! options
5352 parsoid=wt2html,wt2wt,html2html
5353 !! wikitext
5354 Old &amp; use: [http://x&amp;y]
5355 !! html/php
5356 <p>Old &amp; use: <a rel="nofollow" class="external autonumber" href="http://x&amp;y">[1]</a>
5357 </p>
5358 !! html/parsoid
5359 <p>Old <span typeof="mw:Entity">&amp;</span> use: <a rel="mw:ExtLink" class="external autonumber" href="http://x&amp;y"></a></p>
5360 !! end
5361
5362 !! test
5363 External links: [raw equals]
5364 !! wikitext
5365 [http://example.com/?foo=bar]
5366 !! html/php
5367 <p><a rel="nofollow" class="external autonumber" href="http://example.com/?foo=bar">[1]</a>
5368 </p>
5369 !! html/parsoid
5370 <p><a rel="mw:ExtLink" class="external autonumber" href="http://example.com/?foo=bar"></a></p>
5371 !! end
5372
5373 # note that parsoid html is identical to [raw equals] case; so html2wt
5374 # mode will return the [raw equals] wikitext
5375 !! test
5376 External links: [encoded equals] (T8102)
5377 !! options
5378 parsoid=wt2html,wt2wt,html2html
5379 !! wikitext
5380 [http://example.com/?foo&#61;bar]
5381 !! html/php
5382 <p><a rel="nofollow" class="external autonumber" href="http://example.com/?foo=bar">[1]</a>
5383 </p>
5384 !! html/parsoid
5385 <p><a rel="mw:ExtLink" class="external autonumber" href="http://example.com/?foo=bar"></a></p>
5386 !! end
5387
5388 # xxx parsoid strips the IDN character, so the round-trip tests will
5389 # obviously fail and are disabled. --cscott
5390 !! test
5391 External links: [IDN ignored character reference in hostname; strip it right off]
5392 !! options
5393 parsoid=wt2html,wt2wt,html2html
5394 !! wikitext
5395 [http://e&zwnj;xample.com/]
5396 !! html/php
5397 <p><a rel="nofollow" class="external autonumber" href="http://example.com/">[1]</a>
5398 </p>
5399 !! html/parsoid
5400 <p><a rel="mw:ExtLink" class="external autonumber" href="http://example.com/"></a></p>
5401 !! end
5402
5403 # FIXME: This test (the IDN characters in the text of a link) is an inconsistency.
5404 # Where an external link could easily circumvent the sanitization of the text of
5405 # a link like this (where an IDN-ignore character is in the URL somewhere), this
5406 # test demands a higher standard. That's a bit strange.
5407 #
5408 # Example:
5409 #
5410 # http://e‌xample.com -> [http://example.com|http://example.com]
5411 # [http://example.com|http://e‌xample.com] -> [http://example.com|http://e‌xample.com]
5412 #
5413 # The first example is sanitized, but the second is not. Any security benefits
5414 # from this production are trivial to circumvent. Either remove this test and
5415 # let the parser(s) do their thing unaccosted, or fix the inconsistency and change
5416 # the test accordingly.
5417 #
5418 # All our love,
5419 # The Parsoid team.
5420 # xxx parsoid strips the IDN character, so the round-trip tests will
5421 # obviously fail and are disabled. --cscott
5422 !! test
5423 External links: IDN ignored character reference in hostname; strip it right off
5424 !! options
5425 parsoid=wt2html,html2html
5426 !! wikitext
5427 http://e&zwnj;xample.com/
5428 !! html/php
5429 <p><a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a>
5430 </p>
5431 !! html/parsoid
5432 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/">http://example.com/</a></p>
5433 !! end
5434
5435 !! test
5436 External links: www.jpeg.org (T2554)
5437 !! wikitext
5438 http://www.jpeg.org
5439 !! html
5440 <p><a rel="nofollow" class="external free" href="http://www.jpeg.org">http://www.jpeg.org</a>
5441 </p>
5442 !! end
5443
5444 # parsoid doesn't explicitly mark autonumbered links, see T55505
5445 !! test
5446 External links: URL within URL (T2002)
5447 !! wikitext
5448 [http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp]
5449 !! html/php
5450 <p><a rel="nofollow" class="external autonumber" href="http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp">[1]</a>
5451 </p>
5452 !! html/parsoid
5453 <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>
5454 !! end
5455
5456 !! test
5457 T2361: URL inside bracketed URL
5458 !! wikitext
5459 [http://www.example.com/foo http://www.example.com/bar]
5460 !! html
5461 <p><a rel="nofollow" class="external text" href="http://www.example.com/foo">http://www.example.com/bar</a>
5462 </p>
5463 !! end
5464
5465 !! test
5466 T2361: URL within URL, not bracketed
5467 !! wikitext
5468 http://www.example.com/foo?=http://www.example.com/bar
5469 !! html
5470 <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>
5471 </p>
5472 !! end
5473
5474 !! test
5475 T2289: ">"-token in URL-tail
5476 !! wikitext
5477 http://www.example.com/<hello>
5478 !! html
5479 <p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a>&lt;hello&gt;
5480 </p>
5481 !!end
5482
5483 !! test
5484 T2289: literal ">"-token in URL-tail
5485 !! wikitext
5486 http://www.example.com/<b>html</b>
5487 !! html/php
5488 <p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a><b>html</b>
5489 </p>
5490 !! html/parsoid
5491 <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>
5492 !! end
5493
5494 !! test
5495 T2289: ">"-token in bracketed URL
5496 !! wikitext
5497 [http://www.example.com/<hello> stuff]
5498 !! html
5499 <p><a rel="nofollow" class="external text" href="http://www.example.com/">&lt;hello&gt; stuff</a>
5500 </p>
5501 !!end
5502
5503 !! test
5504 T2289: literal ">"-token in bracketed URL
5505 !! wikitext
5506 [http://www.example.com/<b>html</b> stuff]
5507 !! html
5508 <p><a rel="nofollow" class="external text" href="http://www.example.com/"><b>html</b> stuff</a>
5509 </p>
5510 !!end
5511
5512 !! test
5513 T2289: literal double quote at end of URL
5514 !! wikitext
5515 http://www.example.com/"hello"
5516 !! html
5517 <p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a>"hello"
5518 </p>
5519 !!end
5520
5521 !! test
5522 T2289: literal double quote in bracketed URL
5523 !! wikitext
5524 [http://www.example.com/"hello" stuff]
5525 !! html
5526 <p><a rel="nofollow" class="external text" href="http://www.example.com/">"hello" stuff</a>
5527 </p>
5528 !!end
5529
5530 !! test
5531 External links: multiple legal whitespace is fine, Magnus. Don't break it please. (T7081)
5532 !! wikitext
5533 [http://www.example.com test]
5534 !! html
5535 <p><a rel="nofollow" class="external text" href="http://www.example.com">test</a>
5536 </p>
5537 !! end
5538
5539 !! test
5540 External links: link text with spaces
5541 !! wikitext
5542 [http://www.example.com a b c]
5543 [http://www.example.com ''a'' ''b'']
5544 !! html
5545 <p><a rel="nofollow" class="external text" href="http://www.example.com">a b c</a>
5546 <a rel="nofollow" class="external text" href="http://www.example.com"><i>a</i> <i>b</i></a>
5547 </p>
5548 !! end
5549
5550 # Note edge case difference between PHP and Parsoid here.
5551 !! test
5552 External links: wiki links within external link (T5695)
5553 !! options
5554 parsoid=wt2html,html2html
5555 !! wikitext
5556 [http://example.com [[wikilink]] embedded in ext link]
5557
5558 [http://example.com test [[wikilink]] embedded in ext link]
5559 !! html/php
5560 <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>
5561 </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>
5562 </p>
5563 !! html/parsoid
5564 <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>
5565 <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>
5566 !! end
5567
5568 !! test
5569 T2787: Links with one slash after the url protocol are invalid
5570 !! wikitext
5571 http:/example.com
5572
5573 [http:/example.com title]
5574 !! html
5575 <p>http:/example.com
5576 </p><p>[http:/example.com title]
5577 </p>
5578 !! end
5579
5580 !! test
5581 Bracketed external links with template-generated invalid target
5582 !! wikitext
5583 [{{echo|http:/example.com}} title]
5584 !! html
5585 <p>[http:/example.com title]
5586 </p>
5587 !! end
5588
5589 # wt2html only because Parsoid would want to add <nowiki>s coming from html
5590 !! test
5591 Broken wikilinks (but not external links) prevent templates from closing
5592 !! options
5593 parsoid=wt2html
5594 !! wikitext
5595 [http://example.com x
5596
5597 {{echo|[http://example.com x}}
5598
5599 [[Foo
5600
5601 {{echo|[[Foo}}
5602 !! html/php
5603 <p>[<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> x
5604 </p><p>[<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> x
5605 </p><p>[[Foo
5606 </p><p>{{echo|[[Foo}}
5607 </p>
5608 !! html/parsoid
5609 <p>[<a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a> x</p>
5610 <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>
5611 <p>[[Foo</p>
5612 <p>{{echo|[[Foo}}</p>
5613 !! end
5614
5615 !! test
5616 Wikilinks with embedded newlines are not broken
5617 !! wikitext
5618 {{echo|[[ Foo
5619 B
5620 C]]}}
5621 !! html/php
5622 <p>[[ Foo
5623 B
5624 C]]
5625 </p>
5626 !! html/parsoid
5627 <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>
5628 !! end
5629
5630 !! test
5631 Broken templates
5632 !! options
5633 parsoid=wt2html
5634 !! wikitext
5635 {{echo|[[Foo|}}]]
5636
5637 [[Foo|{{echo|]]}}
5638 !! html/php
5639 <p>{{echo|<a href="/wiki/Foo" title="Foo">}}</a>
5640 </p><p>[[Foo|]]
5641 </p>
5642 !! html/parsoid
5643 <p>{{echo|<a rel="mw:WikiLink" href="./Foo" title="Foo">}}</a></p>
5644 <p>[[Foo|<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"]]"}},"i":0}}]}'>]]</span></p>
5645 !! end
5646
5647 !! test
5648 T4702: Mismatched <i>, <b> and <a> tags are invalid
5649 !! wikitext
5650 ''[http://example.com text'']
5651 [http://example.com '''text]'''
5652 ''Something [http://example.com in italic'']
5653 ''Something [http://example.com mixed''''', even bold]'''
5654 '''''Now [http://example.com both''''']
5655 !! html
5656 <p><a rel="nofollow" class="external text" href="http://example.com"><i>text</i></a>
5657 <a rel="nofollow" class="external text" href="http://example.com"><b>text</b></a>
5658 <i>Something </i><a rel="nofollow" class="external text" href="http://example.com"><i>in italic</i></a>
5659 <i>Something </i><a rel="nofollow" class="external text" href="http://example.com"><i>mixed</i><b>, even bold</b></a>
5660 <i><b>Now </b></i><a rel="nofollow" class="external text" href="http://example.com"><i><b>both</b></i></a>
5661 </p>
5662 !! end
5663
5664
5665 !! test
5666 T6781: %26 in URL
5667 !! wikitext
5668 http://www.example.com/?title=AT%26T
5669 !! html/php
5670 <p><a rel="nofollow" class="external free" href="http://www.example.com/?title=AT%26T">http://www.example.com/?title=AT%26T</a>
5671 </p>
5672 !! html/parsoid
5673 <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>
5674 !! end
5675
5676 # According to https://www.w3.org/TR/2011/WD-html5-20110525/Overview.html#parsing-urls a plain
5677 # % is actually legal in HTML5. Any change in output would need testing though.
5678 !! test
5679 T6781, T7267: %25 in URL
5680 !! wikitext
5681 http://www.example.com/?title=100%25_Bran
5682 !! html/php
5683 <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>
5684 </p>
5685 !! html/parsoid
5686 <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>
5687 !! end
5688
5689 !! test
5690 T6781, T7267: %28, %29 in URL
5691 !! wikitext
5692 http://www.example.com/?title=Ben-Hur_%281959_film%29
5693 !! html/php
5694 <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>
5695 </p>
5696 !! html/parsoid
5697 <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>
5698 !! end
5699
5700
5701 !! test
5702 T6781: %26 in autonumber URL
5703 !! wikitext
5704 [http://www.example.com/?title=AT%26T]
5705 !! html/php
5706 <p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=AT%26T">[1]</a>
5707 </p>
5708 !! html/parsoid
5709 <p><a rel="mw:ExtLink" class="external autonumber" href="http://www.example.com/?title=AT%26T"></a></p>
5710 !! end
5711
5712 !! test
5713 T6781, T7267: %26 in autonumber URL
5714 !! wikitext
5715 [http://www.example.com/?title=100%25_Bran]
5716 !! html/php
5717 <p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=100%25_Bran">[1]</a>
5718 </p>
5719 !! html/parsoid
5720 <p><a rel="mw:ExtLink" class="external autonumber" href="http://www.example.com/?title=100%25_Bran"></a></p>
5721 !! end
5722
5723 !! test
5724 T6781, T7267: %28, %29 in autonumber URL
5725 !! wikitext
5726 [http://www.example.com/?title=Ben-Hur_%281959_film%29]
5727 !! html/php
5728 <p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">[1]</a>
5729 </p>
5730 !! html/parsoid
5731 <p><a rel="mw:ExtLink" class="external autonumber" href="http://www.example.com/?title=Ben-Hur_%281959_film%29"></a></p>
5732 !! end
5733
5734
5735 !! test
5736 T6781: %26 in bracketed URL
5737 !! wikitext
5738 [http://www.example.com/?title=AT%26T link]
5739 !! html/php
5740 <p><a rel="nofollow" class="external text" href="http://www.example.com/?title=AT%26T">link</a>
5741 </p>
5742 !! html/parsoid
5743 <p><a rel="mw:ExtLink" class="external text" href="http://www.example.com/?title=AT%26T">link</a></p>
5744 !! end
5745
5746 !! test
5747 T6781, T7267: %25 in bracketed URL
5748 !! wikitext
5749 [http://www.example.com/?title=100%25_Bran link]
5750 !! html
5751 <p><a rel="nofollow" class="external text" href="http://www.example.com/?title=100%25_Bran">link</a>
5752 </p>
5753 !! end
5754
5755 !! test
5756 T6781, T7267: %28, %29 in bracketed URL
5757 !! wikitext
5758 [http://www.example.com/?title=Ben-Hur_%281959_film%29 link]
5759 !! html/php
5760 <p><a rel="nofollow" class="external text" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">link</a>
5761 </p>
5762 !! html/parsoid
5763 <p><a rel="mw:ExtLink" class="external text" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">link</a></p>
5764 !! end
5765
5766 !! test
5767 External link containing a period in the anchor. (T65947)
5768 !! wikitext
5769 [//foo.org/bar#baz. bang]
5770
5771 [//foo.org/bar. bang]
5772 !! html/php
5773 <p><a rel="nofollow" class="external text" href="//foo.org/bar#baz.">bang</a>
5774 </p><p><a rel="nofollow" class="external text" href="//foo.org/bar.">bang</a>
5775 </p>
5776 !! html/parsoid
5777 <p><a rel="mw:ExtLink" class="external text" href="//foo.org/bar#baz.">bang</a></p>
5778 <p><a rel="mw:ExtLink" class="external text" href="//foo.org/bar.">bang</a></p>
5779 !! end
5780
5781 !! test
5782 External link containing a single quote. (T65947)
5783 !! wikitext
5784 [//foo.org/bar'baz]
5785
5786 [//foo.org/bar'baz bang]
5787 !! html/php
5788 <p><a rel="nofollow" class="external autonumber" href="//foo.org/bar&#39;baz">[1]</a>
5789 </p><p><a rel="nofollow" class="external text" href="//foo.org/bar&#39;baz">bang</a>
5790 </p>
5791 !! html/parsoid
5792 <p><a rel="mw:ExtLink" class="external autonumber" href="//foo.org/bar'baz"></a></p>
5793 <p><a rel="mw:ExtLink" class="external text" href="//foo.org/bar'baz">bang</a></p>
5794 !! end
5795
5796 !! test
5797 External link containing double-single-quotes in text '' (T6598 sanity check)
5798 !! wikitext
5799 Some [http://example.com/ pretty ''italics'' and stuff]!
5800 !! html
5801 <p>Some <a rel="nofollow" class="external text" href="http://example.com/">pretty <i>italics</i> and stuff</a>!
5802 </p>
5803 !! end
5804
5805 !! test
5806 External link containing double-single-quotes in text embedded in italics (T6598 sanity check)
5807 !! wikitext
5808 ''Some [http://example.com/ pretty ''italics'' and stuff]!''
5809 !! html
5810 <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>
5811 </p>
5812 !! end
5813
5814 # Don't add the html/php section since the output is broken and there isn't any reason to spec it
5815 !! test
5816 External link containing double-single-quotes with no space separating the url from text in italics
5817 !! wikitext
5818 [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]].]
5819 !! html/php+tidy
5820 <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>.
5821 </p>
5822 !! html/parsoid
5823 <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>
5824 !! end
5825
5826 !! test
5827 External link with comments in link text
5828 !! wikitext
5829 [http://www.google.com Google <!-- comment -->]
5830 !! html/php
5831 <p><a rel="nofollow" class="external text" href="http://www.google.com">Google </a>
5832 </p>
5833 !! html/parsoid
5834 <p><a rel="mw:ExtLink" class="external text" href="http://www.google.com">Google <!-- comment --></a></p>
5835 !! end
5836
5837 !! test
5838 External link to bare IPv4 address
5839 !! wikitext
5840 [http://192.168.0.1 Link]
5841 !! html/php
5842 <p><a rel="nofollow" class="external text" href="http://192.168.0.1">Link</a>
5843 </p>
5844 !! html/parsoid
5845 <p><a rel="mw:ExtLink" class="external text" href="http://192.168.0.1">Link</a></p>
5846 !! end
5847
5848 !! test
5849 URL-encoding in URL functions (single parameter)
5850 !! wikitext
5851 {{localurl:Some page|amp=&}}
5852 !! html
5853 <p>/index.php?title=Some_page&amp;amp=&amp;
5854 </p>
5855 !! end
5856
5857 !! test
5858 URL-encoding in URL functions (multiple parameters)
5859 !! wikitext
5860 {{localurl:Some page|q=?&amp=&}}
5861 !! html
5862 <p>/index.php?title=Some_page&amp;q=?&amp;amp=&amp;
5863 </p>
5864 !! end
5865
5866 !! test
5867 Brackets in urls
5868 !! wikitext
5869 http://example.com/index.php?foozoid%5B%5D=bar
5870
5871 http://example.com/index.php?foozoid&#x5B;&#x5D;=bar
5872 !! html/php
5873 <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>
5874 </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>
5875 </p>
5876 !! html/parsoid
5877 <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>
5878
5879 <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>
5880 !! end
5881
5882 !! test
5883 IPv6 urls, autolink format (T23261)
5884 !! wikitext
5885 http://[2404:130:0:1000::187:2]/index.php
5886
5887 Examples from RFC 2373, section 2.2:
5888
5889 *http://[1080::8:800:200C:417A]/unicast
5890 *http://[FF01::101]/multicast
5891 *http://[::1]/loopback
5892 *http://[::]/unspecified
5893 *http://[::13.1.68.3]/ipv4compat
5894 *http://[::FFFF:129.144.52.38]/ipv4compat
5895
5896 Examples from RFC 2732, section 2:
5897
5898 *http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html
5899 *http://[1080:0:0:0:8:800:200C:417A]/index.html
5900 *http://[3ffe:2a00:100:7031::1]
5901 *http://[1080::8:800:200C:417A]/foo
5902 *http://[::192.9.5.5]/ipng
5903 *http://[::FFFF:129.144.52.38]:80/index.html
5904 *http://[2010:836B:4179::836B:4179]
5905 !! html/php
5906 <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>
5907 </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:
5908 </p>
5909 <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>
5910 <li><a rel="nofollow" class="external free" href="http://[FF01::101]/multicast">http://[FF01::101]/multicast</a></li>
5911 <li><a rel="nofollow" class="external free" href="http://[::1]/loopback">http://[::1]/loopback</a></li>
5912 <li><a rel="nofollow" class="external free" href="http://[::]/unspecified">http://[::]/unspecified</a></li>
5913 <li><a rel="nofollow" class="external free" href="http://[::13.1.68.3]/ipv4compat">http://[::13.1.68.3]/ipv4compat</a></li>
5914 <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>
5915 <p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc2732">RFC 2732</a>, section 2:
5916 </p>
5917 <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>
5918 <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>
5919 <li><a rel="nofollow" class="external free" href="http://[3ffe:2a00:100:7031::1]">http://[3ffe:2a00:100:7031::1]</a></li>
5920 <li><a rel="nofollow" class="external free" href="http://[1080::8:800:200C:417A]/foo">http://[1080::8:800:200C:417A]/foo</a></li>
5921 <li><a rel="nofollow" class="external free" href="http://[::192.9.5.5]/ipng">http://[::192.9.5.5]/ipng</a></li>
5922 <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>
5923 <li><a rel="nofollow" class="external free" href="http://[2010:836B:4179::836B:4179]">http://[2010:836B:4179::836B:4179]</a></li></ul>
5924
5925 !! html/parsoid
5926 <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>
5927
5928 <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>
5929 <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>
5930 <li><a rel="mw:ExtLink" class="external free" href="http://[FF01::101]/multicast">http://[FF01::101]/multicast</a></li>
5931 <li><a rel="mw:ExtLink" class="external free" href="http://[::1]/loopback">http://[::1]/loopback</a></li>
5932 <li><a rel="mw:ExtLink" class="external free" href="http://[::]/unspecified">http://[::]/unspecified</a></li>
5933 <li><a rel="mw:ExtLink" class="external free" href="http://[::13.1.68.3]/ipv4compat">http://[::13.1.68.3]/ipv4compat</a></li>
5934 <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>
5935
5936 <p>Examples from <a href="https://tools.ietf.org/html/rfc2732" rel="mw:ExtLink" class="external mw-magiclink">RFC 2732</a>, section 2:</p>
5937 <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>
5938 <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>
5939 <li><a rel="mw:ExtLink" class="external free" href="http://[3ffe:2a00:100:7031::1]">http://[3ffe:2a00:100:7031::1]</a></li>
5940 <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>
5941 <li><a rel="mw:ExtLink" class="external free" href="http://[::192.9.5.5]/ipng">http://[::192.9.5.5]/ipng</a></li>
5942 <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>
5943 <li><a rel="mw:ExtLink" class="external free" href="http://[2010:836B:4179::836B:4179]">http://[2010:836B:4179::836B:4179]</a></li></ul>
5944 !! end
5945
5946 !! test
5947 IPv6 urls, bracketed format (T23261)
5948 !! wikitext
5949 [http://[2404:130:0:1000::187:2]/index.php test]
5950
5951 Examples from RFC 2373, section 2.2:
5952
5953 *[http://[1080::8:800:200C:417A] unicast]
5954 *[http://[FF01::101] multicast]
5955 *[http://[::1]/ loopback]
5956 *[http://[::] unspecified]
5957 *[http://[::13.1.68.3] ipv4compat]
5958 *[http://[::FFFF:129.144.52.38] ipv4compat]
5959
5960 Examples from RFC 2732, section 2:
5961
5962 *[http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html 1]
5963 *[http://[1080:0:0:0:8:800:200C:417A]/index.html 2]
5964 *[http://[3ffe:2a00:100:7031::1] 3]
5965 *[http://[1080::8:800:200C:417A]/foo 4]
5966 *[http://[::192.9.5.5]/ipng 5]
5967 *[http://[::FFFF:129.144.52.38]:80/index.html 6]
5968 *[http://[2010:836B:4179::836B:4179] 7]
5969 !! html/php
5970 <p><a rel="nofollow" class="external text" href="http://[2404:130:0:1000::187:2]/index.php">test</a>
5971 </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:
5972 </p>
5973 <ul><li><a rel="nofollow" class="external text" href="http://[1080::8:800:200C:417A]">unicast</a></li>
5974 <li><a rel="nofollow" class="external text" href="http://[FF01::101]">multicast</a></li>
5975 <li><a rel="nofollow" class="external text" href="http://[::1]/">loopback</a></li>
5976 <li><a rel="nofollow" class="external text" href="http://[::]">unspecified</a></li>
5977 <li><a rel="nofollow" class="external text" href="http://[::13.1.68.3]">ipv4compat</a></li>
5978 <li><a rel="nofollow" class="external text" href="http://[::FFFF:129.144.52.38]">ipv4compat</a></li></ul>
5979 <p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc2732">RFC 2732</a>, section 2:
5980 </p>
5981 <ul><li><a rel="nofollow" class="external text" href="http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html">1</a></li>
5982 <li><a rel="nofollow" class="external text" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">2</a></li>
5983 <li><a rel="nofollow" class="external text" href="http://[3ffe:2a00:100:7031::1]">3</a></li>
5984 <li><a rel="nofollow" class="external text" href="http://[1080::8:800:200C:417A]/foo">4</a></li>
5985 <li><a rel="nofollow" class="external text" href="http://[::192.9.5.5]/ipng">5</a></li>
5986 <li><a rel="nofollow" class="external text" href="http://[::FFFF:129.144.52.38]:80/index.html">6</a></li>
5987 <li><a rel="nofollow" class="external text" href="http://[2010:836B:4179::836B:4179]">7</a></li></ul>
5988
5989 !! html/parsoid
5990 <p><a rel="mw:ExtLink" class="external text" href="http://[2404:130:0:1000::187:2]/index.php">test</a></p>
5991
5992 <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>
5993 <ul><li><a rel="mw:ExtLink" class="external text" href="http://[1080::8:800:200C:417A]">unicast</a></li>
5994 <li><a rel="mw:ExtLink" class="external text" href="http://[FF01::101]">multicast</a></li>
5995 <li><a rel="mw:ExtLink" class="external text" href="http://[::1]/">loopback</a></li>
5996 <li><a rel="mw:ExtLink" class="external text" href="http://[::]">unspecified</a></li>
5997 <li><a rel="mw:ExtLink" class="external text" href="http://[::13.1.68.3]">ipv4compat</a></li>
5998 <li><a rel="mw:ExtLink" class="external text" href="http://[::FFFF:129.144.52.38]">ipv4compat</a></li></ul>
5999
6000 <p>Examples from <a href="https://tools.ietf.org/html/rfc2732" rel="mw:ExtLink" class="external mw-magiclink">RFC 2732</a>, section 2:</p>
6001 <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>
6002 <li><a rel="mw:ExtLink" class="external text" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">2</a></li>
6003 <li><a rel="mw:ExtLink" class="external text" href="http://[3ffe:2a00:100:7031::1]">3</a></li>
6004 <li><a rel="mw:ExtLink" class="external text" href="http://[1080::8:800:200C:417A]/foo">4</a></li>
6005 <li><a rel="mw:ExtLink" class="external text" href="http://[::192.9.5.5]/ipng">5</a></li>
6006 <li><a rel="mw:ExtLink" class="external text" href="http://[::FFFF:129.144.52.38]:80/index.html">6</a></li>
6007 <li><a rel="mw:ExtLink" class="external text" href="http://[2010:836B:4179::836B:4179]">7</a></li></ul>
6008 !! end
6009
6010 !! test
6011 Non-extlinks in brackets
6012 !! wikitext
6013 [foo]
6014 [foo bar]
6015 [foo ''bar'']
6016 [fool's] errand
6017 [fool's errand]
6018 [{{echo|foo}}]
6019 [{{echo|foo}} bar]
6020 [{{echo|foo}} ''bar'']
6021 [{{echo|foo}}l's] errand
6022 [{{echo|foo}}l's errand]
6023 [url={{echo|foo}}]
6024 [url=http://example.com]
6025 [http:// bare protocols don't count]
6026 !! html/php
6027 <p>[foo]
6028 [foo bar]
6029 [foo <i>bar</i>]
6030 [fool's] errand
6031 [fool's errand]
6032 [foo]
6033 [foo bar]
6034 [foo <i>bar</i>]
6035 [fool's] errand
6036 [fool's errand]
6037 [url=foo]
6038 [url=<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>]
6039 [http:// bare protocols don't count]
6040 </p>
6041 !! html/parsoid
6042 <p>[foo]
6043 [foo bar]
6044 [foo <i>bar</i>]
6045 [fool's] errand
6046 [fool's errand]
6047 [<span about="#mwt19" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</span>]
6048 [<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]
6049 [<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>]
6050 [<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
6051 [<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]
6052 [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>]
6053 [url=<a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>]
6054 [http:// bare protocols don't count]</p>
6055 !! end
6056
6057 !! test
6058 Percent encoding in external links
6059 !! wikitext
6060 [https://github.com/search?l=&q=ResourceLoader+%40wikimedia Search]
6061 !! html/php
6062 <p><a rel="nofollow" class="external text" href="https://github.com/search?l=&amp;q=ResourceLoader+%40wikimedia">Search</a>
6063 </p>
6064 !! html/parsoid
6065 <p><a rel="mw:ExtLink" class="external text" href="https://github.com/search?l=&amp;q=ResourceLoader+%40wikimedia">Search</a></p>
6066 !! end
6067
6068 !! test
6069 Use url link syntax for links where the content is equal the link target
6070 !! wikitext
6071 http://example.com
6072 !! html/php
6073 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
6074 </p>
6075 !! html/parsoid
6076 <p><a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a></p>
6077 !! end
6078
6079 !! test
6080 Parenthesis in external links, especially URL links
6081 !! wikitext
6082 http://example.com)
6083
6084 http://example.com/test)
6085
6086 http://example.com/(test)
6087
6088 http://example.com/((test)
6089
6090 (http://example.com/(test))
6091
6092 (http://example.com/(test)))))
6093
6094 http://example.com/a)b
6095
6096 [http://example.com) foo]
6097 !! html/php
6098 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
6099 </p><p><a rel="nofollow" class="external free" href="http://example.com/test">http://example.com/test</a>)
6100 </p><p><a rel="nofollow" class="external free" href="http://example.com/(test)">http://example.com/(test)</a>
6101 </p><p><a rel="nofollow" class="external free" href="http://example.com/((test)">http://example.com/((test)</a>
6102 </p><p>(<a rel="nofollow" class="external free" href="http://example.com/(test))">http://example.com/(test))</a>
6103 </p><p>(<a rel="nofollow" class="external free" href="http://example.com/(test)))))">http://example.com/(test)))))</a>
6104 </p><p><a rel="nofollow" class="external free" href="http://example.com/a)b">http://example.com/a)b</a>
6105 </p><p><a rel="nofollow" class="external text" href="http://example.com)">foo</a>
6106 </p>
6107 !! html/parsoid
6108 <p><a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>)</p>
6109 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/test">http://example.com/test</a>)</p>
6110 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/(test)">http://example.com/(test)</a></p>
6111 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/((test)">http://example.com/((test)</a></p>
6112 <p>(<a rel="mw:ExtLink" class="external free" href="http://example.com/(test))">http://example.com/(test))</a></p>
6113 <p>(<a rel="mw:ExtLink" class="external free" href="http://example.com/(test)))))">http://example.com/(test)))))</a></p>
6114 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/a)b">http://example.com/a)b</a></p>
6115 <p><a rel="mw:ExtLink" class="external text" href="http://example.com)">foo</a></p>
6116 !! end
6117
6118 !! test
6119 Parenthesis in external links, w/ transclusion or comment
6120 !! wikitext
6121 (http://example.com/{{echo|hi}})
6122
6123 (http://example.com<!-- hi -->)
6124 !! html/php
6125 <p>(<a rel="nofollow" class="external free" href="http://example.com/hi">http://example.com/hi</a>)
6126 </p><p>(<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
6127 </p>
6128 !! html/parsoid
6129 <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>
6130
6131 <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>
6132 !! end
6133
6134 !! test
6135 Serialize <a> tags with invalid link targets as plain text
6136 !! options
6137 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
6138 !! html/parsoid
6139 <a rel="mw:WikiLink" href="[[foo]]">text</a>
6140 <a rel="mw:WikiLink" href="[[foo]]">*text</a>
6141 <a rel="mw:WikiLink" href="[[foo]]">[[foo]]</a>
6142 <a rel="mw:WikiLink" href="[[foo]]">*a [[foo]]</a>
6143 !! wikitext
6144 text
6145 <nowiki>*</nowiki>text
6146 <nowiki>[[foo]]</nowiki>
6147 <nowiki>*</nowiki>a <nowiki>[[foo]]</nowiki>
6148 !! end
6149
6150 !! test
6151 mw:ExtLink -vs- mw:WikiLink (T94723)
6152 !! options
6153 parsoid=html2wt
6154 !! html/parsoid
6155 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"piped","a":{"href":"./Foo"},"sa":{"href":"Foo"}}'>Bar</a>
6156 <a rel="mw:WikiLink" href="./Foo" title="Foo">Bar</a>
6157 <a rel="mw:WikiLink" href="http://en.wikipedia.org/wiki/Foo" title="Foo">Bar</a>
6158 <a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/Foo" title="Foo">Bar</a>
6159 <p>
6160 <a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/European_Robin">European Robin</a>
6161 <a rel="mw:WikiLink" href="http://en.wikipedia.org/wiki/European_Robin">European Robin</a>
6162 </p>
6163 !! wikitext
6164 [[Foo|Bar]]
6165 [[Foo|Bar]]
6166 [[:en:Foo|Bar]]
6167 [[:en:Foo|Bar]]
6168
6169 [[:en:European_Robin|European Robin]]
6170 [[:en:European_Robin|European Robin]]
6171 !! end
6172
6173 !! test
6174 mw:ExtLink linking to a interwiki URL can be round-tripped losslessly (T94723)
6175 !! options
6176 parsoid=wt2wt
6177 !! wikitext
6178 [http://en.wikipedia.org/wiki/European_Robin European Robin]
6179 !! html/parsoid
6180 THIS SECTION IS NOT USED (but Parsoid won't run the test without it)
6181 !! end
6182
6183
6184 ###
6185 ### Quotes
6186 ###
6187
6188 !! test
6189 Quotes
6190 !! wikitext
6191 Normal text. '''Bold text.''' Normal text. ''Italic text.''
6192
6193 Normal text. '''''Bold italic text.''''' Normal text.
6194 !! html
6195 <p>Normal text. <b>Bold text.</b> Normal text. <i>Italic text.</i>
6196 </p><p>Normal text. <i><b>Bold italic text.</b></i> Normal text.
6197 </p>
6198 !! end
6199
6200 !! test
6201 Quotes wrapping HTML table
6202 !! wikitext
6203 '''<table><tr><td>hi</td></tr></table>'''
6204 !! html/php+tidy
6205 <b><table><tbody><tr><td>hi</td></tr></tbody></table></b>
6206 !! html/parsoid
6207 <b><table data-parsoid='{"stx":"html"}'><tbody><tr data-parsoid='{"stx":"html"}'><td data-parsoid='{"stx":"html"}'>hi</td></tr></tbody></table></b>
6208 !! end
6209
6210 # Parsoid inserts an empty bold tag pair at the end of the line, that the PHP
6211 # parser strips. The wikitext contains just the first half of the bold
6212 # quote pair.
6213 !! test
6214 Unclosed and unmatched quotes
6215 !! wikitext
6216 '''''Bold italic text '''with bold deactivated''' in between.'''''
6217
6218 '''''Bold italic text ''with italic deactivated'' in between.'''''
6219
6220 '''Bold text..
6221
6222 ..spanning two paragraphs (should not work).'''
6223
6224 '''Bold tag left open
6225
6226 ''Italic tag left open
6227
6228 Normal text.
6229
6230 <!-- Unmatching number of opening, closing tags: -->
6231 '''This year''''s election ''should'' beat '''last year''''s.
6232
6233 ''Tom'''s car is bigger than ''Susan'''s.
6234
6235 Plain ''italic'''s plain
6236 !! html/php
6237 <p><i><b>Bold italic text </b>with bold deactivated<b> in between.</b></i>
6238 </p><p><b><i>Bold italic text </i>with italic deactivated<i> in between.</i></b>
6239 </p><p><b>Bold text..</b>
6240 </p><p>..spanning two paragraphs (should not work).
6241 </p><p><b>Bold tag left open</b>
6242 </p><p><i>Italic tag left open</i>
6243 </p><p>Normal text.
6244 </p><p><b>This year'</b>s election <i>should</i> beat <b>last year'</b>s.
6245 </p><p><i>Tom<b>s car is bigger than </b></i><b>Susan</b>s.
6246 </p><p>Plain <i>italic'</i>s plain
6247 </p>
6248 !! html/parsoid
6249 <p><i><b>Bold italic text </b>with bold deactivated<b> in between.</b></i>
6250 </p><p><b><i>Bold italic text </i>with italic deactivated<i> in between.</i></b>
6251 </p><p><b>Bold text..</b>
6252 </p><p>..spanning two paragraphs (should not work).<b></b>
6253 </p><p><b>Bold tag left open</b>
6254 </p><p><i>Italic tag left open</i>
6255 </p><p>Normal text.
6256 </p>
6257 <!-- Unmatching number of opening, closing tags: -->
6258 <p><b>This year'</b>s election <i>should</i> beat <b>last year'</b>s.
6259 </p><p><i>Tom<b>s car is bigger than </b></i><b>Susan</b>s.
6260 </p><p>Plain <i>italic'</i>s plain
6261 </p>
6262 !! end
6263
6264 ###
6265 ### Tables
6266 ###
6267 ### some content taken from http://meta.wikimedia.org/wiki/MediaWiki_User%27s_Guide:_Using_tables
6268 ###
6269
6270 # This should not produce <table></table> as <table><tr><td></td></tr></table>
6271 # is the bare minimum required by the spec, see:
6272 # https://www.w3.org/TR/xhtml-modularization/dtd_module_defs.html#a_module_Basic_Tables
6273 # Parsoid team replies: empty table tags are legal in HTML5
6274 !! test
6275 A table with no data.
6276 !! options
6277 parsoid=wt2html
6278 !! wikitext
6279 {||}
6280 !! html/php
6281
6282 !! html/parsoid
6283 <table></table>
6284
6285 !! end
6286
6287 !! test
6288 A table with stray table end tags on start tag line (wt2html)
6289 !! options
6290 parsoid=wt2html
6291 !! wikitext
6292 {|style="color: red;"|}
6293
6294 {|style="color: red;" |}
6295 |foo
6296 |}
6297
6298 {|style="color: red;"|} id="foo"
6299 |foo
6300 |}
6301
6302 {|style="color: red;" |} id="foo"
6303 |foo
6304 |}
6305 !! html/php+tidy
6306 <table style="color: red;">
6307
6308 </table><table style="color: red;">
6309 <tbody><tr>
6310 <td>foo
6311 </td></tr></tbody></table>
6312 <table style="color: red;" id="foo">
6313 <tbody><tr>
6314 <td>foo
6315 </td></tr></tbody></table>
6316 <table style="color: red;" id="foo">
6317 <tbody><tr>
6318 <td>foo
6319 </td></tr></tbody></table>
6320 !! html/parsoid
6321 <table style="color: red;"></table>
6322
6323 <table style="color: red;">
6324 <tbody><tr>
6325 <td>foo</td>
6326 </tr></tbody>
6327 </table>
6328
6329 <table style="color: red;" id="foo">
6330 <tbody><tr>
6331 <td>foo</td>
6332 </tr></tbody>
6333 </table>
6334
6335 <table style="color: red;" id="foo">
6336 <tbody><tr>
6337 <td>foo</td>
6338 </tr></tbody>
6339 </table>
6340
6341 !! end
6342
6343 !! test
6344 A table with no data (take 2)
6345 !! wikitext
6346 {|
6347 |}
6348 !! html/parsoid
6349 <table></table>
6350 !! end
6351
6352 # A table with nothing but a caption is invalid XHTML, we might want to render
6353 # this as <p>caption</p>
6354 # Parsoid team replies: table with only a caption is legal in HTML5
6355 !! test
6356 A table with nothing but a caption
6357 !! wikitext
6358 {|
6359 |+caption
6360 |}
6361 !! html/php
6362 <table>
6363 <caption>caption
6364 </caption><tr><td></td></tr></table>
6365
6366 !! html/parsoid
6367 <table><caption>caption</caption></table>
6368 !! end
6369
6370 !! test
6371 A table with caption with default-spaced attributes and a table row
6372 !! wikitext
6373 {|
6374 |+ style="color: red;" |caption1
6375 |-
6376 |foo
6377 |}
6378 !! html
6379 <table>
6380 <caption style="color: red;">caption1
6381 </caption>
6382 <tr>
6383 <td>foo
6384 </td></tr></table>
6385
6386 !! end
6387
6388 !! test
6389 A table with captions with non-default spaced attributes and a table row
6390 !! wikitext
6391 {|
6392 |+style="color: red;"|caption2
6393 |+ style="color: red;"|caption3
6394 |-
6395 |foo
6396 |}
6397 !! html
6398 <table>
6399 <caption style="color: red;">caption2
6400 </caption>
6401 <caption style="color: red;">caption3
6402 </caption>
6403 <tr>
6404 <td>foo
6405 </td></tr></table>
6406
6407 !! end
6408
6409 !! test
6410 Table td-cell syntax variations
6411 !! wikitext
6412 {|
6413 |foo bar foo|baz
6414 |foo bar foo||baz
6415 |style='color:red;'|baz
6416 |style='color:red;'||baz
6417 |}
6418 !! html
6419 <table>
6420 <tr>
6421 <td>baz
6422 </td>
6423 <td>foo bar foo</td>
6424 <td>baz
6425 </td>
6426 <td style="color:red;">baz
6427 </td>
6428 <td>style='color:red;'</td>
6429 <td>baz
6430 </td></tr></table>
6431
6432 !! end
6433
6434 !! test
6435 Simple table
6436 !! wikitext
6437 {|
6438 |1||2
6439 |-
6440 |3||4
6441 |}
6442 !! html
6443 <table>
6444 <tr>
6445 <td>1</td>
6446 <td>2
6447 </td></tr>
6448 <tr>
6449 <td>3</td>
6450 <td>4
6451 </td></tr></table>
6452
6453 !! end
6454
6455 !! test
6456 Simple table but with multiple dashes for row wikitext
6457 !! wikitext
6458 {|
6459 |foo
6460 |-----
6461 |bar
6462 |}
6463 !! html
6464 <table>
6465 <tr>
6466 <td>foo
6467 </td></tr>
6468 <tr>
6469 <td>bar
6470 </td></tr></table>
6471
6472 !! end
6473
6474 !! test
6475 Multiplication table
6476 !! wikitext
6477 {| border="1" cellpadding="2"
6478 |+Multiplication table
6479 |-
6480 !&times;!!1!!2!!3
6481 |-
6482 !1
6483 |1||2||3
6484 |-
6485 !2
6486 |2||4||6
6487 |-
6488 !3
6489 |3||6||9
6490 |-
6491 !4
6492 |4||8||12
6493 |-
6494 !5
6495 |5||10||15
6496 |}
6497 !! html
6498 <table border="1" cellpadding="2">
6499 <caption>Multiplication table
6500 </caption>
6501 <tr>
6502 <th>&#215;</th>
6503 <th>1</th>
6504 <th>2</th>
6505 <th>3
6506 </th></tr>
6507 <tr>
6508 <th>1
6509 </th>
6510 <td>1</td>
6511 <td>2</td>
6512 <td>3
6513 </td></tr>
6514 <tr>
6515 <th>2
6516 </th>
6517 <td>2</td>
6518 <td>4</td>
6519 <td>6
6520 </td></tr>
6521 <tr>
6522 <th>3
6523 </th>
6524 <td>3</td>
6525 <td>6</td>
6526 <td>9
6527 </td></tr>
6528 <tr>
6529 <th>4
6530 </th>
6531 <td>4</td>
6532 <td>8</td>
6533 <td>12
6534 </td></tr>
6535 <tr>
6536 <th>5
6537 </th>
6538 <td>5</td>
6539 <td>10</td>
6540 <td>15
6541 </td></tr></table>
6542
6543 !! end
6544
6545 !! test
6546 Accept "||" in table headings
6547 !! wikitext
6548 {|
6549 !h1||h2
6550 |}
6551 !! html
6552 <table>
6553 <tr>
6554 <th>h1</th>
6555 <th>h2
6556 </th></tr></table>
6557
6558 !! end
6559
6560 !! test
6561 Accept "!!" in table data
6562 !! wikitext
6563 {|
6564 |Foo!!||
6565 |}
6566 !! html
6567 <table>
6568 <tr>
6569 <td>Foo!!</td>
6570 <td>
6571 </td></tr></table>
6572
6573 !! html/parsoid
6574 <table>
6575 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'> Foo!! </td><td data-parsoid='{"stx":"row","autoInsertedEnd":true}'></td></tr>
6576 </tbody></table>
6577 !! end
6578
6579 !! test
6580 Accept "||" in indented table headings
6581 !! wikitext
6582 :{|
6583 !h1||h2
6584 |}
6585 !! html
6586 <dl><dd><table>
6587 <tr>
6588 <th>h1</th>
6589 <th>h2
6590 </th></tr></table></dd></dl>
6591
6592 !! end
6593
6594 !! test
6595 Accept "!!" in templates
6596 !! wikitext
6597 {|
6598 !a {{echo|b!!c}}
6599 |}
6600 !! html/php
6601 <table>
6602 <tr>
6603 <th>a b</th>
6604 <th>c
6605 </th></tr></table>
6606
6607 !! html/parsoid
6608 <table>
6609 <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>
6610 !! end
6611
6612 !! test
6613 Accept "!!" in table headings after newline
6614 !! wikitext
6615 {|
6616 !a
6617 b!!c
6618 |}
6619 !! html/php
6620 <table>
6621 <tr>
6622 <th>a
6623 <p>b!!c
6624 </p>
6625 </th></tr></table>
6626
6627 !! html/parsoid
6628 <table>
6629 <tbody><tr><th>a
6630 <p>b!!c</p></th></tr>
6631 </tbody></table>
6632 !! end
6633
6634 !! test
6635 Accept "!!" in table data of mixed wikitext / html syntax
6636 !! wikitext
6637 {|
6638 !a
6639 <tr><td>b!!c</td></tr>
6640 |}
6641 !! html/php+tidy
6642 <table>
6643 <tbody><tr>
6644 <th>a
6645 </th></tr><tr><td>b!!c</td></tr>
6646 </tbody></table>
6647 !! html/parsoid
6648 <table>
6649 <tbody><tr><th>a</th></tr>
6650 <tr data-parsoid='{"stx":"html"}'><td data-parsoid='{"stx":"html"}'>b!!c</td></tr>
6651 </tbody></table>
6652 !! end
6653
6654 !! test
6655 Accept empty attributes in td/th cells (td/th cells starting with leading ||)
6656 !! wikitext
6657 {|
6658 !|h1
6659 ||a
6660 |}
6661 !! html
6662 <table>
6663 <tr>
6664 <th>h1
6665 </th>
6666 <td>a
6667 </td></tr></table>
6668
6669 !! end
6670
6671 !!test
6672 Accept "| !" at start of line in tables (ignore !-attribute)
6673 !! wikitext
6674 {|
6675 |-
6676 |!style="color:red"|bar
6677 |}
6678 !! html
6679 <table>
6680
6681 <tr>
6682 <td>bar
6683 </td></tr></table>
6684
6685 !!end
6686
6687 !!test
6688 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 +/-
6689 !! wikitext
6690 {|
6691 |-
6692 |style='color:red;'|+1
6693 |style='color:blue;'|-1
6694 |-
6695 |1||2||3
6696 |1||+2||-3
6697 |-
6698 | +1
6699 | -1
6700 |}
6701 !! html
6702 <table>
6703
6704 <tr>
6705 <td style="color:red;">+1
6706 </td>
6707 <td style="color:blue;">-1
6708 </td></tr>
6709 <tr>
6710 <td>1</td>
6711 <td>2</td>
6712 <td>3
6713 </td>
6714 <td>1</td>
6715 <td>+2</td>
6716 <td>-3
6717 </td></tr>
6718 <tr>
6719 <td>+1
6720 </td>
6721 <td>-1
6722 </td></tr></table>
6723
6724 !!end
6725
6726 !! test
6727 Table rowspan
6728 !! wikitext
6729 {| border=1
6730 |Cell 1, row 1
6731 |rowspan=2|Cell 2, row 1 (and 2)
6732 |Cell 3, row 1
6733 |-
6734 |Cell 1, row 2
6735 |Cell 3, row 2
6736 |}
6737 !! html
6738 <table border="1">
6739 <tr>
6740 <td>Cell 1, row 1
6741 </td>
6742 <td rowspan="2">Cell 2, row 1 (and 2)
6743 </td>
6744 <td>Cell 3, row 1
6745 </td></tr>
6746 <tr>
6747 <td>Cell 1, row 2
6748 </td>
6749 <td>Cell 3, row 2
6750 </td></tr></table>
6751
6752 !! end
6753
6754 !! test
6755 Nested table
6756 !! wikitext
6757 {| border=1
6758 | &alpha;
6759 |
6760 {| bgcolor=#ABCDEF border=2
6761 |nested
6762 |-
6763 |table
6764 |}
6765 |the original table again
6766 |}
6767 !! html
6768 <table border="1">
6769 <tr>
6770 <td>&#945;
6771 </td>
6772 <td>
6773 <table bgcolor="#ABCDEF" border="2">
6774 <tr>
6775 <td>nested
6776 </td></tr>
6777 <tr>
6778 <td>table
6779 </td></tr></table>
6780 </td>
6781 <td>the original table again
6782 </td></tr></table>
6783
6784 !! end
6785
6786 !! test
6787 Invalid attributes in table cell (T3830)
6788 !! wikitext
6789 {|
6790 |Cell:|broken
6791 |}
6792 !! html
6793 <table>
6794 <tr>
6795 <td>broken
6796 </td></tr></table>
6797
6798 !! end
6799
6800 !! test
6801 Table cell attributes: Pipes protected by nowikis should be treated as a plain character
6802 !! wikitext
6803 {|
6804 |title="foo" |bar
6805 |title="foo<nowiki>|</nowiki>" |bar
6806 |title="foo<nowiki>|</nowiki>" bar
6807 |}
6808 !! html/php
6809 <table>
6810 <tr>
6811 <td title="foo">bar
6812 </td>
6813 <td title="foo&#124;">bar
6814 </td>
6815 <td>title="foo|" bar
6816 </td></tr></table>
6817
6818 !! html/parsoid
6819 <table>
6820 <tbody><tr><td title="foo">bar</td>
6821 <td title="foo|" data-parsoid='{"a":{"title":"foo|"},"sa":{"title":"foo&lt;nowiki>|&lt;/nowiki>"},"autoInsertedEnd":true}'>bar</td>
6822 <td> title="foo<span typeof="mw:Nowiki">|</span>" bar</td></tr>
6823 </tbody></table>
6824 !! end
6825
6826 # See: http://lists.wikimedia.org/mailman/htdig/wikitech-l/2006-April/022293.html
6827 # N.B. The "|}" to close the table is missing from the input, so parsoid's
6828 # *2wt modes will fail.
6829 !! test
6830 Table security: embedded pipes
6831 !! options
6832 parsoid=wt2html,html2html
6833 !! wikitext
6834 {|
6835 | |[ftp://|x||]" onmouseover="alert(document.cookie)">test
6836 !! html/php
6837 <table>
6838 <tr>
6839 <td>[<a rel="nofollow" class="external free" href="ftp://%7Cx">ftp://%7Cx</a></td>
6840 <td>]" onmouseover="alert(document.cookie)"&gt;test
6841 </td>
6842 </tr>
6843 </table>
6844
6845 !! html/parsoid
6846 <table><tbody>
6847 <tr>
6848 <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>
6849 !! end
6850
6851 !! test
6852 Element attributes with double ! should not be broken up by <th>
6853 !! wikitext
6854 {|
6855 !hi <div class="!!">ha</div> ho
6856 |}
6857 !! html/php
6858 <table>
6859 <tr>
6860 <th>hi <div class="!!">ha</div> ho
6861 </th></tr></table>
6862
6863 !! html/parsoid
6864 <table>
6865 <tbody><tr><th>hi <div class="!!" data-parsoid='{"stx":"html"}'>ha</div> ho</th></tr>
6866 </tbody></table>
6867 !! end
6868
6869 !! test
6870 ! and || in element attributes should not be parsed as <th>/<td>
6871 !! wikitext
6872 {|
6873 |<div style="color: red !important;" data-contrived="put this here ||">hi</div>
6874 |}
6875 !! html/php
6876 <table>
6877 <tr>
6878 <td><div style="color: red !important;" data-contrived="put this here &#124;&#124;">hi</div>
6879 </td></tr></table>
6880
6881 !! html/parsoid
6882 <table>
6883 <tbody><tr><td><div style="color: red !important;" data-contrived="put this here ||" data-parsoid='{"stx":"html"}'>hi</div></td></tr>
6884 </tbody></table>
6885 !! end
6886
6887 # FIXME: The output seems broken. Filed as T110268.
6888 !! test
6889 ! and || in td attributes should not be parsed as <th>/<td>
6890 !! options
6891 parsoid=wt2html
6892 !! wikitext
6893 {|
6894 |style="color: red !important;" data-contrived="put this here ||"|foo
6895 |}
6896 !! html/php
6897 <table>
6898 <tr>
6899 <td>style="color: red !important;" data-contrived="put this here</td>
6900 <td>foo
6901 </td></tr></table>
6902
6903 !! html/parsoid
6904 <table>
6905 <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>
6906 </tbody></table>
6907 !! end
6908
6909 !! test
6910 Break on | in element attribute in template
6911 !! options
6912 parsoid=wt2html,html2html
6913 !! wikitext
6914 {{echo|1=<div class="hi|ho">ha</div>}}
6915 !! html/php
6916 <p>ho"&gt;ha&lt;/div&gt;
6917 </p>
6918 !! html/parsoid
6919 <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>
6920 !! end
6921
6922 !! test
6923 Break on | in element attribute name in template
6924 !! wikitext
6925 {{echo|<div cla|ss="hiho">ha</div>}}
6926 !! html/parsoid
6927 <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>
6928 !! end
6929
6930 !! test
6931 Don't break on | in extension attribute in template
6932 !! wikitext
6933 {{echo|<ref name="hi|ho">ha</ref>}}
6934
6935 <references />
6936 !! html/parsoid
6937 <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>
6938
6939 <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>
6940 !! end
6941
6942 ## We don't support roundtripping of these attributes in Parsoid.
6943 ## Selective serialization takes care of preventing dirty diffs.
6944 ## But, on edits, we dirty-diff the invalid attribute text.
6945 !! test
6946 Invalid text in table attributes should be discarded
6947 !! options
6948 parsoid=wt2html
6949 !! wikitext
6950 {| <span>boo</span> style='border:1px solid black'
6951 | <span>boo</span> style='color:blue' |1
6952 |<span>boo</span> style='color:blue'|2
6953 |}
6954 !! html/php
6955 <table style="border:1px solid black">
6956 <tr>
6957 <td style="color:blue">1
6958 </td>
6959 <td style="color:blue">2
6960 </td></tr></table>
6961
6962 !! html/parsoid
6963 <table style="border:1px solid black">
6964 <tr>
6965 <td style="color:blue">1</td>
6966 <td style="color:blue">2</td>
6967 </tr>
6968 </table>
6969 !! end
6970
6971 !! test
6972 Invalid text in table attributes should be preserved by selective serializer
6973 !! options
6974 parsoid={
6975 "modes": ["selser"],
6976 "changes": [
6977 ["td:first-child", "text", "abc"],
6978 ["td + td", "text", "xyz"]
6979 ]
6980 }
6981 !! wikitext
6982 {| <span>boo</span> style='border:1px solid black'
6983 | <span>boo</span> style='color:blue' | 1
6984 |<span>boo</span> style='color:blue'| 2
6985 |}
6986 !! wikitext/edited
6987 {| <span>boo</span> style='border:1px solid black'
6988 | <span>boo</span> style='color:blue' | abc
6989 |<span>boo</span> style='color:blue'| xyz
6990 |}
6991 !! end
6992
6993 !! test
6994 1. Template-generated table cell attributes and cell content
6995 !! wikitext
6996 {|
6997 |{{table_attribs}}
6998 | {{table_attribs}}
6999 || {{table_attribs_5}}
7000 | <!--foo--> <!--bar--> <!--baz--> {{table_attribs}}
7001 |align=center {{table_attribs}}
7002 | <!--foo--> align=center <!--bar--> {{table_attribs}}
7003 |}
7004 !! html
7005 <table>
7006 <tr>
7007 <td style="color:red;">Foo
7008 </td>
7009 <td style="color:red;">Foo
7010 </td>
7011 <td>style="color:red;"</td>
7012 <td>Bar
7013 </td>
7014 <td style="color:red;">Foo
7015 </td>
7016 <td align="center" style="color:red;">Foo
7017 </td>
7018 <td align="center" style="color:red;">Foo
7019 </td></tr></table>
7020
7021 !! end
7022
7023 !! test
7024 2. Template-generated table cell attributes and cell content
7025 !! wikitext
7026 {|
7027 |{{table_attribs_2}}
7028 |}
7029 !! html/php
7030 <table>
7031 <tr>
7032 <td style="color:red;">Foo
7033 </td>
7034 <td>Bar</td>
7035 <td>Baz
7036 </td></tr></table>
7037
7038 !! html/parsoid
7039 <table>
7040 <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>
7041 <td about="#mwt1">Bar</td><td about="#mwt1">Baz</td></tr>
7042 </tbody></table>
7043 !! end
7044
7045 !! test
7046 3. Template-generated table cell attributes and cell content
7047 !! wikitext
7048 {|
7049 !align=center {{table_header_cells}}
7050 |-
7051 |align=center {{table_cells}}
7052 |}
7053 !! html/php
7054 <table>
7055 <tr>
7056 <th align="center" style="color:red;">Foo</th>
7057 <th style="color:red;"><i>Bar</i></th>
7058 <th style="color:brown;"><i>Foo</i> and Baz
7059 </th></tr>
7060 <tr>
7061 <td align="center" style="color:red;">Foo</td>
7062 <td style="color:red;"><i>Bar</i></td>
7063 <td style="color:brown;"><i>Foo</i> and Baz
7064 </td></tr></table>
7065
7066 !! html/parsoid
7067 <table>
7068 <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>
7069 <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>
7070 </tbody></table>
7071 !! end
7072
7073 !! test
7074 4. Template-generated table cell attributes and cell content inside a templated table
7075 !! wikitext
7076 {{tbl-start}}
7077 !align=center {{table_header_cells}}
7078 |-
7079 |align=center {{table_cells}}
7080 {{tbl-end}}
7081 !! html/php
7082 <table>
7083 <tr>
7084 <th align="center" style="color:red;">Foo</th>
7085 <th style="color:red;"><i>Bar</i></th>
7086 <th style="color:brown;"><i>Foo</i> and Baz
7087 </th></tr>
7088 <tr>
7089 <td align="center" style="color:red;">Foo</td>
7090 <td style="color:red;"><i>Bar</i></td>
7091 <td style="color:brown;"><i>Foo</i> and Baz
7092 </td></tr></table>
7093
7094 !! html/parsoid
7095 <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}}]}'>
7096 <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>
7097 <tr>
7098 <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>
7099 </tbody></table>
7100 !! end
7101
7102 ## Edge case fix to prevent future regressions
7103 !! test
7104 T107652: <ref>s in templates that also generate table cell attributes should be rendered properly
7105 !! wikitext
7106 {|
7107 |{{table_attribs_7}}
7108 |}
7109 <references />
7110 !! html/parsoid
7111 <table>
7112 <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>
7113 </tbody></table>
7114 <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>
7115 !! end
7116
7117 !! test
7118 Table with row followed by newlines and table heading
7119 !! options
7120 parsoid=wt2html,html2html
7121 !! wikitext
7122 {|
7123 |-
7124
7125 !foo
7126 |}
7127 !! html/*
7128 <table>
7129
7130
7131 <tr>
7132 <th>foo
7133 </th></tr></table>
7134
7135 !! end
7136
7137 !! test
7138 Table with empty line following the start tag
7139 !! options
7140 parsoid=wt2html,html2html
7141 !! wikitext
7142 {|
7143
7144 |-
7145 |foo
7146 |}
7147 !! html/*
7148 <table>
7149
7150
7151 <tr>
7152 <td>foo
7153 </td></tr></table>
7154
7155 !! end
7156
7157 !! test
7158 Table attributes with empty value
7159 !! options
7160 parsoid=wt2html,html2html
7161 !! wikitext
7162 {|
7163 | style=|hello
7164 |}
7165 !! html/php
7166 <table>
7167 <tr>
7168 <td style="">hello
7169 </td></tr></table>
7170
7171 !! html/parsoid
7172 <table>
7173 <tbody><tr><td style="">hello</td></tr>
7174 </tbody></table>
7175 !! end
7176
7177 !! test
7178 Wikitext table with a lot of comments
7179 !! wikitext
7180 {|
7181 <!-- c0 -->
7182 |foo
7183 <!-- c1 -->
7184 |-<!-- c2 -->
7185 <!-- c3 -->
7186 |<!-- c4 -->
7187 <!-- c5 -->
7188 |}
7189 !! html
7190 <table>
7191 <tr>
7192 <td>foo
7193 </td></tr>
7194 <tr>
7195 <td>
7196 </td></tr></table>
7197
7198 !! end
7199
7200 !! test
7201 Wikitext table comments represented in parsoid dom
7202 !! wikitext
7203 {|<!--c1--><!--c2-->
7204 |-<!--c3-->
7205 |x
7206 |}
7207 !! html/php+tidy
7208 <table>
7209
7210 <tbody><tr>
7211 <td>x
7212 </td></tr></tbody></table>
7213 !! html/parsoid
7214 <table><!--c1--><!--c2-->
7215 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'><!--c3-->
7216 <td data-parsoid='{"autoInsertedEnd":true}'>x</td></tr>
7217 </tbody></table>
7218 !! end
7219
7220 !! test
7221 Wikitext table with double-line table cell
7222 !! wikitext
7223 {|
7224 |a
7225 b
7226 |}
7227 !! html
7228 <table>
7229 <tr>
7230 <td>a
7231 <p>b
7232 </p>
7233 </td></tr></table>
7234
7235 !! end
7236
7237 !! test
7238 Table cell with a single comment
7239 !! wikitext
7240 {|
7241 |<!-- c1 -->
7242 |a
7243 |}
7244 !! html
7245 <table>
7246 <tr>
7247 <td>
7248 </td>
7249 <td>a
7250 </td></tr></table>
7251
7252 !! end
7253
7254 !! test
7255 Table-cell after a comment-only-empty-line
7256 !! wikitext
7257 {|
7258 |a
7259 <!--c1-->
7260 <!--c2-->|b
7261 |}
7262 !! html
7263 <table>
7264 <tr>
7265 <td>a
7266 </td>
7267 <td>b
7268 </td></tr></table>
7269
7270 !! html/parsoid
7271 <table>
7272 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'>a</td>
7273 <!--c1-->
7274 <!--c2--><td data-parsoid='{"autoInsertedEnd":true}'>b</td></tr>
7275 </tbody></table>
7276
7277 !! end
7278
7279 !! test
7280 Build table with {{!}}
7281 !! wikitext
7282 {{{!}} class="wikitable"
7283 !header
7284 !second header
7285 {{!}}- style="color:red;"
7286 {{!}}data{{!}}{{!}} style="color:red;" {{!}}second data
7287 {{!}}}
7288 !! html
7289 <table class="wikitable">
7290 <tr>
7291 <th>header
7292 </th>
7293 <th>second header
7294 </th></tr>
7295 <tr style="color:red;">
7296 <td>data</td>
7297 <td style="color:red;">second data
7298 </td></tr></table>
7299
7300 !! end
7301
7302 !! test
7303 Build table with pipe as data
7304 !! wikitext
7305 {| class="wikitable"
7306 !header
7307 !second header
7308 |- style="color:red;"
7309 |data|| style="color:red;" |second data
7310 |-
7311 | style="color:red;" |data with | || style="color:red;" | second data with |
7312 |-
7313 ||data with | |||second data with |
7314 |}
7315 !! html
7316 <table class="wikitable">
7317 <tr>
7318 <th>header
7319 </th>
7320 <th>second header
7321 </th></tr>
7322 <tr style="color:red;">
7323 <td>data</td>
7324 <td style="color:red;">second data
7325 </td></tr>
7326 <tr>
7327 <td style="color:red;">data with |</td>
7328 <td style="color:red;">second data with |
7329 </td></tr>
7330 <tr>
7331 <td>data with |</td>
7332 <td>second data with |
7333 </td></tr></table>
7334
7335 !! end
7336
7337 !! test
7338 Build table with wikilink
7339 !! wikitext
7340 {| class="wikitable"
7341 !header||second header
7342 |- style="color:red;"
7343 |data [[Main Page|linktext]]||second data [[Main Page|linktext]]
7344 |-
7345 |data||second data [[Main Page|link|text with pipe]]
7346 |}
7347 !! html
7348 <table class="wikitable">
7349 <tr>
7350 <th>header</th>
7351 <th>second header
7352 </th></tr>
7353 <tr style="color:red;">
7354 <td>data <a href="/wiki/Main_Page" title="Main Page">linktext</a></td>
7355 <td>second data <a href="/wiki/Main_Page" title="Main Page">linktext</a>
7356 </td></tr>
7357 <tr>
7358 <td>data</td>
7359 <td>second data <a href="/wiki/Main_Page" title="Main Page">link|text with pipe</a>
7360 </td></tr></table>
7361
7362 !! end
7363
7364 # The expected HTML structure in this test is debatable. The PHP parser does
7365 # not parse this kind of table at all. The main focus for Parsoid is on
7366 # round-tripping, so this output is ok for now. TODO: revisit!
7367 !! test
7368 Wikitext table with html-syntax row
7369 !! wikitext
7370 {|
7371 |-
7372 <td>foo</td>
7373 |}
7374 !! html/parsoid
7375 <table>
7376 <tbody>
7377 <tr>
7378 <td>foo</td></tr></tbody></table>
7379 !! end
7380
7381 ## Remex doesn't account for fostered content.
7382 !! test
7383 Fostered content in tables: Plain text
7384 !! options
7385 parsoid=wt2html
7386 !! wikitext
7387 {|
7388 |-
7389 a
7390 |}
7391 !! html/php
7392 <table>
7393
7394 a
7395 </table>
7396
7397 !! html/php+tidy
7398
7399
7400 a
7401 <table></table>
7402 !! html/parsoid
7403 <p data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true}'>
7404 a</p>
7405 <table>
7406 <tbody><tr class="mw-empty-elt" data-parsoid='{"startTagSrc":"|-"}'></tr></tbody></table>
7407 !! end
7408
7409 !! test
7410 Fostered content in tables: Lists
7411 !! options
7412 parsoid=wt2html,html2html
7413 !! wikitext
7414 {|
7415 |-
7416 *a
7417 |}
7418 !! html/php
7419 <table>
7420
7421 <ul><li>a</li></ul>
7422 </table>
7423
7424 !! html/php+tidy
7425 <ul><li>a</li></ul><table>
7426
7427
7428 </table>
7429 !! html/parsoid
7430 <ul data-parsoid='{"fostered":true,"autoInsertedEnd":true}'><li>a</li></ul><table>
7431 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
7432
7433 </tr></tbody></table>
7434 !! end
7435
7436 !! test
7437 Template generated table cell with attributes
7438 !! wikitext
7439 {|
7440 |-
7441 {{table_attribs_4}} ||a||b
7442 |}
7443 !! html/php+tidy
7444 <table>
7445
7446 <tbody><tr>
7447 <td style="background-color:#DC241f;" width="10px"></td>
7448 <td>a</td>
7449 <td>b
7450 </td></tr></tbody></table>
7451 !! html/parsoid
7452 <table>
7453 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
7454 <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>
7455 !! end
7456
7457 !! test
7458 Parsoid: Round-trip tables directly followed by content (T53219)
7459 !! options
7460 parsoid=wt2html,wt2wt
7461 !! wikitext
7462 {|
7463 |foo
7464 |} bar
7465
7466 {|
7467 |baz
7468 |}<b>quux</b>
7469 !! html+tidy
7470 <table>
7471 <tbody><tr>
7472 <td>foo
7473 </td></tr></tbody></table><p> bar
7474 </p><table>
7475 <tbody><tr>
7476 <td>baz
7477 </td></tr></tbody></table><p><b>quux</b>
7478 </p>
7479 !! end
7480
7481 !! test
7482 Parsoid: Default to a newline after tables in new content (T53219)
7483 !! options
7484 parsoid=html2wt
7485 !! html/parsoid
7486 <table><tbody>
7487 <tr><td>foo</td></tr></tbody></table> bar
7488 <table><tbody>
7489 <tr><td>baz</td></tr></tbody></table><b>quux</b>
7490 !! wikitext
7491 {|
7492 |foo
7493 |}
7494 <nowiki> </nowiki>bar
7495 {|
7496 |baz
7497 |}
7498 '''quux'''
7499 !! end
7500
7501 !! test
7502 Parsoid: Row-syntax table headings followed by comment & table cells
7503 !! options
7504 parsoid=wt2html,wt2wt
7505 !! wikitext
7506 {|
7507 !foo||bar
7508 <!-- foo --> ||baz||quux
7509 |}
7510 !! html/php
7511 <table>
7512 <tr>
7513 <th>foo</th>
7514 <th>bar
7515 </th>
7516 <td>baz</td>
7517 <td>quux
7518 </td></tr></table>
7519
7520 !! html/parsoid
7521 <table>
7522 <tbody><tr><th>foo</th><th>bar
7523 <!-- foo --></th><td> baz </td><td>quux</td></tr>
7524 </tbody></table>
7525 !! end
7526
7527 !!test
7528 Parsoid: Recover better from broken table attributes
7529 !!options
7530 parsoid=wt2html
7531 !!wikitext
7532 {| class="foo
7533 | class="bar" |
7534 foo
7535 |}
7536 !!html/php+tidy
7537 <table class="foo">
7538 <tbody><tr>
7539 <td class="bar">
7540 <p>foo
7541 </p>
7542 </td></tr></tbody></table>
7543 !!html/parsoid
7544 <table class="foo">
7545 <tr>
7546 <td class="bar">
7547 <p>foo</p></td></tr>
7548 </tbody></table>
7549 !!end
7550
7551 # Note: PHP parser omits empty rows
7552 !! test
7553 Tables: Digest broken attributes on table and tr tag
7554 !! options
7555 parsoid=wt2html
7556 !! wikitext
7557 {| || |} ++
7558 |- || || ++ --
7559 |- > [
7560 |}
7561 !! html/php+tidy
7562 <table>
7563
7564
7565 </table>
7566 !! html/parsoid
7567 <table>
7568 <tbody>
7569 <tr class='mw-empty-elt'></tr>
7570 <tr class='mw-empty-elt'></tr>
7571 </tbody></table>
7572 !! end
7573
7574 !! test
7575 Table with missing opening <tr> tag
7576 !! options
7577 parsoid=wt2html,wt2wt
7578 !! wikitext
7579 <table>
7580 <td>foo</td>
7581 </tr>
7582 </table>
7583 !! html+tidy
7584 <table>
7585 <tbody><tr><td>foo</td>
7586 </tr>
7587 </tbody></table>
7588 !! end
7589
7590 # T137406: Whitespace in the HTML
7591 !! test
7592 1. Generate correct wikitext for tables with thead/tbody/tfoot
7593 !! options
7594 parsoid=html2wt
7595 !! html/parsoid
7596 <table>
7597 <caption>Test</caption>
7598 <thead>
7599 <tr>
7600 <th>Month</th>
7601 <th>Savings</th>
7602 </tr>
7603 </thead>
7604 <tbody>
7605 <tr>
7606 <td>January</td>
7607 <td>$100</td>
7608 </tr>
7609 <tr>
7610 <td>February</td>
7611 <td>$80</td>
7612 </tr>
7613 </tbody>
7614 <tfoot>
7615 <tr>
7616 <td>Sum</td>
7617 <td>$180</td>
7618 </tr>
7619 </tfoot>
7620 </table>
7621 !! wikitext
7622 {|
7623 |+Test
7624 !Month
7625 !Savings
7626 |-
7627 |January
7628 |$100
7629 |-
7630 |February
7631 |$80
7632 |-
7633 |Sum
7634 |$180
7635 |}
7636 !! html/php+tidy
7637 <table>
7638 <caption>Test
7639 </caption>
7640 <tbody><tr>
7641 <th>Month
7642 </th>
7643 <th>Savings
7644 </th></tr>
7645 <tr>
7646 <td>January
7647 </td>
7648 <td>$100
7649 </td></tr>
7650 <tr>
7651 <td>February
7652 </td>
7653 <td>$80
7654 </td></tr>
7655 <tr>
7656 <td>Sum
7657 </td>
7658 <td>$180
7659 </td></tr></tbody></table>
7660 !! end
7661
7662 # T137406: No whitespace in the HTML
7663 !! test
7664 2. Generate correct wikitext for tables with thead/tbody/tfoot
7665 !! options
7666 parsoid=html2wt
7667 !! html/parsoid
7668 <table><thead><tr><th>heading</th></tr></thead><tbody><tr><td>foo</td></tr></tbody></table>
7669 !! wikitext
7670 {|
7671 !heading
7672 |-
7673 |foo
7674 |}
7675 !! end
7676
7677 !! test
7678 Wikitext tables can be nested inside HTML tables
7679 !! options
7680 parsoid=html2wt
7681 !! html/parsoid
7682 <table data-parsoid='{"stx":"html"}'>
7683 <tr><td>
7684 <table>
7685 <tr><td>foo</td></tr>
7686 </table>
7687 </td></tr>
7688 </table>
7689 !! wikitext
7690 <table>
7691 <tr><td>
7692 {|
7693 |foo
7694 |}
7695 </td></tr>
7696 </table>
7697 !! html/php+tidy
7698 <table>
7699 <tbody><tr><td>
7700 <table>
7701 <tbody><tr>
7702 <td>foo
7703 </td></tr></tbody></table>
7704 </td></tr>
7705 </tbody></table>
7706 !! end
7707
7708 ###
7709 ### Internal links
7710 ###
7711 !! test
7712 Plain link, capitalized
7713 !! wikitext
7714 [[Main Page]]
7715 !! html
7716 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
7717 </p>
7718 !! end
7719
7720 !! test
7721 Plain link, uncapitalized
7722 !! wikitext
7723 [[main Page]]
7724 !! html
7725 <p><a href="/wiki/Main_Page" title="Main Page">main Page</a>
7726 </p>
7727 !! end
7728
7729 !! test
7730 Piped link
7731 !! wikitext
7732 [[Main Page|The Main Page]]
7733 !! html
7734 <p><a href="/wiki/Main_Page" title="Main Page">The Main Page</a>
7735 </p>
7736 !! end
7737
7738 !! test
7739 Piped link with comment in link text
7740 !! wikitext
7741 [[Main Page|The Main<!--front--> Page]]
7742 !! html
7743 <p><a href="/wiki/Main_Page" title="Main Page">The Main Page</a>
7744 </p>
7745 !! end
7746
7747 !! test
7748 Piped link with multiple pipe characters in link text
7749 !! wikitext
7750 [[Main Page||The|Main|Page|]]
7751 !! html/php
7752 <p><a href="/wiki/Main_Page" title="Main Page">|The|Main|Page|</a>
7753 </p>
7754 !! html/parsoid
7755 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">|The|Main|Page|</a></p>
7756 !! end
7757
7758 !! test
7759 Piped link with no link text
7760 !! wikitext
7761 [[Thomas Bek (bishop of St David's)|]]
7762 !! html/php
7763 <p>[[Thomas Bek (bishop of St David's)|]]
7764 </p>
7765 !! html/parsoid
7766 <p>[[Thomas Bek (bishop of St David's)|]]</p>
7767 !! end
7768
7769 !! test
7770 Piped link with empty link text
7771 !! wikitext
7772 [[Main Page|<nowiki/>]] - empty nowiki
7773 [[Main Page| ]] - empty space
7774 [[Main Page|&nbsp;]] - empty non breaking space
7775 !! html/php
7776 <p><a href="/wiki/Main_Page" title="Main Page"></a> - empty nowiki
7777 <a href="/wiki/Main_Page" title="Main Page"> </a> - empty space
7778 <a href="/wiki/Main_Page" title="Main Page">&#160;</a> - empty non breaking space
7779 </p>
7780 !! html/parsoid
7781 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page"><span typeof="mw:Nowiki"></span></a> - empty nowiki
7782 <a rel="mw:WikiLink" href="./Main_Page" title="Main Page"> </a> - empty space
7783 <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>
7784 !! end
7785
7786 !! test
7787 Broken link
7788 !! wikitext
7789 [[Zigzagzogzagzig]]
7790 !! html
7791 <p><a href="/index.php?title=Zigzagzogzagzig&amp;action=edit&amp;redlink=1" class="new" title="Zigzagzogzagzig (page does not exist)">Zigzagzogzagzig</a>
7792 </p>
7793 !! end
7794
7795 !! test
7796 Broken link with fragment
7797 !! wikitext
7798 [[Zigzagzogzagzig#zug]]
7799 !! html
7800 <p><a href="/index.php?title=Zigzagzogzagzig&amp;action=edit&amp;redlink=1" class="new" title="Zigzagzogzagzig (page does not exist)">Zigzagzogzagzig#zug</a>
7801 </p>
7802 !! end
7803
7804 !! test
7805 Special page link with fragment
7806 !! wikitext
7807 [[Special:Version#anchor]]
7808 !! html
7809 <p><a href="/wiki/Special:Version#anchor" title="Special:Version">Special:Version#anchor</a>
7810 </p>
7811 !! end
7812
7813 !! test
7814 Nonexistent special page link with fragment
7815 !! wikitext
7816 [[Special:ThisNameWillHopefullyNeverBeUsed#anchor]]
7817 !! html
7818 <p><a href="/wiki/Special:ThisNameWillHopefullyNeverBeUsed" class="new" title="Special:ThisNameWillHopefullyNeverBeUsed (page does not exist)">Special:ThisNameWillHopefullyNeverBeUsed#anchor</a>
7819 </p>
7820 !! end
7821
7822 !! test
7823 Link with prefix
7824 !! wikitext
7825 xxx[[main Page]], xxx[[Main Page]], Xxx[[main Page]] XXX[[main Page]], XXX[[Main Page]]
7826 !! html
7827 <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>
7828 </p>
7829 !! end
7830
7831 !! test
7832 Link with suffix
7833 !! wikitext
7834 [[Main Page]]xxx, [[Main Page]]XXX, [[Main Page]]!!!
7835 !! html
7836 <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>!!!
7837 </p>
7838 !! end
7839
7840 !! article
7841 prefixed article
7842 !! text
7843 Some text
7844 !! endarticle
7845
7846 !! test
7847 T45661: Piped links with identical prefixes
7848 !! wikitext
7849 [[prefixed article|prefixed articles with spaces]]
7850
7851 [[prefixed article|prefixed articlesaoeu]]
7852
7853 [[Main Page|Main Page test]]
7854 !! html
7855 <p><a href="/wiki/Prefixed_article" title="Prefixed article">prefixed articles with spaces</a>
7856 </p><p><a href="/wiki/Prefixed_article" title="Prefixed article">prefixed articlesaoeu</a>
7857 </p><p><a href="/wiki/Main_Page" title="Main Page">Main Page test</a>
7858 </p>
7859 !! end
7860
7861
7862 !! test
7863 Link with HTML entity in suffix / tail
7864 !! wikitext
7865 [[Main Page]]&quot;, [[Main Page]]&#97;
7866 !! html/php
7867 <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;
7868 </p>
7869 !! html/parsoid
7870 <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>
7871 !! end
7872
7873 !! test
7874 Link with 3 brackets
7875 !! wikitext
7876 [[[Main Page]]]
7877 Foo [[[Main Page]]]
7878 !! html
7879 <p>[[[Main Page]]]
7880 Foo [[[Main Page]]]
7881 </p>
7882 !! end
7883
7884 !! test
7885 Link with 4 brackets
7886 !! wikitext
7887 [[[[Main Page]]]]
7888 !! html
7889 <p>[[<a href="/wiki/Main_Page" title="Main Page">Main Page</a>]]
7890 </p>
7891 !! end
7892
7893 !! test
7894 Piped link with 3 brackets
7895 !! wikitext
7896 [[[main page|the main page]]]
7897 !! html
7898 <p>[[[main page|the main page]]]
7899 </p>
7900 !! end
7901
7902 !! test
7903 Piped link with extlink-like text
7904 !! wikitext
7905 [[Main Page|[bar]]]
7906 [[Main Page|This is a [bar]]]
7907 [[Main Page|[bar]]
7908 !! html/php
7909 <p><a href="/wiki/Main_Page" title="Main Page">[bar]</a>
7910 <a href="/wiki/Main_Page" title="Main Page">This is a [bar]</a>
7911 <a href="/wiki/Main_Page" title="Main Page">[bar</a>
7912 </p>
7913 !! html/parsoid
7914 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"piped"}'>[bar]</a>
7915 <a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"piped"}'>This is a [bar]</a>
7916 <a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"piped"}'>[bar</a></p>
7917 !! end
7918
7919 !! test
7920 Link with multiple pipes
7921 !! wikitext
7922 [[Main Page|The|Main|Page]]
7923 !! html
7924 <p><a href="/wiki/Main_Page" title="Main Page">The|Main|Page</a>
7925 </p>
7926 !! end
7927
7928 !! test
7929 Anchor containing a #. (T65430)
7930 !! config
7931 wgFragmentMode=[ 'html5', 'legacy' ]
7932 !! wikitext
7933 [[Main Page#And#Link]]
7934 !! html/php
7935 <p><a href="/wiki/Main_Page#And#Link" title="Main Page">Main Page#And#Link</a>
7936 </p>
7937 !! html/parsoid
7938 <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>
7939 !! end
7940
7941 !! test
7942 Link to namespaces
7943 !! wikitext
7944 [[Talk:Parser testing]], [[Meta:Disclaimers]]
7945 !! html
7946 <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>
7947 </p>
7948 !! end
7949
7950 !! test
7951 Link with space in namespace
7952 !! wikitext
7953 [[User talk:Foo bar]]
7954 !! html
7955 <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>
7956 </p>
7957 !! end
7958
7959 !! article
7960 MemoryAlpha:AlphaTest
7961 !! text
7962 This is an article in the MemoryAlpha namespace
7963 (which shadows the memoryalpha interwiki link).
7964 !! endarticle
7965
7966 !! test
7967 Namespace takes precedence over interwiki link (T53680)
7968 !! wikitext
7969 [[MemoryAlpha:AlphaTest]]
7970 !! html
7971 <p><a href="/wiki/MemoryAlpha:AlphaTest" title="MemoryAlpha:AlphaTest">MemoryAlpha:AlphaTest</a>
7972 </p>
7973 !! end
7974
7975 # The previous test doesn't work correctly in html2*, due to not recognizing the
7976 # link as an internal one. This one checks for the correct behavior.
7977 !! test
7978 Link to namespace preferred over interwiki with correct rel attribute
7979 !! options
7980 parsoid=html2wt,html2html
7981 !! html/parsoid
7982 <p><a rel="mw:WikiLink" href="./MemoryAlpha:AlphaTest" title="MemoryAlpha:AlphaTest">MemoryAlpha:AlphaTest</a></p>
7983 !! wikitext
7984 [[MemoryAlpha:AlphaTest]]
7985 !! end
7986
7987 !! test
7988 Piped link to namespace
7989 !! wikitext
7990 [[Meta:Disclaimers|The disclaimers]]
7991 !! html
7992 <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>
7993 </p>
7994 !! end
7995
7996 !! test
7997 Link containing }
7998 !! wikitext
7999 [[Usually caused by a typo (oops}]]
8000 !! html
8001 <p>[[Usually caused by a typo (oops}]]
8002 </p>
8003 !! end
8004
8005 !! article
8006 7% Solution
8007 !! text
8008 Just a test of an article title containing a percent.
8009 !! endarticle
8010
8011 !! test
8012 Link containing % (not as a hex sequence)
8013 !! wikitext
8014 [[7% Solution]]
8015 [[7% Solution|7%25 Solution]]
8016 !! html/php
8017 <p><a href="/wiki/7%25_Solution" title="7% Solution">7% Solution</a>
8018 <a href="/wiki/7%25_Solution" title="7% Solution">7%25 Solution</a>
8019 </p>
8020 !! html/parsoid
8021 <p><a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7% Solution</a>
8022 <a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7%25 Solution</a></p>
8023 !! end
8024
8025 # note that the parsoid HTML is identical to the previous test output,
8026 # so the previous test ensures that the html2wt mode will generate the
8027 # "not as a hex sequence" wikitext.
8028 !! test
8029 Link containing % as a single hex sequence interpreted to char
8030 !! options
8031 parsoid=wt2wt,wt2html,html2html
8032 !! wikitext
8033 [[7%25 Solution]]
8034 [[7%25 Solution|7%25 Solution]]
8035 !! html/php
8036 <p><a href="/wiki/7%25_Solution" title="7% Solution">7% Solution</a>
8037 <a href="/wiki/7%25_Solution" title="7% Solution">7%25 Solution</a>
8038 </p>
8039 !! html/parsoid
8040 <p><a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7% Solution</a>
8041 <a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7%25 Solution</a></p>
8042 !!end
8043
8044 !! test
8045 Link containing % as a double hex sequence interpreted to hex sequence
8046 !! wikitext
8047 [[7%2525 Solution]]
8048 !! html
8049 <p>[[7%2525 Solution]]
8050 </p>
8051 !!end
8052
8053 ## Example for such a section: == < ==
8054 !! test
8055 Link containing "#<" and "#>" % as a hex sequences- these are valid section anchors
8056 !! options
8057 title=[[Main Page]]
8058 !! config
8059 wgFragmentMode=[ 'html5', 'legacy' ]
8060 !! wikitext
8061 [[%23%3c]][[%23%3e]]
8062 !! html/php
8063 <p><a href="#&lt;">#&lt;</a><a href="#&gt;">#&gt;</a>
8064 </p>
8065 !! html/parsoid
8066 <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>
8067 !! end
8068
8069 ## Example for such a section: == < ==
8070 !! test
8071 Link containing "#<" and "#>" % as a hex sequences- these are valid section anchors (legacy)
8072 !! config
8073 wgFragmentMode=[ 'legacy' ]
8074 !! wikitext
8075 [[%23%3c]][[%23%3e]]
8076 !! html/php
8077 <p><a href="#.3C">#&lt;</a><a href="#.3E">#&gt;</a>
8078 </p>
8079 !! end
8080
8081 !! test
8082 Link containing "<#" and ">#" as a hex sequences
8083 !! wikitext
8084 [[%3c%23]][[%3e%23]]
8085 !! html
8086 <p>[[%3c%23]][[%3e%23]]
8087 </p>
8088 !! end
8089
8090 !! test
8091 Link containing an equals sign
8092 !! wikitext
8093 [[Special:BookSources/isbn=4-00-026157-6]]
8094 !! html/php
8095 <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>
8096 </p>
8097 !! html/parsoid
8098 <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>
8099 !! end
8100
8101 !! article
8102 Foo & bar
8103 !! text
8104 Just a test of an article title containing an ampersand
8105 !! endarticle
8106
8107 !! test
8108 Link containing an ampersand
8109 !! wikitext
8110 [[Foo & bar]]
8111
8112 [[Foo &amp; bar]]
8113
8114 [[Foo &amp;amp; bar]]
8115 !! html/php+tidy
8116 <p><a href="/wiki/Foo_%26_bar" title="Foo &amp; bar">Foo &amp; bar</a>
8117 </p><p><a href="/wiki/Foo_%26_bar" title="Foo &amp; bar">Foo &amp; bar</a>
8118 </p><p>[[Foo &amp;amp; bar]]
8119 </p>
8120 !! html/parsoid
8121 <p><a rel="mw:WikiLink" href="./Foo_&amp;_bar" title="Foo &amp; bar">Foo &amp; bar</a></p>
8122 <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>
8123 <p>[[Foo <span typeof="mw:Entity" data-parsoid='{"src":"&amp;amp;","srcContent":"&amp;"}'>&amp;</span>amp; bar]]</p>
8124 !! end
8125
8126 !! article
8127 Foo~bar
8128 !! text
8129 Just a test of an article title containing a tilde.
8130 !! endarticle
8131
8132 # note that links containing signatures, like [[Foo~~~~]], are
8133 # massaged by the pre-save transform (PST) and so the tildes are never
8134 # seen by the parser.
8135 !! test
8136 Link containing a tilde
8137 !! wikitext
8138 [[Foo~bar]]
8139 !! html/php
8140 <p><a href="/wiki/Foo~bar" title="Foo~bar">Foo~bar</a>
8141 </p>
8142 !! html/parsoid
8143 <p><a rel="mw:WikiLink" href="./Foo~bar" title="Foo~bar">Foo~bar</a></p>
8144 !! end
8145
8146 !! test
8147 Link containing double-single-quotes '' (T6598)
8148 !! wikitext
8149 [[Lista d''e paise d''o munno]]
8150 !! html/php
8151 <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>
8152 </p>
8153 !! html/parsoid
8154 <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>
8155 !! end
8156
8157 !! test
8158 Link containing double quotes and spaces
8159 !! wikitext
8160 [[Cool "Gator"]]
8161 !! html/php
8162 <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>
8163 </p>
8164 !! html/parsoid
8165 <p><a rel="mw:WikiLink" href='./Cool_"Gator"' title='Cool "Gator"'>Cool "Gator"</a></p>
8166 !! end
8167
8168 !! test
8169 File containing double quotes and spaces
8170 !! wikitext
8171 [[File:Cool "Gator".png]]
8172 !! html/parsoid
8173 <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>
8174 !! end
8175
8176 !! test
8177 Redirect containing double quotes and spaces
8178 !! wikitext
8179 #REDIRECT [[Cool "Gator"]]
8180 !! html/parsoid
8181 <link rel="mw:PageProp/redirect" href="./Cool_%22Gator%22" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./Cool_%22Gator%22"},"sa":{"href":"Cool \"Gator\""}}'/>
8182 !! end
8183
8184 !! test
8185 Link containing double-single-quotes '' in text (T6598 sanity check)
8186 !! wikitext
8187 Some [[Link|pretty ''italics'' and stuff]]!
8188 !! html/php
8189 <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>!
8190 </p>
8191 !! html/parsoid
8192 <p>Some <a rel="mw:WikiLink" href="./Link" title="Link">pretty <i>italics</i> and stuff</a>!</p>
8193 !! end
8194
8195 !! test
8196 Link containing double-single-quotes '' in text embedded in italics (T6598 sanity check)
8197 !! wikitext
8198 ''Some [[Link|pretty ''italics'' and stuff]]!''
8199 !! html
8200 <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>
8201 </p>
8202 !! end
8203
8204 !! test
8205 Link with double quotes in title part (literal) and alternate part (interpreted)
8206 !! wikitext
8207 [[File:Denys_Savchenko_''Pentecoste''.jpg]]
8208
8209 [[''Pentecoste'']]
8210
8211 [[''Pentecoste''|Pentecoste]]
8212
8213 [[''Pentecoste''|''Pentecoste'']]
8214 !! html/php
8215 <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>
8216 </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>
8217 </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>
8218 </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>
8219 </p>
8220 !! html/parsoid
8221 <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>
8222 <p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''">''Pentecoste''</a></p>
8223 <p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''">Pentecoste</a></p>
8224 <p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''"><i>Pentecoste</i></a></p>
8225 !! end
8226
8227 !! test
8228 Broken image links with HTML captions (T41700)
8229 !! wikitext
8230 [[File:Nonexistent|<script></script>]]
8231 [[File:Nonexistent|100x100px|<script></script>]]
8232 [[File:Nonexistent|&lt;]]
8233 [[File:Nonexistent|a<i>b</i>c]]
8234 !! html/php
8235 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">&lt;script&gt;&lt;/script&gt;</a>
8236 <a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">&lt;script&gt;&lt;/script&gt;</a>
8237 <a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">&lt;</a>
8238 <a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">abc</a>
8239 </p>
8240 !! html/parsoid
8241 <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>
8242 <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>
8243 <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>
8244 <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>
8245 !! end
8246
8247 !! test
8248 Plain link to URL
8249 !! wikitext
8250 [[http://www.example.com]]
8251 !! html/php
8252 <p>[<a rel="nofollow" class="external autonumber" href="http://www.example.com">[1]</a>]
8253 </p>
8254 !! html/parsoid
8255 <p>[<a rel="mw:ExtLink" class="external autonumber" href="http://www.example.com"></a>]</p>
8256 !! end
8257
8258 !! test
8259 Plain link to URL with link text
8260 !! wikitext
8261 [[http://www.example.com Link text]]
8262 !! html
8263 <p>[<a rel="nofollow" class="external text" href="http://www.example.com">Link text</a>]
8264 </p>
8265 !! end
8266
8267 !! test
8268 Plain link to protocol-relative URL
8269 !! wikitext
8270 [[//www.example.com]]
8271 !! html/php
8272 <p>[<a rel="nofollow" class="external autonumber" href="//www.example.com">[1]</a>]
8273 </p>
8274 !! html/parsoid
8275 <p>[<a rel="mw:ExtLink" class="external autonumber" href="//www.example.com"></a>]</p>
8276 !! end
8277
8278 !! test
8279 Plain link to protocol-relative URL with link text
8280 !! wikitext
8281 [[//www.example.com Link text]]
8282 !! html
8283 <p>[<a rel="nofollow" class="external text" href="//www.example.com">Link text</a>]
8284 </p>
8285 !! end
8286
8287 !! test
8288 Plain link to page with question mark in title
8289 !! wikitext
8290 [[A?b]]
8291
8292 [[A?b|Baz]]
8293 !! html
8294 <p><a href="/wiki/A%3Fb" title="A?b">A?b</a>
8295 </p><p><a href="/wiki/A%3Fb" title="A?b">Baz</a>
8296 </p>
8297 !! end
8298
8299 # I'm fairly sure the expected result here is wrong.
8300 # We want these to be URL links, not pseudo-pages with URLs for titles....
8301 # However the current output is also pretty screwy.
8302 #
8303 # ----
8304 # I'm changing it to match the current output--it arguably makes more
8305 # sense in the light of the test above. Old expected result was:
8306 #<p>Piped link to URL: <a href="/index.php?title=Http://www.example.com&amp;action=edit" class="new">an example URL</a>
8307 #</p>
8308 # But I think this test is bordering on "garbage in, garbage out" anyway.
8309 # -- wtm
8310 !! test
8311 Piped link to URL
8312 !! wikitext
8313 Piped link to URL: [[http://www.example.com|an example URL]]
8314 !! html/php
8315 <p>Piped link to URL: [<a rel="nofollow" class="external text" href="http://www.example.com%7Can">example URL</a>]
8316 </p>
8317 !! html/parsoid
8318 <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>
8319 !! end
8320
8321 !! test
8322 Plain link in template argument
8323 !! options
8324 parsoid=wt2html
8325 !! wikitext
8326 {{echo|[http://www.example.com |123]}}
8327
8328 {{echo|[[http://www.example.com |123]]}}
8329
8330 {{echo|[[http://www.example.com |123]}}
8331
8332 {{echo|[http://www.example.com |123]]}}
8333 !! html/php
8334 <p>[<a rel="nofollow" class="external free" href="http://www.example.com">http://www.example.com</a>
8335 </p><p>[<a rel="nofollow" class="external text" href="http://www.example.com">|123</a>]
8336 </p><p>{{echo|[<a rel="nofollow" class="external text" href="http://www.example.com">|123</a>}}
8337 </p><p>[<a rel="nofollow" class="external free" href="http://www.example.com">http://www.example.com</a>
8338 </p>
8339 !! html/parsoid
8340 <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>
8341
8342 <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>
8343
8344 <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>
8345
8346 <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>
8347 !! end
8348
8349 !! test
8350 T2002: [[page|http://url/]] should link to page, not http://url/
8351 !! wikitext
8352 [[Main Page|http://url/]]
8353 !! html/php
8354 <p><a href="/wiki/Main_Page" title="Main Page">http://url/</a>
8355 </p>
8356 !! html/parsoid
8357 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">http://url/</a></p>
8358 !! end
8359
8360 # Parsoid does not mark self-links, by design.
8361 !! test
8362 T2337: Escaped self-links should be bold
8363 !! options
8364 title=[[Bug462]]
8365 !! wikitext
8366 [[Bu&#103;462]] [[Bug462]]
8367 !! html/php+tidy
8368 <p><a class="mw-selflink selflink">Bu&#103;462</a> <a class="mw-selflink selflink">Bug462</a>
8369 </p>
8370 !! html/parsoid
8371 <p><a rel="mw:WikiLink" href="./Bug462" title="Bug462">Bug462</a> <a rel="mw:WikiLink" href="./Bug462" title="Bug462">Bug462</a></p>
8372 !! end
8373
8374 !! test
8375 Self-link to section should not be bold
8376 !! options
8377 title=[[Main Page]]
8378 !! wikitext
8379 [[Main Page#section]]
8380 !! html
8381 <p><a href="/wiki/Main_Page#section" title="Main Page">Main Page#section</a>
8382 </p>
8383 !! end
8384
8385 !! article
8386 00
8387 !! text
8388 This is 00.
8389 !! endarticle
8390
8391 !!test
8392 Self-link to numeric title
8393 !!options
8394 title=[[0]]
8395 !! wikitext
8396 [[0]]
8397 !! html
8398 <p><a class="mw-selflink selflink">0</a>
8399 </p>
8400 !!end
8401
8402 !!test
8403 Link to numeric-equivalent title
8404 !!options
8405 title=[[0]]
8406 !! wikitext
8407 [[00]]
8408 !! html
8409 <p><a href="/wiki/00" title="00">00</a>
8410 </p>
8411 !!end
8412
8413 !! test
8414 <nowiki> inside a link
8415 !! wikitext
8416 [[Main<nowiki> Page</nowiki>]] [[Main Page|the main page <nowiki>[it's not very good]</nowiki>]]
8417 !! html
8418 <p>[[Main Page]] <a href="/wiki/Main_Page" title="Main Page">the main page [it's not very good]</a>
8419 </p>
8420 !! end
8421
8422 !! test
8423 Non-breaking spaces in title
8424 !! wikitext
8425 [[&nbsp; Main &nbsp; Page &nbsp;]]
8426 !! html
8427 <p><a href="/wiki/Main_Page" title="Main Page">&#160; Main &#160; Page &#160;</a>
8428 </p>
8429 !!end
8430
8431 # Add new article for the test below so that it doesn't red-link
8432 !! article
8433 Foo bar baz
8434 !! text
8435 boo
8436 !! endarticle
8437
8438 !! test
8439 Multiple spaces in titles should normalize to a single underscore
8440 !! options
8441 parsoid=wt2html,wt2wt
8442 !! wikitext
8443 [[Foo bar baz|x]]
8444 [[Foo bar baz|x]]
8445 [[Foo bar baz|x]]
8446 !! html/php
8447 <p><a href="/wiki/Foo_bar_baz" title="Foo bar baz">x</a>
8448 <a href="/wiki/Foo_bar_baz" title="Foo bar baz">x</a>
8449 <a href="/wiki/Foo_bar_baz" title="Foo bar baz">x</a>
8450 </p>
8451 !! html/parsoid
8452 <p><a rel="mw:WikiLink" href="./Foo_bar_baz" title="Foo bar baz">x</a>
8453 <a rel="mw:WikiLink" href="./Foo_bar_baz" title="Foo bar baz">x</a>
8454 <a rel="mw:WikiLink" href="./Foo_bar_baz" title="Foo bar baz">x</a>
8455 </p>
8456 !! end
8457
8458 !! test
8459 Internal link with ca linktrail, surrounded by bold apostrophes (T29473 primary issue)
8460 !! options
8461 language=ca
8462 !! wikitext
8463 '''[[Main Page]]'''
8464 !! html
8465 <p><b><a href="/wiki/Main_Page" title="Main Page">Main Page</a></b>
8466 </p>
8467 !! end
8468
8469 !! test
8470 Internal link with ca linktrail, surrounded by italic apostrophes (T29473 primary issue)
8471 !! options
8472 language=ca
8473 !! wikitext
8474 ''[[Main Page]]''
8475 !! html
8476 <p><i><a href="/wiki/Main_Page" title="Main Page">Main Page</a></i>
8477 </p>
8478 !! end
8479
8480 !! test
8481 Internal link with en linktrail: no apostrophes (T29473)
8482 !! options
8483 language=en
8484 !! wikitext
8485 [[Something]]'nice
8486 !! html
8487 <p><a href="/index.php?title=Something&amp;action=edit&amp;redlink=1" class="new" title="Something (page does not exist)">Something</a>'nice
8488 </p>
8489 !! end
8490
8491 !! test
8492 Internal link with ca linktrail with apostrophes (T29473)
8493 !! options
8494 language=ca
8495 !! wikitext
8496 [[Something]]'nice
8497 !! html
8498 <p><a href="/index.php?title=Something&amp;action=edit&amp;redlink=1" class="new" title="Something (encara no existeix)">Something'nice</a>
8499 </p>
8500 !! end
8501
8502 !! test
8503 Internal link with kaa linktrail with apostrophes (T29473)
8504 !! options
8505 language=kaa
8506 !! wikitext
8507 [[Something]]'nice
8508 !! html
8509 <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>
8510 </p>
8511 !! end
8512
8513 !! test
8514 Link with multiple ":" in a subpage-supporting namespace (T65636)
8515 !! wikitext
8516 [[User:Foo/Test/63636:Bar|Test]]
8517 !! html/php
8518 <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>
8519 </p>
8520 !! html/parsoid
8521 <p><a rel="mw:WikiLink" href="./User:Foo/Test/63636:Bar" title="User:Foo/Test/63636:Bar">Test</a></p>
8522 !! end
8523
8524 ## Mainly a sanity check for Parsoid
8525 !! test
8526 Handle title parsing for subpages
8527 !! options
8528 title=[[/123123]]
8529 subpage
8530 !! wikitext
8531 123
8532 !! html/php
8533 <p>123
8534 </p>
8535 !! html/parsoid
8536 <p>123</p>
8537 !! end
8538
8539 !! article
8540 User:Test/123
8541 !! text
8542 test 123
8543 !! endarticle
8544
8545 !! test
8546 Link to a subpage from a namespace other than main
8547 !! options
8548 title=[[User:Test]]
8549 subpage
8550 !! wikitext
8551 [[/123]]
8552 !! html/php
8553 <p><a href="/wiki/User:Test/123" title="User:Test/123">/123</a>
8554 </p>
8555 !! html/parsoid
8556 <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>
8557 !! end
8558
8559 !! test
8560 Ensure that transclusion titles are not url-decoded
8561 !! options
8562 subpage title=[[Test]]
8563 parsoid=wt2html
8564 !! wikitext
8565 {{Bar%C3%A9}} {{/Bar%C3%A9}}
8566 !! html/php
8567 <p>{{Bar%C3%A9}} {{/Bar%C3%A9}}
8568 </p>
8569 !! html/parsoid
8570 <p>{{Bar%C3%A9}} {{/Bar%C3%A9}}</p>
8571 !! end
8572
8573 !! test
8574 Purely hash wikilink
8575 !! options
8576 title=[[User:Test/123]]
8577 subpage
8578 !! wikitext
8579 [[#a|b]]
8580 !! html/php
8581 <p><a href="#a">b</a>
8582 </p>
8583 !! html/parsoid
8584 <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>
8585 !! end
8586
8587 !! test
8588 Serialization of purely hash wikilink
8589 !! options
8590 title=[[User:Test/123]]
8591 subpage
8592 parsoid=html2wt
8593 !! html/parsoid
8594 <p><a href="#a">[[</a></p>
8595 !! wikitext
8596 [[#a|<nowiki>[[</nowiki>]]
8597 !! html/php
8598 <p><a href="#a">[[</a>
8599 </p>
8600 !! end
8601
8602 !! test
8603 1. Interaction of linktrail and template encapsulation
8604 !! wikitext
8605 {{echo|[[Foo]]}}l
8606 !! html/php+tidy
8607 <p><a href="/wiki/Foo" title="Foo">Fool</a>
8608 </p>
8609 !! html/parsoid
8610 <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>
8611 !! end
8612
8613 !! test
8614 2. Interaction of linktrail and template encapsulation
8615 !! wikitext
8616 {{echo|Some [[Fool]]}}s
8617 !! html/php+tidy
8618 <p>Some <a href="/index.php?title=Fool&amp;action=edit&amp;redlink=1" class="new" title="Fool (page does not exist)">Fools</a>
8619 </p>
8620 !! html/parsoid
8621 <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>
8622 !! end
8623
8624 !! test
8625 3. Interaction of linktrail and template encapsulation
8626 !! wikitext
8627 {{echo|Some [[Fool]]s are '''bold and foolish'''}}
8628 !! html/php+tidy
8629 <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>
8630 </p>
8631 !! html/parsoid
8632 <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>
8633 !! end
8634
8635 !! article
8636 Söfnuður
8637 !! text
8638 Test.
8639 !! endarticle
8640
8641 !! test
8642 Internal link with is link prefix
8643 !! options
8644 language=is
8645 !! wikitext
8646 Aðrir mótmælenda[[söfnuður|söfnuðir]] og
8647 !! html
8648 <p>Aðrir <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðir</a> og
8649 </p>
8650 !! end
8651
8652 !! article
8653 Mótmælendatrú
8654 !! text
8655 Test.
8656 !! endarticle
8657
8658 !! test
8659 Internal link with is link trail and link prefix
8660 !! options
8661 language=is
8662 !! wikitext
8663 [[mótmælendatrú|xxx]]ar
8664 [[mótmælendatrú]]ar
8665 mótmælenda[[söfnuður]]
8666 mótmælenda[[söfnuður|söfnuðir]]
8667 mótmælenda[[söfnuður|söfnuðir]]xxx
8668 !! html
8669 <p><a href="/wiki/M%C3%B3tm%C3%A6lendatr%C3%BA" title="Mótmælendatrú">xxxar</a>
8670 <a href="/wiki/M%C3%B3tm%C3%A6lendatr%C3%BA" title="Mótmælendatrú">mótmælendatrúar</a>
8671 <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuður</a>
8672 <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðir</a>
8673 <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðirxxx</a>
8674 </p>
8675 !! end
8676
8677 !! test
8678 Parsoid link trail escaping
8679 !! options
8680 parsoid=html2wt,html2html
8681 !! html/parsoid
8682 <p><a rel="mw:WikiLink" href="./Apple" title="Apple">apple</a>s</p>
8683 !! wikitext
8684 [[apple]]<nowiki/>s
8685 !! end
8686
8687 !! test
8688 Parsoid link prefix escaping
8689 !! options
8690 language=is
8691 parsoid=html2wt,html2html
8692 !! html/parsoid
8693 <p>Aðrir mótmælenda<a rel="mw:WikiLink" href="./Söfnuður" title="Söfnuður">söfnuður</a></p>
8694 !! wikitext
8695 Aðrir mótmælenda<nowiki/>[[söfnuður]]
8696 !! end
8697
8698 !! test
8699 Parsoid link bracket escaping
8700 !! options
8701 parsoid=html2wt,html2html
8702 !! html/parsoid
8703 <p><a rel="mw:WikiLink" href="./Test" title="Test">Test</a></p>
8704 <p>[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]</p>
8705 <p>[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]</p>
8706 <p>[[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]]</p>
8707 <p>[[[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]]]</p>
8708 <p>[[[[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]]]]</p>
8709 !! wikitext
8710 [[Test]]
8711
8712 [<nowiki/>[[Test]]]
8713
8714 [[[[Test]]]]
8715
8716 [[[<nowiki/>[[Test]]]]]
8717
8718 [[[[[[Test]]]]]]
8719
8720 [[[[[<nowiki/>[[Test]]]]]]]
8721 !! end
8722
8723 !! test
8724 Parsoid-centric test: Whitespace in ext- and wiki-links should be preserved
8725 !! wikitext
8726 [[Foo| bar]]
8727
8728 [[Foo| ''bar'']]
8729
8730 [http://wp.org foo]
8731
8732 [http://wp.org ''foo'']
8733 !! html
8734 <p><a href="/wiki/Foo" title="Foo"> bar</a>
8735 </p><p><a href="/wiki/Foo" title="Foo"> <i>bar</i></a>
8736 </p><p><a rel="nofollow" class="external text" href="http://wp.org">foo</a>
8737 </p><p><a rel="nofollow" class="external text" href="http://wp.org"><i>foo</i></a>
8738 </p>
8739 !! end
8740
8741 !! test
8742 Parsoid: Scoped parsing should handle mixed transclusions and plain text
8743 !! wikitext
8744 [[Foo|{{echo|a}} b {{echo|c}}]]
8745 !! html/parsoid
8746 <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>
8747 !! end
8748
8749 !! test
8750 Link with angle bracket after anchor
8751 !! config
8752 wgFragmentMode=[ 'html5', 'legacy' ]
8753 !! wikitext
8754 [[Foo#<bar>]]
8755 !! html/php
8756 <p><a href="/wiki/Foo#&lt;bar&gt;" title="Foo">Foo#&lt;bar&gt;</a>
8757 </p>
8758 !! html/parsoid
8759 <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>
8760 !! end
8761
8762 !! test
8763 Link with angle bracket after anchor (legacy)
8764 !! config
8765 wgFragmentMode=[ 'legacy' ]
8766 !! wikitext
8767 [[Foo#<bar>]]
8768 !! html/php
8769 <p><a href="/wiki/Foo#.3Cbar.3E" title="Foo">Foo#&lt;bar&gt;</a>
8770 </p>
8771 !! end
8772
8773 ###
8774 ### Interwiki links (see maintenance/interwiki.sql)
8775 ###
8776
8777 !! test
8778 Inline interwiki link
8779 !! options
8780 parsoid=wt2html,wt2wt,html2html
8781 !! wikitext
8782 [[MeatBall:SoftSecurity]]
8783 !! html/php
8784 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity" class="extiw" title="meatball:SoftSecurity">MeatBall:SoftSecurity</a>
8785 </p>
8786 !! html/parsoid
8787 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity" title="meatball:SoftSecurity">MeatBall:SoftSecurity</a></p>
8788 !! end
8789
8790 !! test
8791 Inline interwiki link with empty title (T4372)
8792 !! options
8793 parsoid=wt2html,wt2wt,html2html
8794 !! wikitext
8795 [[MeatBall:]]
8796 !! html/php
8797 <p><a href="http://www.usemod.com/cgi-bin/mb.pl" class="extiw" title="meatball:">MeatBall:</a>
8798 </p>
8799 !! html/parsoid
8800 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?" title="meatball:">MeatBall:</a></p>
8801 !! end
8802
8803 ## html2wt and html2html will fail because we will prefer the :en: interwiki prefix over wikipedia:
8804 !! test
8805 Interwiki link encoding conversion (T3636)
8806 !! options
8807 parsoid=wt2html,wt2wt
8808 !! wikitext
8809 *[[Wikipedia:ro:Olteni&#0355;a]]
8810 *[[Wikipedia:ro:Olteni&#355;a]]
8811 !! html/php
8812 <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>
8813 <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>
8814
8815 !! html/php+tidy
8816 <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>
8817 <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>
8818 !! html/parsoid
8819 <ul>
8820 <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>
8821 <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>
8822 </ul>
8823 !! end
8824
8825 !! test
8826 Interwiki link with fragment (T4130)
8827 !! wikitext
8828 [[MeatBall:SoftSecurity#foo]]
8829 !! html
8830 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity#foo" class="extiw" title="meatball:SoftSecurity">MeatBall:SoftSecurity#foo</a>
8831 </p>
8832 !! end
8833
8834 !! test
8835 Link scenarios with escaped fragments
8836 !! options
8837 title=[[Main Page]]
8838 !! config
8839 wgFragmentMode=[ 'html5', 'legacy' ]
8840 !! wikitext
8841 [[#Is this great?]]
8842 [[Foo#Is this great?]]
8843 [[meatball:Foo#Is this great?]]
8844 !! html/php
8845 <p><a href="#Is_this_great?">#Is this great?</a>
8846 <a href="/wiki/Foo#Is_this_great?" title="Foo">Foo#Is this great?</a>
8847 <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>
8848 </p>
8849 !! html/parsoid
8850 <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>
8851 <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>
8852 <a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?Foo#Is_this_great?" title="meatball:Foo" data-parsoid='{"stx":"simple","a":{"href":"http://www.usemod.com/cgi-bin/mb.pl?Foo#Is_this_great?"},"sa":{"href":"meatball:Foo#Is this great?"},"isIW":true}'>meatball:Foo#Is this great?</a></p>
8853 !! end
8854
8855 !! test
8856 Link scenarios with escaped fragments (legacy)
8857 !! config
8858 wgFragmentMode=[ 'legacy' ]
8859 !! wikitext
8860 [[#Is this great?]]
8861 [[Foo#Is this great?]]
8862 [[meatball:Foo#Is this great?]]
8863 !! html/php
8864 <p><a href="#Is_this_great.3F">#Is this great?</a>
8865 <a href="/wiki/Foo#Is_this_great.3F" title="Foo">Foo#Is this great?</a>
8866 <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>
8867 </p>
8868 !! end
8869
8870 # Ideally the wikipedia: prefix here should be proto-relative too
8871 # [CSA]: this is kind of a bogus test, as the PHP parser test doesn't
8872 # define the 'en' prefix, and originally the test used 'wikipedia',
8873 # which isn't a localinterwiki prefix hence the links to the 'en:Foo'
8874 # article.
8875 !! test
8876 Different interwiki prefixes mapping to the same URL
8877 !! wikitext
8878 [[:en:Foo]]
8879
8880 [[:en:Foo|Foo]]
8881
8882 [[wikipedia:Foo]]
8883
8884 [[:wikipedia:Foo|Foo]]
8885
8886 [[wikipedia:en:Foo]]
8887
8888 [[:wikipedia:en:Foo]]
8889
8890 [[ wikiPEdia :Foo]]
8891 !! html/parsoid
8892 <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>
8893
8894 <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>
8895
8896 <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>
8897
8898 <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>
8899
8900 <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>
8901
8902 <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>
8903
8904 <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>
8905 !! end
8906
8907 !! test
8908 Interwiki links that cannot be represented in wiki syntax
8909 !! wikitext
8910 [[meatball:ok]]
8911 [[meatball:ok#foo|ok with fragment]]
8912 [[meatball:ok_as_well?|ok ending with ? mark]]
8913 [http://de.wikipedia.org/wiki/Foo?action=history has query]
8914 [http://de.wikipedia.org/wiki/#foo is just fragment]
8915
8916 !! html/php
8917 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?ok" class="extiw" title="meatball:ok">meatball:ok</a>
8918 <a href="http://www.usemod.com/cgi-bin/mb.pl?ok#foo" class="extiw" title="meatball:ok">ok with fragment</a>
8919 <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>
8920 <a rel="nofollow" class="external text" href="http://de.wikipedia.org/wiki/Foo?action=history">has query</a>
8921 <a rel="nofollow" class="external text" href="http://de.wikipedia.org/wiki/#foo">is just fragment</a>
8922 </p>
8923 !! html/parsoid
8924 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?ok" title="meatball:ok">meatball:ok</a>
8925 <a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?ok#foo" title="meatball:ok">ok with fragment</a>
8926 <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>
8927 <a rel="mw:ExtLink" class="external text" href="http://de.wikipedia.org/wiki/Foo?action=history">has query</a>
8928 <a rel="mw:ExtLink" class="external text" href="http://de.wikipedia.org/wiki/#foo">is just fragment</a></p>
8929 !! end
8930
8931 !! test
8932 Interwiki links: trail
8933 !! wikitext
8934 [[wikipedia:Foo|Ba]]r
8935 !! html/php
8936 <p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo">Bar</a>
8937 </p>
8938 !! html/parsoid
8939 <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>
8940 !! end
8941
8942 !! test
8943 Local interwiki link
8944 !! options
8945 parsoid=wt2html,wt2wt,html2html
8946 !! wikitext
8947 [[local:Template:Foo]]
8948 !! html/php
8949 <p><a href="/wiki/Template:Foo" title="Template:Foo">local:Template:Foo</a>
8950 </p>
8951 !! html/parsoid
8952 <p><a rel="mw:WikiLink" href="./Template:Foo" title="Template:Foo">local:Template:Foo</a></p>
8953 !! end
8954
8955 # Parsoid does not mark self-links, by design.
8956 !! test
8957 Local interwiki link: self-link to current page
8958 !! options
8959 title=[[Main Page]]
8960 parsoid=wt2html,wt2wt,html2html
8961 !! wikitext
8962 [[local:Main Page]]
8963 !! html/php
8964 <p><a class="mw-selflink selflink">local:Main Page</a>
8965 </p>
8966 !! html/parsoid
8967 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">local:Main Page</a></p>
8968 !! end
8969
8970 !! test
8971 Local interwiki link: prefix only (T66167)
8972 !! options
8973 parsoid=wt2html,wt2wt,html2html
8974 !! wikitext
8975 [[local:]]
8976 !! html/php
8977 <p><a href="/wiki/Main_Page" title="Main Page">local:</a>
8978 </p>
8979 !! html/parsoid
8980 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">local:</a></p>
8981 !! end
8982
8983 !! test
8984 Local interwiki link: with additional interwiki prefix (T63357)
8985 !! options
8986 parsoid=wt2html,wt2wt,html2html
8987 !! wikitext
8988 [[local:meatball:Hello]]
8989 !! html/php
8990 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?Hello" class="extiw" title="meatball:Hello">local:meatball:Hello</a>
8991 </p>
8992 !! html/parsoid
8993 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?Hello" title="meatball:Hello">local:meatball:Hello</a></p>
8994 !! end
8995
8996 !! test
8997 Multiple local interwiki link prefixes
8998 !! wikitext
8999 [[local:local:local:local:mi:local:Foo]]
9000 !! options
9001 parsoid=wt2html,wt2wt,html2html
9002 !! html/php
9003 <p><a href="/wiki/Foo" title="Foo">local:local:local:local:mi:local:Foo</a>
9004 </p>
9005 !! html/parsoid
9006 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">local:local:local:local:mi:local:Foo</a></p>
9007 !! end
9008
9009 !! test
9010 Interwiki link with percent encoded target
9011 !! wikitext
9012 [[:es:Nueva Guip%C3%BAzcoa|Nueva Guipúzcoa]]
9013 !! html/php
9014 <p><a href="http://es.wikipedia.org/wiki/Nueva_Guip%C3%BAzcoa" class="extiw" title="es:Nueva Guipúzcoa">Nueva Guipúzcoa</a>
9015 </p>
9016 !! html/parsoid
9017 <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>
9018 !! end
9019
9020 ###
9021 ### Interlanguage links
9022 ### Language links (so that searching for '### language' matches..)
9023 ###
9024
9025 !! test
9026 Interlanguage link
9027 !! wikitext
9028 Blah blah blah
9029 [[zh:Chinese]]
9030 !! html/php
9031 <p>Blah blah blah
9032 </p>
9033 !! html/parsoid
9034 <p>Blah blah blah</p>
9035 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
9036 !! end
9037
9038 ## parsoid html2wt will lose the space variations
9039 !! test
9040 Interlanguage link with spacing
9041 !! options
9042 parsoid=wt2html,wt2wt,html2html
9043 !! wikitext
9044 Blah blah blah
9045 [[ zh : Chinese ]]
9046 !! html/php
9047 <p>Blah blah blah
9048 </p>
9049 !! html/parsoid
9050 <p>Blah blah blah</p>
9051 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
9052 !! end
9053
9054 !! test
9055 Double interlanguage link
9056 !! wikitext
9057 Blah blah blah
9058 [[es:Spanish]]
9059 [[zh:Chinese]]
9060 !! html/php
9061 <p>Blah blah blah
9062 </p>
9063 !! html/parsoid
9064 <p>Blah blah blah</p>
9065 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Spanish"/>
9066 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
9067 !! end
9068
9069 ## parsoid html2wt will lose the space variations
9070 !! test
9071 Interlanguage link variations
9072 !! options
9073 parsoid=wt2html,wt2wt,html2html
9074 !! wikitext
9075 Blah blah blah
9076 [[ es :Spanish]]
9077 [[ ZH :Chinese]]
9078 [[es:Foo_bar]]
9079 !! html/php
9080 <p>Blah blah blah
9081 </p>
9082 !! html/parsoid
9083 <p>Blah blah blah</p>
9084 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Spanish" />
9085 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese" />
9086 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo_bar" />
9087 !! end
9088
9089 !! test
9090 Escaping of interlanguage links (T129218, T156308)
9091 !! wikitext
9092 Blah blah blah
9093 [[:es:Spanish]]
9094 [[ : zh : Chinese ]]
9095 !! html/php
9096 <p>Blah blah blah
9097 <a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">es:Spanish</a>
9098 <a href="http://zh.wikipedia.org/wiki/Chinese" class="extiw" title="zh:Chinese"> zh : Chinese </a>
9099 </p>
9100 !! html/parsoid
9101 <p>Blah blah blah
9102 <a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">es:Spanish</a>
9103 <a rel="mw:WikiLink/Interwiki" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese"> zh : Chinese </a></p>
9104 !! end
9105
9106 !! test
9107 Multiple colons escaping interlanguage links
9108 !! options
9109 parsoid=wt2html
9110 !! wikitext
9111 [[:es:Spanish]]
9112 [[::es:Spanish]]
9113 [[:::es:Spanish]]
9114 !! html/php
9115 <p><a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">es:Spanish</a>
9116 [[::es:Spanish]]
9117 [[:::es:Spanish]]
9118 </p>
9119 !! html/parsoid
9120 <p><a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">es:Spanish</a>
9121 [[::es:Spanish]]
9122 [[:::es:Spanish]]</p>
9123 !! end
9124
9125 ## parsoid html2wt will normalize the space to _
9126 !! test
9127 Space and question mark encoding in interlanguage links (T95473)
9128 !! options
9129 parsoid=wt2html,wt2wt,html2html
9130 !! wikitext
9131 Blah blah blah
9132 [[es:Foo bar?]]
9133 !! html/php
9134 <p>Blah blah blah
9135 </p>
9136 !! html/parsoid
9137 <p>Blah blah blah</p>
9138 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo_bar%3F" />
9139 !! end
9140
9141 !! test
9142 Interlanguage link, with prefix links
9143 !! options
9144 language=ln
9145 !! wikitext
9146 Blah blah blah
9147 [[zh:Chinese]]
9148 !! html/php
9149 <p>Blah blah blah
9150 </p>
9151 !! html/parsoid
9152 <p>Blah blah blah</p>
9153 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
9154 !! end
9155
9156 !! test
9157 Double interlanguage link, with prefix links (T10897)
9158 !! options
9159 language=ln
9160 !! wikitext
9161 Blah blah blah
9162 [[es:Spanish]]
9163 [[zh:Chinese]]
9164 !! html/php
9165 <p>Blah blah blah
9166 </p>
9167 !! html/parsoid
9168 <p>Blah blah blah</p>
9169 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Spanish"/>
9170 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
9171 !! end
9172
9173 !! test
9174 "Extra" interlanguage links (T34189 / gerrit 111390)
9175 !! wikitext
9176 Blah blah blah
9177 [[mul:Article]]
9178 !! html/php
9179 <p>Blah blah blah
9180 </p>
9181 !! html/parsoid
9182 <p>Blah blah blah</p>
9183 <link rel="mw:PageProp/Language" title="Multilingual" href="http://wikisource.org/wiki/Article"/>
9184 !! end
9185
9186 ## PHP parser tests script needs an update
9187 ## Parsoid html2wt will normalize output to [[:zh:Chinese]]
9188 !! test
9189 Language links render as inline links if $wgInterwikiMagic=false
9190 !! options
9191 wgInterwikiMagic=false
9192 parsoid=wt2html,wt2wt,html2html
9193 !! wikitext
9194 Blah blah blah
9195 [[zh:Chinese]]
9196 !! html/parsoid
9197 <p>Blah blah blah <a rel="mw:WikiLink/Interwiki" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese">zh:Chinese</a></p>
9198 !! end
9199
9200 ## PHP parser tests script needs an update
9201 ## Parsoid html2wt will normalize output to [[:zh:Chinese]]
9202 !! test
9203 Language links render as inline links in the Talk namespace
9204 !! options
9205 title=Talk:Foo
9206 parsoid=wt2html,wt2wt,html2html
9207 !! wikitext
9208 Blah blah blah
9209 [[zh:Chinese]]
9210 !! html/parsoid
9211 <p>Blah blah blah <a rel="mw:WikiLink/Interwiki" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese">zh:Chinese</a></p>
9212 !! end
9213
9214 !! test
9215 Parsoid-specific test: Wikilinks with &nbsp; should RT properly
9216 !! options
9217 language=ln
9218 !! wikitext
9219 [[WW&nbsp;II]]
9220 !! html
9221 <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>
9222 </p>
9223 !! end
9224
9225 !! test
9226 Parsoid T55221: Wikilinks should be properly entity-escaped
9227 !! options
9228 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
9229 !! html/parsoid
9230 <p>He&amp;nbsp;llo <a href="./Foo" rel="mw:WikiLink">He&amp;nbsp;llo</a></p>
9231 <p>He&amp;nbsp;llo <a href="./He&amp;nbsp;llo" rel="mw:WikiLink">He&amp;nbsp;llo</a></p>
9232 !! wikitext
9233 He&amp;nbsp;llo [[Foo|He&amp;nbsp;llo]]
9234
9235 He&amp;nbsp;llo He&amp;nbsp;llo
9236 !! html/php
9237 <p>He&amp;nbsp;llo <a href="/wiki/Foo" title="Foo">He&amp;nbsp;llo</a>
9238 </p><p>He&amp;nbsp;llo He&amp;nbsp;llo
9239 </p>
9240 !! end
9241
9242 # html2wt will fail because of title normalization without data-parsoid
9243 !! test
9244 Parsoid: handle constructor well
9245 !! options
9246 parsoid=wt2html,wt2wt
9247 !! wikitext
9248 [[constructor]]
9249
9250 [[constructor:foo]]
9251 !! html/php
9252 <p><a href="/index.php?title=Constructor&amp;action=edit&amp;redlink=1" class="new" title="Constructor (page does not exist)">constructor</a>
9253 </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>
9254 </p>
9255 !! html/parsoid
9256 <p><a rel="mw:WikiLink" href="./Constructor" title="Constructor" data-parsoid='{"stx":"simple","a":{"href":"./Constructor"},"sa":{"href":"constructor"}}'>constructor</a></p>
9257
9258 <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>
9259 !! end
9260
9261 !! test
9262 Template parameter named "constructor"
9263 !! wikitext
9264 {{echo| constructor = |hi}}
9265 !! html/parsoid
9266 <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>
9267 !! end
9268
9269 !! article
9270 ko:
9271 !! text
9272 Test.
9273 !! endarticle
9274
9275 # Note that `ko` isn't a known interlanguage prefix
9276 !! test
9277 Parsoid: recognize interlanguage links without a target page
9278 !! options
9279 ill
9280 !! wikitext
9281 [[es:]]
9282
9283 [[ko:]]
9284 !! html/php
9285 es:
9286 !! html/parsoid
9287 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/"/>
9288
9289 <p><a rel="mw:WikiLink" href="./Ko:" title="Ko:">ko:</a></p>
9290 !! end
9291
9292 # Note that `ko` isn't a known interwiki prefix
9293 !! test
9294 Parsoid: recognize interwiki links without a target page
9295 !! options
9296 parsoid=wt2html,wt2wt,html2html
9297 !! wikitext
9298 [[:es:]]
9299
9300 [[:ko:]]
9301 !! html/php
9302 <p><a href="http://es.wikipedia.org/wiki/" class="extiw" title="es:">es:</a>
9303 </p><p><a href="/wiki/Ko:" title="Ko:">ko:</a>
9304 </p>
9305 !! html/parsoid
9306 <p><a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/" title="es:">es:</a></p>
9307 <p><a rel="mw:WikiLink" href="./Ko:" title="Ko:">ko:</a></p>
9308 !! end
9309
9310 !! test
9311 Handle interwiki links pointing to the current wiki as plain wiki links (T47209)
9312 !! wikitext
9313 [[mi:Foo]]
9314 !! html/php
9315 <p><a href="/wiki/Foo" title="Foo">mi:Foo</a>
9316 </p>
9317 !! html/parsoid
9318 <p><a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"simple","a":{"href":"./Foo"},"sa":{"href":"mi:Foo"}}'>mi:Foo</a></p>
9319 !! end
9320
9321 !! test
9322 Interlanguage link with preceding local interwiki link (T70085)
9323 !! options
9324 parsoid=wt2html,wt2wt,html2html
9325 !! wikitext
9326 Blah blah blah
9327 [[local:es:Spanish]]
9328 !! html/php
9329 <p>Blah blah blah
9330 <a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">local:es:Spanish</a>
9331 </p>
9332 !! html/parsoid
9333 <p>Blah blah blah
9334 <a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">local:es:Spanish</a></p>
9335 !! end
9336
9337 !! test
9338 Looks like an interlanguage link, but is actually a local interwiki
9339 !! options
9340 parsoid=wt2html,wt2wt,html2html
9341 !! wikitext
9342 Blah blah blah
9343 [[mi:Template:Foo]]
9344 !! html/php
9345 <p>Blah blah blah
9346 <a href="/wiki/Template:Foo" title="Template:Foo">mi:Template:Foo</a>
9347 </p>
9348 !! html/parsoid
9349 <p>Blah blah blah
9350 <a rel="mw:WikiLink" href="./Template:Foo" title="Template:Foo">mi:Template:Foo</a></p>
9351 !! end
9352
9353 ###
9354 ### Redirects, Parsoid-only
9355 ###
9356
9357 !! test
9358 1. Simple redirect to page
9359 !! wikitext
9360 #REDIRECT [[Main Page]]
9361 !! html/parsoid
9362 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9363 !! end
9364
9365 !! test
9366 2. Other redirect variants
9367 !! wikitext
9368 #REDIRECT [[Main_Page]]
9369 !! html/parsoid
9370 <link rel="mw:PageProp/redirect" href="./Main_Page" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./Main_Page"},"sa":{"href":"Main_Page"}}'/>
9371 !! end
9372
9373 # Not a valid redirect in PHP (although perhaps it was, once upon a time)
9374 # This tests the Parsoid bail-out code.
9375 !! test
9376 3. Other redirect variants
9377 !! options
9378 parsoid=wt2html
9379 !! wikitext
9380 #REDIRECT [[<nowiki>[[Bar]]</nowiki>]]
9381 !! html/parsoid
9382 <ol><li>REDIRECT [[<span typeof="mw:Nowiki">[[Bar]]</span>]]</li></ol>
9383 !! end
9384
9385 !! test
9386 4. Redirect to a templated destination
9387 !! wikitext
9388 #REDIRECT [[{{echo|Foo}}bar]]
9389 !! html/parsoid
9390 <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"}]]}'/>
9391 !! end
9392
9393 !! test
9394 Empty redirect
9395 !! options
9396 parsoid=wt2html,wt2wt
9397 !! wikitext
9398 #REDIRECT [[]]
9399 !! html/parsoid
9400 <ol>
9401 <li>REDIRECT [[]]</li></ol>
9402 !! end
9403
9404 !! test
9405 Optional colon in #REDIRECT
9406 !! options
9407 # the colon is archaic syntax. we support it for wt2html, but we
9408 # don't care that it roundtrips back to the modern syntax.
9409 parsoid=wt2html,html2html
9410 !! wikitext
9411 #REDIRECT:[[Main Page]]
9412 !! html/parsoid
9413 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9414 !! end
9415
9416 !! test
9417 Whitespace in #REDIRECT with optional colon
9418 !! options
9419 # the colon and gratuitous whitespace is archaic syntax. we support
9420 # it for wt2html, but we don't care that it roundtrips back to the
9421 # modern syntax (without extra whitespace)
9422 parsoid=wt2html,html2html
9423 !! wikitext
9424
9425 #REDIRECT
9426 :
9427 [[Main Page]]
9428 !! html/parsoid
9429 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9430 !! end
9431
9432 !! test
9433 Piped link in #REDIRECT
9434 !! options
9435 # content after piped link is ignored. we support this syntax,
9436 # but don't care that the piped link is lost when we roundtrip this.
9437 parsoid=wt2html
9438 !! wikitext
9439 #REDIRECT [[Main Page|bar]]
9440 !! html/parsoid
9441 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9442 !! end
9443
9444 !! test
9445 Redirect to category (T104502)
9446 !! options
9447 parsoid=wt2html,wt2wt
9448 !! wikitext
9449 #REDIRECT [[Category:Foo]]
9450 !! html/parsoid
9451 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
9452 !! end
9453
9454 !! test
9455 Redirect to category with URL encoding (T104502)
9456 !! options
9457 parsoid=wt2html
9458 !! wikitext
9459 #REDIRECT [[Category%3AFoo]]
9460 !! html/parsoid
9461 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
9462 !! end
9463
9464 !! test
9465 Redirect to category page
9466 !! wikitext
9467 #REDIRECT [[:Category:Foo]]
9468 !! html/parsoid
9469 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
9470 !! end
9471
9472 !! test
9473 Redirect to image page (1)
9474 !! wikitext
9475 #REDIRECT [[File:Wiki.png]]
9476 !! html/parsoid
9477 <link rel="mw:PageProp/redirect" href="./File:Wiki.png"/>
9478 !! end
9479
9480 !! test
9481 Redirect to image page (2)
9482 !! wikitext
9483 #REDIRECT [[Image:Wiki.png]]
9484 !! html/parsoid
9485 <link rel="mw:PageProp/redirect" href="./File:Wiki.png" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./File:Wiki.png"},"sa":{"href":"Image:Wiki.png"}}'/>
9486 !! end
9487
9488 # html2wt disabled because wts serializes as "#REDIRECT [[:en:File:Wiki.png]]"
9489 # Next test confirms this.
9490 !! test
9491 Redirect to language (1) (T104918)
9492 !! options
9493 parsoid=wt2html,wt2wt,html2html
9494 !! wikitext
9495 #REDIRECT [[en:File:Wiki.png]]
9496 !! html/parsoid
9497 <link rel="mw:PageProp/redirect" href="//en.wikipedia.org/wiki/File:Wiki.png"/>
9498 !! end
9499
9500 !! test
9501 Redirect to language (2) (T104918)
9502 !! wikitext
9503 #REDIRECT [[:en:File:Wiki.png]]
9504 !! html/parsoid
9505 <link rel="mw:PageProp/redirect" href="//en.wikipedia.org/wiki/File:Wiki.png"/>
9506 !! end
9507
9508 !! test
9509 Redirect to interwiki (T104918)
9510 !! wikitext
9511 #REDIRECT [[meatball:File:Wiki.png]]
9512 !! html/parsoid
9513 <link rel="mw:PageProp/redirect" href="http://www.usemod.com/cgi-bin/mb.pl?File:Wiki.png"/>
9514 !! end
9515
9516 !! test
9517 Non-English #REDIRECT
9518 !! options
9519 language=is
9520 !! wikitext
9521 #TILVÍSUN [[Main Page]]
9522 !! html/parsoid
9523 <link rel="mw:PageProp/redirect" href="./Main_Page" data-parsoid='{"src":"#TILVÍSUN ","a":{"href":"./Main_Page"},"sa":{"href":"Main Page"}}'/>
9524 !! end
9525
9526 !! test
9527 Redirect syntax under text isn't considered a redirect
9528 !! wikitext
9529 some text
9530
9531 #redirect [[Main Page]]
9532 !! html/parsoid
9533 <p>some text</p>
9534 <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>
9535 !! end
9536
9537 !! test
9538 New redirect
9539 !! options
9540 parsoid=html2wt
9541 !! html/parsoid
9542 <p>Foo<link rel="mw:PageProp/redirect" href="./Foo"/></p>
9543 !! wikitext
9544 #REDIRECT [[Foo]]
9545 Foo
9546 !! end
9547
9548 !! test
9549 Redirect followed by block on the same line
9550 !! options
9551 parsoid=wt2html
9552 !! wikitext
9553 #REDIRECT [[Main Page]]<!-- haha -->==hi==
9554 !! html/parsoid
9555 <link rel="mw:PageProp/redirect" href="./Main_Page"/><!-- haha --><h2 id="hi">hi</h2>
9556 !! end
9557
9558 !! test
9559 Redirect followed by a newline
9560 !! wikitext
9561 #REDIRECT [[Main Page]]
9562 A newline
9563 !! html/parsoid
9564 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9565 <p>A newline</p>
9566 !! end
9567
9568 !! test
9569 Redirect followed by multiple newlines
9570 !! wikitext
9571 #REDIRECT [[Main Page]]
9572
9573
9574 A newline
9575 !! html/parsoid
9576 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9577
9578 <p><br/>
9579 A newline</p>
9580 !! end
9581
9582 !! test
9583 Drop duplicate redirects
9584 !! options
9585 parsoid=html2wt
9586 !! html/parsoid
9587 <link rel="mw:PageProp/redirect" href="./Foo"/>
9588 <link rel="mw:PageProp/redirect" href="./Bar"/>
9589 <link rel="mw:PageProp/redirect" href="./Baz"/>
9590 !! wikitext
9591 #REDIRECT [[Foo]]
9592 !! end
9593
9594 ##
9595 ## XHTML tidiness
9596 ###
9597
9598 !! test
9599 <br> to <br />
9600 !! wikitext
9601 1<br>2<br />3
9602 !! html
9603 <p>1<br />2<br />3
9604 </p>
9605 !! end
9606
9607 !! test
9608 Broken br tag sanitization
9609 !! wikitext
9610 </br>
9611 !! html/php
9612 <p>&lt;/br&gt;
9613 </p>
9614 !! end
9615
9616 # TODO: Fix html2html mode (T53055)!
9617 !! test
9618 Parsoid: Broken br tag recognition
9619 !! options
9620 parsoid=wt2html
9621 !! wikitext
9622 </br>
9623
9624 <br/ >
9625 !! html+tidy
9626 <p><br />
9627 </p><p><br />
9628 </p>
9629 !! end
9630
9631 !! test
9632 Incorrecly removing closing slashes from correctly formed XHTML
9633 !! wikitext
9634 <br style="clear:both;" />
9635 !! html
9636 <p><br style="clear:both;" />
9637 </p>
9638 !! end
9639
9640 !! test
9641 Failing to transform badly formed HTML into correct XHTML
9642 !! wikitext
9643 <br style="clear: left;">
9644 <br style="clear: right;">
9645 <br style="clear: both;">
9646 !! html
9647 <p><br style="clear: left;" />
9648 <br style="clear: right;" />
9649 <br style="clear: both;" />
9650 </p>
9651 !!end
9652
9653 ## FIXME: Is Parsoid's acceptance of self-closing html-tags
9654 ## a feature or a bug? See https://phabricator.wikimedia.org/T76962
9655 !! test
9656 Handling html with a div self-closing tag
9657 !! wikitext
9658 <div title />
9659 <div title/>
9660 <div title/ >
9661 <div title=bar />
9662 <div title=bar/>
9663 <div title=bar/ >
9664 !! html/php+tidy
9665 <div title=""></div>
9666 <div title=""></div>
9667 <div title="">
9668 <div title="bar"></div>
9669 <div title="bar"></div>
9670 <div title="bar/">
9671 </div></div>
9672 !! html/parsoid
9673 <div title="" data-parsoid='{"stx":"html","selfClose":true}'></div>
9674 <div title="" data-parsoid='{"stx":"html","selfClose":true}'></div>
9675 <div title="" data-parsoid='{"stx":"html","autoInsertedEnd":true}'>
9676 <div title="bar" data-parsoid='{"stx":"html","selfClose":true}'></div>
9677 <div title="bar" data-parsoid='{"stx":"html","selfClose":true}'></div>
9678 <div title="bar/" data-parsoid='{"stx":"html","autoInsertedEnd":true}'></div></div>
9679 !! end
9680
9681 !! test
9682 Elements with solidus in various attribute positions
9683 !! options
9684 parsoid=wt2html,html2html
9685 !! wikitext
9686 <div cla/ss="123">ha</div>
9687
9688 <div / class="123">ha</div>
9689
9690 <div class= / "123">ha</div>
9691 !! html/php+tidy
9692 <div>ha</div>
9693 <div class="123">ha</div>
9694 <div class="/">ha</div>
9695 !! html/parsoid
9696 <div data-parsoid='{"stx":"html","a":{"cla":null,"ss":null},"sa":{"cla":"","ss":"123"}}'>ha</div>
9697
9698 <div class="123" data-parsoid='{"stx":"html"}'>ha</div>
9699
9700 <div class="/" data-parsoid='{"stx":"html","a":{"\"123\"":null},"sa":{"\"123\"":""}}'>ha</div>
9701 !! end
9702
9703 !! test
9704 Handling html with a br self-closing tag
9705 !! wikitext
9706 <br title />
9707 <br title/>
9708 <br title/ >
9709 <br title=bar />
9710 <br title=bar/>
9711 <br title=bar/ >
9712 !! html/php+tidy
9713 <p><br title="" />
9714 <br title="" />
9715 <br title="" />
9716 <br title="bar" />
9717 <br title="bar" />
9718 <br title="bar/" />
9719 </p>
9720 !! html/parsoid
9721 <p><br title="" />
9722 <br title="" />
9723 <br title="" />
9724 <br title="bar" />
9725 <br title="bar" />
9726 <br title="bar/" />
9727 </p>
9728 !! end
9729
9730 !! test
9731 Quoted attributes without spaces
9732 !! options
9733 parsoid=wt2html
9734 !! wikitext
9735 <div class="foo"style="color:red">red</div>
9736 !! html/php+tidy
9737 <div class="foo" style="color:red">red</div>
9738 !! html/parsoid
9739 <div class="foo" style="color:red">red</div>
9740 !! end
9741
9742 !! test
9743 Horizontal ruler (should it add that extra space?)
9744 !! wikitext
9745 <hr>
9746 <hr >
9747 foo <hr
9748 > bar
9749 !! html+tidy
9750 <hr />
9751 <hr /><p>
9752 foo </p><hr /><p> bar
9753 </p>
9754 !! end
9755
9756 !! test
9757 Horizontal ruler -- 4+ dashes render hr
9758 !! wikitext
9759 ----
9760 !! html
9761 <hr />
9762
9763 !! end
9764
9765 !! test
9766 Horizontal ruler -- eats additional dashes on the same line
9767 !! wikitext
9768 ---------
9769 !! html
9770 <hr />
9771
9772 !! end
9773
9774 !! test
9775 Horizontal ruler -- does not collapse dashes on consecutive lines
9776 !! wikitext
9777 ----
9778 ----
9779 !! html
9780 <hr />
9781 <hr />
9782
9783 !! end
9784
9785 !! test
9786 Horizontal ruler -- <4 dashes render as plain text
9787 !! wikitext
9788 ---
9789 !! html
9790 <p>---
9791 </p>
9792 !! end
9793
9794 !! test
9795 Horizontal ruler -- Supports content following dashes on same line
9796 !! wikitext
9797 ---- Foo
9798 !! html
9799 <hr /> Foo
9800
9801 !! html+tidy
9802 <hr /><p> Foo
9803 </p>
9804 !! end
9805
9806 ###
9807 ### Block-level elements
9808 ###
9809 !! test
9810 Common list
9811 !! wikitext
9812 *Common list
9813 *item 2
9814 *item 3
9815 !! html
9816 <ul><li>Common list</li>
9817 <li>item 2</li>
9818 <li>item 3</li></ul>
9819
9820 !! end
9821
9822 !! test
9823 Numbered list
9824 !! wikitext
9825 #Numbered list
9826 #item 2
9827 #item 3
9828 !! html
9829 <ol><li>Numbered list</li>
9830 <li>item 2</li>
9831 <li>item 3</li></ol>
9832
9833 !! end
9834
9835 # the switch from level 3 to ordered should not introduce a newline between
9836 !! test
9837 Mixed list
9838 !! wikitext
9839 *Mixed list
9840 *#with numbers
9841 **and bullets
9842 *#and numbers
9843 *bullets again
9844 **bullet level 2
9845 ***bullet level 3
9846 ***#Number on level 4
9847 **bullet level 2
9848 **#Number on level 3
9849 **#Number on level 3
9850 *#number level 2
9851 *Level 1
9852 ***Level 3
9853 #**Level 3, but ordered
9854 !! html
9855 <ul><li>Mixed list
9856 <ol><li>with numbers</li></ol>
9857 <ul><li>and bullets</li></ul>
9858 <ol><li>and numbers</li></ol></li>
9859 <li>bullets again
9860 <ul><li>bullet level 2
9861 <ul><li>bullet level 3
9862 <ol><li>Number on level 4</li></ol></li></ul></li>
9863 <li>bullet level 2
9864 <ol><li>Number on level 3</li>
9865 <li>Number on level 3</li></ol></li></ul>
9866 <ol><li>number level 2</li></ol></li>
9867 <li>Level 1
9868 <ul><li><ul><li>Level 3</li></ul></li></ul></li></ul>
9869 <ol><li><ul><li><ul><li>Level 3, but ordered</li></ul></li></ul></li></ol>
9870
9871 !! end
9872
9873 !! test
9874 1. Nested mixed wikitext and html list
9875 !! wikitext
9876 *hi
9877 *<ul><li>ho</li></ul>
9878 *hi
9879 **ho
9880 !! html/php
9881 <ul><li>hi</li>
9882 <li><ul><li>ho</li></ul></li>
9883 <li>hi
9884 <ul><li>ho</li></ul></li></ul>
9885
9886 !! html/parsoid
9887 <ul><li>hi</li>
9888 <li><ul data-parsoid='{"stx":"html"}'><li data-parsoid='{"stx":"html"}'>ho</li></ul></li>
9889 <li>hi
9890 <ul><li>ho</li></ul></li></ul>
9891 !! end
9892
9893 !! test
9894 2. Nested mixed wikitext and html list (incompatible)
9895 !! wikitext
9896 ;hi
9897 :{{echo|<li>ho</li>}}
9898 !! html/php
9899 <dl><dt>hi</dt>
9900 <dd><li>ho</li></dd></dl>
9901
9902 !! html/parsoid
9903 <dl><dt>hi</dt>
9904 <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>
9905 !! end
9906
9907 !! test
9908 Nested lists 1
9909 !! wikitext
9910 *foo
9911 **bar
9912 !! html
9913 <ul><li>foo
9914 <ul><li>bar</li></ul></li></ul>
9915
9916 !! end
9917
9918 !! test
9919 Nested lists 2
9920 !! wikitext
9921 **foo
9922 *bar
9923 !! html
9924 <ul><li><ul><li>foo</li></ul></li>
9925 <li>bar</li></ul>
9926
9927 !! end
9928
9929 !! test
9930 Nested lists 3 (first element empty)
9931 !! wikitext
9932 *
9933 **bar
9934 !! html
9935 <ul><li>
9936 <ul><li>bar</li></ul></li></ul>
9937
9938 !! end
9939
9940 !! test
9941 Nested lists 4 (first element empty)
9942 !! wikitext
9943 **
9944 *bar
9945 !! html
9946 <ul><li><ul><li></li></ul></li>
9947 <li>bar</li></ul>
9948
9949 !! end
9950
9951 !! test
9952 Nested lists 5 (both elements empty)
9953 !! wikitext
9954 **
9955 *
9956 !! html
9957 <ul><li><ul><li></li></ul></li>
9958 <li></li></ul>
9959
9960 !! end
9961
9962 !! test
9963 Nested lists 6 (both elements empty)
9964 !! wikitext
9965 *
9966 **
9967 !! html
9968 <ul><li>
9969 <ul><li></li></ul></li></ul>
9970
9971 !! end
9972
9973 !! test
9974 Nested lists 7 (skip initial nesting levels)
9975 !! wikitext
9976 ***foo
9977 !! html
9978 <ul><li><ul><li><ul><li>foo</li></ul></li></ul></li></ul>
9979
9980 !! end
9981
9982 !! test
9983 Nested lists 8 (multiple nesting transitions)
9984 !! wikitext
9985 *foo
9986 ***bar
9987 **baz
9988 *boo
9989 !! html
9990 <ul><li>foo
9991 <ul><li><ul><li>bar</li></ul></li>
9992 <li>baz</li></ul></li>
9993 <li>boo</li></ul>
9994
9995 !! end
9996
9997 # XXX this test should be moved to citeParserTests, since it depends
9998 # on the Cite extension, which is "built in" to Parsoid.
9999 !! test
10000 Nested lists 9 (extension interaction)
10001 !! wikitext
10002 *<references />
10003 !! html/php+tidy-DISABLED
10004 <ul><li class="mw-empty-elt"></li></ul>
10005 !! html/parsoid
10006 <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>
10007 !! end
10008
10009 !! test
10010 1. Lists with start-of-line-transparent tokens before bullets: Comments
10011 !! wikitext
10012 *foo
10013 *<!--cmt-->bar
10014 <!--cmt-->*baz
10015 !! html
10016 <ul><li>foo</li>
10017 <li>bar</li>
10018 <li>baz</li></ul>
10019
10020 !! end
10021
10022 !! test
10023 Nested lists 10 (list and span siblings: wt2wt regression)
10024 !! wikitext
10025 *a <span>x</span>
10026 **b <span>y</span>
10027 !! html/parsoid
10028 <ul><li>a <span>x</span>
10029 <ul><li>b <span>y</span></li></ul></li></ul>
10030 !! end
10031
10032 !! test
10033 2. Lists with start-of-line-transparent tokens before bullets: Template close
10034 !! wikitext
10035 *foo {{echo|bar
10036 }}*baz
10037 !! html
10038 <ul><li>foo bar</li>
10039 <li>baz</li></ul>
10040
10041 !! end
10042
10043 !! test
10044 List items are not parsed correctly following a <pre> block (T2785)
10045 !! wikitext
10046 *<pre>foo</pre>
10047 *<pre>bar</pre>
10048 *zar
10049 !! html/php
10050 <ul><li><pre>foo</pre></li>
10051 <li><pre>bar</pre></li>
10052 <li>zar</li></ul>
10053
10054 !! html/parsoid
10055 <ul><li><pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo"}}'>foo</pre></li>
10056 <li><pre typeof="mw:Extension/pre" about="#mwt4" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"bar"}}'>bar</pre></li>
10057 <li>zar</li></ul>
10058 !! end
10059
10060 # FIXME: Might benefit from a html/parsoid since this has a template
10061 !! test
10062 List items from template
10063 !! wikitext
10064
10065 {{inner list}}
10066 *item 2
10067
10068 *item 0
10069 {{inner list}}
10070 *item 2
10071
10072 *item 0
10073 *notSOL{{inner list}}
10074 *item 2
10075 !! html
10076 <ul><li>item 1</li>
10077 <li>item 2</li></ul>
10078 <ul><li>item 0</li>
10079 <li>item 1</li>
10080 <li>item 2</li></ul>
10081 <ul><li>item 0</li>
10082 <li>notSOL</li>
10083 <li>item 1</li>
10084 <li>item 2</li></ul>
10085
10086 !! end
10087
10088 !! test
10089 List interrupted by empty line or heading
10090 !! wikitext
10091 *foo
10092
10093 **bar
10094 ==A heading==
10095 *Another list item
10096 !! html
10097 <ul><li>foo</li></ul>
10098 <ul><li><ul><li>bar</li></ul></li></ul>
10099 <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>
10100 <ul><li>Another list item</li></ul>
10101
10102 !!end
10103
10104 !! test
10105 Multiple list tags generated by templates
10106 !! wikitext
10107 {{echo|<li>}}a
10108 {{echo|<li>}}b
10109 {{echo|<li>}}c
10110 !! html
10111 <li>a
10112 <li>b
10113 <li>c</li>
10114 </li>
10115 </li>
10116
10117
10118 !! html+tidy
10119 <li>a
10120 </li><li>b
10121 </li><li>c
10122 </li>
10123 !! html/parsoid
10124 <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>
10125 <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>
10126 <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>
10127 !! end
10128
10129 !! test
10130 Multiple newlines in between HTML list items don't induce paragraph wrapping
10131 !! wikitext
10132 <ul>
10133 <li>hi</li>
10134
10135
10136
10137
10138 <li>ho</li>
10139 </ul>
10140
10141 <dl>
10142 <dt>hi</dt>
10143 <dd>ho<div>123</div>
10144 </dd>
10145
10146
10147 </dl>
10148 !! html/php+tidy
10149 <ul>
10150 <li>hi</li>
10151
10152
10153
10154
10155 <li>ho</li>
10156 </ul>
10157 <dl>
10158 <dt>hi</dt>
10159 <dd>ho<div>123</div>
10160 </dd>
10161
10162
10163 </dl>
10164 !! end
10165
10166 !!test
10167 Single-comment whitespace lines dont break lists, and neither do multi-comment whitespace lines
10168 !! wikitext
10169 *a
10170 <!--This line will NOT split the list-->
10171 *b
10172 <!--This line will NOT split the list either-->
10173 *c
10174 <!--foo--> <!----> <!--This line NOT split the list either-->
10175 *d
10176 !! html
10177 <ul><li>a</li>
10178 <li>b</li>
10179 <li>c</li>
10180 <li>d</li></ul>
10181
10182 !!end
10183
10184 !!test
10185 Replacing whitespace with tabs still doesn't break the list (gerrit 78327)
10186 !! wikitext
10187 *a
10188 <!--This line will NOT split the list-->
10189 *b
10190 <!--This line will NOT split the list either-->
10191 *c
10192 <!--foo--> <!----> <!--This line NOT split the list
10193 either-->
10194 *d
10195 !! html
10196 <ul><li>a</li>
10197 <li>b</li>
10198 <li>c</li>
10199 <li>d</li></ul>
10200
10201 !!end
10202
10203 # FIXME: Parsoid has a dedicated DOM pass to mimic this Tidy-specific li-hack
10204 # That pass could possibly be removed.
10205 !!test
10206 Test the li-hack (a hack from Tidy days, but doesn't work as advertised with Remex)
10207 !!options
10208 parsoid=wt2html,wt2wt
10209 !! wikitext
10210 *foo
10211 *<li>li-hack
10212 *{{echo|<li>templated li-hack}}
10213 *<!--foo--><li> unsupported li-hack with preceding comments
10214
10215 <ul>
10216 <li><li>not a li-hack
10217 </li>
10218 </ul>
10219 !! html+tidy
10220 <ul><li>foo</li>
10221 <li class="mw-empty-elt"></li><li>li-hack</li>
10222 <li class="mw-empty-elt"></li><li>templated li-hack</li>
10223 <li class="mw-empty-elt"></li><li> unsupported li-hack with preceding comments</li></ul>
10224 <ul>
10225 <li class="mw-empty-elt"></li><li>not a li-hack
10226 </li>
10227 </ul>
10228 !! html/parsoid
10229 <ul><li> foo</li>
10230 <li data-parsoid='{"stx":"html","autoInsertedEnd":true,"liHackSrc":"*"}'>li-hack</li>
10231 <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>
10232 <li data-parsoid='{"autoInsertedEnd":true}'><!--foo--></li><li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>unsupported li-hack with preceding comments</li></ul>
10233
10234 <ul data-parsoid='{"stx":"html"}'>
10235 <li class="mw-empty-elt" data-parsoid='{"stx":"html","autoInsertedEnd":true}'></li><li data-parsoid='{"stx":"html"}'>not a li-hack
10236 </li>
10237 </ul>
10238
10239 !!end
10240
10241 !! test
10242 Parsoid: Make sure nested lists are serialized on their own line even if HTML contains no newlines
10243 !! wikitext
10244 #foo
10245 ##bar
10246
10247 *foo
10248 **bar
10249
10250 :foo
10251 ::bar
10252 !! html/php+tidy
10253 <ol><li>foo
10254 <ol><li>bar</li></ol></li></ol>
10255 <ul><li>foo
10256 <ul><li>bar</li></ul></li></ul>
10257 <dl><dd>foo
10258 <dl><dd>bar</dd></dl></dd></dl>
10259 !! html/parsoid
10260 <ol>
10261 <li>foo<ol>
10262 <li>bar</li>
10263 </ol></li>
10264 </ol><ul>
10265 <li>foo<ul>
10266 <li>bar</li>
10267 </ul></li>
10268 </ul><dl>
10269 <dd>foo<dl>
10270 <dd>bar</dd>
10271 </dl></dd>
10272 </dl>
10273 !! end
10274
10275 !! test
10276 Parsoid: Test of whitespace serialization with Templated bullets
10277 !! options
10278 parsoid=wt2html
10279 !! wikitext
10280 * {{bullet}}
10281 !! html/parsoid
10282 <ul>
10283 <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>
10284 </ul>
10285 !! end
10286
10287 # ------------------------------------------------------------------------
10288 # The next set of tests are about Parsoid's ability to handle badly nested
10289 # tags (parse, minimize scope of fixup, and roundtrip back)
10290 # ------------------------------------------------------------------------
10291
10292 # Remex and Parsoid output stems from list handling diffs because Parsoid & PHP parser.
10293 # Parsoid's list handling is more aware of block structure.
10294 !! test
10295 Unbalanced closing block tags break a list
10296 !! wikitext
10297 <div>
10298 *a</div><div>
10299 *b</div>
10300 !! html+tidy
10301 <div>
10302 <ul><li>a</li></ul></div><div>
10303 <li>b</li></div>
10304 !! html/parsoid
10305 <div><ul>
10306 <li>a</li>
10307 </ul></div>
10308 <div><ul>
10309 <li>b</li>
10310 </ul></div>
10311 !! end
10312
10313 !! test
10314 Unbalanced closing non-block tags don't break a list
10315 !! options
10316 parsoid=wt2html,html2html
10317 !! wikitext
10318 <span>
10319 *a</span><span>
10320 *b</span>
10321 !! html/php+tidy
10322 <p><span>
10323 </span></p>
10324 <ul><li>a<span></span></li>
10325 <li>b</li></ul>
10326 !! html/parsoid
10327 <p><span data-parsoid='{"stx":"html","autoInsertedEnd":true}'></span></p>
10328 <ul><li>a<span data-parsoid='{"stx":"html","autoInsertedEnd":true}'></span></li>
10329 <li>b</li></ul>
10330 !! end
10331
10332 # Parsoid does some post-dom-building cleanup
10333 # which is why its output differs from Remex.
10334 !! test
10335 Unclosed formatting tags that straddle lists are closed and reopened
10336 !! options
10337 parsoid=wt2html,wt2wt,html2html
10338 !! wikitext
10339 #<s> a
10340 #b </s>
10341 !! html/php+tidy
10342 <ol><li><s> a</s></li><s>
10343 </s><li><s>b </s></li></ol>
10344 !! html/parsoid
10345 <ol><li><s> a</s></li>
10346 <li><s>b </s></li></ol>
10347 !! end
10348
10349 # Output is ugly because of all the misnested tag fixups.
10350 !! test
10351 1. List embedded in a formatting tag
10352 !! wikitext
10353 <small>
10354 *foo
10355 </small>
10356 !! html/php+tidy
10357 <p><small>
10358 </small></p><small><ul><li>foo</li></ul></small><small></small><p><small></small>
10359 </p>
10360 !! html/parsoid
10361 <p><small data-parsoid='{"stx":"html","autoInsertedEnd":true}'></small></p><small data-parsoid='{"stx":"html","autoInsertedEnd":true,"autoInsertedStart":true}'>
10362 <ul><li data-parsoid='{}'>foo</li></ul></small>
10363 <p><small data-parsoid='{"stx":"html","autoInsertedStart":true}'></small></p>
10364 !! end
10365
10366 # Output is ugly because of all the misnested tag fixups.
10367 !! test
10368 2. List embedded in a formatting tag in a misnested way
10369 !! wikitext
10370 <small>
10371 *a
10372 *b</small>
10373 !! html/php+tidy
10374 <p><small>
10375 </small></p><small></small><ul><small><li>a</li>
10376 </small><li><small>b</small></li></ul>
10377 !! html/parsoid
10378 <p><small data-parsoid='{"stx":"html","autoInsertedEnd":true}'></small></p>
10379 <ul><small data-parsoid='{"stx":"html","autoInsertedEnd":true,"autoInsertedStart":true}'><li>a</li></small>
10380 <li><small data-parsoid='{"stx":"html","autoInsertedStart":true}'>b</small></li></ul>
10381 !! end
10382
10383 # Output is ugly because of all the misnested tag fixups.
10384 !! test
10385 3. List embedded in a formatting tag in a misnested way
10386 !! wikitext
10387 <small>
10388
10389 ** 123</small>
10390 !! html/php+tidy
10391 <p><small>
10392 </small></p><small></small><ul><small></small><li><small></small><ul><small></small><li><small>123</small></li></ul></li></ul>
10393 !! html/parsoid
10394 <p><small data-parsoid='{"stx":"html","autoInsertedEnd":true}'></small></p>
10395
10396 <ul><li><ul><li data-parsoid='{}'><small data-parsoid='{"stx":"html","autoInsertedStart":true}'> 123</small></li></ul></li></ul>
10397 !! end
10398
10399 ###
10400 ### Magic Words
10401 ###
10402
10403 # Note that the current date is hard-coded as
10404 # 1970-01-01T00:02:03Z (a Thursday)
10405 # when running parser tests. The timezone is also fixed to GMT, so
10406 # local date will be identical to current date.
10407
10408 !! test
10409 Magic Word: {{CURRENTDAY}}
10410 !! wikitext
10411 {{CURRENTDAY}}
10412 !! html
10413 <p>1
10414 </p>
10415 !! end
10416
10417 !! test
10418 Magic Word: {{CURRENTDAY2}}
10419 !! wikitext
10420 {{CURRENTDAY2}}
10421 !! html
10422 <p>01
10423 </p>
10424 !! end
10425
10426 !! test
10427 Magic Word: {{CURRENTDAYNAME}}
10428 !! wikitext
10429 {{CURRENTDAYNAME}}
10430 !! html
10431 <p>Thursday
10432 </p>
10433 !! end
10434
10435 !! test
10436 Magic Word: {{CURRENTDOW}}
10437 !! wikitext
10438 {{CURRENTDOW}}
10439 !! html
10440 <p>4
10441 </p>
10442 !! end
10443
10444 !! test
10445 Magic Word: {{CURRENTMONTH}}
10446 !! wikitext
10447 {{CURRENTMONTH}}
10448 !! html
10449 <p>01
10450 </p>
10451 !! end
10452
10453 !! test
10454 Magic Word: {{CURRENTMONTH1}}
10455 !! wikitext
10456 {{CURRENTMONTH1}}
10457 !! html
10458 <p>1
10459 </p>
10460 !! end
10461
10462 !! test
10463 Magic Word: {{CURRENTMONTHABBREV}}
10464 !! wikitext
10465 {{CURRENTMONTHABBREV}}
10466 !! html
10467 <p>Jan
10468 </p>
10469 !! end
10470
10471 !! test
10472 Magic Word: {{CURRENTMONTHNAME}}
10473 !! wikitext
10474 {{CURRENTMONTHNAME}}
10475 !! html
10476 <p>January
10477 </p>
10478 !! end
10479
10480 !! test
10481 Magic Word: {{CURRENTMONTHNAMEGEN}}
10482 !! wikitext
10483 {{CURRENTMONTHNAMEGEN}}
10484 !! html
10485 <p>January
10486 </p>
10487 !! end
10488
10489 !! test
10490 Magic Word: {{CURRENTTIME}}
10491 !! wikitext
10492 {{CURRENTTIME}}
10493 !! html
10494 <p>00:02
10495 </p>
10496 !! end
10497
10498 !! test
10499 Magic Word: {{CURRENTHOUR}}
10500 !! wikitext
10501 {{CURRENTHOUR}}
10502 !! html
10503 <p>00
10504 </p>
10505 !! end
10506
10507 !! test
10508 Magic Word: {{CURRENTWEEK}} (T6594)
10509 !! wikitext
10510 {{CURRENTWEEK}}
10511 !! html
10512 <p>1
10513 </p>
10514 !! end
10515
10516 !! test
10517 Magic Word: {{CURRENTYEAR}}
10518 !! wikitext
10519 {{CURRENTYEAR}}
10520 !! html
10521 <p>1970
10522 </p>
10523 !! end
10524
10525 !! test
10526 Magic Word: {{CURRENTTIMESTAMP}}
10527 !! wikitext
10528 {{CURRENTTIMESTAMP}}
10529 !! html
10530 <p>19700101000203
10531 </p>
10532 !! end
10533
10534 !! test
10535 Magic Words LOCAL (UTC)
10536 !! wikitext
10537 *{{LOCALMONTH}}
10538 *{{LOCALMONTH1}}
10539 *{{LOCALMONTHNAME}}
10540 *{{LOCALMONTHNAMEGEN}}
10541 *{{LOCALMONTHABBREV}}
10542 *{{LOCALDAY}}
10543 *{{LOCALDAY2}}
10544 *{{LOCALDAYNAME}}
10545 *{{LOCALYEAR}}
10546 *{{LOCALTIME}}
10547 *{{LOCALHOUR}}
10548 *{{LOCALWEEK}}
10549 *{{LOCALDOW}}
10550 *{{LOCALTIMESTAMP}}
10551 !! html
10552 <ul><li>01</li>
10553 <li>1</li>
10554 <li>January</li>
10555 <li>January</li>
10556 <li>Jan</li>
10557 <li>1</li>
10558 <li>01</li>
10559 <li>Thursday</li>
10560 <li>1970</li>
10561 <li>00:02</li>
10562 <li>00</li>
10563 <li>1</li>
10564 <li>4</li>
10565 <li>19700101000203</li></ul>
10566
10567 !! end
10568
10569 !! test
10570 Magic Word: {{FULLPAGENAME}}
10571 !! options
10572 title=[[User:Ævar Arnfjörð Bjarmason]]
10573 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10574 !! wikitext
10575 {{FULLPAGENAME}}
10576 !! html/*
10577 <p>User:Ævar Arnfjörð Bjarmason
10578 </p>
10579 !! end
10580
10581 !! test
10582 Magic Word: {{FULLPAGENAMEE}}
10583 !! options
10584 title=[[User:Ævar Arnfjörð Bjarmason]]
10585 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10586 !! wikitext
10587 {{FULLPAGENAMEE}}
10588 !! html/*
10589 <p>User:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10590 </p>
10591 !! end
10592
10593 !! test
10594 Magic Word: {{TALKSPACE}}
10595 !! options
10596 title=[[User:Ævar Arnfjörð Bjarmason]]
10597 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10598 !! wikitext
10599 {{TALKSPACE}}
10600 !! html/*
10601 <p>User talk
10602 </p>
10603 !! end
10604
10605 !! test
10606 Magic Word: {{TALKSPACE}}, same namespace
10607 !! options
10608 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10609 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10610 !! wikitext
10611 {{TALKSPACE}}
10612 !! html/*
10613 <p>User talk
10614 </p>
10615 !! end
10616
10617 !! test
10618 Magic Word: {{TALKSPACE}}, main namespace
10619 !! options
10620 title=[[Parser Test]]
10621 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10622 !! wikitext
10623 {{TALKSPACE}}
10624 !! html/*
10625 <p>Talk
10626 </p>
10627 !! end
10628
10629 !! test
10630 Magic Word: {{TALKSPACEE}}
10631 !! options
10632 title=[[User:Ævar Arnfjörð Bjarmason]]
10633 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10634 !! wikitext
10635 {{TALKSPACEE}}
10636 !! html/*
10637 <p>User_talk
10638 </p>
10639 !! end
10640
10641 !! test
10642 Magic Word: {{SUBJECTSPACE}}
10643 !! options
10644 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10645 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10646 !! wikitext
10647 {{SUBJECTSPACE}}
10648 !! html/*
10649 <p>User
10650 </p>
10651 !! end
10652
10653 !! test
10654 Magic Word: {{SUBJECTSPACE}}, same namespace
10655 !! options
10656 title=[[User:Ævar Arnfjörð Bjarmason]]
10657 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10658 !! wikitext
10659 {{SUBJECTSPACE}}
10660 !! html/*
10661 <p>User
10662 </p>
10663 !! end
10664
10665 !! test
10666 Magic Word: {{SUBJECTSPACE}}, main namespace
10667 !! options
10668 title=[[Parser Test]]
10669 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10670 !! wikitext
10671 {{SUBJECTSPACE}}
10672 !! html/*
10673
10674 !! end
10675
10676 !! test
10677 Magic Word: {{SUBJECTSPACEE}}
10678 !! options
10679 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10680 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10681 !! wikitext
10682 {{SUBJECTSPACEE}}
10683 !! html/*
10684 <p>User
10685 </p>
10686 !! end
10687
10688 !! test
10689 Magic Word: {{NAMESPACE}}
10690 !! options
10691 title=[[User:Ævar Arnfjörð Bjarmason]]
10692 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10693 !! wikitext
10694 {{NAMESPACE}}
10695 !! html/*
10696 <p>User
10697 </p>
10698 !! end
10699
10700 !! test
10701 Magic Word: {{NAMESPACEE}}
10702 !! options
10703 title=[[User:Ævar Arnfjörð Bjarmason]]
10704 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10705 !! wikitext
10706 {{NAMESPACEE}}
10707 !! html/*
10708 <p>User
10709 </p>
10710 !! end
10711
10712 !! test
10713 Magic Word: {{NAMESPACENUMBER}}
10714 !! options
10715 title=[[User:Ævar Arnfjörð Bjarmason]]
10716 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10717 !! wikitext
10718 {{NAMESPACENUMBER}}
10719 !! html/*
10720 <p>2
10721 </p>
10722 !! end
10723
10724 !! test
10725 Magic Word: {{SUBPAGENAME}}
10726 !! options
10727 title=[[Ævar Arnfjörð Bjarmason/sub ö]] subpage
10728 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10729 !! wikitext
10730 {{SUBPAGENAME}}
10731 !! html/*
10732 <p>sub ö
10733 </p>
10734 !! end
10735
10736 !! test
10737 Magic Word: {{SUBPAGENAMEE}}
10738 !! options
10739 title=[[Ævar Arnfjörð Bjarmason/sub ö]] subpage
10740 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10741 !! wikitext
10742 {{SUBPAGENAMEE}}
10743 !! html/*
10744 <p>sub_%C3%B6
10745 </p>
10746 !! end
10747
10748 !! test
10749 Magic Word: {{ROOTPAGENAME}}
10750 !! options
10751 title=[[Ævar Arnfjörð Bjarmason/sub/sub2]] subpage
10752 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10753 !! wikitext
10754 {{ROOTPAGENAME}}
10755 !! html/*
10756 <p>Ævar Arnfjörð Bjarmason
10757 </p>
10758 !! end
10759
10760 !! test
10761 Magic Word: {{ROOTPAGENAMEE}}
10762 !! options
10763 title=[[Ævar Arnfjörð Bjarmason/sub/sub2]] subpage
10764 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10765 !! wikitext
10766 {{ROOTPAGENAMEE}}
10767 !! html/*
10768 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10769 </p>
10770 !! end
10771
10772 !! test
10773 Magic Word: {{BASEPAGENAME}}
10774 !! options
10775 title=[[Ævar Arnfjörð Bjarmason/sub]] subpage
10776 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10777 !! wikitext
10778 {{BASEPAGENAME}}
10779 !! html/*
10780 <p>Ævar Arnfjörð Bjarmason
10781 </p>
10782 !! end
10783
10784 !! test
10785 Magic Word: {{BASEPAGENAMEE}}
10786 !! options
10787 title=[[Ævar Arnfjörð Bjarmason/sub]] subpage
10788 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10789 !! wikitext
10790 {{BASEPAGENAMEE}}
10791 !! html/*
10792 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10793 </p>
10794 !! end
10795
10796 !! test
10797 Magic Word: {{TALKPAGENAME}}
10798 !! options
10799 title=[[User:Ævar Arnfjörð Bjarmason]]
10800 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10801 !! wikitext
10802 {{TALKPAGENAME}}
10803 !! html/*
10804 <p>User talk:Ævar Arnfjörð Bjarmason
10805 </p>
10806 !! end
10807
10808 !! test
10809 Magic Word: {{TALKPAGENAMEE}}
10810 !! options
10811 title=[[User:Ævar Arnfjörð Bjarmason]]
10812 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10813 !! wikitext
10814 {{TALKPAGENAMEE}}
10815 !! html/*
10816 <p>User_talk:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10817 </p>
10818 !! end
10819
10820 !! test
10821 Magic Word: {{SUBJECTPAGENAME}}
10822 !! options
10823 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10824 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10825 !! wikitext
10826 {{SUBJECTPAGENAME}}
10827 !! html/*
10828 <p>User:Ævar Arnfjörð Bjarmason
10829 </p>
10830 !! end
10831
10832 !! test
10833 Magic Word: {{SUBJECTPAGENAMEE}}
10834 !! options
10835 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10836 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10837 !! wikitext
10838 {{SUBJECTPAGENAMEE}}
10839 !! html/*
10840 <p>User:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10841 </p>
10842 !! end
10843
10844 !! test
10845 Magic Word: {{NUMBEROFFILES}}
10846 !! options
10847 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10848 !! wikitext
10849 {{NUMBEROFFILES}}
10850 !! html/*
10851 <p>7
10852 </p>
10853 !! end
10854
10855 !! test
10856 Magic Word: {{PAGENAME}}
10857 !! options
10858 title=[[User:Ævar Arnfjörð Bjarmason]]
10859 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10860 !! wikitext
10861 {{PAGENAME}}
10862 !! html/*
10863 <p>Ævar Arnfjörð Bjarmason
10864 </p>
10865 !! end
10866
10867 !! test
10868 Magic Word: {{PAGENAME}} with metacharacters
10869 !! options
10870 title=[['foo & bar = baz']]
10871 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10872 !! wikitext
10873 ''{{PAGENAME}}''
10874 !! html+tidy
10875 <p><i>&#39;foo &#38; bar &#61; baz&#39;</i>
10876 </p>
10877 !! end
10878
10879 !! test
10880 Magic Word: {{PAGENAME}} with metacharacters (T28781)
10881 !! options
10882 title=[[*RFC 1234 http://example.com/]]
10883 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10884 !! wikitext
10885 {{PAGENAME}}
10886 !! html+tidy
10887 <p>&#42;RFC&#32;1234 http&#58;//example.com/
10888 </p>
10889 !! end
10890
10891 !! test
10892 Magic Word: {{PAGENAMEE}}
10893 !! options
10894 title=[[User:Ævar Arnfjörð Bjarmason]]
10895 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10896 !! wikitext
10897 {{PAGENAMEE}}
10898 !! html/*
10899 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10900 </p>
10901 !! end
10902
10903 !! test
10904 Magic Word: {{PAGENAMEE}} with metacharacters (T28781)
10905 !! options
10906 title=[[*RFC 1234 http://example.com/]]
10907 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10908 !! wikitext
10909 {{PAGENAMEE}}
10910 !! html+tidy
10911 <p>&#42;RFC_1234_http&#58;//example.com/
10912 </p>
10913 !! end
10914
10915 !! test
10916 Magic Word: {{REVISIONID}}
10917 !! options
10918 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10919 showflags
10920 !! wikitext
10921 {{REVISIONID}}
10922 !! html/*
10923 <p>1337
10924 </p>
10925 flags=vary-revision-id
10926 !! end
10927
10928 !! test
10929 Magic Word: {{SCRIPTPATH}}
10930 !! options
10931 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10932 !! wikitext
10933 {{SCRIPTPATH}}
10934 !! html/*
10935
10936 !! end
10937
10938 !! test
10939 Magic Word: {{STYLEPATH}}
10940 !! options
10941 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10942 !! wikitext
10943 {{STYLEPATH}}
10944 !! html/*
10945 <p>/skins
10946 </p>
10947 !! end
10948
10949 !! test
10950 Magic Word: {{SERVER}}
10951 !! options
10952 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10953 !! wikitext
10954 {{SERVER}}
10955 !! html/*
10956 <p><a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>
10957 </p>
10958 !! end
10959
10960 !! test
10961 Magic Word: {{SERVERNAME}}
10962 !! options
10963 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10964 !! wikitext
10965 {{SERVERNAME}}
10966 !! html/*
10967 <p>example.org
10968 </p>
10969 !! end
10970
10971 !! test
10972 Magic Word: {{SITENAME}}
10973 !! options
10974 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10975 !! wikitext
10976 {{SITENAME}}
10977 !! html/*
10978 <p>MediaWiki
10979 </p>
10980 !! end
10981
10982 !! test
10983 Magic Word: {{PAGELANGUAGE}}
10984 !! options
10985 language=fr
10986 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10987 !! wikitext
10988 {{PAGELANGUAGE}}
10989 !! html/*
10990 <p>fr
10991 </p>
10992 !! end
10993
10994 !! test
10995 Magic Word: {{PAGELANGUAGE}} on a page with no explicitly set language
10996 !! options
10997 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10998 !! wikitext
10999 {{PAGELANGUAGE}}
11000 !! html/*
11001 <p>en
11002 </p>
11003 !! end
11004
11005 !! test
11006 Case-sensitive magic words, when cased differently, should just be template transclusions
11007 !! wikitext
11008 {{CurrentMonth}}
11009 {{currentday}}
11010 {{cURreNTweEK}}
11011 {{currentHour}}
11012 !! html
11013 <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>
11014 <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>
11015 <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>
11016 <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>
11017 </p>
11018 !! end
11019
11020 !! test
11021 Case-insensitive magic words should still work with weird casing.
11022 !! wikitext
11023 {{sErVeRNaMe}}
11024 {{LCFirst:AOEU}}
11025 {{ucFIRST:aoeu}}
11026 {{SERver}}
11027 !! html
11028 <p>example.org
11029 aOEU
11030 Aoeu
11031 <a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>
11032 </p>
11033 !! end
11034
11035 # From plwiki:PLOS_ONE
11036 !! test
11037 Parsoid: Page property magic word with magic word contents
11038 !! options
11039 showtitle
11040 !! config
11041 wgAllowDisplayTitle=true
11042 wgRestrictDisplayTitle=false
11043 !! wikitext
11044 {{DISPLAYTITLE:''{{PAGENAME}}''}}
11045 !! html/php+tidy
11046 <i>Parser test</i>
11047
11048 !! html/parsoid
11049 <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>"}]]}'/>
11050 !! end
11051
11052 # NOTE: mw:ExpandedAttrs is not the best typeof here. mw:Transclusion is better.
11053 # But, this is a limitation of our representation and is documented in
11054 # TemplateHandler.js in processSpecialMagicWord
11055 !! test
11056 Parsoid: Template-generated DISPLAYTITLE
11057 !! wikitext
11058 {{{{echo|DISPLAYTITLE}}:Foo}}
11059 !! options
11060 showtitle
11061 !! config
11062 wgAllowDisplayTitle=true
11063 wgRestrictDisplayTitle=false
11064 !! html/php
11065 Foo
11066
11067 !! html/parsoid
11068 <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"}]]}'/>
11069 !! end
11070
11071 !! test
11072 Namespace 1 {{ns:1}}
11073 !! wikitext
11074 {{ns:1}}
11075 !! html
11076 <p>Talk
11077 </p>
11078 !! end
11079
11080 !! test
11081 Namespace 1 {{ns:01}}
11082 !! wikitext
11083 {{ns:01}}
11084 !! html
11085 <p>Talk
11086 </p>
11087 !! end
11088
11089 !! test
11090 Namespace 0 {{ns:0}} (T6783)
11091 !! wikitext
11092 {{ns:0}}
11093 !! html
11094
11095 !! end
11096
11097 !! test
11098 Namespace 0 {{ns:00}} (T6783)
11099 !! wikitext
11100 {{ns:00}}
11101 !! html
11102
11103 !! end
11104
11105 !! test
11106 Namespace -1 {{ns:-1}}
11107 !! wikitext
11108 {{ns:-1}}
11109 !! html
11110 <p>Special
11111 </p>
11112 !! end
11113
11114 !! test
11115 Namespace User {{ns:User}}
11116 !! wikitext
11117 {{ns:User}}
11118 !! html
11119 <p>User
11120 </p>
11121 !! end
11122
11123 !! test
11124 Namespace User talk {{ns:User_talk}}
11125 !! wikitext
11126 {{ns:User_talk}}
11127 !! html
11128 <p>User talk
11129 </p>
11130 !! end
11131
11132 !! test
11133 Namespace User talk {{ns:uSeR tAlK}}
11134 !! wikitext
11135 {{ns:uSeR tAlK}}
11136 !! html
11137 <p>User talk
11138 </p>
11139 !! end
11140
11141 !! test
11142 Namespace File {{ns:File}}
11143 !! wikitext
11144 {{ns:File}}
11145 !! html
11146 <p>File
11147 </p>
11148 !! end
11149
11150 !! test
11151 Namespace File {{ns:Image}}
11152 !! wikitext
11153 {{ns:Image}}
11154 !! html
11155 <p>File
11156 </p>
11157 !! end
11158
11159 !! test
11160 Namespace (lang=de) Benutzer {{ns:User}}
11161 !! options
11162 language=de
11163 !! wikitext
11164 {{ns:User}}
11165 !! html
11166 <p>Benutzer
11167 </p>
11168 !! end
11169
11170 !! test
11171 Namespace (lang=de) Benutzer Diskussion {{ns:3}}
11172 !! options
11173 language=de
11174 !! wikitext
11175 {{ns:3}}
11176 !! html
11177 <p>Benutzer Diskussion
11178 </p>
11179 !! end
11180
11181 !! test
11182 Urlencode
11183 !! wikitext
11184 {{urlencode:hi world?!}}
11185 {{urlencode:hi world?!|WIKI}}
11186 {{urlencode:hi world?!|PATH}}
11187 {{urlencode:hi world?!|QUERY}}
11188 !! html/php
11189 <p>hi+world%3F%21
11190 hi_world%3F!
11191 hi%20world%3F%21
11192 hi+world%3F%21
11193 </p>
11194 !! end
11195
11196 !! test
11197 Magic Word: prioritize type info over data-parsoid
11198 !! options
11199 parsoid=html2wt
11200 !! html/parsoid
11201 <meta property="mw:PageProp/forcetoc" data-parsoid='{"magicSrc":"__NOTOC__"}'/>
11202 !! wikitext
11203 __FORCETOC__
11204 !! end
11205
11206 !! test
11207 Magic Word: serialize on separate line (parsoid)
11208 !! options
11209 parsoid=wt2wt,html2wt
11210 !! wikitext
11211 foo
11212 __NOTOC__
11213 bar
11214 !! html/parsoid
11215 foo<meta property="mw:PageProp/notoc"/>bar
11216 !! end
11217
11218 !! test
11219 Magic Word: rt non-english wikis
11220 !! options
11221 parsoid=wt2wt
11222 language=de
11223 !! wikitext
11224 __NOEDITSECTION__
11225 !! html/parsoid
11226 <meta property="mw:PageProp/noeditsection" data-parsoid='{"magicSrc":"__NOEDITSECTION__"}'/>
11227 !! end
11228
11229 !!test
11230 __proto__ is treated as normal wikitext (T105997)
11231 !!wikitext
11232 __proto__
11233 !!html
11234 <p>__proto__
11235 </p>
11236 !!end
11237
11238 ###
11239 ### Magic links
11240 ###
11241 !! test
11242 Magic links: internal link to RFC (T2479)
11243 !! wikitext
11244 [[RFC 123]]
11245 !! html/php
11246 <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>
11247 </p>
11248 !! html/parsoid
11249 <p><a rel="mw:WikiLink" href="./RFC_123" title="RFC 123">RFC 123</a></p>
11250 !! end
11251
11252 !! test
11253 Magic links: RFC (T2479)
11254 !! wikitext
11255 RFC 822
11256 !! html/php
11257 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc822">RFC 822</a>
11258 </p>
11259 !! html/parsoid
11260 <p><a href="https://tools.ietf.org/html/rfc822" rel="mw:ExtLink" class="external mw-magiclink">RFC 822</a></p>
11261 !! end
11262
11263 !! test
11264 Magic links: RFC (T67278)
11265 !! wikitext
11266 This is RFC 822 but thisRFC 822 is not RFC 822linked.
11267 !! html/php
11268 <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.
11269 </p>
11270 !! html/parsoid
11271 <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>
11272 !! end
11273
11274 !! test
11275 Magic links: RFC (w/ non-newline whitespace, T30950/T31025)
11276 !! wikitext
11277 RFC &nbsp;&#160;&#0160;&#xA0;&#Xa0; 822
11278 RFC
11279 822
11280 !! html/php
11281 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc822">RFC 822</a>
11282 RFC
11283 822
11284 </p>
11285 !! html/parsoid
11286 <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>
11287 RFC
11288 822</p>
11289 !! end
11290
11291 !! test
11292 Magic links: ISBN (T3937)
11293 !! wikitext
11294 ISBN 0-306-40615-2
11295 !! html/php
11296 <p><a href="/wiki/Special:BookSources/0306406152" class="internal mw-magiclink-isbn">ISBN 0-306-40615-2</a>
11297 </p>
11298 !! html/parsoid
11299 <p><a href="./Special:BookSources/0306406152" rel="mw:WikiLink">ISBN 0-306-40615-2</a></p>
11300 !! end
11301
11302 !! test
11303 Magic links: ISBN (T67278)
11304 !! wikitext
11305 This is ISBN 978-0-316-09811-3 but thisISBN 978-0-316-09811-3 is not ISBN 978-0-316-09811-3linked.
11306 !! html/php
11307 <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.
11308 </p>
11309 !! html/parsoid
11310 <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>
11311 !! end
11312
11313 !! test
11314 Magic links: ISBN (w/ non-newline whitespace, T30950/T31025)
11315 !! wikitext
11316 ISBN &nbsp;&#160;&#0160;&#xA0;&#Xa0; 978&nbsp;0&#160;316&#0160;09811&#xA0;3
11317 ISBN
11318 9780316098113
11319 ISBN 978
11320 0316098113
11321 !! html/php
11322 <p><a href="/wiki/Special:BookSources/9780316098113" class="internal mw-magiclink-isbn">ISBN 978 0 316 09811 3</a>
11323 ISBN
11324 9780316098113
11325 ISBN 978
11326 0316098113
11327 </p>
11328 !! html/parsoid
11329 <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>
11330 ISBN
11331 9780316098113
11332 ISBN 978
11333 0316098113</p>
11334 !! end
11335
11336 !! test
11337 Magic links: PMID incorrectly converts space to underscore
11338 !! wikitext
11339 PMID 1234
11340 !! html/php
11341 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a>
11342 </p>
11343 !! html/parsoid
11344 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract" rel="mw:ExtLink" class="external mw-magiclink">PMID 1234</a></p>
11345 !! end
11346
11347 !! test
11348 Magic links: PMID (T67278)
11349 !! wikitext
11350 This is PMID 1234 but thisPMID 1234 is not PMID 1234linked.
11351 !! html/php
11352 <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.
11353 </p>
11354 !! html/parsoid
11355 <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>
11356 !! end
11357
11358 !! test
11359 Magic links: PMID (w/ non-newline whitespace, T30950/T31025)
11360 !! wikitext
11361 PMID &nbsp;&#160;&#0160;&#xA0;&#Xa0; 1234
11362 PMID
11363 1234
11364 !! html/php
11365 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a>
11366 PMID
11367 1234
11368 </p>
11369 !! html/parsoid
11370 <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>
11371 PMID
11372 1234</p>
11373 !! end
11374
11375 # <nowiki> nodes shouldn't be inserted during html2wt by Parsoid,
11376 # since these are ExtLinkText, not MagicLinkText
11377 !! test
11378 Magic links: use appropriate serialization for "almost" magic links.
11379 !! wikitext
11380 X[[Special:BookSources/0978739256|foo]]
11381
11382 X[https://tools.ietf.org/html/rfc1234 foo]
11383 !! html/php
11384 <p>X<a href="/wiki/Special:BookSources/0978739256" title="Special:BookSources/0978739256">foo</a>
11385 </p><p>X<a rel="nofollow" class="external text" href="https://tools.ietf.org/html/rfc1234">foo</a>
11386 </p>
11387 !! html/parsoid
11388 <p>X<a rel="mw:WikiLink" href="./Special:BookSources/0978739256" title="Special:BookSources/0978739256">foo</a></p>
11389 <p>X<a rel="mw:ExtLink" class="external text" href="https://tools.ietf.org/html/rfc1234">foo</a></p>
11390 !! end
11391
11392 !! test
11393 Magic links: All disabled (T47942)
11394 !! options
11395 wgEnableMagicLinks={"ISBN":false, "PMID":false, "RFC":false}
11396 !! wikitext
11397 ISBN 0-306-40615-2
11398 PMID 1234
11399 RFC 4321
11400 !! html/php
11401 <p>ISBN 0-306-40615-2
11402 PMID 1234
11403 RFC 4321
11404 </p>
11405 !! end
11406
11407 ###
11408 ### Templates
11409 ####
11410
11411 !! test
11412 Nonexistent template
11413 !! wikitext
11414 {{thistemplatedoesnotexist}}
11415 !! html
11416 <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>
11417 </p>
11418 !! end
11419
11420 !! test
11421 Template with invalid target containing tags
11422 !! wikitext
11423 {{a<b>b</b>|{{echo|foo}}|{{echo|a}}={{echo|b}}|a = b}}
11424 !! html
11425 <p>{{a<b>b</b>|foo|a=b|a = b}}
11426 </p>
11427 !! end
11428
11429 !! test
11430 Template with invalid target containing unclosed tag
11431 !! wikitext
11432 {{a<b>|{{echo|foo}}|{{echo|a}}={{echo|b}}|a = b}}
11433 !! html
11434 <p>{{a<b>|foo|a=b|a = b}}</b>
11435 </p>
11436 !! end
11437
11438 !! test
11439 Template with invalid target containing wikilink
11440 !! wikitext
11441 {{[[Main Page]]}}
11442 !! html/php
11443 <p>{{<a href="/wiki/Main_Page" title="Main Page">Main Page</a>}}
11444 </p>
11445 !! html/parsoid
11446 <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>
11447 !! end
11448
11449 !! test
11450 Template with just whitespace in it, T70421
11451 !! wikitext
11452 {{echo|{{ }}}}
11453 !! html/parsoid
11454 <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>
11455 !! end
11456
11457 !! article
11458 Template:test
11459 !! text
11460 This is a test template
11461 !! endarticle
11462
11463 !! test
11464 Simple template
11465 !! wikitext
11466 {{test}}
11467 !! html
11468 <p>This is a test template
11469 </p>
11470 !! end
11471
11472 !! test
11473 Template with explicit namespace
11474 !! wikitext
11475 {{Template:test}}
11476 !! html
11477 <p>This is a test template
11478 </p>
11479 !! end
11480
11481
11482 !! article
11483 Template:paramtest
11484 !! text
11485 This is a test template with parameter {{{param}}}
11486 !! endarticle
11487
11488 !! test
11489 Template parameter
11490 !! wikitext
11491 {{paramtest|param=foo}}
11492 !! html
11493 <p>This is a test template with parameter foo
11494 </p>
11495 !! end
11496
11497 !! article
11498 Template:paramtestnum
11499 !! text
11500 [[{{{1}}}|{{{2}}}]]
11501 !! endarticle
11502
11503 !! test
11504 Template unnamed parameter
11505 !! wikitext
11506 {{paramtestnum|Main Page|the main page}}
11507 !! html
11508 <p><a href="/wiki/Main_Page" title="Main Page">the main page</a>
11509 </p>
11510 !! end
11511
11512 !! article
11513 Template:templatesimple
11514 !! text
11515 (test)
11516 !! endarticle
11517
11518 !! article
11519 Template:templateredirect
11520 !! text
11521 #redirect [[Template:templatesimple]]
11522 !! endarticle
11523
11524 !! article
11525 Template:templateasargtestnum
11526 !! text
11527 {{{{{1}}}}}
11528 !! endarticle
11529
11530 !! article
11531 Template:templateasargtest
11532 !! text
11533 {{template{{{templ}}}}}
11534 !! endarticle
11535
11536 !! article
11537 Template:templateasargtest2
11538 !! text
11539 {{{{{templ}}}}}
11540 !! endarticle
11541
11542 !! test
11543 Template with template name as unnamed argument
11544 !! wikitext
11545 {{templateasargtestnum|templatesimple}}
11546 !! html
11547 <p>(test)
11548 </p>
11549 !! end
11550
11551 !! test
11552 Template with template name as argument
11553 !! wikitext
11554 {{templateasargtest|templ=simple}}
11555 !! html
11556 <p>(test)
11557 </p>
11558 !! end
11559
11560 !! test
11561 Template with template name as argument (2)
11562 !! wikitext
11563 {{templateasargtest2|templ=templatesimple}}
11564 !! html
11565 <p>(test)
11566 </p>
11567 !! end
11568
11569 !! article
11570 Template:templateasargtestdefault
11571 !! text
11572 {{{{{templ|templatesimple}}}}}
11573 !! endarticle
11574
11575 !! article
11576 Template:templa
11577 !! text
11578 '''templ'''
11579 !! endarticle
11580
11581 !! test
11582 Template with default value
11583 !! wikitext
11584 {{templateasargtestdefault}}
11585 !! html
11586 <p>(test)
11587 </p>
11588 !! end
11589
11590 !! test
11591 Template with default value (value set)
11592 !! wikitext
11593 {{templateasargtestdefault|templ=templa}}
11594 !! html
11595 <p><b>templ</b>
11596 </p>
11597 !! end
11598
11599 !! test
11600 Template redirect
11601 !! wikitext
11602 {{templateredirect}}
11603 !! html/php
11604 <p>(test)
11605 </p>
11606 !! html/parsoid
11607 <link rel="mw:PageProp/redirect" href="./Template:Templatesimple" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"templateredirect","href":"./Template:Templateredirect"},"params":{},"i":0}}]}'/>
11608 !! end
11609
11610 !! test
11611 Template with argument in separate line
11612 !! wikitext
11613 {{ templateasargtest |
11614 templ = simple }}
11615 !! html
11616 <p>(test)
11617 </p>
11618 !! end
11619
11620 !! test
11621 Template with complex template as argument
11622 !! wikitext
11623 {{paramtest|
11624 param ={{ templateasargtest |
11625 templ = simple }}}}
11626 !! html
11627 <p>This is a test template with parameter (test)
11628 </p>
11629 !! end
11630
11631 !! test
11632 Templates with templated name
11633 !! wikitext
11634 {{{{echo|echo}}|foo}}
11635 {{{{echo|inner list}} }}
11636 !! html
11637 <p>foo
11638 </p>
11639 <ul><li>item 1</li></ul>
11640
11641 !! html/parsoid
11642 <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>
11643 <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>
11644 !! end
11645
11646 ## Regression test; the output here isn't really that interesting.
11647 !! test
11648 Templates with templated name and top level template args
11649 !! wikitext
11650 {{1{{2{{{3}}}|4=5}}}}
11651 !! html/parsoid
11652 <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>
11653 !! end
11654
11655 # Parsoid markup is deliberate "broken". This is an edge case.
11656 # See long comment in TemplateHandler.js:convertAttribsToString.
11657 !! test
11658 Templates with invalid templated targets
11659 !! wikitext
11660 {{echo
11661 {{echo|foo}}
11662 }}
11663 !! html/php
11664 <p>{{echo
11665 foo
11666 }}
11667 </p>
11668 !! html/parsoid
11669 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo\n{{echo|foo}}\n"},"params":{},"i":0}}]}'>{{echo
11670 foo }}</p>
11671 !! end
11672
11673 !! test
11674 Template with thumb image (with link in description)
11675 !! wikitext
11676 {{paramtest|param=[[Image:noimage.png|thumb|[[no link|link]] [[no link|caption]]]]}}
11677 !! html/php
11678 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>
11679
11680 !! html+tidy
11681 <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>
11682 !! html/parsoid
11683 <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>
11684 !! end
11685
11686 !! article
11687 Template:complextemplate
11688 !! text
11689 {{{1}}} {{paramtest|
11690 param ={{{param}}}}}
11691 !! endarticle
11692
11693 !! test
11694 Template with complex arguments
11695 !! wikitext
11696 {{complextemplate|
11697 param ={{ templateasargtest |
11698 templ = simple }}|[[Template:complextemplate|link]]}}
11699 !! html
11700 <p><a href="/wiki/Template:Complextemplate" title="Template:Complextemplate">link</a> This is a test template with parameter (test)
11701 </p>
11702 !! end
11703
11704 !! test
11705 T2553: link with two variables in a piped link
11706 !! wikitext
11707 {|
11708 |[[{{{1}}}|{{{2}}}]]
11709 |}
11710 !! html/php
11711 <table>
11712 <tr>
11713 <td>[[{{{1}}}|{{{2}}}]]
11714 </td></tr></table>
11715
11716 !! html/parsoid
11717 <table>
11718 <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>
11719 </tbody></table>
11720 !! end
11721
11722 # See: T2553
11723 !! test
11724 Abort table cell attribute parsing on wikilink
11725 !! wikitext
11726 {|
11727 |testing [[one|two]] |three||four
11728 |testing one two |three||four
11729 |testing="[[one|two]]" |three||four
11730 |}
11731 !! html/php
11732 <table>
11733 <tr>
11734 <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>
11735 <td>four
11736 </td>
11737 <td>three</td>
11738 <td>four
11739 </td>
11740 <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>
11741 <td>four
11742 </td></tr></table>
11743
11744 !! html/parsoid
11745 <table>
11746 <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>
11747 <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>
11748 <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>
11749 </tbody></table>
11750 !! end
11751
11752 !! test
11753 Don't abort table cell attribute parsing if wikilink is found in template arg
11754 !! wikitext
11755 {|
11756 |Test {{#tag:ref|One two "[[three]]" four}}
11757 |}
11758 !! html/parsoid
11759 <table>
11760 <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>
11761 </tbody></table>
11762 !! end
11763
11764 !! test
11765 Magic variable as template parameter
11766 !! wikitext
11767 {{paramtest|param={{SITENAME}}}}
11768 !! html
11769 <p>This is a test template with parameter MediaWiki
11770 </p>
11771 !! end
11772
11773 !! article
11774 Template:linktest
11775 !! text
11776 [[{{{param}}}|link]]
11777 !! endarticle
11778
11779 !! test
11780 Template parameter as link source
11781 !! wikitext
11782 {{linktest|param=Main Page}}
11783 !! html
11784 <p><a href="/wiki/Main_Page" title="Main Page">link</a>
11785 </p>
11786 !! end
11787
11788 !!article
11789 Template:paramtest2
11790 !! text
11791 including another template, {{paramtest|param={{{arg}}}}}
11792 !! endarticle
11793
11794 !! test
11795 Template passing argument to another template
11796 !! wikitext
11797 {{paramtest2|arg='hmm'}}
11798 !! html
11799 <p>including another template, This is a test template with parameter 'hmm'
11800 </p>
11801 !! end
11802
11803 !! article
11804 Template:Linktest2
11805 !! text
11806 Main Page
11807 !! endarticle
11808
11809 !! test
11810 Template as link source
11811 !! wikitext
11812 [[{{linktest2}}]]
11813
11814 [[{{linktest2}}|Main Page]]
11815
11816 [[{{linktest2}}]]Page
11817 !! html
11818 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
11819 </p><p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
11820 </p><p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>Page
11821 </p>
11822 !! end
11823
11824
11825 !! article
11826 Template:loop1
11827 !! text
11828 {{loop2}}
11829 !! endarticle
11830
11831 !! article
11832 Template:loop2
11833 !! text
11834 {{loop1}}
11835 !! endarticle
11836
11837 !! test
11838 Template infinite loop
11839 !! wikitext
11840 {{loop1}}
11841 !! html
11842 <p><span class="error">Template loop detected: <a href="/wiki/Template:Loop1" title="Template:Loop1">Template:Loop1</a></span>
11843 </p>
11844 !! end
11845
11846 !! test
11847 Template from main namespace
11848 !! wikitext
11849 {{:Main Page}}
11850 !! html
11851 <p>blah blah
11852 </p>
11853 !! end
11854
11855 !! test
11856 Template from non-includable namespace
11857 !! options
11858 wgNonincludableNamespaces=10
11859 !! wikitext
11860 {{echo|uh oh!}}
11861 !! html
11862 <p><a href="/wiki/Template:Echo" title="Template:Echo">Template:Echo</a>
11863 </p>
11864 !! end
11865
11866 !! article
11867 Template:table
11868 !! text
11869 {|
11870 | 1 || 2
11871 |-
11872 | 3 || 4
11873 |}
11874 !! endarticle
11875
11876 !! test
11877 T2529: Template with table, not included at beginning of line
11878 !! wikitext
11879 foo {{table}}
11880 !! html
11881 <p>foo
11882 </p>
11883 <table>
11884 <tr>
11885 <td>1</td>
11886 <td>2
11887 </td></tr>
11888 <tr>
11889 <td>3</td>
11890 <td>4
11891 </td></tr></table>
11892
11893 !! end
11894
11895 !! test
11896 T2523: Template shouldn't eat newline (or add an extra one before table)
11897 !! wikitext
11898 foo
11899 {{table}}
11900 !! html
11901 <p>foo
11902 </p>
11903 <table>
11904 <tr>
11905 <td>1</td>
11906 <td>2
11907 </td></tr>
11908 <tr>
11909 <td>3</td>
11910 <td>4
11911 </td></tr></table>
11912
11913 !! end
11914
11915 !! test
11916 T2041: Template parameters shown as broken links
11917 !! wikitext
11918 {{{parameter}}}
11919 !! html
11920 <p>{{{parameter}}}
11921 </p>
11922 !! end
11923
11924 !! test
11925 Template with targets containing wikilinks
11926 !! options
11927 parsoid=wt2html
11928 !! wikitext
11929 {{[[foo]]}}
11930
11931 {{[[{{echo|foo}}]]}}
11932
11933 {{{{echo|[[foo}}]]}}
11934 !! html/php
11935 <p>{{<a href="/wiki/Foo" title="Foo">foo</a>}}
11936 </p><p>{{<a href="/wiki/Foo" title="Foo">foo</a>}}
11937 </p><p>{{[[foo}}]]
11938 </p>
11939 !! html/parsoid
11940 <p>{{<a rel="mw:WikiLink" href="./Foo" title="Foo">foo</a>}}</p>
11941 <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>
11942 <p>{{<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[foo}}]]"}},"i":0}}]}'>[[foo}}]]</span></p>
11943 !! end
11944
11945 !! article
11946 Template:''
11947 !! text
11948 bar
11949 !! endarticle
11950
11951 !! test
11952 Templates: Double quotes as template target
11953 !! wikitext
11954 foo {{''}} baz
11955 !! html/php
11956 <p>foo bar baz
11957 </p>
11958 !! html/parsoid
11959 <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
11960 </p>
11961 !! end
11962
11963 ## This test is about making sure Parsoid's data-mw is well formed in the
11964 ## face of multiple templates with intersecting and overlapping ranges. The
11965 ## wikitext itself is wretched.
11966 !! test
11967 Templates with intersecting and overlapping ranges
11968 !! wikitext
11969 {|{{echo|
11970 <p>ha</p>}}
11971 {|{{echo|
11972 <p>ho</p>}}
11973 {{echo|{{!}}hi}}
11974 |}
11975 !! html/php+tidy
11976 <p>ha</p><table>
11977
11978 </table><p>ho</p><table>
11979
11980 <tbody><tr>
11981 <td>hi
11982 </td></tr></tbody></table>
11983 !! html/parsoid
11984 <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":""}]]}'>
11985
11986 </table><p about="#mwt1">ho</p><table about="#mwt1" typeof="mw:ExpandedAttrs" data-mw='{"attribs":[[{"txt":"","html":""},{"html":""}]]}'>
11987
11988 <tbody><tr><td>hi</td></tr>
11989 </tbody></table>
11990 !! end
11991
11992 !! article
11993 Template:MSGNW test
11994 !! text
11995 ''None'' of '''this''' should be
11996 * interpreted
11997 but rather passed unmodified
11998 {{test}}
11999 <gallery>
12000 File:Foobar.jpg
12001 </gallery>
12002 <!-- comment -->
12003 !! endarticle
12004
12005 # hmm, fix this or just deprecate msgnw and document its behavior?
12006 !! test
12007 msgnw keyword
12008 !! wikitext
12009 {{msgnw:MSGNW test}}
12010 !! html/php
12011 <p>&#39;&#39;None&#39;&#39; of &#39;&#39;&#39;this&#39;&#39;&#39; should be
12012 &#42; interpreted
12013 &#32;but rather passed unmodified
12014 &#123;&#123;test&#125;&#125;
12015 &#60;gallery&#62;
12016 File:Foobar.jpg
12017 &#60;/gallery&#62;
12018 &#60;!-- comment --&#62;
12019 </p>
12020 !! end
12021
12022 !! test
12023 int keyword
12024 !! wikitext
12025 {{int:youhavenewmessages|lots of money|not!}}
12026 !! html
12027 <p>You have lots of money (not!).
12028 </p>
12029 !! end
12030
12031 !! test
12032 int keyword - non-existing message
12033 !! wikitext
12034 {{int:var}}
12035 !! html
12036 <p>⧼var⧽
12037 </p>
12038 !! end
12039
12040 !! article
12041 Template:Includes
12042 !! text
12043 Foo<noinclude>zar</noinclude><includeonly>bar</includeonly>
12044 !! endarticle
12045
12046 !! test
12047 <includeonly> and <noinclude> being included
12048 !! wikitext
12049 {{Includes}}
12050 !! html
12051 <p>Foobar
12052 </p>
12053 !! end
12054
12055 !! article
12056 Template:Includes2
12057 !! text
12058 <onlyinclude>Foo</onlyinclude>bar
12059 !! endarticle
12060
12061 !! test
12062 <onlyinclude> being included
12063 !! wikitext
12064 {{Includes2}}
12065 !! html
12066 <p>Foo
12067 </p>
12068 !! end
12069
12070
12071 !! article
12072 Template:Includes3
12073 !! text
12074 <onlyinclude>Foo</onlyinclude>bar<includeonly>zar</includeonly>
12075 !! endarticle
12076
12077 !! test
12078 <onlyinclude> and <includeonly> being included
12079 !! wikitext
12080 {{Includes3}}
12081 !! html
12082 <p>Foo
12083 </p>
12084 !! end
12085
12086 !! test
12087 <includeonly> and <noinclude> on a page
12088 !! wikitext
12089 Foo<noinclude>zar</noinclude><includeonly>bar</includeonly>
12090 !! html
12091 <p>Foozar
12092 </p>
12093 !! end
12094
12095 !! test
12096 Un-closed <noinclude>
12097 !! wikitext
12098 <noinclude>
12099 !! html
12100 !! end
12101
12102 !! test
12103 <onlyinclude> on a page
12104 !! wikitext
12105 <onlyinclude>Foo</onlyinclude>bar
12106 !! html
12107 <p>Foobar
12108 </p>
12109 !! end
12110
12111 !! test
12112 Un-closed <onlyinclude>
12113 !! wikitext
12114 <onlyinclude>
12115 !! html
12116 !! end
12117
12118 !!test
12119 Self-closed noinclude, includeonly, onlyinclude tags
12120 !! wikitext
12121 <noinclude />
12122 <includeonly />
12123 <onlyinclude />
12124 !! html
12125 <p><br />
12126 </p>
12127 !!end
12128
12129 !!test
12130 Unbalanced includeonly and noinclude tags
12131 !! wikitext
12132 {|
12133 |a</noinclude>
12134 |b</noinclude></noinclude>
12135 |c</noinclude></includeonly>
12136 |d</includeonly></includeonly>
12137 |}
12138 !! html
12139 <table>
12140 <tr>
12141 <td>a
12142 </td>
12143 <td>b
12144 </td>
12145 <td>c&lt;/includeonly&gt;
12146 </td>
12147 <td>d&lt;/includeonly&gt;&lt;/includeonly&gt;
12148 </td></tr></table>
12149
12150 !!end
12151
12152 !! article
12153 Template:Includeonly section
12154 !! text
12155 <includeonly>
12156 ==Includeonly section==
12157 </includeonly>
12158 ==Section T-1==
12159 !!endarticle
12160
12161 !! test
12162 T8563: Edit link generation for section shown by <includeonly>
12163 !! wikitext
12164 {{includeonly section}}
12165 !! html
12166 <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>
12167 <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>
12168
12169 !! end
12170
12171 # Uses same input as the contents of [[Template:Includeonly section]]
12172 !! test
12173 T8563: Section extraction for section shown by <includeonly>
12174 !! options
12175 section=T-2
12176 !! wikitext
12177 <includeonly>
12178 ==Includeonly section==
12179 </includeonly>
12180 ==Section T-2==
12181 !! html
12182 ==Section T-2==
12183 !! end
12184
12185 !! test
12186 T8563: Edit link generation for section suppressed by <includeonly>
12187 !! wikitext
12188 <includeonly>
12189 ==Includeonly section==
12190 </includeonly>
12191 ==Section 1==
12192 !! html
12193 <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>
12194
12195 !! end
12196
12197 !! test
12198 T8563: Section extraction for section suppressed by <includeonly>
12199 !! options
12200 section=1
12201 !! wikitext
12202 <includeonly>
12203 ==Includeonly section==
12204 </includeonly>
12205 ==Section 1==
12206 !! html
12207 ==Section 1==
12208 !! end
12209
12210 !! test
12211 Un-closed <includeonly>
12212 !! wikitext
12213 <includeonly>
12214 !! html/php
12215 !! html/parsoid
12216 <meta typeof="mw:Includes/IncludeOnly" data-parsoid='{"src":"&lt;includeonly>"}' data-mw='{"src":"&lt;includeonly>"}'/>
12217 !! end
12218
12219 ## We used to, but no longer wt2wt this test since the default serializer
12220 ## will normalize the include directives to serialize on their own line.
12221 ## Selser will take care of preserving formatting in scenarios where they
12222 ## intermingled with other wikitext.
12223 !! test
12224 Includes and comments at SOL
12225 !! options
12226 parsoid=wt2html,html2html
12227 !! wikitext
12228 <!-- comment --><noinclude><!-- comment --></noinclude><!-- comment -->==hu==
12229
12230 <noinclude>
12231 some
12232 </noinclude>*stuff
12233 *here
12234
12235 <noinclude>
12236 some</noinclude>* stuff
12237 * here
12238
12239 <includeonly>can have stuff</includeonly>===here===
12240
12241 !! html/php
12242 <h2><span class="mw-headline" id="hu">hu</span></h2>
12243 <p>some
12244 </p>
12245 <ul><li>stuff</li>
12246 <li>here</li></ul>
12247 <p><br />
12248 some* stuff
12249 </p>
12250 <ul><li>here</li></ul>
12251 <h3><span class="mw-headline" id="here">here</span></h3>
12252
12253 !! html/parsoid
12254 <!-- 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>
12255
12256 <meta typeof="mw:Includes/NoInclude" data-parsoid='{"src":"&lt;noinclude>"}'/>
12257 <p>some</p>
12258 <meta typeof="mw:Includes/NoInclude/End" data-parsoid='{"src":"&lt;/noinclude>"}'/><ul><li>stuff</li>
12259 <li>here</li></ul>
12260
12261 <meta typeof="mw:Includes/NoInclude" data-parsoid='{"src":"&lt;noinclude>"}'/>
12262 <p>some<meta typeof="mw:Includes/NoInclude/End" data-parsoid='{"src":"&lt;/noinclude>"}'/>* stuff</p>
12263 <ul><li>here</li></ul>
12264
12265 <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>
12266
12267 !! end
12268
12269 # TODO: test with DOM fragment reuse!
12270 !! test
12271 Parsoid: DOM fragment reuse
12272 !! options
12273 parsoid=wt2wt,wt2html
12274 !! wikitext
12275 a{{echo|b<table></table>c}}d
12276
12277 a{{echo|b
12278 <table></table>
12279 c}}d
12280
12281 {{echo|a
12282
12283 <table></table>
12284
12285 b}}
12286 !! html/php+tidy
12287 <p>ab</p><table></table><p>cd
12288 </p><p>ab
12289 </p>
12290 <table></table>
12291 <p>cd
12292 </p><p>a
12293 </p>
12294 <table></table>
12295 <p>b
12296 </p>
12297 !! html/parsoid
12298 <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>
12299
12300 <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">
12301 </span><table about="#mwt2" data-parsoid='{"stx":"html"}'></table><span about="#mwt2">
12302 </span><p about="#mwt2">cd</p>
12303
12304 <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">
12305
12306 </span><table about="#mwt3" data-parsoid='{"stx":"html"}'></table><span about="#mwt3">
12307
12308 </span><p about="#mwt3">b</p>
12309 !! end
12310
12311 !! test
12312 Parsoid: Merge double tds (T52603)
12313 !! wikitext
12314 {|
12315 |{{echo|{{!}} foo}}
12316 |}
12317 !! html/php+tidy
12318 <table>
12319 <tbody><tr>
12320 <td>foo
12321 </td></tr></tbody></table>
12322 !! html/parsoid
12323 <table><tbody>
12324 <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>
12325 </tbody></table>
12326 !! end
12327
12328 !! test
12329 Parsoid: Merge double tds in nested transclusion content (T52603)
12330 !! wikitext
12331 {{echo|<div>}}
12332 {|
12333 |{{echo|{{!}} foo}}
12334 |}
12335 {{echo|</div>}}
12336 !! html/php+tidy
12337 <div>
12338 <table>
12339 <tbody><tr>
12340 <td>foo
12341 </td></tr></tbody></table>
12342 </div>
12343 !! html/parsoid
12344 <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}}]}'>
12345 <table><tbody>
12346 <tr><td data-mw='{"parts":["|"]}'> foo</td></tr>
12347 </tbody></table>
12348 </div>
12349 !! end
12350
12351 ###
12352 ### <includeonly> and <noinclude> in attributes
12353 ###
12354 !!test
12355 0. includeonly around the entire attribute
12356 !! wikitext
12357 <span <includeonly>id="v1"</includeonly><noinclude>id="v2"</noinclude>>bar</span>
12358 !! html
12359 <p><span id="v2">bar</span>
12360 </p>
12361 !!end
12362
12363 !!test
12364 1. includeonly in html attr key
12365 !! wikitext
12366 <span <noinclude>id</noinclude><includeonly>about</includeonly>="foo">bar</span>
12367 !! html
12368 <p><span id="foo">bar</span>
12369 </p>
12370 !!end
12371
12372 !!test
12373 2. includeonly in html attr value
12374 !! wikitext
12375 <span id="<noinclude>v1</noinclude><includeonly>v2</includeonly>">bar</span>
12376 <span id=<noinclude>"v1"</noinclude><includeonly>"v2"</includeonly>>bar</span>
12377 !! html
12378 <p><span id="v1">bar</span>
12379 <span id="v1">bar</span>
12380 </p>
12381 !!end
12382
12383 !!test
12384 3. includeonly in part of an attr value
12385 !! wikitext
12386 <span style="color:<noinclude>red</noinclude><includeonly>blue</includeonly>;">bar</span>
12387 !! html
12388 <p><span style="color:red;">bar</span>
12389 </p>
12390 !!end
12391
12392 !!test
12393 4. includeonly in table attributes
12394 !! wikitext
12395 {|
12396 |- <noinclude>
12397 |-
12398 |a
12399 </noinclude>
12400 |- <includeonly>
12401 |-
12402 |b
12403 </includeonly>
12404 |}
12405 !! html
12406 <table>
12407
12408
12409 <tr>
12410 <td>a
12411 </td></tr>
12412 </table>
12413
12414 !!end
12415
12416 ###
12417 ### Preprocessor precedence tests
12418 ### See: https://www.mediawiki.org/wiki/Preprocessor_ABNF
12419 ###
12420 ##{{[[-{{{{{{[[Foo|bar}}]]}-}}}}}]]
12421 !! test
12422 Preprocessor precedence 1: link is rightmost opening
12423 !! options
12424 parsoid=wt2html
12425 !! wikitext
12426 {{[[Foo|bar}}]]
12427
12428 But close-brace is not a valid character in a link title:
12429 {{[[Foo}}|bar]]
12430
12431 However, we can still tell this was handled as a link in the preprocessor:
12432 {{echo|[[Foo}}|bar]]|bat}}
12433 !! html/php
12434 <p>{{<a href="/wiki/Foo" title="Foo">bar}}</a>
12435 </p><p>But close-brace is not a valid character in a link title:
12436 {{[[Foo}}|bar]]
12437 </p><p>However, we can still tell this was handled as a link in the preprocessor:
12438 [[Foo}}|bar]]
12439 </p>
12440 !! html/parsoid
12441 <p>{{<a rel="mw:WikiLink" href="./Foo" title="Foo">bar}}</a></p>
12442 <p>But close-brace is not a valid character in a link title: {{[[Foo}}|bar]]</p>
12443 <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>
12444 !! end
12445
12446 !! test
12447 Preprocessor precedence 2: template is rightmost opening
12448 !! options
12449 language=zh
12450 !! wikitext
12451 -{{echo|foo}-}}-
12452 !! html/php
12453 <p>-foo}--
12454 </p>
12455 !! html/parsoid
12456 <p>-<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo}-"}},"i":0}}]}'>foo}-</span>-</p>
12457 !! end
12458
12459 !! test
12460 Preprocessor precedence 3: language converter is rightmost opening
12461 !! options
12462 language=zh
12463 parsoid=wt2html
12464 !! wikitext
12465 {{echo|hi}}
12466
12467 {{-{R|echo|hi}}}-
12468
12469 [[-{R|raw]]}-
12470 !! html/php
12471 <p>hi
12472 </p><p>{{echo|hi}}
12473 </p><p>[[raw]]
12474 </p>
12475 !! html/parsoid
12476 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi"}},"i":0}}]}'>hi</p>
12477 <p>{{<span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"echo|hi}}"}}'></span></p>
12478 <p>[[<span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw]]"}}'></span></p>
12479 !! end
12480
12481 !! test
12482 Preprocessor precedence 4: left-most angle bracket
12483 !! options
12484 language=zh
12485 !! wikitext
12486 <!--{raw}-->
12487 !! html/php
12488 !! html/parsoid
12489 <!--{raw}-->
12490 !! end
12491
12492 !! article
12493 Template:Precedence5
12494 !! text
12495 {{{{{1}}}}}
12496 !! endarticle
12497
12498 !! test
12499 Preprocessor precedence 5: tplarg takes precedence over template
12500 !! wikitext
12501 {{Precedence5|Bullet}}
12502 !! html/php
12503 <ul><li>Bar</li></ul>
12504
12505 !! html/parsoid
12506 <ul typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"Precedence5","href":"./Template:Precedence5"},"params":{"1":{"wt":"Bullet"}},"i":0}}]}'><li>Bar</li></ul>
12507 !! end
12508
12509 !! test
12510 Preprocessor precedence 6: broken link is rightmost opening
12511 !! options
12512 parsoid=wt2html
12513 !! wikitext
12514 {{echo|[[Foo}}
12515
12516 {{echo|[[Foo|bar|bat=baz}}
12517 !! html/php
12518 <p>{{echo|[[Foo}}
12519 </p><p>{{echo|[[Foo|bar|bat=baz}}
12520 </p>
12521 !! html/parsoid
12522 <p>{{echo|[[Foo}}</p>
12523 <p>{{echo|[[Foo|bar|bat=baz}}</p>
12524 !! end
12525
12526 # This next test exposes a difference between PHP and Parsoid:
12527 # Given [[Foo|{{echo|Bar]]x}}y]]z:
12528 # 1) Both PHP and Parsoid ignore the `]]` inside the `echo` in the
12529 # "preprocessor" stage. The `{{echo` extends until the `x}}`, and the
12530 # outer `[[Foo` extends until the `y]]`
12531 # 2a) But then the PHP preprocessor emits `[[Foo|Bar]]xy]]z` as an
12532 # intermediate result (after template expansion), and link processing
12533 # happens on this intermediate result, which moves the wikilink
12534 # boundary leftward to `[[Foo|Bar]]`
12535 # 2b) Parsoid works in a single step, so it's going to keep the
12536 # wikilink as extending to the `y]]`
12537 # 3a) Then PHP does linktrail processing which slurps up the trailing
12538 # `xy` inside the link.
12539 # 3b) Parsoid will do linktrail processing to slurp up the trailing
12540 # `z` inside the link.
12541 # This is "correct" behavior. Parsoid's basic worldview is that the
12542 # `]]` inside the template shouldn't be allowed to leak out to affect
12543 # the surrounding wikilink. PHP may match Parsoid (in the future)
12544 # if you use {{#balance}} (T114445).
12545
12546 !! test
12547 Preprocessor precedence 7: broken template is rightmost opening
12548 !! options
12549 parsoid=wt2html
12550 !! wikitext
12551 [[Foo|{{echo|Bar]]
12552
12553 [[Foo|{{echo|Bar]]-x}}-y]]-z
12554
12555 Careful: linktrails can move the end of the wikilink:
12556 [[Foo|{{echo|y']]a}}l]]l
12557 !! html/php
12558 <p><a href="/wiki/Foo" title="Foo">{{echo|Bar</a>
12559 </p><p><a href="/wiki/Foo" title="Foo">Bar</a>-x-y]]-z
12560 </p><p>Careful: linktrails can move the end of the wikilink:
12561 <a href="/wiki/Foo" title="Foo">y'al</a>]]l
12562 </p>
12563 !! html/parsoid
12564 <p>[[Foo|{{echo|Bar]]</p>
12565 <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>
12566 <p>Careful: linktrails can move the end of the wikilink:
12567 <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>
12568 !! end
12569
12570 !! test
12571 Preprocessor precedence 8: broken language converter is rightmost opening
12572 !! options
12573 language=zh
12574 !! wikitext
12575 [[Foo-{R|raw]]
12576 !! html
12577 <p>[[Foo-{R|raw]]
12578 </p>
12579 !! end
12580
12581 !! article
12582 Template:Preprocessor_precedence_9
12583 !! text
12584 ;4: {{{{1}}}}
12585 ;5: {{{{{2}}}}}
12586 ;6: {{{{{{3}}}}}}
12587 ;7: {{{{{{{4}}}}}}}
12588 !! endarticle
12589
12590 !! test
12591 Preprocessor precedence 9: groups of braces
12592 !! wikitext
12593 {{Preprocessor precedence 9|Four|Bullet|1|2}}
12594 !! html/php
12595 <dl><dt>4</dt>
12596 <dd>{Four}</dd>
12597 <dt>5</dt>
12598 <dd></dd></dl>
12599 <ul><li>Bar</li></ul>
12600 <dl><dt>6</dt>
12601 <dd>Four</dd>
12602 <dt>7</dt>
12603 <dd>{Bullet}</dd></dl>
12604
12605 !! html/parsoid
12606 <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}}]}'>
12607 <dt>4</dt>
12608 <dd>{Four}</dd>
12609 <dt>5</dt>
12610 <dd></dd>
12611 </dl><ul about="#mwt1">
12612 <li>Bar</li>
12613 </ul><span about="#mwt1"> </span><dl about="#mwt1">
12614 <dt>6</dt>
12615 <dd>Four</dd>
12616 <dt>7</dt>
12617 <dd>{Bullet}</dd>
12618 </dl>
12619 !! end
12620
12621 !! article
12622 Template:Preprocessor_precedence_10
12623 !! text
12624 ;1: -{R|raw}-
12625 ;2: -{{Bullet}}-
12626 ;3: -{{{1}}}-
12627 ;4: -{{{{2}}}}-
12628 ;5: -{{{{{3}}}}}-
12629 ;6: -{{{{{{4}}}}}}-
12630 ;7: -{{{{{{{5}}}}}}}-
12631 !! endarticle
12632
12633 !! test
12634 Preprocessor precedence 10: groups of braces with leading dash
12635 !! options
12636 language=zh
12637 !! wikitext
12638 {{Preprocessor precedence 10|Three|raw2|Bullet|1|2}}
12639 !! html/php
12640 <dl><dt>1</dt>
12641 <dd>raw</dd>
12642 <dt>2</dt>
12643 <dd>-</dd></dl>
12644 <ul><li>Bar-</li></ul>
12645 <dl><dt>3</dt>
12646 <dd>-Three-</dd>
12647 <dt>4</dt>
12648 <dd>raw2</dd>
12649 <dt>5</dt>
12650 <dd>-</dd></dl>
12651 <ul><li>Bar-</li></ul>
12652 <dl><dt>6</dt>
12653 <dd>-Three-</dd>
12654 <dt>7</dt>
12655 <dd>raw2</dd></dl>
12656
12657 !! html/parsoid
12658 <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}}]}'>
12659 <dt>1</dt>
12660 <dd><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw"}}'></span></dd>
12661 <dt>2</dt>
12662 <dd>-</dd>
12663 </dl><ul about="#mwt1">
12664 <li>Bar-</li>
12665 </ul><span about="#mwt1"> </span><dl about="#mwt1">
12666 <dt>3</dt>
12667 <dd>-Three-</dd>
12668 <dt>4</dt>
12669 <dd><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw2"}}'></span></dd>
12670 <dt>5</dt>
12671 <dd>-</dd>
12672 </dl><ul about="#mwt1">
12673 <li>Bar-</li>
12674 </ul><span about="#mwt1"> </span><dl about="#mwt1">
12675 <dt>6</dt>
12676 <dd>-Three-</dd>
12677 <dt>7</dt>
12678 <dd><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw2"}}'></span></dd>
12679 </dl>
12680 !! end
12681
12682 !! test
12683 Preprocessor precedence 11: found during visual diff testing
12684 !! wikitext
12685 {{#tag:span|-{{#tag:span|-{{echo|x}}}}}}
12686
12687 {{echo|-{{echo|-{{echo|x}}}}}}
12688
12689 {{echo|-{{echo|x}}}}
12690 !! html/php
12691 <p><span>-<span>-x</span></span>
12692 </p><p>--x
12693 </p><p>-x
12694 </p>
12695 !! html/parsoid
12696 <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>
12697
12698 <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>
12699
12700 <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>
12701 !! end
12702
12703 !! test
12704 Preprocessor precedence 12: broken language converter closed by brace.
12705 !! options
12706 parsoid=wt2html
12707 !! wikitext
12708 This form breaks the template, which is unfortunate:
12709 *{{echo|foo-{bar}bat}}
12710
12711 But if the broken language converter markup is inside an extension
12712 tag, nothing bad happens:
12713 *<nowiki>foo-{bar}bat</nowiki>
12714 *{{echo|<nowiki>foo-{bar}bat</nowiki>}}
12715 *<pre>foo-{bar}bat</pre>
12716 *{{echo|<pre>foo-{bar}bat</pre>}}
12717
12718 <tag>foo-{bar}bat</tag>
12719 {{echo|<tag>foo-{bar}bat</tag>}}
12720
12721 !! html/php+tidy
12722 <p>This form breaks the template, which is unfortunate:
12723 </p>
12724 <ul><li>{{echo|foo-{bar}bat}}</li></ul>
12725 <p>But if the broken language converter markup is inside an extension
12726 tag, nothing bad happens:
12727 </p>
12728 <ul><li>foo-&#123;bar}bat</li>
12729 <li>foo-&#123;bar}bat</li>
12730 <li><pre>foo-{bar}bat</pre></li>
12731 <li><pre>foo-{bar}bat</pre></li></ul>
12732 <pre>'foo-{bar}bat'
12733 array (
12734 )
12735 </pre>
12736 <pre>'foo-{bar}bat'
12737 array (
12738 )
12739 </pre>
12740 !! html/parsoid
12741 <p>This form breaks the template, which is unfortunate:</p>
12742 <ul>
12743 <li>{{echo|foo-{bar}bat}}</li>
12744 </ul>
12745 <p>But if the broken language converter markup is inside an extension tag, nothing bad happens:</p>
12746 <ul>
12747 <li><span typeof="mw:Nowiki">foo-{bar}bat</span></li>
12748 <li><span typeof="mw:Transclusion mw:Nowiki" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;nowiki>foo-{bar}bat&lt;/nowiki>"}},"i":0}}]}'>foo-{bar}bat</span></li>
12749 <li><pre typeof="mw:Extension/pre" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo-{bar}bat"}}'>foo-{bar}bat</pre></li>
12750 <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>
12751 </ul>
12752 <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>
12753 !! end
12754
12755 !! test
12756 Preprocessor precedence 13: broken language converter in external link
12757 !! options
12758 parsoid=wt2html
12759 !! wikitext
12760 *[http://example.com/-{foo Example in URL]
12761 *[http://example.com Example in -{link} description]
12762 *{{echo|[http://example.com/-{foo Breaks template, however]}}
12763 !! html/php+tidy
12764 <ul><li><a rel="nofollow" class="external text" href="http://example.com/-{foo">Example in URL</a></li>
12765 <li><a rel="nofollow" class="external text" href="http://example.com">Example in -{link} description</a></li>
12766 <li>{{echo|<a rel="nofollow" class="external text" href="http://example.com/-{foo">Breaks template, however</a>}}</li></ul>
12767 !! html/parsoid
12768 <ul>
12769 <li><a rel="mw:ExtLink" class="external text" href="http://example.com/-{foo">Example in URL</a></li>
12770 <li><a rel="mw:ExtLink" class="external text" href="http://example.com">Example in -{link} description</a></li>
12771 <li>{{echo|<a rel="mw:ExtLink" class="external text" href="http://example.com/-{foo">Breaks template, however</a>}}</li>
12772 </ul>
12773 !! end
12774
12775 !! test
12776 Preprocessor precedence 14: broken language converter in comment
12777 !! wikitext
12778 *<!--{{foo}}-->...should be ok
12779 *<!---{{foo}}-->...extra dashes
12780 *{{echo|foo<!-- -{bar} -->bat}}...should be ok
12781 !! html/php+tidy
12782 <ul><li>...should be ok</li>
12783 <li>...extra dashes</li>
12784 <li>foobat...should be ok</li></ul>
12785 !! html/parsoid
12786 <ul>
12787 <li><!--{{foo}}-->...should be ok</li>
12788 <li><!--&#x2D;{{foo}}-->...extra dashes</li>
12789 <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>
12790 </ul>
12791 !! end
12792
12793 !! test
12794 Preprocessor precedence 15: broken brace markup in headings
12795 !! config
12796 wgFragmentMode=[ 'html5', 'legacy' ]
12797 !! options
12798 parsoid=wt2html
12799 !! wikitext
12800 __NOTOC__ __NOEDITSECTION__
12801 ===1 foo[bar 1===
12802 1
12803 ===2 foo[[bar 2===
12804 2
12805 ===3 foo{bar 3===
12806 3
12807 ===4 foo{{bar 4===
12808 4
12809 ===5 foo{{{bar 5===
12810 5
12811 ===6 foo-{bar 6===
12812 6
12813 !! html/php+tidy
12814 <h3><span id="1_foo.5Bbar_1"></span><span class="mw-headline" id="1_foo[bar_1">1 foo[bar 1</span></h3>
12815 <p>1
12816 </p>
12817 <h3><span id="2_foo.5B.5Bbar_2"></span><span class="mw-headline" id="2_foo[[bar_2">2 foo[[bar 2</span></h3>
12818 <p>2
12819 </p>
12820 <h3><span id="3_foo.7Bbar_3"></span><span class="mw-headline" id="3_foo{bar_3">3 foo{bar 3</span></h3>
12821 <p>3
12822 </p>
12823 <h3><span id="4_foo.7B.7Bbar_4"></span><span class="mw-headline" id="4_foo{{bar_4">4 foo{{bar 4</span></h3>
12824 <p>4
12825 </p>
12826 <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>
12827 <p>5
12828 </p>
12829 <h3><span id="6_foo-.7Bbar_6"></span><span class="mw-headline" id="6_foo-{bar_6">6 foo-{bar 6</span></h3>
12830 <p>6
12831 </p>
12832 !! html/parsoid
12833 <meta property="mw:PageProp/notoc"/> <meta property="mw:PageProp/noeditsection"/>
12834 <h3 id="1_foo[bar_1"><span id="1_foo.5Bbar_1" typeof="mw:FallbackId"></span>1 foo[bar 1</h3>
12835 <p>1</p>
12836 <h3 id="2_foo[[bar_2"><span id="2_foo.5B.5Bbar_2" typeof="mw:FallbackId"></span>2 foo[[bar 2</h3>
12837 <p>2</p>
12838 <h3 id="3_foo{bar_3"><span id="3_foo.7Bbar_3" typeof="mw:FallbackId"></span>3 foo{bar 3</h3>
12839 <p>3</p>
12840 <h3 id="4_foo{{bar_4"><span id="4_foo.7B.7Bbar_4" typeof="mw:FallbackId"></span>4 foo{{bar 4</h3>
12841 <p>4</p>
12842 <h3 id="5_foo{{{bar_5"><span id="5_foo.7B.7B.7Bbar_5" typeof="mw:FallbackId"></span>5 foo{{{bar 5</h3>
12843 <p>5</p>
12844 <h3 id="6_foo-{bar_6"><span id="6_foo-.7Bbar_6" typeof="mw:FallbackId"></span>6 foo-{bar 6</h3>
12845 <p>6</p>
12846 !! end
12847
12848 !! test
12849 Preprocessor precedence 16: matching closing braces to opening braces
12850 !! options
12851 language=zh
12852 parsoid=wt2html
12853 !! wikitext
12854 -{{{echo|foo}}bar}-
12855 !! html/php
12856 <p>foobar
12857 </p>
12858 !! html/parsoid
12859 <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>
12860 !! end
12861
12862 !! test
12863 Preprocessor precedence 17: template w/o target shouldn't prevent closing
12864 !! options
12865 parsoid=wt2html
12866 !! wikitext
12867 {{echo|hi {{}}}}
12868 !! html/php
12869 <p>hi {{}}
12870 </p>
12871 !! html/parsoid
12872 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi {{}}"}},"i":0}}]}'>hi {{}}</p>
12873 !! end
12874
12875 # Ensure we're using a language without variants for this test; even
12876 # if $wgUsePigLatinVariant is true. We've picked `de` arbitrarily.
12877 !! test
12878 Preprocessor precedence 18: another rightmost wins scenario
12879 !! options
12880 parsoid=wt2html
12881 language=de
12882 !! wikitext
12883 {{ -{{{{1|tplarg}}} }} }-
12884 !! html/php
12885 <p>{{ -{tplarg }} }-
12886 </p>
12887 !! html/parsoid
12888 <p>{{ -{<span about="#mwt1" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"1"},"params":{"1":{"wt":"tplarg"}},"i":0}}]}'>tplarg</span> }} }-</p>
12889 !! end
12890
12891 !! test
12892 Preprocessor precedence 19: break syntax
12893 !! options
12894 parsoid=wt2html
12895 !! wikitext
12896 -{{
12897 !! html/php
12898 <p>-{{
12899 </p>
12900 !! html/parsoid
12901 <p>-{{</p>
12902 !! end
12903
12904 ###
12905 ### Token Stream Patcher tests
12906 ###
12907 ### These tests won't always pass wt2wt and other modes because
12908 ### on serialization, the table will be output on a new line.
12909 ### For now, we are blacklisting them, and using this to test selser.
12910 ###
12911
12912 !!test
12913 1. Table tag in SOL posn. should get reparsed correctly with valid TSR
12914 !!options
12915 parsoid=wt2html,wt2wt
12916 !!wikitext
12917 {{echo|}}{| width = '100%'
12918 |foo
12919 |}
12920 !!html/parsoid
12921 <span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":""}},"i":0}}]}'></span><table width="100%">
12922 <tbody><tr><td>foo</td></tr>
12923 </tbody></table>
12924 !!end
12925
12926 ## We used to, but no longer wt2wt this test since the default serializer
12927 ## will normalize the include directives to serialize on their own line.
12928 ## Selser will take care of preserving formatting in scenarios where they
12929 ## intermingled with other wikitext.
12930 !!test
12931 2. Table tag in SOL posn. should get reparsed correctly with valid TSR
12932 !!options
12933 parsoid=wt2html
12934 !!wikitext
12935 <includeonly>a</includeonly>{| {{{b}}}
12936 |c
12937 |}
12938 !!html/parsoid
12939 <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":""}]]}'>
12940 <tbody><tr><td>c</td></tr>
12941 </tbody></table>
12942 !!end
12943
12944 !! test
12945 Table wikitext syntax outside wiki-tables
12946 !! wikitext
12947 a
12948 |+ not a caption
12949 ! not a table heading
12950 |- not a table row
12951 | not a table cell
12952 | class="foo bar" | baz
12953 b
12954 |}
12955 |-
12956 c
12957 !! html
12958 <p>a
12959 |+ not a caption
12960 ! not a table heading
12961 |- not a table row
12962 | not a table cell
12963 | class="foo bar" | baz
12964 b
12965 |}
12966 |-
12967 c
12968 </p>
12969 !! end
12970
12971 ###
12972 ### Testing parsing of templates where a template arg
12973 ### has the same name as the template itself.
12974 ###
12975
12976 !! article
12977 Template:quote
12978 !! text
12979 {{{quote|{{{1}}}}}}
12980 !! endarticle
12981
12982 !!test
12983 Templates: Template Name/Arg clash: 1. Use of positional param
12984 !! wikitext
12985 {{quote|foo}}
12986 !! html
12987 <p>foo
12988 </p>
12989 !!end
12990
12991 !!test
12992 Templates: Template Name/Arg clash: 2. Use of named param
12993 !! wikitext
12994 {{quote|quote=foo}}
12995 !! html
12996 <p>foo
12997 </p>
12998 !!end
12999
13000 !!test
13001 Templates: Template Name/Arg clash: 3. Use of named param with empty input
13002 !! wikitext
13003 {{quote|quote}}
13004 !! html
13005 <p>quote
13006 </p>
13007 !!end
13008
13009 ###
13010 ### Parsoid-centric tests to stress Parsoid's ability to RT them unchanged
13011 ###
13012
13013 !!test
13014 Templates: 1. Simple use
13015 !! wikitext
13016 {{echo|Foo}}
13017 !! html
13018 <p>Foo
13019 </p>
13020 !!end
13021
13022 !!test
13023 Templates: 2. Inside a block tag
13024 !! wikitext
13025 <div>{{echo|Foo}}</div>
13026 <blockquote>{{echo|Foo}}</blockquote>
13027 !! html
13028 <div>Foo</div>
13029 <blockquote>Foo</blockquote>
13030
13031 !! html+tidy
13032 <div>Foo</div>
13033 <blockquote><p>Foo</p></blockquote>
13034 !!end
13035
13036 !!test
13037 Templates: P-wrapping: 1a. Templates on consecutive lines
13038 !! wikitext
13039 {{echo|Foo}}
13040 {{echo|bar}}
13041 !! html
13042 <p>Foo
13043 bar
13044 </p>
13045 !!end
13046
13047 !!test
13048 Templates: P-wrapping: 1b. Templates on consecutive lines
13049 !! wikitext
13050 Foo
13051
13052 {{echo|bar}}
13053 {{echo|baz}}
13054 !! html
13055 <p>Foo
13056 </p><p>bar
13057 baz
13058 </p>
13059 !!end
13060
13061 !!test
13062 Templates: P-wrapping: 1c. Templates on consecutive lines
13063 !! wikitext
13064 {{echo|Foo}}
13065 {{echo|bar}} <div>baz</div>
13066 !! html
13067 <p>Foo
13068 </p>
13069 bar <div>baz</div>
13070
13071 !! html+tidy
13072 <p>Foo
13073 </p><p>
13074 bar </p><div>baz</div>
13075 !! end
13076
13077 !! test
13078 Templates: P-wrapping: 1d. Template preceded by comment-only line
13079 !! wikitext
13080 <!-- foo -->
13081 {{echo|Bar}}
13082 !! html/php+tidy
13083 <p>Bar
13084 </p>
13085 !! html/parsoid
13086 <!-- foo -->
13087
13088 <p about="#mwt223" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"Bar"}},"i":0}}]}'>Bar</p>
13089 !!end
13090
13091 !! test
13092 Templates: Scopes should not be expanded unnecessarily
13093 !! options
13094 parsoid=wt2html,wt2wt
13095 !! wikitext
13096 {{echo|<div>a</div>}}b{{echo|
13097 <div>c</div>}}
13098 !! html/php+tidy
13099 <div>a</div><p>b
13100 </p><div>c</div>
13101 !! html/parsoid
13102 <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}}]}'>
13103 </span><div about="#mwt2">c</div>
13104 !! end
13105
13106 !!test
13107 Templates: Inline Text: 1. Multiple template uses
13108 !! wikitext
13109 {{echo|Foo}}bar{{echo|baz}}
13110 !! html
13111 <p>Foobarbaz
13112 </p>
13113 !!end
13114
13115 !!test
13116 Templates: Inline Text: 2. Back-to-back template uses
13117 !! wikitext
13118 {{echo|Foo}}{{echo|bar}}
13119 !! html
13120 <p>Foobar
13121 </p>
13122 !!end
13123
13124 !!test
13125 Templates: Block Tags: 1. Multiple template uses
13126 !! wikitext
13127 {{echo|<div>Foo</div>}}<div>bar</div>{{echo|<div>baz</div>}}
13128 !! html
13129 <div>Foo</div><div>bar</div><div>baz</div>
13130
13131 !!end
13132
13133 !!test
13134 Templates: Block Tags: 2. Back-to-back template uses
13135 !! wikitext
13136 {{echo|<div>Foo</div>}}{{echo|<div>bar</div>}}
13137 !! html
13138 <div>Foo</div><div>bar</div>
13139
13140 !!end
13141
13142 ## Parsoid drops empty elements in templates.
13143 !! test
13144 Templates: Correctly encapsulate templates producing </p> tag without a corresponding <p> tag
13145 !! wikitext
13146 {{echo|a
13147 b</p>}}
13148 !! html/php+tidy
13149 <p>a
13150 </p><p>
13151 b</p><p class="mw-empty-elt"></p>
13152 !! html/parsoid
13153 <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">
13154 </span><p about="#mwt1">b</p>
13155 !! end
13156
13157 !!test
13158 Templates: Links: 1. Simple example
13159 !! wikitext
13160 {{echo|[[Foo|bar]]}}
13161 !! html
13162 <p><a href="/wiki/Foo" title="Foo">bar</a>
13163 </p>
13164 !!end
13165
13166 !!test
13167 Templates: Links: 2. Generation of link href
13168 !! wikitext
13169 [[{{echo|Foo}}|bar]]
13170 !! html
13171 <p><a href="/wiki/Foo" title="Foo">bar</a>
13172 </p>
13173 !!end
13174
13175 !!test
13176 Templates: Links: 3. Generation of part of a link href
13177 !! wikitext
13178 [[Fo{{echo|o}}|bar]]
13179
13180 [[Foo{{echo|bar}}]]
13181
13182 [[Foo{{echo|bar}}baz]]
13183
13184 [[Foo{{echo|bar}}|bar]]
13185
13186 [[:Foo{{echo|bar}}]]
13187
13188 [[:Foo{{echo|bar}}|bar]]
13189 !! html
13190 <p><a href="/wiki/Foo" title="Foo">bar</a>
13191 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
13192 </p><p><a href="/index.php?title=Foobarbaz&amp;action=edit&amp;redlink=1" class="new" title="Foobarbaz (page does not exist)">Foobarbaz</a>
13193 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">bar</a>
13194 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
13195 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">bar</a>
13196 </p>
13197 !!end
13198
13199 !!test
13200 Templates: Links: 4. Multiple templates generating link href
13201 !! wikitext
13202 [[{{echo|F}}{{echo|o}}ob{{echo|ar}}]]
13203 !! html
13204 <p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
13205 </p>
13206 !!end
13207
13208 !!test
13209 Templates: Links: 5. Generation of link text
13210 !! wikitext
13211 [[Foo|{{echo|bar}}]]
13212 !! html
13213 <p><a href="/wiki/Foo" title="Foo">bar</a>
13214 </p>
13215 !!end
13216
13217 !!test
13218 Templates: Links: 5. Nested templates (only outermost template should be marked)
13219 !! wikitext
13220 {{echo|[[{{echo|Foo}}|bar]]}}
13221 !! html
13222 <p><a href="/wiki/Foo" title="Foo">bar</a>
13223 </p>
13224 !!end
13225
13226 !!test
13227 Templates: HTML Tag: 1. Generation of HTML attr. key
13228 !! wikitext
13229 <div {{echo|style}}="color:red;">foo</div>
13230 !! html
13231 <div style="color:red;">foo</div>
13232
13233 !!end
13234
13235 !!test
13236 Templates: HTML Tag: 2. Generation of HTML attr. value
13237 !! wikitext
13238 <div style={{echo|'color:red;'}}>foo</div>
13239 !! html
13240 <div style="color:red;">foo</div>
13241
13242 !!end
13243
13244 !!test
13245 Templates: HTML Tag: 3. Generation of HTML attr key and value
13246 !! wikitext
13247 <div {{echo|style}}={{echo|'color:red;'}}>foo</div>
13248 !! html
13249 <div style="color:red;">foo</div>
13250
13251 !!end
13252
13253 !!test
13254 Templates: HTML Tag: 4. Generation of starting piece of HTML attr value
13255 !! wikitext
13256 <div title="{{echo|This is a long title}} with just one piece templated">foo</div>
13257 !! html
13258 <div title="This is a long title with just one piece templated">foo</div>
13259
13260 !!end
13261
13262 !!test
13263 Templates: HTML Tag: 5. Generation of middle piece of HTML attr value
13264 !! wikitext
13265 <div title="This is a long title with just {{echo|one piece}} templated">foo</div>
13266 !! html
13267 <div title="This is a long title with just one piece templated">foo</div>
13268
13269 !!end
13270
13271 !!test
13272 Templates: HTML Tag: 6. Generation of end piece of HTML attr value
13273 !! wikitext
13274 <div title="This is a long title with just one piece {{echo|templated}}">foo</div>
13275 !! html
13276 <div title="This is a long title with just one piece templated">foo</div>
13277
13278 !!end
13279
13280 # SSS FIXME: While it is great we added support for all this,
13281 # do we want to make this part of the spec? Maybe we want to
13282 # deprecate this kind of usage in the future?
13283 !!test
13284 Templates: HTML Tag: 7. Generation of partial attribute key string
13285 !! wikitext
13286 <div st{{echo|yle}}="color:red;">foo</div>
13287 !! html
13288 <div style="color:red;">foo</div>
13289
13290 !!end
13291
13292 !! test
13293 Templates: HTML Tag: 8. Template-generated attribute (k=v)
13294 !! wikitext
13295 <div {{echo|1=id="v1"}}>bar</div>
13296 !! html
13297 <div id="v1">bar</div>
13298
13299 !!end
13300
13301 !! test
13302 Templates: HTML Tag: 9. Multiple template-generated attributes
13303 !! wikitext
13304 <div {{echo|1=id="v1" title="foo"}}>bar</div>
13305 !! html
13306 <div id="v1" title="foo">bar</div>
13307
13308 !!end
13309
13310 !! test
13311 Templates: Support for templates generating attributes and content
13312 !! wikitext
13313 {| {{mixed_attr_content_template}}
13314 |-
13315 |bar
13316 |}
13317 !! html/php
13318 <table style="color:red;" title="T48811">
13319
13320 <tr>
13321 <td>foo
13322 </td></tr>
13323 <tr>
13324 <td>bar
13325 </td></tr></table>
13326
13327 !! html/parsoid
13328 <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|}"]}'>
13329 <tbody><tr>
13330 <td>foo</td></tr>
13331 <tr>
13332 <td>bar</td></tr>
13333 </tbody></table>
13334 !!end
13335
13336 !! article
13337 Template:attribute_from_template
13338 !! text
13339 class="123"
13340 !! endarticle
13341
13342 !! test
13343 Table cell with attribute before expanded attribute
13344 !! wikitext
13345 {|
13346 | align="center" {{attribute_from_template}} |456
13347 |}
13348 !! html/parsoid
13349 <table>
13350 <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>
13351 </tbody></table>
13352 !! end
13353
13354 !! test
13355 1. Entities and nowikis inside templated attributes should be handled correctly
13356 !! wikitext
13357 <div {{echo|style{{=}}"background:&#35;f9f9f9;"}}>foo</div>
13358 !! html/php
13359 <div style="background:#f9f9f9;">foo</div>
13360
13361 !! html/parsoid
13362 <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>
13363 !! end
13364
13365 !! test
13366 2. Entities and nowikis inside templated attributes should be handled correctly
13367 !! wikitext
13368 {|
13369 |{{table_attribs_3}}
13370 |}
13371 !! html/php
13372 <table>
13373 <tr>
13374 <td style="background:#f9f9f9;">Foo
13375 </td></tr></table>
13376
13377 !! html/parsoid
13378 <table>
13379 <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>
13380 </tbody></table>
13381 !! end
13382
13383 !! test
13384 3. Entities and nowikis inside templated attributes should be handled correctly inside templated tables
13385 !! wikitext
13386 {{tbl-start}}
13387 |{{table_attribs_3}}
13388 {{tbl-end}}
13389 !! html/php
13390 <table>
13391 <tr>
13392 <td style="background:#f9f9f9;">Foo
13393 </td></tr></table>
13394
13395 !! html/parsoid
13396 <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}}]}'>
13397 <tbody><tr><td style="background:#f9f9f9;">Foo</td></tr>
13398 </tbody></table>
13399 !! end
13400
13401 # T107622
13402 !! test
13403 4. Entities and nowikis inside templated attributes should be handled correctly inside templated tables
13404 !! wikitext
13405 {|
13406 |{{table_attribs_6}} hi
13407 |}
13408 !! html/php
13409 <table>
13410 <tr>
13411 <td style="background: red;">hi
13412 </td></tr></table>
13413
13414 !! html/parsoid
13415 <table>
13416 <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>
13417 </tbody></table>
13418 !! end
13419
13420 !!test
13421 Templates: HTML Tables: 1. Generating start of a HTML table
13422 !! wikitext
13423 {{echo|<table><tr><td>foo</td>}}</tr></table>
13424 !! html
13425 <table><tr><td>foo</td></tr></table>
13426
13427 !!end
13428
13429 !!test
13430 Templates: HTML Tables: 2a. Generating middle of a HTML table
13431 !! wikitext
13432 <table><tr>{{echo|<td>foo</td>}}</tr></table>
13433 !! html
13434 <table><tr><td>foo</td></tr></table>
13435
13436 !!end
13437
13438 !!test
13439 Templates: HTML Tables: 2b. Generating middle of a HTML table
13440 !! wikitext
13441 <table>{{echo|<tr><td>foo</td></tr>}}</table>
13442 !! html
13443 <table><tr><td>foo</td></tr></table>
13444
13445 !!end
13446
13447 !!test
13448 Templates: HTML Tables: 3. Generating end of a HTML table
13449 !! wikitext
13450 <table><tr>{{echo|<td>foo</td></tr></table>}}
13451 !! html
13452 <table><tr><td>foo</td></tr></table>
13453
13454 !!end
13455
13456 !!test
13457 Templates: HTML Tables: 4a. Generating a single tag of a HTML table
13458 !! wikitext
13459 {{echo|<table>}}<tr><td>foo</td></tr></table>
13460 !! html
13461 <table><tr><td>foo</td></tr></table>
13462
13463 !!end
13464
13465 !!test
13466 Templates: HTML Tables: 4b. Generating a single tag of a HTML table
13467 !! wikitext
13468 <table>{{echo|<tr>}}<td>foo</td></tr></table>
13469 !! html
13470 <table><tr><td>foo</td></tr></table>
13471
13472 !!end
13473
13474 !!test
13475 Templates: HTML Tables: 4c. Generating a single tag of a HTML table
13476 !! wikitext
13477 <table><tr>{{echo|<td>}}foo</td></tr></table>
13478 !! html
13479 <table><tr><td>foo</td></tr></table>
13480
13481 !!end
13482
13483 !!test
13484 Templates: HTML Tables: 4d. Generating a single tag of a HTML table
13485 !! wikitext
13486 <table><tr><td>foo{{echo|</td>}}</tr></table>
13487 !! html
13488 <table><tr><td>foo</td></tr></table>
13489
13490 !!end
13491
13492 !!test
13493 Templates: HTML Tables: 4e. Generating a single tag of a HTML table
13494 !! wikitext
13495 <table><tr><td>foo</td>{{echo|</tr>}}</table>
13496 !! html
13497 <table><tr><td>foo</td></tr></table>
13498
13499 !!end
13500
13501 !!test
13502 Templates: HTML Tables: 4f. Generating a single tag of a HTML table
13503 !! wikitext
13504 <table><tr><td>foo</td></tr>{{echo|</table>}}
13505 !! html
13506 <table><tr><td>foo</td></tr></table>
13507
13508 !!end
13509
13510 !!test
13511 Templates: HTML Tables: 5. Proper fostering of categories from inside
13512 !!options
13513 parsoid=wt2html,wt2wt
13514 !! wikitext
13515 <table>[[Category:foo1]]<tr><td>foo</td></tr></table>
13516 <!--Two categories (T52330)-->
13517 <table>[[Category:bar1]][[Category:bar2]]<tr><td>foo</td></tr></table>
13518 !! html/php+tidy
13519 <table><tbody><tr><td>foo</td></tr></tbody></table>
13520 <table><tbody><tr><td>foo</td></tr></tbody></table>
13521 !! html/parsoid
13522 <link rel="mw:PageProp/Category" href="./Category:Foo1"><table><tbody><tr><td>foo</td></tr></tbody></table>
13523 <!--Two categories (T52330)-->
13524 <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>
13525 !!end
13526
13527 ## Remex doesn't account for fostered content.
13528 !! test
13529 Templates: Wiki Tables: 1a. Fostering of entire template content
13530 !! wikitext
13531 {|
13532 {{echo|a}}
13533 |}
13534 !! html/php
13535 <table>
13536 a
13537 <tr><td></td></tr></table>
13538
13539 !! html/php+tidy
13540
13541 a
13542 <table><tbody><tr><td></td></tr></tbody></table>
13543 !! html/parsoid
13544 <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">
13545
13546 </table>
13547 !! end
13548
13549 !!test
13550 Templates: Wiki Tables: 1b. Fostering of entire template content
13551 !! wikitext
13552 {|
13553 {{echo|<div>}}
13554 foo
13555 {{echo|</div>}}
13556 |}
13557 !! html
13558 <table>
13559 <div>
13560 <p>foo
13561 </p>
13562 </div>
13563 <tr><td></td></tr></table>
13564
13565 !! html/php+tidy
13566 <div>
13567 <p>foo
13568 </p>
13569 </div><table>
13570
13571 <tbody><tr><td></td></tr></tbody></table>
13572 !! html/parsoid
13573 <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|}"]}'>
13574 <p>foo</p>
13575 </div><table about="#mwt3">
13576
13577 </table>
13578 !! end
13579
13580 ## Remex doesn't account for fostered content.
13581 !! test
13582 Templates: Wiki Tables: 2. Fostering of partial template content
13583 !! wikitext
13584 {|
13585 {{echo|a
13586 <div>b</div>}}
13587 |}
13588 !! html/php
13589 <table>
13590 a
13591 <div>b</div>
13592 <tr><td></td></tr></table>
13593
13594 !! html/php+tidy
13595
13596 a
13597 <div>b</div><table>
13598 <tbody><tr><td></td></tr></tbody></table>
13599 !! html/parsoid
13600 <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">
13601
13602
13603 </table>
13604 !! end
13605
13606 !!test
13607 Templates: Wiki Tables: 3. td-content via multiple templates
13608 !! wikitext
13609 {|
13610 {{echo|{{pipe}}a}}{{echo|b}}
13611 |}
13612 !! html
13613 <table>
13614 <tr>
13615 <td>ab
13616 </td></tr></table>
13617
13618 !!end
13619
13620 !!test
13621 Templates: Wiki Tables: 4. Templated tags, no content
13622 !! wikitext
13623 {{tbl-start}}
13624 {{tbl-end}}
13625 !! html
13626 <table>
13627 <tr><td></td></tr></table>
13628
13629 !!end
13630
13631 !!test
13632 Templates: Wiki Tables: 5. Templated tags, regular td-tags
13633 !! wikitext
13634 {{tbl-start}}
13635 |foo
13636 {{tbl-end}}
13637 !! html
13638 <table>
13639 <tr>
13640 <td>foo
13641 </td></tr></table>
13642
13643 !!end
13644
13645 !!test
13646 Templates: Wiki Tables: 6. Templated tags, templated td-tags
13647 !! wikitext
13648 {{tbl-start}}
13649 {{!}}foo
13650 {{tbl-end}}
13651 !! html
13652 <table>
13653 <tr>
13654 <td>foo
13655 </td></tr></table>
13656
13657 !!end
13658
13659 ## This test case is very specific to Parsoid's internals
13660 ## and is hence only tested for Parsoid's code. Parsoid uses
13661 ## a <meta> marker tag for <ref> tags and they are expanded
13662 ## much later. We are verifying that this <meta> tag usage
13663 ## doesn't prevent foster parenting.
13664 !! test
13665 Templates: Wiki Tables: 7. Fosterable <ref>s should get fostered
13666 !! wikitext
13667 {{PartialTable}}<ref>foo</ref>
13668 |}
13669
13670 <references />
13671 !! html/parsoid
13672 <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">
13673 <tbody>
13674 </tbody></table>
13675
13676 <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>
13677 !! end
13678
13679 !! test
13680 Templates: Wiki Tables: 8. Fosterable meta-tags should get fostered
13681 !! wikitext
13682 {{echo|
13683 {{{!}}
13684 {{!}}-}}
13685 <onlyinclude>
13686 |foo
13687 </onlyinclude>
13688 {{!}}}
13689 !! html/parsoid
13690 <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{{!}}}"]}'>
13691 </span><meta typeof="mw:Includes/OnlyInclude" about="#mwt1"/><table about="#mwt1">
13692 <tbody><tr>
13693
13694 <td>foo
13695 <meta typeof="mw:Includes/OnlyInclude/End"/></td></tr>
13696 </tbody></table>
13697 !! end
13698
13699 !!test
13700 Templates: Lists: Multi-line list-items via templates
13701 !! wikitext
13702 *{{echo|a {{nonexistent|
13703 unused}}}}
13704 *{{echo|b {{nonexistent|
13705 unused}}}}
13706 !! html
13707 <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>
13708 <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>
13709
13710 !!end
13711
13712 !!test
13713 Templates: Ugly nesting: 1. Quotes opened/closed across templates (echo)
13714 !! wikitext
13715 {{echo|''a}}{{echo|b''c''d}}{{echo|''e}}
13716 !! html
13717 <p><i>ab</i>c<i>d</i>e
13718 </p>
13719 !!end
13720
13721 !!test
13722 Templates: Ugly nesting: 2. Quotes opened/closed across templates (echo_with_span)
13723 (PHP parser generates misnested html)
13724 !! wikitext
13725 {{echo_with_span|''a}}{{echo_with_span|b''c''d}}{{echo_with_span|''e}}
13726 !! html/parsoid
13727 <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>
13728 !!end
13729
13730 !!test
13731 Templates: Ugly nesting: 3. Quotes opened/closed across templates (echo_with_div)
13732 (PHP parser generates misnested html; Parsoid html2wt mode adds newlines between {{echo}}s)
13733 !! options
13734 parsoid=wt2html,wt2wt
13735 !! wikitext
13736 {{echo_with_div|''a}}{{echo_with_div|b''c''d}}{{echo_with_div|''e}}
13737 !! html/php+tidy
13738 <div><i>a</i></div><div><i>b</i>c<i>d</i></div><div>e</div>
13739 !! html/parsoid
13740 <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>
13741 <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>
13742 <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>
13743 !!end
13744
13745 !!test
13746 Templates: Ugly nesting: 4. Divs opened/closed across templates
13747 !! wikitext
13748 a<div>b{{echo|c</div>d}}e
13749 !! html
13750 a<div>bc</div>de
13751
13752 !! html+tidy
13753 <p>a</p><div>bc</div><p>de
13754 </p>
13755 !! end
13756
13757 !! test
13758 Templates: Ugly templates: 3. newline-only template parameter
13759 !! wikitext
13760 foo {{echo|
13761 }}
13762 !! html
13763 <p>foo
13764 </p>
13765 !! end
13766
13767 # This looks like a bug: a single newline triggers p/br for some reason.
13768 !! test
13769 Templates: Ugly templates: 4. newline-only template parameter inconsistency
13770 !! wikitext
13771 {{echo|
13772 }}
13773 !! html
13774 <p><br />
13775 </p>
13776 !! end
13777
13778 # T66017 -- ugly wikitext with fostered content generates two template ranges that
13779 # have a true overlap (T1-start - T2-start - T1-end - T2-end).
13780 !! test
13781 Templates: Ugly templates: 5. Template encapsulation test: Non-trivial overlap of template ranges is properly handled
13782 !! wikitext
13783 {{echo|<table>}}
13784 {{echo|<div>foo}}
13785 {{echo|</table>}}
13786 !! html/parsoid
13787 <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">
13788 </span><table about="#mwt1">
13789 </table>
13790 !! end
13791
13792 # T66017 -- ugly wikitext with fostered content generates two template ranges
13793 # that are "identical" and generate nesting cycles in the algorithm
13794 !! test
13795 Templates: Ugly templates: 6. Template encapsulation test: Cyclical nesting of template ranges is properly handled
13796 !! wikitext
13797 {{echo|<table><tr><td><table>}}
13798 {{echo|<div>}}
13799 {{echo|</div>}}
13800 !! html/parsoid
13801 <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"}'>
13802 </div><table about="#mwt1" data-parsoid='{"stx":"html"}'>
13803 </table></td></tr></tbody></table>
13804 !! end
13805
13806 !! test
13807 Templates: Parameters substituted at the top-level
13808 !! wikitext
13809 {{{foo|''who'' {{echo|me}}? '''never!'''}}}
13810
13811 {{{foo|bar|baz}}}
13812 !! html/php
13813 <p><i>who</i> me? <b>never!</b>
13814 </p><p>bar
13815 </p>
13816 !! html/parsoid
13817 <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>
13818
13819 <p about="#mwt3" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"foo"},"params":{"1":{"wt":"bar"},"2":{"wt":"baz"}},"i":0}}]}'>bar</p>
13820 !! end
13821
13822 !! test
13823 Templates: Param with empty arg in the final position
13824 !! wikitext
13825 {{{hi|}}}
13826 !! html/parsoid
13827 <span about="#mwt1" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"hi"},"params":{"1":{"wt":""}},"i":0}}]}'></span>
13828 !! end
13829
13830 !!test
13831 Parser Functions: 1. Simple example
13832 !! wikitext
13833 {{uc:foo}}
13834 !! html
13835 <p>FOO
13836 </p>
13837 !!end
13838
13839 !!test
13840 Parser Functions: 2. Nested use (only outermost should be marked up)
13841 !! wikitext
13842 {{uc:{{lc:FOO}}}}
13843 !! html
13844 <p>FOO
13845 </p>
13846 !!end
13847
13848 ## Note that the templates inside the references are not wrapped
13849 !! test
13850 Template nested in extension tag in template
13851 !! options
13852 title=[[Main Page]]
13853 language=zh
13854 !! wikitext
13855 {{echo|hi<ref>[[ho|{{echo|hi}}]]</ref>}}
13856 {{echo|hi<ref>[http://test.com?q={{echo|ho}}]</ref>}}
13857 {{echo|hi<ref>-{ho|{{echo|hi}}}-</ref>}}
13858 <references />
13859 !! html/parsoid
13860 <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>
13861 <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>
13862 <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>
13863 <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>
13864 !! end
13865
13866 ###
13867 ### Pre-save transform tests
13868 ###
13869
13870 !! test
13871 pre-save transform: subst:
13872 !! options
13873 pst
13874 !! wikitext
13875 {{subst:test}}
13876 !! html/php
13877 This is a test template
13878 !! end
13879
13880 !! test
13881 pre-save transform: normal template
13882 !! options
13883 pst
13884 !! wikitext
13885 {{test}}
13886 !! html/php
13887 {{test}}
13888 !! end
13889
13890 !! test
13891 pre-save transform: nonexistent template
13892 !! options
13893 pst
13894 !! wikitext
13895 {{thistemplatedoesnotexist}}
13896 !! html/php
13897 {{thistemplatedoesnotexist}}
13898 !! end
13899
13900 !! test
13901 pre-save transform: subst magic variables
13902 !! options
13903 pst
13904 !! wikitext
13905 {{subst:SITENAME}}
13906 !! html/php
13907 MediaWiki
13908 !! end
13909
13910 # This is T2089, which I fixed. -- wtm
13911 !! test
13912 pre-save transform: subst: templates with parameters
13913 !! options
13914 pst
13915 !! wikitext
13916 {{subst:paramtest|param="something else"}}
13917 !! html/php
13918 This is a test template with parameter "something else"
13919 !! end
13920
13921 !! article
13922 Template:nowikitest
13923 !! text
13924 <nowiki>'''not wiki'''</nowiki>
13925 !! endarticle
13926
13927 !! test
13928 pre-save transform: nowiki in subst (T3188)
13929 !! options
13930 pst
13931 !! wikitext
13932 {{subst:nowikitest}}
13933 !! html/php
13934 <nowiki>'''not wiki'''</nowiki>
13935 !! end
13936
13937 !! article
13938 Template:commenttest
13939 !! text
13940 This template has <!-- a comment --> in it.
13941 !! endarticle
13942
13943 !! test
13944 pre-save transform: comment in subst (T3936)
13945 !! options
13946 pst
13947 !! wikitext
13948 {{subst:commenttest}}
13949 !! html/php
13950 This template has <!-- a comment --> in it.
13951 !! end
13952
13953 !! test
13954 pre-save transform: unclosed tag
13955 !! options
13956 pst
13957 !! wikitext
13958 <nowiki>'''not wiki'''
13959 !! html/php
13960 <nowiki>'''not wiki'''
13961 !! end
13962
13963 !! test
13964 pre-save transform: mixed tag case
13965 !! options
13966 pst
13967 !! wikitext
13968 <NOwiki>'''not wiki'''</noWIKI>
13969 !! html/php
13970 <NOwiki>'''not wiki'''</noWIKI>
13971 !! end
13972
13973 !! test
13974 pre-save transform: unclosed comment in <nowiki>
13975 !! options
13976 pst
13977 !! wikitext
13978 wiki<nowiki>nowiki<!--nowiki</nowiki>wiki
13979 !! html/php
13980 wiki<nowiki>nowiki<!--nowiki</nowiki>wiki
13981 !!end
13982
13983 # Leading @ in this template definition works around a limitation
13984 # in parsoid's parserTests which otherwise strips the <span> from the
13985 # result (confusing it for a template wrapper)
13986 !! article
13987 Template:dangerous
13988 !!text
13989 @<span onmouseover="alert('crap')">Oh no</span>
13990 !!endarticle
13991
13992 !!test
13993 (confirming safety of fix for subst T3936)
13994 !! wikitext
13995 {{Template:dangerous}}
13996 !! html
13997 <p>@<span>Oh no</span>
13998 </p>
13999 !! end
14000
14001 !! test
14002 pre-save transform: comment containing gallery (T7024)
14003 !! options
14004 pst
14005 !! wikitext
14006 <!-- <gallery>data</gallery> -->
14007 !! html/php
14008 <!-- <gallery>data</gallery> -->
14009 !!end
14010
14011 !! test
14012 pre-save transform: comment containing extension
14013 !! options
14014 pst
14015 !! wikitext
14016 <!-- <tag>data</tag> -->
14017 !! html/php
14018 <!-- <tag>data</tag> -->
14019 !!end
14020
14021 !! test
14022 pre-save transform: comment containing nowiki
14023 !! options
14024 pst
14025 !! wikitext
14026 <!-- <nowiki>data</nowiki> -->
14027 !! html/php
14028 <!-- <nowiki>data</nowiki> -->
14029 !!end
14030
14031 !! test
14032 pre-save transform: <noinclude> in subst (T5298)
14033 !! options
14034 pst
14035 !! wikitext
14036 {{subst:Includes}}
14037 !! html/php
14038 Foobar
14039 !! end
14040
14041 !! test
14042 pre-save transform: <onlyinclude> in subst (T5298)
14043 !! options
14044 pst
14045 !! wikitext
14046 {{subst:Includes2}}
14047 !! html/php
14048 Foo
14049 !! end
14050
14051 !! article
14052 Template:SubstTest
14053 !!text
14054 {{<includeonly>subst:</includeonly>Includes}}
14055 !! endarticle
14056
14057 !! article
14058 Template:SafeSubstTest
14059 !! text
14060 {{<includeonly>safesubst:</includeonly>Includes}}
14061 !! endarticle
14062
14063 !! test
14064 T24297: safesubst: works during PST
14065 !! options
14066 pst
14067 !! wikitext
14068 {{subst:SafeSubstTest}}{{safesubst:SubstTest}}
14069 !! html/php
14070 FoobarFoobar
14071 !! end
14072
14073 !! test
14074 T24297: safesubst: works during normal parse
14075 !! wikitext
14076 {{SafeSubstTest}}
14077 !! html
14078 <p>Foobar
14079 </p>
14080 !! end
14081
14082 !! test
14083 subst: does not work during normal parse
14084 !! wikitext
14085 {{SubstTest}}
14086 !! html
14087 <p>{{subst:Includes}}
14088 </p>
14089 !! end
14090
14091 !! test
14092 pre-save transform: context links ("pipe trick")
14093 !! options
14094 pst
14095 !! wikitext
14096 [[Article (context)|]]
14097 [[Bar:Article|]]
14098 [[:Bar:Article|]]
14099 [[Bar:Article (context)|]]
14100 [[:Bar:Article (context)|]]
14101 [[|Article]]
14102 [[|Article (context)]]
14103 [[Bar:X (Y) Z|]]
14104 [[:Bar:X (Y) Z|]]
14105 !! html/php
14106 [[Article (context)|Article]]
14107 [[Bar:Article|Article]]
14108 [[:Bar:Article|Article]]
14109 [[Bar:Article (context)|Article]]
14110 [[:Bar:Article (context)|Article]]
14111 [[Article]]
14112 [[Article (context)]]
14113 [[Bar:X (Y) Z|X (Y) Z]]
14114 [[:Bar:X (Y) Z|X (Y) Z]]
14115 !! end
14116
14117 !! test
14118 pre-save transform: context links ("pipe trick") with interwiki prefix
14119 !! options
14120 pst
14121 !! wikitext
14122 [[interwiki:Article|]]
14123 [[:interwiki:Article|]]
14124 [[interwiki:Bar:Article|]]
14125 [[:interwiki:Bar:Article|]]
14126 !! html/php
14127 [[interwiki:Article|Article]]
14128 [[:interwiki:Article|Article]]
14129 [[interwiki:Bar:Article|Bar:Article]]
14130 [[:interwiki:Bar:Article|Bar:Article]]
14131 !! end
14132
14133 !! test
14134 pre-save transform: context links ("pipe trick") with parens in title
14135 !! options
14136 pst title=[[Somearticle (context)]]
14137 !! wikitext
14138 [[|Article]]
14139 !! html/php
14140 [[Article (context)|Article]]
14141 !! end
14142
14143 !! test
14144 pre-save transform: context links ("pipe trick") with comma in title
14145 !! options
14146 pst title=[[Someplace, Somewhere]]
14147 !! wikitext
14148 [[|Otherplace]]
14149 [[Otherplace, Elsewhere|]]
14150 [[Otherplace, Elsewhere, Anywhere|]]
14151 !! html/php
14152 [[Otherplace, Somewhere|Otherplace]]
14153 [[Otherplace, Elsewhere|Otherplace]]
14154 [[Otherplace, Elsewhere, Anywhere|Otherplace]]
14155 !! end
14156
14157 !! test
14158 pre-save transform: context links ("pipe trick") with parens and comma
14159 !! options
14160 pst title=[[Someplace (IGNORED), Somewhere]]
14161 !! wikitext
14162 [[|Otherplace]]
14163 [[Otherplace (place), Elsewhere|]]
14164 !! html/php
14165 [[Otherplace, Somewhere|Otherplace]]
14166 [[Otherplace (place), Elsewhere|Otherplace]]
14167 !! end
14168
14169 !! test
14170 pre-save transform: context links ("pipe trick") with comma and parens
14171 !! options
14172 pst title=[[Who, me? (context)]]
14173 !! wikitext
14174 [[|Yes, you.]]
14175 [[Me, Myself, and I (1937 song)|]]
14176 !! html/php
14177 [[Yes, you. (context)|Yes, you.]]
14178 [[Me, Myself, and I (1937 song)|Me, Myself, and I]]
14179 !! end
14180
14181 !! test
14182 pre-save transform: context links ("pipe trick") with namespace
14183 !! options
14184 pst title=[[Ns:Somearticle]]
14185 !! wikitext
14186 [[|Article]]
14187 !! html/php
14188 [[Ns:Article|Article]]
14189 !! end
14190
14191 !! test
14192 pre-save transform: context links ("pipe trick") with namespace and parens
14193 !! options
14194 pst title=[[Ns:Somearticle (context)]]
14195 !! wikitext
14196 [[|Article]]
14197 !! html/php
14198 [[Ns:Article (context)|Article]]
14199 !! end
14200
14201 !! test
14202 pre-save transform: context links ("pipe trick") with namespace and comma
14203 !! options
14204 pst title=[[Ns:Somearticle, Context, Whatever]]
14205 !! wikitext
14206 [[|Article]]
14207 !! html/php
14208 [[Ns:Article, Context, Whatever|Article]]
14209 !! end
14210
14211 !! test
14212 pre-save transform: context links ("pipe trick") with namespace, comma and parens
14213 !! options
14214 pst title=[[Ns:Somearticle, Context (context)]]
14215 !! wikitext
14216 [[|Article]]
14217 !! html/php
14218 [[Ns:Article (context)|Article]]
14219 !! end
14220
14221 !! test
14222 pre-save transform: context links ("pipe trick") with namespace, parens and comma
14223 !! options
14224 pst title=[[Ns:Somearticle (IGNORED), Context]]
14225 !! wikitext
14226 [[|Article]]
14227 !! html/php
14228 [[Ns:Article, Context|Article]]
14229 !! end
14230
14231 !! test
14232 pre-save transform: context links ("pipe trick") with full-width parens and no space (Japanese and Chinese style, T32149)
14233 !! options
14234 pst
14235 !! wikitext
14236 [[Article(context)|]]
14237 [[Bar:Article(context)|]]
14238 [[:Bar:Article(context)|]]
14239 [[|Article(context)]]
14240 [[Bar:X(Y)Z|]]
14241 [[:Bar:X(Y)Z|]]
14242 !! html/php
14243 [[Article(context)|Article]]
14244 [[Bar:Article(context)|Article]]
14245 [[:Bar:Article(context)|Article]]
14246 [[Article(context)]]
14247 [[Bar:X(Y)Z|X(Y)Z]]
14248 [[:Bar:X(Y)Z|X(Y)Z]]
14249 !! end
14250
14251 !! test
14252 pre-save transform: context links ("pipe trick") with full-width parens and space (Japanese and Chinese style, T32149)
14253 !! options
14254 pst
14255 !! wikitext
14256 [[Article (context)|]]
14257 [[Bar:Article (context)|]]
14258 [[:Bar:Article (context)|]]
14259 [[|Article (context)]]
14260 [[Bar:X (Y) Z|]]
14261 [[:Bar:X (Y) Z|]]
14262 !! html/php
14263 [[Article (context)|Article]]
14264 [[Bar:Article (context)|Article]]
14265 [[:Bar:Article (context)|Article]]
14266 [[Article (context)]]
14267 [[Bar:X (Y) Z|X (Y) Z]]
14268 [[:Bar:X (Y) Z|X (Y) Z]]
14269 !! end
14270
14271 !! test
14272 pre-save transform: context links ("pipe trick") with parens and no space (Korean style, T32149)
14273 !! options
14274 pst
14275 !! wikitext
14276 [[Article(context)|]]
14277 [[Bar:Article(context)|]]
14278 [[:Bar:Article(context)|]]
14279 [[|Article(context)]]
14280 [[Bar:X(Y)Z|]]
14281 [[:Bar:X(Y)Z|]]
14282 !! html/php
14283 [[Article(context)|Article]]
14284 [[Bar:Article(context)|Article]]
14285 [[:Bar:Article(context)|Article]]
14286 [[Article(context)]]
14287 [[Bar:X(Y)Z|X(Y)Z]]
14288 [[:Bar:X(Y)Z|X(Y)Z]]
14289 !! end
14290
14291 !! test
14292 pre-save transform: context links ("pipe trick") with commas (T23660)
14293 !! options
14294 pst
14295 !! wikitext
14296 [[Article (context), context|]]
14297 [[Article (context),context|]]
14298 [[Bar:Article (context), context|]]
14299 [[Bar:Article (context),context|]]
14300 [[:Bar:Article (context), context|]]
14301 [[:Bar:Article (context),context|]]
14302 !! html/php
14303 [[Article (context), context|Article]]
14304 [[Article (context),context|Article]]
14305 [[Bar:Article (context), context|Article]]
14306 [[Bar:Article (context),context|Article]]
14307 [[:Bar:Article (context), context|Article]]
14308 [[:Bar:Article (context),context|Article]]
14309 !! end
14310
14311 !! test
14312 Parsoid: backwards pipe trick
14313 !! wikitext
14314 [[|'''bar''']]
14315 !! html/php
14316 <p>[[|<b>bar</b>]]
14317 </p>
14318 !! html/parsoid
14319 <p>[[|<b>bar</b>]]</p>
14320 !! end
14321
14322 !! test
14323 pre-save transform: trim trailing empty lines
14324 !! options
14325 pst
14326 !! wikitext
14327 Empty lines are trimmed
14328
14329
14330
14331
14332 !! html/php
14333 Empty lines are trimmed
14334 !! end
14335
14336 !! test
14337 pre-save transform: Signature expansion
14338 !! options
14339 pst
14340 !! wikitext
14341 * ~~~
14342 * ~~~~
14343 * ~~~~~
14344 * <noinclude>~~~</noinclude>
14345 * <includeonly>~~~</includeonly>
14346 * <onlyinclude>~~~</onlyinclude>
14347 !! html/php
14348 * [[Special:Contributions/127.0.0.1|127.0.0.1]]
14349 * [[Special:Contributions/127.0.0.1|127.0.0.1]] 00:02, 1 January 1970 (UTC)
14350 * 00:02, 1 January 1970 (UTC)
14351 * <noinclude>[[Special:Contributions/127.0.0.1|127.0.0.1]]</noinclude>
14352 * <includeonly>[[Special:Contributions/127.0.0.1|127.0.0.1]]</includeonly>
14353 * <onlyinclude>[[Special:Contributions/127.0.0.1|127.0.0.1]]</onlyinclude>
14354 !! end
14355
14356
14357 !! test
14358 ParserOutput flags from signature expansion (T84843)
14359 !! options
14360 pst
14361 showflags
14362 !! wikitext
14363 ~~~~
14364 !! html/php
14365 [[Special:Contributions/127.0.0.1|127.0.0.1]] 00:02, 1 January 1970 (UTC)
14366 flags=user-signature
14367 !! end
14368
14369
14370 !! test
14371 pre-save transform: Signature expansion in nowiki tags (T2093)
14372 !! options
14373 pst disabled
14374 !! wikitext
14375 Shall not expand:
14376
14377 <nowiki>~~~~</nowiki>
14378
14379 <includeonly><nowiki>~~~~</nowiki></includeonly>
14380
14381 <noinclude><nowiki>~~~~</nowiki></noinclude>
14382
14383 <onlyinclude><nowiki>~~~~</nowiki></onlyinclude>
14384
14385 {{subst:Foo}} shall be converted to FOO
14386
14387 As well as inside noinclude/onlyinclude
14388 <noinclude>{{subst:Foo}}</noinclude>
14389 <onlyinclude>{{subst:Foo}}</onlyinclude>
14390
14391 But not inside includeonly
14392 <includeonly>{{subst:Foo}}</includeonly>
14393 !! html/php
14394 Shall not expand:
14395
14396 <nowiki>~~~~</nowiki>
14397
14398 <includeonly><nowiki>~~~~</nowiki></includeonly>
14399
14400 <noinclude><nowiki>~~~~</nowiki></noinclude>
14401
14402 <onlyinclude><nowiki>~~~~</nowiki></onlyinclude>
14403
14404 FOO shall be converted to FOO
14405
14406 As well as inside noinclude/onlyinclude
14407 <noinclude>FOO</noinclude>
14408 <onlyinclude>FOO</onlyinclude>
14409
14410 But not inside includeonly
14411 <includeonly>{{subst:Foo}}</includeonly>
14412 !! end
14413
14414 !! test
14415 Parsoid: Recognize nowiki with trailing space in tags
14416 !! options
14417 parsoid=wt2html
14418 !! wikitext
14419 <nowiki ><div>[[foo]]</nowiki >
14420
14421 a<nowiki / >b
14422
14423 c<nowiki />d
14424
14425 e<nowiki/ >f
14426 !! html/php+tidy
14427 <p>&lt;div&gt;[[foo]]
14428 </p><p>a&lt;nowiki / &gt;b
14429 </p><p>cd
14430 </p><p>e&lt;nowiki/ &gt;f
14431 </p>
14432 !! html/parsoid
14433 <p><span typeof="mw:Nowiki">&lt;div>[[foo]]</span></p>
14434
14435 <p>a&lt;nowiki / >b</p>
14436
14437 <p>c<span typeof="mw:Nowiki"></span>d</p>
14438
14439 <p>e&lt;nowiki/ >f</p>
14440 !! end
14441
14442 !! test
14443 Parsoid: Recognize nowiki with odd capitalization
14444 !! options
14445 parsoid=wt2html
14446 !! wikitext
14447 <noWikI ><div>[[foo]]</Nowiki >
14448 !! html/php+tidy
14449 <p>&lt;div&gt;[[foo]]
14450 </p>
14451 !! html/parsoid
14452 <p><span typeof="mw:Nowiki">&lt;div&gt;[[foo]]</span></p>
14453 !! end
14454
14455
14456 !! test
14457 Parsoid: Escape nowiki with trailing space in tags
14458 !! options
14459 parsoid=html2wt
14460 !! html/parsoid
14461 <p>&lt;nowiki &gt; foo &lt/nowiki ></p>
14462 <p>a&lt;nowiki /&gt;b</p>
14463 <p>c&lt;nowiki/ &gt;d</p>
14464 !! wikitext
14465 &lt;nowiki &gt; foo &lt;/nowiki &gt;
14466
14467 a&lt;nowiki /&gt;b
14468
14469 c&lt;nowiki/ &gt;d
14470 !! end
14471
14472 !! test
14473 Parsoid: Escape weird noWikI capitalizations
14474 !! options
14475 parsoid=html2wt
14476 !! html/parsoid
14477 <p>&lt;noWikI &gt; foo &lt/NoWikI ></p>
14478 !! wikitext
14479 &lt;noWikI &gt; foo &lt;/NoWikI &gt;
14480 !! end
14481
14482 ###
14483 ### Message transform tests
14484 ###
14485 !! test
14486 message transform: magic variables
14487 !! options
14488 msg
14489 !! wikitext
14490 {{SITENAME}}
14491 !! html
14492 MediaWiki
14493 !! end
14494
14495 !! test
14496 message transform: should not transform wiki markup
14497 !! options
14498 msg
14499 !! wikitext
14500 ''test''
14501 !! html
14502 ''test''
14503 !! end
14504
14505 !! test
14506 message transform: <noinclude> in transcluded template (T6926)
14507 !! options
14508 msg
14509 !! wikitext
14510 {{Includes}}
14511 !! html
14512 Foobar
14513 !! end
14514
14515 !! test
14516 message transform: <onlyinclude> in transcluded template (T6926)
14517 !! options
14518 msg
14519 !! wikitext
14520 {{Includes2}}
14521 !! html
14522 Foo
14523 !! end
14524
14525 !! test
14526 {{#special:}} page name, known
14527 !! options
14528 msg
14529 !! wikitext
14530 {{#special:Recentchanges}}
14531 !! html
14532 Special:RecentChanges
14533 !! end
14534
14535 !! test
14536 {{#special:}} page name with subpage, known
14537 !! options
14538 msg
14539 !! wikitext
14540 {{#special:Recentchanges/param}}
14541 !! html
14542 Special:RecentChanges/param
14543 !! end
14544
14545 !! test
14546 {{#special:}} page name, unknown
14547 !! options
14548 msg
14549 !! wikitext
14550 {{#special:foobar nonexistent}}
14551 !! html
14552 Special:Foobar nonexistent
14553 !! end
14554
14555 !! test
14556 {{#speciale:}} page name, known
14557 !! options
14558 msg
14559 !! wikitext
14560 {{#speciale:Recentchanges}}
14561 !! html
14562 Special:RecentChanges
14563 !! end
14564
14565 !! test
14566 {{#speciale:}} page name with subpage, known
14567 !! options
14568 msg
14569 !! wikitext
14570 {{#speciale:Recentchanges/param}}
14571 !! html
14572 Special:RecentChanges/param
14573 !! end
14574
14575 !! test
14576 {{#speciale:}} page name, unknown
14577 !! options
14578 msg
14579 !! wikitext
14580 {{#speciale:foobar nonexistent}}
14581 !! html
14582 Special:Foobar_nonexistent
14583 !! end
14584
14585 ###
14586 ### Images
14587 ###
14588 ### For Parsoid-specific tests, see
14589 #### https://www.mediawiki.org/wiki/Parsoid/MediaWiki_DOM_spec#Images
14590
14591 !! test
14592 Simple image
14593 !! options
14594 parsoid=wt2html,wt2wt,html2html
14595 !! wikitext
14596 [[Image:foobar.jpg]]
14597 !! html/php
14598 <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>
14599 </p>
14600 !! html/parsoid
14601 <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>
14602 !! end
14603
14604 !! test
14605 Serialize simple image with span wrapper
14606 !! options
14607 parsoid=html2wt
14608 !! html/parsoid
14609 <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>
14610 !! wikitext
14611 [[File:Foobar.jpg]]
14612 !! end
14613
14614 !! test
14615 Simple image (using File: namespace, now canonical)
14616 !! wikitext
14617 [[File:Foobar.jpg]]
14618 !! html/php
14619 <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>
14620 </p>
14621 !! html/parsoid
14622 <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>
14623 !! end
14624
14625 !! test
14626 Right-aligned image
14627 !! wikitext
14628 [[File:Foobar.jpg|right]]
14629 !! html/php
14630 <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>
14631
14632 !! html/parsoid
14633 <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>
14634 !! end
14635
14636 !! test
14637 Image with caption
14638 !! wikitext
14639 [[File:Foobar.jpg|right|Caption text]]
14640 !! html/php
14641 <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>
14642
14643 !! html/parsoid
14644 <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>
14645 !! end
14646
14647 !! test
14648 Image with caption, T55312 #1
14649 !! wikitext
14650 [[File:Foobar.jpg|right|Caption page stuff]]
14651 !! html/php
14652 <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>
14653
14654 !! html/parsoid
14655 <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>
14656 !! end
14657
14658 !! test
14659 Image with caption, T55312 #2
14660 !! wikitext
14661 [[File:Foobar.jpg|right|Caption page=]]
14662 !! html/php
14663 <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>
14664
14665 !! html/parsoid
14666 <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>
14667 !! end
14668
14669 !! test
14670 Image with caption, T55312 #3
14671 !! wikitext
14672 [[File:Foobar.jpg|right|Caption page=stuff]]
14673 !! html/php
14674 <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>
14675
14676 !! html/parsoid
14677 <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>
14678 !! end
14679
14680 !! test
14681 Image caption with pipe entity
14682 !! wikitext
14683 [[File:Foobar.jpg|thumb|one &#x7C; two]]
14684 [[File:Foobar.jpg|thumb|one ''two'' &#x7C; three]]
14685 !! html/php
14686 <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>
14687 <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>
14688
14689 !! html/parsoid
14690 <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>
14691 <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>
14692 !! end
14693
14694 !! test
14695 Allow empty links in image captions (T62753)
14696 !! options
14697 thumbsize=220
14698 !! wikitext
14699 [[File:Foobar.jpg|thumb|Caption [[Link1]]
14700 [[]]
14701 [[Link2]]
14702 ]]
14703 !! html/php
14704 <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>
14705
14706 !! html/parsoid
14707 <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>
14708 [[]]
14709 <a rel="mw:WikiLink" href="./Link2" title="Link2" data-parsoid='{"stx":"simple","a":{"href":"./Link2"},"sa":{"href":"Link2"}}'>Link2</a>
14710 </figcaption></figure>
14711 !! end
14712
14713 !! test
14714 Titles in unlinked images (T23454)
14715 !! wikitext
14716 [[File:Foobar.jpg|link=|stuff]]
14717 !! html/php
14718 <p><img alt="stuff" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" title="stuff" width="1941" height="220" />
14719 </p>
14720 !! html/parsoid
14721 <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>
14722 !! end
14723
14724 !! test
14725 Link with empty target
14726 !! wikitext
14727 [[]]
14728 !! html
14729 <p>[[]]
14730 </p>
14731 !! end
14732
14733 !! test
14734 Image with link trail
14735 !! wikitext
14736 Linktrails should not work for images: [[File:Foobar.jpg]]s
14737 !! html/php
14738 <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
14739 </p>
14740 !! html/parsoid
14741 <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>
14742 !! end
14743
14744 !! test
14745 Image with empty attribute
14746 !! options
14747 parsoid=wt2html,wt2wt,html2html
14748 !! wikitext
14749 [[File:Foobar.jpg|right||Caption text]]
14750 !! html/php
14751 <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>
14752
14753 !! html/parsoid
14754 <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>
14755 !! end
14756
14757 !! test
14758 1. Block image with individual attributes from templates
14759 !! wikitext
14760 [[File:Foobar.jpg|thumb|{{echo|137px}}|This is a caption]]
14761 !! html/php
14762 <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>
14763
14764 !! html/parsoid
14765 <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>
14766 !! end
14767
14768 !! test
14769 2. Block Image with individual attributes from templates
14770 !! wikitext
14771 [[File:Foobar.jpg|{{echo|thumb}}|{{echo|137px}}|This is a caption]]
14772 !! html/php
14773 <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>
14774
14775 !! html/parsoid
14776 <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>
14777 !! end
14778
14779 !! test
14780 3. Inline image with individual attributes from templates
14781 !! wikitext
14782 [[File:Foobar.jpg|{{echo|50px}}]]
14783 !! html/php
14784 <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>
14785 </p>
14786 !! html/parsoid
14787 <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>
14788 !! end
14789
14790 ## Parsoid does not provide editing support for images where templates produce multiple image attributes.
14791 ## To signal this, we add a 'mw:Placeholder' type to such images. This could change in the future.
14792 !! test
14793 Image with multiple attributes from the same template
14794 !! wikitext
14795 [[File:Foobar.jpg|{{image_attribs}}]]
14796 !! html/php
14797 <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>
14798
14799 !! html/parsoid
14800 <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>
14801 !! end
14802
14803 !! test
14804 Image with link tails
14805 !! options
14806 thumbsize=220
14807 !! wikitext
14808 123[[File:Foobar.jpg]]456
14809 123[[File:Foobar.jpg|right]]456
14810 123[[File:Foobar.jpg|thumb]]456
14811 !! html/php
14812 <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
14813 </p>
14814 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
14815 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
14816
14817 !! html/php+tidy
14818 <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
14819 </p><p>
14820 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
14821 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
14822 </p>
14823 !! html/parsoid
14824 <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>
14825 <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
14826 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>
14827 !! end
14828
14829 !! test
14830 Image with multiple captions -- only last one is accepted
14831 !! wikitext
14832 [[File:Foobar.jpg|right|Caption1 - ignored|[[Caption2]] - ignored|Caption3 - accepted]]
14833 !! html/php
14834 <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>
14835
14836 !! html/parsoid
14837 <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>
14838 !! end
14839
14840 !! test
14841 Image with multiple widths -- use last
14842 !! wikitext
14843 [[File:Foobar.jpg|200px|300px|caption]]
14844 !! html/php
14845 <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>
14846 </p>
14847 !! html/parsoid
14848 <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>
14849 !! end
14850
14851 !! test
14852 Image with multiple alignments -- use first (T50664)
14853 !! options
14854 thumbsize=220
14855 !! wikitext
14856 [[File:Foobar.jpg|thumb|left|right|center|caption]]
14857
14858 [[File:Foobar.jpg|middle|text-top|caption]]
14859 !! html/php
14860 <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>
14861 <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>
14862 </p>
14863 !! html/parsoid
14864 <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>
14865 <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>
14866 !! end
14867
14868 !! test
14869 Image with width attribute at different positions
14870 !! wikitext
14871 [[File:Foobar.jpg|200px|right|Caption]]
14872 [[File:Foobar.jpg|right|200px|Caption]]
14873 [[File:Foobar.jpg|right|Caption|200px]]
14874 !! html/php
14875 <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>
14876 <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>
14877 <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>
14878
14879 !! html/parsoid
14880 <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>
14881 <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>
14882 <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>
14883 !! end
14884
14885 # a sad bit of backward-compatibility
14886 !! test
14887 Image with size specified with pxpx (T15500, T53628)
14888 !! options
14889 parsoid=wt2html,wt2wt,html2html
14890 !! wikitext
14891 [[File:Foobar.jpg|20pxpx]]
14892 [[File:Foobar.jpg|200x20pxpx]]
14893 !! html/php
14894 <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>
14895 <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>
14896 </p>
14897 !! html/parsoid
14898 <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>
14899 !! end
14900
14901 !! test
14902 Image with link parameter, wiki target
14903 !! wikitext
14904 [[File:Foobar.jpg|link=Main Page]]
14905 !! html/php
14906 <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>
14907 </p>
14908 !! html/parsoid
14909 <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>
14910 !! end
14911
14912 # parsoid T51293 (part 1)
14913 !! test
14914 Image with link parameter, URL target
14915 !! wikitext
14916 [[File:Foobar.jpg|link=http://example.com/]]
14917 !! html/php
14918 <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>
14919 </p>
14920 !! html/parsoid
14921 <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>
14922 !! end
14923
14924 # parsoid T51293 (part 2)
14925 !! test
14926 Image with link parameter, protocol-less URL target
14927 !! wikitext
14928 [[File:Foobar.jpg|link=//example.com/]]
14929 !! html/php
14930 <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>
14931 </p>
14932 !! html/parsoid
14933 <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>
14934 !! end
14935
14936 !! test
14937 Escaping non-block captions (T107435)
14938 !! options
14939 parsoid={
14940 "modes": ["wt2wt"],
14941 "changes": [
14942 ["[typeof~='mw:Image']", "attr", "data-mw", "{\"caption\": \"|\"}"]
14943 ]
14944 }
14945 !! wikitext
14946 [[Image:Foobar.jpg|caption]]
14947 !! wikitext/edited
14948 [[Image:Foobar.jpg|<nowiki>|</nowiki>]]
14949 !! end
14950
14951 # wgExternalLinkTarget not supported by Parsoid
14952 !! test
14953 Image with link parameter, wgExternalLinkTarget
14954 !! wikitext
14955 [[Image:foobar.jpg|link=http://example.com/]]
14956 !! config
14957 wgExternalLinkTarget='foobar'
14958 !! html/php
14959 <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>
14960 </p>
14961 !! end
14962
14963 !! test
14964 Image with link parameter, wgNoFollowLinks set to false
14965 !! wikitext
14966 [[Image:foobar.jpg|link=http://example.com/]]
14967 !! config
14968 wgNoFollowLinks=false
14969 !! html/php
14970 <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>
14971 </p>
14972 !! end
14973
14974 !! test
14975 Image with link parameter, wgNoFollowDomainExceptions
14976 !! wikitext
14977 [[Image:foobar.jpg|link=http://example.com/]]
14978 !! config
14979 wgNoFollowDomainExceptions='example.com'
14980 !! html/php
14981 <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>
14982 </p>
14983 !! end
14984
14985 # wgExternalLinkTarget not supported by Parsoid
14986 !! test
14987 Image with link parameter, wgExternalLinkTarget, unnamed parameter
14988 !! wikitext
14989 [[Image:foobar.jpg|link=http://example.com/|Title]]
14990 !! config
14991 wgExternalLinkTarget='foobar'
14992 !! html/php
14993 <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>
14994 </p>
14995 !! end
14996
14997 !! test
14998 Image with empty link parameter
14999 !! wikitext
15000 [[File:Foobar.jpg|link=]]
15001 !! html/php
15002 <p><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" />
15003 </p>
15004 !! html/parsoid
15005 <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>
15006 !! end
15007
15008 !! test
15009 Image with link parameter (wiki target) and unnamed parameter
15010 !! wikitext
15011 [[File:Foobar.jpg|link=Main_Page|Title]]
15012 !! html/php
15013 <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>
15014 </p>
15015 !! html/parsoid
15016 <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>
15017 !! end
15018
15019 !! test
15020 Image with link parameter (URL target) and unnamed parameter
15021 !! wikitext
15022 [[File:Foobar.jpg|link=http://example.com/|Title]]
15023 !! html/php
15024 <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>
15025 </p>
15026 !! html/parsoid
15027 <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>
15028 !! end
15029
15030 !! test
15031 Thumbnail image with link parameter
15032 !! options
15033 thumbsize=220
15034 parsoid=wt2html,wt2wt,html2html
15035 !! wikitext
15036 [[File:Foobar.jpg|thumb|link=http://example.com/|Title]]
15037 !! html/php
15038 <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>
15039
15040 !! html/parsoid
15041 <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>
15042 !! end
15043
15044 !! test
15045 Manually-specified thumbnail image
15046 !! options
15047 thumbsize=220
15048 !! wikitext
15049 [[File:Foobar.jpg|thumbnail=Thumb.png|Title]]
15050 !! html/php
15051 <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>
15052
15053 !! html/parsoid
15054 <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>
15055 !! end
15056
15057 !! test
15058 Manually-specified thumbnail image with explicit link to wiki page
15059 !! options
15060 thumbsize=220
15061 parsoid=wt2html,wt2wt,html2html
15062 !! wikitext
15063 [[File:Foobar.jpg|thumb=Thumb.png|link=Main_Page|Title]]
15064 !! html/php
15065 <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>
15066
15067 !! html/parsoid
15068 <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>
15069 !! end
15070
15071 !! test
15072 Manually-specified thumbnail image with explicit link to url
15073 !! options
15074 thumbsize=220
15075 parsoid=wt2html,wt2wt,html2html
15076 !! wikitext
15077 [[File:Foobar.jpg|thumb=Thumb.png|link=http://example.com|Title]]
15078 !! html/php
15079 <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>
15080
15081 !! html/parsoid
15082 <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>
15083 !! end
15084
15085 !! test
15086 Manually-specified thumbnail image with explicit no link
15087 !! options
15088 thumbsize=220
15089 parsoid=wt2html,wt2wt,html2html
15090 !! wikitext
15091 [[File:Foobar.jpg|thumb=Thumb.png|link=|Title]]
15092 !! html/php
15093 <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>
15094
15095 !! html/parsoid
15096 <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>
15097 !! end
15098
15099 !! test
15100 Manually-specified thumbnail image with explicit link and alt text
15101 !! options
15102 thumbsize=220
15103 parsoid=wt2html,wt2wt,html2html
15104 !! wikitext
15105 [[File:Foobar.jpg|thumb=Thumb.png|link=Main_Page|alt=alttext|Title]]
15106 !! html/php
15107 <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>
15108
15109 !! html/parsoid
15110 <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>
15111 !! end
15112
15113 !! test
15114 Image with frame and link
15115 !! options
15116 parsoid=wt2html,wt2wt,html2html
15117 !! wikitext
15118 [[File:Foobar.jpg|frame|left|This is a test image [[Main Page]]]]
15119 !! html/php
15120 <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>
15121
15122 !! html/parsoid
15123 <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>
15124 !! end
15125
15126 !! test
15127 Image with frame and link and explicit alt
15128 !! options
15129 parsoid=wt2html,wt2wt,html2html
15130 !! wikitext
15131 [[Image:Foobar.jpg|frame|left|This is a test image [[Main Page]]|alt=Altitude]]
15132 !! html/php
15133 <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>
15134
15135 !! html/parsoid
15136 <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>
15137 !! end
15138
15139 !! test
15140 Image with wiki markup in implicit alt
15141 !! wikitext
15142 [[Image:Foobar.jpg|testing '''bold''' in alt]]
15143
15144 [[Image:Foobar.jpg|alt=testing '''bold''' in alt]]
15145 !! html/php
15146 <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>
15147 </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>
15148 </p>
15149 !! html/parsoid
15150 <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>
15151
15152 <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>
15153 !! end
15154
15155 !! test
15156 Alt image option should handle most kinds of wikitext without barfing
15157 !! wikitext
15158 [[Image:Foobar.jpg|thumb|This is the image caption|alt=This is a [[link]] and a {{echo|''bold template''}}.]]
15159 !! html/php
15160 <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>
15161
15162 !! html/parsoid
15163 <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>
15164 !! end
15165
15166 !! test
15167 Ampersand in alt attribute (T206940)
15168 !! options
15169 parsoid = {
15170 "nativeGallery": true
15171 }
15172 !! wikitext
15173 [[File:Foobar.jpg|alt=&amp;amp;]]
15174
15175 <!-- consistency with gallery extension -->
15176 <gallery>
15177 File:Foobar.jpg|alt=&amp;amp;
15178 </gallery>
15179 !! html/php+tidy
15180 <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>
15181 </p>
15182 <ul class="gallery mw-gallery-traditional">
15183 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15184 <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>
15185 <div class="gallerytext">
15186 </div>
15187 </div></li>
15188 </ul>
15189 !! html/parsoid
15190 <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>
15191
15192 <!-- consistency with gallery extension -->
15193 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
15194 <li class="gallerybox">
15195 <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>
15196 <div class="gallerytext"></div>
15197 </li>
15198 </ul>
15199 !! end
15200
15201 !! test
15202 Italics markup in alt attribute (T206940)
15203 !! wikitext
15204 [[File:Foobar.jpg|alt=''x''|caption]]
15205
15206 <!-- consistency with gallery extension -->
15207 <gallery>
15208 File:Foobar.jpg|alt=''x''|caption
15209 </gallery>
15210 !! html/php+tidy
15211 <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>
15212 </p>
15213 <ul class="gallery mw-gallery-traditional">
15214 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15215 <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>
15216 <div class="gallerytext">
15217 <p>caption
15218 </p>
15219 </div>
15220 </div></li>
15221 </ul>
15222 !! html/parsoid
15223 <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>
15224
15225 <!-- consistency with gallery extension -->
15226 <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"}}'>
15227 <li class="gallerybox">
15228 <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>
15229 <div class="gallerytext">caption</div>
15230 </li>
15231 </ul>
15232 !! end
15233
15234 !! test
15235 Nowiki markup in alt attribute (T206940)
15236 !! wikitext
15237 [[File:Foobar.jpg|alt=<nowiki>''</nowiki>x<nowiki>''</nowiki>|caption]]
15238
15239 <!-- consistency with gallery extension -->
15240 <gallery>
15241 File:Foobar.jpg|alt=<nowiki>''</nowiki>x<nowiki>''</nowiki>|caption
15242 </gallery>
15243 !! html/php+tidy
15244 <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>
15245 </p>
15246 <ul class="gallery mw-gallery-traditional">
15247 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15248 <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>
15249 <div class="gallerytext">
15250 <p>caption
15251 </p>
15252 </div>
15253 </div></li>
15254 </ul>
15255 !! html/parsoid
15256 <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>
15257
15258 <!-- consistency with gallery extension -->
15259 <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"}}'>
15260 <li class="gallerybox">
15261 <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>
15262 <div class="gallerytext">caption</div>
15263 </li>
15264 </ul>
15265 !! end
15266
15267 !! test
15268 Nowiki markup in alt attribute (edited html, no data-parsoid) (T206940)
15269 !! options
15270 parsoid = {
15271 "nativeGallery": true
15272 }
15273 !! wikitext
15274 [[File:Foobar.jpg|alt=<nowiki>''x''</nowiki>|caption]]
15275
15276 <!-- consistency with gallery extension -->
15277 <gallery>
15278 File:Foobar.jpg|alt=<nowiki>''x''</nowiki>|caption
15279 </gallery>
15280 !! html/php+tidy
15281 <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>
15282 </p>
15283 <ul class="gallery mw-gallery-traditional">
15284 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15285 <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>
15286 <div class="gallerytext">
15287 <p>caption
15288 </p>
15289 </div>
15290 </div></li>
15291 </ul>
15292 !! html/parsoid
15293 <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>
15294
15295 <!-- consistency with gallery extension -->
15296 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
15297 <li class="gallerybox">
15298 <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>
15299 <div class="gallerytext">caption</div>
15300 </li>
15301 </ul>
15302 !! end
15303
15304 !! test
15305 Ampersand in link attribute (T206940)
15306 !! wikitext
15307 [[File:Foobar.jpg|link=Foo &amp; bar]]
15308
15309 <!-- consistency with gallery extension -->
15310 <gallery>
15311 File:Foobar.jpg|link=Foo &amp; bar
15312 </gallery>
15313 !! html/php+tidy
15314 <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>
15315 </p>
15316 <ul class="gallery mw-gallery-traditional">
15317 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15318 <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>
15319 <div class="gallerytext">
15320 </div>
15321 </div></li>
15322 </ul>
15323 !! html/parsoid
15324 <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>
15325
15326 <!-- consistency with gallery extension -->
15327 <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"}}'>
15328 <li class="gallerybox">
15329 <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>
15330 <div class="gallerytext"></div>
15331 </li>
15332 </ul>
15333 !! end
15334
15335 !! test
15336 Ampersand in link attribute (edited html, no data-parsoid) (T206940)
15337 !! options
15338 parsoid = {
15339 "nativeGallery": true
15340 }
15341 !! wikitext
15342 [[File:Foobar.jpg|link=Foo_&_bar]]
15343
15344 <!-- consistency with gallery extension -->
15345 <gallery>
15346 File:Foobar.jpg|link=Foo_&_bar
15347 </gallery>
15348 !! html/php+tidy
15349 <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>
15350 </p>
15351 <ul class="gallery mw-gallery-traditional">
15352 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15353 <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>
15354 <div class="gallerytext">
15355 </div>
15356 </div></li>
15357 </ul>
15358 !! html/parsoid
15359 <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>
15360
15361 <!-- consistency with gallery extension -->
15362 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
15363 <li class="gallerybox">
15364 <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>
15365 <div class="gallerytext"></div>
15366 </li>
15367 </ul>
15368 !! end
15369
15370 !! test
15371 Italics markup in link attribute (T206940)
15372 !! wikitext
15373 [[Foo''s bar''s]]
15374
15375 <!-- Note that "italics" are stripped, even though this is a valid page title -->
15376 [[File:Foobar.jpg|link=Foo''s bar''s|caption1]]
15377
15378 [[File:Foobar.jpg|link=''Main Page''|caption2]]
15379
15380 <!-- consistency with gallery extension -->
15381 <gallery>
15382 File:Foobar.jpg|link=Foo''s bar''s|caption1
15383 File:Foobar.jpg|link=''Main Page''|caption2
15384 </gallery>
15385 !! html/php+tidy
15386 <p><a href="/wiki/Foo%27%27s_bar%27%27s" title="Foo&#39;&#39;s bar&#39;&#39;s">Foo''s bar''s</a>
15387 </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>
15388 </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>
15389 </p>
15390 <ul class="gallery mw-gallery-traditional">
15391 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15392 <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>
15393 <div class="gallerytext">
15394 <p>caption1
15395 </p>
15396 </div>
15397 </div></li>
15398 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15399 <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>
15400 <div class="gallerytext">
15401 <p>caption2
15402 </p>
15403 </div>
15404 </div></li>
15405 </ul>
15406 !! html/parsoid
15407 <p><a rel="mw:WikiLink" href="./Foo''s_bar''s" title="Foo''s bar''s">Foo''s bar''s</a></p>
15408
15409 <!-- Note that "italics" are stripped, even though this is a valid page title -->
15410 <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>
15411
15412 <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>
15413
15414 <!-- consistency with gallery extension -->
15415 <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"}}'>
15416 <li class="gallerybox">
15417 <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>
15418 <div class="gallerytext">caption1</div>
15419 </li>
15420 <li class="gallerybox">
15421 <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>
15422 <div class="gallerytext">caption2</div>
15423 </li>
15424 </ul>
15425 !! end
15426
15427 !! test
15428 Nowiki markup in link attribute (T206940)
15429 !! wikitext
15430 [[File:Foobar.jpg|link=Foo<nowiki>''</nowiki>s_bar<nowiki>''</nowiki>s|caption]]
15431
15432 <!-- consistency with gallery extension -->
15433 <gallery>
15434 File:Foobar.jpg|link=Foo<nowiki>''</nowiki>s_bar<nowiki>''</nowiki>s|caption
15435 </gallery>
15436 !! html/php+tidy
15437 <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>
15438 </p>
15439 <ul class="gallery mw-gallery-traditional">
15440 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15441 <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>
15442 <div class="gallerytext">
15443 <p>caption
15444 </p>
15445 </div>
15446 </div></li>
15447 </ul>
15448 !! html/parsoid
15449 <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>
15450
15451 <!-- consistency with gallery extension -->
15452 <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"}}'>
15453 <li class="gallerybox">
15454 <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>
15455 <div class="gallerytext">caption</div>
15456 </li>
15457 </ul>
15458 !! end
15459
15460 !! test
15461 Nowiki markup in link attribute (edited html, no data-parsoid) (T206940)
15462 !! options
15463 parsoid = {
15464 "nativeGallery": true
15465 }
15466 !! wikitext
15467 [[File:Foobar.jpg|link=Foo<nowiki>''s_bar''</nowiki>s|caption]]
15468
15469 <!-- consistency with gallery extension -->
15470 <gallery>
15471 File:Foobar.jpg|link=Foo<nowiki>''s_bar''</nowiki>s|caption
15472 </gallery>
15473 !! html/php+tidy
15474 <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>
15475 </p>
15476 <ul class="gallery mw-gallery-traditional">
15477 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15478 <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>
15479 <div class="gallerytext">
15480 <p>caption
15481 </p>
15482 </div>
15483 </div></li>
15484 </ul>
15485 !! html/parsoid
15486 <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>
15487
15488 <!-- consistency with gallery extension -->
15489 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
15490 <li class="gallerybox">
15491 <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>
15492 <div class="gallerytext">caption</div>
15493 </li>
15494 </ul>
15495 !! end
15496
15497 !! test
15498 HTML entity prefix in link markup (T209236)
15499 !! wikitext
15500 [[File:Foobar.jpg|link=https://example.com?foo&params=bar]]
15501
15502 <!-- consistency with gallery extension -->
15503 <gallery>
15504 File:Foobar.jpg|link=https://example.com?foo&params=bar
15505 </gallery>
15506 !! html/php+tidy
15507 <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>
15508 </p>
15509 <ul class="gallery mw-gallery-traditional">
15510 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15511 <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>
15512 <div class="gallerytext">
15513 </div>
15514 </div></li>
15515 </ul>
15516 !! html/parsoid
15517 <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>
15518
15519 <!-- consistency with gallery extension -->
15520 <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"}}'>
15521 <li class="gallerybox">
15522 <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>
15523 <div class="gallerytext"></div>
15524 </li>
15525 </ul>
15526 !! end
15527
15528 !! test
15529 Image with table with attributes in caption
15530 !! options
15531 parsoid=wt2html,html2html
15532 !! wikitext
15533 [[File:Foobar.jpg|thumb|
15534 {| class="123" |
15535 |- class="456" |
15536 | ha
15537 |}
15538 ]]
15539 !! html/parsoid
15540 <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>
15541 <table class="123">
15542 <tbody><tr class="456" data-parsoid='{"startTagSrc":"|-"}'>
15543 <td> ha</td></tr>
15544 </tbody></table>
15545 </figcaption></figure>
15546 !! end
15547
15548 !! test
15549 Image with table with rows from templates in caption
15550 !! wikitext
15551 [[File:Foobar.jpg|thumb|
15552 {|
15553 {{echo|{{!}} hi}}
15554 |}
15555 ]]
15556 !! html/parsoid
15557 <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>
15558 <table>
15559 <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>
15560 </tbody></table>
15561 </figcaption></figure>
15562 !! end
15563
15564 !! test
15565 Image with nested tables in caption
15566 !! wikitext
15567 [[File:Foobar.jpg|thumb|Foo<br />
15568 {|
15569 |
15570 {|
15571 |z
15572 |}
15573 |}
15574 ]]
15575 !! html/parsoid
15576 <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}'/>
15577 <table>
15578 <tbody><tr><td>
15579 <table>
15580 <tbody><tr><td>z</td></tr>
15581 </tbody></table></td></tr>
15582 </tbody></table>
15583 </figcaption></figure>
15584 !! end
15585
15586 !! test
15587 Image with heading and horizontal rule in caption
15588 !! wikitext
15589 [[File:Foobar.jpg|thumb|
15590 ===Testing===
15591 123
15592 --------------
15593 ]]
15594 !! html/php
15595 <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>
15596
15597 !! html/parsoid
15598 <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>
15599 <h3 id="Testing">Testing</h3>
15600 123
15601 <hr data-parsoid='{"extra_dashes":10}'/>
15602 </figcaption></figure>
15603 !! end
15604
15605 ###################
15606 # Conflicting image format options.
15607 # First option specified should 'win'.
15608 # All three cases in each test should be identical.
15609
15610 !! test
15611 Image with 'frameless' first.
15612 !! options
15613 parsoid=wt2html,wt2wt,html2html
15614 !! wikitext
15615 [[File:Foobar.jpg|frameless|caption]]
15616
15617 [[File:Foobar.jpg|frameless|frame|caption]]
15618
15619 [[File:Foobar.jpg|frameless|thumb|caption]]
15620 !! html/php
15621 <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>
15622 </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>
15623 </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>
15624 </p>
15625 !! html/parsoid
15626 <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>
15627 <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>
15628 <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>
15629 !! end
15630
15631 !! test
15632 Image with 'frame' first.
15633 !! options
15634 parsoid=wt2html,wt2wt,html2html
15635 !! wikitext
15636 [[File:Foobar.jpg|frame|caption]]
15637 [[File:Foobar.jpg|frame|frameless|caption]]
15638 [[File:Foobar.jpg|frame|thumb|caption]]
15639 !! html/php
15640 <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>
15641 <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>
15642 <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>
15643
15644 !! html/parsoid
15645 <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>
15646 <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>
15647 <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>
15648 !! end
15649
15650 !! test
15651 Image with 'thumb' first.
15652 !! options
15653 parsoid=wt2html,wt2wt,html2html
15654 !! wikitext
15655 [[File:Foobar.jpg|thumb|caption]]
15656 [[File:Foobar.jpg|thumb|frameless|caption]]
15657 [[File:Foobar.jpg|thumb|frame|caption]]
15658 !! html/php
15659 <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>
15660 <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>
15661 <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>
15662
15663 !! html/parsoid
15664 <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>
15665 <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>
15666 <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>
15667 !! end
15668
15669 ###################
15670 # Image sizing.
15671 # See https://www.mediawiki.org/wiki/Help:Images#Size_and_frame
15672 # and https://phabricator.wikimedia.org/T64258
15673 # Foobar has actual size of 1941x220
15674 # 1. Thumbs & frameless always reduce, can't be enlarged unless it's
15675 # a scalable format.
15676 # 2. Framed images always ignore size options; always render at default size.
15677 # 3. "Unspecified format" and border are the only types which can be
15678 # enlarged.
15679
15680 !! test
15681 Image: unspecified format and border enlarge
15682 !! options
15683 parsoid=wt2html,wt2wt,html2html
15684 !! wikitext
15685 [[File:Foobar.jpg|2000px]]
15686
15687 [[File:Foobar.jpg|border|2000px]]
15688 !! html/php
15689 <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>
15690 </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>
15691 </p>
15692 !! html/parsoid
15693 <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>
15694 <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>
15695 !! end
15696
15697 !! test
15698 Image: "unspecified format" and border reduce
15699 !! options
15700 parsoid=wt2html,wt2wt,html2html
15701 !! wikitext
15702 [[File:Foobar.jpg|1000px]]
15703
15704 [[File:Foobar.jpg|border|1000px]]
15705 !! html/php
15706 <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>
15707 </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>
15708 </p>
15709 !! html/parsoid
15710 <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>
15711 <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>
15712 !! end
15713
15714 !! test
15715 Image: thumbs reduce
15716 !! options
15717 parsoid=wt2html,wt2wt,html2html
15718 !! wikitext
15719 [[File:Foobar.jpg|thumb|50px]]
15720 !! html/php
15721 <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>
15722
15723 !! html/parsoid
15724 <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>
15725 !! end
15726
15727 !! test
15728 Image: bitmap thumbs can't be enlarged past original size, but vector can.
15729 !! options
15730 parsoid=wt2html,wt2wt,html2html
15731 !! wikitext
15732 [[File:Foobar.jpg|thumb|2000px]]
15733
15734 [[File:Foobar.svg|thumb|2000px]]
15735 !! html/php
15736 <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>
15737 <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>
15738
15739 !! html/parsoid
15740 <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>
15741 <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>
15742 !! end
15743
15744 !! test
15745 Image: frameless can reduce in size
15746 !! options
15747 parsoid=wt2html,wt2wt,html2html
15748 !! wikitext
15749 [[File:Foobar.jpg|frameless|50px]]
15750 !! html/php
15751 <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>
15752 </p>
15753 !! html/parsoid
15754 <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>
15755 !! end
15756
15757 !! test
15758 Image: bitmap frameless can't be enlarged past original size, but vector can
15759 !! options
15760 parsoid=wt2html,wt2wt,html2html
15761 !! wikitext
15762 [[File:Foobar.jpg|frameless|2000px]]
15763
15764 [[File:Foobar.svg|frameless|2000px]]
15765 !! html/php
15766 <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>
15767 </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>
15768 </p>
15769 !! html/parsoid
15770 <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>
15771 <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>
15772 !! end
15773
15774 !! test
15775 Image: framed images are always unscaled.
15776 !! options
15777 parsoid=wt2html,wt2wt,html2html
15778 !! wikitext
15779 [[File:Foobar.jpg|frame]]
15780
15781 [[File:Foobar.jpg|frame|50px]]
15782
15783 [[File:Foobar.jpg|frame|50x50px]]
15784
15785 [[File:Foobar.jpg|frame|2000px]]
15786 !! html/php
15787 <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>
15788 <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>
15789 <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>
15790 <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>
15791
15792 !! html/parsoid
15793 <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>
15794 <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>
15795 <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>
15796 <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>
15797 !! end
15798
15799 ###################
15800
15801 !! test
15802 Link to image page- image page normally doesn't exists, hence edit link
15803 Add test with existing image page
15804 #<p><a href="/wiki/File:Test" title="Image:Test">Image:test</a>
15805 !! wikitext
15806 [[:Image:test]]
15807 !! html
15808 <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>
15809 </p>
15810 !! end
15811
15812 !! test
15813 T20784 Link to non-existent image page with caption should use caption as link text
15814 !! wikitext
15815 [[:Image:test|caption]]
15816 !! html
15817 <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>
15818 </p>
15819 !! end
15820
15821 !! test
15822 Frameless image caption with a free URL
15823 !! wikitext
15824 [[File:Foobar.jpg|http://example.com]]
15825 !! html/php
15826 <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>
15827 </p>
15828 !! html/parsoid
15829 <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>
15830 !! end
15831
15832 !! test
15833 Thumbnail image caption with a free URL
15834 !! options
15835 thumbsize=220
15836 !! wikitext
15837 [[File:Foobar.jpg|thumb|http://example.com]]
15838 !! html/php
15839 <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>
15840
15841 !! html/parsoid
15842 <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>
15843 !! end
15844
15845 !! test
15846 Thumbnail image caption with a free URL and explicit alt
15847 !! options
15848 thumbsize=220
15849 parsoid=wt2html,wt2wt,html2html
15850 !! wikitext
15851 [[File:Foobar.jpg|thumb|http://example.com|alt=Alteration]]
15852 !! html/php
15853 <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>
15854
15855 !! html/parsoid
15856 <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>
15857 !! end
15858
15859 !! test
15860 SVG thumbnails with no language set
15861 !! options
15862 !! wikitext
15863 [[File:Foobar.svg|thumb|caption]]
15864 !! html/php
15865 <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>
15866
15867 !! html/parsoid
15868 <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>
15869 !! end
15870
15871 !! test
15872 SVG thumbnails with language de
15873 !! options
15874 parsoid=wt2html,wt2wt,html2html
15875 !! wikitext
15876 [[File:Foobar.svg|thumb|caption|lang=de]]
15877 !! html/php
15878 <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>
15879
15880 !! html/parsoid
15881 <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>
15882 !! end
15883
15884 !! test
15885 SVG thumbnails with invalid language code
15886 !! options
15887 parsoid=wt2html,wt2wt,html2html
15888 !! wikitext
15889 [[File:Foobar.svg|thumb|caption|lang=invalid:language:code]]
15890 !! html/php
15891 <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>
15892
15893 !! html/parsoid
15894 <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>
15895 !! end
15896
15897 !! test
15898 SVG thumbnails in page language
15899 !! options
15900 language=ru
15901 wgMediaInTargetLanguage = true
15902 !! wikitext
15903 [[File:Foobar.svg]] [[File:Foobar.svg|lang=en]]
15904 !! html/php
15905 <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>
15906 </p>
15907 !! end
15908
15909 !! test
15910 SVG thumbnails in page language not present in the file
15911 !! options
15912 language=de
15913 wgMediaInTargetLanguage = true
15914 !! wikitext
15915 [[File:Foobar.svg]] [[File:Foobar.svg|lang=ru]]
15916 !! html/php
15917 <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>
15918 </p>
15919 !! end
15920
15921 !! test
15922 T3887: A ISBN with a thumbnail
15923 !! wikitext
15924 [[File:Foobar.jpg|thumb|ISBN 1235467890]]
15925 !! html/php
15926 <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>
15927
15928 !! html/parsoid
15929 <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>
15930 !! end
15931
15932 !! test
15933 T3887: A RFC with a thumbnail
15934 !! wikitext
15935 [[File:Foobar.jpg|thumb|This is RFC 12354]]
15936 !! html/php
15937 <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>
15938
15939 !! html/parsoid
15940 <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>
15941 !! end
15942
15943 !! test
15944 T3887: A mailto link with a thumbnail
15945 !! wikitext
15946 [[File:Foobar.jpg|thumb|Please mailto:nobody@example.com]]
15947 !! html/php
15948 <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>
15949
15950 !! html/parsoid
15951 <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>
15952 !! end
15953
15954 # Pending resolution to T2368
15955 !! test
15956 T2648: Frameless image caption with a link
15957 !! wikitext
15958 [[File:Foobar.jpg|text with a [[link]] in it]]
15959 !! html/php
15960 <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>
15961 </p>
15962 !! html/parsoid
15963 <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>
15964 !! end
15965
15966 !! test
15967 T2648: Frameless image caption with a link (suffix)
15968 !! wikitext
15969 [[File:Foobar.jpg|text with a [[link]]foo in it]]
15970 !! html/php
15971 <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>
15972 </p>
15973 !! html/parsoid
15974 <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>
15975 !! end
15976
15977 !! test
15978 T2648: Frameless image caption with an interwiki link
15979 !! wikitext
15980 [[File:Foobar.jpg|text with a [[MeatBall:Link]] in it]]
15981 !! html/php
15982 <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>
15983 </p>
15984 !! html/parsoid
15985 <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>
15986 !! end
15987
15988 !! test
15989 T2648: Frameless image caption with a piped interwiki link
15990 !! wikitext
15991 [[File:Foobar.jpg|text with a [[MeatBall:Link|link]] in it]]
15992 !! html/php
15993 <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>
15994 </p>
15995 !! html/parsoid
15996 <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>
15997 !! end
15998
15999 !! test
16000 T107474: Frameless image caption with <nowiki>
16001 !! wikitext
16002 [[File:Foobar.jpg|<nowiki>text with a [[MeatBall:Link|link]] in it</nowiki>]]
16003 !! html/parsoid
16004 <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>
16005 !! end
16006
16007 !! test
16008 Escape HTML special chars in image alt text
16009 !! wikitext
16010 [[File:Foobar.jpg|& < > "]]
16011 !! html/php
16012 <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>
16013 </p>
16014 !! html/parsoid
16015 <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>
16016 !! end
16017
16018 !! test
16019 Escape HTML special chars in image alt text with LanguageConverter
16020 !! options
16021 language=zh
16022 !! wikitext
16023 [[File:Foobar.jpg|& < > "]]
16024 !! html/php
16025 <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>
16026 </p>
16027 !! html/parsoid
16028 <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>
16029 !! end
16030
16031 !! test
16032 Entities in file name and attributes
16033 !! wikitext
16034 [[File:7%25 solution.gif|manualthumb=7%25 solution.gif|link=7%25 solution|[[7%25 solution]]]]
16035 !! html/php
16036 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=7%25_solution.gif" class="new" title="File:7% solution.gif">7% solution</a>
16037 </p>
16038 !! html/parsoid
16039 <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>
16040 !! end
16041
16042 !! test
16043 T2499: Alt text should have &#1234;, not &amp;1234;
16044 !! wikitext
16045 [[File:Foobar.jpg|&#9792;]]
16046 !! html/php
16047 <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>
16048 </p>
16049 !! html/parsoid
16050 <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>
16051 !! end
16052
16053 !! test
16054 Broken image caption with link
16055 !! options
16056 parsoid=wt2html,wt2wt,html2html
16057 !! wikitext
16058 [[Image:Foobar.jpg|thumb|This is a broken caption. But [[Main Page|this]] is just an ordinary link.
16059 !! html/php
16060 <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.
16061 </p>
16062 !! html/parsoid
16063 <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>
16064 !! end
16065
16066 !! test
16067 Image caption containing another image
16068 !! wikitext
16069 [[File:Foobar.jpg|thumb|This is a caption with another [[File:Thumb.png|image]] inside it!]]
16070 !! html/php
16071 <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>
16072
16073 !! html/parsoid
16074 <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>
16075 !! end
16076
16077 !! test
16078 Image: caption containing a newline
16079 !! wikitext
16080 [[File:Foobar.jpg|This
16081 *is some text]]
16082 !! html/php
16083 <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>
16084 </p>
16085 !! html/parsoid
16086 <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>
16087 !!end
16088
16089 !!test
16090 Image: caption containing leading space
16091 (The leading space should not trigger nowiki escaping in wt2wt mode)
16092 !! wikitext
16093 [[File:Foobar.jpg|thumb| bar]]
16094 !! html/php
16095 <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>
16096
16097 !! html/parsoid
16098 <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>
16099 !!end
16100
16101 # html/php output not have newlines after table, td, th, etc. because
16102 # Linker::makeThumbLink2() replaces the newlines with spaces since
16103 # the table is inside a caption.
16104 # FIXME: Verify if that circa 2004 fix is still required.
16105 !! test
16106 Image: caption containing a table
16107 !! options
16108 parsoid=wt2html,wt2wt,html2html
16109 !! wikitext
16110 [[Image:Foobar.jpg|thumb|200px|This is an example image thumbnail caption with a table
16111 {|
16112 !Foo!!Bar
16113 |-
16114 |Foo1||Bar1
16115 |}
16116 and some more text.]]
16117 !! html/php
16118 <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>
16119
16120 !! html/parsoid
16121 <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
16122 <table>
16123 <tbody>
16124 <tr><th>Foo</th><th>Bar</th></tr>
16125 <tr>
16126 <td>Foo1</td>
16127 <td>Bar1</td></tr></tbody></table>and some more text.</figcaption></figure>
16128 !! end
16129
16130 !! test
16131 T5090: External links other than http: in image captions
16132 !! wikitext
16133 [[File:Foobar.jpg|thumb|200x200px|This caption has [irc://example.net irc] and [https://example.com Secure] ext links in it.]]
16134 !! html/php
16135 <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>
16136
16137 !! html/parsoid
16138 <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>
16139 !! end
16140
16141 !! test
16142 Custom class
16143 !! options
16144 parsoid=wt2html,wt2wt,html2html
16145 !! wikitext
16146 [[Image:foobar.jpg|a|class=b]]
16147 !! html/php
16148 <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>
16149 </p>
16150 !! html/parsoid
16151 <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>
16152 !! end
16153
16154 !! test
16155 Localized image handling (1).
16156 !! options
16157 parsoid=wt2html,wt2wt,html2html
16158 language=es
16159 !! wikitext
16160 [[Archivo:Foobar.jpg|izquierda|enlace=foo|caption]]
16161 !! html/php
16162 <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>
16163
16164 !! html/parsoid
16165 <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>
16166 !! end
16167
16168 !! test
16169 Localized image handling (2).
16170 !! options
16171 thumbsize=220
16172 parsoid=wt2html,wt2wt,html2html
16173 language=es
16174 !! wikitext
16175 [[Archivo:Foobar.jpg|miniatura|izquierda|enlace=foo|caption]]
16176 !! html/php
16177 <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>
16178
16179 !! html/parsoid
16180 <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>
16181 !! end
16182
16183 !! test
16184 Localized image handling (3).
16185 !! options
16186 language=fa
16187 parsoid=html2wt
16188 !! html/parsoid
16189 <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>
16190 !! wikitext
16191 [[File:Foobar.jpg|بندانگشتی]]
16192 !! end
16193
16194 !! test
16195 "border", "frameless" and "class" attributes on an image.
16196 !! options
16197 thumbsize=220
16198 parsoid=wt2html,wt2wt,html2html
16199 !! wikitext
16200 [[File:Foobar.jpg|frameless|border|class=extra|caption]]
16201 !! html/php
16202 <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>
16203 </p>
16204 !! html/parsoid
16205 <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>
16206 !! end
16207
16208 # Note that 'right' is the default alignment, despite the misspelled 'righ' below
16209 !! test
16210 Invalid image attributes (T64500)
16211 !! options
16212 thumbsize=220
16213 parsoid=wt2html,wt2wt,html2html
16214 !! wikitext
16215 [[File:Foobar.jpg|thumb|float|left|caption]]
16216
16217 [[File:Foobar.jpg|thumb|righ|caption]]
16218
16219 [[File:Foobar.jpg|bogus1|thumb|bogus2|left|bogus3|caption]]
16220 !! html/php
16221 <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>
16222 <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>
16223 <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>
16224
16225 !! html/parsoid
16226 <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>
16227 <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>
16228 <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>
16229 !! end
16230
16231 !! article
16232 File:Barfoo.jpg
16233 !! text
16234 #REDIRECT [[File:Barfoo.jpg]]
16235 !! endarticle
16236
16237 # FIXME: Parsoid should run this test -- but we'd need to teach the
16238 # mockAPI about the redirected Barfoo.jpg image.
16239 !! test
16240 Redirected image
16241 !! wikitext
16242 [[Image:Barfoo.jpg]]
16243 !! html/php
16244 <p><a href="/wiki/File:Barfoo.jpg" class="mw-redirect" title="File:Barfoo.jpg">File:Barfoo.jpg</a>
16245 </p>
16246 !! end
16247
16248 !! test
16249 Missing image with uploads disabled
16250 !! options
16251 wgEnableUploads=0
16252 !! wikitext
16253 [[File:Foobaz.jpg]]
16254 !! html/php
16255 <p><a href="/wiki/File:Foobaz.jpg" title="File:Foobaz.jpg">File:Foobaz.jpg</a>
16256 </p>
16257 !! html/parsoid
16258 <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>
16259 !! end
16260
16261 # Parsoid-specific testing for images
16262 # https://www.mediawiki.org/wiki/Parsoid/MediaWiki_DOM_spec#Images
16263 # Currently imperfect due to a flaw in the Parsoid testrunner
16264 # Work in progress
16265 # THESE TESTS SHOULD BE MOVED UP and merged with the php-specific
16266 # image tests.
16267
16268 !! test
16269 Parsoid-specific image handling - simple image with size and middle alignment
16270 !! wikitext
16271 [[File:Foobar.jpg|middle|50px]]
16272 !! html/parsoid
16273 <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>
16274 !! end
16275
16276 !! test
16277 Parsoid-specific image handling - simple image with size, middle alignment, non-standard namespace alias
16278 !! options
16279 parsoid=wt2wt,wt2html,html2html
16280 !! wikitext
16281 [[Image:Foobar.jpg|middle|50px]]
16282 !! html/parsoid
16283 <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>
16284 !! end
16285
16286 !! test
16287 Parsoid-specific image handling - simple image with size and middle alignment (existing content)
16288 !! wikitext
16289 [[File:Foobar.jpg|50px|middle]]
16290 !! html/parsoid
16291 <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>
16292 !! end
16293
16294 !! test
16295 Parsoid-specific image handling - simple image with size and middle alignment and non-standard namespace name
16296 !! options
16297 parsoid=wt2html,wt2wt,html2html
16298 !! wikitext
16299 [[Image:Foobar.jpg|50px|middle]]
16300 !! html/parsoid
16301 <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>
16302 !! end
16303
16304 !! test
16305 Parsoid-specific image handling - simple image with both sizes, a baseline alignment, and a caption
16306 !! wikitext
16307 [[File:Foobar.jpg|500x10px|baseline|caption]]
16308 !! html/parsoid
16309 <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>
16310 !! end
16311
16312 !! test
16313 Parsoid-specific image handling - simple image with border and size spec
16314 !! wikitext
16315 [[File:Foobar.jpg|50px|border|caption]]
16316 !! html/parsoid
16317 <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>
16318 !! end
16319
16320 !! test
16321 Parsoid-specific image handling - thumbnail with halign, valign, and caption
16322 !! options
16323 parsoid=wt2html,html2html
16324 !! wikitext
16325 [[File:Foobar.jpg|left|baseline|thumb|caption content]]
16326 !! html/parsoid
16327 <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>
16328 !! end
16329
16330 !! test
16331 Parsoid-specific image handling - thumbnail with halign, valign, and caption (existing content)
16332 !! options
16333 parsoid=wt2html,html2html
16334 !! wikitext
16335 [[File:Foobar.jpg|thumb|left|baseline|caption content]]
16336 !! html/parsoid
16337 <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>
16338 !! end
16339
16340 !! test
16341 Parsoid-specific image handling - thumbnail with specific size, halign, valign, and caption
16342 !! options
16343 parsoid=wt2html,html2html
16344 !! wikitext
16345 [[Image:Foobar.jpg|right|middle|thumb|50x50px|caption]]
16346 !! html/parsoid
16347 <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>
16348 !! end
16349
16350 !! test
16351 Parsoid-specific image handling - thumbnail with specific size, halign, valign, and caption (existing content)
16352 !! options
16353 parsoid=wt2html,html2html
16354 !! wikitext
16355 [[File:Foobar.jpg|thumb|50x50px|right|middle|caption]]
16356 !! html/parsoid
16357 <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>
16358 !! end
16359
16360 !! test
16361 Parsoid-specific image handling - framed image with specific size and caption (size is ignored)
16362 !! options
16363 parsoid=wt2html,wt2wt,html2html
16364 !! wikitext
16365 [[File:Foobar.jpg|frame|500x50px|caption]]
16366 !! html/parsoid
16367 <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>
16368 !! end
16369
16370 !! test
16371 Parsoid-specific image handling - framed image with specific size, halign, valign, and caption (size is ignored)
16372 !! options
16373 parsoid=wt2html,html2html
16374 !! wikitext
16375 [[File:Foobar.jpg|left|baseline|frame|500x50px|caption]]
16376 !! html/parsoid
16377 <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>
16378 !! end
16379
16380 !! test
16381 Parsoid-specific image handling - frameless image with specific size, border, and caption
16382 !! wikitext
16383 [[File:Foobar.jpg|frameless|442x50px|border|caption]]
16384 !! html/parsoid
16385 <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>
16386 !! end
16387
16388 !! test
16389 Parsoid-specific image handling - simple image with a formatted caption
16390 !! wikitext
16391 [[File:Foobar.jpg|<table><tr><td>a</td><td>b</td></tr><tr><td>c</td></tr></table>]]
16392 !! html/parsoid
16393 <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>
16394 !! end
16395
16396 !! test
16397 Parsoid-specific image handling - caption with a template in it
16398 !! wikitext
16399 [[File:Foobar.jpg|thumb|200x23px|This caption has a {{echo|transclusion}} in it.]]
16400 !! html/parsoid
16401 <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>
16402 !! end
16403
16404 !! test
16405 Parsoid-specific image handling - caption with unbalanced tags in it
16406 !! options
16407 parsoid=wt2html,wt2wt,html2html
16408 !! wikitext
16409 foo
16410 [[File:Foobar.jpg|thumb|200x200px|This caption has a <center>unbalanced tag in it.]]
16411 bar
16412 !! html/parsoid
16413 <p>foo</p>
16414 <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>
16415 <p>bar</p>
16416 !! end
16417
16418 !! test
16419 Parsoid-specific image handling - empty caption (1)
16420 !! options
16421 parsoid=wt2html,wt2wt
16422 !! wikitext
16423 [[File:Foobar.jpg|thumb|]]
16424 !! html/parsoid
16425 <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>
16426 !! end
16427
16428 # empty captions don't get serialized unless we're in the "round trip" case
16429 !! test
16430 Parsoid-specific image handling - empty caption (2)
16431 !! options
16432 parsoid=html2wt
16433 !! html/parsoid
16434 <figure class="mw-default-size" typeof="mw:Image/Thumb">
16435 <a href="./File:Foobar.jpg">
16436 <img resource="./File:Foobar.jpg"
16437 src="//example.com/images/3/3a/Foobar.jpg"
16438 data-file-width="1941" data-file-height="220" data-file-type="bitmap"
16439 height="25" width="220"/>
16440 </a>
16441 <figcaption></figcaption>
16442 </figure>
16443 !! wikitext
16444 [[File:Foobar.jpg|thumb]]
16445 !! end
16446
16447 !! test
16448 Parsoid-specific image handling - whitespace caption
16449 !! wikitext
16450 [[File:Foobar.jpg|thumb| ]]
16451 !! html/parsoid
16452 <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>
16453 !! end
16454
16455 !! test
16456 Parsoid-specific image handling - lang option
16457 !! wikitext
16458 foo
16459 [[File:Foobar.svg|lang=de|caption]]
16460 bar
16461 !! html/parsoid
16462 <p>foo
16463 <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>
16464 bar</p>
16465 !! end
16466
16467 ## Edge case bugs in Parsoid from T93580
16468 !! test
16469 T93580: 1. Templated <ref> inside block images
16470 !! wikitext
16471 [[File:Foobar.jpg|thumb|Caption with templated ref: {{echo|<ref>foo</ref>}}]]
16472
16473 <references />
16474 !! html/parsoid
16475 <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>
16476
16477 <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>
16478 !! end
16479
16480 !! test
16481 T93580: 2. <ref> inside inline images
16482 !! wikitext
16483 [[File:Foobar.jpg|Undisplayed caption in inline image with ref: <ref>foo</ref>]]
16484
16485 <references />
16486 !! html/parsoid
16487 <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>
16488
16489 <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>
16490 !! end
16491
16492 !! test
16493 T93580: 3. Templated <ref> inside inline images
16494 !! wikitext
16495 [[File:Foobar.jpg|Undisplayed caption in inline image with ref: {{echo|<ref>{{echo|foo}}</ref>}}]]
16496
16497 <references />
16498 !! html/parsoid
16499 <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>
16500
16501 <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>
16502 !! end
16503
16504 ###
16505 ### Subpages
16506 ###
16507 !! article
16508 Subpage test/subpage
16509 !! text
16510 foo
16511 !! endarticle
16512
16513 !! test
16514 Subpage link
16515 !! options
16516 subpage title=[[Subpage test]]
16517 !! wikitext
16518 [[/subpage]]
16519 !! html
16520 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a>
16521 </p>
16522 !! end
16523
16524 !! test
16525 Subpage noslash link
16526 !! options
16527 subpage title=[[Subpage test]]
16528 !! wikitext
16529 [[/subpage/]]
16530 !! html
16531 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">subpage</a>
16532 </p>
16533 !! end
16534
16535 !! article
16536 Subpage test/1/2/subpage
16537 !! text
16538 blah
16539 !! endarticle
16540
16541 !! test
16542 Relative subpage noslash link
16543 !! options
16544 parsoid=wt2wt,wt2html,html2html
16545 subpage title=[[Subpage test/1/2/3/4]]
16546 !! wikitext
16547 [[../../subpage/]]
16548
16549 [[../../subpage]]
16550 !! html/php
16551 <p><a href="/wiki/Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">subpage</a>
16552 </p><p><a href="/wiki/Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">Subpage test/1/2/subpage</a>
16553 </p>
16554 !! html/parsoid
16555 <p><a rel="mw:WikiLink" href="./Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">subpage</a></p>
16556 <p><a rel="mw:WikiLink" href="./Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">Subpage_test/1/2/subpage</a></p>
16557 !! end
16558
16559 !! test
16560 Parsoid: dot-slash prefixed wikilinks
16561 !! wikitext
16562 [[./foo]]
16563
16564 [[././bar]]
16565
16566 [[././baz/]]
16567 !! html/php
16568 <p>[[./foo]]
16569 </p><p>[[././bar]]
16570 </p><p>[[././baz/]]
16571 </p>
16572 !! html/parsoid
16573 <p>[[./foo]]
16574 </p><p>[[././bar]]
16575 </p><p>[[././baz/]]
16576 </p>
16577 !! end
16578
16579 !! test
16580 Render invalid page names as plain text (T53090)
16581 !! wikitext
16582 [[./../foo|bar]]
16583 [[foo�|bar]]
16584 [[foo/.|bar]]
16585 [[foo/..|bar]]
16586 [[foo~~~bar]]
16587 [[foo>bar]]
16588 [[foo[bar]]
16589 [[.]]
16590 [[..]]
16591 [[foo././bar]]
16592 [[foo[http://example.com]xyz]]
16593
16594 [[{{echo|./../foo}}|bar]]
16595 [[{{echo|foo/.}}|bar]]
16596 [[{{echo|foo/..}}|bar]]
16597 [[{{echo|foo~~~~bar}}]]
16598 [[{{echo|foo>bar}}]]
16599 [[{{echo|foo././bar}}]]
16600 [[{{echo|foo{bar}}]]
16601 [[{{echo|foo}bar}}]]
16602 [[{{echo|foo[bar}}]]
16603 [[{{echo|foo]bar}}]]
16604 [[{{echo|foo<bar}}]]
16605 !!html/php
16606 <p>[[./../foo|bar]]
16607 [[foo�|bar]]
16608 [[foo/.|bar]]
16609 [[foo/..|bar]]
16610 [[foo~~~bar]]
16611 [[foo&gt;bar]]
16612 [[foo[bar]]
16613 [[.]]
16614 [[..]]
16615 [[foo././bar]]
16616 [[foo<a rel="nofollow" class="external autonumber" href="http://example.com">[1]</a>xyz]]
16617 </p><p>[[./../foo|bar]]
16618 [[foo/.|bar]]
16619 [[foo/..|bar]]
16620 [[foo~~~~bar]]
16621 [[foo&gt;bar]]
16622 [[foo././bar]]
16623 [[foo{bar]]
16624 [[foo}bar]]
16625 [[foo[bar]]
16626 [[foo]bar]]
16627 [[foo&lt;bar]]
16628 </p>
16629 !!html/parsoid
16630 <p>[[./../foo|bar]]
16631 [[foo�|bar]]
16632 [[foo/.|bar]]
16633 [[foo/..|bar]]
16634 [[foo~~~bar]]
16635 [[foo>bar]]
16636 [[foo[bar]]
16637 [[.]]
16638 [[..]]
16639 [[foo././bar]]
16640 [[foo<a rel="mw:ExtLink" class="external autonumber" href="http://example.com"></a>xyz]]</p>
16641
16642 <p>[[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"./../foo"}},"i":0}}]}'>./../foo</span>|bar]]
16643 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo/."}},"i":0}}]}'>foo/.</span>|bar]]
16644 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo/.."}},"i":0}}]}'>foo/..</span>|bar]]
16645 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo~~~~bar"}},"i":0}}]}'>foo~~~~bar</span>]]
16646 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo>bar"}},"i":0}}]}'>foo>bar</span>]]
16647 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo././bar"}},"i":0}}]}'>foo././bar</span>]]
16648 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo{bar"}},"i":0}}]}'>foo{bar</span>]]
16649 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo}bar"}},"i":0}}]}'>foo}bar</span>]]
16650 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo[bar"}},"i":0}}]}'>foo[bar</span>]]
16651 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo]bar"}},"i":0}}]}'>foo]bar</span>]]
16652 [[<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>
16653 !!end
16654
16655 !! test
16656 Disabled subpages
16657 !! wikitext
16658 [[/subpage]]
16659 !! html
16660 <p><a href="/index.php?title=/subpage&amp;action=edit&amp;redlink=1" class="new" title="/subpage (page does not exist)">/subpage</a>
16661 </p>
16662 !! end
16663
16664 !! test
16665 T2561: {{/Subpage}}
16666 !! options
16667 subpage title=[[Page]]
16668 !! wikitext
16669 {{/Subpage}}
16670 !! html
16671 <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>
16672 </p>
16673 !! end
16674
16675 ###
16676 ### Categories
16677 ###
16678 !! article
16679 Category:MediaWiki User's Guide
16680 !! text
16681 blah
16682 !! endarticle
16683
16684 !! test
16685 Link to category
16686 !! wikitext
16687 [[:Category:MediaWiki User's Guide]]
16688 !! html
16689 <p><a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User&#39;s Guide">Category:MediaWiki User's Guide</a>
16690 </p>
16691 !! end
16692
16693 !! test
16694 Simple category
16695 !! options
16696 cat
16697 !! wikitext
16698 [[Category:MediaWiki User's Guide]]
16699 !! html/php
16700 cat=MediaWiki_User's_Guide sort=
16701 !! html/parsoid
16702 <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"}}'/>
16703 !! end
16704
16705 !! test
16706 PAGESINCATEGORY invalid title fatal (r33546 fix)
16707 !! wikitext
16708 {{PAGESINCATEGORY:<bogus>}}
16709 !! html
16710 <p>0
16711 </p>
16712 !! end
16713
16714 !! test
16715 Category with different sort key
16716 !! options
16717 cat
16718 !! wikitext
16719 [[Category:MediaWiki User's Guide|Foo]]
16720 !! html/php
16721 cat=MediaWiki_User's_Guide sort=Foo
16722 !! html/parsoid
16723 <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"}}'/>
16724 !! end
16725
16726 !! test
16727 Category with identical sort key
16728 !! options
16729 cat
16730 !! wikitext
16731 [[Category:MediaWiki User's Guide|MediaWiki User's Guide]]
16732 !! html/php
16733 cat=MediaWiki_User's_Guide sort=MediaWiki User's Guide
16734 !! html/parsoid
16735 <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"}}'/>
16736 !! end
16737
16738 !! test
16739 Category with empty sort key
16740 !! options
16741 cat
16742 pst
16743 !! wikitext
16744 [[Category:MediaWiki User's Guide|]]
16745 !! html/php
16746 [[Category:MediaWiki User's Guide|MediaWiki User's Guide]]
16747 !! end
16748
16749 !! test
16750 Category with empty sort key and parentheses
16751 !! options
16752 cat
16753 pst
16754 !! wikitext
16755 [[Category:Foo (bar)|]]
16756 !! html/php
16757 [[Category:Foo (bar)|Foo]]
16758 !! end
16759
16760 !! test
16761 Category with link tail
16762 !! options
16763 cat
16764 pst
16765 !! wikitext
16766 123[[Category:Foo]]456
16767 !! html/php
16768 123[[Category:Foo]]456
16769 !! end
16770
16771 !! test
16772 Category with template
16773 !! options
16774 cat
16775 pst
16776 !! wikitext
16777 [[Category:{{echo|Foo}}]]
16778 !! html/php
16779 [[Category:{{echo|Foo}}]]
16780 !! end
16781
16782 !! test
16783 Category with template in sort key
16784 !! options
16785 cat
16786 pst
16787 !! wikitext
16788 [[Category:Foo|{{echo|Bar}}]]
16789 !! html/php
16790 [[Category:Foo|{{echo|Bar}}]]
16791 !! end
16792
16793 !! test
16794 Category with template in sort key and title
16795 !! options
16796 cat
16797 pst
16798 !! wikitext
16799 [[Category:{{echo|Foo}}|{{echo|Bar}}]]
16800 !! html/php
16801 [[Category:{{echo|Foo}}|{{echo|Bar}}]]
16802 !! end
16803
16804 ## We used to, but no longer wt2wt this test since the default serializer
16805 ## will normalize all categories to serialize on their own line.
16806 ## This wikitext usage is going to be fairly uncommon in production and
16807 ## selser will take care of preserving formatting in those scenarios.
16808 !! test
16809 Category / paragraph interactions
16810 !! options
16811 parsoid=wt2html
16812 !! wikitext
16813 Foo [[Category:Baz]] Bar
16814
16815 Foo [[Category:Baz]]
16816 Bar
16817
16818 Foo
16819 [[Category:Baz]]
16820 Bar
16821
16822 Foo
16823 [[Category:Baz]] Bar
16824
16825 Foo
16826 [[Category:Baz]]
16827 [[Category:Baz]]
16828 [[Category:Baz]]
16829 Bar
16830
16831 [[Category:Baz]]
16832 [[Category:Baz]]
16833 [[Category:Baz]]
16834
16835 [[Category:Baz]]
16836 {{echo|[[Category:Baz]]}}
16837 [[Category:Baz]]
16838 !! html/php
16839 <p>Foo Bar
16840 </p><p>Foo
16841 Bar
16842 </p><p>Foo
16843 Bar
16844 </p><p>Foo Bar
16845 </p><p>Foo
16846 Bar
16847 </p>
16848 !! html/parsoid
16849 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16850 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16851 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16852 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16853 <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>
16854 <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}}]}'/>
16855 <link rel="mw:PageProp/Category" href="./Category:Baz"/>
16856 !! end
16857
16858 ## We used to, but no longer wt2wt this test since the default serializer
16859 ## will normalize all categories to serialize on their own line.
16860 ## This wikitext usage is going to be fairly uncommon in production and
16861 ## selser will take care of preserving formatting in those scenarios.
16862 ##
16863 ## The whitespace on the empty line is part of the test. Please do not delete
16864 !! test
16865 1. Categories and newlines: All preceding newlines should be suppressed (courtesy T2087)
16866 !! options
16867 parsoid=wt2html
16868 !! wikitext
16869 This
16870
16871 [[Category:Foo]] and this should be part of same paragraph (not an indent-pre)
16872
16873 {{echo|[[Category:Foo]] and so should this!}}
16874 !! html/php
16875 <p>This and this should be part of same paragraph (not an indent-pre) and so should this!
16876 </p>
16877 !! html/parsoid
16878 <p>This
16879
16880 <link rel="mw:PageProp/Category" href="./Category:Foo"/> and this should be part of same paragraph (not an indent-pre)
16881
16882 <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>
16883 !! end
16884
16885 ## Parsoid will not try to wt2wt this while preserving newlines because
16886 ## it suppresses excess newlines within list items -- and we don't want to
16887 ## introduce a special case just for categories, which is, in reality somewhat
16888 ## odd behavior -- categories are unlikely to be used in list items like this
16889 ## in top-level pages and are only likely to show up in template-generated
16890 ## list items where this RT-ing is a non-issue.
16891 ##
16892 ## The whitespace on the empty line is part of the test. Please do not delete
16893 !! test
16894 2. Categories and newlines: All preceding newlines should be suppressed (courtesy T2087)
16895 !! options
16896 parsoid=wt2html
16897 !! wikitext
16898 * This
16899
16900 [[Category:Foo]] and this should be part of the same list item
16901 * So should this
16902
16903 {{echo|[[Category:Foo]] and this should be part of the same list item}}
16904 !! html/php+tidy
16905 <ul><li>This and this should be part of the same list item</li>
16906 <li>So should this and this should be part of the same list item</li></ul>
16907 !! html/parsoid
16908 <ul>
16909 <li>This <link rel="mw:PageProp/Category" href="./Category:Foo"/> and this should be part of the same list item</li>
16910 <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>
16911 </ul>
16912 !! end
16913
16914 ## Newlines and categories that follow the last item of a list
16915 ## are treated differently because this (list followed by categories)
16916 ## is an extremely common pattern on wikis.
16917 !! test
16918 3. Categories and newlines: newline suppression for last list item should RT properly
16919 !! wikitext
16920 *a
16921 *b
16922
16923 [[Category:Foo]]
16924
16925 [[Category:Bar]]
16926 [[Category:Baz]]
16927
16928 :c
16929
16930 [[Category:C]]
16931
16932 ;d
16933
16934 [[Category:D]]
16935 !! html/parsoid
16936 <ul><li>a</li>
16937 <li>b</li></ul>
16938
16939 <link rel="mw:PageProp/Category" href="./Category:Foo"/>
16940
16941 <link rel="mw:PageProp/Category" href="./Category:Bar"/>
16942 <link rel="mw:PageProp/Category" href="./Category:Baz"/>
16943
16944 <dl><dd>c</dd></dl>
16945
16946 <link rel="mw:PageProp/Category" href="./Category:C"/>
16947
16948 <dl><dt>d</dt></dl>
16949
16950 <link rel="mw:PageProp/Category" href="./Category:D"/>
16951 !! end
16952
16953 !! test
16954 4. Categories and newlines: newline suppression for last list item should RT properly
16955 !! wikitext
16956 *a
16957 ****b
16958
16959 [[Category:Foo]]
16960 !! html/parsoid
16961 <ul><li>a
16962 <ul><li><ul><li><ul><li>b</li></ul></li></ul></li></ul></li></ul>
16963
16964 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
16965 !! end
16966
16967 ## only wt2html for this to make sure the algo only applies to the rightmost path
16968 !! test
16969 5. Categories and newlines: migrateTrailingCategories dom pass should only run on the rightmost path of nested lists
16970 !! options
16971 parsoid=wt2html
16972 !! wikitext
16973 *a
16974 **b
16975 [[Category:Foo]]
16976 *c
16977 **d
16978 [[Category:Foo]]
16979 !! html/parsoid
16980 <ul><li>a
16981 <ul><li>b
16982 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/></li></ul></li>
16983 <li>c
16984 <ul><li>d</li></ul></li></ul>
16985 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
16986 !! end
16987
16988 ## We used to, but no longer wt2wt this test since the default serializer
16989 ## will normalize all categories to serialize on their own line.
16990 ## This wikitext usage is going to be fairly uncommon in production and
16991 ## selser will take care of preserving formatting in those scenarios.
16992 !! test
16993 6. Categories and newlines: migrateTrailingCategories dom pass should not migrate categories not preceded by newlines
16994 !! options
16995 parsoid=wt2html
16996 !! wikitext
16997 *a [[Category:Foo]]
16998 !! html/parsoid
16999 <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>
17000 !! end
17001
17002 # This test also demonstrates because of newline+category tunneling
17003 # through the list hander, template wrapping doesn't expand to the
17004 # containing list when the list item swallows the category.
17005 !! test
17006 7. Categories and newlines: migrateTrailingCategories dom pass should leave template content alone
17007 !! wikitext
17008 *{{echo|a
17009 [[Category:Foo]]}}
17010 !! html/parsoid
17011 <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
17012 </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>
17013 !! end
17014
17015 !! test
17016 8. Categories and newlines: migrateTrailingCategories dom pass should not get tripped by intervening templates
17017 !! wikitext
17018 *a
17019
17020 {{echo|[[Category:Foo]]
17021 [[Category:Bar]]}}
17022 [[Category:Baz]]
17023 !! html/parsoid
17024 <ul><li>a</li></ul>
17025
17026 <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">
17027 </span><link rel="mw:PageProp/Category" href="./Category:Bar" about="#mwt1" data-parsoid='{"stx":"simple","a":{"href":"./Category:Bar"},"sa":{"href":"Category:Bar"}}'/>
17028 <link rel="mw:PageProp/Category" href="./Category:Baz" data-parsoid='{"stx":"simple","a":{"href":"./Category:Baz"},"sa":{"href":"Category:Baz"}}'/>
17029 !! end
17030
17031 !! test
17032 Categories and newlines: migrateTrailingCategories dom pass should not get tripped by comments and whitespace
17033 !! wikitext
17034 *a
17035
17036 [[Category:Bar]]<!--boo1--> <!--boo2-->
17037 [[Category:Baz]]<!--boo3--> <!--boo4-->
17038 !! html/parsoid
17039 <ul><li>a</li></ul>
17040
17041 <link rel="mw:PageProp/Category" href="./Category:Bar"/><!--boo1--> <!--boo2-->
17042 <link rel="mw:PageProp/Category" href="./Category:Baz"/><!--boo3--> <!--boo4-->
17043 !! end
17044
17045 !! test
17046 Categories and newlines: should behave properly with linkprefix (T87753)
17047 !! options
17048 language=ar
17049 !! wikitext
17050 foo bar
17051 foo bar
17052 [[تصنيف:Foo]]
17053 [[تصنيف:Bar]]
17054 !! html/php
17055 <p>foo bar
17056 foo bar
17057 </p>
17058 !! html/parsoid
17059 <p>foo bar
17060 foo bar</p>
17061 <link rel="mw:PageProp/Category" href="./تصنيف:Foo"/>
17062 <link rel="mw:PageProp/Category" href="./تصنيف:Bar"/>
17063 !! end
17064
17065 !! test
17066 No regressions on internal links following category (T174639)
17067 !! options
17068 parsoid=wt2html,html2html
17069 !! wikitext
17070 [[Category:Foo]]<div>a
17071
17072 [[Foo]]</div>
17073 !! html/php
17074 <div>a
17075 <a href="/wiki/Foo" title="Foo">Foo</a></div>
17076
17077 !! html/parsoid
17078 <link rel="mw:PageProp/Category" href="./Category:Foo"/><div>a
17079
17080 <a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></div>
17081 !! end
17082
17083 # Note that Parsoid differs slightly from PHP due to T175421
17084 !! test
17085 11. Special case where only newlines separate links (T175416)
17086 !! options
17087 parsoid=wt2html,html2html
17088 !! wikitext
17089 [[Category:Foo]]
17090
17091 [[Foo]][[es:Alimento]]
17092
17093 [[Foo]]
17094 !! html/php
17095 <p><br />
17096 <a href="/wiki/Foo" title="Foo">Foo</a>
17097 </p><p><a href="/wiki/Foo" title="Foo">Foo</a>
17098 </p>
17099 !! html/parsoid
17100 <link rel="mw:PageProp/Category" href="./Category:Foo"/>
17101
17102 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></p><link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Alimento"/>
17103
17104 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></p>
17105 !! end
17106
17107 !! test
17108 Category links with multiple namespaces
17109 !! wikitext
17110 [[Category:Project:Foo]]
17111 !! html/parsoid
17112 <link rel="mw:PageProp/Category" href="./Category:Project:Foo" />
17113 !! end
17114
17115 !! test
17116 Parsoid: Serialize link to category page with colon escape
17117 !! wikitext
17118
17119 [[:Category:Foo]]
17120 [[:Category:Foo|Bar]]
17121 !! html/php+tidy
17122 <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>
17123 <a href="/index.php?title=Category:Foo&amp;action=edit&amp;redlink=1" class="new" title="Category:Foo (page does not exist)">Bar</a>
17124 </p>
17125 !! html/parsoid
17126 <p>
17127 <a rel="mw:WikiLink" href="./Category:Foo" title="Category:Foo">Category:Foo</a>
17128 <a rel="mw:WikiLink" href="./Category:Foo" title="Category:Foo">Bar</a>
17129 </p>
17130 !! end
17131
17132 # We used to, but no longer wt2wt this test since the default serializer
17133 # will normalize all categories to serialize on their own line.
17134 # This wikitext usage is going to be fairly uncommon in production and
17135 # selser will take care of preventing whitespace insertion if this
17136 # occurs in an article.
17137 #
17138 # html2html disabled for the same reason (whitespace insertion between
17139 # x and y).
17140 #
17141 # html2wt disabled because it localizes the "Category" namespace.
17142 !! test
17143 Link prefix/suffixes aren't applied to category links
17144 !! options
17145 parsoid=wt2html
17146 language=is
17147 !! wikitext
17148 x[[Category:Foo]]y
17149 !! html/php
17150 <p>xy
17151 </p>
17152 !! html/parsoid
17153 <p>x<link rel="mw:PageProp/Category" href="./Flokkur:Foo" data-parsoid=""/>y</p>
17154 !! end
17155
17156 !! test
17157 Link prefix/suffixes aren't applied to language links
17158 !! options
17159 parsoid=wt2html
17160 language=is
17161 !! wikitext
17162 x[[es:Foo]]y
17163 !! html/php
17164 <p>xy
17165 </p>
17166 !! html/parsoid
17167 <p>x<link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo" data-parsoid=""/>y</p>
17168 !! end
17169
17170 !! test
17171 Parsoid: Serialize link to file page with colon escape
17172 !! wikitext
17173
17174 [[:File:Foo.png]]
17175 [[:File:Foo.png|Bar]]
17176 !! html/php+tidy
17177 <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>
17178 <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>
17179 </p>
17180 !! html/parsoid
17181 <p>
17182 <a rel="mw:WikiLink" href="./File:Foo.png" title="File:Foo.png">File:Foo.png</a>
17183 <a rel="mw:WikiLink" href="./File:Foo.png" title="File:Foo.png">Bar</a>
17184 </p>
17185 !! end
17186
17187 !! test
17188 Parsoid: Serialize a genuine category link without colon escape
17189 !! wikitext
17190 [[Category:Foo]]
17191 [[Category:Foo|Bar]]
17192 !! html/php+tidy
17193 !! html/parsoid
17194 <link rel="mw:PageProp/Category" href="./Category:Foo">
17195 <link rel="mw:PageProp/Category" href="./Category:Foo#Bar">
17196 !! end
17197
17198 !! test
17199 Normalize hrefs properly before testing for invalid link targets (T72894)
17200 !! options
17201 parsoid=html2wt
17202 !! html/parsoid
17203 <link rel="mw:PageProp/Category" href="./Category:Toxine_bactérienne"/>
17204 !! wikitext
17205 [[Category:Toxine bactérienne]]
17206 !! end
17207
17208 !! test
17209 Parsoid: Defaultsort
17210 !! wikitext
17211 {{DEFAULTSORT:Foo}}
17212 !! html/parsoid
17213 <meta property="mw:PageProp/categorydefaultsort" content="Foo"/>
17214 !! end
17215
17216 # NOTE: mw:ExpandedAttrs is not the best typeof here. mw:Transclusion is better.
17217 # But, this is a limitation of our representation and is documented in
17218 # TemplateHandler.js in processSpecialMagicWord
17219 !! test
17220 Parsoid: Defaultsort (template-generated)
17221 !! wikitext
17222 {{{{echo|DEFAULTSORT}}:Foo}}
17223 !! html/parsoid
17224 <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"}]]}'/>
17225 !! end
17226
17227 ###
17228 ### Inter-language links
17229 ###
17230 !! test
17231 Interlanguage links
17232 !! options
17233 ill
17234 !! wikitext
17235 [[es:Alimento]]
17236 [[fr:Nourriture]]
17237 [[zh:食品]]
17238 !! html/php
17239 es:Alimento fr:Nourriture zh:食品
17240 !! html/parsoid
17241 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Alimento"/>
17242 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/Nourriture"/>
17243 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/食品"/>
17244 !! end
17245
17246 !! test
17247 Duplicate interlanguage links (T26502)
17248 !! options
17249 ill
17250 !! wikitext
17251 [[es:1]]
17252 [[es:2]]
17253 [[fr:1]]
17254 [[fr:2]]
17255 !! html/php
17256 es:1 fr:1
17257 !! html/parsoid
17258 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/1"/>
17259 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/2"/>
17260 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/1"/>
17261 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/2"/>
17262 !! end
17263
17264 ###
17265 ### Sections
17266 ###
17267 !! test
17268 Basic section headings
17269 !! wikitext
17270 ==Headline 1==
17271 Some text
17272
17273 ==Headline 2==
17274 More
17275 ===Smaller headline===
17276 Blah blah
17277 !! html
17278 <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>
17279 <p>Some text
17280 </p>
17281 <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>
17282 <p>More
17283 </p>
17284 <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>
17285 <p>Blah blah
17286 </p>
17287 !! end
17288
17289 !! test
17290 Section headings with TOC
17291 !! wikitext
17292 ==Headline 1==
17293 ===Subheadline 1===
17294 =====Skipping a level=====
17295 ======Skipping a level======
17296
17297 ==Headline 2==
17298 Some text
17299 ===Another headline===
17300 !! html
17301 <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>
17302 <ul>
17303 <li class="toclevel-1 tocsection-1"><a href="#Headline_1"><span class="tocnumber">1</span> <span class="toctext">Headline 1</span></a>
17304 <ul>
17305 <li class="toclevel-2 tocsection-2"><a href="#Subheadline_1"><span class="tocnumber">1.1</span> <span class="toctext">Subheadline 1</span></a>
17306 <ul>
17307 <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>
17308 <ul>
17309 <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>
17310 </ul>
17311 </li>
17312 </ul>
17313 </li>
17314 </ul>
17315 </li>
17316 <li class="toclevel-1 tocsection-5"><a href="#Headline_2"><span class="tocnumber">2</span> <span class="toctext">Headline 2</span></a>
17317 <ul>
17318 <li class="toclevel-2 tocsection-6"><a href="#Another_headline"><span class="tocnumber">2.1</span> <span class="toctext">Another headline</span></a></li>
17319 </ul>
17320 </li>
17321 </ul>
17322 </div>
17323
17324 <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>
17325 <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>
17326 <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>
17327 <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>
17328 <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>
17329 <p>Some text
17330 </p>
17331 <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>
17332
17333 !! end
17334
17335 !! test
17336 TOC anchors don't collide
17337 !! wikitext
17338 __FORCETOC__
17339 ==Headline 2==
17340 ==Headline==
17341 ==Headline 2==
17342 ==Headline==
17343 !! html/php
17344 <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>
17345 <ul>
17346 <li class="toclevel-1 tocsection-1"><a href="#Headline_2"><span class="tocnumber">1</span> <span class="toctext">Headline 2</span></a></li>
17347 <li class="toclevel-1 tocsection-2"><a href="#Headline"><span class="tocnumber">2</span> <span class="toctext">Headline</span></a></li>
17348 <li class="toclevel-1 tocsection-3"><a href="#Headline_2_2"><span class="tocnumber">3</span> <span class="toctext">Headline 2</span></a></li>
17349 <li class="toclevel-1 tocsection-4"><a href="#Headline_3"><span class="tocnumber">4</span> <span class="toctext">Headline</span></a></li>
17350 </ul>
17351 </div>
17352
17353 <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>
17354 <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>
17355 <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>
17356 <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>
17357
17358 !! end
17359
17360 # perl -e 'print "="x$_," Level $_ heading","="x$_,"\n" for 1..10'
17361 # Parsoid html2wt direction adds <nowiki> for level 7 and up.
17362 !! test
17363 Handling of sections up to level 6 and beyond
17364 !! options
17365 parsoid=wt2html
17366 !! wikitext
17367 =Level 1 Heading=
17368 ==Level 2 Heading==
17369 ===Level 3 Heading===
17370 ====Level 4 Heading====
17371 =====Level 5 Heading=====
17372 ======Level 6 Heading======
17373 =======Level 7 Heading=======
17374 ========Level 8 Heading========
17375 =========Level 9 Heading=========
17376 ==========Level 10 Heading==========
17377 !! html/php
17378 <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>
17379 <ul>
17380 <li class="toclevel-1 tocsection-1"><a href="#Level_1_Heading"><span class="tocnumber">1</span> <span class="toctext">Level 1 Heading</span></a>
17381 <ul>
17382 <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>
17383 <ul>
17384 <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>
17385 <ul>
17386 <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>
17387 <ul>
17388 <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>
17389 <ul>
17390 <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>
17391 <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>
17392 <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>
17393 <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>
17394 <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>
17395 </ul>
17396 </li>
17397 </ul>
17398 </li>
17399 </ul>
17400 </li>
17401 </ul>
17402 </li>
17403 </ul>
17404 </li>
17405 </ul>
17406 </div>
17407
17408 <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>
17409 <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>
17410 <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>
17411 <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>
17412 <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>
17413 <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>
17414 <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>
17415 <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>
17416 <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>
17417 <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>
17418
17419 !! html/parsoid
17420 <h1 id="Level_1_Heading" data-parsoid='{}'>Level 1 Heading</h1>
17421 <h2 id="Level_2_Heading" data-parsoid='{}'>Level 2 Heading</h2>
17422 <h3 id="Level_3_Heading" data-parsoid='{}'>Level 3 Heading</h3>
17423 <h4 id="Level_4_Heading" data-parsoid='{}'>Level 4 Heading</h4>
17424 <h5 id="Level_5_Heading" data-parsoid='{}'>Level 5 Heading</h5>
17425 <h6 id="Level_6_Heading" data-parsoid='{}'>Level 6 Heading</h6>
17426 <h6 id="=Level_7_Heading=" data-parsoid='{}'><span id=".3DLevel_7_Heading.3D" typeof="mw:FallbackId"></span>=Level 7 Heading=</h6>
17427 <h6 id="==Level_8_Heading==" data-parsoid='{}'><span id=".3D.3DLevel_8_Heading.3D.3D" typeof="mw:FallbackId"></span>==Level 8 Heading==</h6>
17428 <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>
17429 <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>
17430 !! end
17431
17432 !! test
17433 TOC regression (T11764)
17434 !! wikitext
17435 ==title 1==
17436 ===title 1.1===
17437 ====title 1.1.1====
17438 ===title 1.2===
17439 ==title 2==
17440 ===title 2.1===
17441 !! html
17442 <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>
17443 <ul>
17444 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
17445 <ul>
17446 <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>
17447 <ul>
17448 <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>
17449 </ul>
17450 </li>
17451 <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>
17452 </ul>
17453 </li>
17454 <li class="toclevel-1 tocsection-5"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a>
17455 <ul>
17456 <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>
17457 </ul>
17458 </li>
17459 </ul>
17460 </div>
17461
17462 <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>
17463 <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>
17464 <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>
17465 <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>
17466 <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>
17467 <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>
17468
17469 !! end
17470
17471 !! test
17472 TOC for heading containing <span id="..."></span> (T96153)
17473 !! wikitext
17474 __FORCETOC__
17475 ==<span id="old-anchor"></span>New title==
17476 !! html/php
17477 <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>
17478 <ul>
17479 <li class="toclevel-1 tocsection-1"><a href="#New_title"><span class="tocnumber">1</span> <span class="toctext">New title</span></a></li>
17480 </ul>
17481 </div>
17482
17483 <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>
17484
17485 !! end
17486
17487 !! test
17488 TOC with wgMaxTocLevel=3 (T8204)
17489 !! options
17490 wgMaxTocLevel=3
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></li>
17504 <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>
17505 </ul>
17506 </li>
17507 <li class="toclevel-1 tocsection-5"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a>
17508 <ul>
17509 <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>
17510 </ul>
17511 </li>
17512 </ul>
17513 </div>
17514
17515 <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>
17516 <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>
17517 <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>
17518 <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>
17519 <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>
17520 <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>
17521
17522 !! end
17523
17524 !! test
17525 TOC with wgMaxTocLevel=3 and two level four headings (T8204)
17526 !! options
17527 wgMaxTocLevel=3
17528 !! wikitext
17529 ==Section 1==
17530 ===Section 1.1===
17531 ====Section 1.1.1====
17532 ====Section 1.1.1.1====
17533 ==Section 2==
17534 !! html
17535 <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>
17536 <ul>
17537 <li class="toclevel-1 tocsection-1"><a href="#Section_1"><span class="tocnumber">1</span> <span class="toctext">Section 1</span></a>
17538 <ul>
17539 <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>
17540 </ul>
17541 </li>
17542 <li class="toclevel-1 tocsection-5"><a href="#Section_2"><span class="tocnumber">2</span> <span class="toctext">Section 2</span></a></li>
17543 </ul>
17544 </div>
17545
17546 <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>
17547 <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>
17548 <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>
17549 <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>
17550 <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>
17551
17552 !! end
17553
17554
17555 !! test
17556 Resolving duplicate section names
17557 !! wikitext
17558 ==Foo bar==
17559 ==Foo bar==
17560 !! html
17561 <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>
17562 <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>
17563
17564 !! end
17565
17566 !! test
17567 Resolving duplicate section names with differing case (T12721)
17568 !! wikitext
17569 ==Foo bar==
17570 ==Foo Bar==
17571 !! html
17572 <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>
17573 <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>
17574
17575 !! end
17576
17577 !! article
17578 Template:sections
17579 !! text
17580 ===Section 1===
17581 ==Section 2==
17582 !! endarticle
17583
17584 !! test
17585 Template with sections, __NOTOC__
17586 !! wikitext
17587 __NOTOC__
17588 ==Section 0==
17589 {{sections}}
17590 ==Section 4==
17591 !! html
17592 <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>
17593 <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>
17594 <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>
17595 <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>
17596
17597 !! end
17598
17599 !! test
17600 __NOEDITSECTION__ keyword
17601 !! wikitext
17602 __NOEDITSECTION__
17603 ==Section 1==
17604 ==Section 2==
17605 !! html
17606 <h2><span class="mw-headline" id="Section_1">Section 1</span></h2>
17607 <h2><span class="mw-headline" id="Section_2">Section 2</span></h2>
17608
17609 !! end
17610
17611 !! test
17612 Link inside a section heading
17613 !! wikitext
17614 ==Section with a [[Main Page|link]] in it==
17615 !! html
17616 <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>
17617
17618 !! end
17619
17620 !! test
17621 TOC regression (T14077)
17622 !! wikitext
17623 __TOC__
17624 ==title 1==
17625 ===title 1.1===
17626 ==title 2==
17627 !! html
17628 <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>
17629 <ul>
17630 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
17631 <ul>
17632 <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>
17633 </ul>
17634 </li>
17635 <li class="toclevel-1 tocsection-3"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a></li>
17636 </ul>
17637 </div>
17638
17639 <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>
17640 <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>
17641 <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>
17642
17643 !! end
17644
17645 !! test
17646 T3219 URL next to image (good)
17647 !! wikitext
17648 http://example.com [[File:Foobar.jpg]]
17649 !! html/php
17650 <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>
17651 </p>
17652 !! html/parsoid
17653 <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>
17654 !!end
17655
17656 # Parsoid doesn't wt2wt this cleanly because it adds <nowiki>s.
17657 !! test
17658 Short headings with trailing space should match behavior of Parser::doHeadings (T21910)
17659 !! options
17660 parsoid=wt2html,html2html
17661 !! wikitext
17662 ===
17663 The line above must have a trailing space!
17664 === <!--
17665 --> <!-- -->
17666 But just in case it doesn't...
17667 !! html/php
17668 <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>
17669 <p>The line above must have a trailing space!
17670 </p>
17671 <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>
17672 <p>But just in case it doesn't...
17673 </p>
17674 !! html/parsoid
17675 <h1 id="="><span id=".3D" typeof="mw:FallbackId"></span>=</h1>
17676 <p>The line above must have a trailing space!</p>
17677 <h1 id="=_2"><span id=".3D_2" typeof="mw:FallbackId"></span>=</h1> <!--
17678 --> <!-- -->
17679 <p>But just in case it doesn't...</p>
17680 !! end
17681
17682 !! test
17683 Header with special characters (T27462)
17684 !! wikitext
17685 The tooltips shall not show entities to the user (ie. be double escaped)
17686
17687 ==text > text==
17688 section 1
17689
17690 ==text < text==
17691 section 2
17692
17693 ==text & text==
17694 section 3
17695
17696 ==text ' text==
17697 section 4
17698
17699 ==text " text==
17700 section 5
17701 !! html/php
17702 <p>The tooltips shall not show entities to the user (ie. be double escaped)
17703 </p>
17704 <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>
17705 <ul>
17706 <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>
17707 <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>
17708 <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>
17709 <li class="toclevel-1 tocsection-4"><a href="#text_.27_text"><span class="tocnumber">4</span> <span class="toctext">text ' text</span></a></li>
17710 <li class="toclevel-1 tocsection-5"><a href="#text_.22_text"><span class="tocnumber">5</span> <span class="toctext">text " text</span></a></li>
17711 </ul>
17712 </div>
17713
17714 <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>
17715 <p>section 1
17716 </p>
17717 <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>
17718 <p>section 2
17719 </p>
17720 <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>
17721 <p>section 3
17722 </p>
17723 <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>
17724 <p>section 4
17725 </p>
17726 <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>
17727 <p>section 5
17728 </p>
17729 !! html/parsoid
17730 <p>The tooltips shall not show entities to the user (ie. be double escaped)</p>
17731
17732 <h2 id="text_>_text"><span id="text_.3E_text" typeof="mw:FallbackId"></span>text > text</h2>
17733 <p>section 1</p>
17734
17735 <h2 id="text_&lt;_text"><span id="text_.3C_text" typeof="mw:FallbackId"></span>text &lt; text</h2>
17736 <p>section 2</p>
17737
17738 <h2 id="text_&amp;_text"><span id="text_.26_text" typeof="mw:FallbackId"></span>text &amp; text</h2>
17739 <p>section 3</p>
17740
17741 <h2 id="text_'_text"><span id="text_.27_text" typeof="mw:FallbackId"></span>text ' text</h2>
17742 <p>section 4</p>
17743
17744 <h2 id='text_"_text'><span id="text_.22_text" typeof="mw:FallbackId"></span>text " text</h2>
17745 <p>section 5</p>
17746 !! end
17747
17748 !! test
17749 Header with space, plus and underscore as entity
17750 !! wikitext
17751 Id should not contain + for spaces
17752
17753 ==Space between Text==
17754 section 1
17755
17756 ==Space-Entity&#32;between&#32;Text==
17757 section 2
17758
17759 ==Plus+between+Text==
17760 section 3
17761
17762 ==Plus-Entity&#43;between&#43;Text==
17763 section 4
17764
17765 ==Underscore_between_Text==
17766 section 5
17767
17768 ==Underscore-Entity&#95;between&#95;Text==
17769 section 6
17770
17771 [[#Space between Text]]
17772 [[#Space-Entity&#32;between&#32;Text]]
17773 [[#Plus+between+Text]]
17774 [[#Plus-Entity&#43;between&#43;Text]]
17775 [[#Underscore_between_Text]]
17776 [[#Underscore-Entity&#95;between&#95;Text]]
17777 !! html/php
17778 <p>Id should not contain + for spaces
17779 </p>
17780 <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>
17781 <ul>
17782 <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>
17783 <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>
17784 <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>
17785 <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>
17786 <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>
17787 <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>
17788 </ul>
17789 </div>
17790
17791 <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>
17792 <p>section 1
17793 </p>
17794 <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>
17795 <p>section 2
17796 </p>
17797 <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>
17798 <p>section 3
17799 </p>
17800 <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>
17801 <p>section 4
17802 </p>
17803 <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>
17804 <p>section 5
17805 </p>
17806 <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>
17807 <p>section 6
17808 </p><p><a href="#Space_between_Text">#Space between Text</a>
17809 <a href="#Space-Entity_between_Text">#Space-Entity&#32;between&#32;Text</a>
17810 <a href="#Plus.2Bbetween.2BText">#Plus+between+Text</a>
17811 <a href="#Plus-Entity.2Bbetween.2BText">#Plus-Entity&#43;between&#43;Text</a>
17812 <a href="#Underscore_between_Text">#Underscore_between_Text</a>
17813 <a href="#Underscore-Entity_between_Text">#Underscore-Entity&#95;between&#95;Text</a>
17814 </p>
17815 !! html/parsoid
17816 <p>Id should not contain + for spaces</p>
17817
17818 <h2 id="Space_between_Text">Space between Text</h2>
17819 <p>section 1</p>
17820
17821 <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>
17822 <p>section 2</p>
17823
17824 <h2 id="Plus+between+Text"><span id="Plus.2Bbetween.2BText" typeof="mw:FallbackId"></span>Plus+between+Text</h2>
17825 <p>section 3</p>
17826
17827 <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>
17828 <p>section 4</p>
17829
17830 <h2 id="Underscore_between_Text">Underscore_between_Text</h2>
17831 <p>section 5</p>
17832
17833 <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>
17834 <p>section 6</p>
17835
17836 <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>
17837 <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>
17838 <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>
17839 <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>
17840 <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>
17841 <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>
17842 !! end
17843
17844 # Parsoid html2wt disabled because it adds padding spaces around =
17845 !! test
17846 Headers with excess '=' characters
17847 (Are similar tests necessary beyond the 1st level?)
17848 !! options
17849 parsoid=wt2html,wt2wt,html2html
17850 !! wikitext
17851 =foo==
17852 ==foo=
17853 =''italic'' heading==
17854 ==''italic'' heading=
17855 !! html/php
17856 <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>
17857 <ul>
17858 <li class="toclevel-1 tocsection-1"><a href="#foo.3D"><span class="tocnumber">1</span> <span class="toctext">foo=</span></a></li>
17859 <li class="toclevel-1 tocsection-2"><a href="#.3Dfoo"><span class="tocnumber">2</span> <span class="toctext">=foo</span></a></li>
17860 <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>
17861 <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>
17862 </ul>
17863 </div>
17864
17865 <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>
17866 <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>
17867 <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>
17868 <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>
17869
17870 !! html/parsoid
17871 <h1 id="foo="><span id="foo.3D" typeof="mw:FallbackId"></span>foo=</h1>
17872 <h1 id="=foo"><span id=".3Dfoo" typeof="mw:FallbackId"></span>=foo</h1>
17873 <h1 id="italic_heading="><span id="italic_heading.3D" typeof="mw:FallbackId"></span><i>italic</i> heading=</h1>
17874 <h1 id="=italic_heading"><span id=".3Ditalic_heading" typeof="mw:FallbackId"></span>=<i>italic</i> heading</h1>
17875 !! end
17876
17877 !! test
17878 HTML headers vs TOC (T25393)
17879 (__NOEDITSECTION__ for clearer output, doesn't matter here)
17880 !! wikitext
17881 <h1>Header 1</h1>
17882 ==Header 1.1==
17883 ==Header 1.2==
17884
17885 <h1>Header 2
17886 </h1>
17887 ==Header 2.1==
17888 ==Header 2.2==
17889 __NOEDITSECTION__
17890 !! html/php
17891 <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>
17892 <ul>
17893 <li class="toclevel-1"><a href="#Header_1"><span class="tocnumber">1</span> <span class="toctext">Header 1</span></a>
17894 <ul>
17895 <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>
17896 <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>
17897 </ul>
17898 </li>
17899 <li class="toclevel-1"><a href="#Header_2"><span class="tocnumber">2</span> <span class="toctext">Header 2</span></a>
17900 <ul>
17901 <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>
17902 <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>
17903 </ul>
17904 </li>
17905 </ul>
17906 </div>
17907
17908 <h1><span class="mw-headline" id="Header_1">Header 1</span></h1>
17909 <h2><span class="mw-headline" id="Header_1.1">Header 1.1</span></h2>
17910 <h2><span class="mw-headline" id="Header_1.2">Header 1.2</span></h2>
17911 <h1><span class="mw-headline" id="Header_2">Header 2
17912 </span></h1>
17913 <h2><span class="mw-headline" id="Header_2.1">Header 2.1</span></h2>
17914 <h2><span class="mw-headline" id="Header_2.2">Header 2.2</span></h2>
17915
17916 !! html/parsoid
17917 <h1 id="Header_1" data-parsoid='{"stx":"html"}'>Header 1</h1>
17918 <h2 id="Header_1.1" data-parsoid='{}'>Header 1.1</h2>
17919 <h2 id="Header_1.2" data-parsoid='{}'>Header 1.2</h2>
17920
17921 <h1 id="Header_2" data-parsoid='{"stx":"html"}'>Header 2
17922 </h1>
17923 <h2 id="Header_2.1" data-parsoid='{}'>Header 2.1</h2>
17924 <h2 id="Header_2.2" data-parsoid='{}'>Header 2.2</h2>
17925 <meta property="mw:PageProp/noeditsection"/>
17926 !! end
17927
17928 !! test
17929 Single-line or multiline-comments can follow headings
17930 !! options
17931 parsoid=wt2html,wt2wt
17932 !! wikitext
17933 ==foo==<!---->
17934 ==bar==<!--c1-->
17935 ==baz==<!--
17936 c2
17937 c3-->
17938 !! html/php
17939 <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>
17940 <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>
17941 <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>
17942
17943 !! html/parsoid
17944 <h2 id="foo">foo</h2><!---->
17945 <h2 id="bar">bar</h2><!--c1-->
17946 <h2 id="baz">baz</h2><!--
17947 c2
17948 c3-->
17949 !! end
17950
17951 !! test
17952 T3219 URL next to image (broken)
17953 !! wikitext
17954 http://example.com[[File:Foobar.jpg]]
17955 !! html/php
17956 <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>
17957 </p>
17958 !! html/parsoid
17959 <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>
17960 !!end
17961
17962 !! test
17963 T3186 news: in the middle of text
17964 !! wikitext
17965 http://en.wikinews.org/wiki/Wikinews:Workplace
17966 !! html
17967 <p><a rel="nofollow" class="external free" href="http://en.wikinews.org/wiki/Wikinews:Workplace">http://en.wikinews.org/wiki/Wikinews:Workplace</a>
17968 </p>
17969 !!end
17970
17971
17972 !! test
17973 Namespaced link must have a title
17974 !! wikitext
17975 [[Project:]]
17976 !! html
17977 <p>[[Project:]]
17978 </p>
17979 !!end
17980
17981 !! test
17982 Namespaced link must have a title (bad fragment version)
17983 !! wikitext
17984 [[Project:#fragment]]
17985 !! html
17986 <p>[[Project:#fragment]]
17987 </p>
17988 !!end
17989
17990
17991 ###
17992 ### HTML tags and HTML attributes
17993 ###
17994
17995 !! test
17996 div with no attributes
17997 !! wikitext
17998 <div>HTML rocks</div>
17999 !! html
18000 <div>HTML rocks</div>
18001
18002 !! end
18003
18004 !! test
18005 div with double-quoted attribute
18006 !! wikitext
18007 <div id="rock">HTML rocks</div>
18008 !! html
18009 <div id="rock">HTML rocks</div>
18010
18011 !! end
18012
18013 !! test
18014 div with single-quoted attribute
18015 !! wikitext
18016 <div id='rock'>HTML rocks</div>
18017 !! html
18018 <div id="rock">HTML rocks</div>
18019
18020 !! end
18021
18022 !! test
18023 div with unquoted attribute
18024 !! wikitext
18025 <div id=rock>HTML rocks</div>
18026 !! html
18027 <div id="rock">HTML rocks</div>
18028
18029 !! end
18030
18031 !! test
18032 div with illegal double attributes
18033 !! wikitext
18034 <div id="a" id="b">HTML rocks</div>
18035 !! html
18036 <div id="b">HTML rocks</div>
18037
18038 !!end
18039
18040 !! test
18041 div with empty attribute value, space before equals
18042 !! options
18043 parsoid=wt2html,html2html
18044 !! wikitext
18045 <div class =>HTML rocks</div>
18046 !! html/php
18047 <div class="">HTML rocks</div>
18048
18049 !! html/parsoid
18050 <div class="" data-parsoid='{"stx":"html"}'>HTML rocks</div>
18051 !! end
18052
18053 !! test
18054 div with multiple empty attribute values
18055 !! config
18056 wgFragmentMode=[ 'html5', 'legacy' ]
18057 !! options
18058 parsoid=wt2html,html2html
18059 !! wikitext
18060 <div id= title=>HTML rocks</div>
18061 !! html/php
18062 <div id="title=">HTML rocks</div>
18063
18064 !! html/parsoid
18065 <div id="title=" data-parsoid='{"stx":"html"}'>HTML rocks</div>
18066 !! end
18067
18068 # FIXME Parsoid doesn't actually match PHP here.
18069 # Probably we should use the synthetic <foo /> or <indicator>
18070 # extensions for this test, which are enabled when running parser tests.
18071 !! test
18072 Extension tag in attribute value
18073 !! wikitext
18074 <span title="<translate>123</translate>">ok</span>
18075 !! html/php+disabled
18076 <p>&lt;span title="&lt;translate&gt;123&lt;/translate&gt;"&gt;ok&lt;/span&gt;
18077 </p>
18078 !! html/parsoid
18079 <p><span title="123" about="#mwt4" typeof="mw:ExpandedAttrs" data-parsoid='{"stx":"html","a":{"title":"123"},"sa":{"title":"&lt;translate>123&lt;/translate>"}}' data-mw='{"attribs":[[{"txt":"title"},{"html":"&lt;translate typeof=\"mw:Extension/translate\" about=\"#mwt3\" data-parsoid=&apos;{\"dsr\":[13,39,2,2]}&apos; data-mw=&apos;{\"name\":\"translate\",\"attrs\":{},\"body\":{\"extsrc\":\"123\"}}&apos;>123&lt;/translate>"}]]}'>ok</span></p>
18080 !! end
18081
18082 !! test
18083 table with multiple empty attribute values
18084 !! options
18085 parsoid=wt2html,html2html
18086 !! wikitext
18087 {| title= id=
18088 |hi
18089 |}
18090 !! html/php
18091 <table title="id=">
18092 <tr>
18093 <td>hi
18094 </td></tr></table>
18095
18096 !! html/parsoid
18097 <table title="id=">
18098 <tbody><tr><td>hi</td></tr>
18099 </tbody></table>
18100 !! end
18101
18102 !! test
18103 div with braces in attribute value
18104 !! wikitext
18105 <div title="{}">Foo</div>
18106 !! html/php
18107 <div title="&#123;&#125;">Foo</div>
18108
18109 !! html/parsoid
18110 <div title="{}">Foo</div>
18111 !! end
18112
18113 !! test
18114 div with empty attribute value, no space before equals
18115 !! options
18116 parsoid=wt2html,html2html
18117 !! wikitext
18118 <div class=>HTML rocks</div>
18119 !! html/php
18120 <div class="">HTML rocks</div>
18121
18122 !! html/parsoid
18123 <div class="">HTML rocks</div>
18124 !! end
18125
18126 !! test
18127 HTML multiple attributes correction
18128 !! wikitext
18129 <p class="error" class="awesome">Awesome!</p>
18130 !! html
18131 <p class="awesome">Awesome!</p>
18132
18133 !!end
18134
18135 !! test
18136 Table multiple attributes correction
18137 !! wikitext
18138 {|
18139 !+ class="error" class="awesome"|status
18140 |}
18141 !! html
18142 <table>
18143 <tr>
18144 <th class="awesome">status
18145 </th></tr></table>
18146
18147 !!end
18148
18149 !! test
18150 DIV IN UPPERCASE
18151 !! wikitext
18152 <DIV ID="x">HTML ROCKS</DIV>
18153 !! html
18154 <div id="x">HTML ROCKS</div>
18155
18156 !!end
18157
18158 !! test
18159 Non-ASCII pseudo-tags are rendered as text
18160 !! wikitext
18161 <khyô>
18162 !! html
18163 <p>&lt;khyô&gt;
18164 </p>
18165 !! end
18166
18167 !! test
18168 Pseudo-tag with URL 'name' renders as url link
18169 !! wikitext
18170 <http://example.com/>
18171 !! html
18172 <p>&lt;<a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a>&gt;
18173 </p>
18174 !! end
18175
18176 !! test
18177 text with amp in the middle of nowhere
18178 !! wikitext
18179 Remember AT&T?
18180 !! html
18181 <p>Remember AT&amp;T?
18182 </p>
18183 !! end
18184
18185 !! test
18186 text with character entity: eacute
18187 !! wikitext
18188 I always thought &eacute; was a cute letter.
18189 !! html+tidy
18190 <p>I always thought &#233; was a cute letter.
18191 </p>
18192 !! end
18193
18194 !! test
18195 text with entity-escaped character entity-like string: eacute
18196 !! wikitext
18197 I always thought &amp;eacute; was a cute letter.
18198 !! html
18199 <p>I always thought &amp;eacute; was a cute letter.
18200 </p>
18201 !! end
18202
18203 !! test
18204 text with undefined character entity: xacute
18205 !! wikitext
18206 I always thought &xacute; was a cute letter.
18207 !! html
18208 <p>I always thought &amp;xacute; was a cute letter.
18209 </p>
18210 !! end
18211
18212 !! test
18213 HTML5 tags
18214 !! wikitext
18215 <data value="5">five</data>
18216 <time datetime="2000-01-01T00:00Z">The new millenium started</time>
18217 <mark>This highlighted text</mark>
18218 !! html
18219 <p><data value="5">five</data>
18220 <time datetime="2000-01-01T00:00Z">The new millenium started</time>
18221 <mark>This highlighted text</mark>
18222 </p>
18223 !! end
18224
18225 !! test
18226 HTML tag with leading space is parsed as text
18227 !! wikitext
18228 < div>foo< /div>
18229 !! html
18230 <p>&lt; div&gt;foo&lt; /div&gt;
18231 </p>
18232 !! end
18233
18234 ## FIXME: The untrimmed attribute in Parsoid is T205737
18235 !! test
18236 Element with broken attribute syntax
18237 !! options
18238 parsoid=wt2html
18239 !! wikitext
18240 <div style=" style="123">hi</div>
18241 <div =>ho</div>
18242 !! html/php
18243 <div style="style=">hi</div>
18244 <div>ho</div>
18245
18246 !! html/parsoid
18247 <div style=" style=" data-parsoid='{"stx":"html","a":{"123\"":null},"sa":{"123\"":""}}'>hi</div>
18248 <div data-parsoid='{"stx":"html","a":{"=":null},"sa":{"=":""}}'>ho</div>
18249 !! end
18250
18251 ###
18252 ### Nesting tests (see T43545, T52604, T53081)
18253 ###
18254
18255 # This test case is fixed in Parsoid by domino 1.0.12. (T52604)
18256 # Note that html2wt is considerably more difficult if we use <b> in
18257 # the test case, instead of <small>
18258 !! test
18259 Ensure that HTML adoption agency algorithm is properly implemented.
18260 !! wikitext
18261 <small>X<small>Y</small>Z</small>
18262 !! html
18263 <p><small>X<small>Y</small>Z</small>
18264 </p>
18265 !! end
18266
18267 # This was T43545 in the PHP parser.
18268 !! test
18269 Nesting of <kbd>
18270 !! wikitext
18271 <kbd>X<kbd>Y</kbd>Z</kbd>
18272 !! html+tidy
18273 <p><kbd>X<kbd>Y</kbd>Z</kbd>
18274 </p>
18275 !! end
18276
18277 # The following cases were T53081 in the PHP parser.
18278 # Note that there are some other nestable tags (b, i, etc) which are
18279 # not covered; see T53081 for discussion.
18280
18281 !! test
18282 Nesting of <em>
18283 !! wikitext
18284 <em>X<em>Y</em>Z</em>
18285 !! html+tidy
18286 <p><em>X<em>Y</em>Z</em>
18287 </p>
18288 !! end
18289
18290 !! test
18291 Nesting of <strong>
18292 !! wikitext
18293 <strong>X<strong>Y</strong>Z</strong>
18294 !! html+tidy
18295 <p><strong>X<strong>Y</strong>Z</strong>
18296 </p>
18297 !! end
18298
18299 !! test
18300 Nesting of <q>
18301 !! wikitext
18302 <q>X<q>Y</q>Z</q>
18303 !! html+tidy
18304 <p><q>X<q>Y</q>Z</q>
18305 </p>
18306 !! end
18307
18308 !! test
18309 Nesting of <ruby>
18310 !! wikitext
18311 <ruby>X<ruby>Y</ruby>Z</ruby>
18312 !! html
18313 <p><ruby>X<ruby>Y</ruby>Z</ruby>
18314 </p>
18315 !! end
18316
18317 !! test
18318 Nesting of <bdo>
18319 !! wikitext
18320 <bdo>X<bdo>Y</bdo>Z</bdo>
18321 !! html
18322 <p><bdo>X<bdo>Y</bdo>Z</bdo>
18323 </p>
18324 !! end
18325
18326
18327 ###
18328 ### Media links
18329 ###
18330
18331 !! test
18332 Media link
18333 !! wikitext
18334 [[Media:Foobar.jpg]]
18335 [[Media:Video.ogv]]
18336 [[:Media:Video.ogv]]
18337 !! html/php
18338 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Media:Foobar.jpg</a>
18339 <a href="http://example.com/images/0/00/Video.ogv" class="internal" title="Video.ogv">Media:Video.ogv</a>
18340 <a href="http://example.com/images/0/00/Video.ogv" class="internal" title="Video.ogv">Media:Video.ogv</a>
18341 </p>
18342 !! html/parsoid
18343 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" resource="./Media:Foobar.jpg" title="Foobar.jpg">Media:Foobar.jpg</a>
18344 <a rel="mw:MediaLink" href="//example.com/images/0/00/Video.ogv" resource="./Media:Video.ogv" title="Video.ogv">Media:Video.ogv</a>
18345 <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>
18346 !! end
18347
18348 !! test
18349 Media link with text
18350 !! wikitext
18351 [[Media:Foobar.jpg|A neat file to look at]]
18352 !! html/php
18353 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">A neat file to look at</a>
18354 </p>
18355 !! html/parsoid
18356 <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>
18357 !! end
18358
18359 !! test
18360 Localized media link
18361 !! options
18362 language=is
18363 !! wikitext
18364 [[Miðill:Foobar.jpg]]
18365
18366 [[Miðill:Foobar.jpg|Icelandic]]
18367 !! html/php
18368 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Miðill:Foobar.jpg</a>
18369 </p><p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Icelandic</a>
18370 </p>
18371 !! html/parsoid
18372 <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>
18373 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" resource="./Miðill:Foobar.jpg" title="Foobar.jpg">Icelandic</a></p>
18374 !! end
18375
18376 # FIXME: this is still bad HTML tag nesting
18377 # FIXME: doBlockLevels won't wrap this in a paragraph because it contains a div
18378 # Parsoid & Remex fix the p-wrapping since they operate on the DOM.
18379 !! test
18380 Media link with nasty text
18381 !! options
18382 parsoid=wt2html,html2html
18383 !! wikitext
18384 [[Media:Foobar.jpg|Safe Link<div style=display:none>" onmouseover="alert(document.cookie)" onfoo="</div>]]
18385 !! html/php
18386 <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>
18387
18388 !! html/php+tidy
18389 <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>
18390 !! html/parsoid
18391 <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>
18392 !! end
18393
18394 !! test
18395 Media link from missing resource (parsoid-only)
18396 !! options
18397 parsoid=html2wt
18398 !! html/parsoid
18399 <a rel="mw:MediaLink" href="http://example.com/images/3/3a/Foobar.jpg">Bat!</a>
18400 !! wikitext
18401 [[Media:Foobar.jpg|Bat!]]
18402 !! end
18403
18404 !! test
18405 Media link from missing resource, localized (parsoid-only)
18406 !! options
18407 parsoid=html2wt
18408 language=is
18409 !! html/parsoid
18410 <a rel="mw:MediaLink" href="http://example.com/images/3/3a/Foobar.jpg">Bat!</a>
18411 !! wikitext
18412 [[Miðill:Foobar.jpg|Bat!]]
18413 !! end
18414
18415 # This is a sanity test to ensure we don't crash or choke when given
18416 # old cached 1.7.0 HTML for media links; we don't require that the
18417 # result be "valid" because wt2wt was completely broken in 1.7.0
18418 !! test
18419 Media link from old 1.7.0 DOM spec (crash test, parsoid-only) T198511
18420 !! options
18421 parsoid=html2wt
18422 !! html/parsoid
18423 <p>This is what Parsoid would emit (and we still handle this HTML fine):</p>
18424 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg">A neat file to look at</a></p>
18425 <p>But VisualEditor would mangle the rel attribute, and give us back this:</p>
18426 <p><a rel="mw:ExtLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg">A neat file to look at</a></p>
18427 <p>But at least we don't crash when trying to handle the mangled HTML!</p>
18428 !! wikitext
18429 This is what Parsoid would emit (and we still handle this HTML fine):
18430
18431 [[Media:Foobar.jpg|A neat file to look at]]
18432
18433 But VisualEditor would mangle the rel attribute, and give us back this:
18434
18435 [//example.com/images/3/3a/Foobar.jpg A neat file to look at]
18436
18437 But at least we don't crash when trying to handle the mangled HTML!
18438 !! end
18439
18440 !! test
18441 Media link to nonexistent file (T3702)
18442 !! wikitext
18443 [[Media:No such.jpg]]
18444 [[Media:No_such file.jpg]]
18445 !! html/php
18446 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=No_such.jpg" class="new" title="No such.jpg">Media:No such.jpg</a>
18447 <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>
18448 </p>
18449 !! html/parsoid
18450 <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>
18451 <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>
18452 !! end
18453
18454 !! test
18455 Image link to nonexistent file (T3850 - good)
18456 !! wikitext
18457 [[File:No_such.jpg]]
18458 !! html/php
18459 <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>
18460 </p>
18461 !! html/parsoid
18462 <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>
18463 !! end
18464
18465 !! test
18466 :Image link to nonexistent file (T3850 - bad)
18467 !! wikitext
18468 [[:Image:No such.jpg]]
18469 !! html/php
18470 <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>
18471 </p>
18472 !! html/parsoid
18473 <p><a rel="mw:WikiLink" href="./File:No_such.jpg" title="File:No such.jpg">Image:No such.jpg</a></p>
18474 !! end
18475
18476 !! test
18477 Character reference normalization in link text (T3938)
18478 !! wikitext
18479 [[Main Page|this&that]]
18480 !! html
18481 <p><a href="/wiki/Main_Page" title="Main Page">this&amp;that</a>
18482 </p>
18483 !!end
18484
18485 !! article
18486 אַ
18487 !! text
18488 Test for unicode normalization
18489
18490 The page's name is U+05d0 U+05b7, with non-canonical form U+FB2E
18491 !! endarticle
18492
18493 !! test
18494 (T21451) Links should refer to the normalized form.
18495 !! wikitext
18496 [[&#xFB2E;]]
18497 [[&#x5d0;&#x5b7;]]
18498 [[&#x5d0;ַ]]
18499 [[א&#x5b7;]]
18500 [[אַ]]
18501 !! html
18502 <p><a href="/wiki/%D7%90%D6%B7" title="אַ">&#xfb2e;</a>
18503 <a href="/wiki/%D7%90%D6%B7" title="אַ">&#x5d0;&#x5b7;</a>
18504 <a href="/wiki/%D7%90%D6%B7" title="אַ">&#x5d0;ַ</a>
18505 <a href="/wiki/%D7%90%D6%B7" title="אַ">א&#x5b7;</a>
18506 <a href="/wiki/%D7%90%D6%B7" title="אַ">אַ</a>
18507 </p>
18508 !! end
18509
18510 !! test
18511 Empty attribute crash test (T4067)
18512 !! wikitext
18513 <font color="">foo</font>
18514 !! html
18515 <p><font color="">foo</font>
18516 </p>
18517 !! end
18518
18519 !! test
18520 Empty attribute crash test single-quotes (T4067)
18521 !! wikitext
18522 <font color=''>foo</font>
18523 !! html
18524 <p><font color="">foo</font>
18525 </p>
18526 !! end
18527
18528 !! test
18529 Attribute test: equals, then nothing
18530 !! options
18531 parsoid=wt2html,html2html
18532 !! wikitext
18533 <font color=>foo</font>
18534 !! html/php
18535 <p><font color="">foo</font>
18536 </p>
18537 !! html/parsoid
18538 <p><font color="" data-parsoid='{"stx":"html"}'>foo</font></p>
18539 !! end
18540
18541 !! test
18542 Attribute test: unquoted value
18543 !! options
18544 parsoid=wt2html,html2html
18545 !! wikitext
18546 <font color=x>foo</font>
18547 !! html/php
18548 <p><font color="x">foo</font>
18549 </p>
18550 !! html/parsoid
18551 <p><font color="x" data-parsoid='{"stx":"html"}'>foo</font></p>
18552 !! end
18553
18554 !! test
18555 Attribute test: unquoted but illegal value (hash)
18556 !! wikitext
18557 <font color=#x>foo</font>
18558 !! html
18559 <p><font color="#x">foo</font>
18560 </p>
18561 !! end
18562
18563 # Parsoid does not serialize to empty attribute syntax,
18564 # so wt2wt and html2wt cases are skipped
18565 !! test
18566 Attribute test: no value (T54330)
18567 !! options
18568 parsoid=wt2html,html2html
18569 !! wikitext
18570 <font color>foo</font>
18571 !! html/php
18572 <p><font color="">foo</font>
18573 </p>
18574 !! html/parsoid
18575 <p><font color="">foo</font></p>
18576 !! end
18577
18578 !! test
18579 T4095: link with three closing brackets
18580 !! wikitext
18581 [[Main Page]]]
18582 !! html/php
18583 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>]
18584 </p>
18585 !! html/parsoid
18586 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a>]</p>
18587 !! end
18588
18589 !! test
18590 T4095: link with pipe and three closing brackets
18591 !! wikitext
18592 [[Main Page|link]]]
18593 !! html/php
18594 <p><a href="/wiki/Main_Page" title="Main Page">link</a>]
18595 </p>
18596 !! html/parsoid
18597 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">link</a>]</p>
18598 !! end
18599
18600 !! test
18601 T4095: link with pipe and three closing brackets, version 2
18602 !! wikitext
18603 [[Main Page|[http://example.com/]]]
18604 !! html/php
18605 <p><a href="/wiki/Main_Page" title="Main Page">[http://example.com/]</a>
18606 </p>
18607 !! html/parsoid
18608 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">[http://example.com/]</a></p>
18609 !! end
18610
18611
18612 ###
18613 ### Safety
18614 ###
18615
18616 !! article
18617 Template:Dangerous attribute
18618 !! text
18619 " onmouseover="alert(document.cookie)
18620 !! endarticle
18621
18622 !! article
18623 Template:Dangerous style attribute
18624 !! text
18625 border-size: expression(alert(document.cookie))
18626 !! endarticle
18627
18628 !! article
18629 Template:Div style
18630 !! text
18631 <div style="float: right; {{{1}}}">Magic div</div>
18632 !! endarticle
18633
18634 !! test
18635 T4304: HTML attribute safety (safe template; regression T4309)
18636 !! wikitext
18637 <div title="{{test}}"></div>
18638 !! html/php
18639 <div title="This is a test template"></div>
18640
18641 !! html/parsoid
18642 <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>
18643 !! end
18644
18645 # Parsoid has enough context to handle this case
18646 !! test
18647 T4304: HTML attribute safety (dangerous template; 2309)
18648 !! wikitext
18649 <div title="{{dangerous attribute}}"></div>
18650 !! html/php
18651 <div title=""></div>
18652
18653 !! html/parsoid
18654 <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>
18655 !! end
18656
18657 !! test
18658 T4304: HTML attribute safety (dangerous style template; 2309)
18659 !! wikitext
18660 <div style="{{dangerous style attribute}}"></div>
18661 !! html/php
18662 <div style="/* insecure input */"></div>
18663
18664 !! html/parsoid
18665 <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>
18666 !! end
18667
18668 !! test
18669 T4304: HTML attribute safety (safe parameter; 2309)
18670 !! wikitext
18671 {{div style|width: 200px}}
18672 !! html/php
18673 <div style="float: right; width: 200px">Magic div</div>
18674
18675 !! html/parsoid
18676 <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>
18677 !! end
18678
18679 !! test
18680 T4304: HTML attribute safety (unsafe parameter; 2309)
18681 !! wikitext
18682 {{div style|width: expression(alert(document.cookie))}}
18683 !! html/php
18684 <div style="/* insecure input */">Magic div</div>
18685
18686 !! html/parsoid
18687 <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>
18688 !! end
18689
18690 ## Parsoid output here differs; needs investigation.
18691 !! test
18692 T4304: HTML attribute safety (unsafe breakout parameter; 2309)
18693 !! wikitext
18694 {{div style|"><script>alert(document.cookie)</script>}}
18695 !! html
18696 <div style="float: right;">&lt;script&gt;alert(document.cookie)&lt;/script&gt;"&gt;Magic div</div>
18697
18698 !! end
18699
18700 ## Parsoid output here differs; needs investigation.
18701 !! test
18702 T4304: HTML attribute safety (unsafe breakout parameter 2; 2309)
18703 !! wikitext
18704 {{div style|" ><script>alert(document.cookie)</script>}}
18705 !! html
18706 <div style="float: right;">&lt;script&gt;alert(document.cookie)&lt;/script&gt;"&gt;Magic div</div>
18707
18708 !! end
18709
18710 !! test
18711 T4304: HTML attribute safety (link)
18712 !! wikitext
18713 <div title="[[Main Page]]"></div>
18714 !! html/php
18715 <div title="&#91;&#91;Main Page&#93;&#93;"></div>
18716
18717 !! html/parsoid
18718 <div title="[[Main Page]]"></div>
18719 !! end
18720
18721 !! test
18722 T4304: HTML attribute safety (italics)
18723 !! wikitext
18724 <div title="''foobar''"></div>
18725 !! html
18726 <div title="&#39;&#39;foobar&#39;&#39;"></div>
18727
18728 !! end
18729
18730 !! test
18731 T4304: HTML attribute safety (bold)
18732 !! wikitext
18733 <div title="'''foobar'''"></div>
18734 !! html
18735 <div title="&#39;&#39;&#39;foobar&#39;&#39;&#39;"></div>
18736
18737 !! end
18738
18739 !! test
18740 T4304: HTML attribute safety (ISBN)
18741 !! wikitext
18742 <div title="ISBN 1234567890"></div>
18743 !! html
18744 <div title="&#73;SBN 1234567890"></div>
18745
18746 !! end
18747
18748 !! test
18749 T4304: HTML attribute safety (RFC)
18750 !! wikitext
18751 <div title="RFC 1234"></div>
18752 !! html
18753 <div title="&#82;FC 1234"></div>
18754
18755 !! end
18756
18757 !! test
18758 T4304: HTML attribute safety (PMID)
18759 !! wikitext
18760 <div title="PMID 1234567890"></div>
18761 !! html
18762 <div title="&#80;MID 1234567890"></div>
18763
18764 !! end
18765
18766 !! test
18767 T4304: HTML attribute safety (web link)
18768 !! wikitext
18769 <div title="http://example.com/"></div>
18770 !! html
18771 <div title="http&#58;//example.com/"></div>
18772
18773 !! end
18774
18775 !! test
18776 T4304: HTML attribute safety (named web link)
18777 !! wikitext
18778 <div title="[http://example.com/ link]"></div>
18779 !! html/php
18780 <div title="&#91;http&#58;//example.com/ link&#93;"></div>
18781
18782 !! html/parsoid
18783 <div title="[http://example.com/ link]"></div>
18784 !! end
18785
18786 !! test
18787 T5244: HTML attribute safety (extension; safe)
18788 !! wikitext
18789 <div style="<nowiki>background:blue</nowiki>"></div>
18790 !! html/php
18791 <div style="background:blue"></div>
18792
18793 !! html/parsoid
18794 <div style="background:blue" data-parsoid='{"stx":"html","a":{"style":"background:blue"},"sa":{"style":"&lt;nowiki>background:blue&lt;/nowiki>"}}'></div>
18795 !! end
18796
18797 !! test
18798 T5244: HTML attribute safety (extension; unsafe)
18799 !! wikitext
18800 <div style="<nowiki>border-left:expression(alert(document.cookie))</nowiki>"></div>
18801 !! html/php
18802 <div style="/* insecure input */"></div>
18803
18804 !! html/parsoid
18805 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"&lt;nowiki>border-left:expression(alert(document.cookie))&lt;/nowiki>"}}'></div>
18806 !! end
18807
18808 # More MSIE fun discovered by Tom Gilder
18809
18810 !! test
18811 MSIE CSS safety test: spurious slash
18812 !! wikitext
18813 <div style="background-image:u\rl(javascript:alert('boo'))">evil</div>
18814 !! html/php
18815 <div style="/* insecure input */">evil</div>
18816
18817 !! html/parsoid
18818 <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>
18819 !! end
18820
18821 !! test
18822 MSIE CSS safety test: hex code
18823 !! wikitext
18824 <div style="background-image:u\72l(javascript:alert('boo'))">evil</div>
18825 !! html/php
18826 <div style="/* insecure input */">evil</div>
18827
18828 !! html/parsoid
18829 <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>
18830 !! end
18831
18832 !! test
18833 MSIE CSS safety test: comment in url
18834 !! wikitext
18835 <div style="background-image:u/**/rl(javascript:alert('boo'))">evil</div>
18836 !! html/php
18837 <div style="background-image:u rl(javascript:alert(&#39;boo&#39;))">evil</div>
18838
18839 !! html/parsoid
18840 <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>
18841 !! end
18842
18843 !! test
18844 MSIE CSS safety test: comment in expression
18845 !! wikitext
18846 <div style="background-image:expres/**/sion(alert('boo4'))">evil4</div>
18847 !! html/php
18848 <div style="background-image:expres sion(alert(&#39;boo4&#39;))">evil4</div>
18849
18850 !! html/parsoid
18851 <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>
18852 !! end
18853
18854 !! test
18855 CSS safety test (all browsers): vertical tab (T57332 / CVE-2013-4567)
18856 !! wikitext
18857 <p style="font-size: 100px; background-image:url\b(https://www.google.com/images/srpr/logo6w.png)">A</p>
18858 !! html/php
18859 <p style="/* invalid control char */">A</p>
18860
18861 !! html/parsoid
18862 <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>
18863 !! end
18864
18865 !! test
18866 MSIE 6 CSS safety test: Fullwidth (T57332)
18867 !! wikitext
18868 <p style="font-size: 100px; color: expression((title='XSSed'),'red')">A</p>
18869 <div style="top:EXPRESSION(alert())">B</div>
18870 !! html/php
18871 <p style="/* insecure input */">A</p>
18872 <div style="/* insecure input */">B</div>
18873
18874 !! html/parsoid
18875 <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>
18876 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"top:EXPRESSION(alert())"}}'>B</div>
18877 !! end
18878
18879 !! test
18880 MSIE 6 CSS safety test: IPA extensions (T57332)
18881 !! wikitext
18882 <div style="background-image:uʀʟ(javascript:alert())">A</div>
18883 <p style="font-size: 100px; color: expʀessɪoɴ((title='XSSed'),'red')">B</p>
18884 !! html/php
18885 <div style="/* insecure input */">A</div>
18886 <p style="/* insecure input */">B</p>
18887
18888 !! html/parsoid
18889 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:uʀʟ(javascript:alert())"}}'>A</div>
18890 <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>
18891 !! end
18892
18893 !! test
18894 MSIE 6 CSS safety test: sup/sub script (T57332)
18895 !! wikitext
18896 <div style="background-image:url⁽javascript:alert())">A</div>
18897 <div style="background-image:url₍javascript:alert())">B</div>
18898 <p style="font-size: 100px; color: expressioⁿ((title='XSSed'),'red')">C</p>
18899 !! html/php
18900 <div style="/* insecure input */">A</div>
18901 <div style="/* insecure input */">B</div>
18902 <p style="/* insecure input */">C</p>
18903
18904 !! html/parsoid
18905 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:url⁽javascript:alert())"}}'>A</div>
18906 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:url₍javascript:alert())"}}'>B</div>
18907 <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>
18908 !! end
18909
18910 !! test
18911 Opera -o-link CSS
18912 !! options
18913 parsoid=wt2html,html2html
18914 !! wikitext
18915 <div
18916 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;"
18917 style="-o-link:attr(title);-o-link-source:current">X</div>
18918 !! html/php
18919 <div title="data:text/html,&lt;img src=1 onerror=alert(1)&gt;" style="/* insecure input */">X</div>
18920
18921 !! html/parsoid
18922 <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>
18923 !! end
18924
18925 !! test
18926 MSIE 6 CSS safety test: Repetition markers (T57332)
18927 !! wikitext
18928 <p style="font-size: 100px; color: expres〱ion((title='XSSed'),'red')">A</p>
18929 <p style="font-size: 100px; color: expresゝion((title='XSSed'),'red')">B</p>
18930 <p style="font-size: 100px; color: expresーion((title='XSSed'),'red')">C</p>
18931 <p style="font-size: 100px; color: expresヽion((title='XSSed'),'red')">D</p>
18932 <p style="font-size: 100px; color: expresﹽion((title='XSSed'),'red')">E</p>
18933 <p style="font-size: 100px; color: expresﹼion((title='XSSed'),'red')">F</p>
18934 <p style="font-size: 100px; color: expresーion((title='XSSed'),'red')">G</p>
18935 !! html/php
18936 <p style="/* insecure input */">A</p>
18937 <p style="/* insecure input */">B</p>
18938 <p style="/* insecure input */">C</p>
18939 <p style="/* insecure input */">D</p>
18940 <p style="/* insecure input */">E</p>
18941 <p style="/* insecure input */">F</p>
18942 <p style="/* insecure input */">G</p>
18943
18944 !! html/parsoid
18945 <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>
18946 <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>
18947 <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>
18948 <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>
18949 <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>
18950 <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>
18951 <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>
18952 !! end
18953
18954 !! test
18955 Table attribute legitimate extension
18956 !! wikitext
18957 {|
18958 !+ style="<nowiki>color:blue</nowiki>"|status
18959 |}
18960 !! html
18961 <table>
18962 <tr>
18963 <th style="color:blue">status
18964 </th></tr></table>
18965
18966 !!end
18967
18968 !! test
18969 Table attribute safety
18970 !! wikitext
18971 {|
18972 !+ style="<nowiki>border-width:expression(0+alert(document.cookie))</nowiki>"|status
18973 |}
18974 !! html
18975 <table>
18976 <tr>
18977 <th style="/* insecure input */">status
18978 </th></tr></table>
18979
18980 !! end
18981
18982 !! test
18983 CSS line continuation 1
18984 !! wikitext
18985 <div style="background-image: u\&#10;rl(test.jpg);"></div>
18986 !! html
18987 <div style="/* insecure input */"></div>
18988
18989 !! end
18990
18991 !! test
18992 CSS line continuation 2
18993 !! wikitext
18994 <div style="background-image: u\&#13;rl(test.jpg); "></div>
18995 !! html
18996 <div style="/* invalid control char */"></div>
18997
18998 !! end
18999
19000 !! article
19001 Template:Identity
19002 !! text
19003 {{{1}}}
19004 !! endarticle
19005
19006 !! test
19007 Expansion of multi-line templates in attribute values (T8255)
19008 !! wikitext
19009 <div style="background: {{identity|#00FF00}}">-</div>
19010 !! html
19011 <div style="background: #00FF00">-</div>
19012
19013 !! end
19014
19015 !! test
19016 Expansion of multi-line templates in attribute values (T8255 sanity check)
19017 !! wikitext
19018 <div style="background:
19019 #00FF00">-</div>
19020 !! html/php
19021 <div style="background: #00FF00">-</div>
19022
19023 !! html/parsoid
19024 <div style="background:
19025 #00FF00">-</div>
19026 !! end
19027
19028 !! test
19029 Expansion of multi-line templates in attribute values (T8255 sanity check 2)
19030 !! wikitext
19031 <div style="background: &#10;#00FF00">-</div>
19032 !! html
19033 <div style="background: &#10;#00FF00">-</div>
19034
19035 !! end
19036
19037 !! test
19038 Tags which are hidden from tidiers cannot pass through the Sanitizer
19039 !! wikitext
19040 <mw:toc><script>alert();</script></mw:toc>
19041 !! html+tidy
19042 <p>&lt;mw:toc&gt;&lt;script&gt;alert();&lt;/script&gt;&lt;/mw:toc&gt;
19043 </p>
19044 !! end
19045
19046 ###
19047 ### Parser hooks (see tests/parser/ParserTestParserHook.php for the <tag> extension)
19048 ###
19049
19050 !! test
19051 Parser hook: empty input
19052 !! wikitext
19053 <tag></tag>
19054 !! html/php
19055 <pre>
19056 ''
19057 array (
19058 )
19059 </pre>
19060
19061 !! html/parsoid
19062 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
19063 !! end
19064
19065 ## Don't expect parsoid to rt this form.
19066 !! test
19067 Parser hook: empty input using terminated empty elements
19068 !! options
19069 parsoid=wt2html,html2html
19070 !! wikitext
19071 <tag/>
19072 !! html/php
19073 <pre>
19074 NULL
19075 array (
19076 )
19077 </pre>
19078
19079 !! html/parsoid
19080 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{}}' data-parsoid='{}' about="#mwt2"></pre>
19081 !! end
19082
19083 !! test
19084 Parser hook: empty input using terminated empty elements (space before)
19085 !! wikitext
19086 <tag />
19087 !! html/php
19088 <pre>
19089 NULL
19090 array (
19091 )
19092 </pre>
19093
19094 !! html/parsoid
19095 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{}}' data-parsoid='{}' about="#mwt2"></pre>
19096 !! end
19097
19098 !! test
19099 Parser hook: basic input
19100 !! wikitext
19101 <tag>input</tag>
19102 !! html/php
19103 <pre>
19104 'input'
19105 array (
19106 )
19107 </pre>
19108
19109 !! html/parsoid
19110 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
19111 !! end
19112
19113 ## Don't expect parsoid to rt this form.
19114 !! test
19115 Parser hook: case insensitive
19116 !! options
19117 parsoid=wt2html,html2html
19118 !! wikitext
19119 <TAG>input</TAG>
19120 !! html/php
19121 <pre>
19122 'input'
19123 array (
19124 )
19125 </pre>
19126
19127 !! html/parsoid
19128 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
19129 !! end
19130
19131 ## Don't expect parsoid to rt this form.
19132 !! test
19133 Parser hook: case insensitive, redux
19134 !! options
19135 parsoid=wt2html,html2html
19136 !! wikitext
19137 <TaG>input</TAg>
19138 !! html/php
19139 <pre>
19140 'input'
19141 array (
19142 )
19143 </pre>
19144
19145 !! html/parsoid
19146 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
19147 !! end
19148
19149 !! test
19150 Parser hook: nested tags
19151 !! options
19152 parsoid=wt2html
19153 !! wikitext
19154 <tag><tag></tag></tag>
19155 !! html/php
19156 <pre>
19157 '<tag>'
19158 array (
19159 )
19160 </pre>&lt;/tag&gt;
19161
19162 !! html/php+tidy
19163 <pre>'<tag>'
19164 array (
19165 )
19166 </tag></pre><p>&lt;/tag&gt;
19167 </p>
19168 !! html/parsoid
19169 <pre typeof="mw:Extension/tag" about="#mwt2" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"&lt;tag>"}}'></pre><p>&lt;/tag></p>
19170 !! end
19171
19172 !! test
19173 Parser hook: basic arguments
19174 !! wikitext
19175 <tag width="200" height="100" depth="50" square=""></tag>
19176 !! html/php
19177 <pre>
19178 ''
19179 array (
19180 'width' => '200',
19181 'height' => '100',
19182 'depth' => '50',
19183 'square' => '',
19184 )
19185 </pre>
19186
19187 !! html/parsoid
19188 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
19189 !! end
19190
19191 ## Don't expect parsoid to rt this form.
19192 !! test
19193 Parser hook: basic arguments, variations
19194 !! options
19195 parsoid=wt2html,html2html
19196 !! wikitext
19197 <tag width=200 height = "100" depth = '50' square></tag>
19198 !! html/php
19199 <pre>
19200 ''
19201 array (
19202 'width' => '200',
19203 'height' => '100',
19204 'depth' => '50',
19205 'square' => '',
19206 )
19207 </pre>
19208
19209 !! html/parsoid
19210 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
19211 !! end
19212
19213 !! test
19214 Parser hook: argument containing a forward slash (T7344)
19215 !! wikitext
19216 <tag filename="/tmp/bla"></tag>
19217 !! html/php
19218 <pre>
19219 ''
19220 array (
19221 'filename' => '/tmp/bla',
19222 )
19223 </pre>
19224
19225 !! html/parsoid
19226 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"filename":"/tmp/bla"},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
19227 !! end
19228
19229 ## Don't expect parsoid to rt this form.
19230 !! test
19231 Parser hook: empty input using terminated empty elements (T4374)
19232 !! options
19233 parsoid=wt2html,html2html
19234 !! wikitext
19235 <tag foo=bar/>text
19236 !! html/php
19237 <pre>
19238 NULL
19239 array (
19240 'foo' => 'bar',
19241 )
19242 </pre>text
19243
19244 !! html/parsoid
19245 <pre typeof="mw:Extension/tag" about="#mwt2" data-mw='{"name":"tag","attrs":{"foo":"bar"}}'></pre><p>text</p>
19246 !! end
19247
19248 ## </tag> should be output literally since there is no matching tag that begins it
19249 ## Don't expect parsoid to rt this form.
19250 !! test
19251 Parser hook: basic arguments using terminated empty elements (T4374)
19252 !! options
19253 parsoid=wt2html
19254 !! wikitext
19255 <tag width=200 height = "100" depth = '50' square/>
19256 other stuff
19257 </tag>
19258 !! html/php
19259 <pre>
19260 NULL
19261 array (
19262 'width' => '200',
19263 'height' => '100',
19264 'depth' => '50',
19265 'square' => '',
19266 )
19267 </pre>
19268 <p>other stuff
19269 &lt;/tag&gt;
19270 </p>
19271 !! html/parsoid
19272 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""}}' about="#mwt2"></pre><p>other stuff
19273 &lt;/tag></p>
19274 !! end
19275
19276 ## Don't expect parsoid to rt this form.
19277 !! test
19278 Parser hook: Don't allow unclosed extension tags
19279 !! options
19280 parsoid=wt2html
19281 !! wikitext
19282 test <tag>123
19283
19284 this is a '''test'''
19285 !! html/php
19286 <p>test &lt;tag&gt;123
19287 </p><p>this is a <b>test</b>
19288 </p>
19289 !! html/parsoid
19290 <p>test &lt;tag>123</p>
19291
19292 <p>this is a <b>test</b></p>
19293 !! end
19294
19295 !! test
19296 Parser hook: horizontal rule inside extension tag that outputs <pre>
19297 !! wikitext
19298 <tag>
19299 Hello
19300 <hr/>
19301 Goodbye
19302 </tag>
19303 !! html/php
19304 <pre>
19305 '
19306 Hello
19307 <hr/>
19308 Goodbye
19309 '
19310 array (
19311 )
19312 </pre>
19313
19314 !! end
19315
19316 ###
19317 ### (see tests/parser/ParserTestParserHook.php for the <statictag> extension)
19318 ###
19319
19320 !! test
19321 Parser hook: static parser hook not inside a comment
19322 !! wikitext
19323 <statictag>hello, world</statictag>
19324
19325 <statictag action="flush" />
19326 !! html/php
19327 <p><br />
19328 hello, world
19329 </p>
19330 !! html/parsoid
19331 <p><span typeof="mw:Extension/statictag" data-mw='{"name":"statictag","attrs":{},"body":{"extsrc":"hello, world"}}' about="#mwt2"></span></p>
19332 <p><span typeof="mw:Extension/statictag" data-mw='{"name":"statictag","attrs":{"action":"flush"}}' about="#mwt4">hello, world</span></p>
19333 !! end
19334
19335 !! test
19336 Parser hook: static parser hook inside a comment
19337 !! wikitext
19338 <!-- <statictag>hello, world</statictag> -->
19339 <statictag action="flush" />
19340 !! html/php
19341 <p><br />
19342 </p>
19343 !! html/parsoid
19344 <!-- <statictag&#x3E;hello, world</statictag&#x3E; -->
19345 <p><span typeof='mw:Extension/statictag' data-mw='{"name":"statictag","attrs":{"action":"flush"}}' data-parsoid='{}' about='#mwt2'></span></p>
19346 !! end
19347
19348 # Nested template calls; this case was broken by Parser.php rev 1.506,
19349 # since reverted.
19350
19351 !! article
19352 Template:One-parameter
19353 !! text
19354 (My parameter is: {{{1}}})
19355 !! endarticle
19356
19357 !! article
19358 Template:Map-one-parameter
19359 !! text
19360 {{{{{1}}}|{{{2}}}}}
19361 !! endarticle
19362
19363 !! test
19364 Nested template calls
19365 !! wikitext
19366 {{Map-one-parameter|One-parameter|param}}
19367 !! html
19368 <p>(My parameter is: param)
19369 </p>
19370 !! end
19371
19372
19373 ###
19374 ### Sanitizer
19375 ###
19376
19377 !! test
19378 Sanitizer: Closing of open tags
19379 !! wikitext
19380 <s></s><table></table>
19381 !! html/php+tidy
19382 <p><s></s></p><table></table>
19383 !! html/parsoid
19384 <p><s data-parsoid='{"stx":"html"}'></s></p><table data-parsoid='{"stx":"html"}'></table>
19385 !! end
19386
19387 !! test
19388 Sanitizer: Closing of open but not closed tags
19389 !! wikitext
19390 <s>foo
19391 !! html
19392 <p><s>foo</s>
19393 </p>
19394 !! end
19395
19396 !! test
19397 Sanitizer: Closing of closed but not open tags
19398 !! options
19399 parsoid=wt2html
19400 !! wikitext
19401 </s>
19402 !! html+tidy
19403 <p class="mw-empty-elt">
19404 </p>
19405 !! end
19406
19407 !! test
19408 Sanitizer: Closing of closed but not open table tags
19409 !! options
19410 parsoid=wt2html
19411 !! wikitext
19412 Table not started</td></tr></table>
19413 !! html+tidy
19414 <p>Table not started
19415 </p>
19416 !! end
19417
19418 !! test
19419 Sanitizer: Escaping of spaces, multibyte characters, colons & other stuff in id=""
19420 !! options
19421 title=[[Main Page]]
19422 !! config
19423 wgFragmentMode=[ 'html5', 'legacy' ]
19424 !! wikitext
19425 <span id="æ: v">byte</span>[[#æ: v|backlink]]
19426 !! html/php
19427 <p><span id="æ:_v">byte</span><a href="#æ:_v">backlink</a>
19428 </p>
19429 !! html/parsoid
19430 <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>
19431 !! end
19432
19433 !! test
19434 Sanitizer: Escaping of spaces, multibyte characters, colons & other stuff in id="" (legacy)
19435 !! config
19436 wgFragmentMode=[ 'legacy' ]
19437 !! wikitext
19438 <span id="æ: v">byte</span>[[#æ: v|backlink]]
19439 !! html/php
19440 <p><span id=".C3.A6:_v">byte</span><a href="#.C3.A6:_v">backlink</a>
19441 </p>
19442 !! end
19443
19444 # In HTML5, the restrictions are that id must contain at least one character,
19445 # and must not contain any space characters.
19446 !! test
19447 Sanitizer: Validating the contents of the id attribute (T6515)
19448 !! options
19449 disabled
19450 !! wikitext
19451 <br id="" /><br id="a space" />
19452 !! html
19453 Something ...
19454 !! end
19455
19456 # In HTML5, id must be unique amongst all the ids in the element's home subtree.
19457 !! test
19458 Sanitizer: Validating id attribute uniqueness (T6515, T8301)
19459 !! options
19460 disabled
19461 !! wikitext
19462 <br id="foo" /><br id="foo" />
19463 !! html
19464 Something need to be done. foo-2 ?
19465 !! end
19466
19467 !! test
19468 Sanitizer: Validating that <meta> and <link> work, but only for Microdata
19469 !! wikitext
19470 <div itemscope>
19471 <meta itemprop="hello" content="world">
19472 <meta http-equiv="refresh" content="5">
19473 <meta itemprop="hello" http-equiv="refresh" content="5">
19474 <link itemprop="hello" href="{{SERVER}}">
19475 <link rel="stylesheet" href="{{SERVER}}">
19476 <link rel="stylesheet" itemprop="hello" href="{{SERVER}}">
19477 </div>
19478 !! html
19479 <div itemscope="">
19480 <p> <meta itemprop="hello" content="world" />
19481 &lt;meta http-equiv="refresh" content="5"&gt;
19482 <meta itemprop="hello" content="5" />
19483 <link itemprop="hello" href="http&#58;//example.org" />
19484 &lt;link rel="stylesheet" href="<a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>"&gt;
19485 <link itemprop="hello" href="http&#58;//example.org" />
19486 </p>
19487 </div>
19488
19489 !! end
19490
19491 !! test
19492 Sanitizer: Strip comments from CSS attributes
19493 !! options
19494 parsoid=wt2html,wt2wt
19495 !! wikitext
19496 <span style="margin:/*negate mbox-text padding */-0.125em -0.45em; /*rainbow*/rgba(255, 0, 0, 0.3)">2013</span>
19497 !! html/php
19498 <p><span style="margin: -0.125em -0.45em; rgba(255, 0, 0, 0.3)">2013</span>
19499 </p>
19500 !! html/parsoid
19501 <p><span style="margin: -0.125em -0.45em; rgba(255, 0, 0, 0.3)">2013</span></p>
19502 !! end
19503
19504 !! test
19505 Sanitizer: Avoid unnecessary percent encoded characters in interwiki links
19506 !! wikitext
19507 [[meatball:Soft"Security]]
19508 !! html/php
19509 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?Soft%22Security" class="extiw" title="meatball:Soft&quot;Security">meatball:Soft"Security</a>
19510 </p>
19511 !! html/parsoid
19512 <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>
19513 !! end
19514
19515 !! test
19516 Sanitizer: angle brackets are invalid, even in interwiki links (T182338)
19517 !! wikitext
19518 [[meatball:Foo<Bar]]
19519 [[meatball:Foo>Bar]]
19520 [[meatball:Foo&lt;bar]]
19521 [[meatball:Foo&gt;bar]]
19522 !! html/php
19523 <p>[[meatball:Foo&lt;Bar]]
19524 [[meatball:Foo&gt;Bar]]
19525 [[meatball:Foo&lt;bar]]
19526 [[meatball:Foo&gt;bar]]
19527 </p>
19528 !! html/parsoid
19529 <p>[[meatball:Foo&lt;Bar]]
19530 [[meatball:Foo>Bar]]
19531 [[meatball:Foo<span typeof="mw:Entity" data-parsoid='{"src":"&amp;lt;","srcContent":"&lt;"}'>&lt;</span>bar]]
19532 [[meatball:Foo<span typeof="mw:Entity" data-parsoid='{"src":"&amp;gt;","srcContent":">"}'>></span>bar]]</p>
19533 !! end
19534
19535 !! test
19536 Language converter: output gets cut off unexpectedly (T7757)
19537 !! options
19538 language=zh
19539 !! wikitext
19540 this bit is safe: }-
19541
19542 but if we add a conversion instance: -{zh-cn:xxx;zh-tw:yyy}-
19543
19544 then we get cut off here: }-
19545
19546 all additional text is vanished
19547 !! html/php
19548 <p>this bit is safe: }-
19549 </p><p>but if we add a conversion instance: xxx
19550 </p><p>then we get cut off here: }-
19551 </p><p>all additional text is vanished
19552 </p>
19553 !! html/parsoid
19554 <p>this bit is safe: }-</p>
19555 <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>
19556 <p>then we get cut off here: }-</p>
19557 <p>all additional text is vanished</p>
19558 !! end
19559
19560 !! test
19561 Language converter glossary rules inside attributes (T119158)
19562 !! options
19563 language=sr variant=sr-el
19564 !! wikitext
19565 -{H|foAjrjvi=>sr-el:" onload="alert(1)" data-foo="}-
19566
19567 [[File:Foobar.jpg|alt=-{}-foAjrjvi-{}-]]
19568 !! html/php
19569 <p>
19570 </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>
19571 </p>
19572 !! html/parsoid
19573 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"foAjrjvi","l":"sr-el","t":"\" onload=\"alert(1)\" data-foo=\""}]}'/></p>
19574
19575 <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>
19576 !! end
19577
19578 !! test
19579 Self closed html pairs (T7487)
19580 !! wikitext
19581 <center><font id="bug" />Centered text</center>
19582 <div><font id="bug2" />In div text</div>
19583 !! html+tidy
19584 <center><font id="bug"></font>Centered text</center>
19585 <div><font id="bug2"></font>In div text</div>
19586 !! end
19587
19588 !! test
19589 Punctuation: nbsp before exclamation
19590 !! wikitext
19591 C'est grave !
19592 !! html
19593 <p>C'est grave&#160;!
19594 </p>
19595 !! end
19596
19597 !! test
19598 Punctuation: CSS !important (T13874)
19599 !! wikitext
19600 <div style="width:50% !important">important</div>
19601 !! html
19602 <div style="width:50% !important">important</div>
19603
19604 !!end
19605
19606 !! test
19607 Punctuation: CSS ! important (T13874; with space after)
19608 !! wikitext
19609 <div style="width:50% ! important">important</div>
19610 !! html
19611 <div style="width:50%&#32;! important">important</div>
19612
19613 !!end
19614
19615 !! test
19616 HTML bullet list, closed tags (T7497)
19617 !! wikitext
19618 <ul>
19619 <li>One</li>
19620 <li>Two</li>
19621 </ul>
19622 !! html/php
19623 <ul>
19624 <li>One</li>
19625 <li>Two</li>
19626 </ul>
19627
19628 !! html/parsoid
19629 <ul data-parsoid='{"stx":"html"}'>
19630 <li data-parsoid='{"stx":"html"}'>One</li>
19631 <li data-parsoid='{"stx":"html"}'>Two</li>
19632 </ul>
19633
19634 !! end
19635
19636 !! test
19637 HTML bullet list, unclosed tags (T7497)
19638 !! wikitext
19639 <ul>
19640 <li>One
19641 <li>Two
19642 </ul>
19643 !! html/php+tidy
19644 <ul>
19645 <li>One
19646 </li><li>Two
19647 </li></ul>
19648 !! html/parsoid
19649 <ul data-parsoid='{"stx":"html"}'>
19650 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>One</li>
19651 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>Two</li>
19652 </ul>
19653
19654 !! end
19655
19656 !! test
19657 HTML ordered list, closed tags (T7497)
19658 !! wikitext
19659 <ol>
19660 <li>One</li>
19661 <li>Two</li>
19662 </ol>
19663 !! html/php
19664 <ol>
19665 <li>One</li>
19666 <li>Two</li>
19667 </ol>
19668
19669 !! html/parsoid
19670 <ol data-parsoid='{"stx":"html"}'>
19671 <li data-parsoid='{"stx":"html"}'>One</li>
19672 <li data-parsoid='{"stx":"html"}'>Two</li>
19673 </ol>
19674
19675 !! end
19676
19677 !! test
19678 HTML ordered list, unclosed tags (T7497)
19679 !! options
19680 !! wikitext
19681 <ol>
19682 <li>One
19683 <li>Two
19684 </ol>
19685 !! html/php+tidy
19686 <ol>
19687 <li>One
19688 </li><li>Two
19689 </li></ol>
19690 !! html/parsoid
19691 <ol data-parsoid='{"stx":"html"}'>
19692 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>One</li>
19693 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>Two</li>
19694 </ol>
19695
19696 !! end
19697
19698 !! test
19699 HTML nested bullet list, closed tags (T7497)
19700 !! wikitext
19701 <ul>
19702 <li>One</li>
19703 <li>Two:
19704 <ul>
19705 <li>Sub-one</li>
19706 <li>Sub-two</li>
19707 </ul>
19708 </li>
19709 </ul>
19710 !! html/php
19711 <ul>
19712 <li>One</li>
19713 <li>Two:
19714 <ul>
19715 <li>Sub-one</li>
19716 <li>Sub-two</li>
19717 </ul>
19718 </li>
19719 </ul>
19720
19721 !! html/parsoid
19722 <ul data-parsoid='{"stx":"html"}'>
19723 <li data-parsoid='{"stx":"html"}'>One</li>
19724 <li data-parsoid='{"stx":"html"}'>Two:
19725 <ul data-parsoid='{"stx":"html"}'>
19726 <li data-parsoid='{"stx":"html"}'>Sub-one</li>
19727 <li data-parsoid='{"stx":"html"}'>Sub-two</li>
19728 </ul>
19729 </li>
19730 </ul>
19731 !! end
19732
19733 !! test
19734 HTML nested bullet list, open tags (T7497)
19735 !! wikitext
19736 <ul>
19737 <li>One
19738 <li>Two:
19739 <ul>
19740 <li>Sub-one
19741 <li>Sub-two
19742 </ul>
19743 </ul>
19744 !! html+tidy
19745 <ul>
19746 <li>One
19747 </li><li>Two:
19748 <ul>
19749 <li>Sub-one
19750 </li><li>Sub-two
19751 </li></ul>
19752 </li></ul>
19753 !! end
19754
19755 !! test
19756 HTML nested ordered list, closed tags (T7497)
19757 !! wikitext
19758 <ol>
19759 <li>One</li>
19760 <li>Two:
19761 <ol>
19762 <li>Sub-one</li>
19763 <li>Sub-two</li>
19764 </ol>
19765 </li>
19766 </ol>
19767 !! html
19768 <ol>
19769 <li>One</li>
19770 <li>Two:
19771 <ol>
19772 <li>Sub-one</li>
19773 <li>Sub-two</li>
19774 </ol>
19775 </li>
19776 </ol>
19777
19778 !! end
19779
19780 !! test
19781 HTML nested ordered list, open tags (T7497)
19782 !! wikitext
19783 <ol>
19784 <li>One
19785 <li>Two:
19786 <ol>
19787 <li>Sub-one
19788 <li>Sub-two
19789 </ol>
19790 </ol>
19791 !! html/php
19792 <ol>
19793 <li>One
19794 <li>Two:
19795 <ol>
19796 <li>Sub-one
19797 <li>Sub-two
19798 </ol>
19799 </ol>
19800
19801 !! html/parsoid
19802 <ol>
19803 <li>One
19804 </li>
19805 <li>Two:
19806 <ol>
19807 <li>Sub-one
19808 </li>
19809 <li>Sub-two
19810 </li>
19811 </ol>
19812 </li>
19813 </ol>
19814
19815 !! end
19816
19817 !! test
19818 HTML ordered list item with parameters oddity
19819 !! wikitext
19820 <ol><li id="fragment">One</li>
19821 </ol>
19822 !! html
19823 <ol><li id="fragment">One</li>
19824 </ol>
19825
19826 !! end
19827
19828 # parsoid doesn't explicitly mark autonumbered links, see T55505
19829 !!test
19830 T7918: autonumbering
19831 !! wikitext
19832 [http://first/] [http://second] [ftp://ftp]
19833
19834 ftp://inlineftp
19835
19836 [mailto:enclosed@mail.tld With target]
19837
19838 [mailto:enclosed@mail.tld]
19839
19840 mailto:inline@mail.tld
19841 !! html/php
19842 <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>
19843 </p><p><a rel="nofollow" class="external free" href="ftp://inlineftp">ftp://inlineftp</a>
19844 </p><p><a rel="nofollow" class="external text" href="mailto:enclosed@mail.tld">With target</a>
19845 </p><p><a rel="nofollow" class="external autonumber" href="mailto:enclosed@mail.tld">[4]</a>
19846 </p><p><a rel="nofollow" class="external free" href="mailto:inline@mail.tld">mailto:inline@mail.tld</a>
19847 </p>
19848 !! html/parsoid
19849 <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>
19850 <p><a rel="mw:ExtLink" class="external free" href="ftp://inlineftp">ftp://inlineftp</a></p>
19851 <p><a rel="mw:ExtLink" class="external text" href="mailto:enclosed@mail.tld">With target</a></p>
19852 <p><a rel="mw:ExtLink" class="external autonumber" href="mailto:enclosed@mail.tld"></a></p>
19853 <p><a rel="mw:ExtLink" class="external free" href="mailto:inline@mail.tld">mailto:inline@mail.tld</a></p>
19854 !! end
19855
19856
19857 #
19858 # Security and HTML correctness
19859 # From Nick Jenkins' fuzz testing
19860 #
19861
19862 !! test
19863 Fuzz testing: Parser13
19864 !! wikitext
19865 {|
19866 | http://a|
19867 !! html
19868 <table>
19869 <tr>
19870 <td>
19871 </td>
19872 </tr>
19873 </table>
19874
19875 !! end
19876
19877 # Note that Parsoid output differs from the PHP parser here: the PHP
19878 # parser breaks the URL for the magic word, while in Parsoid the URL
19879 # production takes precedence.
19880 !! test
19881 Fuzz testing: Parser14
19882 !! wikitext
19883 ==onmouseover===
19884 http://__TOC__
19885 !! html/php
19886 <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>
19887 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>
19888 <ul>
19889 <li class="toclevel-1 tocsection-1"><a href="#onmouseover.3D"><span class="tocnumber">1</span> <span class="toctext">onmouseover=</span></a></li>
19890 </ul>
19891 </div>
19892
19893
19894 !! html/php+tidy
19895 <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>
19896 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>
19897 <ul>
19898 <li class="toclevel-1 tocsection-1"><a href="#onmouseover.3D"><span class="tocnumber">1</span> <span class="toctext">onmouseover=</span></a></li>
19899 </ul>
19900 </div>
19901 !! html/parsoid
19902 <h2 id="onmouseover="><span id="onmouseover.3D" typeof="mw:FallbackId"></span>onmouseover=</h2>
19903 <p><a rel="mw:ExtLink" class="external free" href="http://__TOC__" data-parsoid='{"stx":"url"}'>http://__TOC__</a></p>
19904 !! end
19905
19906 !! test
19907 Fuzz testing: Parser14-table
19908 !! options
19909 parsoid=wt2html,html2html
19910 !! wikitext
19911 ==a==
19912 {| STYLE=__TOC__
19913 !! html/php
19914 <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>
19915 <table style="&#95;_TOC&#95;_">
19916 <tr><td></td></tr>
19917 </table>
19918
19919 !! html/php+tidy
19920 <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>
19921 <table style="&#95;_TOC&#95;_">
19922 <tbody><tr><td></td></tr>
19923 </tbody></table>
19924 !! html/parsoid
19925 <h2 id="a">a</h2>
19926 <table style="__TOC__"></table>
19927 !! end
19928
19929 # Known to produce bogus xml (extra </td>)
19930 # Don't add the html/php section since it generates broken HTML
19931 !! test
19932 Fuzz testing: Parser16
19933 !! wikitext
19934 {|
19935 !https://||||||
19936 !! html+tidy
19937 <table>
19938 <tbody><tr>
19939 <th>https://</th>
19940 <th></th>
19941 <th></th>
19942 <th>
19943
19944 </th></tr>
19945 </tbody></table>
19946 !! end
19947
19948 !! test
19949 Fuzz testing: Parser21
19950 !! wikitext
19951 {|
19952 !irc://{{ftp://a" onmouseover="alert('hello world');"
19953 |
19954 !! html
19955 <table>
19956 <tr>
19957 <th><a rel="nofollow" class="external free" href="irc://{{ftp://a">irc://{{ftp://a</a>" onmouseover="alert('hello world');"
19958 </th>
19959 <td>
19960 </td>
19961 </tr>
19962 </table>
19963
19964 !! end
19965
19966 !! test
19967 Fuzz testing: Parser22
19968 !! wikitext
19969 http://===r:::https://b
19970
19971 {|
19972 !! html
19973 <p><a rel="nofollow" class="external free" href="http://===r:::https://b">http://===r:::https://b</a>
19974 </p>
19975 <table>
19976 <tr><td></td></tr>
19977 </table>
19978
19979 !! end
19980
19981 ## Remex doesn't account for fostered content.
19982 ## Known to produce bad XML for now
19983 !! test
19984 Fuzz testing: Parser24
19985 !! options
19986 parsoid=wt2html
19987 !! wikitext
19988 {|
19989 {{{|
19990 <u CLASS=
19991 | {{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx--><noinclude>}}}} >
19992 <br style="onmouseover='alert(document.cookie);' " />
19993
19994 MOVE YOUR MOUSE CURSOR OVER THIS TEXT
19995 |
19996 !! html/php
19997 <table>
19998 {{{|
19999 <u class="&#124;">}}}} &gt;
20000 <br style="onmouseover=&#39;alert(document.cookie);&#39;" />
20001
20002 MOVE YOUR MOUSE CURSOR OVER THIS TEXT
20003 <tr>
20004 <td></u>
20005 </td>
20006 </tr>
20007 </table>
20008
20009 !! html/php+tidy
20010
20011 {{{|
20012 <u class="&#124;">}}}} &gt;
20013 <br style="onmouseover=&#39;alert(document.cookie);&#39;" />
20014
20015 MOVE YOUR MOUSE CURSOR OVER THIS TEXT
20016 </u><table><tbody><tr>
20017 <td>
20018 </td>
20019 </tr>
20020 </tbody></table><p><u class="&#124;">
20021 </u></p>
20022 !! html/parsoid
20023 <p data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true}'>
20024 {{{|
20025 <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>"}'/>}}}} >
20026 <br style="onmouseover='alert(document.cookie);' " data-parsoid='{"stx":"html","selfClose":true}'/>
20027
20028 MOVE YOUR MOUSE CURSOR OVER THIS TEXT</u></p>
20029 <table data-parsoid='{"autoInsertedEnd":true}'><tbody><tr data-parsoid='{"autoInsertedStart":true}'><td></td></tr></tbody></table>
20030 !! end
20031
20032 # Note: the current result listed for this is not what the original one was,
20033 # but the original bug was JavaScript injection, which is fixed in any case.
20034 # It's not clear that the original result listed was any more correct than the
20035 # current one. Original result:
20036 # <p>{{{|
20037 # </p>
20038 # <li class="&#124;&#124;">
20039 # }}}blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b>
20040 !!test
20041 Fuzz testing: Parser25 (T8055)
20042 !! wikitext
20043 {{{
20044 |
20045 <LI CLASS=||
20046 >
20047 }}}blah" onmouseover="alert('hello world');" align="left"'''MOVE MOUSE CURSOR OVER HERE
20048 !! html/php
20049 <p>&lt;LI CLASS=blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b>
20050 </p>
20051 !! html/parsoid
20052 <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"]}'>
20053 </span><p about="#mwt1">&lt;LI CLASS=blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b></p>
20054 !! end
20055
20056 !!test
20057 Fuzz testing: URL adjacent extension (with space, clean)
20058 !! wikitext
20059 http://example.com <nowiki>junk</nowiki>
20060 !! html/php
20061 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> junk
20062 </p>
20063 !! html/parsoid
20064 <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>
20065 !! end
20066
20067 !!test
20068 Fuzz testing: URL adjacent extension (no space, dirty; nowiki)
20069 !! wikitext
20070 http://example.com<nowiki>junk</nowiki>
20071 !! html/php
20072 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>junk
20073 </p>
20074 !! html/parsoid
20075 <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>
20076 !! end
20077
20078 !! test
20079 Fuzz testing: URL adjacent extension (no space, dirty; pre)
20080 !! wikitext
20081 http://example.com<pre>junk</pre>
20082 !! html/php
20083 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a><pre>junk</pre>
20084
20085 !! html/php+tidy
20086 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a></p><pre>junk</pre>
20087 !! html/parsoid
20088 <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>
20089 !! end
20090
20091 !! test
20092 Fuzz testing: image with bogus manual thumbnail
20093 !! wikitext
20094 [[Image:foobar.jpg|thumbnail= ]]
20095 !! html/php
20096 <div class="thumb tright"><div class="thumbinner" style="width:182px;">Error creating thumbnail: <div class="thumbcaption"></div></div></div>
20097
20098 !! html/parsoid
20099 <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>
20100 !! end
20101
20102 # Parsoid will emit the newline literally in wt2wt; see next test case.
20103 !! test
20104 Fuzz testing: encoded newline in generated HTML replacements (T8577)
20105 !! options
20106 parsoid=wt2html
20107 !! wikitext
20108 <pre dir="&#10;"></pre>
20109 !! html/php
20110 <pre dir="&#10;"></pre>
20111
20112 !! html/parsoid
20113 <pre dir="
20114 " typeof="mw:Extension/pre" about="#mwt2"data-mw='{"name":"pre","attrs":{"dir":"\n"},"body":{"extsrc":""}}'></pre>
20115 !! end
20116
20117 !! test
20118 Fuzz testing: encoded newline in generated HTML replacements, html2wt (T8577)
20119 !! options
20120 parsoid=html2wt
20121 !! html/parsoid
20122 <pre typeof="mw:Extension/pre" about="#mwt2" dir="
20123 " data-mw='{"name":"pre","attrs":{"dir":"\n"},"body":{"extsrc":""}}'></pre>
20124 !! wikitext
20125 <pre dir="
20126 "></pre>
20127 !! html/php
20128 <pre dir=""></pre>
20129
20130 !! end
20131
20132 !! test
20133 Templates in extension attributes are not expanded
20134 !! wikitext
20135 <pre dir="{{echo|ltr}}"></pre>
20136 !! html/php
20137 <pre dir="{{echo|ltr}}"></pre>
20138
20139 !! html/parsoid
20140 <pre dir="{{echo|ltr}}" typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{"dir":"{{echo|ltr}}"},"body":{"extsrc":""}}'></pre>
20141 !! end
20142
20143 !! test
20144 Parsing optional HTML elements (T8171)
20145 !! options
20146 !! wikitext
20147 <table>
20148 <tr>
20149 <td> Some tabular data</td>
20150 <td> More tabular data ...
20151 <td> And yet som tabular data</td>
20152 </tr>
20153 </table>
20154 !! html
20155 <table>
20156 <tr>
20157 <td> Some tabular data</td>
20158 <td> More tabular data ...
20159 </td><td> And yet som tabular data</td>
20160 </tr>
20161 </table>
20162
20163 !! end
20164
20165 !! test
20166 Correct handling of <td>, <tr> (T8171)
20167 !! options
20168 !! wikitext
20169 <table>
20170 <tr>
20171 <td> Some tabular data</td>
20172 <td> More tabular data ...</td>
20173 <td> And yet som tabular data</td>
20174 </tr>
20175 </table>
20176 !! html
20177 <table>
20178 <tr>
20179 <td> Some tabular data</td>
20180 <td> More tabular data ...</td>
20181 <td> And yet som tabular data</td>
20182 </tr>
20183 </table>
20184
20185 !! end
20186
20187
20188 !! test
20189 Parsing crashing regression (fr:JavaScript)
20190 !! wikitext
20191 </body></x>
20192 !! html
20193 <p>&lt;/body&gt;&lt;/x&gt;
20194 </p>
20195 !! end
20196
20197 !! test
20198 Inline wiki vs wiki block nesting
20199 !! wikitext
20200 '''Bold paragraph
20201
20202 New wiki paragraph
20203 !! html
20204 <p><b>Bold paragraph</b>
20205 </p><p>New wiki paragraph
20206 </p>
20207 !! end
20208
20209 # FIXME: The current php output is documented
20210 # and desired output is the parsoid target.
20211 !! test
20212 Inline HTML vs wiki block nesting
20213 !! wikitext
20214 <b>Bold paragraph
20215
20216 New wiki paragraph
20217 !! html/php
20218 <p><b>Bold paragraph
20219 </p><p>New wiki paragraph</b>
20220 </p>
20221 !! html/php+tidy
20222 <p><b>Bold paragraph
20223 </b></p><p><b>New wiki paragraph
20224 </b></p>
20225 !! html/parsoid
20226 <p><b>Bold paragraph</b>
20227 </p><p>New wiki paragraph
20228 </p>
20229 !! end
20230
20231 # Original result was this:
20232 # <p><b>bold</b><b>bold<i>bolditalics</i></b>
20233 # </p>
20234 # While that might be marginally more intuitive, maybe, the six-apostrophe
20235 # construct is clearly pathological and the result stated here (which is what
20236 # the parser actually does) is about as reasonable as anything.
20237 !!test
20238 Mixing markup for italics and bold
20239 !! options
20240 !! wikitext
20241 '''bold''''''bold''bolditalics'''''
20242 !! html
20243 <p>'<i>bold'</i><b>bold<i>bolditalics</i></b>
20244 </p>
20245 !! end
20246
20247
20248 !! article
20249 Xyzzyx
20250 !! text
20251 Article for special page transclusion test
20252 !! endarticle
20253
20254 !! test
20255 Special page transclusion
20256 !! options
20257 !! wikitext
20258 {{Special:Prefixindex/Xyzzyx}}
20259 !! html
20260 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
20261 </ul>
20262
20263 !! end
20264
20265 !! test
20266 Special page transclusion twice (T7021)
20267 !! options
20268 !! wikitext
20269 {{Special:Prefixindex/Xyzzyx}}
20270 {{Special:Prefixindex/Xyzzyx}}
20271 !! html
20272 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
20273 </ul>
20274 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
20275 </ul>
20276
20277 !! end
20278
20279 !! test
20280 Transclusion of default MediaWiki message
20281 !! wikitext
20282 {{MediaWiki:Mainpage}}
20283 !! html
20284 <p>Main Page
20285 </p>
20286 !! end
20287
20288 !! test
20289 Transclusion of nonexistent MediaWiki message
20290 !! wikitext
20291 {{MediaWiki:Mainpagexxx}}
20292 !! html
20293 <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>
20294 </p>
20295 !! end
20296
20297 !! test
20298 Transclusion of MediaWiki message with underscore
20299 !! wikitext
20300 {{MediaWiki:history_short}}
20301 !! html
20302 <p>History
20303 </p>
20304 !! end
20305
20306 !! test
20307 Transclusion of MediaWiki message with space
20308 !! wikitext
20309 {{MediaWiki:history short}}
20310 !! html
20311 <p>History
20312 </p>
20313 !! end
20314
20315 !! test
20316 Invalid header with following text
20317 !! wikitext
20318 = x = y
20319 !! html
20320 <p>= x = y
20321 </p>
20322 !! end
20323
20324
20325 !! test
20326 Section extraction test (section 0)
20327 !! options
20328 section=0
20329 !! wikitext
20330 start
20331 ==a==
20332 ===aa===
20333 ====aaa====
20334 ==b==
20335 ===ba===
20336 ===bb===
20337 ====bba====
20338 ===bc===
20339 ==c==
20340 ===ca===
20341 !! html/php
20342 start
20343 !! end
20344
20345 !! test
20346 Section extraction test (section 1)
20347 !! options
20348 section=1
20349 !! wikitext
20350 start
20351 ==a==
20352 ===aa===
20353 ====aaa====
20354 ==b==
20355 ===ba===
20356 ===bb===
20357 ====bba====
20358 ===bc===
20359 ==c==
20360 ===ca===
20361 !! html/php
20362 ==a==
20363 ===aa===
20364 ====aaa====
20365 !! end
20366
20367 !! test
20368 Section extraction test (section 2)
20369 !! options
20370 section=2
20371 !! wikitext
20372 start
20373 ==a==
20374 ===aa===
20375 ====aaa====
20376 ==b==
20377 ===ba===
20378 ===bb===
20379 ====bba====
20380 ===bc===
20381 ==c==
20382 ===ca===
20383 !! html/php
20384 ===aa===
20385 ====aaa====
20386 !! end
20387
20388 !! test
20389 Section extraction test (section 3)
20390 !! options
20391 section=3
20392 !! wikitext
20393 start
20394 ==a==
20395 ===aa===
20396 ====aaa====
20397 ==b==
20398 ===ba===
20399 ===bb===
20400 ====bba====
20401 ===bc===
20402 ==c==
20403 ===ca===
20404 !! html/php
20405 ====aaa====
20406 !! end
20407
20408 !! test
20409 Section extraction test (section 4)
20410 !! options
20411 section=4
20412 !! wikitext
20413 start
20414 ==a==
20415 ===aa===
20416 ====aaa====
20417 ==b==
20418 ===ba===
20419 ===bb===
20420 ====bba====
20421 ===bc===
20422 ==c==
20423 ===ca===
20424 !! html/php
20425 ==b==
20426 ===ba===
20427 ===bb===
20428 ====bba====
20429 ===bc===
20430 !! end
20431
20432 !! test
20433 Section extraction test (section 5)
20434 !! options
20435 section=5
20436 !! wikitext
20437 start
20438 ==a==
20439 ===aa===
20440 ====aaa====
20441 ==b==
20442 ===ba===
20443 ===bb===
20444 ====bba====
20445 ===bc===
20446 ==c==
20447 ===ca===
20448 !! html/php
20449 ===ba===
20450 !! end
20451
20452 !! test
20453 Section extraction test (section 6)
20454 !! options
20455 section=6
20456 !! wikitext
20457 start
20458 ==a==
20459 ===aa===
20460 ====aaa====
20461 ==b==
20462 ===ba===
20463 ===bb===
20464 ====bba====
20465 ===bc===
20466 ==c==
20467 ===ca===
20468 !! html/php
20469 ===bb===
20470 ====bba====
20471 !! end
20472
20473 !! test
20474 Section extraction test (section 7)
20475 !! options
20476 section=7
20477 !! wikitext
20478 start
20479 ==a==
20480 ===aa===
20481 ====aaa====
20482 ==b==
20483 ===ba===
20484 ===bb===
20485 ====bba====
20486 ===bc===
20487 ==c==
20488 ===ca===
20489 !! html/php
20490 ====bba====
20491 !! end
20492
20493 !! test
20494 Section extraction test (section 8)
20495 !! options
20496 section=8
20497 !! wikitext
20498 start
20499 ==a==
20500 ===aa===
20501 ====aaa====
20502 ==b==
20503 ===ba===
20504 ===bb===
20505 ====bba====
20506 ===bc===
20507 ==c==
20508 ===ca===
20509 !! html/php
20510 ===bc===
20511 !! end
20512
20513 !! test
20514 Section extraction test (section 9)
20515 !! options
20516 section=9
20517 !! wikitext
20518 start
20519 ==a==
20520 ===aa===
20521 ====aaa====
20522 ==b==
20523 ===ba===
20524 ===bb===
20525 ====bba====
20526 ===bc===
20527 ==c==
20528 ===ca===
20529 !! html/php
20530 ==c==
20531 ===ca===
20532 !! end
20533
20534 !! test
20535 Section extraction test (section 10)
20536 !! options
20537 section=10
20538 !! wikitext
20539 start
20540 ==a==
20541 ===aa===
20542 ====aaa====
20543 ==b==
20544 ===ba===
20545 ===bb===
20546 ====bba====
20547 ===bc===
20548 ==c==
20549 ===ca===
20550 !! html/php
20551 ===ca===
20552 !! end
20553
20554 !! test
20555 Section extraction test (nonexistent section 11)
20556 !! options
20557 section=11
20558 !! wikitext
20559 start
20560 ==a==
20561 ===aa===
20562 ====aaa====
20563 ==b==
20564 ===ba===
20565 ===bb===
20566 ====bba====
20567 ===bc===
20568 ==c==
20569 ===ca===
20570 !! html/php
20571 !! end
20572
20573 !! test
20574 Section extraction test with bogus heading (section 1)
20575 !! options
20576 section=1
20577 !! wikitext
20578 ==a==
20579 ==bogus== not a legal section
20580 ==b==
20581 !! html/php
20582 ==a==
20583 ==bogus== not a legal section
20584 !! end
20585
20586 !! test
20587 Section extraction test with bogus heading (section 2)
20588 !! options
20589 section=2
20590 !! wikitext
20591 ==a==
20592 ==bogus== not a legal section
20593 ==b==
20594 !! html/php
20595 ==b==
20596 !! end
20597
20598 !! test
20599 Section extraction test with comment after heading (section 1)
20600 !! options
20601 section=1
20602 !! wikitext
20603 ==a==
20604 ==b== <!-- -->
20605 ==c==
20606 !! html/php
20607 ==a==
20608 !! end
20609
20610 !! test
20611 Section extraction test with comment after heading (section 2)
20612 !! options
20613 section=2
20614 !! wikitext
20615 ==a==
20616 ==b== <!-- -->
20617 ==c==
20618 !! html/php
20619 ==b== <!-- -->
20620 !! end
20621
20622 !! test
20623 Section extraction test with bogus <nowiki> heading (section 1)
20624 !! options
20625 section=1
20626 !! wikitext
20627 ==a==
20628 ==bogus== <nowiki>not a legal section</nowiki>
20629 ==b==
20630 !! html/php
20631 ==a==
20632 ==bogus== <nowiki>not a legal section</nowiki>
20633 !! end
20634
20635 !! test
20636 Section extraction test with bogus <nowiki> heading (section 2)
20637 !! options
20638 section=2
20639 !! wikitext
20640 ==a==
20641 ==bogus== <nowiki>not a legal section</nowiki>
20642 ==b==
20643 !! html/php
20644 ==b==
20645 !! end
20646
20647 # Formerly testing for T4587, now resolved by the use of unmarked sections
20648 # instead of respecting commented sections
20649 !! test
20650 Section extraction prefixed by comment (section 1)
20651 !! options
20652 section=1
20653 !! wikitext
20654 <!-- -->==sec1==
20655 ==sec2==
20656 !! html/php
20657 ==sec2==
20658 !!end
20659
20660 !! test
20661 Section extraction prefixed by comment (section 2)
20662 !! options
20663 section=2
20664 !! wikitext
20665 <!-- -->==sec1==
20666 ==sec2==
20667 !! html/php
20668
20669 !!end
20670
20671 # Formerly testing for T4607, now resolved by the use of unmarked sections
20672 # instead of respecting HTML-style headings
20673 !! test
20674 Section extraction, mixed wiki and html (section 1)
20675 !! options
20676 section=1
20677 !! wikitext
20678 <h2>unmarked</h2>
20679 unmarked
20680 ==1==
20681 one
20682 ==2==
20683 two
20684 !! html/php
20685 ==1==
20686 one
20687 !! end
20688
20689 !! test
20690 Section extraction, mixed wiki and html (section 2)
20691 !! options
20692 section=2
20693 !! wikitext
20694 <h2>unmarked</h2>
20695 unmarked
20696 ==1==
20697 one
20698 ==2==
20699 two
20700 !! html/php
20701 ==2==
20702 two
20703 !! end
20704
20705
20706 # Formerly testing for T5342
20707 !! test
20708 Section extraction, heading surrounded by <noinclude>
20709 !! options
20710 section=1
20711 !! wikitext
20712 <noinclude>==unmarked==</noinclude>
20713 ==marked==
20714 !! html/php
20715 ==marked==
20716 !!end
20717
20718 # Test behavior of T21910
20719 !! test
20720 Sectiion with all-equals
20721 !! options
20722 section=2
20723 !! wikitext
20724 ===
20725 The line above must have a trailing space
20726 === <!--
20727 --> <!-- -->
20728 But just in case it doesn't...
20729 !! html/php
20730 === <!--
20731 --> <!-- -->
20732 But just in case it doesn't...
20733 !! end
20734
20735 !! test
20736 Section replacement test (section 0)
20737 !! options
20738 replace=0,"xxx"
20739 !! wikitext
20740 start
20741 ==a==
20742 ===aa===
20743 ====aaa====
20744 ==b==
20745 ===ba===
20746 ===bb===
20747 ====bba====
20748 ===bc===
20749 ==c==
20750 ===ca===
20751 !! html/php
20752 xxx
20753
20754 ==a==
20755 ===aa===
20756 ====aaa====
20757 ==b==
20758 ===ba===
20759 ===bb===
20760 ====bba====
20761 ===bc===
20762 ==c==
20763 ===ca===
20764 !! end
20765
20766 !! test
20767 Section replacement test (section 1)
20768 !! options
20769 replace=1,"xxx"
20770 !! wikitext
20771 start
20772 ==a==
20773 ===aa===
20774 ====aaa====
20775 ==b==
20776 ===ba===
20777 ===bb===
20778 ====bba====
20779 ===bc===
20780 ==c==
20781 ===ca===
20782 !! html/php
20783 start
20784 xxx
20785
20786 ==b==
20787 ===ba===
20788 ===bb===
20789 ====bba====
20790 ===bc===
20791 ==c==
20792 ===ca===
20793 !! end
20794
20795 !! test
20796 Section replacement test (section 2)
20797 !! options
20798 replace=2,"xxx"
20799 !! wikitext
20800 start
20801 ==a==
20802 ===aa===
20803 ====aaa====
20804 ==b==
20805 ===ba===
20806 ===bb===
20807 ====bba====
20808 ===bc===
20809 ==c==
20810 ===ca===
20811 !! html/php
20812 start
20813 ==a==
20814 xxx
20815
20816 ==b==
20817 ===ba===
20818 ===bb===
20819 ====bba====
20820 ===bc===
20821 ==c==
20822 ===ca===
20823 !! end
20824
20825 !! test
20826 Section replacement test (section 3)
20827 !! options
20828 replace=3,"xxx"
20829 !! wikitext
20830 start
20831 ==a==
20832 ===aa===
20833 ====aaa====
20834 ==b==
20835 ===ba===
20836 ===bb===
20837 ====bba====
20838 ===bc===
20839 ==c==
20840 ===ca===
20841 !! html/php
20842 start
20843 ==a==
20844 ===aa===
20845 xxx
20846
20847 ==b==
20848 ===ba===
20849 ===bb===
20850 ====bba====
20851 ===bc===
20852 ==c==
20853 ===ca===
20854 !! end
20855
20856 !! test
20857 Section replacement test (section 4)
20858 !! options
20859 replace=4,"xxx"
20860 !! wikitext
20861 start
20862 ==a==
20863 ===aa===
20864 ====aaa====
20865 ==b==
20866 ===ba===
20867 ===bb===
20868 ====bba====
20869 ===bc===
20870 ==c==
20871 ===ca===
20872 !! html/php
20873 start
20874 ==a==
20875 ===aa===
20876 ====aaa====
20877 xxx
20878
20879 ==c==
20880 ===ca===
20881 !! end
20882
20883 !! test
20884 Section replacement test (section 5)
20885 !! options
20886 replace=5,"xxx"
20887 !! wikitext
20888 start
20889 ==a==
20890 ===aa===
20891 ====aaa====
20892 ==b==
20893 ===ba===
20894 ===bb===
20895 ====bba====
20896 ===bc===
20897 ==c==
20898 ===ca===
20899 !! html/php
20900 start
20901 ==a==
20902 ===aa===
20903 ====aaa====
20904 ==b==
20905 xxx
20906
20907 ===bb===
20908 ====bba====
20909 ===bc===
20910 ==c==
20911 ===ca===
20912 !! end
20913
20914 !! test
20915 Section replacement test (section 6)
20916 !! options
20917 replace=6,"xxx"
20918 !! wikitext
20919 start
20920 ==a==
20921 ===aa===
20922 ====aaa====
20923 ==b==
20924 ===ba===
20925 ===bb===
20926 ====bba====
20927 ===bc===
20928 ==c==
20929 ===ca===
20930 !! html/php
20931 start
20932 ==a==
20933 ===aa===
20934 ====aaa====
20935 ==b==
20936 ===ba===
20937 xxx
20938
20939 ===bc===
20940 ==c==
20941 ===ca===
20942 !! end
20943
20944 !! test
20945 Section replacement test (section 7)
20946 !! options
20947 replace=7,"xxx"
20948 !! wikitext
20949 start
20950 ==a==
20951 ===aa===
20952 ====aaa====
20953 ==b==
20954 ===ba===
20955 ===bb===
20956 ====bba====
20957 ===bc===
20958 ==c==
20959 ===ca===
20960 !! html/php
20961 start
20962 ==a==
20963 ===aa===
20964 ====aaa====
20965 ==b==
20966 ===ba===
20967 ===bb===
20968 xxx
20969
20970 ===bc===
20971 ==c==
20972 ===ca===
20973 !! end
20974
20975 !! test
20976 Section replacement test (section 8)
20977 !! options
20978 replace=8,"xxx"
20979 !! wikitext
20980 start
20981 ==a==
20982 ===aa===
20983 ====aaa====
20984 ==b==
20985 ===ba===
20986 ===bb===
20987 ====bba====
20988 ===bc===
20989 ==c==
20990 ===ca===
20991 !! html/php
20992 start
20993 ==a==
20994 ===aa===
20995 ====aaa====
20996 ==b==
20997 ===ba===
20998 ===bb===
20999 ====bba====
21000 xxx
21001
21002 ==c==
21003 ===ca===
21004 !!end
21005
21006 !! test
21007 Section replacement test (section 9)
21008 !! options
21009 replace=9,"xxx"
21010 !! wikitext
21011 start
21012 ==a==
21013 ===aa===
21014 ====aaa====
21015 ==b==
21016 ===ba===
21017 ===bb===
21018 ====bba====
21019 ===bc===
21020 ==c==
21021 ===ca===
21022 !! html/php
21023 start
21024 ==a==
21025 ===aa===
21026 ====aaa====
21027 ==b==
21028 ===ba===
21029 ===bb===
21030 ====bba====
21031 ===bc===
21032 xxx
21033 !! end
21034
21035 !! test
21036 Section replacement test (section 10)
21037 !! options
21038 replace=10,"xxx"
21039 !! wikitext
21040 start
21041 ==a==
21042 ===aa===
21043 ====aaa====
21044 ==b==
21045 ===ba===
21046 ===bb===
21047 ====bba====
21048 ===bc===
21049 ==c==
21050 ===ca===
21051 !! html/php
21052 start
21053 ==a==
21054 ===aa===
21055 ====aaa====
21056 ==b==
21057 ===ba===
21058 ===bb===
21059 ====bba====
21060 ===bc===
21061 ==c==
21062 xxx
21063 !! end
21064
21065 !! test
21066 Section replacement test with initial whitespace (T15728)
21067 !! options
21068 replace=2,"xxx"
21069 !! wikitext
21070 Preformatted initial line
21071 ==a==
21072 ===a===
21073 !! html/php
21074 Preformatted initial line
21075 ==a==
21076 xxx
21077 !! end
21078
21079
21080 !! test
21081 Section extraction, heading followed by pre with 20 spaces (T8398)
21082 !! options
21083 section=1
21084 !! wikitext
21085 ==a==
21086 a
21087 !! html/php
21088 ==a==
21089 a
21090 !! end
21091
21092 !! test
21093 Section extraction, heading followed by pre with 19 spaces (T8398 sanity check)
21094 !! options
21095 section=1
21096 !! wikitext
21097 ==a==
21098 a
21099 !! html/php
21100 ==a==
21101 a
21102 !! end
21103
21104
21105 !! test
21106 Section extraction, <pre> around bogus header (T12309)
21107 !! options
21108 section=2
21109 !! wikitext
21110 == Section One ==
21111 <pre>
21112 =======
21113 </pre>
21114
21115 == Section Two ==
21116 stuff
21117 !! html/php
21118 == Section Two ==
21119 stuff
21120 !! end
21121
21122 !! test
21123 Section replacement, <pre> around bogus header (T12309)
21124 !! options
21125 replace=2,"xxx"
21126 !! wikitext
21127 == Section One ==
21128 <pre>
21129 =======
21130 </pre>
21131
21132 == Section Two ==
21133 stuff
21134 !! html/php
21135 == Section One ==
21136 <pre>
21137 =======
21138 </pre>
21139
21140 xxx
21141 !! end
21142
21143 !! test
21144 Handling of &#x0A; in URLs
21145 !! wikitext
21146 *irc://&#x0A;a
21147 !! html/php
21148 <ul><li><a rel="nofollow" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul>
21149
21150 !! html/parsoid
21151 <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>
21152 !! end
21153
21154 !! test
21155 Handling of %0A in URLs
21156 !! wikitext
21157 *irc://%0Aa
21158 !! html/php
21159 <ul><li><a rel="nofollow" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul>
21160
21161 !! html/parsoid
21162 <ul><li><a rel="mw:ExtLink" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul>
21163 !! end
21164
21165 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
21166 !! test
21167 5 quotes, code coverage +1 line
21168 !! options
21169 parsoid=wt2html
21170 !! wikitext
21171 '''''
21172 !! html/php
21173 !! html/parsoid
21174 <p><b><i></i></b></p>
21175 !! end
21176
21177 # same html as previous, but wikitext adjusted to match parsoid html2wt
21178 # note that wt2html and html2html will put the <i> before the <b>
21179 !! test
21180 5 quotes, code coverage +1 line w/ nowiki (1)
21181 !! options
21182 parsoid=wt2wt,html2wt
21183 !! wikitext
21184 '''''<nowiki/>'''''
21185 !! html/php
21186 <p><i></i>
21187 </p>
21188 !! html/parsoid
21189 <p><b><i></i></b></p>
21190 !! end
21191
21192 # same as previous, just swapping the <i> and <b>
21193 !! test
21194 5 quotes, code coverage +1 line w/ nowiki (2)
21195 !! wikitext
21196 '''''<nowiki/>'''''
21197 !! html/php
21198 <p><i></i>
21199 </p>
21200 !! html/parsoid
21201 <p><i><b></b></i></p>
21202 !! end
21203
21204 !! test
21205 Special:Search page linking.
21206 !! wikitext
21207 {{Special:search}}
21208 !! html
21209 <p><a href="/wiki/Special:Search" title="Special:Search">Special:Search</a>
21210 </p>
21211 !! end
21212
21213 !! test
21214 {{!}} is a magic word
21215 !! wikitext
21216 {{!}} is a magic word there and {{!}} is still a magic word here
21217 | is not a magic word here but {{!}} is still a magic word here
21218 !! html/php
21219 <p>| is a magic word there and | is still a magic word here
21220 | is not a magic word here but | is still a magic word here
21221 </p>
21222 !! html/parsoid
21223 <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
21224 | 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>
21225 !! end
21226
21227 !! test
21228 Say the magic word
21229 !! options
21230 title=[[Parser test]]
21231 !! wikitext
21232 *{{PAGENAME}}
21233 *{{PAGENAMEE}}
21234 *{{FULLPAGENAME}}
21235 *{{FULLPAGENAMEE}}
21236 *{{BASEPAGENAME}}
21237 *{{BASEPAGENAMEE}}
21238 *{{SUBPAGENAME}}
21239 *{{SUBPAGENAMEE}}
21240 *{{ROOTPAGENAME}}
21241 *{{ROOTPAGENAMEE}}
21242 *{{TALKPAGENAME}}
21243 *{{TALKPAGENAMEE}}
21244 *{{SUBJECTPAGENAME}}
21245 *{{SUBJECTPAGENAMEE}}
21246 *{{NAMESPACEE}}
21247 *{{NAMESPACE}}
21248 *{{NAMESPACENUMBER}}
21249 *{{TALKSPACE}}
21250 *{{TALKSPACEE}}
21251 *{{SUBJECTSPACE}}
21252 *{{SUBJECTSPACEE}}
21253 *{{Dynamic|{{NUMBEROFUSERS}}|{{NUMBEROFPAGES}}|{{CURRENTVERSION}}|{{CONTENTLANGUAGE}}|{{DIRECTIONMARK}}|{{CURRENTTIMESTAMP}}|{{NUMBEROFARTICLES}}}}
21254 !! html
21255 <ul><li>Parser test</li>
21256 <li>Parser_test</li>
21257 <li>Parser test</li>
21258 <li>Parser_test</li>
21259 <li>Parser test</li>
21260 <li>Parser_test</li>
21261 <li>Parser test</li>
21262 <li>Parser_test</li>
21263 <li>Parser test</li>
21264 <li>Parser_test</li>
21265 <li>Talk:Parser test</li>
21266 <li>Talk:Parser_test</li>
21267 <li>Parser test</li>
21268 <li>Parser_test</li>
21269 <li></li>
21270 <li></li>
21271 <li>0</li>
21272 <li>Talk</li>
21273 <li>Talk</li>
21274 <li></li>
21275 <li></li>
21276 <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>
21277
21278 !! end
21279 ### Note: Above tests excludes the "{{NUMBEROFADMINS}}" magic word because it generates a MySQL error when included.
21280
21281 !! test
21282 Gallery with valid attributes
21283 !! wikitext
21284 <gallery type="123" summary="345">
21285 File:File:Foobar.jpg
21286 </gallery>
21287 !! html/php
21288 <ul class="gallery mw-gallery-traditional" type="123">
21289 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21290 <div class="thumb" style="height: 150px;">File:Foobar.jpg</div>
21291 <div class="gallerytext">
21292 </div>
21293 </div></li>
21294 </ul>
21295
21296 !! html/parsoid
21297 <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"}}'>
21298 <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>
21299 </ul>
21300 !! end
21301
21302 ## Parsoid thinks the "centre" here is a property, not a caption.
21303 !! test
21304 Gallery
21305 !! options
21306 parsoid={
21307 "modes": ["wt2html"],
21308 "nativeGallery": true
21309 }
21310 !! wikitext
21311 <gallery>
21312 image1.png |
21313 image2.gif|||||
21314
21315 image3|
21316 image4 |300px| centre
21317 image5.svg| http://///////
21318 [[x|xx]]]]
21319 * image6
21320 </gallery>
21321 !! html/php
21322 <ul class="gallery mw-gallery-traditional">
21323 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21324 <div class="thumb" style="height: 150px;">Image1.png</div>
21325 <div class="gallerytext">
21326 </div>
21327 </div></li>
21328 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21329 <div class="thumb" style="height: 150px;">Image2.gif</div>
21330 <div class="gallerytext">
21331 </div>
21332 </div></li>
21333 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21334 <div class="thumb" style="height: 150px;">Image3</div>
21335 <div class="gallerytext">
21336 </div>
21337 </div></li>
21338 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21339 <div class="thumb" style="height: 150px;">Image4</div>
21340 <div class="gallerytext">
21341 <pre>centre
21342 </pre>
21343 </div>
21344 </div></li>
21345 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21346 <div class="thumb" style="height: 150px;">Image5.svg</div>
21347 <div class="gallerytext">
21348 <p><a rel="nofollow" class="external free" href="http://///////">http://///////</a>
21349 </p>
21350 </div>
21351 </div></li>
21352 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21353 <div class="thumb" style="height: 150px;">* image6</div>
21354 <div class="gallerytext">
21355 </div>
21356 </div></li>
21357 </ul>
21358
21359 !! html/parsoid
21360 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21361 <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>
21362 <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>
21363 <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>
21364 <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>
21365 <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>
21366 <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>
21367 </ul>
21368 !! end
21369
21370 !! test
21371 Gallery (with options, html)
21372 !! options
21373 parsoid={
21374 "modes": ["wt2html", "html2html"],
21375 "nativeGallery": true
21376 }
21377 !! wikitext
21378 <gallery widths="70px" heights="40px" perrow="2" caption="Foo [[Main Page]]">
21379 File:Nonexistent.jpg|caption
21380 File:Nonexistent.jpg
21381 image:foobar.jpg|some '''caption''' [[Main Page]]
21382 image:foobar.jpg
21383 image:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla.
21384 </gallery>
21385 !! html/php
21386 <ul class="gallery mw-gallery-traditional" style="max-width: 226px;_width: 226px;">
21387 <li class='gallerycaption'>Foo <a href="/wiki/Main_Page" title="Main Page">Main Page</a></li>
21388 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21389 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
21390 <div class="gallerytext">
21391 <p>caption
21392 </p>
21393 </div>
21394 </div></li>
21395 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21396 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
21397 <div class="gallerytext">
21398 </div>
21399 </div></li>
21400 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21401 <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>
21402 <div class="gallerytext">
21403 <p>some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
21404 </p>
21405 </div>
21406 </div></li>
21407 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21408 <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>
21409 <div class="gallerytext">
21410 </div>
21411 </div></li>
21412 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21413 <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>
21414 <div class="gallerytext">
21415 <p>blabla.
21416 </p>
21417 </div>
21418 </div></li>
21419 </ul>
21420
21421 !! html/parsoid
21422 <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":{}}'>
21423 <li class="gallerycaption">Foo <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></li>
21424 <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>
21425 <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>
21426 <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>
21427 <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>
21428 <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>
21429 </ul>
21430 !! end
21431
21432 !! test
21433 Gallery (with options, extsrc)
21434 !! options
21435 parsoid={
21436 "nativeGallery": false
21437 }
21438 !! wikitext
21439 <gallery widths="70px" heights="40px" perrow="2" caption="Foo [[Main Page]]">
21440 File:Nonexistent.jpg|caption
21441 File:Nonexistent.jpg
21442 image:foobar.jpg|some '''caption''' [[Main Page]]
21443 image:foobar.jpg
21444 image:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla.
21445 </gallery>
21446 !! html/php
21447 <ul class="gallery mw-gallery-traditional" style="max-width: 226px;_width: 226px;">
21448 <li class='gallerycaption'>Foo <a href="/wiki/Main_Page" title="Main Page">Main Page</a></li>
21449 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21450 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
21451 <div class="gallerytext">
21452 <p>caption
21453 </p>
21454 </div>
21455 </div></li>
21456 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21457 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
21458 <div class="gallerytext">
21459 </div>
21460 </div></li>
21461 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21462 <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>
21463 <div class="gallerytext">
21464 <p>some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
21465 </p>
21466 </div>
21467 </div></li>
21468 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21469 <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>
21470 <div class="gallerytext">
21471 </div>
21472 </div></li>
21473 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21474 <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>
21475 <div class="gallerytext">
21476 <p>blabla.
21477 </p>
21478 </div>
21479 </div></li>
21480 </ul>
21481
21482 !! html/parsoid
21483 <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"}}'>
21484 <li class="gallerycaption">Foo <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></li>
21485 <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>
21486 <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>
21487 <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>
21488 <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>
21489 <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>
21490 </ul>
21491 !! end
21492
21493 !! test
21494 Gallery (without px units)
21495 !! wikitext
21496 <gallery widths="70" heights="40">
21497 File:Foobar.jpg
21498 </gallery>
21499 !! html/php
21500 <ul class="gallery mw-gallery-traditional">
21501 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21502 <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>
21503 <div class="gallerytext">
21504 </div>
21505 </div></li>
21506 </ul>
21507
21508 !! html/parsoid
21509 <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"}}'>
21510 <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>
21511 </ul>
21512 !! end
21513
21514 !! test
21515 Gallery (with invalid units)
21516 !! wikitext
21517 <gallery widths="70em" heights="40em">
21518 File:Foobar.jpg
21519 </gallery>
21520 !! html/php
21521 <ul class="gallery mw-gallery-traditional">
21522 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21523 <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>
21524 <div class="gallerytext">
21525 </div>
21526 </div></li>
21527 </ul>
21528
21529 !! html/parsoid
21530 <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"}}'>
21531 <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>
21532 </ul>
21533 !! end
21534
21535 !! test
21536 Gallery with link that has fragment
21537 !! options
21538 parsoid={
21539 "modes": ["wt2html", "html2html"],
21540 "nativeGallery": true
21541 }
21542 !! wikitext
21543 <gallery>
21544 image:foobar.jpg|link=Main_Page
21545 image:foobar.jpg|link=Main_Page#section
21546 image:foobar.jpg|link=Main Page#section|caption
21547 </gallery>
21548 !! html/php
21549 <ul class="gallery mw-gallery-traditional">
21550 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21551 <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>
21552 <div class="gallerytext">
21553 </div>
21554 </div></li>
21555 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21556 <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>
21557 <div class="gallerytext">
21558 </div>
21559 </div></li>
21560 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21561 <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>
21562 <div class="gallerytext">
21563 <p>caption
21564 </p>
21565 </div>
21566 </div></li>
21567 </ul>
21568
21569 !! html/parsoid
21570 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21571 <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>
21572 <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>
21573 <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>
21574 </ul>
21575 !! end
21576
21577 !! test
21578 Gallery with template inside caption
21579 !! options
21580 parsoid={
21581 "nativeGallery": true
21582 }
21583 !! wikitext
21584 <gallery caption="{{echo|hi}}">
21585 File:Foobar.jpg|{{echo|ho}}
21586 </gallery>
21587 !! html/php
21588 <ul class="gallery mw-gallery-traditional">
21589 <li class='gallerycaption'>hi</li>
21590 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21591 <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>
21592 <div class="gallerytext">
21593 <p>ho
21594 </p>
21595 </div>
21596 </div></li>
21597 </ul>
21598
21599 !! html/parsoid
21600 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt6" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21601 <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>
21602 <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>
21603 </ul>
21604 !! end
21605
21606 !! test
21607 Gallery with wikitext inside gallery caption
21608 !! wikitext
21609 <gallery caption="# List item
21610
21611 Text '''bold''' [[link]] {{ns:-1}}
21612
21613 [[File:Foobar.jpg|thumb|File in gallery caption]]">
21614 File:Foobar.jpg|Image caption
21615 </gallery>
21616 !! html/php
21617 <ul class="gallery mw-gallery-traditional">
21618 <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>
21619 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21620 <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>
21621 <div class="gallerytext">
21622 <p>Image caption
21623 </p>
21624 </div>
21625 </div></li>
21626 </ul>
21627
21628 !! end
21629
21630 !! test
21631 Gallery with wikitext inside caption
21632 !! options
21633 parsoid={
21634 "nativeGallery": true
21635 }
21636 !! wikitext
21637 <gallery>
21638 File:Foobar.jpg|alt=galleryalt|[[File:Foobar.jpg|alt=inneralt|20x20px|desc]]
21639 File:Foobar.jpg|alt=galleryalt|{{Test|unamedParam|alt=param}}
21640 </gallery>
21641 !! html/php
21642 <ul class="gallery mw-gallery-traditional">
21643 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21644 <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>
21645 <div class="gallerytext">
21646 <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>
21647 </p>
21648 </div>
21649 </div></li>
21650 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21651 <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>
21652 <div class="gallerytext">
21653 <p>This is a test template
21654 </p>
21655 </div>
21656 </div></li>
21657 </ul>
21658
21659 !! html/parsoid
21660 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt6" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21661 <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>
21662 <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>
21663 </ul>
21664 !! end
21665
21666 !! test
21667 Gallery (with showfilename option)
21668 !! options
21669 parsoid={
21670 "nativeGallery": true
21671 }
21672 !! wikitext
21673 <gallery showfilename="">
21674 File:Nonexistent.jpg|caption
21675 File:Nonexistent.jpg
21676 File:Foobar.jpg|some '''caption''' [[Main Page]]
21677 File:Foobar.jpg
21678 </gallery>
21679 !! html/php
21680 <ul class="gallery mw-gallery-traditional">
21681 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21682 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
21683 <div class="gallerytext">
21684 <p><a href="/wiki/File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">Nonexistent.jpg</a>
21685 caption
21686 </p>
21687 </div>
21688 </div></li>
21689 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21690 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
21691 <div class="gallerytext">
21692 <p><a href="/wiki/File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">Nonexistent.jpg</a>
21693 </p>
21694 </div>
21695 </div></li>
21696 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21697 <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>
21698 <div class="gallerytext">
21699 <p><a href="/wiki/File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">Foobar.jpg</a>
21700 some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
21701 </p>
21702 </div>
21703 </div></li>
21704 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21705 <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>
21706 <div class="gallerytext">
21707 <p><a href="/wiki/File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">Foobar.jpg</a>
21708 </p>
21709 </div>
21710 </div></li>
21711 </ul>
21712
21713 !! html/parsoid
21714 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{"showfilename":""},"body":{}}'>
21715 <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>
21716 <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>
21717 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline typeof="mw:Image"><a href="./File:Foobar.jpg"><img 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>
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 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>
21719 </ul>
21720 !! end
21721
21722 ## Should Parsoid be preserving these variations? See T151367
21723 !! test
21724 Gallery (with namespace-less filenames)
21725 !! options
21726 parsoid={
21727 "modes": ["wt2html", "html2html"],
21728 "nativeGallery": true
21729 }
21730 !! wikitext
21731 <gallery>
21732 File:Nonexistent.jpg
21733 Nonexistent.jpg
21734 image:foobar.jpg
21735 foobar.jpg
21736 </gallery>
21737 !! html/php
21738 <ul class="gallery mw-gallery-traditional">
21739 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21740 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
21741 <div class="gallerytext">
21742 </div>
21743 </div></li>
21744 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21745 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
21746 <div class="gallerytext">
21747 </div>
21748 </div></li>
21749 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21750 <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>
21751 <div class="gallerytext">
21752 </div>
21753 </div></li>
21754 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21755 <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>
21756 <div class="gallerytext">
21757 </div>
21758 </div></li>
21759 </ul>
21760
21761 !! html/parsoid
21762 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21763 <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>
21764 <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>
21765 <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>
21766 <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>
21767 </ul>
21768 !! end
21769
21770 !! test
21771 Gallery override link with wikilink (T36852)
21772 !! options
21773 parsoid={
21774 "nativeGallery": true
21775 }
21776 !! wikitext
21777 <gallery>
21778 File:Foobar.jpg|alt=galleryalt|link=Wikilink
21779 </gallery>
21780 !! html/php
21781 <ul class="gallery mw-gallery-traditional">
21782 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21783 <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>
21784 <div class="gallerytext">
21785 </div>
21786 </div></li>
21787 </ul>
21788
21789 !! html/parsoid
21790 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21791 <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>
21792 </ul>
21793 !! end
21794
21795 !! test
21796 Gallery override link with absolute external link (T36852)
21797 !! options
21798 parsoid={
21799 "nativeGallery": true
21800 }
21801 !! wikitext
21802 <gallery>
21803 File:Foobar.jpg|alt=galleryalt|link=http://www.example.org
21804 </gallery>
21805 !! html/php
21806 <ul class="gallery mw-gallery-traditional">
21807 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21808 <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>
21809 <div class="gallerytext">
21810 </div>
21811 </div></li>
21812 </ul>
21813
21814 !! html/parsoid
21815 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21816 <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>
21817 </ul>
21818 !! end
21819
21820 !! test
21821 Gallery override link with absolute external link with LanguageConverter
21822 !! options
21823 language=zh
21824 !! wikitext
21825 <gallery>
21826 File:foobar.jpg|caption|alt=galleryalt|link=http://www.example.org
21827 </gallery>
21828 !! html/php
21829 <ul class="gallery mw-gallery-traditional">
21830 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21831 <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>
21832 <div class="gallerytext">
21833 <p>caption
21834 </p>
21835 </div>
21836 </div></li>
21837 </ul>
21838
21839 !! html/parsoid
21840 <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"}}'>
21841 <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>
21842 </ul>
21843 !! end
21844
21845 !! test
21846 Gallery override link with malicious javascript (T36852)
21847 !! options
21848 parsoid={
21849 "modes": ["wt2html", "html2html"],
21850 "nativeGallery": true
21851 }
21852 !! wikitext
21853 <gallery>
21854 File:Foobar.jpg|alt=galleryalt|link=" onclick="alert('malicious javascript code!');
21855 </gallery>
21856 !! html/php
21857 <ul class="gallery mw-gallery-traditional">
21858 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21859 <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>
21860 <div class="gallerytext">
21861 </div>
21862 </div></li>
21863 </ul>
21864
21865 !! html/parsoid
21866 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21867 <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>
21868 </ul>
21869 !! end
21870
21871 # Note that parsoid uses the invalid link as a caption, PHP does not.
21872 !! test
21873 Gallery with invalid title as link (T45964)
21874 !! options
21875 parsoid={
21876 "modes": ["wt2html", "html2html"],
21877 "nativeGallery": true
21878 }
21879 !! wikitext
21880 <gallery>
21881 File:Foobar.jpg|link=<
21882 </gallery>
21883 !! html/php
21884 <ul class="gallery mw-gallery-traditional">
21885 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21886 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/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>
21887 <div class="gallerytext">
21888 </div>
21889 </div></li>
21890 </ul>
21891
21892 !! html/parsoid
21893 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21894 <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>
21895 </ul>
21896 !! end
21897
21898 !! test
21899 Serialize gallery without attrs in data-mw
21900 !! options
21901 parsoid={
21902 "modes": ["html2wt"],
21903 "nativeGallery": true
21904 }
21905 !! html/parsoid
21906 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","body":{}}'>
21907 <li class="gallerycaption">123</li>
21908 <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>
21909 </ul>
21910 !! wikitext
21911 <gallery caption="123">
21912 File:Test.png
21913 </gallery>
21914 !! end
21915
21916 !! test
21917 Gallery with class and style attributes
21918 !! options
21919 parsoid={
21920 "nativeGallery": true
21921 }
21922 !! wikitext
21923 <gallery class="center" style="text-align: center;">
21924 File:Foobar.jpg
21925 </gallery>
21926 !! html/php
21927 <ul class="gallery mw-gallery-traditional center" style="text-align: center;">
21928 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21929 <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>
21930 <div class="gallerytext">
21931 </div>
21932 </div></li>
21933 </ul>
21934
21935 !! html/parsoid
21936 <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":{}}'>
21937 <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>
21938 </ul>
21939 !! end
21940
21941 !! test
21942 Gallery in slideshow mode
21943 !! options
21944 parsoid={
21945 "nativeGallery": true
21946 }
21947 !! wikitext
21948 <gallery mode="slideshow" showthumbnails="">
21949 File:Foobar.jpg
21950 </gallery>
21951 !! html/php
21952 <ul class="gallery mw-gallery-slideshow" data-showthumbnails="1">
21953 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21954 <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>
21955 <div class="gallerytext">
21956 </div>
21957 </div></li>
21958 </ul>
21959
21960 !! html/parsoid
21961 <ul class="gallery mw-gallery-slideshow" data-showthumbnails="1" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{"mode":"slideshow","showthumbnails":""},"body":{}}'>
21962 <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>
21963 </ul>
21964 !! end
21965
21966 !! test
21967 Serialize gallery image captions on a line
21968 !! options
21969 parsoid={
21970 "modes": ["html2wt"],
21971 "nativeGallery": true
21972 }
21973 !! html/parsoid
21974 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21975 <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>
21976 <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>
21977 </ul>
21978 !! wikitext
21979 <gallery>
21980 File:Foobar.jpg| hi ho
21981 File:Foobar.jpg|hi<br />ho
21982 </gallery>
21983 !! end
21984
21985 !! test
21986 HTML Hex character encoding (spells the word "JavaScript")
21987 !! options
21988 parsoid=wt2html,wt2wt,html2html
21989 !! wikitext
21990 &#x4A;&#x061;&#x0076;&#x00061;&#x000053;&#x0000063;&#114;&#x0000069;&#00000112;&#x0000000074;
21991 !! html/php
21992 <p>&#x4a;&#x61;&#x76;&#x61;&#x53;&#x63;&#114;&#x69;&#112;&#x74;
21993 </p>
21994 !! html/parsoid
21995 <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>
21996 !! end
21997
21998 !! test
21999 HTML Hex character encoding bogus encoding (T28437 regression check)
22000 !! wikitext
22001 &#xsee;&#XSEE;
22002 !! html
22003 <p>&amp;#xsee;&amp;#XSEE;
22004 </p>
22005 !! end
22006
22007 !! test
22008 HTML Hex character encoding mixed case
22009 !! options
22010 parsoid=wt2html,wt2wt,html2html
22011 !! wikitext
22012 &#xEE;&#Xee;
22013 !! html/php
22014 <p>&#xee;&#xee;
22015 </p>
22016 !! html/parsoid
22017 <p><span typeof="mw:Entity">î</span><span typeof="mw:Entity">î</span></p>
22018 !! end
22019
22020 # See: https://www.w3.org/TR/html5/syntax.html#character-references
22021 # Note that U+000C (form feed) is not a valid XML character, so
22022 # it is banned even though allowed in HTML5.
22023 !! test
22024 Illegal character references (T106578)
22025 !! wikitext
22026 ; Null: &#00;
22027 ; FF: &#xC;
22028 ; CR: &#xD;
22029 ; Control (low): &#8;
22030 ; Control (high): &#x7F; &#x9F;
22031 ; Surrogate: &#xD83D;&#xDCA9;
22032 ; This is an okay astral character: &#x1F4A9;
22033 !! html+tidy
22034 <dl><dt>Null</dt>
22035 <dd>&amp;#00;</dd>
22036 <dt>FF</dt>
22037 <dd>&amp;#xC;</dd>
22038 <dt>CR</dt>
22039 <dd>&amp;#xD;</dd>
22040 <dt>Control (low)</dt>
22041 <dd>&amp;#8;</dd>
22042 <dt>Control (high)</dt>
22043 <dd>&amp;#x7F; &amp;#x9F;</dd>
22044 <dt>Surrogate</dt>
22045 <dd>&amp;#xD83D;&amp;#xDCA9;</dd>
22046 <dt>This is an okay astral character</dt>
22047 <dd>&#x1f4a9;</dd></dl>
22048 !! end
22049
22050 !! test
22051 __FORCETOC__ override
22052 !! wikitext
22053 __NEWSECTIONLINK__
22054 __FORCETOC__
22055 !! html/php
22056 <p><br />
22057 </p>
22058 !! end
22059
22060 !! test
22061 ISBN code coverage
22062 !! wikitext
22063 ISBN 978-0-1234-56&#x20;789
22064 !! html/php
22065 <p><a href="/wiki/Special:BookSources/9780123456" class="internal mw-magiclink-isbn">ISBN 978-0-1234-56</a>&#x20;789
22066 </p>
22067 !! html/parsoid
22068 <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>
22069 !! end
22070
22071 !! test
22072 ISBN followed by 5 spaces
22073 !! wikitext
22074 ISBN
22075 !! html
22076 <p>ISBN
22077 </p>
22078 !! end
22079
22080 !! test
22081 Double ISBN
22082 !! wikitext
22083 ISBN ISBN 1234567890
22084 !! html/php
22085 <p>ISBN <a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
22086 </p>
22087 !! html/parsoid
22088 <p>ISBN <a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a></p>
22089 !! end
22090
22091 # Uppercase X and lowercase x as well
22092 !! test
22093 ISBN with an X
22094 !! wikitext
22095 ISBN 3-462-04561-X
22096 ISBN 3-462-04561-x
22097 ISBN 080442957X
22098 ISBN 080442957x
22099 ISBN 978080442957X
22100 ISBN 978080442957x
22101 !! html/php
22102 <p><a href="/wiki/Special:BookSources/346204561X" class="internal mw-magiclink-isbn">ISBN 3-462-04561-X</a>
22103 <a href="/wiki/Special:BookSources/346204561X" class="internal mw-magiclink-isbn">ISBN 3-462-04561-x</a>
22104 <a href="/wiki/Special:BookSources/080442957X" class="internal mw-magiclink-isbn">ISBN 080442957X</a>
22105 <a href="/wiki/Special:BookSources/080442957X" class="internal mw-magiclink-isbn">ISBN 080442957x</a>
22106 <a href="/wiki/Special:BookSources/978080442957X" class="internal mw-magiclink-isbn">ISBN 978080442957X</a>
22107 <a href="/wiki/Special:BookSources/978080442957X" class="internal mw-magiclink-isbn">ISBN 978080442957x</a>
22108 </p>
22109 !! html/parsoid
22110 <p><a href="./Special:BookSources/346204561X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 3-462-04561-X</a>
22111 <a href="./Special:BookSources/346204561X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 3-462-04561-x</a>
22112 <a href="./Special:BookSources/080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 080442957X</a>
22113 <a href="./Special:BookSources/080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 080442957x</a>
22114 <a href="./Special:BookSources/978080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978080442957X</a>
22115 <a href="./Special:BookSources/978080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978080442957x</a></p>
22116 !! end
22117
22118 !! test
22119 ISBN with empty prefix (parsoid test)
22120 !! wikitext
22121 ISBN 1234567890
22122 !! html/php
22123 <p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
22124 </p>
22125 !! html/parsoid
22126 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink">ISBN 1234567890</a></p>
22127 !! end
22128
22129 !! test
22130 T24905: <abbr> followed by ISBN followed by </a>
22131 !! wikitext
22132 <abbr>(fr)</abbr> ISBN 2753300917 [http://www.example.com example.com]
22133 !! html/php
22134 <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>
22135 </p>
22136 !! html/parsoid
22137 <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>
22138 !! end
22139
22140 !! test
22141 Double RFC
22142 !! wikitext
22143 RFC RFC 1234
22144 !! html/php
22145 <p>RFC <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc1234">RFC 1234</a>
22146 </p>
22147 !! html/parsoid
22148 <p>RFC <a href="https://tools.ietf.org/html/rfc1234" rel="mw:ExtLink" class="external mw-magiclink">RFC 1234</a></p>
22149 !! end
22150
22151 !! test
22152 Double RFC with a wiki link
22153 !! wikitext
22154 RFC [[RFC 1234]]
22155 !! html/php
22156 <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>
22157 </p>
22158 !! html/parsoid
22159 <p>RFC <a rel="mw:WikiLink" href="./RFC_1234" title="RFC 1234">RFC 1234</a></p>
22160 !! end
22161
22162 !! test
22163 RFC code coverage
22164 !! wikitext
22165 RFC 983&#x20;987
22166 !! html/php
22167 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc983">RFC 983</a>&#x20;987
22168 </p>
22169 !! html/parsoid
22170 <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>
22171 !! end
22172
22173 !! test
22174 Centre-aligned image
22175 !! wikitext
22176 [[Image:foobar.jpg|centre]]
22177 !! html/php
22178 <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>
22179
22180 !! html/parsoid
22181 <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>
22182 !! end
22183
22184 !! test
22185 None-aligned image
22186 !! wikitext
22187 [[Image:foobar.jpg|none]]
22188 !! html/php
22189 <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>
22190
22191 !! html/parsoid
22192 <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>
22193 !! end
22194
22195 !! test
22196 Width + Height sized image (using px) (height is ignored)
22197 !! wikitext
22198 [[Image:foobar.jpg|640x480px]]
22199 !! html/php
22200 <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>
22201 </p>
22202 !! html/parsoid
22203 <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>
22204 !! end
22205
22206 !! test
22207 Width-sized image (using px, no following whitespace)
22208 !! wikitext
22209 [[Image:foobar.jpg|640px]]
22210 !! html/php
22211 <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>
22212 </p>
22213 !! html/parsoid
22214 <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>
22215 !! end
22216
22217 !! test
22218 Width-sized image (using px, with following whitespace - test regression from r39467)
22219 !! wikitext
22220 [[Image:foobar.jpg|640px ]]
22221 !! html/php
22222 <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>
22223 </p>
22224 !! html/parsoid
22225 <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>
22226 !!end
22227
22228 !! test
22229 Width-sized image (using px, with preceding whitespace - test regression from r39467)
22230 !! wikitext
22231 [[Image:foobar.jpg| 640px]]
22232 !! html/php
22233 <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>
22234 </p>
22235 !! html/parsoid
22236 <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>
22237 !! end
22238
22239 !! test
22240 Image with page parameter
22241 !! options
22242 djvu
22243 !! wikitext
22244 [[File:LoremIpsum.djvu|page=2]]
22245 !! html/php
22246 <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>
22247 </p>
22248 !! html/parsoid
22249 <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>
22250 !! end
22251
22252 !! test
22253 Another italics / bold test
22254 !! wikitext
22255 ''' ''x'
22256 !! html
22257 <pre>'<i> </i>x'
22258 </pre>
22259 !!end
22260
22261 # FIXME: The php output seems broken. It's interleaving some open/close tags.
22262 !! test
22263 dt/dd/dl test
22264 !! wikitext
22265 :;;;::
22266 !! html/php
22267 <dl><dd><dl><dt><dl><dt><dl><dt><dl><dd><dl><dd></dt></dl></dd></dl></dd></dl></dd></dl></dd></dl></dd></dl>
22268
22269 !! html/parsoid
22270 <dl><dd><dl><dt><dl><dt><dl><dt><dl><dd><dl><dd></dd></dl></dd></dl></dt></dl></dt></dl></dt></dl></dd></dl>
22271
22272 !!end
22273
22274 # Images with the "|" character in external URLs in comment tags; Eats half the comment, leaves unmatched "</a>" tag.
22275 !! test
22276 Images with the "|" character in the comment
22277 !! wikitext
22278 [[File:Foobar.jpg|thumb|An [http://test/?param1=|left|&param2=|x external] URL]]
22279 !! html/php
22280 <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>
22281
22282 !! html/parsoid
22283 <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>
22284 !! end
22285
22286 !! test
22287 [Before] HTML without raw HTML enabled ($wgRawHtml==false)
22288 !! wikitext
22289 <html><script>alert(1);</script></html>
22290 !! html
22291 <p>&lt;html&gt;&lt;script&gt;alert(1);&lt;/script&gt;&lt;/html&gt;
22292 </p>
22293 !! end
22294
22295 !! test
22296 HTML with raw HTML ($wgRawHtml==true)
22297 !! options
22298 wgRawHtml=1
22299 !! wikitext
22300 <html><script>alert(1);</script></html>
22301 !! html/php
22302 <p><script>alert(1);</script>
22303 </p>
22304 !! html/parsoid
22305 <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>
22306 !! end
22307
22308 !! test
22309 Parents of subpages, one level up
22310 !! options
22311 subpage title=[[Subpage test/L1/L2/L3]]
22312 !! wikitext
22313 [[../|L2]]
22314 !! html
22315 <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>
22316 </p>
22317 !! end
22318
22319
22320 !! test
22321 Parents of subpages, one level up, not named
22322 !! options
22323 subpage title=[[Subpage test/L1/L2/L3]]
22324 !! wikitext
22325 [[../]]
22326 !! html
22327 <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>
22328 </p>
22329 !! end
22330
22331
22332
22333 !! test
22334 Parents of subpages, two levels up
22335 !! options
22336 subpage title=[[Subpage test/L1/L2/L3]]
22337 !! wikitext
22338 [[../../|L1]]2
22339
22340 [[../../|L1]]l
22341 !! html
22342 <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
22343 </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>
22344 </p>
22345 !! end
22346
22347 !! test
22348 Parents of subpages, two levels up, without trailing slash or name.
22349 !! options
22350 subpage title=[[Subpage test/L1/L2/L3]]
22351 !! wikitext
22352 [[../..]]
22353 !! html
22354 <p>[[../..]]
22355 </p>
22356 !! end
22357
22358 !! test
22359 Parents of subpages, two levels up, with lots of extra trailing slashes.
22360 !! options
22361 subpage title=[[Subpage test/L1/L2/L3]]
22362 !! wikitext
22363 [[../../////]]
22364 !! html
22365 <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>
22366 </p>
22367 !! end
22368
22369 !! article
22370 Subpage test/L1/L2/L3Sibling
22371 !! text
22372 Sibling article
22373 !! endarticle
22374
22375 !! test
22376 Transclusion of a sibling page (one level up)
22377 !! options
22378 subpage title=[[Subpage test/L1/L2/L3]]
22379 !! wikitext
22380 {{../L3Sibling}}
22381 !! html
22382 <p>Sibling article
22383 </p>
22384 !! end
22385
22386 !! test
22387 Transclusion of a child page
22388 !! options
22389 subpage title=[[Subpage test/L1/L2]]
22390 !! wikitext
22391 {{/L3Sibling}}
22392 !! html
22393 <p>Sibling article
22394 </p>
22395 !! end
22396
22397 # This is wt2html only in Parsoid because we add <nowiki>
22398 # because of {{..}} and we don't expect to fix that to
22399 # eliminate the nowikis selective for {{..}} markup.
22400 !! test
22401 Non-transclusion because of too many up levels
22402 !! options
22403 subpage title=[[Subpage test/L1/L2/L3]]
22404 parsoid=wt2html
22405 !! wikitext
22406 {{../../../../More than parent}}
22407 !! html/php
22408 <p>{{../../../../More than parent}}
22409 </p>
22410 !! html/parsoid
22411 <p>{{../../../../More than parent}}</p>
22412 !! end
22413
22414 !! test
22415 Definition list code coverage
22416 !! wikitext
22417 ;title :def
22418 ;title :def
22419 ;title:def
22420 !! html/php
22421 <dl><dt>title</dt>
22422 <dd>def</dd>
22423 <dt>title</dt>
22424 <dd>def</dd>
22425 <dt>title</dt>
22426 <dd>def</dd></dl>
22427
22428 !! html/parsoid
22429 <dl><dt>title </dt><dd>def</dd>
22430 <dt>title </dt><dd>def</dd>
22431 <dt>title</dt><dd>def</dd></dl>
22432 !! end
22433
22434 !! test
22435 Don't fall for the self-closing div
22436 !! wikitext
22437 <div>hello world</div/>
22438 !! html
22439 <div>hello world</div>
22440
22441 !! end
22442
22443 !! test
22444 MSGNW magic word
22445 !! wikitext
22446 {{MSGNW:msg}}
22447 !! html/php
22448 <p>&#91;&#91;:Template:Msg&#93;&#93;
22449 </p>
22450 !! end
22451
22452 !! test
22453 RAW magic word
22454 !! wikitext
22455 {{RAW:QUERTY}}
22456 !! html
22457 <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>
22458 </p>
22459 !! end
22460
22461 # This isn't needed for XHTML conformance, but would be handy as a fallback security measure
22462 !! test
22463 Always escape literal '>' in output, not just after '<'
22464 !! wikitext
22465 ><>
22466 !! html
22467 <p>&gt;&lt;&gt;
22468 </p>
22469 !! end
22470
22471 !! test
22472 Template caching
22473 !! wikitext
22474 {{Test}}
22475 {{Test}}
22476 !! html
22477 <p>This is a test template
22478 This is a test template
22479 </p>
22480 !! end
22481
22482
22483 !! article
22484 MediaWiki:Fake
22485 !! text
22486 ==header==
22487 !! endarticle
22488
22489 !! test
22490 Inclusion of !userCanEdit() content
22491 !! wikitext
22492 {{MediaWiki:Fake}}
22493 !! html
22494 <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>
22495
22496 !! end
22497
22498
22499 !! test
22500 Out-of-order TOC heading levels
22501 !! wikitext
22502 ==2==
22503 ======6======
22504 ===3===
22505 =1=
22506 =====5=====
22507 ==2==
22508 !! html
22509 <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>
22510 <ul>
22511 <li class="toclevel-1 tocsection-1"><a href="#2"><span class="tocnumber">1</span> <span class="toctext">2</span></a>
22512 <ul>
22513 <li class="toclevel-2 tocsection-2"><a href="#6"><span class="tocnumber">1.1</span> <span class="toctext">6</span></a></li>
22514 <li class="toclevel-2 tocsection-3"><a href="#3"><span class="tocnumber">1.2</span> <span class="toctext">3</span></a></li>
22515 </ul>
22516 </li>
22517 <li class="toclevel-1 tocsection-4"><a href="#1"><span class="tocnumber">2</span> <span class="toctext">1</span></a>
22518 <ul>
22519 <li class="toclevel-2 tocsection-5"><a href="#5"><span class="tocnumber">2.1</span> <span class="toctext">5</span></a></li>
22520 <li class="toclevel-2 tocsection-6"><a href="#2_2"><span class="tocnumber">2.2</span> <span class="toctext">2</span></a></li>
22521 </ul>
22522 </li>
22523 </ul>
22524 </div>
22525
22526 <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>
22527 <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>
22528 <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>
22529 <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>
22530 <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>
22531 <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>
22532
22533 !! end
22534
22535
22536 !! test
22537 ISBN with a dummy number
22538 !! wikitext
22539 ISBN ---
22540 !! html
22541 <p>ISBN ---
22542 </p>
22543 !! end
22544
22545
22546 !! test
22547 ISBN with space-delimited number
22548 !! wikitext
22549 ISBN 92 9017 032 8
22550 !! html/php
22551 <p><a href="/wiki/Special:BookSources/9290170328" class="internal mw-magiclink-isbn">ISBN 92 9017 032 8</a>
22552 </p>
22553 !! html/parsoid
22554 <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>
22555 !! end
22556
22557
22558 !! test
22559 ISBN with multiple spaces, no number
22560 !! wikitext
22561 ISBN foo
22562 !! html
22563 <p>ISBN foo
22564 </p>
22565 !! end
22566
22567
22568 !! test
22569 ISBN length
22570 !! wikitext
22571 ISBN 123456789
22572
22573 ISBN 1234567890
22574
22575 ISBN 12345678901
22576 !! html/php
22577 <p>ISBN 123456789
22578 </p><p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
22579 </p><p>ISBN 12345678901
22580 </p>
22581 !! html/parsoid
22582 <p>ISBN 123456789</p>
22583
22584 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a></p>
22585
22586 <p>ISBN 12345678901</p>
22587 !! end
22588
22589
22590 !! test
22591 ISBN with trailing year (T9110)
22592 !! wikitext
22593 ISBN 1-234-56789-0 - 2006
22594
22595 ISBN 1 234 56789 0 - 2006
22596 !! html/php
22597 <p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1-234-56789-0</a> - 2006
22598 </p><p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1 234 56789 0</a> - 2006
22599 </p>
22600 !! html/parsoid
22601 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1-234-56789-0</a> - 2006</p>
22602
22603 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1 234 56789 0</a> - 2006</p>
22604 !! end
22605
22606
22607 !! test
22608 anchorencode
22609 !! config
22610 wgFragmentMode=[ 'html5', 'legacy' ]
22611 !! wikitext
22612 {{anchorencode:foo bar©#%n}}
22613 !! html/php
22614 <p>foo_bar©#%n
22615 </p>
22616 !! html/parsoid
22617 <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>
22618 !! end
22619
22620 !! test
22621 anchorencode (legacy)
22622 !! config
22623 wgFragmentMode=[ 'legacy' ]
22624 !! wikitext
22625 {{anchorencode:foo bar©#%n}}
22626 !! html/php
22627 <p>foo_bar.C2.A9.23.25n
22628 </p>
22629 !! end
22630
22631 !! test
22632 anchorencode trims spaces
22633 !! config
22634 wgFragmentMode=[ 'html5', 'legacy' ]
22635 !! wikitext
22636 {{anchorencode: __pretty__please__}}
22637 !! html/php
22638 <p>pretty_please
22639 </p>
22640 !! html/parsoid
22641 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: __pretty__please__","function":"anchorencode"},"params":{},"i":0}}]}'>pretty_please</p>
22642 !! end
22643
22644 !! test
22645 anchorencode deals with links
22646 !! config
22647 wgFragmentMode=[ 'html5', 'legacy' ]
22648 !! wikitext
22649 {{anchorencode: [[hello|world]] [[hi]]}}
22650 !! html/php
22651 <p>world_hi
22652 </p>
22653 !! html/parsoid
22654 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: [[hello|world]] [[hi]]","function":"anchorencode"},"params":{},"i":0}}]}'>world_hi</p>
22655 !! end
22656
22657 !! test
22658 anchorencode deals with templates
22659 !! config
22660 wgFragmentMode=[ 'html5', 'legacy' ]
22661 !! wikitext
22662 {{anchorencode: {{Foo}} x}}
22663 !! html/php
22664 <p>FOO_x
22665 </p>
22666 !! html/parsoid
22667 <p about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: {{Foo}} x","function":"anchorencode"},"params":{},"i":0}}]}'>FOO_x</p>
22668 !! end
22669
22670 !! test
22671 anchorencode encodes like the TOC generator: (T20431)
22672 !! config
22673 wgFragmentMode=[ 'html5', 'legacy' ]
22674 !! wikitext
22675 ===_ +:.3A%3A _ &&amp;]] x===
22676 {{anchorencode: _ +:.3A%3A _ &&amp;]] x}}
22677 __NOEDITSECTION__
22678 !! html/php
22679 <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>
22680 <p>+:.3A%3A_&amp;&amp;&#93;&#93;_x
22681 </p>
22682 !! html/parsoid
22683 <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>
22684 <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>
22685 <meta property="mw:PageProp/noeditsection"/>
22686 !! end
22687
22688 !! test
22689 anchorencode encodes like the TOC generator: (T20431) (legacy)
22690 !! config
22691 wgFragmentMode=[ 'legacy' ]
22692 !! wikitext
22693 ===_ +:.3A%3A&&amp;]]===
22694 {{anchorencode: _ +:.3A%3A&&amp;]] }}
22695 __NOEDITSECTION__
22696 !! html/php
22697 <h3><span class="mw-headline" id=".2B:.3A.253A.26.26.5D.5D">_ +:.3A%3A&amp;&amp;]]</span></h3>
22698 <p>.2B:.3A.253A.26.26.5D.5D
22699 </p>
22700 !! end
22701
22702 !! test
22703 T8200: blockquotes and paragraph formatting
22704 !! wikitext
22705 <blockquote>
22706 foo
22707 </blockquote>
22708
22709 bar
22710
22711 baz
22712 !! html
22713 <blockquote>
22714 <p>foo
22715 </p>
22716 </blockquote>
22717 <p>bar
22718 </p>
22719 <pre>baz
22720 </pre>
22721 !! end
22722
22723 !! test
22724 T10293: Use of center tag ruins paragraph formatting
22725 !! wikitext
22726 <center>
22727 foo
22728 </center>
22729
22730 bar
22731
22732 baz
22733 !! html
22734 <center>
22735 <p>foo
22736 </p>
22737 </center>
22738 <p>bar
22739 </p>
22740 <pre>baz
22741 </pre>
22742 !! end
22743
22744 !!test
22745 Parsing of overlapping (improperly nested) inline html tags
22746 !! wikitext
22747 <span><s>x</span></s>
22748 !! html/php
22749 <p><span><s>x&lt;/span&gt;</s></span>
22750 </p>
22751 !! html/parsoid
22752 <p><span><s>x</s></span>
22753 </p>
22754 !!end
22755
22756 ###
22757 ### Language variants related tests
22758 ###
22759
22760 # Parsoid does not mark self-links.
22761 # Parsoid does not convert links; PHP will do any necessary redirects.
22762
22763 !! test
22764 Self-link in language variants
22765 !! options
22766 title=[[Dunav]] language=sr
22767 !! wikitext
22768 Both [[Dunav]] and [[Дунав]] are names for this river.
22769 !! html/php
22770 <p>Both <a class="mw-selflink selflink">Dunav</a> and <a class="mw-selflink selflink">Дунав</a> are names for this river.
22771 </p>
22772 !! html/parsoid
22773 <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>
22774 !! end
22775
22776 !! article
22777 Дуна
22778 !! text
22779 content
22780 !! endarticle
22781
22782 !! test
22783 Link to another existing title shouldn't be parsed as self-link even if it's a variant of this title
22784 !! options
22785 title=[[Duna]] language=sr
22786 !! wikitext
22787 [[Дуна]] is not a self-link while [[Duna]] and [[Dуна]] are still self-links.
22788 !! html/php
22789 <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.
22790 </p>
22791 !! html/parsoid
22792 <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>
22793 !! end
22794
22795 !! test
22796 Link to a section of a variant of this title shouldn't be parsed as self-link
22797 !! options
22798 title=[[Duna]] language=sr
22799 !! wikitext
22800 [[Dуна]] is a self-link while [[Dunа#Foo]] and [[Dуна#Foo]] are not self-links.
22801 !! html/php
22802 <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.
22803 </p>
22804 !! html/parsoid
22805 <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>
22806 !! end
22807
22808 !! test
22809 Link to pages in language variants
22810 !! options
22811 language=sr
22812 !! wikitext
22813 Main Page can be written as [[Маин Паге]]
22814 !! html/php
22815 <p>Main Page can be written as <a href="/wiki/Main_Page" title="Main Page">Маин Паге</a>
22816 </p>
22817 !! html/parsoid
22818 <p>Main Page can be written as <a rel="mw:WikiLink" href="./Маин_Паге" title="Маин Паге">Маин Паге</a></p>
22819 !! end
22820
22821
22822 !! test
22823 Multiple links to pages in language variants
22824 !! options
22825 language=sr
22826 !! wikitext
22827 [[Main Page]] can be written as [[Маин Паге]] same as [[Маин Паге]].
22828 !! html/php
22829 <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>.
22830 </p>
22831 !! html/parsoid
22832 <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>
22833 !! end
22834
22835
22836 !! test
22837 Simple template in language variants
22838 !! options
22839 language=sr
22840 !! wikitext
22841 {{тест}}
22842 !! html/php
22843 <p>This is a test template
22844 </p>
22845 !! end
22846
22847
22848 !! test
22849 Template with explicit namespace in language variants
22850 !! options
22851 language=sr
22852 !! wikitext
22853 {{Template:тест}}
22854 !! html/php
22855 <p>This is a test template
22856 </p>
22857 !! end
22858
22859
22860 !! test
22861 Basic test for template parameter in language variants
22862 !! options
22863 language=sr
22864 !! wikitext
22865 {{парамтест|param=foo}}
22866 !! html/php
22867 <p>This is a test template with parameter foo
22868 </p>
22869 !! end
22870
22871 !! test
22872 Simple category in language variants
22873 !! options
22874 language=sr cat
22875 !! wikitext
22876 [[Category:МедиаWики Усер'с Гуиде]]
22877 !! html/php
22878 cat=МедиаWики_Усер'с_Гуиде sort=
22879 !! html/parsoid
22880 <link rel="mw:PageProp/Category" href="./Категорија:МедиаWики_Усер'с_Гуиде" data-parsoid='{"stx":"simple","a":{"href":"./Категорија:МедиаWики_Усер&#39;с_Гуиде"},"sa":{"href":"Category:МедиаWики Усер&#39;с Гуиде"}}'/>
22881 !! end
22882
22883 !! article
22884 Category:分类
22885 !! text
22886 blah
22887 !! endarticle
22888
22889 !! article
22890 Category:分類
22891 !! text
22892 blah
22893 !! endarticle
22894
22895 ## We used to, but no longer wt2wt this test since the default serializer
22896 ## will normalize all categories to serialize on their own line.
22897 ## This wikitext usage is going to be fairly uncommon in production and
22898 ## selser will take care of preserving formatting in those scenarios.
22899 !! test
22900 Don't convert blue categorylinks to another variant (T35210)
22901 !! options
22902 cat
22903 language=zh
22904 parsoid=wt2html
22905 !! wikitext
22906 [[A]][[Category:分类]]
22907 !! html/php
22908 cat=分类 sort=
22909 !! html/parsoid
22910 <p><a rel="mw:WikiLink" href="./A" title="A">A</a></p>
22911 <link rel="mw:PageProp/Category" href="./Category:分类"/>
22912 !! end
22913
22914 !! test
22915 Stripping -{}- tags (language variants)
22916 !! options
22917 language=sr
22918 !! wikitext
22919 Latin proverb: -{Ne nuntium necare}-
22920 !! html/php
22921 <p>Latin proverb: Ne nuntium necare
22922 </p>
22923 !! html/parsoid
22924 <p>Latin proverb: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
22925 !! end
22926
22927
22928 !! test
22929 Prevent conversion with -{}- tags (language variants)
22930 !! options
22931 language=sr variant=sr-ec
22932 !! wikitext
22933 Latinski: -{Ne nuntium necare}-
22934 !! html/php
22935 <p>Латински: Ne nuntium necare
22936 </p>
22937 !! html/parsoid
22938 <p>Latinski: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
22939 !! end
22940
22941
22942 !! test
22943 Prevent conversion of text with -{}- tags (language variants)
22944 !! options
22945 language=sr variant=sr-ec
22946 !! wikitext
22947 Latinski: -{Ne nuntium necare}-
22948 !! html/php
22949 <p>Латински: Ne nuntium necare
22950 </p>
22951 !! html/parsoid
22952 <p>Latinski: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
22953 !! end
22954
22955
22956 !! test
22957 Prevent conversion of links with -{}- tags (language variants)
22958 !! options
22959 language=sr variant=sr-ec
22960 !! wikitext
22961 -{[[Main Page]]}-
22962 !! html/php
22963 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
22964 </p>
22965 !! html/parsoid
22966 <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>
22967 !! end
22968
22969
22970 !! test
22971 -{}- tags within headlines (within html for parserConvert())
22972 !! config
22973 wgFragmentMode=[ 'html5', 'legacy' ]
22974 !! options
22975 language=sr variant=sr-ec
22976 !! wikitext
22977 ==-{Naslov}-==
22978
22979 Note that even an unprotected headline ID is not affected by language
22980 conversion:
22981
22982 ==Latinski==
22983 !! html/php
22984 <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>
22985 <p>Ноте тхат евен ан унпротецтед хеадлине ИД ис нот аффецтед бy лангуаге
22986 цонверсион:
22987 </p>
22988 <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>
22989
22990 !! html/parsoid
22991 <h2 id="-{Naslov}-"><span id="-.7BNaslov.7D-" typeof="mw:FallbackId"></span><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Naslov"}}'></span></h2>
22992
22993 <p>Note that even an unprotected headline ID is not affected by language
22994 conversion:</p>
22995
22996 <h2 id="Latinski">Latinski</h2>
22997 !! end
22998
22999 !! test
23000 Explicit definition of language variant alternatives
23001 !! options
23002 language=zh variant=zh-tw
23003 !! wikitext
23004 -{zh:China;zh-tw:Taiwan}-, not China
23005 !! html/php
23006 <p>Taiwan, not China
23007 </p>
23008 !! html/parsoid
23009 <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>
23010 !! end
23011
23012 !! test
23013 Explicit definition of language variant alternatives (BCP 47 codes)
23014 !! options
23015 language=zh variant=zh-tw
23016 !! wikitext
23017 -{zh:China;zh-Hant-TW:Taiwan}-, not China
23018 !! html/php
23019 <p>Taiwan, not China
23020 </p>
23021 !! html/parsoid
23022 <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>
23023 !! end
23024
23025 !! test
23026 Filter syntax for language variants
23027 !! options
23028 language=zh variant=zh-tw
23029 !! wikitext
23030 foo-{zh;zh-hans;zh-hant|blog, WEBJOURNAL, WEBLOG}-quux
23031 !! html/php
23032 <p>fooblog, WEBJOURNAL, WEBLOGquux
23033 </p>
23034 !! html/parsoid
23035 <p>foo<span typeof="mw:LanguageVariant" data-mw-variant='{"filter":{"l":["zh","zh-hans","zh-hant"],"t":"blog, WEBJOURNAL, WEBLOG"}}'></span>quux</p>
23036 !! end
23037
23038 # Note that Parsoid post-processing for language variants needs to
23039 # update the `title` attribute here, based on the mw:ExpandedAttrs property
23040 !! test
23041 Conversion around HTML tags
23042 !! options
23043 language=sr variant=sr-ec
23044 !! wikitext
23045 -{H|span=>sr-ec:script;title=>sr-ec:src}-
23046 <span title="La-{sr-el:L;sr-ec:C}-tin">ski</span>
23047 !! html/php
23048 <p>
23049 <span title="ЛаCтин">ски</span>
23050 </p>
23051 !! html/parsoid
23052 <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"}]}'/>
23053 <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>
23054 !! end
23055
23056 !! test
23057 Explicit session-wise two-way language variant mapping (A flag and - flag)
23058 !! options
23059 language=zh variant=zh-tw
23060 !! wikitext
23061 This is -{zh:China; zh-tw:Taiwan}-, but we'll forget that now.
23062
23063 Taiwan is not China.
23064
23065 But -{A|zh:China; zh-tw:Taiwan}- is China,
23066
23067 (This-{-|zh:China; zh-tw:Taiwan}- should be stripped!)
23068
23069 and -{China}- is China.
23070 !! html/php
23071 <p>This is Taiwan, but we'll forget that now.
23072 </p><p>Taiwan is not China.
23073 </p><p>But Taiwan is Taiwan,
23074 </p><p>(This should be stripped!)
23075 </p><p>and China is China.
23076 </p>
23077 !! html/parsoid
23078 <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>
23079 <p>Taiwan is not China.</p>
23080 <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>
23081 <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>
23082 <p>and <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"China"}}'></span> is China.</p>
23083 !! end
23084
23085 !! test
23086 Explicit session-wise one-way language variant mapping (A flag and - flag)
23087 !! options
23088 language=zh variant=zh-tw
23089 !! wikitext
23090 This is -{COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}-, but we'll forget that now.
23091
23092 COUNTRY is China or Taiwan.
23093
23094 But -{A|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- is COUNTRY,
23095
23096 (This-{-|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- should be stripped!)
23097
23098 and -{COUNTRY}- is COUNTRY.
23099 !! html/php
23100 <p>This is Taiwan, but we'll forget that now.
23101 </p><p>COUNTRY is China or Taiwan.
23102 </p><p>But Taiwan is Taiwan,
23103 </p><p>(This should be stripped!)
23104 </p><p>and COUNTRY is COUNTRY.
23105 </p>
23106 !! html/parsoid
23107 <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>
23108 <p>COUNTRY is China or Taiwan.</p>
23109 <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>
23110 <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>
23111 <p>and <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"COUNTRY"}}'></span> is COUNTRY.</p>
23112 !! end
23113
23114 !! test
23115 Explicit session-wise two-way language variant mapping (H flag for hide)
23116 !! options
23117 language=zh variant=zh-tw
23118 !! wikitext
23119 (This-{H|zh:China;zh-tw:Taiwan}- should be stripped!)
23120
23121 Taiwan is China.
23122 !! html/php
23123 <p>(This should be stripped!)
23124 </p><p>Taiwan is Taiwan.
23125 </p>
23126 !! html/parsoid
23127 <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>
23128 <p>Taiwan is China.</p>
23129 !! end
23130
23131 !! test
23132 Explicit session-wise one-way language variant mapping (H flag for hide)
23133 !! options
23134 language=zh variant=zh-tw
23135 !! wikitext
23136 (This-{H|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- should be stripped!)
23137
23138 COUNTRY is Taiwan or China.
23139 !! html/php
23140 <p>(This should be stripped!)
23141 </p><p>Taiwan is Taiwan or China.
23142 </p>
23143 !! html/parsoid
23144 <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>
23145 <p>COUNTRY is Taiwan or China.</p>
23146 !! end
23147
23148 ## Note that parsoid test runner does not support 'showtitle' option.
23149 !! test
23150 Adding explicit conversion rule for title (T flag)
23151 !! options
23152 language=zh variant=zh-tw showtitle
23153 !! wikitext
23154 Should be stripped-{T|zh:China;zh-tw:Taiwan}-!
23155
23156 Taiwan is China.
23157 !! html/php
23158 Taiwan
23159 <p>Should be stripped!
23160 </p><p>Taiwan is China.
23161 </p>
23162 !! html/parsoid
23163 <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>
23164 <p>Taiwan is China.</p>
23165 !! end
23166
23167 !! test
23168 Code coverage: T combined with H flag
23169 !! options
23170 language=zh variant=zh-tw showtitle
23171 !! wikitext
23172 Should be stripped-{T;H|zh:China; zh-tw:Taiwan}-!
23173
23174 Taiwan is China.
23175 !! html/php
23176 Taiwan
23177 <p>Should be stripped!
23178 </p><p>Taiwan is Taiwan.
23179 </p>
23180 !! html/parsoid
23181 <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>
23182 <p>Taiwan is China.</p>
23183 !! end
23184
23185 !! test
23186 Code coverage: T with no variants
23187 !! options
23188 language=zh variant=zh-tw showtitle
23189 !! wikitext
23190 -{H|zh:China; zh-tw:Taiwan}-
23191 Taiwan is China.-{T|Taiwan is China}-
23192 !! html/php
23193 Taiwan is China
23194 <p>
23195 Taiwan is Taiwan.
23196 </p>
23197 !! html/parsoid
23198 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>
23199 Taiwan is China.<meta typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Taiwan is China"},"title":true}'/></p>
23200 !! end
23201
23202 !! test
23203 Code coverage: rules with no variants
23204 !! options
23205 language=zh variant=zh-tw
23206 !! wikitext
23207 -{H|zh:China; zh-tw:Taiwan}-
23208 Taiwan is China.
23209 -{H|China}-
23210 Taiwan is China.
23211 !! html/php
23212 <p>
23213 Taiwan is Taiwan.
23214
23215 Taiwan is China.
23216 </p>
23217 !! html/parsoid
23218 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>
23219 Taiwan is China.
23220 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"*","t":"China"}]}'/>
23221 Taiwan is China.</p>
23222 !! end
23223
23224
23225 !! test
23226 Code coverage: D flag for conversion rule
23227 !! options
23228 language=zh variant=zh-tw
23229 !! wikitext
23230 -{D|zh-cn:XA; zh-tw:YA}-
23231 -{A;D|zh-cn:XB; zh-tw:YB}-
23232 -{D;H|zh-cn:XC; zh-tw:YC}-
23233
23234 -{D;H|FOO=>zh-tw:BAR;FOO=>zh-cn:BAT}-
23235
23236 -{D|0=>zh-tw:1}-
23237 -{A;D|2=>zh-tw:3}-
23238 -{D;H|4=>zh-tw:5}-
23239
23240 XA XB XC YA YB YC FOO BAR BAT 012345
23241 !! html/php
23242 <p>大陆:XA;台灣:YA;
23243
23244 大陆:XC;台灣:YC;
23245 </p><p>FOO⇒台灣:BAR;FOO⇒大陆:BAT;
23246 </p><p>0⇒台灣:1;
23247
23248 4⇒台灣:5;
23249 </p><p>XA YB YC YA YB YC BAR BAR BAT 013355
23250 </p>
23251 !! html/parsoid
23252 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"describe":true,"twoway":[{"l":"zh-cn","t":"XA"},{"l":"zh-tw","t":"YA"}]}'></span>
23253 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"twoway":[{"l":"zh-cn","t":"XB"},{"l":"zh-tw","t":"YB"}]}'/>
23254 <span typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"twoway":[{"l":"zh-cn","t":"XC"},{"l":"zh-tw","t":"YC"}]}'></span></p>
23255 <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>
23256 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"describe":true,"oneway":[{"f":"0","l":"zh-tw","t":"1"}]}'></span>
23257 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"oneway":[{"f":"2","l":"zh-tw","t":"3"}]}'/>
23258 <span typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"oneway":[{"f":"4","l":"zh-tw","t":"5"}]}'></span></p>
23259 <p>XA XB XC YA YB YC FOO BAR BAT 012345</p>
23260 !! end
23261
23262 !! test
23263 Code coverage: N flag for conversion rule
23264 !! options
23265 language=zh variant=zh-cn
23266 !! wikitext
23267 -{N|zh-cn}-
23268
23269 -{N|zh-tw}-
23270
23271 -{N|sr-ec}-
23272 !! html/php
23273 <p>大陆
23274 </p><p>台灣
23275 </p><p>српски (ћирилица)‎
23276 </p>
23277 !! html/parsoid
23278 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"zh-cn"}}'></span></p>
23279 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"zh-tw"}}'></span></p>
23280 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"sr-ec"}}'></span></p>
23281 !! end
23282
23283 # html2wt suppresses the bogus 'D' flag, so this is wt2html only
23284 !! test
23285 Code coverage: N flag for conversion rule (wt2html only)
23286 !! options
23287 language=zh variant=zh-cn
23288 parsoid=wt2html,html2html
23289 !! wikitext
23290 -{D;N|en}-
23291 !! html/php
23292 <p>English
23293 </p>
23294 !! html/parsoid
23295 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"en"}}' data-parsoid='{"fl":["D","N"]}'></span></p>
23296 !! end
23297
23298 !! test
23299 Testing that changing the language variant here in the tests actually works
23300 !! options
23301 language=zh variant=zh showtitle
23302 !! wikitext
23303 Should be stripped-{T|zh:China; zh-tw:Taiwan}-!
23304 !! html/php
23305 China
23306 <p>Should be stripped!
23307 </p>
23308 !! html/parsoid
23309 <p>Should be stripped<meta typeof="mw:LanguageVariant" data-mw-variant='{"title":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>!</p>
23310 !! end
23311
23312 !! test
23313 Recursive conversion of alt and title attrs shouldn't clear converter state
23314 !! options
23315 language=zh variant=zh-cn
23316 showtitle
23317 !! wikitext
23318 -{H|zh-cn:Exclamation; zh-tw:exclamation}-
23319 Should be stripped-{T|zh-cn:China; zh-tw:Taiwan}-<span title="exclamation">!</span>
23320 !! html/php
23321 China
23322 <p>
23323 Should be stripped<span title="Exclamation">!</span>
23324 </p>
23325 !! html/parsoid
23326 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh-cn","t":"Exclamation"},{"l":"zh-tw","t":"exclamation"}]}'/>
23327 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>
23328 !! end
23329
23330 !! test
23331 T26072: more test on conversion rule for title
23332 !! options
23333 language=zh variant=zh-tw showtitle
23334 !! wikitext
23335 This should be stripped-{T|zh:China; zh-tw:Taiwan}-!
23336
23337 This won't take interferes with the title rule-{H|zh:Beijing; zh-tw:Taipei}-.
23338 !! html/php
23339 Taiwan
23340 <p>This should be stripped!
23341 </p><p>This won't take interferes with the title rule.
23342 </p>
23343 !! html/parsoid
23344 <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>
23345 <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>
23346 !! end
23347
23348 !! test
23349 Partly disable title conversion if variant == main language code
23350 !! options
23351 language=zh variant=zh title=[[ZH]] showtitle
23352 !! wikitext
23353 -{T|zh-cn:CN;zh-tw:TW}-
23354 !! html/php
23355 ZH
23356 <p>
23357 </p>
23358 !! html/parsoid
23359 <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>
23360 !! end
23361
23362 !! test
23363 Partly disable title conversion if variant == main language code, more
23364 !! options
23365 language=zh variant=zh title=[[ZH]] showtitle
23366 !! wikitext
23367 -{T|TW}-
23368 !! html/php
23369 ZH
23370 <p>
23371 </p>
23372 !! html/parsoid
23373 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"TW"},"title":true}'/></p>
23374 !! end
23375
23376 !! test
23377 Raw output of variant escape tags (R flag)
23378 !! options
23379 language=zh variant=zh-tw
23380 !! wikitext
23381 Raw: -{R|zh:China;zh-tw:Taiwan}-
23382 !! html/php
23383 <p>Raw: zh:China;zh-tw:Taiwan
23384 </p>
23385 !! html/parsoid
23386 <p>Raw: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"zh:China;zh-tw:Taiwan"}}'></span></p>
23387 !! end
23388
23389 # html2wt suppresses the bogus 'D' flags, so this is wt2html only
23390 !! test
23391 Raw output of variant escape tags (R flag) (wt2html only)
23392 !! options
23393 language=zh variant=zh-tw
23394 parsoid=wt2html,html2html
23395 !! wikitext
23396 -{Variant}- -{D|syntax}- -{D;R|options}-
23397 !! html/php
23398 <p>Variant syntax options
23399 </p>
23400 !! html/parsoid
23401 <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>
23402 !! end
23403
23404 !! test
23405 Nested markup inside raw output of variant escape tags (R flag)
23406 !! options
23407 language=zh variant=zh-tw
23408 !! wikitext
23409 Nested raw: -{R|nested -{zh:China;zh-tw:Taiwan}- nested}-
23410 !! html/php
23411 <p>Nested raw: nested Taiwan nested
23412 </p>
23413 !! html/parsoid
23414 <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>
23415 !! end
23416
23417 !! test
23418 Nested markup and spaces inside raw output of variant escape tags (R flag)
23419 !! options
23420 language=zh variant=zh-tw
23421 !! wikitext
23422 X-{ outer -{ inner }- outer }-X
23423 !! html/php
23424 <p>X outer inner outer X
23425 </p>
23426 !! html/parsoid
23427 <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>
23428 !! end
23429
23430 !! test
23431 Templates inside raw output of variant escape tags (R flag)
23432 !! options
23433 language=zh variant=zh-tw
23434 !! wikitext
23435 Nested raw: -{R|nested {{echo|hi}} templates}-
23436 !! html/php
23437 <p>Nested raw: nested hi templates
23438 </p>
23439 !! html/parsoid
23440 <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>
23441 !! end
23442
23443 !! test
23444 Strings evaluating false shouldn't be ignored by Language converter (T51072)
23445 !! options
23446 language=zh variant=zh-cn
23447 !! wikitext
23448 -{zh-cn:0;zh-sg:1;zh-tw:2;zh-hk:3}-
23449 !! html/php
23450 <p>0
23451 </p>
23452 !! html/parsoid
23453 <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>
23454 !! end
23455
23456 !! test
23457 Conversion rules from [numeric-only string] to [something else] (T48634)
23458 !! options
23459 language=zh variant=zh-cn
23460 !! wikitext
23461 -{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
23462 !! html/php
23463 <p>D12345EE12345
23464 </p>
23465 !! html/parsoid
23466 <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>
23467 !! end
23468
23469 !! test
23470 Two-way converter rule entries with an empty value should be ignored (T53551)
23471 !! options
23472 language=zh variant=zh-cn
23473 !! wikitext
23474 -{H|zh-cn:foo;zh-tw:;}-foobar
23475 !! html/php
23476 <p>foobar
23477 </p>
23478 !! html/parsoid
23479 <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>
23480 !! end
23481
23482 !! test
23483 One-way converter rule entries with an empty "from" string should be ignored (T53551)
23484 !! options
23485 language=zh variant=zh-cn
23486 !! wikitext
23487 -{H|=>zh-cn:foo;}-foobar
23488 !! html/php
23489 <p>foobar
23490 </p>
23491 !! html/parsoid
23492 <p><meta typeof="mw:LanguageVariant" data-parsoid='{"tSp":[5]}' data-mw-variant='{"add":true,"oneway":[{"f":"","l":"zh-cn","t":"foo"}]}'/>foobar</p>
23493 !! end
23494
23495 !! test
23496 Empty converter rule entries shouldn't be inserted into the conversion table (T53551)
23497 !! options
23498 language=zh variant=zh-cn
23499 !! wikitext
23500 -{H|}-foobar
23501 !! html/php
23502 <p>foobar
23503 </p>
23504 !! html/parsoid
23505 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"*","t":""}]}'/>foobar</p>
23506 !! end
23507
23508 !! test
23509 Nested using of manual convert syntax
23510 !! options
23511 language=zh variant=zh-hk
23512 !! wikitext
23513 Nested: -{zh-hans:Hi -{zh-cn:China;zh-sg:Singapore;}-;zh-hant:Hello -{zh-tw:Taiwan;zh-hk:H-{ong}- K-{}-ong;}-;}-!
23514 !! html/php
23515 <p>Nested: Hello Hong Kong!
23516 </p>
23517 !! html/parsoid
23518 <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>
23519 !! end
23520
23521 !! test
23522 HTML markups with conversion syntax in attribs, nested in other conversion blocks
23523 !! options
23524 language=zh variant=zh-cn
23525 !! wikitext
23526 -{zh;zh-hans;zh-hant|<span title="-{X}-">A</span>}-
23527 !! html/php
23528 <p><span title="X">A</span>
23529 </p>
23530 !! html/parsoid
23531 <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>
23532 !! end
23533
23534 !! test
23535 HTML markups with conversion syntax in attribs, nested in other conversion blocks (not working yet in PHP parser)
23536 !! options
23537 language=zh variant=zh-cn
23538 !! wikitext
23539 -{<span title="-{X}-">A</span>}-
23540 !! html/php+disabled
23541 <p><span title="X">A</span>
23542 </p>
23543 !! html/parsoid
23544 <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>
23545 !! end
23546
23547 # Parsoid and PHP disagree on how to parse this example: Parsoid
23548 # insists that the content of a language converter element be a valid
23549 # DOM fragment or attribute string
23550 !! test
23551 Language converter markup with block content
23552 !! options
23553 language=zh variant=zh-cn
23554 !! wikitext
23555 <span>a-{b<div>c}-d
23556
23557 <span>a-{zh;zh-hans;zh-hant|b<div>c}-d
23558
23559 <span>a-{H|0=>zh-cn:x<span>y;0=>zh-tw:b<div>c}-d
23560 !! html/php+tidy
23561 <span>ab<div>cd
23562 <span>ab<div>cd
23563 <span>ad
23564 </span></div></span></div></span>
23565 !! html/parsoid
23566 <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
23567
23568 <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
23569
23570 <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>
23571 !! end
23572
23573 !! test
23574 LanguageConverter selser (1)
23575 !! options
23576 language=zh variant=zh-cn
23577 parsoid={
23578 "modes": ["wt2wt", "selser"],
23579 "changes": [
23580 ["span[typeof]", "attr", "data-mw-variant", "{\"disabled\":{\"t\":\"edited\"}}"]
23581 ]
23582 }
23583 !! wikitext
23584 -{raw}-
23585 !! wikitext/edited
23586 -{edited}-
23587 !! end
23588
23589 !! test
23590 LanguageConverter selser (2)
23591 !! options
23592 language=zh variant=zh-cn
23593 parsoid={
23594 "modes": ["wt2wt", "selser"],
23595 "changes": [
23596 ["span[class='x']", "contents", "text", "-{foo}-"],
23597 ["a", "contents", "text", "-{"],
23598 ["span[typeof]", "attr", "data-mw", "{\"parts\":[{\"template\":{\"target\":{\"wt\":\"1x\",\"href\":\"./Template:1x\"},\"params\":{\"1\":{\"wt\":\"-{\"}},\"i\":0}}]}"]
23599 ]
23600 }
23601 !! wikitext
23602 <span class="x">TEXT1</span>
23603 [http://example.com TEXT2]
23604 [[Foo|TEXT3]]
23605 {{echo|TEXT4}}
23606 !! wikitext/edited
23607 <span class="x"><nowiki>-{foo}-</nowiki></span>
23608 [http://example.com -{]
23609 [[Foo|<nowiki>-{</nowiki>]]
23610 {{1x|<nowiki>-{</nowiki>}}
23611 !! end
23612
23613 # Tests LanguageVariantText in ConstrainedText
23614 !! test
23615 LanguageConverter selser (3)
23616 !! options
23617 language=zh variant=zh-cn
23618 parsoid={
23619 "modes": ["wt2wt", "selser"],
23620 "changes": [
23621 ["td > span", "attr", "typeof", "mw:LanguageVariant"],
23622 ["td > span", "attr", "data-mw-variant", "{\"disabled\":{\"t\":\"edited\"}}"]
23623 ]
23624 }
23625 !! wikitext
23626 {|
23627 |-
23628 |<span>Foo</span>
23629 |}
23630 !! wikitext/edited
23631 {|
23632 |-
23633 |<nowiki/>-{edited}-
23634 |}
23635 !! end
23636
23637 # Tests LanguageVariantText._fromSelSer
23638 !! test
23639 LanguageConverter selser (4)
23640 !! options
23641 language=zh variant=zh-cn
23642 parsoid={
23643 "modes": ["wt2wt", "selser"],
23644 "changes": [
23645 ["td > span.x", "remove"]
23646 ]
23647 }
23648 !! wikitext
23649 {|
23650 |-
23651 |<span class="x">Foo</span>-{Bar}-
23652 ||<span class="x">Foo</span>-{Bar}-
23653 |}
23654 !! wikitext/edited
23655 {|
23656 |-
23657 |<nowiki/>-{Bar}-
23658 ||-{Bar}-
23659 |}
23660 !! end
23661
23662 # Since Parsoid is starting to emit canonical wikitext for links,
23663 # [http://example.com http://example.com] will not RT back to that
23664 # form anymore.
23665 # Parsoid does not language-convert links (it is done in a
23666 # post-processing step)
23667 !! test
23668 Proper conversion of text in external links
23669 !! options
23670 language=sr variant=sr-ec
23671 parsoid=wt2html
23672 !! wikitext
23673 http://www.google.com
23674 gopher://www.google.com
23675 [http://www.google.com http://www.google.com]
23676 [gopher://www.google.com gopher://www.google.com]
23677 [https://www.google.com irc://www.google.com]
23678 [ftp://www.google.com www.google.com/ftp://dir]
23679 [//www.google.com www.google.com]
23680 !! html/php
23681 <p><a rel="nofollow" class="external free" href="http://www.google.com">http://www.google.com</a>
23682 <a rel="nofollow" class="external free" href="gopher://www.google.com">gopher://www.google.com</a>
23683 <a rel="nofollow" class="external text" href="http://www.google.com">http://www.google.com</a>
23684 <a rel="nofollow" class="external text" href="gopher://www.google.com">gopher://www.google.com</a>
23685 <a rel="nofollow" class="external text" href="https://www.google.com">irc://www.google.com</a>
23686 <a rel="nofollow" class="external text" href="ftp://www.google.com">www.гоогле.цом/фтп://дир</a>
23687 <a rel="nofollow" class="external text" href="//www.google.com">www.гоогле.цом</a>
23688 </p>
23689 !! html/parsoid
23690 <p><a rel="mw:ExtLink" class="external free" href="http://www.google.com">http://www.google.com</a>
23691 <a rel="mw:ExtLink" class="external free" href="gopher://www.google.com">gopher://www.google.com</a>
23692 <a rel="mw:ExtLink" class="external text" href="http://www.google.com">http://www.google.com</a>
23693 <a rel="mw:ExtLink" class="external text" href="gopher://www.google.com">gopher://www.google.com</a>
23694 <a rel="mw:ExtLink" class="external text" href="https://www.google.com">irc://www.google.com</a>
23695 <a rel="mw:ExtLink" class="external text" href="ftp://www.google.com">www.google.com/ftp://dir</a>
23696 <a rel="mw:ExtLink" class="external text" href="//www.google.com">www.google.com</a></p>
23697 !! end
23698
23699 !! test
23700 Do not convert roman numbers to language variants
23701 !! options
23702 language=sr variant=sr-ec
23703 !! wikitext
23704 Fridrih IV je car.
23705 !! html/php
23706 <p>Фридрих IV је цар.
23707 </p>
23708 !! html/parsoid
23709 <p>Fridrih IV je car.</p>
23710 !! end
23711
23712 !! test
23713 Unclosed language converter markup "-{"
23714 !! options
23715 language=sr
23716 !! wikitext
23717 -{T|hello
23718 !! html
23719 <p>-{T|hello
23720 </p>
23721 !! end
23722
23723 !! test
23724 Don't convert raw rule "-{R|=&gt;}-" to "=>"
23725 !! options
23726 language=sr
23727 !! wikitext
23728 -{R|=&gt;}-
23729 !! html/php
23730 <p>=&gt;
23731 </p>
23732 !! html/parsoid
23733 <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>
23734 !!end
23735
23736 !! test
23737 Don't break link parsing if language converter markup is in the caption.
23738 !! options
23739 language=sr variant=sr-ec
23740 !! wikitext
23741 [[Main Page|-{R|main page}-]]
23742 !! html/php
23743 <p><a href="/wiki/Main_Page" title="Маин Паге">main page</a>
23744 </p>
23745 !! html/parsoid
23746 <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>
23747 !! end
23748
23749 !! test
23750 T146304: Don't break template parsing if language converter markup is in the parameter.
23751 !! options
23752 language=sr variant=sr-ec
23753 !! wikitext
23754 {{echo|-{R|foo}-}}
23755 !! html/php
23756 <p>foo
23757 </p>
23758 !! html/parsoid
23759 <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>
23760 !! end
23761
23762 !! test
23763 T146305: Don't break image parsing if language converter markup is in the caption.
23764 !! options
23765 language=sr
23766 !! wikitext
23767 [[Датотека:Foobar.jpg|thumb|-{R|caption:}-]]
23768 !! html/php
23769 <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>
23770
23771 !! html/parsoid
23772 <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>
23773 !! end
23774
23775 !! test
23776 T146305: Don't break image parsing if nested language converter markup is in the caption.
23777 !! options
23778 language=zh variant=zh-cn
23779 !! wikitext
23780 [[File:Foobar.jpg|thumb|-{|zh-cn:blog (hk: -{zh-hans|WEBJOURNAL}-, tw: -{zh-hans|WEBLOG}-)}-]]
23781 !! html/php
23782 <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>
23783
23784 !! html/parsoid
23785 <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>
23786 !! end
23787
23788 # XXX html2wt disabled because rich markup in alt is not preserved.
23789 !! test
23790 Don't break gallery if language converter markup is inside.
23791 !! options
23792 language=zh
23793 !! wikitext
23794 <gallery>
23795 File:foobar.jpg|[[File:foobar.jpg|20px|desc|alt=-{R|foo}-|-{R|bar}-]]|alt=-{R|bat}-
23796 File:foobar.jpg|{{Test|unamedParam|alt=-{R|param}-}}|alt=galleryalt
23797 </gallery>
23798 !! html/php
23799 <ul class="gallery mw-gallery-traditional">
23800 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
23801 <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>
23802 <div class="gallerytext">
23803 <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>
23804 </p>
23805 </div>
23806 </div></li>
23807 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
23808 <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>
23809 <div class="gallerytext">
23810 <p>This is a test template
23811 </p>
23812 </div>
23813 </div></li>
23814 </ul>
23815
23816 !! html/parsoid
23817 <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"}}'>
23818 <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>
23819 <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>
23820 </ul>
23821 !! end
23822
23823 !! test
23824 T153135: Don't break list handling if language converter markup is in the item.
23825 !! options
23826 language=zh variant=zh-cn
23827 !! wikitext
23828 ;-{zh-cn:AAA;zh-tw:BBB}-
23829 ;-{R|foo:bar}-
23830 !! html/php
23831 <dl><dt>AAA</dt>
23832 <dt>foo:bar</dt></dl>
23833
23834 !! html/parsoid
23835 <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>
23836 <dt data-parsoid='{"dsr":[25,39,1,0]}'><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"foo:bar"}}'></span></dt>
23837 </dl>
23838 !! end
23839
23840 // Note that parsoid does not protect colons unless language converter
23841 // markup is properly nested, because it is a backtracking parser.
23842 !! test
23843 T153135: Unclosed markup in definition list (code coverage)
23844 !! options
23845 language=zh variant=zh-cn
23846 !! wikitext
23847 ;<b>foo:bar
23848 ;-{zh-cn:AAA
23849 !! html/php+tidy
23850 <dl><dt><b>foo:bar</b></dt><b>
23851 <dt>-{zh-cn:AAA</dt></b></dl><p><b>
23852 </b></p>
23853 !! html/parsoid
23854 <dl><dt data-parsoid='{}'><b data-parsoid='{"stx":"html","autoInsertedEnd":true}'>foo:bar</b></dt><b data-parsoid='{"stx":"html","autoInsertedEnd":true,"autoInsertedStart":true}'>
23855 <dt data-parsoid='{}'>-{zh-cn</dt><dd data-parsoid='{"stx":"row"}'>AAA</dd></b></dl>
23856 !! end
23857
23858 !! test
23859 T153135: Nested language converter markup in definition list (code coverage)
23860 !! options
23861 language=zh variant=zh-cn
23862 !! wikitext
23863 ;-{|zh-cn:AAA -{zh-hans|foo:bar}- -{R|bat:baz}-}-:def
23864 !! html/php
23865 <dl><dt>AAA foo:bar bat:baz</dt>
23866 <dd>def</dd></dl>
23867
23868 !! html/parsoid
23869 <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>
23870 <dd data-parsoid='{"stx":"row","dsr":[49,53,1,0]}'>def</dd>
23871 </dl>
23872 !! end
23873
23874 # html2wt mode disabled due to <nowiki> insertion.
23875 !! test
23876 T153140: Don't break table handling if language converter markup is in the cell.
23877 !! options
23878 language=sr variant=sr-ec
23879 parsoid=wt2html,wt2wt,html2html
23880 !! wikitext
23881 {|
23882 |-
23883 | -{R|B}-
23884 |}
23885 !! html/php
23886 <table>
23887
23888 <tr>
23889 <td>B
23890 </td></tr></table>
23891
23892 !! html/parsoid
23893 <table>
23894 <tbody>
23895 <tr>
23896 <td><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"B"}}'></span></td>
23897 </tr>
23898 </tbody>
23899 </table>
23900 !! end
23901
23902 !! test
23903 Language converter tricky html2wt cases (1)
23904 !! options
23905 language=sr
23906 parsoid=html2wt,wt2wt
23907 !! html/parsoid
23908 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"}-"}}'></span></p>
23909 !! wikitext
23910 -{<nowiki>}-</nowiki>}-
23911 !! html/php
23912 <p>&#125;-
23913 </p>
23914 !! end
23915
23916 !! test
23917 Language converter tricky html2wt cases (2)
23918 !! options
23919 language=sr
23920 parsoid=html2wt,wt2wt
23921 !! html/parsoid
23922 <p>-{foo}-</p>
23923 !! wikitext
23924 <nowiki>-{foo}-</nowiki>
23925 !! html/php
23926 <p>-&#123;foo&#125;-
23927 </p>
23928 !! end
23929
23930 !! test
23931 Language converter tricky html2wt cases (3)
23932 !! options
23933 language=sr
23934 parsoid=html2wt,wt2wt
23935 !! html/parsoid
23936 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"|"}}'></span></p>
23937 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"R|raw"}}'></span></p>
23938 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"-{foo}-"}}'></span></p>
23939 !! wikitext
23940 -{R||}-
23941
23942 -{R|R|raw}-
23943
23944 -{<nowiki>-{foo}-</nowiki>}-
23945 !! html/php
23946 <p>|
23947 </p><p>R|raw
23948 </p><p>-&#123;foo&#125;-
23949 </p>
23950 !! end
23951
23952 !! test
23953 Language converter tricky html2wt cases (4)
23954 !! options
23955 language=sr
23956 parsoid=html2wt,wt2wt
23957 !! html/parsoid
23958 <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>
23959 !! wikitext
23960 -{R|{{echo|hey}}}-
23961 !! html/php
23962 <p>hey
23963 </p>
23964 !! end
23965
23966 # Note that the <nowiki> escaping added by parsoid for source text,
23967 # destination text, and language names only works on the PHP side
23968 # for *destination text*. (HTML entity escaping wouldn't work
23969 # any better.) This is probably a bug, at least for source texts.
23970 # (For language names PHP uses a precise regexp based on the languages
23971 # it currently knows have variants, which is fragile since this set
23972 # can grow/shrink over time.)
23973 !! test
23974 Language converter tricky html2wt cases (5)
23975 !! options
23976 language=zh variant=zh-cn
23977 !! html/parsoid
23978 <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>
23979 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"A","l":"bo:g;us","t":"B"}]}'/></p>
23980 <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>
23981 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"twoway":[{"l":"bo:g;us","t":"xyz"},{"l":"zh-cn","t":"abc"}]}'></span></p>
23982 <p>a:b=>c xyz</p>
23983 !! wikitext
23984 -{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
23985
23986 -{H|A=><nowiki>bo:g;us</nowiki>:B}-
23987
23988 -{A|zh-tw:xyz; zh-cn:<nowiki>0;zh-tw:bar</nowiki>}-
23989
23990 -{<nowiki>bo:g;us</nowiki>:xyz; zh-cn:abc}-
23991
23992 a:b=>c xyz
23993 !! html/php+disabled
23994 <p>foobat;xyz=&gt;zh-cn:abc
23995 </p><p>A
23996 </p><p>0;zh-tw:bar
23997 </p><p>abc
23998 </p><p>a:b=&gt;c 0;zh-tw:bar
23999 </p>
24000 !! end
24001
24002 !! test
24003 T179579: Nowiki and lc interaction
24004 !! options
24005 parsoid=wt2html
24006 language=sr
24007 !! wikitext
24008 -{</nowiki>123}-
24009
24010 -{123<nowiki>|</nowiki>456}-
24011 !! html/parsoid
24012 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"&amp;lt;/nowiki>123"}}' data-parsoid='{"fl":[],"src":"-{&lt;/nowiki>123}-"}'></span></p>
24013
24014 <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>
24015 !! end
24016
24017 !! test
24018 T2529: Uncovered bullet
24019 !! wikitext
24020 *Foo {{bullet}}
24021 !! html
24022 <ul><li>Foo</li>
24023 <li>Bar</li></ul>
24024
24025 !! end
24026
24027 !! test
24028 T2529: Uncovered bullet in a deeply nested list
24029 !! wikitext
24030 *******Foo {{bullet}}
24031 !! html
24032 <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>
24033 <li>Bar</li></ul>
24034
24035 !! end
24036
24037 !! test
24038 T2529: Uncovered table already at line-start
24039 !! wikitext
24040 x
24041
24042 {{table}}
24043 y
24044 !! html
24045 <p>x
24046 </p>
24047 <table>
24048 <tr>
24049 <td>1</td>
24050 <td>2
24051 </td></tr>
24052 <tr>
24053 <td>3</td>
24054 <td>4
24055 </td></tr></table>
24056 <p>y
24057 </p>
24058 !! end
24059
24060 !! test
24061 T2529: Uncovered bullet in parser function result
24062 !! wikitext
24063 *Foo {{lc:{{bullet}} }}
24064 !! html
24065 <ul><li>Foo</li>
24066 <li>bar</li></ul>
24067
24068 !! end
24069
24070 !! test
24071 T7678: Double-parsed template argument
24072 !! wikitext
24073 {{lc:{{{1}}}|hello}}
24074 !! html
24075 <p>{{{1}}}
24076 </p>
24077 !! end
24078
24079 !! test
24080 T7678: Double-parsed template invocation
24081 !! wikitext
24082 {{lc:{{paramtest {{!}} param = hello }} }}
24083 !! html
24084 <p>{{paramtest | param = hello }}
24085 </p>
24086 !! end
24087
24088 !! test
24089 Case insensitivity of parser functions for non-ASCII characters (T10143)
24090 !! options
24091 language=cs
24092 title=[[Main Page]]
24093 !! wikitext
24094 {{PRVNÍVELKÉ:ěščř}}
24095 {{prvnívelké:ěščř}}
24096 {{PRVNÍMALÉ:ěščř}}
24097 {{prvnímalé:ěščř}}
24098 {{MALÁ:ěščř}}
24099 {{malá:ěščř}}
24100 {{VELKÁ:ěščř}}
24101 {{velká:ěščř}}
24102 !! html
24103 <p>Ěščř
24104 Ěščř
24105 ěščř
24106 ěščř
24107 ěščř
24108 ěščř
24109 ĚŠČŘ
24110 ĚŠČŘ
24111 </p>
24112 !! end
24113
24114 !! test
24115 Morwen/13: Unclosed link followed by heading
24116 !! wikitext
24117 [[link
24118 ==heading==
24119 !! html
24120 <p>[[link
24121 </p>
24122 <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>
24123
24124 !! end
24125
24126 !! test
24127 HHP2.1: Heuristics for headings in preprocessor parenthetical structures
24128 !! wikitext
24129 {{foo|
24130 =heading=
24131 !! html
24132 <p>{{foo|
24133 </p>
24134 <h1><span class="mw-headline" id="heading">heading</span></h1>
24135
24136 !! end
24137
24138 !! test
24139 HHP2.2: Heuristics for headings in preprocessor parenthetical structures
24140 !! wikitext
24141 {{foo|
24142 ==heading==
24143 !! html
24144 <p>{{foo|
24145 </p>
24146 <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>
24147
24148 !! end
24149
24150 !! test
24151 Tildes in comments
24152 !! options
24153 pst
24154 !! wikitext
24155 <!-- ~~~~ -->
24156 !! html/php
24157 <!-- ~~~~ -->
24158 !! end
24159
24160 !! test
24161 Paragraphs inside divs (no extra line breaks)
24162 !! wikitext
24163 <div>Line one
24164
24165 Line two</div>
24166 !! html
24167 <div>Line one
24168 Line two</div>
24169
24170 !! end
24171
24172 !! test
24173 Paragraphs inside divs (extra line break on open)
24174 !! wikitext
24175 <div>
24176 Line one
24177
24178 Line two</div>
24179 !! html
24180 <div>
24181 <p>Line one
24182 </p>
24183 Line two</div>
24184
24185 !! end
24186
24187 !! test
24188 Paragraphs inside divs (extra line break on close)
24189 !! wikitext
24190 <div>Line one
24191
24192 Line two
24193 </div>
24194 !! html
24195 <div>Line one
24196 <p>Line two
24197 </p>
24198 </div>
24199
24200 !! end
24201
24202 !! test
24203 Paragraphs inside divs (extra line break on open and close)
24204 !! wikitext
24205 <div>
24206 Line one
24207
24208 Line two
24209 </div>
24210 !! html
24211 <div>
24212 <p>Line one
24213 </p><p>Line two
24214 </p>
24215 </div>
24216
24217 !! end
24218
24219 # doBlockLevels screws up this output and Remex cleans up as much as it can.
24220 !! test
24221 Nesting tags, paragraphs on lines which begin with <div>
24222 !! wikitext
24223 <div></div><strong>A
24224 B</strong>
24225 !! html/php+tidy
24226 <div></div><p><strong>A
24227 </strong></p><strong></strong><p><strong>B</strong>
24228 </p>
24229 !! html/parsoid
24230 <div data-parsoid='{"stx":"html"}'></div><p><strong data-parsoid='{"stx":"html","autoInsertedEnd":true}'>A</strong></p>
24231 <p><strong data-parsoid='{"stx":"html","autoInsertedStart":true}'>B</strong></p>
24232 !! end
24233
24234 # T8200: <blockquote> should behave like <div> with respect to line breaks
24235 !! test
24236 T8200: paragraphs inside blockquotes (no extra line breaks)
24237 !! wikitext
24238 <blockquote>Line one
24239
24240 Line two</blockquote>
24241 !! html
24242 <blockquote>Line one
24243 Line two</blockquote>
24244
24245 !! html+tidy
24246 <blockquote><p>Line one
24247 Line two</p></blockquote>
24248 !! end
24249
24250 !! test
24251 T8200: paragraphs inside blockquotes (extra line break on open)
24252 !! wikitext
24253 <blockquote>
24254 Line one
24255
24256 Line two</blockquote>
24257 !! html
24258 <blockquote>
24259 <p>Line one
24260 </p>
24261 Line two</blockquote>
24262
24263 !! html+tidy
24264 <blockquote>
24265 <p>Line one
24266 </p><p>
24267 Line two</p></blockquote>
24268 !! end
24269
24270 !! test
24271 T8200: paragraphs inside blockquotes (extra line break on close)
24272 !! wikitext
24273 <blockquote>Line one
24274
24275 Line two
24276 </blockquote>
24277 !! html
24278 <blockquote>Line one
24279 <p>Line two
24280 </p>
24281 </blockquote>
24282
24283 !! html+tidy
24284 <blockquote><p>Line one
24285 </p><p>Line two
24286 </p>
24287 </blockquote>
24288 !! end
24289
24290 !! test
24291 T8200: paragraphs inside blockquotes (extra line break on open and close)
24292 !! wikitext
24293 <blockquote>
24294 Line one
24295
24296 Line two
24297 </blockquote>
24298 !! html
24299 <blockquote>
24300 <p>Line one
24301 </p><p>Line two
24302 </p>
24303 </blockquote>
24304
24305 !! end
24306
24307 ## This is a corner case interaction between the paragraph wrapping in the
24308 ## php parser's BlockLevelPass and Remex. `doBlockLevels` has a notion of
24309 ## some tags which close paragraphs (and thus prevent wrapping on their line),
24310 ## of which "div" is one, but do p-wrapping inside them. These are referred
24311 ## to as "never suppressing". Remex, for its part, doesn't traverse into
24312 ## "div"s to p-wrap. Hence, we only get this partial wrapping.
24313 !! test
24314 Paragraphs inside blockquotes/divs (no extra line breaks)
24315 !! wikitext
24316 <blockquote><div>Line one
24317
24318 Line two</div></blockquote>
24319 !! html
24320 <blockquote><div>Line one
24321 Line two</div></blockquote>
24322
24323 !! end
24324
24325 !! test
24326 Paragraphs inside blockquotes/divs (extra line break on open)
24327 !! wikitext
24328 <blockquote><div>
24329 Line one
24330
24331 Line two</div></blockquote>
24332 !! html
24333 <blockquote><div>
24334 <p>Line one
24335 </p>
24336 Line two</div></blockquote>
24337
24338 !! end
24339
24340 !! test
24341 Paragraphs inside blockquotes/divs (extra line break on close)
24342 !! wikitext
24343 <blockquote><div>Line one
24344
24345 Line two
24346 </div></blockquote>
24347 !! html
24348 <blockquote><div>Line one
24349 <p>Line two
24350 </p>
24351 </div></blockquote>
24352
24353 !! end
24354
24355 !! test
24356 Paragraphs inside blockquotes/divs (extra line break on open and close)
24357 !! wikitext
24358 <blockquote><div>
24359 Line one
24360
24361 Line two
24362 </div></blockquote>
24363 !! html
24364 <blockquote><div>
24365 <p>Line one
24366 </p><p>Line two
24367 </p>
24368 </div></blockquote>
24369
24370 !! end
24371
24372 !! test
24373 Interwiki links trounced by replaceExternalLinks after early LinkHolderArray expansion
24374 !! options
24375 wgLinkHolderBatchSize=0
24376 !! wikitext
24377 [[meatball:1]]
24378 [[meatball:2]]
24379 [[meatball:3]]
24380 !! html
24381 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?1" class="extiw" title="meatball:1">meatball:1</a>
24382 <a href="http://www.usemod.com/cgi-bin/mb.pl?2" class="extiw" title="meatball:2">meatball:2</a>
24383 <a href="http://www.usemod.com/cgi-bin/mb.pl?3" class="extiw" title="meatball:3">meatball:3</a>
24384 </p>
24385 !! end
24386
24387 !! test
24388 Free external link invading image caption
24389 !! wikitext
24390 [[Image:Foobar.jpg|thumb|http://x|hello]]
24391 !! html/php
24392 <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>
24393
24394 !! html/parsoid
24395 <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>
24396 !! end
24397
24398 !! test
24399 T17196: localised external link numbers
24400 !! options
24401 language=fa
24402 !! wikitext
24403 [http://en.wikipedia.org/]
24404 !! html/php
24405 <p><a rel="nofollow" class="external autonumber" href="http://en.wikipedia.org/">[۱]</a>
24406 </p>
24407 !! html/parsoid
24408 <p><a rel="mw:ExtLink" class="external autonumber" href="http://en.wikipedia.org/"></a></p>
24409 !! end
24410
24411 !! test
24412 Multibyte character in padleft
24413 !! wikitext
24414 {{padleft:-Hello|7|Æ}}
24415 !! html/php
24416 <p>Æ-Hello
24417 </p>
24418 !! html/parsoid
24419 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padleft:-Hello","function":"padleft"},"params":{"1":{"wt":"7"},"2":{"wt":"Æ"}},"i":0}}]}'>Æ-Hello</p>
24420 !! end
24421
24422 !! test
24423 Multibyte character in padright
24424 !! wikitext
24425 {{padright:Hello-|7|Æ}}
24426 !! html/php
24427 <p>Hello-Æ
24428 </p>
24429 !! html/parsoid
24430 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padright:Hello-","function":"padright"},"params":{"1":{"wt":"7"},"2":{"wt":"Æ"}},"i":0}}]}'>Hello-Æ</p>
24431 !! end
24432
24433 !!test
24434 formatdate parser function
24435 !! wikitext
24436 {{#formatdate:2009-03-24}}
24437 !! html
24438 <p><span class="mw-formatted-date" title="2009-03-24">2009-03-24</span>
24439 </p>
24440 !! end
24441
24442 !!test
24443 formatdate parser function, with default format
24444 !! wikitext
24445 {{#formatdate:2009-03-24|mdy}}
24446 !! html
24447 <p><span class="mw-formatted-date" title="2009-03-24">March 24, 2009</span>
24448 </p>
24449 !! end
24450
24451 !! test
24452 Spacing of numbers in formatted dates
24453 !! wikitext
24454 {{#formatdate:January 15}}
24455 !! html
24456 <p><span class="mw-formatted-date" title="01-15">January 15</span>
24457 </p>
24458 !! end
24459
24460 !! test
24461 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
24462 !! options
24463 language=nl title=[[MediaWiki:Common.css]]
24464 !! wikitext
24465 {{#formatdate:2009-03-24|dmy}}
24466 !! html
24467 <p><span class="mw-formatted-date" title="2009-03-24">24 March 2009</span>
24468 </p>
24469 !! end
24470
24471 #
24472 #
24473 #
24474
24475 #
24476 # Edit comments
24477 #
24478
24479 !! test
24480 Edit comment with link
24481 !! options
24482 comment
24483 !! wikitext
24484 I like the [[Main Page]] a lot
24485 !! html/php
24486 I like the <a href="/wiki/Main_Page" title="Main Page">Main Page</a> a lot
24487 !!end
24488
24489 !! test
24490 Edit comment with link and link text
24491 !! options
24492 comment
24493 !! wikitext
24494 I like the [[Main Page|best pages]] a lot
24495 !! html/php
24496 I like the <a href="/wiki/Main_Page" title="Main Page">best pages</a> a lot
24497 !!end
24498
24499 !! test
24500 Edit comment with link and link text with suffix
24501 !! options
24502 comment
24503 !! wikitext
24504 I like the [[Main Page|best page]]s a lot
24505 !! html/php
24506 I like the <a href="/wiki/Main_Page" title="Main Page">best pages</a> a lot
24507 !!end
24508
24509 !! test
24510 Edit comment with section link (non-local, eg in history list)
24511 !! options
24512 comment title=[[Main Page]]
24513 !! wikitext
24514 /* External links */ removed bogus entries
24515 !! html/php
24516 <span dir="auto"><span class="autocomment"><a href="/wiki/Main_Page#External_links" title="Main Page">→‎External links</a>: </span> removed bogus entries</span>
24517 !!end
24518
24519 !! test
24520 Edit comment with section link and text before it (non-local, eg in history list)
24521 !! options
24522 comment title=[[Main Page]]
24523 !! wikitext
24524 pre-comment text /* External links */ removed bogus entries
24525 !! html/php
24526 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>
24527 !!end
24528
24529 !! test
24530 Edit comment with section link (local, eg in diff view)
24531 !! options
24532 comment local title=[[Main Page]]
24533 !! wikitext
24534 /* External links */ removed bogus entries
24535 !! html/php
24536 <span dir="auto"><span class="autocomment"><a href="#External_links">→‎External links</a>: </span> removed bogus entries</span>
24537 !!end
24538
24539 !! test
24540 Edit comment with section link that has a link in it
24541 !! options
24542 comment local title=[[Main Page]]
24543 !! wikitext
24544 /* [[A link]] */
24545 !! html/php
24546 <span dir="auto"><span class="autocomment"><a href="#A_link">→‎&#91;[A link]]</a></span></span>
24547 !! end
24548
24549 !! test
24550 Edit comment with section link that has a template in it
24551 !! options
24552 comment local title=[[Main Page]]
24553 !! wikitext
24554 /* {{foobar|param}} */
24555 !! html/php
24556 <span dir="auto"><span class="autocomment"><a href="#.7B.7Bfoobar.7Cparam.7D.7D">→‎{{foobar|param}}</a></span></span>
24557 !! end
24558
24559 !! test
24560 Edit comment with subpage link (T16080)
24561 !! options
24562 comment
24563 subpage
24564 title=[[Subpage test]]
24565 !! wikitext
24566 Poked at a [[/subpage]] here...
24567 !! html/php
24568 Poked at a <a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a> here...
24569 !!end
24570
24571 !! test
24572 Edit comment with subpage link and link text (T16080)
24573 !! options
24574 comment
24575 subpage
24576 title=[[Subpage test]]
24577 !! wikitext
24578 Poked at a [[/subpage|neat little page]] here...
24579 !! html/php
24580 Poked at a <a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">neat little page</a> here...
24581 !!end
24582
24583 !! test
24584 Edit comment with bogus subpage link in non-subpage NS (T16080)
24585 !! options
24586 comment
24587 title=[[Subpage test]]
24588 !! wikitext
24589 Poked at a [[/subpage]] here...
24590 !! html/php
24591 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...
24592 !!end
24593
24594 !! test
24595 Edit comment with bare anchor link (local, as on diff)
24596 !! options
24597 comment
24598 local
24599 title=[[Main Page]]
24600 !! wikitext
24601 [[#section]]
24602 !! html/php
24603 <a href="#section">#section</a>
24604 !! end
24605
24606 !! test
24607 Edit comment with bare anchor link (non-local, as on history)
24608 !! options
24609 comment
24610 title=[[Main Page]]
24611 !! wikitext
24612 [[#section]]
24613 !! html/php
24614 <a href="/wiki/Main_Page#section" title="Main Page">#section</a>
24615 !! end
24616
24617 !! test
24618 Anchor starting with underscore
24619 !! options
24620 title=[[Foo]]
24621 !! wikitext
24622 [[#_ref|One]]
24623 !! html/php
24624 <p><a href="#_ref">One</a>
24625 </p>
24626 !! html/parsoid
24627 <p><a rel="mw:WikiLink" href="./Foo#_ref" data-parsoid='{"stx":"piped","a":{"href":"./Foo#_ref"},"sa":{"href":"#_ref"}}'>One</a></p>
24628 !! end
24629
24630 !! test
24631 Id starting with underscore
24632 !! wikitext
24633 <div id="_ref"></div>
24634 !! html/*
24635 <div id="_ref"></div>
24636
24637 !! end
24638
24639 !! test
24640 Edit comment with link with more than one pipe (T99346)
24641 !! options
24642 comment
24643 !! wikitext
24644 [[Main Page|Many|pipes]]
24645 !! html/php
24646 <a href="/wiki/Main_Page" title="Main Page">Many|pipes</a>
24647 !! end
24648
24649 !! test
24650 Complex edit comment with link with more than one pipe (T99346)
24651 !! options
24652 comment
24653 !! wikitext
24654 Created page with "<noinclude>[[Category:Requests for permissions/Bot|{{subst:#titleparts:{{subst:PAGENAME}}|1|3}}]]</noinclude> === [[User:MineoBot|]] 8=== {{Request for permissions/links|Mineo..."
24655 !! html/php
24656 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;
24657 !! end
24658
24659 !! test
24660 Space normalisation on autocomment (T24784)
24661 !! options
24662 comment
24663 title=[[Main Page]]
24664 !! wikitext
24665 /* __hello__world__ */
24666 !! html/php
24667 <span dir="auto"><span class="autocomment"><a href="/wiki/Main_Page#hello_world" title="Main Page">→‎__hello__world__</a></span></span>
24668 !! end
24669
24670 !! test
24671 percent-encoding and + signs in comments (T28410)
24672 !! options
24673 comment
24674 !! wikitext
24675 [[ABC%33D% ++]] [[ABC%33D% ++|+%20]]
24676 !! html/php
24677 <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>
24678 !! end
24679
24680 # Parsoid doesn't support this yet: see T75581
24681 # but it *should* omit the 'src' attribute if the image is bad.
24682 # PHP side of tests was disabled in
24683 # mediawiki/core:6bd31e7d95161a6e88fa86df60871051da997c3c
24684 # because of issues in the PHP parserTests infrastructure
24685 # (but the output below is indeed what the PHP side emits)
24686 !! test
24687 Bad images - basic functionality
24688 !! wikitext
24689 [[File:Bad.jpg]]
24690 !! html/php+disabled
24691 !! html/parsoid
24692 <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>
24693 !! end
24694
24695 !! test
24696 Bad images - T18039: text after bad image disappears
24697 !! wikitext
24698 Foo bar
24699 [[File:Bad.jpg]]
24700 Bar foo
24701 !! html/php+disabled
24702 <p>Foo bar
24703 </p><p>Bar foo
24704 </p>
24705 !! html/parsoid
24706 <p>Foo bar
24707 <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>
24708 Bar foo</p>
24709 !! end
24710
24711 !! test
24712 Verify that displaytitle works (T24501) no displaytitle
24713 !! options
24714 showtitle
24715 !! config
24716 wgAllowDisplayTitle=true
24717 wgRestrictDisplayTitle=false
24718 !! wikitext
24719 this is not the the title
24720 !! html/php
24721 Parser test
24722 <p>this is not the the title
24723 </p>
24724 !! end
24725
24726 !! test
24727 Verify that displaytitle works (T24501) RestrictDisplayTitle=false
24728 !! options
24729 showtitle
24730 title=[[Screen]]
24731 !! config
24732 wgAllowDisplayTitle=true
24733 wgRestrictDisplayTitle=false
24734 !! wikitext
24735 this is not the the title
24736 {{DISPLAYTITLE:whatever}}
24737 !! html/php
24738 whatever
24739 <p>this is not the the title
24740 </p>
24741 !! end
24742
24743 !! test
24744 Verify that displaytitle works (T24501) RestrictDisplayTitle=true mismatch
24745 !! options
24746 showtitle
24747 title=[[Screen]]
24748 !! config
24749 wgAllowDisplayTitle=true
24750 wgRestrictDisplayTitle=true
24751 !! wikitext
24752 this is not the the title
24753 {{DISPLAYTITLE:whatever}}
24754 !! html/php
24755 Screen
24756 <p>this is not the the title
24757 </p>
24758 !! end
24759
24760 !! test
24761 Verify that displaytitle works (T24501) RestrictDisplayTitle=true matching
24762 !! options
24763 showtitle
24764 title=[[Screen]]
24765 !! config
24766 wgAllowDisplayTitle=true
24767 wgRestrictDisplayTitle=true
24768 !! wikitext
24769 this is not the the title
24770 {{DISPLAYTITLE:screen}}
24771 !! html/php
24772 screen
24773 <p>this is not the the title
24774 </p>
24775 !! end
24776
24777 !! test
24778 Verify that displaytitle works (T24501) AllowDisplayTitle=false
24779 !! options
24780 showtitle
24781 title=[[Screen]]
24782 !! config
24783 wgAllowDisplayTitle=false
24784 !! wikitext
24785 this is not the the title
24786 {{DISPLAYTITLE:screen}}
24787 !! html/php
24788 Screen
24789 <p>this is not the the title
24790 <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>
24791 </p>
24792 !! end
24793
24794 !! test
24795 Verify that displaytitle works (T24501) AllowDisplayTitle=false no DISPLAYTITLE
24796 !! options
24797 showtitle
24798 title=[[Screen]]
24799 !! config
24800 wgAllowDisplayTitle=false
24801 !! wikitext
24802 this is not the the title
24803 !! html/php
24804 Screen
24805 <p>this is not the the title
24806 </p>
24807 !! end
24808
24809 !! test
24810 Verify that displaytitle handles inline CSS styles (T28547) - rejected value
24811 !! options
24812 showtitle
24813 title=[[Screen]]
24814 !! config
24815 wgAllowDisplayTitle=true
24816 wgRestrictDisplayTitle=true
24817 !! wikitext
24818 this is not the the title
24819 {{DISPLAYTITLE:<span style="display: none;">s</span>creen}}
24820 !! html/php
24821 <span style="/* attempt to bypass $wgRestrictDisplayTitle */">s</span>creen
24822 <p>this is not the the title
24823 </p>
24824 !! end
24825
24826 !! test
24827 Verify that displaytitle handles inline CSS styles (T28547) - accepted value
24828 !! options
24829 showtitle
24830 title=[[Screen]]
24831 !! config
24832 wgAllowDisplayTitle=true
24833 wgRestrictDisplayTitle=true
24834 !! wikitext
24835 this is not the the title
24836 {{DISPLAYTITLE:<span style="color: red;">s</span>creen}}
24837 !! html/php
24838 <span style="color: red;">s</span>creen
24839 <p>this is not the the title
24840 </p>
24841 !! end
24842
24843 !! test
24844 Page status indicators: Empty name is invalid
24845 !! options
24846 showindicators
24847 !! wikitext
24848 <indicator name=" "></indicator>
24849 <indicator></indicator>
24850 !! html/php
24851 <p><span class="error"><strong>Error:</strong> Page status indicators' <code>name</code> attribute must not be empty.</span>
24852 <span class="error"><strong>Error:</strong> Page status indicators' <code>name</code> attribute must not be empty.</span>
24853 </p>
24854 !! end
24855
24856 !! test
24857 Page status indicators: Weird syntaxes that are okay
24858 !! options
24859 showindicators
24860 !! wikitext
24861 <indicator name="empty" />
24862 <indicator name="name"></indicator>
24863 !! html/php
24864 empty=
24865 name=
24866 <p><br />
24867 </p>
24868 !! end
24869
24870 !! test
24871 Page status indicators: Torture test
24872 !! options
24873 showindicators
24874 !! wikitext
24875 <indicator name="01">hello world</indicator>
24876 <indicator name="02">[[Main Page]]</indicator>
24877 <indicator name="03">[[File:Foobar.jpg|25px|link=]]</indicator>
24878 <indicator name="04">[[File:Foobar.jpg|25px]]</indicator>
24879 <indicator name="05">*foo
24880 *bar</indicator>
24881 <indicator name="06"><nowiki>foo</nowiki></indicator>
24882 <indicator name="07"> Preformatted</indicator>
24883 <indicator name="08"><div>Broken tag</indicator>
24884 <indicator name="09">{| class=wikitable
24885 |cell
24886 |}</indicator>
24887 <indicator name="10">Two
24888
24889 paragraphs</indicator>
24890 !! html/php
24891 01=hello world
24892 02=<a href="/wiki/Main_Page" title="Main Page">Main Page</a>
24893 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" />
24894 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>
24895 05=<ul><li>foo</li>
24896 <li>bar</li></ul>
24897
24898 06=foo
24899 07=<pre>Preformatted
24900 </pre>
24901 08=<div>Broken tag</div>
24902
24903 09=<table class="wikitable">
24904 <tr>
24905 <td>cell
24906 </td></tr></table>
24907
24908 10=<p>Two
24909 </p><p>paragraphs
24910 </p>
24911 <p><br />
24912 </p><p><br />
24913 </p><p><br />
24914 </p><p><br />
24915 </p><p><br />
24916 </p>
24917 !! end
24918
24919 !! test
24920 preload: check <noinclude> and <includeonly>
24921 !! options
24922 preload
24923 !! wikitext
24924 Hello <noinclude>cruel</noinclude><includeonly>kind</includeonly> world.
24925 !! html/php
24926 Hello kind world.
24927 !! end
24928
24929 !! test
24930 preload: check <onlyinclude>
24931 !! options
24932 preload
24933 !! wikitext
24934 Goodbye <onlyinclude>Hello world</onlyinclude>
24935 !! html/php
24936 Hello world
24937 !! end
24938
24939 !! test
24940 preload: can pass tags through if we want to
24941 !! options
24942 preload
24943 !! wikitext
24944 <includeonly><</includeonly>includeonly>Hello world<includeonly><</includeonly>/includeonly>
24945 !! html/php
24946 <includeonly>Hello world</includeonly>
24947 !! end
24948
24949 !! test
24950 preload: check that it doesn't try to do tricks
24951 !! options
24952 preload
24953 !! wikitext
24954 * <!-- Hello --> ''{{world}}'' {{<includeonly>subst:</includeonly>How are you}}{{ {{{|safesubst:}}} #if:1|2|3}}
24955 !! html/php
24956 * <!-- Hello --> ''{{world}}'' {{subst:How are you}}{{ {{{|safesubst:}}} #if:1|2|3}}
24957 !! end
24958
24959 !! test
24960 Play a bit with r67090 and T5158
24961 !! wikitext
24962 <div style="width:50% !important">&nbsp;</div>
24963 <div style="width:50%&nbsp;!important">&nbsp;</div>
24964 <div style="width:50%&#160;!important">&nbsp;</div>
24965 <div style="border : solid;">&nbsp;</div>
24966 !! html/php
24967 <div style="width:50% !important">&#160;</div>
24968 <div style="width:50% !important">&#160;</div>
24969 <div style="width:50% !important">&#160;</div>
24970 <div style="border&#32;: solid;">&#160;</div>
24971
24972 !! html/parsoid
24973 <div style="width:50% !important" data-parsoid='{"stx":"html"}'><span typeof="mw:Entity" data-parsoid='{"srcContent":" "}'> </span></div>
24974 <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>
24975 <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>
24976 <div style="border : solid;" data-parsoid='{"stx":"html"}'><span typeof="mw:Entity" data-parsoid='{"srcContent":" "}'> </span></div>
24977
24978 !! end
24979
24980 !! test
24981 French spaces in wikitext
24982 !! wikitext
24983 foo ! bar ? bat 50 % is less than 75 %.
24984
24985 Hello : this ; is « something ‹ else › again »
24986 !! html
24987 <p>foo&#160;! bar&#160;? bat 50&#160;% is less than 75&#160;%.
24988 </p><p>Hello&#160;: this&#160;; is «&#160;something ‹&#160;else&#160;› again&#160;»
24989 </p>
24990 !! end
24991
24992 # It would be reasonable for Parsoid and PHP to differ here.
24993 # The PHP behavior is arguably a bug.
24994 !! test
24995 Corner case: french spaces in definition list
24996 !! wikitext
24997 ;foo : bar
24998 !! html+tidy
24999 <dl><dt>foo&#160;</dt>
25000 <dd>bar</dd></dl>
25001 !! end
25002
25003 !! test
25004 T5158: Test for French spaces in attributes
25005 !! wikitext
25006 <br style=" clear : both ; " />
25007 !! html/php
25008 <p><br style="clear&#32;: both&#32;;" />
25009 </p>
25010 !! end
25011
25012 !! test
25013 HTML5 data attributes
25014 !! wikitext
25015 <span data-foo="bar">Baz</span>
25016 <p data-abc-def_hij="">Quuz</p>
25017 !! html/php
25018 <p><span data-foo="bar">Baz</span>
25019 </p>
25020 <p data-abc-def_hij="">Quuz</p>
25021
25022 !! html/parsoid
25023 <p><span data-foo="bar" data-parsoid='{"stx":"html"}'>Baz</span></p>
25024 <p data-abc-def_hij="" data-parsoid='{"stx":"html"}'>Quuz</p>
25025 !! end
25026
25027 !! test
25028 Strip reserved data attributes
25029 !! wikitext
25030 <div data-mw="foo" data-parsoid="bar" data-mw-someext="baz" data-ok="fred" data-ooui="xyzzy" data-bad:ns="ns">d</div>
25031 !! html/php
25032 <div data-ok="fred">d</div>
25033
25034 !! html/parsoid
25035 <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>
25036 !! end
25037
25038 !! test
25039 percent-encoding and + signs in internal links (T28410)
25040 !! wikitext
25041 [[User:+%]] [[Page+title%]]
25042 [[%+]] [[%+|%20]] [[%+ ]] [[%+r]]
25043 [[%]] [[+]] [[File:%+abc%39|foo|[[bar]]]]
25044 [[%33%45]] [[%33%45+]]
25045 !! html/php
25046 <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>
25047 <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>
25048 <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>
25049 <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>
25050 </p>
25051 !! html/parsoid
25052 <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>
25053 <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>
25054 <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>
25055 <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>
25056 !! end
25057
25058 !! test
25059 Special characters in embedded file links (T29679)
25060 !! wikitext
25061 [[File:Contains & ampersand.jpg]]
25062 [[File:Does not exist.jpg|Title with & ampersand]]
25063 !! html/php
25064 <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>
25065 <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>
25066 </p>
25067 !! html/parsoid
25068 <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>
25069 <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>
25070 !! end
25071
25072 !! test
25073 Confirm that 'apos' named character reference doesn't make it to output (not legal in HTML 4)
25074 !! wikitext
25075 Text&apos;s been normalized?
25076 !! html
25077 <p>Text&#39;s been normalized?
25078 </p>
25079 !! end
25080
25081 !! test
25082 T21052 U+3000 IDEOGRAPHIC SPACE should terminate free external links
25083 !! wikitext
25084 http://www.example.org/ <-- U+3000 (vim: ^Vu3000)
25085 !! html
25086 <p><a rel="nofollow" class="external free" href="http://www.example.org/">http://www.example.org/</a> &lt;-- U+3000 (vim: ^Vu3000)
25087 </p>
25088 !! end
25089
25090 !! test
25091 T21052 U+3000 IDEOGRAPHIC SPACE should terminate bracketed external links
25092 !! wikitext
25093 [http://www.example.org/ ideograms]
25094 !! html
25095 <p><a rel="nofollow" class="external text" href="http://www.example.org/">ideograms</a>
25096 </p>
25097 !! end
25098
25099 !! test
25100 T21052 U+3000 IDEOGRAPHIC SPACE should terminate external images links
25101 !! wikitext
25102 http://www.example.org/pic.png <-- U+3000 (vim: ^Vu3000)
25103 !! html
25104 <p><img src="http://www.example.org/pic.png" alt="pic.png"/> &lt;-- U+3000 (vim: ^Vu3000)
25105 </p>
25106 !! end
25107
25108 !! article
25109 Mediawiki:loop1
25110 !! text
25111 {{Identical|A}}
25112 !! endarticle
25113
25114 !! article
25115 Mediawiki:loop2
25116 !! text
25117 {{Identical|B}}
25118 !! endarticle
25119
25120 !! article
25121 Template:Identical
25122 !! text
25123 {{int:loop1}}
25124 {{int:loop2}}
25125 !! endarticle
25126
25127 !! test
25128 T33098 Template which includes system messages which includes the template
25129 !! wikitext
25130 {{Identical}}
25131 !! html
25132 <p><span class="error">Template loop detected: <a href="/wiki/Template:Identical" title="Template:Identical">Template:Identical</a></span>
25133 <span class="error">Template loop detected: <a href="/wiki/Template:Identical" title="Template:Identical">Template:Identical</a></span>
25134 </p>
25135 !! end
25136
25137 !! test
25138 T33490 Turkish: ucfirst 'blah'
25139 !! options
25140 language=tr
25141 !! wikitext
25142 {{ucfirst:blah}}
25143 !! html
25144 <p>Blah
25145 </p>
25146 !! end
25147
25148 !! test
25149 T33490 Turkish: ucfirst 'ix'
25150 !! options
25151 language=tr
25152 !! wikitext
25153 {{ucfirst:ix}}
25154 !! html
25155 <p>İx
25156 </p>
25157 !! end
25158
25159 !! test
25160 T33490 Turkish: lcfirst 'BLAH'
25161 !! options
25162 language=tr
25163 !! wikitext
25164 {{lcfirst:BLAH}}
25165 !! html
25166 <p>bLAH
25167 </p>
25168 !! end
25169
25170 !! test
25171 T33490 Turkish: ucfırst (with a dotless i)
25172 !! options
25173 language=tr
25174 !! wikitext
25175 {{ucfırst:blah}}
25176 !! html
25177 <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>
25178 </p>
25179 !! end
25180
25181 !! test
25182 T33490 ucfırst (with a dotless i) with English language
25183 !! options
25184 language=en
25185 !! wikitext
25186 {{ucfırst:blah}}
25187 !! html
25188 <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>
25189 </p>
25190 !! end
25191
25192 # Note that Parsoid doesn't emit an explicit TOC.
25193 # Note also that the html2wt direction tends to emit an extra newline
25194 # between the __TOC__ magicword and the first heading unless *both*
25195 # the <meta> and the <h2> have a data-parsoid attribute set (even if
25196 # it's "{}").
25197
25198 !! test
25199 T28375: TOC with italics
25200 !! options
25201 title=[[Main Page]]
25202 !! wikitext
25203 __TOC__
25204 ==''Lost'' episodes==
25205 !! html/php
25206 <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>
25207 <ul>
25208 <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>
25209 </ul>
25210 </div>
25211
25212 <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>
25213
25214 !! html/parsoid
25215 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25216 <h2 id="Lost_episodes" data-parsoid='{}'><i>Lost</i> episodes</h2>
25217 !! end
25218
25219 !! test
25220 T28375: TOC with bold
25221 !! options
25222 title=[[Main Page]]
25223 !! wikitext
25224 __TOC__
25225 =='''should be bold''' then normal text==
25226 !! html/php
25227 <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>
25228 <ul>
25229 <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>
25230 </ul>
25231 </div>
25232
25233 <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>
25234
25235 !! html/parsoid
25236 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25237 <h2 id="should_be_bold_then_normal_text" data-parsoid='{}'><b>should be bold</b> then normal text</h2>
25238 !! end
25239
25240 !! test
25241 T35845: Headings become cursive in TOC when they contain an image
25242 !! options
25243 title=[[Main Page]]
25244 !! wikitext
25245 __TOC__
25246 ==Image [[Image:foobar.jpg]]==
25247 !! html/php
25248 <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>
25249 <ul>
25250 <li class="toclevel-1 tocsection-1"><a href="#Image"><span class="tocnumber">1</span> <span class="toctext">Image</span></a></li>
25251 </ul>
25252 </div>
25253
25254 <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>
25255
25256 !! html/parsoid
25257 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25258 <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>
25259 !! end
25260
25261 !! test
25262 T35845 (2): Headings become bold in TOC when they contain a blockquote
25263 !! options
25264 title=[[Main Page]]
25265 !! wikitext
25266 __TOC__
25267 ==<blockquote>Quote</blockquote>==
25268 !! html/php
25269 <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>
25270 <ul>
25271 <li class="toclevel-1 tocsection-1"><a href="#Quote"><span class="tocnumber">1</span> <span class="toctext">Quote</span></a></li>
25272 </ul>
25273 </div>
25274
25275 <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>
25276
25277 !! html/php+tidy
25278 <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>
25279 <ul>
25280 <li class="toclevel-1 tocsection-1"><a href="#Quote"><span class="tocnumber">1</span> <span class="toctext">Quote</span></a></li>
25281 </ul>
25282 </div>
25283
25284 <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>
25285 !! html/parsoid
25286 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25287 <h2 id="Quote" data-parsoid='{}'><blockquote><p>Quote</p></blockquote></h2>
25288 !! end
25289
25290 !! test
25291 Unclosed tags in TOC
25292 !! config
25293 wgFragmentMode=[ 'html5', 'legacy' ]
25294 !! options
25295 title=[[Main Page]]
25296 !! wikitext
25297 __TOC__
25298 ==Proof: 2 < 3==
25299 <small>Hanc marginis exiguitas non caperet.</small>
25300 QED
25301 !! html/php
25302 <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>
25303 <ul>
25304 <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>
25305 </ul>
25306 </div>
25307
25308 <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>
25309 <p><small>Hanc marginis exiguitas non caperet.</small>
25310 QED
25311 </p>
25312 !! html/parsoid
25313 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25314 <h2 id="Proof:_2_&lt;_3" data-parsoid='{}'><span id="Proof:_2_.3C_3" typeof="mw:FallbackId"></span>Proof: 2 &lt; 3</h2>
25315 <p><small>Hanc marginis exiguitas non caperet.</small>
25316 QED</p>
25317 !! end
25318
25319 !! test
25320 Multiple tags in TOC
25321 !! wikitext
25322 __TOC__
25323 ==<i>Foo</i> <b>Bar</b>==
25324
25325 ==<i>Foo</i> <blockquote>Bar</blockquote>==
25326 !! html/php
25327 <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>
25328 <ul>
25329 <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>
25330 <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>
25331 </ul>
25332 </div>
25333
25334 <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>
25335 <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>
25336
25337 !! html/php+tidy
25338 <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>
25339 <ul>
25340 <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>
25341 <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>
25342 </ul>
25343 </div>
25344
25345 <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>
25346 <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>
25347 !! html/parsoid
25348 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25349 <h2 id="Foo_Bar" data-parsoid='{}'><i data-parsoid='{"stx":"html"}'>Foo</i> <b data-parsoid='{"stx":"html"}'>Bar</b></h2>
25350
25351 <h2 id="Foo_Bar_2" data-parsoid='{}'><i data-parsoid='{"stx":"html"}'>Foo</i> <blockquote><p>Bar</p></blockquote></h2>
25352 !! end
25353
25354 # Don't expect Parsoid to roundtrip this until the php parser comes closer to
25355 # html5 tag parsing.
25356 !! test
25357 Tags with parameters in TOC
25358 !! options
25359 parsoid=wt2html
25360 !! wikitext
25361 __TOC__
25362 ==<sup class="in-h2">Hello</sup>==
25363
25364 ==<sup class="a > b">Evilbye</sup>==
25365 !! html/php
25366 <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>
25367 <ul>
25368 <li class="toclevel-1 tocsection-1"><a href="#Hello"><span class="tocnumber">1</span> <span class="toctext"><sup>Hello</sup></span></a></li>
25369 <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>
25370 </ul>
25371 </div>
25372
25373 <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>
25374 <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>
25375
25376 !! html/parsoid
25377 <meta property="mw:PageProp/toc" />
25378 <h2 id="Hello"><sup class="in-h2" data-parsoid='{"stx":"html"}'>Hello</sup></h2>
25379
25380 <h2 id='b">Evilbye'><span id="b.22.3EEvilbye" typeof="mw:FallbackId"></span><sup class="a " data-parsoid='{"stx":"html"}'> b">Evilbye</sup></h2>
25381 !! end
25382
25383 !! test
25384 span tags with directionality in TOC
25385 !! wikitext
25386 __TOC__
25387 ==<span dir="ltr">C++</span>==
25388
25389 ==<span dir="rtl">זבנג!</span>==
25390
25391 ==<span style="font-style: italic">The attributes on these span tags must be deleted from the TOC</span>==
25392
25393 ==<span style="font-style: italic" dir="ltr">All attributes on these span tags must be deleted from the TOC</span>==
25394
25395 ==<span dir="ltr" style="font-style: italic">Attributes after dir on these span tags must be deleted from the TOC</span>==
25396 !! html/php
25397 <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>
25398 <ul>
25399 <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>
25400 <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>
25401 <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>
25402 <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>
25403 <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>
25404 </ul>
25405 </div>
25406
25407 <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>
25408 <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>
25409 <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>
25410 <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>
25411 <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>
25412
25413 !! html/parsoid
25414 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25415 <h2 id="C++" data-parsoid='{}'><span id="C.2B.2B" typeof="mw:FallbackId"></span><span dir="ltr">C++</span></h2>
25416 <h2 id="זבנג!"><span id=".D7.96.D7.91.D7.A0.D7.92.21" typeof="mw:FallbackId"></span><span dir="rtl">זבנג!</span></h2>
25417 <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>
25418 <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>
25419 <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>
25420 !! end
25421
25422 !! test
25423 T74884: bdi element in ToC
25424 !! wikitext
25425 __TOC__
25426 ==<bdi>test</bdi>==
25427 !! html/php
25428 <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>
25429 <ul>
25430 <li class="toclevel-1 tocsection-1"><a href="#test"><span class="tocnumber">1</span> <span class="toctext"><bdi>test</bdi></span></a></li>
25431 </ul>
25432 </div>
25433
25434 <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>
25435
25436 !! html/parsoid
25437 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25438 <h2 id="test" data-parsoid='{}'><bdi>test</bdi></h2>
25439 !! end
25440
25441 !! test
25442 T35715: s/strike element in ToC
25443 !! wikitext
25444 __TOC__
25445 ==<s>test</s> test <strike>test</strike>==
25446 !! html/php
25447 <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>
25448 <ul>
25449 <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>
25450 </ul>
25451 </div>
25452
25453 <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>
25454
25455 !! html/parsoid
25456 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25457 <h2 id="test_test_test" data-parsoid='{}'><s>test</s> test <strike>test</strike></h2>
25458 !! end
25459
25460 !! test
25461 T198618: style element in ToC
25462 !! options
25463 styletag=1
25464 !! wikitext
25465 __TOC__
25466 ==<style>.foo {}</style>Style<style>.bar {}</style>==
25467 !! html/php
25468 <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>
25469 <ul>
25470 <li class="toclevel-1 tocsection-1"><a href="#Style"><span class="tocnumber">1</span> <span class="toctext">Style</span></a></li>
25471 </ul>
25472 </div>
25473
25474 <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>
25475
25476 !! html/parsoid
25477 <meta property="mw:PageProp/toc" data-parsoid="{}"/>
25478 <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>
25479 !! end
25480
25481 !! test
25482 T198618: script element in ToC
25483 !! options
25484 wgRawHtml=1
25485 !! wikitext
25486 __TOC__
25487 ==<html><script>alert(1);</script></html>Script<html><script>alert(1);</script></html>==
25488 !! html/php
25489 <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>
25490 <ul>
25491 <li class="toclevel-1 tocsection-1"><a href="#Script"><span class="tocnumber">1</span> <span class="toctext">Script</span></a></li>
25492 </ul>
25493 </div>
25494
25495 <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>
25496
25497 !! html/parsoid
25498 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25499 <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>
25500 !! end
25501
25502 !! test
25503 Empty <p> tag in TOC, removed by Sanitizer (T92892)
25504 !! wikitext
25505 __TOC__
25506 ==x==
25507 !! html/php
25508 <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>
25509 <ul>
25510 <li class="toclevel-1 tocsection-1"><a href="#x"><span class="tocnumber">1</span> <span class="toctext">x</span></a></li>
25511 </ul>
25512 </div>
25513
25514 <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>
25515
25516 !! html/parsoid
25517 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25518 <h2 id="x" data-parsoid='{}'>x</h2>
25519 !! end
25520
25521 !! article
25522 MediaWiki:T34057
25523 !! text
25524 == {{int:headline_sample}} ==
25525 !! endarticle
25526
25527 !! test
25528 T34057: Title needed when expanding <h> nodes.
25529 !! options
25530 title=[[Main Page]]
25531 !! wikitext
25532 {{int:T34057}}
25533 !! html
25534 <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>
25535
25536 !! end
25537
25538 !! test
25539 Strip marker in urlencode
25540 !! wikitext
25541 {{urlencode:x<nowiki/>y}}
25542 {{urlencode:x<nowiki/>y|wiki}}
25543 {{urlencode:x<nowiki/>y|path}}
25544 {{urlencode:x<pre id="one">two</pre>y}}
25545 !! html/php
25546 <p>xy
25547 xy
25548 xy
25549 xy
25550 </p>
25551 !! end
25552
25553 !! test
25554 Strip marker in lc
25555 !! wikitext
25556 {{lc:x<nowiki/>y}}
25557 !! html
25558 <p>xy
25559 </p>
25560 !! end
25561
25562 !! test
25563 Strip marker in uc
25564 !! wikitext
25565 {{uc:x<nowiki/>y}}
25566 !! html
25567 <p>XY
25568 </p>
25569 !! end
25570
25571 !! test
25572 Strip marker in formatNum
25573 !! wikitext
25574 {{formatnum:1<nowiki/>2}}
25575 {{formatnum:1<nowiki/>2|R}}
25576 !! html
25577 <p>12
25578 12
25579 </p>
25580 !! end
25581
25582 !! test
25583 Check noCommafy in formatNum
25584 !! options
25585 language=be-tarask
25586 !! wikitext
25587 {{formatnum:123456.78}}
25588 {{formatnum:123456.78|NOSEP}}
25589 !! html
25590 <p>123 456,78
25591 123456.78
25592 </p>
25593 !! end
25594
25595 !! test
25596 Wrong option for formatNum (T58199)
25597 !! wikitext
25598 {{formatnum:1,234.56|Random}}
25599 {{formatnum:1,234.56|EVERYTHING}}
25600 {{formatnum:1234.56|any argument that has the string 'NOSEP'}}
25601 !! html
25602 <p>1,234.56
25603 1,234.56
25604 1,234.56
25605 </p>
25606 !! end
25607
25608 !! test
25609 Strip marker in grammar
25610 !! options
25611 language=fi
25612 !! wikitext
25613 {{grammar:elative|foo<nowiki/>bar}}
25614 !! html
25615 <p>foobarista
25616 </p>
25617 !! end
25618
25619 !! test
25620 Strip marker in padleft
25621 !! wikitext
25622 {{padleft:|2|x<nowiki/>y}}
25623 !! html
25624 <p>xy
25625 </p>
25626 !! end
25627
25628 !! test
25629 Strip marker in padright
25630 !! wikitext
25631 {{padright:|2|x<nowiki/>y}}
25632 !! html
25633 <p>xy
25634 </p>
25635 !! end
25636
25637 !! test
25638 Strip marker in anchorencode
25639 !! wikitext
25640 {{anchorencode:x<nowiki/>y}}
25641 !! html/php
25642 <p>xy
25643 </p>
25644 !! html/parsoid
25645 <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>
25646 !! end
25647
25648 !! test
25649 nowiki inside link inside heading (T20295)
25650 !! wikitext
25651 ==[[foo|x<nowiki>y</nowiki>z]]==
25652 !! html
25653 <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>
25654
25655 !! end
25656
25657 !! test
25658 new support for bdi element (T33817)
25659 !! wikitext
25660 <p dir="rtl" lang="he">ולדימיר לנין (ברוסית: <bdi lang="ru">Владимир Ленин</bdi>, 24 באפריל 1870–22 בינואר 1924) הוא מנהיג פוליטי קומוניסטי רוסי.</p>
25661 !! html
25662 <p dir="rtl" lang="he">ולדימיר לנין (ברוסית: <bdi lang="ru">Владимир Ленин</bdi>, 24 באפריל 1870–22 בינואר 1924) הוא מנהיג פוליטי קומוניסטי רוסי.</p>
25663
25664 !!end
25665
25666 !! test
25667 Ignore pipe between table row attributes
25668 !! wikitext
25669 {|
25670 |quux
25671 |- id=foo | style='color: red'
25672 |bar
25673 |}
25674 !! html
25675 <table>
25676 <tr>
25677 <td>quux
25678 </td></tr>
25679 <tr id="foo" style="color: red">
25680 <td>bar
25681 </td></tr></table>
25682
25683 !! end
25684
25685 !!test
25686 Language parser function
25687 !! wikitext
25688 {{#language:ar}}
25689 !! html
25690 <p>العربية
25691 </p>
25692 !! end
25693
25694 !!test
25695 Padleft and padright (default 0-padding)
25696 !! wikitext
25697 {{padleft:xyz|5}}
25698 {{padright:xyz|5}}
25699 !! html/php
25700 <p>00xyz
25701 xyz00
25702 </p>
25703 !! html/parsoid
25704 <p><span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padleft:xyz","function":"padleft"},"params":{"1":{"wt":"5"}},"i":0}}]}'>00xyz</span>
25705 <span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padright:xyz","function":"padright"},"params":{"1":{"wt":"5"}},"i":0}}]}'>xyz00</span></p>
25706 !! end
25707
25708 !!test
25709 Padleft and padright (partial fill)
25710 !! wikitext
25711 {{padleft:xyz|6|ab}}
25712 {{padright:xyz|6|ab}}
25713 !! html/php
25714 <p>abaxyz
25715 xyzaba
25716 </p>
25717 !! html/parsoid
25718 <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>
25719 <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>
25720 !! end
25721
25722 !!test
25723 Padleft and padright as substr
25724 !! wikitext
25725 {{padleft:|3|abcde}}
25726 {{padright:|3|abcde}}
25727 !! html/php
25728 <p>abc
25729 abc
25730 </p>
25731 !! html/parsoid
25732 <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>
25733 <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>
25734 !! end
25735
25736 !! test
25737 Padleft and padright with non-numerical length (T180403)
25738 !! wikitext
25739 {{padleft:abcdef|junk}}
25740 {{padright:abcdef|junk}}
25741 !! html/php
25742 <p>abcdef
25743 abcdef
25744 </p>
25745 !! end
25746
25747 !!test
25748 Special parser function
25749 !! wikitext
25750 {{#special:RandomPage}}
25751 {{#special:BaDtItLe}}
25752 {{#special:Foobar}}
25753 !! html
25754 <p>Special:Random
25755 Special:Badtitle
25756 Special:Foobar
25757 </p>
25758 !! end
25759
25760 !!test
25761 T36939 - Case insensitive link parsing ([HttP://])
25762 !! wikitext
25763 [HttP://MediaWiki.Org/]
25764 !! html/php
25765 <p><a rel="nofollow" class="external autonumber" href="HttP://MediaWiki.Org/">[1]</a>
25766 </p>
25767 !! html/parsoid
25768 <p><a rel="mw:ExtLink" class="external autonumber" href="HttP://MediaWiki.Org/"></a></p>
25769 !! end
25770
25771 !!test
25772 T36939 - Case insensitive link parsing ([HttP:// title])
25773 !! wikitext
25774 [HttP://MediaWiki.Org/ MediaWiki]
25775 !! html
25776 <p><a rel="nofollow" class="external text" href="HttP://MediaWiki.Org/">MediaWiki</a>
25777 </p>
25778 !! end
25779
25780 !!test
25781 T36939 - Case insensitive link parsing (HttP://)
25782 !! wikitext
25783 HttP://MediaWiki.Org/
25784 !! html/php
25785 <p><a rel="nofollow" class="external free" href="HttP://MediaWiki.Org/">HttP://MediaWiki.Org/</a>
25786 </p>
25787 !! html/parsoid
25788 <p><a rel="mw:ExtLink" class="external free" href="HttP://MediaWiki.Org/">HttP://MediaWiki.Org/</a></p>
25789 !! end
25790
25791 !!test
25792 Disable TOC
25793 !! options
25794 notoc
25795 !! wikitext
25796 Lead
25797 ==Section 1==
25798 ==Section 2==
25799 ==Section 3==
25800 ==Section 4==
25801 ==Section 5==
25802 !! html
25803 <p>Lead
25804 </p>
25805
25806 <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>
25807 <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>
25808 <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>
25809 <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>
25810 <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>
25811
25812 !! end
25813
25814
25815 ###
25816 ### Parsoid-specific tests
25817 ### Parsoid-PHP parser incompatibilities
25818 ###
25819 !!test
25820 1. SOL-sensitive wikitext tokens as template-args
25821 !! options
25822 parsoid=wt2html,wt2wt
25823 !! wikitext
25824 {{echo|*a}}
25825 {{echo|#a}}
25826 {{echo|:a}}
25827 !! html/php+tidy
25828 <ul><li>a</li></ul>
25829 <ol><li>a</li></ol>
25830 <dl><dd>a</dd></dl>
25831 !! html/parsoid
25832 <span about="#mwt1" typeof="mw:Transclusion">
25833 </span><ul about="#mwt1"><li>a</li>
25834 </ul>
25835 <span about="#mwt2" typeof="mw:Transclusion">
25836 </span><ol about="#mwt2"><li>a</li>
25837 </ol>
25838 <span about="#mwt3" typeof="mw:Transclusion">
25839 </span><dl about="#mwt3"><dd>a</dd>
25840 </dl>
25841 !!end
25842
25843 #### -----------------------------------------------------------------
25844 #### Parsoid-specific functionality tests
25845 #### -----------------------------------------------------------------
25846
25847 # T65642/T68749: Formatting elt fixup around images.
25848 # We know wt2wt will fail, but we expect selser to pass.
25849 # Due to the nature of our testing, wt2wt and selser tests will enter the
25850 # blacklist and we'll catch selser regressions based on changes to the
25851 # blacklist entries for selser tests.
25852 !! test
25853 1. Treebuilder fixup of formatting elt
25854 !! options
25855 parsoid=wt2html,wt2wt
25856 !! wikitext
25857 {|
25858 |
25859 <small>
25860 [[Image:Foobar.jpg|right|Test]]
25861 </small>
25862 |}
25863 !! html/php+tidy
25864 <table>
25865 <tbody><tr>
25866 <td>
25867 <p><small>
25868 </small></p><small>
25869 <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>
25870 </small><p><small></small>
25871 </p>
25872 </td></tr></tbody></table>
25873 !! html/parsoid
25874 <table>
25875 <tbody><tr><td>
25876 <p><small data-parsoid='{"stx":"html","autoInsertedEnd":true}'></small></p><small data-parsoid='{"stx":"html","autoInsertedEnd":true,"autoInsertedStart":true}'>
25877 <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>
25878 <p><small data-parsoid='{"stx":"html","autoInsertedStart":true}'></small></p></td></tr>
25879 </tbody></table>
25880 !! end
25881
25882 !! test
25883 2. Treebuilder fixup of formatting elt
25884 !! options
25885 parsoid=wt2html,wt2wt
25886 !! wikitext
25887 '''foo[[File:Foobar.jpg|thumb|caption]]bar'''
25888
25889 <small>[[Image:Foobar.jpg|right|300px]]</small>
25890 !! html/php+tidy
25891 <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>
25892 </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>
25893 !! html/parsoid
25894 <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>
25895
25896 <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>
25897 !! end
25898
25899 !! test
25900 3. Treebuilder fixup of formatting elt
25901 !! options
25902 parsoid=wt2html,wt2wt
25903 !! wikitext
25904 <small>'''foo[[File:Foobar.jpg|thumb|caption]]bar'''</small>
25905 !! html/php+tidy
25906 <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>
25907 </p>
25908 !! html/parsoid
25909 <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>
25910 !! end
25911
25912 !! test
25913 4. Treebuilder fixup of formatting elt: formatting tags around captionless images
25914 !! options
25915 parsoid=wt2html,wt2wt
25916 !! wikitext
25917 '''<small>[[Image:Foobar.jpg|right|300px]]</small>'''
25918 !! html/php+tidy
25919 <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>
25920 !! html/parsoid
25921 <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>
25922 !! end
25923
25924 #### ----------------------------------------------------------------
25925 #### Parsoid-only testing of Parsoid's impl of LST
25926 #### Not implemented yet, see
25927 #### https://www.mediawiki.org/wiki/Parsoid/HTML_based_LST
25928 #### ----------------------------------------------------------------
25929
25930 ## We still need to support serializing the older format while content is stored.
25931 !! test
25932 LST Sections: Backwards compatibility
25933 !! options
25934 parsoid={
25935 "suppressErrors": true,
25936 "modes": ["html2wt"]
25937 }
25938 !! wikitext
25939 <section begin="2011-05-16" />
25940 <section end="2014-04-10 (MW 1.23wmf22)" />
25941 !! html/parsoid
25942 <p><meta typeof="mw:Extension/LabeledSectionTransclusion/begin" content="2011-05-16"/>
25943 <meta typeof="mw:Extension/LabeledSectionTransclusion/end" content="2014-04-10 (MW 1.23wmf22)"/></p>
25944 !! end
25945
25946 !! test
25947 LST Sections: Newfangled approach
25948 !! wikitext
25949 <section begin="2011-05-16" />
25950 <section end="2014-04-10 (MW 1.23wmf22)" />
25951 !! html/parsoid
25952 <p><span typeof="mw:Extension/section" about="#mwt4" data-mw='{"name":"section","attrs":{"begin":"2011-05-16"}}'>
25953 </span>
25954 <span typeof="mw:Extension/section" about="#mwt6" data-mw='{"name":"section","attrs":{"end":"2014-04-10 (MW 1.23wmf22)"}}'>
25955 </span></p>
25956 !! end
25957
25958 #--------- Test stripping of empty nodes in template content ----------
25959
25960 !! test
25961 Empty LI and TR nodes should be stripped from template content
25962 !! wikitext
25963 {{EmptyLITest}}
25964 {{EmptyTRTest}}
25965 !! html/parsoid
25966 <ul about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyLITest","href":"./Template:EmptyLITest"},"params":{},"i":0}}]}'>
25967 <li>a</li>
25968 <li>b</li>
25969 </ul>
25970 <table about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyTRTest","href":"./Template:EmptyTRTest"},"params":{},"i":0}}]}'>
25971 <tbody>
25972 <tr>
25973 <td>foo</td>
25974 </tr>
25975 <tr>
25976 <td>bar</td>
25977 </tr>
25978 </tbody>
25979 </table>
25980 !! end
25981
25982 !! test
25983 Empty LI and TR nodes should not be stripped from top-level content
25984 !! wikitext
25985 *a
25986 *
25987 *b
25988
25989 {|
25990 |-
25991 |-
25992 |foo
25993 |}
25994 !! html/parsoid
25995 <ul>
25996 <li>a</li>
25997 <li class='mw-empty-elt'></li>
25998 <li>b</li>
25999 </ul>
26000 <table>
26001 <tbody>
26002 <tr class='mw-empty-elt'></tr>
26003 <tr>
26004 <td>foo</td>
26005 </tr>
26006 </tbody>
26007 </table>
26008 !! end
26009
26010 !! test
26011 Empty TR nodes should not be stripped if they have any attributes set
26012 !! wikitext
26013 {{EmptyTRWithHTMLAttrTest}}
26014 !! html/parsoid
26015 <table about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyTRWithHTMLAttrTest","href":"./Template:EmptyTRWithHTMLAttrTest"},"params":{},"i":0}}]}'>
26016 <tr align='center'></tr>
26017 <tr><td>foo</td></tr>
26018 <tr align='center'></tr>
26019 <tr><td>bar</td></tr>
26020 </table>
26021 !! end
26022
26023 #### ----------------------------------------------------------------
26024 #### The following section of tests are primarily to test
26025 #### wikitext escaping capabilities of Parsoid. Given that
26026 #### escaping can be done any number of ways, the wikitext (input)
26027 #### is always adjusted to reflect how Parsoid adds nowiki
26028 #### escape tags.
26029 ####
26030 #### We are marking several tests as parsoid-only since the
26031 #### HTML in the result section is different from what the
26032 #### PHP parser generates for it.
26033 #### ----------------------------------------------------------------
26034
26035
26036 #### --------------- Headings ---------------
26037 #### 0. Unnested
26038 #### 1. Nested inside html <h1>=foo=</h1>
26039 #### 2. Outside heading nest on a single line <h1>foo</h1>*bar
26040 #### 3. Nested inside html with wikitext split by html tags
26041 #### 4. No escape needed
26042 #### 5. Empty headings <h1></h1>
26043 #### 6. Heading chars in SOL context
26044 #### ----------------------------------------
26045 !! test
26046 Headings: 0. Unnested
26047 !! options
26048 parsoid=html2wt
26049 !! html/parsoid
26050 <p>=foo=</p>
26051
26052 <p> =foo=
26053 <!--cmt-->
26054 =foo=</p>
26055
26056 <p>=foo<i>a</i>=</p>
26057 !! wikitext
26058 <nowiki>=foo=</nowiki>
26059
26060 <nowiki> </nowiki>=foo=
26061 <!--cmt-->
26062 <nowiki>=foo=</nowiki>
26063
26064 =foo''a''<nowiki>=</nowiki>
26065 !!end
26066
26067 # New headings and existing headings are handled differently
26068 !! test
26069 Headings: 1. Nested inside html
26070 !! options
26071 parsoid=html2wt
26072 !! html/parsoid
26073 <h1>=foo=</h1>
26074 <h2>=foo=</h2>
26075 <h3>=foo=</h3>
26076
26077 <h1 data-parsoid=''>=foo=</h1>
26078 <h2 data-parsoid=''>=foo=</h2>
26079 <h3 data-parsoid=''>=foo=</h3>
26080 <h4 data-parsoid=''>=foo=</h4>
26081 <h5 data-parsoid=''>=foo=</h5>
26082 <h6 data-parsoid=''>=foo=</h6>
26083 !! wikitext
26084 = =foo= =
26085
26086 == =foo= ==
26087
26088 === =foo= ===
26089
26090 =<nowiki>=foo=</nowiki>=
26091 ==<nowiki>=foo=</nowiki>==
26092 ===<nowiki>=foo=</nowiki>===
26093 ====<nowiki>=foo=</nowiki>====
26094 =====<nowiki>=foo=</nowiki>=====
26095 ======<nowiki>=foo=</nowiki>======
26096
26097 !!end
26098
26099 !! test
26100 Headings: 2. Outside heading nest on a single line <h1>foo</h1>*bar
26101 !! options
26102 parsoid=html2wt
26103 !! html/parsoid
26104 <h1>foo</h1>*bar
26105 <h1>foo</h1>=bar
26106 <h1>foo</h1>=bar=
26107 !! wikitext
26108 = foo =
26109 <nowiki>*</nowiki>bar
26110
26111 = foo =
26112 =bar
26113
26114 = foo =
26115 <nowiki>=bar=</nowiki>
26116 !!end
26117
26118 !! test
26119 Headings: 3. Nested inside html with wikitext split by html tags
26120 !! options
26121 parsoid=html2wt
26122 !! html/parsoid
26123 <h1>=<b>bold</b>foo=</h1>
26124 !! wikitext
26125 = ='''bold'''foo= =
26126 !!end
26127
26128 !! test
26129 Headings: 4a. No escaping needed (testing just h1 and h2)
26130 !! options
26131 parsoid=html2wt
26132 !! html/parsoid
26133 <h1>=foo</h1>
26134 <h1>foo=</h1>
26135 <h1> =foo= </h1>
26136 <h1>=foo= bar</h1>
26137 <h2>=foo</h2>
26138 <h2>foo=</h2>
26139 <h1>=</h1>
26140 <h1><i>=</i>foo=</h1>
26141 !! wikitext
26142 = =foo =
26143
26144 = foo= =
26145
26146 = =foo= =
26147
26148 = =foo= bar =
26149
26150 == =foo ==
26151
26152 == foo= ==
26153
26154 = = =
26155
26156 = ''=''foo= =
26157 !!end
26158
26159 !! test
26160 Headings: 4b. No escaping needed (inside p-tags)
26161 !! options
26162 parsoid=html2wt
26163 !! html/parsoid
26164 <p>=foo= x
26165 =foo= <s></s>
26166 </p>
26167 !! wikitext
26168 =foo= x
26169 =foo= <s></s>
26170 !! html/php
26171 <p>=foo= x
26172 =foo= <s></s>
26173 </p>
26174 !!end
26175
26176 !! test
26177 Headings: 4c. Short headings (1)
26178 !! options
26179 parsoid=html2wt
26180 !! html/parsoid
26181 <p>===
26182 </p>
26183 !! wikitext
26184 <nowiki>===</nowiki>
26185 !! html/php
26186 <p>===
26187 </p>
26188 !! end
26189
26190 # in the html2wt direction we emit '= = =' or '=<nowiki>=</nowiki>='
26191 !! test
26192 Headings: 4d. Short headings (2)
26193 !! options
26194 parsoid=wt2html,html2html
26195 !! wikitext
26196 =
26197 ==
26198 ===
26199 ====
26200 =====
26201 !! html/php
26202 <p>=
26203 ==
26204 </p>
26205 <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>
26206 <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>
26207 <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>
26208
26209 !! html/parsoid
26210 <p>=
26211 ==</p>
26212 <h1 id="="><span id=".3D" typeof="mw:FallbackId"></span>=</h1>
26213 <h1 id="=="><span id=".3D.3D" typeof="mw:FallbackId"></span>==</h1>
26214 <h2 id="=_2"><span id=".3D_2" typeof="mw:FallbackId"></span>=</h2>
26215 !! end
26216
26217 !! test
26218 Headings: 5. Empty headings
26219 !! options
26220 parsoid=html2wt
26221 !! html/parsoid
26222 <h1 data-parsoid='{}'></h1>
26223
26224 <h2 data-parsoid='{}'></h2>
26225
26226 <h3 data-parsoid='{}'></h3>
26227
26228 <h4 data-parsoid='{}'></h4>
26229
26230 <h5 data-parsoid='{}'></h5>
26231
26232 <h6 data-parsoid='{}'></h6>
26233 !! wikitext
26234 =<nowiki/>=
26235
26236 ==<nowiki/>==
26237
26238 ===<nowiki/>===
26239
26240 ====<nowiki/>====
26241
26242 =====<nowiki/>=====
26243
26244 ======<nowiki/>======
26245 !!end
26246
26247 !! test
26248 Headings: 6a. Heading chars in SOL context (with trailing spaces)
26249 !! options
26250 parsoid=html2wt
26251 !! html/parsoid
26252 <p>=a=</p>
26253
26254 <p>=a=</p>
26255
26256 <p>=a=</p>
26257 !! wikitext
26258 <nowiki>=a=</nowiki>
26259
26260 <nowiki>=a=</nowiki>
26261
26262 <nowiki>=a=</nowiki>
26263 !!end
26264
26265 !! test
26266 Headings: 6b. Heading chars in SOL context (with trailing newlines)
26267 !! options
26268 parsoid=html2wt
26269 !! html/parsoid
26270 <p>=a=
26271 b</p>
26272
26273 <p>=a=
26274 b</p>
26275
26276 <p>=a=
26277 b</p>
26278 !! wikitext
26279 <nowiki>=a=</nowiki>
26280 b
26281
26282 <nowiki>=a=</nowiki>
26283 b
26284
26285 <nowiki>=a=</nowiki>
26286 b
26287 !!end
26288
26289 !! test
26290 Headings: 6c. Heading chars in SOL context (leading newline break)
26291 !! options
26292 parsoid=html2wt
26293 !! html/parsoid
26294 <p>a
26295 =b=</p>
26296 !! wikitext
26297 a
26298 <nowiki>=b=</nowiki>
26299 !!end
26300
26301 !! test
26302 Headings: 6d. Heading chars in SOL context (with interspersed comments)
26303 !! options
26304 parsoid=html2wt
26305 !! html/parsoid
26306 <!--c0--><p>=a=</p>
26307
26308 <!--c1--><p>=a=</p> <!--c2--> <!--c3-->
26309 !! wikitext
26310 <!--c0--><nowiki>=a=</nowiki>
26311
26312 <!--c1--><nowiki>=a=</nowiki> <!--c2--> <!--c3-->
26313 !!end
26314
26315 !! test
26316 Headings: 6d. Heading chars in SOL context (No escaping needed)
26317 !! options
26318 parsoid=html2wt
26319 !! html/parsoid
26320 =a=<div>b</div>
26321 !! wikitext
26322 =a=<div>b</div>
26323 !!end
26324
26325 !! test
26326 Headings: 7. Insert a newline between new content and headings
26327 !! options
26328 parsoid=html2wt
26329 !! html/parsoid
26330 <h2>NEW</h2>
26331 <p>new</p>
26332 <h2 data-parsoid='{}'>A</h2>
26333 <p data-parsoid='{}'>a</p>
26334 !! wikitext
26335 == NEW ==
26336 new
26337
26338 ==A==
26339 a
26340
26341 !! end
26342
26343 !! test
26344 Headings: Used as horizontal rule
26345 !! config
26346 wgFragmentMode=[ 'html5', 'legacy' ]
26347 !! options
26348 parsoid=wt2html
26349 !! wikitext
26350 ===============
26351 !! html/php
26352 <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>
26353
26354 !! html/parsoid
26355 <h6 id="==="><span id=".3D.3D.3D" typeof="mw:FallbackId"></span>===</h6>
26356 !! end
26357
26358 #### --------------- Lists ---------------
26359 #### 0. Outside nests (*foo, etc.)
26360 #### 1. Nested inside html <ul><li>*foo</li></ul>
26361 #### 2. Inside definition lists
26362 #### 3. Only bullets at start should be escaped
26363 #### 4. No escapes needed
26364 #### 5. No unnecessary escapes
26365 #### 6. Escape bullets in SOL position
26366 #### 7. Escape bullets in a multi-line context
26367 #### ----------------------------------------
26368
26369 !! test
26370 Lists: 0. Outside nests
26371 !! options
26372 parsoid=html2wt
26373 !! html/parsoid
26374 <p>*foo</p>
26375
26376 <p>#foo</p>
26377
26378 <p>;Foo:bar</p>
26379 !! wikitext
26380 <nowiki>*</nowiki>foo
26381
26382 <nowiki>#</nowiki>foo
26383
26384 <nowiki>;</nowiki>Foo<nowiki>:</nowiki>bar
26385 !!end
26386
26387 ## Making these next 3 tests Parsoid-only since they are html2wt tests
26388 ## to test wikitext escaping, and insignificant whitespace diffs
26389 ## cause PHP parser tests to barf
26390 !! test
26391 Lists: 1. Nested inside html (No unnecessary escapes)
26392 !! options
26393 parsoid=html2wt
26394 !! html/parsoid
26395 <ul>
26396 <li>*foo</li>
26397 <li>#foo</li>
26398 <li>:foo</li>
26399 <li>;foo</li>
26400 <li data-parsoid='{}'>*foo</li>
26401 <li data-parsoid='{}'>#foo</li>
26402 <li data-parsoid='{}'>:foo</li>
26403 <li data-parsoid='{}'>;foo</li>
26404 </ul>
26405
26406 <ol>
26407 <li>*foo</li>
26408 <li>#foo</li>
26409 <li>:foo</li>
26410 <li>;foo</li>
26411 <li data-parsoid='{}'>*foo</li>
26412 <li data-parsoid='{}'>#foo</li>
26413 <li data-parsoid='{}'>:foo</li>
26414 <li data-parsoid='{}'>;foo</li>
26415 </ol>
26416 !! wikitext
26417 * *foo
26418 * #foo
26419 * :foo
26420 * ;foo
26421 *<nowiki>*foo</nowiki>
26422 *<nowiki>#foo</nowiki>
26423 *<nowiki>:foo</nowiki>
26424 *<nowiki>;foo</nowiki>
26425
26426 # *foo
26427 # #foo
26428 # :foo
26429 # ;foo
26430 #<nowiki>*foo</nowiki>
26431 #<nowiki>#foo</nowiki>
26432 #<nowiki>:foo</nowiki>
26433 #<nowiki>;foo</nowiki>
26434 !!end
26435
26436 !! test
26437 Lists: 2. Inside definition lists
26438 !! options
26439 parsoid=html2wt
26440 !! html/parsoid
26441 <dl><dt>;foo</dt></dl>
26442 <dl><dt>:foo</dt></dl>
26443 <dl><dt>:foo</dt>
26444 <dd>bar</dd></dl>
26445 <dl><dd>:foo</dd></dl>
26446 !! wikitext
26447 ; ;foo
26448
26449 ; <nowiki>:foo</nowiki>
26450
26451 ; <nowiki>:foo</nowiki>
26452 : bar
26453
26454 : :foo
26455 !!end
26456
26457 !! test
26458 Lists: 3. Only bullets at start of text in wikitext-generated HTML should be escaped
26459 !! options
26460 parsoid=html2wt
26461 !! html/parsoid
26462 <ul>
26463 <li>*foo*bar</li>
26464 <li data-parsoid='{}'>*foo<i>it</i>*bar</li>
26465 </ul>
26466 !! wikitext
26467 * *foo*bar
26468 *<nowiki>*foo</nowiki>''it''*bar
26469 !!end
26470
26471 !! test
26472 Lists: 4. No escapes needed
26473 !! options
26474 parsoid=html2wt
26475 !! html/parsoid
26476 <ul>
26477 <li>foo*bar
26478 </li>
26479 </ul>
26480 <ul>
26481 <li><i>foo</i>*bar
26482 </li>
26483 </ul>
26484 <ul>
26485 <li><a rel="mw:WikiLink" href="Foo" title="Foo">Foo</a>: bar
26486 </li>
26487 </ul>
26488 <ul>
26489 <li><a rel="mw:WikiLink" href="Foo" title="Foo">Foo</a>*bar
26490 </li>
26491 </ul>
26492 !! wikitext
26493 *foo*bar
26494
26495 *''foo''*bar
26496
26497 *[[Foo]]: bar
26498
26499 *[[Foo]]*bar
26500 !!end
26501
26502 !! test
26503 Lists: 5. No unnecessary escapes
26504 !! options
26505 parsoid=html2wt
26506 !! html/parsoid
26507 <ul><li> bar <span>[[foo]]</span></li></ul>
26508 <ul><li> =bar <span>[[foo]]</span></li></ul>
26509 <ul><li> [[bar <span>[[foo]]</span></li></ul>
26510 <ul><li> ]]bar <span>[[foo]]</span></li></ul>
26511 <ul><li> =bar <span>foo]]</span>=</li></ul>
26512 <ul><li> <s></s>: a</li></ul>
26513 <ul><li> <i>* foo</i></li></ul>
26514
26515 !! wikitext
26516 * bar <span><nowiki>[[foo]]</nowiki></span>
26517
26518 * =bar <span><nowiki>[[foo]]</nowiki></span>
26519
26520 * [[bar <span><nowiki>[[foo]]</nowiki></span>
26521
26522 * ]]bar <span><nowiki>[[foo]]</nowiki></span>
26523
26524 * =bar <span>foo]]</span>=
26525
26526 * <s></s>: a
26527
26528 * ''* foo''
26529 !!end
26530
26531 !! test
26532 Lists: 6. Escape bullets in SOL position
26533 !! options
26534 parsoid=html2wt
26535 !! html/parsoid
26536 <p><!--cmt-->*foo</p>
26537 !! wikitext
26538 <!--cmt--><nowiki>*</nowiki>foo
26539 !!end
26540
26541 !! test
26542 Lists: 7. Escape bullets in a multi-line context
26543 !! options
26544 parsoid=html2wt
26545 !! html/parsoid
26546 <p>a
26547 *b
26548 </p>
26549 !! wikitext
26550 a
26551 <nowiki>*</nowiki>b
26552 !!end
26553
26554 !! test
26555 Lists: 8. Escape colons only if not present in tags
26556 !! options
26557 parsoid=html2wt
26558 !! html/parsoid
26559 <dl><dt>a:b<i>c:d</i></dt></dl>
26560 !! wikitext
26561 ; <nowiki>a:b</nowiki>''c:d''
26562 !! end
26563
26564 #### --------------- HRs ---------------
26565 #### 1. Single line
26566 #### -----------------------------------
26567
26568 !! test
26569 HRs: 1. Single line
26570 !! options
26571 parsoid=html2wt
26572 !! html/parsoid
26573 <hr />----
26574 <hr />=foo=
26575 <hr />*foo
26576 !! wikitext
26577 ----<nowiki>----</nowiki>
26578 ----=foo=
26579 ----*foo
26580 !! end
26581
26582 #### --------------- Tables ---------------
26583 #### 1a. Simple example
26584 #### 1b. No escaping needed (!foo)
26585 #### 1c. No escaping needed (|foo)
26586 #### 1d. No escaping needed (|}foo)
26587 ####
26588 #### 2a. Nested in td (<td>foo|bar</td>)
26589 #### 2b. Nested in td (<td>foo||bar</td>)
26590 #### 2c. Nested in td -- no escaping needed(<td>foo!!bar</td>)
26591 ####
26592 #### 3a. Nested in th (<th>foo!bar</th>)
26593 #### 3b. Nested in th (<th>foo!!bar</th>)
26594 #### 3c. Nested in th -- no escaping needed(<th>foo||bar</th>)
26595 ####
26596 #### 4a. Escape -
26597 #### 4b. Escape +
26598 #### 4c. No escaping needed
26599 #### --------------------------------------
26600
26601 !! test
26602 Tables: 1a. Simple example
26603 !! options
26604 parsoid=html2wt
26605 !! html/parsoid
26606 <p>{|
26607 |}
26608 </p>
26609 !! wikitext
26610 <nowiki>{|</nowiki>
26611 |}
26612 !! end
26613
26614 !! test
26615 Tables: 1b. No escaping needed
26616 !! options
26617 parsoid=html2wt
26618 !! html/parsoid
26619 <p>!foo
26620 </p>
26621 !! wikitext
26622 !foo
26623 !! end
26624
26625 !! test
26626 Tables: 1c. No escaping needed
26627 !! options
26628 parsoid=html2wt
26629 !! html/parsoid
26630 <p>|foo
26631 </p>
26632 !! wikitext
26633 |foo
26634 !! end
26635
26636 !! test
26637 Tables: 1d. No escaping needed
26638 !! options
26639 parsoid=html2wt
26640 !! html/parsoid
26641 <p>|}foo
26642 </p>
26643 !! wikitext
26644 |}foo
26645 !! end
26646
26647 !! test
26648 Tables: 2a. Nested in td
26649 !! options
26650 parsoid=html2wt
26651 !! html/parsoid
26652 <table><tbody><tr>
26653 <td>foo|bar</td></tr>
26654 <tr><td>x<div>a|b</div></td>
26655 </tbody></table>
26656 !! wikitext
26657 {|
26658 |<nowiki>foo|bar</nowiki>
26659 |-
26660 |x<div><nowiki>a|b</nowiki></div>
26661 |}
26662 !! html/php+tidy
26663 <table>
26664 <tbody><tr>
26665 <td>foo|bar
26666 </td></tr>
26667 <tr>
26668 <td>x<div>a|b</div>
26669 </td></tr></tbody></table>
26670 !! end
26671
26672 !! test
26673 Tables: 2b. Nested in td
26674 !! options
26675 parsoid=html2wt
26676 !! html/parsoid
26677 <table><tbody><tr>
26678 <td>foo||bar</td>
26679 <td>a<i>b||c</i></td>
26680 <td>a<i><div>b||c</div></i></td>
26681 </tr></tbody></table>
26682 !! wikitext
26683 {|
26684 |<nowiki>foo||bar</nowiki>
26685 |a''<nowiki>b||c</nowiki>''
26686 |a''<div><nowiki>b||c</nowiki></div>''
26687 |}
26688 !! html/php
26689 <table>
26690 <tr>
26691 <td>foo||bar
26692 </td>
26693 <td>a<i>b||c</i>
26694 </td>
26695 <td>a<i><div>b||c</div></i>
26696 </td></tr></table>
26697
26698 !! end
26699
26700 !! test
26701 Tables: 2c. Nested in td -- no escaping needed
26702 !! options
26703 parsoid=html2wt
26704 !! html/*
26705 <table>
26706 <tr>
26707 <td>foo!!bar
26708 </td></tr></table>
26709
26710 !! wikitext
26711 {|
26712 |foo!!bar
26713 |}
26714 !! end
26715
26716 !! test
26717 Tables: 3a. Nested in th
26718 !! options
26719 parsoid=html2wt
26720 !! html/*
26721 <table>
26722 <tr>
26723 <th>foo!bar
26724 </th></tr></table>
26725
26726 !! wikitext
26727 {|
26728 !foo!bar
26729 |}
26730 !! end
26731
26732 !! test
26733 Tables: 3b. Nested in th
26734 !! options
26735 parsoid=html2wt
26736 !! html/parsoid
26737 <table><tbody>
26738 <tr><th>foo!!bar</th>
26739 <th><i>foo|bar</i></th>
26740 <th><i>foo!!bar</i></th>
26741 <th><i><span>foo!!bar</span></i></th>
26742 </tr></tbody></table>
26743 !! wikitext
26744 {|
26745 !<nowiki>foo!!bar</nowiki>
26746 !''<nowiki>foo|bar</nowiki>''
26747 !''<nowiki>foo!!bar</nowiki>''
26748 !''<span><nowiki>foo!!bar</nowiki></span>''
26749 |}
26750 !! html/php
26751 <table>
26752 <tr>
26753 <th>foo!!bar
26754 </th>
26755 <th><i>foo|bar</i>
26756 </th>
26757 <th><i>foo!!bar</i>
26758 </th>
26759 <th><i><span>foo!!bar</span></i>
26760 </th></tr></table>
26761
26762 !! end
26763
26764 !! test
26765 Tables: 3c. Nested in th
26766 !! options
26767 parsoid=html2wt
26768 !! html/parsoid
26769 <table><tbody>
26770 <tr><th>foo||bar</th>
26771 <th><span typeof="mw:Nowiki">foo||bar</span></th>
26772 </tr></tbody></table>
26773 !! wikitext
26774 {|
26775 !<nowiki>foo||bar</nowiki>
26776 !<nowiki>foo||bar</nowiki>
26777 |}
26778 !! html/php
26779 <table>
26780 <tr>
26781 <th>foo||bar
26782 </th>
26783 <th>foo||bar
26784 </th></tr></table>
26785
26786 !! end
26787
26788 !! test
26789 Tables: 4a. Escape -
26790 !! options
26791 parsoid=html2wt
26792 !! html/*
26793 <table>
26794 <tr>
26795 <th>-bar
26796 </th></tr>
26797 <tr>
26798 <td>-bar
26799 </td></tr></table>
26800
26801 !! wikitext
26802 {|
26803 !-bar
26804 |-
26805 |<nowiki>-bar</nowiki>
26806 |}
26807 !! end
26808
26809 !! test
26810 Tables: 4b. Escape +
26811 !! options
26812 parsoid=html2wt
26813 !! html/*
26814 <table>
26815 <tr>
26816 <th>+bar
26817 </th></tr>
26818 <tr>
26819 <td>+bar
26820 </td></tr></table>
26821
26822 !! wikitext
26823 {|
26824 !+bar
26825 |-
26826 |<nowiki>+bar</nowiki>
26827 |}
26828 !! end
26829
26830 !! test
26831 Tables: 4c. No escaping needed
26832 !! options
26833 parsoid=html2wt
26834 !! html/parsoid
26835 <table><tbody>
26836 <tr><td>foo-bar</td><td>foo+bar</td></tr>
26837 <tr><td><i>foo</i>-bar</td><td><i>foo</i>+bar</td></tr>
26838 <tr><td>foo
26839 <p>bar|baz
26840 +bar
26841 -bar</p></td></tr>
26842 <tr><td>x
26843 <div>a|b</div></td>
26844 </tbody></table>
26845 !! wikitext
26846 {|
26847 |foo-bar
26848 |foo+bar
26849 |-
26850 |''foo''-bar
26851 |''foo''+bar
26852 |-
26853 |foo
26854 bar|baz
26855 +bar
26856 -bar
26857 |-
26858 |x
26859 <div>a|b</div>
26860 |}
26861 !! html/php
26862 <table>
26863 <tr>
26864 <td>foo-bar
26865 </td>
26866 <td>foo+bar
26867 </td></tr>
26868 <tr>
26869 <td><i>foo</i>-bar
26870 </td>
26871 <td><i>foo</i>+bar
26872 </td></tr>
26873 <tr>
26874 <td>foo
26875 <p>bar|baz
26876 +bar
26877 -bar
26878 </p>
26879 </td></tr>
26880 <tr>
26881 <td>x
26882 <div>a|b</div>
26883 </td></tr></table>
26884
26885 !! end
26886
26887 !! test
26888 Tables: 4d. No escaping needed
26889 !! options
26890 parsoid=html2wt
26891 !! html/parsoid
26892 <table>
26893 <tbody><tr><td><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a>-bar</td>
26894 <td data-parsoid='{"startTagSrc":"|","attrSepSrc":"|"}'>+1</td>
26895 <td data-parsoid='{"startTagSrc":"|","attrSepSrc":"|"}'>-2</td></tr>
26896 </tbody></table>
26897 !! wikitext
26898 {|
26899 |[[Foo]]-bar
26900 ||+1
26901 ||-2
26902 |}
26903 !! html/php
26904 <table>
26905 <tr>
26906 <td><a href="/wiki/Foo" title="Foo">Foo</a>-bar
26907 </td>
26908 <td>+1
26909 </td>
26910 <td>-2
26911 </td></tr></table>
26912
26913 !! end
26914
26915 !! test
26916 Tables: 4e. Escape }
26917 !! options
26918 parsoid=html2wt
26919 !! html/parsoid
26920 <table>
26921 <tr><td>}</td></tr>
26922 <tr><td>x</td><td data-parsoid='{"stx":"row"}'>}</td></tr></table>
26923 </table>
26924 !! wikitext
26925 {|
26926 |<nowiki>}</nowiki>
26927 |-
26928 |x||}
26929 |}
26930 !! html/php
26931 <table>
26932 <tr>
26933 <td>}
26934 </td></tr>
26935 <tr>
26936 <td>x</td>
26937 <td>}
26938 </td></tr></table>
26939
26940 !! end
26941
26942 !! test
26943 Tables: 5. Empty table cells should get whitespace to avoid need for nowikis
26944 !! options
26945 parsoid=html2wt
26946 !! html/parsoid
26947 <table><tr><td></td><td align="center" data-parsoid='{"stx":"row"}'></td><td data-parsoid='{"stx":"row"}'></td></tr></table>
26948
26949 <table><tr><td></td><td align="center"></td><td></td></tr></table>
26950
26951 <table><tr><td></td><td align="center" data-parsoid='{"stx":"row", "startTagSrc":"{{!}}{{!}}"}'></td><td data-parsoid='{"stx":"row"}'></td></tr></table>
26952
26953 <table><tr><th></th><th align="center" data-parsoid='{"stx":"row"}'></th><th data-parsoid='{"stx":"row"}'></th></tr></table>
26954 !! wikitext
26955 {|
26956 | || align="center" | ||
26957 |}
26958
26959 {|
26960 |
26961 | align="center" |
26962 |
26963 |}
26964
26965 {|
26966 | {{!}}{{!}} align="center" | ||
26967 |}
26968
26969 {|
26970 ! !! align="center" | !!
26971 |}
26972 !! html/php+tidy
26973 <table>
26974 <tbody><tr>
26975 <td></td>
26976 <td align="center"></td>
26977 <td>
26978 </td></tr></tbody></table>
26979 <table>
26980 <tbody><tr>
26981 <td>
26982 </td>
26983 <td align="center">
26984 </td>
26985 <td>
26986 </td></tr></tbody></table>
26987 <table>
26988 <tbody><tr>
26989 <td></td>
26990 <td align="center"></td>
26991 <td>
26992 </td></tr></tbody></table>
26993 <table>
26994 <tbody><tr>
26995 <th></th>
26996 <th align="center"></th>
26997 <th>
26998 </th></tr></tbody></table>
26999 !! end
27000
27001 !! test
27002 T97430: Don't emit empty nowiki pairs around marker meta tags
27003 !! options
27004 parsoid=html2wt
27005 !! html/parsoid
27006 <p>*This is a long sentence here that will make the nowiki algo split up the nowikis into multiple pairs
27007 |** Make this another long long long sentence forcing the nowiki algo to split up the nowikis.</p>
27008 !! wikitext
27009 <nowiki>*</nowiki>This is a long sentence here that will make the nowiki algo split up the nowikis into multiple pairs
27010 |** Make this another long long long sentence forcing the nowiki algo to split up the nowikis.
27011 !! end
27012
27013 !! test
27014 Unclosed xmlish element in table line shouldn't eat end delimiters
27015 !! options
27016 parsoid=html2wt
27017 !! html/parsoid
27018 <table>
27019 <tbody><tr><td> &lt;foo</td>
27020 <td> bar></td></tr>
27021 </tbody></table>
27022 !! wikitext
27023 {|
27024 | <foo
27025 | bar>
27026 |}
27027 !! html/php
27028 <table>
27029 <tr>
27030 <td>&lt;foo
27031 </td>
27032 <td>bar&gt;
27033 </td></tr></table>
27034
27035 !! end
27036
27037 #### --------------- Links ----------------
27038 #### 1. Quote marks in link text
27039 #### 2. Wikilinks: Escapes needed
27040 #### 3. Wikilinks: No escapes needed
27041 #### 4. Extlinks: Escapes needed
27042 #### 5. Extlinks: No escapes needed
27043 #### --------------------------------------
27044 !! test
27045 Links 1. WikiLinks: No escapes needed
27046 !! options
27047 parsoid=html2wt
27048 !! html/parsoid
27049 <p><a rel="mw:WikiLink" href="Foo" title="Foo">Foo<i>boo</i></a>
27050 <a rel="mw:WikiLink" href="Foo" title="Foo">[Foobar]</a>
27051 <a rel="mw:WikiLink" href="Foo" title="Foo">x [Foobar] x</a></p>
27052 !! wikitext
27053 [[Foo|Foo''boo'']]
27054 [[Foo|[Foobar]]]
27055 [[Foo|x [Foobar] x]]
27056 !! html/php
27057 <p><a href="/wiki/Foo" title="Foo">Foo<i>boo</i></a>
27058 <a href="/wiki/Foo" title="Foo">[Foobar]</a>
27059 <a href="/wiki/Foo" title="Foo">x [Foobar] x</a>
27060 </p>
27061 !! end
27062
27063 !! test
27064 Links 2. WikiLinks: Escapes needed
27065 !! options
27066 parsoid=html2wt
27067 !! html/parsoid
27068 <a href="Foo" rel="mw:WikiLink">Foobar]</a>
27069 <a href="Foo" rel="mw:WikiLink">x [http://google.com g] x</a>
27070 <a href="Foo" rel="mw:WikiLink">[[Bar]]</a>
27071 <a href="Foo" rel="mw:WikiLink">x [[Bar]] x</a>
27072 <a href="Foo" rel="mw:WikiLink">|Bar</a>
27073 <a href="Foo" rel="mw:WikiLink">]]bar</a>
27074 <a href="Foo" rel="mw:WikiLink">[[bar</a>
27075 <a href="Foo" rel="mw:WikiLink">x [[ y</a>
27076 <a href="Foo" rel="mw:WikiLink">x ]] y</a>
27077 <a href="Foo" rel="mw:WikiLink">x ]] y [[ z</a>
27078 !! wikitext
27079 [[Foo|<nowiki>Foobar]</nowiki>]]
27080 [[Foo|x <nowiki>[http://google.com g]</nowiki> x]]
27081 [[Foo|<nowiki>[[Bar]]</nowiki>]]
27082 [[Foo|<nowiki>x [[Bar]] x</nowiki>]]
27083 [[Foo|<nowiki>|Bar</nowiki>]]
27084 [[Foo|<nowiki>]]bar</nowiki>]]
27085 [[Foo|<nowiki>[[bar</nowiki>]]
27086 [[Foo|<nowiki>x [[ y</nowiki>]]
27087 [[Foo|<nowiki>x ]] y</nowiki>]]
27088 [[Foo|<nowiki>x ]] y [[ z</nowiki>]]
27089 !! html/php
27090 <p><a href="/wiki/Foo" title="Foo">Foobar]</a>
27091 <a href="/wiki/Foo" title="Foo">x [http://google.com g] x</a>
27092 <a href="/wiki/Foo" title="Foo">[[Bar]]</a>
27093 <a href="/wiki/Foo" title="Foo">x [[Bar]] x</a>
27094 <a href="/wiki/Foo" title="Foo">|Bar</a>
27095 <a href="/wiki/Foo" title="Foo">]]bar</a>
27096 <a href="/wiki/Foo" title="Foo">[[bar</a>
27097 <a href="/wiki/Foo" title="Foo">x [[ y</a>
27098 <a href="/wiki/Foo" title="Foo">x ]] y</a>
27099 <a href="/wiki/Foo" title="Foo">x ]] y [[ z</a>
27100 </p>
27101 !! end
27102
27103 !! test
27104 Links 3. WikiLinks: No escapes needed
27105 !! options
27106 parsoid=html2wt
27107 !! html/parsoid
27108 <p><a rel="mw:WikiLink" href="Foo">[Foobar</a>
27109 <a rel="mw:WikiLink" href="Foo" title="Foo">foo|bar</a></p>
27110 !! wikitext
27111 [[Foo|[Foobar]]
27112 [[Foo|foo|bar]]
27113 !! html/php
27114 <p><a href="/wiki/Foo" title="Foo">[Foobar</a>
27115 <a href="/wiki/Foo" title="Foo">foo|bar</a>
27116 </p>
27117 !! end
27118
27119 !! test
27120 Links 4. ExtLinks: Escapes needed
27121 !! options
27122 parsoid=html2wt
27123 !! html/parsoid
27124 <p><a rel="mw:ExtLink" href="http://google.com">[google]</a>
27125 <a rel="mw:ExtLink" href="http://google.com">google]</a>
27126 <a rel="mw:ExtLink" href="http://google.com">goog] le</a></p>
27127 <p>[http://google.com]</p>
27128 <p>[http://google.com google]</p>
27129 <p>[<a rel="mw:ExtLink" href="http://google.com">http://google.com</a>]</p>
27130 <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>
27131 !! wikitext
27132 [http://google.com <nowiki>[google]</nowiki>]
27133 [http://google.com <nowiki>google]</nowiki>]
27134 [http://google.com <nowiki>goog] le</nowiki>]
27135
27136 <nowiki>[http://google.com]</nowiki>
27137
27138 <nowiki>[http://google.com google]</nowiki>
27139
27140 [http://google.com<nowiki>]</nowiki>
27141
27142 [{{echo|http://google.com}}<nowiki>]</nowiki>
27143 !! html/php
27144 <p><a rel="nofollow" class="external text" href="http://google.com">[google]</a>
27145 <a rel="nofollow" class="external text" href="http://google.com">google]</a>
27146 <a rel="nofollow" class="external text" href="http://google.com">goog] le</a>
27147 </p><p>[http://google.com]
27148 </p><p>[http://google.com google]
27149 </p><p>[<a rel="nofollow" class="external free" href="http://google.com">http://google.com</a>]
27150 </p><p>[<a rel="nofollow" class="external free" href="http://google.com">http://google.com</a>]
27151 </p>
27152 !! end
27153
27154 !! test
27155 Links 5. ExtLinks: No escapes needed
27156 !! options
27157 parsoid=html2wt
27158 !! html/parsoid
27159 <p><a rel="mw:ExtLink" href="http://google.com">[google</a></p>
27160 <p>[<a ref="mw:ExtLink" href="http://google.com"></a>]</p>
27161 !! wikitext
27162 [http://google.com [google]
27163
27164 [[http://google.com]]
27165 !! html/php
27166 <p><a rel="nofollow" class="external text" href="http://google.com">[google</a>
27167 </p><p>[<a rel="nofollow" class="external autonumber" href="http://google.com">[1]</a>]
27168 </p>
27169 !! end
27170
27171 !! test
27172 Links 6. Add <nowiki/>s between text-nodes and url-links when required (T66300)
27173 !! options
27174 parsoid=html2wt
27175 !! html/parsoid
27176 <p>x<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>y
27177 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>?x
27178 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>&amp;x
27179 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>'x
27180 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>,x
27181 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>.x
27182 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>;x
27183 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>:x
27184 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>;x
27185 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>!x
27186 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>=x
27187 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>(x)
27188 <a rel="mw:ExtLink" href="http://example.com(x" data-parsoid='{"stx":"url"}'>http://example.com(x</a>)
27189 </p>
27190 !! wikitext
27191 x<nowiki/>http://example.com<nowiki/>y
27192 http://example.com<nowiki/>?x
27193 http://example.com<nowiki/>&x
27194 http://example.com<nowiki/>'x
27195 http://example.com<nowiki/>,x
27196 http://example.com<nowiki/>.x
27197 http://example.com<nowiki/>;x
27198 http://example.com<nowiki/>:x
27199 http://example.com<nowiki/>;x
27200 http://example.com<nowiki/>!x
27201 http://example.com<nowiki/>=x
27202 http://example.com<nowiki/>(x)
27203 http://example.com(x<nowiki/>)
27204 !! end
27205
27206 !! test
27207 Links 7a. Don't add spurious <nowiki/>s between text-nodes and url-links (T66300)
27208 !! options
27209 parsoid=html2wt
27210 !! html/parsoid
27211 <p>x
27212 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>
27213 y
27214 "<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>"
27215 (<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>)
27216 (<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>) foo
27217 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>,
27218 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>, foo
27219 </p>
27220 !! wikitext
27221 x
27222 http://example.com
27223 y
27224 "http://example.com"
27225 (http://example.com)
27226 (http://example.com) foo
27227 http://example.com,
27228 http://example.com, foo
27229 !! html/php
27230 <p>x
27231 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
27232 y
27233 "<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>"
27234 (<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
27235 (<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>) foo
27236 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>,
27237 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>, foo
27238 </p>
27239 !! end
27240
27241 !! test
27242 Links 7b. Don't add spurious <nowiki/>s between text-nodes and url-links (T66300)
27243 !! options
27244 parsoid=html2wt
27245 !! html/parsoid
27246 <p><a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>.,;:!?\
27247 -<a rel="mw:ExtLink" href="http://example.com">http://example.com</a>:</p>
27248 !! wikitext
27249 http://example.com.,;:!?\
27250 -http://example.com:
27251 !! html/php
27252 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>.,;:!?\
27253 -<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>:
27254 </p>
27255 !! end
27256
27257 !! test
27258 Links 8. Add <nowiki/>s between text-nodes and RFC-links when required (T66300)
27259 !! options
27260 parsoid=html2wt
27261 !! html/parsoid
27262 <p><a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>4
27263 <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y
27264 X<a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y</p>
27265 !! wikitext
27266 RFC 123<nowiki/>4
27267 RFC 123<nowiki/>y
27268 X<nowiki/>RFC 123<nowiki/>y
27269 !! end
27270
27271 !! test
27272 Links 9. Don't add spurious <nowiki/>s between text-nodes and RFC-links (T66300)
27273 !! options
27274 parsoid=html2wt
27275 !! html/parsoid
27276 <p><a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>?foo
27277 <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>&amp;foo
27278 -<a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>-
27279 </p>
27280 !! wikitext
27281 RFC 123?foo
27282 RFC 123&foo
27283 -RFC 123-
27284 !! html/php
27285 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>?foo
27286 <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>&amp;foo
27287 -<a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>-
27288 </p>
27289 !! end
27290
27291 !! test
27292 Links 10. Add <nowiki/>s between text-nodes and PMID-links when required (T66300)
27293 !! options
27294 parsoid=html2wt
27295 !! html/parsoid
27296 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>4
27297 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>y
27298 X<a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>y
27299 !! wikitext
27300 PMID 123<nowiki/>4
27301 PMID 123<nowiki/>y
27302 X<nowiki/>PMID 123<nowiki/>y
27303 !! end
27304
27305 !! test
27306 Links 11. Don't add spurious <nowiki/>s between text-nodes and PMID-links (T66300)
27307 !! options
27308 parsoid=html2wt
27309 !! html/parsoid
27310 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>?foo
27311 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>&foo
27312 -<a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>-
27313 </p>
27314 !! wikitext
27315 PMID 123?foo
27316 PMID 123&foo
27317 -PMID 123-
27318 !! html/php
27319 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>?foo
27320 <a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>&amp;foo
27321 -<a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>-
27322 </p>
27323 !! end
27324
27325 !! test
27326 Links 12. Add <nowiki/>s between text-nodes and ISBN-links when required (T66300)
27327 !! options
27328 parsoid=html2wt
27329 !! html/parsoid
27330 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>1
27331 <a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>x
27332 a<a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>b
27333 </p>
27334 !! wikitext
27335 ISBN 1234567890<nowiki/>1
27336 ISBN 1234567890<nowiki/>x
27337 a<nowiki/>ISBN 1234567890<nowiki/>b
27338 !! end
27339
27340 !! test
27341 Links 13. Don't add spurious <nowiki/>s between text-nodes and ISBN-links (T66300)
27342 !! options
27343 parsoid=html2wt
27344 !! html/parsoid
27345 <p>-<a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>'s
27346 !! wikitext
27347 -ISBN 1234567890's
27348 !! html/php
27349 <p>-<a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>'s
27350 </p>
27351 !! end
27352
27353 !! test
27354 Links 14. Protect link-like plain text. (Parsoid bug T78425)
27355 !! options
27356 parsoid=html2wt
27357 !! html/*
27358 <p>this is not a link: http://example.com
27359 </p>
27360 !! wikitext
27361 this is not a link: <nowiki>http://example.com</nowiki>
27362 !! end
27363
27364 !! test
27365 Links 15. Link trails can't become link prefixes.
27366 !! options
27367 language=is
27368 parsoid=html2wt
27369 !! html/parsoid
27370 <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>
27371 !! wikitext
27372 [[Söfnuður]]-[[00]]
27373 !! html/php
27374 <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>
27375 </p>
27376 !! end
27377
27378 #### --------------- Quotes ---------------
27379 #### 1. Quotes inside <b> and <i>
27380 #### 2. Link fragments separated by <i> and <b> tags
27381 #### 3. Link fragments inside <i> and <b>
27382 #### 4. No escaping needed
27383 #### --------------------------------------
27384 !! test
27385 1a. Quotes inside <b> and <i>
27386 !! options
27387 parsoid=html2wt
27388 !! html/*
27389 <p><i>'foo'</i>
27390 <i>''foo''</i>
27391 <i>'''foo'''</i>
27392 <i>foo</i>'s
27393 <b>'foo'</b>
27394 <b>''foo''</b>
27395 <b>'''foo'''</b>
27396 <b>foo'<i>bar'</i>baz</b>
27397 <b>foo</b>'s
27398 '<i>foo</i>
27399 <i>foo</i>'
27400 <i>foo'</i>'
27401 '<i>foo</i>'
27402 '<b>foo</b>
27403 <b>foo</b>'
27404 '<b>foo</b>'
27405 <i>fools'<span> errand</span></i>
27406 <i><span>fool</span>'s errand</i>
27407 '<i>foo</i> bar '<i>baz</i>
27408 a|!*#-:;+-~[]{}b'<i>x</i>
27409 </p>
27410 !! wikitext
27411 ''<nowiki/>'foo'''
27412 ''<nowiki>''foo''</nowiki>''
27413 ''<nowiki>'''foo'''</nowiki>''
27414 ''foo''<nowiki/>'s
27415 '''<nowiki/>'foo''''
27416 '''<nowiki>''foo''</nowiki>'''
27417 '''<nowiki>'''foo'''</nowiki>'''
27418 '''foo'<nowiki/>''bar'<nowiki/>''baz'''
27419 '''foo'''<nowiki/>'s
27420 '''foo''
27421 ''foo''<nowiki/>'
27422 ''foo'''<nowiki/>'
27423 '''foo''<nowiki/>'
27424 ''''foo'''
27425 '''foo'''<nowiki/>'
27426 ''''foo'''<nowiki/>'
27427 ''fools'<span> errand</span>''
27428 ''<span>fool</span>'s errand''
27429 '<nowiki/>''foo'' bar '''baz''
27430 a|!*#-:;+-~[]{}b'''x''
27431 !! end
27432
27433 !! test
27434 1b. Quotes inside <b> and <i> with other tags on same line
27435 !! options
27436 parsoid=html2wt
27437 !! html/parsoid
27438 '<i>a</i> foo <i><a rel="mw:WikiLink" href="Bar" title="Bar">bar</a></i>
27439 <i>a'</i> foo <i><a rel="mw:WikiLink" href="Bar" title="Bar">bar</a></i>
27440 <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>
27441 <a rel="mw:WikiLink" href="Foo" title="Foo">foo</a> x'<i><a href="Bar" rel="mw:WikiLink" title="Bar">bar</a></i>
27442 '<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>
27443 '<i>foo</i> <div title="name">test</div>
27444 '<i>foo</i> and <br data-parsoid='{"stx":"html","noClose":true}'/> bar
27445 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt5" data-mw='{"name":"references","attrs":{}}'>
27446 <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>
27447 </ol>
27448 !! wikitext
27449 '''a'' foo ''[[bar]]''
27450 ''a''' foo ''[[bar]]''
27451 ''a''' foo '''{{echo|[[bar]]}}'''
27452 [[foo]] x'''[[bar]]''
27453 '''foo'' <ref>test</ref>
27454 '''foo'' <div title="name">test</div>
27455 '''foo'' and <br> bar
27456 <references />
27457 !! end
27458
27459 !! test
27460 2. Link fragments separated by <i> and <b> tags
27461 !! options
27462 parsoid=html2wt
27463 !! html/parsoid
27464 <p>[[<i>foo</i>hello]]</p>
27465 <p>[[<b>foo</b>hello]]</p>
27466 !! wikitext
27467 [[''foo''<nowiki>hello]]</nowiki>
27468
27469 [['''foo'''<nowiki>hello]]</nowiki>
27470 !! end
27471
27472 # FIXME: Escaping one or both of [[ and ]] is also acceptable --
27473 # this is one of the shortcomings of this format
27474 !! test
27475 3. Link fragments inside <i> and <b>
27476 !! options
27477 parsoid=html2wt
27478 !! html/parsoid
27479 <p><i>[[foo</i>]]</p>
27480 <p><b>[[foo</b>]]</p>
27481 !! wikitext
27482 ''[[foo''<nowiki>]]</nowiki>
27483
27484 '''[[foo'''<nowiki>]]</nowiki>
27485 !! end
27486
27487 !! test
27488 4. No escaping needed
27489 !! options
27490 parsoid=html2wt
27491 !! html/parsoid
27492 <p>'<span><i>bar</i></span>'
27493 '<span><b>bar</b></span>'
27494 'a:b'foo
27495 </p>
27496 !! wikitext
27497 '<span>''bar''</span>'
27498 '<span>'''bar'''</span>'
27499 'a:b'foo
27500 !! end
27501
27502 #### ----------- Paragraphs ---------------
27503 #### 1. No unnecessary escapes
27504 #### --------------------------------------
27505
27506 !! test
27507 1. No unnecessary escapes
27508 !! options
27509 parsoid=html2wt
27510 !! html/parsoid
27511 <p>bar <span>[[foo]]</span>
27512 </p><p>=bar <span>[[foo]]</span>
27513 </p><p>[[bar <span>[[foo]]</span>
27514 </p><p>]]bar <span>[[foo]]</span>
27515 </p><p>=bar <span>foo]]</span>=
27516 </p>
27517 !! wikitext
27518 bar <span><nowiki>[[foo]]</nowiki></span>
27519
27520 =bar <span><nowiki>[[foo]]</nowiki></span>
27521
27522 [[bar <span><nowiki>[[foo]]</nowiki></span>
27523
27524 ]]bar <span><nowiki>[[foo]]</nowiki></span>
27525
27526 =bar <span>foo]]</span><nowiki>=</nowiki>
27527 !!end
27528
27529 #### ----------------------- PRE --------------------------
27530 !! test
27531 1. Leading whitespace in SOL context should be escaped
27532 !! options
27533 parsoid=html2wt
27534 !! html/parsoid
27535 <p> a</p>
27536
27537 <p> a</p>
27538
27539 <p> a(tab)</p>
27540
27541 <p> a
27542 <!--cmt-->
27543 a</p>
27544
27545 <p>a
27546 b</p>
27547
27548 <p>a
27549 b</p>
27550
27551 <p>a
27552 b</p>
27553 !! wikitext
27554 <nowiki> </nowiki>a
27555
27556 <nowiki> </nowiki> a
27557
27558 a(tab)
27559
27560 <nowiki> </nowiki> a
27561 <!--cmt-->
27562 <nowiki> </nowiki>a
27563
27564 a
27565 <nowiki> </nowiki>b
27566
27567 a
27568 b
27569
27570 a
27571 b
27572 !! html/php
27573 <p> a
27574 </p><p> a
27575 </p><p> a(tab)
27576 </p><p> a
27577 a
27578 </p><p>a
27579 b
27580 </p><p>a
27581 b
27582 </p><p>a
27583 b
27584 </p>
27585 !! end
27586
27587 !! test
27588 2. Leading whitespace in non-indent-pre contexts should not be escaped
27589 !! options
27590 parsoid=html2wt
27591 !! html/parsoid
27592 <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>
27593 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt4" data-mw='{"name":"references","attrs":{}}'>
27594 <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>
27595 b</span></li>
27596 </ol>
27597 !! wikitext
27598 foo <ref>''a''
27599 b</ref>
27600 <references />
27601 !! end
27602
27603 !! test
27604 3. Leading whitespace in indent-pre suppressing contexts should not be escaped
27605 !! options
27606 parsoid=html2wt
27607 !! html/parsoid
27608 <blockquote>
27609 <p>
27610 a
27611 <span>b</span>
27612 c</p>
27613 </blockquote>
27614 !! wikitext
27615 <blockquote>
27616 a
27617 <span>b</span>
27618 c
27619 </blockquote>
27620 !! end
27621
27622 !! test
27623 4. Leading whitespace in indent-pre suppressing contexts should not be escaped
27624 !! options
27625 parsoid=html2wt
27626 !! html/parsoid
27627 <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>
27628 !! wikitext
27629 [[File:Foobar.jpg|thumb|caption]]
27630 !! end
27631
27632 !! test
27633 5. Nowiki escaping should account for indent-pres
27634 !! options
27635 parsoid=html2wt
27636 !! html/parsoid
27637 <pre>==foo==</pre>
27638 !! wikitext
27639 ==foo==
27640 !! end
27641
27642 !! test
27643 T95794: nowiki escaping should account for leading space at start-of-line in an indent-pre block
27644 !! options
27645 parsoid=html2wt
27646 !! html/parsoid
27647 <pre>
27648 * foo
27649 * bar
27650 </pre>
27651 !! wikitext
27652 * foo
27653 * bar
27654 !! end
27655
27656 !! test
27657 Whitespace scrubbing in SOL position should account for SOL-sensitive wikitext markup
27658 !! options
27659 parsoid = {
27660 "modes": ["html2wt"],
27661 "scrubWikitext": true
27662 }
27663 !! html/parsoid
27664 <p> foo</p>
27665 <p> %foo</p>
27666 <p> *foo</p>
27667 <p> #foo</p>
27668 <p> =foo=</p>
27669 <p><link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid="{}"> *foo</p>
27670 <p> <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid="{}">*foo</p>
27671 <p> <!--boo-->*foo</p>
27672 <p><!--boo--> *foo</p>
27673 <p><!--a--> <!--b--> <!--c--> <!--d--> <!--e--> foo</p>
27674 <p><!--a--> <!--b--> <!--c--> <!--d--> <!--e--> *foo</p>
27675 !! wikitext
27676 foo
27677
27678 %foo
27679
27680 <nowiki/>*foo
27681
27682 <nowiki/>#foo
27683
27684 <nowiki/>=foo=
27685
27686 [[Category:Foo]]
27687 <nowiki/>*foo
27688
27689 [[Category:Foo]]
27690 <nowiki>*</nowiki>foo
27691
27692 <nowiki/><!--boo-->*foo
27693
27694 <!--boo--><nowiki/>*foo
27695
27696 <!--a--><!--b--><!--c--><!--d--><!--e-->foo
27697
27698 <!--a--><nowiki/><!--b--><!--c--><!--d--><!--e-->*foo
27699 !! end
27700
27701 #### --------------- Behavior Switches --------------------
27702
27703 !! test
27704 1. Valid behavior switches should be escaped
27705 !! options
27706 parsoid=html2wt
27707 !! html/parsoid
27708 __TOC__
27709 <i>__TOC__</i>
27710 !! wikitext
27711 <nowiki>__TOC__</nowiki>
27712 ''<nowiki>__TOC__</nowiki>''
27713 !! end
27714
27715 !! test
27716 2. Invalid behavior switches should not be escaped
27717 !! options
27718 parsoid=html2wt
27719 !! html/parsoid
27720 __TOO__
27721 __|__
27722 !! wikitext
27723 __TOO__
27724 __|__
27725 !! end
27726
27727 # We use indent-pre as an indirect way to test for sol-transparent behavior.
27728 !! test
27729 Behavior switches should be SOL-transparent
27730 !! options
27731 parsoid=html2wt
27732 !! html/parsoid
27733 <meta property="mw:PageProp/toc" />
27734
27735 <!-- this one's bogus -->
27736 <pre>__TOO__</pre>
27737
27738 <pre data-parsoid='{}'><meta property="mw:PageProp/toc" data-parsoid='{"src":"__TOC__","magicSrc":"__TOC__"}'/> foo</pre>
27739
27740 <meta property="mw:PageProp/toc" data-parsoid='{"src":"__TOC__","magicSrc":"__TOC__"}'/><pre data-parsoid='{}'>bar</pre>
27741 !! wikitext
27742 __TOC__
27743
27744 <!-- this one's bogus -->
27745 __TOO__
27746
27747 __TOC__ foo
27748
27749 __TOC__
27750 bar
27751 !! end
27752
27753 #### --------------- HTML tags ---------------
27754 #### 1. a tags
27755 #### 2. other tags
27756 #### 3. multi-line html tag
27757 #### 4. extension tags
27758 #### -----------------------------------------
27759 !! test
27760 1. a tags
27761 !! options
27762 parsoid=html2wt
27763 !! html/parsoid
27764 &lt;a href=&quot;http://google.com&quot;&gt;google&lt;/a&gt;
27765 !! wikitext
27766 <a href="http://google.com">google</a>
27767 !! end
27768
27769 !! test
27770 2. other tags
27771 !! options
27772 parsoid=html2wt
27773 !! html/parsoid
27774 <ul><li> &lt;div&gt;foo&lt;/div&gt;</li>
27775 <li> &lt;div style=&quot;color:red&quot;&gt;foo&lt;/div&gt;</li>
27776 <li> &lt;td&gt;</li></ul>
27777
27778 !! wikitext
27779 * <nowiki><div>foo</div></nowiki>
27780 * <nowiki><div style="color:red">foo</div></nowiki>
27781 * <nowiki><td></nowiki>
27782 !! end
27783
27784 !! test
27785 3. multi-line html tag
27786 !! options
27787 parsoid=html2wt
27788 !! html/parsoid
27789 <p>&lt;div
27790 &gt;foo&lt;/div
27791 &gt;
27792 </p>
27793 !! wikitext
27794 <nowiki><div
27795 >foo</div
27796 ></nowiki>
27797 !! end
27798
27799 !! test
27800 4. extension tags
27801 !! options
27802 parsoid=html2wt
27803 !! html/parsoid
27804 <p>&lt;ref&gt;foo&lt;/ref&gt;
27805 </p><p>&lt;ref&gt;bar
27806 </p><p>baz&lt;/ref&gt;
27807 </p>
27808 !! wikitext
27809 <nowiki><ref>foo</ref></nowiki>
27810
27811 <nowiki><ref>bar</nowiki>
27812
27813 baz<nowiki></ref></nowiki>
27814 !! end
27815
27816 !! test
27817 Parsoid: newline inducing block nodes don't suppress <nowiki>
27818 !! options
27819 parsoid=html2wt
27820 !! html/parsoid
27821 a<h1>foo</h1>
27822 !! wikitext
27823 <nowiki> </nowiki>a
27824
27825 = foo =
27826 !! end
27827
27828 #### --------------- Others ---------------
27829 !! test
27830 Escaping nowikis
27831 !! options
27832 parsoid=html2wt
27833 !! html/parsoid
27834 <p>&lt;nowiki&gt;foo&lt;/nowiki&gt;
27835 </p>
27836 !! wikitext
27837 &lt;nowiki&gt;foo&lt;/nowiki&gt;
27838 !! end
27839
27840 ## The quote-char in the input is necessary for triggering the bug
27841 !! test
27842 (T54035) Nowiki-escaping should not get tripped by " :" in text
27843 !! options
27844 parsoid=html2wt
27845 !! html/parsoid
27846 <p>foo's bar :</p>
27847 !! wikitext
27848 foo's bar :
27849 !! end
27850
27851 #----------- End of wikitext escaping tests --------------
27852
27853 !! test
27854
27855 Tag-like HTML structures are passed through as text
27856 !! wikitext
27857 <x y>
27858
27859 <x.y>
27860
27861 <x-y>
27862
27863 1>2
27864
27865 x<y
27866
27867 a>b
27868
27869 1<d e>f
27870 !! html
27871 <p>&lt;x y&gt;
27872 </p><p>&lt;x.y&gt;
27873 </p><p>&lt;x-y&gt;
27874 </p><p>1&gt;2
27875 </p><p>x&lt;y
27876 </p><p>a&gt;b
27877 </p><p>1&lt;d e&gt;f
27878 </p>
27879 !! end
27880
27881 !! test
27882 HTML tag with necessary entities in attributes
27883 !! wikitext
27884 <span title="&amp;amp;">foo</span>
27885 !! html
27886 <p><span title="&amp;amp;">foo</span>
27887 </p>
27888 !! end
27889
27890 !! test
27891 HTML tag with 'unnecessary' entity encoding in attributes
27892 !! wikitext
27893 <span title="&amp;">foo</span>
27894 !! html
27895 <p><span title="&amp;">foo</span>
27896 </p>
27897 !! end
27898
27899 !! test
27900 HTML tag with broken attribute value quoting
27901 !! options
27902 parsoid=wt2html,html2html
27903 !! wikitext
27904 <span title="Hello world>Foo</span>
27905 !! html/php
27906 <p><span title="Hello world">Foo</span>
27907 </p>
27908 !! html/parsoid
27909 <p><span title="Hello world">Foo</span></p>
27910 !! end
27911
27912 !! test
27913 Self-closed tag with broken attribute value quoting
27914 !! options
27915 parsoid=wt2html,html2html
27916 !! wikitext
27917 <div title="Hello world />Foo
27918 !! html/php+tidy
27919 <div title="Hello world"></div><p>Foo
27920 </p>
27921 !! html/parsoid
27922 <div title="Hello world " data-parsoid='{"stx":"html","selfClose":true}'></div><p>Foo</p>
27923 !! end
27924
27925 !! test
27926 Table with broken attribute value quoting
27927 !! options
27928 parsoid=wt2html,html2html
27929 !! wikitext
27930 {|
27931 | title="Hello world|Foo
27932 |}
27933 !! html/php
27934 <table>
27935 <tr>
27936 <td title="Hello world">Foo
27937 </td></tr></table>
27938
27939 !! html/parsoid
27940 <table>
27941 <tr>
27942 <td title="Hello world">Foo
27943 </td></tr></table>
27944
27945 !! end
27946
27947 !! test
27948 Table with broken attribute value quoting on consecutive lines
27949 !! options
27950 parsoid=wt2html,html2html
27951 !! wikitext
27952 {|
27953 | title="Hello world|Foo
27954 | style="color:red|Bar
27955 |}
27956 !! html/php
27957 <table>
27958 <tr>
27959 <td title="Hello world">Foo
27960 </td>
27961 <td style="color:red">Bar
27962 </td></tr></table>
27963
27964 !! html/parsoid
27965 <table><tbody>
27966 <tr>
27967 <td title="Hello world">Foo
27968 </td><td style="color: red">Bar
27969 </td></tr></tbody></table>
27970
27971 !! end
27972
27973 !!test
27974 Accept empty td cell attribute
27975 !! wikitext
27976 {|
27977 | align="center" |foo|| |
27978 |}
27979 !! html
27980 <table>
27981 <tr>
27982 <td align="center">foo</td>
27983 <td>
27984 </td></tr></table>
27985
27986 !!end
27987
27988 !!test
27989 Non-empty attributes in th-cells
27990 !! wikitext
27991 {|
27992 !Foo!! style="color: red" |Bar
27993 |}
27994 !! html
27995 <table>
27996 <tr>
27997 <th>Foo</th>
27998 <th style="color: red">Bar
27999 </th></tr></table>
28000
28001 !!end
28002
28003 !!test
28004 Accept empty attributes in th-cells
28005 !! wikitext
28006 {|
28007 !|foo!!|bar
28008 |}
28009 !! html
28010 <table>
28011 <tr>
28012 <th>foo</th>
28013 <th>bar
28014 </th></tr></table>
28015
28016 !!end
28017
28018 !!test
28019 Empty table rows go away
28020 !! wikitext
28021 {|
28022 |Hello
28023 |there
28024 |- class="foo"
28025 |-
28026 |}
28027 !! html
28028 <table>
28029 <tr>
28030 <td>Hello
28031 </td>
28032 <td>there
28033 </td></tr>
28034
28035 </table>
28036
28037 !! end
28038
28039 ###
28040 ### Parsoid-centric tests for testing RTing of inter-element separators
28041 ### Edge cases not tested by existing parser tests and specific to
28042 ### Parsoid-specific serialization strategies.
28043 ###
28044
28045 !!test
28046 RT-ed inter-element separators should be valid separators
28047 !! wikitext
28048 {|
28049 |- [[foo]]
28050 |}
28051 !! html/php
28052 <table>
28053
28054 </table>
28055
28056 !! html/parsoid
28057 <table>
28058 <tbody><tr class='mw-empty-elt' data-parsoid='{"startTagSrc":"|-","a":{"[[foo]]":null},"sa":{"[[foo]]":""},"autoInsertedEnd":true}'></tr>
28059 </tbody></table>
28060 !!end
28061
28062 # Parsoid-only test of a DOM pass
28063 !!test
28064 Trailing newlines in a deep dom-subtree that ends a wikitext line should be migrated out
28065 !! wikitext
28066 {|
28067 |<small>foo
28068 bar
28069 |}
28070
28071 {|
28072 |<small>foo<small>
28073 |}
28074 !! html/parsoid
28075 <table>
28076 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'><small data-parsoid='{"stx":"html","autoInsertedEnd":true}'>foo
28077 <p>bar</p></small></td></tr>
28078 </tbody></table>
28079
28080 <table>
28081 <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>
28082 </tbody></table>
28083 !!end
28084
28085 # Note that the "style" attribute is really a template parameter here.
28086 # The = would have to be {{=}} if you wanted the literal.
28087 !!test
28088 Empty TD followed by TD with tpl-generated attribute
28089 !! wikitext
28090 {|
28091 |-
28092 |
28093 |{{echo|style='color:red'}}|foo
28094 |}
28095 !! html
28096 <table>
28097
28098 <tr>
28099 <td>
28100 </td>
28101 <td>foo
28102 </td></tr></table>
28103
28104 !!end
28105
28106 !!test
28107 Indented table with an empty td
28108 !! wikitext
28109 {|
28110 |-
28111 |
28112 |foo
28113 |}
28114 !! html
28115 <table>
28116
28117 <tr>
28118 <td>
28119 </td>
28120 <td>foo
28121 </td></tr></table>
28122
28123 !!end
28124
28125 !! test
28126 Indented table with blank lines in between (T85627)
28127 !! wikitext
28128 {|
28129 |foo
28130
28131
28132 |}
28133 !! html/php
28134 <table>
28135 <tr>
28136 <td>foo
28137 <p><br />
28138 </p>
28139 </td></tr></table>
28140
28141 !! html/parsoid
28142 <table>
28143 <tbody><tr><td>foo
28144 <p>
28145 <br /></p></td></tr>
28146 </tbody></table>
28147 !! end
28148
28149 !!test
28150 Indented block & table
28151 !! wikitext
28152 <div>foo</div>
28153 {|
28154 |foo
28155 |}
28156 !! html/php
28157 <div>foo</div>
28158 <table>
28159 <tr>
28160 <td>foo
28161 </td></tr></table>
28162
28163 !! html/parsoid
28164 <div data-parsoid='{"stx":"html"}'>foo</div>
28165 <table><tbody>
28166 <tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'>foo</td></tr>
28167 </tbody></table>
28168 !!end
28169
28170 !! test
28171 Indent and comment before table row
28172 !! wikitext
28173 {|
28174 <!--hi-->|-
28175 |there
28176 |}
28177 !! html/php
28178 <table>
28179
28180 <tr>
28181 <td>there
28182 </td></tr></table>
28183
28184 !! html/parsoid
28185 <table>
28186 <!--hi--><tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
28187 <td data-parsoid='{"autoInsertedEnd":true}'> there</td></tr>
28188 </tbody></table>
28189 !! end
28190
28191 # PHP parser omits empty TR
28192 !!test
28193 Empty TR followed by a template-generated TR
28194 !! wikitext
28195 {|
28196 |-
28197 {{echo|<tr><td>foo</td></tr>}}
28198 |}
28199 !! html/php+tidy
28200 <table>
28201
28202 <tbody><tr><td>foo</td></tr>
28203 </tbody></table>
28204 !! html/parsoid
28205 <table>
28206 <tbody>
28207 <tr class='mw-empty-elt'></tr>
28208 <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}}]}'>
28209 <td>foo</td></tr>
28210 </tbody></table>
28211 !!end
28212
28213 ## PHP and parsoid output differ for this; as usual PHP omits empty
28214 ## elements, and since it strips the comments the TR is empty.
28215 !!test
28216 Empty TR followed by mixed-ws-comment line should RT correctly
28217 !! wikitext
28218 {|
28219 |-
28220 <!--c-->
28221 |-
28222 <!--c--> <!--d-->
28223 |}
28224 !! html/php+tidy
28225 <table>
28226
28227
28228 </table>
28229 !! html/parsoid
28230 <table>
28231 <tbody>
28232 <tr class='mw-empty-elt'></tr>
28233 <!--c-->
28234 <tr>
28235 <!--c--> </tr><!--d-->
28236 </tbody></table>
28237
28238 !!end
28239
28240 !!test
28241 Multi-line image caption generated by templates with/without trailing newlines
28242 !! wikitext
28243 [[File:Foobar.jpg|thumb|300x300px|foo\n{{echo|A}}\n{{echo|B}}\n{{echo|C}}]]
28244 [[File:Foobar.jpg|thumb|300x300px|foo\n{{echo|A}}\n{{echo|B}}\n{{echo|C}}\n\n]]
28245 !! html/parsoid
28246 <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>
28247 <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>
28248 !!end
28249
28250 !! test
28251 New element inserted (without intervening newlines) after an old sol-transparent node should serialize correctly
28252 !! options
28253 parsoid=html2wt
28254 !! html/parsoid
28255 <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>
28256
28257 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{}'/><h1>new heading</h1>
28258 !! wikitext
28259 <includeonly>foo</includeonly>
28260 new para
28261
28262 [[Category:Foo]]
28263
28264 = new heading =
28265 !! end
28266
28267 ## PHP emits broken html for this, and since this is primarily
28268 ## a Parsoid serializer test, marking this Parsoid only
28269 !!test
28270 Improperly nested inline or quotes tags with whitespace in between
28271 !! wikitext
28272 <span> <s>x</span> </s>
28273 ''' ''x''' ''
28274 !! html/parsoid
28275 <p><span> <s>x</s></span><s> </s>
28276 <b> <i>x</i></b><i> </i>
28277 </p>
28278 !!end
28279
28280 !!test
28281 Encapsulate protected attributes from wt
28282 !! wikitext
28283 <div typeof="mw:placeholder stuff" data-mw="whoo" data-parsoid="weird" data-parsoid-other="no" about="time" rel="mw:true">foo</div>
28284
28285 {| typeof="mw:placeholder stuff" data-mw="whoo" data-parsoid="weird" data-parsoid-other="no" about="time" rel="mw:true"
28286 |ok
28287 |}
28288 !! html/parsoid
28289 <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>
28290
28291 <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">
28292 <tbody><tr><td data-parsoid='{"autoInsertedEnd":true}'>ok</td></tr>
28293 </tbody></table>
28294 !!end
28295
28296 ## Currently the p-wrapper is fragile in how it adds / removes transformations.
28297 ## Having nested or stray pre tags results in the attempt to add duplicates,
28298 ## causing an assertion fail. This test tries to prevent that situation.
28299 !! test
28300 Ensure ParagraphWrapper can deal with stray closing pre tags
28301 !! options
28302 parsoid=wt2html
28303 !! wikitext
28304 plain text</pre>
28305 !! html/parsoid
28306 <p>plain text</p>
28307 !! end
28308
28309 ## Remex doesn't account for fostered content.
28310 !! test
28311 1. Ensure fostered text content is wrapped in element nodes
28312 !! options
28313 parsoid=wt2html
28314 !! wikitext
28315 <table>hi</table><table>ho</table>
28316 !! html/php+tidy
28317 hi<table></table>ho<table></table>
28318 !! html/parsoid
28319 <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>
28320 !! end
28321
28322 ## Remex doesn't account for fostered content.
28323 !! test
28324 2. Ensure fostered text content is wrapped in element nodes (traps regressions around fostered marker on the element getting lost)
28325 !! options
28326 parsoid=wt2html,wt2wt
28327 !! wikitext
28328 <table>
28329 <tr> || ||
28330 <td> a
28331 </table>
28332 !! html/php+tidy
28333 || ||
28334 <table>
28335 <tbody><tr><td> a
28336 </td></tr></tbody></table>
28337 !! html/parsoid
28338 <p data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true}'> || ||</p>
28339 <table data-parsoid='{"stx":"html"}'>
28340 <tbody><tr data-parsoid='{"stx":"html","autoInsertedEnd":true}'><td data-parsoid='{"stx":"html","autoInsertedEnd":true}'> a
28341 </td></tr></tbody></table>
28342 !! end
28343
28344 ## Remex doesn't account for fostered content.
28345 !! test
28346 Encapsulation properly handles null DSR information from foster box
28347 !! options
28348 parsoid=wt2html,wt2wt
28349 !! wikitext
28350 {{echo|<table>foo<tr><td>bar</td></tr></table>}}
28351 !! html/parsoid
28352 <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>
28353 !! end
28354
28355 ## Remex doesn't account for fostered content.
28356 !! test
28357 1. Encapsulate foster-parented transclusion content
28358 !! options
28359 parsoid=wt2wt,wt2html
28360 !! wikitext
28361 <table>{{echo|foo<tr><td>bar</td></tr>}}</table>
28362 !! html/php+tidy
28363 foo<table><tbody><tr><td>bar</td></tr></tbody></table>
28364 !! html/parsoid
28365 <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>
28366 !! end
28367
28368 !! test
28369 2. Encapsulate foster-parented transclusion content
28370 !! options
28371 parsoid=wt2wt,wt2html
28372 !! wikitext
28373 <table><div>{{echo|foo}}</div><tr><td>bar</td></tr></table>
28374 !! html/parsoid
28375 <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>
28376 <table>
28377 <tbody>
28378 <tr>
28379 <td>bar</td>
28380 </tr>
28381 </tbody>
28382 </table>
28383 !! end
28384
28385 !! test
28386 3. Encapsulate foster-parented transclusion content
28387 !! options
28388 parsoid=wt2wt,wt2html
28389 !! wikitext
28390 <table><div><p>{{echo|foo</p></div><tr><td>}}bar</td></tr></table>
28391 !! html/parsoid
28392 <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;]}">
28393 <p>foo</p>
28394 </div>
28395 <table>
28396 <tbody>
28397 <tr>
28398 <td>bar</td>
28399 </tr>
28400 </tbody>
28401 </table>
28402 !! end
28403
28404 !! test
28405 4. Encapsulate foster-parented transclusion content
28406 !! options
28407 parsoid=wt2wt,wt2html
28408 !! wikitext
28409 <table><div><p>{{echo|foo</p></div><tr><td>}}bar</td></tr></table>
28410 !! html/parsoid
28411 <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;]}">
28412 <p>foo</p>
28413 </div>
28414 <table>
28415 <tbody>
28416 <tr>
28417 <td>bar</td>
28418 </tr>
28419 </tbody>
28420 </table>
28421 !! end
28422
28423 ## Remex doesn't account for fostered content.
28424 !! test
28425 5. Encapsulate foster-parented transclusion content
28426 !!options
28427 parsoid=wt2wt,wt2html
28428 !! wikitext
28429 <table><tr><td><div><p>{{echo|foo</p></div></td>foo}}</tr></table>
28430 !! html/php+tidy
28431 foo<table><tbody><tr><td><div><p>foo</p></div></td></tr></tbody></table>
28432 !! html/parsoid
28433 <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>
28434 !! end
28435
28436 ## Remex doesn't account for fostered content.
28437 !! test
28438 6. Encapsulate foster-parented transclusion content
28439 !! options
28440 parsoid=wt2wt,wt2html
28441 !! wikitext
28442 <table><tr><td><div><p>{{echo|foo</p></div></td>foo</tr></table>}}<p>ok</p>
28443 !! html/php+tidy
28444 foo<table><tbody><tr><td><div><p>foo</p></div></td></tr></tbody></table><p>ok</p>
28445 !! html/parsoid
28446 <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>
28447 !! end
28448
28449 !! test
28450 7. Encapsulate foster-parented transclusion content
28451 !!options
28452 parsoid=wt2wt,wt2html
28453 !! wikitext
28454 <table>{{echo|<p>foo</p>}}<td>bar</td></table>
28455 !! html/parsoid
28456 <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>
28457 <table>
28458 <tbody>
28459 <tr>
28460 <td>bar</td>
28461 </tr>
28462 </tbody>
28463 </table>
28464 !! end
28465
28466 ## Remex doesn't account for fostered content.
28467 # Note that the wt is broken on purpose: the = should be {{=}} if you
28468 # don't want it to be a template parameter key.
28469 !! test
28470 8. Encapsulate foster-parented transclusion content
28471 !! options
28472 parsoid=wt2wt,wt2html
28473 !! wikitext
28474 {{echo|a
28475 }}{|{{echo|style='color:red'}}
28476 |-
28477 |b
28478 |}
28479 !! html/php+tidy
28480 <p>a
28481 </p>
28482 <table>
28483
28484 <tbody><tr>
28485 <td>b
28486 </td></tr></tbody></table>
28487 !! html/parsoid
28488 <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">
28489 </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">
28490 <tbody><tr>
28491 <td>b
28492 </td></tr></tbody></table>
28493 !! end
28494
28495 ## Remex doesn't account for fostered content.
28496 !! test
28497 9. Encapsulate foster-parented transclusion content
28498 !!options
28499 parsoid=wt2wt,wt2html
28500 !! wikitext
28501 <table>{{echo|hi</table>hello}}
28502 !! html/php+tidy
28503 hi<table></table><p>hello
28504 </p>
28505 !! html/parsoid
28506 <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>
28507 !! end
28508
28509 !! test
28510 Table in fosterable position
28511 !!options
28512 parsoid=wt2html
28513 !! wikitext
28514 {{OpenTable}}
28515 <div>
28516 {|
28517 |}
28518 </div>
28519 |}
28520 !! html/parsoid
28521 <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">
28522 </span>
28523 <table about="#mwt1" data-parsoid='{"autoInsertedEnd":true}'></table>
28524
28525 <table>
28526 </table>
28527 !! end
28528
28529 # Parsoid only for T66747
28530 !! test
28531 Properly encapsulate empty-content transclusions in fosterable positions
28532 !! wikitext
28533 <table>
28534 {{#if:|
28535 <td>foo</td>
28536 }}
28537 </table>
28538 !! html/parsoid
28539 <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"}]]}'>
28540
28541 </table>
28542 !! end
28543
28544 ## No longer captures its original intention
28545 !! test
28546 Always encapsulate foster box when template range is expanded to table
28547 !! options
28548 disabled
28549 parsoid=wt2wt
28550 !! wikitext
28551 {|
28552 hello
28553 {{OpenTable}}
28554 |}
28555 !! html/parsoid
28556
28557 !! end
28558
28559 !! test
28560 T115289: Unclosed table
28561 !! wikitext
28562 {{echo|<table>}}<!--c-->[[Category:Two]]
28563 !! html/parsoid
28564 <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>
28565 !! end
28566
28567 !! test
28568 T115289: Don't migrate newlines out of tables with fostered content
28569 !! wikitext
28570 <table><td></td>{{echo|<tr>[[Category:One]]}}<!--c-->[[Category:Two]]
28571 !! html/parsoid
28572 <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>
28573 !! end
28574
28575 !! test
28576 T73074: More fostering fun
28577 !! wikitext
28578 <table><td></td>{{echo|<tr>}}<!--c-->[[Category:Two]]
28579 !! html/parsoid
28580 <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>
28581 !! end
28582
28583 !!test
28584 Support <object> element with .data attribute
28585 !!options
28586 parsoid=html2wt
28587 !! html/parsoid
28588 <object data="test.swf"></object>
28589 !! wikitext
28590 <object data="test.swf"></object>
28591 !!end
28592
28593 !! test
28594 Don't block XML namespace declaration
28595 !! wikitext
28596 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">MediaWiki</span>
28597 !! html/php
28598 <p><span xmlns:dct="http&#58;//purl.org/dc/terms/" property="dct:title">MediaWiki</span>
28599 </p>
28600 !! html/parsoid
28601 <p><span xmlns:dct="http://purl.org/dc/terms/" data-x-property="dct:title" data-parsoid='{"stx":"html"}'>MediaWiki</span></p>
28602 !! end
28603
28604 # -----------------------------------------------------------------
28605 # The following section of tests are primarily to spec requirements
28606 # around Parsoid's serialization (old, new, edited content)
28607 #
28608 # All these tests are marked Parsoid html2wt and html2html only
28609 # ----------------------------------------------------------------
28610
28611 !! test
28612 Ignore rel attribute in a-tags during serialization to url-links
28613 !! options
28614 parsoid=html2wt
28615 !! html/parsoid
28616 <a href='http://en.wikipedia.org/wiki/Foobar'>http://en.wikipedia.org/wiki/Foobar</a>
28617 <a href='http://en.wikipedia.org/wiki/Foobar' rel='mw:ExtLink'>http://en.wikipedia.org/wiki/Foobar</a>
28618 <a href='http://en.wikipedia.org/wiki/Foobar' rel='mw:WikiLink'>http://en.wikipedia.org/wiki/Foobar</a>
28619 !! wikitext
28620 http://en.wikipedia.org/wiki/Foobar
28621 http://en.wikipedia.org/wiki/Foobar
28622 http://en.wikipedia.org/wiki/Foobar
28623 !! end
28624
28625 # 'mi' is a localinterwiki prefix as well as a language
28626 !! test
28627 Serialize interwiki links pointing to the current wiki as plain wiki links (T67869)
28628 !! options
28629 parsoid=html2wt
28630 !! html/parsoid
28631 <p><a rel="mw:ExtLink" href="http://mi.wikipedia.org/wiki/Foo">Foo</a></p>
28632 !! wikitext
28633 [[Foo]]
28634 !! end
28635
28636 !! test
28637 Parsoid should accept interwiki shortcuts
28638 !! options
28639 parsoid=html2wt
28640 !! html/parsoid
28641 <p><a rel='mw:WikiLink' href='./fr:Foo'>Foo</a>
28642 <a rel='mw:ExtLink' href='./fr:Foo'>Foo</a>
28643 <a href='./fr:Foo'>Foo</a></p>
28644 <p><a rel='mw:WikiLink' href='fr%3AFoo'>Foo</a>
28645 <a rel='mw:ExtLink' href='fr%3AFoo'>Foo</a>
28646 <a href='fr%3AFoo'>Foo</a></p>
28647 <p><a href='FR%3AFoo'>Foo</a>
28648 <a href='./FR:Foo'>Foo</a></p>
28649 !! wikitext
28650 [[:fr:Foo|Foo]]
28651 [[:fr:Foo|Foo]]
28652 [[:fr:Foo|Foo]]
28653
28654 [[:fr:Foo|Foo]]
28655 [[:fr:Foo|Foo]]
28656 [[:fr:Foo|Foo]]
28657
28658 [[:fr:Foo|Foo]]
28659 [[:fr:Foo|Foo]]
28660 !! end
28661
28662 !! test
28663 Parsoid should not accept invalid interwiki shortcuts
28664 !! options
28665 parsoid=html2wt
28666 !! html/parsoid
28667 <p><a rel='mw:WikiLink' href='news:Foo'>Foo</a>
28668 <a rel='mw:ExtLink' href='news:Foo'>Foo</a>
28669 <a href='news:Foo'>Foo</a></p>
28670 !! wikitext
28671 [news:Foo Foo]
28672 [news:Foo Foo]
28673 [news:Foo Foo]
28674 !! end
28675
28676 # See T93839
28677 !! test
28678 New wikilinks should be serialized properly
28679 !! options
28680 parsoid=html2wt
28681 !! html/parsoid
28682 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{}'>Foo</a>
28683 <a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a>
28684 <a href="//en.wikipedia.org/wiki/Foo">//en.wikipedia.org/wiki/Foo</a>
28685 <a href="http://en.wikipedia.org/wiki/Foo">http://en.wikipedia.org/wiki/Foo</a>
28686 <a href="//en.wikipedia.org/wiki/Foo_bar">//en.wikipedia.org/wiki/Foo bar</a>
28687 !! wikitext
28688 [[Foo]]
28689 [[Foo]]
28690 [[:en:Foo|//en.wikipedia.org/wiki/Foo]]
28691 http://en.wikipedia.org/wiki/Foo
28692 [[:en:Foo_bar|//en.wikipedia.org/wiki/Foo bar]]
28693 !! end
28694
28695 !! test
28696 New wiki links (href variations)
28697 !! options
28698 parsoid=html2wt
28699 !! html/parsoid
28700 <a rel="mw:WikiLink" href="./Foo_bar">Foo_bar</a>
28701 <a rel="mw:WikiLink" href="Foo_bar">Foo_bar</a>
28702 <a rel="mw:WikiLink" href="Foo bar">Foo_bar</a>
28703 <a rel="mw:WikiLink" href="./Toxine_bact%C3%A9rienne">Toxine bactérienne</a>
28704 !! wikitext
28705 [[Foo_bar]]
28706 [[Foo_bar]]
28707 [[Foo_bar]]
28708 [[Toxine bactérienne]]
28709 !! end
28710
28711 !! test
28712 New wiki links (content string variations)
28713 !! options
28714 parsoid=html2wt
28715 !! html/parsoid
28716 <a rel="mw:WikiLink" href="./Foo_bar">Foo_bar</a>
28717 <a rel="mw:WikiLink" href="./Foo_bar">Foo bar</a>
28718 <a rel="mw:WikiLink" href="./Foo_bar">./Foo_bar</a>
28719 !! wikitext
28720 [[Foo_bar]]
28721 [[Foo bar]]
28722 [[Foo_bar|./Foo_bar]]
28723 !! end
28724
28725 !! test
28726 New category links (href variations)
28727 !! options
28728 parsoid=html2wt
28729 !! html/parsoid
28730 <link rel="mw:PageProp/Category" href="./Category:Toxine_bactérienne" />
28731 <link rel="mw:PageProp/Category" href="./Category:Toxine_bact%C3%A9rienne" />
28732 <link rel="mw:PageProp/Category" href="Category:Toxine_bact%C3%A9rienne" />
28733 !! wikitext
28734 [[Category:Toxine bactérienne]]
28735 [[Category:Toxine bactérienne]]
28736 [[Category:Toxine bactérienne]]
28737 !! end
28738
28739 !! test
28740 New sol transparent links don't need indent-pre nowiki protection
28741 !! options
28742 parsoid=html2wt
28743 language=de
28744 !! html/parsoid
28745 <link rel="mw:PageProp/redirect" href="./Main_Page">
28746 <!-- this is good --> <link rel="mw:PageProp/Category" href="./Category:Good" />
28747 <!-- this is great --> <link rel="mw:PageProp/Category" href="./Kategorie:Great" />
28748 !! wikitext
28749 #WEITERLEITUNG [[Main Page]]
28750 <!-- this is good --> [[Category:Good]]
28751 <!-- this is great --> [[Kategorie:Great]]
28752 !! end
28753
28754 !! test
28755 New interlanguage links (href variations)
28756 !! options
28757 parsoid=html2wt
28758 !! html/parsoid
28759 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine bactérienne" />
28760 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine_bactérienne" />
28761 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine_bact%C3%A9rienne" />
28762 !! wikitext
28763 [[es:Toxine bactérienne]]
28764 [[es:Toxine_bactérienne]]
28765 [[es:Toxine_bactérienne]]
28766 !! end
28767
28768 !! test
28769 Image: Modifying size of an image (1)
28770 !! options
28771 parsoid={
28772 "modes": ["wt2wt"],
28773 "changes": [
28774 ["img[height]", "attr", "height", "22"],
28775 ["img[width]", "attr", "width", "200"]
28776 ]
28777 }
28778 !! wikitext
28779 [[Image:Foobar.jpg|230x230px]]
28780 !! wikitext/edited
28781 [[Image:Foobar.jpg|200x200px]]
28782 !!end
28783
28784 !! test
28785 Image: Modifying size of an image (2)
28786 !! options
28787 parsoid={
28788 "modes": ["wt2wt"],
28789 "changes": [
28790 ["img[height]", "attr", "height", "100"],
28791 ["img[width]", "attr", "width", "500"]
28792 ]
28793 }
28794 !! wikitext
28795 [[Image:Foobar.jpg|230x230px]]
28796 !! wikitext/edited
28797 [[Image:Foobar.jpg|500x500px]]
28798 !!end
28799
28800 # Change in size is ignored so long as class='mw-default-size'
28801 !! test
28802 Image: Modifying size of an image (3)
28803 !! options
28804 parsoid={
28805 "modes": ["wt2wt"],
28806 "changes": [
28807 ["figure[class]", "removeClass", "mw-default-size"],
28808 ["figure img", "attr", "height", "19"],
28809 ["figure img", "attr", "width", "170"]
28810 ]
28811 }
28812 !! wikitext
28813 [[Image:Foobar.jpg|thumb]]
28814 !! wikitext/edited
28815 [[Image:Foobar.jpg|thumb|170x170px]]
28816 !!end
28817
28818 !! test
28819 Image: Modifying alignment of an image (T50665)
28820 !! options
28821 parsoid={
28822 "modes": ["wt2wt"],
28823 "changes": [
28824 ["figure[class]", "removeClass", "mw-halign-right"],
28825 ["figure[class]", "addClass", "mw-halign-left"]
28826 ]
28827 }
28828 !! wikitext
28829 [[Image:Foobar.jpg|thumb|caption|right]]
28830 !! wikitext/edited
28831 [[Image:Foobar.jpg|thumb|caption|left]]
28832 !! end
28833
28834 !! test
28835 Image: Modifying mw-default-size of an frameless image (T64805)
28836 !! options
28837 parsoid={
28838 "modes": ["wt2wt"],
28839 "changes": [
28840 ["figure.mw-default-size", "removeClass", "mw-default-size"]
28841 ]
28842 }
28843 !! wikitext
28844 [[Image:Foobar.jpg|frameless|right]]
28845 !! wikitext/edited
28846 [[Image:Foobar.jpg|frameless|right|220x220px]]
28847 !! end
28848
28849 !! test
28850 Image: Modifying valign of an image (T51221)
28851 !! options
28852 parsoid={
28853 "modes": ["wt2wt"],
28854 "changes": [
28855 ["*[typeof=\"mw:Image\"]", "removeClass", "mw-valign-middle"],
28856 ["*[typeof=\"mw:Image\"]", "addClass", "mw-valign-text-top"]
28857 ]
28858 }
28859 !! wikitext
28860 [[File:Foobar.jpg|20px|middle]]
28861 !! wikitext/edited
28862 [[File:Foobar.jpg|20px|text-top]]
28863 !! end
28864
28865 !! test
28866 Image: Modifying alt attribute of an image (T58400)
28867 !! options
28868 parsoid={
28869 "modes": ["wt2wt"],
28870 "changes": [
28871 ["img[alt]", "attr", "alt", "some alternate edited text"]
28872 ]
28873 }
28874 !! wikitext
28875 [[File:Foobar.jpg|thumb|some caption|alt=some alternate text]]
28876 !! wikitext/edited
28877 [[File:Foobar.jpg|thumb|some caption|alt=some alternate edited text]]
28878 !!end
28879
28880 !! test
28881 Image: Modifying caption of an image
28882 !! options
28883 parsoid={
28884 "modes": ["wt2wt"],
28885 "changes": [
28886 ["figcaption", "text", "new caption"]
28887 ]
28888 }
28889 !! wikitext
28890 [[Image:Foobar.jpg|thumb|original caption]]
28891 !! wikitext/edited
28892 [[Image:Foobar.jpg|thumb|new caption]]
28893 !!end
28894
28895 !! test
28896 Image: empty alt attribute (T50924)
28897 !! wikitext
28898 [[File:Foobar.jpg|thumb|alt=|bar]]
28899 !! html/php+tidy
28900 <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>
28901 !! html/parsoid
28902 <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>
28903 !! end
28904
28905 !! test
28906 Image: new attributes should be serialized in wiki's language for RTL languages (T53852)
28907 !! options
28908 parsoid=html2wt
28909 language=ar
28910 disabled
28911 !! html/parsoid
28912 <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>
28913 !! wikitext
28914 [[Imagen:Foobar.jpg|derecha|miniaturadeimagen]]
28915 !! end
28916
28917 !! test
28918 Image: Block level image should have \n before and after
28919 !! wikitext
28920 123
28921 [[File:Foobar.jpg|right|thumb|150x150px]]
28922 456
28923 !! html/parsoid
28924 <p>123</p>
28925 <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>
28926 <p>456</p>
28927 !! end
28928
28929 !! test
28930 Image: New block level image should have \n before and after (existing content)
28931 !! wikitext
28932 123
28933 [[File:Foobar.jpg|right|thumb|150x150px]]
28934 456
28935 !! html/parsoid
28936 <p>123</p>
28937 <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>
28938 <p>456</p>
28939 !! end
28940
28941 !! test
28942 Image: upright option (parsoid)
28943 !! wikitext
28944 [[File:Foobar.jpg|thumb|upright|caption]]
28945 [[File:Foobar.jpg|thumb|upright=0.5|caption]]
28946 [[File:Foobar.jpg|thumb|500x500px|upright=0.5|caption]]
28947 !! html/parsoid
28948 <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>
28949 <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>
28950 <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>
28951 !! end
28952
28953 !! test
28954 Image: upright option is ignored on inline and frame images (parsoid)
28955 !! wikitext
28956 [[File:Foobar.jpg|500x500px|upright=0.5|caption]]
28957 !! html/parsoid
28958 <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>
28959 !! end
28960
28961 !! test
28962 Image: in template parameter with empty parameter
28963 !! wikitext
28964 {{echo|[[File:Foobar.jpg|link=]]}}
28965 !! html/parsoid
28966 <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>
28967 !! end
28968
28969 !! test
28970 Image: from basic HTML (1)
28971 !! options
28972 parsoid=html2wt
28973 !! html/parsoid
28974 <span typeof="mw:Image">
28975 <img src="./File:Foobar.jpg" width=100 height=100 alt="Alt">
28976 </span>
28977 !! wikitext
28978 [[File:Foobar.jpg|link=|alt=Alt|100x100px]]
28979 !! end
28980
28981 !! test
28982 Image: from basic HTML (2)
28983 !! options
28984 parsoid=html2wt
28985 !! html/parsoid
28986 <img src="./File:Foobar.jpg" width=100 height=100 alt="Alt">
28987 !! wikitext
28988 [[File:Foobar.jpg|link=|alt=Alt|100x100px]]
28989 !! end
28990
28991 !! test
28992 Image: from basic HTML (3)
28993 !! options
28994 parsoid=html2wt
28995 !! html/parsoid
28996 <a href="Main"><img src="./File:Foobar.jpg" width=100 height=100 alt="Alt"></a>
28997 !! wikitext
28998 [[File:Foobar.jpg|link=Main|alt=Alt|100x100px]]
28999 !! end
29000
29001 !! test
29002 Image: from basic HTML (4)
29003 !! options
29004 parsoid=html2wt
29005 !! html/parsoid
29006 <img src="./File:Foobar.jpg">
29007 !! wikitext
29008 [[File:Foobar.jpg|link=]]
29009 !! end
29010
29011 !! test
29012 Image: Invalid title as link
29013 !! wikitext
29014 [[File:Foobar.jpg|link=<]]
29015 !! html/php
29016 <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>
29017 </p>
29018 !! html/parsoid
29019 <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>
29020 !! end
29021
29022 !! test
29023 Various link types in alt and link options
29024 !! wikitext
29025 [[File:Foobar.jpg|link=[[Main Page]]|alt=[[Main Page]]|caption]]
29026
29027 [[File:Foobar.jpg|link=[[Media:Thumb.png]]|alt=[[Media:Thumb.png]]|caption]]
29028
29029 [[File:Foobar.jpg|link=[[wikipedia:Foo]]|alt=[[wikipedia:Foo]]|caption]]
29030 !! html/php+tidy
29031 <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>
29032 </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>
29033 </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>
29034 </p>
29035 !! html/parsoid
29036 <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>
29037
29038 <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>
29039
29040 <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>
29041 !! end
29042
29043 !! test
29044 Lists: Serialize correctly even when list content is wrapped in p-tags (like VE does)
29045 !! options
29046 parsoid=html2wt
29047 !! html/parsoid
29048 <ul>
29049 <li><p>foo</p></li>
29050 </ul>
29051 !! wikitext
29052 * foo
29053 !! end
29054
29055 !! test
29056 Lists: Serialize correctly even when list tags has unneeded whitespace between tags
29057 !! options
29058 parsoid=html2wt
29059 !! html/parsoid
29060 <ul> <li>foo</li></ul>
29061 !! wikitext
29062 * foo
29063 !! end
29064
29065 !! test
29066 Don't strip leading whitespace when handling indent-pre suppressing tags
29067 !! options
29068 parsoid=html2wt
29069 !! html/parsoid
29070 <table>
29071 <tr><td> indented row</td></tr>
29072 </table>
29073 <blockquote><p>
29074 <b>This is very bold of you!</b>
29075 </p>
29076 <table><tr><td>
29077 indented cell (no pre-wrapping!)
29078 </td></tr></table>
29079 </blockquote>
29080 <p>foo</p>
29081 <div>bar</div>
29082 !! wikitext
29083 {|
29084 | indented row
29085 |}
29086 <blockquote>
29087 '''This is very bold of you!'''
29088
29089 {|
29090 |
29091 indented cell (no pre-wrapping!)
29092 |}
29093 </blockquote>
29094 foo
29095 <div>bar</div>
29096 !! end
29097
29098 !! test
29099 Nowiki-wrap leading whitespace when handling indent-pre inducing tags
29100 !! options
29101 parsoid=html2wt
29102 !! html/parsoid
29103 <p>foo</p>
29104 <span>bar</span>
29105
29106 <span>foo2
29107 </span>bar2
29108
29109 <div>foo</div>
29110 <span>bar</span>
29111
29112 <div>
29113 <span>foo</span>
29114 </div>
29115 !! wikitext
29116 foo
29117
29118 <span>bar</span>
29119
29120 <span>foo2
29121 <nowiki> </nowiki></span>bar2
29122
29123 <div>foo</div>
29124 <nowiki> </nowiki><span>bar</span>
29125
29126 <div>
29127 <nowiki> </nowiki><span>foo</span>
29128 </div>
29129 !! end
29130
29131 !! test
29132 Lists: Dont insert newlines in a serialized list item.
29133 !! options
29134 parsoid=html2wt
29135 !! html/parsoid
29136 <ul><li>a<br>b</li><li>c</li></ul>
29137 !! wikitext
29138 * a<br />b
29139 * c
29140 !! end
29141
29142 !! test
29143 1. Headings: Force sol-transparent links and behavior switches to serialize before/after
29144 !! options
29145 parsoid={
29146 "modes": ["html2wt"],
29147 "scrubWikitext": false
29148 }
29149 !! html/parsoid
29150 <h2>hello there<link href="./Category:A1" rel="mw:PageProp/Category" /></h2>
29151 <h2><link href="./Category:A2" rel="mw:PageProp/Category" />hi pal</h2>
29152
29153 <h2><!--foo--> <link href="./Category:A3" rel="mw:PageProp/Category" /> how goes it</h2>
29154 <h2>it goes well <link href="./Category:A4" rel="mw:PageProp/Category" /> <!--bar--></h2>
29155
29156 <h2 data-parsoid='{}'>howdy<link href="./Category:A5" rel="mw:PageProp/Category" /></h2>
29157
29158 <h2><meta property="mw:PageProp/toc" /> ok</h2>
29159 !! wikitext
29160 == hello there [[Category:A1]] ==
29161
29162 == [[Category:A2]] hi pal ==
29163
29164 == <!--foo--> [[Category:A3]] how goes it ==
29165
29166 == it goes well [[Category:A4]] <!--bar--> ==
29167
29168 ==howdy [[Category:A5]]==
29169
29170 == __TOC__ ok ==
29171 !! end
29172
29173 !! test
29174 2. Headings: Force sol-transparent links and behavior switches to serialize before/after
29175 !! options
29176 parsoid={
29177 "modes": ["html2wt"],
29178 "scrubWikitext": true
29179 }
29180 !! html/parsoid
29181 <h2>hello there<link href="./Category:A1" rel="mw:PageProp/Category" /></h2>
29182 <h2><link href="./Category:A2" rel="mw:PageProp/Category" />hi pal</h2>
29183
29184 <h2><!--foo--> <link href="./Category:A3" rel="mw:PageProp/Category" /> how goes it</h2>
29185 <h2>it goes well <link href="./Category:A4" rel="mw:PageProp/Category" /> <!--bar--></h2>
29186
29187 <h2><meta property="mw:PageProp/toc" /> ok</h2>
29188 !! wikitext
29189 == hello there ==
29190 [[Category:A1]]
29191 [[Category:A2]]
29192
29193 == hi pal ==
29194
29195 <!--foo-->[[Category:A3]]
29196
29197 == how goes it ==
29198
29199 == it goes well ==
29200 [[Category:A4]] <!--bar-->
29201
29202 __TOC__
29203
29204 == ok ==
29205 !! end
29206
29207 !! test
29208 Headings: Don't hoist metas that come from templates
29209 !! options
29210 parsoid={
29211 "modes": ["html2wt"],
29212 "scrubWikitext": true
29213 }
29214 !! html/parsoid
29215 <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>
29216 !! wikitext
29217 == {{echo|foo [[Category:Foo]]}} ==
29218 !! end
29219
29220 !! test
29221 Headings: Category in ref isn't hoisted
29222 !! options
29223 parsoid={
29224 "modes": ["html2wt"],
29225 "scrubWikitext": true
29226 }
29227 !! html/parsoid
29228 <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>
29229
29230 <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>
29231 !! wikitext
29232 == foo <ref>bar
29233 [[Category:Baz]] </ref> ==
29234
29235 <references />
29236 !! end
29237
29238 !! test
29239 Parsoid: Serialize positional parameters with = in them as named parameter
29240 !! options
29241 parsoid=html2wt
29242 !! html/parsoid
29243 <p about="#mwt1" typeof="mw:Transclusion"
29244 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"f=oo"}},"i":0}}]}'>foo</p>
29245
29246 <p about="#mwt1" typeof="mw:Transclusion"
29247 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"f=oo"}, "2":{"wt":"bar"}},"i":0}}]}'>foo</p>
29248
29249 <!--Orig params with data-parsoid has heuristics for handling = chars-->
29250 <!--FIXME: But maybe the heuristic needs fixing to apply to new params as well-->
29251 <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>
29252 !! wikitext
29253 {{echo|1=f=oo}}
29254
29255 {{echo|1=f=oo|2=bar}}
29256
29257 <!--Orig params with data-parsoid has heuristics for handling = chars-->
29258 <!--FIXME: But maybe the heuristic needs fixing to apply to new params as well-->
29259 {{echo|<nowiki>f=oo</nowiki>|bar}}
29260 !! end
29261
29262 !! test
29263 Parsoid: Serialize positional parameters with = in extlink as named parameter
29264 !! options
29265 parsoid=html2wt
29266 !! html/parsoid
29267 <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>
29268 !! wikitext
29269 {{echo|1=http://stuff?is=ok}}
29270 !! end
29271
29272 !! test
29273 Parsoid: Correctly serialize block-node children when they are a combination of text and p-nodes
29274 !! options
29275 parsoid=html2wt
29276 !! html/parsoid
29277 <div>a<p>b</p></div>
29278 <div>a
29279 <p>b</p></div>
29280 <div>
29281 a
29282 <p>b</p></div>
29283 !! wikitext
29284 <div>a
29285 b
29286 </div>
29287 <div>a
29288 b
29289 </div>
29290 <div>
29291 a
29292
29293 b
29294 </div>
29295 !! end
29296
29297 !! test
29298 Substrings resembling wikitext in hrefs should not get nowiki escapes
29299 !! options
29300 parsoid=html2wt
29301 !! html/parsoid
29302 <a rel="mw:WikiLink" href="./Foo''bar''baz">Foo''bar''baz</a>
29303 !! wikitext
29304 [[Foo''bar''baz]]
29305 !! end
29306
29307 !! test
29308 Enforce single-line context in the serializer
29309 !! options
29310 parsoid=html2wt
29311 !! html/parsoid
29312 <h2>testing
29313 123</h2>
29314
29315 <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">
29316 </span><span about="#mwt1">you</span> </h2>
29317
29318 <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>
29319
29320 <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
29321 there</span></li></ol>
29322
29323 <ul><li>asd
29324 sdf</li></ul>
29325
29326 <ul><li>foo
29327 bar
29328 baz</li>
29329 <li>foo <b>bar</b>
29330 baz</li></ul>
29331
29332 <dl><dt>hi
29333 ho </dt><dd data-parsoid='{"stx":"row"}'> hi
29334 ho</dd></dl>
29335
29336 <dl><dd> <table>
29337 <tbody><tr><td> ha
29338 ha
29339 ha</td></tr>
29340 </tbody></table></dd></dl>
29341 !! wikitext
29342 == testing 123 ==
29343
29344 == hi {{bogus|there
29345 you}} ==
29346
29347 == foo <ref>hello
29348 there</ref> ==
29349
29350 <references />
29351
29352 * asd sdf
29353
29354 * foo bar baz
29355 * foo '''bar''' baz
29356
29357 ; hi ho : hi ho
29358
29359 : {|
29360 | ha
29361 ha
29362 ha
29363 |}
29364 !! end
29365
29366 !! test
29367 Serialize new placeholder space without spans
29368 !! options
29369 parsoid=html2wt
29370 !! html/parsoid
29371 <p>foo<span typeof="mw:Placeholder"> </span>: bar</p>
29372
29373 <p>foo<span typeof="mw:DisplaySpace mw:Placeholder" data-parsoid='{"src":" ","isDisplayHack":true}'> </span>: bar</p>
29374
29375 <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>
29376 !! wikitext
29377 foo : bar
29378
29379 foo : bar
29380
29381 <ref>foo : bar</ref>ok
29382 !! end
29383
29384
29385 #-----------------------
29386 # Tag minimization tests
29387 #-----------------------
29388
29389 !! test
29390 1. I/B quote minimization: wikitext-only tags should be combined
29391 !! options
29392 parsoid=html2wt
29393 !! html/parsoid
29394 <p><i>A</i><i>B</i></p>
29395 <p><b>A</b><b>B</b></p>
29396 <p><i>A</i><b><i>B</i></b></p>
29397 <p><b>A</b><i><b>B</b></i></p>
29398 <p><b>A</b><i><b>B</b><b>C</b></i><b>D</b></p>
29399 <p><i><b>A</b></i><i><b>B</b></i></p>
29400 <p><i><b>A</b></i><b><i>B</i></b></p>
29401 <p><b><i>A</i></b><i><b>B</b></i></p>
29402 !! wikitext
29403 ''AB''
29404
29405 '''AB'''
29406
29407 ''A'''B'''''
29408
29409 '''A''B'''''
29410
29411 '''A''BC''D'''
29412
29413 '''''AB'''''
29414
29415 '''''AB'''''
29416
29417 '''''AB'''''
29418 !! end
29419
29420 !! test
29421 2. I/B quote minimization: wikitext and html tags should not be combined
29422 !! options
29423 parsoid=html2wt
29424 !! html/parsoid
29425 <p><i>A</i><i data-parsoid='{"stx":"html"}'>B</i></p>
29426 <p><i>A</i><b><i data-parsoid='{"stx":"html"}'>B</i></b></p>
29427 !! wikitext
29428 ''A''<i>B</i>
29429
29430 ''A''<nowiki/>'''<i>B</i>'''
29431 !! end
29432
29433 !! test
29434 3. I/B quote minimization: templated content stops minimization
29435 !! options
29436 parsoid=html2wt
29437 !! html/parsoid
29438 <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>
29439 <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>
29440 !! wikitext
29441 ''A''{{echo|''B''}}
29442
29443 ''A''{{echo|'''''B'''''}}
29444 !! end
29445
29446 !! test
29447 4. I/B quote minimization: new content should be mimimized with adjacent old content
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 !! wikitext
29455 ''AB''
29456
29457 '''AB'''
29458
29459 ''A'''B'''''
29460 !! end
29461
29462 !! test
29463 5a. Merge adjacent quote nodes if they've been edited
29464 !! options
29465 parsoid={
29466 "modes": ["wt2wt", "selser"],
29467 "changes": [
29468 ["p", "contents", "remove", ":contains('b')"]
29469 ]
29470 }
29471 !! wikitext
29472 ''a''b''c''
29473 !! wikitext/edited
29474 ''ac''
29475 !! end
29476
29477 !! test
29478 5b. Merge adjacent quote nodes if they've been edited
29479 !! options
29480 parsoid={
29481 "modes": ["wt2wt", "selser"],
29482 "changes": [
29483 ["#x", "remove"]
29484 ]
29485 }
29486 !! wikitext
29487 ''a''<span id="x">b</span>''c''
29488 !! wikitext/edited
29489 ''ac''
29490 !! end
29491
29492 !! test
29493 1. Merge adjacent link nodes as long as at least one element is new
29494 !! options
29495 parsoid={
29496 "modes": ["html2wt"],
29497 "scrubWikitext": true
29498 }
29499 !! html/parsoid
29500 <a rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
29501 <a data-parsoid="{}" rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
29502 <a data-parsoid="{}" rel="mw:WikiLink" href="./Football">Foot</a><a data-parsoid="{}" rel="mw:WikiLink" href="./Football">ball</a>
29503 !! wikitext
29504 [[Football]]
29505 [[Football]]
29506 [[Football|Foot]][[Football|ball]]
29507 !! end
29508
29509 !! test
29510 2. Merge adjacent link nodes and enable additional normalizations
29511 !! options
29512 parsoid={
29513 "modes": ["html2wt"],
29514 "scrubWikitext": true
29515 }
29516 !! html/parsoid
29517 <a rel="mw:WikiLink" href="./Football"><i>Foot</i></a><a rel="mw:WikiLink" href="./Football"><i>ball</i></a>
29518 !! wikitext
29519 ''[[Football]]''
29520 !! end
29521
29522 !! test
29523 3. Don't merge adjacent link nodes if scrubWikitext is false
29524 !! options
29525 parsoid={
29526 "modes": ["html2wt"],
29527 "scrubWikitext": false
29528 }
29529 !! html/parsoid
29530 <a rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
29531 !! wikitext
29532 [[Football|Foot]][[Football|ball]]
29533 !! end
29534
29535 !! test
29536 1. Move format tags outside of WikiLink
29537 !! options
29538 parsoid={
29539 "modes": ["html2wt"],
29540 "scrubWikitext": true
29541 }
29542 !! html/parsoid
29543 <a rel="mw:WikiLink" href="./Football"><i>Football</i></a>
29544 <a rel="mw:WikiLink" href="./Football"><i><b>Football</b></i></a>
29545 <a rel="mw:WikiLink" href="./Football"><u><i><b>Football</b></i></u></a>
29546 !! wikitext
29547 ''[[Football]]''
29548 '''''[[Football]]'''''
29549 <u>'''''[[Football]]'''''</u>
29550 !! end
29551
29552 !! test
29553 2. Move format tags outside of WikiLink with mergable A tags
29554 !! options
29555 parsoid={
29556 "modes": ["html2wt"],
29557 "scrubWikitext": true
29558 }
29559 !! html/parsoid
29560 <a rel="mw:WikiLink" href="./Football"><i><b>Foot</b></i></a><a rel="mw:WikiLink" href="./Football"><i><b>ball</b></i></a>
29561 !! wikitext
29562 '''''[[Football]]'''''
29563 !! end
29564
29565 !! test
29566 3. Move format tags outside of WikiLink while preserving formats already outside WikiLink
29567 !! options
29568 parsoid={
29569 "modes": ["html2wt"],
29570 "scrubWikitext": true
29571 }
29572 !! html/parsoid
29573 <font color="red"><a rel="mw:WikiLink" href="./Foo" title="Foo" class="mw-redirect"><u><b>Foo</b></u></a></font>
29574 !! wikitext
29575 <font color="red"><u>'''[[Foo]]'''</u></font>
29576 !! end
29577
29578 !! test
29579 4. Do not move format tags outside of WikiLink which includes attributes color, style and class
29580 !! options
29581 parsoid={
29582 "modes": ["html2wt"],
29583 "scrubWikitext": true
29584 }
29585 !! html/parsoid
29586 <a rel="mw:WikiLink" href="./Foo" title="Foo" class="mw-redirect"><font color="red">Foo</font></a>
29587 <a rel="mw:WikiLink" href="./Foo" title="Foo" class="mw-redirect"><span style="color: blue; font-size: 46px;">Foo></span></a>
29588 <a rel="mw:WikiLink" href="./Foo" title="Foo" class="mw-redirect"><span class="Bar">Foo</span></a>
29589 !! wikitext
29590 [[Foo|<font color="red">Foo</font>]]
29591 [[Foo|<span style="color: blue; font-size: 46px;">Foo></span>]]
29592 [[Foo|<span class="Bar">Foo</span>]]
29593 !! end
29594
29595 !! test
29596 5. T194083 Regression test: Manual edit test that also enables scrubWikitext to move format tags outside wikilinks
29597 !! options
29598 parsoid={
29599 "modes": ["selser"],
29600 "scrubWikitext": true,
29601 "changes": [
29602 ["a", "html", "<i>Foo</i>"]
29603 ]
29604 }
29605 !! wikitext
29606 [[Foo]]
29607 !! wikitext/edited
29608 ''[[Foo]]''
29609 !! end
29610
29611 !! test
29612 6. Regression test: Manual edit test to ensure diff markers are not lost
29613 !! options
29614 parsoid={
29615 "modes": ["selser"],
29616 "scrubWikitext": true,
29617 "changes": [
29618 ["i", "wrap", "<a href='./Foo' rel='mw:WikiLink'></a>"]
29619 ]
29620 }
29621 !! wikitext
29622 ''Foo''
29623 !! wikitext/edited
29624 ''[[Foo]]''
29625 !! end
29626
29627 !! test
29628 7. T194083 Regression test: Manual edit test to ensure nested diff markers aren't inserted
29629 !! options
29630 parsoid={
29631 "modes": ["selser"],
29632 "scrubWikitext": true,
29633 "changes": [
29634 ["div", "after", "\n<p><a href='./Foo' rel='mw:WikiLink'>Foo </a>, placeholder</p>"]
29635 ]
29636 }
29637 !! wikitext
29638 <div>placeholder</div>
29639 !! wikitext/edited
29640 <div>placeholder</div>
29641 [[Foo]] , placeholder
29642 !! end
29643
29644 #------------------------------
29645 # End of tag minimization tests
29646 #------------------------------
29647
29648 !!test
29649 T56262: New entities
29650 !! options
29651 parsoid=html2wt
29652 !! html/parsoid
29653 <span typeof="mw:Entity">&nbsp;</span>
29654 !! wikitext
29655 &nbsp;
29656 !! end
29657
29658 ## Note that there is no wikitext output for 'unknownproperty' ##
29659 ## Unknown magic words are silently dropped ##
29660
29661 !! test
29662 Magic words
29663 !! options
29664 parsoid=html2wt
29665 !! html/parsoid
29666 <meta property='mw:PageProp/toc' />
29667 <meta property='mw:PageProp/notoc' />
29668 <meta property='mw:PageProp/forcetoc' />
29669 <meta property='mw:PageProp/index' />
29670 <meta property='mw:PageProp/noindex' />
29671 <meta property='mw:PageProp/nogallery' />
29672 <meta property='mw:PageProp/noeditsection' />
29673 <meta property='mw:PageProp/notitleconvert' />
29674 <meta property='mw:PageProp/nocontentconvert' />
29675 <meta property='mw:PageProp/unknownproperty' />
29676 !! wikitext
29677 __TOC__
29678 __NOTOC__
29679 __FORCETOC__
29680 __INDEX__
29681 __NOINDEX__
29682 __NOGALLERY__
29683 __NOEDITSECTION__
29684 __NOTITLECONVERT__
29685 __NOCONTENTCONVERT__
29686 !! end
29687
29688 !! test
29689 Consecutive <pre>s should not get merged
29690 !! options
29691 parsoid=html2wt,html2html
29692 !! html/parsoid
29693 <pre>a</pre><pre>b</pre>
29694
29695 <pre>c
29696 </pre><pre>
29697 d</pre>
29698
29699 <pre>e
29700
29701 </pre><pre>
29702
29703 f</pre>
29704 !! wikitext
29705 a
29706
29707 b
29708
29709 c
29710
29711 d
29712
29713 e
29714
29715
29716
29717 f
29718 !! end
29719
29720 !! test
29721 Edited ISBN links not serializable as ISBN links should serialize as wikilinks
29722 !! options
29723 parsoid=html2wt
29724 !! html/parsoid
29725 <a href="./Special:BookSources/1234567890" rel="mw:ExtLink">ISBN 1234567895</a>
29726 !! wikitext
29727 [[Special:BookSources/1234567890|ISBN 1234567895]]
29728 !! end
29729
29730 !! test
29731 Edited RFC links not serializable as RFC links should serialize as extlinks
29732 !! options
29733 parsoid=html2wt
29734 !! html/parsoid
29735 <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink">New RFC</a>
29736 !! wikitext
29737 [https://tools.ietf.org/html/rfc123 New RFC]
29738 !! end
29739
29740 !! test
29741 Edited PMID links not serializable as PMID links should serialize as extlinks
29742 !! options
29743 parsoid=html2wt
29744 !! html/parsoid
29745 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink">New PMID</a>
29746 !! wikitext
29747 [//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract New PMID]
29748 !! end
29749
29750 !! test
29751 WTS of autolinks with trailing/surrounding context
29752 !! options
29753 parsoid=html2wt
29754 !! html/parsoid
29755 <p><a href="http://cscott.net">http://cscott.net</a><b>foo</b></p>
29756 <p><a href="http://cscott.net">http://cscott.net</a><b data-parsoid='{"stx":"html"}'>foo</b></p>
29757 <p><b><a href="http://cscott.net">http://cscott.net</a></b></p>
29758 <p><b><a href="http://cscott.net">http://cscott.net</a> </b></p>
29759 <p><b><a href="http://cscott.net">http://cscott.net</a>x</b></p>
29760 <p><a href="http://cscott.net">http://cscott.net</a>x</p>
29761 !! wikitext
29762 http://cscott.net'''foo'''
29763
29764 http://cscott.net<b>foo</b>
29765
29766 '''http://cscott.net'''
29767
29768 '''http://cscott.net '''
29769
29770 '''http://cscott.net<nowiki/>x'''
29771
29772 http://cscott.net<nowiki/>x
29773 !! end
29774
29775 !! test
29776 WTS of autolinks with nowikis (round-trip)
29777 !! wikitext
29778 x<nowiki/>http://cscott.net<nowiki/>x
29779 !! html/parsoid
29780 <p>x<a rel="mw:ExtLink" class="external free" href="http://cscott.net">http://cscott.net</a>x</p>
29781 !! end
29782
29783 # this is the "easy" test because it leaves in place all the
29784 # data-parsoid information indicating this is an autolink
29785 !! test
29786 WTS of autolinks with escapes (editing)
29787 !! options
29788 parsoid={
29789 "modes": ["wt2wt"],
29790 "changes": [
29791 [ "span", "remove" ]
29792 ]
29793 }
29794 !! wikitext
29795 x<nowiki/>http://cscott.net<nowiki/>x
29796 !! wikitext/edited
29797 x<nowiki/>http://cscott.net<nowiki/>x
29798 !! end
29799
29800 !! test
29801 WTS of edited autolink-like text (T103364)
29802 !! options
29803 parsoid={
29804 "modes": ["wt2wt"],
29805 "changes": [
29806 [ "span[typeof]", "removeAttr", "typeof" ]
29807 ]
29808 }
29809 !! wikitext
29810 Not a link: <nowiki>http://example.com</nowiki>.
29811 !! wikitext/edited
29812 Not a link: <span><nowiki>http://example.com</nowiki></span>.
29813 !! end
29814
29815 !! test
29816 WTS of newly-authored autolink-like text (T103364)
29817 !! options
29818 parsoid=html2wt
29819 !! html/parsoid
29820 <p>http://example.com is not a link.</p>
29821 !! wikitext
29822 <nowiki>http://example.com</nowiki> is not a link.
29823 !! end
29824
29825 !! test
29826 WTS of autolink-like text after an autolink (T108563)
29827 !! options
29828 parsoid=html2wt
29829 !! html/parsoid
29830 <p><a rel="mw:ExtLink" href="http://example.com">http://example.com</a> http://example.com is not a link.</p>
29831 !! wikitext
29832 http://example.com <nowiki>http://example.com</nowiki> is not a link.
29833 !! end
29834
29835 !! test
29836 Magic links inside links (not autolinked)
29837 !! wikitext
29838 [[Foo|http://example.com]]
29839 [[Foo|RFC 1234]]
29840 [[Foo|PMID 1234]]
29841 [[Foo|ISBN 123456789x]]
29842
29843 [http://foo.com http://example.com]
29844 [http://foo.com RFC 1234]
29845 [http://foo.com PMID 1234]
29846 [http://foo.com ISBN 123456789x]
29847 !! html+tidy
29848 <p><a href="/wiki/Foo" title="Foo">http://example.com</a>
29849 <a href="/wiki/Foo" title="Foo">RFC 1234</a>
29850 <a href="/wiki/Foo" title="Foo">PMID 1234</a>
29851 <a href="/wiki/Foo" title="Foo">ISBN 123456789x</a>
29852 </p><p><a rel="nofollow" class="external text" href="http://foo.com">http://example.com</a>
29853 <a rel="nofollow" class="external text" href="http://foo.com">RFC 1234</a>
29854 <a rel="nofollow" class="external text" href="http://foo.com">PMID 1234</a>
29855 <a rel="nofollow" class="external text" href="http://foo.com">ISBN 123456789x</a>
29856 </p>
29857 !! html/parsoid
29858 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">http://example.com</a>
29859 <a rel="mw:WikiLink" href="./Foo" title="Foo">RFC 1234</a>
29860 <a rel="mw:WikiLink" href="./Foo" title="Foo">PMID 1234</a>
29861 <a rel="mw:WikiLink" href="./Foo" title="Foo">ISBN 123456789x</a></p>
29862
29863 <p><a rel="mw:ExtLink" class="external text" href="http://foo.com">http://example.com</a>
29864 <a rel="mw:ExtLink" class="external text" href="http://foo.com">RFC 1234</a>
29865 <a rel="mw:ExtLink" class="external text" href="http://foo.com">PMID 1234</a>
29866 <a rel="mw:ExtLink" class="external text" href="http://foo.com">ISBN 123456789x</a></p>
29867 !! end
29868
29869 !! test
29870 Magic links inside image captions (autolinked)
29871 !! wikitext
29872 [[File:Foobar.jpg|thumb|http://example.com]]
29873 [[File:Foobar.jpg|thumb|RFC 1234]]
29874 [[File:Foobar.jpg|thumb|PMID 1234]]
29875 [[File:Foobar.jpg|thumb|ISBN 123456789x]]
29876 !! html+tidy
29877 <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>
29878 <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>
29879 <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>
29880 <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>
29881 !! html/parsoid
29882 <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>
29883 <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>
29884 <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>
29885 <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>
29886 !! end
29887
29888 !! test
29889 WTS of magic word text (T109371)
29890 !! options
29891 parsoid=html2wt
29892 !! html/parsoid
29893 <p>RFC 1234</p>
29894 <p><a href="http://foo.com" rel="mw:ExtLink">RFC 1234</a></p>
29895 <p><a href="./Foo" rel="mw:WikiLink">RFC 1234</a></p>
29896 !! wikitext
29897 <nowiki>RFC 1234</nowiki>
29898
29899 [http://foo.com RFC 1234]
29900
29901 [[Foo|RFC 1234]]
29902 !! end
29903
29904 !! test
29905 Edited Redirect link should emit a non-piped wikitext link
29906 !! options
29907 parsoid=html2wt
29908 !! html/parsoid
29909 <link rel="mw:PageProp/redirect" href="Bar" data-parsoid='{"a":{"href":"./Foo"},"sa":{"href":"Foo"}}'>
29910 !! wikitext
29911 #REDIRECT [[Bar]]
29912 !! end
29913
29914 !! test
29915 T75121: Infer extension name from typeOf if data-mw is not present
29916 !! options
29917 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
29918 !! html/parsoid
29919 <div typeOf="mw:Extension/foo"></div>
29920 !! wikitext
29921 <foo />
29922 !! end
29923
29924 # Note that the <p> wrapping isn't present in PHP parser output
29925 # The important thing for this test is that P-wrapping doesn't
29926 # interfere with the <nowiki> protection for leading - in <td>
29927 # (which isn't necessary for <th>).
29928 !! test
29929 T88318: p-wrapped dash in table.
29930 !! options
29931 parsoid=html2wt,wt2wt
29932 !! html/parsoid
29933 <table><tbody>
29934 <tr><th><p>-</p></th><th><p>- </p></th></tr>
29935 <tr><td><p>-</p></td><td><p>- </p></td></tr>
29936 <tr><td><small>-</small></td><td><br/><p>-</p></td><td><br/>-</td></tr>
29937 </tbody></table>
29938 !! wikitext
29939 {|
29940 !-
29941 !-
29942 |-
29943 |<nowiki>-</nowiki>
29944 |<nowiki>- </nowiki>
29945 |-
29946 |<small>-</small>
29947 |<br />
29948 -
29949 |<br />-
29950 |}
29951 !! html/php+tidy
29952 <table>
29953 <tbody><tr>
29954 <th>-
29955 </th>
29956 <th>-
29957 </th></tr>
29958 <tr>
29959 <td>-
29960 </td>
29961 <td>-
29962 </td></tr>
29963 <tr>
29964 <td><small>-</small>
29965 </td>
29966 <td><br />
29967 <p>-
29968 </p>
29969 </td>
29970 <td><br />-
29971 </td></tr></tbody></table>
29972 !! end
29973
29974 !! test
29975 T149209: WTS: Handle newlines in table cells properly
29976 !! options
29977 parsoid=html2wt
29978 !! html/parsoid
29979 <table>
29980 <tbody>
29981 <tr><td>a
29982 b
29983 </td><td data-parsoid='{"stx":"row"}'>c</td></tr>
29984 <tr><td><p>x</p>
29985 </td><td data-parsoid='{"stx":"row", "startTagSrc": "{{!}}{{!}}"}'>y</td></tr>
29986 </tbody></table>
29987 <table>
29988 <tbody>
29989 <tr><th>a
29990 b
29991 </th><th data-parsoid='{"stx":"row"}'>c</th></tr>
29992 <tr><th><p>x</h>
29993 </th><th data-parsoid='{"stx":"row"}'>y</th></tr>
29994 </tbody></table>
29995 !! wikitext
29996 {|
29997 |a
29998 b
29999 |c
30000 |-
30001 |x
30002 {{!}}y
30003 |}
30004 {|
30005 !a
30006 b
30007 !c
30008 |-
30009 !x
30010 !y
30011 |}
30012 !! end
30013
30014 !! test
30015 T149209: Selser: Handle newlines in table cells properly
30016 !! options
30017 parsoid={
30018 "modes": ["selser"],
30019 "changes": [
30020 [ "#h1", "html", "a\nb\n" ],
30021 [ "#h2", "html", "a\nb\n" ],
30022 [ "#c1", "html", "a\nb\n" ],
30023 [ "#c2", "html", "<p>a</p>" ],
30024 [ "#c3", "html", "<p>a</p>" ],
30025 [ "#c4", "html", "edit-me<p>a</p>" ]
30026 ]
30027 }
30028 !! wikitext
30029 {|
30030 ! id="h1" |edit-me!!1
30031 |-
30032 ! id="h2" |edit-me||2
30033 |-
30034 | id="c1" |edit-me||3
30035 |-
30036 | id="c2" |edit-me||4
30037 |-
30038 | id="c3" |edit-me||p||q||r
30039 |-
30040 | id="c4" |edit-me||p||q||r
30041 |}
30042 !! wikitext/edited
30043 {|
30044 ! id="h1" |a
30045 b
30046 !1
30047 |-
30048 ! id="h2" |a
30049 b
30050 !2
30051 |-
30052 | id="c1" |a
30053 b
30054 |3
30055 |-
30056 | id="c2" |a
30057 |4
30058 |-
30059 | id="c3" |a
30060 |p||q||r
30061 |-
30062 | id="c4" |edit-me
30063 a
30064 |p||q||r
30065 |}
30066 !! end
30067
30068 !! test
30069 HTML id attribute with Parsoid-like element ids should not be serialized to wikitext
30070 !! options
30071 parsoid=html2wt
30072 !! html/parsoid
30073 <table id='mwAb'>
30074 <td id='mwAc'>foo</td>
30075 <td id='serialize-this'>bar</td>
30076 </table>
30077 !! wikitext
30078 {|
30079 |foo
30080 | id="serialize-this" |bar
30081 |}
30082 !! end
30083
30084 !! test
30085 Parsoid-like element ids should not be serialized to wikitext unless shadowed
30086 !! options
30087 parsoid=html2wt
30088 !! html/parsoid
30089 <div id="mwAQ" data-parsoid='{"stx":"html","a":{"id":"mwAQ"},"sa":{"id":"hello"}}'>ok</div>
30090 !! wikitext
30091 <div id="hello">ok</div>
30092 !! end
30093
30094 !! test
30095 Testing serialization after deletion in references
30096 !! options
30097 parsoid={
30098 "modes": ["wt2wt"],
30099 "changes": [
30100 ["#x", "remove"]
30101 ]
30102 }
30103 !! wikitext
30104 hi <ref><div id="x">ho</div></ref>
30105
30106 <references />
30107 !! wikitext/edited
30108 hi <ref></ref>
30109
30110 <references />
30111 !! end
30112
30113 !!test
30114 Testing serialization after deletion of table cells
30115 !!options
30116 parsoid={
30117 "modes": ["wt2wt", "selser"],
30118 "changes": [
30119 ["#x", "remove"]
30120 ]
30121 }
30122 !!wikitext
30123 {|
30124 !h1 !!h2 !!h3
30125 | id="x" |c1 {{!}}{{!}}{{!}}c2 |||c3
30126 |}
30127 !! wikitext/edited
30128 {|
30129 !h1!!h2!!h3
30130 |c2|||c3
30131 |}
30132 !!end
30133
30134 !! test
30135 Testing selser after addition of new row before first row (T125419)
30136 !! options
30137 parsoid={
30138 "modes": ["wt2wt", "selser"],
30139 "changes": [
30140 [ "tr", "before", "<tr><td>X</td></tr>" ]
30141 ]
30142 }
30143 !! wikitext
30144 {|
30145 |a
30146 |}
30147 !! wikitext/edited
30148 {|
30149 |X
30150 |-
30151 |a
30152 |}
30153 !! end
30154
30155 !! test
30156 Serialize new table rows in a HTML table using HTML tags
30157 !! options
30158 parsoid={
30159 "modes": ["wt2wt", "selser"],
30160 "changes": [
30161 [ "tr", "before", "<tr><td>X</td></tr>" ]
30162 ]
30163 }
30164 !! wikitext
30165 <table><tr><td>a</td></tr></table>
30166 !! wikitext/edited
30167 <table><tr><td>X</td></tr><tr><td>a</td></tr></table>
30168 !! end
30169
30170 !! test
30171 Serialize new table cells in a HTML row using HTML tags
30172 !! options
30173 parsoid={
30174 "modes": ["wt2wt", "selser"],
30175 "changes": [
30176 [ "td", "before", "<td>X</td>" ]
30177 ]
30178 }
30179 !! wikitext
30180 <table><tr><td>a</td></tr></table>
30181 !! wikitext/edited
30182 <table><tr><td>X</td><td>a</td></tr></table>
30183 !! end
30184
30185 !! test
30186 Serialize wikitext list items as HTML list items when embedded in a HTML list
30187 !! options
30188 parsoid=html2wt
30189 !! html/parsoid
30190 <ul data-parsoid='{"stx": "html"}'>
30191 <li data-parsoid='{}'>a</li>
30192 <li>b</li>
30193 </ul>
30194 !! wikitext
30195 <ul>
30196 <li>a</li>
30197 <li>b</li>
30198 </ul>
30199 !! html/php+tidy
30200 <ul>
30201 <li>a</li>
30202 <li>b</li>
30203 </ul>
30204 !! end
30205
30206 # Nested list should be inside <li>, that is
30207 # <ul><li>foo<ul>..</ul></li></ul> instead of
30208 # <ul><li>foo</li><ul>..</ul></ul>
30209 # See https://stackoverflow.com/questions/5899337/proper-way-to-make-html-nested-list
30210 !! test
30211 Wikitext lists can be nested inside HTML lists
30212 !! options
30213 parsoid=html2wt
30214 !! html/parsoid
30215 <ul data-parsoid='{"stx": "html"}'>
30216 <li data-parsoid='{"stx": "html"}'>a
30217 <ul><li>b</li></ul>
30218 </li>
30219 </ul>
30220
30221 <ul data-parsoid='{"stx": "html"}'>
30222 <li>x
30223 <ul><li>y</li></ul>
30224 </li>
30225 </ul>
30226 !! wikitext
30227 <ul>
30228 <li>a
30229 * b
30230 </li>
30231 </ul>
30232
30233 <ul>
30234 <li>x
30235 * y
30236 </li>
30237 </ul>
30238 !! html/php+tidy
30239 <ul>
30240 <li>a
30241 <ul><li>b</li></ul>
30242 </li>
30243 </ul>
30244 <ul>
30245 <li>x
30246 <ul><li>y</li></ul>
30247 </li>
30248 </ul>
30249 !! end
30250
30251 !! test
30252 WTS change modes
30253 !! options
30254 parsoid={
30255 "modes": ["wt2wt"],
30256 "changes": [
30257 [ "#xyz", "before", "<b>before</b> stuff " ],
30258 [ "#xyz", "after", " stuff <i>after</i>" ],
30259 [ "#xyz", "html", "x <b>y</b> z" ]
30260 ]
30261 }
30262 !! wikitext
30263 <span id="xyz">hello</span>
30264 !! wikitext/edited
30265 '''before''' stuff <span id="xyz">x '''y''' z</span> stuff ''after''
30266 !! end
30267
30268 !! test
30269 Never serialize a-tag as html, regardless of what data-parsoid has to say
30270 !! options
30271 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
30272 !! html/parsoid
30273 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"html"}'>Foo</a>
30274 !! wikitext
30275 [[Foo]]
30276 !! end
30277
30278 ## SSS FIXME: This is broken output nevertheless.
30279 ## What might be a reasonable non-broken output for this?
30280 ## This is an edge case unlikely to be seen in production
30281 ## that I am not wasting more time on this right now.
30282 !! test
30283 Never serialize a-tag as html, no matter what attributes it has
30284 !! options
30285 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
30286 !! html/parsoid
30287 <a bad='true' href='http://boo.org'><img src='http://boohoo.org' /></a>
30288 !! wikitext
30289 [http://boo.org http://boohoo.org]
30290 !! end
30291
30292 # Misnested is an indication that selser can reuse the source but these have
30293 # shown to sneak through on occasion. See T101768.
30294 # The original wikitext here is: [http://test.com [[one]] two three]
30295 !! test
30296 Strip span tags added to mark misnested links
30297 !! options
30298 parsoid=html2wt
30299 !! html/parsoid
30300 <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>
30301 !! wikitext
30302 [http://test.com][[one]] two three
30303 !! end
30304
30305 !! test
30306 Catch regression when unpacking misnested links
30307 !! options
30308 parsoid=wt2html
30309 !! wikitext
30310 {{echo|hi}}[http://example.com [[ho]]]
30311 !! html/parsoid
30312 <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>
30313 !! end
30314
30315 !! test
30316 Catch regression when unpacking with trailing content
30317 !! wikitext
30318 {{echo|Foo <references/> bar}}
30319 !! html/parsoid
30320 <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>
30321 !! end
30322
30323 !! test
30324 Use data-parsoid.firstWikitextNode to compute newline constraints for template content
30325 !! options
30326 parsoid=html2wt
30327 !! html/parsoid
30328 <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|}"]}'>
30329 <tbody><tr><td>d
30330 </td></tr>
30331 </tbody></table>
30332 !! wikitext
30333 {{echo|a}}
30334 {|{{echo|c
30335 {{!}}d
30336 }}
30337 |}
30338 !! end
30339
30340 ## This test verifies the presence and computation of this attribute indirectly
30341 ## by making an edit and ensuring that the serialization is correct (which it would be
30342 ## only if firstWikitextNode is properly set).
30343 !! test
30344 data-parsoid.firstWikitextNode should be computed properly in the presence of fostered content
30345 !! options
30346 parsoid= {
30347 "modes": ["wt2wt"],
30348 "changes": [
30349 [ "div#x", "remove" ],
30350 [ "div", "before", "<div>new</div>" ]
30351 ]
30352 }
30353 !! wikitext
30354 <div id="x">foo</div>
30355 {|
30356 {{echo|<div>boo</div>
30357 {{!}}b}}
30358 |c
30359 |}
30360 !! wikitext/edited
30361
30362 <div>new</div>
30363 {|
30364 {{echo|<div>boo</div>
30365 {{!}}b}}
30366 |c
30367 |}
30368 !! end
30369
30370 # --------------------------------------------
30371 # Tests spec'ing wikitext serialization norms |
30372 # --------------------------------------------
30373
30374 !! test
30375 Serialize multi-line indent-pre starting with wikitext syntax
30376 !! options
30377 parsoid=html2wt
30378 !! html/parsoid
30379 <pre>* 1
30380 ** 2
30381 * 3</pre>
30382 !! wikitext
30383 * 1
30384 ** 2
30385 * 3
30386 !! end
30387
30388 !! test
30389 1. Categories should always be serialized on their own line
30390 !! options
30391 parsoid=html2wt
30392 !! html/parsoid
30393 foo<link rel="mw:PageProp/Category" href="./Category:Foo">bar
30394 !! wikitext
30395 foo
30396 [[Category:Foo]]
30397 bar
30398 !! end
30399
30400 !! test
30401 2. Categories that are part of templates should not introduce a line break
30402 !! wikitext
30403 foo {{echo|<span>bar</span> [[Category:baz]]}} bar
30404 !! html/parsoid
30405 <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>
30406 !! end
30407
30408 # Careful while editing these next 2 tests. There are \u200f characters
30409 # before and after the <link> tags in the HTML and following some
30410 # of the categories in wikitext
30411 # Do not remove these characters in edits.
30412 #
30413 # As part of the serialization, these bidi characters will get stripped.
30414 !! test
30415 RTL (\u200f) and LTR (\u200e) markers around category tags should be stripped
30416 !! options
30417 parsoid={
30418 "modes": ["html2wt"],
30419 "scrubWikitext": true
30420 }
30421 !! html/parsoid
30422 <p>‏<link rel="mw:PageProp/Category" href="./קטגוריה:טקסים" />‏
30423 ‏<link rel="mw:PageProp/Category" href="./קטגוריה:_שיטות_משפט" />‏</p>
30424 !! wikitext
30425 [[קטגוריה:טקסים]]
30426 [[קטגוריה: שיטות משפט]]
30427 !! end
30428
30429 !! test
30430 RTL (\u200f) and LTR (\u200e) markers should not be stripped if followed by a text node
30431 !! options
30432 parsoid={
30433 "modes": ["html2wt"],
30434 "scrubWikitext": true
30435 }
30436 !! html/parsoid
30437 <p>‏<link rel="mw:PageProp/Category" href="./קטגוריה:טקסים" />‏y</p>
30438 !! wikitext
30439 [[קטגוריה:טקסים]]
30440 ‏y
30441 !! end
30442
30443 !! test
30444 Lists: Add space after bullets
30445 !! options
30446 parsoid=html2wt
30447 !! html/parsoid
30448 <ul>
30449 <li>foo</li>
30450 <li> bar</li>
30451 <li><span> baz</span></li>
30452 </ul>
30453 !! wikitext
30454 * foo
30455 * bar
30456 * <span> baz</span>
30457 !! end
30458
30459 !! test
30460 1. Headings: Add space before/after == (T53744)
30461 !! options
30462 parsoid=html2wt
30463 !! html/parsoid
30464 <h2>foo</h2>
30465 <h2> bar</h2>
30466 <h2>baz </h2>
30467 <h2><span> baz</span></h2>
30468 !! wikitext
30469 == foo ==
30470
30471 == bar ==
30472
30473 == baz ==
30474
30475 == <span> baz</span> ==
30476 !! end
30477
30478 !! test
30479 2. Headings: Add space before/after == even after hoisted content
30480 !! options
30481 parsoid={
30482 "modes": ["html2wt"],
30483 "scrubWikitext": true
30484 }
30485 !! html/parsoid
30486 <h2> <link href="./Category:A2" rel="mw:PageProp/Category" />ok</h2>
30487 !! wikitext
30488 [[Category:A2]]
30489
30490 == ok ==
30491 !! end
30492
30493 !! test
30494 1. Headings: suppress newly created empty headings
30495 !! options
30496 parsoid={
30497 "modes": ["html2wt"],
30498 "scrubWikitext": true
30499 }
30500 !! html/parsoid
30501 <h2></h2>
30502 !! wikitext
30503 !! end
30504
30505 !! test
30506 2. Headings: don't suppress empty headings if scrubWikitext is false
30507 !! options
30508 parsoid=html2wt
30509 !! html/parsoid
30510 <h2></h2>
30511 !! wikitext
30512 ==<nowiki/>==
30513 !! end
30514
30515 !! test
30516 3. Headings: suppress empty headings on edits
30517 !! options
30518 parsoid={
30519 "modes": ["selser"],
30520 "scrubWikitext": true,
30521 "changes": [
30522 [ "#x", "remove"]
30523 ]
30524 }
30525 !! wikitext
30526 ==<span id="x">foo</span>==
30527 !! wikitext/edited
30528 !! end
30529
30530 !! test
30531 Headings: Replace <br/> with a single whitespace char (when scrubWikitext = true)
30532 !! options
30533 parsoid={
30534 "modes": ["html2wt"],
30535 "scrubWikitext": true
30536 }
30537 !! html/parsoid
30538 <h2>foo<br/>bar</h2>
30539 <h2>foo <span><br/>bar</span> baz</h2>
30540 !! wikitext
30541 == foo bar ==
30542
30543 == foo <span> bar</span> baz ==
30544 !! end
30545
30546 !! test
30547 Headings: Replace <br/> with a single whitespace char (when scrubWikitext = false)
30548 !! options
30549 parsoid={
30550 "modes": ["html2wt"],
30551 "scrubWikitext": false
30552 }
30553 !! html/parsoid
30554 <h2>foo<br/>bar</h2>
30555 !! wikitext
30556 == foo<br />bar ==
30557 !! end
30558
30559 !! test
30560 1. WT Quote Tags: suppress newly created empty style tags
30561 !! options
30562 parsoid={
30563 "modes": ["html2wt"],
30564 "scrubWikitext": true
30565 }
30566 !! html/parsoid
30567 <i></i><b></b>
30568 !! wikitext
30569 !! end
30570
30571 !! test
30572 2. WT Quote Tags: don't suppress empty style tags if scrubWikitext is false
30573 !! options
30574 parsoid=html2wt
30575 !! html/parsoid
30576 <i></i><b></b>
30577 !! wikitext
30578 ''<nowiki/>'''''<nowiki/>'''
30579 !! end
30580
30581 !! test
30582 3. WT Quote Tags: suppress empty style tags on edits
30583 !! options
30584 parsoid={
30585 "modes": ["selser"],
30586 "scrubWikitext": true,
30587 "changes": [
30588 [ "#x", "remove"]
30589 ]
30590 }
30591 !! wikitext
30592 '''<span id="x">foo</span>'''
30593 !! wikitext/edited
30594 !! end
30595
30596 !! test
30597 1. Anchors: suppress newly created empty anchors
30598 !! options
30599 parsoid={
30600 "modes": ["html2wt"],
30601 "scrubWikitext": true
30602 }
30603 !! html/parsoid
30604 <a rel="mw:WikiLink" href="./Test" title="Test"></a>
30605 !! wikitext
30606 !! end
30607
30608 !! test
30609 2. Anchors: don't suppress empty anchors if scrubWikitext is false
30610 !! options
30611 parsoid={
30612 "modes": ["html2wt"],
30613 "scrubWikitext": false
30614 }
30615 !! html/parsoid
30616 <a rel="mw:WikiLink" href="./Test" title="Test"></a>
30617 !! wikitext
30618 [[Test|<nowiki/>]]
30619 !! end
30620
30621 !! test
30622 3. Anchors: suppress empty anchors on edits
30623 !! options
30624 parsoid={
30625 "modes": ["selser"],
30626 "scrubWikitext": true,
30627 "changes": [
30628 [ "#x", "remove"]
30629 ]
30630 }
30631 !! wikitext
30632 [[Test|<span id="x">foo</span>]]
30633 !! wikitext/edited
30634 !! end
30635
30636 !! test
30637 3a. Anchors: do not suppress numbered extlinks
30638 !! options
30639 parsoid={
30640 "modes": ["wt2wt"],
30641 "scrubWikitext": true
30642 }
30643 !! wikitext
30644 [http://foo.com]
30645 !! html/parsoid
30646 <a rel="mw:ExtLink" href="http://foo.com"></a>
30647 !! end
30648
30649 !! test
30650 3b. Anchors: do not suppress numbered extlinks
30651 !! options
30652 parsoid={
30653 "modes": ["wt2wt"],
30654 "scrubWikitext": true,
30655 "changes": [
30656 [ "#x", "remove"]
30657 ]
30658 }
30659 !! wikitext
30660 [http://foo.com <span id="x">foo</span>]
30661 !! wikitext/edited
30662 [http://foo.com]
30663 !! end
30664
30665 !!test
30666 Normalizations should be restricted to edited content
30667 !!options
30668 parsoid={
30669 "modes": ["selser"],
30670 "scrubWikitext": true,
30671 "changes": [
30672 [ "h1", "before", "<i></i>"]
30673 ]
30674 }
30675 !!wikitext
30676 a
30677 = =
30678 b
30679 !!wikitext/edited
30680 a
30681 = =
30682 b
30683 !!end
30684
30685 !! test
30686 1. Multiple normalizations (html2wt)
30687 !! options
30688 parsoid={
30689 "modes": ["html2wt"],
30690 "scrubWikitext": true
30691 }
30692 !! html/parsoid
30693 <h2><i></i></h2>
30694 <p><a href='Foo' rel='mw:WikiLink'>foo<i></i>
30695 </a><b><i></i></b>x</p>
30696 !! wikitext
30697
30698 [[foo]]
30699 x
30700
30701 !! end
30702
30703 !! test
30704 2. Multiple normalizations (selser)
30705 !! options
30706 parsoid={
30707 "modes": ["selser"],
30708 "scrubWikitext": true,
30709 "changes": [
30710 [ "#x", "after", "<h1><i></i></h1>\n<p> bar<b></b></p>"]
30711 ]
30712 }
30713 !! wikitext
30714 <div id="x">foo</div>
30715 !! wikitext/edited
30716 <div id="x">foo</div>
30717 bar
30718 !! end
30719
30720 !! test
30721 1. Indent Pre Nowiki: suppress whitespace at the start of new paragraph
30722 !! options
30723 parsoid={
30724 "modes": ["html2wt"],
30725 "scrubWikitext": true
30726 }
30727 !! html/parsoid
30728 <p> hi</p>
30729 <p> hello</p>
30730 !! wikitext
30731 hi
30732
30733 hello
30734 !! end
30735
30736 !! test
30737 2. Indent Pre Nowiki: don't suppress whitespace at the start of new paragraph if scrubWikitext is false
30738 !! options
30739 parsoid=html2wt
30740 !! html/parsoid
30741 <p> hi</p>
30742 <p> hello</p>
30743 !! wikitext
30744 <nowiki> </nowiki>hi
30745
30746 <nowiki> </nowiki> hello
30747 !! end
30748
30749 !! test
30750 3. Indent Pre Nowiki: suppress whitespace after newlines in new paragraph or table cell
30751 !! options
30752 parsoid={
30753 "modes": ["html2wt"],
30754 "scrubWikitext": true
30755 }
30756 !! html/parsoid
30757 <p>Foo
30758 bar
30759 baz</p>
30760
30761 <table><tr><td>Foo
30762 bar
30763 baz bang</td></tr></table>
30764
30765 <p><!--boo--> foo
30766 bar</p>
30767
30768 <p> foo
30769 bar<span>boo</span></p>
30770 !! wikitext
30771 Foo
30772 bar
30773 baz
30774
30775 {|
30776 |Foo
30777 bar
30778 baz bang
30779 |}
30780
30781 <!--boo-->foo
30782 bar
30783
30784 foo
30785 bar<span>boo</span>
30786 !! end
30787
30788 !! test
30789 4. Indent Pre Nowiki: suppress leading whitespace in edited paragraphs
30790 !! options
30791 parsoid={
30792 "modes": ["selser"],
30793 "scrubWikitext": true,
30794 "changes": [
30795 [ "p", "html", " a\n b" ]
30796 ]
30797 }
30798 !! wikitext
30799 xyz
30800 !! wikitext/edited
30801 a
30802 b
30803 !! end
30804
30805 !! test
30806 1. New links that end in spaces
30807 !! options
30808 parsoid={
30809 "modes": ["html2wt"],
30810 "scrubWikitext": false
30811 }
30812 !! html/parsoid
30813 <p><a rel="mw:WikiLink" href="./Berlin" title="Berlin">Berlin </a>is the capital of Germany.</p>
30814 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo </a><b>bar</b></p>
30815 <p><a rel="mw:WikiLink" href="./Boston" title="Boston">Boston </a> is a city.</p>
30816 !! wikitext
30817 [[Berlin ]]<nowiki/>is the capital of Germany.
30818
30819 [[Foo ]]'''bar'''
30820
30821 [[Boston ]] is a city.
30822 !! end
30823
30824 !! test
30825 2. New links that end in spaces
30826 !! options
30827 parsoid={
30828 "modes": ["html2wt"],
30829 "scrubWikitext": true
30830 }
30831 !! html/parsoid
30832 <p><a rel="mw:WikiLink" href="./Berlin" title="Berlin">Berlin </a>is the capital of Germany.</p>
30833 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo </a><b>bar</b></p>
30834 <p><a rel="mw:WikiLink" href="./Boston" title="Boston">Boston </a> is a city.</p>
30835 !! wikitext
30836 [[Berlin]] is the capital of Germany.
30837
30838 [[Foo]] '''bar'''
30839
30840 [[Boston]] is a city.
30841 !! end
30842
30843 !! test
30844 1. Table cells with escapable prefixes
30845 !! options
30846 parsoid={
30847 "modes": ["html2wt"],
30848 "scrubWikitext": false
30849 }
30850 !! html/parsoid
30851 <table>
30852 <tr><td>a</td></tr>
30853 <tr><td>-</td></tr>
30854 <tr><td>+</td></tr>
30855 <tr><td>}</td></tr>
30856 </table>
30857 !! wikitext
30858 {|
30859 |a
30860 |-
30861 |<nowiki>-</nowiki>
30862 |-
30863 |<nowiki>+</nowiki>
30864 |-
30865 |<nowiki>}</nowiki>
30866 |}
30867 !! end
30868
30869 !! test
30870 2. Table cells with escapable prefixes
30871 !! options
30872 parsoid={
30873 "modes": ["html2wt"],
30874 "scrubWikitext": true
30875 }
30876 !! html/parsoid
30877 <table>
30878 <tr><td>a</td></tr>
30879 <tr><td>-</td></tr>
30880 <tr><td>+</td></tr>
30881 <tr><td>}</td></tr>
30882 </table>
30883 !! wikitext
30884 {|
30885 |a
30886 |-
30887 | -
30888 |-
30889 | +
30890 |-
30891 | }
30892 |}
30893 !! end
30894
30895 !! test
30896 3a. Table cells with escapable prefixes after edits
30897 !! options
30898 parsoid={
30899 "modes": ["selser"],
30900 "scrubWikitext": true,
30901 "changes": [
30902 [ "table tbody tr:first-child td:first-child", "remove"]
30903 ]
30904 }
30905 !! wikitext
30906 {|
30907 |a||-
30908 |}
30909 !! wikitext/edited
30910 {|
30911 | -
30912 |}
30913 !! end
30914
30915 !! test
30916 3b. Table cells with escapable prefixes after edits
30917 !! options
30918 parsoid={
30919 "modes": ["selser"],
30920 "scrubWikitext": true,
30921 "changes": [
30922 [ "table tbody tr:first-child td:first-child", "html", "-" ],
30923 [ "#x", "remove" ]
30924 ]
30925 }
30926 !! wikitext
30927 {|
30928 |pqr
30929 |<span id="x">foo</span>+
30930 |}
30931 !! wikitext/edited
30932 {|
30933 | -
30934 | +
30935 |}
30936 !! end
30937
30938 # FIXME: This test will fail because
30939 # normalization doesn't realize that the id attribute
30940 # will eliminate the escapable scenario
30941 !! test
30942 4a. Table cells without escapable prefixes after edits
30943 !! options
30944 parsoid={
30945 "modes": ["selser"],
30946 "scrubWikitext": true,
30947 "changes": [
30948 [ "#x", "html", "-" ]
30949 ]
30950 }
30951 !! wikitext
30952 {|
30953 | id="x" |abcd
30954 |}
30955 !! wikitext/edited
30956 {|
30957 | id="x" |-
30958 |}
30959 !! end
30960
30961 ## This tests normalizer's ability to discriminate between
30962 ## cells having identical content.
30963 !! test
30964 4b. Table cells without escapable prefixes after edits
30965 !! options
30966 parsoid={
30967 "modes": ["selser"],
30968 "scrubWikitext": true,
30969 "changes": [
30970 [ "td", "html", "-" ]
30971 ]
30972 }
30973 !! wikitext
30974 {|
30975 |a||b
30976 |}
30977 !! wikitext/edited
30978 {|
30979 | -||-
30980 |}
30981 !! end
30982
30983 ## This tests normalizer's ability to not be tripped by
30984 ## comments (and whitespace)
30985 !! test
30986 4c. Table cells without escapable prefixes after edits
30987 !! options
30988 parsoid={
30989 "modes": ["selser"],
30990 "scrubWikitext": true,
30991 "changes": [
30992 [ "table tbody tr td:first-child", "remove" ]
30993 ]
30994 }
30995 !! wikitext
30996 {|
30997 |-
30998 <!--foo--> |a||-
30999 |}
31000 !! wikitext/edited
31001 {|
31002 |-
31003 <!--foo--> | -
31004 |}
31005 !! end
31006
31007 ## This tests normalizer's ability to handle HTML cells
31008 !! test
31009 4d. Table cells without escapable prefixes after edits
31010 !! options
31011 parsoid={
31012 "modes": ["selser"],
31013 "scrubWikitext": true,
31014 "changes": [
31015 [ "td", "html", "-" ]
31016 ]
31017 }
31018 !! wikitext
31019 <table>
31020 <tr><td>a</td></tr>
31021 </table>
31022 !! wikitext/edited
31023 <table>
31024 <tr><td>-</td></tr>
31025 </table>
31026 !! end
31027
31028 ## T111151 Remove font elements without attributes
31029 !! test
31030 5a. font tags without attributes should be dropped in scrubWikitext mode
31031 !! options
31032 parsoid={
31033 "modes": ["html2wt"],
31034 "scrubWikitext": true
31035 }
31036 !! html/parsoid
31037 <font>foo</font>
31038 <font><font>bar</font></font>
31039 <font class="x">boo</font>
31040 !! wikitext
31041 foo
31042 bar
31043 <font class="x">boo</font>
31044 !! end
31045
31046 !! test
31047 5b. font tags should not be dropped without scrubWikitext being enabled
31048 !! options
31049 parsoid={
31050 "modes": ["html2wt"],
31051 "scrubWikitext": false
31052 }
31053 !! html/parsoid
31054 <font>foo</font>
31055 !! wikitext
31056 <font>foo</font>
31057 !! end
31058
31059 !! test
31060 Ignore empty <p></p> when scrubWikitext is false
31061 !! options
31062 parsoid={
31063 "modes": ["html2wt"],
31064 "scrubWikitext": false
31065 }
31066 !! html/parsoid
31067 <div>1</div>
31068 <p>a</p><p></p><p>b</p>
31069 <div>2</div>
31070 <p>a</p>
31071 <p></p>
31072 <p>b</p>
31073 <div>3</div>
31074 <p>a</p>
31075 <p></p>
31076 <p></p>
31077 <p></p>
31078 <p></p>
31079 <p>b</p>
31080 !! wikitext
31081 <div>1</div>
31082 a
31083
31084 b
31085 <div>2</div>
31086 a
31087
31088 b
31089 <div>3</div>
31090 a
31091
31092 b
31093 !! html/php+tidy
31094 <div>1</div>
31095 <p>a
31096 </p><p>b
31097 </p>
31098 <div>2</div>
31099 <p>a
31100 </p><p>b
31101 </p>
31102 <div>3</div>
31103 <p>a
31104 </p><p>b
31105 </p>
31106 !! end
31107
31108 !! test
31109 Normalize empty paragraphs to HTML form that html2wt expects
31110 !! options
31111 parsoid={
31112 "modes": ["html2wt"],
31113 "scrubWikitext": true
31114 }
31115 !! html/parsoid
31116 <div>1</div>
31117 <p>a</p><p></p><p>b</p>
31118 <div>2</div>
31119 <p>a</p>
31120 <p></p>
31121 <p>b</p>
31122 <div>3</div>
31123 <p>a</p>
31124 <p></p>
31125 <p></p>
31126 <p></p>
31127 <p></p>
31128 <p>b</p>
31129 <div>4</div>
31130 <p>a</p>
31131 <p></p>
31132 <div>foo</div>
31133 !! wikitext
31134 <div>1</div>
31135 a
31136
31137
31138 b
31139 <div>2</div>
31140 a
31141
31142
31143 b
31144 <div>3</div>
31145 a
31146
31147
31148
31149
31150
31151 b
31152 <div>4</div>
31153 a
31154
31155 <br />
31156 <div>foo</div>
31157 !! html/php+tidy
31158 <div>1</div>
31159 <p>a
31160 </p><p><br />
31161 b
31162 </p>
31163 <div>2</div>
31164 <p>a
31165 </p><p><br />
31166 b
31167 </p>
31168 <div>3</div>
31169 <p>a
31170 </p><p><br />
31171 </p><p><br />
31172 </p><p>b
31173 </p>
31174 <div>4</div>
31175 <p>a
31176 </p><p><br />
31177 </p>
31178 <div>foo</div>
31179 !! end
31180
31181 !! test
31182 Empty paragraphs (marked with mw-empty-elt) found in source should not be normalized away
31183 !! options
31184 parsoid={
31185 "modes": ["html2wt"],
31186 "scrubWikitext": true
31187 }
31188 !! html/parsoid
31189 <table>
31190 <tbody>
31191 <tr>
31192 <td><div>foo
31193 </div>
31194 <p class="mw-empty-elt"></p>
31195 </td>
31196 </tr>
31197 </tbody>
31198 <caption></caption>
31199 </table>
31200 !! wikitext
31201 {|
31202 |<div>foo
31203 </div>
31204 |+
31205 |}
31206 !! end
31207
31208 !! test
31209 Templated content should be skipped over by normalization
31210 !! options
31211 parsoid={
31212 "modes": ["html2wt"],
31213 "scrubWikitext": true
31214 }
31215 !! html/parsoid
31216 <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">
31217 </span><p about="#mwt2"></p><span about="#mwt2">
31218 </span>
31219 !! wikitext
31220 {{SomeTemplate1|boo}}{{SomeTemplate2|booboo}}
31221 !! end
31222
31223 !! test
31224 Escape nowiki DOM elements
31225 !! options
31226 parsoid=html2wt
31227 !! html/parsoid
31228 <nowiki><i>foo</i></nowiki>
31229 !! wikitext
31230 &lt;nowiki&gt;''foo''&lt;/nowiki&gt;
31231 !! end
31232
31233 # This is meant to be an interim fix while we go about figuring out
31234 # how to not introduce these trailing <nowiki/>s in the first place.
31235 !! test
31236 T115717: Strip trailing <nowiki/>s (without affecting valid uses)
31237 !! options
31238 parsoid=html2wt
31239 !! html/parsoid
31240 <p>x<meta typeof="mw:Placeholder" data-parsoid='{"src":"&lt;nowiki/>"}'/><meta typeof="mw:Placeholder" data-parsoid='{"src":"&lt;nowiki/>"}'/>
31241 y</p>
31242 <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>
31243 <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>
31244 !! wikitext
31245 x
31246 y
31247
31248 {{echo|
31249 1 = <nowiki/>}}
31250
31251 {{echo|
31252 1 = <nowiki/>
31253 }}
31254 !! end
31255
31256 !! test
31257 New list is serialized on newlines
31258 !! options
31259 parsoid=html2wt
31260 !! html/parsoid
31261 <p>The quick brown fox jumps over the lazy dog.</p><ul>
31262 <li>Yesterday</li>
31263 <li>Today</li>
31264 <li>Tomorrow</li>
31265 </ul><p>The quick onyx goblin jumps over the lazy dwarf.</p>
31266 !! wikitext
31267 The quick brown fox jumps over the lazy dog.
31268
31269 * Yesterday
31270 * Today
31271 * Tomorrow
31272
31273 The quick onyx goblin jumps over the lazy dwarf.
31274 !! end
31275
31276 !! test
31277 New lists in formatting elements serialized w/o newlines
31278 !! options
31279 parsoid=html2wt
31280 !! html/parsoid
31281 <small>
31282
31283 <ul>
31284 <li>123</li>
31285 </ul>
31286
31287 </small>
31288
31289 <small><ul><li>hi</li></ul></small>
31290 !! wikitext
31291 <small>
31292 * 123
31293 </small>
31294
31295 <small>
31296 * hi
31297 </small>
31298 !! end
31299
31300 !! test
31301 New list in table doesn't need newlines
31302 !! options
31303 parsoid=html2wt
31304 !! html/parsoid
31305 <table><tr><td><ul><li>test</li><li>123</li></td></tr></table>
31306 !! wikitext
31307 {|
31308 |
31309 * test
31310 * 123
31311 |}
31312 !! end
31313
31314 # ---------------------------------------------------
31315 # End of tests spec'ing wikitext serialization norms |
31316 # ---------------------------------------------------
31317
31318 # T104032
31319 !! test
31320 Bare inline nodes not wrapped inside p-tags should be treated as p-wrapped
31321 !! options
31322 parsoid=html2wt
31323 !! html/parsoid
31324 a<p>b</p>
31325 <b>c</b><p>d</p>
31326 <table><tr>
31327 <td>a<p>b</p></td>
31328 <td><b>c</b><p>d</p></td>
31329 </tr></table>
31330 !! wikitext
31331 a
31332
31333 b
31334
31335 '''c'''
31336
31337 d
31338 {|
31339 |a
31340 b
31341 |'''c'''
31342 d
31343 |}
31344 !! end
31345
31346 !! test
31347 Anchor without href scenarios
31348 !! options
31349 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
31350 !! html/parsoid
31351 <a class="bc"></a>
31352 <a class="no">dice</a>
31353 <a name="foo"></a>
31354 !! wikitext
31355
31356 dice
31357 <span name="foo"></span>
31358 !! end
31359
31360 !! test
31361 New transclusion added after a list should be serialized after the list
31362 !! options
31363 parsoid=html2wt
31364 !! html/parsoid
31365 <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>
31366 !! wikitext
31367 * a
31368 {{echo|foo}}
31369 !! end
31370
31371 # -----------------------------------------------------------------
31372 # End of section for Parsoid-only html2wt tests for serialization
31373 # of new content
31374 # -----------------------------------------------------------------
31375
31376 # -----------------------------------------------------------------
31377 # The following section of tests are primarily to spec behavior of
31378 # the selective serializer. All these tests have manual selser
31379 # changes. The automated selser changes for all tests handle the
31380 # wide variation of changes, but these tests here capture specs
31381 # deterministically.
31382 # ----------------------------------------------------------------
31383
31384 ## T90517
31385 !! test
31386 Selser: New comments should not be lost
31387 !! options
31388 parsoid={
31389 "modes": ["selser"],
31390 "changes": [
31391 [ "#a", "after", "<!--c1-->" ],
31392 [ "#b", "before", "<!--c2-->" ]
31393 ]
31394 }
31395 !! wikitext
31396 <span id="a">a</span>
31397
31398 <span id="b">b</span>
31399 !! wikitext/edited
31400 <span id="a">a</span><!--c1-->
31401
31402 <!--c2--><span id="b">b</span>
31403 !! end
31404
31405 ## T89383
31406 !! test
31407 Selser: Check for validity of DSR before using it
31408 !! options
31409 parsoid={
31410 "modes": ["selser"],
31411 "changes": [
31412 [ "#a", "before", "<meta property='mw:PageProp/displaytitle' content='foo'>" ]
31413 ]
31414 }
31415 !! wikitext
31416 <span id="a">a</span>
31417 !! wikitext/edited
31418 {{DISPLAYTITLE:foo}}
31419 <span id="a">a</span>
31420 !! end
31421
31422 !! test
31423 1. DOMDiff: Changes to <ref> content should be looked up using id
31424 !! options
31425 parsoid={
31426 "modes": ["selser"],
31427 "changes": [
31428 ["#X", "after", "bar"],
31429 ["#Y", "after", "baz"]
31430 ]
31431 }
31432 !! wikitext
31433 X <ref><span id="X">foo</span></ref>
31434 Y <ref name="a" />
31435 <references>
31436 <ref name="a"><span id="Y">foo</span></ref>
31437 </references>
31438 !! wikitext/edited
31439 X <ref><span id="X">foo</span>bar</ref>
31440 Y <ref name="a" />
31441 <references>
31442 <ref name="a"><span id="Y">foo</span>baz</ref>
31443 </references>
31444 !! end
31445
31446 !! test
31447 2. DOMDiff: Changes to <ref> content should be looked up using id
31448 !! options
31449 parsoid={
31450 "modes": ["selser"],
31451 "changes": [
31452 ["#Z", "after", "bar"]
31453 ]
31454 }
31455 !! wikitext
31456 A <ref>foo bar for a</ref>
31457 B <ref group="X" name="b" />
31458
31459 <references />
31460
31461 <references group="X">
31462 <ref name="b"><span id="Z">foo</span></ref>
31463 </references>
31464 !! wikitext/edited
31465 A <ref>foo bar for a</ref>
31466 B <ref group="X" name="b" />
31467
31468 <references />
31469
31470 <references group="X">
31471 <ref name="b"><span id="Z">foo</span>bar</ref>
31472 </references>
31473 !! end
31474
31475 !! test
31476 DOMDiff: Edits to content nested in elements with templated attributes should not be lost (T139388)
31477 !! options
31478 parsoid={
31479 "modes": ["selser"],
31480 "changes": [
31481 [ "div:first-child", "text", "bar" ]
31482 ]
31483 }
31484 !! wikitext
31485 <div style="{{1x|color:red;}}%">foo</div>
31486 !! wikitext/edited
31487 <div style="{{1x|color:red;}}%">bar</div>
31488 !! end
31489
31490 !! test
31491 Empty LI (T49673)
31492 !! wikitext
31493 *a
31494 *
31495 *
31496 *b
31497 !! html+tidy
31498 <ul><li>a</li>
31499 <li class="mw-empty-elt"></li>
31500 <li class="mw-empty-elt"></li>
31501 <li>b</li></ul>
31502 !! end
31503
31504 !! test
31505 Thumbnail output
31506 !! wikitext
31507 [[File:Thumb.png|thumb]]
31508 !! html/php+tidy
31509 <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>
31510 !! html/parsoid
31511 <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>
31512 !! end
31513
31514 !! test
31515 unclosed internal link XSS (T137264)
31516 !! wikitext
31517 [[#%3Cscript%3Ealert(1)%3C/script%3E|
31518 !! html/php
31519 <p>[[#&lt;script&gt;alert(1)&lt;/script&gt;|
31520 </p>
31521 !! html/parsoid
31522 <p>[[#%3Cscript%3Ealert(1)%3C/script%3E|</p>
31523 !! end
31524
31525 !! test
31526 Validating that <style> isn't eaten by tidy (T167349)
31527 !! options
31528 styletag=1
31529 !! wikitext
31530 <div class="foo">
31531 <style>.foo::before { content: "<foo>"; }</style>
31532 <style data-mw-foobar="baz">.foo::after { content: "<bar>"; }</style>
31533 </div>
31534 !! html/php+tidy
31535 <div class="foo">
31536 <style>.foo::before { content: "<foo>"; }</style>
31537 <style data-mw-foobar="baz">.foo::after { content: "<bar>"; }</style>
31538 </div>
31539 !! html/parsoid
31540 <div class="foo">
31541 <style typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{},"body":{"extsrc":".foo::before { content: \"&lt;foo>\"; }"}}'>.foo::before { content: "<foo>"; }</style>
31542 <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>
31543 </div>
31544 !! end
31545
31546 ## Right now, Parsoid doesn't de-duplicate style tags.
31547 ## So, we shouldn't see link tags that need to bypass the sanitizer.
31548 ## In a followup patch, when we de-duplicate style tags and
31549 ## introduce link tags, we'll add a hook for link tags in
31550 ## the parser test runner script.
31551 !! test
31552 Validating that <style> isn't wrapped in a paragraph (T186965)
31553 !! options
31554 styletag=1
31555 !! wikitext
31556 A style tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
31557
31558 <style>.foo::before { content: "<foo>"; }</style>
31559
31560 <style>.foo::before { content: "<foo>"; }</style> <link rel="foo" href="bar"/><style>.foo::before { content: "<foo>"; }</style>
31561
31562 But if it's on a line with other content, let it be wrapped.
31563
31564 <style>.foo::before { content: "<foo>"; }</style> bar
31565
31566 foo <style>.foo::before { content: "<foo>"; }</style>
31567
31568 foo <style>.foo::before { content: "<foo>"; }</style> bar
31569
31570 And the same if we have non-paragraph-breaking whitespace
31571
31572 foo
31573 <style>.foo::before { content: "<foo>"; }</style>
31574 bar
31575 !! html/php
31576 <p>A style tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
31577 </p>
31578 <style>.foo::before { content: "<foo>"; }</style>
31579 <style>.foo::before { content: "<foo>"; }</style> <link rel="foo" href="bar"/><style>.foo::before { content: "<foo>"; }</style>
31580 <p>But if it's on a line with other content, let it be wrapped.
31581 </p><p><style>.foo::before { content: "<foo>"; }</style> bar
31582 </p><p>foo <style>.foo::before { content: "<foo>"; }</style>
31583 </p><p>foo <style>.foo::before { content: "<foo>"; }</style> bar
31584 </p><p>And the same if we have non-paragraph-breaking whitespace
31585 </p><p>foo
31586 <style>.foo::before { content: "<foo>"; }</style>
31587 bar
31588 </p>
31589 !! html/parsoid
31590 <p>A style tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph</p>
31591
31592 <style typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{},"body":{"extsrc":".foo::before { content: \"&lt;foo>\"; }"}}'>.foo::before { content: "<foo>"; }</style>
31593
31594 <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>
31595
31596 <p>But if it's on a line with other content, let it be wrapped.</p>
31597
31598 <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>
31599
31600 <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>
31601
31602 <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>
31603
31604 <p>And the same if we have non-paragraph-breaking whitespace</p>
31605
31606 <p>foo
31607 <style typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{},"body":{"extsrc":".foo::before { content: \"&lt;foo>\"; }"}}'>.foo::before { content: "<foo>"; }</style>
31608 bar</p>
31609 !! end
31610
31611 !! test
31612 Validating that <link> isn't wrapped in a paragraph (T186965)
31613 !! options
31614 styletag=1
31615 !! wikitext
31616 A link tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
31617
31618 <link rel="foo" href="bar"/>
31619
31620 <link rel="foo" href="bar"/> <style>.foo::before { content: "<foo>"; }</style><link rel="foo" href="bar"/>
31621
31622 But if it's on a line with other content, let it be wrapped.
31623
31624 <link rel="foo" href="bar"/> bar
31625
31626 foo <link rel="foo" href="bar"/>
31627
31628 foo <link rel="foo" href="bar"/> bar
31629
31630 And the same if we have non-paragraph-breaking whitespace
31631
31632 foo
31633 <link rel="foo" href="bar"/>
31634 bar
31635 !! html/php
31636 <p>A link tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
31637 </p>
31638 <link rel="foo" href="bar"/>
31639 <link rel="foo" href="bar"/> <style>.foo::before { content: "<foo>"; }</style><link rel="foo" href="bar"/>
31640 <p>But if it's on a line with other content, let it be wrapped.
31641 </p><p><link rel="foo" href="bar"/> bar
31642 </p><p>foo <link rel="foo" href="bar"/>
31643 </p><p>foo <link rel="foo" href="bar"/> bar
31644 </p><p>And the same if we have non-paragraph-breaking whitespace
31645 </p><p>foo
31646 <link rel="foo" href="bar"/>
31647 bar
31648 </p>
31649 !! end
31650
31651 !! test
31652 Extension returning multiple nodes starting with a style tag roundtrips
31653 !! options
31654 wgRawHtml=1
31655 !! wikitext
31656 <table>
31657 {{echo|<html><style>.hi { color: red; }</style>
31658 </html>}}
31659 <tr><td class="hi">ho</td></tr>
31660 </table>
31661 !! html/parsoid
31662 <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">
31663 </span></p><table about="#mwt5" data-parsoid='{"stx":"html"}'>
31664
31665 <tbody><tr><td class="hi">ho</td></tr>
31666 </tbody></table>
31667 !! end
31668
31669 !! test
31670 Decoding of HTML entities in headings and links for IDs and link fragments (T103714)
31671 !! config
31672 wgFragmentMode=[ 'html5', 'legacy' ]
31673 !! wikitext
31674 ==A&B&amp;C&amp;amp;D&amp;amp;amp;E==
31675 [[#A&B&amp;C&amp;amp;D&amp;amp;amp;E]]
31676 !! html/php
31677 <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>
31678 <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>
31679 </p>
31680 !! html/parsoid
31681 <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>
31682 <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>
31683 !! end
31684
31685 !! test
31686 Decoding of HTML entities in headings and links for IDs and link fragments (T103714) (legacy)
31687 !! config
31688 wgFragmentMode=[ 'legacy' ]
31689 !! wikitext
31690 ==A&B&amp;C&amp;amp;D&amp;amp;amp;E==
31691 [[#A&B&amp;C&amp;amp;D&amp;amp;amp;E]]
31692 !! html/php
31693 <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>
31694 <p><a href="#A.26B.26C.26amp.3BD.26amp.3Bamp.3BE">#A&amp;B&amp;C&amp;amp;D&amp;amp;amp;E</a>
31695 </p>
31696 !! end
31697
31698 !! test
31699 Decoding of HTML entities in embedded HTML tags
31700 !! wikitext
31701 <table class="1&2&amp;3&amp;amp;4&amp;amp;amp;5"><tr><td>x</td></tr></table>
31702 !! html/php
31703 <table class="1&amp;2&amp;3&amp;amp;4&amp;amp;amp;5"><tr><td>x</td></tr></table>
31704
31705 !! html/parsoid
31706 <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>
31707 !! end
31708
31709 !! test
31710 Decoding of HTML entities in indicator names for IDs (T104196)
31711 !! options
31712 parsoid=wt2html,html2html
31713 showindicators
31714 !! wikitext
31715 <indicator name="1&2&amp;3&amp;amp;4&amp;amp;amp;5">Indicator</indicator>
31716 !! html/php
31717 1&2&3&amp;4&amp;amp;5=Indicator
31718
31719 !! html/parsoid
31720 <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>
31721 !! end
31722
31723 # this version of the test strips out the ambiguity so Parsoid rts cleanly
31724 !! test
31725 Decoding of HTML entities in indicator names for IDs (unambiguous) (T104196)
31726 !! options
31727 showindicators
31728 !! wikitext
31729 <indicator name="1&2&3&amp;amp;4&amp;amp;amp;5">Indicator</indicator>
31730 !! html/php
31731 1&2&3&amp;4&amp;amp;5=Indicator
31732
31733 !! html/parsoid
31734 <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>
31735 !! end
31736
31737 # This fragment mode is what Parsoid supports.
31738 !! test
31739 HTML5 ids: fallback to legacy
31740 !! config
31741 wgFragmentMode=[ 'html5', 'legacy' ]
31742 !! wikitext
31743 ==Foo bar==
31744
31745 ==foo Bar==
31746
31747 ==Тест==
31748
31749 ==Тест==
31750
31751 ==тест==
31752
31753 ==Hey < # " > % : '==
31754 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
31755
31756 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
31757
31758 <!-- These two links should produce identical HTML -->
31759 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
31760
31761 !! html/php
31762 <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>
31763 <ul>
31764 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
31765 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
31766 <li class="toclevel-1 tocsection-3"><a href="#Тест"><span class="tocnumber">3</span> <span class="toctext">Тест</span></a></li>
31767 <li class="toclevel-1 tocsection-4"><a href="#Тест_2"><span class="tocnumber">4</span> <span class="toctext">Тест</span></a></li>
31768 <li class="toclevel-1 tocsection-5"><a href="#тест"><span class="tocnumber">5</span> <span class="toctext">тест</span></a></li>
31769 <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>
31770 </ul>
31771 </div>
31772
31773 <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>
31774 <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>
31775 <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>
31776 <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>
31777 <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>
31778 <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>
31779 <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>
31780 </p><p>💩 <span id="💩"></span>
31781 </p><p><a href="#啤酒">#啤酒</a> <a href="#啤酒">#啤酒</a>
31782 </p>
31783 !! html/parsoid
31784 <h2 id="Foo_bar">Foo bar</h2>
31785
31786 <h2 id="foo_Bar_2">foo Bar</h2>
31787
31788 <h2 id="Тест"><span id=".D0.A2.D0.B5.D1.81.D1.82" typeof="mw:FallbackId"></span>Тест</h2>
31789
31790 <h2 id="Тест_2"><span id=".D0.A2.D0.B5.D1.81.D1.82_2" typeof="mw:FallbackId"></span>Тест</h2>
31791
31792 <h2 id="тест"><span id=".D1.82.D0.B5.D1.81.D1.82" typeof="mw:FallbackId"></span>тест</h2>
31793
31794 <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>
31795 <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>
31796
31797 <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>
31798
31799 <!-- These two links should produce identical HTML -->
31800 <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>
31801 !! end
31802
31803 # Parsoid doesn't support this mode
31804 !! test
31805 HTML5 ids: legacy with a fallback to modern
31806 !! config
31807 wgFragmentMode=[ 'legacy', 'html5' ]
31808 !! wikitext
31809 ==Foo bar==
31810
31811 ==foo Bar==
31812
31813 ==Тест==
31814
31815 ==Тест==
31816
31817 ==тест==
31818
31819 ==Hey < # " > % : '==
31820 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
31821
31822 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
31823
31824 <!-- These two links should produce identical HTML -->
31825 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
31826
31827 !! html/php
31828 <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>
31829 <ul>
31830 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
31831 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
31832 <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>
31833 <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>
31834 <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>
31835 <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>
31836 </ul>
31837 </div>
31838
31839 <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>
31840 <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>
31841 <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>
31842 <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>
31843 <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>
31844 <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>
31845 <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>
31846 </p><p>.F0.9F.92.A9 <span id=".F0.9F.92.A9"></span>
31847 </p><p><a href="#.E5.95.A4.E9.85.92">#啤酒</a> <a href="#.E5.95.A4.E9.85.92">#啤酒</a>
31848 </p>
31849 !! end
31850
31851 # Parsoid doesn't support this mode.
31852 !! test
31853 HTML5 ids: no legacy
31854 !! config
31855 wgFragmentMode=[ 'html5' ]
31856 !! wikitext
31857 ==Foo bar==
31858
31859 ==foo Bar==
31860
31861 ==Тест==
31862
31863 ==Тест==
31864
31865 ==тест==
31866
31867 ==Hey < # " > % : '==
31868 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
31869
31870 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
31871
31872 <!-- These two links should produce identical HTML -->
31873 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
31874
31875 !! html/php
31876 <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>
31877 <ul>
31878 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
31879 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
31880 <li class="toclevel-1 tocsection-3"><a href="#Тест"><span class="tocnumber">3</span> <span class="toctext">Тест</span></a></li>
31881 <li class="toclevel-1 tocsection-4"><a href="#Тест_2"><span class="tocnumber">4</span> <span class="toctext">Тест</span></a></li>
31882 <li class="toclevel-1 tocsection-5"><a href="#тест"><span class="tocnumber">5</span> <span class="toctext">тест</span></a></li>
31883 <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>
31884 </ul>
31885 </div>
31886
31887 <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>
31888 <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>
31889 <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>
31890 <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>
31891 <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>
31892 <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>
31893 <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>
31894 </p><p>💩 <span id="💩"></span>
31895 </p><p><a href="#啤酒">#啤酒</a> <a href="#啤酒">#啤酒</a>
31896 </p>
31897 !! end
31898
31899 !! test
31900 T90902: Normalize weird characters in section IDs
31901 !! config
31902 wgFragmentMode=[ 'html5', 'legacy' ]
31903 !! wikitext
31904 ==Foo&nbsp;bar==
31905 [[#Foo&nbsp;bar]]
31906
31907 !! html/php
31908 <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>
31909 <p><a href="#Foo_bar">#Foo&#160;bar</a>
31910 </p>
31911 !! html/parsoid
31912 <h2 id="Foo_bar"> Foo<span typeof="mw:Entity" data-parsoid='{"src":"&amp;nbsp;","srcContent":" "}'> </span>bar </h2>
31913 <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>
31914 !! end
31915
31916 !! test
31917 T51672: Test for brackets in attributes of elements in external link texts
31918 !! wikitext
31919 [http://example.com/ link <span title="title with [brackets]">span</span>]
31920 [http://example.com/ link <span title="title with &#91;brackets&#93;">span</span>]
31921
31922 !! html/php
31923 <p><a rel="nofollow" class="external text" href="http://example.com/">link <span title="title with &#91;brackets&#93;">span</span></a>
31924 <a rel="nofollow" class="external text" href="http://example.com/">link <span title="title with &#91;brackets&#93;">span</span></a>
31925 </p>
31926 !! html/parsoid
31927 <p><a rel="mw:ExtLink" class="external text" href="http://example.com/">link <span title="title with [brackets]">span</span></a>
31928 <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>
31929 !! end
31930
31931 !! test
31932 T72875: Test for brackets in attributes of elements in internal link texts
31933 !! wikitext
31934 [[Foo|link <span title="title with [[double brackets]]">span</span>]]
31935 [[Foo|link <span title="title with &#91;&#91;double brackets&#93;&#93;">span</span>]]
31936
31937 !! html/php
31938 <p><a href="/wiki/Foo" title="Foo">link <span title="title with &#91;&#91;double brackets&#93;&#93;">span</span></a>
31939 <a href="/wiki/Foo" title="Foo">link <span title="title with &#91;&#91;double brackets&#93;&#93;">span</span></a>
31940 </p>
31941 !! html/parsoid
31942 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">link <span title="title with [[double brackets]]">span</span></a>
31943 <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>
31944 !! end
31945
31946 !! test
31947 T199926: html arrow wt: Parsoid sometimes trips up on verticalbar chars in hrefs
31948 !! options
31949 parsoid={
31950 "modes": ["html2wt"]
31951 }
31952 !! html/parsoid
31953 <a href="https://stats.wikimedia.org/v2/#/fr.wikipedia.org/reading/page-views-by-country/normal|map|2-Year~2016060100~2018071100|~total">9</a>
31954 <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>
31955 !! wikitext
31956 [https://stats.wikimedia.org/v2/#/fr.wikipedia.org/reading/page-views-by-country/normal|map|2-Year~2016060100~2018071100|~total 9]
31957 [[stats:v2/#/fr.wikipedia.org/reading/page-views-by-country/normal%7Cmap%7C2-Year~2016060100~2018071100%7C~total|10]]
31958 !! end
31959
31960 !! test
31961 T179544: {{anchorencode:}} output should be always usable in links
31962 !! config
31963 wgFragmentMode=[ 'html5' ]
31964 !! wikitext
31965 <span id="{{anchorencode:[foo]}}"></span>[[#{{anchorencode:[foo]}}]]
31966 !! html/php
31967 <p><span id="&#91;foo&#93;"></span><a href="#[foo]">#&#91;foo&#93;</a>
31968 </p>
31969 !! html/parsoid
31970 <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>
31971 !! end
31972
31973 ## ------------------------------
31974 ## Parsoid section-wrapping tests
31975 ## ------------------------------
31976 !! test
31977 Section wrapping for well-nested sections (no leading content)
31978 !! options
31979 parsoid={
31980 "wrapSections": true
31981 }
31982 !! wikitext
31983 =1=
31984 a
31985
31986 =2=
31987 b
31988
31989 ==2.1==
31990 c
31991
31992 ==2.2==
31993 d
31994
31995 ===2.2.1===
31996 e
31997
31998 =3=
31999 f
32000 !! html/parsoid
32001 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1>
32002 <p>a</p>
32003
32004 </section><section data-mw-section-id="2"><h1 id="2">2</h1>
32005 <p>b</p>
32006
32007 <section data-mw-section-id="3"><h2 id="2.1">2.1</h2>
32008 <p>c</p>
32009
32010 </section><section data-mw-section-id="4"><h2 id="2.2">2.2</h2>
32011 <p>d</p>
32012
32013 <section data-mw-section-id="5"><h3 id="2.2.1">2.2.1</h3>
32014 <p>e</p>
32015
32016 </section></section></section><section data-mw-section-id="6"><h1 id="3">3</h1>
32017 <p>f</p>
32018
32019 </section>
32020 !! end
32021
32022 !! test
32023 Section wrapping for well-nested sections (with leading content)
32024 !! options
32025 parsoid={
32026 "wrapSections": true
32027 }
32028 !! wikitext
32029 Para 1.
32030
32031 Para 2 with a <div>nested in it</div>
32032
32033 Para 3.
32034
32035 =1=
32036 a
32037
32038 =2=
32039 b
32040
32041 ==2.1==
32042 c
32043 !! html/parsoid
32044 <section data-mw-section-id="0"><p>Para 1.</p>
32045
32046 <p>Para 2 with a </p><div>nested in it</div>
32047
32048 <p>Para 3.</p>
32049
32050 </section><section data-mw-section-id="1"><h1 id="1">1</h1>
32051 <p>a</p>
32052
32053 </section><section data-mw-section-id="2"><h1 id="2">2</h1>
32054 <p>b</p>
32055
32056 <section data-mw-section-id="3"><h2 id="2.1">2.1</h2>
32057 <p>c</p>
32058
32059 </section></section>
32060 !! end
32061
32062 !! test
32063 Section wrapping with template-generated sections (good nesting 1)
32064 !! options
32065 parsoid={
32066 "wrapSections": true
32067 }
32068 !! wikitext
32069 =1=
32070 a
32071
32072 {{echo|1=
32073 ==1.1==
32074 b
32075 }}
32076
32077 ==1.2==
32078 c
32079
32080 =2=
32081 d
32082 !! html/parsoid
32083 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1>
32084 <p>a</p>
32085
32086 <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">
32087 </span><p about="#mwt1">b</p>
32088 </section><section data-mw-section-id="3"><h2 id="1.2">1.2</h2>
32089 <p>c</p>
32090
32091 </section></section><section data-mw-section-id="4"><h1 id="2">2</h1>
32092 <p>d</p></section>
32093 !! end
32094
32095 # In this example, the template scope is mildly expanded to incorporate the
32096 # trailing newline after the transclusion since that is part of section 1.1.1
32097 !! test
32098 Section wrapping with template-generated sections (good nesting 2)
32099 !! options
32100 parsoid={
32101 "wrapSections": true,
32102 "modes": ["wt2html", "wt2wt"]
32103 }
32104 !! wikitext
32105 =1=
32106 a
32107
32108 {{echo|1=
32109 ==1.1==
32110 b
32111 ===1.1.1===
32112 d
32113 }}
32114 =2=
32115 e
32116 !! html/parsoid
32117 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1>
32118 <p>a</p>
32119
32120 <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">
32121 </span><p about="#mwt1">b</p><span about="#mwt1">
32122 </span><section data-mw-section-id="-1" about="#mwt1"><h3 about="#mwt1" id="1.1.1">1.1.1</h3><span about="#mwt1">
32123 </span><p about="#mwt1">d</p><span about="#mwt1">
32124 </span></section></section></section><section data-mw-section-id="4" data-parsoid="{}"><h1 id="2">2</h1>
32125 <p>e</p></section>
32126 !! end
32127
32128 # In this example, the template scope is mildly expanded to incorporate the
32129 # trailing newline after the transclusion since that is part of section 1.2.1
32130 !! test
32131 Section wrapping with template-generated sections (good nesting 3)
32132 !! options
32133 parsoid={
32134 "wrapSections": true,
32135 "modes": ["wt2html", "wt2wt"]
32136 }
32137 !! wikitext
32138 =1=
32139 a
32140
32141 {{echo|1=
32142 x
32143 ==1.1==
32144 b
32145 ==1.2==
32146 c
32147 ===1.2.1===
32148 d
32149 }}
32150 =2=
32151 e
32152 !! html/parsoid
32153 <section data-mw-section-id="0"></section><section data-mw-section-id="1" data-parsoid="{}"><h1 id="1"> 1 </h1>
32154 <p>a</p>
32155
32156 <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">
32157 </span><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="1.1">1.1</h2><span about="#mwt1">
32158 </span><p about="#mwt1">b</p><span about="#mwt1">
32159 </span></section><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="1.2">1.2</h2><span about="#mwt1">
32160 </span><p about="#mwt1">c</p><span about="#mwt1">
32161 </span><section data-mw-section-id="-1" about="#mwt1"><h3 about="#mwt1" id="1.2.1">1.2.1</h3><span about="#mwt1">
32162 </span><p about="#mwt1">d</p><span about="#mwt1">
32163 </span></section></section></section><section data-mw-section-id="5"><h1 id="2">2</h1>
32164 <p>e</p></section>
32165 !! end
32166
32167 # Because of section-wrapping and template-wrapping interactions,
32168 # the scope of the template is expanded so that the template markup
32169 # is valid in the presence of <section> tags.
32170 # This exercises the s1 is null scenario in the wrapSections code
32171 !! test
32172 Section wrapping with template-generated sections (bad nesting 1)
32173 !! options
32174 parsoid={
32175 "wrapSections": true
32176 }
32177 !! wikitext
32178 <div>
32179 a
32180
32181 {{echo|
32182 =1=
32183 b
32184 }}
32185
32186 c
32187 </div>
32188 !! html/parsoid
32189 <section data-mw-section-id="-1"></section><section data-mw-section-id="-2"><div data-parsoid='{"stx":"html"}'>
32190 <p>a</p>
32191
32192 <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"]}'>
32193 </span><section data-mw-section-id="-1" about="#mwt1"><h1 about="#mwt1" id="1">1</h1><span about="#mwt1">
32194 </span><p about="#mwt1">b
32195 </p><span about="#mwt1">
32196
32197 </span><p about="#mwt1">c</p><span about="#mwt1">
32198 </span></section></div></section>
32199 !! end
32200
32201 # Because of section-wrapping and template-wrapping interactions,
32202 # the scope of the template is expanded so that the template markup
32203 # is valid in the presence of <section> tags.
32204 # This exercises the s1 is ancestor of s2 scenario in the wrapSections code
32205 !! test
32206 Section wrapping with template-generated sections (bad nesting 2)
32207 !! options
32208 parsoid={
32209 "wrapSections": true
32210 }
32211 !! wikitext
32212 =1=
32213 a
32214
32215 {{echo|1=
32216 =2=
32217 b
32218 ==2.1==
32219 c
32220 }}
32221
32222 d
32223
32224 =3=
32225 e
32226 !! html/parsoid
32227 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1>
32228 <p>a</p>
32229
32230 </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">
32231 </span><p about="#mwt1">b</p><span about="#mwt1">
32232 </span><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="2.1">2.1</h2><span about="#mwt1">
32233 </span><p about="#mwt1">c</p><span about="#mwt1">
32234
32235 </span><p about="#mwt1">d</p><span about="#mwt1">
32236
32237 </span></section></section><section data-mw-section-id="4"><h1 id="3">3</h1>
32238 <p>e</p></section>
32239 !! end
32240
32241 # Because of section-wrapping and template-wrapping interactions,
32242 # additional template wrappers are added to <section> tags
32243 # so that template wrapping semantics are valid whether section
32244 # tags are retained or stripped. But, the template scope can expand
32245 # greatly when accounting for section tags.
32246 # This exercises the s1 and s2 are in different subtrees scenario
32247 !! test
32248 Section wrapping with template-generated sections (bad nesting 3)
32249 !! options
32250 parsoid={
32251 "wrapSections": true,
32252 "modes": ["wt2html", "wt2wt"]
32253 }
32254 !! wikitext
32255 =1=
32256 a
32257
32258 {{echo|1=
32259 ==1.2==
32260 b
32261 =2=
32262 c
32263 }}
32264
32265 d
32266
32267 =3=
32268 e
32269 !! html/parsoid
32270 <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>
32271 <p>a</p>
32272
32273 <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">
32274 </span><p about="#mwt1">b</p><span about="#mwt1">
32275 </span></section></section><section data-mw-section-id="-1" about="#mwt1"><h1 about="#mwt1" id="2">2</h1><span about="#mwt1">
32276 </span><p about="#mwt1">c</p>
32277
32278 <p>d</p>
32279 </section><section data-mw-section-id="4" data-parsoid="{}"><h1 id="3">3</h1>
32280 <p>e</p></section>
32281 !! end
32282
32283 !! test
32284 Section wrapping with uneditable lead section + div wrapping multiple sections
32285 !! options
32286 parsoid={
32287 "wrapSections": true
32288 }
32289 !! wikitext
32290 foo
32291
32292 <div style="border:1px solid red;">
32293 =1=
32294 a
32295
32296 ==1.1==
32297 b
32298
32299 =2=
32300 c
32301 </div>
32302
32303 =3=
32304 d
32305
32306 ==3.1==
32307 e
32308 !! html/parsoid
32309 <section data-mw-section-id="-1"><p>foo</p>
32310
32311 </section><section data-mw-section-id="-2"><div style="border:1px solid red;">
32312 <section data-mw-section-id="1"><h1 id="1">1</h1>
32313 <p>a</p>
32314
32315 <section data-mw-section-id="2"><h2 id="1.1">1.1</h2>
32316 <p>b</p>
32317
32318 </section></section><section data-mw-section-id="-1"><h1 id="2">2</h1>
32319 <p>c</p>
32320 </section></div>
32321
32322 </section><section data-mw-section-id="4"><h1 id="3">3</h1>
32323 <p>d</p>
32324
32325 <section data-mw-section-id="5"><h2 id="3.1">3.1</h2>
32326 <p>e</p>
32327 </section></section>
32328 !! end
32329
32330 !! test
32331 Section wrapping with editable lead section + div overlapping multiple sections
32332 !! options
32333 parsoid={
32334 "wrapSections": true
32335 }
32336 !! wikitext
32337 foo
32338
32339 =1=
32340 a
32341 <div style="border:1px solid red;">
32342 b
32343
32344 ==1.1==
32345 c
32346
32347 =2=
32348 d
32349 </div>
32350 e
32351
32352 =3=
32353 f
32354
32355 ==3.1==
32356 g
32357 !! html/parsoid
32358 <section data-mw-section-id="0"><p>foo</p>
32359
32360 </section><section data-mw-section-id="-1"><h1 id="1">1</h1>
32361 <p>a</p>
32362 </section><section data-mw-section-id="-2"><div style="border:1px solid red;">
32363 <p>b</p>
32364
32365 <section data-mw-section-id="2"><h2 id="1.1">1.1</h2>
32366 <p>c</p>
32367
32368 </section><section data-mw-section-id="-1"><h1 id="2">2</h1>
32369 <p>d</p>
32370 </section></div>
32371 <p>e</p>
32372
32373 </section><section data-mw-section-id="4"><h1 id="3">3</h1>
32374 <p>f</p>
32375
32376 <section data-mw-section-id="5"><h2 id="3.1">3.1</h2>
32377 <p>g</p>
32378 </section></section>
32379 !! end
32380
32381 !! test
32382 HTML header tags should not be wrapped in section tags
32383 !! options
32384 parsoid={
32385 "wrapSections": true
32386 }
32387 !! wikitext
32388 foo
32389
32390 <h1>a</h1>
32391
32392 =b=
32393
32394 <h1>c</h1>
32395
32396 =d=
32397 !! html/parsoid
32398 <section data-mw-section-id="0"><p>foo</p>
32399
32400 <h1 id="a" data-parsoid='{"stx":"html"}'>a</h1>
32401
32402 </section><section data-mw-section-id="1"><h1 id="b">b</h1>
32403
32404 <h1 id="c" data-parsoid='{"stx":"html"}'>c</h1>
32405
32406 </section><section data-mw-section-id="2"><h1 id="d">d</h1></section>
32407 !! end
32408
32409 !! test
32410 Lead section containing only whitespace and comments.
32411 !! options
32412 parsoid={
32413 "wrapSections": true
32414 }
32415 !! wikitext
32416
32417 <!-- this is a comment, presumably significant to editors -->
32418 =1=
32419 a
32420
32421 =2=
32422 b
32423 !! html/parsoid
32424 <section data-mw-section-id="0" data-parsoid="{}">
32425 <!-- this is a comment, presumably significant to editors -->
32426 </section><section data-mw-section-id="1"><h1 id="1">1</h1>
32427 <p>a</p>
32428
32429 </section><section data-mw-section-id="2"><h1 id="2">2</h1>
32430 <p>b</p></section>
32431 !! end
32432
32433 !! test
32434 Pseudo-sections emitted by templates should have id -2
32435 !! options
32436 parsoid={
32437 "wrapSections": true
32438 }
32439 !! wikitext
32440 foo
32441 {{echo|<div>
32442 ==a==
32443 ==b==
32444 </div>
32445 }}
32446 !! html/parsoid
32447 <section data-mw-section-id="-1"><p>foo</p>
32448 </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}}]}'>
32449 <section data-mw-section-id="-1"><h2 id="a">a</h2>
32450 </section><section data-mw-section-id="-1"><h2 id="b">b</h2>
32451 </section></div><span about="#mwt1">
32452 </span></section>
32453 !! end
32454
32455 ##########################################################################
32456 Tests demonstrating white-space insensitivity in input wikitext
32457 for wikitext headings, wikitext list items, and wikitext table captions,
32458 headings, and cells. HTML versions of the same should preserve whitespace.
32459 ##########################################################################
32460 !! test
32461 Trim whitespace in wikitext headings, list items, table captions, headings, and cells
32462 !! options
32463 parsoid={
32464 "modes": ["wt2html"],
32465 "preserveIEW": true
32466 }
32467 !! wikitext
32468 __NOTOC__
32469 == <!--c1--> <!--c2--> Spaces <!--c3--> <!--c4--> ==
32470 == <!--c1--> <!--c2--> Tabs <!--c3--><!--c4--> ==
32471 == <!--Headings with fallback ids--> Личная жизнь ==
32472 * <!--c1--> <!--c2--> List item <!--c3--> <!--c4-->
32473 ; <!--term to define--> term : <!--term's definition--> definition
32474 {|
32475 |+ <!--c1--> <!--c2--> Table Caption <!--c3--> <!--c4-->
32476 |-
32477 ! <!--c1--> <!--c2--> Table Heading 1 <!--c3--> <!--c4--> !! Table Heading 2 <!--c5-->
32478 |-
32479 | <!--c1--> <!--c2--> Table Cell 1 <!--c3--> <!--c4--> || Table Cell 2 <!--c5-->
32480 |-
32481 | class="foo" || <!--c1--> <!--c2--> Table Cell 3 <!--c3--> <!--c4-->
32482 |-
32483 | <!--c1--> testing [[one|two]] <!--c2--> | <!--c3--> some content
32484 |}
32485 : {|
32486 | <!--c1--> <!--c2--> Table Cell 1 <!--c3--> <!--c4--> || Table Cell 2 <!--c5-->
32487 |} foo <!--c1-->
32488 !! html/php+tidy
32489 <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>
32490 <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>
32491 <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>
32492 <ul><li>List item</li></ul>
32493 <dl><dt>term&#160;</dt>
32494 <dd>definition</dd></dl>
32495 <table>
32496 <caption>Table Caption
32497 </caption>
32498 <tbody><tr>
32499 <th>Table Heading 1</th>
32500 <th>Table Heading 2
32501 </th></tr>
32502 <tr>
32503 <td>Table Cell 1</td>
32504 <td>Table Cell 2
32505 </td></tr>
32506 <tr>
32507 <td>class="foo"</td>
32508 <td>Table Cell 3
32509 </td></tr>
32510 <tr>
32511 <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
32512 </td></tr></tbody></table>
32513 <dl><dd><table>
32514 <tbody><tr>
32515 <td>Table Cell 1</td>
32516 <td>Table Cell 2
32517 </td></tr></tbody></table> foo</dd></dl>
32518 !! html/parsoid
32519 <meta property="mw:PageProp/notoc">
32520 <h2 id="Spaces"><!--c1--><!--c2-->Spaces<!--c3--><!--c4--></h2>
32521 <h2 id="Tabs"><!--c1--><!--c2-->Tabs<!--c3--><!--c4--></h2>
32522 <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>
32523 <ul><li><!--c1--><!--c2-->List item<!--c3--><!--c4--></li></ul>
32524 <dl><dt><!--term to define-->term&nbsp;</dt><dd><!--term's definition-->definition</dd></dl>
32525 <table>
32526 <caption><!--c1--><!--c2-->Table Caption<!--c3--><!--c4--></caption>
32527 <tbody><tr>
32528 <th><!--c1--><!--c2-->Table Heading 1<!--c3--><!--c4--></th><th>Table Heading 2<!--c5--></th></tr>
32529 <tr>
32530 <td><!--c1--><!--c2-->Table Cell 1<!--c3--><!--c4--></td><td>Table Cell 2<!--c5--></td></tr>
32531 <tr>
32532 <td>class="foo"</td><td><!--c1--><!--c2-->Table Cell 3<!--c3--><!--c4--></td></tr>
32533 <tr>
32534 <td><!--c1-->testing <a rel="mw:WikiLink" href="./One" title="One">two</a> <!--c2--> | <!--c3--> some content</td></tr>
32535 </tbody></table>
32536 <dl><dd><table>
32537 <tbody><tr><td><!--c1--><!--c2-->Table Cell 1<!--c3--><!--c4--></td><td>Table Cell 2<!--c5--></td></tr>
32538 </tbody></table> foo<!--c1--></dd></dl>
32539 !! end
32540
32541 # Looks like <caption> is not accepted in HTML
32542 !! test
32543 Do not trim whitespace in HTML headings, list items, table captions, headings, and cells
32544 !! options
32545 parsoid={
32546 "modes": ["wt2html"],
32547 "preserveIEW": true
32548 }
32549 !! wikitext
32550 __NOTOC__
32551 <h2> <!--c1--> <!--c2--> Heading <!--c3--> <!--c4--> </h2>
32552 <ul><li> <!--c1--> <!--c2--> List item <!--c3--> <!--c4--> </li></ul>
32553 <table>
32554 <tr><th> <!--c1--> <!--c2--> Table Heading <!--c3--> <!--c4--> <th></tr>
32555 <tr><td> <!--c1--> <!--c2--> Table Cell <!--c3--> <!--c4--> <th></tr>
32556 </table>
32557 !! html/php+tidy
32558 <h2><span class="mw-headline" id="Heading"> Heading </span></h2>
32559 <ul><li> List item </li></ul>
32560 <table>
32561 <tbody><tr><th> Table Heading </th><th></th></tr>
32562 <tr><td> Table Cell </td><th></th></tr>
32563 </tbody></table>
32564 !! html/parsoid
32565 <meta property="mw:PageProp/notoc"/>
32566 <h2 id="Heading"> <!--c1--> <!--c2--> Heading <!--c3--> <!--c4--> </h2>
32567 <ul><li> <!--c1--> <!--c2--> List item <!--c3--> <!--c4--> </li></ul>
32568 <table>
32569 <tbody><tr><th> <!--c1--> <!--c2--> Table Heading <!--c3--> <!--c4--> </th><th></th></tr>
32570 <tr><td> <!--c1--> <!--c2--> Table Cell <!--c3--> <!--c4--> </td><th></th></tr>
32571 </tbody></table>
32572 !! end
32573
32574 !! test
32575 Do not trim whitespace in links and quotes
32576 !! options
32577 parsoid={
32578 "modes": ["wt2html"],
32579 "preserveIEW": true
32580 }
32581 !! wikitext
32582 foo '' <!--c1--> italic <!--c2--> '' and ''' <!--c3--> bold <!--c4--> '''
32583 [[Foo| some text ]]
32584 !! html/php+tidy
32585 <p>foo <i> italic </i> and <b> bold </b>
32586 <a href="/wiki/Foo" title="Foo"> some text </a>
32587 </p>
32588 !! html/parsoid
32589 <p>foo <i> <!--c1--> italic <!--c2--> </i> and <b> <!--c3--> bold <!--c4--> </b>
32590 <a rel="mw:WikiLink" href="./Foo" title="Foo"> some text </a></p>
32591 !! end
32592
32593 !! test
32594 Remove p tags surrounding a single element in a figcaption
32595 !! options
32596 parsoid=html2wt
32597 !! wikitext
32598 [[File:Foobar.jpg|right|200x200px|Caption]]
32599 !! html/parsoid
32600 <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>
32601 !! end
32602
32603 !! test
32604 Selser preserves lack of newline before list and allows newline after the list
32605 !! options
32606 parsoid={
32607 "modes": ["selser"],
32608 "scrubWikitext": true,
32609 "changes": [
32610 [ "ul", "after", "<p>footer</p>" ]
32611 ]
32612 }
32613 !! wikitext
32614 header
32615 *foo
32616 *bar
32617 !! wikitext/edited
32618 header
32619 *foo
32620 *bar
32621
32622 footer
32623 !! end
32624
32625
32626 !! test
32627 Selser does not introduce newlines between unedited paragraph preceding the list
32628 !! options
32629 parsoid={
32630 "modes": ["selser"],
32631 "changes": [
32632 [ "table tbody tr td p:last-child", "empty" ]
32633 ]
32634 }
32635 !! wikitext
32636 {|
32637 |
32638 header
32639 *foo
32640 *bar
32641 footer
32642 |}
32643 !! wikitext/edited
32644 {|
32645 |
32646 header
32647 *foo
32648 *bar
32649
32650 |}
32651 !! end
32652
32653 !! test
32654 Selser does not introduce newlines between unedited paragraph following the list
32655 !! options
32656 parsoid={
32657 "modes": ["selser"],
32658 "changes": [
32659 [ "table tbody tr td p:first-child", "empty" ]
32660 ]
32661 }
32662 !! wikitext
32663 {|
32664 |
32665 header
32666 *foo
32667 *bar
32668 footer
32669 |}
32670 !! wikitext/edited
32671 {|
32672 |
32673
32674 *foo
32675 *bar
32676 footer
32677 |}
32678 !! end
32679
32680 !! test
32681 Remove a list item but do not insert newline above list
32682 !! options
32683 parsoid={
32684 "modes": ["selser"],
32685 "changes": [
32686 [ "ul li:last-child", "remove" ]
32687 ]
32688 }
32689 !! wikitext
32690 header
32691 *foo
32692 *bar
32693 footer
32694 !! wikitext/edited
32695 header
32696 *foo
32697 footer
32698 !! end