parser: Remove trailing newline after prefixes have been cleared
[lhc/web/wiklou.git] / tests / parser / parserTests.txt
1 # MediaWiki Parser test cases
2 # Some taken from https://meta.wikimedia.org/wiki/Parser_testing
3 # All (C) their respective authors and released under the GPL
4 #
5 # The syntax should be fairly self-explanatory.
6 #
7 # Currently supported test options:
8 # One of the following three:
9 #
10 # (default) generate HTML output
11 # pst apply pre-save transform
12 # msg apply message transform
13 #
14 # Plus any combination of these:
15 #
16 # cat add category links
17 # (ignored by Parsoid, since it emits <link>s)
18 # ill add inter-language links
19 # (ignored by Parsoid, since it emits <link>s)
20 # subpage enable subpages (disabled by default)
21 # title=[[XXX]] run test using article title XXX
22 # language=XXX set content language to XXX for this test
23 # variant=XXX set the variant of language for this test (eg zh-tw)
24 # disabled do not run test
25 # parsoid parsoid-specific options (not run by PHP parser unless
26 # the test includes an html/php section)
27 # php php-only test (not run by the parsoid parser unless
28 # the test includes an html/parsoid section)
29 # showtitle make the first line the title
30 # showindicators make the first lines the page status indicators
31 # comment run through Linker::formatComment() instead of main parser
32 # local format section links in edit comment text as local links
33 # notoc disable table of contents
34 # thumbsize=NNN set the default thumb size to NNNpx for this test
35 # wrap include the normal wrapper <div class="mw-parser-output"> (since 1.30)
36 #
37 # You can also set the following parser properties via test options:
38 # wgEnableUploads, wgAllowExternalImages, wgMaxTocLevel,
39 # wgLinkHolderBatchSize, wgRawHtml, wgInterwikiMagic,
40 # wgEnableMagicLinks
41 #
42 # For testing purposes, temporary articles can created:
43 # !!article / NAMESPACE:TITLE / !!text / ARTICLE TEXT / !!endarticle
44 # where '/' denotes a newline.
45
46 # This is the standard article assumed to exist.
47 !! article
48 Main Page
49 !! text
50 blah blah
51 !! endarticle
52
53 !!article
54 Foo
55 !!text
56 FOO
57 !!endarticle
58
59 !!article
60 Foo''s bar''s
61 !!text
62 Article titles can contain single quotes!
63 !!endarticle
64
65 !!article
66 Template:Foo
67 !!text
68 FOO
69 !!endarticle
70
71 !! article
72 Template:redirect to foo
73 !! text
74 #REDIRECT [[Template:Foo]]
75 !! endarticle
76
77 !! article
78 Template:Blank
79 !! text
80 !! endarticle
81
82 !! article
83 Template:pipe
84 !! text
85 |
86 !! endarticle
87
88 !! article
89 Template:=
90 !! text
91 <nowiki>=</nowiki>
92 !! endarticle
93
94 !!article
95 MediaWiki:bad image list
96 !!text
97 * [[File:Bad.jpg]] except [[Nasty page]]
98 !!endarticle
99
100 !! article
101 Template:inner list
102 !! text
103 * item 1
104 !! endarticle
105
106 !! article
107 Template:tbl-start
108 !! text
109 {|
110 !! endarticle
111
112 !! article
113 Template:tbl-end
114 !! text
115 |}
116 !! endarticle
117
118 !! article
119 Template:echo
120 !! text
121 {{{1}}}
122 !! endarticle
123
124 !! article
125 Template:echo3
126 !! text
127 {{{1}}}
128 {{{1}}}
129 {{{1}}}
130 !! endarticle
131
132 // For Serbian; localize Template namespace
133 !! article
134 Шаблон:Echo
135 !! text
136 {{{1}}}
137 !! endarticle
138
139 !! article
140 Template:echo_with_span
141 !! text
142 <span>{{{1}}}</span>
143 !! endarticle
144
145 !! article
146 Template:echo_with_div
147 !! text
148 <div>{{{1}}}</div>
149 !! endarticle
150
151 !! article
152 Template:echo with depth
153 !! text
154 {{echo|{{{1}}}}}
155 !! endarticle
156
157 !! article
158 Template:blank_param
159 !! text
160 {{{1}}}
161 {{{}}}
162 !! endarticle
163
164 !! article
165 Template:table_attribs
166 !! text
167 <noinclude>
168 |</noinclude>style="color:red;"|Foo
169 !! endarticle
170
171 !! article
172 Template:table_attribs_2
173 !! text
174 <noinclude>
175 |</noinclude>style="color:red;"|Foo
176 |Bar||Baz
177 !! endarticle
178
179 !! article
180 Template:table_attribs_3
181 !! text
182 <noinclude>
183 |</noinclude>style{{=}}"background:&#35;f9f9f9;"|Foo
184 !! endarticle
185
186 !! article
187 Template:table_attribs_4
188 !! text
189 | style="background-color:#DC241f;" width="10px" |
190 !! endarticle
191
192 !! article
193 Template:table_attribs_5
194 !! text
195 <noinclude>
196 |</noinclude>style="color:red;"||Bar
197 !! endarticle
198
199 !! article
200 Template:table_attribs_6
201 !! text
202 style="background: <nowiki>
203
204
205 red;</nowiki>" |
206 !! endarticle
207
208 !! article
209 Template:table_attribs_7
210 !! text
211 <noinclude>
212 |</noinclude>style{{=}}"background:&#35;f9f9f9;"|Foo<ref>foo</ref>
213 !! endarticle
214
215 !! article
216 Template:table_header_cells
217 !! text
218 {{table_attribs}}!!style='color:red;'|''Bar''||style='color:brown;'|''Foo'' and Baz
219 !! endarticle
220
221 !! article
222 Template:table_cells
223 !! text
224 {{table_attribs}}||style='color:red;'|''Bar''||style='color:brown;'|''Foo'' and Baz
225 !! endarticle
226
227 !! article
228 Template:PartialTable
229 !! text
230 {|
231 |-
232 !! endarticle
233
234 !! article
235 Template:image_attribs
236 !! text
237 <noinclude>
238 [[File:foobar.jpg|</noinclude>right|Caption text<noinclude>]]</noinclude>
239 !! endarticle
240
241 ## See T48811 for details
242 !! article
243 Template:mixed_attr_content_template
244 !! text
245 style="color:red;" title="T48811"
246 |-
247 |foo
248 !! endarticle
249
250 !! article
251 Template:definition_list
252 !! text
253 one
254 ::two
255 !! endarticle
256
257 !! article
258 A?b
259 !! text
260 Weirdo titles!
261 !! endarticle
262
263 !!article
264 Template:Bullet
265 !!text
266 *Bar
267 !!endarticle
268
269 !!article
270 Template:OpenTable
271 !!text
272 {|
273 !!endarticle
274
275 !!article
276 Template:EmptyLITest
277 !!text
278 *a
279 *
280 *
281 *b
282 !!endarticle
283
284 !!article
285 Template:EmptyTRTest
286 !!text
287 {|
288 |-
289 |-
290 |foo
291 |-
292 |-
293 |bar
294 |}
295 !!endarticle
296
297 !!article
298 Template:EmptyTRWithHTMLAttrTest
299 !!text
300 <table>
301 <tr align="center"></tr>
302 <tr><td>foo</td></tr>
303 <tr align="center"></tr>
304 <tr><td>bar</td></tr>
305 </table>
306 !!endarticle
307
308 !! article
309 Template:With: Colon
310 !! text
311 Template with colon
312 !! endarticle
313
314 ###
315 ### Basic tests
316 ###
317
318 !! test
319 Blank input
320 !! wikitext
321 !! html
322 !! end
323
324 !! test
325 Simple paragraph
326 !! wikitext
327 This is a simple paragraph.
328 !! html
329 <p>This is a simple paragraph.
330 </p>
331 !! end
332
333 !! test
334 Paragraphs with extra newline spacing
335 !! wikitext
336 a
337
338 b (+2 nls)
339
340
341 c (+3 nls)
342
343
344
345 d (+4 nls)
346
347
348
349
350 e (+5 nls)
351 !! html
352 <p>a
353 </p><p>b (+2 nls)
354 </p><p><br />
355 c (+3 nls)
356 </p><p><br />
357 </p><p>d (+4 nls)
358 </p><p><br />
359 </p><p><br />
360 e (+5 nls)
361 </p>
362 !! end
363
364 !! test
365 Paragraphs with newline spacing with comment lines in between
366 !! wikitext
367 ----
368 a
369 <!--foo-->
370 b
371 ----
372 a
373 <!--foo--><!--More than 1 comment, still stripped-->
374 b
375 ----
376 a
377 <!--foo--> <!----> <!-- bar -->
378 b
379 ----
380 a
381 <!--foo-->
382
383 b
384 ----
385 a
386
387 <!--foo-->
388 b
389 ----
390 a
391 <!--foo-->
392
393
394 b
395 ----
396 a
397
398
399 <!--foo-->
400 b
401 ----
402 !! html
403 <hr />
404 <p>a
405 b
406 </p>
407 <hr />
408 <p>a
409 b
410 </p>
411 <hr />
412 <p>a
413 b
414 </p>
415 <hr />
416 <p>a
417 </p><p>b
418 </p>
419 <hr />
420 <p>a
421 </p><p>b
422 </p>
423 <hr />
424 <p>a
425 </p><p><br />
426 b
427 </p>
428 <hr />
429 <p>a
430 </p><p><br />
431 b
432 </p>
433 <hr />
434
435 !! end
436
437 !! test
438 Paragraphs with newline spacing with non-empty white-space lines in between
439 !! wikitext
440 ----
441 a
442
443 b
444 ----
445 a
446
447
448 b
449 ----
450 !! html
451 <hr />
452 <p>a
453 </p><p>b
454 </p>
455 <hr />
456 <p>a
457 </p><p><br />
458 b
459 </p>
460 <hr />
461
462 !! end
463
464 !! test
465 Paragraphs with newline spacing with non-empty mixed comment and white-space lines in between
466 !! wikitext
467 ----
468 a
469 <!--foo-->
470 b
471 ----
472 a
473 <!--foo--><!--More than 1 comment doesn't disable stripping of this line!-->
474 b
475 ----
476 a
477
478 <!--foo-->
479 <!--bar-->
480 b
481 ----
482 a
483
484 <!--foo-->
485 <!--bar-->
486
487 b
488 ----
489 !! html
490 <hr />
491 <p>a
492 b
493 </p>
494 <hr />
495 <p>a
496 b
497 </p>
498 <hr />
499 <p>a
500 </p><p>b
501 </p>
502 <hr />
503 <p>a
504 </p><p><br />
505 b
506 </p>
507 <hr />
508
509 !! end
510
511 !! test
512 Extra newlines: More paragraphs with indented comment
513 !! wikitext
514 a
515
516 <!--boo-->
517
518 b
519 !! html
520 <p>a
521 </p><p><br />
522 b
523 </p>
524 !!end
525
526 !! test
527 Extra newlines followed by heading
528 !! wikitext
529 a
530
531
532 =b=
533 [[a]]
534
535
536 =b=
537 !! html
538 <p>a
539 </p><p><br />
540 </p>
541 <h1><span class="mw-headline" id="b">b</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: b">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
542 <p><a href="/index.php?title=A&amp;action=edit&amp;redlink=1" class="new" title="A (page does not exist)">a</a>
543 </p><p><br />
544 </p>
545 <h1><span class="mw-headline" id="b_2">b</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: b">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
546
547 !! end
548
549 !! test
550 Extra newlines between heading and content are swallowed (Parsoid does not)
551 !! wikitext
552 =b=
553
554
555
556 [[a]]
557 !! html/php+tidy
558 <h1><span class="mw-headline" id="b">b</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: b">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
559 <p><a href="/index.php?title=A&amp;action=edit&amp;redlink=1" class="new" title="A (page does not exist)">a</a>
560 </p>
561 !! html/parsoid
562 <h1 id="b">b</h1>
563 <p>
564 <br></p>
565
566 <p><a rel="mw:WikiLink" href="./A" title="A">a</a></p>
567 !! end
568
569 !! test
570 Extra new lines before and after lists are preserved
571 !! wikitext
572 a
573
574
575 *b
576
577
578 c
579 !! html/php+tidy
580 <p>a
581 </p><p><br />
582 </p>
583 <ul><li>b</li></ul>
584 <p><br />
585 c
586 </p>
587 !! html/parsoid
588 <p>a</p>
589 <p>
590 <br></p>
591 <ul><li>b</li></ul>
592 <p>
593 <br>
594 c</p>
595 !! end
596
597 # Parsoid regression test
598 !!test
599 Multiple newlines after tables are converted to p-br-p tags
600 !!options
601 parsoid=wt2html,wt2wt
602 !!wikitext
603 {|
604 |x
605 |}
606
607
608
609
610 =b=
611 !!html/php+tidy
612 <table>
613 <tbody><tr>
614 <td>x
615 </td></tr></tbody></table>
616 <p><br />
617 </p><p><br />
618 </p>
619 <h1><span class="mw-headline" id="b">b</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: b">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
620 !!html/parsoid
621 <table>
622 <tbody>
623 <tr>
624 <td>x</td>
625 </tr>
626 </tbody>
627 </table>
628 <p><br/></p>
629 <p><br/></p>
630 <h1 id="b">b</h1>
631 !!end
632
633 !! test
634 Heading with line break in nowiki
635 !! options
636 parsoid=wt2html
637 !! config
638 wgFragmentMode=[ 'html5', 'legacy' ]
639 !! wikitext
640 ==A <nowiki>B
641 C</nowiki>==
642 !! html/php
643 <h2><span id="A_B.0AC"></span><span class="mw-headline" id="A_B
644 C">A B
645 C</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: A B&#10;C">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
646
647 !! html/parsoid
648 <h2 id="A_B
649 C"><span id="A_B.0AC" typeof="mw:FallbackId"></span>A <span typeof="mw:Nowiki">B
650 C</span></h2>
651 !! end
652
653 !! test
654 Parsing an URL
655 !! wikitext
656 http://fr.wikipedia.org/wiki/🍺
657 <!-- EasterEgg we love beer, better be able be able to link to it -->
658 !! html
659 <p><a rel="nofollow" class="external free" href="http://fr.wikipedia.org/wiki/🍺">http://fr.wikipedia.org/wiki/🍺</a>
660 </p>
661 !! end
662
663 !! test
664 Simple list
665 !! wikitext
666 *Item 1
667 *Item 2
668 !! html
669 <ul><li>Item 1</li>
670 <li>Item 2</li></ul>
671 !! end
672
673 !! test
674 Italics and bold
675 !! wikitext
676 *plain
677 *plain''italic''plain
678 *plain''italic''plain''italic''plain
679 *plain'''bold'''plain
680 *plain'''bold'''plain'''bold'''plain
681 *plain''italic''plain'''bold'''plain
682 *plain'''bold'''plain''italic''plain
683 *plain''italic'''bold-italic'''italic''plain
684 *plain'''bold''bold-italic''bold'''plain
685 *plain'''''bold-italic'''italic''plain
686 *plain'''''bold-italic''bold'''plain
687 *plain''italic'''bold-italic'''''plain
688 *plain'''bold''bold-italic'''''plain
689 *plain l'''italic''plain
690 *plain l''''bold''' plain
691 !! html
692 <ul><li>plain</li>
693 <li>plain<i>italic</i>plain</li>
694 <li>plain<i>italic</i>plain<i>italic</i>plain</li>
695 <li>plain<b>bold</b>plain</li>
696 <li>plain<b>bold</b>plain<b>bold</b>plain</li>
697 <li>plain<i>italic</i>plain<b>bold</b>plain</li>
698 <li>plain<b>bold</b>plain<i>italic</i>plain</li>
699 <li>plain<i>italic<b>bold-italic</b>italic</i>plain</li>
700 <li>plain<b>bold<i>bold-italic</i>bold</b>plain</li>
701 <li>plain<i><b>bold-italic</b>italic</i>plain</li>
702 <li>plain<b><i>bold-italic</i>bold</b>plain</li>
703 <li>plain<i>italic<b>bold-italic</b></i>plain</li>
704 <li>plain<b>bold<i>bold-italic</i></b>plain</li>
705 <li>plain l'<i>italic</i>plain</li>
706 <li>plain l'<b>bold</b> plain</li></ul>
707 !! end
708
709 # this example taken from the [[simple:Moon]] article (T49326)
710 !! test
711 Italics and possessives (1)
712 !! wikitext
713 obtained by ''[[Lunar Prospector]]'''s gamma-ray spectrometer
714 !! html
715 <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
716 </p>
717 !! end
718
719 # this example taken from [[en:Flaming Pie]] (T51926)
720 !! test
721 Italics and possessives (2)
722 !! wikitext
723 '''''Flaming Pie''''' is ... released in 1997. In ''Flaming Pie'''s liner notes
724 !! html
725 <p><i><b>Flaming Pie</b></i> is ... released in 1997. In <i>Flaming Pie'</i>s liner notes
726 </p>
727 !! end
728
729 # this example taken from [[en:Dictionary]] (T51926)
730 !! test
731 Italics and possessives (3)
732 !! wikitext
733 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''.
734 !! html
735 <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>.
736 </p>
737 !! end
738
739
740 ###
741 ### 2-quote opening sequence tests
742 ###
743 !! test
744 Italics and bold: 2-quote opening sequence: (2,2)
745 !! wikitext
746 ''foo''
747 !! html
748 <p><i>foo</i>
749 </p>
750 !!end
751
752 !! test
753 Italics and bold: 2-quote opening sequence: (2,3)
754 !! wikitext
755 ''foo'''
756 !! html/*
757 <p><i>foo'</i>
758 </p>
759 !!end
760
761 !! test
762 Italics and bold: 2-quote opening sequence: (2,4)
763 !! options
764 parsoid=wt2html
765 !! wikitext
766 ''foo''''
767 !! html/*
768 <p><i>foo''</i>
769 </p>
770 !!end
771
772 # same html as previous, but wikitext adjusted to match parsoid html2wt
773 !! test
774 Italics and bold: 2-quote opening sequence: (2,4) w/ nowiki
775 !! wikitext
776 ''foo<nowiki>''</nowiki>''
777 !! html
778 <p><i>foo''</i>
779 </p>
780 !! end
781
782 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
783 !! test
784 Italics and bold: 2-quote opening sequence: (2,5)
785 !! options
786 parsoid=wt2html
787 !! wikitext
788 ''foo'''''
789 !! html/php
790 <p><i>foo</i>
791 </p>
792 !! html/parsoid
793 <p><i>foo</i><b></b>
794 </p>
795 !!end
796
797 # same html as previous, but wikitext adjusted to match parsoid html2wt
798 !! test
799 Italics and bold: 2-quote opening sequence: (2,5+3) w/ nowiki
800 !! wikitext
801 ''foo'''''<nowiki/>'''
802 !! html/php
803 <p><i>foo</i>
804 </p>
805 !! html/parsoid
806 <p><i>foo</i><b></b>
807 </p>
808 !! end
809
810
811 ###
812 ### 3-quote opening sequence tests
813 ###
814
815 !! test
816 Italics and bold: 3-quote opening sequence: (3,2)
817 !! wikitext
818 '''foo''
819 !! html/*
820 <p>'<i>foo</i>
821 </p>
822 !!end
823
824 !! test
825 Italics and bold: 3-quote opening sequence: (3,3)
826 !! wikitext
827 '''foo'''
828 !! html
829 <p><b>foo</b>
830 </p>
831 !!end
832
833 !! test
834 Italics and bold: 3-quote opening sequence: (3,4)
835 !! wikitext
836 '''foo''''
837 !! html/*
838 <p><b>foo'</b>
839 </p>
840 !!end
841
842 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
843 !! test
844 Italics and bold: 3-quote opening sequence: (3,5)
845 !! options
846 parsoid=wt2html
847 !! wikitext
848 '''foo'''''
849 !! html/php
850 <p><b>foo</b>
851 </p>
852 !! html/parsoid
853 <p><b>foo</b><i></i>
854 </p>
855 !!end
856
857 # same html as previous, but wikitext adjusted to match parsoid html2wt
858 !! test
859 Italics and bold: 3-quote opening sequence: (3,5+2) w/ nowiki
860 !! wikitext
861 '''foo'''''<nowiki/>''
862 !! html/php
863 <p><b>foo</b>
864 </p>
865 !! html/parsoid
866 <p><b>foo</b><i></i>
867 </p>
868 !! end
869
870
871 ###
872 ### 4-quote opening sequence tests
873 ###
874
875 !! test
876 Italics and bold: 4-quote opening sequence: (4,2)
877 !! options
878 parsoid=wt2html
879 !! wikitext
880 ''''foo''
881 !! html/*
882 <p>''<i>foo</i>
883 </p>
884 !!end
885
886 # same html as previous, but wikitext adjusted to match parsoid html2wt
887 !! test
888 Italics and bold: 4-quote opening sequence: (4,2) w/ nowiki
889 !! wikitext
890 <nowiki>''</nowiki>''foo''
891 !! html
892 <p>''<i>foo</i>
893 </p>
894 !! end
895
896 !! test
897 Italics and bold: 4-quote opening sequence: (4,3)
898 !! wikitext
899 ''''foo'''
900 !! html/*
901 <p>'<b>foo</b>
902 </p>
903 !!end
904
905 !! test
906 Italics and bold: 4-quote opening sequence: (4,4)
907 !! options
908 parsoid=wt2html
909 !! wikitext
910 ''''foo''''
911 !! html/*
912 <p>'<b>foo'</b>
913 </p>
914 !!end
915
916 # same html as previous, but wikitext adjusted to match parsoid html2wt
917 !! test
918 Italics and bold: 4-quote opening sequence: (4,4) w/ nowiki
919 !! wikitext
920 '<nowiki/>'''foo''''
921 !! html
922 <p>'<b>foo'</b>
923 </p>
924 !! end
925
926 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
927 !! test
928 Italics and bold: 4-quote opening sequence: (4,5)
929 !! options
930 parsoid=wt2html
931 !! wikitext
932 ''''foo'''''
933 !! html/php
934 <p>'<b>foo</b>
935 </p>
936 !! html/parsoid
937 <p>'<b>foo</b><i></i>
938 </p>
939 !!end
940
941 # same html as previous, but wikitext adjusted to match parsoid html2wt
942 !! test
943 Italics and bold: 4-quote opening sequence: (4,5+2) w/ nowiki
944 !! wikitext
945 '<nowiki/>'''foo'''''<nowiki/>''
946 !! html/php
947 <p>'<b>foo</b>
948 </p>
949 !! html/parsoid
950 <p>'<b>foo</b><i></i>
951 </p>
952 !! end
953
954
955 ###
956 ### 5-quote opening sequence tests
957 ###
958
959 !! test
960 Italics and bold: 5-quote opening sequence: (5,2)
961 !! options
962 parsoid=wt2html
963 !! wikitext
964 '''''foo''
965 !! html/*
966 <p><b><i>foo</i></b>
967 </p>
968 !!end
969
970 # same html as previous, but wikitext adjusted to match parsoid html2wt
971 !! test
972 Italics and bold: 5-quote opening sequence: (5,2+3)
973 !! wikitext
974 '''''foo'''''
975 !! html/*
976 <p><i><b>foo</b></i>
977 </p>
978 !! end
979
980 !! test
981 Italics and bold: 5-quote opening sequence: (5,3)
982 !! options
983 parsoid=wt2html
984 !! wikitext
985 '''''foo'''
986 !! html/*
987 <p><i><b>foo</b></i>
988 </p>
989 !!end
990
991 # same html as previous, but wikitext adjusted to match parsoid html2wt
992 !! test
993 Italics and bold: 5-quote opening sequence: (5,3+2)
994 !! wikitext
995 '''''foo'''''
996 !! html
997 <p><i><b>foo</b></i>
998 </p>
999 !! end
1000
1001 !! test
1002 Italics and bold: 5-quote opening sequence: (5,4)
1003 !! options
1004 parsoid=wt2html
1005 !! wikitext
1006 '''''foo''''
1007 !! html/*
1008 <p><i><b>foo'</b></i>
1009 </p>
1010 !!end
1011
1012 !! test
1013 Italics and bold: 5-quote opening sequence: (5,5)
1014 !! wikitext
1015 '''''foo'''''
1016 !! html
1017 <p><i><b>foo</b></i>
1018 </p>
1019 !!end
1020
1021 !! test
1022 Italics and bold: 5-quote opening sequence: (5,6)
1023 !! wikitext
1024 '''''foo''''''
1025 !! html/*
1026 <p><i><b>foo'</b></i>
1027 </p>
1028 !! end
1029
1030 ###
1031 ### multiple quote sequences in a line
1032 ###
1033
1034 !! test
1035 Italics and bold: multiple quote sequences: (2,4,2)
1036 !! options
1037 parsoid=wt2html
1038 !! wikitext
1039 ''foo''''bar''
1040 !! html/*
1041 <p><i>foo'<b>bar</b></i>
1042 </p>
1043 !! end
1044
1045 # same html as previous, but wikitext adjusted to match parsoid html2wt
1046 !! test
1047 Italics and bold: multiple quote sequences: (2,4,2+3) w/ nowiki
1048 !! wikitext
1049 ''foo'<nowiki/>'''bar'''''
1050 !! html
1051 <p><i>foo'<b>bar</b></i>
1052 </p>
1053 !! end
1054
1055 !! test
1056 Italics and bold: multiple quote sequences: (2,4,3)
1057 !! options
1058 parsoid=wt2html
1059 !! wikitext
1060 ''foo''''bar'''
1061 !! html/*
1062 <p><i>foo'<b>bar</b></i>
1063 </p>
1064 !! end
1065
1066 # same html as previous, but wikitext adjusted to match parsoid html2wt
1067 !! test
1068 Italics and bold: multiple quote sequences: (2,4,3+2) w/ nowiki
1069 !! wikitext
1070 ''foo'<nowiki/>'''bar'''''
1071 !! html
1072 <p><i>foo'<b>bar</b></i>
1073 </p>
1074 !! end
1075
1076 !! test
1077 Italics and bold: multiple quote sequences: (2,4,4)
1078 !! options
1079 parsoid=wt2html
1080 !! wikitext
1081 ''foo''''bar''''
1082 !! html/*
1083 <p><i>foo'<b>bar'</b></i>
1084 </p>
1085 !! end
1086
1087 # same html as previous, but wikitext adjusted to match parsoid html2wt
1088 !! test
1089 Italics and bold: multiple quote sequences: (2,4,4+2) w/ nowiki
1090 !! wikitext
1091 ''foo'<nowiki/>'''bar'<nowiki/>'''''
1092 !! html
1093 <p><i>foo'<b>bar'</b></i>
1094 </p>
1095 !! end
1096
1097 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
1098 !! test
1099 Italics and bold: multiple quote sequences: (3,4,2)
1100 !! options
1101 parsoid=wt2html
1102 !! wikitext
1103 '''foo''''bar''
1104 !! html/php
1105 <p><b>foo'</b>bar
1106 </p>
1107 !! html/parsoid
1108 <p><b>foo'</b>bar<i></i>
1109 </p>
1110 !! end
1111
1112 # same html as previous, but wikitext adjusted to match parsoid html2wt
1113 !! test
1114 Italics and bold: multiple quote sequences: (3,4,2+2) w/ nowiki
1115 !! wikitext
1116 '''foo''''bar''<nowiki/>''
1117 !! html/php
1118 <p><b>foo'</b>bar
1119 </p>
1120 !! html/parsoid
1121 <p><b>foo'</b>bar<i></i>
1122 </p>
1123 !! end
1124
1125 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
1126 !! test
1127 Italics and bold: multiple quote sequences: (3,4,3)
1128 !! options
1129 parsoid=wt2html
1130 !! wikitext
1131 '''foo''''bar'''
1132 !! html/php
1133 <p><b>foo'</b>bar
1134 </p>
1135 !! html/parsoid
1136 <p><b>foo'</b>bar<b></b>
1137 </p>
1138 !! end
1139
1140 # same html as previous, but wikitext adjusted to match parsoid html2wt
1141 !! test
1142 Italics and bold: multiple quote sequences: (3,4,3+3) w/ nowiki
1143 !! wikitext
1144 '''foo''''bar'''<nowiki/>'''
1145 !! html/php
1146 <p><b>foo'</b>bar
1147 </p>
1148 !! html/parsoid
1149 <p><b>foo'</b>bar<b></b>
1150 </p>
1151 !! end
1152
1153 ###
1154 ### other quote tests
1155 ###
1156 !! test
1157 Italics and bold: other quote tests: (2,3,5)
1158 !! wikitext
1159 ''this is about '''foo's family'''''
1160 !! html
1161 <p><i>this is about <b>foo's family</b></i>
1162 </p>
1163 !!end
1164
1165
1166 !! test
1167 Italics and bold: other quote tests: (2,(3,3),2)
1168 !! wikitext
1169 ''this is about '''foo's''' family''
1170 !! html
1171 <p><i>this is about <b>foo's</b> family</i>
1172 </p>
1173 !!end
1174
1175
1176 !! test
1177 Italics and bold: other quote tests: (3,2,3,2)
1178 !! options
1179 parsoid=wt2html
1180 !! wikitext
1181 '''this is about ''foo'''s family''
1182 !! html/*
1183 <p><b>this is about <i>foo</i></b><i>s family</i>
1184 </p>
1185 !!end
1186
1187
1188 # same html as previous, but wikitext adjusted to match parsoid html2wt
1189 !! test
1190 Italics and bold: other quote tests: (3,2,3+2+2,2)
1191 !! wikitext
1192 '''this is about ''foo'''''<nowiki/>''s family''
1193 !! html
1194 <p><b>this is about <i>foo</i></b><i>s family</i>
1195 </p>
1196 !! end
1197
1198
1199 !! test
1200 Italics and bold: other quote tests: (3,2,3,3)
1201 !! wikitext
1202 '''this is about ''foo'''s family'''
1203 !! html/*
1204 <p>'<i>this is about </i>foo<b>s family</b>
1205 </p>
1206 !!end
1207
1208
1209 !! test
1210 Italics and bold: other quote tests: (3,(2,2),3)
1211 !! wikitext
1212 '''this is about ''foo's'' family'''
1213 !! html
1214 <p><b>this is about <i>foo's</i> family</b>
1215 </p>
1216 !!end
1217
1218
1219 !! test
1220 Italicized possessive
1221 !! wikitext
1222 The ''[[Main Page]]'''s talk page.
1223 !! html/php
1224 <p>The <i><a href="/wiki/Main_Page" title="Main Page">Main Page</a>'</i>s talk page.
1225 </p>
1226 !! html/parsoid
1227 <p>The <i><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a>'</i>s talk page.</p>
1228 !! end
1229
1230 !! test
1231 Quote balancing context should be restricted to td/th cells on the same wikitext line
1232 !! options
1233 parsoid=wt2html,wt2wt
1234 !! wikitext
1235 {|
1236 !''a!!''b
1237 |''a||''b
1238 |}
1239 !! html+tidy
1240 <table>
1241 <tbody><tr>
1242 <th><i>a</i></th>
1243 <th><i>b</i>
1244 </th>
1245 <td><i>a</i></td>
1246 <td><i>b</i>
1247 </td></tr></tbody></table>
1248 !! end
1249
1250 !! test
1251 Bold conversion test
1252 !! wikitext
1253 a b'''c ''d e'''f'' g h'''i ''j
1254 !! options
1255 parsoid=wt2html
1256 !! html+tidy
1257 <p>a b'<i>c </i>d e<b>f<i> g h</i></b><i>i </i>j
1258 </p>
1259 !! end
1260
1261 ###
1262 ### Non-html5 tags
1263 ###
1264
1265 !! test
1266 Non-html5 tags should be accepted
1267 !! wikitext
1268 <center>''foo''</center>
1269 <big>''foo''</big>
1270 <font>''foo''</font>
1271 <strike>''foo''</strike>
1272 <tt>''foo''</tt>
1273 !! html
1274 <center><i>foo</i></center>
1275 <p><big><i>foo</i></big>
1276 <font><i>foo</i></font>
1277 <strike><i>foo</i></strike>
1278 <tt><i>foo</i></tt>
1279 </p>
1280 !! end
1281
1282 !! test
1283 <wbr> is valid wikitext (T54468)
1284 !! wikitext
1285 <wbr>
1286 !! html
1287 <p><wbr />
1288 </p>
1289 !! end
1290
1291 # <strike> is HTML4, <s> is HTML4/5.
1292 !! test
1293 <s> or <strike> for strikethrough
1294 !! wikitext
1295 <strike>strike</strike>
1296
1297 <s>s</s>
1298 !! html
1299 <p><strike>strike</strike>
1300 </p><p><s>s</s>
1301 </p>
1302 !! end
1303
1304 ## a not permitted
1305 ## i,b,br omitted
1306 !! test
1307 Text-level semantic html elements in wikitext
1308 !! wikitext
1309 <em>text</em>
1310 <strong>text</strong>
1311 <small>text</small>
1312 <s>text</s>
1313 <cite>text</cite>
1314 <q>text</q>
1315 <dfn>text</dfn>
1316 <abbr>text</abbr>
1317 <data>text</data>
1318 <time>text</time>
1319 <code>text</code>
1320 <var>text</var>
1321 <samp>text</samp>
1322 <kbd>text</kbd>
1323 <sub>text</sub>
1324 <u>text</u>
1325 <mark>text</mark>
1326 <ruby><rb>明日</rb><rp>(</rp><rt>Ashita</rt><rp> </rp><rtc>あした</rtc><rp>)</rp></ruby>
1327 <bdi>text</bdi>
1328 <bdo>text</bdo>
1329 <span>text</span>
1330 <wbr />
1331 !! html
1332 <p><em>text</em>
1333 <strong>text</strong>
1334 <small>text</small>
1335 <s>text</s>
1336 <cite>text</cite>
1337 <q>text</q>
1338 <dfn>text</dfn>
1339 <abbr>text</abbr>
1340 <data>text</data>
1341 <time>text</time>
1342 <code>text</code>
1343 <var>text</var>
1344 <samp>text</samp>
1345 <kbd>text</kbd>
1346 <sub>text</sub>
1347 <u>text</u>
1348 <mark>text</mark>
1349 <ruby><rb>明日</rb><rp>(</rp><rt>Ashita</rt><rp> </rp><rtc>あした</rtc><rp>)</rp></ruby>
1350 <bdi>text</bdi>
1351 <bdo>text</bdo>
1352 <span>text</span>
1353 <wbr />
1354 </p>
1355 !! end
1356
1357 # test cases taken from
1358 # https://www.w3.org/TR/html5/text-level-semantics.html#the-ruby-element
1359 !! test
1360 Ruby markup (W3C-style)
1361 !! wikitext
1362 ;Mono-ruby for individual base characters
1363 :<ruby>日<rt>に</rt>本<rt>ほん</rt>語<rt>ご</rt></ruby>
1364 ;Group ruby
1365 :<ruby>今日<rt>きょう</rt></ruby>
1366 ;Jukugo ruby
1367 :<ruby>法<rb>華</rb><rb>経</rb><rt>ほ</rt><rt>け</rt><rt>きょう</rt></ruby>
1368 ;Inline ruby
1369 :<ruby>東<rb>京</rb><rp>(</rp><rt>とう</rt><rt>きょう</rt><rp>)</rp></ruby>
1370 ;Double-sided ruby
1371 :<ruby><rb>旧</rb><rb>金</rb><rb>山</rb><rt>jiù</rt><rt>jīn</rt><rt>shān</rt><rtc>San Francisco</rtc></ruby>
1372
1373 <ruby>
1374 <rb>♥</rb><rtc><rt>Heart</rt></rtc><rtc lang="fr"><rt>Cœur</rt></rtc>
1375 <rb>☘</rb><rtc><rt>Shamrock</rt></rtc><rtc lang="fr"><rt>Trèfle</rt></rtc>
1376 <rb>✶</rb><rtc><rt>Star</rt></rtc><rtc lang="fr"><rt>Étoile</rt></rtc>
1377 </ruby>
1378 !! html
1379 <dl><dt>Mono-ruby for individual base characters</dt>
1380 <dd><ruby>日<rt>に</rt>本<rt>ほん</rt>語<rt>ご</rt></ruby></dd>
1381 <dt>Group ruby</dt>
1382 <dd><ruby>今日<rt>きょう</rt></ruby></dd>
1383 <dt>Jukugo ruby</dt>
1384 <dd><ruby>法<rb>華</rb><rb>経</rb><rt>ほ</rt><rt>け</rt><rt>きょう</rt></ruby></dd>
1385 <dt>Inline ruby</dt>
1386 <dd><ruby>東<rb>京</rb><rp>(</rp><rt>とう</rt><rt>きょう</rt><rp>)</rp></ruby></dd>
1387 <dt>Double-sided ruby</dt>
1388 <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>
1389 <p><ruby>
1390 <rb>♥</rb><rtc><rt>Heart</rt></rtc><rtc lang="fr"><rt>Cœur</rt></rtc>
1391 <rb>☘</rb><rtc><rt>Shamrock</rt></rtc><rtc lang="fr"><rt>Trèfle</rt></rtc>
1392 <rb>✶</rb><rtc><rt>Star</rt></rtc><rtc lang="fr"><rt>Étoile</rt></rtc>
1393 </ruby>
1394 </p>
1395 !! end
1396
1397 # The next two test different paths in the sanitizer.
1398 !! test
1399 Non-word characters don't terminate tag names (T19663, T42670, T54022)
1400 !! wikitext
1401 <blockquote|>a</blockquote>
1402
1403 <b→> doesn't terminate </b→>
1404
1405 <bä> doesn't terminate </bä>
1406
1407 <boo> doesn't terminate </boo>
1408
1409 <s.foo> doesn't terminate </s.foo>
1410
1411 <sub-ID#1>
1412 !! html/php
1413 <p>&lt;blockquote|&gt;a&lt;/blockquote&gt;
1414 </p><p>&lt;b→&gt; doesn't terminate &lt;/b→&gt;
1415 </p><p>&lt;bä&gt; doesn't terminate &lt;/bä&gt;
1416 </p><p>&lt;boo&gt; doesn't terminate &lt;/boo&gt;
1417 </p><p>&lt;s.foo&gt; doesn't terminate &lt;/s.foo&gt;
1418 </p><p>&lt;sub-ID#1&gt;
1419 </p>
1420 !! end
1421
1422 !! test
1423 Non-word characters don't terminate tag names
1424 !! wikitext
1425 <blockquote|>a</blockquote>
1426
1427 <b→> doesn't terminate </b→>
1428
1429 <bä> doesn't terminate </bä>
1430
1431 <boo> doesn't terminate </boo>
1432
1433 <s.foo> doesn't terminate </s.foo>
1434
1435 <sub-ID#1>
1436 !! html+tidy
1437 <p>&lt;blockquote|&gt;a
1438 </p><p>&lt;b→&gt; doesn't terminate &lt;/b→&gt;
1439 </p><p>&lt;bä&gt; doesn't terminate &lt;/bä&gt;
1440 </p><p>&lt;boo&gt; doesn't terminate &lt;/boo&gt;
1441 </p><p>&lt;s.foo&gt; doesn't terminate &lt;/s.foo&gt;
1442 </p><p>&lt;sub-ID#1&gt;
1443 </p>
1444 !! end
1445
1446 ###
1447 ### See tests/parser/ParserTestParserHook.php for the <tåg> extension)
1448 ### This checks that HTML5 tags (with non-word characters in the tag
1449 ### name) make it safely through the parser -- the Sanitizer will
1450 ### munge them later, as it should.
1451 ###
1452 !! test
1453 Non-word characters are valid in extension tags (T19663)
1454 !! wikitext
1455 <tåg>tåg</tåg>
1456 !! html/php
1457 <pre>
1458 'tåg'
1459 array (
1460 )
1461 </pre>
1462
1463 !! html/parsoid
1464 <pre typeof="mw:Extension/tåg" data-mw='{"name":"tåg","attrs":{},"body":{"extsrc":"tåg"}}' data-parsoid='{}' about="#mwt2"></pre>
1465 !! end
1466
1467 !! test
1468 Isolated close tags should be treated as literal text (T54760)
1469 !! options
1470 parsoid=wt2html
1471 !! wikitext
1472 </b>
1473
1474 <s.foo>s</s>
1475 !! html+tidy
1476 <p class="mw-empty-elt">
1477 </p><p>&lt;s.foo&gt;s
1478 </p>
1479 !! end
1480
1481 ###
1482 ### Special characters
1483 ###
1484
1485 !! test
1486 Bare pipe character (T54363)
1487 !! wikitext
1488 |
1489 !! html
1490 <p>|
1491 </p>
1492 !! end
1493
1494 !! test
1495 Bare pipe character from a template (T54363)
1496 !! wikitext
1497 {{pipe}}
1498 !! html
1499 <p>|
1500 </p>
1501 !! end
1502
1503 ###
1504 ### <nowiki> test cases
1505 ###
1506
1507 !! test
1508 <nowiki> unordered list
1509 !! wikitext
1510 <nowiki>* This is not an unordered list item.</nowiki>
1511 !! html/php
1512 <p>* This is not an unordered list item.
1513 </p>
1514 !! html/parsoid
1515 <p><span typeof="mw:Nowiki">* This is not an unordered list item.</span></p>
1516 !! end
1517
1518 !! test
1519 <nowiki> spacing
1520 !! wikitext
1521 <nowiki>Lorem ipsum dolor
1522
1523 sed abit.
1524 sed nullum.
1525
1526 :and a colon
1527 </nowiki>
1528 !! html/php
1529 <p>Lorem ipsum dolor
1530
1531 sed abit.
1532 sed nullum.
1533
1534 :and a colon
1535
1536 </p>
1537 !! html/parsoid
1538 <p><span typeof="mw:Nowiki">Lorem ipsum dolor
1539
1540 sed abit.
1541 sed nullum.
1542
1543 :and a colon
1544 </span></p>
1545 !! end
1546
1547 !! test
1548 Don't parse <nowiki><span class="error"></nowiki> (T149622)
1549 !! wikitext
1550 <nowiki><span class="error"></nowiki>
1551 !! html/php
1552 <p>&lt;span class="error"&gt;
1553 </p>
1554 !! html/parsoid
1555 <p><span typeof="mw:Nowiki">&lt;span class="error"></span></p>
1556 !! end
1557
1558 !! test
1559 nowiki 3
1560 !! wikitext
1561 :There is not nowiki.
1562 :There is <nowiki>nowiki</nowiki>.
1563
1564 #There is not nowiki.
1565 #There is <nowiki>nowiki</nowiki>.
1566
1567 *There is not nowiki.
1568 *There is <nowiki>nowiki</nowiki>.
1569 !! html/php
1570 <dl><dd>There is not nowiki.</dd>
1571 <dd>There is nowiki.</dd></dl>
1572 <ol><li>There is not nowiki.</li>
1573 <li>There is nowiki.</li></ol>
1574 <ul><li>There is not nowiki.</li>
1575 <li>There is nowiki.</li></ul>
1576 !! html/parsoid
1577 <dl><dd data-parsoid='{}'>There is not nowiki.</dd>
1578 <dd data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</dd></dl>
1579
1580 <ol><li data-parsoid='{}'>There is not nowiki.</li>
1581 <li data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</li></ol>
1582
1583 <ul><li data-parsoid='{}'>There is not nowiki.</li>
1584 <li data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</li></ul>
1585 !! end
1586
1587 !! test
1588 Entities inside <nowiki>
1589 !! wikitext
1590 <nowiki>&lt;</nowiki>
1591 !! html/php
1592 <p>&lt;
1593 </p>
1594 !! html/parsoid
1595 <p><span typeof="mw:Nowiki"><span typeof="mw:Entity" data-parsoid='{"src":"&amp;lt;","srcContent":"&lt;"}'>&lt;</span></span></p>
1596 !! end
1597
1598 !! test
1599 Entities inside template parameters
1600 !! wikitext
1601 {{echo|&ndash;}}
1602 !! html/php+tidy
1603 <p>&#8211;
1604 </p>
1605 !! html/parsoid
1606 <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>
1607 !! end
1608
1609 !! test
1610 Properly escape nowiki when combined with other wiki markup
1611 !! options
1612 parsoid=html2wt
1613 !! html/parsoid
1614 <p>* &lt;/nowiki&gt; tag</p>
1615 !! wikitext
1616 <nowiki>*</nowiki> <nowiki>&lt;/nowiki&gt;</nowiki> tag
1617 !! end
1618
1619 !! test
1620 T93824: Put escaped HTML tags inside nowiki
1621 !! options
1622 parsoid=html2wt
1623 !! html/parsoid
1624 <p>&lt;h2&gt;foo&lt;/h2&gt;</p>
1625 !! wikitext
1626 <nowiki><h2>foo</h2></nowiki>
1627 !! end
1628
1629 !! test
1630 T71950: 1. Put nowiki as close to cause as possible, even with non-quote escapable chars
1631 !! options
1632 parsoid=html2wt
1633 !! html/parsoid
1634 <p>This text: L'<a rel="mw:WikiLink" href="./Foo">Foo</a>
1635 This text: L''<a rel="mw:WikiLink" href="./Foo">Foo</a>
1636 This text: L'''<a rel="mw:WikiLink" href="./Foo">Foo</a>''</p>
1637 !! wikitext
1638 This text: L'[[Foo]]
1639 This text: L<nowiki>''</nowiki>[[Foo]]
1640 This text: L<nowiki>'''</nowiki>[[Foo]]<nowiki>''</nowiki>
1641 !! end
1642
1643 # This test fails because wikitext whitespace is not normalized before comparing.
1644 !! test
1645 T71950: 2. Put nowiki as close to cause as possible, after ' :'
1646 !! options
1647 parsoid=html2wt
1648 !! html/parsoid
1649 <p>This text : L''<a rel="mw:WikiLink" href="./Foo">Foo</a>
1650 </p>
1651 !! wikitext
1652 This text : L<nowiki>''</nowiki>[[Foo]]
1653 !! end
1654
1655 # This test and the next one are html2wt only as they test that incorrect wikitext
1656 # passed in template arguments gets escaped or wrapped in nowikis where required.
1657 !! test
1658 T71482: Use {{!}} instead of nowiki for single pipe in template argument
1659 !! options
1660 parsoid=html2wt
1661 !! html/parsoid
1662 <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>
1663 <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>
1664 !! wikitext
1665 {{echo|foo{{!}}bar}}
1666 {{echo|<nowiki>foo|bar |[[</nowiki>}}
1667 !! end
1668
1669 !! test
1670 T53961: Output correct nowikis in template arguments
1671 !! options
1672 parsoid=html2wt
1673 !! html/parsoid
1674 <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>
1675 <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>
1676 <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>
1677 <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>
1678 <span typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;a }&quot;}},&quot;i&quot;:0}}]}" about="#mwt5"></span></p>
1679 !! wikitext
1680 {{echo|a [ b}}
1681 {{echo|<nowiki>a }} b</nowiki>}}
1682 {{echo|<nowiki>a [[ b</nowiki>}}
1683 {{echo|<nowiki>a | {{ ]]</nowiki>}}
1684 {{echo|a <nowiki>}</nowiki>}}
1685 !! end
1686
1687 !! test
1688 Cases where "!!" needs nowiki protection
1689 !! options
1690 parsoid=html2wt
1691 !! html/parsoid
1692 <table>
1693 <tr><th>this needs protection !! here</th></tr>
1694 </table>
1695
1696 <table>
1697 <tr><th>this does not need
1698 protection !! here</th></tr>
1699 </table>
1700 !! wikitext
1701 {|
1702 !<nowiki>this needs protection !! here</nowiki>
1703 |}
1704
1705 {|
1706 !this does not need
1707 protection !! here
1708 |}
1709 !! end
1710
1711 ###
1712 ### Comments
1713 ###
1714 !! test
1715 Comments and Indent-Pre
1716 !! wikitext
1717 <!-- comment 1 --> asdf
1718
1719 <!-- comment 1 --> asdf
1720 <!-- comment 2 -->
1721
1722 <!-- comment 1 --> asdf
1723 <!-- comment 2 -->xyz
1724
1725 <!-- comment 1 --> asdf
1726 <!-- comment 2 --> xyz
1727 !! html
1728 <pre>asdf
1729 </pre>
1730 <pre>asdf
1731 </pre>
1732 <pre>asdf
1733 </pre>
1734 <p>xyz
1735 </p>
1736 <pre>asdf
1737 xyz
1738 </pre>
1739 !! end
1740
1741 !! test
1742 Comment test 2a
1743 !! wikitext
1744 asdf
1745 <!-- comment 1 -->
1746 jkl
1747 !! html
1748 <p>asdf
1749 jkl
1750 </p>
1751 !! end
1752
1753 !! test
1754 Comment test 2b
1755 !! wikitext
1756 asdf
1757 <!-- comment 1 -->
1758
1759 jkl
1760 !! html
1761 <p>asdf
1762 </p><p>jkl
1763 </p>
1764 !! end
1765
1766 !! test
1767 Comment test 3
1768 !! wikitext
1769 asdf
1770 <!-- comment 1 -->
1771 <!-- comment 2 -->
1772 jkl
1773 !! html
1774 <p>asdf
1775 jkl
1776 </p>
1777 !! end
1778
1779 !! test
1780 Comment test 4
1781 !! wikitext
1782 asdf<!-- comment 1 -->jkl
1783 !! html
1784 <p>asdfjkl
1785 </p>
1786 !! end
1787
1788 !! test
1789 Comment spacing
1790 !! wikitext
1791 a
1792 <!-- foo --> b <!-- bar -->
1793 c
1794 !! html
1795 <p>a
1796 </p>
1797 <pre> b
1798 </pre>
1799 <p>c
1800 </p>
1801 !! end
1802
1803 !! test
1804 Comment whitespace
1805 !! wikitext
1806 <!-- returns a single newline, not nothing, since the newline after > is not stripped -->
1807 !! html
1808
1809 !! end
1810
1811 !! test
1812 Comment semantics and delimiters
1813 !! wikitext
1814 <!-- --><!----><!-----><!------>
1815 !! html/php
1816
1817 !! html/parsoid
1818 <!-- --><!----><!--&#x2D;--><!--&#x2D;&#x2D;-->
1819 !! end
1820
1821 !! test
1822 Comment semantics and delimiters, redux
1823 !! wikitext
1824 <!-- In SGML every "foo" here would actually show up in the text -- foo -- bar
1825 -- foo -- funky huh? ... -->
1826 !! html/php
1827
1828 !! html/parsoid
1829 <!-- In SGML every "foo" here would actually show up in the text &#x2D;&#x2D; foo &#x2D;&#x2D; bar
1830 &#x2D;&#x2D; foo &#x2D;&#x2D; funky huh? ... -->
1831 !! end
1832
1833 !! test
1834 Comment semantics and delimiters: directors cut
1835 !! wikitext
1836 <!-- ... However we like to keep things simple and somewhat XML-ish so we eat
1837 everything starting with < followed by !-- until the first -- and > we see,
1838 that wouldn't be valid XML however, since in XML -- has to terminate a comment
1839 -->-->
1840 !! html/php
1841 <p>--&gt;
1842 </p>
1843 !! html/parsoid
1844 <!-- ... However we like to keep things simple and somewhat XML&#x2D;ish so we eat
1845 everything starting with < followed by !&#x2D;&#x2D; until the first &#x2D;&#x2D; and &#x3E; we see,
1846 that wouldn't be valid XML however, since in XML &#x2D;&#x2D; has to terminate a comment
1847 --><p>--></p>
1848 !! end
1849
1850 !! test
1851 Comment semantics: nesting
1852 !! wikitext
1853 <!--<!-- no, we're not going to do anything fancy here -->-->
1854 !! html/php
1855 <p>--&gt;
1856 </p>
1857 !! html/parsoid
1858 <!--<!&#x2D;&#x2D; no, we're not going to do anything fancy here --><p>--></p>
1859 !! end
1860
1861 # Parsoid closes the unclosed comment, even if it means a slight
1862 # round-trip diff.
1863 !! test
1864 Comment semantics: unclosed comment at end
1865 !! options
1866 parsoid=wt2html,html2html
1867 !! wikitext
1868 <!--This comment will run out to the end of the document
1869 !! html/php
1870
1871 !! html/parsoid
1872 <!--This comment will run out to the end of the document-->
1873 !! end
1874
1875 !! test
1876 Comment semantics: normalize comments to play nice with XML and browsers
1877 !! wikitext
1878 <!-- Browsers --!> think this is closed -->
1879 <!--> This would normally be text -->
1880 <!---> As would this -->
1881 <!-- XML doesn't like trailing dashes -------->
1882 <!-- Nor doubled hyphens -- anywhere in the data -->
1883 But this is not a comment.
1884 !! html/php
1885 <p>But this is not a comment.
1886 </p>
1887 !! html/parsoid
1888 <!-- Browsers &#x2D;&#x2D;!&#x3E; think this is closed -->
1889 <!--&#x3E; This would normally be text -->
1890 <!--&#x2D;&#x3E; As would this -->
1891 <!-- XML doesn't like trailing dashes &#x2D;&#x2D;&#x2D;&#x2D;&#x2D;&#x2D;-->
1892 <!-- Nor doubled hyphens &#x2D;&#x2D; anywhere in the data -->
1893 <p>But this is not a comment.</p>
1894 !! end
1895
1896 !! test
1897 Comment semantics: round-trip even text which contains encoded -->
1898 !! wikitext
1899 <!-- hello & goodbye - > --&gt; --&amp;gt; --&xx -->
1900 !! html/parsoid
1901 <!-- hello &#x26; goodbye &#x2D; &#x3E; &#x2D;&#x2D;&#x3E; &#x2D;&#x2D;&#x26;gt; &#x2D;&#x2D;&#x26;xx -->
1902 !! end
1903
1904 !! test
1905 Comment in template title
1906 !! wikitext
1907 {{f<!---->oo}}
1908 !! html
1909 <p>FOO
1910 </p>
1911 !! end
1912
1913 !! test
1914 Comment on its own line post-expand
1915 !! wikitext
1916 a
1917 {{blank}}<!---->
1918 b
1919 !! html
1920 <p>a
1921 </p><p>b
1922 </p>
1923 !! end
1924
1925 !! test
1926 Comment on its own line post-expand with non-significant whitespace
1927 !! wikitext
1928 a
1929 {{blank}} <!---->
1930 b
1931 !! html
1932 <p>a
1933 </p><p>b
1934 </p>
1935 !! end
1936
1937 !! test
1938 post-expand include size being exceeded
1939 !! options
1940 maxincludesize=20
1941 !! wikitext
1942 {{echo3|1234567890}}
1943 !! html
1944 <p><a href="/wiki/Template:Echo3" title="Template:Echo3">Template:Echo3</a><!-- WARNING: template omitted, post-expand include size too large -->
1945 </p>
1946 !! end
1947
1948 !! test
1949 max template depth being reached
1950 !! options
1951 maxtemplatedepth=1
1952 !! wikitext
1953 {{echo with depth|too deep!}}
1954 !! html
1955 <p><span class="error">Template recursion depth limit exceeded (1)</span>
1956 </p>
1957 !! end
1958
1959 !! test
1960 multiple templates that are redirects
1961 !! wikitext
1962 {{redirect to foo}}
1963 {{redirect to foo}}
1964 !! html
1965 <p>FOO
1966 FOO
1967 </p>
1968 !! end
1969
1970 !! test
1971 Multiple comments should still parse as SOL-transparent
1972 !! options
1973 parsoid=wt2html,wt2wt
1974 !! wikitext
1975 <!--c1-->*a
1976 <!--c2--><!--c3--><!--c4-->*b
1977 !! html/php
1978 <ul><li>a</li>
1979 <li>b</li></ul>
1980 !! html/parsoid
1981 <!--c1--><ul>
1982 <li>a
1983 </li>
1984 <!--c2--><!--c3--><!--c4-->
1985 <li>b
1986 </li>
1987 </ul>
1988 !! end
1989
1990 ## Make sure ">" gets escaped in comments to avoid XSS
1991 !! test
1992 IE conditional comments
1993 !! wikitext
1994 <!--[if lt IE 9]>
1995 <script>alert('hi');</script>
1996 <![endif]-->
1997 !! html/parsoid
1998 <!--[if lt IE 9]&#x3E;
1999 <script&#x3E;alert('hi');</script&#x3E;
2000 <![endif]-->
2001 !! end
2002
2003 ###
2004 ### paragraph wrapping tests
2005 ###
2006
2007 !! test
2008 No block tags
2009 !! wikitext
2010 a
2011
2012 b
2013 !! html
2014 <p>a
2015 </p><p>b
2016 </p>
2017 !! end
2018
2019 !! test
2020 Block tag on one line (<div>)
2021 !! wikitext
2022 a <div>foo</div>
2023
2024 b
2025 !! html
2026 a <div>foo</div>
2027 <p>b
2028 </p>
2029 !! html+tidy
2030 <p>a </p><div>foo</div>
2031 <p>b
2032 </p>
2033 !! end
2034
2035 !! test
2036 No p-wrappable content
2037 !! options
2038 parsoid=wt2html,html2html
2039 !! wikitext
2040 <span><div>x</div></span>
2041 <span><s><div>x</div></s></span>
2042 <small><em></em></small><span><s><div>x</div></s></span>
2043 !! html+tidy
2044 <span><div>x</div></span>
2045 <span><s><div>x</div></s></span>
2046 <p><small><em></em></small></p><span><s><div>x</div></s></span>
2047 !! end
2048
2049 # T177612: Parsoid-only test
2050 !! test
2051 Transclusion meta tags shouldn't trip Parsoid's useless p-wrapper stripping code
2052 !! wikitext
2053 {{echo|<span><div>x</div></span>}}
2054 x
2055 !! html/parsoid
2056 <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>
2057 <p>x</p>
2058 !! end
2059
2060 !! test
2061 Block tag on one line (<blockquote>)
2062 !! wikitext
2063 a <blockquote>foo</blockquote>
2064
2065 b
2066 !! html
2067 a <blockquote>foo</blockquote>
2068 <p>b
2069 </p>
2070 !! html+tidy
2071 <p>a </p><blockquote><p>foo</p></blockquote>
2072 <p>b
2073 </p>
2074 !! end
2075
2076 !! test
2077 Block tag on both lines (<div>)
2078 !! wikitext
2079 a <div>foo</div>
2080
2081 b <div>foo</div>
2082 !! html
2083 a <div>foo</div>
2084 b <div>foo</div>
2085
2086 !! html+tidy
2087 <p>a </p><div>foo</div><p>
2088 b </p><div>foo</div>
2089 !! end
2090
2091 !! test
2092 Block tag on both lines (<blockquote>)
2093 !! wikitext
2094 a <blockquote>foo</blockquote>
2095
2096 b <blockquote>foo</blockquote>
2097 !! html
2098 a <blockquote>foo</blockquote>
2099 b <blockquote>foo</blockquote>
2100
2101 !! html+tidy
2102 <p>a </p><blockquote><p>foo</p></blockquote><p>
2103 b </p><blockquote><p>foo</p></blockquote>
2104 !! end
2105
2106 !! test
2107 Multiple lines without block tags
2108 !! wikitext
2109 <div>foo</div> a
2110 b
2111 c
2112 d<!--foo--> e
2113 x <div>foo</div> z
2114 !! html
2115 <div>foo</div> a
2116 <p>b
2117 c
2118 d e
2119 </p>
2120 x <div>foo</div> z
2121
2122 !! html+tidy
2123 <div>foo</div><p> a
2124 </p><p>b
2125 c
2126 d e
2127 </p><p>
2128 x </p><div>foo</div><p> z
2129 </p>
2130 !! end
2131
2132 !! test
2133 Empty lines between lines with block tags
2134 !! wikitext
2135 <div></div>
2136
2137
2138 <div></div>a
2139
2140 b
2141 <div>a</div>b
2142
2143 <div>b</div>d
2144
2145
2146 <div>e</div>
2147 !! html
2148 <div></div>
2149 <p><br />
2150 </p>
2151 <div></div>a
2152 <p>b
2153 </p>
2154 <div>a</div>b
2155 <div>b</div>d
2156 <p><br />
2157 </p>
2158 <div>e</div>
2159
2160 !! html+tidy
2161 <div></div>
2162 <p><br />
2163 </p>
2164 <div></div><p>a
2165 </p><p>b
2166 </p>
2167 <div>a</div><p>b
2168 </p><div>b</div><p>d
2169 </p><p><br />
2170 </p>
2171 <div>e</div>
2172 !! html/parsoid
2173 <div data-parsoid='{"stx":"html"}'></div>
2174
2175 <p><br /></p>
2176 <div data-parsoid='{"stx":"html"}'></div><p>a</p>
2177
2178 <p>b</p>
2179 <div data-parsoid='{"stx":"html"}'>a</div><p>b</p>
2180
2181 <div data-parsoid='{"stx":"html"}'>b</div><p>d</p>
2182
2183 <p><br /></p>
2184 <div data-parsoid='{"stx":"html"}'>e</div>
2185 !! end
2186
2187 !! test
2188 Unclosed HTML p-tags should be handled properly
2189 !! wikitext
2190 <div><p>foo</div>
2191 a
2192
2193 b
2194 !! html/php+tidy
2195 <div><p>foo</p></div>
2196 <p>a
2197 </p><p>b
2198 </p>
2199 !! html/parsoid
2200 <div data-parsoid='{"stx":"html"}'><p data-parsoid='{"stx":"html", "autoInsertedEnd":true}'>foo</p></div>
2201 <p>a</p>
2202 <p>b</p>
2203 !! end
2204
2205 ## SSS FIXME: I can come up with other scenarios where this doesn't work because
2206 ## of eager output of buffered tokens in the p-wrapper. But, I'm going to ignore
2207 ## them for now.
2208 !! test
2209 1. P-wrapping should leave sol-transparent tags outside p-tags where possible
2210 !! options
2211 parsoid=wt2html
2212 !! wikitext
2213 a [[Category:A1]] [[Category:A2]]
2214 [[Category:A3]]
2215 [[Category:A4]]
2216 !! html/parsoid
2217 <p>a</p>
2218 <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"/>
2219 !! end
2220
2221 !! test
2222 2. P-wrapping should leave sol-transparent tags outside p-tags where possible
2223 !! options
2224 parsoid=wt2html
2225 !! wikitext
2226 [[Category:A1]]a
2227 !! html/parsoid
2228 <link rel="mw:PageProp/Category" href="./Category:A1"/><p>a</p>
2229 !! end
2230
2231 !! test
2232 No paragraph necessary for SOL transparent template
2233 !! wikitext
2234 <span><div>foo</div></span>
2235 [[Category:Foo]]
2236
2237 <span><div>foo</div></span>
2238 {{echo|[[Category:Foo]]}}
2239 !! html/php
2240 <span><div>foo</div></span>
2241 <span><div>foo</div></span>
2242
2243 !! html/parsoid
2244 <span data-parsoid='{"stx":"html"}'><div data-parsoid='{"stx":"html"}'>foo</div></span>
2245 <link rel="mw:PageProp/Category" href="./Category:Foo"/>
2246
2247 <span data-parsoid='{"stx":"html"}'><div data-parsoid='{"stx":"html"}'>foo</div></span>
2248 <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}}]}'/>
2249 !! end
2250
2251 !! test
2252 Avoid expanding multiline sol transparent template ranges unnecessarily
2253 !! wikitext
2254 hi
2255
2256
2257 {{echo|<br/>
2258 }}
2259
2260 [[Category:Ho]]
2261 !! html/php
2262 <p>hi
2263 </p><p><br />
2264 <br />
2265 </p>
2266 !! html/parsoid
2267 <p>hi</p>
2268
2269 <p><br />
2270 <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">
2271 </span></p>
2272
2273 <link rel="mw:PageProp/Category" href="./Category:Ho" />
2274 !! end
2275
2276 !! test
2277 Paragraph wrapping following unclosed table
2278 !! options
2279 parsoid=wt2html,html2html
2280 !! wikitext
2281 {|
2282 |-
2283
2284 {|
2285 | x
2286 |}
2287
2288 a
2289
2290 b
2291
2292 c
2293 !! html/php+tidy
2294 <table>
2295
2296
2297 </table><table>
2298 <tbody><tr>
2299 <td>x
2300 </td></tr></tbody></table>
2301 <p>a
2302 </p><p>b
2303 </p><p>c
2304 </p>
2305 !! html/parsoid
2306 <table data-parsoid='{"autoInsertedEnd":true}'>
2307 <tbody><tr class="mw-empty-elt" data-parsoid='{"startTagSrc":"|-"}'></tr>
2308
2309 </tbody></table><table>
2310 <tbody><tr data-parsoid='{"autoInsertedStart":true}'><td>x</td></tr>
2311 </tbody></table>
2312
2313 <p>a</p>
2314
2315 <p>b</p>
2316
2317 <p>c</p>
2318 !! end
2319
2320 !! test
2321 Paragraph wrapping suppressed in html p
2322 !! options
2323 parsoid=wt2html,html2html
2324 !! wikitext
2325 <p>
2326
2327
2328 hi
2329
2330
2331
2332 </p>
2333 !! html/php+tidy
2334 <p>
2335
2336
2337 hi
2338
2339
2340
2341 </p>
2342 !! html/parsoid
2343 <p data-parsoid='{"stx":"html"}'>
2344
2345
2346 hi
2347
2348
2349
2350 </p>
2351 !! end
2352
2353 !! test
2354 Dangling table row doesn't prevent p-wrapping
2355 !! options
2356 parsoid=wt2html,html2html
2357 !! wikitext
2358 {|
2359 | hi
2360 |-
2361 |} ho
2362 !! html/parsoid
2363 <table>
2364 <tbody><tr><td>hi</td></tr>
2365 <tr class="mw-empty-elt"></tr>
2366 </tbody></table><p> ho</p>
2367 !! end
2368
2369 !! test
2370 P-wrapping non-breaking spaces
2371 !! wikitext
2372  
2373 !! html/php+tidy
2374 <p>&#160;
2375 </p>
2376 !! html/parsoid
2377 <p> </p>
2378 !! end
2379
2380 ###
2381 ### Preformatted text
2382 ###
2383
2384 !! test
2385 Preformatted text
2386 !! wikitext
2387 This is some
2388 Preformatted text
2389 With ''italic''
2390 And '''bold'''
2391 And a [[Main Page|link]]
2392 !! html
2393 <pre>This is some
2394 Preformatted text
2395 With <i>italic</i>
2396 And <b>bold</b>
2397 And a <a href="/wiki/Main_Page" title="Main Page">link</a>
2398 </pre>
2399 !! end
2400
2401 !! test
2402 Tabs don't trigger preformatted text
2403 !! wikitext
2404 This is not
2405 preformatted text.
2406 This is preformatted text.
2407 So is this.
2408 !! html/php
2409 <p> This is not
2410 preformatted text.
2411 </p>
2412 <pre>This is preformatted text.
2413 So is this.
2414 </pre>
2415 !! html/parsoid
2416 <p> This is not
2417 preformatted text.</p>
2418 <pre>This is preformatted text.
2419 So is this.</pre>
2420 !! end
2421
2422 !! test
2423 Space before tab needs nowiki pre protection
2424 !! options
2425 parsoid=html2wt
2426 !! html/parsoid
2427 <p> a</p>
2428 !! wikitext
2429 <nowiki> </nowiki> a
2430 !! end
2431
2432 !! test
2433 Ident preformatting with inline content
2434 !! wikitext
2435 a
2436 ''b''
2437 !! html
2438 <pre>a
2439 <i>b</i>
2440 </pre>
2441 !! end
2442
2443 !! test
2444 <pre> with <nowiki> inside (compatibility with 1.6 and earlier)
2445 !! wikitext
2446 <pre><nowiki>
2447 <b>
2448 <cite>
2449 <em>
2450 </nowiki></pre>
2451 !! html
2452 <pre>
2453 &lt;b&gt;
2454 &lt;cite&gt;
2455 &lt;em&gt;
2456 </pre>
2457
2458 !! end
2459
2460 !! test
2461 Regression with preformatted in <center>
2462 !! wikitext
2463 <center>
2464 Blah
2465 </center>
2466 !! html
2467 <center>
2468 <pre>Blah
2469 </pre>
2470 </center>
2471
2472 !! end
2473
2474 !! test
2475 T54763: Preformatted in <blockquote>
2476 !! wikitext
2477 <blockquote>
2478 Blah
2479 {|
2480 |
2481 indented cell (no pre-wrapping!)
2482 |}
2483 </blockquote>
2484 !! html
2485 <blockquote>
2486 <p> Blah
2487 </p>
2488 <table>
2489 <tr>
2490 <td>
2491 <p> indented cell (no pre-wrapping!)
2492 </p>
2493 </td></tr></table>
2494 </blockquote>
2495
2496 !! end
2497
2498 !! test
2499 T53086: Double newlines in blockquotes should be turned into paragraphs
2500 !! wikitext
2501 <blockquote>
2502 Foo
2503
2504 Bar
2505 </blockquote>
2506 !! html
2507 <blockquote>
2508 <p>Foo
2509 </p><p>Bar
2510 </p>
2511 </blockquote>
2512
2513 !! end
2514
2515 !! test
2516 T17491: <ins>/<del> in blockquote
2517 !! wikitext
2518 <blockquote>
2519 Foo <del>bar</del> <ins>baz</ins> quux
2520 </blockquote>
2521 !! html
2522 <blockquote>
2523 <p>Foo <del>bar</del> <ins>baz</ins> quux
2524 </p>
2525 </blockquote>
2526
2527 !! html+tidy
2528 <blockquote>
2529 <p>Foo <del>bar</del> <ins>baz</ins> quux
2530 </p>
2531 </blockquote>
2532 !! end
2533
2534 !! test
2535 T17491: <ins>/<del> in blockquote (2)
2536 !! wikitext
2537 <blockquote>Foo <del>bar</del> <ins>baz</ins> quux
2538 </blockquote>
2539 !! html
2540 <blockquote>Foo <del>bar</del> <ins>baz</ins> quux
2541 </blockquote>
2542
2543 !! html+tidy
2544 <blockquote><p>Foo <del>bar</del> <ins>baz</ins> quux
2545 </p></blockquote>
2546 !! end
2547
2548 !! test
2549 <pre> with attributes (T5202)
2550 !! wikitext
2551 <pre style="background: blue; color:white">Bluescreen of WikiDeath</pre>
2552 !! html
2553 <pre style="background: blue; color:white">Bluescreen of WikiDeath</pre>
2554
2555 !! end
2556
2557 !! test
2558 <pre> with width attribute (T5202)
2559 !! wikitext
2560 <pre width="8">Narrow screen goodies</pre>
2561 !! html
2562 <pre width="8">Narrow screen goodies</pre>
2563
2564 !! end
2565
2566 !! test
2567 <pre> with forbidden attribute (T5202)
2568 !! wikitext
2569 <pre width="8" onmouseover="alert(document.cookie)">Narrow screen goodies</pre>
2570 !! html
2571 <pre width="8">Narrow screen goodies</pre>
2572
2573 !! end
2574
2575 !! test
2576 Entities inside <pre>
2577 !! wikitext
2578 <pre>&lt;</pre>
2579 !! html
2580 <pre>&lt;</pre>
2581
2582 !! end
2583
2584 !! test
2585 <pre> with forbidden attribute values (T5202)
2586 !! wikitext
2587 <pre width="8" style="border-width: expression(alert(document.cookie))">Narrow screen goodies</pre>
2588 !! html
2589 <pre width="8" style="/* insecure input */">Narrow screen goodies</pre>
2590
2591 !! end
2592
2593 !! test
2594 <nowiki> inside <pre> (T15238)
2595 !! wikitext
2596 <pre>
2597 <nowiki>
2598 </pre>
2599 <pre>
2600 <nowiki></nowiki>
2601 </pre>
2602 <pre><nowiki><nowiki></nowiki>Foo<nowiki></nowiki></nowiki></pre>
2603 !! html
2604 <pre>
2605 &lt;nowiki&gt;
2606 </pre>
2607 <pre>
2608
2609 </pre>
2610 <pre>&lt;nowiki&gt;Foo&lt;/nowiki&gt;</pre>
2611
2612 !! end
2613
2614 !! test
2615 <nowiki> inside of #tag:pre
2616 !! wikitext
2617 {{#tag:pre|Foo <nowiki>&rarr;bar</nowiki>}}
2618 !! html/php
2619 <pre>Foo &#8594;bar</pre>
2620
2621 !! html/parsoid
2622 <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>
2623 !! end
2624
2625 ## Don't expect this to rt, Parsoid drops the unmatched closing pre tags that
2626 ## aren't enclosed in nowikis.
2627 !! test
2628 <nowiki> and <pre> preference (first one wins)
2629 !! options
2630 parsoid=wt2html
2631 !! wikitext
2632 <pre>
2633 <nowiki>
2634 </pre>
2635 </nowiki>
2636 </pre>
2637
2638 <nowiki>
2639 <pre>
2640 <nowiki>
2641 </pre>
2642 </nowiki>
2643 </pre>
2644
2645 !! html/php
2646 <pre>
2647 &lt;nowiki&gt;
2648 </pre>
2649 <p>&lt;/nowiki&gt;
2650 &lt;/pre&gt;
2651 </p><p>
2652 &lt;pre&gt;
2653 &lt;nowiki&gt;
2654 &lt;/pre&gt;
2655
2656 &lt;/pre&gt;
2657 </p>
2658 !! html/parsoid
2659 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n&lt;nowiki>\n"}}'>&lt;nowiki>
2660 </pre>
2661 <p>&lt;/nowiki></p>
2662
2663
2664 <p><span typeof="mw:Nowiki">
2665 &lt;pre>
2666 &lt;nowiki>
2667 &lt;/pre>
2668 </span></p>
2669 !! end
2670
2671 !! test
2672 </pre> inside nowiki
2673 !! wikitext
2674 <nowiki></pre></nowiki>
2675 !! html
2676 <p>&lt;/pre&gt;
2677 </p>
2678 !! end
2679
2680 !! test
2681 Empty pre; pre inside other HTML tags (T56946)
2682 !! wikitext
2683 a
2684
2685 <div><pre>
2686 foo
2687 </pre></div>
2688 <pre></pre>
2689 !! html/php+tidy
2690 <p>a
2691 </p>
2692 <div><pre>foo
2693 </pre></div>
2694 <pre></pre>
2695 !! html/parsoid
2696 <p>a</p>
2697
2698 <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
2699 </pre></div>
2700 <pre typeof="mw:Extension/pre" about="#mwt4" data-parsoid='{"stx":"html"}' data-mw='{"name":"pre","attrs":{},"body":{"extsrc":""}}'></pre>
2701 !! end
2702
2703 !! test
2704 HTML pre followed by indent-pre
2705 !! wikitext
2706 <pre>foo</pre>
2707 bar
2708 !! html
2709 <pre>foo</pre>
2710 <pre>bar
2711 </pre>
2712 !! end
2713
2714 !! test
2715 Block tag pre
2716 !! wikitext
2717 <p><pre>foo</pre></p>
2718 !! html/php+tidy
2719 <p class="mw-empty-elt"></p><pre>foo</pre><p class="mw-empty-elt"></p>
2720 !! html/parsoid
2721 <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>
2722 !! end
2723
2724 !!test
2725 Templates: Indent-Pre: 1a. Templates that break a line should suppress <pre>
2726 !! wikitext
2727 {{echo|}}
2728 !! html
2729
2730 !!end
2731
2732 !!test
2733 Templates: Indent-Pre: 1b. Templates that break a line should suppress <pre>
2734 !! wikitext
2735 {{echo|
2736 foo}}
2737 !! html
2738 <p>foo
2739 </p>
2740 !!end
2741
2742 !! test
2743 Templates: Indent-Pre: 1c: Wrapping should be based on expanded content
2744 !! wikitext
2745 {{echo|a
2746 b}}
2747 !! html
2748 <pre>a
2749 </pre>
2750 <p>b
2751 </p>
2752 !!end
2753
2754 !! test
2755 Templates: Indent-Pre: 1d: Wrapping should be based on expanded content
2756 !! wikitext
2757 {{echo|a
2758 b
2759 c
2760 d
2761 e
2762 }}
2763 !! html
2764 <pre>a
2765 </pre>
2766 <p>b
2767 c
2768 </p>
2769 <pre>d
2770 </pre>
2771 <p>e
2772 </p>
2773 !!end
2774
2775 !!test
2776 Templates: Indent-Pre: 1e. Wrapping should be based on expanded content
2777 !! wikitext
2778 {{echo| foo}}
2779
2780 {{echo| foo}}{{echo| bar}}
2781
2782 {{echo| foo}}
2783 {{echo| bar}}
2784
2785 {{echo|<!--cmt--> foo}}
2786
2787 <!--cmt-->{{echo| foo}}
2788
2789 {{echo|{{echo| }}bar}}
2790 !! html
2791 <pre>foo
2792 </pre>
2793 <pre>foo bar
2794 </pre>
2795 <pre>foo
2796 bar
2797 </pre>
2798 <pre>foo
2799 </pre>
2800 <pre>foo
2801 </pre>
2802 <pre>bar
2803 </pre>
2804 !!end
2805
2806 !! test
2807 Templates: Indent-Pre: 1f: Wrapping should be based on expanded content
2808 !! wikitext
2809 {{echo| }}a
2810
2811 {{echo|
2812 }}a
2813
2814 {{echo|
2815 b}}
2816
2817 {{echo|a
2818 }}b
2819
2820 {{echo|a
2821 }} b
2822 !! html
2823 <pre>a
2824 </pre>
2825 <p><br />
2826 </p>
2827 <pre>a
2828 </pre>
2829 <p><br />
2830 </p>
2831 <pre>b
2832 </pre>
2833 <p>a
2834 </p>
2835 <pre>b
2836 </pre>
2837 <p>a
2838 </p>
2839 <pre>b
2840 </pre>
2841 !!end
2842
2843 ## Hmm, should Parsoid rt this?
2844 !! test
2845 Pres with newline attributes
2846 !! options
2847 parsoid=wt2html,html2html
2848 !! wikitext
2849 <pre class="one
2850 two">hi</pre>
2851 !! html/php
2852 <pre class="one two">hi</pre>
2853
2854 !! html/parsoid
2855 <pre class="one two" typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{"class":"one two"},"body":{"extsrc":"hi"}}'>hi</pre>
2856 !! end
2857
2858 !! test
2859 Things that look like <pre> tags aren't treated as such
2860 !! wikitext
2861 Barack Obama <President> of the United States
2862 <President></President>
2863 !! html
2864 <p>Barack Obama &lt;President&gt; of the United States
2865 &lt;President&gt;&lt;/President&gt;
2866 </p>
2867 !! end
2868
2869 ## Remex doesn't account for fostered content.
2870 ## The difference between Parsoid and the PHP parser can be attributed to core
2871 ## commit 674e8388cba and 710618f89af in Parsoid's repo. Parsoid doesn't
2872 ## tokenize unmatched extension tags that shadow html tags as strings to ease
2873 ## an escaping mechanism. See the comment in `maybeExtensionTag`.
2874 !! test
2875 Handle broken pre-like tags (T66025)
2876 !! options
2877 parsoid=wt2html
2878 !! wikitext
2879 {{echo|<pre <pre>x</pre>}}
2880
2881 <table><pre </table>
2882 !! html/php
2883 <pre>x</pre>
2884 <table>&lt;pre </table>
2885
2886 !! html/php+tidy
2887 <pre>x</pre>
2888 &lt;pre <table></table>
2889 !! html/parsoid
2890 <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>
2891
2892 <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>
2893 !! end
2894
2895 ## Similar to the above, but shows the difference between extension and html tags
2896 !! test
2897 Less than in attribute position
2898 !! wikitext
2899 <pre <pre>123</pre>
2900
2901 <div <div>123</div>
2902 !! html/php+tidy
2903 <pre>123</pre><p>
2904 &lt;div </p><div>123</div>
2905 !! html/parsoid
2906 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{"&lt;pre":""},"body":{"extsrc":"123"}}'>123</pre><p>
2907
2908 &lt;div </p><div>123</div>
2909 !! end
2910
2911 !! test
2912 Parsoid: handle pre with space after attribute
2913 !! options
2914 parsoid=wt2html
2915 !! wikitext
2916 <pre style="width:50%;" >{{echo|foo}}</pre>
2917 !! html/php
2918 <pre style="width:50%;">{{echo|foo}}</pre>
2919
2920 !! html/parsoid
2921 <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>
2922 !! end
2923
2924 !! test
2925 Self-closed pre
2926 !! wikitext
2927 <pre />
2928 !! html/php
2929 <pre></pre>
2930
2931 !! html/parsoid
2932 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{}}'></pre>
2933 !! end
2934
2935 !! test
2936 Newline before table-close generates empty table row: T208619
2937 !! wikitext
2938 {|
2939
2940 |}
2941 !! html/php+tidy
2942 <table>
2943
2944 <tbody><tr><td></td></tr></tbody></table>
2945 !! html/parsoid
2946 <table data-parsoid='{}'>
2947
2948 </table>
2949 !! end
2950
2951 # PHP has one more row in the output than Parsoid does: T208619
2952 !! test
2953 Parsoid: Don't paragraph-wrap fosterable content even if table syntax is unbalanced
2954 !! options
2955 parsoid=wt2html
2956 !! wikitext
2957 {|
2958 <td>
2959 <td>
2960 </td>
2961
2962
2963
2964 |}
2965 !! html/php+tidy
2966 <table>
2967 <tbody><tr><td>
2968 </td><td>
2969 </td>
2970
2971
2972
2973 </tr><tr><td></td></tr></tbody></table>
2974 !! html/parsoid
2975 <table>
2976
2977 <tbody>
2978 <tr>
2979 <td></td>
2980
2981 <td>
2982 </td></tr>
2983
2984
2985
2986 </tbody></table>
2987 !! end
2988
2989
2990 #--------------------------------------------------------------------
2991 # Transclusion parameter whitespace stripping tests
2992 # Behavior is different for positional and named parameters
2993 #--------------------------------------------------------------------
2994 !! test
2995 Templates: Strip leading and trailing whitespace from named-param values
2996 !! wikitext
2997 {{echo|1= a }}
2998
2999 {{echo|1= {{echo|b}} }}
3000
3001 {{echo| 1 =
3002 c }}
3003
3004 {{echo| 1 =
3005 * d
3006 }}
3007 !! html
3008 <p>a
3009 </p><p>b
3010 </p><p>c
3011 </p>
3012 <ul><li>d</li></ul>
3013 !! end
3014
3015 !! test
3016 Templates: Don't strip whitespace from positional-param values
3017 !! wikitext
3018 {{echo|a }}
3019
3020 {{echo|{{echo|b}} }}
3021
3022 {{echo| c
3023 }}
3024
3025 {{echo| {{echo|d}}
3026 }}
3027
3028 {{echo|
3029 e}}
3030
3031 {{echo|
3032 *f}}
3033
3034 {{echo|
3035 }}g
3036 !! html
3037 <p>a
3038 </p><p>b
3039 </p>
3040 <pre>c
3041 </pre>
3042 <p><br />
3043 </p>
3044 <pre>d
3045 </pre>
3046 <p><br />
3047 </p>
3048 <pre>e
3049 </pre>
3050 <p><br />
3051 </p>
3052 <ul><li>f</li></ul>
3053 <p><br />
3054 </p>
3055 <pre>g
3056 </pre>
3057 !! end
3058
3059 !! test
3060 Templates: Don't recognize targets split by newlines
3061 !! options
3062 parsoid=wt2html
3063 !! wikitext
3064 {{ech
3065 o|foo}}
3066 !! html/php
3067 <p>{{ech
3068 o|foo}}
3069 </p>
3070 !! html/parsoid
3071 <p>{{ech
3072 o|foo}}</p>
3073 !! end
3074
3075 !! test
3076 Templates: Recognize targets when newlines and comments don't split the target
3077 !! options
3078 parsoid=wt2html
3079 !! wikitext
3080 {{
3081 <!--X--> ech<!--X-->o<!--X-->
3082 <!--X--> <!--X-->
3083
3084 |foo}}
3085 !! html/php
3086 <p>foo
3087 </p>
3088 !! html/parsoid
3089 <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>
3090 !! end
3091
3092 !! test
3093 Templates: Handle empty comment-and-ws-only lines correctly
3094 !! wikitext
3095 {{echo|foo
3096 <!--should be ignored-->
3097 <!--should be ignored as well-->
3098 bar}}
3099 !! html/php
3100 <p>foo
3101 bar
3102 </p>
3103 !! html/parsoid
3104 <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>
3105 !! end
3106
3107 !! test
3108 Templates: Handle comments in the target
3109 !! wikitext
3110 {{echo
3111 <!-- should be ignored -->
3112 |foo}}
3113
3114 {{echo
3115 <!-- should be ignored and spaces on next line should not trip us up (T147742) -->
3116 |foo}}
3117
3118 {{echo<!-- should be ignored -->
3119 |foo}}
3120
3121 {{echo<!-- should be ignored -->|foo}}
3122
3123 {{<!-- should be ignored -->echo|foo}}
3124 !! html/php
3125 <p>foo
3126 </p><p>foo
3127 </p><p>foo
3128 </p><p>foo
3129 </p><p>foo
3130 </p>
3131 !! html/parsoid
3132 <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>
3133
3134 <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>
3135
3136 <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>
3137
3138 <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>
3139
3140 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</p>
3141 !! end
3142
3143 !! test
3144 Templates: Handle comments in parameter names (T69657)
3145 !! wikitext
3146 {{echo|1
3147 <!-- should be ignored -->
3148 =foo}}
3149
3150 {{echo|
3151 <!-- should be ignored -->
3152 1 = foo}}
3153
3154 {{echo|1<!-- should be ignored -->=foo}}
3155
3156 {{echo|<!-- should be ignored -->1=foo}}
3157 !! html/php
3158 <p>foo
3159 </p><p>foo
3160 </p><p>foo
3161 </p><p>foo
3162 </p>
3163 !! html/parsoid
3164 <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>
3165
3166 <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>
3167
3168 <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>
3169
3170 <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>
3171 !! end
3172
3173 !! test
3174 Templates: Other wikitext in parameter names (T69657)
3175 !! wikitext
3176 {{echo|''1''=foo}}
3177 !! html/php
3178 <p>{{{1}}}
3179 </p>
3180 !! html/parsoid
3181 <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>
3182 !! end
3183
3184 !! test
3185 Templates: With colons
3186 !! wikitext
3187 {{With: Colon}}
3188 !! html/php
3189 <p>Template with colon
3190 </p>
3191 !! html/parsoid
3192 <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>
3193 !! end
3194
3195 #--------------------------------------------------------------------
3196 # Transclusion parameter escaping tests
3197 #--------------------------------------------------------------------
3198
3199 !! test
3200 Templates: Parsoid parameter escaping test 1
3201 !! wikitext
3202 {{echo|[foo]|{{echo|[bar]}}}}
3203 !! html/php+tidy
3204 <p>[foo]
3205 </p>
3206 !! html/parsoid
3207 <p about="#mwt1" typeof="mw:Transclusion"
3208 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[foo]"},"2":{"wt":"{{echo|[bar]}}"}},"i":0}}]}'>[foo]</p>
3209 !! end
3210
3211 !! test
3212 Parsoid: Pipes in external links in template parameter
3213 !! wikitext
3214 {{echo|[{{echo|http://example.com}} link]}}
3215 !! html/php+tidy
3216 <p><a rel="nofollow" class="external text" href="http://example.com">link</a>
3217 </p>
3218 !! html/parsoid
3219 <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>
3220 !! end
3221
3222 !! test
3223 Parsoid: pipe in transclusion parameter
3224 !! wikitext
3225 {{echo|http://foo.com/a&#124;b}}
3226 !! html/php+tidy
3227 <p><a rel="nofollow" class="external free" href="http://foo.com/a%7Cb">http://foo.com/a%7Cb</a>
3228 </p>
3229 !! html/parsoid
3230 <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>
3231 !! end
3232
3233 !! test
3234 Parsoid: Pipe in external link target and content in template parameter
3235 !! options
3236 parsoid=html2wt,wt2wt
3237 !! wikitext
3238 {{echo|[http://foo.com/a&#124;b a&#124;b]}}
3239 !! html/php+tidy
3240 <p><a rel="nofollow" class="external text" href="http://foo.com/a%7Cb">a&#124;b</a>
3241 </p>
3242 !! html/parsoid
3243 <p><a rel="mw:ExtLink" href="http://foo.com/a|b" about="#mwt1"
3244 typeof="mw:Transclusion"
3245 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},
3246 "params":{"1":{"wt":"[http://foo.com/a|b a|b]"}},"i":0}}]}'>a|b</a></p>
3247 !! end
3248
3249 !! test
3250 Parsoid: Pipe in template with nested template in external link target in template parameter (seriously)
3251 !! wikitext
3252 {{echo|[{{fullurl:{{FULLPAGENAME}}|action=edit}} bar]}}
3253 !! html/php+tidy
3254 <p><a rel="nofollow" class="external text" href="http://example.org/index.php?title=Parser_test&amp;action=edit">bar</a>
3255 </p>
3256 !! html/parsoid
3257 <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>
3258 !! end
3259
3260 !! test
3261 Templates: Don't escape already nowiki-escaped text in template parameters
3262 !! options
3263 parsoid=html2wt,wt2wt
3264 !! wikitext
3265 {{echo|foo<nowiki>|</nowiki>bar}}
3266 {{echo|<nowiki>&lt;div&gt;</nowiki>}}
3267 {{echo|<nowiki></nowiki>}}
3268 !! html/php+tidy
3269 <p>foo|bar
3270 &lt;div&gt;
3271
3272 </p>
3273 !! html/parsoid
3274 <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>
3275 <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>
3276 <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>
3277 </p>
3278 !! end
3279
3280 ## T54824
3281 !! test
3282 Templates: '=' char in nested transclusions should not trigger nowiki escapes or conversion to named param
3283 !! options
3284 parsoid=html2wt,wt2wt
3285 !! wikitext
3286 {{echo|{{echo|1=bar}}}}
3287 !! html/php+tidy
3288 <p>bar
3289 </p>
3290 !! html/parsoid
3291 <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>
3292 !! end
3293
3294 ## T58733
3295 !! test
3296 Templates parameters with special tokenizing behavior dont get modified because of arg escaping
3297 !! wikitext
3298 {{echo|a : b}}
3299 !! html/php+tidy
3300 <p>a&#160;: b
3301 </p>
3302 !! html/parsoid
3303 <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>
3304 !! end
3305
3306 ## T73412
3307 !! test
3308 Templates: Preserve blank parameter names
3309 !! wikitext
3310 {{echo|=foo}}
3311 !! html/php+tidy
3312 <p>{{{1}}}
3313 </p>
3314 !! html/parsoid
3315 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"":{"wt":"foo"}},"i":0}}]}'>{{{1}}}</p>
3316 !! end
3317
3318 !! test
3319 Templates: Preserve blank parameter names in other positions
3320 !! wikitext
3321 {{blank_param|bar|=foo}}
3322 !! html/php+tidy
3323 <p>bar
3324 foo
3325 </p>
3326 !! html/parsoid
3327 <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
3328 foo</p>
3329 !! end
3330
3331 ###
3332 ### Parsoid-centric tests for testing RT edge cases for pre
3333 ###
3334
3335 !!test
3336 1a. Indent-Pre and Comments
3337 !! wikitext
3338 a
3339 <!--a-->
3340 c
3341 !! html
3342 <pre>a
3343 </pre>
3344 <p>c
3345 </p>
3346 !!end
3347
3348 !!test
3349 1b. Indent-Pre and Comments
3350 !! wikitext
3351 a
3352 <!--a-->
3353 c
3354 !! html
3355 <pre>a
3356 </pre>
3357 <p>c
3358 </p>
3359 !!end
3360
3361 !!test
3362 1c. Indent-Pre and Comments
3363 !! wikitext
3364 <!--a--> a
3365
3366 <!--a--> a
3367 !! html
3368 <pre> a
3369 </pre>
3370 <pre> a
3371 </pre>
3372 !!end
3373
3374 !!test
3375 1d. Indent-Pre and Comments
3376 (Pre-handler currently cannot distinguish between comment/ws order and normalizes them to [comment,ws] order)
3377 !! wikitext
3378 <!--a--> a
3379
3380 <!--b-->b
3381 !! html
3382 <pre>a
3383 </pre>
3384 <pre>b
3385 </pre>
3386 !!end
3387
3388 !!test
3389 2a. Indent-Pre and tables
3390 !! wikitext
3391 {|
3392 |-
3393 !h1!!h2
3394 |foo||bar
3395 |}
3396 !! html
3397 <table>
3398
3399 <tr>
3400 <th>h1</th>
3401 <th>h2
3402 </th>
3403 <td>foo</td>
3404 <td>bar
3405 </td></tr></table>
3406
3407 !!end
3408
3409 !!test
3410 2b. Indent-Pre and tables
3411 !! wikitext
3412 {|
3413 |-
3414 |foo
3415 |}
3416 !! html
3417 <table>
3418
3419 <tr>
3420 <td>foo
3421 </td></tr></table>
3422
3423 !!end
3424
3425 !!test
3426 2c. Indent-Pre and tables (T44252)
3427 !! wikitext
3428 {|
3429 |+foo
3430 ! |bar
3431 |}
3432 !! html
3433 <table>
3434 <caption>foo
3435 </caption>
3436 <tr>
3437 <th>bar
3438 </th></tr></table>
3439
3440 !!end
3441
3442 !!test
3443 2d. Indent-Pre and tables
3444 !! wikitext
3445 a
3446 {|
3447 |b
3448 |}
3449 !! html/php
3450 <pre>a
3451 </pre>
3452 <table>
3453 <tr>
3454 <td>b
3455 </td></tr></table>
3456
3457 !! html/parsoid
3458 <pre>a</pre>
3459 <table>
3460 <tbody><tr><td> b</td></tr>
3461 </tbody></table>
3462 !!end
3463
3464 !!test
3465 2e. Indent-Pre and table-line syntax
3466 !! wikitext
3467 a
3468 | b
3469 | c
3470 !! html/php
3471 <pre>a
3472 | b
3473 | c
3474 </pre>
3475 !!end
3476
3477 !!test
3478 2f. Indent-pre started by table-line syntax
3479 !! wikitext
3480 a
3481 | b
3482 | c
3483 !! html/php
3484 <p>a
3485 </p>
3486 <pre>| b
3487 | c
3488 </pre>
3489 !! html/parsoid
3490 <p>a</p>
3491 <pre>
3492 | b
3493 | c</pre>
3494 !!end
3495
3496 !! test
3497 2g. Indented table markup mixed with indented pre content (proposed in T8200)
3498 !! wikitext
3499 <table>
3500 <tr>
3501 <td>
3502 Text that should be rendered preformatted
3503 </td>
3504 </tr>
3505 </table>
3506 !! html
3507 <table>
3508 <tr>
3509 <td>
3510 <pre>Text that should be rendered preformatted
3511 </pre>
3512 </td>
3513 </tr>
3514 </table>
3515
3516 !! end
3517
3518 !! test
3519 2h. Indent pre in tables
3520 !! options
3521 parsoid=wt2html,html2html
3522 !! wikitext
3523 {|
3524 !
3525 foo
3526 !
3527 bar
3528 |-
3529 |
3530 baz
3531 {{!}}
3532 bam
3533 |}
3534 !! html/php
3535 <table>
3536 <tr>
3537 <th>
3538 <pre>foo
3539 </pre>
3540 </th>
3541 <th>
3542 <pre>bar
3543 </pre>
3544 </th></tr>
3545 <tr>
3546 <td>
3547 <pre>baz
3548 </pre>
3549 </td>
3550 <td>
3551 <pre>bam
3552 </pre>
3553 </td></tr></table>
3554
3555 !! html/parsoid
3556 <table>
3557 <tbody><tr><th>
3558 <pre>foo</pre>
3559 </th><th>
3560 <pre>bar</pre>
3561 </th></tr><tr>
3562 <td>
3563 <pre>baz</pre>
3564 </td><td data-parsoid='{"startTagSrc":"{{!}}"}'>
3565 <pre>bam</pre>
3566 </td></tr></tbody></table>
3567 !! end
3568
3569 !! test
3570 3a. Indent-Pre and block tags (single-line html)
3571 !! wikitext
3572 a <p> foo </p>
3573 b <div> foo </div>
3574 c <blockquote> foo </blockquote>
3575 <span> foo </span>
3576 !! html
3577 a <p> foo </p>
3578 b <div> foo </div>
3579 c <blockquote> foo </blockquote>
3580 <pre><span> foo </span>
3581 </pre>
3582 !! html/php+tidy
3583 <p> a </p><p> foo </p><p>
3584 b </p><div> foo </div><p>
3585 c </p><blockquote><p> foo </p></blockquote>
3586 <pre><span> foo </span>
3587 </pre>
3588 !! html/parsoid
3589 <p> a </p><p data-parsoid='{"stx":"html"}'> foo </p><p>
3590 b </p><div data-parsoid='{"stx":"html"}'> foo </div><p>
3591 c </p><blockquote data-parsoid='{"stx":"html"}'><p> foo </p></blockquote>
3592 <pre><span data-parsoid='{"stx":"html"}'> foo </span></pre>
3593 !! end
3594
3595 !! test
3596 3b. Indent-Pre and block tags (multi-line html)
3597 !! wikitext
3598 a <span>foo</span>
3599 <!-- comment --> b <div> foo </div>
3600 !! html/php
3601 <pre>a <span>foo</span>
3602 </pre>
3603 b <div> foo </div>
3604
3605 !! html/parsoid
3606 <pre>a <span data-parsoid='{"stx":"html"}'>foo</span></pre>
3607 <!-- comment --> <p>b </p><div data-parsoid='{"stx":"html"}'> foo </div>
3608 !! html/php+tidy
3609 <pre>a <span>foo</span>
3610 </pre><p>
3611 b </p><div> foo </div>
3612 !! end
3613
3614 !! test
3615 3c. Indent-Pre and block tags (pre-content on separate line)
3616 !! wikitext
3617 <p>
3618 foo
3619 </p>
3620
3621 <div>
3622 foo
3623 </div>
3624
3625 <center>
3626 foo
3627 </center>
3628
3629 <blockquote>
3630 foo
3631 </blockquote>
3632
3633 <blockquote>
3634 <pre>
3635 foo
3636 </pre>
3637 </blockquote>
3638
3639 <table><tr><td>
3640 foo
3641 </td></tr></table>
3642
3643 <ul><li>
3644 foo
3645 </li></ul>
3646
3647 !! html/php
3648 <p>
3649 foo
3650 </p>
3651 <div>
3652 <pre>foo
3653 </pre>
3654 </div>
3655 <center>
3656 <pre>foo
3657 </pre>
3658 </center>
3659 <blockquote>
3660 <p> foo
3661 </p>
3662 </blockquote>
3663 <blockquote>
3664 <pre>
3665 foo
3666 </pre>
3667 </blockquote>
3668 <table><tr><td>
3669 <pre>foo
3670 </pre>
3671 </td></tr></table>
3672 <ul><li>
3673 foo
3674 </li></ul>
3675
3676 !! html/parsoid
3677 <p data-parsoid='{"stx":"html"}'>
3678 foo
3679 </p>
3680
3681 <div>
3682 <pre>foo</pre>
3683 </div>
3684
3685 <center>
3686 <pre>foo</pre>
3687 </center>
3688
3689 <blockquote>
3690 <p> foo</p>
3691 </blockquote>
3692
3693 <blockquote>
3694 <pre typeof="mw:Extension/pre" about="#mwt3" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\nfoo\n"}}'>foo
3695 </pre>
3696 </blockquote>
3697
3698 <table data-parsoid='{"stx":"html"}'><tbody><tr data-parsoid='{"stx":"html"}'><td data-parsoid='{"stx":"html"}'>
3699 <pre>foo</pre>
3700 </td></tr></tbody></table>
3701
3702 <ul data-parsoid='{"stx":"html"}'><li data-parsoid='{"stx":"html"}'>
3703 foo
3704 </li></ul>
3705 !! end
3706
3707 !! test
3708 4. Indent-Pre and extension tags
3709 !! options
3710 parsoid=wt2html,html2html
3711 !! wikitext
3712 a <tag />
3713 !! html/php+tidy
3714 <p> a </p><pre>NULL
3715 array (
3716 )
3717 </pre>
3718 !! html/parsoid
3719 <p> a </p><pre typeof="mw:Extension/tag" about="#mwt2" data-mw='{"name":"tag","attrs":{}}'></pre>
3720 !! end
3721
3722 !! test
3723 5. Indent-Pre and html pre
3724 !! wikitext
3725 <pre class="123">hi</pre>
3726 !! html/php
3727 <pre class="123">hi</pre>
3728
3729 !! html/parsoid
3730 <pre class="123" typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{"class":"123"},"body":{"extsrc":"hi"}}'>hi</pre>
3731 !! end
3732
3733 !!test
3734 Render paragraphs when indent-pre is suppressed in blocklevels
3735 !! wikitext
3736 <blockquote>
3737 foo
3738
3739 bar
3740 </blockquote>
3741 !! html
3742 <blockquote>
3743 <p> foo
3744 </p><p> bar
3745 </p>
3746 </blockquote>
3747
3748 !!end
3749
3750 !!test
3751 4. Multiple spaces at start-of-line
3752 !! wikitext
3753 <p> foo </p>
3754 foo
3755 {|
3756 |foo
3757 |}
3758 !! html
3759 <p> foo </p>
3760 <pre> foo
3761 </pre>
3762 <table>
3763 <tr>
3764 <td>foo
3765 </td></tr></table>
3766
3767 !!end
3768
3769 ## NOTE: the leading white-space chars on empty line are significant
3770 !! test
3771 5a. White-space in indent-pre
3772 !! wikitext
3773 a<br />
3774
3775 b
3776 !! html
3777 <pre>a<br />
3778
3779 b
3780 </pre>
3781 !! end
3782
3783 ## NOTE: the leading white-space chars on empty line are significant
3784 !! test
3785 5b. White-space in indent-pre
3786 !! wikitext
3787 a
3788
3789 b
3790
3791
3792 c
3793 !! html
3794 <pre>a
3795
3796 b
3797
3798
3799 c
3800 </pre>
3801 !! end
3802
3803 !! test
3804 5c. White-space in indent-pre
3805 !! wikitext
3806 ''a''
3807 ''b''
3808 ''c''
3809 !! html
3810 <pre><i>a</i>
3811 <i>b</i>
3812 <i>c</i>
3813 </pre>
3814 !! end
3815
3816 !! test
3817 6. Pre-blocks should extend across lines with leading WS even when there is no wrappable content
3818 !! wikitext
3819 a
3820
3821 <!-- continue -->
3822 b
3823
3824 c
3825
3826 d
3827 !! html
3828 <pre>a
3829
3830 b
3831 </pre>
3832 <pre>c
3833
3834 </pre>
3835 <p>d
3836 </p>
3837 !! end
3838
3839 !! test
3840 7a. Indent-pre and category links
3841 !! options
3842 parsoid=wt2html,wt2wt
3843 !! wikitext
3844 [[Category:foo]] <!-- No pre-wrapping -->
3845 {{echo| [[Category:foo]]}} <!-- No pre-wrapping -->
3846 !! html/php+tidy
3847 !! html/parsoid
3848 <link rel="mw:PageProp/Category" href="./Category:Foo"> <!-- No pre&#x2D;wrapping -->
3849 <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 -->
3850 !! end
3851
3852 ## We used to, but no longer wt2wt this test since the default serializer
3853 ## will normalize all categories to serialize on their own line.
3854 ## This wikitext usage is going to be fairly uncommon in production and
3855 ## selser will take care of preserving formatting in those scenarios.
3856 !! test
3857 7b. Indent-pre and category links
3858 !! options
3859 parsoid=wt2html
3860 !! wikitext
3861 [[Category:foo]] a
3862 [[Category:foo]] {{echo|b}}
3863 !! html/parsoid
3864 <pre><link rel="mw:PageProp/Category" href="./Category:Foo"> a
3865 <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>
3866 !! end
3867
3868 !! test
3869 Indent-Pre: Newlines in comments shouldn't affect sol state
3870 !! wikitext
3871 a <!--
3872 foo
3873 --> b
3874 !! html/php+tidy
3875 <p>a b
3876 </p>
3877 !! html/parsoid
3878 <p>a <!--
3879 foo
3880 --> b</p>
3881 !! end
3882
3883 ###
3884 ### HTML-pre (some to spec PHP parser behavior and some Parsoid-RT-centric)
3885 ###
3886
3887 !!test
3888 HTML-pre: 1. embedded newlines
3889 !! wikitext
3890 <pre>foo</pre>
3891
3892 <pre>
3893 foo
3894 </pre>
3895
3896 <pre>
3897
3898 foo
3899 </pre>
3900
3901 <pre>
3902
3903
3904 foo
3905 </pre>
3906 !! html/php+tidy
3907 <pre>foo</pre>
3908 <pre>foo
3909 </pre>
3910 <pre>
3911
3912 foo
3913 </pre>
3914 <pre>
3915
3916
3917 foo
3918 </pre>
3919 !! html/parsoid
3920 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo"}}'>foo</pre>
3921
3922 <pre typeof="mw:Extension/pre" about="#mwt4" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\nfoo\n"}}'>foo
3923 </pre>
3924
3925 <pre typeof="mw:Extension/pre" about="#mwt6" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n\nfoo\n"}}'>
3926
3927 foo
3928 </pre>
3929
3930 <pre typeof="mw:Extension/pre" about="#mwt8" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n\n\nfoo\n"}}'>
3931
3932
3933 foo
3934 </pre>
3935 !!end
3936
3937 !! test
3938 HTML-pre: big spaces
3939 !! wikitext
3940 <pre>
3941
3942
3943
3944
3945 haha
3946
3947
3948
3949
3950 haha
3951
3952
3953
3954
3955 </pre>
3956 !! html/php+tidy
3957 <pre>
3958
3959
3960
3961
3962 haha
3963
3964
3965
3966
3967 haha
3968
3969
3970
3971
3972 </pre>
3973 !! html/parsoid
3974 <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"}}'>
3975
3976
3977
3978
3979 haha
3980
3981
3982
3983
3984 haha
3985
3986
3987
3988
3989 </pre>
3990 !! end
3991
3992 !!test
3993 HTML-pre: 2: indented text
3994 !! wikitext
3995 <pre>
3996 foo
3997 </pre>
3998 !! html
3999 <pre>
4000 foo
4001 </pre>
4002
4003 !!end
4004
4005 !!test
4006 HTML-pre: 3: other wikitext
4007 !! wikitext
4008 <pre>
4009 * foo
4010 # bar
4011 = no-h =
4012 '' no-italic ''
4013 [[ NoLink ]]
4014 </pre>
4015 !! html/php
4016 <pre>
4017 * foo
4018 # bar
4019 = no-h =
4020 '' no-italic ''
4021 [[ NoLink ]]
4022 </pre>
4023
4024 !! html/parsoid
4025 <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
4026 # bar
4027 = no-h =
4028 '' no-italic ''
4029 [[ NoLink ]]
4030 </pre>
4031 !!end
4032
4033 ###
4034 ### Definition lists
4035 ###
4036 !! test
4037 Simple definition
4038 !! wikitext
4039 ;name :Definition
4040 !! html
4041 <dl><dt>name</dt>
4042 <dd>Definition</dd></dl>
4043 !! end
4044
4045 !! test
4046 Definition list for indentation only
4047 !! wikitext
4048 :Indented text
4049 !! html
4050 <dl><dd>Indented text</dd></dl>
4051 !! end
4052
4053 !! test
4054 Definition list with no space
4055 !! wikitext
4056 ;name:Definition
4057 !! html
4058 <dl><dt>name</dt>
4059 <dd>Definition</dd></dl>
4060 !!end
4061
4062 !! test
4063 Definition list with URL link
4064 !! wikitext
4065 ;http://example.com/ :definition
4066 !! html
4067 <dl><dt><a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a></dt>
4068 <dd>definition</dd></dl>
4069 !! end
4070
4071 !! test
4072 Definition list with bracketed URL link
4073 !! wikitext
4074 ;[http://www.example.com/ Example]:Something about it
4075 !! html
4076 <dl><dt><a rel="nofollow" class="external text" href="http://www.example.com/">Example</a></dt>
4077 <dd>Something about it</dd></dl>
4078 !! end
4079
4080 !! test
4081 Definition list with wikilink containing colon
4082 !! wikitext
4083 ;[[Help:FAQ]]:The least-read page on Wikipedia
4084 !! html
4085 <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>
4086 <dd>The least-read page on Wikipedia</dd></dl>
4087 !! end
4088
4089 # At Brion's and JeLuF's insistence... :)
4090 !! test
4091 Definition list with news link containing colon
4092 !! wikitext
4093 ;news:alt.wikipedia.rox :This isn't even a real newsgroup!
4094 !! html/php
4095 <dl><dt><a rel="nofollow" class="external free" href="news:alt.wikipedia.rox">news:alt.wikipedia.rox</a></dt>
4096 <dd>This isn't even a real newsgroup!</dd></dl>
4097 !! html/parsoid
4098 <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>
4099 !! end
4100
4101 !! test
4102 Malformed definition list with colon
4103 !! wikitext
4104 ;news:alt.wikipedia.rox -- don't crash or enter an infinite loop
4105 !! html
4106 <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>
4107 !! end
4108
4109 !! test
4110 Definition lists: colon in external link text
4111 !! wikitext
4112 ;[http://www.wikipedia2.org/ Wikipedia :The Next Generation] :OK, I made that up
4113 !! html
4114 <dl><dt><a rel="nofollow" class="external text" href="http://www.wikipedia2.org/">Wikipedia :The Next Generation</a></dt>
4115 <dd>OK, I made that up</dd></dl>
4116 !! end
4117
4118 !! test
4119 Definition lists: colon in HTML attribute
4120 !! wikitext
4121 ;<b style="display: inline">bold</b>
4122 !! html
4123 <dl><dt><b style="display: inline">bold</b></dt></dl>
4124 !! end
4125
4126 !! test
4127 Definition lists: self-closed tag
4128 !! wikitext
4129 ;one<br/>two :two-line fun
4130 !! html
4131 <dl><dt>one<br />two</dt>
4132 <dd>two-line fun</dd></dl>
4133 !! end
4134
4135 !! test
4136 Definition lists: ignore colons inside tags
4137 !! wikitext
4138 ;one <b>two : tag <i>fun:</i>:</b>:def
4139 !! html
4140 <dl><dt>one <b>two&#160;: tag <i>fun:</i>:</b></dt>
4141 <dd>def</dd></dl>
4142 !! end
4143
4144 !! test
4145 Definition lists: excess closed tags
4146 !! wikitext
4147 ;one</b>two :bad tag fun
4148 !! html/php+tidy
4149 <dl><dt>onetwo</dt>
4150 <dd>bad tag fun</dd></dl>
4151 !! html/parsoid
4152 <dl>
4153 <dt>onetwo</dt>
4154 <dd>bad tag fun</dd>
4155 </dl>
4156 !! end
4157
4158 !! test
4159 T13748: Literal closing tags
4160 !! wikitext
4161 <dl>
4162 <dt>test 1</dt>
4163 <dd>test test test test test</dd>
4164 <dt>test 2</dt>
4165 <dd>test test test test test</dd>
4166 </dl>
4167 !! html
4168 <dl>
4169 <dt>test 1</dt>
4170 <dd>test test test test test</dd>
4171 <dt>test 2</dt>
4172 <dd>test test test test test</dd>
4173 </dl>
4174
4175 !! end
4176
4177 !! test
4178 Definition and unordered list using wiki syntax nested in unordered list using html tags.
4179 !! wikitext
4180 <ul><li>
4181 ;term :description
4182 *unordered
4183 </li></ul>
4184 !! html
4185 <ul><li>
4186 <dl><dt>term</dt>
4187 <dd>description</dd></dl>
4188 <ul><li>unordered</li></ul>
4189 </li></ul>
4190
4191 !! end
4192
4193 !! test
4194 Definition list with empty definition and following paragraph
4195 !! wikitext
4196 ;term:
4197
4198 Paragraph text
4199 !! html
4200 <dl><dt>term</dt>
4201 <dd></dd></dl>
4202 <p>Paragraph text
4203 </p>
4204 !! end
4205
4206 !! test
4207 Nested definition lists using html syntax
4208 !! wikitext
4209 <dl><dt>x</dt>
4210 <dd>a</dd>
4211 <dd>b</dd></dl>
4212 !! html
4213 <dl><dt>x</dt>
4214 <dd>a</dd>
4215 <dd>b</dd></dl>
4216
4217 !! end
4218
4219 !! test
4220 Definition Lists: No nesting: Multiple dd's
4221 !! wikitext
4222 ;x
4223 :a
4224 :b
4225 !! html
4226 <dl><dt>x</dt>
4227 <dd>a</dd>
4228 <dd>b</dd></dl>
4229 !! end
4230
4231 !! test
4232 Definition Lists: Indentation: Regular
4233 !! wikitext
4234 :i1
4235 ::i2
4236 :::i3
4237 !! html
4238 <dl><dd>i1
4239 <dl><dd>i2
4240 <dl><dd>i3</dd></dl></dd></dl></dd></dl>
4241 !! end
4242
4243 !! test
4244 Definition Lists: Indentation: Missing 1st level
4245 !! wikitext
4246 ::i2
4247 :::i3
4248 !! html
4249 <dl><dd><dl><dd>i2
4250 <dl><dd>i3</dd></dl></dd></dl></dd></dl>
4251 !! end
4252
4253 !! test
4254 Definition Lists: Indentation: Multi-level indent
4255 !! wikitext
4256 :::i3
4257 !! html
4258 <dl><dd><dl><dd><dl><dd>i3</dd></dl></dd></dl></dd></dl>
4259 !! end
4260
4261 !! test
4262 Definition Lists: Hacky use to indent tables
4263 !! wikitext
4264 ::{|
4265 |foo
4266 |bar
4267 |}
4268 this text
4269 should be left alone
4270 !! html
4271 <dl><dd><dl><dd><table>
4272 <tr>
4273 <td>foo
4274 </td>
4275 <td>bar
4276 </td></tr></table></dd></dl></dd></dl>
4277 <p>this text
4278 should be left alone
4279 </p>
4280 !! end
4281
4282 !! test
4283 Definition Lists: Hacky use to indent tables (with content following table)
4284 !! wikitext
4285 :{|
4286 |foo
4287 |bar
4288 |} <!--c1--> this text should be part of the dl
4289 !! html/php+tidy
4290 <dl><dd><table>
4291 <tbody><tr>
4292 <td>foo
4293 </td>
4294 <td>bar
4295 </td></tr></tbody></table> this text should be part of the dl</dd></dl>
4296 !! html/parsoid
4297 <dl><dd><table>
4298 <tbody><tr>
4299 <td>foo
4300 </td>
4301 <td>bar
4302 </td></tr></tbody></table> <!--c1--> this text should be part of the dl</dd></dl>
4303 !! end
4304
4305 !! test
4306 Definition Lists: Hacky use to indent tables, with comments (T65979)
4307 !! wikitext
4308 <!-- foo -->
4309 ::{|
4310 |foo
4311 |bar
4312 |}<!-- bar -->
4313 this text
4314 should be left alone
4315 !! html/parsoid
4316 <!-- foo -->
4317 <dl><dd><dl><dd><table><tr>
4318 <td>foo</td>
4319 <td>bar</td>
4320 </tr></table><!-- bar --></dd></dl></dd></dl>
4321 <p>this text
4322 should be left alone</p>
4323 !! end
4324
4325 !! test
4326 Definition Lists: Hacky use to indent tables, with comment before table
4327 !!options
4328 parsoid=wt2html
4329 !! wikitext
4330 ::<!-- foo -->{|
4331 |foo
4332 |}
4333 !! html/parsoid
4334 <dl><dd><dl><dd><!-- foo --><table><tr>
4335 <td>foo</td>
4336 </tr></table></dd></dl></dd></dl>
4337 !! end
4338
4339 # The trailing whitespace in this test is to catch a regression in
4340 # Parsoid after T54473.
4341 !! test
4342 Definition Lists: Hacky use to indent tables (WS-insensitive)
4343 !! wikitext
4344 :{|
4345 |a
4346 |}
4347 !! html/php
4348 <dl><dd><table>
4349 <tr>
4350 <td>a
4351 </td></tr></table></dd></dl>
4352
4353 !! html/parsoid
4354 <dl><dd><table>
4355 <tbody><tr><td>a</td></tr>
4356 </tbody></table></dd></dl>
4357 !! end
4358
4359 ## The PHP parser treats : items (dd) without a corresponding ; item (dt)
4360 ## as an empty dt item. It also ignores all but the last ";" when followed
4361 ## by ":" later on. So, ";" are not ignored in ";;;t3" but are ignored in
4362 ## ";;;t3 :d1". So, PHP parser behavior is a little inconsistent wrt multiple
4363 ## ";"s.
4364 ##
4365 ## Ex: ";;t2 ::d2" is transformed into:
4366 ##
4367 ## <dl>
4368 ## <dt>t2 </dt>
4369 ## <dd>
4370 ## <dl>
4371 ## <dt></dt>
4372 ## <dd>d2</dd>
4373 ## </dl>
4374 ## </dd>
4375 ## </dl>
4376 ##
4377 ## But, Parsoid treats "; :" as a tight atomic unit and excess ":" as plain text
4378 ## So, the same wikitext above (;;t2 ::d2) is transformed into:
4379 ##
4380 ## <dl>
4381 ## <dt>
4382 ## <dl>
4383 ## <dt>t2 </dt>
4384 ## <dd>:d2</dd>
4385 ## </dl>
4386 ## </dt>
4387 ## </dl>
4388 ##
4389 ## All Parsoid only definition list tests have this difference.
4390 ##
4391 ## See also: https://phabricator.wikimedia.org/T8569
4392 ## and https://lists.wikimedia.org/pipermail/wikitext-l/2011-November/000483.html
4393
4394 !! test
4395 Table / list interaction: indented table with lists in table contents
4396 !! wikitext
4397 :{|
4398 |-
4399 |a
4400
4401 *b
4402 |-
4403 |c
4404
4405 *d
4406 |}
4407 !! html
4408 <dl><dd><table>
4409
4410 <tr>
4411 <td>a
4412 <ul><li>b</li></ul>
4413 </td></tr>
4414 <tr>
4415 <td>c
4416 <ul><li>d</li></ul>
4417 </td></tr></table></dd></dl>
4418
4419 !! end
4420
4421 !!test
4422 Table / list interaction: lists nested in tables nested in indented lists
4423 !! wikitext
4424 :{|
4425 |
4426 :a
4427 :b
4428 |
4429 *c
4430 *d
4431 |}
4432
4433 *e
4434 *f
4435 !! html
4436 <dl><dd><table>
4437 <tr>
4438 <td>
4439 <dl><dd>a</dd>
4440 <dd>b</dd></dl>
4441 </td>
4442 <td>
4443 <ul><li>c</li>
4444 <li>d</li></ul>
4445 </td></tr></table></dd></dl>
4446 <ul><li>e</li>
4447 <li>f</li></ul>
4448 !!end
4449
4450 !! test
4451 Definition Lists: Nesting: Multi-level (Parsoid only)
4452 !! wikitext
4453 ;t1 :d1
4454 ;;t2 ::d2
4455 ;;;t3 :::d3
4456 !! html/parsoid
4457 <dl>
4458 <dt>t1 </dt>
4459 <dd>d1</dd>
4460 <dt>
4461 <dl>
4462 <dt>t2 </dt>
4463 <dd>:d2</dd>
4464 <dt>
4465 <dl>
4466 <dt>t3 </dt>
4467 <dd>::d3</dd>
4468 </dl>
4469 </dt>
4470 </dl>
4471 </dt>
4472 </dl>
4473
4474
4475 !! end
4476
4477
4478 !! test
4479 Definition Lists: Nesting: Test 2
4480 !! wikitext
4481 ;t1
4482 ::d2
4483 !! html+tidy
4484 <dl><dt>t1</dt>
4485 <dd>
4486 <dl><dd>d2</dd></dl></dd></dl>
4487 !! end
4488
4489
4490 !! test
4491 Definition Lists: Nesting: Test 3
4492 !! wikitext
4493 :;t1
4494 ::::d2
4495 !! html+tidy
4496 <dl><dd><dl><dt>t1</dt>
4497 <dd>
4498 <dl><dd><dl><dd>d2</dd></dl></dd></dl></dd></dl></dd></dl>
4499 !! end
4500
4501
4502 !! test
4503 Definition Lists: Nesting: Test 4
4504 !! wikitext
4505 ::;t3
4506 :::d3
4507 !! html
4508 <dl><dd><dl><dd><dl><dt>t3</dt>
4509 <dd>d3</dd></dl></dd></dl></dd></dl>
4510 !! end
4511
4512
4513 ## The Parsoid team believes the following three test exposes a
4514 ## bug in the PHP parser. (Parsoid team thinks the PHP parser is
4515 ## wrong to close the <dl> after the <dt> containing the <ul>.)
4516 ## It also exposes a "misfeature" in tidy, which doesn't like
4517 ## <dl> tags with a single <dt> child; it converts the <dt> into
4518 ## a <dd> in that case. (Parsoid leaves the <dt> alone!)
4519 !! test
4520 Definition Lists: Mixed Lists: Test 1
4521 !! wikitext
4522 :;*foo
4523 ::*bar
4524 :;baz
4525 !! html/php
4526 <dl><dd><dl><dt><ul><li>foo</li>
4527 <li>bar</li></ul></dt></dl>
4528 <dl><dt>baz</dt></dl></dd></dl>
4529 !! html/php+tidy
4530 <dl><dd><dl><dt><ul><li>foo</li>
4531 <li>bar</li></ul></dt></dl>
4532 <dl><dt>baz</dt></dl></dd></dl>
4533 !! html/parsoid
4534 <dl>
4535 <dd><dl>
4536 <dt><ul>
4537 <li>foo
4538 </li>
4539 </ul></dt>
4540 <dd><ul>
4541 <li>bar
4542 </li>
4543 </ul></dd>
4544 <dt>baz</dt>
4545 </dl></dd>
4546 </dl>
4547 !! end
4548
4549 !! test
4550 Definition Lists: Mixed Lists: Test 2
4551 !! wikitext
4552 *:d1
4553 *:d2
4554 !! html
4555 <ul><li><dl><dd>d1</dd>
4556 <dd>d2</dd></dl></li></ul>
4557 !! end
4558
4559
4560 !! test
4561 Definition Lists: Mixed Lists: Test 3
4562 !! wikitext
4563 *:::d1
4564 *:::d2
4565 !! html
4566 <ul><li><dl><dd><dl><dd><dl><dd>d1</dd>
4567 <dd>d2</dd></dl></dd></dl></dd></dl></li></ul>
4568 !! end
4569
4570
4571 !! test
4572 Definition Lists: Mixed Lists: Test 4
4573 !! wikitext
4574 *;d1 :d2
4575 *;d3 :d4
4576 !! html
4577 <ul><li><dl><dt>d1</dt>
4578 <dd>d2</dd>
4579 <dt>d3</dt>
4580 <dd>d4</dd></dl></li></ul>
4581 !! end
4582
4583
4584 !! test
4585 Definition Lists: Mixed Lists: Test 5
4586 !! wikitext
4587 *:d1
4588 *::d2
4589 !! html
4590 <ul><li><dl><dd>d1
4591 <dl><dd>d2</dd></dl></dd></dl></li></ul>
4592 !! end
4593
4594
4595 !! test
4596 Definition Lists: Mixed Lists: Test 6
4597 !! wikitext
4598 #*:d1
4599 #*:::d3
4600 !! html
4601 <ol><li><ul><li><dl><dd>d1
4602 <dl><dd><dl><dd>d3</dd></dl></dd></dl></dd></dl></li></ul></li></ol>
4603 !! end
4604
4605
4606 !! test
4607 Definition Lists: Mixed Lists: Test 7
4608 !! wikitext
4609 :*d1
4610 :*d2
4611 !! html
4612 <dl><dd><ul><li>d1</li>
4613 <li>d2</li></ul></dd></dl>
4614 !! end
4615
4616
4617 !! test
4618 Definition Lists: Mixed Lists: Test 8
4619 !! wikitext
4620 :*d1
4621 ::*d2
4622 !! html
4623 <dl><dd><ul><li>d1</li></ul>
4624 <dl><dd><ul><li>d2</li></ul></dd></dl></dd></dl>
4625 !! end
4626
4627
4628 !! test
4629 Definition Lists: Mixed Lists: Test 9
4630 !! wikitext
4631 *;foo :bar
4632 !! html
4633 <ul><li><dl><dt>foo</dt>
4634 <dd>bar</dd></dl></li></ul>
4635 !! end
4636
4637
4638 !! test
4639 Definition Lists: Mixed Lists: Test 10
4640 !! wikitext
4641 *#;foo :bar
4642 !! html
4643 <ul><li><ol><li><dl><dt>foo</dt>
4644 <dd>bar</dd></dl></li></ol></li></ul>
4645 !! end
4646
4647 # The Parsoid team disagrees with the PHP parser's seemingly-random
4648 # rules regarding dd/dt on the next few tests. Parsoid is more
4649 # consistent, and recognizes the shared nesting and keeps the
4650 # still-open tags around until the nesting is complete.
4651
4652 # This is a regression test for T175099
4653 !! test
4654 Definition Lists: Mixed Lists: Test 11
4655 !! wikitext
4656 ;a
4657 :*b
4658 !! html/php
4659 <dl><dt>a</dt>
4660 <dd>
4661 <ul><li>b</li></ul></dd></dl>
4662 !! html/parsoid
4663 <dl><dt>a
4664 <dd><ul><li>b</li></ul></dd></dl>
4665 !! end
4666
4667 # FIXME: Maybe get rid of this test?
4668 !! test
4669 Definition Lists: Mixed Lists: Test 12
4670 !! wikitext
4671 *#*#;*;;foo :bar
4672 *#*#;boo :baz
4673 !! html/php
4674 <ul><li><ol><li><ul><li><ol><li><dl><dt>foo</dt>
4675 <dd><ul><li><dl><dt><dl><dt>bar</dt></dl></dd></dl></li></ul></dd></dl>
4676 <dl><dt>boo</dt>
4677 <dd>baz</dd></dl></li></ol></li></ul></li></ol></li></ul>
4678 !! html/php+tidy
4679 <ul><li><ol><li><ul><li><ol><li><dl><dt>foo</dt>
4680 <dd><ul><li><dl><dt><dl><dt>bar</dt></dl></dt></dl></li></ul></dd></dl></li></ol></li></ul>
4681 <dl><dt>boo</dt>
4682 <dd>baz</dd></dl></li></ol></li></ul>
4683 !! html/parsoid
4684 <ul>
4685 <li>
4686 <ol>
4687 <li>
4688 <ul>
4689 <li>
4690 <ol>
4691 <li>
4692 <dl>
4693 <dt>
4694 <ul>
4695 <li>
4696 <dl>
4697 <dt>
4698 <dl>
4699 <dt>foo</dt>
4700 <dd data-parsoid='{"stx":"row"}'>bar</dd>
4701 </dl></dt>
4702 </dl></li>
4703 </ul></dt>
4704 <dt>boo</dt>
4705 <dd data-parsoid='{"stx":"row"}'>baz</dd>
4706 </dl></li>
4707 </ol></li>
4708 </ul></li>
4709 </ol></li>
4710 </ul>
4711 !! end
4712
4713 !! test
4714 Definition Lists: Mixed Lists: Test 13
4715 !! wikitext
4716 *#*#;*;;foo : bar
4717 *#*#;boo : baz
4718 !! html+tidy
4719 <ul><li><ol><li><ul><li><ol><li><dl><dt>foo&#160;</dt>
4720 <dd><ul><li><dl><dt><dl><dt>bar</dt></dl></dt></dl></li></ul></dd></dl></li></ol></li></ul>
4721 <dl><dt>boo&#160;</dt>
4722 <dd>baz</dd></dl></li></ol></li></ul>
4723 !! end
4724
4725 # FIXME: Maybe get rid of this test?
4726 # From whitelist:
4727 # * The test is wrong, there are two colons where there should be :;
4728 # * The PHP parser is wrong to close the <dl> after the <dt> containing the <ul>.
4729 !! test
4730 Definition Lists: Weird Ones: Test 1
4731 !! wikitext
4732 *#;*::;;foo :bar (who uses this?)
4733 !! html/php+tidy
4734 <ul><li><ol><li><dl><dt>foo</dt>
4735 <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>
4736 !! html/parsoid
4737 <ul>
4738 <li>
4739 <ol>
4740 <li>
4741 <dl>
4742 <dt>
4743 <ul>
4744 <li>
4745 <dl>
4746 <dd>
4747 <dl>
4748 <dd>
4749 <dl>
4750 <dt>
4751 <dl>
4752 <dt>foo</dt>
4753 <dd data-parsoid='{"stx":"row"}'>bar (who uses this?)</dd>
4754 </dl></dt>
4755 </dl></dd>
4756 </dl></dd>
4757 </dl></li>
4758 </ul></dt>
4759 </dl></li>
4760 </ol></li>
4761 </ul>
4762 !! end
4763
4764 !! test
4765 Definition Lists: colons occurring in tags
4766 !! wikitext
4767 ;a:b
4768 ;'''a:b'''
4769 ;<i>a:b</i>
4770 ;<span>a:b</span>
4771 ;<div>a:b</div>
4772 ;<div>a
4773 :b</div>
4774 ;{{echo|a:b}}
4775 ;{{echo|''a:b''}}
4776 ;;;''a:b''
4777 !! html+tidy
4778 <dl><dt>a</dt>
4779 <dd>b</dd>
4780 <dt><b>a:b</b></dt>
4781 <dt><i>a:b</i></dt>
4782 <dt><span>a:b</span></dt>
4783 <dt><div>a:b</div></dt>
4784 <dt><div>a</div></dt>
4785 <dd>b</dd>
4786 <dt>a</dt>
4787 <dd>b</dd>
4788 <dt><i>a:b</i></dt></dl>
4789 <dl><dt><dl><dt><dl><dt><i>a:b</i></dt></dl></dt></dl></dt></dl>
4790 !! html/parsoid
4791 <dl><dt>a</dt><dd data-parsoid='{"stx":"row"}'>b</dd>
4792 <dt><b>a:b</b></dt>
4793 <dt><i data-parsoid='{"stx":"html"}'>a:b</i></dt>
4794 <dt><span data-parsoid='{"stx":"html"}'>a:b</span></dt>
4795 <dt><div data-parsoid='{"stx":"html"}'>a:b</div></dt>
4796 <dt><div data-parsoid='{"stx":"html","autoInsertedEnd":true}'>a</div></dt>
4797 <dd>b</dd>
4798 <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>
4799 <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>
4800 <dl><dt><dl><dt><i>a:b</i></dt></dl></dt></dl></dt></dl>
4801 !! end
4802
4803 # Parsoid's output differs here again because it shares
4804 # nesting between the two lists unlike the PHP parser.
4805 # Unsure which is more desirable.
4806 !! test
4807 Definition Lists: colons and tables 1
4808 !! wikitext
4809 :{|
4810 |x
4811 |}
4812 :{|
4813 |y
4814 |}
4815 !! html/php
4816 <dl><dd><table>
4817 <tr>
4818 <td>x
4819 </td></tr></table></dd></dl>
4820 <dl><dd><table>
4821 <tr>
4822 <td>y
4823 </td></tr></table></dd></dl>
4824
4825 !! html/parsoid
4826 <dl><dd><table>
4827 <tr>
4828 <td>x
4829 </td></tr></table></dd>
4830 <dd><table>
4831 <tr>
4832 <td>y
4833 </td></tr></table></dd></dl>
4834 !! end
4835
4836 # FIXME: Does this need a html/php section?
4837 !! test
4838 Definition Lists: template interaction
4839 !! wikitext
4840 ::{{definition_list}}
4841
4842 :one
4843 ::{{definition_list}}
4844 :::two
4845 :::three
4846 ::four
4847 !! html/parsoid
4848 <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">
4849 </span><dd about="#mwt1">two</dd></dl></dd></dl>
4850
4851 <dl><dd data-parsoid='{}'>one
4852 <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">
4853 </span><dd about="#mwt2">two
4854 <dl><dd>two</dd>
4855 <dd>three</dd></dl></dd>
4856 <dd data-parsoid='{}'>four</dd></dl></dd></dl>
4857 !! end
4858
4859
4860 ###
4861 ### External links
4862 ###
4863 !! test
4864 External links: non-bracketed
4865 !! wikitext
4866 Non-bracketed: http://example.com
4867 !! html
4868 <p>Non-bracketed: <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
4869 </p>
4870 !! end
4871
4872 # parsoid doesn't explicitly mark autonumbered links, see T55505
4873 !! test
4874 External links: numbered
4875 !! wikitext
4876 Numbered: [http://example.com]
4877 Numbered: [http://example.net]
4878 Numbered: [http://example.com]
4879 !! html/php
4880 <p>Numbered: <a rel="nofollow" class="external autonumber" href="http://example.com">[1]</a>
4881 Numbered: <a rel="nofollow" class="external autonumber" href="http://example.net">[2]</a>
4882 Numbered: <a rel="nofollow" class="external autonumber" href="http://example.com">[3]</a>
4883 </p>
4884 !! html/parsoid
4885 <p>Numbered: <a rel="mw:ExtLink" class="external autonumber" href="http://example.com"></a>
4886 Numbered: <a rel="mw:ExtLink" class="external autonumber" href="http://example.net"></a>
4887 Numbered: <a rel="mw:ExtLink" class="external autonumber" href="http://example.com"></a></p>
4888 !!end
4889
4890 !! test
4891 External links: specified text
4892 !! wikitext
4893 Specified text: [http://example.com link]
4894 !! html
4895 <p>Specified text: <a rel="nofollow" class="external text" href="http://example.com">link</a>
4896 </p>
4897 !!end
4898
4899 !! test
4900 External links: trail
4901 !! wikitext
4902 Linktrails should not work for external links: [http://example.com link]s
4903 !! html
4904 <p>Linktrails should not work for external links: <a rel="nofollow" class="external text" href="http://example.com">link</a>s
4905 </p>
4906 !! end
4907
4908 !! test
4909 External links: dollar sign in URL
4910 !! wikitext
4911 http://example.com/1$2345
4912 !! html
4913 <p><a rel="nofollow" class="external free" href="http://example.com/1$2345">http://example.com/1$2345</a>
4914 </p>
4915 !! end
4916
4917 # parsoid doesn't explicitly mark autonumbered links, see T55505
4918 !! test
4919 External links: dollar sign in URL (autonumber)
4920 !! wikitext
4921 [http://example.com/1$2345]
4922 !! html/php
4923 <p><a rel="nofollow" class="external autonumber" href="http://example.com/1$2345">[1]</a>
4924 </p>
4925 !! html/parsoid
4926 <p><a rel="mw:ExtLink" class="external autonumber" href="http://example.com/1$2345"></a></p>
4927 !!end
4928
4929 !! test
4930 External links: open square bracket forbidden in URL (T6377)
4931 !! options
4932 parsoid=wt2html,wt2wt,html2html
4933 !! wikitext
4934 http://example.com/1[2345
4935 !! html/php
4936 <p><a rel="nofollow" class="external free" href="http://example.com/1">http://example.com/1</a>[2345
4937 </p>
4938 !! html/parsoid
4939 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/1">http://example.com/1</a>[2345</p>
4940 !! end
4941
4942 !! test
4943 External links: open square bracket forbidden in URL (named) (T6377)
4944 !! options
4945 parsoid=wt2html,html2html
4946 !! wikitext
4947 [http://example.com/1[2345]
4948 !! html/php
4949 <p><a rel="nofollow" class="external text" href="http://example.com/1">[2345</a>
4950 </p>
4951 !! html/parsoid
4952 <p><a rel="mw:ExtLink" class="external text" href="http://example.com/1">[2345</a></p>
4953 !!end
4954
4955 # parsoid adds a space before the link name
4956 !! test
4957 External links: open square bracket forbidden in URL (named) (T6377)
4958 Parsoid variant.
4959 !! wikitext
4960 [http://example.com/1 [2345]
4961 !! html
4962 <p><a rel="nofollow" class="external text" href="http://example.com/1">[2345</a>
4963 </p>
4964 !!end
4965
4966 !! test
4967 External links: nowiki in URL link text (T8230)
4968 !! wikitext
4969 [http://example.com/ <nowiki>''example site''</nowiki>]
4970 !! html
4971 <p><a rel="nofollow" class="external text" href="http://example.com/">''example site''</a>
4972 </p>
4973 !! end
4974
4975 !! test
4976 External links: newline forbidden in text (T8230 regression check)
4977 !! wikitext
4978 [http://example.com/ first
4979 second]
4980 !! html
4981 <p>[<a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a> first
4982 second]
4983 </p>
4984 !!end
4985
4986 !! test
4987 External links: Pipe char between url and text
4988 !! wikitext
4989 [http://example.com | link]
4990 !! html
4991 <p><a rel="nofollow" class="external text" href="http://example.com">| link</a>
4992 </p>
4993 !!end
4994
4995 !! test
4996 External links: protocol-relative URL in brackets
4997 !! wikitext
4998 [//example.com/ Test]
4999 !! html
5000 <p><a rel="nofollow" class="external text" href="//example.com/">Test</a>
5001 </p>
5002 !! end
5003
5004 # parsoid doesn't explicitly mark autonumbered links, see T55505
5005 !! test
5006 External links: protocol-relative URL in brackets without text
5007 !! wikitext
5008 [//example.com]
5009 !! html/php
5010 <p><a rel="nofollow" class="external autonumber" href="//example.com">[1]</a>
5011 </p>
5012 !! html/parsoid
5013 <p><a rel="mw:ExtLink" class="external autonumber" href="//example.com"></a></p>
5014 !! end
5015
5016 !! test
5017 External links: protocol-relative URL in free text is left alone
5018 !! wikitext
5019 //example.com/Foo
5020 !! html
5021 <p>//example.com/Foo
5022 </p>
5023 !!end
5024
5025 !! test
5026 External links: protocol-relative URL in the middle of a word is left alone (T32269)
5027 !! wikitext
5028 foo//example.com/Foo
5029 !! html
5030 <p>foo//example.com/Foo
5031 </p>
5032 !! end
5033
5034 ## html2wt and html2html will fail because we will prefer the :en: interwiki prefix over wikipedia:
5035 !! test
5036 External links: with no contents
5037 !! options
5038 parsoid=wt2html,wt2wt
5039 !! wikitext
5040 [http://en.wikipedia.org/wiki/Foo]
5041
5042 [[wikipedia:Foo|Bar]]
5043
5044 [[wikipedia:Foo|<span>Bar</span>]]
5045 !! html/php
5046 <p><a rel="nofollow" class="external autonumber" href="http://en.wikipedia.org/wiki/Foo">[1]</a>
5047 </p><p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo">Bar</a>
5048 </p><p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo"><span>Bar</span></a>
5049 </p>
5050 !! html/parsoid
5051 <p><a rel="mw:ExtLink" class="external autonumber" href="http://en.wikipedia.org/wiki/Foo"></a></p>
5052 <p><a rel="mw:WikiLink/Interwiki" href="http://en.wikipedia.org/wiki/Foo" title="wikipedia:Foo">Bar</a></p>
5053 <p><a rel="mw:WikiLink/Interwiki" href="http://en.wikipedia.org/wiki/Foo" title="wikipedia:Foo"><span>Bar</span></a></p>
5054 !! end
5055
5056 !! test
5057 External links: Free with trailing punctuation
5058 !! wikitext
5059 http://example.com,
5060 http://example.com;
5061 http://example.com\
5062 http://example.com.
5063 http://example.com:
5064 http://example.com!
5065 http://example.com?
5066 http://example.com)
5067 http://example.com/url_with_(brackets)
5068 (http://example.com/url_without_brackets)
5069 http://example.com/url_with_entity&amp;
5070 http://example.com/url_with_entity&#x26;
5071 http://example.com/url_with_entity&#038;
5072 http://example.com/url_with_entity&nbsp;
5073 http://example.com/url_with_entity&#xA0;
5074 http://example.com/url_with_entity&#160;
5075 http://example.com/url_with_entity&lt;
5076 http://example.com/url_with_entity&#x3C;
5077 http://example.com/url_with_entity&#60;
5078 !! html/php
5079 <p><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">http://example.com</a>.
5083 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>:
5084 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>!
5085 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>?
5086 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
5087 <a rel="nofollow" class="external free" href="http://example.com/url_with_(brackets)">http://example.com/url_with_(brackets)</a>
5088 (<a rel="nofollow" class="external free" href="http://example.com/url_without_brackets">http://example.com/url_without_brackets</a>)
5089 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
5090 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
5091 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
5092 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#160;
5093 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#xa0;
5094 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#160;
5095 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&lt;
5096 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#x3c;
5097 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#60;
5098 </p>
5099 !! html/parsoid
5100 <p><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">http://example.com</a>.
5104 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>:
5105 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>!
5106 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>?
5107 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>)
5108 <a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_(brackets)">http://example.com/url_with_(brackets)</a>
5109 (<a rel="mw:ExtLink" class="external free" href="http://example.com/url_without_brackets">http://example.com/url_without_brackets</a>)
5110 <a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
5111 <a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
5112 <a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
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;nbsp;","srcContent":" "}'> </span>
5114 <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>
5115 <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>
5116 <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>
5117 <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>
5118 <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>
5119 !! end
5120
5121 !! test
5122 External links: tricky Parsoid html2html case
5123 !! options
5124 parsoid=wt2html,wt2wt,html2html
5125 !! wikitext
5126 http://example.com/url_with_entity&amp;amp;
5127 !! html/php
5128 <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>;
5129 </p>
5130 !! html/parsoid
5131 <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>
5132 !! end
5133
5134 !! test
5135 External links: Free with trailing quotes (T113666)
5136 !! wikitext
5137 '''News:''' Stuff here
5138
5139 news:'a'b''c''d e
5140 !! html/php
5141 <p><b>News:</b> Stuff here
5142 </p><p><a rel="nofollow" class="external free" href="news:&#39;a&#39;b">news:'a'b</a><i>c</i>d e
5143 </p>
5144 !! html/parsoid
5145 <p><b>News:</b> Stuff here</p>
5146 <p><a rel="mw:ExtLink" class="external free" href="news:'a'b">news:'a'b</a><i>c</i>d e</p>
5147 !! end
5148
5149 !! test
5150 External links: with entity
5151 !! wikitext
5152 [http://&#x20;www.librarieswithoutborders.org Libraries without borders]
5153 !! html/php
5154 <p><a rel="nofollow" class="external text" href="http://+www.librarieswithoutborders.org">Libraries without borders</a>
5155 </p>
5156 !! html/parsoid
5157 <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>
5158 !! end
5159
5160 !! test
5161 External links: Lone protocols are never linked (T105697)
5162 !! wikitext
5163 http://
5164 http://;
5165 (http://)
5166 bitcoin:
5167 bitcoin:;
5168 (bitcoin:)
5169 !! html
5170 <p>http://
5171 http://;
5172 (http://)
5173 bitcoin:
5174 bitcoin:;
5175 (bitcoin:)
5176 </p>
5177 !! end
5178
5179 !! test
5180 External links: No preceding word characters allowed (T67278)
5181 !! wikitext
5182 NOPEhttp://example.com
5183 N0http://example.com
5184 ok:http://example.com
5185 ok-http://example.com
5186 !! html
5187 <p>NOPEhttp://example.com
5188 N0http://example.com
5189 ok:<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
5190 ok-<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
5191 </p>
5192 !! end
5193
5194 !! test
5195 External links: nofollow domain exception
5196 !! wikitext
5197 A [https://no-nofollow.org/foobar link], and another [https://example.org link].
5198 !! html
5199 <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>.
5200 </p>
5201 !!end
5202
5203 !! test
5204 External image
5205 !! wikitext
5206 External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
5207 !! html
5208 <p>External image: <img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png"/>
5209 </p>
5210 !! end
5211
5212 !! test
5213 External image from https
5214 !! wikitext
5215 External image from https: https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
5216 !! html
5217 <p>External image from https: <img src="https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png"/>
5218 </p>
5219 !! end
5220
5221 !! test
5222 External image (when not allowed)
5223 !! options
5224 wgAllowExternalImages=0
5225 !! wikitext
5226 External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
5227 !! html
5228 <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>
5229 </p>
5230 !! end
5231
5232 !! test
5233 Link to non-http image, no img tag
5234 !! wikitext
5235 Link to non-http image, no img tag: ftp://example.com/test.jpg
5236 !! html
5237 <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>
5238 </p>
5239 !! end
5240
5241 !! test
5242 External links: terminating separator
5243 !! wikitext
5244 Terminating separator: http://example.com/thing,
5245 !! html
5246 <p>Terminating separator: <a rel="nofollow" class="external free" href="http://example.com/thing">http://example.com/thing</a>,
5247 </p>
5248 !! end
5249
5250 !! test
5251 External links: intervening separator
5252 !! wikitext
5253 Intervening separator: http://example.com/1,2,3
5254 !! html
5255 <p>Intervening separator: <a rel="nofollow" class="external free" href="http://example.com/1,2,3">http://example.com/1,2,3</a>
5256 </p>
5257 !! end
5258
5259 !! test
5260 External links: old bug with URL in query
5261 !! wikitext
5262 Old bug with URL in query: [http://example.com/thing?url=http://example.com link]
5263 !! html
5264 <p>Old bug with URL in query: <a rel="nofollow" class="external text" href="http://example.com/thing?url=http://example.com">link</a>
5265 </p>
5266 !! end
5267
5268 !! test
5269 External links: old URL-in-URL bug, mixed protocols
5270 !! wikitext
5271 And again with mixed protocols: [ftp://example.com?url=http://example.com link]
5272 !! html
5273 <p>And again with mixed protocols: <a rel="nofollow" class="external text" href="ftp://example.com?url=http://example.com">link</a>
5274 </p>
5275 !!end
5276
5277 # Since Parsoid is starting to emit canonical wikitext for links,
5278 # [http://example.com http://example.com] will not RT back to that
5279 # form anymore.
5280 !! test
5281 External links: URL in text
5282 !! options
5283 parsoid=wt2html
5284 !! wikitext
5285 URL in text: [http://example.com http://example.com]
5286 !! html/php
5287 <p>URL in text: <a rel="nofollow" class="external text" href="http://example.com">http://example.com</a>
5288 </p>
5289 !! html/parsoid
5290 <p>URL in text: <a rel="mw:ExtLink" class="external text" href="http://example.com">http://example.com</a></p>
5291 !! end
5292
5293 !! test
5294 External links: Clickable images
5295 !! wikitext
5296 ja-style clickable images: [http://example.com http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png]
5297 !! html/php
5298 <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>
5299 </p>
5300 !! html/parsoid
5301 <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>
5302 !! end
5303
5304 !! test
5305 External links: raw ampersand
5306 !! wikitext
5307 Old &amp; use: http://x&y
5308 !! html
5309 <p>Old &amp; use: <a rel="nofollow" class="external free" href="http://x&amp;y">http://x&amp;y</a>
5310 </p>
5311 !! end
5312
5313 !! test
5314 External links: encoded ampersand
5315 !! wikitext
5316 Old &amp; use: http://x&amp;y
5317 !! html/php
5318 <p>Old &amp; use: <a rel="nofollow" class="external free" href="http://x&amp;y">http://x&amp;y</a>
5319 </p>
5320 !! html/parsoid
5321 <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>
5322 !! end
5323
5324 !! test
5325 External links: encoded equals (T8102)
5326 !! wikitext
5327 http://example.com/?foo&#61;bar
5328 !! html/php
5329 <p><a rel="nofollow" class="external free" href="http://example.com/?foo=bar">http://example.com/?foo=bar</a>
5330 </p>
5331 !! html/parsoid
5332 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/?foo=bar">http://example.com/?foo=bar</a></p>
5333 !! end
5334
5335 ##
5336 ## Note that parsoid doesn't explicit mark autonumbered links, nor
5337 ## does it number them. As discussed in T55505, we can identify
5338 ## autonumbered links via CSS.
5339 ##
5340
5341 !! test
5342 External links: [raw ampersand]
5343 !! wikitext
5344 Old &amp; use: [http://x&y]
5345 !! html/php
5346 <p>Old &amp; use: <a rel="nofollow" class="external autonumber" href="http://x&amp;y">[1]</a>
5347 </p>
5348 !! html/parsoid
5349 <p>Old <span typeof="mw:Entity">&amp;</span> use: <a rel="mw:ExtLink" class="external autonumber" href="http://x&amp;y"></a></p>
5350 !! end
5351
5352 # note that parsoid html is identical to [raw ampersand] case; so html2wt
5353 # mode will return the [raw ampersand] wikitext
5354 !! test
5355 External links: [encoded ampersand]
5356 !! options
5357 parsoid=wt2html,wt2wt,html2html
5358 !! wikitext
5359 Old &amp; use: [http://x&amp;y]
5360 !! html/php
5361 <p>Old &amp; use: <a rel="nofollow" class="external autonumber" href="http://x&amp;y">[1]</a>
5362 </p>
5363 !! html/parsoid
5364 <p>Old <span typeof="mw:Entity">&amp;</span> use: <a rel="mw:ExtLink" class="external autonumber" href="http://x&amp;y"></a></p>
5365 !! end
5366
5367 !! test
5368 External links: [raw equals]
5369 !! wikitext
5370 [http://example.com/?foo=bar]
5371 !! html/php
5372 <p><a rel="nofollow" class="external autonumber" href="http://example.com/?foo=bar">[1]</a>
5373 </p>
5374 !! html/parsoid
5375 <p><a rel="mw:ExtLink" class="external autonumber" href="http://example.com/?foo=bar"></a></p>
5376 !! end
5377
5378 # note that parsoid html is identical to [raw equals] case; so html2wt
5379 # mode will return the [raw equals] wikitext
5380 !! test
5381 External links: [encoded equals] (T8102)
5382 !! options
5383 parsoid=wt2html,wt2wt,html2html
5384 !! wikitext
5385 [http://example.com/?foo&#61;bar]
5386 !! html/php
5387 <p><a rel="nofollow" class="external autonumber" href="http://example.com/?foo=bar">[1]</a>
5388 </p>
5389 !! html/parsoid
5390 <p><a rel="mw:ExtLink" class="external autonumber" href="http://example.com/?foo=bar"></a></p>
5391 !! end
5392
5393 # xxx parsoid strips the IDN character, so the round-trip tests will
5394 # obviously fail and are disabled. --cscott
5395 !! test
5396 External links: [IDN ignored character reference in hostname; strip it right off]
5397 !! options
5398 parsoid=wt2html,wt2wt,html2html
5399 !! wikitext
5400 [http://e&zwnj;xample.com/]
5401 !! html/php
5402 <p><a rel="nofollow" class="external autonumber" href="http://example.com/">[1]</a>
5403 </p>
5404 !! html/parsoid
5405 <p><a rel="mw:ExtLink" class="external autonumber" href="http://example.com/"></a></p>
5406 !! end
5407
5408 # FIXME: This test (the IDN characters in the text of a link) is an inconsistency.
5409 # Where an external link could easily circumvent the sanitization of the text of
5410 # a link like this (where an IDN-ignore character is in the URL somewhere), this
5411 # test demands a higher standard. That's a bit strange.
5412 #
5413 # Example:
5414 #
5415 # http://e‌xample.com -> [http://example.com|http://example.com]
5416 # [http://example.com|http://e‌xample.com] -> [http://example.com|http://e‌xample.com]
5417 #
5418 # The first example is sanitized, but the second is not. Any security benefits
5419 # from this production are trivial to circumvent. Either remove this test and
5420 # let the parser(s) do their thing unaccosted, or fix the inconsistency and change
5421 # the test accordingly.
5422 #
5423 # All our love,
5424 # The Parsoid team.
5425 # xxx parsoid strips the IDN character, so the round-trip tests will
5426 # obviously fail and are disabled. --cscott
5427 !! test
5428 External links: IDN ignored character reference in hostname; strip it right off
5429 !! options
5430 parsoid=wt2html,html2html
5431 !! wikitext
5432 http://e&zwnj;xample.com/
5433 !! html/php
5434 <p><a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a>
5435 </p>
5436 !! html/parsoid
5437 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/">http://example.com/</a></p>
5438 !! end
5439
5440 !! test
5441 External links: www.jpeg.org (T2554)
5442 !! wikitext
5443 http://www.jpeg.org
5444 !! html
5445 <p><a rel="nofollow" class="external free" href="http://www.jpeg.org">http://www.jpeg.org</a>
5446 </p>
5447 !! end
5448
5449 # parsoid doesn't explicitly mark autonumbered links, see T55505
5450 !! test
5451 External links: URL within URL (T2002)
5452 !! wikitext
5453 [http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp]
5454 !! html/php
5455 <p><a rel="nofollow" class="external autonumber" href="http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp">[1]</a>
5456 </p>
5457 !! html/parsoid
5458 <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>
5459 !! end
5460
5461 !! test
5462 T2361: URL inside bracketed URL
5463 !! wikitext
5464 [http://www.example.com/foo http://www.example.com/bar]
5465 !! html
5466 <p><a rel="nofollow" class="external text" href="http://www.example.com/foo">http://www.example.com/bar</a>
5467 </p>
5468 !! end
5469
5470 !! test
5471 T2361: URL within URL, not bracketed
5472 !! wikitext
5473 http://www.example.com/foo?=http://www.example.com/bar
5474 !! html
5475 <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>
5476 </p>
5477 !! end
5478
5479 !! test
5480 T2289: ">"-token in URL-tail
5481 !! wikitext
5482 http://www.example.com/<hello>
5483 !! html
5484 <p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a>&lt;hello&gt;
5485 </p>
5486 !!end
5487
5488 !! test
5489 T2289: literal ">"-token in URL-tail
5490 !! wikitext
5491 http://www.example.com/<b>html</b>
5492 !! html/php
5493 <p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a><b>html</b>
5494 </p>
5495 !! html/parsoid
5496 <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>
5497 !! end
5498
5499 !! test
5500 T2289: ">"-token in bracketed URL
5501 !! wikitext
5502 [http://www.example.com/<hello> stuff]
5503 !! html
5504 <p><a rel="nofollow" class="external text" href="http://www.example.com/">&lt;hello&gt; stuff</a>
5505 </p>
5506 !!end
5507
5508 !! test
5509 T2289: literal ">"-token in bracketed URL
5510 !! wikitext
5511 [http://www.example.com/<b>html</b> stuff]
5512 !! html
5513 <p><a rel="nofollow" class="external text" href="http://www.example.com/"><b>html</b> stuff</a>
5514 </p>
5515 !!end
5516
5517 !! test
5518 T2289: literal double quote at end of URL
5519 !! wikitext
5520 http://www.example.com/"hello"
5521 !! html
5522 <p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a>"hello"
5523 </p>
5524 !!end
5525
5526 !! test
5527 T2289: literal double quote in bracketed URL
5528 !! wikitext
5529 [http://www.example.com/"hello" stuff]
5530 !! html
5531 <p><a rel="nofollow" class="external text" href="http://www.example.com/">"hello" stuff</a>
5532 </p>
5533 !!end
5534
5535 !! test
5536 External links: multiple legal whitespace is fine, Magnus. Don't break it please. (T7081)
5537 !! wikitext
5538 [http://www.example.com test]
5539 !! html
5540 <p><a rel="nofollow" class="external text" href="http://www.example.com">test</a>
5541 </p>
5542 !! end
5543
5544 !! test
5545 External links: link text with spaces
5546 !! wikitext
5547 [http://www.example.com a b c]
5548 [http://www.example.com ''a'' ''b'']
5549 !! html
5550 <p><a rel="nofollow" class="external text" href="http://www.example.com">a b c</a>
5551 <a rel="nofollow" class="external text" href="http://www.example.com"><i>a</i> <i>b</i></a>
5552 </p>
5553 !! end
5554
5555 # Note edge case difference between PHP and Parsoid here.
5556 !! test
5557 External links: wiki links within external link (T5695)
5558 !! options
5559 parsoid=wt2html,html2html
5560 !! wikitext
5561 [http://example.com [[wikilink]] embedded in ext link]
5562
5563 [http://example.com test [[wikilink]] embedded in ext link]
5564 !! html/php
5565 <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>
5566 </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>
5567 </p>
5568 !! html/parsoid
5569 <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>
5570 <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>
5571 !! end
5572
5573 !! test
5574 T2787: Links with one slash after the url protocol are invalid
5575 !! wikitext
5576 http:/example.com
5577
5578 [http:/example.com title]
5579 !! html
5580 <p>http:/example.com
5581 </p><p>[http:/example.com title]
5582 </p>
5583 !! end
5584
5585 !! test
5586 Bracketed external links with template-generated invalid target
5587 !! wikitext
5588 [{{echo|http:/example.com}} title]
5589 !! html
5590 <p>[http:/example.com title]
5591 </p>
5592 !! end
5593
5594 # wt2html only because Parsoid would want to add <nowiki>s coming from html
5595 !! test
5596 Broken wikilinks (but not external links) prevent templates from closing
5597 !! options
5598 parsoid=wt2html
5599 !! wikitext
5600 [http://example.com x
5601
5602 {{echo|[http://example.com x}}
5603
5604 [[Foo
5605
5606 {{echo|[[Foo}}
5607 !! html/php
5608 <p>[<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> x
5609 </p><p>[<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> x
5610 </p><p>[[Foo
5611 </p><p>{{echo|[[Foo}}
5612 </p>
5613 !! html/parsoid
5614 <p>[<a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a> x</p>
5615 <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>
5616 <p>[[Foo</p>
5617 <p>{{echo|[[Foo}}</p>
5618 !! end
5619
5620 !! test
5621 Wikilinks with embedded newlines are not broken
5622 !! wikitext
5623 {{echo|[[ Foo
5624 B
5625 C]]}}
5626 !! html/php
5627 <p>[[ Foo
5628 B
5629 C]]
5630 </p>
5631 !! html/parsoid
5632 <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>
5633 !! end
5634
5635 !! test
5636 Broken templates
5637 !! options
5638 parsoid=wt2html
5639 !! wikitext
5640 {{echo|[[Foo|}}]]
5641
5642 [[Foo|{{echo|]]}}
5643 !! html/php
5644 <p>{{echo|<a href="/wiki/Foo" title="Foo">}}</a>
5645 </p><p>[[Foo|]]
5646 </p>
5647 !! html/parsoid
5648 <p>{{echo|<a rel="mw:WikiLink" href="./Foo" title="Foo">}}</a></p>
5649 <p>[[Foo|<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"]]"}},"i":0}}]}'>]]</span></p>
5650 !! end
5651
5652 !! test
5653 T4702: Mismatched <i>, <b> and <a> tags are invalid
5654 !! wikitext
5655 ''[http://example.com text'']
5656 [http://example.com '''text]'''
5657 ''Something [http://example.com in italic'']
5658 ''Something [http://example.com mixed''''', even bold]'''
5659 '''''Now [http://example.com both''''']
5660 !! html
5661 <p><a rel="nofollow" class="external text" href="http://example.com"><i>text</i></a>
5662 <a rel="nofollow" class="external text" href="http://example.com"><b>text</b></a>
5663 <i>Something </i><a rel="nofollow" class="external text" href="http://example.com"><i>in italic</i></a>
5664 <i>Something </i><a rel="nofollow" class="external text" href="http://example.com"><i>mixed</i><b>, even bold</b></a>
5665 <i><b>Now </b></i><a rel="nofollow" class="external text" href="http://example.com"><i><b>both</b></i></a>
5666 </p>
5667 !! end
5668
5669
5670 !! test
5671 T6781: %26 in URL
5672 !! wikitext
5673 http://www.example.com/?title=AT%26T
5674 !! html/php
5675 <p><a rel="nofollow" class="external free" href="http://www.example.com/?title=AT%26T">http://www.example.com/?title=AT%26T</a>
5676 </p>
5677 !! html/parsoid
5678 <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>
5679 !! end
5680
5681 # According to https://www.w3.org/TR/2011/WD-html5-20110525/Overview.html#parsing-urls a plain
5682 # % is actually legal in HTML5. Any change in output would need testing though.
5683 !! test
5684 T6781, T7267: %25 in URL
5685 !! wikitext
5686 http://www.example.com/?title=100%25_Bran
5687 !! html/php
5688 <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>
5689 </p>
5690 !! html/parsoid
5691 <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>
5692 !! end
5693
5694 !! test
5695 T6781, T7267: %28, %29 in URL
5696 !! wikitext
5697 http://www.example.com/?title=Ben-Hur_%281959_film%29
5698 !! html/php
5699 <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>
5700 </p>
5701 !! html/parsoid
5702 <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>
5703 !! end
5704
5705
5706 !! test
5707 T6781: %26 in autonumber URL
5708 !! wikitext
5709 [http://www.example.com/?title=AT%26T]
5710 !! html/php
5711 <p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=AT%26T">[1]</a>
5712 </p>
5713 !! html/parsoid
5714 <p><a rel="mw:ExtLink" class="external autonumber" href="http://www.example.com/?title=AT%26T"></a></p>
5715 !! end
5716
5717 !! test
5718 T6781, T7267: %26 in autonumber URL
5719 !! wikitext
5720 [http://www.example.com/?title=100%25_Bran]
5721 !! html/php
5722 <p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=100%25_Bran">[1]</a>
5723 </p>
5724 !! html/parsoid
5725 <p><a rel="mw:ExtLink" class="external autonumber" href="http://www.example.com/?title=100%25_Bran"></a></p>
5726 !! end
5727
5728 !! test
5729 T6781, T7267: %28, %29 in autonumber URL
5730 !! wikitext
5731 [http://www.example.com/?title=Ben-Hur_%281959_film%29]
5732 !! html/php
5733 <p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">[1]</a>
5734 </p>
5735 !! html/parsoid
5736 <p><a rel="mw:ExtLink" class="external autonumber" href="http://www.example.com/?title=Ben-Hur_%281959_film%29"></a></p>
5737 !! end
5738
5739
5740 !! test
5741 T6781: %26 in bracketed URL
5742 !! wikitext
5743 [http://www.example.com/?title=AT%26T link]
5744 !! html/php
5745 <p><a rel="nofollow" class="external text" href="http://www.example.com/?title=AT%26T">link</a>
5746 </p>
5747 !! html/parsoid
5748 <p><a rel="mw:ExtLink" class="external text" href="http://www.example.com/?title=AT%26T">link</a></p>
5749 !! end
5750
5751 !! test
5752 T6781, T7267: %25 in bracketed URL
5753 !! wikitext
5754 [http://www.example.com/?title=100%25_Bran link]
5755 !! html
5756 <p><a rel="nofollow" class="external text" href="http://www.example.com/?title=100%25_Bran">link</a>
5757 </p>
5758 !! end
5759
5760 !! test
5761 T6781, T7267: %28, %29 in bracketed URL
5762 !! wikitext
5763 [http://www.example.com/?title=Ben-Hur_%281959_film%29 link]
5764 !! html/php
5765 <p><a rel="nofollow" class="external text" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">link</a>
5766 </p>
5767 !! html/parsoid
5768 <p><a rel="mw:ExtLink" class="external text" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">link</a></p>
5769 !! end
5770
5771 !! test
5772 External link containing a period in the anchor. (T65947)
5773 !! wikitext
5774 [//foo.org/bar#baz. bang]
5775
5776 [//foo.org/bar. bang]
5777 !! html/php
5778 <p><a rel="nofollow" class="external text" href="//foo.org/bar#baz.">bang</a>
5779 </p><p><a rel="nofollow" class="external text" href="//foo.org/bar.">bang</a>
5780 </p>
5781 !! html/parsoid
5782 <p><a rel="mw:ExtLink" class="external text" href="//foo.org/bar#baz.">bang</a></p>
5783 <p><a rel="mw:ExtLink" class="external text" href="//foo.org/bar.">bang</a></p>
5784 !! end
5785
5786 !! test
5787 External link containing a single quote. (T65947)
5788 !! wikitext
5789 [//foo.org/bar'baz]
5790
5791 [//foo.org/bar'baz bang]
5792 !! html/php
5793 <p><a rel="nofollow" class="external autonumber" href="//foo.org/bar&#39;baz">[1]</a>
5794 </p><p><a rel="nofollow" class="external text" href="//foo.org/bar&#39;baz">bang</a>
5795 </p>
5796 !! html/parsoid
5797 <p><a rel="mw:ExtLink" class="external autonumber" href="//foo.org/bar'baz"></a></p>
5798 <p><a rel="mw:ExtLink" class="external text" href="//foo.org/bar'baz">bang</a></p>
5799 !! end
5800
5801 !! test
5802 External link containing double-single-quotes in text '' (T6598 sanity check)
5803 !! wikitext
5804 Some [http://example.com/ pretty ''italics'' and stuff]!
5805 !! html
5806 <p>Some <a rel="nofollow" class="external text" href="http://example.com/">pretty <i>italics</i> and stuff</a>!
5807 </p>
5808 !! end
5809
5810 !! test
5811 External link containing double-single-quotes in text embedded in italics (T6598 sanity check)
5812 !! wikitext
5813 ''Some [http://example.com/ pretty ''italics'' and stuff]!''
5814 !! html
5815 <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>
5816 </p>
5817 !! end
5818
5819 # Don't add the html/php section since the output is broken and there isn't any reason to spec it
5820 !! test
5821 External link containing double-single-quotes with no space separating the url from text in italics
5822 !! wikitext
5823 [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]].]
5824 !! html/php+tidy
5825 <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>.
5826 </p>
5827 !! html/parsoid
5828 <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>
5829 !! end
5830
5831 !! test
5832 External link with comments in link text
5833 !! wikitext
5834 [http://www.google.com Google <!-- comment -->]
5835 !! html/php
5836 <p><a rel="nofollow" class="external text" href="http://www.google.com">Google </a>
5837 </p>
5838 !! html/parsoid
5839 <p><a rel="mw:ExtLink" class="external text" href="http://www.google.com">Google <!-- comment --></a></p>
5840 !! end
5841
5842 !! test
5843 External link to bare IPv4 address
5844 !! wikitext
5845 [http://192.168.0.1 Link]
5846 !! html/php
5847 <p><a rel="nofollow" class="external text" href="http://192.168.0.1">Link</a>
5848 </p>
5849 !! html/parsoid
5850 <p><a rel="mw:ExtLink" class="external text" href="http://192.168.0.1">Link</a></p>
5851 !! end
5852
5853 !! test
5854 URL-encoding in URL functions (single parameter)
5855 !! wikitext
5856 {{localurl:Some page|amp=&}}
5857 !! html
5858 <p>/index.php?title=Some_page&amp;amp=&amp;
5859 </p>
5860 !! end
5861
5862 !! test
5863 URL-encoding in URL functions (multiple parameters)
5864 !! wikitext
5865 {{localurl:Some page|q=?&amp=&}}
5866 !! html
5867 <p>/index.php?title=Some_page&amp;q=?&amp;amp=&amp;
5868 </p>
5869 !! end
5870
5871 !! test
5872 Brackets in urls
5873 !! wikitext
5874 http://example.com/index.php?foozoid%5B%5D=bar
5875
5876 http://example.com/index.php?foozoid&#x5B;&#x5D;=bar
5877 !! html/php
5878 <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>
5879 </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>
5880 </p>
5881 !! html/parsoid
5882 <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>
5883
5884 <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>
5885 !! end
5886
5887 !! test
5888 IPv6 urls, autolink format (T23261)
5889 !! wikitext
5890 http://[2404:130:0:1000::187:2]/index.php
5891
5892 Examples from RFC 2373, section 2.2:
5893
5894 *http://[1080::8:800:200C:417A]/unicast
5895 *http://[FF01::101]/multicast
5896 *http://[::1]/loopback
5897 *http://[::]/unspecified
5898 *http://[::13.1.68.3]/ipv4compat
5899 *http://[::FFFF:129.144.52.38]/ipv4compat
5900
5901 Examples from RFC 2732, section 2:
5902
5903 *http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html
5904 *http://[1080:0:0:0:8:800:200C:417A]/index.html
5905 *http://[3ffe:2a00:100:7031::1]
5906 *http://[1080::8:800:200C:417A]/foo
5907 *http://[::192.9.5.5]/ipng
5908 *http://[::FFFF:129.144.52.38]:80/index.html
5909 *http://[2010:836B:4179::836B:4179]
5910 !! html/php
5911 <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>
5912 </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:
5913 </p>
5914 <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>
5915 <li><a rel="nofollow" class="external free" href="http://[FF01::101]/multicast">http://[FF01::101]/multicast</a></li>
5916 <li><a rel="nofollow" class="external free" href="http://[::1]/loopback">http://[::1]/loopback</a></li>
5917 <li><a rel="nofollow" class="external free" href="http://[::]/unspecified">http://[::]/unspecified</a></li>
5918 <li><a rel="nofollow" class="external free" href="http://[::13.1.68.3]/ipv4compat">http://[::13.1.68.3]/ipv4compat</a></li>
5919 <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>
5920 <p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc2732">RFC 2732</a>, section 2:
5921 </p>
5922 <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>
5923 <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>
5924 <li><a rel="nofollow" class="external free" href="http://[3ffe:2a00:100:7031::1]">http://[3ffe:2a00:100:7031::1]</a></li>
5925 <li><a rel="nofollow" class="external free" href="http://[1080::8:800:200C:417A]/foo">http://[1080::8:800:200C:417A]/foo</a></li>
5926 <li><a rel="nofollow" class="external free" href="http://[::192.9.5.5]/ipng">http://[::192.9.5.5]/ipng</a></li>
5927 <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>
5928 <li><a rel="nofollow" class="external free" href="http://[2010:836B:4179::836B:4179]">http://[2010:836B:4179::836B:4179]</a></li></ul>
5929 !! html/parsoid
5930 <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>
5931
5932 <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>
5933 <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>
5934 <li><a rel="mw:ExtLink" class="external free" href="http://[FF01::101]/multicast">http://[FF01::101]/multicast</a></li>
5935 <li><a rel="mw:ExtLink" class="external free" href="http://[::1]/loopback">http://[::1]/loopback</a></li>
5936 <li><a rel="mw:ExtLink" class="external free" href="http://[::]/unspecified">http://[::]/unspecified</a></li>
5937 <li><a rel="mw:ExtLink" class="external free" href="http://[::13.1.68.3]/ipv4compat">http://[::13.1.68.3]/ipv4compat</a></li>
5938 <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>
5939
5940 <p>Examples from <a href="https://tools.ietf.org/html/rfc2732" rel="mw:ExtLink" class="external mw-magiclink">RFC 2732</a>, section 2:</p>
5941 <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>
5942 <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>
5943 <li><a rel="mw:ExtLink" class="external free" href="http://[3ffe:2a00:100:7031::1]">http://[3ffe:2a00:100:7031::1]</a></li>
5944 <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>
5945 <li><a rel="mw:ExtLink" class="external free" href="http://[::192.9.5.5]/ipng">http://[::192.9.5.5]/ipng</a></li>
5946 <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>
5947 <li><a rel="mw:ExtLink" class="external free" href="http://[2010:836B:4179::836B:4179]">http://[2010:836B:4179::836B:4179]</a></li></ul>
5948 !! end
5949
5950 !! test
5951 IPv6 urls, bracketed format (T23261)
5952 !! wikitext
5953 [http://[2404:130:0:1000::187:2]/index.php test]
5954
5955 Examples from RFC 2373, section 2.2:
5956
5957 *[http://[1080::8:800:200C:417A] unicast]
5958 *[http://[FF01::101] multicast]
5959 *[http://[::1]/ loopback]
5960 *[http://[::] unspecified]
5961 *[http://[::13.1.68.3] ipv4compat]
5962 *[http://[::FFFF:129.144.52.38] ipv4compat]
5963
5964 Examples from RFC 2732, section 2:
5965
5966 *[http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html 1]
5967 *[http://[1080:0:0:0:8:800:200C:417A]/index.html 2]
5968 *[http://[3ffe:2a00:100:7031::1] 3]
5969 *[http://[1080::8:800:200C:417A]/foo 4]
5970 *[http://[::192.9.5.5]/ipng 5]
5971 *[http://[::FFFF:129.144.52.38]:80/index.html 6]
5972 *[http://[2010:836B:4179::836B:4179] 7]
5973 !! html/php
5974 <p><a rel="nofollow" class="external text" href="http://[2404:130:0:1000::187:2]/index.php">test</a>
5975 </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:
5976 </p>
5977 <ul><li><a rel="nofollow" class="external text" href="http://[1080::8:800:200C:417A]">unicast</a></li>
5978 <li><a rel="nofollow" class="external text" href="http://[FF01::101]">multicast</a></li>
5979 <li><a rel="nofollow" class="external text" href="http://[::1]/">loopback</a></li>
5980 <li><a rel="nofollow" class="external text" href="http://[::]">unspecified</a></li>
5981 <li><a rel="nofollow" class="external text" href="http://[::13.1.68.3]">ipv4compat</a></li>
5982 <li><a rel="nofollow" class="external text" href="http://[::FFFF:129.144.52.38]">ipv4compat</a></li></ul>
5983 <p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc2732">RFC 2732</a>, section 2:
5984 </p>
5985 <ul><li><a rel="nofollow" class="external text" href="http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html">1</a></li>
5986 <li><a rel="nofollow" class="external text" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">2</a></li>
5987 <li><a rel="nofollow" class="external text" href="http://[3ffe:2a00:100:7031::1]">3</a></li>
5988 <li><a rel="nofollow" class="external text" href="http://[1080::8:800:200C:417A]/foo">4</a></li>
5989 <li><a rel="nofollow" class="external text" href="http://[::192.9.5.5]/ipng">5</a></li>
5990 <li><a rel="nofollow" class="external text" href="http://[::FFFF:129.144.52.38]:80/index.html">6</a></li>
5991 <li><a rel="nofollow" class="external text" href="http://[2010:836B:4179::836B:4179]">7</a></li></ul>
5992 !! html/parsoid
5993 <p><a rel="mw:ExtLink" class="external text" href="http://[2404:130:0:1000::187:2]/index.php">test</a></p>
5994
5995 <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>
5996 <ul><li><a rel="mw:ExtLink" class="external text" href="http://[1080::8:800:200C:417A]">unicast</a></li>
5997 <li><a rel="mw:ExtLink" class="external text" href="http://[FF01::101]">multicast</a></li>
5998 <li><a rel="mw:ExtLink" class="external text" href="http://[::1]/">loopback</a></li>
5999 <li><a rel="mw:ExtLink" class="external text" href="http://[::]">unspecified</a></li>
6000 <li><a rel="mw:ExtLink" class="external text" href="http://[::13.1.68.3]">ipv4compat</a></li>
6001 <li><a rel="mw:ExtLink" class="external text" href="http://[::FFFF:129.144.52.38]">ipv4compat</a></li></ul>
6002
6003 <p>Examples from <a href="https://tools.ietf.org/html/rfc2732" rel="mw:ExtLink" class="external mw-magiclink">RFC 2732</a>, section 2:</p>
6004 <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>
6005 <li><a rel="mw:ExtLink" class="external text" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">2</a></li>
6006 <li><a rel="mw:ExtLink" class="external text" href="http://[3ffe:2a00:100:7031::1]">3</a></li>
6007 <li><a rel="mw:ExtLink" class="external text" href="http://[1080::8:800:200C:417A]/foo">4</a></li>
6008 <li><a rel="mw:ExtLink" class="external text" href="http://[::192.9.5.5]/ipng">5</a></li>
6009 <li><a rel="mw:ExtLink" class="external text" href="http://[::FFFF:129.144.52.38]:80/index.html">6</a></li>
6010 <li><a rel="mw:ExtLink" class="external text" href="http://[2010:836B:4179::836B:4179]">7</a></li></ul>
6011 !! end
6012
6013 !! test
6014 Non-extlinks in brackets
6015 !! wikitext
6016 [foo]
6017 [foo bar]
6018 [foo ''bar'']
6019 [fool's] errand
6020 [fool's errand]
6021 [{{echo|foo}}]
6022 [{{echo|foo}} bar]
6023 [{{echo|foo}} ''bar'']
6024 [{{echo|foo}}l's] errand
6025 [{{echo|foo}}l's errand]
6026 [url={{echo|foo}}]
6027 [url=http://example.com]
6028 [http:// bare protocols don't count]
6029 !! html/php
6030 <p>[foo]
6031 [foo bar]
6032 [foo <i>bar</i>]
6033 [fool's] errand
6034 [fool's errand]
6035 [foo]
6036 [foo bar]
6037 [foo <i>bar</i>]
6038 [fool's] errand
6039 [fool's errand]
6040 [url=foo]
6041 [url=<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>]
6042 [http:// bare protocols don't count]
6043 </p>
6044 !! html/parsoid
6045 <p>[foo]
6046 [foo bar]
6047 [foo <i>bar</i>]
6048 [fool's] errand
6049 [fool's errand]
6050 [<span about="#mwt19" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</span>]
6051 [<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]
6052 [<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>]
6053 [<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
6054 [<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]
6055 [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>]
6056 [url=<a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>]
6057 [http:// bare protocols don't count]</p>
6058 !! end
6059
6060 !! test
6061 Percent encoding in external links
6062 !! wikitext
6063 [https://github.com/search?l=&q=ResourceLoader+%40wikimedia Search]
6064 !! html/php
6065 <p><a rel="nofollow" class="external text" href="https://github.com/search?l=&amp;q=ResourceLoader+%40wikimedia">Search</a>
6066 </p>
6067 !! html/parsoid
6068 <p><a rel="mw:ExtLink" class="external text" href="https://github.com/search?l=&amp;q=ResourceLoader+%40wikimedia">Search</a></p>
6069 !! end
6070
6071 !! test
6072 Use url link syntax for links where the content is equal the link target
6073 !! wikitext
6074 http://example.com
6075 !! html/php
6076 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
6077 </p>
6078 !! html/parsoid
6079 <p><a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a></p>
6080 !! end
6081
6082 !! test
6083 Parenthesis in external links, especially URL links
6084 !! wikitext
6085 http://example.com)
6086
6087 http://example.com/test)
6088
6089 http://example.com/(test)
6090
6091 http://example.com/((test)
6092
6093 (http://example.com/(test))
6094
6095 (http://example.com/(test)))))
6096
6097 http://example.com/a)b
6098
6099 [http://example.com) foo]
6100 !! html/php
6101 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</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/((test)">http://example.com/((test)</a>
6105 </p><p>(<a rel="nofollow" class="external free" href="http://example.com/(test))">http://example.com/(test))</a>
6106 </p><p>(<a rel="nofollow" class="external free" href="http://example.com/(test)))))">http://example.com/(test)))))</a>
6107 </p><p><a rel="nofollow" class="external free" href="http://example.com/a)b">http://example.com/a)b</a>
6108 </p><p><a rel="nofollow" class="external text" href="http://example.com)">foo</a>
6109 </p>
6110 !! html/parsoid
6111 <p><a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</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/((test)">http://example.com/((test)</a></p>
6115 <p>(<a rel="mw:ExtLink" class="external free" href="http://example.com/(test))">http://example.com/(test))</a></p>
6116 <p>(<a rel="mw:ExtLink" class="external free" href="http://example.com/(test)))))">http://example.com/(test)))))</a></p>
6117 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/a)b">http://example.com/a)b</a></p>
6118 <p><a rel="mw:ExtLink" class="external text" href="http://example.com)">foo</a></p>
6119 !! end
6120
6121 !! test
6122 Parenthesis in external links, w/ transclusion or comment
6123 !! wikitext
6124 (http://example.com/{{echo|hi}})
6125
6126 (http://example.com<!-- hi -->)
6127 !! html/php
6128 <p>(<a rel="nofollow" class="external free" href="http://example.com/hi">http://example.com/hi</a>)
6129 </p><p>(<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
6130 </p>
6131 !! html/parsoid
6132 <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>
6133
6134 <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>
6135 !! end
6136
6137 !! test
6138 Serialize <a> tags with invalid link targets as plain text
6139 !! options
6140 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
6141 !! html/parsoid
6142 <a rel="mw:WikiLink" href="[[foo]]">text</a>
6143 <a rel="mw:WikiLink" href="[[foo]]">*text</a>
6144 <a rel="mw:WikiLink" href="[[foo]]">[[foo]]</a>
6145 <a rel="mw:WikiLink" href="[[foo]]">*a [[foo]]</a>
6146 !! wikitext
6147 text
6148 <nowiki>*</nowiki>text
6149 <nowiki>[[foo]]</nowiki>
6150 <nowiki>*</nowiki>a <nowiki>[[foo]]</nowiki>
6151 !! end
6152
6153 !! test
6154 mw:ExtLink -vs- mw:WikiLink (T94723)
6155 !! options
6156 parsoid=html2wt
6157 !! html/parsoid
6158 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"piped","a":{"href":"./Foo"},"sa":{"href":"Foo"}}'>Bar</a>
6159 <a rel="mw:WikiLink" href="./Foo" title="Foo">Bar</a>
6160 <a rel="mw:WikiLink" href="http://en.wikipedia.org/wiki/Foo" title="Foo">Bar</a>
6161 <a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/Foo" title="Foo">Bar</a>
6162 <p>
6163 <a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/European_Robin">European Robin</a>
6164 <a rel="mw:WikiLink" href="http://en.wikipedia.org/wiki/European_Robin">European Robin</a>
6165 </p>
6166 !! wikitext
6167 [[Foo|Bar]]
6168 [[Foo|Bar]]
6169 [[:en:Foo|Bar]]
6170 [[:en:Foo|Bar]]
6171
6172 [[:en:European_Robin|European Robin]]
6173 [[:en:European_Robin|European Robin]]
6174 !! end
6175
6176 !! test
6177 mw:ExtLink linking to a interwiki URL can be round-tripped losslessly (T94723)
6178 !! options
6179 parsoid=wt2wt
6180 !! wikitext
6181 [http://en.wikipedia.org/wiki/European_Robin European Robin]
6182 !! html/parsoid
6183 THIS SECTION IS NOT USED (but Parsoid won't run the test without it)
6184 !! end
6185
6186
6187 ###
6188 ### Quotes
6189 ###
6190
6191 !! test
6192 Quotes
6193 !! wikitext
6194 Normal text. '''Bold text.''' Normal text. ''Italic text.''
6195
6196 Normal text. '''''Bold italic text.''''' Normal text.
6197 !! html
6198 <p>Normal text. <b>Bold text.</b> Normal text. <i>Italic text.</i>
6199 </p><p>Normal text. <i><b>Bold italic text.</b></i> Normal text.
6200 </p>
6201 !! end
6202
6203 !! test
6204 Quotes wrapping HTML table
6205 !! wikitext
6206 '''<table><tr><td>hi</td></tr></table>'''
6207 !! html/php+tidy
6208 <b><table><tbody><tr><td>hi</td></tr></tbody></table></b>
6209 !! html/parsoid
6210 <b><table data-parsoid='{"stx":"html"}'><tbody><tr data-parsoid='{"stx":"html"}'><td data-parsoid='{"stx":"html"}'>hi</td></tr></tbody></table></b>
6211 !! end
6212
6213 # Parsoid inserts an empty bold tag pair at the end of the line, that the PHP
6214 # parser strips. The wikitext contains just the first half of the bold
6215 # quote pair.
6216 !! test
6217 Unclosed and unmatched quotes
6218 !! wikitext
6219 '''''Bold italic text '''with bold deactivated''' in between.'''''
6220
6221 '''''Bold italic text ''with italic deactivated'' in between.'''''
6222
6223 '''Bold text..
6224
6225 ..spanning two paragraphs (should not work).'''
6226
6227 '''Bold tag left open
6228
6229 ''Italic tag left open
6230
6231 Normal text.
6232
6233 <!-- Unmatching number of opening, closing tags: -->
6234 '''This year''''s election ''should'' beat '''last year''''s.
6235
6236 ''Tom'''s car is bigger than ''Susan'''s.
6237
6238 Plain ''italic'''s plain
6239 !! html/php
6240 <p><i><b>Bold italic text </b>with bold deactivated<b> in between.</b></i>
6241 </p><p><b><i>Bold italic text </i>with italic deactivated<i> in between.</i></b>
6242 </p><p><b>Bold text..</b>
6243 </p><p>..spanning two paragraphs (should not work).
6244 </p><p><b>Bold tag left open</b>
6245 </p><p><i>Italic tag left open</i>
6246 </p><p>Normal text.
6247 </p><p><b>This year'</b>s election <i>should</i> beat <b>last year'</b>s.
6248 </p><p><i>Tom<b>s car is bigger than </b></i><b>Susan</b>s.
6249 </p><p>Plain <i>italic'</i>s plain
6250 </p>
6251 !! html/parsoid
6252 <p><i><b>Bold italic text </b>with bold deactivated<b> in between.</b></i>
6253 </p><p><b><i>Bold italic text </i>with italic deactivated<i> in between.</i></b>
6254 </p><p><b>Bold text..</b>
6255 </p><p>..spanning two paragraphs (should not work).<b></b>
6256 </p><p><b>Bold tag left open</b>
6257 </p><p><i>Italic tag left open</i>
6258 </p><p>Normal text.
6259 </p>
6260 <!-- Unmatching number of opening, closing tags: -->
6261 <p><b>This year'</b>s election <i>should</i> beat <b>last year'</b>s.
6262 </p><p><i>Tom<b>s car is bigger than </b></i><b>Susan</b>s.
6263 </p><p>Plain <i>italic'</i>s plain
6264 </p>
6265 !! end
6266
6267 ###
6268 ### Tables
6269 ###
6270 ### some content taken from http://meta.wikimedia.org/wiki/MediaWiki_User%27s_Guide:_Using_tables
6271 ###
6272
6273 # This should not produce <table></table> as <table><tr><td></td></tr></table>
6274 # is the bare minimum required by the spec, see:
6275 # https://www.w3.org/TR/xhtml-modularization/dtd_module_defs.html#a_module_Basic_Tables
6276 # Parsoid team replies: empty table tags are legal in HTML5
6277 !! test
6278 A table with no data.
6279 !! options
6280 parsoid=wt2html
6281 !! wikitext
6282 {||}
6283 !! html/php
6284
6285 !! html/parsoid
6286 <table></table>
6287
6288 !! end
6289
6290 !! test
6291 A table with stray table end tags on start tag line (wt2html)
6292 !! options
6293 parsoid=wt2html
6294 !! wikitext
6295 {|style="color: red;"|}
6296
6297 {|style="color: red;" |}
6298 |foo
6299 |}
6300
6301 {|style="color: red;"|} id="foo"
6302 |foo
6303 |}
6304
6305 {|style="color: red;" |} id="foo"
6306 |foo
6307 |}
6308 !! html/php+tidy
6309 <table style="color: red;">
6310
6311 </table><table style="color: red;">
6312 <tbody><tr>
6313 <td>foo
6314 </td></tr></tbody></table>
6315 <table style="color: red;" id="foo">
6316 <tbody><tr>
6317 <td>foo
6318 </td></tr></tbody></table>
6319 <table style="color: red;" id="foo">
6320 <tbody><tr>
6321 <td>foo
6322 </td></tr></tbody></table>
6323 !! html/parsoid
6324 <table style="color: red;"></table>
6325
6326 <table style="color: red;">
6327 <tbody><tr>
6328 <td>foo</td>
6329 </tr></tbody>
6330 </table>
6331
6332 <table style="color: red;" id="foo">
6333 <tbody><tr>
6334 <td>foo</td>
6335 </tr></tbody>
6336 </table>
6337
6338 <table style="color: red;" id="foo">
6339 <tbody><tr>
6340 <td>foo</td>
6341 </tr></tbody>
6342 </table>
6343
6344 !! end
6345
6346 !! test
6347 A table with no data (take 2)
6348 !! wikitext
6349 {|
6350 |}
6351 !! html/parsoid
6352 <table></table>
6353 !! end
6354
6355 # A table with nothing but a caption is invalid XHTML, we might want to render
6356 # this as <p>caption</p>
6357 # Parsoid team replies: table with only a caption is legal in HTML5
6358 !! test
6359 A table with nothing but a caption
6360 !! wikitext
6361 {|
6362 |+caption
6363 |}
6364 !! html/php
6365 <table>
6366 <caption>caption
6367 </caption><tr><td></td></tr></table>
6368
6369 !! html/parsoid
6370 <table><caption>caption</caption></table>
6371 !! end
6372
6373 !! test
6374 A table with caption with default-spaced attributes and a table row
6375 !! wikitext
6376 {|
6377 |+ style="color: red;" |caption1
6378 |-
6379 |foo
6380 |}
6381 !! html
6382 <table>
6383 <caption style="color: red;">caption1
6384 </caption>
6385 <tr>
6386 <td>foo
6387 </td></tr></table>
6388
6389 !! end
6390
6391 !! test
6392 A table with captions with non-default spaced attributes and a table row
6393 !! wikitext
6394 {|
6395 |+style="color: red;"|caption2
6396 |+ style="color: red;"|caption3
6397 |-
6398 |foo
6399 |}
6400 !! html
6401 <table>
6402 <caption style="color: red;">caption2
6403 </caption>
6404 <caption style="color: red;">caption3
6405 </caption>
6406 <tr>
6407 <td>foo
6408 </td></tr></table>
6409
6410 !! end
6411
6412 !! test
6413 Table td-cell syntax variations
6414 !! wikitext
6415 {|
6416 |foo bar foo|baz
6417 |foo bar foo||baz
6418 |style='color:red;'|baz
6419 |style='color:red;'||baz
6420 |}
6421 !! html
6422 <table>
6423 <tr>
6424 <td>baz
6425 </td>
6426 <td>foo bar foo</td>
6427 <td>baz
6428 </td>
6429 <td style="color:red;">baz
6430 </td>
6431 <td>style='color:red;'</td>
6432 <td>baz
6433 </td></tr></table>
6434
6435 !! end
6436
6437 !! test
6438 Simple table
6439 !! wikitext
6440 {|
6441 |1||2
6442 |-
6443 |3||4
6444 |}
6445 !! html
6446 <table>
6447 <tr>
6448 <td>1</td>
6449 <td>2
6450 </td></tr>
6451 <tr>
6452 <td>3</td>
6453 <td>4
6454 </td></tr></table>
6455
6456 !! end
6457
6458 !! test
6459 Simple table but with multiple dashes for row wikitext
6460 !! wikitext
6461 {|
6462 |foo
6463 |-----
6464 |bar
6465 |}
6466 !! html
6467 <table>
6468 <tr>
6469 <td>foo
6470 </td></tr>
6471 <tr>
6472 <td>bar
6473 </td></tr></table>
6474
6475 !! end
6476
6477 !! test
6478 Multiplication table
6479 !! wikitext
6480 {| border="1" cellpadding="2"
6481 |+Multiplication table
6482 |-
6483 !&times;!!1!!2!!3
6484 |-
6485 !1
6486 |1||2||3
6487 |-
6488 !2
6489 |2||4||6
6490 |-
6491 !3
6492 |3||6||9
6493 |-
6494 !4
6495 |4||8||12
6496 |-
6497 !5
6498 |5||10||15
6499 |}
6500 !! html
6501 <table border="1" cellpadding="2">
6502 <caption>Multiplication table
6503 </caption>
6504 <tr>
6505 <th>&#215;</th>
6506 <th>1</th>
6507 <th>2</th>
6508 <th>3
6509 </th></tr>
6510 <tr>
6511 <th>1
6512 </th>
6513 <td>1</td>
6514 <td>2</td>
6515 <td>3
6516 </td></tr>
6517 <tr>
6518 <th>2
6519 </th>
6520 <td>2</td>
6521 <td>4</td>
6522 <td>6
6523 </td></tr>
6524 <tr>
6525 <th>3
6526 </th>
6527 <td>3</td>
6528 <td>6</td>
6529 <td>9
6530 </td></tr>
6531 <tr>
6532 <th>4
6533 </th>
6534 <td>4</td>
6535 <td>8</td>
6536 <td>12
6537 </td></tr>
6538 <tr>
6539 <th>5
6540 </th>
6541 <td>5</td>
6542 <td>10</td>
6543 <td>15
6544 </td></tr></table>
6545
6546 !! end
6547
6548 !! test
6549 Accept "||" in table headings
6550 !! wikitext
6551 {|
6552 !h1||h2
6553 |}
6554 !! html
6555 <table>
6556 <tr>
6557 <th>h1</th>
6558 <th>h2
6559 </th></tr></table>
6560
6561 !! end
6562
6563 !! test
6564 Accept "!!" in table data
6565 !! wikitext
6566 {|
6567 |Foo!!||
6568 |}
6569 !! html
6570 <table>
6571 <tr>
6572 <td>Foo!!</td>
6573 <td>
6574 </td></tr></table>
6575
6576 !! html/parsoid
6577 <table>
6578 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'> Foo!! </td><td data-parsoid='{"stx":"row","autoInsertedEnd":true}'></td></tr>
6579 </tbody></table>
6580 !! end
6581
6582 !! test
6583 Accept "||" in indented table headings
6584 !! wikitext
6585 :{|
6586 !h1||h2
6587 |}
6588 !! html
6589 <dl><dd><table>
6590 <tr>
6591 <th>h1</th>
6592 <th>h2
6593 </th></tr></table></dd></dl>
6594
6595 !! end
6596
6597 !! test
6598 Accept "!!" in templates
6599 !! wikitext
6600 {|
6601 !a {{echo|b!!c}}
6602 |}
6603 !! html/php
6604 <table>
6605 <tr>
6606 <th>a b</th>
6607 <th>c
6608 </th></tr></table>
6609
6610 !! html/parsoid
6611 <table>
6612 <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>
6613 !! end
6614
6615 !! test
6616 Accept "!!" in table headings after newline
6617 !! wikitext
6618 {|
6619 !a
6620 b!!c
6621 |}
6622 !! html/php
6623 <table>
6624 <tr>
6625 <th>a
6626 <p>b!!c
6627 </p>
6628 </th></tr></table>
6629
6630 !! html/parsoid
6631 <table>
6632 <tbody><tr><th>a
6633 <p>b!!c</p></th></tr>
6634 </tbody></table>
6635 !! end
6636
6637 !! test
6638 Accept "!!" in table data of mixed wikitext / html syntax
6639 !! wikitext
6640 {|
6641 !a
6642 <tr><td>b!!c</td></tr>
6643 |}
6644 !! html/php+tidy
6645 <table>
6646 <tbody><tr>
6647 <th>a
6648 </th></tr><tr><td>b!!c</td></tr>
6649 </tbody></table>
6650 !! html/parsoid
6651 <table>
6652 <tbody><tr><th>a</th></tr>
6653 <tr data-parsoid='{"stx":"html"}'><td data-parsoid='{"stx":"html"}'>b!!c</td></tr>
6654 </tbody></table>
6655 !! end
6656
6657 !! test
6658 Accept empty attributes in td/th cells (td/th cells starting with leading ||)
6659 !! wikitext
6660 {|
6661 !|h1
6662 ||a
6663 |}
6664 !! html
6665 <table>
6666 <tr>
6667 <th>h1
6668 </th>
6669 <td>a
6670 </td></tr></table>
6671
6672 !! end
6673
6674 !!test
6675 Accept "| !" at start of line in tables (ignore !-attribute)
6676 !! wikitext
6677 {|
6678 |-
6679 |!style="color:red"|bar
6680 |}
6681 !! html
6682 <table>
6683
6684 <tr>
6685 <td>bar
6686 </td></tr></table>
6687
6688 !!end
6689
6690 !!test
6691 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 +/-
6692 !! wikitext
6693 {|
6694 |-
6695 |style='color:red;'|+1
6696 |style='color:blue;'|-1
6697 |-
6698 |1||2||3
6699 |1||+2||-3
6700 |-
6701 | +1
6702 | -1
6703 |}
6704 !! html
6705 <table>
6706
6707 <tr>
6708 <td style="color:red;">+1
6709 </td>
6710 <td style="color:blue;">-1
6711 </td></tr>
6712 <tr>
6713 <td>1</td>
6714 <td>2</td>
6715 <td>3
6716 </td>
6717 <td>1</td>
6718 <td>+2</td>
6719 <td>-3
6720 </td></tr>
6721 <tr>
6722 <td>+1
6723 </td>
6724 <td>-1
6725 </td></tr></table>
6726
6727 !!end
6728
6729 !! test
6730 Table rowspan
6731 !! wikitext
6732 {| border=1
6733 |Cell 1, row 1
6734 |rowspan=2|Cell 2, row 1 (and 2)
6735 |Cell 3, row 1
6736 |-
6737 |Cell 1, row 2
6738 |Cell 3, row 2
6739 |}
6740 !! html
6741 <table border="1">
6742 <tr>
6743 <td>Cell 1, row 1
6744 </td>
6745 <td rowspan="2">Cell 2, row 1 (and 2)
6746 </td>
6747 <td>Cell 3, row 1
6748 </td></tr>
6749 <tr>
6750 <td>Cell 1, row 2
6751 </td>
6752 <td>Cell 3, row 2
6753 </td></tr></table>
6754
6755 !! end
6756
6757 !! test
6758 Nested table
6759 !! wikitext
6760 {| border=1
6761 | &alpha;
6762 |
6763 {| bgcolor=#ABCDEF border=2
6764 |nested
6765 |-
6766 |table
6767 |}
6768 |the original table again
6769 |}
6770 !! html
6771 <table border="1">
6772 <tr>
6773 <td>&#945;
6774 </td>
6775 <td>
6776 <table bgcolor="#ABCDEF" border="2">
6777 <tr>
6778 <td>nested
6779 </td></tr>
6780 <tr>
6781 <td>table
6782 </td></tr></table>
6783 </td>
6784 <td>the original table again
6785 </td></tr></table>
6786
6787 !! end
6788
6789 !! test
6790 Invalid attributes in table cell (T3830)
6791 !! wikitext
6792 {|
6793 |Cell:|broken
6794 |}
6795 !! html
6796 <table>
6797 <tr>
6798 <td>broken
6799 </td></tr></table>
6800
6801 !! end
6802
6803 !! test
6804 Table cell attributes: Pipes protected by nowikis should be treated as a plain character
6805 !! wikitext
6806 {|
6807 |title="foo" |bar
6808 |title="foo<nowiki>|</nowiki>" |bar
6809 |title="foo<nowiki>|</nowiki>" bar
6810 |}
6811 !! html/php
6812 <table>
6813 <tr>
6814 <td title="foo">bar
6815 </td>
6816 <td title="foo&#124;">bar
6817 </td>
6818 <td>title="foo|" bar
6819 </td></tr></table>
6820
6821 !! html/parsoid
6822 <table>
6823 <tbody><tr><td title="foo">bar</td>
6824 <td title="foo|" about="#mwt3" typeof="mw:ExpandedAttrs" data-parsoid='{"a":{"title":"foo|"},"sa":{"title":"foo&lt;nowiki>|&lt;/nowiki>"}}' data-mw='{"attribs":[[{"txt":"title"},{"html":"foo&lt;span typeof=\"mw:Nowiki\" data-parsoid=&apos;{\"dsr\":[32,50,8,9]}&apos;>|&lt;/span>"}]]}'>bar</td>
6825 <td>title="foo<span typeof="mw:Nowiki">|</span>" bar</td></tr>
6826 </tbody></table>
6827 !! end
6828
6829 # See: http://lists.wikimedia.org/mailman/htdig/wikitech-l/2006-April/022293.html
6830 # N.B. The "|}" to close the table is missing from the input, so parsoid's
6831 # *2wt modes will fail.
6832 !! test
6833 Table security: embedded pipes
6834 !! options
6835 parsoid=wt2html,html2html
6836 !! wikitext
6837 {|
6838 | |[ftp://|x||]" onmouseover="alert(document.cookie)">test
6839 !! html/php
6840 <table>
6841 <tr>
6842 <td>[<a rel="nofollow" class="external free" href="ftp://%7Cx">ftp://%7Cx</a></td>
6843 <td>]" onmouseover="alert(document.cookie)"&gt;test
6844 </td>
6845 </tr>
6846 </table>
6847
6848 !! html/parsoid
6849 <table><tbody>
6850 <tr>
6851 <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>
6852 !! end
6853
6854 !! test
6855 Element attributes with double ! should not be broken up by <th>
6856 !! wikitext
6857 {|
6858 !hi <div class="!!">ha</div> ho
6859 |}
6860 !! html/php
6861 <table>
6862 <tr>
6863 <th>hi <div class="!!">ha</div> ho
6864 </th></tr></table>
6865
6866 !! html/parsoid
6867 <table>
6868 <tbody><tr><th>hi <div class="!!" data-parsoid='{"stx":"html"}'>ha</div> ho</th></tr>
6869 </tbody></table>
6870 !! end
6871
6872 !! test
6873 ! and || in element attributes should not be parsed as <th>/<td>
6874 !! wikitext
6875 {|
6876 |<div style="color: red !important;" data-contrived="put this here ||">hi</div>
6877 |}
6878 !! html/php
6879 <table>
6880 <tr>
6881 <td><div style="color: red !important;" data-contrived="put this here &#124;&#124;">hi</div>
6882 </td></tr></table>
6883
6884 !! html/parsoid
6885 <table>
6886 <tbody><tr><td><div style="color: red !important;" data-contrived="put this here ||" data-parsoid='{"stx":"html"}'>hi</div></td></tr>
6887 </tbody></table>
6888 !! end
6889
6890 # FIXME: The output seems broken. Filed as T110268.
6891 !! test
6892 ! and || in td attributes should not be parsed as <th>/<td>
6893 !! options
6894 parsoid=wt2html
6895 !! wikitext
6896 {|
6897 |style="color: red !important;" data-contrived="put this here ||"|foo
6898 |}
6899 !! html/php
6900 <table>
6901 <tr>
6902 <td>style="color: red !important;" data-contrived="put this here</td>
6903 <td>foo
6904 </td></tr></table>
6905
6906 !! html/parsoid
6907 <table>
6908 <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>
6909 </tbody></table>
6910 !! end
6911
6912 !! test
6913 Break on | in element attribute in template
6914 !! options
6915 parsoid=wt2html,html2html
6916 !! wikitext
6917 {{echo|1=<div class="hi|ho">ha</div>}}
6918 !! html/php
6919 <p>ho"&gt;ha&lt;/div&gt;
6920 </p>
6921 !! html/parsoid
6922 <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>
6923 !! end
6924
6925 !! test
6926 Break on | in element attribute name in template
6927 !! wikitext
6928 {{echo|<div cla|ss="hiho">ha</div>}}
6929 !! html/parsoid
6930 <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>
6931 !! end
6932
6933 !! test
6934 Don't break on | in extension attribute in template
6935 !! wikitext
6936 {{echo|<ref name="hi|ho">ha</ref>}}
6937
6938 <references />
6939 !! html/parsoid
6940 <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>
6941
6942 <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>
6943 !! end
6944
6945 ## We don't support roundtripping of these attributes in Parsoid.
6946 ## Selective serialization takes care of preventing dirty diffs.
6947 ## But, on edits, we dirty-diff the invalid attribute text.
6948 !! test
6949 Invalid text in table attributes should be discarded
6950 !! options
6951 parsoid=wt2html
6952 !! wikitext
6953 {| <span>boo</span> style='border:1px solid black'
6954 | <span>boo</span> style='color:blue' |1
6955 |<span>boo</span> style='color:blue'|2
6956 |}
6957 !! html/php
6958 <table style="border:1px solid black">
6959 <tr>
6960 <td style="color:blue">1
6961 </td>
6962 <td style="color:blue">2
6963 </td></tr></table>
6964
6965 !! html/parsoid
6966 <table style="border:1px solid black">
6967 <tr>
6968 <td style="color:blue">1</td>
6969 <td style="color:blue">2</td>
6970 </tr>
6971 </table>
6972 !! end
6973
6974 !! test
6975 Invalid text in table attributes should be preserved by selective serializer
6976 !! options
6977 parsoid={
6978 "modes": ["selser"],
6979 "changes": [
6980 ["td:first-child", "text", "abc"],
6981 ["td + td", "text", "xyz"]
6982 ]
6983 }
6984 !! wikitext
6985 {| <span>boo</span> style='border:1px solid black'
6986 | <span>boo</span> style='color:blue' | 1
6987 |<span>boo</span> style='color:blue'| 2
6988 |}
6989 !! wikitext/edited
6990 {| <span>boo</span> style='border:1px solid black'
6991 | <span>boo</span> style='color:blue' | abc
6992 |<span>boo</span> style='color:blue'| xyz
6993 |}
6994 !! end
6995
6996 !! test
6997 1. Template-generated table cell attributes and cell content
6998 !! wikitext
6999 {|
7000 |{{table_attribs}}
7001 | {{table_attribs}}
7002 || {{table_attribs_5}}
7003 | <!--foo--> <!--bar--> <!--baz--> {{table_attribs}}
7004 |align=center {{table_attribs}}
7005 | <!--foo--> align=center <!--bar--> {{table_attribs}}
7006 |}
7007 !! html
7008 <table>
7009 <tr>
7010 <td style="color:red;">Foo
7011 </td>
7012 <td style="color:red;">Foo
7013 </td>
7014 <td>style="color:red;"</td>
7015 <td>Bar
7016 </td>
7017 <td style="color:red;">Foo
7018 </td>
7019 <td align="center" style="color:red;">Foo
7020 </td>
7021 <td align="center" style="color:red;">Foo
7022 </td></tr></table>
7023
7024 !! end
7025
7026 !! test
7027 2. Template-generated table cell attributes and cell content
7028 !! wikitext
7029 {|
7030 |{{table_attribs_2}}
7031 |}
7032 !! html/php
7033 <table>
7034 <tr>
7035 <td style="color:red;">Foo
7036 </td>
7037 <td>Bar</td>
7038 <td>Baz
7039 </td></tr></table>
7040
7041 !! html/parsoid
7042 <table>
7043 <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>
7044 <td about="#mwt1">Bar</td><td about="#mwt1">Baz</td></tr>
7045 </tbody></table>
7046 !! end
7047
7048 !! test
7049 3. Template-generated table cell attributes and cell content
7050 !! wikitext
7051 {|
7052 !align=center {{table_header_cells}}
7053 |-
7054 |align=center {{table_cells}}
7055 |}
7056 !! html/php
7057 <table>
7058 <tr>
7059 <th align="center" style="color:red;">Foo</th>
7060 <th style="color:red;"><i>Bar</i></th>
7061 <th style="color:brown;"><i>Foo</i> and Baz
7062 </th></tr>
7063 <tr>
7064 <td align="center" style="color:red;">Foo</td>
7065 <td style="color:red;"><i>Bar</i></td>
7066 <td style="color:brown;"><i>Foo</i> and Baz
7067 </td></tr></table>
7068
7069 !! html/parsoid
7070 <table>
7071 <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>
7072 <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>
7073 </tbody></table>
7074 !! end
7075
7076 !! test
7077 4. Template-generated table cell attributes and cell content inside a templated table
7078 !! wikitext
7079 {{tbl-start}}
7080 !align=center {{table_header_cells}}
7081 |-
7082 |align=center {{table_cells}}
7083 {{tbl-end}}
7084 !! html/php
7085 <table>
7086 <tr>
7087 <th align="center" style="color:red;">Foo</th>
7088 <th style="color:red;"><i>Bar</i></th>
7089 <th style="color:brown;"><i>Foo</i> and Baz
7090 </th></tr>
7091 <tr>
7092 <td align="center" style="color:red;">Foo</td>
7093 <td style="color:red;"><i>Bar</i></td>
7094 <td style="color:brown;"><i>Foo</i> and Baz
7095 </td></tr></table>
7096
7097 !! html/parsoid
7098 <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}}]}'>
7099 <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>
7100 <tr>
7101 <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>
7102 </tbody></table>
7103 !! end
7104
7105 ## Edge case fix to prevent future regressions
7106 !! test
7107 T107652: <ref>s in templates that also generate table cell attributes should be rendered properly
7108 !! wikitext
7109 {|
7110 |{{table_attribs_7}}
7111 |}
7112 <references />
7113 !! html/parsoid
7114 <table>
7115 <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>
7116 </tbody></table>
7117 <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>
7118 !! end
7119
7120 !! test
7121 Table with row followed by newlines and table heading
7122 !! options
7123 parsoid=wt2html,html2html
7124 !! wikitext
7125 {|
7126 |-
7127
7128 !foo
7129 |}
7130 !! html/*
7131 <table>
7132
7133
7134 <tr>
7135 <th>foo
7136 </th></tr></table>
7137
7138 !! end
7139
7140 !! test
7141 Table with empty line following the start tag
7142 !! options
7143 parsoid=wt2html,html2html
7144 !! wikitext
7145 {|
7146
7147 |-
7148 |foo
7149 |}
7150 !! html/*
7151 <table>
7152
7153
7154 <tr>
7155 <td>foo
7156 </td></tr></table>
7157
7158 !! end
7159
7160 !! test
7161 Table attributes with empty value
7162 !! options
7163 parsoid=wt2html,html2html
7164 !! wikitext
7165 {|
7166 | style=|hello
7167 |}
7168 !! html/php
7169 <table>
7170 <tr>
7171 <td style="">hello
7172 </td></tr></table>
7173
7174 !! html/parsoid
7175 <table>
7176 <tbody><tr><td style="">hello</td></tr>
7177 </tbody></table>
7178 !! end
7179
7180 !! test
7181 Wikitext table with a lot of comments
7182 !! wikitext
7183 {|
7184 <!-- c0 -->
7185 |foo
7186 <!-- c1 -->
7187 |-<!-- c2 -->
7188 <!-- c3 -->
7189 |<!-- c4 -->
7190 <!-- c5 -->
7191 |}
7192 !! html
7193 <table>
7194 <tr>
7195 <td>foo
7196 </td></tr>
7197 <tr>
7198 <td>
7199 </td></tr></table>
7200
7201 !! end
7202
7203 !! test
7204 Wikitext table comments represented in parsoid dom
7205 !! wikitext
7206 {|<!--c1--><!--c2-->
7207 |-<!--c3-->
7208 |x
7209 |}
7210 !! html/php+tidy
7211 <table>
7212
7213 <tbody><tr>
7214 <td>x
7215 </td></tr></tbody></table>
7216 !! html/parsoid
7217 <table><!--c1--><!--c2-->
7218 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'><!--c3-->
7219 <td data-parsoid='{"autoInsertedEnd":true}'>x</td></tr>
7220 </tbody></table>
7221 !! end
7222
7223 !! test
7224 Wikitext table with double-line table cell
7225 !! wikitext
7226 {|
7227 |a
7228 b
7229 |}
7230 !! html
7231 <table>
7232 <tr>
7233 <td>a
7234 <p>b
7235 </p>
7236 </td></tr></table>
7237
7238 !! end
7239
7240 !! test
7241 Table cell with a single comment
7242 !! wikitext
7243 {|
7244 |<!-- c1 -->
7245 |a
7246 |}
7247 !! html
7248 <table>
7249 <tr>
7250 <td>
7251 </td>
7252 <td>a
7253 </td></tr></table>
7254
7255 !! end
7256
7257 !! test
7258 Table-cell after a comment-only-empty-line
7259 !! wikitext
7260 {|
7261 |a
7262 <!--c1-->
7263 <!--c2-->|b
7264 |}
7265 !! html
7266 <table>
7267 <tr>
7268 <td>a
7269 </td>
7270 <td>b
7271 </td></tr></table>
7272
7273 !! html/parsoid
7274 <table>
7275 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'>a</td>
7276 <!--c1-->
7277 <!--c2--><td data-parsoid='{"autoInsertedEnd":true}'>b</td></tr>
7278 </tbody></table>
7279
7280 !! end
7281
7282 !! test
7283 Build table with {{!}}
7284 !! wikitext
7285 {{{!}} class="wikitable"
7286 !header
7287 !second header
7288 {{!}}- style="color:red;"
7289 {{!}}data{{!}}{{!}} style="color:red;" {{!}}second data
7290 {{!}}}
7291 !! html
7292 <table class="wikitable">
7293 <tr>
7294 <th>header
7295 </th>
7296 <th>second header
7297 </th></tr>
7298 <tr style="color:red;">
7299 <td>data</td>
7300 <td style="color:red;">second data
7301 </td></tr></table>
7302
7303 !! end
7304
7305 !! test
7306 Build table with pipe as data
7307 !! wikitext
7308 {| class="wikitable"
7309 !header
7310 !second header
7311 |- style="color:red;"
7312 |data|| style="color:red;" |second data
7313 |-
7314 | style="color:red;" |data with | || style="color:red;" | second data with |
7315 |-
7316 ||data with | |||second data with |
7317 |}
7318 !! html
7319 <table class="wikitable">
7320 <tr>
7321 <th>header
7322 </th>
7323 <th>second header
7324 </th></tr>
7325 <tr style="color:red;">
7326 <td>data</td>
7327 <td style="color:red;">second data
7328 </td></tr>
7329 <tr>
7330 <td style="color:red;">data with |</td>
7331 <td style="color:red;">second data with |
7332 </td></tr>
7333 <tr>
7334 <td>data with |</td>
7335 <td>second data with |
7336 </td></tr></table>
7337
7338 !! end
7339
7340 !! test
7341 Build table with wikilink
7342 !! wikitext
7343 {| class="wikitable"
7344 !header||second header
7345 |- style="color:red;"
7346 |data [[Main Page|linktext]]||second data [[Main Page|linktext]]
7347 |-
7348 |data||second data [[Main Page|link|text with pipe]]
7349 |}
7350 !! html
7351 <table class="wikitable">
7352 <tr>
7353 <th>header</th>
7354 <th>second header
7355 </th></tr>
7356 <tr style="color:red;">
7357 <td>data <a href="/wiki/Main_Page" title="Main Page">linktext</a></td>
7358 <td>second data <a href="/wiki/Main_Page" title="Main Page">linktext</a>
7359 </td></tr>
7360 <tr>
7361 <td>data</td>
7362 <td>second data <a href="/wiki/Main_Page" title="Main Page">link|text with pipe</a>
7363 </td></tr></table>
7364
7365 !! end
7366
7367 # The expected HTML structure in this test is debatable. The PHP parser does
7368 # not parse this kind of table at all. The main focus for Parsoid is on
7369 # round-tripping, so this output is ok for now. TODO: revisit!
7370 !! test
7371 Wikitext table with html-syntax row
7372 !! wikitext
7373 {|
7374 |-
7375 <td>foo</td>
7376 |}
7377 !! html/parsoid
7378 <table>
7379 <tbody>
7380 <tr>
7381 <td>foo</td></tr></tbody></table>
7382 !! end
7383
7384 ## Remex doesn't account for fostered content.
7385 !! test
7386 Fostered content in tables: Plain text
7387 !! options
7388 parsoid=wt2html
7389 !! wikitext
7390 {|
7391 |-
7392 a
7393 |}
7394 !! html/php
7395 <table>
7396
7397 a
7398 </table>
7399
7400 !! html/php+tidy
7401
7402
7403 a
7404 <table></table>
7405 !! html/parsoid
7406 <p data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true}'>
7407 a</p>
7408 <table>
7409 <tbody><tr class="mw-empty-elt" data-parsoid='{"startTagSrc":"|-"}'></tr></tbody></table>
7410 !! end
7411
7412 !! test
7413 Fostered content in tables: Lists
7414 !! options
7415 parsoid=wt2html,html2html
7416 !! wikitext
7417 {|
7418 |-
7419 *a
7420 |}
7421 !! html/php
7422 <table>
7423
7424 <ul><li>a</li></ul>
7425 </table>
7426
7427 !! html/php+tidy
7428 <ul><li>a</li></ul><table>
7429
7430
7431 </table>
7432 !! html/parsoid
7433 <ul data-parsoid='{"fostered":true,"autoInsertedEnd":true}'><li>a</li></ul><table>
7434 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
7435
7436 </tr></tbody></table>
7437 !! end
7438
7439 !! test
7440 Template generated table cell with attributes
7441 !! wikitext
7442 {|
7443 |-
7444 {{table_attribs_4}} ||a||b
7445 |}
7446 !! html/php+tidy
7447 <table>
7448
7449 <tbody><tr>
7450 <td style="background-color:#DC241f;" width="10px"></td>
7451 <td>a</td>
7452 <td>b
7453 </td></tr></tbody></table>
7454 !! html/parsoid
7455 <table>
7456 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
7457 <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>
7458 !! end
7459
7460 !! test
7461 Parsoid: Round-trip tables directly followed by content (T53219)
7462 !! options
7463 parsoid=wt2html,wt2wt
7464 !! wikitext
7465 {|
7466 |foo
7467 |} bar
7468
7469 {|
7470 |baz
7471 |}<b>quux</b>
7472 !! html+tidy
7473 <table>
7474 <tbody><tr>
7475 <td>foo
7476 </td></tr></tbody></table><p> bar
7477 </p><table>
7478 <tbody><tr>
7479 <td>baz
7480 </td></tr></tbody></table><p><b>quux</b>
7481 </p>
7482 !! end
7483
7484 !! test
7485 Parsoid: Default to a newline after tables in new content (T53219)
7486 !! options
7487 parsoid=html2wt
7488 !! html/parsoid
7489 <table><tbody>
7490 <tr><td>foo</td></tr></tbody></table> bar
7491 <table><tbody>
7492 <tr><td>baz</td></tr></tbody></table><b>quux</b>
7493 !! wikitext
7494 {|
7495 |foo
7496 |}
7497 <nowiki> </nowiki>bar
7498 {|
7499 |baz
7500 |}
7501 '''quux'''
7502 !! end
7503
7504 !! test
7505 Parsoid: Row-syntax table headings followed by comment & table cells
7506 !! options
7507 parsoid=wt2html,wt2wt
7508 !! wikitext
7509 {|
7510 !foo||bar
7511 <!-- foo --> ||baz||quux
7512 |}
7513 !! html/php
7514 <table>
7515 <tr>
7516 <th>foo</th>
7517 <th>bar
7518 </th>
7519 <td>baz</td>
7520 <td>quux
7521 </td></tr></table>
7522
7523 !! html/parsoid
7524 <table>
7525 <tbody><tr><th>foo</th><th>bar
7526 <!-- foo --></th><td> baz </td><td>quux</td></tr>
7527 </tbody></table>
7528 !! end
7529
7530 !!test
7531 Parsoid: Recover better from broken table attributes
7532 !!options
7533 parsoid=wt2html
7534 !!wikitext
7535 {| class="foo
7536 | class="bar" |
7537 foo
7538 |}
7539 !!html/php+tidy
7540 <table class="foo">
7541 <tbody><tr>
7542 <td class="bar">
7543 <p>foo
7544 </p>
7545 </td></tr></tbody></table>
7546 !!html/parsoid
7547 <table class="foo">
7548 <tr>
7549 <td class="bar">
7550 <p>foo</p></td></tr>
7551 </tbody></table>
7552 !!end
7553
7554 # Note: PHP parser omits empty rows
7555 !! test
7556 Tables: Digest broken attributes on table and tr tag
7557 !! options
7558 parsoid=wt2html
7559 !! wikitext
7560 {| || |} ++
7561 |- || || ++ --
7562 |- > [
7563 |}
7564 !! html/php+tidy
7565 <table>
7566
7567
7568 </table>
7569 !! html/parsoid
7570 <table>
7571 <tbody>
7572 <tr class='mw-empty-elt'></tr>
7573 <tr class='mw-empty-elt'></tr>
7574 </tbody></table>
7575 !! end
7576
7577 !! test
7578 Table with missing opening <tr> tag
7579 !! options
7580 parsoid=wt2html,wt2wt
7581 !! wikitext
7582 <table>
7583 <td>foo</td>
7584 </tr>
7585 </table>
7586 !! html+tidy
7587 <table>
7588 <tbody><tr><td>foo</td>
7589 </tr>
7590 </tbody></table>
7591 !! end
7592
7593 # T137406: Whitespace in the HTML
7594 !! test
7595 1. Generate correct wikitext for tables with thead/tbody/tfoot
7596 !! options
7597 parsoid=html2wt
7598 !! html/parsoid
7599 <table>
7600 <caption>Test</caption>
7601 <thead>
7602 <tr>
7603 <th>Month</th>
7604 <th>Savings</th>
7605 </tr>
7606 </thead>
7607 <tbody>
7608 <tr>
7609 <td>January</td>
7610 <td>$100</td>
7611 </tr>
7612 <tr>
7613 <td>February</td>
7614 <td>$80</td>
7615 </tr>
7616 </tbody>
7617 <tfoot>
7618 <tr>
7619 <td>Sum</td>
7620 <td>$180</td>
7621 </tr>
7622 </tfoot>
7623 </table>
7624 !! wikitext
7625 {|
7626 |+Test
7627 !Month
7628 !Savings
7629 |-
7630 |January
7631 |$100
7632 |-
7633 |February
7634 |$80
7635 |-
7636 |Sum
7637 |$180
7638 |}
7639 !! html/php+tidy
7640 <table>
7641 <caption>Test
7642 </caption>
7643 <tbody><tr>
7644 <th>Month
7645 </th>
7646 <th>Savings
7647 </th></tr>
7648 <tr>
7649 <td>January
7650 </td>
7651 <td>$100
7652 </td></tr>
7653 <tr>
7654 <td>February
7655 </td>
7656 <td>$80
7657 </td></tr>
7658 <tr>
7659 <td>Sum
7660 </td>
7661 <td>$180
7662 </td></tr></tbody></table>
7663 !! end
7664
7665 # T137406: No whitespace in the HTML
7666 !! test
7667 2. Generate correct wikitext for tables with thead/tbody/tfoot
7668 !! options
7669 parsoid=html2wt
7670 !! html/parsoid
7671 <table><thead><tr><th>heading</th></tr></thead><tbody><tr><td>foo</td></tr></tbody></table>
7672 !! wikitext
7673 {|
7674 !heading
7675 |-
7676 |foo
7677 |}
7678 !! end
7679
7680 !! test
7681 Wikitext tables can be nested inside HTML tables
7682 !! options
7683 parsoid=html2wt
7684 !! html/parsoid
7685 <table data-parsoid='{"stx":"html"}'>
7686 <tr><td>
7687 <table>
7688 <tr><td>foo</td></tr>
7689 </table>
7690 </td></tr>
7691 </table>
7692 !! wikitext
7693 <table>
7694 <tr><td>
7695 {|
7696 |foo
7697 |}
7698 </td></tr>
7699 </table>
7700 !! html/php+tidy
7701 <table>
7702 <tbody><tr><td>
7703 <table>
7704 <tbody><tr>
7705 <td>foo
7706 </td></tr></tbody></table>
7707 </td></tr>
7708 </tbody></table>
7709 !! end
7710
7711 ###
7712 ### Internal links
7713 ###
7714 !! test
7715 Plain link, capitalized
7716 !! wikitext
7717 [[Main Page]]
7718 !! html
7719 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
7720 </p>
7721 !! end
7722
7723 !! test
7724 Plain link, uncapitalized
7725 !! wikitext
7726 [[main Page]]
7727 !! html
7728 <p><a href="/wiki/Main_Page" title="Main Page">main Page</a>
7729 </p>
7730 !! end
7731
7732 !! test
7733 Piped link
7734 !! wikitext
7735 [[Main Page|The Main Page]]
7736 !! html
7737 <p><a href="/wiki/Main_Page" title="Main Page">The Main Page</a>
7738 </p>
7739 !! end
7740
7741 !! test
7742 Piped link with comment in link text
7743 !! wikitext
7744 [[Main Page|The Main<!--front--> Page]]
7745 !! html
7746 <p><a href="/wiki/Main_Page" title="Main Page">The Main Page</a>
7747 </p>
7748 !! end
7749
7750 !! test
7751 Piped link with multiple pipe characters in link text
7752 !! wikitext
7753 [[Main Page||The|Main|Page|]]
7754 !! html/php
7755 <p><a href="/wiki/Main_Page" title="Main Page">|The|Main|Page|</a>
7756 </p>
7757 !! html/parsoid
7758 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">|The|Main|Page|</a></p>
7759 !! end
7760
7761 !! test
7762 Piped link with no link text
7763 !! wikitext
7764 [[Thomas Bek (bishop of St David's)|]]
7765 !! html/php
7766 <p>[[Thomas Bek (bishop of St David's)|]]
7767 </p>
7768 !! html/parsoid
7769 <p>[[Thomas Bek (bishop of St David's)|]]</p>
7770 !! end
7771
7772 !! test
7773 Piped link with empty link text
7774 !! wikitext
7775 [[Main Page|<nowiki/>]] - empty nowiki
7776 [[Main Page| ]] - empty space
7777 [[Main Page|&nbsp;]] - empty non breaking space
7778 !! html/php
7779 <p><a href="/wiki/Main_Page" title="Main Page"></a> - empty nowiki
7780 <a href="/wiki/Main_Page" title="Main Page"> </a> - empty space
7781 <a href="/wiki/Main_Page" title="Main Page">&#160;</a> - empty non breaking space
7782 </p>
7783 !! html/parsoid
7784 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page"><span typeof="mw:Nowiki"></span></a> - empty nowiki
7785 <a rel="mw:WikiLink" href="./Main_Page" title="Main Page"> </a> - empty space
7786 <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>
7787 !! end
7788
7789 !! test
7790 Broken link
7791 !! wikitext
7792 [[Zigzagzogzagzig]]
7793 !! html
7794 <p><a href="/index.php?title=Zigzagzogzagzig&amp;action=edit&amp;redlink=1" class="new" title="Zigzagzogzagzig (page does not exist)">Zigzagzogzagzig</a>
7795 </p>
7796 !! end
7797
7798 !! test
7799 Broken link with fragment
7800 !! wikitext
7801 [[Zigzagzogzagzig#zug]]
7802 !! html
7803 <p><a href="/index.php?title=Zigzagzogzagzig&amp;action=edit&amp;redlink=1" class="new" title="Zigzagzogzagzig (page does not exist)">Zigzagzogzagzig#zug</a>
7804 </p>
7805 !! end
7806
7807 !! test
7808 Special page link with fragment
7809 !! wikitext
7810 [[Special:Version#anchor]]
7811 !! html
7812 <p><a href="/wiki/Special:Version#anchor" title="Special:Version">Special:Version#anchor</a>
7813 </p>
7814 !! end
7815
7816 !! test
7817 Nonexistent special page link with fragment
7818 !! wikitext
7819 [[Special:ThisNameWillHopefullyNeverBeUsed#anchor]]
7820 !! html
7821 <p><a href="/wiki/Special:ThisNameWillHopefullyNeverBeUsed" class="new" title="Special:ThisNameWillHopefullyNeverBeUsed (page does not exist)">Special:ThisNameWillHopefullyNeverBeUsed#anchor</a>
7822 </p>
7823 !! end
7824
7825 !! test
7826 Link with prefix
7827 !! wikitext
7828 xxx[[main Page]], xxx[[Main Page]], Xxx[[main Page]] XXX[[main Page]], XXX[[Main Page]]
7829 !! html
7830 <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>
7831 </p>
7832 !! end
7833
7834 !! test
7835 Link with suffix
7836 !! wikitext
7837 [[Main Page]]xxx, [[Main Page]]XXX, [[Main Page]]!!!
7838 !! html
7839 <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>!!!
7840 </p>
7841 !! end
7842
7843 !! article
7844 prefixed article
7845 !! text
7846 Some text
7847 !! endarticle
7848
7849 !! test
7850 T45661: Piped links with identical prefixes
7851 !! wikitext
7852 [[prefixed article|prefixed articles with spaces]]
7853
7854 [[prefixed article|prefixed articlesaoeu]]
7855
7856 [[Main Page|Main Page test]]
7857 !! html
7858 <p><a href="/wiki/Prefixed_article" title="Prefixed article">prefixed articles with spaces</a>
7859 </p><p><a href="/wiki/Prefixed_article" title="Prefixed article">prefixed articlesaoeu</a>
7860 </p><p><a href="/wiki/Main_Page" title="Main Page">Main Page test</a>
7861 </p>
7862 !! end
7863
7864
7865 !! test
7866 Link with HTML entity in suffix / tail
7867 !! wikitext
7868 [[Main Page]]&quot;, [[Main Page]]&#97;
7869 !! html/php
7870 <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;
7871 </p>
7872 !! html/parsoid
7873 <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>
7874 !! end
7875
7876 !! test
7877 Link with 3 brackets
7878 !! wikitext
7879 [[[Main Page]]]
7880 Foo [[[Main Page]]]
7881 !! html
7882 <p>[[[Main Page]]]
7883 Foo [[[Main Page]]]
7884 </p>
7885 !! end
7886
7887 !! test
7888 Link with 4 brackets
7889 !! wikitext
7890 [[[[Main Page]]]]
7891 !! html
7892 <p>[[<a href="/wiki/Main_Page" title="Main Page">Main Page</a>]]
7893 </p>
7894 !! end
7895
7896 !! test
7897 Piped link with 3 brackets
7898 !! wikitext
7899 [[[main page|the main page]]]
7900 !! html
7901 <p>[[[main page|the main page]]]
7902 </p>
7903 !! end
7904
7905 !! test
7906 Piped link with extlink-like text
7907 !! wikitext
7908 [[Main Page|[bar]]]
7909 [[Main Page|This is a [bar]]]
7910 [[Main Page|[bar]]
7911 !! html/php
7912 <p><a href="/wiki/Main_Page" title="Main Page">[bar]</a>
7913 <a href="/wiki/Main_Page" title="Main Page">This is a [bar]</a>
7914 <a href="/wiki/Main_Page" title="Main Page">[bar</a>
7915 </p>
7916 !! html/parsoid
7917 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"piped"}'>[bar]</a>
7918 <a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"piped"}'>This is a [bar]</a>
7919 <a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"piped"}'>[bar</a></p>
7920 !! end
7921
7922 !! test
7923 Link with multiple pipes
7924 !! wikitext
7925 [[Main Page|The|Main|Page]]
7926 !! html
7927 <p><a href="/wiki/Main_Page" title="Main Page">The|Main|Page</a>
7928 </p>
7929 !! end
7930
7931 !! test
7932 Anchor containing a #. (T65430)
7933 !! config
7934 wgFragmentMode=[ 'html5', 'legacy' ]
7935 !! wikitext
7936 [[Main Page#And#Link]]
7937 !! html/php
7938 <p><a href="/wiki/Main_Page#And#Link" title="Main Page">Main Page#And#Link</a>
7939 </p>
7940 !! html/parsoid
7941 <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>
7942 !! end
7943
7944 !! test
7945 Link to namespaces
7946 !! wikitext
7947 [[Talk:Parser testing]], [[Meta:Disclaimers]]
7948 !! html
7949 <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>
7950 </p>
7951 !! end
7952
7953 !! test
7954 Link with space in namespace
7955 !! wikitext
7956 [[User talk:Foo bar]]
7957 !! html
7958 <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>
7959 </p>
7960 !! end
7961
7962 !! article
7963 MemoryAlpha:AlphaTest
7964 !! text
7965 This is an article in the MemoryAlpha namespace
7966 (which shadows the memoryalpha interwiki link).
7967 !! endarticle
7968
7969 !! test
7970 Namespace takes precedence over interwiki link (T53680)
7971 !! wikitext
7972 [[MemoryAlpha:AlphaTest]]
7973 !! html
7974 <p><a href="/wiki/MemoryAlpha:AlphaTest" title="MemoryAlpha:AlphaTest">MemoryAlpha:AlphaTest</a>
7975 </p>
7976 !! end
7977
7978 # The previous test doesn't work correctly in html2*, due to not recognizing the
7979 # link as an internal one. This one checks for the correct behavior.
7980 !! test
7981 Link to namespace preferred over interwiki with correct rel attribute
7982 !! options
7983 parsoid=html2wt,html2html
7984 !! html/parsoid
7985 <p><a rel="mw:WikiLink" href="./MemoryAlpha:AlphaTest" title="MemoryAlpha:AlphaTest">MemoryAlpha:AlphaTest</a></p>
7986 !! wikitext
7987 [[MemoryAlpha:AlphaTest]]
7988 !! end
7989
7990 !! test
7991 Piped link to namespace
7992 !! wikitext
7993 [[Meta:Disclaimers|The disclaimers]]
7994 !! html
7995 <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>
7996 </p>
7997 !! end
7998
7999 !! test
8000 Link containing }
8001 !! wikitext
8002 [[Usually caused by a typo (oops}]]
8003 !! html
8004 <p>[[Usually caused by a typo (oops}]]
8005 </p>
8006 !! end
8007
8008 !! article
8009 7% Solution
8010 !! text
8011 Just a test of an article title containing a percent.
8012 !! endarticle
8013
8014 !! test
8015 Link containing % (not as a hex sequence)
8016 !! wikitext
8017 [[7% Solution]]
8018 [[7% Solution|7%25 Solution]]
8019 !! html/php
8020 <p><a href="/wiki/7%25_Solution" title="7% Solution">7% Solution</a>
8021 <a href="/wiki/7%25_Solution" title="7% Solution">7%25 Solution</a>
8022 </p>
8023 !! html/parsoid
8024 <p><a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7% Solution</a>
8025 <a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7%25 Solution</a></p>
8026 !! end
8027
8028 # note that the parsoid HTML is identical to the previous test output,
8029 # so the previous test ensures that the html2wt mode will generate the
8030 # "not as a hex sequence" wikitext.
8031 !! test
8032 Link containing % as a single hex sequence interpreted to char
8033 !! options
8034 parsoid=wt2wt,wt2html,html2html
8035 !! wikitext
8036 [[7%25 Solution]]
8037 [[7%25 Solution|7%25 Solution]]
8038 !! html/php
8039 <p><a href="/wiki/7%25_Solution" title="7% Solution">7% Solution</a>
8040 <a href="/wiki/7%25_Solution" title="7% Solution">7%25 Solution</a>
8041 </p>
8042 !! html/parsoid
8043 <p><a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7% Solution</a>
8044 <a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7%25 Solution</a></p>
8045 !!end
8046
8047 !! test
8048 Link containing % as a double hex sequence interpreted to hex sequence
8049 !! wikitext
8050 [[7%2525 Solution]]
8051 !! html
8052 <p>[[7%2525 Solution]]
8053 </p>
8054 !!end
8055
8056 ## Example for such a section: == < ==
8057 !! test
8058 Link containing "#<" and "#>" % as a hex sequences- these are valid section anchors
8059 !! options
8060 title=[[Main Page]]
8061 !! config
8062 wgFragmentMode=[ 'html5', 'legacy' ]
8063 !! wikitext
8064 [[%23%3c]][[%23%3e]]
8065 !! html/php
8066 <p><a href="#&lt;">#&lt;</a><a href="#&gt;">#&gt;</a>
8067 </p>
8068 !! html/parsoid
8069 <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>
8070 !! end
8071
8072 ## Example for such a section: == < ==
8073 !! test
8074 Link containing "#<" and "#>" % as a hex sequences- these are valid section anchors (legacy)
8075 !! config
8076 wgFragmentMode=[ 'legacy' ]
8077 !! wikitext
8078 [[%23%3c]][[%23%3e]]
8079 !! html/php
8080 <p><a href="#.3C">#&lt;</a><a href="#.3E">#&gt;</a>
8081 </p>
8082 !! end
8083
8084 !! test
8085 Link containing "<#" and ">#" as a hex sequences
8086 !! wikitext
8087 [[%3c%23]][[%3e%23]]
8088 !! html
8089 <p>[[%3c%23]][[%3e%23]]
8090 </p>
8091 !! end
8092
8093 !! test
8094 Link containing an equals sign
8095 !! wikitext
8096 [[Special:BookSources/isbn=4-00-026157-6]]
8097 !! html/php
8098 <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>
8099 </p>
8100 !! html/parsoid
8101 <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>
8102 !! end
8103
8104 !! article
8105 Foo & bar
8106 !! text
8107 Just a test of an article title containing an ampersand
8108 !! endarticle
8109
8110 !! test
8111 Link containing an ampersand
8112 !! wikitext
8113 [[Foo & bar]]
8114
8115 [[Foo &amp; bar]]
8116
8117 [[Foo &amp;amp; bar]]
8118 !! html/php+tidy
8119 <p><a href="/wiki/Foo_%26_bar" title="Foo &amp; bar">Foo &amp; bar</a>
8120 </p><p><a href="/wiki/Foo_%26_bar" title="Foo &amp; bar">Foo &amp; bar</a>
8121 </p><p>[[Foo &amp;amp; bar]]
8122 </p>
8123 !! html/parsoid
8124 <p><a rel="mw:WikiLink" href="./Foo_&amp;_bar" title="Foo &amp; bar">Foo &amp; bar</a></p>
8125 <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>
8126 <p>[[Foo <span typeof="mw:Entity" data-parsoid='{"src":"&amp;amp;","srcContent":"&amp;"}'>&amp;</span>amp; bar]]</p>
8127 !! end
8128
8129 !! article
8130 Foo~bar
8131 !! text
8132 Just a test of an article title containing a tilde.
8133 !! endarticle
8134
8135 # note that links containing signatures, like [[Foo~~~~]], are
8136 # massaged by the pre-save transform (PST) and so the tildes are never
8137 # seen by the parser.
8138 !! test
8139 Link containing a tilde
8140 !! wikitext
8141 [[Foo~bar]]
8142 !! html/php
8143 <p><a href="/wiki/Foo~bar" title="Foo~bar">Foo~bar</a>
8144 </p>
8145 !! html/parsoid
8146 <p><a rel="mw:WikiLink" href="./Foo~bar" title="Foo~bar">Foo~bar</a></p>
8147 !! end
8148
8149 !! test
8150 Link containing double-single-quotes '' (T6598)
8151 !! wikitext
8152 [[Lista d''e paise d''o munno]]
8153 !! html/php
8154 <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>
8155 </p>
8156 !! html/parsoid
8157 <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>
8158 !! end
8159
8160 !! test
8161 Link containing double quotes and spaces
8162 !! wikitext
8163 [[Cool "Gator"]]
8164 !! html/php
8165 <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>
8166 </p>
8167 !! html/parsoid
8168 <p><a rel="mw:WikiLink" href='./Cool_"Gator"' title='Cool "Gator"'>Cool "Gator"</a></p>
8169 !! end
8170
8171 !! test
8172 File containing double quotes and spaces
8173 !! wikitext
8174 [[File:Cool "Gator".png]]
8175 !! html/parsoid
8176 <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>
8177 !! end
8178
8179 !! test
8180 Redirect containing double quotes and spaces
8181 !! wikitext
8182 #REDIRECT [[Cool "Gator"]]
8183 !! html/parsoid
8184 <link rel="mw:PageProp/redirect" href="./Cool_%22Gator%22" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./Cool_%22Gator%22"},"sa":{"href":"Cool \"Gator\""}}'/>
8185 !! end
8186
8187 !! test
8188 Link containing double-single-quotes '' in text (T6598 sanity check)
8189 !! wikitext
8190 Some [[Link|pretty ''italics'' and stuff]]!
8191 !! html/php
8192 <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>!
8193 </p>
8194 !! html/parsoid
8195 <p>Some <a rel="mw:WikiLink" href="./Link" title="Link">pretty <i>italics</i> and stuff</a>!</p>
8196 !! end
8197
8198 !! test
8199 Link containing double-single-quotes '' in text embedded in italics (T6598 sanity check)
8200 !! wikitext
8201 ''Some [[Link|pretty ''italics'' and stuff]]!''
8202 !! html
8203 <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>
8204 </p>
8205 !! end
8206
8207 !! test
8208 Link with double quotes in title part (literal) and alternate part (interpreted)
8209 !! wikitext
8210 [[File:Denys_Savchenko_''Pentecoste''.jpg]]
8211
8212 [[''Pentecoste'']]
8213
8214 [[''Pentecoste''|Pentecoste]]
8215
8216 [[''Pentecoste''|''Pentecoste'']]
8217 !! html/php
8218 <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>
8219 </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>
8220 </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>
8221 </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>
8222 </p>
8223 !! html/parsoid
8224 <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>
8225 <p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''">''Pentecoste''</a></p>
8226 <p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''">Pentecoste</a></p>
8227 <p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''"><i>Pentecoste</i></a></p>
8228 !! end
8229
8230 !! test
8231 Broken image links with HTML captions (T41700)
8232 !! wikitext
8233 [[File:Nonexistent|<script></script>]]
8234 [[File:Nonexistent|100x100px|<script></script>]]
8235 [[File:Nonexistent|&lt;]]
8236 [[File:Nonexistent|a<i>b</i>c]]
8237 !! html/php
8238 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">&lt;script&gt;&lt;/script&gt;</a>
8239 <a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">&lt;script&gt;&lt;/script&gt;</a>
8240 <a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">&lt;</a>
8241 <a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">abc</a>
8242 </p>
8243 !! html/parsoid
8244 <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>
8245 <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>
8246 <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>
8247 <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>
8248 !! end
8249
8250 !! test
8251 Plain link to URL
8252 !! wikitext
8253 [[http://www.example.com]]
8254 !! html/php
8255 <p>[<a rel="nofollow" class="external autonumber" href="http://www.example.com">[1]</a>]
8256 </p>
8257 !! html/parsoid
8258 <p>[<a rel="mw:ExtLink" class="external autonumber" href="http://www.example.com"></a>]</p>
8259 !! end
8260
8261 !! test
8262 Plain link to URL with link text
8263 !! wikitext
8264 [[http://www.example.com Link text]]
8265 !! html
8266 <p>[<a rel="nofollow" class="external text" href="http://www.example.com">Link text</a>]
8267 </p>
8268 !! end
8269
8270 !! test
8271 Plain link to protocol-relative URL
8272 !! wikitext
8273 [[//www.example.com]]
8274 !! html/php
8275 <p>[<a rel="nofollow" class="external autonumber" href="//www.example.com">[1]</a>]
8276 </p>
8277 !! html/parsoid
8278 <p>[<a rel="mw:ExtLink" class="external autonumber" href="//www.example.com"></a>]</p>
8279 !! end
8280
8281 !! test
8282 Plain link to protocol-relative URL with link text
8283 !! wikitext
8284 [[//www.example.com Link text]]
8285 !! html
8286 <p>[<a rel="nofollow" class="external text" href="//www.example.com">Link text</a>]
8287 </p>
8288 !! end
8289
8290 !! test
8291 Plain link to page with question mark in title
8292 !! wikitext
8293 [[A?b]]
8294
8295 [[A?b|Baz]]
8296 !! html
8297 <p><a href="/wiki/A%3Fb" title="A?b">A?b</a>
8298 </p><p><a href="/wiki/A%3Fb" title="A?b">Baz</a>
8299 </p>
8300 !! end
8301
8302 # I'm fairly sure the expected result here is wrong.
8303 # We want these to be URL links, not pseudo-pages with URLs for titles....
8304 # However the current output is also pretty screwy.
8305 #
8306 # ----
8307 # I'm changing it to match the current output--it arguably makes more
8308 # sense in the light of the test above. Old expected result was:
8309 #<p>Piped link to URL: <a href="/index.php?title=Http://www.example.com&amp;action=edit" class="new">an example URL</a>
8310 #</p>
8311 # But I think this test is bordering on "garbage in, garbage out" anyway.
8312 # -- wtm
8313 !! test
8314 Piped link to URL
8315 !! wikitext
8316 Piped link to URL: [[http://www.example.com|an example URL]]
8317 !! html/php
8318 <p>Piped link to URL: [<a rel="nofollow" class="external text" href="http://www.example.com%7Can">example URL</a>]
8319 </p>
8320 !! html/parsoid
8321 <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>
8322 !! end
8323
8324 !! test
8325 Plain link in template argument
8326 !! options
8327 parsoid=wt2html
8328 !! wikitext
8329 {{echo|[http://www.example.com |123]}}
8330
8331 {{echo|[[http://www.example.com |123]]}}
8332
8333 {{echo|[[http://www.example.com |123]}}
8334
8335 {{echo|[http://www.example.com |123]]}}
8336 !! html/php
8337 <p>[<a rel="nofollow" class="external free" href="http://www.example.com">http://www.example.com</a>
8338 </p><p>[<a rel="nofollow" class="external text" href="http://www.example.com">|123</a>]
8339 </p><p>{{echo|[<a rel="nofollow" class="external text" href="http://www.example.com">|123</a>}}
8340 </p><p>[<a rel="nofollow" class="external free" href="http://www.example.com">http://www.example.com</a>
8341 </p>
8342 !! html/parsoid
8343 <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>
8344
8345 <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>
8346
8347 <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>
8348
8349 <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>
8350 !! end
8351
8352 !! test
8353 T2002: [[page|http://url/]] should link to page, not http://url/
8354 !! wikitext
8355 [[Main Page|http://url/]]
8356 !! html/php
8357 <p><a href="/wiki/Main_Page" title="Main Page">http://url/</a>
8358 </p>
8359 !! html/parsoid
8360 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">http://url/</a></p>
8361 !! end
8362
8363 # Parsoid does not mark self-links, by design.
8364 !! test
8365 T2337: Escaped self-links should be bold
8366 !! options
8367 title=[[Bug462]]
8368 !! wikitext
8369 [[Bu&#103;462]] [[Bug462]]
8370 !! html/php+tidy
8371 <p><a class="mw-selflink selflink">Bu&#103;462</a> <a class="mw-selflink selflink">Bug462</a>
8372 </p>
8373 !! html/parsoid
8374 <p><a rel="mw:WikiLink" href="./Bug462" title="Bug462">Bug462</a> <a rel="mw:WikiLink" href="./Bug462" title="Bug462">Bug462</a></p>
8375 !! end
8376
8377 !! test
8378 Self-link to section should not be bold
8379 !! options
8380 title=[[Main Page]]
8381 !! wikitext
8382 [[Main Page#section]]
8383 !! html
8384 <p><a href="/wiki/Main_Page#section" title="Main Page">Main Page#section</a>
8385 </p>
8386 !! end
8387
8388 !! article
8389 00
8390 !! text
8391 This is 00.
8392 !! endarticle
8393
8394 !!test
8395 Self-link to numeric title
8396 !!options
8397 title=[[0]]
8398 !! wikitext
8399 [[0]]
8400 !! html
8401 <p><a class="mw-selflink selflink">0</a>
8402 </p>
8403 !!end
8404
8405 !!test
8406 Link to numeric-equivalent title
8407 !!options
8408 title=[[0]]
8409 !! wikitext
8410 [[00]]
8411 !! html
8412 <p><a href="/wiki/00" title="00">00</a>
8413 </p>
8414 !!end
8415
8416 !! test
8417 <nowiki> inside a link
8418 !! wikitext
8419 [[Main<nowiki> Page</nowiki>]] [[Main Page|the main page <nowiki>[it's not very good]</nowiki>]]
8420 !! html/php+tidy
8421 <p>[[Main Page]] <a href="/wiki/Main_Page" title="Main Page">the main page [it's not very good]</a>
8422 </p>
8423 !! html/parsoid
8424 <p>[[Main<span typeof="mw:Nowiki"> Page</span>]] <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">the main page <span typeof="mw:Nowiki">[it's not very good]</span></a></p>
8425 !! end
8426
8427 ## Parsoid doesn't get this right and even fails wt2html because, when doing the
8428 ## normalization for comparison, the html serialization / re-parse doesn't
8429 ## roundtrip. This is T49963
8430 !! test
8431 <pre> inside a link
8432 !! wikitext
8433 [[Main<pre> Page</pre>]] [[Main Page|the main page <pre>[it's not very good]</pre>]]
8434 !! html/php+tidy
8435 <p>[[Main</p><pre> Page</pre><p>]] <a href="/wiki/Main_Page" title="Main Page">the main page </a></p><a href="/wiki/Main_Page" title="Main Page"><pre>[it's not very good]</pre></a>
8436 !! html/parsoid
8437 <p>[[Main</p><pre typeof="mw:Extension/pre" about="#mwt4" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":" Page"}}'> Page</pre><p>]] <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">the main page <pre typeof="mw:Extension/pre" about="#mwt6" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"[it&apos;s not very good]"}}'>[it's not very good]</pre></a></p>
8438 !! end
8439
8440 !! test
8441 Non-breaking spaces in title
8442 !! wikitext
8443 [[&nbsp; Main &nbsp; Page &nbsp;]]
8444 !! html
8445 <p><a href="/wiki/Main_Page" title="Main Page">&#160; Main &#160; Page &#160;</a>
8446 </p>
8447 !!end
8448
8449 # Add new article for the test below so that it doesn't red-link
8450 !! article
8451 Foo bar baz
8452 !! text
8453 boo
8454 !! endarticle
8455
8456 !! test
8457 Multiple spaces in titles should normalize to a single underscore
8458 !! options
8459 parsoid=wt2html,wt2wt
8460 !! wikitext
8461 [[Foo bar baz|x]]
8462 [[Foo bar baz|x]]
8463 [[Foo bar baz|x]]
8464 !! html/php
8465 <p><a href="/wiki/Foo_bar_baz" title="Foo bar baz">x</a>
8466 <a href="/wiki/Foo_bar_baz" title="Foo bar baz">x</a>
8467 <a href="/wiki/Foo_bar_baz" title="Foo bar baz">x</a>
8468 </p>
8469 !! html/parsoid
8470 <p><a rel="mw:WikiLink" href="./Foo_bar_baz" title="Foo bar baz">x</a>
8471 <a rel="mw:WikiLink" href="./Foo_bar_baz" title="Foo bar baz">x</a>
8472 <a rel="mw:WikiLink" href="./Foo_bar_baz" title="Foo bar baz">x</a>
8473 </p>
8474 !! end
8475
8476 !! test
8477 Internal link with ca linktrail, surrounded by bold apostrophes (T29473 primary issue)
8478 !! options
8479 language=ca
8480 !! wikitext
8481 '''[[Main Page]]'''
8482 !! html
8483 <p><b><a href="/wiki/Main_Page" title="Main Page">Main Page</a></b>
8484 </p>
8485 !! end
8486
8487 !! test
8488 Internal link with ca linktrail, surrounded by italic apostrophes (T29473 primary issue)
8489 !! options
8490 language=ca
8491 !! wikitext
8492 ''[[Main Page]]''
8493 !! html
8494 <p><i><a href="/wiki/Main_Page" title="Main Page">Main Page</a></i>
8495 </p>
8496 !! end
8497
8498 !! test
8499 Internal link with en linktrail: no apostrophes (T29473)
8500 !! options
8501 language=en
8502 !! wikitext
8503 [[Something]]'nice
8504 !! html
8505 <p><a href="/index.php?title=Something&amp;action=edit&amp;redlink=1" class="new" title="Something (page does not exist)">Something</a>'nice
8506 </p>
8507 !! end
8508
8509 !! test
8510 Internal link with ca linktrail with apostrophes (T29473)
8511 !! options
8512 language=ca
8513 !! wikitext
8514 [[Something]]'nice
8515 !! html
8516 <p><a href="/index.php?title=Something&amp;action=edit&amp;redlink=1" class="new" title="Something (encara no existeix)">Something'nice</a>
8517 </p>
8518 !! end
8519
8520 !! test
8521 Internal link with kaa linktrail with apostrophes (T29473)
8522 !! options
8523 language=kaa
8524 !! wikitext
8525 [[Something]]'nice
8526 !! html
8527 <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>
8528 </p>
8529 !! end
8530
8531 !! test
8532 Link with multiple ":" in a subpage-supporting namespace (T65636)
8533 !! wikitext
8534 [[User:Foo/Test/63636:Bar|Test]]
8535 !! html/php
8536 <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>
8537 </p>
8538 !! html/parsoid
8539 <p><a rel="mw:WikiLink" href="./User:Foo/Test/63636:Bar" title="User:Foo/Test/63636:Bar">Test</a></p>
8540 !! end
8541
8542 ## Mainly a sanity check for Parsoid
8543 !! test
8544 Handle title parsing for subpages
8545 !! options
8546 title=[[/123123]]
8547 subpage
8548 !! wikitext
8549 123
8550 !! html/php
8551 <p>123
8552 </p>
8553 !! html/parsoid
8554 <p>123</p>
8555 !! end
8556
8557 !! article
8558 User:Test/123
8559 !! text
8560 test 123
8561 !! endarticle
8562
8563 !! test
8564 Link to a subpage from a namespace other than main
8565 !! options
8566 title=[[User:Test]]
8567 subpage
8568 !! wikitext
8569 [[/123]]
8570 !! html/php
8571 <p><a href="/wiki/User:Test/123" title="User:Test/123">/123</a>
8572 </p>
8573 !! html/parsoid
8574 <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>
8575 !! end
8576
8577 !! test
8578 Ensure that transclusion titles are not url-decoded
8579 !! options
8580 subpage title=[[Test]]
8581 parsoid=wt2html
8582 !! wikitext
8583 {{Bar%C3%A9}} {{/Bar%C3%A9}}
8584 !! html/php
8585 <p>{{Bar%C3%A9}} {{/Bar%C3%A9}}
8586 </p>
8587 !! html/parsoid
8588 <p>{{Bar%C3%A9}} {{/Bar%C3%A9}}</p>
8589 !! end
8590
8591 !! test
8592 Purely hash wikilink
8593 !! options
8594 title=[[User:Test/123]]
8595 subpage
8596 !! wikitext
8597 [[#a|b]]
8598 !! html/php
8599 <p><a href="#a">b</a>
8600 </p>
8601 !! html/parsoid
8602 <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>
8603 !! end
8604
8605 !! test
8606 Serialization of purely hash wikilink
8607 !! options
8608 title=[[User:Test/123]]
8609 subpage
8610 parsoid=html2wt
8611 !! html/parsoid
8612 <p><a href="#a">[[</a></p>
8613 !! wikitext
8614 [[#a|<nowiki>[[</nowiki>]]
8615 !! html/php
8616 <p><a href="#a">[[</a>
8617 </p>
8618 !! end
8619
8620 !! test
8621 1. Interaction of linktrail and template encapsulation
8622 !! wikitext
8623 {{echo|[[Foo]]}}l
8624 !! html/php+tidy
8625 <p><a href="/wiki/Foo" title="Foo">Fool</a>
8626 </p>
8627 !! html/parsoid
8628 <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>
8629 !! end
8630
8631 !! test
8632 2. Interaction of linktrail and template encapsulation
8633 !! wikitext
8634 {{echo|Some [[Fool]]}}s
8635 !! html/php+tidy
8636 <p>Some <a href="/index.php?title=Fool&amp;action=edit&amp;redlink=1" class="new" title="Fool (page does not exist)">Fools</a>
8637 </p>
8638 !! html/parsoid
8639 <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>
8640 !! end
8641
8642 !! test
8643 3. Interaction of linktrail and template encapsulation
8644 !! wikitext
8645 {{echo|Some [[Fool]]s are '''bold and foolish'''}}
8646 !! html/php+tidy
8647 <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>
8648 </p>
8649 !! html/parsoid
8650 <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>
8651 !! end
8652
8653 !! article
8654 Söfnuður
8655 !! text
8656 Test.
8657 !! endarticle
8658
8659 !! test
8660 Internal link with is link prefix
8661 !! options
8662 language=is
8663 !! wikitext
8664 Aðrir mótmælenda[[söfnuður|söfnuðir]] og
8665 !! html
8666 <p>Aðrir <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðir</a> og
8667 </p>
8668 !! end
8669
8670 !! article
8671 Mótmælendatrú
8672 !! text
8673 Test.
8674 !! endarticle
8675
8676 !! test
8677 Internal link with is link trail and link prefix
8678 !! options
8679 language=is
8680 !! wikitext
8681 [[mótmælendatrú|xxx]]ar
8682 [[mótmælendatrú]]ar
8683 mótmælenda[[söfnuður]]
8684 mótmælenda[[söfnuður|söfnuðir]]
8685 mótmælenda[[söfnuður|söfnuðir]]xxx
8686 !! html
8687 <p><a href="/wiki/M%C3%B3tm%C3%A6lendatr%C3%BA" title="Mótmælendatrú">xxxar</a>
8688 <a href="/wiki/M%C3%B3tm%C3%A6lendatr%C3%BA" title="Mótmælendatrú">mótmælendatrúar</a>
8689 <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuður</a>
8690 <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðir</a>
8691 <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðirxxx</a>
8692 </p>
8693 !! end
8694
8695 !! test
8696 Parsoid link trail escaping
8697 !! options
8698 parsoid=html2wt,html2html
8699 !! html/parsoid
8700 <p><a rel="mw:WikiLink" href="./Apple" title="Apple">apple</a>s</p>
8701 !! wikitext
8702 [[apple]]<nowiki/>s
8703 !! end
8704
8705 !! test
8706 Parsoid link prefix escaping
8707 !! options
8708 language=is
8709 parsoid=html2wt,html2html
8710 !! html/parsoid
8711 <p>Aðrir mótmælenda<a rel="mw:WikiLink" href="./Söfnuður" title="Söfnuður">söfnuður</a></p>
8712 !! wikitext
8713 Aðrir mótmælenda<nowiki/>[[söfnuður]]
8714 !! end
8715
8716 !! test
8717 Parsoid link bracket escaping
8718 !! options
8719 parsoid=html2wt,html2html
8720 !! html/parsoid
8721 <p><a rel="mw:WikiLink" href="./Test" title="Test">Test</a></p>
8722 <p>[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]</p>
8723 <p>[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]</p>
8724 <p>[[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]]</p>
8725 <p>[[[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]]]</p>
8726 <p>[[[[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]]]]</p>
8727 !! wikitext
8728 [[Test]]
8729
8730 [<nowiki/>[[Test]]]
8731
8732 [[[[Test]]]]
8733
8734 [[[<nowiki/>[[Test]]]]]
8735
8736 [[[[[[Test]]]]]]
8737
8738 [[[[[<nowiki/>[[Test]]]]]]]
8739 !! end
8740
8741 !! test
8742 Parsoid-centric test: Whitespace in ext- and wiki-links should be preserved
8743 !! wikitext
8744 [[Foo| bar]]
8745
8746 [[Foo| ''bar'']]
8747
8748 [http://wp.org foo]
8749
8750 [http://wp.org ''foo'']
8751 !! html
8752 <p><a href="/wiki/Foo" title="Foo"> bar</a>
8753 </p><p><a href="/wiki/Foo" title="Foo"> <i>bar</i></a>
8754 </p><p><a rel="nofollow" class="external text" href="http://wp.org">foo</a>
8755 </p><p><a rel="nofollow" class="external text" href="http://wp.org"><i>foo</i></a>
8756 </p>
8757 !! end
8758
8759 !! test
8760 Parsoid: Scoped parsing should handle mixed transclusions and plain text
8761 !! wikitext
8762 [[Foo|{{echo|a}} b {{echo|c}}]]
8763 !! html/parsoid
8764 <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>
8765 !! end
8766
8767 !! test
8768 Link with angle bracket after anchor
8769 !! config
8770 wgFragmentMode=[ 'html5', 'legacy' ]
8771 !! wikitext
8772 [[Foo#<bar>]]
8773 !! html/php
8774 <p><a href="/wiki/Foo#&lt;bar&gt;" title="Foo">Foo#&lt;bar&gt;</a>
8775 </p>
8776 !! html/parsoid
8777 <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>
8778 !! end
8779
8780 !! test
8781 Link with angle bracket after anchor (legacy)
8782 !! config
8783 wgFragmentMode=[ 'legacy' ]
8784 !! wikitext
8785 [[Foo#<bar>]]
8786 !! html/php
8787 <p><a href="/wiki/Foo#.3Cbar.3E" title="Foo">Foo#&lt;bar&gt;</a>
8788 </p>
8789 !! end
8790
8791 ###
8792 ### Interwiki links (see maintenance/interwiki.sql)
8793 ###
8794
8795 !! test
8796 Inline interwiki link
8797 !! options
8798 parsoid=wt2html,wt2wt,html2html
8799 !! wikitext
8800 [[MeatBall:SoftSecurity]]
8801 !! html/php
8802 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity" class="extiw" title="meatball:SoftSecurity">MeatBall:SoftSecurity</a>
8803 </p>
8804 !! html/parsoid
8805 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity" title="meatball:SoftSecurity">MeatBall:SoftSecurity</a></p>
8806 !! end
8807
8808 !! test
8809 Inline interwiki link with empty title (T4372)
8810 !! options
8811 parsoid=wt2html,wt2wt,html2html
8812 !! wikitext
8813 [[MeatBall:]]
8814 !! html/php
8815 <p><a href="http://www.usemod.com/cgi-bin/mb.pl" class="extiw" title="meatball:">MeatBall:</a>
8816 </p>
8817 !! html/parsoid
8818 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?" title="meatball:">MeatBall:</a></p>
8819 !! end
8820
8821 ## html2wt and html2html will fail because we will prefer the :en: interwiki prefix over wikipedia:
8822 !! test
8823 Interwiki link encoding conversion (T3636)
8824 !! options
8825 parsoid=wt2html,wt2wt
8826 !! wikitext
8827 *[[Wikipedia:ro:Olteni&#0355;a]]
8828 *[[Wikipedia:ro:Olteni&#355;a]]
8829 !! html/php
8830 <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>
8831 <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>
8832 !! html/php+tidy
8833 <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>
8834 <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>
8835 !! html/parsoid
8836 <ul>
8837 <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>
8838 <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>
8839 </ul>
8840 !! end
8841
8842 !! test
8843 Interwiki link with fragment (T4130)
8844 !! wikitext
8845 [[MeatBall:SoftSecurity#foo]]
8846 !! html
8847 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity#foo" class="extiw" title="meatball:SoftSecurity">MeatBall:SoftSecurity#foo</a>
8848 </p>
8849 !! end
8850
8851 ## The interwiki case here continued to be legacy escaped because of the
8852 ## default setting of $wgExternalInterwikiFragmentMode
8853 !! test
8854 Link scenarios with escaped fragments
8855 !! options
8856 title=[[Main Page]]
8857 !! config
8858 wgFragmentMode=[ 'html5', '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?">#Is this great?</a>
8865 <a href="/wiki/Foo#Is_this_great?" 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 !! html/parsoid
8869 <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>
8870 <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>
8871 <a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?Foo#Is_this_great.3F" title="meatball:Foo" data-parsoid='{"stx":"simple","a":{"href":"http://www.usemod.com/cgi-bin/mb.pl?Foo#Is_this_great.3F"},"sa":{"href":"meatball:Foo#Is this great?"},"isIW":true}'>meatball:Foo#Is this great?</a></p>
8872 !! end
8873
8874 !! test
8875 Link scenarios with escaped fragments (legacy)
8876 !! config
8877 wgFragmentMode=[ 'legacy' ]
8878 !! wikitext
8879 [[#Is this great?]]
8880 [[Foo#Is this great?]]
8881 [[meatball:Foo#Is this great?]]
8882 !! html/php
8883 <p><a href="#Is_this_great.3F">#Is this great?</a>
8884 <a href="/wiki/Foo#Is_this_great.3F" title="Foo">Foo#Is this great?</a>
8885 <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>
8886 </p>
8887 !! end
8888
8889 # Ideally the wikipedia: prefix here should be proto-relative too
8890 # [CSA]: this is kind of a bogus test, as the PHP parser test doesn't
8891 # define the 'en' prefix, and originally the test used 'wikipedia',
8892 # which isn't a localinterwiki prefix hence the links to the 'en:Foo'
8893 # article.
8894 !! test
8895 Different interwiki prefixes mapping to the same URL
8896 !! wikitext
8897 [[:en:Foo]]
8898
8899 [[:en:Foo|Foo]]
8900
8901 [[wikipedia:Foo]]
8902
8903 [[:wikipedia:Foo|Foo]]
8904
8905 [[wikipedia:en:Foo]]
8906
8907 [[:wikipedia:en:Foo]]
8908
8909 [[ wikiPEdia :Foo]]
8910 !! html/parsoid
8911 <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>
8912
8913 <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>
8914
8915 <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>
8916
8917 <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>
8918
8919 <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>
8920
8921 <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>
8922
8923 <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>
8924 !! end
8925
8926 !! test
8927 Interwiki links that cannot be represented in wiki syntax
8928 !! wikitext
8929 [[meatball:ok]]
8930 [[meatball:ok#foo|ok with fragment]]
8931 [[meatball:ok_as_well?|ok ending with ? mark]]
8932 [http://de.wikipedia.org/wiki/Foo?action=history has query]
8933 [http://de.wikipedia.org/wiki/#foo is just fragment]
8934
8935 !! html/php
8936 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?ok" class="extiw" title="meatball:ok">meatball:ok</a>
8937 <a href="http://www.usemod.com/cgi-bin/mb.pl?ok#foo" class="extiw" title="meatball:ok">ok with fragment</a>
8938 <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>
8939 <a rel="nofollow" class="external text" href="http://de.wikipedia.org/wiki/Foo?action=history">has query</a>
8940 <a rel="nofollow" class="external text" href="http://de.wikipedia.org/wiki/#foo">is just fragment</a>
8941 </p>
8942 !! html/parsoid
8943 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?ok" title="meatball:ok">meatball:ok</a>
8944 <a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?ok#foo" title="meatball:ok">ok with fragment</a>
8945 <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>
8946 <a rel="mw:ExtLink" class="external text" href="http://de.wikipedia.org/wiki/Foo?action=history">has query</a>
8947 <a rel="mw:ExtLink" class="external text" href="http://de.wikipedia.org/wiki/#foo">is just fragment</a></p>
8948 !! end
8949
8950 !! test
8951 Interwiki links: trail
8952 !! wikitext
8953 [[wikipedia:Foo|Ba]]r
8954 !! html/php
8955 <p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo">Bar</a>
8956 </p>
8957 !! html/parsoid
8958 <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>
8959 !! end
8960
8961 !! test
8962 Local interwiki link
8963 !! options
8964 parsoid=wt2html,wt2wt,html2html
8965 !! wikitext
8966 [[local:Template:Foo]]
8967 !! html/php
8968 <p><a href="/wiki/Template:Foo" title="Template:Foo">local:Template:Foo</a>
8969 </p>
8970 !! html/parsoid
8971 <p><a rel="mw:WikiLink" href="./Template:Foo" title="Template:Foo">local:Template:Foo</a></p>
8972 !! end
8973
8974 # Parsoid does not mark self-links, by design.
8975 !! test
8976 Local interwiki link: self-link to current page
8977 !! options
8978 title=[[Main Page]]
8979 parsoid=wt2html,wt2wt,html2html
8980 !! wikitext
8981 [[local:Main Page]]
8982 !! html/php
8983 <p><a class="mw-selflink selflink">local:Main Page</a>
8984 </p>
8985 !! html/parsoid
8986 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">local:Main Page</a></p>
8987 !! end
8988
8989 !! test
8990 Local interwiki link: prefix only (T66167)
8991 !! options
8992 parsoid=wt2html,wt2wt,html2html
8993 !! wikitext
8994 [[local:]]
8995 !! html/php
8996 <p><a href="/wiki/Main_Page" title="Main Page">local:</a>
8997 </p>
8998 !! html/parsoid
8999 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">local:</a></p>
9000 !! end
9001
9002 !! test
9003 Local interwiki link: with additional interwiki prefix (T63357)
9004 !! options
9005 parsoid=wt2html,wt2wt,html2html
9006 !! wikitext
9007 [[local:meatball:Hello]]
9008 !! html/php
9009 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?Hello" class="extiw" title="meatball:Hello">local:meatball:Hello</a>
9010 </p>
9011 !! html/parsoid
9012 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?Hello" title="meatball:Hello">local:meatball:Hello</a></p>
9013 !! end
9014
9015 !! test
9016 Multiple local interwiki link prefixes
9017 !! wikitext
9018 [[local:local:local:local:mi:local:Foo]]
9019 !! options
9020 parsoid=wt2html,wt2wt,html2html
9021 !! html/php
9022 <p><a href="/wiki/Foo" title="Foo">local:local:local:local:mi:local:Foo</a>
9023 </p>
9024 !! html/parsoid
9025 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">local:local:local:local:mi:local:Foo</a></p>
9026 !! end
9027
9028 !! test
9029 Interwiki link with percent encoded target
9030 !! wikitext
9031 [[:es:Nueva Guip%C3%BAzcoa|Nueva Guipúzcoa]]
9032 !! html/php
9033 <p><a href="http://es.wikipedia.org/wiki/Nueva_Guip%C3%BAzcoa" class="extiw" title="es:Nueva Guipúzcoa">Nueva Guipúzcoa</a>
9034 </p>
9035 !! html/parsoid
9036 <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>
9037 !! end
9038
9039 ###
9040 ### Interlanguage links
9041 ### Language links (so that searching for '### language' matches..)
9042 ###
9043
9044 !! test
9045 Interlanguage link
9046 !! wikitext
9047 Blah blah blah
9048 [[zh:Chinese]]
9049 !! html/php
9050 <p>Blah blah blah
9051 </p>
9052 !! html/parsoid
9053 <p>Blah blah blah</p>
9054 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
9055 !! end
9056
9057 ## parsoid html2wt will lose the space variations
9058 !! test
9059 Interlanguage link with spacing
9060 !! options
9061 parsoid=wt2html,wt2wt,html2html
9062 !! wikitext
9063 Blah blah blah
9064 [[ zh : Chinese ]]
9065 !! html/php
9066 <p>Blah blah blah
9067 </p>
9068 !! html/parsoid
9069 <p>Blah blah blah</p>
9070 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
9071 !! end
9072
9073 !! test
9074 Double interlanguage link
9075 !! wikitext
9076 Blah blah blah
9077 [[es:Spanish]]
9078 [[zh:Chinese]]
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 !! end
9087
9088 ## parsoid html2wt will lose the space variations
9089 !! test
9090 Interlanguage link variations
9091 !! options
9092 parsoid=wt2html,wt2wt,html2html
9093 !! wikitext
9094 Blah blah blah
9095 [[ es :Spanish]]
9096 [[ ZH :Chinese]]
9097 [[es:Foo_bar]]
9098 !! html/php
9099 <p>Blah blah blah
9100 </p>
9101 !! html/parsoid
9102 <p>Blah blah blah</p>
9103 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Spanish" />
9104 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese" />
9105 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo_bar" />
9106 !! end
9107
9108 !! test
9109 Escaping of interlanguage links (T129218, T156308)
9110 !! wikitext
9111 Blah blah blah
9112 [[:es:Spanish]]
9113 [[ : zh : Chinese ]]
9114 !! html/php
9115 <p>Blah blah blah
9116 <a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">es:Spanish</a>
9117 <a href="http://zh.wikipedia.org/wiki/Chinese" class="extiw" title="zh:Chinese"> zh : Chinese </a>
9118 </p>
9119 !! html/parsoid
9120 <p>Blah blah blah
9121 <a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">es:Spanish</a>
9122 <a rel="mw:WikiLink/Interwiki" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese"> zh : Chinese </a></p>
9123 !! end
9124
9125 !! test
9126 Multiple colons escaping interlanguage links
9127 !! options
9128 parsoid=wt2html
9129 !! wikitext
9130 [[:es:Spanish]]
9131 [[::es:Spanish]]
9132 [[:::es:Spanish]]
9133 !! html/php
9134 <p><a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">es:Spanish</a>
9135 [[::es:Spanish]]
9136 [[:::es:Spanish]]
9137 </p>
9138 !! html/parsoid
9139 <p><a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">es:Spanish</a>
9140 [[::es:Spanish]]
9141 [[:::es:Spanish]]</p>
9142 !! end
9143
9144 ## parsoid html2wt will normalize the space to _
9145 !! test
9146 Space and question mark encoding in interlanguage links (T95473)
9147 !! options
9148 parsoid=wt2html,wt2wt,html2html
9149 !! wikitext
9150 Blah blah blah
9151 [[es:Foo bar?]]
9152 !! html/php
9153 <p>Blah blah blah
9154 </p>
9155 !! html/parsoid
9156 <p>Blah blah blah</p>
9157 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo_bar%3F" />
9158 !! end
9159
9160 !! test
9161 Interlanguage link, with prefix links
9162 !! options
9163 language=ln
9164 !! wikitext
9165 Blah blah blah
9166 [[zh:Chinese]]
9167 !! html/php
9168 <p>Blah blah blah
9169 </p>
9170 !! html/parsoid
9171 <p>Blah blah blah</p>
9172 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
9173 !! end
9174
9175 !! test
9176 Double interlanguage link, with prefix links (T10897)
9177 !! options
9178 language=ln
9179 !! wikitext
9180 Blah blah blah
9181 [[es:Spanish]]
9182 [[zh:Chinese]]
9183 !! html/php
9184 <p>Blah blah blah
9185 </p>
9186 !! html/parsoid
9187 <p>Blah blah blah</p>
9188 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Spanish"/>
9189 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
9190 !! end
9191
9192 !! test
9193 "Extra" interlanguage links (T34189 / gerrit 111390)
9194 !! wikitext
9195 Blah blah blah
9196 [[mul:Article]]
9197 !! html/php
9198 <p>Blah blah blah
9199 </p>
9200 !! html/parsoid
9201 <p>Blah blah blah</p>
9202 <link rel="mw:PageProp/Language" title="Multilingual" href="http://wikisource.org/wiki/Article"/>
9203 !! end
9204
9205 ## PHP parser tests script needs an update
9206 ## Parsoid html2wt will normalize output to [[:zh:Chinese]]
9207 !! test
9208 Language links render as inline links if $wgInterwikiMagic=false
9209 !! options
9210 wgInterwikiMagic=false
9211 parsoid=wt2html,wt2wt,html2html
9212 !! wikitext
9213 Blah blah blah
9214 [[zh:Chinese]]
9215 !! html/parsoid
9216 <p>Blah blah blah <a rel="mw:WikiLink/Interwiki" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese">zh:Chinese</a></p>
9217 !! end
9218
9219 ## PHP parser tests script needs an update
9220 ## Parsoid html2wt will normalize output to [[:zh:Chinese]]
9221 !! test
9222 Language links render as inline links in the Talk namespace
9223 !! options
9224 title=Talk:Foo
9225 parsoid=wt2html,wt2wt,html2html
9226 !! wikitext
9227 Blah blah blah
9228 [[zh:Chinese]]
9229 !! html/parsoid
9230 <p>Blah blah blah <a rel="mw:WikiLink/Interwiki" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese">zh:Chinese</a></p>
9231 !! end
9232
9233 !! test
9234 Parsoid-specific test: Wikilinks with &nbsp; should RT properly
9235 !! options
9236 language=ln
9237 !! wikitext
9238 [[WW&nbsp;II]]
9239 !! html
9240 <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>
9241 </p>
9242 !! end
9243
9244 !! test
9245 Parsoid T55221: Wikilinks should be properly entity-escaped
9246 !! options
9247 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
9248 !! html/parsoid
9249 <p>He&amp;nbsp;llo <a href="./Foo" rel="mw:WikiLink">He&amp;nbsp;llo</a></p>
9250 <p>He&amp;nbsp;llo <a href="./He&amp;nbsp;llo" rel="mw:WikiLink">He&amp;nbsp;llo</a></p>
9251 !! wikitext
9252 He&amp;nbsp;llo [[Foo|He&amp;nbsp;llo]]
9253
9254 He&amp;nbsp;llo He&amp;nbsp;llo
9255 !! html/php
9256 <p>He&amp;nbsp;llo <a href="/wiki/Foo" title="Foo">He&amp;nbsp;llo</a>
9257 </p><p>He&amp;nbsp;llo He&amp;nbsp;llo
9258 </p>
9259 !! end
9260
9261 # html2wt will fail because of title normalization without data-parsoid
9262 !! test
9263 Parsoid: handle constructor well
9264 !! options
9265 parsoid=wt2html,wt2wt
9266 !! wikitext
9267 [[constructor]]
9268
9269 [[constructor:foo]]
9270 !! html/php
9271 <p><a href="/index.php?title=Constructor&amp;action=edit&amp;redlink=1" class="new" title="Constructor (page does not exist)">constructor</a>
9272 </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>
9273 </p>
9274 !! html/parsoid
9275 <p><a rel="mw:WikiLink" href="./Constructor" title="Constructor" data-parsoid='{"stx":"simple","a":{"href":"./Constructor"},"sa":{"href":"constructor"}}'>constructor</a></p>
9276
9277 <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>
9278 !! end
9279
9280 !! test
9281 Template parameter named "constructor"
9282 !! wikitext
9283 {{echo| constructor = |hi}}
9284 !! html/parsoid
9285 <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>
9286 !! end
9287
9288 !! article
9289 ko:
9290 !! text
9291 Test.
9292 !! endarticle
9293
9294 # Note that `ko` isn't a known interlanguage prefix
9295 !! test
9296 Parsoid: recognize interlanguage links without a target page
9297 !! options
9298 ill
9299 !! wikitext
9300 [[es:]]
9301
9302 [[ko:]]
9303 !! html/php
9304 es:
9305 !! html/parsoid
9306 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/"/>
9307
9308 <p><a rel="mw:WikiLink" href="./Ko:" title="Ko:">ko:</a></p>
9309 !! end
9310
9311 # Note that `ko` isn't a known interwiki prefix
9312 !! test
9313 Parsoid: recognize interwiki links without a target page
9314 !! options
9315 parsoid=wt2html,wt2wt,html2html
9316 !! wikitext
9317 [[:es:]]
9318
9319 [[:ko:]]
9320 !! html/php
9321 <p><a href="http://es.wikipedia.org/wiki/" class="extiw" title="es:">es:</a>
9322 </p><p><a href="/wiki/Ko:" title="Ko:">ko:</a>
9323 </p>
9324 !! html/parsoid
9325 <p><a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/" title="es:">es:</a></p>
9326 <p><a rel="mw:WikiLink" href="./Ko:" title="Ko:">ko:</a></p>
9327 !! end
9328
9329 !! test
9330 Handle interwiki links pointing to the current wiki as plain wiki links (T47209)
9331 !! wikitext
9332 [[mi:Foo]]
9333 !! html/php
9334 <p><a href="/wiki/Foo" title="Foo">mi:Foo</a>
9335 </p>
9336 !! html/parsoid
9337 <p><a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"simple","a":{"href":"./Foo"},"sa":{"href":"mi:Foo"}}'>mi:Foo</a></p>
9338 !! end
9339
9340 !! test
9341 Interlanguage link with preceding local interwiki link (T70085)
9342 !! options
9343 parsoid=wt2html,wt2wt,html2html
9344 !! wikitext
9345 Blah blah blah
9346 [[local:es:Spanish]]
9347 !! html/php
9348 <p>Blah blah blah
9349 <a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">local:es:Spanish</a>
9350 </p>
9351 !! html/parsoid
9352 <p>Blah blah blah
9353 <a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">local:es:Spanish</a></p>
9354 !! end
9355
9356 !! test
9357 Looks like an interlanguage link, but is actually a local interwiki
9358 !! options
9359 parsoid=wt2html,wt2wt,html2html
9360 !! wikitext
9361 Blah blah blah
9362 [[mi:Template:Foo]]
9363 !! html/php
9364 <p>Blah blah blah
9365 <a href="/wiki/Template:Foo" title="Template:Foo">mi:Template:Foo</a>
9366 </p>
9367 !! html/parsoid
9368 <p>Blah blah blah
9369 <a rel="mw:WikiLink" href="./Template:Foo" title="Template:Foo">mi:Template:Foo</a></p>
9370 !! end
9371
9372 ###
9373 ### Redirects, Parsoid-only
9374 ###
9375
9376 !! test
9377 1. Simple redirect to page
9378 !! wikitext
9379 #REDIRECT [[Main Page]]
9380 !! html/parsoid
9381 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9382 !! end
9383
9384 !! test
9385 2. Other redirect variants
9386 !! wikitext
9387 #REDIRECT [[Main_Page]]
9388 !! html/parsoid
9389 <link rel="mw:PageProp/redirect" href="./Main_Page" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./Main_Page"},"sa":{"href":"Main_Page"}}'/>
9390 !! end
9391
9392 # Not a valid redirect in PHP (although perhaps it was, once upon a time)
9393 # This tests the Parsoid bail-out code.
9394 !! test
9395 3. Other redirect variants
9396 !! options
9397 parsoid=wt2html
9398 !! wikitext
9399 #REDIRECT [[<nowiki>[[Bar]]</nowiki>]]
9400 !! html/parsoid
9401 <ol><li>REDIRECT [[<span typeof="mw:Nowiki">[[Bar]]</span>]]</li></ol>
9402 !! end
9403
9404 !! test
9405 4. Redirect to a templated destination
9406 !! wikitext
9407 #REDIRECT [[{{echo|Foo}}bar]]
9408 !! html/parsoid
9409 <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"}]]}'/>
9410 !! end
9411
9412 !! test
9413 Empty redirect
9414 !! options
9415 parsoid=wt2html,wt2wt
9416 !! wikitext
9417 #REDIRECT [[]]
9418 !! html/parsoid
9419 <ol>
9420 <li>REDIRECT [[]]</li></ol>
9421 !! end
9422
9423 !! test
9424 Optional colon in #REDIRECT
9425 !! options
9426 # the colon is archaic syntax. we support it for wt2html, but we
9427 # don't care that it roundtrips back to the modern syntax.
9428 parsoid=wt2html,html2html
9429 !! wikitext
9430 #REDIRECT:[[Main Page]]
9431 !! html/parsoid
9432 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9433 !! end
9434
9435 !! test
9436 Whitespace in #REDIRECT with optional colon
9437 !! options
9438 # the colon and gratuitous whitespace is archaic syntax. we support
9439 # it for wt2html, but we don't care that it roundtrips back to the
9440 # modern syntax (without extra whitespace)
9441 parsoid=wt2html,html2html
9442 !! wikitext
9443
9444 #REDIRECT
9445 :
9446 [[Main Page]]
9447 !! html/parsoid
9448 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9449 !! end
9450
9451 !! test
9452 Piped link in #REDIRECT
9453 !! options
9454 # content after piped link is ignored. we support this syntax,
9455 # but don't care that the piped link is lost when we roundtrip this.
9456 parsoid=wt2html
9457 !! wikitext
9458 #REDIRECT [[Main Page|bar]]
9459 !! html/parsoid
9460 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9461 !! end
9462
9463 !! test
9464 Redirect to category (T104502)
9465 !! options
9466 parsoid=wt2html,wt2wt
9467 !! wikitext
9468 #REDIRECT [[Category:Foo]]
9469 !! html/parsoid
9470 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
9471 !! end
9472
9473 !! test
9474 Redirect to category with URL encoding (T104502)
9475 !! options
9476 parsoid=wt2html
9477 !! wikitext
9478 #REDIRECT [[Category%3AFoo]]
9479 !! html/parsoid
9480 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
9481 !! end
9482
9483 !! test
9484 Redirect to category page
9485 !! wikitext
9486 #REDIRECT [[:Category:Foo]]
9487 !! html/parsoid
9488 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
9489 !! end
9490
9491 !! test
9492 Redirect to image page (1)
9493 !! wikitext
9494 #REDIRECT [[File:Wiki.png]]
9495 !! html/parsoid
9496 <link rel="mw:PageProp/redirect" href="./File:Wiki.png"/>
9497 !! end
9498
9499 !! test
9500 Redirect to image page (2)
9501 !! wikitext
9502 #REDIRECT [[Image:Wiki.png]]
9503 !! html/parsoid
9504 <link rel="mw:PageProp/redirect" href="./File:Wiki.png" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./File:Wiki.png"},"sa":{"href":"Image:Wiki.png"}}'/>
9505 !! end
9506
9507 # html2wt disabled because wts serializes as "#REDIRECT [[:en:File:Wiki.png]]"
9508 # Next test confirms this.
9509 !! test
9510 Redirect to language (1) (T104918)
9511 !! options
9512 parsoid=wt2html,wt2wt,html2html
9513 !! wikitext
9514 #REDIRECT [[en:File:Wiki.png]]
9515 !! html/parsoid
9516 <link rel="mw:PageProp/redirect" href="//en.wikipedia.org/wiki/File:Wiki.png"/>
9517 !! end
9518
9519 !! test
9520 Redirect to language (2) (T104918)
9521 !! wikitext
9522 #REDIRECT [[:en:File:Wiki.png]]
9523 !! html/parsoid
9524 <link rel="mw:PageProp/redirect" href="//en.wikipedia.org/wiki/File:Wiki.png"/>
9525 !! end
9526
9527 !! test
9528 Redirect to interwiki (T104918)
9529 !! wikitext
9530 #REDIRECT [[meatball:File:Wiki.png]]
9531 !! html/parsoid
9532 <link rel="mw:PageProp/redirect" href="http://www.usemod.com/cgi-bin/mb.pl?File:Wiki.png"/>
9533 !! end
9534
9535 !! test
9536 Non-English #REDIRECT
9537 !! options
9538 language=is
9539 !! wikitext
9540 #TILVÍSUN [[Main Page]]
9541 !! html/parsoid
9542 <link rel="mw:PageProp/redirect" href="./Main_Page" data-parsoid='{"src":"#TILVÍSUN ","a":{"href":"./Main_Page"},"sa":{"href":"Main Page"}}'/>
9543 !! end
9544
9545 !! test
9546 Redirect syntax under text isn't considered a redirect
9547 !! wikitext
9548 some text
9549
9550 #redirect [[Main Page]]
9551 !! html/parsoid
9552 <p>some text</p>
9553 <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>
9554 !! end
9555
9556 !! test
9557 New redirect
9558 !! options
9559 parsoid=html2wt
9560 !! html/parsoid
9561 <p>Foo<link rel="mw:PageProp/redirect" href="./Foo"/></p>
9562 !! wikitext
9563 #REDIRECT [[Foo]]
9564 Foo
9565 !! end
9566
9567 !! test
9568 Redirect followed by block on the same line
9569 !! options
9570 parsoid=wt2html
9571 !! wikitext
9572 #REDIRECT [[Main Page]]<!-- haha -->==hi==
9573 !! html/parsoid
9574 <link rel="mw:PageProp/redirect" href="./Main_Page"/><!-- haha --><h2 id="hi">hi</h2>
9575 !! end
9576
9577 !! test
9578 Redirect followed by a newline
9579 !! wikitext
9580 #REDIRECT [[Main Page]]
9581 A newline
9582 !! html/parsoid
9583 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9584 <p>A newline</p>
9585 !! end
9586
9587 !! test
9588 Redirect followed by multiple newlines
9589 !! wikitext
9590 #REDIRECT [[Main Page]]
9591
9592
9593 A newline
9594 !! html/parsoid
9595 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9596
9597 <p><br/>
9598 A newline</p>
9599 !! end
9600
9601 !! test
9602 Drop duplicate redirects
9603 !! options
9604 parsoid=html2wt
9605 !! html/parsoid
9606 <link rel="mw:PageProp/redirect" href="./Foo"/>
9607 <link rel="mw:PageProp/redirect" href="./Bar"/>
9608 <link rel="mw:PageProp/redirect" href="./Baz"/>
9609 !! wikitext
9610 #REDIRECT [[Foo]]
9611 !! end
9612
9613 ##
9614 ## XHTML tidiness
9615 ###
9616
9617 !! test
9618 <br> to <br />
9619 !! wikitext
9620 1<br>2<br />3
9621 !! html
9622 <p>1<br />2<br />3
9623 </p>
9624 !! end
9625
9626 !! test
9627 Broken br tag sanitization
9628 !! wikitext
9629 </br>
9630 !! html/php
9631 <p>&lt;/br&gt;
9632 </p>
9633 !! end
9634
9635 # TODO: Fix html2html mode (T53055)!
9636 !! test
9637 Parsoid: Broken br tag recognition
9638 !! options
9639 parsoid=wt2html
9640 !! wikitext
9641 </br>
9642
9643 <br/ >
9644 !! html+tidy
9645 <p><br />
9646 </p><p><br />
9647 </p>
9648 !! end
9649
9650 !! test
9651 Incorrecly removing closing slashes from correctly formed XHTML
9652 !! wikitext
9653 <br style="clear:both;" />
9654 !! html
9655 <p><br style="clear:both;" />
9656 </p>
9657 !! end
9658
9659 !! test
9660 Failing to transform badly formed HTML into correct XHTML
9661 !! wikitext
9662 <br style="clear: left;">
9663 <br style="clear: right;">
9664 <br style="clear: both;">
9665 !! html
9666 <p><br style="clear: left;" />
9667 <br style="clear: right;" />
9668 <br style="clear: both;" />
9669 </p>
9670 !!end
9671
9672 ## FIXME: Is Parsoid's acceptance of self-closing html-tags
9673 ## a feature or a bug? See https://phabricator.wikimedia.org/T76962
9674 !! test
9675 Handling html with a div self-closing tag
9676 !! wikitext
9677 <div title />
9678 <div title/>
9679 <div title/ >
9680 <div title=bar />
9681 <div title=bar/>
9682 <div title=bar/ >
9683 !! html/php+tidy
9684 <div title=""></div>
9685 <div title=""></div>
9686 <div title="">
9687 <div title="bar"></div>
9688 <div title="bar"></div>
9689 <div title="bar/">
9690 </div></div>
9691 !! html/parsoid
9692 <div title="" data-parsoid='{"stx":"html","selfClose":true}'></div>
9693 <div title="" data-parsoid='{"stx":"html","selfClose":true}'></div>
9694 <div title="" data-parsoid='{"stx":"html","autoInsertedEnd":true}'>
9695 <div title="bar" data-parsoid='{"stx":"html","selfClose":true}'></div>
9696 <div title="bar" data-parsoid='{"stx":"html","selfClose":true}'></div>
9697 <div title="bar/" data-parsoid='{"stx":"html","autoInsertedEnd":true}'></div></div>
9698 !! end
9699
9700 !! test
9701 Elements with solidus in various attribute positions
9702 !! options
9703 parsoid=wt2html,html2html
9704 !! wikitext
9705 <div cla/ss="123">ha</div>
9706
9707 <div / class="123">ha</div>
9708
9709 <div class= / "123">ha</div>
9710 !! html/php+tidy
9711 <div>ha</div>
9712 <div class="123">ha</div>
9713 <div class="/">ha</div>
9714 !! html/parsoid
9715 <div data-parsoid='{"stx":"html","a":{"cla":null,"ss":null},"sa":{"cla":"","ss":"123"}}'>ha</div>
9716
9717 <div class="123" data-parsoid='{"stx":"html"}'>ha</div>
9718
9719 <div class="/" data-parsoid='{"stx":"html","a":{"\"123\"":null},"sa":{"\"123\"":""}}'>ha</div>
9720 !! end
9721
9722 !! test
9723 Handling html with a br self-closing tag
9724 !! wikitext
9725 <br title />
9726 <br title/>
9727 <br title/ >
9728 <br title=bar />
9729 <br title=bar/>
9730 <br title=bar/ >
9731 !! html/php+tidy
9732 <p><br title="" />
9733 <br title="" />
9734 <br title="" />
9735 <br title="bar" />
9736 <br title="bar" />
9737 <br title="bar/" />
9738 </p>
9739 !! html/parsoid
9740 <p><br title="" />
9741 <br title="" />
9742 <br title="" />
9743 <br title="bar" />
9744 <br title="bar" />
9745 <br title="bar/" />
9746 </p>
9747 !! end
9748
9749 !! test
9750 Quoted attributes without spaces
9751 !! options
9752 parsoid=wt2html
9753 !! wikitext
9754 <div class="foo"style="color:red">red</div>
9755 !! html/php+tidy
9756 <div class="foo" style="color:red">red</div>
9757 !! html/parsoid
9758 <div class="foo" style="color:red">red</div>
9759 !! end
9760
9761 !! test
9762 Horizontal ruler (should it add that extra space?)
9763 !! wikitext
9764 <hr>
9765 <hr >
9766 foo <hr
9767 > bar
9768 !! html+tidy
9769 <hr />
9770 <hr /><p>
9771 foo </p><hr /><p> bar
9772 </p>
9773 !! end
9774
9775 !! test
9776 Horizontal ruler -- 4+ dashes render hr
9777 !! wikitext
9778 ----
9779 !! html
9780 <hr />
9781
9782 !! end
9783
9784 !! test
9785 Horizontal ruler -- eats additional dashes on the same line
9786 !! wikitext
9787 ---------
9788 !! html
9789 <hr />
9790
9791 !! end
9792
9793 !! test
9794 Horizontal ruler -- does not collapse dashes on consecutive lines
9795 !! wikitext
9796 ----
9797 ----
9798 !! html
9799 <hr />
9800 <hr />
9801
9802 !! end
9803
9804 !! test
9805 Horizontal ruler -- <4 dashes render as plain text
9806 !! wikitext
9807 ---
9808 !! html
9809 <p>---
9810 </p>
9811 !! end
9812
9813 !! test
9814 Horizontal ruler -- Supports content following dashes on same line
9815 !! wikitext
9816 ---- Foo
9817 !! html
9818 <hr /> Foo
9819
9820 !! html+tidy
9821 <hr /><p> Foo
9822 </p>
9823 !! end
9824
9825 ###
9826 ### Block-level elements
9827 ###
9828 !! test
9829 Common list
9830 !! wikitext
9831 *Common list
9832 *item 2
9833 *item 3
9834 !! html
9835 <ul><li>Common list</li>
9836 <li>item 2</li>
9837 <li>item 3</li></ul>
9838 !! end
9839
9840 !! test
9841 Numbered list
9842 !! wikitext
9843 #Numbered list
9844 #item 2
9845 #item 3
9846 !! html
9847 <ol><li>Numbered list</li>
9848 <li>item 2</li>
9849 <li>item 3</li></ol>
9850 !! end
9851
9852 # the switch from level 3 to ordered should not introduce a newline between
9853 !! test
9854 Mixed list
9855 !! wikitext
9856 *Mixed list
9857 *#with numbers
9858 **and bullets
9859 *#and numbers
9860 *bullets again
9861 **bullet level 2
9862 ***bullet level 3
9863 ***#Number on level 4
9864 **bullet level 2
9865 **#Number on level 3
9866 **#Number on level 3
9867 *#number level 2
9868 *Level 1
9869 ***Level 3
9870 #**Level 3, but ordered
9871 !! html
9872 <ul><li>Mixed list
9873 <ol><li>with numbers</li></ol>
9874 <ul><li>and bullets</li></ul>
9875 <ol><li>and numbers</li></ol></li>
9876 <li>bullets again
9877 <ul><li>bullet level 2
9878 <ul><li>bullet level 3
9879 <ol><li>Number on level 4</li></ol></li></ul></li>
9880 <li>bullet level 2
9881 <ol><li>Number on level 3</li>
9882 <li>Number on level 3</li></ol></li></ul>
9883 <ol><li>number level 2</li></ol></li>
9884 <li>Level 1
9885 <ul><li><ul><li>Level 3</li></ul></li></ul></li></ul>
9886 <ol><li><ul><li><ul><li>Level 3, but ordered</li></ul></li></ul></li></ol>
9887 !! end
9888
9889 !! test
9890 1. Nested mixed wikitext and html list
9891 !! wikitext
9892 *hi
9893 *<ul><li>ho</li></ul>
9894 *hi
9895 **ho
9896 !! html/php
9897 <ul><li>hi</li>
9898 <li><ul><li>ho</li></ul></li>
9899 <li>hi
9900 <ul><li>ho</li></ul></li></ul>
9901 !! html/parsoid
9902 <ul><li>hi</li>
9903 <li><ul data-parsoid='{"stx":"html"}'><li data-parsoid='{"stx":"html"}'>ho</li></ul></li>
9904 <li>hi
9905 <ul><li>ho</li></ul></li></ul>
9906 !! end
9907
9908 !! test
9909 2. Nested mixed wikitext and html list (incompatible)
9910 !! wikitext
9911 ;hi
9912 :{{echo|<li>ho</li>}}
9913 !! html/php
9914 <dl><dt>hi</dt>
9915 <dd><li>ho</li></dd></dl>
9916 !! html/parsoid
9917 <dl><dt>hi</dt>
9918 <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>
9919 !! end
9920
9921 !! test
9922 Nested lists 1
9923 !! wikitext
9924 *foo
9925 **bar
9926 !! html
9927 <ul><li>foo
9928 <ul><li>bar</li></ul></li></ul>
9929 !! end
9930
9931 !! test
9932 Nested lists 2
9933 !! wikitext
9934 **foo
9935 *bar
9936 !! html
9937 <ul><li><ul><li>foo</li></ul></li>
9938 <li>bar</li></ul>
9939 !! end
9940
9941 !! test
9942 Nested lists 3 (first element empty)
9943 !! wikitext
9944 *
9945 **bar
9946 !! html
9947 <ul><li>
9948 <ul><li>bar</li></ul></li></ul>
9949 !! end
9950
9951 !! test
9952 Nested lists 4 (first element empty)
9953 !! wikitext
9954 **
9955 *bar
9956 !! html
9957 <ul><li><ul><li></li></ul></li>
9958 <li>bar</li></ul>
9959 !! end
9960
9961 !! test
9962 Nested lists 5 (both elements empty)
9963 !! wikitext
9964 **
9965 *
9966 !! html
9967 <ul><li><ul><li></li></ul></li>
9968 <li></li></ul>
9969 !! end
9970
9971 !! test
9972 Nested lists 6 (both elements empty)
9973 !! wikitext
9974 *
9975 **
9976 !! html
9977 <ul><li>
9978 <ul><li></li></ul></li></ul>
9979 !! end
9980
9981 !! test
9982 Nested lists 7 (skip initial nesting levels)
9983 !! wikitext
9984 ***foo
9985 !! html
9986 <ul><li><ul><li><ul><li>foo</li></ul></li></ul></li></ul>
9987 !! end
9988
9989 !! test
9990 Nested lists 8 (multiple nesting transitions)
9991 !! wikitext
9992 *foo
9993 ***bar
9994 **baz
9995 *boo
9996 !! html
9997 <ul><li>foo
9998 <ul><li><ul><li>bar</li></ul></li>
9999 <li>baz</li></ul></li>
10000 <li>boo</li></ul>
10001 !! end
10002
10003 # XXX this test should be moved to citeParserTests, since it depends
10004 # on the Cite extension, which is "built in" to Parsoid.
10005 !! test
10006 Nested lists 9 (extension interaction)
10007 !! wikitext
10008 *<references />
10009 !! html/php+tidy-DISABLED
10010 <ul><li class="mw-empty-elt"></li></ul>
10011 !! html/parsoid
10012 <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>
10013 !! end
10014
10015 !! test
10016 1. Lists with start-of-line-transparent tokens before bullets: Comments
10017 !! wikitext
10018 *foo
10019 *<!--cmt-->bar
10020 <!--cmt-->*baz
10021 !! html
10022 <ul><li>foo</li>
10023 <li>bar</li>
10024 <li>baz</li></ul>
10025 !! end
10026
10027 !! test
10028 Nested lists 10 (list and span siblings: wt2wt regression)
10029 !! wikitext
10030 *a <span>x</span>
10031 **b <span>y</span>
10032 !! html/parsoid
10033 <ul><li>a <span>x</span>
10034 <ul><li>b <span>y</span></li></ul></li></ul>
10035 !! end
10036
10037 !! test
10038 2. Lists with start-of-line-transparent tokens before bullets: Template close
10039 !! wikitext
10040 *foo {{echo|bar
10041 }}*baz
10042 !! html
10043 <ul><li>foo bar</li>
10044 <li>baz</li></ul>
10045 !! end
10046
10047 !! test
10048 List items are not parsed correctly following a <pre> block (T2785)
10049 !! wikitext
10050 *<pre>foo</pre>
10051 *<pre>bar</pre>
10052 *zar
10053 !! html/php
10054 <ul><li><pre>foo</pre></li>
10055 <li><pre>bar</pre></li>
10056 <li>zar</li></ul>
10057 !! html/parsoid
10058 <ul><li><pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo"}}'>foo</pre></li>
10059 <li><pre typeof="mw:Extension/pre" about="#mwt4" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"bar"}}'>bar</pre></li>
10060 <li>zar</li></ul>
10061 !! end
10062
10063 # FIXME: Might benefit from a html/parsoid since this has a template
10064 !! test
10065 List items from template
10066 !! wikitext
10067
10068 {{inner list}}
10069 *item 2
10070
10071 *item 0
10072 {{inner list}}
10073 *item 2
10074
10075 *item 0
10076 *notSOL{{inner list}}
10077 *item 2
10078 !! html
10079 <ul><li>item 1</li>
10080 <li>item 2</li></ul>
10081 <ul><li>item 0</li>
10082 <li>item 1</li>
10083 <li>item 2</li></ul>
10084 <ul><li>item 0</li>
10085 <li>notSOL</li>
10086 <li>item 1</li>
10087 <li>item 2</li></ul>
10088 !! end
10089
10090 !! test
10091 List interrupted by empty line or heading
10092 !! wikitext
10093 *foo
10094
10095 **bar
10096 ==A heading==
10097 *Another list item
10098 !! html
10099 <ul><li>foo</li></ul>
10100 <ul><li><ul><li>bar</li></ul></li></ul>
10101 <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>
10102 <ul><li>Another list item</li></ul>
10103 !!end
10104
10105 !! test
10106 Multiple list tags generated by templates
10107 !! wikitext
10108 {{echo|<li>}}a
10109 {{echo|<li>}}b
10110 {{echo|<li>}}c
10111 !! html
10112 <li>a
10113 <li>b
10114 <li>c</li>
10115 </li>
10116 </li>
10117
10118
10119 !! html+tidy
10120 <li>a
10121 </li><li>b
10122 </li><li>c
10123 </li>
10124 !! html/parsoid
10125 <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>
10126 <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>
10127 <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>
10128 !! end
10129
10130 !! test
10131 Multiple newlines in between HTML list items don't induce paragraph wrapping
10132 !! wikitext
10133 <ul>
10134 <li>hi</li>
10135
10136
10137
10138
10139 <li>ho</li>
10140 </ul>
10141
10142 <dl>
10143 <dt>hi</dt>
10144 <dd>ho<div>123</div>
10145 </dd>
10146
10147
10148 </dl>
10149 !! html/php+tidy
10150 <ul>
10151 <li>hi</li>
10152
10153
10154
10155
10156 <li>ho</li>
10157 </ul>
10158 <dl>
10159 <dt>hi</dt>
10160 <dd>ho<div>123</div>
10161 </dd>
10162
10163
10164 </dl>
10165 !! end
10166
10167 !!test
10168 Single-comment whitespace lines dont break lists, and neither do multi-comment whitespace lines
10169 !! wikitext
10170 *a
10171 <!--This line will NOT split the list-->
10172 *b
10173 <!--This line will NOT split the list either-->
10174 *c
10175 <!--foo--> <!----> <!--This line NOT split the list either-->
10176 *d
10177 !! html
10178 <ul><li>a</li>
10179 <li>b</li>
10180 <li>c</li>
10181 <li>d</li></ul>
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 !!end
10201
10202 # FIXME: Parsoid has a dedicated DOM pass to mimic this Tidy-specific li-hack
10203 # That pass could possibly be removed.
10204 !!test
10205 Test the li-hack (a hack from Tidy days, but doesn't work as advertised with Remex)
10206 !!options
10207 parsoid=wt2html,wt2wt
10208 !! wikitext
10209 *foo
10210 *<li>li-hack
10211 *{{echo|<li>templated li-hack}}
10212 *<!--foo--><li> unsupported li-hack with preceding comments
10213
10214 <ul>
10215 <li><li>not a li-hack
10216 </li>
10217 </ul>
10218 !! html+tidy
10219 <ul><li>foo</li>
10220 <li class="mw-empty-elt"></li><li>li-hack</li>
10221 <li class="mw-empty-elt"></li><li>templated li-hack</li>
10222 <li class="mw-empty-elt"></li><li> unsupported li-hack with preceding comments</li></ul>
10223 <ul>
10224 <li class="mw-empty-elt"></li><li>not a li-hack
10225 </li>
10226 </ul>
10227 !! html/parsoid
10228 <ul><li> foo</li>
10229 <li data-parsoid='{"stx":"html","autoInsertedEnd":true,"liHackSrc":"*"}'>li-hack</li>
10230 <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>
10231 <li data-parsoid='{"autoInsertedEnd":true}'><!--foo--></li><li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>unsupported li-hack with preceding comments</li></ul>
10232
10233 <ul data-parsoid='{"stx":"html"}'>
10234 <li class="mw-empty-elt" data-parsoid='{"stx":"html","autoInsertedEnd":true}'></li><li data-parsoid='{"stx":"html"}'>not a li-hack
10235 </li>
10236 </ul>
10237
10238 !!end
10239
10240 !! test
10241 Parsoid: Make sure nested lists are serialized on their own line even if HTML contains no newlines
10242 !! wikitext
10243 #foo
10244 ##bar
10245
10246 *foo
10247 **bar
10248
10249 :foo
10250 ::bar
10251 !! html/php+tidy
10252 <ol><li>foo
10253 <ol><li>bar</li></ol></li></ol>
10254 <ul><li>foo
10255 <ul><li>bar</li></ul></li></ul>
10256 <dl><dd>foo
10257 <dl><dd>bar</dd></dl></dd></dl>
10258 !! html/parsoid
10259 <ol>
10260 <li>foo<ol>
10261 <li>bar</li>
10262 </ol></li>
10263 </ol><ul>
10264 <li>foo<ul>
10265 <li>bar</li>
10266 </ul></li>
10267 </ul><dl>
10268 <dd>foo<dl>
10269 <dd>bar</dd>
10270 </dl></dd>
10271 </dl>
10272 !! end
10273
10274 !! test
10275 Parsoid: Test of whitespace serialization with Templated bullets
10276 !! options
10277 parsoid=wt2html
10278 !! wikitext
10279 * {{bullet}}
10280 !! html/parsoid
10281 <ul>
10282 <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>
10283 </ul>
10284 !! end
10285
10286 # ------------------------------------------------------------------------
10287 # The next set of tests are about Parsoid's ability to handle badly nested
10288 # tags (parse, minimize scope of fixup, and roundtrip back)
10289 # ------------------------------------------------------------------------
10290
10291 # Remex and Parsoid output stems from list handling diffs because Parsoid & PHP parser.
10292 # Parsoid's list handling is more aware of block structure.
10293 !! test
10294 Unbalanced closing block tags break a list
10295 !! wikitext
10296 <div>
10297 *a</div><div>
10298 *b</div>
10299 !! html+tidy
10300 <div>
10301 <ul><li>a</li></ul></div><div>
10302 <li>b</li></div>
10303 !! html/parsoid
10304 <div><ul>
10305 <li>a</li>
10306 </ul></div>
10307 <div><ul>
10308 <li>b</li>
10309 </ul></div>
10310 !! end
10311
10312 !! test
10313 Unbalanced closing non-block tags don't break a list
10314 !! options
10315 parsoid=wt2html,html2html
10316 !! wikitext
10317 <span>
10318 *a</span><span>
10319 *b</span>
10320 !! html/php+tidy
10321 <p><span>
10322 </span></p>
10323 <ul><li>a<span></span></li>
10324 <li>b</li></ul>
10325 !! html/parsoid
10326 <p><span data-parsoid='{"stx":"html","autoInsertedEnd":true}'></span></p>
10327 <ul><li>a<span data-parsoid='{"stx":"html","autoInsertedEnd":true}'></span></li>
10328 <li>b</li></ul>
10329 !! end
10330
10331 # Parsoid does some post-dom-building cleanup
10332 # which is why its output differs from Remex.
10333 !! test
10334 Unclosed formatting tags that straddle lists are closed and reopened
10335 !! options
10336 parsoid=wt2html,wt2wt,html2html
10337 !! wikitext
10338 #<s> a
10339 #b </s>
10340 !! html/php+tidy
10341 <ol><li><s> a</s></li><s>
10342 </s><li><s>b </s></li></ol>
10343 !! html/parsoid
10344 <ol><li><s> a</s></li>
10345 <li><s>b </s></li></ol>
10346 !! end
10347
10348 # Output is ugly because of all the misnested tag fixups.
10349 !! test
10350 1. List embedded in a formatting tag
10351 !! wikitext
10352 <small>
10353 *foo
10354 </small>
10355 !! html/php+tidy
10356 <p><small>
10357 </small></p><small><ul><li>foo</li></ul></small><small></small><p><small></small>
10358 </p>
10359 !! html/parsoid
10360 <p><small data-parsoid='{"stx":"html","autoInsertedEnd":true}'></small></p><small data-parsoid='{"stx":"html","autoInsertedEnd":true,"autoInsertedStart":true}'>
10361 <ul><li data-parsoid='{}'>foo</li></ul></small>
10362 <p><small data-parsoid='{"stx":"html","autoInsertedStart":true}'></small></p>
10363 !! end
10364
10365 # Output is ugly because of all the misnested tag fixups.
10366 !! test
10367 2. List embedded in a formatting tag in a misnested way
10368 !! wikitext
10369 <small>
10370 *a
10371 *b</small>
10372 !! html/php+tidy
10373 <p><small>
10374 </small></p><small></small><ul><small><li>a</li>
10375 </small><li><small>b</small></li></ul>
10376 !! html/parsoid
10377 <p><small data-parsoid='{"stx":"html","autoInsertedEnd":true}'></small></p>
10378 <ul><small data-parsoid='{"stx":"html","autoInsertedEnd":true,"autoInsertedStart":true}'><li>a</li></small>
10379 <li><small data-parsoid='{"stx":"html","autoInsertedStart":true}'>b</small></li></ul>
10380 !! end
10381
10382 # Output is ugly because of all the misnested tag fixups.
10383 !! test
10384 3. List embedded in a formatting tag in a misnested way
10385 !! wikitext
10386 <small>
10387
10388 ** 123</small>
10389 !! html/php+tidy
10390 <p><small>
10391 </small></p><small></small><ul><small></small><li><small></small><ul><small></small><li><small>123</small></li></ul></li></ul>
10392 !! html/parsoid
10393 <p><small data-parsoid='{"stx":"html","autoInsertedEnd":true}'></small></p>
10394
10395 <ul><li><ul><li data-parsoid='{}'><small data-parsoid='{"stx":"html","autoInsertedStart":true}'> 123</small></li></ul></li></ul>
10396 !! end
10397
10398 ###
10399 ### Magic Words
10400 ###
10401
10402 # Note that the current date is hard-coded as
10403 # 1970-01-01T00:02:03Z (a Thursday)
10404 # when running parser tests. The timezone is also fixed to GMT, so
10405 # local date will be identical to current date.
10406
10407 !! test
10408 Magic Word: {{CURRENTDAY}}
10409 !! wikitext
10410 {{CURRENTDAY}}
10411 !! html
10412 <p>1
10413 </p>
10414 !! end
10415
10416 !! test
10417 Magic Word: {{CURRENTDAY2}}
10418 !! wikitext
10419 {{CURRENTDAY2}}
10420 !! html
10421 <p>01
10422 </p>
10423 !! end
10424
10425 !! test
10426 Magic Word: {{CURRENTDAYNAME}}
10427 !! wikitext
10428 {{CURRENTDAYNAME}}
10429 !! html
10430 <p>Thursday
10431 </p>
10432 !! end
10433
10434 !! test
10435 Magic Word: {{CURRENTDOW}}
10436 !! wikitext
10437 {{CURRENTDOW}}
10438 !! html
10439 <p>4
10440 </p>
10441 !! end
10442
10443 !! test
10444 Magic Word: {{CURRENTMONTH}}
10445 !! wikitext
10446 {{CURRENTMONTH}}
10447 !! html
10448 <p>01
10449 </p>
10450 !! end
10451
10452 !! test
10453 Magic Word: {{CURRENTMONTH1}}
10454 !! wikitext
10455 {{CURRENTMONTH1}}
10456 !! html
10457 <p>1
10458 </p>
10459 !! end
10460
10461 !! test
10462 Magic Word: {{CURRENTMONTHABBREV}}
10463 !! wikitext
10464 {{CURRENTMONTHABBREV}}
10465 !! html
10466 <p>Jan
10467 </p>
10468 !! end
10469
10470 !! test
10471 Magic Word: {{CURRENTMONTHNAME}}
10472 !! wikitext
10473 {{CURRENTMONTHNAME}}
10474 !! html
10475 <p>January
10476 </p>
10477 !! end
10478
10479 !! test
10480 Magic Word: {{CURRENTMONTHNAMEGEN}}
10481 !! wikitext
10482 {{CURRENTMONTHNAMEGEN}}
10483 !! html
10484 <p>January
10485 </p>
10486 !! end
10487
10488 !! test
10489 Magic Word: {{CURRENTTIME}}
10490 !! wikitext
10491 {{CURRENTTIME}}
10492 !! html
10493 <p>00:02
10494 </p>
10495 !! end
10496
10497 !! test
10498 Magic Word: {{CURRENTHOUR}}
10499 !! wikitext
10500 {{CURRENTHOUR}}
10501 !! html
10502 <p>00
10503 </p>
10504 !! end
10505
10506 !! test
10507 Magic Word: {{CURRENTWEEK}} (T6594)
10508 !! wikitext
10509 {{CURRENTWEEK}}
10510 !! html
10511 <p>1
10512 </p>
10513 !! end
10514
10515 !! test
10516 Magic Word: {{CURRENTYEAR}}
10517 !! wikitext
10518 {{CURRENTYEAR}}
10519 !! html
10520 <p>1970
10521 </p>
10522 !! end
10523
10524 !! test
10525 Magic Word: {{CURRENTTIMESTAMP}}
10526 !! wikitext
10527 {{CURRENTTIMESTAMP}}
10528 !! html
10529 <p>19700101000203
10530 </p>
10531 !! end
10532
10533 !! test
10534 Magic Words LOCAL (UTC)
10535 !! wikitext
10536 *{{LOCALMONTH}}
10537 *{{LOCALMONTH1}}
10538 *{{LOCALMONTHNAME}}
10539 *{{LOCALMONTHNAMEGEN}}
10540 *{{LOCALMONTHABBREV}}
10541 *{{LOCALDAY}}
10542 *{{LOCALDAY2}}
10543 *{{LOCALDAYNAME}}
10544 *{{LOCALYEAR}}
10545 *{{LOCALTIME}}
10546 *{{LOCALHOUR}}
10547 *{{LOCALWEEK}}
10548 *{{LOCALDOW}}
10549 *{{LOCALTIMESTAMP}}
10550 !! html
10551 <ul><li>01</li>
10552 <li>1</li>
10553 <li>January</li>
10554 <li>January</li>
10555 <li>Jan</li>
10556 <li>1</li>
10557 <li>01</li>
10558 <li>Thursday</li>
10559 <li>1970</li>
10560 <li>00:02</li>
10561 <li>00</li>
10562 <li>1</li>
10563 <li>4</li>
10564 <li>19700101000203</li></ul>
10565 !! end
10566
10567 !! test
10568 Magic Word: {{FULLPAGENAME}}
10569 !! options
10570 title=[[User:Ævar Arnfjörð Bjarmason]]
10571 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10572 !! wikitext
10573 {{FULLPAGENAME}}
10574 !! html/*
10575 <p>User:Ævar Arnfjörð Bjarmason
10576 </p>
10577 !! end
10578
10579 !! test
10580 Magic Word: {{FULLPAGENAMEE}}
10581 !! options
10582 title=[[User:Ævar Arnfjörð Bjarmason]]
10583 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10584 !! wikitext
10585 {{FULLPAGENAMEE}}
10586 !! html/*
10587 <p>User:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10588 </p>
10589 !! end
10590
10591 !! test
10592 Magic Word: {{TALKSPACE}}
10593 !! options
10594 title=[[User:Ævar Arnfjörð Bjarmason]]
10595 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10596 !! wikitext
10597 {{TALKSPACE}}
10598 !! html/*
10599 <p>User talk
10600 </p>
10601 !! end
10602
10603 !! test
10604 Magic Word: {{TALKSPACE}}, same namespace
10605 !! options
10606 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10607 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10608 !! wikitext
10609 {{TALKSPACE}}
10610 !! html/*
10611 <p>User talk
10612 </p>
10613 !! end
10614
10615 !! test
10616 Magic Word: {{TALKSPACE}}, main namespace
10617 !! options
10618 title=[[Parser Test]]
10619 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10620 !! wikitext
10621 {{TALKSPACE}}
10622 !! html/*
10623 <p>Talk
10624 </p>
10625 !! end
10626
10627 !! test
10628 Magic Word: {{TALKSPACEE}}
10629 !! options
10630 title=[[User:Ævar Arnfjörð Bjarmason]]
10631 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10632 !! wikitext
10633 {{TALKSPACEE}}
10634 !! html/*
10635 <p>User_talk
10636 </p>
10637 !! end
10638
10639 !! test
10640 Magic Word: {{SUBJECTSPACE}}
10641 !! options
10642 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10643 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10644 !! wikitext
10645 {{SUBJECTSPACE}}
10646 !! html/*
10647 <p>User
10648 </p>
10649 !! end
10650
10651 !! test
10652 Magic Word: {{SUBJECTSPACE}}, same namespace
10653 !! options
10654 title=[[User:Ævar Arnfjörð Bjarmason]]
10655 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10656 !! wikitext
10657 {{SUBJECTSPACE}}
10658 !! html/*
10659 <p>User
10660 </p>
10661 !! end
10662
10663 !! test
10664 Magic Word: {{SUBJECTSPACE}}, main namespace
10665 !! options
10666 title=[[Parser Test]]
10667 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10668 !! wikitext
10669 {{SUBJECTSPACE}}
10670 !! html/*
10671
10672 !! end
10673
10674 !! test
10675 Magic Word: {{SUBJECTSPACEE}}
10676 !! options
10677 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10678 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10679 !! wikitext
10680 {{SUBJECTSPACEE}}
10681 !! html/*
10682 <p>User
10683 </p>
10684 !! end
10685
10686 !! test
10687 Magic Word: {{NAMESPACE}}
10688 !! options
10689 title=[[User:Ævar Arnfjörð Bjarmason]]
10690 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10691 !! wikitext
10692 {{NAMESPACE}}
10693 !! html/*
10694 <p>User
10695 </p>
10696 !! end
10697
10698 !! test
10699 Magic Word: {{NAMESPACEE}}
10700 !! options
10701 title=[[User:Ævar Arnfjörð Bjarmason]]
10702 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10703 !! wikitext
10704 {{NAMESPACEE}}
10705 !! html/*
10706 <p>User
10707 </p>
10708 !! end
10709
10710 !! test
10711 Magic Word: {{NAMESPACENUMBER}}
10712 !! options
10713 title=[[User:Ævar Arnfjörð Bjarmason]]
10714 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10715 !! wikitext
10716 {{NAMESPACENUMBER}}
10717 !! html/*
10718 <p>2
10719 </p>
10720 !! end
10721
10722 !! test
10723 Magic Word: {{SUBPAGENAME}}
10724 !! options
10725 title=[[Ævar Arnfjörð Bjarmason/sub ö]] subpage
10726 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10727 !! wikitext
10728 {{SUBPAGENAME}}
10729 !! html/*
10730 <p>sub ö
10731 </p>
10732 !! end
10733
10734 !! test
10735 Magic Word: {{SUBPAGENAMEE}}
10736 !! options
10737 title=[[Ævar Arnfjörð Bjarmason/sub ö]] subpage
10738 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10739 !! wikitext
10740 {{SUBPAGENAMEE}}
10741 !! html/*
10742 <p>sub_%C3%B6
10743 </p>
10744 !! end
10745
10746 !! test
10747 Magic Word: {{ROOTPAGENAME}}
10748 !! options
10749 title=[[Ævar Arnfjörð Bjarmason/sub/sub2]] subpage
10750 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10751 !! wikitext
10752 {{ROOTPAGENAME}}
10753 !! html/*
10754 <p>Ævar Arnfjörð Bjarmason
10755 </p>
10756 !! end
10757
10758 !! test
10759 Magic Word: {{ROOTPAGENAMEE}}
10760 !! options
10761 title=[[Ævar Arnfjörð Bjarmason/sub/sub2]] subpage
10762 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10763 !! wikitext
10764 {{ROOTPAGENAMEE}}
10765 !! html/*
10766 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10767 </p>
10768 !! end
10769
10770 !! test
10771 Magic Word: {{BASEPAGENAME}}
10772 !! options
10773 title=[[Ævar Arnfjörð Bjarmason/sub]] subpage
10774 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10775 !! wikitext
10776 {{BASEPAGENAME}}
10777 !! html/*
10778 <p>Ævar Arnfjörð Bjarmason
10779 </p>
10780 !! end
10781
10782 !! test
10783 Magic Word: {{BASEPAGENAMEE}}
10784 !! options
10785 title=[[Ævar Arnfjörð Bjarmason/sub]] subpage
10786 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10787 !! wikitext
10788 {{BASEPAGENAMEE}}
10789 !! html/*
10790 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10791 </p>
10792 !! end
10793
10794 !! test
10795 Magic Word: {{TALKPAGENAME}}
10796 !! options
10797 title=[[User:Ævar Arnfjörð Bjarmason]]
10798 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10799 !! wikitext
10800 {{TALKPAGENAME}}
10801 !! html/*
10802 <p>User talk:Ævar Arnfjörð Bjarmason
10803 </p>
10804 !! end
10805
10806 !! test
10807 Magic Word: {{TALKPAGENAMEE}}
10808 !! options
10809 title=[[User:Ævar Arnfjörð Bjarmason]]
10810 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10811 !! wikitext
10812 {{TALKPAGENAMEE}}
10813 !! html/*
10814 <p>User_talk:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10815 </p>
10816 !! end
10817
10818 !! test
10819 Magic Word: {{SUBJECTPAGENAME}}
10820 !! options
10821 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10822 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10823 !! wikitext
10824 {{SUBJECTPAGENAME}}
10825 !! html/*
10826 <p>User:Ævar Arnfjörð Bjarmason
10827 </p>
10828 !! end
10829
10830 !! test
10831 Magic Word: {{SUBJECTPAGENAMEE}}
10832 !! options
10833 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10834 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10835 !! wikitext
10836 {{SUBJECTPAGENAMEE}}
10837 !! html/*
10838 <p>User:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10839 </p>
10840 !! end
10841
10842 !! test
10843 Magic Word: {{NUMBEROFFILES}}
10844 !! options
10845 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10846 !! wikitext
10847 {{NUMBEROFFILES}}
10848 !! html/*
10849 <p>7
10850 </p>
10851 !! end
10852
10853 !! test
10854 Magic Word: {{PAGENAME}}
10855 !! options
10856 title=[[User:Ævar Arnfjörð Bjarmason]]
10857 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10858 !! wikitext
10859 {{PAGENAME}}
10860 !! html/*
10861 <p>Ævar Arnfjörð Bjarmason
10862 </p>
10863 !! end
10864
10865 !! test
10866 Magic Word: {{PAGENAME}} with metacharacters
10867 !! options
10868 title=[['foo & bar = baz']]
10869 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10870 !! wikitext
10871 ''{{PAGENAME}}''
10872 !! html+tidy
10873 <p><i>&#39;foo &#38; bar &#61; baz&#39;</i>
10874 </p>
10875 !! end
10876
10877 !! test
10878 Magic Word: {{PAGENAME}} with metacharacters (T28781)
10879 !! options
10880 title=[[*RFC 1234 http://example.com/]]
10881 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10882 !! wikitext
10883 {{PAGENAME}}
10884 !! html+tidy
10885 <p>&#42;RFC&#32;1234 http&#58;//example.com/
10886 </p>
10887 !! end
10888
10889 !! test
10890 Magic Word: {{PAGENAMEE}}
10891 !! options
10892 title=[[User:Ævar Arnfjörð Bjarmason]]
10893 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10894 !! wikitext
10895 {{PAGENAMEE}}
10896 !! html/*
10897 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10898 </p>
10899 !! end
10900
10901 !! test
10902 Magic Word: {{PAGENAMEE}} with metacharacters (T28781)
10903 !! options
10904 title=[[*RFC 1234 http://example.com/]]
10905 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10906 !! wikitext
10907 {{PAGENAMEE}}
10908 !! html+tidy
10909 <p>&#42;RFC_1234_http&#58;//example.com/
10910 </p>
10911 !! end
10912
10913 !! test
10914 Magic Word: {{REVISIONID}}
10915 !! options
10916 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10917 showflags
10918 !! wikitext
10919 {{REVISIONID}}
10920 !! html/*
10921 <p>1337
10922 </p>
10923 flags=vary-revision-id
10924 !! end
10925
10926 !! test
10927 Magic Word: {{SCRIPTPATH}}
10928 !! options
10929 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10930 !! wikitext
10931 {{SCRIPTPATH}}
10932 !! html/*
10933
10934 !! end
10935
10936 !! test
10937 Magic Word: {{STYLEPATH}}
10938 !! options
10939 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10940 !! wikitext
10941 {{STYLEPATH}}
10942 !! html/*
10943 <p>/skins
10944 </p>
10945 !! end
10946
10947 !! test
10948 Magic Word: {{SERVER}}
10949 !! options
10950 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10951 !! wikitext
10952 {{SERVER}}
10953 !! html/*
10954 <p><a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>
10955 </p>
10956 !! end
10957
10958 !! test
10959 Magic Word: {{SERVERNAME}}
10960 !! options
10961 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10962 !! wikitext
10963 {{SERVERNAME}}
10964 !! html/*
10965 <p>example.org
10966 </p>
10967 !! end
10968
10969 !! test
10970 Magic Word: {{SITENAME}}
10971 !! options
10972 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10973 !! wikitext
10974 {{SITENAME}}
10975 !! html/*
10976 <p>MediaWiki
10977 </p>
10978 !! end
10979
10980 !! test
10981 Magic Word: {{PAGELANGUAGE}}
10982 !! options
10983 language=fr
10984 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10985 !! wikitext
10986 {{PAGELANGUAGE}}
10987 !! html/*
10988 <p>fr
10989 </p>
10990 !! end
10991
10992 !! test
10993 Magic Word: {{PAGELANGUAGE}} on a page with no explicitly set language
10994 !! options
10995 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10996 !! wikitext
10997 {{PAGELANGUAGE}}
10998 !! html/*
10999 <p>en
11000 </p>
11001 !! end
11002
11003 !! test
11004 Case-sensitive magic words, when cased differently, should just be template transclusions
11005 !! wikitext
11006 {{CurrentMonth}}
11007 {{currentday}}
11008 {{cURreNTweEK}}
11009 {{currentHour}}
11010 !! html
11011 <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>
11012 <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>
11013 <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>
11014 <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>
11015 </p>
11016 !! end
11017
11018 !! test
11019 Case-insensitive magic words should still work with weird casing.
11020 !! wikitext
11021 {{sErVeRNaMe}}
11022 {{LCFirst:AOEU}}
11023 {{ucFIRST:aoeu}}
11024 {{SERver}}
11025 !! html
11026 <p>example.org
11027 aOEU
11028 Aoeu
11029 <a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>
11030 </p>
11031 !! end
11032
11033 # From plwiki:PLOS_ONE
11034 !! test
11035 Parsoid: Page property magic word with magic word contents
11036 !! options
11037 showtitle
11038 !! config
11039 wgAllowDisplayTitle=true
11040 wgRestrictDisplayTitle=false
11041 !! wikitext
11042 {{DISPLAYTITLE:''{{PAGENAME}}''}}
11043 !! html/php+tidy
11044 <i>Parser test</i>
11045
11046 !! html/parsoid
11047 <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>"}]]}'/>
11048 !! end
11049
11050 # NOTE: mw:ExpandedAttrs is not the best typeof here. mw:Transclusion is better.
11051 # But, this is a limitation of our representation and is documented in
11052 # TemplateHandler.js in processSpecialMagicWord
11053 !! test
11054 Parsoid: Template-generated DISPLAYTITLE
11055 !! wikitext
11056 {{{{echo|DISPLAYTITLE}}:Foo}}
11057 !! options
11058 showtitle
11059 !! config
11060 wgAllowDisplayTitle=true
11061 wgRestrictDisplayTitle=false
11062 !! html/php
11063 Foo
11064
11065 !! html/parsoid
11066 <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"}]]}'/>
11067 !! end
11068
11069 !! test
11070 Namespace 1 {{ns:1}}
11071 !! wikitext
11072 {{ns:1}}
11073 !! html
11074 <p>Talk
11075 </p>
11076 !! end
11077
11078 !! test
11079 Namespace 1 {{ns:01}}
11080 !! wikitext
11081 {{ns:01}}
11082 !! html
11083 <p>Talk
11084 </p>
11085 !! end
11086
11087 !! test
11088 Namespace 0 {{ns:0}} (T6783)
11089 !! wikitext
11090 {{ns:0}}
11091 !! html
11092
11093 !! end
11094
11095 !! test
11096 Namespace 0 {{ns:00}} (T6783)
11097 !! wikitext
11098 {{ns:00}}
11099 !! html
11100
11101 !! end
11102
11103 !! test
11104 Namespace -1 {{ns:-1}}
11105 !! wikitext
11106 {{ns:-1}}
11107 !! html
11108 <p>Special
11109 </p>
11110 !! end
11111
11112 !! test
11113 Namespace User {{ns:User}}
11114 !! wikitext
11115 {{ns:User}}
11116 !! html
11117 <p>User
11118 </p>
11119 !! end
11120
11121 !! test
11122 Namespace User talk {{ns:User_talk}}
11123 !! wikitext
11124 {{ns:User_talk}}
11125 !! html
11126 <p>User talk
11127 </p>
11128 !! end
11129
11130 !! test
11131 Namespace User talk {{ns:uSeR tAlK}}
11132 !! wikitext
11133 {{ns:uSeR tAlK}}
11134 !! html
11135 <p>User talk
11136 </p>
11137 !! end
11138
11139 !! test
11140 Namespace File {{ns:File}}
11141 !! wikitext
11142 {{ns:File}}
11143 !! html
11144 <p>File
11145 </p>
11146 !! end
11147
11148 !! test
11149 Namespace File {{ns:Image}}
11150 !! wikitext
11151 {{ns:Image}}
11152 !! html
11153 <p>File
11154 </p>
11155 !! end
11156
11157 !! test
11158 Namespace (lang=de) Benutzer {{ns:User}}
11159 !! options
11160 language=de
11161 !! wikitext
11162 {{ns:User}}
11163 !! html
11164 <p>Benutzer
11165 </p>
11166 !! end
11167
11168 !! test
11169 Namespace (lang=de) Benutzer Diskussion {{ns:3}}
11170 !! options
11171 language=de
11172 !! wikitext
11173 {{ns:3}}
11174 !! html
11175 <p>Benutzer Diskussion
11176 </p>
11177 !! end
11178
11179 !! test
11180 Urlencode
11181 !! wikitext
11182 {{urlencode:hi world?!}}
11183 {{urlencode:hi world?!|WIKI}}
11184 {{urlencode:hi world?!|PATH}}
11185 {{urlencode:hi world?!|QUERY}}
11186 !! html/php
11187 <p>hi+world%3F%21
11188 hi_world%3F!
11189 hi%20world%3F%21
11190 hi+world%3F%21
11191 </p>
11192 !! end
11193
11194 !! test
11195 Magic Word: prioritize type info over data-parsoid
11196 !! options
11197 parsoid=html2wt
11198 !! html/parsoid
11199 <meta property="mw:PageProp/forcetoc" data-parsoid='{"magicSrc":"__NOTOC__"}'/>
11200 !! wikitext
11201 __FORCETOC__
11202 !! end
11203
11204 !! test
11205 Magic Word: serialize on separate line (parsoid)
11206 !! options
11207 parsoid=wt2wt,html2wt
11208 !! wikitext
11209 foo
11210 __NOTOC__
11211 bar
11212 !! html/parsoid
11213 foo<meta property="mw:PageProp/notoc"/>bar
11214 !! end
11215
11216 !! test
11217 Magic Word: rt non-english wikis
11218 !! options
11219 parsoid=wt2wt
11220 language=de
11221 !! wikitext
11222 __NOEDITSECTION__
11223 !! html/parsoid
11224 <meta property="mw:PageProp/noeditsection" data-parsoid='{"magicSrc":"__NOEDITSECTION__"}'/>
11225 !! end
11226
11227 !!test
11228 __proto__ is treated as normal wikitext (T105997)
11229 !!wikitext
11230 __proto__
11231 !!html
11232 <p>__proto__
11233 </p>
11234 !!end
11235
11236 ###
11237 ### Magic links
11238 ###
11239 !! test
11240 Magic links: internal link to RFC (T2479)
11241 !! wikitext
11242 [[RFC 123]]
11243 !! html/php
11244 <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>
11245 </p>
11246 !! html/parsoid
11247 <p><a rel="mw:WikiLink" href="./RFC_123" title="RFC 123">RFC 123</a></p>
11248 !! end
11249
11250 !! test
11251 Magic links: RFC (T2479)
11252 !! wikitext
11253 RFC 822
11254 !! html/php
11255 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc822">RFC 822</a>
11256 </p>
11257 !! html/parsoid
11258 <p><a href="https://tools.ietf.org/html/rfc822" rel="mw:ExtLink" class="external mw-magiclink">RFC 822</a></p>
11259 !! end
11260
11261 !! test
11262 Magic links: RFC (T67278)
11263 !! wikitext
11264 This is RFC 822 but thisRFC 822 is not RFC 822linked.
11265 !! html/php
11266 <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.
11267 </p>
11268 !! html/parsoid
11269 <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>
11270 !! end
11271
11272 !! test
11273 Magic links: RFC (w/ non-newline whitespace, T30950/T31025)
11274 !! wikitext
11275 RFC &nbsp;&#160;&#0160;&#xA0;&#Xa0; 822
11276 RFC
11277 822
11278 !! html/php
11279 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc822">RFC 822</a>
11280 RFC
11281 822
11282 </p>
11283 !! html/parsoid
11284 <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>
11285 RFC
11286 822</p>
11287 !! end
11288
11289 !! test
11290 Magic links: ISBN (T3937)
11291 !! wikitext
11292 ISBN 0-306-40615-2
11293 !! html/php
11294 <p><a href="/wiki/Special:BookSources/0306406152" class="internal mw-magiclink-isbn">ISBN 0-306-40615-2</a>
11295 </p>
11296 !! html/parsoid
11297 <p><a href="./Special:BookSources/0306406152" rel="mw:WikiLink">ISBN 0-306-40615-2</a></p>
11298 !! end
11299
11300 !! test
11301 Magic links: ISBN (T67278)
11302 !! wikitext
11303 This is ISBN 978-0-316-09811-3 but thisISBN 978-0-316-09811-3 is not ISBN 978-0-316-09811-3linked.
11304 !! html/php
11305 <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.
11306 </p>
11307 !! html/parsoid
11308 <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>
11309 !! end
11310
11311 !! test
11312 Magic links: ISBN (w/ non-newline whitespace, T30950/T31025)
11313 !! wikitext
11314 ISBN &nbsp;&#160;&#0160;&#xA0;&#Xa0; 978&nbsp;0&#160;316&#0160;09811&#xA0;3
11315 ISBN
11316 9780316098113
11317 ISBN 978
11318 0316098113
11319 !! html/php
11320 <p><a href="/wiki/Special:BookSources/9780316098113" class="internal mw-magiclink-isbn">ISBN 978 0 316 09811 3</a>
11321 ISBN
11322 9780316098113
11323 ISBN 978
11324 0316098113
11325 </p>
11326 !! html/parsoid
11327 <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>
11328 ISBN
11329 9780316098113
11330 ISBN 978
11331 0316098113</p>
11332 !! end
11333
11334 !! test
11335 Magic links: PMID incorrectly converts space to underscore
11336 !! wikitext
11337 PMID 1234
11338 !! html/php
11339 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a>
11340 </p>
11341 !! html/parsoid
11342 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract" rel="mw:ExtLink" class="external mw-magiclink">PMID 1234</a></p>
11343 !! end
11344
11345 !! test
11346 Magic links: PMID (T67278)
11347 !! wikitext
11348 This is PMID 1234 but thisPMID 1234 is not PMID 1234linked.
11349 !! html/php
11350 <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.
11351 </p>
11352 !! html/parsoid
11353 <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>
11354 !! end
11355
11356 !! test
11357 Magic links: PMID (w/ non-newline whitespace, T30950/T31025)
11358 !! wikitext
11359 PMID &nbsp;&#160;&#0160;&#xA0;&#Xa0; 1234
11360 PMID
11361 1234
11362 !! html/php
11363 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a>
11364 PMID
11365 1234
11366 </p>
11367 !! html/parsoid
11368 <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>
11369 PMID
11370 1234</p>
11371 !! end
11372
11373 # <nowiki> nodes shouldn't be inserted during html2wt by Parsoid,
11374 # since these are ExtLinkText, not MagicLinkText
11375 !! test
11376 Magic links: use appropriate serialization for "almost" magic links.
11377 !! wikitext
11378 X[[Special:BookSources/0978739256|foo]]
11379
11380 X[https://tools.ietf.org/html/rfc1234 foo]
11381 !! html/php
11382 <p>X<a href="/wiki/Special:BookSources/0978739256" title="Special:BookSources/0978739256">foo</a>
11383 </p><p>X<a rel="nofollow" class="external text" href="https://tools.ietf.org/html/rfc1234">foo</a>
11384 </p>
11385 !! html/parsoid
11386 <p>X<a rel="mw:WikiLink" href="./Special:BookSources/0978739256" title="Special:BookSources/0978739256">foo</a></p>
11387 <p>X<a rel="mw:ExtLink" class="external text" href="https://tools.ietf.org/html/rfc1234">foo</a></p>
11388 !! end
11389
11390 !! test
11391 Magic links: All disabled (T47942)
11392 !! options
11393 wgEnableMagicLinks={"ISBN":false, "PMID":false, "RFC":false}
11394 !! wikitext
11395 ISBN 0-306-40615-2
11396 PMID 1234
11397 RFC 4321
11398 !! html/php
11399 <p>ISBN 0-306-40615-2
11400 PMID 1234
11401 RFC 4321
11402 </p>
11403 !! end
11404
11405 ###
11406 ### Templates
11407 ####
11408
11409 !! test
11410 Nonexistent template
11411 !! wikitext
11412 {{thistemplatedoesnotexist}}
11413 !! html
11414 <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>
11415 </p>
11416 !! end
11417
11418 !! test
11419 Template with invalid target containing tags
11420 !! wikitext
11421 {{a<b>b</b>|{{echo|foo}}|{{echo|a}}={{echo|b}}|a = b}}
11422 !! html
11423 <p>{{a<b>b</b>|foo|a=b|a = b}}
11424 </p>
11425 !! end
11426
11427 !! test
11428 Template with invalid target containing unclosed tag
11429 !! wikitext
11430 {{a<b>|{{echo|foo}}|{{echo|a}}={{echo|b}}|a = b}}
11431 !! html
11432 <p>{{a<b>|foo|a=b|a = b}}</b>
11433 </p>
11434 !! end
11435
11436 !! test
11437 Template with invalid target containing wikilink
11438 !! wikitext
11439 {{[[Main Page]]}}
11440 !! html/php
11441 <p>{{<a href="/wiki/Main_Page" title="Main Page">Main Page</a>}}
11442 </p>
11443 !! html/parsoid
11444 <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>
11445 !! end
11446
11447 !! test
11448 Template with just whitespace in it, T70421
11449 !! wikitext
11450 {{echo|{{ }}}}
11451 !! html/parsoid
11452 <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>
11453 !! end
11454
11455 !! article
11456 Template:test
11457 !! text
11458 This is a test template
11459 !! endarticle
11460
11461 !! test
11462 Simple template
11463 !! wikitext
11464 {{test}}
11465 !! html
11466 <p>This is a test template
11467 </p>
11468 !! end
11469
11470 !! test
11471 Template with explicit namespace
11472 !! wikitext
11473 {{Template:test}}
11474 !! html
11475 <p>This is a test template
11476 </p>
11477 !! end
11478
11479
11480 !! article
11481 Template:paramtest
11482 !! text
11483 This is a test template with parameter {{{param}}}
11484 !! endarticle
11485
11486 !! test
11487 Template parameter
11488 !! wikitext
11489 {{paramtest|param=foo}}
11490 !! html
11491 <p>This is a test template with parameter foo
11492 </p>
11493 !! end
11494
11495 !! article
11496 Template:paramtestnum
11497 !! text
11498 [[{{{1}}}|{{{2}}}]]
11499 !! endarticle
11500
11501 !! test
11502 Template unnamed parameter
11503 !! wikitext
11504 {{paramtestnum|Main Page|the main page}}
11505 !! html
11506 <p><a href="/wiki/Main_Page" title="Main Page">the main page</a>
11507 </p>
11508 !! end
11509
11510 !! article
11511 Template:templatesimple
11512 !! text
11513 (test)
11514 !! endarticle
11515
11516 !! article
11517 Template:templateredirect
11518 !! text
11519 #redirect [[Template:templatesimple]]
11520 !! endarticle
11521
11522 !! article
11523 Template:templateasargtestnum
11524 !! text
11525 {{{{{1}}}}}
11526 !! endarticle
11527
11528 !! article
11529 Template:templateasargtest
11530 !! text
11531 {{template{{{templ}}}}}
11532 !! endarticle
11533
11534 !! article
11535 Template:templateasargtest2
11536 !! text
11537 {{{{{templ}}}}}
11538 !! endarticle
11539
11540 !! test
11541 Template with template name as unnamed argument
11542 !! wikitext
11543 {{templateasargtestnum|templatesimple}}
11544 !! html
11545 <p>(test)
11546 </p>
11547 !! end
11548
11549 !! test
11550 Template with template name as argument
11551 !! wikitext
11552 {{templateasargtest|templ=simple}}
11553 !! html
11554 <p>(test)
11555 </p>
11556 !! end
11557
11558 !! test
11559 Template with template name as argument (2)
11560 !! wikitext
11561 {{templateasargtest2|templ=templatesimple}}
11562 !! html
11563 <p>(test)
11564 </p>
11565 !! end
11566
11567 !! article
11568 Template:templateasargtestdefault
11569 !! text
11570 {{{{{templ|templatesimple}}}}}
11571 !! endarticle
11572
11573 !! article
11574 Template:templa
11575 !! text
11576 '''templ'''
11577 !! endarticle
11578
11579 !! test
11580 Template with default value
11581 !! wikitext
11582 {{templateasargtestdefault}}
11583 !! html
11584 <p>(test)
11585 </p>
11586 !! end
11587
11588 !! test
11589 Template with default value (value set)
11590 !! wikitext
11591 {{templateasargtestdefault|templ=templa}}
11592 !! html
11593 <p><b>templ</b>
11594 </p>
11595 !! end
11596
11597 !! test
11598 Template redirect
11599 !! wikitext
11600 {{templateredirect}}
11601 !! html/php
11602 <p>(test)
11603 </p>
11604 !! html/parsoid
11605 <link rel="mw:PageProp/redirect" href="./Template:Templatesimple" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"templateredirect","href":"./Template:Templateredirect"},"params":{},"i":0}}]}'/>
11606 !! end
11607
11608 !! test
11609 Template with argument in separate line
11610 !! wikitext
11611 {{ templateasargtest |
11612 templ = simple }}
11613 !! html
11614 <p>(test)
11615 </p>
11616 !! end
11617
11618 !! test
11619 Template with complex template as argument
11620 !! wikitext
11621 {{paramtest|
11622 param ={{ templateasargtest |
11623 templ = simple }}}}
11624 !! html
11625 <p>This is a test template with parameter (test)
11626 </p>
11627 !! end
11628
11629 !! test
11630 Templates with templated name
11631 !! wikitext
11632 {{{{echo|echo}}|foo}}
11633 {{{{echo|inner list}} }}
11634 !! html
11635 <p>foo
11636 </p>
11637 <ul><li>item 1</li></ul>
11638 !! html/parsoid
11639 <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>
11640 <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>
11641 !! end
11642
11643 ## Regression test; the output here isn't really that interesting.
11644 !! test
11645 Templates with templated name and top level template args
11646 !! wikitext
11647 {{1{{2{{{3}}}|4=5}}}}
11648 !! html/parsoid
11649 <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>
11650 !! end
11651
11652 # Parsoid markup is deliberate "broken". This is an edge case.
11653 # See long comment in TemplateHandler.js:convertAttribsToString.
11654 !! test
11655 Templates with invalid templated targets
11656 !! wikitext
11657 {{echo
11658 {{echo|foo}}
11659 }}
11660 !! html/php
11661 <p>{{echo
11662 foo
11663 }}
11664 </p>
11665 !! html/parsoid
11666 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo\n{{echo|foo}}\n"},"params":{},"i":0}}]}'>{{echo
11667 foo }}</p>
11668 !! end
11669
11670 !! test
11671 Template with thumb image (with link in description)
11672 !! wikitext
11673 {{paramtest|param=[[Image:noimage.png|thumb|[[no link|link]] [[no link|caption]]]]}}
11674 !! html/php
11675 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>
11676
11677 !! html+tidy
11678 <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>
11679 !! html/parsoid
11680 <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>
11681 !! end
11682
11683 !! article
11684 Template:complextemplate
11685 !! text
11686 {{{1}}} {{paramtest|
11687 param ={{{param}}}}}
11688 !! endarticle
11689
11690 !! test
11691 Template with complex arguments
11692 !! wikitext
11693 {{complextemplate|
11694 param ={{ templateasargtest |
11695 templ = simple }}|[[Template:complextemplate|link]]}}
11696 !! html
11697 <p><a href="/wiki/Template:Complextemplate" title="Template:Complextemplate">link</a> This is a test template with parameter (test)
11698 </p>
11699 !! end
11700
11701 !! test
11702 T2553: link with two variables in a piped link
11703 !! wikitext
11704 {|
11705 |[[{{{1}}}|{{{2}}}]]
11706 |}
11707 !! html/php
11708 <table>
11709 <tr>
11710 <td>[[{{{1}}}|{{{2}}}]]
11711 </td></tr></table>
11712
11713 !! html/parsoid
11714 <table>
11715 <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>
11716 </tbody></table>
11717 !! end
11718
11719 # See: T2553
11720 !! test
11721 Abort table cell attribute parsing on wikilink
11722 !! wikitext
11723 {|
11724 |testing [[one|two]] |three||four
11725 |testing one two |three||four
11726 |testing="[[one|two]]" |three||four
11727 |}
11728 !! html/php
11729 <table>
11730 <tr>
11731 <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>
11732 <td>four
11733 </td>
11734 <td>three</td>
11735 <td>four
11736 </td>
11737 <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>
11738 <td>four
11739 </td></tr></table>
11740
11741 !! html/parsoid
11742 <table>
11743 <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>
11744 <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>
11745 <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>
11746 </tbody></table>
11747 !! end
11748
11749 !! test
11750 Don't abort table cell attribute parsing if wikilink is found in template arg
11751 !! wikitext
11752 {|
11753 |Test {{#tag:ref|One two "[[three]]" four}}
11754 |}
11755 !! html/parsoid
11756 <table>
11757 <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>
11758 </tbody></table>
11759 !! end
11760
11761 !! test
11762 Magic variable as template parameter
11763 !! wikitext
11764 {{paramtest|param={{SITENAME}}}}
11765 !! html
11766 <p>This is a test template with parameter MediaWiki
11767 </p>
11768 !! end
11769
11770 !! article
11771 Template:linktest
11772 !! text
11773 [[{{{param}}}|link]]
11774 !! endarticle
11775
11776 !! test
11777 Template parameter as link source
11778 !! wikitext
11779 {{linktest|param=Main Page}}
11780 !! html
11781 <p><a href="/wiki/Main_Page" title="Main Page">link</a>
11782 </p>
11783 !! end
11784
11785 !!article
11786 Template:paramtest2
11787 !! text
11788 including another template, {{paramtest|param={{{arg}}}}}
11789 !! endarticle
11790
11791 !! test
11792 Template passing argument to another template
11793 !! wikitext
11794 {{paramtest2|arg='hmm'}}
11795 !! html
11796 <p>including another template, This is a test template with parameter 'hmm'
11797 </p>
11798 !! end
11799
11800 !! article
11801 Template:Linktest2
11802 !! text
11803 Main Page
11804 !! endarticle
11805
11806 !! test
11807 Template as link source
11808 !! wikitext
11809 [[{{linktest2}}]]
11810
11811 [[{{linktest2}}|Main Page]]
11812
11813 [[{{linktest2}}]]Page
11814 !! html
11815 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
11816 </p><p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
11817 </p><p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>Page
11818 </p>
11819 !! end
11820
11821
11822 !! article
11823 Template:loop1
11824 !! text
11825 {{loop2}}
11826 !! endarticle
11827
11828 !! article
11829 Template:loop2
11830 !! text
11831 {{loop1}}
11832 !! endarticle
11833
11834 !! test
11835 Template infinite loop
11836 !! wikitext
11837 {{loop1}}
11838 !! html
11839 <p><span class="error">Template loop detected: <a href="/wiki/Template:Loop1" title="Template:Loop1">Template:Loop1</a></span>
11840 </p>
11841 !! end
11842
11843 !! test
11844 Template from main namespace
11845 !! wikitext
11846 {{:Main Page}}
11847 !! html
11848 <p>blah blah
11849 </p>
11850 !! end
11851
11852 !! test
11853 Template from non-includable namespace
11854 !! options
11855 wgNonincludableNamespaces=10
11856 !! wikitext
11857 {{echo|uh oh!}}
11858 !! html
11859 <p><a href="/wiki/Template:Echo" title="Template:Echo">Template:Echo</a>
11860 </p>
11861 !! end
11862
11863 !! article
11864 Template:table
11865 !! text
11866 {|
11867 | 1 || 2
11868 |-
11869 | 3 || 4
11870 |}
11871 !! endarticle
11872
11873 !! test
11874 T2529: Template with table, not included at beginning of line
11875 !! wikitext
11876 foo {{table}}
11877 !! html
11878 <p>foo
11879 </p>
11880 <table>
11881 <tr>
11882 <td>1</td>
11883 <td>2
11884 </td></tr>
11885 <tr>
11886 <td>3</td>
11887 <td>4
11888 </td></tr></table>
11889
11890 !! end
11891
11892 !! test
11893 T2523: Template shouldn't eat newline (or add an extra one before table)
11894 !! wikitext
11895 foo
11896 {{table}}
11897 !! html
11898 <p>foo
11899 </p>
11900 <table>
11901 <tr>
11902 <td>1</td>
11903 <td>2
11904 </td></tr>
11905 <tr>
11906 <td>3</td>
11907 <td>4
11908 </td></tr></table>
11909
11910 !! end
11911
11912 !! test
11913 T2041: Template parameters shown as broken links
11914 !! wikitext
11915 {{{parameter}}}
11916 !! html
11917 <p>{{{parameter}}}
11918 </p>
11919 !! end
11920
11921 !! test
11922 Template with targets containing wikilinks
11923 !! options
11924 parsoid=wt2html
11925 !! wikitext
11926 {{[[foo]]}}
11927
11928 {{[[{{echo|foo}}]]}}
11929
11930 {{{{echo|[[foo}}]]}}
11931 !! html/php
11932 <p>{{<a href="/wiki/Foo" title="Foo">foo</a>}}
11933 </p><p>{{<a href="/wiki/Foo" title="Foo">foo</a>}}
11934 </p><p>{{[[foo}}]]
11935 </p>
11936 !! html/parsoid
11937 <p>{{<a rel="mw:WikiLink" href="./Foo" title="Foo">foo</a>}}</p>
11938 <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>
11939 <p>{{<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[foo}}]]"}},"i":0}}]}'>[[foo}}]]</span></p>
11940 !! end
11941
11942 !! article
11943 Template:''
11944 !! text
11945 bar
11946 !! endarticle
11947
11948 !! test
11949 Templates: Double quotes as template target
11950 !! wikitext
11951 foo {{''}} baz
11952 !! html/php
11953 <p>foo bar baz
11954 </p>
11955 !! html/parsoid
11956 <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
11957 </p>
11958 !! end
11959
11960 ## This test is about making sure Parsoid's data-mw is well formed in the
11961 ## face of multiple templates with intersecting and overlapping ranges. The
11962 ## wikitext itself is wretched.
11963 !! test
11964 Templates with intersecting and overlapping ranges
11965 !! wikitext
11966 {|{{echo|
11967 <p>ha</p>}}
11968 {|{{echo|
11969 <p>ho</p>}}
11970 {{echo|{{!}}hi}}
11971 |}
11972 !! html/php+tidy
11973 <p>ha</p><table>
11974
11975 </table><p>ho</p><table>
11976
11977 <tbody><tr>
11978 <td>hi
11979 </td></tr></tbody></table>
11980 !! html/parsoid
11981 <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":""}]]}'>
11982
11983 </table><p about="#mwt1">ho</p><table about="#mwt1" typeof="mw:ExpandedAttrs" data-mw='{"attribs":[[{"txt":"","html":""},{"html":""}]]}'>
11984
11985 <tbody><tr><td>hi</td></tr>
11986 </tbody></table>
11987 !! end
11988
11989 !! article
11990 Template:MSGNW test
11991 !! text
11992 ''None'' of '''this''' should be
11993 * interpreted
11994 but rather passed unmodified
11995 {{test}}
11996 <gallery>
11997 File:Foobar.jpg
11998 </gallery>
11999 <!-- comment -->
12000 !! endarticle
12001
12002 # hmm, fix this or just deprecate msgnw and document its behavior?
12003 !! test
12004 msgnw keyword
12005 !! wikitext
12006 {{msgnw:MSGNW test}}
12007 !! html/php
12008 <p>&#39;&#39;None&#39;&#39; of &#39;&#39;&#39;this&#39;&#39;&#39; should be
12009 &#42; interpreted
12010 &#32;but rather passed unmodified
12011 &#123;&#123;test&#125;&#125;
12012 &#60;gallery&#62;
12013 File:Foobar.jpg
12014 &#60;/gallery&#62;
12015 &#60;!-- comment --&#62;
12016 </p>
12017 !! end
12018
12019 !! test
12020 int keyword
12021 !! wikitext
12022 {{int:youhavenewmessages|lots of money|not!}}
12023 !! html
12024 <p>You have lots of money (not!).
12025 </p>
12026 !! end
12027
12028 !! test
12029 int keyword - non-existing message
12030 !! wikitext
12031 {{int:var}}
12032 !! html
12033 <p>⧼var⧽
12034 </p>
12035 !! end
12036
12037 !! article
12038 Template:Includes
12039 !! text
12040 Foo<noinclude>zar</noinclude><includeonly>bar</includeonly>
12041 !! endarticle
12042
12043 !! test
12044 <includeonly> and <noinclude> being included
12045 !! wikitext
12046 {{Includes}}
12047 !! html
12048 <p>Foobar
12049 </p>
12050 !! end
12051
12052 !! article
12053 Template:Includes2
12054 !! text
12055 <onlyinclude>Foo</onlyinclude>bar
12056 !! endarticle
12057
12058 !! test
12059 <onlyinclude> being included
12060 !! wikitext
12061 {{Includes2}}
12062 !! html
12063 <p>Foo
12064 </p>
12065 !! end
12066
12067
12068 !! article
12069 Template:Includes3
12070 !! text
12071 <onlyinclude>Foo</onlyinclude>bar<includeonly>zar</includeonly>
12072 !! endarticle
12073
12074 !! test
12075 <onlyinclude> and <includeonly> being included
12076 !! wikitext
12077 {{Includes3}}
12078 !! html
12079 <p>Foo
12080 </p>
12081 !! end
12082
12083 !! test
12084 <includeonly> and <noinclude> on a page
12085 !! wikitext
12086 Foo<noinclude>zar</noinclude><includeonly>bar</includeonly>
12087 !! html
12088 <p>Foozar
12089 </p>
12090 !! end
12091
12092 !! test
12093 Un-closed <noinclude>
12094 !! wikitext
12095 <noinclude>
12096 !! html
12097 !! end
12098
12099 !! test
12100 <onlyinclude> on a page
12101 !! wikitext
12102 <onlyinclude>Foo</onlyinclude>bar
12103 !! html
12104 <p>Foobar
12105 </p>
12106 !! end
12107
12108 !! test
12109 Un-closed <onlyinclude>
12110 !! wikitext
12111 <onlyinclude>
12112 !! html
12113 !! end
12114
12115 !!test
12116 Self-closed noinclude, includeonly, onlyinclude tags
12117 !! wikitext
12118 <noinclude />
12119 <includeonly />
12120 <onlyinclude />
12121 !! html
12122 <p><br />
12123 </p>
12124 !!end
12125
12126 !!test
12127 Unbalanced includeonly and noinclude tags
12128 !! wikitext
12129 {|
12130 |a</noinclude>
12131 |b</noinclude></noinclude>
12132 |c</noinclude></includeonly>
12133 |d</includeonly></includeonly>
12134 |}
12135 !! html
12136 <table>
12137 <tr>
12138 <td>a
12139 </td>
12140 <td>b
12141 </td>
12142 <td>c&lt;/includeonly&gt;
12143 </td>
12144 <td>d&lt;/includeonly&gt;&lt;/includeonly&gt;
12145 </td></tr></table>
12146
12147 !!end
12148
12149 !! article
12150 Template:Includeonly section
12151 !! text
12152 <includeonly>
12153 ==Includeonly section==
12154 </includeonly>
12155 ==Section T-1==
12156 !!endarticle
12157
12158 !! test
12159 T8563: Edit link generation for section shown by <includeonly>
12160 !! wikitext
12161 {{includeonly section}}
12162 !! html
12163 <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>
12164 <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>
12165
12166 !! end
12167
12168 # Uses same input as the contents of [[Template:Includeonly section]]
12169 !! test
12170 T8563: Section extraction for section shown by <includeonly>
12171 !! options
12172 section=T-2
12173 !! wikitext
12174 <includeonly>
12175 ==Includeonly section==
12176 </includeonly>
12177 ==Section T-2==
12178 !! html
12179 ==Section T-2==
12180 !! end
12181
12182 !! test
12183 T8563: Edit link generation for section suppressed by <includeonly>
12184 !! wikitext
12185 <includeonly>
12186 ==Includeonly section==
12187 </includeonly>
12188 ==Section 1==
12189 !! html
12190 <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>
12191
12192 !! end
12193
12194 !! test
12195 T8563: Section extraction for section suppressed by <includeonly>
12196 !! options
12197 section=1
12198 !! wikitext
12199 <includeonly>
12200 ==Includeonly section==
12201 </includeonly>
12202 ==Section 1==
12203 !! html
12204 ==Section 1==
12205 !! end
12206
12207 !! test
12208 Un-closed <includeonly>
12209 !! wikitext
12210 <includeonly>
12211 !! html/php
12212 !! html/parsoid
12213 <meta typeof="mw:Includes/IncludeOnly" data-parsoid='{"src":"&lt;includeonly>"}' data-mw='{"src":"&lt;includeonly>"}'/>
12214 !! end
12215
12216 ## We used to, but no longer wt2wt this test since the default serializer
12217 ## will normalize the include directives to serialize on their own line.
12218 ## Selser will take care of preserving formatting in scenarios where they
12219 ## intermingled with other wikitext.
12220 !! test
12221 Includes and comments at SOL
12222 !! options
12223 parsoid=wt2html,html2html
12224 !! wikitext
12225 <!-- comment --><noinclude><!-- comment --></noinclude><!-- comment -->==hu==
12226
12227 <noinclude>
12228 some
12229 </noinclude>*stuff
12230 *here
12231
12232 <noinclude>
12233 some</noinclude>* stuff
12234 * here
12235
12236 <includeonly>can have stuff</includeonly>===here===
12237
12238 !! html/php
12239 <h2><span class="mw-headline" id="hu">hu</span></h2>
12240 <p>some
12241 </p>
12242 <ul><li>stuff</li>
12243 <li>here</li></ul>
12244 <p><br />
12245 some* stuff
12246 </p>
12247 <ul><li>here</li></ul>
12248 <h3><span class="mw-headline" id="here">here</span></h3>
12249
12250 !! html/parsoid
12251 <!-- 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>
12252
12253 <meta typeof="mw:Includes/NoInclude" data-parsoid='{"src":"&lt;noinclude>"}'/>
12254 <p>some</p>
12255 <meta typeof="mw:Includes/NoInclude/End" data-parsoid='{"src":"&lt;/noinclude>"}'/><ul><li>stuff</li>
12256 <li>here</li></ul>
12257
12258 <meta typeof="mw:Includes/NoInclude" data-parsoid='{"src":"&lt;noinclude>"}'/>
12259 <p>some<meta typeof="mw:Includes/NoInclude/End" data-parsoid='{"src":"&lt;/noinclude>"}'/>* stuff</p>
12260 <ul><li>here</li></ul>
12261
12262 <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>
12263
12264 !! end
12265
12266 # TODO: test with DOM fragment reuse!
12267 !! test
12268 Parsoid: DOM fragment reuse
12269 !! options
12270 parsoid=wt2wt,wt2html
12271 !! wikitext
12272 a{{echo|b<table></table>c}}d
12273
12274 a{{echo|b
12275 <table></table>
12276 c}}d
12277
12278 {{echo|a
12279
12280 <table></table>
12281
12282 b}}
12283 !! html/php+tidy
12284 <p>ab</p><table></table><p>cd
12285 </p><p>ab
12286 </p>
12287 <table></table>
12288 <p>cd
12289 </p><p>a
12290 </p>
12291 <table></table>
12292 <p>b
12293 </p>
12294 !! html/parsoid
12295 <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>
12296
12297 <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">
12298 </span><table about="#mwt2" data-parsoid='{"stx":"html"}'></table><span about="#mwt2">
12299 </span><p about="#mwt2">cd</p>
12300
12301 <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">
12302
12303 </span><table about="#mwt3" data-parsoid='{"stx":"html"}'></table><span about="#mwt3">
12304
12305 </span><p about="#mwt3">b</p>
12306 !! end
12307
12308 !! test
12309 Parsoid: Merge double tds (T52603)
12310 !! wikitext
12311 {|
12312 |{{echo|{{!}} foo}}
12313 |}
12314 !! html/php+tidy
12315 <table>
12316 <tbody><tr>
12317 <td>foo
12318 </td></tr></tbody></table>
12319 !! html/parsoid
12320 <table><tbody>
12321 <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>
12322 </tbody></table>
12323 !! end
12324
12325 !! test
12326 Parsoid: Merge double tds in nested transclusion content (T52603)
12327 !! wikitext
12328 {{echo|<div>}}
12329 {|
12330 |{{echo|{{!}} foo}}
12331 |}
12332 {{echo|</div>}}
12333 !! html/php+tidy
12334 <div>
12335 <table>
12336 <tbody><tr>
12337 <td>foo
12338 </td></tr></tbody></table>
12339 </div>
12340 !! html/parsoid
12341 <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}}]}'>
12342 <table><tbody>
12343 <tr><td data-mw='{"parts":["|"]}'> foo</td></tr>
12344 </tbody></table>
12345 </div>
12346 !! end
12347
12348 ###
12349 ### <includeonly> and <noinclude> in attributes
12350 ###
12351 !!test
12352 0. includeonly around the entire attribute
12353 !! wikitext
12354 <span <includeonly>id="v1"</includeonly><noinclude>id="v2"</noinclude>>bar</span>
12355 !! html
12356 <p><span id="v2">bar</span>
12357 </p>
12358 !!end
12359
12360 !!test
12361 1. includeonly in html attr key
12362 !! wikitext
12363 <span <noinclude>id</noinclude><includeonly>about</includeonly>="foo">bar</span>
12364 !! html
12365 <p><span id="foo">bar</span>
12366 </p>
12367 !!end
12368
12369 !!test
12370 2. includeonly in html attr value
12371 !! wikitext
12372 <span id="<noinclude>v1</noinclude><includeonly>v2</includeonly>">bar</span>
12373 <span id=<noinclude>"v1"</noinclude><includeonly>"v2"</includeonly>>bar</span>
12374 !! html
12375 <p><span id="v1">bar</span>
12376 <span id="v1">bar</span>
12377 </p>
12378 !!end
12379
12380 !!test
12381 3. includeonly in part of an attr value
12382 !! wikitext
12383 <span style="color:<noinclude>red</noinclude><includeonly>blue</includeonly>;">bar</span>
12384 !! html
12385 <p><span style="color:red;">bar</span>
12386 </p>
12387 !!end
12388
12389 !!test
12390 4. includeonly in table attributes
12391 !! wikitext
12392 {|
12393 |- <noinclude>
12394 |-
12395 |a
12396 </noinclude>
12397 |- <includeonly>
12398 |-
12399 |b
12400 </includeonly>
12401 |}
12402 !! html
12403 <table>
12404
12405
12406 <tr>
12407 <td>a
12408 </td></tr>
12409 </table>
12410
12411 !!end
12412
12413 ###
12414 ### Preprocessor precedence tests
12415 ### See: https://www.mediawiki.org/wiki/Preprocessor_ABNF
12416 ###
12417 ##{{[[-{{{{{{[[Foo|bar}}]]}-}}}}}]]
12418 !! test
12419 Preprocessor precedence 1: link is rightmost opening
12420 !! options
12421 parsoid=wt2html
12422 !! wikitext
12423 {{[[Foo|bar}}]]
12424
12425 But close-brace is not a valid character in a link title:
12426 {{[[Foo}}|bar]]
12427
12428 However, we can still tell this was handled as a link in the preprocessor:
12429 {{echo|[[Foo}}|bar]]|bat}}
12430 !! html/php
12431 <p>{{<a href="/wiki/Foo" title="Foo">bar}}</a>
12432 </p><p>But close-brace is not a valid character in a link title:
12433 {{[[Foo}}|bar]]
12434 </p><p>However, we can still tell this was handled as a link in the preprocessor:
12435 [[Foo}}|bar]]
12436 </p>
12437 !! html/parsoid
12438 <p>{{<a rel="mw:WikiLink" href="./Foo" title="Foo">bar}}</a></p>
12439 <p>But close-brace is not a valid character in a link title: {{[[Foo}}|bar]]</p>
12440 <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>
12441 !! end
12442
12443 !! test
12444 Preprocessor precedence 2: template is rightmost opening
12445 !! options
12446 language=zh
12447 !! wikitext
12448 -{{echo|foo}-}}-
12449 !! html/php
12450 <p>-foo}--
12451 </p>
12452 !! html/parsoid
12453 <p>-<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo}-"}},"i":0}}]}'>foo}-</span>-</p>
12454 !! end
12455
12456 !! test
12457 Preprocessor precedence 3: language converter is rightmost opening
12458 !! options
12459 language=zh
12460 parsoid=wt2html
12461 !! wikitext
12462 {{echo|hi}}
12463
12464 {{-{R|echo|hi}}}-
12465
12466 [[-{R|raw]]}-
12467 !! html/php
12468 <p>hi
12469 </p><p>{{echo|hi}}
12470 </p><p>[[raw]]
12471 </p>
12472 !! html/parsoid
12473 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi"}},"i":0}}]}'>hi</p>
12474 <p>{{<span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"echo|hi}}"}}'></span></p>
12475 <p>[[<span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw]]"}}'></span></p>
12476 !! end
12477
12478 !! test
12479 Preprocessor precedence 4: left-most angle bracket
12480 !! options
12481 language=zh
12482 !! wikitext
12483 <!--{raw}-->
12484 !! html/php
12485 !! html/parsoid
12486 <!--{raw}-->
12487 !! end
12488
12489 !! article
12490 Template:Precedence5
12491 !! text
12492 {{{{{1}}}}}
12493 !! endarticle
12494
12495 !! test
12496 Preprocessor precedence 5: tplarg takes precedence over template
12497 !! wikitext
12498 {{Precedence5|Bullet}}
12499 !! html/php
12500 <ul><li>Bar</li></ul>
12501 !! html/parsoid
12502 <ul typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"Precedence5","href":"./Template:Precedence5"},"params":{"1":{"wt":"Bullet"}},"i":0}}]}'><li>Bar</li></ul>
12503 !! end
12504
12505 !! test
12506 Preprocessor precedence 6: broken link is rightmost opening
12507 !! options
12508 parsoid=wt2html
12509 !! wikitext
12510 {{echo|[[Foo}}
12511
12512 {{echo|[[Foo|bar|bat=baz}}
12513 !! html/php
12514 <p>{{echo|[[Foo}}
12515 </p><p>{{echo|[[Foo|bar|bat=baz}}
12516 </p>
12517 !! html/parsoid
12518 <p>{{echo|[[Foo}}</p>
12519 <p>{{echo|[[Foo|bar|bat=baz}}</p>
12520 !! end
12521
12522 # This next test exposes a difference between PHP and Parsoid:
12523 # Given [[Foo|{{echo|Bar]]x}}y]]z:
12524 # 1) Both PHP and Parsoid ignore the `]]` inside the `echo` in the
12525 # "preprocessor" stage. The `{{echo` extends until the `x}}`, and the
12526 # outer `[[Foo` extends until the `y]]`
12527 # 2a) But then the PHP preprocessor emits `[[Foo|Bar]]xy]]z` as an
12528 # intermediate result (after template expansion), and link processing
12529 # happens on this intermediate result, which moves the wikilink
12530 # boundary leftward to `[[Foo|Bar]]`
12531 # 2b) Parsoid works in a single step, so it's going to keep the
12532 # wikilink as extending to the `y]]`
12533 # 3a) Then PHP does linktrail processing which slurps up the trailing
12534 # `xy` inside the link.
12535 # 3b) Parsoid will do linktrail processing to slurp up the trailing
12536 # `z` inside the link.
12537 # This is "correct" behavior. Parsoid's basic worldview is that the
12538 # `]]` inside the template shouldn't be allowed to leak out to affect
12539 # the surrounding wikilink. PHP may match Parsoid (in the future)
12540 # if you use {{#balance}} (T114445).
12541
12542 !! test
12543 Preprocessor precedence 7: broken template is rightmost opening
12544 !! options
12545 parsoid=wt2html
12546 !! wikitext
12547 [[Foo|{{echo|Bar]]
12548
12549 [[Foo|{{echo|Bar]]-x}}-y]]-z
12550
12551 Careful: linktrails can move the end of the wikilink:
12552 [[Foo|{{echo|y']]a}}l]]l
12553 !! html/php
12554 <p><a href="/wiki/Foo" title="Foo">{{echo|Bar</a>
12555 </p><p><a href="/wiki/Foo" title="Foo">Bar</a>-x-y]]-z
12556 </p><p>Careful: linktrails can move the end of the wikilink:
12557 <a href="/wiki/Foo" title="Foo">y'al</a>]]l
12558 </p>
12559 !! html/parsoid
12560 <p>[[Foo|{{echo|Bar]]</p>
12561 <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>
12562 <p>Careful: linktrails can move the end of the wikilink:
12563 <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>
12564 !! end
12565
12566 !! test
12567 Preprocessor precedence 8: broken language converter is rightmost opening
12568 !! options
12569 language=zh
12570 !! wikitext
12571 [[Foo-{R|raw]]
12572 !! html
12573 <p>[[Foo-{R|raw]]
12574 </p>
12575 !! end
12576
12577 !! article
12578 Template:Preprocessor_precedence_9
12579 !! text
12580 ;4: {{{{1}}}}
12581 ;5: {{{{{2}}}}}
12582 ;6: {{{{{{3}}}}}}
12583 ;7: {{{{{{{4}}}}}}}
12584 !! endarticle
12585
12586 !! test
12587 Preprocessor precedence 9: groups of braces
12588 !! wikitext
12589 {{Preprocessor precedence 9|Four|Bullet|1|2}}
12590 !! html/php
12591 <dl><dt>4</dt>
12592 <dd>{Four}</dd>
12593 <dt>5</dt>
12594 <dd></dd></dl>
12595 <ul><li>Bar</li></ul>
12596 <dl><dt>6</dt>
12597 <dd>Four</dd>
12598 <dt>7</dt>
12599 <dd>{Bullet}</dd></dl>
12600 !! html/parsoid
12601 <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}}]}'>
12602 <dt>4</dt>
12603 <dd>{Four}</dd>
12604 <dt>5</dt>
12605 <dd></dd>
12606 </dl><ul about="#mwt1">
12607 <li>Bar</li>
12608 </ul><span about="#mwt1"> </span><dl about="#mwt1">
12609 <dt>6</dt>
12610 <dd>Four</dd>
12611 <dt>7</dt>
12612 <dd>{Bullet}</dd>
12613 </dl>
12614 !! end
12615
12616 !! article
12617 Template:Preprocessor_precedence_10
12618 !! text
12619 ;1: -{R|raw}-
12620 ;2: -{{Bullet}}-
12621 ;3: -{{{1}}}-
12622 ;4: -{{{{2}}}}-
12623 ;5: -{{{{{3}}}}}-
12624 ;6: -{{{{{{4}}}}}}-
12625 ;7: -{{{{{{{5}}}}}}}-
12626 !! endarticle
12627
12628 !! test
12629 Preprocessor precedence 10: groups of braces with leading dash
12630 !! options
12631 language=zh
12632 !! wikitext
12633 {{Preprocessor precedence 10|Three|raw2|Bullet|1|2}}
12634 !! html/php
12635 <dl><dt>1</dt>
12636 <dd>raw</dd>
12637 <dt>2</dt>
12638 <dd>-</dd></dl>
12639 <ul><li>Bar-</li></ul>
12640 <dl><dt>3</dt>
12641 <dd>-Three-</dd>
12642 <dt>4</dt>
12643 <dd>raw2</dd>
12644 <dt>5</dt>
12645 <dd>-</dd></dl>
12646 <ul><li>Bar-</li></ul>
12647 <dl><dt>6</dt>
12648 <dd>-Three-</dd>
12649 <dt>7</dt>
12650 <dd>raw2</dd></dl>
12651 !! html/parsoid
12652 <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}}]}'>
12653 <dt>1</dt>
12654 <dd><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw"}}'></span></dd>
12655 <dt>2</dt>
12656 <dd>-</dd>
12657 </dl><ul about="#mwt1">
12658 <li>Bar-</li>
12659 </ul><span about="#mwt1"> </span><dl about="#mwt1">
12660 <dt>3</dt>
12661 <dd>-Three-</dd>
12662 <dt>4</dt>
12663 <dd><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw2"}}'></span></dd>
12664 <dt>5</dt>
12665 <dd>-</dd>
12666 </dl><ul about="#mwt1">
12667 <li>Bar-</li>
12668 </ul><span about="#mwt1"> </span><dl about="#mwt1">
12669 <dt>6</dt>
12670 <dd>-Three-</dd>
12671 <dt>7</dt>
12672 <dd><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw2"}}'></span></dd>
12673 </dl>
12674 !! end
12675
12676 !! test
12677 Preprocessor precedence 11: found during visual diff testing
12678 !! wikitext
12679 {{#tag:span|-{{#tag:span|-{{echo|x}}}}}}
12680
12681 {{echo|-{{echo|-{{echo|x}}}}}}
12682
12683 {{echo|-{{echo|x}}}}
12684 !! html/php
12685 <p><span>-<span>-x</span></span>
12686 </p><p>--x
12687 </p><p>-x
12688 </p>
12689 !! html/parsoid
12690 <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>
12691
12692 <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>
12693
12694 <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>
12695 !! end
12696
12697 !! test
12698 Preprocessor precedence 12: broken language converter closed by brace.
12699 !! options
12700 parsoid=wt2html
12701 !! wikitext
12702 This form breaks the template, which is unfortunate:
12703 *{{echo|foo-{bar}bat}}
12704
12705 But if the broken language converter markup is inside an extension
12706 tag, nothing bad happens:
12707 *<nowiki>foo-{bar}bat</nowiki>
12708 *{{echo|<nowiki>foo-{bar}bat</nowiki>}}
12709 *<pre>foo-{bar}bat</pre>
12710 *{{echo|<pre>foo-{bar}bat</pre>}}
12711
12712 <tag>foo-{bar}bat</tag>
12713 {{echo|<tag>foo-{bar}bat</tag>}}
12714
12715 !! html/php+tidy
12716 <p>This form breaks the template, which is unfortunate:
12717 </p>
12718 <ul><li>{{echo|foo-{bar}bat}}</li></ul>
12719 <p>But if the broken language converter markup is inside an extension
12720 tag, nothing bad happens:
12721 </p>
12722 <ul><li>foo-&#123;bar}bat</li>
12723 <li>foo-&#123;bar}bat</li>
12724 <li><pre>foo-{bar}bat</pre></li>
12725 <li><pre>foo-{bar}bat</pre></li></ul>
12726 <pre>'foo-{bar}bat'
12727 array (
12728 )
12729 </pre>
12730 <pre>'foo-{bar}bat'
12731 array (
12732 )
12733 </pre>
12734 !! html/parsoid
12735 <p>This form breaks the template, which is unfortunate:</p>
12736 <ul>
12737 <li>{{echo|foo-{bar}bat}}</li>
12738 </ul>
12739 <p>But if the broken language converter markup is inside an extension tag, nothing bad happens:</p>
12740 <ul>
12741 <li><span typeof="mw:Nowiki">foo-{bar}bat</span></li>
12742 <li><span typeof="mw:Nowiki mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;nowiki>foo-{bar}bat&lt;/nowiki>"}},"i":0}}]}'>foo-{bar}bat</span></li>
12743 <li><pre typeof="mw:Extension/pre" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo-{bar}bat"}}'>foo-{bar}bat</pre></li>
12744 <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>
12745 </ul>
12746 <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>
12747 !! end
12748
12749 !! test
12750 Preprocessor precedence 13: broken language converter in external link
12751 !! options
12752 parsoid=wt2html
12753 !! wikitext
12754 *[http://example.com/-{foo Example in URL]
12755 *[http://example.com Example in -{link} description]
12756 *{{echo|[http://example.com/-{foo Breaks template, however]}}
12757 !! html/php+tidy
12758 <ul><li><a rel="nofollow" class="external text" href="http://example.com/-{foo">Example in URL</a></li>
12759 <li><a rel="nofollow" class="external text" href="http://example.com">Example in -{link} description</a></li>
12760 <li>{{echo|<a rel="nofollow" class="external text" href="http://example.com/-{foo">Breaks template, however</a>}}</li></ul>
12761 !! html/parsoid
12762 <ul>
12763 <li><a rel="mw:ExtLink" class="external text" href="http://example.com/-{foo">Example in URL</a></li>
12764 <li><a rel="mw:ExtLink" class="external text" href="http://example.com">Example in -{link} description</a></li>
12765 <li>{{echo|<a rel="mw:ExtLink" class="external text" href="http://example.com/-{foo">Breaks template, however</a>}}</li>
12766 </ul>
12767 !! end
12768
12769 !! test
12770 Preprocessor precedence 14: broken language converter in comment
12771 !! wikitext
12772 *<!--{{foo}}-->...should be ok
12773 *<!---{{foo}}-->...extra dashes
12774 *{{echo|foo<!-- -{bar} -->bat}}...should be ok
12775 !! html/php+tidy
12776 <ul><li>...should be ok</li>
12777 <li>...extra dashes</li>
12778 <li>foobat...should be ok</li></ul>
12779 !! html/parsoid
12780 <ul>
12781 <li><!--{{foo}}-->...should be ok</li>
12782 <li><!--&#x2D;{{foo}}-->...extra dashes</li>
12783 <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>
12784 </ul>
12785 !! end
12786
12787 !! test
12788 Preprocessor precedence 15: broken brace markup in headings
12789 !! config
12790 wgFragmentMode=[ 'html5', 'legacy' ]
12791 !! options
12792 parsoid=wt2html
12793 !! wikitext
12794 __NOTOC__ __NOEDITSECTION__
12795 ===1 foo[bar 1===
12796 1
12797 ===2 foo[[bar 2===
12798 2
12799 ===3 foo{bar 3===
12800 3
12801 ===4 foo{{bar 4===
12802 4
12803 ===5 foo{{{bar 5===
12804 5
12805 ===6 foo-{bar 6===
12806 6
12807 !! html/php+tidy
12808 <h3><span id="1_foo.5Bbar_1"></span><span class="mw-headline" id="1_foo[bar_1">1 foo[bar 1</span></h3>
12809 <p>1
12810 </p>
12811 <h3><span id="2_foo.5B.5Bbar_2"></span><span class="mw-headline" id="2_foo[[bar_2">2 foo[[bar 2</span></h3>
12812 <p>2
12813 </p>
12814 <h3><span id="3_foo.7Bbar_3"></span><span class="mw-headline" id="3_foo{bar_3">3 foo{bar 3</span></h3>
12815 <p>3
12816 </p>
12817 <h3><span id="4_foo.7B.7Bbar_4"></span><span class="mw-headline" id="4_foo{{bar_4">4 foo{{bar 4</span></h3>
12818 <p>4
12819 </p>
12820 <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>
12821 <p>5
12822 </p>
12823 <h3><span id="6_foo-.7Bbar_6"></span><span class="mw-headline" id="6_foo-{bar_6">6 foo-{bar 6</span></h3>
12824 <p>6
12825 </p>
12826 !! html/parsoid
12827 <meta property="mw:PageProp/notoc"/> <meta property="mw:PageProp/noeditsection"/>
12828 <h3 id="1_foo[bar_1"><span id="1_foo.5Bbar_1" typeof="mw:FallbackId"></span>1 foo[bar 1</h3>
12829 <p>1</p>
12830 <h3 id="2_foo[[bar_2"><span id="2_foo.5B.5Bbar_2" typeof="mw:FallbackId"></span>2 foo[[bar 2</h3>
12831 <p>2</p>
12832 <h3 id="3_foo{bar_3"><span id="3_foo.7Bbar_3" typeof="mw:FallbackId"></span>3 foo{bar 3</h3>
12833 <p>3</p>
12834 <h3 id="4_foo{{bar_4"><span id="4_foo.7B.7Bbar_4" typeof="mw:FallbackId"></span>4 foo{{bar 4</h3>
12835 <p>4</p>
12836 <h3 id="5_foo{{{bar_5"><span id="5_foo.7B.7B.7Bbar_5" typeof="mw:FallbackId"></span>5 foo{{{bar 5</h3>
12837 <p>5</p>
12838 <h3 id="6_foo-{bar_6"><span id="6_foo-.7Bbar_6" typeof="mw:FallbackId"></span>6 foo-{bar 6</h3>
12839 <p>6</p>
12840 !! end
12841
12842 !! test
12843 Preprocessor precedence 16: matching closing braces to opening braces
12844 !! options
12845 language=zh
12846 parsoid=wt2html
12847 !! wikitext
12848 -{{{echo|foo}}bar}-
12849 !! html/php
12850 <p>foobar
12851 </p>
12852 !! html/parsoid
12853 <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>
12854 !! end
12855
12856 !! test
12857 Preprocessor precedence 17: template w/o target shouldn't prevent closing
12858 !! options
12859 parsoid=wt2html
12860 !! wikitext
12861 {{echo|hi {{}}}}
12862 !! html/php
12863 <p>hi {{}}
12864 </p>
12865 !! html/parsoid
12866 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi {{}}"}},"i":0}}]}'>hi {{}}</p>
12867 !! end
12868
12869 # Ensure we're using a language without variants for this test; even
12870 # if $wgUsePigLatinVariant is true. We've picked `de` arbitrarily.
12871 !! test
12872 Preprocessor precedence 18: another rightmost wins scenario
12873 !! options
12874 parsoid=wt2html
12875 language=de
12876 !! wikitext
12877 {{ -{{{{1|tplarg}}} }} }-
12878 !! html/php
12879 <p>{{ -{tplarg }} }-
12880 </p>
12881 !! html/parsoid
12882 <p>{{ -{<span about="#mwt1" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"1"},"params":{"1":{"wt":"tplarg"}},"i":0}}]}'>tplarg</span> }} }-</p>
12883 !! end
12884
12885 !! test
12886 Preprocessor precedence 19: break syntax
12887 !! options
12888 parsoid=wt2html
12889 !! wikitext
12890 -{{
12891 !! html/php
12892 <p>-{{
12893 </p>
12894 !! html/parsoid
12895 <p>-{{</p>
12896 !! end
12897
12898 ###
12899 ### Token Stream Patcher tests
12900 ###
12901 ### These tests won't always pass wt2wt and other modes because
12902 ### on serialization, the table will be output on a new line.
12903 ### For now, we are blacklisting them, and using this to test selser.
12904 ###
12905
12906 !!test
12907 1. Table tag in SOL posn. should get reparsed correctly with valid TSR
12908 !!options
12909 parsoid=wt2html,wt2wt
12910 !!wikitext
12911 {{echo|}}{| width = '100%'
12912 |foo
12913 |}
12914 !!html/parsoid
12915 <span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":""}},"i":0}}]}'></span><table width="100%">
12916 <tbody><tr><td>foo</td></tr>
12917 </tbody></table>
12918 !!end
12919
12920 ## We used to, but no longer wt2wt this test since the default serializer
12921 ## will normalize the include directives to serialize on their own line.
12922 ## Selser will take care of preserving formatting in scenarios where they
12923 ## intermingled with other wikitext.
12924 !!test
12925 2. Table tag in SOL posn. should get reparsed correctly with valid TSR
12926 !!options
12927 parsoid=wt2html
12928 !!wikitext
12929 <includeonly>a</includeonly>{| {{{b}}}
12930 |c
12931 |}
12932 !!html/parsoid
12933 <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":""}]]}'>
12934 <tbody><tr><td>c</td></tr>
12935 </tbody></table>
12936 !!end
12937
12938 !! test
12939 Table wikitext syntax outside wiki-tables
12940 !! wikitext
12941 a
12942 |+ not a caption
12943 ! not a table heading
12944 |- not a table row
12945 | not a table cell
12946 | class="foo bar" | baz
12947 b
12948 |}
12949 |-
12950 c
12951 !! html
12952 <p>a
12953 |+ not a caption
12954 ! not a table heading
12955 |- not a table row
12956 | not a table cell
12957 | class="foo bar" | baz
12958 b
12959 |}
12960 |-
12961 c
12962 </p>
12963 !! end
12964
12965 ###
12966 ### Testing parsing of templates where a template arg
12967 ### has the same name as the template itself.
12968 ###
12969
12970 !! article
12971 Template:quote
12972 !! text
12973 {{{quote|{{{1}}}}}}
12974 !! endarticle
12975
12976 !!test
12977 Templates: Template Name/Arg clash: 1. Use of positional param
12978 !! wikitext
12979 {{quote|foo}}
12980 !! html
12981 <p>foo
12982 </p>
12983 !!end
12984
12985 !!test
12986 Templates: Template Name/Arg clash: 2. Use of named param
12987 !! wikitext
12988 {{quote|quote=foo}}
12989 !! html
12990 <p>foo
12991 </p>
12992 !!end
12993
12994 !!test
12995 Templates: Template Name/Arg clash: 3. Use of named param with empty input
12996 !! wikitext
12997 {{quote|quote}}
12998 !! html
12999 <p>quote
13000 </p>
13001 !!end
13002
13003 ###
13004 ### Parsoid-centric tests to stress Parsoid's ability to RT them unchanged
13005 ###
13006
13007 !!test
13008 Templates: 1. Simple use
13009 !! wikitext
13010 {{echo|Foo}}
13011 !! html
13012 <p>Foo
13013 </p>
13014 !!end
13015
13016 !!test
13017 Templates: 2. Inside a block tag
13018 !! wikitext
13019 <div>{{echo|Foo}}</div>
13020 <blockquote>{{echo|Foo}}</blockquote>
13021 !! html
13022 <div>Foo</div>
13023 <blockquote>Foo</blockquote>
13024
13025 !! html+tidy
13026 <div>Foo</div>
13027 <blockquote><p>Foo</p></blockquote>
13028 !!end
13029
13030 !!test
13031 Templates: P-wrapping: 1a. Templates on consecutive lines
13032 !! wikitext
13033 {{echo|Foo}}
13034 {{echo|bar}}
13035 !! html
13036 <p>Foo
13037 bar
13038 </p>
13039 !!end
13040
13041 !!test
13042 Templates: P-wrapping: 1b. Templates on consecutive lines
13043 !! wikitext
13044 Foo
13045
13046 {{echo|bar}}
13047 {{echo|baz}}
13048 !! html
13049 <p>Foo
13050 </p><p>bar
13051 baz
13052 </p>
13053 !!end
13054
13055 !!test
13056 Templates: P-wrapping: 1c. Templates on consecutive lines
13057 !! wikitext
13058 {{echo|Foo}}
13059 {{echo|bar}} <div>baz</div>
13060 !! html
13061 <p>Foo
13062 </p>
13063 bar <div>baz</div>
13064
13065 !! html+tidy
13066 <p>Foo
13067 </p><p>
13068 bar </p><div>baz</div>
13069 !! end
13070
13071 !! test
13072 Templates: P-wrapping: 1d. Template preceded by comment-only line
13073 !! wikitext
13074 <!-- foo -->
13075 {{echo|Bar}}
13076 !! html/php+tidy
13077 <p>Bar
13078 </p>
13079 !! html/parsoid
13080 <!-- foo -->
13081
13082 <p about="#mwt223" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"Bar"}},"i":0}}]}'>Bar</p>
13083 !!end
13084
13085 !! test
13086 Templates: Scopes should not be expanded unnecessarily
13087 !! options
13088 parsoid=wt2html,wt2wt
13089 !! wikitext
13090 {{echo|<div>a</div>}}b{{echo|
13091 <div>c</div>}}
13092 !! html/php+tidy
13093 <div>a</div><p>b
13094 </p><div>c</div>
13095 !! html/parsoid
13096 <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}}]}'>
13097 </span><div about="#mwt2">c</div>
13098 !! end
13099
13100 !!test
13101 Templates: Inline Text: 1. Multiple template uses
13102 !! wikitext
13103 {{echo|Foo}}bar{{echo|baz}}
13104 !! html
13105 <p>Foobarbaz
13106 </p>
13107 !!end
13108
13109 !!test
13110 Templates: Inline Text: 2. Back-to-back template uses
13111 !! wikitext
13112 {{echo|Foo}}{{echo|bar}}
13113 !! html
13114 <p>Foobar
13115 </p>
13116 !!end
13117
13118 !!test
13119 Templates: Block Tags: 1. Multiple template uses
13120 !! wikitext
13121 {{echo|<div>Foo</div>}}<div>bar</div>{{echo|<div>baz</div>}}
13122 !! html
13123 <div>Foo</div><div>bar</div><div>baz</div>
13124
13125 !!end
13126
13127 !!test
13128 Templates: Block Tags: 2. Back-to-back template uses
13129 !! wikitext
13130 {{echo|<div>Foo</div>}}{{echo|<div>bar</div>}}
13131 !! html
13132 <div>Foo</div><div>bar</div>
13133
13134 !!end
13135
13136 ## Parsoid drops empty elements in templates.
13137 !! test
13138 Templates: Correctly encapsulate templates producing </p> tag without a corresponding <p> tag
13139 !! wikitext
13140 {{echo|a
13141 b</p>}}
13142 !! html/php+tidy
13143 <p>a
13144 </p><p>
13145 b</p><p class="mw-empty-elt"></p>
13146 !! html/parsoid
13147 <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">
13148 </span><p about="#mwt1">b</p>
13149 !! end
13150
13151 !!test
13152 Templates: Links: 1. Simple example
13153 !! wikitext
13154 {{echo|[[Foo|bar]]}}
13155 !! html
13156 <p><a href="/wiki/Foo" title="Foo">bar</a>
13157 </p>
13158 !!end
13159
13160 !!test
13161 Templates: Links: 2. Generation of link href
13162 !! wikitext
13163 [[{{echo|Foo}}|bar]]
13164 !! html
13165 <p><a href="/wiki/Foo" title="Foo">bar</a>
13166 </p>
13167 !!end
13168
13169 !!test
13170 Templates: Links: 3. Generation of part of a link href
13171 !! wikitext
13172 [[Fo{{echo|o}}|bar]]
13173
13174 [[Foo{{echo|bar}}]]
13175
13176 [[Foo{{echo|bar}}baz]]
13177
13178 [[Foo{{echo|bar}}|bar]]
13179
13180 [[:Foo{{echo|bar}}]]
13181
13182 [[:Foo{{echo|bar}}|bar]]
13183 !! html
13184 <p><a href="/wiki/Foo" title="Foo">bar</a>
13185 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
13186 </p><p><a href="/index.php?title=Foobarbaz&amp;action=edit&amp;redlink=1" class="new" title="Foobarbaz (page does not exist)">Foobarbaz</a>
13187 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">bar</a>
13188 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
13189 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">bar</a>
13190 </p>
13191 !!end
13192
13193 !!test
13194 Templates: Links: 4. Multiple templates generating link href
13195 !! wikitext
13196 [[{{echo|F}}{{echo|o}}ob{{echo|ar}}]]
13197 !! html
13198 <p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
13199 </p>
13200 !!end
13201
13202 !!test
13203 Templates: Links: 5. Generation of link text
13204 !! wikitext
13205 [[Foo|{{echo|bar}}]]
13206 !! html
13207 <p><a href="/wiki/Foo" title="Foo">bar</a>
13208 </p>
13209 !!end
13210
13211 !!test
13212 Templates: Links: 5. Nested templates (only outermost template should be marked)
13213 !! wikitext
13214 {{echo|[[{{echo|Foo}}|bar]]}}
13215 !! html
13216 <p><a href="/wiki/Foo" title="Foo">bar</a>
13217 </p>
13218 !!end
13219
13220 !!test
13221 Templates: HTML Tag: 1. Generation of HTML attr. key
13222 !! wikitext
13223 <div {{echo|style}}="color:red;">foo</div>
13224 !! html
13225 <div style="color:red;">foo</div>
13226
13227 !!end
13228
13229 !!test
13230 Templates: HTML Tag: 2. Generation of HTML attr. value
13231 !! wikitext
13232 <div style={{echo|'color:red;'}}>foo</div>
13233 !! html
13234 <div style="color:red;">foo</div>
13235
13236 !!end
13237
13238 !!test
13239 Templates: HTML Tag: 3. Generation of HTML attr key and value
13240 !! wikitext
13241 <div {{echo|style}}={{echo|'color:red;'}}>foo</div>
13242 !! html
13243 <div style="color:red;">foo</div>
13244
13245 !!end
13246
13247 !!test
13248 Templates: HTML Tag: 4. Generation of starting piece of HTML attr value
13249 !! wikitext
13250 <div title="{{echo|This is a long title}} with just one piece templated">foo</div>
13251 !! html
13252 <div title="This is a long title with just one piece templated">foo</div>
13253
13254 !!end
13255
13256 !!test
13257 Templates: HTML Tag: 5. Generation of middle piece of HTML attr value
13258 !! wikitext
13259 <div title="This is a long title with just {{echo|one piece}} templated">foo</div>
13260 !! html
13261 <div title="This is a long title with just one piece templated">foo</div>
13262
13263 !!end
13264
13265 !!test
13266 Templates: HTML Tag: 6. Generation of end piece of HTML attr value
13267 !! wikitext
13268 <div title="This is a long title with just one piece {{echo|templated}}">foo</div>
13269 !! html
13270 <div title="This is a long title with just one piece templated">foo</div>
13271
13272 !!end
13273
13274 # SSS FIXME: While it is great we added support for all this,
13275 # do we want to make this part of the spec? Maybe we want to
13276 # deprecate this kind of usage in the future?
13277 !!test
13278 Templates: HTML Tag: 7. Generation of partial attribute key string
13279 !! wikitext
13280 <div st{{echo|yle}}="color:red;">foo</div>
13281 !! html
13282 <div style="color:red;">foo</div>
13283
13284 !!end
13285
13286 !! test
13287 Templates: HTML Tag: 8. Template-generated attribute (k=v)
13288 !! wikitext
13289 <div {{echo|1=id="v1"}}>bar</div>
13290 !! html
13291 <div id="v1">bar</div>
13292
13293 !!end
13294
13295 !! test
13296 Templates: HTML Tag: 9. Multiple template-generated attributes
13297 !! wikitext
13298 <div {{echo|1=id="v1" title="foo"}}>bar</div>
13299 !! html
13300 <div id="v1" title="foo">bar</div>
13301
13302 !!end
13303
13304 !! test
13305 Templates: Support for templates generating attributes and content
13306 !! wikitext
13307 {| {{mixed_attr_content_template}}
13308 |-
13309 |bar
13310 |}
13311 !! html/php
13312 <table style="color:red;" title="T48811">
13313
13314 <tr>
13315 <td>foo
13316 </td></tr>
13317 <tr>
13318 <td>bar
13319 </td></tr></table>
13320
13321 !! html/parsoid
13322 <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|}"]}'>
13323 <tbody><tr>
13324 <td>foo</td></tr>
13325 <tr>
13326 <td>bar</td></tr>
13327 </tbody></table>
13328 !!end
13329
13330 !! article
13331 Template:attribute_from_template
13332 !! text
13333 class="123"
13334 !! endarticle
13335
13336 !! test
13337 Table cell with attribute before expanded attribute
13338 !! wikitext
13339 {|
13340 | align="center" {{attribute_from_template}} |456
13341 |}
13342 !! html/parsoid
13343 <table>
13344 <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>
13345 </tbody></table>
13346 !! end
13347
13348 !! test
13349 1. Entities and nowikis inside templated attributes should be handled correctly
13350 !! wikitext
13351 <div {{echo|style{{=}}"background:&#35;f9f9f9;"}}>foo</div>
13352 !! html/php
13353 <div style="background:#f9f9f9;">foo</div>
13354
13355 !! html/parsoid
13356 <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>
13357 !! end
13358
13359 !! test
13360 2. Entities and nowikis inside templated attributes should be handled correctly
13361 !! wikitext
13362 {|
13363 |{{table_attribs_3}}
13364 |}
13365 !! html/php
13366 <table>
13367 <tr>
13368 <td style="background:#f9f9f9;">Foo
13369 </td></tr></table>
13370
13371 !! html/parsoid
13372 <table>
13373 <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>
13374 </tbody></table>
13375 !! end
13376
13377 !! test
13378 3. Entities and nowikis inside templated attributes should be handled correctly inside templated tables
13379 !! wikitext
13380 {{tbl-start}}
13381 |{{table_attribs_3}}
13382 {{tbl-end}}
13383 !! html/php
13384 <table>
13385 <tr>
13386 <td style="background:#f9f9f9;">Foo
13387 </td></tr></table>
13388
13389 !! html/parsoid
13390 <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}}]}'>
13391 <tbody><tr><td style="background:#f9f9f9;">Foo</td></tr>
13392 </tbody></table>
13393 !! end
13394
13395 # T107622
13396 !! test
13397 4. Entities and nowikis inside templated attributes should be handled correctly inside templated tables
13398 !! wikitext
13399 {|
13400 |{{table_attribs_6}} hi
13401 |}
13402 !! html/php
13403 <table>
13404 <tr>
13405 <td style="background: red;">hi
13406 </td></tr></table>
13407
13408 !! html/parsoid
13409 <table>
13410 <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>
13411 </tbody></table>
13412 !! end
13413
13414 !!test
13415 Templates: HTML Tables: 1. Generating start of a HTML table
13416 !! wikitext
13417 {{echo|<table><tr><td>foo</td>}}</tr></table>
13418 !! html
13419 <table><tr><td>foo</td></tr></table>
13420
13421 !!end
13422
13423 !!test
13424 Templates: HTML Tables: 2a. Generating middle of a HTML table
13425 !! wikitext
13426 <table><tr>{{echo|<td>foo</td>}}</tr></table>
13427 !! html
13428 <table><tr><td>foo</td></tr></table>
13429
13430 !!end
13431
13432 !!test
13433 Templates: HTML Tables: 2b. Generating middle of a HTML table
13434 !! wikitext
13435 <table>{{echo|<tr><td>foo</td></tr>}}</table>
13436 !! html
13437 <table><tr><td>foo</td></tr></table>
13438
13439 !!end
13440
13441 !!test
13442 Templates: HTML Tables: 3. Generating end of a HTML table
13443 !! wikitext
13444 <table><tr>{{echo|<td>foo</td></tr></table>}}
13445 !! html
13446 <table><tr><td>foo</td></tr></table>
13447
13448 !!end
13449
13450 !!test
13451 Templates: HTML Tables: 4a. Generating a single tag of a HTML table
13452 !! wikitext
13453 {{echo|<table>}}<tr><td>foo</td></tr></table>
13454 !! html
13455 <table><tr><td>foo</td></tr></table>
13456
13457 !!end
13458
13459 !!test
13460 Templates: HTML Tables: 4b. Generating a single tag of a HTML table
13461 !! wikitext
13462 <table>{{echo|<tr>}}<td>foo</td></tr></table>
13463 !! html
13464 <table><tr><td>foo</td></tr></table>
13465
13466 !!end
13467
13468 !!test
13469 Templates: HTML Tables: 4c. Generating a single tag of a HTML table
13470 !! wikitext
13471 <table><tr>{{echo|<td>}}foo</td></tr></table>
13472 !! html
13473 <table><tr><td>foo</td></tr></table>
13474
13475 !!end
13476
13477 !!test
13478 Templates: HTML Tables: 4d. Generating a single tag of a HTML table
13479 !! wikitext
13480 <table><tr><td>foo{{echo|</td>}}</tr></table>
13481 !! html
13482 <table><tr><td>foo</td></tr></table>
13483
13484 !!end
13485
13486 !!test
13487 Templates: HTML Tables: 4e. Generating a single tag of a HTML table
13488 !! wikitext
13489 <table><tr><td>foo</td>{{echo|</tr>}}</table>
13490 !! html
13491 <table><tr><td>foo</td></tr></table>
13492
13493 !!end
13494
13495 !!test
13496 Templates: HTML Tables: 4f. Generating a single tag of a HTML table
13497 !! wikitext
13498 <table><tr><td>foo</td></tr>{{echo|</table>}}
13499 !! html
13500 <table><tr><td>foo</td></tr></table>
13501
13502 !!end
13503
13504 !!test
13505 Templates: HTML Tables: 5. Proper fostering of categories from inside
13506 !!options
13507 parsoid=wt2html,wt2wt
13508 !! wikitext
13509 <table>[[Category:foo1]]<tr><td>foo</td></tr></table>
13510 <!--Two categories (T52330)-->
13511 <table>[[Category:bar1]][[Category:bar2]]<tr><td>foo</td></tr></table>
13512 !! html/php+tidy
13513 <table><tbody><tr><td>foo</td></tr></tbody></table>
13514 <table><tbody><tr><td>foo</td></tr></tbody></table>
13515 !! html/parsoid
13516 <link rel="mw:PageProp/Category" href="./Category:Foo1"><table><tbody><tr><td>foo</td></tr></tbody></table>
13517 <!--Two categories (T52330)-->
13518 <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>
13519 !!end
13520
13521 ## Remex doesn't account for fostered content.
13522 !! test
13523 Templates: Wiki Tables: 1a. Fostering of entire template content
13524 !! wikitext
13525 {|
13526 {{echo|a}}
13527 |}
13528 !! html/php
13529 <table>
13530 a
13531 <tr><td></td></tr></table>
13532
13533 !! html/php+tidy
13534
13535 a
13536 <table><tbody><tr><td></td></tr></tbody></table>
13537 !! html/parsoid
13538 <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">
13539
13540 </table>
13541 !! end
13542
13543 !!test
13544 Templates: Wiki Tables: 1b. Fostering of entire template content
13545 !! wikitext
13546 {|
13547 {{echo|<div>}}
13548 foo
13549 {{echo|</div>}}
13550 |}
13551 !! html
13552 <table>
13553 <div>
13554 <p>foo
13555 </p>
13556 </div>
13557 <tr><td></td></tr></table>
13558
13559 !! html/php+tidy
13560 <div>
13561 <p>foo
13562 </p>
13563 </div><table>
13564
13565 <tbody><tr><td></td></tr></tbody></table>
13566 !! html/parsoid
13567 <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|}"]}'>
13568 <p>foo</p>
13569 </div><table about="#mwt3">
13570
13571 </table>
13572 !! end
13573
13574 ## Remex doesn't account for fostered content.
13575 !! test
13576 Templates: Wiki Tables: 2. Fostering of partial template content
13577 !! wikitext
13578 {|
13579 {{echo|a
13580 <div>b</div>}}
13581 |}
13582 !! html/php
13583 <table>
13584 a
13585 <div>b</div>
13586 <tr><td></td></tr></table>
13587
13588 !! html/php+tidy
13589
13590 a
13591 <div>b</div><table>
13592 <tbody><tr><td></td></tr></tbody></table>
13593 !! html/parsoid
13594 <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">
13595
13596
13597 </table>
13598 !! end
13599
13600 !!test
13601 Templates: Wiki Tables: 3. td-content via multiple templates
13602 !! wikitext
13603 {|
13604 {{echo|{{pipe}}a}}{{echo|b}}
13605 |}
13606 !! html
13607 <table>
13608 <tr>
13609 <td>ab
13610 </td></tr></table>
13611
13612 !!end
13613
13614 !!test
13615 Templates: Wiki Tables: 4. Templated tags, no content
13616 !! wikitext
13617 {{tbl-start}}
13618 {{tbl-end}}
13619 !! html
13620 <table>
13621 <tr><td></td></tr></table>
13622
13623 !!end
13624
13625 !!test
13626 Templates: Wiki Tables: 5. Templated tags, regular td-tags
13627 !! wikitext
13628 {{tbl-start}}
13629 |foo
13630 {{tbl-end}}
13631 !! html
13632 <table>
13633 <tr>
13634 <td>foo
13635 </td></tr></table>
13636
13637 !!end
13638
13639 !!test
13640 Templates: Wiki Tables: 6. Templated tags, templated td-tags
13641 !! wikitext
13642 {{tbl-start}}
13643 {{!}}foo
13644 {{tbl-end}}
13645 !! html
13646 <table>
13647 <tr>
13648 <td>foo
13649 </td></tr></table>
13650
13651 !!end
13652
13653 ## This test case is very specific to Parsoid's internals
13654 ## and is hence only tested for Parsoid's code. Parsoid uses
13655 ## a <meta> marker tag for <ref> tags and they are expanded
13656 ## much later. We are verifying that this <meta> tag usage
13657 ## doesn't prevent foster parenting.
13658 !! test
13659 Templates: Wiki Tables: 7. Fosterable <ref>s should get fostered
13660 !! wikitext
13661 {{PartialTable}}<ref>foo</ref>
13662 |}
13663
13664 <references />
13665 !! html/parsoid
13666 <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">
13667 <tbody>
13668 </tbody></table>
13669
13670 <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>
13671 !! end
13672
13673 !! test
13674 Templates: Wiki Tables: 8. Fosterable meta-tags should get fostered
13675 !! wikitext
13676 {{echo|
13677 {{{!}}
13678 {{!}}-}}
13679 <onlyinclude>
13680 |foo
13681 </onlyinclude>
13682 {{!}}}
13683 !! html/parsoid
13684 <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{{!}}}"]}'>
13685 </span><meta typeof="mw:Includes/OnlyInclude" about="#mwt1"/><table about="#mwt1">
13686 <tbody><tr>
13687
13688 <td>foo
13689 <meta typeof="mw:Includes/OnlyInclude/End"/></td></tr>
13690 </tbody></table>
13691 !! end
13692
13693 !!test
13694 Templates: Lists: Multi-line list-items via templates
13695 !! wikitext
13696 *{{echo|a {{nonexistent|
13697 unused}}}}
13698 *{{echo|b {{nonexistent|
13699 unused}}}}
13700 !! html
13701 <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>
13702 <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>
13703 !!end
13704
13705 !!test
13706 Templates: Ugly nesting: 1. Quotes opened/closed across templates (echo)
13707 !! wikitext
13708 {{echo|''a}}{{echo|b''c''d}}{{echo|''e}}
13709 !! html
13710 <p><i>ab</i>c<i>d</i>e
13711 </p>
13712 !!end
13713
13714 !!test
13715 Templates: Ugly nesting: 2. Quotes opened/closed across templates (echo_with_span)
13716 (PHP parser generates misnested html)
13717 !! wikitext
13718 {{echo_with_span|''a}}{{echo_with_span|b''c''d}}{{echo_with_span|''e}}
13719 !! html/parsoid
13720 <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>
13721 !!end
13722
13723 !!test
13724 Templates: Ugly nesting: 3. Quotes opened/closed across templates (echo_with_div)
13725 (PHP parser generates misnested html; Parsoid html2wt mode adds newlines between {{echo}}s)
13726 !! options
13727 parsoid=wt2html,wt2wt
13728 !! wikitext
13729 {{echo_with_div|''a}}{{echo_with_div|b''c''d}}{{echo_with_div|''e}}
13730 !! html/php+tidy
13731 <div><i>a</i></div><div><i>b</i>c<i>d</i></div><div>e</div>
13732 !! html/parsoid
13733 <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>
13734 <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>
13735 <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>
13736 !!end
13737
13738 !!test
13739 Templates: Ugly nesting: 4. Divs opened/closed across templates
13740 !! wikitext
13741 a<div>b{{echo|c</div>d}}e
13742 !! html
13743 a<div>bc</div>de
13744
13745 !! html+tidy
13746 <p>a</p><div>bc</div><p>de
13747 </p>
13748 !! end
13749
13750 !! test
13751 Templates: Ugly templates: 3. newline-only template parameter
13752 !! wikitext
13753 foo {{echo|
13754 }}
13755 !! html
13756 <p>foo
13757 </p>
13758 !! end
13759
13760 # This looks like a bug: a single newline triggers p/br for some reason.
13761 !! test
13762 Templates: Ugly templates: 4. newline-only template parameter inconsistency
13763 !! wikitext
13764 {{echo|
13765 }}
13766 !! html
13767 <p><br />
13768 </p>
13769 !! end
13770
13771 # T66017 -- ugly wikitext with fostered content generates two template ranges that
13772 # have a true overlap (T1-start - T2-start - T1-end - T2-end).
13773 !! test
13774 Templates: Ugly templates: 5. Template encapsulation test: Non-trivial overlap of template ranges is properly handled
13775 !! wikitext
13776 {{echo|<table>}}
13777 {{echo|<div>foo}}
13778 {{echo|</table>}}
13779 !! html/parsoid
13780 <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">
13781 </span><table about="#mwt1">
13782 </table>
13783 !! end
13784
13785 # T66017 -- ugly wikitext with fostered content generates two template ranges
13786 # that are "identical" and generate nesting cycles in the algorithm
13787 !! test
13788 Templates: Ugly templates: 6. Template encapsulation test: Cyclical nesting of template ranges is properly handled
13789 !! wikitext
13790 {{echo|<table><tr><td><table>}}
13791 {{echo|<div>}}
13792 {{echo|</div>}}
13793 !! html/parsoid
13794 <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"}'>
13795 </div><table about="#mwt1" data-parsoid='{"stx":"html"}'>
13796 </table></td></tr></tbody></table>
13797 !! end
13798
13799 !! test
13800 Templates: Parameters substituted at the top-level
13801 !! wikitext
13802 {{{foo|''who'' {{echo|me}}? '''never!'''}}}
13803
13804 {{{foo|bar|baz}}}
13805 !! html/php
13806 <p><i>who</i> me? <b>never!</b>
13807 </p><p>bar
13808 </p>
13809 !! html/parsoid
13810 <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>
13811
13812 <p about="#mwt3" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"foo"},"params":{"1":{"wt":"bar"},"2":{"wt":"baz"}},"i":0}}]}'>bar</p>
13813 !! end
13814
13815 !! test
13816 Templates: Param with empty arg in the final position
13817 !! wikitext
13818 {{{hi|}}}
13819 !! html/parsoid
13820 <span about="#mwt1" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"hi"},"params":{"1":{"wt":""}},"i":0}}]}'></span>
13821 !! end
13822
13823 !!test
13824 Parser Functions: 1. Simple example
13825 !! wikitext
13826 {{uc:foo}}
13827 !! html
13828 <p>FOO
13829 </p>
13830 !!end
13831
13832 !!test
13833 Parser Functions: 2. Nested use (only outermost should be marked up)
13834 !! wikitext
13835 {{uc:{{lc:FOO}}}}
13836 !! html
13837 <p>FOO
13838 </p>
13839 !!end
13840
13841 ## Note that the templates inside the references are not wrapped
13842 !! test
13843 Template nested in extension tag in template
13844 !! options
13845 title=[[Main Page]]
13846 language=zh
13847 !! wikitext
13848 {{echo|hi<ref>[[ho|{{echo|hi}}]]</ref>}}
13849 {{echo|hi<ref>[http://test.com?q={{echo|ho}}]</ref>}}
13850 {{echo|hi<ref>-{ho|{{echo|hi}}}-</ref>}}
13851 <references />
13852 !! html/parsoid
13853 <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>
13854 <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>
13855 <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>
13856 <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>
13857 !! end
13858
13859 ###
13860 ### Pre-save transform tests
13861 ###
13862
13863 !! test
13864 pre-save transform: subst:
13865 !! options
13866 pst
13867 !! wikitext
13868 {{subst:test}}
13869 !! html/php
13870 This is a test template
13871 !! end
13872
13873 !! test
13874 pre-save transform: normal template
13875 !! options
13876 pst
13877 !! wikitext
13878 {{test}}
13879 !! html/php
13880 {{test}}
13881 !! end
13882
13883 !! test
13884 pre-save transform: nonexistent template
13885 !! options
13886 pst
13887 !! wikitext
13888 {{thistemplatedoesnotexist}}
13889 !! html/php
13890 {{thistemplatedoesnotexist}}
13891 !! end
13892
13893 !! test
13894 pre-save transform: subst magic variables
13895 !! options
13896 pst
13897 !! wikitext
13898 {{subst:SITENAME}}
13899 !! html/php
13900 MediaWiki
13901 !! end
13902
13903 # This is T2089, which I fixed. -- wtm
13904 !! test
13905 pre-save transform: subst: templates with parameters
13906 !! options
13907 pst
13908 !! wikitext
13909 {{subst:paramtest|param="something else"}}
13910 !! html/php
13911 This is a test template with parameter "something else"
13912 !! end
13913
13914 !! article
13915 Template:nowikitest
13916 !! text
13917 <nowiki>'''not wiki'''</nowiki>
13918 !! endarticle
13919
13920 !! test
13921 pre-save transform: nowiki in subst (T3188)
13922 !! options
13923 pst
13924 !! wikitext
13925 {{subst:nowikitest}}
13926 !! html/php
13927 <nowiki>'''not wiki'''</nowiki>
13928 !! end
13929
13930 !! article
13931 Template:commenttest
13932 !! text
13933 This template has <!-- a comment --> in it.
13934 !! endarticle
13935
13936 !! test
13937 pre-save transform: comment in subst (T3936)
13938 !! options
13939 pst
13940 !! wikitext
13941 {{subst:commenttest}}
13942 !! html/php
13943 This template has <!-- a comment --> in it.
13944 !! end
13945
13946 !! test
13947 pre-save transform: unclosed tag
13948 !! options
13949 pst
13950 !! wikitext
13951 <nowiki>'''not wiki'''
13952 !! html/php
13953 <nowiki>'''not wiki'''
13954 !! end
13955
13956 !! test
13957 pre-save transform: mixed tag case
13958 !! options
13959 pst
13960 !! wikitext
13961 <NOwiki>'''not wiki'''</noWIKI>
13962 !! html/php
13963 <NOwiki>'''not wiki'''</noWIKI>
13964 !! end
13965
13966 !! test
13967 pre-save transform: unclosed comment in <nowiki>
13968 !! options
13969 pst
13970 !! wikitext
13971 wiki<nowiki>nowiki<!--nowiki</nowiki>wiki
13972 !! html/php
13973 wiki<nowiki>nowiki<!--nowiki</nowiki>wiki
13974 !!end
13975
13976 # Leading @ in this template definition works around a limitation
13977 # in parsoid's parserTests which otherwise strips the <span> from the
13978 # result (confusing it for a template wrapper)
13979 !! article
13980 Template:dangerous
13981 !!text
13982 @<span onmouseover="alert('crap')">Oh no</span>
13983 !!endarticle
13984
13985 !!test
13986 (confirming safety of fix for subst T3936)
13987 !! wikitext
13988 {{Template:dangerous}}
13989 !! html
13990 <p>@<span>Oh no</span>
13991 </p>
13992 !! end
13993
13994 !! test
13995 pre-save transform: comment containing gallery (T7024)
13996 !! options
13997 pst
13998 !! wikitext
13999 <!-- <gallery>data</gallery> -->
14000 !! html/php
14001 <!-- <gallery>data</gallery> -->
14002 !!end
14003
14004 !! test
14005 pre-save transform: comment containing extension
14006 !! options
14007 pst
14008 !! wikitext
14009 <!-- <tag>data</tag> -->
14010 !! html/php
14011 <!-- <tag>data</tag> -->
14012 !!end
14013
14014 !! test
14015 pre-save transform: comment containing nowiki
14016 !! options
14017 pst
14018 !! wikitext
14019 <!-- <nowiki>data</nowiki> -->
14020 !! html/php
14021 <!-- <nowiki>data</nowiki> -->
14022 !!end
14023
14024 !! test
14025 pre-save transform: <noinclude> in subst (T5298)
14026 !! options
14027 pst
14028 !! wikitext
14029 {{subst:Includes}}
14030 !! html/php
14031 Foobar
14032 !! end
14033
14034 !! test
14035 pre-save transform: <onlyinclude> in subst (T5298)
14036 !! options
14037 pst
14038 !! wikitext
14039 {{subst:Includes2}}
14040 !! html/php
14041 Foo
14042 !! end
14043
14044 !! article
14045 Template:SubstTest
14046 !!text
14047 {{<includeonly>subst:</includeonly>Includes}}
14048 !! endarticle
14049
14050 !! article
14051 Template:SafeSubstTest
14052 !! text
14053 {{<includeonly>safesubst:</includeonly>Includes}}
14054 !! endarticle
14055
14056 !! test
14057 T24297: safesubst: works during PST
14058 !! options
14059 pst
14060 !! wikitext
14061 {{subst:SafeSubstTest}}{{safesubst:SubstTest}}
14062 !! html/php
14063 FoobarFoobar
14064 !! end
14065
14066 !! test
14067 T24297: safesubst: works during normal parse
14068 !! wikitext
14069 {{SafeSubstTest}}
14070 !! html
14071 <p>Foobar
14072 </p>
14073 !! end
14074
14075 !! test
14076 subst: does not work during normal parse
14077 !! wikitext
14078 {{SubstTest}}
14079 !! html
14080 <p>{{subst:Includes}}
14081 </p>
14082 !! end
14083
14084 !! test
14085 pre-save transform: context links ("pipe trick")
14086 !! options
14087 pst
14088 !! wikitext
14089 [[Article (context)|]]
14090 [[Bar:Article|]]
14091 [[:Bar:Article|]]
14092 [[Bar:Article (context)|]]
14093 [[:Bar:Article (context)|]]
14094 [[|Article]]
14095 [[|Article (context)]]
14096 [[Bar:X (Y) Z|]]
14097 [[:Bar:X (Y) Z|]]
14098 !! html/php
14099 [[Article (context)|Article]]
14100 [[Bar:Article|Article]]
14101 [[:Bar:Article|Article]]
14102 [[Bar:Article (context)|Article]]
14103 [[:Bar:Article (context)|Article]]
14104 [[Article]]
14105 [[Article (context)]]
14106 [[Bar:X (Y) Z|X (Y) Z]]
14107 [[:Bar:X (Y) Z|X (Y) Z]]
14108 !! end
14109
14110 !! test
14111 pre-save transform: context links ("pipe trick") with interwiki prefix
14112 !! options
14113 pst
14114 !! wikitext
14115 [[interwiki:Article|]]
14116 [[:interwiki:Article|]]
14117 [[interwiki:Bar:Article|]]
14118 [[:interwiki:Bar:Article|]]
14119 !! html/php
14120 [[interwiki:Article|Article]]
14121 [[:interwiki:Article|Article]]
14122 [[interwiki:Bar:Article|Bar:Article]]
14123 [[:interwiki:Bar:Article|Bar:Article]]
14124 !! end
14125
14126 !! test
14127 pre-save transform: context links ("pipe trick") with parens in title
14128 !! options
14129 pst title=[[Somearticle (context)]]
14130 !! wikitext
14131 [[|Article]]
14132 !! html/php
14133 [[Article (context)|Article]]
14134 !! end
14135
14136 !! test
14137 pre-save transform: context links ("pipe trick") with comma in title
14138 !! options
14139 pst title=[[Someplace, Somewhere]]
14140 !! wikitext
14141 [[|Otherplace]]
14142 [[Otherplace, Elsewhere|]]
14143 [[Otherplace, Elsewhere, Anywhere|]]
14144 !! html/php
14145 [[Otherplace, Somewhere|Otherplace]]
14146 [[Otherplace, Elsewhere|Otherplace]]
14147 [[Otherplace, Elsewhere, Anywhere|Otherplace]]
14148 !! end
14149
14150 !! test
14151 pre-save transform: context links ("pipe trick") with parens and comma
14152 !! options
14153 pst title=[[Someplace (IGNORED), Somewhere]]
14154 !! wikitext
14155 [[|Otherplace]]
14156 [[Otherplace (place), Elsewhere|]]
14157 !! html/php
14158 [[Otherplace, Somewhere|Otherplace]]
14159 [[Otherplace (place), Elsewhere|Otherplace]]
14160 !! end
14161
14162 !! test
14163 pre-save transform: context links ("pipe trick") with comma and parens
14164 !! options
14165 pst title=[[Who, me? (context)]]
14166 !! wikitext
14167 [[|Yes, you.]]
14168 [[Me, Myself, and I (1937 song)|]]
14169 !! html/php
14170 [[Yes, you. (context)|Yes, you.]]
14171 [[Me, Myself, and I (1937 song)|Me, Myself, and I]]
14172 !! end
14173
14174 !! test
14175 pre-save transform: context links ("pipe trick") with namespace
14176 !! options
14177 pst title=[[Ns:Somearticle]]
14178 !! wikitext
14179 [[|Article]]
14180 !! html/php
14181 [[Ns:Article|Article]]
14182 !! end
14183
14184 !! test
14185 pre-save transform: context links ("pipe trick") with namespace and parens
14186 !! options
14187 pst title=[[Ns:Somearticle (context)]]
14188 !! wikitext
14189 [[|Article]]
14190 !! html/php
14191 [[Ns:Article (context)|Article]]
14192 !! end
14193
14194 !! test
14195 pre-save transform: context links ("pipe trick") with namespace and comma
14196 !! options
14197 pst title=[[Ns:Somearticle, Context, Whatever]]
14198 !! wikitext
14199 [[|Article]]
14200 !! html/php
14201 [[Ns:Article, Context, Whatever|Article]]
14202 !! end
14203
14204 !! test
14205 pre-save transform: context links ("pipe trick") with namespace, comma and parens
14206 !! options
14207 pst title=[[Ns:Somearticle, Context (context)]]
14208 !! wikitext
14209 [[|Article]]
14210 !! html/php
14211 [[Ns:Article (context)|Article]]
14212 !! end
14213
14214 !! test
14215 pre-save transform: context links ("pipe trick") with namespace, parens and comma
14216 !! options
14217 pst title=[[Ns:Somearticle (IGNORED), Context]]
14218 !! wikitext
14219 [[|Article]]
14220 !! html/php
14221 [[Ns:Article, Context|Article]]
14222 !! end
14223
14224 !! test
14225 pre-save transform: context links ("pipe trick") with full-width parens and no space (Japanese and Chinese style, T32149)
14226 !! options
14227 pst
14228 !! wikitext
14229 [[Article(context)|]]
14230 [[Bar:Article(context)|]]
14231 [[:Bar:Article(context)|]]
14232 [[|Article(context)]]
14233 [[Bar:X(Y)Z|]]
14234 [[:Bar:X(Y)Z|]]
14235 !! html/php
14236 [[Article(context)|Article]]
14237 [[Bar:Article(context)|Article]]
14238 [[:Bar:Article(context)|Article]]
14239 [[Article(context)]]
14240 [[Bar:X(Y)Z|X(Y)Z]]
14241 [[:Bar:X(Y)Z|X(Y)Z]]
14242 !! end
14243
14244 !! test
14245 pre-save transform: context links ("pipe trick") with full-width parens and space (Japanese and Chinese style, T32149)
14246 !! options
14247 pst
14248 !! wikitext
14249 [[Article (context)|]]
14250 [[Bar:Article (context)|]]
14251 [[:Bar:Article (context)|]]
14252 [[|Article (context)]]
14253 [[Bar:X (Y) Z|]]
14254 [[:Bar:X (Y) Z|]]
14255 !! html/php
14256 [[Article (context)|Article]]
14257 [[Bar:Article (context)|Article]]
14258 [[:Bar:Article (context)|Article]]
14259 [[Article (context)]]
14260 [[Bar:X (Y) Z|X (Y) Z]]
14261 [[:Bar:X (Y) Z|X (Y) Z]]
14262 !! end
14263
14264 !! test
14265 pre-save transform: context links ("pipe trick") with parens and no space (Korean style, T32149)
14266 !! options
14267 pst
14268 !! wikitext
14269 [[Article(context)|]]
14270 [[Bar:Article(context)|]]
14271 [[:Bar:Article(context)|]]
14272 [[|Article(context)]]
14273 [[Bar:X(Y)Z|]]
14274 [[:Bar:X(Y)Z|]]
14275 !! html/php
14276 [[Article(context)|Article]]
14277 [[Bar:Article(context)|Article]]
14278 [[:Bar:Article(context)|Article]]
14279 [[Article(context)]]
14280 [[Bar:X(Y)Z|X(Y)Z]]
14281 [[:Bar:X(Y)Z|X(Y)Z]]
14282 !! end
14283
14284 !! test
14285 pre-save transform: context links ("pipe trick") with commas (T23660)
14286 !! options
14287 pst
14288 !! wikitext
14289 [[Article (context), context|]]
14290 [[Article (context),context|]]
14291 [[Bar:Article (context), context|]]
14292 [[Bar:Article (context),context|]]
14293 [[:Bar:Article (context), context|]]
14294 [[:Bar:Article (context),context|]]
14295 !! html/php
14296 [[Article (context), context|Article]]
14297 [[Article (context),context|Article]]
14298 [[Bar:Article (context), context|Article]]
14299 [[Bar:Article (context),context|Article]]
14300 [[:Bar:Article (context), context|Article]]
14301 [[:Bar:Article (context),context|Article]]
14302 !! end
14303
14304 !! test
14305 Parsoid: backwards pipe trick
14306 !! wikitext
14307 [[|'''bar''']]
14308 !! html/php
14309 <p>[[|<b>bar</b>]]
14310 </p>
14311 !! html/parsoid
14312 <p>[[|<b>bar</b>]]</p>
14313 !! end
14314
14315 !! test
14316 pre-save transform: trim trailing empty lines
14317 !! options
14318 pst
14319 !! wikitext
14320 Empty lines are trimmed
14321
14322
14323
14324
14325 !! html/php
14326 Empty lines are trimmed
14327 !! end
14328
14329 !! test
14330 pre-save transform: Signature expansion
14331 !! options
14332 pst
14333 !! wikitext
14334 * ~~~
14335 * ~~~~
14336 * ~~~~~
14337 * <noinclude>~~~</noinclude>
14338 * <includeonly>~~~</includeonly>
14339 * <onlyinclude>~~~</onlyinclude>
14340 !! html/php
14341 * [[Special:Contributions/127.0.0.1|127.0.0.1]]
14342 * [[Special:Contributions/127.0.0.1|127.0.0.1]] 00:02, 1 January 1970 (UTC)
14343 * 00:02, 1 January 1970 (UTC)
14344 * <noinclude>[[Special:Contributions/127.0.0.1|127.0.0.1]]</noinclude>
14345 * <includeonly>[[Special:Contributions/127.0.0.1|127.0.0.1]]</includeonly>
14346 * <onlyinclude>[[Special:Contributions/127.0.0.1|127.0.0.1]]</onlyinclude>
14347 !! end
14348
14349
14350 !! test
14351 ParserOutput flags from signature expansion (T84843)
14352 !! options
14353 pst
14354 showflags
14355 !! wikitext
14356 ~~~~
14357 !! html/php
14358 [[Special:Contributions/127.0.0.1|127.0.0.1]] 00:02, 1 January 1970 (UTC)
14359 flags=user-signature
14360 !! end
14361
14362
14363 !! test
14364 pre-save transform: Signature expansion in nowiki tags (T2093)
14365 !! options
14366 pst disabled
14367 !! wikitext
14368 Shall not expand:
14369
14370 <nowiki>~~~~</nowiki>
14371
14372 <includeonly><nowiki>~~~~</nowiki></includeonly>
14373
14374 <noinclude><nowiki>~~~~</nowiki></noinclude>
14375
14376 <onlyinclude><nowiki>~~~~</nowiki></onlyinclude>
14377
14378 {{subst:Foo}} shall be converted to FOO
14379
14380 As well as inside noinclude/onlyinclude
14381 <noinclude>{{subst:Foo}}</noinclude>
14382 <onlyinclude>{{subst:Foo}}</onlyinclude>
14383
14384 But not inside includeonly
14385 <includeonly>{{subst:Foo}}</includeonly>
14386 !! html/php
14387 Shall not expand:
14388
14389 <nowiki>~~~~</nowiki>
14390
14391 <includeonly><nowiki>~~~~</nowiki></includeonly>
14392
14393 <noinclude><nowiki>~~~~</nowiki></noinclude>
14394
14395 <onlyinclude><nowiki>~~~~</nowiki></onlyinclude>
14396
14397 FOO shall be converted to FOO
14398
14399 As well as inside noinclude/onlyinclude
14400 <noinclude>FOO</noinclude>
14401 <onlyinclude>FOO</onlyinclude>
14402
14403 But not inside includeonly
14404 <includeonly>{{subst:Foo}}</includeonly>
14405 !! end
14406
14407 !! test
14408 Parsoid: Recognize nowiki with trailing space in tags
14409 !! options
14410 parsoid=wt2html
14411 !! wikitext
14412 <nowiki ><div>[[foo]]</nowiki >
14413
14414 a<nowiki / >b
14415
14416 c<nowiki />d
14417
14418 e<nowiki/ >f
14419 !! html/php+tidy
14420 <p>&lt;div&gt;[[foo]]
14421 </p><p>a&lt;nowiki / &gt;b
14422 </p><p>cd
14423 </p><p>e&lt;nowiki/ &gt;f
14424 </p>
14425 !! html/parsoid
14426 <p><span typeof="mw:Nowiki">&lt;div>[[foo]]</span></p>
14427
14428 <p>a&lt;nowiki / >b</p>
14429
14430 <p>c<span typeof="mw:Nowiki"></span>d</p>
14431
14432 <p>e&lt;nowiki/ >f</p>
14433 !! end
14434
14435 !! test
14436 Parsoid: Recognize nowiki with odd capitalization
14437 !! options
14438 parsoid=wt2html
14439 !! wikitext
14440 <noWikI ><div>[[foo]]</Nowiki >
14441 !! html/php+tidy
14442 <p>&lt;div&gt;[[foo]]
14443 </p>
14444 !! html/parsoid
14445 <p><span typeof="mw:Nowiki">&lt;div&gt;[[foo]]</span></p>
14446 !! end
14447
14448
14449 !! test
14450 Parsoid: Escape nowiki with trailing space in tags
14451 !! options
14452 parsoid=html2wt
14453 !! html/parsoid
14454 <p>&lt;nowiki &gt; foo &lt/nowiki ></p>
14455 <p>a&lt;nowiki /&gt;b</p>
14456 <p>c&lt;nowiki/ &gt;d</p>
14457 !! wikitext
14458 &lt;nowiki &gt; foo &lt;/nowiki &gt;
14459
14460 a&lt;nowiki /&gt;b
14461
14462 c&lt;nowiki/ &gt;d
14463 !! end
14464
14465 !! test
14466 Parsoid: Escape weird noWikI capitalizations
14467 !! options
14468 parsoid=html2wt
14469 !! html/parsoid
14470 <p>&lt;noWikI &gt; foo &lt/NoWikI ></p>
14471 !! wikitext
14472 &lt;noWikI &gt; foo &lt;/NoWikI &gt;
14473 !! end
14474
14475 ###
14476 ### Message transform tests
14477 ###
14478 !! test
14479 message transform: magic variables
14480 !! options
14481 msg
14482 !! wikitext
14483 {{SITENAME}}
14484 !! html
14485 MediaWiki
14486 !! end
14487
14488 !! test
14489 message transform: should not transform wiki markup
14490 !! options
14491 msg
14492 !! wikitext
14493 ''test''
14494 !! html
14495 ''test''
14496 !! end
14497
14498 !! test
14499 message transform: <noinclude> in transcluded template (T6926)
14500 !! options
14501 msg
14502 !! wikitext
14503 {{Includes}}
14504 !! html
14505 Foobar
14506 !! end
14507
14508 !! test
14509 message transform: <onlyinclude> in transcluded template (T6926)
14510 !! options
14511 msg
14512 !! wikitext
14513 {{Includes2}}
14514 !! html
14515 Foo
14516 !! end
14517
14518 !! test
14519 {{#special:}} page name, known
14520 !! options
14521 msg
14522 !! wikitext
14523 {{#special:Recentchanges}}
14524 !! html
14525 Special:RecentChanges
14526 !! end
14527
14528 !! test
14529 {{#special:}} page name with subpage, known
14530 !! options
14531 msg
14532 !! wikitext
14533 {{#special:Recentchanges/param}}
14534 !! html
14535 Special:RecentChanges/param
14536 !! end
14537
14538 !! test
14539 {{#special:}} page name, unknown
14540 !! options
14541 msg
14542 !! wikitext
14543 {{#special:foobar nonexistent}}
14544 !! html
14545 Special:Foobar nonexistent
14546 !! end
14547
14548 !! test
14549 {{#speciale:}} page name, known
14550 !! options
14551 msg
14552 !! wikitext
14553 {{#speciale:Recentchanges}}
14554 !! html
14555 Special:RecentChanges
14556 !! end
14557
14558 !! test
14559 {{#speciale:}} page name with subpage, known
14560 !! options
14561 msg
14562 !! wikitext
14563 {{#speciale:Recentchanges/param}}
14564 !! html
14565 Special:RecentChanges/param
14566 !! end
14567
14568 !! test
14569 {{#speciale:}} page name, unknown
14570 !! options
14571 msg
14572 !! wikitext
14573 {{#speciale:foobar nonexistent}}
14574 !! html
14575 Special:Foobar_nonexistent
14576 !! end
14577
14578 ###
14579 ### Images
14580 ###
14581 ### For Parsoid-specific tests, see
14582 #### https://www.mediawiki.org/wiki/Parsoid/MediaWiki_DOM_spec#Images
14583
14584 !! test
14585 Simple image
14586 !! options
14587 parsoid=wt2html,wt2wt,html2html
14588 !! wikitext
14589 [[Image:foobar.jpg]]
14590 !! html/php
14591 <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>
14592 </p>
14593 !! html/parsoid
14594 <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>
14595 !! end
14596
14597 !! test
14598 Serialize simple image with span wrapper
14599 !! options
14600 parsoid=html2wt
14601 !! html/parsoid
14602 <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>
14603 !! wikitext
14604 [[File:Foobar.jpg]]
14605 !! end
14606
14607 !! test
14608 Simple image (using File: namespace, now canonical)
14609 !! wikitext
14610 [[File:Foobar.jpg]]
14611 !! html/php
14612 <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>
14613 </p>
14614 !! html/parsoid
14615 <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>
14616 !! end
14617
14618 !! test
14619 Right-aligned image
14620 !! wikitext
14621 [[File:Foobar.jpg|right]]
14622 !! html/php
14623 <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>
14624
14625 !! html/parsoid
14626 <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>
14627 !! end
14628
14629 !! test
14630 Image with caption
14631 !! wikitext
14632 [[File:Foobar.jpg|right|Caption text]]
14633 !! html/php
14634 <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>
14635
14636 !! html/parsoid
14637 <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>
14638 !! end
14639
14640 !! test
14641 Image with caption, T55312 #1
14642 !! wikitext
14643 [[File:Foobar.jpg|right|Caption page stuff]]
14644 !! html/php
14645 <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>
14646
14647 !! html/parsoid
14648 <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>
14649 !! end
14650
14651 !! test
14652 Image with caption, T55312 #2
14653 !! wikitext
14654 [[File:Foobar.jpg|right|Caption page=]]
14655 !! html/php
14656 <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>
14657
14658 !! html/parsoid
14659 <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>
14660 !! end
14661
14662 !! test
14663 Image with caption, T55312 #3
14664 !! wikitext
14665 [[File:Foobar.jpg|right|Caption page=stuff]]
14666 !! html/php
14667 <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>
14668
14669 !! html/parsoid
14670 <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>
14671 !! end
14672
14673 !! test
14674 Image caption with pipe entity
14675 !! wikitext
14676 [[File:Foobar.jpg|thumb|one &#x7C; two]]
14677 [[File:Foobar.jpg|thumb|one ''two'' &#x7C; three]]
14678 !! html/php
14679 <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>
14680 <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>
14681
14682 !! html/parsoid
14683 <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>
14684 <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>
14685 !! end
14686
14687 !! test
14688 Allow empty links in image captions (T62753)
14689 !! options
14690 thumbsize=220
14691 !! wikitext
14692 [[File:Foobar.jpg|thumb|Caption [[Link1]]
14693 [[]]
14694 [[Link2]]
14695 ]]
14696 !! html/php
14697 <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>
14698
14699 !! html/parsoid
14700 <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>
14701 [[]]
14702 <a rel="mw:WikiLink" href="./Link2" title="Link2" data-parsoid='{"stx":"simple","a":{"href":"./Link2"},"sa":{"href":"Link2"}}'>Link2</a>
14703 </figcaption></figure>
14704 !! end
14705
14706 !! test
14707 Titles in unlinked images (T23454)
14708 !! wikitext
14709 [[File:Foobar.jpg|link=|stuff]]
14710 !! html/php
14711 <p><img alt="stuff" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" title="stuff" width="1941" height="220" />
14712 </p>
14713 !! html/parsoid
14714 <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>
14715 !! end
14716
14717 !! test
14718 Link with empty target
14719 !! wikitext
14720 [[]]
14721 !! html
14722 <p>[[]]
14723 </p>
14724 !! end
14725
14726 !! test
14727 Image with link trail
14728 !! wikitext
14729 Linktrails should not work for images: [[File:Foobar.jpg]]s
14730 !! html/php
14731 <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
14732 </p>
14733 !! html/parsoid
14734 <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>
14735 !! end
14736
14737 !! test
14738 Image with empty attribute
14739 !! options
14740 parsoid=wt2html,wt2wt,html2html
14741 !! wikitext
14742 [[File:Foobar.jpg|right||Caption text]]
14743 !! html/php
14744 <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>
14745
14746 !! html/parsoid
14747 <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>
14748 !! end
14749
14750 !! test
14751 1. Block image with individual attributes from templates
14752 !! wikitext
14753 [[File:Foobar.jpg|thumb|{{echo|137px}}|This is a caption]]
14754 !! html/php
14755 <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>
14756
14757 !! html/parsoid
14758 <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>
14759 !! end
14760
14761 !! test
14762 2. Block Image with individual attributes from templates
14763 !! wikitext
14764 [[File:Foobar.jpg|{{echo|thumb}}|{{echo|137px}}|This is a caption]]
14765 !! html/php
14766 <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>
14767
14768 !! html/parsoid
14769 <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>
14770 !! end
14771
14772 !! test
14773 3. Inline image with individual attributes from templates
14774 !! wikitext
14775 [[File:Foobar.jpg|{{echo|50px}}]]
14776 !! html/php
14777 <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>
14778 </p>
14779 !! html/parsoid
14780 <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>
14781 !! end
14782
14783 ## Parsoid does not provide editing support for images where templates produce multiple image attributes.
14784 ## To signal this, we add a 'mw:Placeholder' type to such images. This could change in the future.
14785 !! test
14786 Image with multiple attributes from the same template
14787 !! wikitext
14788 [[File:Foobar.jpg|{{image_attribs}}]]
14789 !! html/php
14790 <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>
14791
14792 !! html/parsoid
14793 <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>
14794 !! end
14795
14796 !! test
14797 Image with link tails
14798 !! options
14799 thumbsize=220
14800 !! wikitext
14801 123[[File:Foobar.jpg]]456
14802 123[[File:Foobar.jpg|right]]456
14803 123[[File:Foobar.jpg|thumb]]456
14804 !! html/php
14805 <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
14806 </p>
14807 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
14808 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
14809
14810 !! html/php+tidy
14811 <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
14812 </p><p>
14813 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
14814 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
14815 </p>
14816 !! html/parsoid
14817 <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>
14818 <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
14819 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>
14820 !! end
14821
14822 !! test
14823 Image with multiple captions -- only last one is accepted
14824 !! wikitext
14825 [[File:Foobar.jpg|right|Caption1 - ignored|[[Caption2]] - ignored|Caption3 - accepted]]
14826 !! html/php
14827 <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>
14828
14829 !! html/parsoid
14830 <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>
14831 !! end
14832
14833 !! test
14834 Image with multiple widths -- use last
14835 !! wikitext
14836 [[File:Foobar.jpg|200px|300px|caption]]
14837 !! html/php
14838 <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>
14839 </p>
14840 !! html/parsoid
14841 <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>
14842 !! end
14843
14844 !! test
14845 Image with multiple alignments -- use first (T50664)
14846 !! options
14847 thumbsize=220
14848 !! wikitext
14849 [[File:Foobar.jpg|thumb|left|right|center|caption]]
14850
14851 [[File:Foobar.jpg|middle|text-top|caption]]
14852 !! html/php
14853 <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>
14854 <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>
14855 </p>
14856 !! html/parsoid
14857 <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>
14858 <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>
14859 !! end
14860
14861 !! test
14862 Image with width attribute at different positions
14863 !! wikitext
14864 [[File:Foobar.jpg|200px|right|Caption]]
14865 [[File:Foobar.jpg|right|200px|Caption]]
14866 [[File:Foobar.jpg|right|Caption|200px]]
14867 !! html/php
14868 <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>
14869 <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>
14870 <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>
14871
14872 !! html/parsoid
14873 <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>
14874 <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>
14875 <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>
14876 !! end
14877
14878 # a sad bit of backward-compatibility
14879 !! test
14880 Image with size specified with pxpx (T15500, T53628)
14881 !! options
14882 parsoid=wt2html,wt2wt,html2html
14883 !! wikitext
14884 [[File:Foobar.jpg|20pxpx]]
14885 [[File:Foobar.jpg|200x20pxpx]]
14886 !! html/php
14887 <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>
14888 <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>
14889 </p>
14890 !! html/parsoid
14891 <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>
14892 !! end
14893
14894 !! test
14895 Image with link parameter, wiki target
14896 !! wikitext
14897 [[File:Foobar.jpg|link=Main Page]]
14898 !! html/php
14899 <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>
14900 </p>
14901 !! html/parsoid
14902 <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>
14903 !! end
14904
14905 # parsoid T51293 (part 1)
14906 !! test
14907 Image with link parameter, URL target
14908 !! wikitext
14909 [[File:Foobar.jpg|link=http://example.com/]]
14910 !! html/php
14911 <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>
14912 </p>
14913 !! html/parsoid
14914 <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>
14915 !! end
14916
14917 # parsoid T51293 (part 2)
14918 !! test
14919 Image with link parameter, protocol-less URL target
14920 !! wikitext
14921 [[File:Foobar.jpg|link=//example.com/]]
14922 !! html/php
14923 <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>
14924 </p>
14925 !! html/parsoid
14926 <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>
14927 !! end
14928
14929 !! test
14930 Escaping non-block captions (T107435)
14931 !! options
14932 parsoid={
14933 "modes": ["wt2wt"],
14934 "changes": [
14935 ["[typeof~='mw:Image']", "attr", "data-mw", "{\"caption\": \"|\"}"]
14936 ]
14937 }
14938 !! wikitext
14939 [[Image:Foobar.jpg|caption]]
14940 !! wikitext/edited
14941 [[Image:Foobar.jpg|<nowiki>|</nowiki>]]
14942 !! end
14943
14944 # wgExternalLinkTarget not supported by Parsoid
14945 !! test
14946 Image with link parameter, wgExternalLinkTarget
14947 !! wikitext
14948 [[Image:foobar.jpg|link=http://example.com/]]
14949 !! config
14950 wgExternalLinkTarget='foobar'
14951 !! html/php
14952 <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>
14953 </p>
14954 !! end
14955
14956 !! test
14957 Image with link parameter, wgNoFollowLinks set to false
14958 !! wikitext
14959 [[Image:foobar.jpg|link=http://example.com/]]
14960 !! config
14961 wgNoFollowLinks=false
14962 !! html/php
14963 <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>
14964 </p>
14965 !! end
14966
14967 !! test
14968 Image with link parameter, wgNoFollowDomainExceptions
14969 !! wikitext
14970 [[Image:foobar.jpg|link=http://example.com/]]
14971 !! config
14972 wgNoFollowDomainExceptions='example.com'
14973 !! html/php
14974 <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>
14975 </p>
14976 !! end
14977
14978 # wgExternalLinkTarget not supported by Parsoid
14979 !! test
14980 Image with link parameter, wgExternalLinkTarget, unnamed parameter
14981 !! wikitext
14982 [[Image:foobar.jpg|link=http://example.com/|Title]]
14983 !! config
14984 wgExternalLinkTarget='foobar'
14985 !! html/php
14986 <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>
14987 </p>
14988 !! end
14989
14990 !! test
14991 Image with empty link parameter
14992 !! wikitext
14993 [[File:Foobar.jpg|link=]]
14994 !! html/php
14995 <p><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" />
14996 </p>
14997 !! html/parsoid
14998 <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>
14999 !! end
15000
15001 !! test
15002 Image with link parameter (wiki target) and unnamed parameter
15003 !! wikitext
15004 [[File:Foobar.jpg|link=Main_Page|Title]]
15005 !! html/php
15006 <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>
15007 </p>
15008 !! html/parsoid
15009 <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>
15010 !! end
15011
15012 !! test
15013 Image with link parameter (URL target) and unnamed parameter
15014 !! wikitext
15015 [[File:Foobar.jpg|link=http://example.com/|Title]]
15016 !! html/php
15017 <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>
15018 </p>
15019 !! html/parsoid
15020 <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>
15021 !! end
15022
15023 !! test
15024 Thumbnail image with link parameter
15025 !! options
15026 thumbsize=220
15027 parsoid=wt2html,wt2wt,html2html
15028 !! wikitext
15029 [[File:Foobar.jpg|thumb|link=http://example.com/|Title]]
15030 !! html/php
15031 <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>
15032
15033 !! html/parsoid
15034 <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>
15035 !! end
15036
15037 !! test
15038 Manually-specified thumbnail image
15039 !! options
15040 thumbsize=220
15041 !! wikitext
15042 [[File:Foobar.jpg|thumbnail=Thumb.png|Title]]
15043 !! html/php
15044 <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>
15045
15046 !! html/parsoid
15047 <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>
15048 !! end
15049
15050 !! test
15051 Manually-specified thumbnail image with explicit link to wiki page
15052 !! options
15053 thumbsize=220
15054 parsoid=wt2html,wt2wt,html2html
15055 !! wikitext
15056 [[File:Foobar.jpg|thumb=Thumb.png|link=Main_Page|Title]]
15057 !! html/php
15058 <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>
15059
15060 !! html/parsoid
15061 <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>
15062 !! end
15063
15064 !! test
15065 Manually-specified thumbnail image with explicit link to url
15066 !! options
15067 thumbsize=220
15068 parsoid=wt2html,wt2wt,html2html
15069 !! wikitext
15070 [[File:Foobar.jpg|thumb=Thumb.png|link=http://example.com|Title]]
15071 !! html/php
15072 <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>
15073
15074 !! html/parsoid
15075 <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>
15076 !! end
15077
15078 !! test
15079 Manually-specified thumbnail image with explicit no link
15080 !! options
15081 thumbsize=220
15082 parsoid=wt2html,wt2wt,html2html
15083 !! wikitext
15084 [[File:Foobar.jpg|thumb=Thumb.png|link=|Title]]
15085 !! html/php
15086 <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>
15087
15088 !! html/parsoid
15089 <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>
15090 !! end
15091
15092 !! test
15093 Manually-specified thumbnail image with explicit link and alt text
15094 !! options
15095 thumbsize=220
15096 parsoid=wt2html,wt2wt,html2html
15097 !! wikitext
15098 [[File:Foobar.jpg|thumb=Thumb.png|link=Main_Page|alt=alttext|Title]]
15099 !! html/php
15100 <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>
15101
15102 !! html/parsoid
15103 <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>
15104 !! end
15105
15106 !! test
15107 Image with frame and link
15108 !! options
15109 parsoid=wt2html,wt2wt,html2html
15110 !! wikitext
15111 [[File:Foobar.jpg|frame|left|This is a test image [[Main Page]]]]
15112 !! html/php
15113 <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>
15114
15115 !! html/parsoid
15116 <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>
15117 !! end
15118
15119 !! test
15120 Image with frame and link and explicit alt
15121 !! options
15122 parsoid=wt2html,wt2wt,html2html
15123 !! wikitext
15124 [[Image:Foobar.jpg|frame|left|This is a test image [[Main Page]]|alt=Altitude]]
15125 !! html/php
15126 <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>
15127
15128 !! html/parsoid
15129 <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>
15130 !! end
15131
15132 !! test
15133 Image with wiki markup in implicit alt
15134 !! wikitext
15135 [[Image:Foobar.jpg|testing '''bold''' in alt]]
15136
15137 [[Image:Foobar.jpg|alt=testing '''bold''' in alt]]
15138 !! html/php
15139 <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>
15140 </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>
15141 </p>
15142 !! html/parsoid
15143 <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>
15144
15145 <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>
15146 !! end
15147
15148 !! test
15149 Alt image option should handle most kinds of wikitext without barfing
15150 !! wikitext
15151 [[Image:Foobar.jpg|thumb|This is the image caption|alt=This is a [[link]] and a {{echo|''bold template''}}.]]
15152 !! html/php
15153 <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>
15154
15155 !! html/parsoid
15156 <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>
15157 !! end
15158
15159 !! test
15160 Ampersand in alt attribute (T206940)
15161 !! options
15162 parsoid = {
15163 "nativeGallery": true
15164 }
15165 !! wikitext
15166 [[File:Foobar.jpg|alt=&amp;amp;]]
15167
15168 <!-- consistency with gallery extension -->
15169 <gallery>
15170 File:Foobar.jpg|alt=&amp;amp;
15171 </gallery>
15172 !! html/php+tidy
15173 <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>
15174 </p>
15175 <ul class="gallery mw-gallery-traditional">
15176 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15177 <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>
15178 <div class="gallerytext">
15179 </div>
15180 </div></li>
15181 </ul>
15182 !! html/parsoid
15183 <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>
15184
15185 <!-- consistency with gallery extension -->
15186 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
15187 <li class="gallerybox">
15188 <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>
15189 <div class="gallerytext"></div>
15190 </li>
15191 </ul>
15192 !! end
15193
15194 !! test
15195 Italics markup in alt attribute (T206940)
15196 !! wikitext
15197 [[File:Foobar.jpg|alt=''x''|caption]]
15198
15199 <!-- consistency with gallery extension -->
15200 <gallery>
15201 File:Foobar.jpg|alt=''x''|caption
15202 </gallery>
15203 !! html/php+tidy
15204 <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>
15205 </p>
15206 <ul class="gallery mw-gallery-traditional">
15207 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15208 <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>
15209 <div class="gallerytext">
15210 <p>caption
15211 </p>
15212 </div>
15213 </div></li>
15214 </ul>
15215 !! html/parsoid
15216 <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>
15217
15218 <!-- consistency with gallery extension -->
15219 <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"}}'>
15220 <li class="gallerybox">
15221 <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>
15222 <div class="gallerytext">caption</div>
15223 </li>
15224 </ul>
15225 !! end
15226
15227 !! test
15228 Nowiki markup in alt attribute (T206940)
15229 !! wikitext
15230 [[File:Foobar.jpg|alt=<nowiki>''</nowiki>x<nowiki>''</nowiki>|caption]]
15231
15232 <!-- consistency with gallery extension -->
15233 <gallery>
15234 File:Foobar.jpg|alt=<nowiki>''</nowiki>x<nowiki>''</nowiki>|caption
15235 </gallery>
15236 !! html/php+tidy
15237 <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>
15238 </p>
15239 <ul class="gallery mw-gallery-traditional">
15240 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15241 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="&#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>
15242 <div class="gallerytext">
15243 <p>caption
15244 </p>
15245 </div>
15246 </div></li>
15247 </ul>
15248 !! html/parsoid
15249 <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>
15250
15251 <!-- consistency with gallery extension -->
15252 <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"}}'>
15253 <li class="gallerybox">
15254 <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>
15255 <div class="gallerytext">caption</div>
15256 </li>
15257 </ul>
15258 !! end
15259
15260 !! test
15261 Nowiki markup in alt attribute (edited html, no data-parsoid) (T206940)
15262 !! options
15263 parsoid = {
15264 "nativeGallery": true
15265 }
15266 !! wikitext
15267 [[File:Foobar.jpg|alt=<nowiki>''x''</nowiki>|caption]]
15268
15269 <!-- consistency with gallery extension -->
15270 <gallery>
15271 File:Foobar.jpg|alt=<nowiki>''x''</nowiki>|caption
15272 </gallery>
15273 !! html/php+tidy
15274 <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>
15275 </p>
15276 <ul class="gallery mw-gallery-traditional">
15277 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15278 <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>
15279 <div class="gallerytext">
15280 <p>caption
15281 </p>
15282 </div>
15283 </div></li>
15284 </ul>
15285 !! html/parsoid
15286 <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>
15287
15288 <!-- consistency with gallery extension -->
15289 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
15290 <li class="gallerybox">
15291 <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>
15292 <div class="gallerytext">caption</div>
15293 </li>
15294 </ul>
15295 !! end
15296
15297 !! test
15298 Ampersand in link attribute (T206940)
15299 !! wikitext
15300 [[File:Foobar.jpg|link=Foo &amp; bar]]
15301
15302 <!-- consistency with gallery extension -->
15303 <gallery>
15304 File:Foobar.jpg|link=Foo &amp; bar
15305 </gallery>
15306 !! html/php+tidy
15307 <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>
15308 </p>
15309 <ul class="gallery mw-gallery-traditional">
15310 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15311 <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>
15312 <div class="gallerytext">
15313 </div>
15314 </div></li>
15315 </ul>
15316 !! html/parsoid
15317 <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>
15318
15319 <!-- consistency with gallery extension -->
15320 <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"}}'>
15321 <li class="gallerybox">
15322 <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>
15323 <div class="gallerytext"></div>
15324 </li>
15325 </ul>
15326 !! end
15327
15328 !! test
15329 Ampersand in link attribute (edited html, no data-parsoid) (T206940)
15330 !! options
15331 parsoid = {
15332 "nativeGallery": true
15333 }
15334 !! wikitext
15335 [[File:Foobar.jpg|link=Foo_&_bar]]
15336
15337 <!-- consistency with gallery extension -->
15338 <gallery>
15339 File:Foobar.jpg|link=Foo_&_bar
15340 </gallery>
15341 !! html/php+tidy
15342 <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>
15343 </p>
15344 <ul class="gallery mw-gallery-traditional">
15345 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15346 <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>
15347 <div class="gallerytext">
15348 </div>
15349 </div></li>
15350 </ul>
15351 !! html/parsoid
15352 <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>
15353
15354 <!-- consistency with gallery extension -->
15355 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
15356 <li class="gallerybox">
15357 <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>
15358 <div class="gallerytext"></div>
15359 </li>
15360 </ul>
15361 !! end
15362
15363 !! test
15364 Italics markup in link attribute (T206940)
15365 !! wikitext
15366 [[Foo''s bar''s]]
15367
15368 <!-- Note that "italics" are stripped, even though this is a valid page title -->
15369 [[File:Foobar.jpg|link=Foo''s bar''s|caption1]]
15370
15371 [[File:Foobar.jpg|link=''Main Page''|caption2]]
15372
15373 <!-- consistency with gallery extension -->
15374 <gallery>
15375 File:Foobar.jpg|link=Foo''s bar''s|caption1
15376 File:Foobar.jpg|link=''Main Page''|caption2
15377 </gallery>
15378 !! html/php+tidy
15379 <p><a href="/wiki/Foo%27%27s_bar%27%27s" title="Foo&#39;&#39;s bar&#39;&#39;s">Foo''s bar''s</a>
15380 </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>
15381 </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>
15382 </p>
15383 <ul class="gallery mw-gallery-traditional">
15384 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15385 <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>
15386 <div class="gallerytext">
15387 <p>caption1
15388 </p>
15389 </div>
15390 </div></li>
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/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>
15393 <div class="gallerytext">
15394 <p>caption2
15395 </p>
15396 </div>
15397 </div></li>
15398 </ul>
15399 !! html/parsoid
15400 <p><a rel="mw:WikiLink" href="./Foo''s_bar''s" title="Foo''s bar''s">Foo''s bar''s</a></p>
15401
15402 <!-- Note that "italics" are stripped, even though this is a valid page title -->
15403 <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>
15404
15405 <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>
15406
15407 <!-- consistency with gallery extension -->
15408 <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"}}'>
15409 <li class="gallerybox">
15410 <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>
15411 <div class="gallerytext">caption1</div>
15412 </li>
15413 <li class="gallerybox">
15414 <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>
15415 <div class="gallerytext">caption2</div>
15416 </li>
15417 </ul>
15418 !! end
15419
15420 !! test
15421 Nowiki markup in link attribute (T206940)
15422 !! wikitext
15423 [[File:Foobar.jpg|link=Foo<nowiki>''</nowiki>s_bar<nowiki>''</nowiki>s|caption]]
15424
15425 <!-- consistency with gallery extension -->
15426 <gallery>
15427 File:Foobar.jpg|link=Foo<nowiki>''</nowiki>s_bar<nowiki>''</nowiki>s|caption
15428 </gallery>
15429 !! html/php+tidy
15430 <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>
15431 </p>
15432 <ul class="gallery mw-gallery-traditional">
15433 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15434 <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>
15435 <div class="gallerytext">
15436 <p>caption
15437 </p>
15438 </div>
15439 </div></li>
15440 </ul>
15441 !! html/parsoid
15442 <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>
15443
15444 <!-- consistency with gallery extension -->
15445 <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"}}'>
15446 <li class="gallerybox">
15447 <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>
15448 <div class="gallerytext">caption</div>
15449 </li>
15450 </ul>
15451 !! end
15452
15453 !! test
15454 Nowiki markup in link attribute (edited html, no data-parsoid) (T206940)
15455 !! options
15456 parsoid = {
15457 "nativeGallery": true
15458 }
15459 !! wikitext
15460 [[File:Foobar.jpg|link=Foo<nowiki>''s_bar''</nowiki>s|caption]]
15461
15462 <!-- consistency with gallery extension -->
15463 <gallery>
15464 File:Foobar.jpg|link=Foo<nowiki>''s_bar''</nowiki>s|caption
15465 </gallery>
15466 !! html/php+tidy
15467 <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>
15468 </p>
15469 <ul class="gallery mw-gallery-traditional">
15470 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15471 <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>
15472 <div class="gallerytext">
15473 <p>caption
15474 </p>
15475 </div>
15476 </div></li>
15477 </ul>
15478 !! html/parsoid
15479 <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>
15480
15481 <!-- consistency with gallery extension -->
15482 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
15483 <li class="gallerybox">
15484 <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>
15485 <div class="gallerytext">caption</div>
15486 </li>
15487 </ul>
15488 !! end
15489
15490 !! test
15491 HTML entity prefix in link markup (T209236)
15492 !! wikitext
15493 [[File:Foobar.jpg|link=https://example.com?foo&params=bar]]
15494
15495 <!-- consistency with gallery extension -->
15496 <gallery>
15497 File:Foobar.jpg|link=https://example.com?foo&params=bar
15498 </gallery>
15499 !! html/php+tidy
15500 <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>
15501 </p>
15502 <ul class="gallery mw-gallery-traditional">
15503 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15504 <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>
15505 <div class="gallerytext">
15506 </div>
15507 </div></li>
15508 </ul>
15509 !! html/parsoid
15510 <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>
15511
15512 <!-- consistency with gallery extension -->
15513 <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"}}'>
15514 <li class="gallerybox">
15515 <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>
15516 <div class="gallerytext"></div>
15517 </li>
15518 </ul>
15519 !! end
15520
15521 !! test
15522 Image with table with attributes in caption
15523 !! options
15524 parsoid=wt2html,html2html
15525 !! wikitext
15526 [[File:Foobar.jpg|thumb|
15527 {| class="123" |
15528 |- class="456" |
15529 | ha
15530 |}
15531 ]]
15532 !! html/parsoid
15533 <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>
15534 <table class="123">
15535 <tbody><tr class="456" data-parsoid='{"startTagSrc":"|-"}'>
15536 <td> ha</td></tr>
15537 </tbody></table>
15538 </figcaption></figure>
15539 !! end
15540
15541 !! test
15542 Image with table with rows from templates in caption
15543 !! wikitext
15544 [[File:Foobar.jpg|thumb|
15545 {|
15546 {{echo|{{!}} hi}}
15547 |}
15548 ]]
15549 !! html/parsoid
15550 <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>
15551 <table>
15552 <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>
15553 </tbody></table>
15554 </figcaption></figure>
15555 !! end
15556
15557 !! test
15558 Image with nested tables in caption
15559 !! wikitext
15560 [[File:Foobar.jpg|thumb|Foo<br />
15561 {|
15562 |
15563 {|
15564 |z
15565 |}
15566 |}
15567 ]]
15568 !! html/parsoid
15569 <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}'/>
15570 <table>
15571 <tbody><tr><td>
15572 <table>
15573 <tbody><tr><td>z</td></tr>
15574 </tbody></table></td></tr>
15575 </tbody></table>
15576 </figcaption></figure>
15577 !! end
15578
15579 !! test
15580 Image with heading and horizontal rule in caption
15581 !! wikitext
15582 [[File:Foobar.jpg|thumb|
15583 ===Testing===
15584 123
15585 --------------
15586 ]]
15587 !! html/php
15588 <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>
15589
15590 !! html/parsoid
15591 <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>
15592 <h3 id="Testing">Testing</h3>
15593 123
15594 <hr data-parsoid='{"extra_dashes":10}'/>
15595 </figcaption></figure>
15596 !! end
15597
15598 ###################
15599 # Conflicting image format options.
15600 # First option specified should 'win'.
15601 # All three cases in each test should be identical.
15602
15603 !! test
15604 Image with 'frameless' first.
15605 !! options
15606 parsoid=wt2html,wt2wt,html2html
15607 !! wikitext
15608 [[File:Foobar.jpg|frameless|caption]]
15609
15610 [[File:Foobar.jpg|frameless|frame|caption]]
15611
15612 [[File:Foobar.jpg|frameless|thumb|caption]]
15613 !! html/php
15614 <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>
15615 </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>
15616 </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>
15617 </p>
15618 !! html/parsoid
15619 <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>
15620 <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>
15621 <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>
15622 !! end
15623
15624 !! test
15625 Image with 'frame' first.
15626 !! options
15627 parsoid=wt2html,wt2wt,html2html
15628 !! wikitext
15629 [[File:Foobar.jpg|frame|caption]]
15630 [[File:Foobar.jpg|frame|frameless|caption]]
15631 [[File:Foobar.jpg|frame|thumb|caption]]
15632 !! html/php
15633 <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>
15634 <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>
15635 <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>
15636
15637 !! html/parsoid
15638 <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>
15639 <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>
15640 <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>
15641 !! end
15642
15643 !! test
15644 Image with 'thumb' first.
15645 !! options
15646 parsoid=wt2html,wt2wt,html2html
15647 !! wikitext
15648 [[File:Foobar.jpg|thumb|caption]]
15649 [[File:Foobar.jpg|thumb|frameless|caption]]
15650 [[File:Foobar.jpg|thumb|frame|caption]]
15651 !! html/php
15652 <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" decoding="async" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>caption</div></div></div>
15653 <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>
15654 <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>
15655
15656 !! html/parsoid
15657 <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>
15658 <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>
15659 <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>
15660 !! end
15661
15662 ###################
15663 # Image sizing.
15664 # See https://www.mediawiki.org/wiki/Help:Images#Size_and_frame
15665 # and https://phabricator.wikimedia.org/T64258
15666 # Foobar has actual size of 1941x220
15667 # 1. Thumbs & frameless always reduce, can't be enlarged unless it's
15668 # a scalable format.
15669 # 2. Framed images always ignore size options; always render at default size.
15670 # 3. "Unspecified format" and border are the only types which can be
15671 # enlarged.
15672
15673 !! test
15674 Image: unspecified format and border enlarge
15675 !! options
15676 parsoid=wt2html,wt2wt,html2html
15677 !! wikitext
15678 [[File:Foobar.jpg|2000px]]
15679
15680 [[File:Foobar.jpg|border|2000px]]
15681 !! html/php
15682 <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>
15683 </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>
15684 </p>
15685 !! html/parsoid
15686 <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>
15687 <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>
15688 !! end
15689
15690 !! test
15691 Image: "unspecified format" and border reduce
15692 !! options
15693 parsoid=wt2html,wt2wt,html2html
15694 !! wikitext
15695 [[File:Foobar.jpg|1000px]]
15696
15697 [[File:Foobar.jpg|border|1000px]]
15698 !! html/php
15699 <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>
15700 </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>
15701 </p>
15702 !! html/parsoid
15703 <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>
15704 <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>
15705 !! end
15706
15707 !! test
15708 Image: thumbs reduce
15709 !! options
15710 parsoid=wt2html,wt2wt,html2html
15711 !! wikitext
15712 [[File:Foobar.jpg|thumb|50px]]
15713 !! html/php
15714 <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>
15715
15716 !! html/parsoid
15717 <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>
15718 !! end
15719
15720 !! test
15721 Image: bitmap thumbs can't be enlarged past original size, but vector can.
15722 !! options
15723 parsoid=wt2html,wt2wt,html2html
15724 !! wikitext
15725 [[File:Foobar.jpg|thumb|2000px]]
15726
15727 [[File:Foobar.svg|thumb|2000px]]
15728 !! html/php
15729 <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>
15730 <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>
15731
15732 !! html/parsoid
15733 <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>
15734 <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>
15735 !! end
15736
15737 !! test
15738 Image: frameless can reduce in size
15739 !! options
15740 parsoid=wt2html,wt2wt,html2html
15741 !! wikitext
15742 [[File:Foobar.jpg|frameless|50px]]
15743 !! html/php
15744 <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>
15745 </p>
15746 !! html/parsoid
15747 <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>
15748 !! end
15749
15750 !! test
15751 Image: bitmap frameless can't be enlarged past original size, but vector can
15752 !! options
15753 parsoid=wt2html,wt2wt,html2html
15754 !! wikitext
15755 [[File:Foobar.jpg|frameless|2000px]]
15756
15757 [[File:Foobar.svg|frameless|2000px]]
15758 !! html/php
15759 <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>
15760 </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>
15761 </p>
15762 !! html/parsoid
15763 <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>
15764 <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>
15765 !! end
15766
15767 !! test
15768 Image: framed images are always unscaled.
15769 !! options
15770 parsoid=wt2html,wt2wt,html2html
15771 !! wikitext
15772 [[File:Foobar.jpg|frame]]
15773
15774 [[File:Foobar.jpg|frame|50px]]
15775
15776 [[File:Foobar.jpg|frame|50x50px]]
15777
15778 [[File:Foobar.jpg|frame|2000px]]
15779 !! html/php
15780 <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>
15781 <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>
15782 <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>
15783 <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>
15784
15785 !! html/parsoid
15786 <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>
15787 <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>
15788 <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>
15789 <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>
15790 !! end
15791
15792 ###################
15793
15794 !! test
15795 Link to image page- image page normally doesn't exists, hence edit link
15796 Add test with existing image page
15797 #<p><a href="/wiki/File:Test" title="Image:Test">Image:test</a>
15798 !! wikitext
15799 [[:Image:test]]
15800 !! html
15801 <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>
15802 </p>
15803 !! end
15804
15805 !! test
15806 T20784 Link to non-existent image page with caption should use caption as link text
15807 !! wikitext
15808 [[:Image:test|caption]]
15809 !! html
15810 <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>
15811 </p>
15812 !! end
15813
15814 !! test
15815 Frameless image caption with a free URL
15816 !! wikitext
15817 [[File:Foobar.jpg|http://example.com]]
15818 !! html/php
15819 <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>
15820 </p>
15821 !! html/parsoid
15822 <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>
15823 !! end
15824
15825 !! test
15826 Thumbnail image caption with a free URL
15827 !! options
15828 thumbsize=220
15829 !! wikitext
15830 [[File:Foobar.jpg|thumb|http://example.com]]
15831 !! html/php
15832 <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>
15833
15834 !! html/parsoid
15835 <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>
15836 !! end
15837
15838 !! test
15839 Thumbnail image caption with a free URL and explicit alt
15840 !! options
15841 thumbsize=220
15842 parsoid=wt2html,wt2wt,html2html
15843 !! wikitext
15844 [[File:Foobar.jpg|thumb|http://example.com|alt=Alteration]]
15845 !! html/php
15846 <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>
15847
15848 !! html/parsoid
15849 <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>
15850 !! end
15851
15852 !! test
15853 SVG thumbnails with no language set
15854 !! options
15855 !! wikitext
15856 [[File:Foobar.svg|thumb|caption]]
15857 !! html/php
15858 <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>
15859
15860 !! html/parsoid
15861 <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>
15862 !! end
15863
15864 !! test
15865 SVG thumbnails with language de
15866 !! options
15867 parsoid=wt2html,wt2wt,html2html
15868 !! wikitext
15869 [[File:Foobar.svg|thumb|caption|lang=de]]
15870 !! html/php
15871 <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>
15872
15873 !! html/parsoid
15874 <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>
15875 !! end
15876
15877 !! test
15878 SVG thumbnails with invalid language code
15879 !! options
15880 parsoid=wt2html,wt2wt,html2html
15881 !! wikitext
15882 [[File:Foobar.svg|thumb|caption|lang=invalid:language:code]]
15883 !! html/php
15884 <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>
15885
15886 !! html/parsoid
15887 <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>
15888 !! end
15889
15890 !! test
15891 SVG thumbnails in page language
15892 !! options
15893 language=ru
15894 !! wikitext
15895 [[File:Foobar.svg]] [[File:Foobar.svg|lang=en]]
15896 !! html/php
15897 <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>
15898 </p>
15899 !! end
15900
15901 !! test
15902 SVG thumbnails in page language not present in the file
15903 !! options
15904 language=de
15905 !! wikitext
15906 [[File:Foobar.svg]] [[File:Foobar.svg|lang=ru]]
15907 !! html/php
15908 <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>
15909 </p>
15910 !! end
15911
15912 !! test
15913 T3887: A ISBN with a thumbnail
15914 !! wikitext
15915 [[File:Foobar.jpg|thumb|ISBN 1235467890]]
15916 !! html/php
15917 <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>
15918
15919 !! html/parsoid
15920 <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>
15921 !! end
15922
15923 !! test
15924 T3887: A RFC with a thumbnail
15925 !! wikitext
15926 [[File:Foobar.jpg|thumb|This is RFC 12354]]
15927 !! html/php
15928 <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>
15929
15930 !! html/parsoid
15931 <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>
15932 !! end
15933
15934 !! test
15935 T3887: A mailto link with a thumbnail
15936 !! wikitext
15937 [[File:Foobar.jpg|thumb|Please mailto:nobody@example.com]]
15938 !! html/php
15939 <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>
15940
15941 !! html/parsoid
15942 <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>
15943 !! end
15944
15945 # Pending resolution to T2368
15946 !! test
15947 T2648: Frameless image caption with a link
15948 !! wikitext
15949 [[File:Foobar.jpg|text with a [[link]] in it]]
15950 !! html/php
15951 <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>
15952 </p>
15953 !! html/parsoid
15954 <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>
15955 !! end
15956
15957 !! test
15958 T2648: Frameless image caption with a link (suffix)
15959 !! wikitext
15960 [[File:Foobar.jpg|text with a [[link]]foo in it]]
15961 !! html/php
15962 <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>
15963 </p>
15964 !! html/parsoid
15965 <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>
15966 !! end
15967
15968 !! test
15969 T2648: Frameless image caption with an interwiki link
15970 !! wikitext
15971 [[File:Foobar.jpg|text with a [[MeatBall:Link]] in it]]
15972 !! html/php
15973 <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>
15974 </p>
15975 !! html/parsoid
15976 <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>
15977 !! end
15978
15979 !! test
15980 T2648: Frameless image caption with a piped interwiki link
15981 !! wikitext
15982 [[File:Foobar.jpg|text with a [[MeatBall:Link|link]] in it]]
15983 !! html/php
15984 <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>
15985 </p>
15986 !! html/parsoid
15987 <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>
15988 !! end
15989
15990 !! test
15991 T107474: Frameless image caption with <nowiki>
15992 !! wikitext
15993 [[File:Foobar.jpg|<nowiki>text with a [[MeatBall:Link|link]] in it</nowiki>]]
15994 !! html/parsoid
15995 <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>
15996 !! end
15997
15998 !! test
15999 Escape HTML special chars in image alt text
16000 !! wikitext
16001 [[File:Foobar.jpg|& < > "]]
16002 !! html/php
16003 <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>
16004 </p>
16005 !! html/parsoid
16006 <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>
16007 !! end
16008
16009 !! test
16010 Escape HTML special chars in image alt text with LanguageConverter
16011 !! options
16012 language=zh
16013 !! wikitext
16014 [[File:Foobar.jpg|& < > "]]
16015 !! html/php
16016 <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>
16017 </p>
16018 !! html/parsoid
16019 <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>
16020 !! end
16021
16022 !! test
16023 Entities in file name and attributes
16024 !! wikitext
16025 [[File:7%25 solution.gif|manualthumb=7%25 solution.gif|link=7%25 solution|[[7%25 solution]]]]
16026 !! html/php
16027 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=7%25_solution.gif" class="new" title="File:7% solution.gif">7% solution</a>
16028 </p>
16029 !! html/parsoid
16030 <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>
16031 !! end
16032
16033 !! test
16034 T2499: Alt text should have &#1234;, not &amp;1234;
16035 !! wikitext
16036 [[File:Foobar.jpg|&#9792;]]
16037 !! html/php
16038 <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>
16039 </p>
16040 !! html/parsoid
16041 <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>
16042 !! end
16043
16044 !! test
16045 Broken image caption with link
16046 !! options
16047 parsoid=wt2html,wt2wt,html2html
16048 !! wikitext
16049 [[Image:Foobar.jpg|thumb|This is a broken caption. But [[Main Page|this]] is just an ordinary link.
16050 !! html/php
16051 <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.
16052 </p>
16053 !! html/parsoid
16054 <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>
16055 !! end
16056
16057 !! test
16058 Image caption containing another image
16059 !! wikitext
16060 [[File:Foobar.jpg|thumb|This is a caption with another [[File:Thumb.png|image]] inside it!]]
16061 !! html/php
16062 <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>
16063
16064 !! html/parsoid
16065 <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>
16066 !! end
16067
16068 !! test
16069 Image: caption containing a newline
16070 !! wikitext
16071 [[File:Foobar.jpg|This
16072 *is some text]]
16073 !! html/php
16074 <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>
16075 </p>
16076 !! html/parsoid
16077 <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>
16078 !!end
16079
16080 !!test
16081 Image: caption containing leading space
16082 (The leading space should not trigger nowiki escaping in wt2wt mode)
16083 !! wikitext
16084 [[File:Foobar.jpg|thumb| bar]]
16085 !! html/php
16086 <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>
16087
16088 !! html/parsoid
16089 <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>
16090 !!end
16091
16092 # html/php output not have newlines after table, td, th, etc. because
16093 # Linker::makeThumbLink2() replaces the newlines with spaces since
16094 # the table is inside a caption.
16095 # FIXME: Verify if that circa 2004 fix is still required.
16096 !! test
16097 Image: caption containing a table
16098 !! options
16099 parsoid=wt2html,wt2wt,html2html
16100 !! wikitext
16101 [[Image:Foobar.jpg|thumb|200px|This is an example image thumbnail caption with a table
16102 {|
16103 !Foo!!Bar
16104 |-
16105 |Foo1||Bar1
16106 |}
16107 and some more text.]]
16108 !! html/php
16109 <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>
16110
16111 !! html/parsoid
16112 <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
16113 <table>
16114 <tbody>
16115 <tr><th>Foo</th><th>Bar</th></tr>
16116 <tr>
16117 <td>Foo1</td>
16118 <td>Bar1</td></tr></tbody></table>and some more text.</figcaption></figure>
16119 !! end
16120
16121 !! test
16122 T5090: External links other than http: in image captions
16123 !! wikitext
16124 [[File:Foobar.jpg|thumb|200x200px|This caption has [irc://example.net irc] and [https://example.com Secure] ext links in it.]]
16125 !! html/php
16126 <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>
16127
16128 !! html/parsoid
16129 <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>
16130 !! end
16131
16132 !! test
16133 Custom class
16134 !! options
16135 parsoid=wt2html,wt2wt,html2html
16136 !! wikitext
16137 [[Image:foobar.jpg|a|class=b]]
16138 !! html/php
16139 <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>
16140 </p>
16141 !! html/parsoid
16142 <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>
16143 !! end
16144
16145 !! test
16146 Localized image handling (1).
16147 !! options
16148 parsoid=wt2html,wt2wt,html2html
16149 language=es
16150 !! wikitext
16151 [[Archivo:Foobar.jpg|izquierda|enlace=foo|caption]]
16152 !! html/php
16153 <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>
16154
16155 !! html/parsoid
16156 <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>
16157 !! end
16158
16159 !! test
16160 Localized image handling (2).
16161 !! options
16162 thumbsize=220
16163 parsoid=wt2html,wt2wt,html2html
16164 language=es
16165 !! wikitext
16166 [[Archivo:Foobar.jpg|miniatura|izquierda|enlace=foo|caption]]
16167 !! html/php
16168 <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>
16169
16170 !! html/parsoid
16171 <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>
16172 !! end
16173
16174 !! test
16175 Localized image handling (3).
16176 !! options
16177 language=fa
16178 parsoid=html2wt
16179 !! html/parsoid
16180 <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>
16181 !! wikitext
16182 [[File:Foobar.jpg|بندانگشتی]]
16183 !! end
16184
16185 !! test
16186 "border", "frameless" and "class" attributes on an image.
16187 !! options
16188 thumbsize=220
16189 parsoid=wt2html,wt2wt,html2html
16190 !! wikitext
16191 [[File:Foobar.jpg|frameless|border|class=extra|caption]]
16192 !! html/php
16193 <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>
16194 </p>
16195 !! html/parsoid
16196 <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>
16197 !! end
16198
16199 # Note that 'right' is the default alignment, despite the misspelled 'righ' below
16200 !! test
16201 Invalid image attributes (T64500)
16202 !! options
16203 thumbsize=220
16204 parsoid=wt2html,wt2wt,html2html
16205 !! wikitext
16206 [[File:Foobar.jpg|thumb|float|left|caption]]
16207
16208 [[File:Foobar.jpg|thumb|righ|caption]]
16209
16210 [[File:Foobar.jpg|bogus1|thumb|bogus2|left|bogus3|caption]]
16211 !! html/php
16212 <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>
16213 <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>
16214 <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>
16215
16216 !! html/parsoid
16217 <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>
16218 <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>
16219 <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>
16220 !! end
16221
16222 !! article
16223 File:Barfoo.jpg
16224 !! text
16225 #REDIRECT [[File:Barfoo.jpg]]
16226 !! endarticle
16227
16228 # FIXME: Parsoid should run this test -- but we'd need to teach the
16229 # mockAPI about the redirected Barfoo.jpg image.
16230 !! test
16231 Redirected image
16232 !! wikitext
16233 [[Image:Barfoo.jpg]]
16234 !! html/php
16235 <p><a href="/wiki/File:Barfoo.jpg" class="mw-redirect" title="File:Barfoo.jpg">File:Barfoo.jpg</a>
16236 </p>
16237 !! end
16238
16239 !! test
16240 Missing image with uploads disabled
16241 !! options
16242 wgEnableUploads=0
16243 !! wikitext
16244 [[File:Foobaz.jpg]]
16245 !! html/php
16246 <p><a href="/wiki/File:Foobaz.jpg" title="File:Foobaz.jpg">File:Foobaz.jpg</a>
16247 </p>
16248 !! html/parsoid
16249 <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>
16250 !! end
16251
16252 # Parsoid-specific testing for images
16253 # https://www.mediawiki.org/wiki/Parsoid/MediaWiki_DOM_spec#Images
16254 # Currently imperfect due to a flaw in the Parsoid testrunner
16255 # Work in progress
16256 # THESE TESTS SHOULD BE MOVED UP and merged with the php-specific
16257 # image tests.
16258
16259 !! test
16260 Parsoid-specific image handling - simple image with size and middle alignment
16261 !! wikitext
16262 [[File:Foobar.jpg|middle|50px]]
16263 !! html/parsoid
16264 <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>
16265 !! end
16266
16267 !! test
16268 Parsoid-specific image handling - simple image with size, middle alignment, non-standard namespace alias
16269 !! options
16270 parsoid=wt2wt,wt2html,html2html
16271 !! wikitext
16272 [[Image:Foobar.jpg|middle|50px]]
16273 !! html/parsoid
16274 <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>
16275 !! end
16276
16277 !! test
16278 Parsoid-specific image handling - simple image with size and middle alignment (existing content)
16279 !! wikitext
16280 [[File:Foobar.jpg|50px|middle]]
16281 !! html/parsoid
16282 <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>
16283 !! end
16284
16285 !! test
16286 Parsoid-specific image handling - simple image with size and middle alignment and non-standard namespace name
16287 !! options
16288 parsoid=wt2html,wt2wt,html2html
16289 !! wikitext
16290 [[Image:Foobar.jpg|50px|middle]]
16291 !! html/parsoid
16292 <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>
16293 !! end
16294
16295 !! test
16296 Parsoid-specific image handling - simple image with both sizes, a baseline alignment, and a caption
16297 !! wikitext
16298 [[File:Foobar.jpg|500x10px|baseline|caption]]
16299 !! html/parsoid
16300 <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>
16301 !! end
16302
16303 !! test
16304 Parsoid-specific image handling - simple image with border and size spec
16305 !! wikitext
16306 [[File:Foobar.jpg|50px|border|caption]]
16307 !! html/parsoid
16308 <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>
16309 !! end
16310
16311 !! test
16312 Parsoid-specific image handling - thumbnail with halign, valign, and caption
16313 !! options
16314 parsoid=wt2html,html2html
16315 !! wikitext
16316 [[File:Foobar.jpg|left|baseline|thumb|caption content]]
16317 !! html/parsoid
16318 <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>
16319 !! end
16320
16321 !! test
16322 Parsoid-specific image handling - thumbnail with halign, valign, and caption (existing content)
16323 !! options
16324 parsoid=wt2html,html2html
16325 !! wikitext
16326 [[File:Foobar.jpg|thumb|left|baseline|caption content]]
16327 !! html/parsoid
16328 <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>
16329 !! end
16330
16331 !! test
16332 Parsoid-specific image handling - thumbnail with specific size, halign, valign, and caption
16333 !! options
16334 parsoid=wt2html,html2html
16335 !! wikitext
16336 [[Image:Foobar.jpg|right|middle|thumb|50x50px|caption]]
16337 !! html/parsoid
16338 <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>
16339 !! end
16340
16341 !! test
16342 Parsoid-specific image handling - thumbnail with specific size, halign, valign, and caption (existing content)
16343 !! options
16344 parsoid=wt2html,html2html
16345 !! wikitext
16346 [[File:Foobar.jpg|thumb|50x50px|right|middle|caption]]
16347 !! html/parsoid
16348 <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>
16349 !! end
16350
16351 !! test
16352 Parsoid-specific image handling - framed image with specific size and caption (size is ignored)
16353 !! options
16354 parsoid=wt2html,wt2wt,html2html
16355 !! wikitext
16356 [[File:Foobar.jpg|frame|500x50px|caption]]
16357 !! html/parsoid
16358 <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>
16359 !! end
16360
16361 !! test
16362 Parsoid-specific image handling - framed image with specific size, halign, valign, and caption (size is ignored)
16363 !! options
16364 parsoid=wt2html,html2html
16365 !! wikitext
16366 [[File:Foobar.jpg|left|baseline|frame|500x50px|caption]]
16367 !! html/parsoid
16368 <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>
16369 !! end
16370
16371 !! test
16372 Parsoid-specific image handling - frameless image with specific size, border, and caption
16373 !! wikitext
16374 [[File:Foobar.jpg|frameless|442x50px|border|caption]]
16375 !! html/parsoid
16376 <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>
16377 !! end
16378
16379 !! test
16380 Parsoid-specific image handling - simple image with a formatted caption
16381 !! wikitext
16382 [[File:Foobar.jpg|<table><tr><td>a</td><td>b</td></tr><tr><td>c</td></tr></table>]]
16383 !! html/parsoid
16384 <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>
16385 !! end
16386
16387 !! test
16388 Parsoid-specific image handling - caption with a template in it
16389 !! wikitext
16390 [[File:Foobar.jpg|thumb|200x23px|This caption has a {{echo|transclusion}} in it.]]
16391 !! html/parsoid
16392 <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>
16393 !! end
16394
16395 !! test
16396 Parsoid-specific image handling - caption with unbalanced tags in it
16397 !! options
16398 parsoid=wt2html,wt2wt,html2html
16399 !! wikitext
16400 foo
16401 [[File:Foobar.jpg|thumb|200x200px|This caption has a <center>unbalanced tag in it.]]
16402 bar
16403 !! html/parsoid
16404 <p>foo</p>
16405 <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>
16406 <p>bar</p>
16407 !! end
16408
16409 !! test
16410 Parsoid-specific image handling - empty caption (1)
16411 !! options
16412 parsoid=wt2html,wt2wt
16413 !! wikitext
16414 [[File:Foobar.jpg|thumb|]]
16415 !! html/parsoid
16416 <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>
16417 !! end
16418
16419 # empty captions don't get serialized unless we're in the "round trip" case
16420 !! test
16421 Parsoid-specific image handling - empty caption (2)
16422 !! options
16423 parsoid=html2wt
16424 !! html/parsoid
16425 <figure class="mw-default-size" typeof="mw:Image/Thumb">
16426 <a href="./File:Foobar.jpg">
16427 <img resource="./File:Foobar.jpg"
16428 src="//example.com/images/3/3a/Foobar.jpg"
16429 data-file-width="1941" data-file-height="220" data-file-type="bitmap"
16430 height="25" width="220"/>
16431 </a>
16432 <figcaption></figcaption>
16433 </figure>
16434 !! wikitext
16435 [[File:Foobar.jpg|thumb]]
16436 !! end
16437
16438 !! test
16439 Parsoid-specific image handling - whitespace caption
16440 !! wikitext
16441 [[File:Foobar.jpg|thumb| ]]
16442 !! html/parsoid
16443 <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>
16444 !! end
16445
16446 !! test
16447 Parsoid-specific image handling - lang option
16448 !! wikitext
16449 foo
16450 [[File:Foobar.svg|lang=de|caption]]
16451 bar
16452 !! html/parsoid
16453 <p>foo
16454 <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>
16455 bar</p>
16456 !! end
16457
16458 ## Edge case bugs in Parsoid from T93580
16459 !! test
16460 T93580: 1. Templated <ref> inside block images
16461 !! wikitext
16462 [[File:Foobar.jpg|thumb|Caption with templated ref: {{echo|<ref>foo</ref>}}]]
16463
16464 <references />
16465 !! html/parsoid
16466 <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>
16467
16468 <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>
16469 !! end
16470
16471 !! test
16472 T93580: 2. <ref> inside inline images
16473 !! wikitext
16474 [[File:Foobar.jpg|Undisplayed caption in inline image with ref: <ref>foo</ref>]]
16475
16476 <references />
16477 !! html/parsoid
16478 <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>
16479
16480 <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>
16481 !! end
16482
16483 !! test
16484 T93580: 3. Templated <ref> inside inline images
16485 !! wikitext
16486 [[File:Foobar.jpg|Undisplayed caption in inline image with ref: {{echo|<ref>{{echo|foo}}</ref>}}]]
16487
16488 <references />
16489 !! html/parsoid
16490 <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>
16491
16492 <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>
16493 !! end
16494
16495 ###
16496 ### Subpages
16497 ###
16498 !! article
16499 Subpage test/subpage
16500 !! text
16501 foo
16502 !! endarticle
16503
16504 !! test
16505 Subpage link
16506 !! options
16507 subpage title=[[Subpage test]]
16508 !! wikitext
16509 [[/subpage]]
16510 !! html
16511 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a>
16512 </p>
16513 !! end
16514
16515 !! test
16516 Subpage noslash link
16517 !! options
16518 subpage title=[[Subpage test]]
16519 !! wikitext
16520 [[/subpage/]]
16521 !! html
16522 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">subpage</a>
16523 </p>
16524 !! end
16525
16526 !! article
16527 Subpage test/1/2/subpage
16528 !! text
16529 blah
16530 !! endarticle
16531
16532 !! test
16533 Relative subpage noslash link
16534 !! options
16535 parsoid=wt2wt,wt2html,html2html
16536 subpage title=[[Subpage test/1/2/3/4]]
16537 !! wikitext
16538 [[../../subpage/]]
16539
16540 [[../../subpage]]
16541 !! html/php
16542 <p><a href="/wiki/Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">subpage</a>
16543 </p><p><a href="/wiki/Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">Subpage test/1/2/subpage</a>
16544 </p>
16545 !! html/parsoid
16546 <p><a rel="mw:WikiLink" href="./Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">subpage</a></p>
16547 <p><a rel="mw:WikiLink" href="./Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">Subpage_test/1/2/subpage</a></p>
16548 !! end
16549
16550 !! test
16551 Parsoid: dot-slash prefixed wikilinks
16552 !! wikitext
16553 [[./foo]]
16554
16555 [[././bar]]
16556
16557 [[././baz/]]
16558 !! html/php
16559 <p>[[./foo]]
16560 </p><p>[[././bar]]
16561 </p><p>[[././baz/]]
16562 </p>
16563 !! html/parsoid
16564 <p>[[./foo]]
16565 </p><p>[[././bar]]
16566 </p><p>[[././baz/]]
16567 </p>
16568 !! end
16569
16570 !! test
16571 Render invalid page names as plain text (T53090)
16572 !! wikitext
16573 [[./../foo|bar]]
16574 [[foo�|bar]]
16575 [[foo/.|bar]]
16576 [[foo/..|bar]]
16577 [[foo~~~bar]]
16578 [[foo>bar]]
16579 [[foo[bar]]
16580 [[.]]
16581 [[..]]
16582 [[foo././bar]]
16583 [[foo[http://example.com]xyz]]
16584
16585 [[{{echo|./../foo}}|bar]]
16586 [[{{echo|foo/.}}|bar]]
16587 [[{{echo|foo/..}}|bar]]
16588 [[{{echo|foo~~~~bar}}]]
16589 [[{{echo|foo>bar}}]]
16590 [[{{echo|foo././bar}}]]
16591 [[{{echo|foo{bar}}]]
16592 [[{{echo|foo}bar}}]]
16593 [[{{echo|foo[bar}}]]
16594 [[{{echo|foo]bar}}]]
16595 [[{{echo|foo<bar}}]]
16596 !!html/php
16597 <p>[[./../foo|bar]]
16598 [[foo�|bar]]
16599 [[foo/.|bar]]
16600 [[foo/..|bar]]
16601 [[foo~~~bar]]
16602 [[foo&gt;bar]]
16603 [[foo[bar]]
16604 [[.]]
16605 [[..]]
16606 [[foo././bar]]
16607 [[foo<a rel="nofollow" class="external autonumber" href="http://example.com">[1]</a>xyz]]
16608 </p><p>[[./../foo|bar]]
16609 [[foo/.|bar]]
16610 [[foo/..|bar]]
16611 [[foo~~~~bar]]
16612 [[foo&gt;bar]]
16613 [[foo././bar]]
16614 [[foo{bar]]
16615 [[foo}bar]]
16616 [[foo[bar]]
16617 [[foo]bar]]
16618 [[foo&lt;bar]]
16619 </p>
16620 !!html/parsoid
16621 <p>[[./../foo|bar]]
16622 [[foo�|bar]]
16623 [[foo/.|bar]]
16624 [[foo/..|bar]]
16625 [[foo~~~bar]]
16626 [[foo>bar]]
16627 [[foo[bar]]
16628 [[.]]
16629 [[..]]
16630 [[foo././bar]]
16631 [[foo<a rel="mw:ExtLink" class="external autonumber" href="http://example.com"></a>xyz]]</p>
16632
16633 <p>[[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"./../foo"}},"i":0}}]}'>./../foo</span>|bar]]
16634 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo/."}},"i":0}}]}'>foo/.</span>|bar]]
16635 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo/.."}},"i":0}}]}'>foo/..</span>|bar]]
16636 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo~~~~bar"}},"i":0}}]}'>foo~~~~bar</span>]]
16637 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo>bar"}},"i":0}}]}'>foo>bar</span>]]
16638 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo././bar"}},"i":0}}]}'>foo././bar</span>]]
16639 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo{bar"}},"i":0}}]}'>foo{bar</span>]]
16640 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo}bar"}},"i":0}}]}'>foo}bar</span>]]
16641 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo[bar"}},"i":0}}]}'>foo[bar</span>]]
16642 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo]bar"}},"i":0}}]}'>foo]bar</span>]]
16643 [[<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>
16644 !!end
16645
16646 !! test
16647 Disabled subpages
16648 !! wikitext
16649 [[/subpage]]
16650 !! html
16651 <p><a href="/index.php?title=/subpage&amp;action=edit&amp;redlink=1" class="new" title="/subpage (page does not exist)">/subpage</a>
16652 </p>
16653 !! end
16654
16655 !! test
16656 T2561: {{/Subpage}}
16657 !! options
16658 subpage title=[[Page]]
16659 !! wikitext
16660 {{/Subpage}}
16661 !! html
16662 <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>
16663 </p>
16664 !! end
16665
16666 ###
16667 ### Categories
16668 ###
16669 !! article
16670 Category:MediaWiki User's Guide
16671 !! text
16672 blah
16673 !! endarticle
16674
16675 !! test
16676 Link to category
16677 !! wikitext
16678 [[:Category:MediaWiki User's Guide]]
16679 !! html
16680 <p><a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User&#39;s Guide">Category:MediaWiki User's Guide</a>
16681 </p>
16682 !! end
16683
16684 !! test
16685 Simple category
16686 !! options
16687 cat
16688 !! wikitext
16689 [[Category:MediaWiki User's Guide]]
16690 !! html/php
16691 cat=MediaWiki_User's_Guide sort=
16692 !! html/parsoid
16693 <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"}}'/>
16694 !! end
16695
16696 !! test
16697 PAGESINCATEGORY invalid title fatal (r33546 fix)
16698 !! wikitext
16699 {{PAGESINCATEGORY:<bogus>}}
16700 !! html
16701 <p>0
16702 </p>
16703 !! end
16704
16705 !! test
16706 Category with different sort key
16707 !! options
16708 cat
16709 !! wikitext
16710 [[Category:MediaWiki User's Guide|Foo]]
16711 !! html/php
16712 cat=MediaWiki_User's_Guide sort=Foo
16713 !! html/parsoid
16714 <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"}}'/>
16715 !! end
16716
16717 !! test
16718 Category with identical sort key
16719 !! options
16720 cat
16721 !! wikitext
16722 [[Category:MediaWiki User's Guide|MediaWiki User's Guide]]
16723 !! html/php
16724 cat=MediaWiki_User's_Guide sort=MediaWiki User's Guide
16725 !! html/parsoid
16726 <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"}}'/>
16727 !! end
16728
16729 !! test
16730 Category with empty sort key
16731 !! options
16732 cat
16733 pst
16734 !! wikitext
16735 [[Category:MediaWiki User's Guide|]]
16736 !! html/php
16737 [[Category:MediaWiki User's Guide|MediaWiki User's Guide]]
16738 !! end
16739
16740 !! test
16741 Category with empty sort key and parentheses
16742 !! options
16743 cat
16744 pst
16745 !! wikitext
16746 [[Category:Foo (bar)|]]
16747 !! html/php
16748 [[Category:Foo (bar)|Foo]]
16749 !! end
16750
16751 !! test
16752 Category with link tail
16753 !! options
16754 cat
16755 pst
16756 !! wikitext
16757 123[[Category:Foo]]456
16758 !! html/php
16759 123[[Category:Foo]]456
16760 !! end
16761
16762 !! test
16763 Category with template
16764 !! options
16765 cat
16766 pst
16767 !! wikitext
16768 [[Category:{{echo|Foo}}]]
16769 !! html/php
16770 [[Category:{{echo|Foo}}]]
16771 !! end
16772
16773 !! test
16774 Category with template in sort key
16775 !! options
16776 cat
16777 pst
16778 !! wikitext
16779 [[Category:Foo|{{echo|Bar}}]]
16780 !! html/php
16781 [[Category:Foo|{{echo|Bar}}]]
16782 !! end
16783
16784 !! test
16785 Category with template in sort key and title
16786 !! options
16787 cat
16788 pst
16789 !! wikitext
16790 [[Category:{{echo|Foo}}|{{echo|Bar}}]]
16791 !! html/php
16792 [[Category:{{echo|Foo}}|{{echo|Bar}}]]
16793 !! end
16794
16795 ## We used to, but no longer wt2wt this test since the default serializer
16796 ## will normalize all categories to serialize on their own line.
16797 ## This wikitext usage is going to be fairly uncommon in production and
16798 ## selser will take care of preserving formatting in those scenarios.
16799 !! test
16800 Category / paragraph interactions
16801 !! options
16802 parsoid=wt2html
16803 !! wikitext
16804 Foo [[Category:Baz]] Bar
16805
16806 Foo [[Category:Baz]]
16807 Bar
16808
16809 Foo
16810 [[Category:Baz]]
16811 Bar
16812
16813 Foo
16814 [[Category:Baz]] Bar
16815
16816 Foo
16817 [[Category:Baz]]
16818 [[Category:Baz]]
16819 [[Category:Baz]]
16820 Bar
16821
16822 [[Category:Baz]]
16823 [[Category:Baz]]
16824 [[Category:Baz]]
16825
16826 [[Category:Baz]]
16827 {{echo|[[Category:Baz]]}}
16828 [[Category:Baz]]
16829 !! html/php
16830 <p>Foo Bar
16831 </p><p>Foo
16832 Bar
16833 </p><p>Foo
16834 Bar
16835 </p><p>Foo Bar
16836 </p><p>Foo
16837 Bar
16838 </p>
16839 !! html/parsoid
16840 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16841 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16842 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16843 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16844 <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>
16845 <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}}]}'/>
16846 <link rel="mw:PageProp/Category" href="./Category:Baz"/>
16847 !! end
16848
16849 ## We used to, but no longer wt2wt this test since the default serializer
16850 ## will normalize all categories to serialize on their own line.
16851 ## This wikitext usage is going to be fairly uncommon in production and
16852 ## selser will take care of preserving formatting in those scenarios.
16853 ##
16854 ## The whitespace on the empty line is part of the test. Please do not delete
16855 !! test
16856 1. Categories and newlines: All preceding newlines should be suppressed (courtesy T2087)
16857 !! options
16858 parsoid=wt2html
16859 !! wikitext
16860 This
16861
16862 [[Category:Foo]] and this should be part of same paragraph (not an indent-pre)
16863
16864 {{echo|[[Category:Foo]] and so should this!}}
16865 !! html/php
16866 <p>This and this should be part of same paragraph (not an indent-pre) and so should this!
16867 </p>
16868 !! html/parsoid
16869 <p>This
16870
16871 <link rel="mw:PageProp/Category" href="./Category:Foo"/> and this should be part of same paragraph (not an indent-pre)
16872
16873 <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>
16874 !! end
16875
16876 ## Parsoid will not try to wt2wt this while preserving newlines because
16877 ## it suppresses excess newlines within list items -- and we don't want to
16878 ## introduce a special case just for categories, which is, in reality somewhat
16879 ## odd behavior -- categories are unlikely to be used in list items like this
16880 ## in top-level pages and are only likely to show up in template-generated
16881 ## list items where this RT-ing is a non-issue.
16882 ##
16883 ## The whitespace on the empty line is part of the test. Please do not delete
16884 !! test
16885 2. Categories and newlines: All preceding newlines should be suppressed (courtesy T2087)
16886 !! options
16887 parsoid=wt2html
16888 !! wikitext
16889 * This
16890
16891 [[Category:Foo]] and this should be part of the same list item
16892 * So should this
16893
16894 {{echo|[[Category:Foo]] and this should be part of the same list item}}
16895 !! html/php+tidy
16896 <ul><li>This and this should be part of the same list item</li>
16897 <li>So should this and this should be part of the same list item</li></ul>
16898 !! html/parsoid
16899 <ul>
16900 <li>This <link rel="mw:PageProp/Category" href="./Category:Foo"/> and this should be part of the same list item</li>
16901 <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>
16902 </ul>
16903 !! end
16904
16905 ## Newlines and categories that follow the last item of a list
16906 ## are treated differently because this (list followed by categories)
16907 ## is an extremely common pattern on wikis.
16908 !! test
16909 3. Categories and newlines: newline suppression for last list item should RT properly
16910 !! wikitext
16911 *a
16912 *b
16913
16914 [[Category:Foo]]
16915
16916 [[Category:Bar]]
16917 [[Category:Baz]]
16918
16919 :c
16920
16921 [[Category:C]]
16922
16923 ;d
16924
16925 [[Category:D]]
16926 !! html/parsoid
16927 <ul><li>a</li>
16928 <li>b</li></ul>
16929
16930 <link rel="mw:PageProp/Category" href="./Category:Foo"/>
16931
16932 <link rel="mw:PageProp/Category" href="./Category:Bar"/>
16933 <link rel="mw:PageProp/Category" href="./Category:Baz"/>
16934
16935 <dl><dd>c</dd></dl>
16936
16937 <link rel="mw:PageProp/Category" href="./Category:C"/>
16938
16939 <dl><dt>d</dt></dl>
16940
16941 <link rel="mw:PageProp/Category" href="./Category:D"/>
16942 !! end
16943
16944 !! test
16945 4. Categories and newlines: newline suppression for last list item should RT properly
16946 !! wikitext
16947 *a
16948 ****b
16949
16950 [[Category:Foo]]
16951 !! html/parsoid
16952 <ul><li>a
16953 <ul><li><ul><li><ul><li>b</li></ul></li></ul></li></ul></li></ul>
16954
16955 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
16956 !! end
16957
16958 ## only wt2html for this to make sure the algo only applies to the rightmost path
16959 !! test
16960 5. Categories and newlines: migrateTrailingCategories dom pass should only run on the rightmost path of nested lists
16961 !! options
16962 parsoid=wt2html
16963 !! wikitext
16964 *a
16965 **b
16966 [[Category:Foo]]
16967 *c
16968 **d
16969 [[Category:Foo]]
16970 !! html/parsoid
16971 <ul><li>a
16972 <ul><li>b
16973 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/></li></ul></li>
16974 <li>c
16975 <ul><li>d</li></ul></li></ul>
16976 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
16977 !! end
16978
16979 ## We used to, but no longer wt2wt this test since the default serializer
16980 ## will normalize all categories to serialize on their own line.
16981 ## This wikitext usage is going to be fairly uncommon in production and
16982 ## selser will take care of preserving formatting in those scenarios.
16983 !! test
16984 6. Categories and newlines: migrateTrailingCategories dom pass should not migrate categories not preceded by newlines
16985 !! options
16986 parsoid=wt2html
16987 !! wikitext
16988 *a [[Category:Foo]]
16989 !! html/parsoid
16990 <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>
16991 !! end
16992
16993 # This test also demonstrates because of newline+category tunneling
16994 # through the list hander, template wrapping doesn't expand to the
16995 # containing list when the list item swallows the category.
16996 !! test
16997 7. Categories and newlines: migrateTrailingCategories dom pass should leave template content alone
16998 !! wikitext
16999 *{{echo|a
17000 [[Category:Foo]]}}
17001 !! html/parsoid
17002 <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
17003 </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>
17004 !! end
17005
17006 !! test
17007 8. Categories and newlines: migrateTrailingCategories dom pass should not get tripped by intervening templates
17008 !! wikitext
17009 *a
17010
17011 {{echo|[[Category:Foo]]
17012 [[Category:Bar]]}}
17013 [[Category:Baz]]
17014 !! html/parsoid
17015 <ul><li>a</li></ul>
17016
17017 <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">
17018 </span><link rel="mw:PageProp/Category" href="./Category:Bar" about="#mwt1" data-parsoid='{"stx":"simple","a":{"href":"./Category:Bar"},"sa":{"href":"Category:Bar"}}'/>
17019 <link rel="mw:PageProp/Category" href="./Category:Baz" data-parsoid='{"stx":"simple","a":{"href":"./Category:Baz"},"sa":{"href":"Category:Baz"}}'/>
17020 !! end
17021
17022 !! test
17023 Categories and newlines: migrateTrailingCategories dom pass should not get tripped by comments and whitespace
17024 !! wikitext
17025 *a
17026
17027 [[Category:Bar]]<!--boo1--> <!--boo2-->
17028 [[Category:Baz]]<!--boo3--> <!--boo4-->
17029 !! html/parsoid
17030 <ul><li>a</li></ul>
17031
17032 <link rel="mw:PageProp/Category" href="./Category:Bar"/><!--boo1--> <!--boo2-->
17033 <link rel="mw:PageProp/Category" href="./Category:Baz"/><!--boo3--> <!--boo4-->
17034 !! end
17035
17036 !! test
17037 Categories and newlines: should behave properly with linkprefix (T87753)
17038 !! options
17039 language=ar
17040 !! wikitext
17041 foo bar
17042 foo bar
17043 [[تصنيف:Foo]]
17044 [[تصنيف:Bar]]
17045 !! html/php
17046 <p>foo bar
17047 foo bar
17048 </p>
17049 !! html/parsoid
17050 <p>foo bar
17051 foo bar</p>
17052 <link rel="mw:PageProp/Category" href="./تصنيف:Foo"/>
17053 <link rel="mw:PageProp/Category" href="./تصنيف:Bar"/>
17054 !! end
17055
17056 !! test
17057 No regressions on internal links following category (T174639)
17058 !! options
17059 parsoid=wt2html,html2html
17060 !! wikitext
17061 [[Category:Foo]]<div>a
17062
17063 [[Foo]]</div>
17064 !! html/php
17065 <div>a
17066 <a href="/wiki/Foo" title="Foo">Foo</a></div>
17067
17068 !! html/parsoid
17069 <link rel="mw:PageProp/Category" href="./Category:Foo"/><div>a
17070
17071 <a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></div>
17072 !! end
17073
17074 # Note that Parsoid differs slightly from PHP due to T175421
17075 !! test
17076 11. Special case where only newlines separate links (T175416)
17077 !! options
17078 parsoid=wt2html,html2html
17079 !! wikitext
17080 [[Category:Foo]]
17081
17082 [[Foo]][[es:Alimento]]
17083
17084 [[Foo]]
17085 !! html/php
17086 <p><br />
17087 <a href="/wiki/Foo" title="Foo">Foo</a>
17088 </p><p><a href="/wiki/Foo" title="Foo">Foo</a>
17089 </p>
17090 !! html/parsoid
17091 <link rel="mw:PageProp/Category" href="./Category:Foo"/>
17092
17093 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></p><link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Alimento"/>
17094
17095 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></p>
17096 !! end
17097
17098 !! test
17099 Category links with multiple namespaces
17100 !! wikitext
17101 [[Category:Project:Foo]]
17102 !! html/parsoid
17103 <link rel="mw:PageProp/Category" href="./Category:Project:Foo" />
17104 !! end
17105
17106 !! test
17107 Parsoid: Serialize link to category page with colon escape
17108 !! wikitext
17109
17110 [[:Category:Foo]]
17111 [[:Category:Foo|Bar]]
17112 !! html/php+tidy
17113 <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>
17114 <a href="/index.php?title=Category:Foo&amp;action=edit&amp;redlink=1" class="new" title="Category:Foo (page does not exist)">Bar</a>
17115 </p>
17116 !! html/parsoid
17117 <p>
17118 <a rel="mw:WikiLink" href="./Category:Foo" title="Category:Foo">Category:Foo</a>
17119 <a rel="mw:WikiLink" href="./Category:Foo" title="Category:Foo">Bar</a>
17120 </p>
17121 !! end
17122
17123 # We used to, but no longer wt2wt this test since the default serializer
17124 # will normalize all categories to serialize on their own line.
17125 # This wikitext usage is going to be fairly uncommon in production and
17126 # selser will take care of preventing whitespace insertion if this
17127 # occurs in an article.
17128 #
17129 # html2html disabled for the same reason (whitespace insertion between
17130 # x and y).
17131 #
17132 # html2wt disabled because it localizes the "Category" namespace.
17133 !! test
17134 Link prefix/suffixes aren't applied to category links
17135 !! options
17136 parsoid=wt2html
17137 language=is
17138 !! wikitext
17139 x[[Category:Foo]]y
17140 !! html/php
17141 <p>xy
17142 </p>
17143 !! html/parsoid
17144 <p>x<link rel="mw:PageProp/Category" href="./Flokkur:Foo" data-parsoid=""/>y</p>
17145 !! end
17146
17147 !! test
17148 Link prefix/suffixes aren't applied to language links
17149 !! options
17150 parsoid=wt2html
17151 language=is
17152 !! wikitext
17153 x[[es:Foo]]y
17154 !! html/php
17155 <p>xy
17156 </p>
17157 !! html/parsoid
17158 <p>x<link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo" data-parsoid=""/>y</p>
17159 !! end
17160
17161 !! test
17162 Parsoid: Serialize link to file page with colon escape
17163 !! wikitext
17164
17165 [[:File:Foo.png]]
17166 [[:File:Foo.png|Bar]]
17167 !! html/php+tidy
17168 <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>
17169 <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>
17170 </p>
17171 !! html/parsoid
17172 <p>
17173 <a rel="mw:WikiLink" href="./File:Foo.png" title="File:Foo.png">File:Foo.png</a>
17174 <a rel="mw:WikiLink" href="./File:Foo.png" title="File:Foo.png">Bar</a>
17175 </p>
17176 !! end
17177
17178 !! test
17179 Parsoid: Serialize a genuine category link without colon escape
17180 !! wikitext
17181 [[Category:Foo]]
17182 [[Category:Foo|Bar]]
17183 !! html/php+tidy
17184 !! html/parsoid
17185 <link rel="mw:PageProp/Category" href="./Category:Foo">
17186 <link rel="mw:PageProp/Category" href="./Category:Foo#Bar">
17187 !! end
17188
17189 !! test
17190 Normalize hrefs properly before testing for invalid link targets (T72894)
17191 !! options
17192 parsoid=html2wt
17193 !! html/parsoid
17194 <link rel="mw:PageProp/Category" href="./Category:Toxine_bactérienne"/>
17195 !! wikitext
17196 [[Category:Toxine bactérienne]]
17197 !! end
17198
17199 !! test
17200 Parsoid: Defaultsort
17201 !! wikitext
17202 {{DEFAULTSORT:Foo}}
17203 !! html/parsoid
17204 <meta property="mw:PageProp/categorydefaultsort" content="Foo"/>
17205 !! end
17206
17207 # NOTE: mw:ExpandedAttrs is not the best typeof here. mw:Transclusion is better.
17208 # But, this is a limitation of our representation and is documented in
17209 # TemplateHandler.js in processSpecialMagicWord
17210 !! test
17211 Parsoid: Defaultsort (template-generated)
17212 !! wikitext
17213 {{{{echo|DEFAULTSORT}}:Foo}}
17214 !! html/parsoid
17215 <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"}]]}'/>
17216 !! end
17217
17218 ###
17219 ### Inter-language links
17220 ###
17221 !! test
17222 Interlanguage links
17223 !! options
17224 ill
17225 !! wikitext
17226 [[es:Alimento]]
17227 [[fr:Nourriture]]
17228 [[zh:食品]]
17229 !! html/php
17230 es:Alimento fr:Nourriture zh:食品
17231 !! html/parsoid
17232 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Alimento"/>
17233 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/Nourriture"/>
17234 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/食品"/>
17235 !! end
17236
17237 !! test
17238 Duplicate interlanguage links (T26502)
17239 !! options
17240 ill
17241 !! wikitext
17242 [[es:1]]
17243 [[es:2]]
17244 [[fr:1]]
17245 [[fr:2]]
17246 !! html/php
17247 es:1 fr:1
17248 !! html/parsoid
17249 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/1"/>
17250 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/2"/>
17251 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/1"/>
17252 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/2"/>
17253 !! end
17254
17255 ###
17256 ### Sections
17257 ###
17258 !! test
17259 Basic section headings
17260 !! wikitext
17261 ==Headline 1==
17262 Some text
17263
17264 ==Headline 2==
17265 More
17266 ===Smaller headline===
17267 Blah blah
17268 !! html
17269 <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>
17270 <p>Some text
17271 </p>
17272 <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>
17273 <p>More
17274 </p>
17275 <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>
17276 <p>Blah blah
17277 </p>
17278 !! end
17279
17280 !! test
17281 Section headings with TOC
17282 !! wikitext
17283 ==Headline 1==
17284 ===Subheadline 1===
17285 =====Skipping a level=====
17286 ======Skipping a level======
17287
17288 ==Headline 2==
17289 Some text
17290 ===Another headline===
17291 !! html
17292 <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>
17293 <ul>
17294 <li class="toclevel-1 tocsection-1"><a href="#Headline_1"><span class="tocnumber">1</span> <span class="toctext">Headline 1</span></a>
17295 <ul>
17296 <li class="toclevel-2 tocsection-2"><a href="#Subheadline_1"><span class="tocnumber">1.1</span> <span class="toctext">Subheadline 1</span></a>
17297 <ul>
17298 <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>
17299 <ul>
17300 <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>
17301 </ul>
17302 </li>
17303 </ul>
17304 </li>
17305 </ul>
17306 </li>
17307 <li class="toclevel-1 tocsection-5"><a href="#Headline_2"><span class="tocnumber">2</span> <span class="toctext">Headline 2</span></a>
17308 <ul>
17309 <li class="toclevel-2 tocsection-6"><a href="#Another_headline"><span class="tocnumber">2.1</span> <span class="toctext">Another headline</span></a></li>
17310 </ul>
17311 </li>
17312 </ul>
17313 </div>
17314
17315 <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>
17316 <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>
17317 <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>
17318 <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>
17319 <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>
17320 <p>Some text
17321 </p>
17322 <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>
17323
17324 !! end
17325
17326 !! test
17327 TOC anchors don't collide
17328 !! wikitext
17329 __FORCETOC__
17330 ==Headline 2==
17331 ==Headline==
17332 ==Headline 2==
17333 ==Headline==
17334 !! html/php
17335 <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>
17336 <ul>
17337 <li class="toclevel-1 tocsection-1"><a href="#Headline_2"><span class="tocnumber">1</span> <span class="toctext">Headline 2</span></a></li>
17338 <li class="toclevel-1 tocsection-2"><a href="#Headline"><span class="tocnumber">2</span> <span class="toctext">Headline</span></a></li>
17339 <li class="toclevel-1 tocsection-3"><a href="#Headline_2_2"><span class="tocnumber">3</span> <span class="toctext">Headline 2</span></a></li>
17340 <li class="toclevel-1 tocsection-4"><a href="#Headline_3"><span class="tocnumber">4</span> <span class="toctext">Headline</span></a></li>
17341 </ul>
17342 </div>
17343
17344 <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>
17345 <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>
17346 <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>
17347 <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>
17348
17349 !! end
17350
17351 # perl -e 'print "="x$_," Level $_ heading","="x$_,"\n" for 1..10'
17352 # Parsoid html2wt direction adds <nowiki> for level 7 and up.
17353 !! test
17354 Handling of sections up to level 6 and beyond
17355 !! options
17356 parsoid=wt2html
17357 !! wikitext
17358 =Level 1 Heading=
17359 ==Level 2 Heading==
17360 ===Level 3 Heading===
17361 ====Level 4 Heading====
17362 =====Level 5 Heading=====
17363 ======Level 6 Heading======
17364 =======Level 7 Heading=======
17365 ========Level 8 Heading========
17366 =========Level 9 Heading=========
17367 ==========Level 10 Heading==========
17368 !! html/php
17369 <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>
17370 <ul>
17371 <li class="toclevel-1 tocsection-1"><a href="#Level_1_Heading"><span class="tocnumber">1</span> <span class="toctext">Level 1 Heading</span></a>
17372 <ul>
17373 <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>
17374 <ul>
17375 <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>
17376 <ul>
17377 <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>
17378 <ul>
17379 <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>
17380 <ul>
17381 <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>
17382 <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>
17383 <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>
17384 <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>
17385 <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>
17386 </ul>
17387 </li>
17388 </ul>
17389 </li>
17390 </ul>
17391 </li>
17392 </ul>
17393 </li>
17394 </ul>
17395 </li>
17396 </ul>
17397 </div>
17398
17399 <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>
17400 <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>
17401 <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>
17402 <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>
17403 <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>
17404 <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>
17405 <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>
17406 <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>
17407 <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>
17408 <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>
17409
17410 !! html/parsoid
17411 <h1 id="Level_1_Heading" data-parsoid='{}'>Level 1 Heading</h1>
17412 <h2 id="Level_2_Heading" data-parsoid='{}'>Level 2 Heading</h2>
17413 <h3 id="Level_3_Heading" data-parsoid='{}'>Level 3 Heading</h3>
17414 <h4 id="Level_4_Heading" data-parsoid='{}'>Level 4 Heading</h4>
17415 <h5 id="Level_5_Heading" data-parsoid='{}'>Level 5 Heading</h5>
17416 <h6 id="Level_6_Heading" data-parsoid='{}'>Level 6 Heading</h6>
17417 <h6 id="=Level_7_Heading=" data-parsoid='{}'><span id=".3DLevel_7_Heading.3D" typeof="mw:FallbackId"></span>=Level 7 Heading=</h6>
17418 <h6 id="==Level_8_Heading==" data-parsoid='{}'><span id=".3D.3DLevel_8_Heading.3D.3D" typeof="mw:FallbackId"></span>==Level 8 Heading==</h6>
17419 <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>
17420 <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>
17421 !! end
17422
17423 !! test
17424 TOC regression (T11764)
17425 !! wikitext
17426 ==title 1==
17427 ===title 1.1===
17428 ====title 1.1.1====
17429 ===title 1.2===
17430 ==title 2==
17431 ===title 2.1===
17432 !! html
17433 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
17434 <ul>
17435 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
17436 <ul>
17437 <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>
17438 <ul>
17439 <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>
17440 </ul>
17441 </li>
17442 <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>
17443 </ul>
17444 </li>
17445 <li class="toclevel-1 tocsection-5"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a>
17446 <ul>
17447 <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>
17448 </ul>
17449 </li>
17450 </ul>
17451 </div>
17452
17453 <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>
17454 <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>
17455 <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>
17456 <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>
17457 <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>
17458 <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>
17459
17460 !! end
17461
17462 !! test
17463 TOC for heading containing <span id="..."></span> (T96153)
17464 !! wikitext
17465 __FORCETOC__
17466 ==<span id="old-anchor"></span>New title==
17467 !! html/php
17468 <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>
17469 <ul>
17470 <li class="toclevel-1 tocsection-1"><a href="#New_title"><span class="tocnumber">1</span> <span class="toctext">New title</span></a></li>
17471 </ul>
17472 </div>
17473
17474 <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>
17475
17476 !! end
17477
17478 !! test
17479 TOC with wgMaxTocLevel=3 (T8204)
17480 !! options
17481 wgMaxTocLevel=3
17482 !! wikitext
17483 ==title 1==
17484 ===title 1.1===
17485 ====title 1.1.1====
17486 ===title 1.2===
17487 ==title 2==
17488 ===title 2.1===
17489 !! html
17490 <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>
17491 <ul>
17492 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
17493 <ul>
17494 <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>
17495 <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>
17496 </ul>
17497 </li>
17498 <li class="toclevel-1 tocsection-5"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a>
17499 <ul>
17500 <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>
17501 </ul>
17502 </li>
17503 </ul>
17504 </div>
17505
17506 <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>
17507 <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>
17508 <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>
17509 <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>
17510 <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>
17511 <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>
17512
17513 !! end
17514
17515 !! test
17516 TOC with wgMaxTocLevel=3 and two level four headings (T8204)
17517 !! options
17518 wgMaxTocLevel=3
17519 !! wikitext
17520 ==Section 1==
17521 ===Section 1.1===
17522 ====Section 1.1.1====
17523 ====Section 1.1.1.1====
17524 ==Section 2==
17525 !! html
17526 <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>
17527 <ul>
17528 <li class="toclevel-1 tocsection-1"><a href="#Section_1"><span class="tocnumber">1</span> <span class="toctext">Section 1</span></a>
17529 <ul>
17530 <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>
17531 </ul>
17532 </li>
17533 <li class="toclevel-1 tocsection-5"><a href="#Section_2"><span class="tocnumber">2</span> <span class="toctext">Section 2</span></a></li>
17534 </ul>
17535 </div>
17536
17537 <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>
17538 <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>
17539 <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>
17540 <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>
17541 <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>
17542
17543 !! end
17544
17545
17546 !! test
17547 Resolving duplicate section names
17548 !! wikitext
17549 ==Foo bar==
17550 ==Foo bar==
17551 !! html
17552 <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>
17553 <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>
17554
17555 !! end
17556
17557 !! test
17558 Resolving duplicate section names with differing case (T12721)
17559 !! wikitext
17560 ==Foo bar==
17561 ==Foo Bar==
17562 !! html
17563 <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>
17564 <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>
17565
17566 !! end
17567
17568 !! article
17569 Template:sections
17570 !! text
17571 ===Section 1===
17572 ==Section 2==
17573 !! endarticle
17574
17575 !! test
17576 Template with sections, __NOTOC__
17577 !! wikitext
17578 __NOTOC__
17579 ==Section 0==
17580 {{sections}}
17581 ==Section 4==
17582 !! html
17583 <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>
17584 <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>
17585 <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>
17586 <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>
17587
17588 !! end
17589
17590 !! test
17591 __NOEDITSECTION__ keyword
17592 !! wikitext
17593 __NOEDITSECTION__
17594 ==Section 1==
17595 ==Section 2==
17596 !! html
17597 <h2><span class="mw-headline" id="Section_1">Section 1</span></h2>
17598 <h2><span class="mw-headline" id="Section_2">Section 2</span></h2>
17599
17600 !! end
17601
17602 !! test
17603 Link inside a section heading
17604 !! wikitext
17605 ==Section with a [[Main Page|link]] in it==
17606 !! html
17607 <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>
17608
17609 !! end
17610
17611 !! test
17612 TOC regression (T14077)
17613 !! wikitext
17614 __TOC__
17615 ==title 1==
17616 ===title 1.1===
17617 ==title 2==
17618 !! html
17619 <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>
17620 <ul>
17621 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
17622 <ul>
17623 <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>
17624 </ul>
17625 </li>
17626 <li class="toclevel-1 tocsection-3"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a></li>
17627 </ul>
17628 </div>
17629
17630 <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>
17631 <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>
17632 <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>
17633
17634 !! end
17635
17636 !! test
17637 T3219 URL next to image (good)
17638 !! wikitext
17639 http://example.com [[File:Foobar.jpg]]
17640 !! html/php
17641 <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>
17642 </p>
17643 !! html/parsoid
17644 <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>
17645 !!end
17646
17647 # Parsoid doesn't wt2wt this cleanly because it adds <nowiki>s.
17648 !! test
17649 Short headings with trailing space should match behavior of Parser::doHeadings (T21910)
17650 !! options
17651 parsoid=wt2html,html2html
17652 !! wikitext
17653 ===
17654 The line above must have a trailing space!
17655 === <!--
17656 --> <!-- -->
17657 But just in case it doesn't...
17658 !! html/php
17659 <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>
17660 <p>The line above must have a trailing space!
17661 </p>
17662 <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>
17663 <p>But just in case it doesn't...
17664 </p>
17665 !! html/parsoid
17666 <h1 id="="><span id=".3D" typeof="mw:FallbackId"></span>=</h1>
17667 <p>The line above must have a trailing space!</p>
17668 <h1 id="=_2"><span id=".3D_2" typeof="mw:FallbackId"></span>=</h1> <!--
17669 --> <!-- -->
17670 <p>But just in case it doesn't...</p>
17671 !! end
17672
17673 !! test
17674 Header with special characters (T27462)
17675 !! wikitext
17676 The tooltips shall not show entities to the user (ie. be double escaped)
17677
17678 ==text > text==
17679 section 1
17680
17681 ==text < text==
17682 section 2
17683
17684 ==text & text==
17685 section 3
17686
17687 ==text ' text==
17688 section 4
17689
17690 ==text " text==
17691 section 5
17692 !! html/php
17693 <p>The tooltips shall not show entities to the user (ie. be double escaped)
17694 </p>
17695 <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>
17696 <ul>
17697 <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>
17698 <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>
17699 <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>
17700 <li class="toclevel-1 tocsection-4"><a href="#text_.27_text"><span class="tocnumber">4</span> <span class="toctext">text ' text</span></a></li>
17701 <li class="toclevel-1 tocsection-5"><a href="#text_.22_text"><span class="tocnumber">5</span> <span class="toctext">text " text</span></a></li>
17702 </ul>
17703 </div>
17704
17705 <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>
17706 <p>section 1
17707 </p>
17708 <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>
17709 <p>section 2
17710 </p>
17711 <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>
17712 <p>section 3
17713 </p>
17714 <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>
17715 <p>section 4
17716 </p>
17717 <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>
17718 <p>section 5
17719 </p>
17720 !! html/parsoid
17721 <p>The tooltips shall not show entities to the user (ie. be double escaped)</p>
17722
17723 <h2 id="text_>_text"><span id="text_.3E_text" typeof="mw:FallbackId"></span>text > text</h2>
17724 <p>section 1</p>
17725
17726 <h2 id="text_&lt;_text"><span id="text_.3C_text" typeof="mw:FallbackId"></span>text &lt; text</h2>
17727 <p>section 2</p>
17728
17729 <h2 id="text_&amp;_text"><span id="text_.26_text" typeof="mw:FallbackId"></span>text &amp; text</h2>
17730 <p>section 3</p>
17731
17732 <h2 id="text_'_text"><span id="text_.27_text" typeof="mw:FallbackId"></span>text ' text</h2>
17733 <p>section 4</p>
17734
17735 <h2 id='text_"_text'><span id="text_.22_text" typeof="mw:FallbackId"></span>text " text</h2>
17736 <p>section 5</p>
17737 !! end
17738
17739 !! test
17740 Header with space, plus and underscore as entity
17741 !! wikitext
17742 Id should not contain + for spaces
17743
17744 ==Space between Text==
17745 section 1
17746
17747 ==Space-Entity&#32;between&#32;Text==
17748 section 2
17749
17750 ==Plus+between+Text==
17751 section 3
17752
17753 ==Plus-Entity&#43;between&#43;Text==
17754 section 4
17755
17756 ==Underscore_between_Text==
17757 section 5
17758
17759 ==Underscore-Entity&#95;between&#95;Text==
17760 section 6
17761
17762 [[#Space between Text]]
17763 [[#Space-Entity&#32;between&#32;Text]]
17764 [[#Plus+between+Text]]
17765 [[#Plus-Entity&#43;between&#43;Text]]
17766 [[#Underscore_between_Text]]
17767 [[#Underscore-Entity&#95;between&#95;Text]]
17768 !! html/php
17769 <p>Id should not contain + for spaces
17770 </p>
17771 <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>
17772 <ul>
17773 <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>
17774 <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>
17775 <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>
17776 <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>
17777 <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>
17778 <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>
17779 </ul>
17780 </div>
17781
17782 <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>
17783 <p>section 1
17784 </p>
17785 <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>
17786 <p>section 2
17787 </p>
17788 <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>
17789 <p>section 3
17790 </p>
17791 <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>
17792 <p>section 4
17793 </p>
17794 <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>
17795 <p>section 5
17796 </p>
17797 <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>
17798 <p>section 6
17799 </p><p><a href="#Space_between_Text">#Space between Text</a>
17800 <a href="#Space-Entity_between_Text">#Space-Entity&#32;between&#32;Text</a>
17801 <a href="#Plus.2Bbetween.2BText">#Plus+between+Text</a>
17802 <a href="#Plus-Entity.2Bbetween.2BText">#Plus-Entity&#43;between&#43;Text</a>
17803 <a href="#Underscore_between_Text">#Underscore_between_Text</a>
17804 <a href="#Underscore-Entity_between_Text">#Underscore-Entity&#95;between&#95;Text</a>
17805 </p>
17806 !! html/parsoid
17807 <p>Id should not contain + for spaces</p>
17808
17809 <h2 id="Space_between_Text">Space between Text</h2>
17810 <p>section 1</p>
17811
17812 <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>
17813 <p>section 2</p>
17814
17815 <h2 id="Plus+between+Text"><span id="Plus.2Bbetween.2BText" typeof="mw:FallbackId"></span>Plus+between+Text</h2>
17816 <p>section 3</p>
17817
17818 <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>
17819 <p>section 4</p>
17820
17821 <h2 id="Underscore_between_Text">Underscore_between_Text</h2>
17822 <p>section 5</p>
17823
17824 <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>
17825 <p>section 6</p>
17826
17827 <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>
17828 <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>
17829 <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>
17830 <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>
17831 <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>
17832 <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>
17833 !! end
17834
17835 # Parsoid html2wt disabled because it adds padding spaces around =
17836 !! test
17837 Headers with excess '=' characters
17838 (Are similar tests necessary beyond the 1st level?)
17839 !! options
17840 parsoid=wt2html,wt2wt,html2html
17841 !! wikitext
17842 =foo==
17843 ==foo=
17844 =''italic'' heading==
17845 ==''italic'' heading=
17846 !! html/php
17847 <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>
17848 <ul>
17849 <li class="toclevel-1 tocsection-1"><a href="#foo.3D"><span class="tocnumber">1</span> <span class="toctext">foo=</span></a></li>
17850 <li class="toclevel-1 tocsection-2"><a href="#.3Dfoo"><span class="tocnumber">2</span> <span class="toctext">=foo</span></a></li>
17851 <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>
17852 <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>
17853 </ul>
17854 </div>
17855
17856 <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>
17857 <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>
17858 <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>
17859 <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>
17860
17861 !! html/parsoid
17862 <h1 id="foo="><span id="foo.3D" typeof="mw:FallbackId"></span>foo=</h1>
17863 <h1 id="=foo"><span id=".3Dfoo" typeof="mw:FallbackId"></span>=foo</h1>
17864 <h1 id="italic_heading="><span id="italic_heading.3D" typeof="mw:FallbackId"></span><i>italic</i> heading=</h1>
17865 <h1 id="=italic_heading"><span id=".3Ditalic_heading" typeof="mw:FallbackId"></span>=<i>italic</i> heading</h1>
17866 !! end
17867
17868 !! test
17869 HTML headers vs TOC (T25393)
17870 (__NOEDITSECTION__ for clearer output, doesn't matter here)
17871 !! wikitext
17872 <h1>Header 1</h1>
17873 ==Header 1.1==
17874 ==Header 1.2==
17875
17876 <h1>Header 2
17877 </h1>
17878 ==Header 2.1==
17879 ==Header 2.2==
17880 __NOEDITSECTION__
17881 !! html/php
17882 <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>
17883 <ul>
17884 <li class="toclevel-1"><a href="#Header_1"><span class="tocnumber">1</span> <span class="toctext">Header 1</span></a>
17885 <ul>
17886 <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>
17887 <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>
17888 </ul>
17889 </li>
17890 <li class="toclevel-1"><a href="#Header_2"><span class="tocnumber">2</span> <span class="toctext">Header 2</span></a>
17891 <ul>
17892 <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>
17893 <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>
17894 </ul>
17895 </li>
17896 </ul>
17897 </div>
17898
17899 <h1><span class="mw-headline" id="Header_1">Header 1</span></h1>
17900 <h2><span class="mw-headline" id="Header_1.1">Header 1.1</span></h2>
17901 <h2><span class="mw-headline" id="Header_1.2">Header 1.2</span></h2>
17902 <h1><span class="mw-headline" id="Header_2">Header 2
17903 </span></h1>
17904 <h2><span class="mw-headline" id="Header_2.1">Header 2.1</span></h2>
17905 <h2><span class="mw-headline" id="Header_2.2">Header 2.2</span></h2>
17906
17907 !! html/parsoid
17908 <h1 id="Header_1" data-parsoid='{"stx":"html"}'>Header 1</h1>
17909 <h2 id="Header_1.1" data-parsoid='{}'>Header 1.1</h2>
17910 <h2 id="Header_1.2" data-parsoid='{}'>Header 1.2</h2>
17911
17912 <h1 id="Header_2" data-parsoid='{"stx":"html"}'>Header 2
17913 </h1>
17914 <h2 id="Header_2.1" data-parsoid='{}'>Header 2.1</h2>
17915 <h2 id="Header_2.2" data-parsoid='{}'>Header 2.2</h2>
17916 <meta property="mw:PageProp/noeditsection"/>
17917 !! end
17918
17919 !! test
17920 Single-line or multiline-comments can follow headings
17921 !! options
17922 parsoid=wt2html,wt2wt
17923 !! wikitext
17924 ==foo==<!---->
17925 ==bar==<!--c1-->
17926 ==baz==<!--
17927 c2
17928 c3-->
17929 !! html/php
17930 <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>
17931 <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>
17932 <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>
17933
17934 !! html/parsoid
17935 <h2 id="foo">foo</h2><!---->
17936 <h2 id="bar">bar</h2><!--c1-->
17937 <h2 id="baz">baz</h2><!--
17938 c2
17939 c3-->
17940 !! end
17941
17942 !! test
17943 T3219 URL next to image (broken)
17944 !! wikitext
17945 http://example.com[[File:Foobar.jpg]]
17946 !! html/php
17947 <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>
17948 </p>
17949 !! html/parsoid
17950 <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>
17951 !!end
17952
17953 !! test
17954 T3186 news: in the middle of text
17955 !! wikitext
17956 http://en.wikinews.org/wiki/Wikinews:Workplace
17957 !! html
17958 <p><a rel="nofollow" class="external free" href="http://en.wikinews.org/wiki/Wikinews:Workplace">http://en.wikinews.org/wiki/Wikinews:Workplace</a>
17959 </p>
17960 !!end
17961
17962
17963 !! test
17964 Namespaced link must have a title
17965 !! wikitext
17966 [[Project:]]
17967 !! html
17968 <p>[[Project:]]
17969 </p>
17970 !!end
17971
17972 !! test
17973 Namespaced link must have a title (bad fragment version)
17974 !! wikitext
17975 [[Project:#fragment]]
17976 !! html
17977 <p>[[Project:#fragment]]
17978 </p>
17979 !!end
17980
17981
17982 ###
17983 ### HTML tags and HTML attributes
17984 ###
17985
17986 !! test
17987 div with no attributes
17988 !! wikitext
17989 <div>HTML rocks</div>
17990 !! html
17991 <div>HTML rocks</div>
17992
17993 !! end
17994
17995 !! test
17996 div with double-quoted attribute
17997 !! wikitext
17998 <div id="rock">HTML rocks</div>
17999 !! html
18000 <div id="rock">HTML rocks</div>
18001
18002 !! end
18003
18004 !! test
18005 div with single-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 unquoted 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 illegal double attributes
18024 !! wikitext
18025 <div id="a" id="b">HTML rocks</div>
18026 !! html
18027 <div id="b">HTML rocks</div>
18028
18029 !!end
18030
18031 !! test
18032 div with empty attribute value, space before equals
18033 !! options
18034 parsoid=wt2html,html2html
18035 !! wikitext
18036 <div class =>HTML rocks</div>
18037 !! html/php
18038 <div class="">HTML rocks</div>
18039
18040 !! html/parsoid
18041 <div class="" data-parsoid='{"stx":"html"}'>HTML rocks</div>
18042 !! end
18043
18044 !! test
18045 div with multiple empty attribute values
18046 !! config
18047 wgFragmentMode=[ 'html5', 'legacy' ]
18048 !! options
18049 parsoid=wt2html,html2html
18050 !! wikitext
18051 <div id= title=>HTML rocks</div>
18052 !! html/php
18053 <div id="title=">HTML rocks</div>
18054
18055 !! html/parsoid
18056 <div id="title=" data-parsoid='{"stx":"html"}'>HTML rocks</div>
18057 !! end
18058
18059 # FIXME Parsoid doesn't actually match PHP here.
18060 !! test
18061 Extension tag in attribute value
18062 !! options
18063 wgRawHtml=1
18064 !! wikitext
18065 <span title="<html><div>123</div></html>">ok</span>
18066 !! html/php+tidy
18067 <p><span title="&lt;div&gt;123&lt;/div&gt;">ok</span>
18068 </p>
18069 !! html/parsoid
18070 <p><span title="123" about="#mwt4" typeof="mw:ExpandedAttrs" data-parsoid='{"stx":"html","a":{"title":"123"},"sa":{"title":"&lt;html>&lt;div>123&lt;/div>&lt;/html>"}}' data-mw='{"attribs":[[{"txt":"title"},{"html":"&lt;div typeof=\"mw:Extension/html\" about=\"#mwt3\" data-parsoid=&apos;{\"dsr\":[13,40,2,2]}&apos; data-mw=&apos;{\"name\":\"html\",\"attrs\":{},\"body\":{\"extsrc\":\"&amp;lt;div>123&amp;lt;/div>\"}}&apos;>123&lt;/div>"}]]}'>ok</span></p>
18071 !! end
18072
18073 !! test
18074 table with multiple empty attribute values
18075 !! options
18076 parsoid=wt2html,html2html
18077 !! wikitext
18078 {| title= id=
18079 |hi
18080 |}
18081 !! html/php
18082 <table title="id=">
18083 <tr>
18084 <td>hi
18085 </td></tr></table>
18086
18087 !! html/parsoid
18088 <table title="id=">
18089 <tbody><tr><td>hi</td></tr>
18090 </tbody></table>
18091 !! end
18092
18093 !! test
18094 div with braces in attribute value
18095 !! wikitext
18096 <div title="{}">Foo</div>
18097 !! html/php
18098 <div title="&#123;&#125;">Foo</div>
18099
18100 !! html/parsoid
18101 <div title="{}">Foo</div>
18102 !! end
18103
18104 !! test
18105 div with empty attribute value, no space before equals
18106 !! options
18107 parsoid=wt2html,html2html
18108 !! wikitext
18109 <div class=>HTML rocks</div>
18110 !! html/php
18111 <div class="">HTML rocks</div>
18112
18113 !! html/parsoid
18114 <div class="">HTML rocks</div>
18115 !! end
18116
18117 !! test
18118 HTML multiple attributes correction
18119 !! wikitext
18120 <p class="error" class="awesome">Awesome!</p>
18121 !! html
18122 <p class="awesome">Awesome!</p>
18123
18124 !!end
18125
18126 !! test
18127 Table multiple attributes correction
18128 !! wikitext
18129 {|
18130 !+ class="error" class="awesome"|status
18131 |}
18132 !! html
18133 <table>
18134 <tr>
18135 <th class="awesome">status
18136 </th></tr></table>
18137
18138 !!end
18139
18140 !! test
18141 DIV IN UPPERCASE
18142 !! wikitext
18143 <DIV ID="x">HTML ROCKS</DIV>
18144 !! html
18145 <div id="x">HTML ROCKS</div>
18146
18147 !!end
18148
18149 !! test
18150 Non-ASCII pseudo-tags are rendered as text
18151 !! wikitext
18152 <khyô>
18153 !! html
18154 <p>&lt;khyô&gt;
18155 </p>
18156 !! end
18157
18158 !! test
18159 Pseudo-tag with URL 'name' renders as url link
18160 !! wikitext
18161 <http://example.com/>
18162 !! html
18163 <p>&lt;<a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a>&gt;
18164 </p>
18165 !! end
18166
18167 !! test
18168 text with amp in the middle of nowhere
18169 !! wikitext
18170 Remember AT&T?
18171 !! html
18172 <p>Remember AT&amp;T?
18173 </p>
18174 !! end
18175
18176 !! test
18177 text with character entity: eacute
18178 !! wikitext
18179 I always thought &eacute; was a cute letter.
18180 !! html+tidy
18181 <p>I always thought &#233; was a cute letter.
18182 </p>
18183 !! end
18184
18185 !! test
18186 text with entity-escaped character entity-like string: eacute
18187 !! wikitext
18188 I always thought &amp;eacute; was a cute letter.
18189 !! html
18190 <p>I always thought &amp;eacute; was a cute letter.
18191 </p>
18192 !! end
18193
18194 !! test
18195 text with undefined character entity: xacute
18196 !! wikitext
18197 I always thought &xacute; was a cute letter.
18198 !! html
18199 <p>I always thought &amp;xacute; was a cute letter.
18200 </p>
18201 !! end
18202
18203 !! test
18204 HTML5 tags
18205 !! wikitext
18206 <data value="5">five</data>
18207 <time datetime="2000-01-01T00:00Z">The new millenium started</time>
18208 <mark>This highlighted text</mark>
18209 !! html
18210 <p><data value="5">five</data>
18211 <time datetime="2000-01-01T00:00Z">The new millenium started</time>
18212 <mark>This highlighted text</mark>
18213 </p>
18214 !! end
18215
18216 !! test
18217 HTML tag with leading space is parsed as text
18218 !! wikitext
18219 < div>foo< /div>
18220 !! html
18221 <p>&lt; div&gt;foo&lt; /div&gt;
18222 </p>
18223 !! end
18224
18225 ## FIXME: The untrimmed attribute in Parsoid is T205737
18226 !! test
18227 Element with broken attribute syntax
18228 !! options
18229 parsoid=wt2html
18230 !! wikitext
18231 <div style=" style="123">hi</div>
18232 <div =>ho</div>
18233 !! html/php
18234 <div style="style=">hi</div>
18235 <div>ho</div>
18236
18237 !! html/parsoid
18238 <div style=" style=" data-parsoid='{"stx":"html","a":{"123\"":null},"sa":{"123\"":""}}'>hi</div>
18239 <div data-parsoid='{"stx":"html","a":{"=":null},"sa":{"=":""}}'>ho</div>
18240 !! end
18241
18242 ###
18243 ### Nesting tests (see T43545, T52604, T53081)
18244 ###
18245
18246 # This test case is fixed in Parsoid by domino 1.0.12. (T52604)
18247 # Note that html2wt is considerably more difficult if we use <b> in
18248 # the test case, instead of <small>
18249 !! test
18250 Ensure that HTML adoption agency algorithm is properly implemented.
18251 !! wikitext
18252 <small>X<small>Y</small>Z</small>
18253 !! html
18254 <p><small>X<small>Y</small>Z</small>
18255 </p>
18256 !! end
18257
18258 # This was T43545 in the PHP parser.
18259 !! test
18260 Nesting of <kbd>
18261 !! wikitext
18262 <kbd>X<kbd>Y</kbd>Z</kbd>
18263 !! html+tidy
18264 <p><kbd>X<kbd>Y</kbd>Z</kbd>
18265 </p>
18266 !! end
18267
18268 # The following cases were T53081 in the PHP parser.
18269 # Note that there are some other nestable tags (b, i, etc) which are
18270 # not covered; see T53081 for discussion.
18271
18272 !! test
18273 Nesting of <em>
18274 !! wikitext
18275 <em>X<em>Y</em>Z</em>
18276 !! html+tidy
18277 <p><em>X<em>Y</em>Z</em>
18278 </p>
18279 !! end
18280
18281 !! test
18282 Nesting of <strong>
18283 !! wikitext
18284 <strong>X<strong>Y</strong>Z</strong>
18285 !! html+tidy
18286 <p><strong>X<strong>Y</strong>Z</strong>
18287 </p>
18288 !! end
18289
18290 !! test
18291 Nesting of <q>
18292 !! wikitext
18293 <q>X<q>Y</q>Z</q>
18294 !! html+tidy
18295 <p><q>X<q>Y</q>Z</q>
18296 </p>
18297 !! end
18298
18299 !! test
18300 Nesting of <ruby>
18301 !! wikitext
18302 <ruby>X<ruby>Y</ruby>Z</ruby>
18303 !! html
18304 <p><ruby>X<ruby>Y</ruby>Z</ruby>
18305 </p>
18306 !! end
18307
18308 !! test
18309 Nesting of <bdo>
18310 !! wikitext
18311 <bdo>X<bdo>Y</bdo>Z</bdo>
18312 !! html
18313 <p><bdo>X<bdo>Y</bdo>Z</bdo>
18314 </p>
18315 !! end
18316
18317
18318 ###
18319 ### Media links
18320 ###
18321
18322 !! test
18323 Media link
18324 !! wikitext
18325 [[Media:Foobar.jpg]]
18326 [[Media:Video.ogv]]
18327 [[:Media:Video.ogv]]
18328 !! html/php
18329 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Media:Foobar.jpg</a>
18330 <a href="http://example.com/images/0/00/Video.ogv" class="internal" title="Video.ogv">Media:Video.ogv</a>
18331 <a href="http://example.com/images/0/00/Video.ogv" class="internal" title="Video.ogv">Media:Video.ogv</a>
18332 </p>
18333 !! html/parsoid
18334 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" resource="./Media:Foobar.jpg" title="Foobar.jpg">Media:Foobar.jpg</a>
18335 <a rel="mw:MediaLink" href="//example.com/images/0/00/Video.ogv" resource="./Media:Video.ogv" title="Video.ogv">Media:Video.ogv</a>
18336 <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>
18337 !! end
18338
18339 !! test
18340 Media link with text
18341 !! wikitext
18342 [[Media:Foobar.jpg|A neat file to look at]]
18343 !! html/php
18344 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">A neat file to look at</a>
18345 </p>
18346 !! html/parsoid
18347 <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>
18348 !! end
18349
18350 !! test
18351 Localized media link
18352 !! options
18353 language=is
18354 !! wikitext
18355 [[Miðill:Foobar.jpg]]
18356
18357 [[Miðill:Foobar.jpg|Icelandic]]
18358 !! html/php
18359 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Miðill:Foobar.jpg</a>
18360 </p><p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Icelandic</a>
18361 </p>
18362 !! html/parsoid
18363 <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>
18364 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" resource="./Miðill:Foobar.jpg" title="Foobar.jpg">Icelandic</a></p>
18365 !! end
18366
18367 # FIXME: this is still bad HTML tag nesting
18368 # FIXME: doBlockLevels won't wrap this in a paragraph because it contains a div
18369 # Parsoid & Remex fix the p-wrapping since they operate on the DOM.
18370 !! test
18371 Media link with nasty text
18372 !! options
18373 parsoid=wt2html,html2html
18374 !! wikitext
18375 [[Media:Foobar.jpg|Safe Link<div style=display:none>" onmouseover="alert(document.cookie)" onfoo="</div>]]
18376 !! html/php
18377 <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>
18378
18379 !! html/php+tidy
18380 <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>
18381 !! html/parsoid
18382 <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>
18383 !! end
18384
18385 !! test
18386 Media link from missing resource (parsoid-only)
18387 !! options
18388 parsoid=html2wt
18389 !! html/parsoid
18390 <a rel="mw:MediaLink" href="http://example.com/images/3/3a/Foobar.jpg">Bat!</a>
18391 !! wikitext
18392 [[Media:Foobar.jpg|Bat!]]
18393 !! end
18394
18395 !! test
18396 Media link from missing resource, localized (parsoid-only)
18397 !! options
18398 parsoid=html2wt
18399 language=is
18400 !! html/parsoid
18401 <a rel="mw:MediaLink" href="http://example.com/images/3/3a/Foobar.jpg">Bat!</a>
18402 !! wikitext
18403 [[Miðill:Foobar.jpg|Bat!]]
18404 !! end
18405
18406 # This is a sanity test to ensure we don't crash or choke when given
18407 # old cached 1.7.0 HTML for media links; we don't require that the
18408 # result be "valid" because wt2wt was completely broken in 1.7.0
18409 !! test
18410 Media link from old 1.7.0 DOM spec (crash test, parsoid-only) T198511
18411 !! options
18412 parsoid=html2wt
18413 !! html/parsoid
18414 <p>This is what Parsoid would emit (and we still handle this HTML fine):</p>
18415 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg">A neat file to look at</a></p>
18416 <p>But VisualEditor would mangle the rel attribute, and give us back this:</p>
18417 <p><a rel="mw:ExtLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg">A neat file to look at</a></p>
18418 <p>But at least we don't crash when trying to handle the mangled HTML!</p>
18419 !! wikitext
18420 This is what Parsoid would emit (and we still handle this HTML fine):
18421
18422 [[Media:Foobar.jpg|A neat file to look at]]
18423
18424 But VisualEditor would mangle the rel attribute, and give us back this:
18425
18426 [//example.com/images/3/3a/Foobar.jpg A neat file to look at]
18427
18428 But at least we don't crash when trying to handle the mangled HTML!
18429 !! end
18430
18431 !! test
18432 Media link to nonexistent file (T3702)
18433 !! wikitext
18434 [[Media:No such.jpg]]
18435 [[Media:No_such file.jpg]]
18436 !! html/php
18437 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=No_such.jpg" class="new" title="No such.jpg">Media:No such.jpg</a>
18438 <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>
18439 </p>
18440 !! html/parsoid
18441 <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>
18442 <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>
18443 !! end
18444
18445 !! test
18446 Image link to nonexistent file (T3850 - good)
18447 !! wikitext
18448 [[File:No_such.jpg]]
18449 !! html/php
18450 <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>
18451 </p>
18452 !! html/parsoid
18453 <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>
18454 !! end
18455
18456 !! test
18457 :Image link to nonexistent file (T3850 - bad)
18458 !! wikitext
18459 [[:Image:No such.jpg]]
18460 !! html/php
18461 <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>
18462 </p>
18463 !! html/parsoid
18464 <p><a rel="mw:WikiLink" href="./File:No_such.jpg" title="File:No such.jpg">Image:No such.jpg</a></p>
18465 !! end
18466
18467 !! test
18468 Character reference normalization in link text (T3938)
18469 !! wikitext
18470 [[Main Page|this&that]]
18471 !! html
18472 <p><a href="/wiki/Main_Page" title="Main Page">this&amp;that</a>
18473 </p>
18474 !!end
18475
18476 !! article
18477 אַ
18478 !! text
18479 Test for unicode normalization
18480
18481 The page's name is U+05d0 U+05b7, with non-canonical form U+FB2E
18482 !! endarticle
18483
18484 !! test
18485 (T21451) Links should refer to the normalized form.
18486 !! wikitext
18487 [[&#xFB2E;]]
18488 [[&#x5d0;&#x5b7;]]
18489 [[&#x5d0;ַ]]
18490 [[א&#x5b7;]]
18491 [[אַ]]
18492 !! html
18493 <p><a href="/wiki/%D7%90%D6%B7" title="אַ">&#xfb2e;</a>
18494 <a href="/wiki/%D7%90%D6%B7" title="אַ">&#x5d0;&#x5b7;</a>
18495 <a href="/wiki/%D7%90%D6%B7" title="אַ">&#x5d0;ַ</a>
18496 <a href="/wiki/%D7%90%D6%B7" title="אַ">א&#x5b7;</a>
18497 <a href="/wiki/%D7%90%D6%B7" title="אַ">אַ</a>
18498 </p>
18499 !! end
18500
18501 !! test
18502 Empty attribute crash test (T4067)
18503 !! wikitext
18504 <font color="">foo</font>
18505 !! html
18506 <p><font color="">foo</font>
18507 </p>
18508 !! end
18509
18510 !! test
18511 Empty attribute crash test single-quotes (T4067)
18512 !! wikitext
18513 <font color=''>foo</font>
18514 !! html
18515 <p><font color="">foo</font>
18516 </p>
18517 !! end
18518
18519 !! test
18520 Attribute test: equals, then nothing
18521 !! options
18522 parsoid=wt2html,html2html
18523 !! wikitext
18524 <font color=>foo</font>
18525 !! html/php
18526 <p><font color="">foo</font>
18527 </p>
18528 !! html/parsoid
18529 <p><font color="" data-parsoid='{"stx":"html"}'>foo</font></p>
18530 !! end
18531
18532 !! test
18533 Attribute test: unquoted value
18534 !! options
18535 parsoid=wt2html,html2html
18536 !! wikitext
18537 <font color=x>foo</font>
18538 !! html/php
18539 <p><font color="x">foo</font>
18540 </p>
18541 !! html/parsoid
18542 <p><font color="x" data-parsoid='{"stx":"html"}'>foo</font></p>
18543 !! end
18544
18545 !! test
18546 Attribute test: unquoted but illegal value (hash)
18547 !! wikitext
18548 <font color=#x>foo</font>
18549 !! html
18550 <p><font color="#x">foo</font>
18551 </p>
18552 !! end
18553
18554 # Parsoid does not serialize to empty attribute syntax,
18555 # so wt2wt and html2wt cases are skipped
18556 !! test
18557 Attribute test: no value (T54330)
18558 !! options
18559 parsoid=wt2html,html2html
18560 !! wikitext
18561 <font color>foo</font>
18562 !! html/php
18563 <p><font color="">foo</font>
18564 </p>
18565 !! html/parsoid
18566 <p><font color="">foo</font></p>
18567 !! end
18568
18569 !! test
18570 T4095: link with three closing brackets
18571 !! wikitext
18572 [[Main Page]]]
18573 !! html/php
18574 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>]
18575 </p>
18576 !! html/parsoid
18577 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a>]</p>
18578 !! end
18579
18580 !! test
18581 T4095: link with pipe and three closing brackets
18582 !! wikitext
18583 [[Main Page|link]]]
18584 !! html/php
18585 <p><a href="/wiki/Main_Page" title="Main Page">link</a>]
18586 </p>
18587 !! html/parsoid
18588 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">link</a>]</p>
18589 !! end
18590
18591 !! test
18592 T4095: link with pipe and three closing brackets, version 2
18593 !! wikitext
18594 [[Main Page|[http://example.com/]]]
18595 !! html/php
18596 <p><a href="/wiki/Main_Page" title="Main Page">[http://example.com/]</a>
18597 </p>
18598 !! html/parsoid
18599 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">[http://example.com/]</a></p>
18600 !! end
18601
18602
18603 ###
18604 ### Safety
18605 ###
18606
18607 !! article
18608 Template:Dangerous attribute
18609 !! text
18610 " onmouseover="alert(document.cookie)
18611 !! endarticle
18612
18613 !! article
18614 Template:Dangerous style attribute
18615 !! text
18616 border-size: expression(alert(document.cookie))
18617 !! endarticle
18618
18619 !! article
18620 Template:Div style
18621 !! text
18622 <div style="float: right; {{{1}}}">Magic div</div>
18623 !! endarticle
18624
18625 !! test
18626 T4304: HTML attribute safety (safe template; regression T4309)
18627 !! wikitext
18628 <div title="{{test}}"></div>
18629 !! html/php
18630 <div title="This is a test template"></div>
18631
18632 !! html/parsoid
18633 <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>
18634 !! end
18635
18636 # Parsoid has enough context to handle this case
18637 !! test
18638 T4304: HTML attribute safety (dangerous template; 2309)
18639 !! wikitext
18640 <div title="{{dangerous attribute}}"></div>
18641 !! html/php
18642 <div title=""></div>
18643
18644 !! html/parsoid
18645 <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>
18646 !! end
18647
18648 !! test
18649 T4304: HTML attribute safety (dangerous style template; 2309)
18650 !! wikitext
18651 <div style="{{dangerous style attribute}}"></div>
18652 !! html/php
18653 <div style="/* insecure input */"></div>
18654
18655 !! html/parsoid
18656 <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>
18657 !! end
18658
18659 !! test
18660 T4304: HTML attribute safety (safe parameter; 2309)
18661 !! wikitext
18662 {{div style|width: 200px}}
18663 !! html/php
18664 <div style="float: right; width: 200px">Magic div</div>
18665
18666 !! html/parsoid
18667 <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>
18668 !! end
18669
18670 !! test
18671 T4304: HTML attribute safety (unsafe parameter; 2309)
18672 !! wikitext
18673 {{div style|width: expression(alert(document.cookie))}}
18674 !! html/php
18675 <div style="/* insecure input */">Magic div</div>
18676
18677 !! html/parsoid
18678 <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>
18679 !! end
18680
18681 ## Parsoid output here differs; needs investigation.
18682 !! test
18683 T4304: HTML attribute safety (unsafe breakout parameter; 2309)
18684 !! wikitext
18685 {{div style|"><script>alert(document.cookie)</script>}}
18686 !! html
18687 <div style="float: right;">&lt;script&gt;alert(document.cookie)&lt;/script&gt;"&gt;Magic div</div>
18688
18689 !! end
18690
18691 ## Parsoid output here differs; needs investigation.
18692 !! test
18693 T4304: HTML attribute safety (unsafe breakout parameter 2; 2309)
18694 !! wikitext
18695 {{div style|" ><script>alert(document.cookie)</script>}}
18696 !! html
18697 <div style="float: right;">&lt;script&gt;alert(document.cookie)&lt;/script&gt;"&gt;Magic div</div>
18698
18699 !! end
18700
18701 !! test
18702 T4304: HTML attribute safety (link)
18703 !! wikitext
18704 <div title="[[Main Page]]"></div>
18705 !! html/php
18706 <div title="&#91;&#91;Main Page&#93;&#93;"></div>
18707
18708 !! html/parsoid
18709 <div title="[[Main Page]]"></div>
18710 !! end
18711
18712 !! test
18713 T4304: HTML attribute safety (italics)
18714 !! wikitext
18715 <div title="''foobar''"></div>
18716 !! html
18717 <div title="&#39;&#39;foobar&#39;&#39;"></div>
18718
18719 !! end
18720
18721 !! test
18722 T4304: HTML attribute safety (bold)
18723 !! wikitext
18724 <div title="'''foobar'''"></div>
18725 !! html
18726 <div title="&#39;&#39;&#39;foobar&#39;&#39;&#39;"></div>
18727
18728 !! end
18729
18730 !! test
18731 T4304: HTML attribute safety (ISBN)
18732 !! wikitext
18733 <div title="ISBN 1234567890"></div>
18734 !! html
18735 <div title="&#73;SBN 1234567890"></div>
18736
18737 !! end
18738
18739 !! test
18740 T4304: HTML attribute safety (RFC)
18741 !! wikitext
18742 <div title="RFC 1234"></div>
18743 !! html
18744 <div title="&#82;FC 1234"></div>
18745
18746 !! end
18747
18748 !! test
18749 T4304: HTML attribute safety (PMID)
18750 !! wikitext
18751 <div title="PMID 1234567890"></div>
18752 !! html
18753 <div title="&#80;MID 1234567890"></div>
18754
18755 !! end
18756
18757 !! test
18758 T4304: HTML attribute safety (web link)
18759 !! wikitext
18760 <div title="http://example.com/"></div>
18761 !! html
18762 <div title="http&#58;//example.com/"></div>
18763
18764 !! end
18765
18766 !! test
18767 T4304: HTML attribute safety (named web link)
18768 !! wikitext
18769 <div title="[http://example.com/ link]"></div>
18770 !! html/php
18771 <div title="&#91;http&#58;//example.com/ link&#93;"></div>
18772
18773 !! html/parsoid
18774 <div title="[http://example.com/ link]"></div>
18775 !! end
18776
18777 !! test
18778 T5244: HTML attribute safety (extension; safe)
18779 !! wikitext
18780 <div style="<nowiki>background:blue</nowiki>"></div>
18781 !! html/php
18782 <div style="background:blue"></div>
18783
18784 !! html/parsoid
18785 <div style="background:blue" about="#mwt3" typeof="mw:ExpandedAttrs" data-parsoid='{"stx":"html","a":{"style":"background:blue"},"sa":{"style":"&lt;nowiki>background:blue&lt;/nowiki>"}}' data-mw='{"attribs":[[{"txt":"style"},{"html":"&lt;span typeof=\"mw:Nowiki\" data-parsoid=&apos;{\"dsr\":[12,44,8,9]}&apos;>background:blue&lt;/span>"}]]}'></div>
18786 !! end
18787
18788 !! test
18789 T5244: HTML attribute safety (extension; unsafe)
18790 !! wikitext
18791 <div style="<nowiki>border-left:expression(alert(document.cookie))</nowiki>"></div>
18792 !! html/php
18793 <div style="/* insecure input */"></div>
18794
18795 !! html/parsoid
18796 <div style="/* insecure input */" about="#mwt3" typeof="mw:ExpandedAttrs" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"&lt;nowiki>border-left:expression(alert(document.cookie))&lt;/nowiki>"}}' data-mw='{"attribs":[[{"txt":"style"},{"html":"&lt;span typeof=\"mw:Nowiki\" data-parsoid=&apos;{\"dsr\":[12,75,8,9]}&apos;>border-left:expression(alert(document.cookie))&lt;/span>"}]]}'></div>
18797 !! end
18798
18799 # More MSIE fun discovered by Tom Gilder
18800
18801 !! test
18802 MSIE CSS safety test: spurious slash
18803 !! wikitext
18804 <div style="background-image:u\rl(javascript:alert('boo'))">evil</div>
18805 !! html/php
18806 <div style="/* insecure input */">evil</div>
18807
18808 !! html/parsoid
18809 <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>
18810 !! end
18811
18812 !! test
18813 MSIE CSS safety test: hex code
18814 !! wikitext
18815 <div style="background-image:u\72l(javascript:alert('boo'))">evil</div>
18816 !! html/php
18817 <div style="/* insecure input */">evil</div>
18818
18819 !! html/parsoid
18820 <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>
18821 !! end
18822
18823 !! test
18824 MSIE CSS safety test: comment in url
18825 !! wikitext
18826 <div style="background-image:u/**/rl(javascript:alert('boo'))">evil</div>
18827 !! html/php
18828 <div style="background-image:u rl(javascript:alert(&#39;boo&#39;))">evil</div>
18829
18830 !! html/parsoid
18831 <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>
18832 !! end
18833
18834 !! test
18835 MSIE CSS safety test: comment in expression
18836 !! wikitext
18837 <div style="background-image:expres/**/sion(alert('boo4'))">evil4</div>
18838 !! html/php
18839 <div style="background-image:expres sion(alert(&#39;boo4&#39;))">evil4</div>
18840
18841 !! html/parsoid
18842 <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>
18843 !! end
18844
18845 !! test
18846 CSS safety test (all browsers): vertical tab (T57332 / CVE-2013-4567)
18847 !! wikitext
18848 <p style="font-size: 100px; background-image:url\b(https://www.google.com/images/srpr/logo6w.png)">A</p>
18849 !! html/php
18850 <p style="/* invalid control char */">A</p>
18851
18852 !! html/parsoid
18853 <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>
18854 !! end
18855
18856 !! test
18857 MSIE 6 CSS safety test: Fullwidth (T57332)
18858 !! wikitext
18859 <p style="font-size: 100px; color: expression((title='XSSed'),'red')">A</p>
18860 <div style="top:EXPRESSION(alert())">B</div>
18861 !! html/php
18862 <p style="/* insecure input */">A</p>
18863 <div style="/* insecure input */">B</div>
18864
18865 !! html/parsoid
18866 <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>
18867 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"top:EXPRESSION(alert())"}}'>B</div>
18868 !! end
18869
18870 !! test
18871 MSIE 6 CSS safety test: IPA extensions (T57332)
18872 !! wikitext
18873 <div style="background-image:uʀʟ(javascript:alert())">A</div>
18874 <p style="font-size: 100px; color: expʀessɪoɴ((title='XSSed'),'red')">B</p>
18875 !! html/php
18876 <div style="/* insecure input */">A</div>
18877 <p style="/* insecure input */">B</p>
18878
18879 !! html/parsoid
18880 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:uʀʟ(javascript:alert())"}}'>A</div>
18881 <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>
18882 !! end
18883
18884 !! test
18885 MSIE 6 CSS safety test: sup/sub script (T57332)
18886 !! wikitext
18887 <div style="background-image:url⁽javascript:alert())">A</div>
18888 <div style="background-image:url₍javascript:alert())">B</div>
18889 <p style="font-size: 100px; color: expressioⁿ((title='XSSed'),'red')">C</p>
18890 !! html/php
18891 <div style="/* insecure input */">A</div>
18892 <div style="/* insecure input */">B</div>
18893 <p style="/* insecure input */">C</p>
18894
18895 !! html/parsoid
18896 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:url⁽javascript:alert())"}}'>A</div>
18897 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:url₍javascript:alert())"}}'>B</div>
18898 <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>
18899 !! end
18900
18901 !! test
18902 Opera -o-link CSS
18903 !! options
18904 parsoid=wt2html,html2html
18905 !! wikitext
18906 <div
18907 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;"
18908 style="-o-link:attr(title);-o-link-source:current">X</div>
18909 !! html/php
18910 <div title="data:text/html,&lt;img src=1 onerror=alert(1)&gt;" style="/* insecure input */">X</div>
18911
18912 !! html/parsoid
18913 <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>
18914 !! end
18915
18916 !! test
18917 MSIE 6 CSS safety test: Repetition markers (T57332)
18918 !! wikitext
18919 <p style="font-size: 100px; color: expres〱ion((title='XSSed'),'red')">A</p>
18920 <p style="font-size: 100px; color: expresゝion((title='XSSed'),'red')">B</p>
18921 <p style="font-size: 100px; color: expresーion((title='XSSed'),'red')">C</p>
18922 <p style="font-size: 100px; color: expresヽion((title='XSSed'),'red')">D</p>
18923 <p style="font-size: 100px; color: expresﹽion((title='XSSed'),'red')">E</p>
18924 <p style="font-size: 100px; color: expresﹼion((title='XSSed'),'red')">F</p>
18925 <p style="font-size: 100px; color: expresーion((title='XSSed'),'red')">G</p>
18926 !! html/php
18927 <p style="/* insecure input */">A</p>
18928 <p style="/* insecure input */">B</p>
18929 <p style="/* insecure input */">C</p>
18930 <p style="/* insecure input */">D</p>
18931 <p style="/* insecure input */">E</p>
18932 <p style="/* insecure input */">F</p>
18933 <p style="/* insecure input */">G</p>
18934
18935 !! html/parsoid
18936 <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>
18937 <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>
18938 <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>
18939 <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>
18940 <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>
18941 <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>
18942 <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>
18943 !! end
18944
18945 !! test
18946 Table attribute legitimate extension
18947 !! wikitext
18948 {|
18949 !+ style="<nowiki>color:blue</nowiki>"|status
18950 |}
18951 !! html
18952 <table>
18953 <tr>
18954 <th style="color:blue">status
18955 </th></tr></table>
18956
18957 !!end
18958
18959 !! test
18960 Table attribute safety
18961 !! wikitext
18962 {|
18963 !+ style="<nowiki>border-width:expression(0+alert(document.cookie))</nowiki>"|status
18964 |}
18965 !! html
18966 <table>
18967 <tr>
18968 <th style="/* insecure input */">status
18969 </th></tr></table>
18970
18971 !! end
18972
18973 !! test
18974 CSS line continuation 1
18975 !! wikitext
18976 <div style="background-image: u\&#10;rl(test.jpg);"></div>
18977 !! html
18978 <div style="/* insecure input */"></div>
18979
18980 !! end
18981
18982 !! test
18983 CSS line continuation 2
18984 !! wikitext
18985 <div style="background-image: u\&#13;rl(test.jpg); "></div>
18986 !! html
18987 <div style="/* invalid control char */"></div>
18988
18989 !! end
18990
18991 !! article
18992 Template:Identity
18993 !! text
18994 {{{1}}}
18995 !! endarticle
18996
18997 !! test
18998 Expansion of multi-line templates in attribute values (T8255)
18999 !! wikitext
19000 <div style="background: {{identity|#00FF00}}">-</div>
19001 !! html
19002 <div style="background: #00FF00">-</div>
19003
19004 !! end
19005
19006 !! test
19007 Expansion of multi-line templates in attribute values (T8255 sanity check)
19008 !! wikitext
19009 <div style="background:
19010 #00FF00">-</div>
19011 !! html/php
19012 <div style="background: #00FF00">-</div>
19013
19014 !! html/parsoid
19015 <div style="background:
19016 #00FF00">-</div>
19017 !! end
19018
19019 !! test
19020 Expansion of multi-line templates in attribute values (T8255 sanity check 2)
19021 !! wikitext
19022 <div style="background: &#10;#00FF00">-</div>
19023 !! html
19024 <div style="background: &#10;#00FF00">-</div>
19025
19026 !! end
19027
19028 !! test
19029 Tags which are hidden from tidiers cannot pass through the Sanitizer
19030 !! wikitext
19031 <mw:toc><script>alert();</script></mw:toc>
19032 !! html+tidy
19033 <p>&lt;mw:toc&gt;&lt;script&gt;alert();&lt;/script&gt;&lt;/mw:toc&gt;
19034 </p>
19035 !! end
19036
19037 ###
19038 ### Parser hooks (see tests/parser/ParserTestParserHook.php for the <tag> extension)
19039 ###
19040
19041 !! test
19042 Parser hook: empty input
19043 !! wikitext
19044 <tag></tag>
19045 !! html/php
19046 <pre>
19047 ''
19048 array (
19049 )
19050 </pre>
19051
19052 !! html/parsoid
19053 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
19054 !! end
19055
19056 ## Don't expect parsoid to rt this form.
19057 !! test
19058 Parser hook: empty input using terminated empty elements
19059 !! options
19060 parsoid=wt2html,html2html
19061 !! wikitext
19062 <tag/>
19063 !! html/php
19064 <pre>
19065 NULL
19066 array (
19067 )
19068 </pre>
19069
19070 !! html/parsoid
19071 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{}}' data-parsoid='{}' about="#mwt2"></pre>
19072 !! end
19073
19074 !! test
19075 Parser hook: empty input using terminated empty elements (space before)
19076 !! wikitext
19077 <tag />
19078 !! html/php
19079 <pre>
19080 NULL
19081 array (
19082 )
19083 </pre>
19084
19085 !! html/parsoid
19086 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{}}' data-parsoid='{}' about="#mwt2"></pre>
19087 !! end
19088
19089 !! test
19090 Parser hook: basic input
19091 !! wikitext
19092 <tag>input</tag>
19093 !! html/php
19094 <pre>
19095 'input'
19096 array (
19097 )
19098 </pre>
19099
19100 !! html/parsoid
19101 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
19102 !! end
19103
19104 ## Don't expect parsoid to rt this form.
19105 !! test
19106 Parser hook: case insensitive
19107 !! options
19108 parsoid=wt2html,html2html
19109 !! wikitext
19110 <TAG>input</TAG>
19111 !! html/php
19112 <pre>
19113 'input'
19114 array (
19115 )
19116 </pre>
19117
19118 !! html/parsoid
19119 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
19120 !! end
19121
19122 ## Don't expect parsoid to rt this form.
19123 !! test
19124 Parser hook: case insensitive, redux
19125 !! options
19126 parsoid=wt2html,html2html
19127 !! wikitext
19128 <TaG>input</TAg>
19129 !! html/php
19130 <pre>
19131 'input'
19132 array (
19133 )
19134 </pre>
19135
19136 !! html/parsoid
19137 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
19138 !! end
19139
19140 !! test
19141 Parser hook: nested tags
19142 !! options
19143 parsoid=wt2html
19144 !! wikitext
19145 <tag><tag></tag></tag>
19146 !! html/php
19147 <pre>
19148 '<tag>'
19149 array (
19150 )
19151 </pre>&lt;/tag&gt;
19152
19153 !! html/php+tidy
19154 <pre>'<tag>'
19155 array (
19156 )
19157 </tag></pre><p>&lt;/tag&gt;
19158 </p>
19159 !! html/parsoid
19160 <pre typeof="mw:Extension/tag" about="#mwt2" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"&lt;tag>"}}'></pre><p>&lt;/tag></p>
19161 !! end
19162
19163 !! test
19164 Parser hook: basic arguments
19165 !! wikitext
19166 <tag width="200" height="100" depth="50" square=""></tag>
19167 !! html/php
19168 <pre>
19169 ''
19170 array (
19171 'width' => '200',
19172 'height' => '100',
19173 'depth' => '50',
19174 'square' => '',
19175 )
19176 </pre>
19177
19178 !! html/parsoid
19179 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
19180 !! end
19181
19182 ## Don't expect parsoid to rt this form.
19183 !! test
19184 Parser hook: basic arguments, variations
19185 !! options
19186 parsoid=wt2html,html2html
19187 !! wikitext
19188 <tag width=200 height = "100" depth = '50' square></tag>
19189 !! html/php
19190 <pre>
19191 ''
19192 array (
19193 'width' => '200',
19194 'height' => '100',
19195 'depth' => '50',
19196 'square' => '',
19197 )
19198 </pre>
19199
19200 !! html/parsoid
19201 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
19202 !! end
19203
19204 !! test
19205 Parser hook: argument containing a forward slash (T7344)
19206 !! wikitext
19207 <tag filename="/tmp/bla"></tag>
19208 !! html/php
19209 <pre>
19210 ''
19211 array (
19212 'filename' => '/tmp/bla',
19213 )
19214 </pre>
19215
19216 !! html/parsoid
19217 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"filename":"/tmp/bla"},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
19218 !! end
19219
19220 ## Don't expect parsoid to rt this form.
19221 !! test
19222 Parser hook: empty input using terminated empty elements (T4374)
19223 !! options
19224 parsoid=wt2html,html2html
19225 !! wikitext
19226 <tag foo=bar/>text
19227 !! html/php
19228 <pre>
19229 NULL
19230 array (
19231 'foo' => 'bar',
19232 )
19233 </pre>text
19234
19235 !! html/parsoid
19236 <pre typeof="mw:Extension/tag" about="#mwt2" data-mw='{"name":"tag","attrs":{"foo":"bar"}}'></pre><p>text</p>
19237 !! end
19238
19239 ## </tag> should be output literally since there is no matching tag that begins it
19240 ## Don't expect parsoid to rt this form.
19241 !! test
19242 Parser hook: basic arguments using terminated empty elements (T4374)
19243 !! options
19244 parsoid=wt2html
19245 !! wikitext
19246 <tag width=200 height = "100" depth = '50' square/>
19247 other stuff
19248 </tag>
19249 !! html/php
19250 <pre>
19251 NULL
19252 array (
19253 'width' => '200',
19254 'height' => '100',
19255 'depth' => '50',
19256 'square' => '',
19257 )
19258 </pre>
19259 <p>other stuff
19260 &lt;/tag&gt;
19261 </p>
19262 !! html/parsoid
19263 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""}}' about="#mwt2"></pre><p>other stuff
19264 &lt;/tag></p>
19265 !! end
19266
19267 ## Don't expect parsoid to rt this form.
19268 !! test
19269 Parser hook: Don't allow unclosed extension tags
19270 !! options
19271 parsoid=wt2html
19272 !! wikitext
19273 test <tag>123
19274
19275 this is a '''test'''
19276 !! html/php
19277 <p>test &lt;tag&gt;123
19278 </p><p>this is a <b>test</b>
19279 </p>
19280 !! html/parsoid
19281 <p>test &lt;tag>123</p>
19282
19283 <p>this is a <b>test</b></p>
19284 !! end
19285
19286 !! test
19287 Parser hook: horizontal rule inside extension tag that outputs <pre>
19288 !! wikitext
19289 <tag>
19290 Hello
19291 <hr/>
19292 Goodbye
19293 </tag>
19294 !! html/php
19295 <pre>
19296 '
19297 Hello
19298 <hr/>
19299 Goodbye
19300 '
19301 array (
19302 )
19303 </pre>
19304
19305 !! end
19306
19307 ###
19308 ### (see tests/parser/ParserTestParserHook.php for the <statictag> extension)
19309 ###
19310
19311 !! test
19312 Parser hook: static parser hook not inside a comment
19313 !! wikitext
19314 <statictag>hello, world</statictag>
19315
19316 <statictag action="flush" />
19317 !! html/php
19318 <p><br />
19319 hello, world
19320 </p>
19321 !! html/parsoid
19322 <p><span typeof="mw:Extension/statictag" data-mw='{"name":"statictag","attrs":{},"body":{"extsrc":"hello, world"}}' about="#mwt2"></span></p>
19323 <p><span typeof="mw:Extension/statictag" data-mw='{"name":"statictag","attrs":{"action":"flush"}}' about="#mwt4">hello, world</span></p>
19324 !! end
19325
19326 !! test
19327 Parser hook: static parser hook inside a comment
19328 !! wikitext
19329 <!-- <statictag>hello, world</statictag> -->
19330 <statictag action="flush" />
19331 !! html/php
19332 <p><br />
19333 </p>
19334 !! html/parsoid
19335 <!-- <statictag&#x3E;hello, world</statictag&#x3E; -->
19336 <p><span typeof='mw:Extension/statictag' data-mw='{"name":"statictag","attrs":{"action":"flush"}}' data-parsoid='{}' about='#mwt2'></span></p>
19337 !! end
19338
19339 # Nested template calls; this case was broken by Parser.php rev 1.506,
19340 # since reverted.
19341
19342 !! article
19343 Template:One-parameter
19344 !! text
19345 (My parameter is: {{{1}}})
19346 !! endarticle
19347
19348 !! article
19349 Template:Map-one-parameter
19350 !! text
19351 {{{{{1}}}|{{{2}}}}}
19352 !! endarticle
19353
19354 !! test
19355 Nested template calls
19356 !! wikitext
19357 {{Map-one-parameter|One-parameter|param}}
19358 !! html
19359 <p>(My parameter is: param)
19360 </p>
19361 !! end
19362
19363
19364 ###
19365 ### Sanitizer
19366 ###
19367
19368 !! test
19369 Sanitizer: Closing of open tags
19370 !! wikitext
19371 <s></s><table></table>
19372 !! html/php+tidy
19373 <p><s></s></p><table></table>
19374 !! html/parsoid
19375 <p><s data-parsoid='{"stx":"html"}'></s></p><table data-parsoid='{"stx":"html"}'></table>
19376 !! end
19377
19378 !! test
19379 Sanitizer: Closing of open but not closed tags
19380 !! wikitext
19381 <s>foo
19382 !! html
19383 <p><s>foo</s>
19384 </p>
19385 !! end
19386
19387 !! test
19388 Sanitizer: Closing of closed but not open tags
19389 !! options
19390 parsoid=wt2html
19391 !! wikitext
19392 </s>
19393 !! html+tidy
19394 <p class="mw-empty-elt">
19395 </p>
19396 !! end
19397
19398 !! test
19399 Sanitizer: Closing of closed but not open table tags
19400 !! options
19401 parsoid=wt2html
19402 !! wikitext
19403 Table not started</td></tr></table>
19404 !! html+tidy
19405 <p>Table not started
19406 </p>
19407 !! end
19408
19409 !! test
19410 Sanitizer: Escaping of spaces, multibyte characters, colons & other stuff in id=""
19411 !! options
19412 title=[[Main Page]]
19413 !! config
19414 wgFragmentMode=[ 'html5', 'legacy' ]
19415 !! wikitext
19416 <span id="æ: v">byte</span>[[#æ: v|backlink]]
19417 !! html/php
19418 <p><span id="æ:_v">byte</span><a href="#æ:_v">backlink</a>
19419 </p>
19420 !! html/parsoid
19421 <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>
19422 !! end
19423
19424 !! test
19425 Sanitizer: Escaping of spaces, multibyte characters, colons & other stuff in id="" (legacy)
19426 !! config
19427 wgFragmentMode=[ 'legacy' ]
19428 !! wikitext
19429 <span id="æ: v">byte</span>[[#æ: v|backlink]]
19430 !! html/php
19431 <p><span id=".C3.A6:_v">byte</span><a href="#.C3.A6:_v">backlink</a>
19432 </p>
19433 !! end
19434
19435 # In HTML5, the restrictions are that id must contain at least one character,
19436 # and must not contain any space characters.
19437 !! test
19438 Sanitizer: Validating the contents of the id attribute (T6515)
19439 !! options
19440 disabled
19441 !! wikitext
19442 <br id="" /><br id="a space" />
19443 !! html
19444 Something ...
19445 !! end
19446
19447 # In HTML5, id must be unique amongst all the ids in the element's home subtree.
19448 !! test
19449 Sanitizer: Validating id attribute uniqueness (T6515, T8301)
19450 !! options
19451 disabled
19452 !! wikitext
19453 <br id="foo" /><br id="foo" />
19454 !! html
19455 Something need to be done. foo-2 ?
19456 !! end
19457
19458 !! test
19459 Sanitizer: Validating that <meta> and <link> work, but only for Microdata
19460 !! wikitext
19461 <div itemscope>
19462 <meta itemprop="hello" content="world">
19463 <meta http-equiv="refresh" content="5">
19464 <meta itemprop="hello" http-equiv="refresh" content="5">
19465 <link itemprop="hello" href="{{SERVER}}">
19466 <link rel="stylesheet" href="{{SERVER}}">
19467 <link rel="stylesheet" itemprop="hello" href="{{SERVER}}">
19468 </div>
19469 !! html
19470 <div itemscope="">
19471 <p> <meta itemprop="hello" content="world" />
19472 &lt;meta http-equiv="refresh" content="5"&gt;
19473 <meta itemprop="hello" content="5" />
19474 <link itemprop="hello" href="http&#58;//example.org" />
19475 &lt;link rel="stylesheet" href="<a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>"&gt;
19476 <link itemprop="hello" href="http&#58;//example.org" />
19477 </p>
19478 </div>
19479
19480 !! end
19481
19482 !! test
19483 Sanitizer: Strip comments from CSS attributes
19484 !! options
19485 parsoid=wt2html,wt2wt
19486 !! wikitext
19487 <span style="margin:/*negate mbox-text padding */-0.125em -0.45em; /*rainbow*/rgba(255, 0, 0, 0.3)">2013</span>
19488 !! html/php
19489 <p><span style="margin: -0.125em -0.45em; rgba(255, 0, 0, 0.3)">2013</span>
19490 </p>
19491 !! html/parsoid
19492 <p><span style="margin: -0.125em -0.45em; rgba(255, 0, 0, 0.3)">2013</span></p>
19493 !! end
19494
19495 !! test
19496 Sanitizer: Avoid unnecessary percent encoded characters in interwiki links
19497 !! wikitext
19498 [[meatball:Soft"Security]]
19499 !! html/php
19500 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?Soft%22Security" class="extiw" title="meatball:Soft&quot;Security">meatball:Soft"Security</a>
19501 </p>
19502 !! html/parsoid
19503 <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>
19504 !! end
19505
19506 !! test
19507 Sanitizer: angle brackets are invalid, even in interwiki links (T182338)
19508 !! wikitext
19509 [[meatball:Foo<Bar]]
19510 [[meatball:Foo>Bar]]
19511 [[meatball:Foo&lt;bar]]
19512 [[meatball:Foo&gt;bar]]
19513 !! html/php
19514 <p>[[meatball:Foo&lt;Bar]]
19515 [[meatball:Foo&gt;Bar]]
19516 [[meatball:Foo&lt;bar]]
19517 [[meatball:Foo&gt;bar]]
19518 </p>
19519 !! html/parsoid
19520 <p>[[meatball:Foo&lt;Bar]]
19521 [[meatball:Foo>Bar]]
19522 [[meatball:Foo<span typeof="mw:Entity" data-parsoid='{"src":"&amp;lt;","srcContent":"&lt;"}'>&lt;</span>bar]]
19523 [[meatball:Foo<span typeof="mw:Entity" data-parsoid='{"src":"&amp;gt;","srcContent":">"}'>></span>bar]]</p>
19524 !! end
19525
19526 !! test
19527 Language converter: output gets cut off unexpectedly (T7757)
19528 !! options
19529 language=zh
19530 !! wikitext
19531 this bit is safe: }-
19532
19533 but if we add a conversion instance: -{zh-cn:xxx;zh-tw:yyy}-
19534
19535 then we get cut off here: }-
19536
19537 all additional text is vanished
19538 !! html/php
19539 <p>this bit is safe: }-
19540 </p><p>but if we add a conversion instance: xxx
19541 </p><p>then we get cut off here: }-
19542 </p><p>all additional text is vanished
19543 </p>
19544 !! html/parsoid
19545 <p>this bit is safe: }-</p>
19546 <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>
19547 <p>then we get cut off here: }-</p>
19548 <p>all additional text is vanished</p>
19549 !! end
19550
19551 !! test
19552 Language converter glossary rules inside attributes (T119158)
19553 !! options
19554 language=sr variant=sr-el
19555 !! wikitext
19556 -{H|foAjrjvi=>sr-el:" onload="alert(1)" data-foo="}-
19557
19558 [[File:Foobar.jpg|alt=-{}-foAjrjvi-{}-]]
19559 !! html/php
19560 <p>
19561 </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>
19562 </p>
19563 !! html/parsoid
19564 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"foAjrjvi","l":"sr-el","t":"\" onload=\"alert(1)\" data-foo=\""}]}'/></p>
19565
19566 <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>
19567 !! end
19568
19569 !! test
19570 Self closed html pairs (T7487)
19571 !! wikitext
19572 <center><font id="bug" />Centered text</center>
19573 <div><font id="bug2" />In div text</div>
19574 !! html+tidy
19575 <center><font id="bug"></font>Centered text</center>
19576 <div><font id="bug2"></font>In div text</div>
19577 !! end
19578
19579 !! test
19580 Punctuation: nbsp before exclamation
19581 !! wikitext
19582 C'est grave !
19583 !! html
19584 <p>C'est grave&#160;!
19585 </p>
19586 !! end
19587
19588 !! test
19589 Punctuation: CSS !important (T13874)
19590 !! wikitext
19591 <div style="width:50% !important">important</div>
19592 !! html
19593 <div style="width:50% !important">important</div>
19594
19595 !!end
19596
19597 !! test
19598 Punctuation: CSS ! important (T13874; with space after)
19599 !! wikitext
19600 <div style="width:50% ! important">important</div>
19601 !! html
19602 <div style="width:50%&#32;! important">important</div>
19603
19604 !!end
19605
19606 !! test
19607 HTML bullet list, closed tags (T7497)
19608 !! wikitext
19609 <ul>
19610 <li>One</li>
19611 <li>Two</li>
19612 </ul>
19613 !! html/php
19614 <ul>
19615 <li>One</li>
19616 <li>Two</li>
19617 </ul>
19618
19619 !! html/parsoid
19620 <ul data-parsoid='{"stx":"html"}'>
19621 <li data-parsoid='{"stx":"html"}'>One</li>
19622 <li data-parsoid='{"stx":"html"}'>Two</li>
19623 </ul>
19624
19625 !! end
19626
19627 !! test
19628 HTML bullet list, unclosed tags (T7497)
19629 !! wikitext
19630 <ul>
19631 <li>One
19632 <li>Two
19633 </ul>
19634 !! html/php+tidy
19635 <ul>
19636 <li>One
19637 </li><li>Two
19638 </li></ul>
19639 !! html/parsoid
19640 <ul data-parsoid='{"stx":"html"}'>
19641 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>One</li>
19642 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>Two</li>
19643 </ul>
19644
19645 !! end
19646
19647 !! test
19648 HTML ordered list, closed tags (T7497)
19649 !! wikitext
19650 <ol>
19651 <li>One</li>
19652 <li>Two</li>
19653 </ol>
19654 !! html/php
19655 <ol>
19656 <li>One</li>
19657 <li>Two</li>
19658 </ol>
19659
19660 !! html/parsoid
19661 <ol data-parsoid='{"stx":"html"}'>
19662 <li data-parsoid='{"stx":"html"}'>One</li>
19663 <li data-parsoid='{"stx":"html"}'>Two</li>
19664 </ol>
19665
19666 !! end
19667
19668 !! test
19669 HTML ordered list, unclosed tags (T7497)
19670 !! options
19671 !! wikitext
19672 <ol>
19673 <li>One
19674 <li>Two
19675 </ol>
19676 !! html/php+tidy
19677 <ol>
19678 <li>One
19679 </li><li>Two
19680 </li></ol>
19681 !! html/parsoid
19682 <ol data-parsoid='{"stx":"html"}'>
19683 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>One</li>
19684 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>Two</li>
19685 </ol>
19686
19687 !! end
19688
19689 !! test
19690 HTML nested bullet list, closed tags (T7497)
19691 !! wikitext
19692 <ul>
19693 <li>One</li>
19694 <li>Two:
19695 <ul>
19696 <li>Sub-one</li>
19697 <li>Sub-two</li>
19698 </ul>
19699 </li>
19700 </ul>
19701 !! html/php
19702 <ul>
19703 <li>One</li>
19704 <li>Two:
19705 <ul>
19706 <li>Sub-one</li>
19707 <li>Sub-two</li>
19708 </ul>
19709 </li>
19710 </ul>
19711
19712 !! html/parsoid
19713 <ul data-parsoid='{"stx":"html"}'>
19714 <li data-parsoid='{"stx":"html"}'>One</li>
19715 <li data-parsoid='{"stx":"html"}'>Two:
19716 <ul data-parsoid='{"stx":"html"}'>
19717 <li data-parsoid='{"stx":"html"}'>Sub-one</li>
19718 <li data-parsoid='{"stx":"html"}'>Sub-two</li>
19719 </ul>
19720 </li>
19721 </ul>
19722 !! end
19723
19724 !! test
19725 HTML nested bullet list, open tags (T7497)
19726 !! wikitext
19727 <ul>
19728 <li>One
19729 <li>Two:
19730 <ul>
19731 <li>Sub-one
19732 <li>Sub-two
19733 </ul>
19734 </ul>
19735 !! html+tidy
19736 <ul>
19737 <li>One
19738 </li><li>Two:
19739 <ul>
19740 <li>Sub-one
19741 </li><li>Sub-two
19742 </li></ul>
19743 </li></ul>
19744 !! end
19745
19746 !! test
19747 HTML nested ordered list, closed tags (T7497)
19748 !! wikitext
19749 <ol>
19750 <li>One</li>
19751 <li>Two:
19752 <ol>
19753 <li>Sub-one</li>
19754 <li>Sub-two</li>
19755 </ol>
19756 </li>
19757 </ol>
19758 !! html
19759 <ol>
19760 <li>One</li>
19761 <li>Two:
19762 <ol>
19763 <li>Sub-one</li>
19764 <li>Sub-two</li>
19765 </ol>
19766 </li>
19767 </ol>
19768
19769 !! end
19770
19771 !! test
19772 HTML nested ordered list, open tags (T7497)
19773 !! wikitext
19774 <ol>
19775 <li>One
19776 <li>Two:
19777 <ol>
19778 <li>Sub-one
19779 <li>Sub-two
19780 </ol>
19781 </ol>
19782 !! html/php
19783 <ol>
19784 <li>One
19785 <li>Two:
19786 <ol>
19787 <li>Sub-one
19788 <li>Sub-two
19789 </ol>
19790 </ol>
19791
19792 !! html/parsoid
19793 <ol>
19794 <li>One
19795 </li>
19796 <li>Two:
19797 <ol>
19798 <li>Sub-one
19799 </li>
19800 <li>Sub-two
19801 </li>
19802 </ol>
19803 </li>
19804 </ol>
19805
19806 !! end
19807
19808 !! test
19809 HTML ordered list item with parameters oddity
19810 !! wikitext
19811 <ol><li id="fragment">One</li>
19812 </ol>
19813 !! html
19814 <ol><li id="fragment">One</li>
19815 </ol>
19816
19817 !! end
19818
19819 # parsoid doesn't explicitly mark autonumbered links, see T55505
19820 !!test
19821 T7918: autonumbering
19822 !! wikitext
19823 [http://first/] [http://second] [ftp://ftp]
19824
19825 ftp://inlineftp
19826
19827 [mailto:enclosed@mail.tld With target]
19828
19829 [mailto:enclosed@mail.tld]
19830
19831 mailto:inline@mail.tld
19832 !! html/php
19833 <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>
19834 </p><p><a rel="nofollow" class="external free" href="ftp://inlineftp">ftp://inlineftp</a>
19835 </p><p><a rel="nofollow" class="external text" href="mailto:enclosed@mail.tld">With target</a>
19836 </p><p><a rel="nofollow" class="external autonumber" href="mailto:enclosed@mail.tld">[4]</a>
19837 </p><p><a rel="nofollow" class="external free" href="mailto:inline@mail.tld">mailto:inline@mail.tld</a>
19838 </p>
19839 !! html/parsoid
19840 <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>
19841 <p><a rel="mw:ExtLink" class="external free" href="ftp://inlineftp">ftp://inlineftp</a></p>
19842 <p><a rel="mw:ExtLink" class="external text" href="mailto:enclosed@mail.tld">With target</a></p>
19843 <p><a rel="mw:ExtLink" class="external autonumber" href="mailto:enclosed@mail.tld"></a></p>
19844 <p><a rel="mw:ExtLink" class="external free" href="mailto:inline@mail.tld">mailto:inline@mail.tld</a></p>
19845 !! end
19846
19847
19848 #
19849 # Security and HTML correctness
19850 # From Nick Jenkins' fuzz testing
19851 #
19852
19853 !! test
19854 Fuzz testing: Parser13
19855 !! wikitext
19856 {|
19857 | http://a|
19858 !! html
19859 <table>
19860 <tr>
19861 <td>
19862 </td>
19863 </tr>
19864 </table>
19865
19866 !! end
19867
19868 # Note that Parsoid output differs from the PHP parser here: the PHP
19869 # parser breaks the URL for the magic word, while in Parsoid the URL
19870 # production takes precedence.
19871 !! test
19872 Fuzz testing: Parser14
19873 !! wikitext
19874 ==onmouseover===
19875 http://__TOC__
19876 !! html/php
19877 <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>
19878 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>
19879 <ul>
19880 <li class="toclevel-1 tocsection-1"><a href="#onmouseover.3D"><span class="tocnumber">1</span> <span class="toctext">onmouseover=</span></a></li>
19881 </ul>
19882 </div>
19883
19884
19885 !! html/php+tidy
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><p>
19887 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>
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 !! html/parsoid
19893 <h2 id="onmouseover="><span id="onmouseover.3D" typeof="mw:FallbackId"></span>onmouseover=</h2>
19894 <p><a rel="mw:ExtLink" class="external free" href="http://__TOC__" data-parsoid='{"stx":"url"}'>http://__TOC__</a></p>
19895 !! end
19896
19897 !! test
19898 Fuzz testing: Parser14-table
19899 !! options
19900 parsoid=wt2html,html2html
19901 !! wikitext
19902 ==a==
19903 {| STYLE=__TOC__
19904 !! html/php
19905 <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>
19906 <table style="&#95;_TOC&#95;_">
19907 <tr><td></td></tr>
19908 </table>
19909
19910 !! html/php+tidy
19911 <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>
19912 <table style="&#95;_TOC&#95;_">
19913 <tbody><tr><td></td></tr>
19914 </tbody></table>
19915 !! html/parsoid
19916 <h2 id="a">a</h2>
19917 <table style="__TOC__"></table>
19918 !! end
19919
19920 # Known to produce bogus xml (extra </td>)
19921 # Don't add the html/php section since it generates broken HTML
19922 !! test
19923 Fuzz testing: Parser16
19924 !! wikitext
19925 {|
19926 !https://||||||
19927 !! html+tidy
19928 <table>
19929 <tbody><tr>
19930 <th>https://</th>
19931 <th></th>
19932 <th></th>
19933 <th>
19934
19935 </th></tr>
19936 </tbody></table>
19937 !! end
19938
19939 !! test
19940 Fuzz testing: Parser21
19941 !! wikitext
19942 {|
19943 !irc://{{ftp://a" onmouseover="alert('hello world');"
19944 |
19945 !! html
19946 <table>
19947 <tr>
19948 <th><a rel="nofollow" class="external free" href="irc://{{ftp://a">irc://{{ftp://a</a>" onmouseover="alert('hello world');"
19949 </th>
19950 <td>
19951 </td>
19952 </tr>
19953 </table>
19954
19955 !! end
19956
19957 !! test
19958 Fuzz testing: Parser22
19959 !! wikitext
19960 http://===r:::https://b
19961
19962 {|
19963 !! html
19964 <p><a rel="nofollow" class="external free" href="http://===r:::https://b">http://===r:::https://b</a>
19965 </p>
19966 <table>
19967 <tr><td></td></tr>
19968 </table>
19969
19970 !! end
19971
19972 ## Remex doesn't account for fostered content.
19973 ## Known to produce bad XML for now
19974 !! test
19975 Fuzz testing: Parser24
19976 !! options
19977 parsoid=wt2html
19978 !! wikitext
19979 {|
19980 {{{|
19981 <u CLASS=
19982 | {{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx--><noinclude>}}}} >
19983 <br style="onmouseover='alert(document.cookie);' " />
19984
19985 MOVE YOUR MOUSE CURSOR OVER THIS TEXT
19986 |
19987 !! html/php
19988 <table>
19989 {{{|
19990 <u class="&#124;">}}}} &gt;
19991 <br style="onmouseover=&#39;alert(document.cookie);&#39;" />
19992
19993 MOVE YOUR MOUSE CURSOR OVER THIS TEXT
19994 <tr>
19995 <td></u>
19996 </td>
19997 </tr>
19998 </table>
19999
20000 !! html/php+tidy
20001
20002 {{{|
20003 <u class="&#124;">}}}} &gt;
20004 <br style="onmouseover=&#39;alert(document.cookie);&#39;" />
20005
20006 MOVE YOUR MOUSE CURSOR OVER THIS TEXT
20007 </u><table><tbody><tr>
20008 <td>
20009 </td>
20010 </tr>
20011 </tbody></table><p><u class="&#124;">
20012 </u></p>
20013 !! html/parsoid
20014 <p data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true}'>
20015 {{{|
20016 <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>"}'/>}}}} >
20017 <br style="onmouseover='alert(document.cookie);' " data-parsoid='{"stx":"html","selfClose":true}'/>
20018
20019 MOVE YOUR MOUSE CURSOR OVER THIS TEXT</u></p>
20020 <table data-parsoid='{"autoInsertedEnd":true}'><tbody><tr data-parsoid='{"autoInsertedStart":true}'><td></td></tr></tbody></table>
20021 !! end
20022
20023 # Note: the current result listed for this is not what the original one was,
20024 # but the original bug was JavaScript injection, which is fixed in any case.
20025 # It's not clear that the original result listed was any more correct than the
20026 # current one. Original result:
20027 # <p>{{{|
20028 # </p>
20029 # <li class="&#124;&#124;">
20030 # }}}blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b>
20031 !!test
20032 Fuzz testing: Parser25 (T8055)
20033 !! wikitext
20034 {{{
20035 |
20036 <LI CLASS=||
20037 >
20038 }}}blah" onmouseover="alert('hello world');" align="left"'''MOVE MOUSE CURSOR OVER HERE
20039 !! html/php
20040 <p>&lt;LI CLASS=blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b>
20041 </p>
20042 !! html/parsoid
20043 <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"]}'>
20044 </span><p about="#mwt1">&lt;LI CLASS=blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b></p>
20045 !! end
20046
20047 !!test
20048 Fuzz testing: URL adjacent extension (with space, clean)
20049 !! wikitext
20050 http://example.com <nowiki>junk</nowiki>
20051 !! html/php
20052 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> junk
20053 </p>
20054 !! html/parsoid
20055 <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>
20056 !! end
20057
20058 !!test
20059 Fuzz testing: URL adjacent extension (no space, dirty; nowiki)
20060 !! wikitext
20061 http://example.com<nowiki>junk</nowiki>
20062 !! html/php
20063 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>junk
20064 </p>
20065 !! html/parsoid
20066 <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>
20067 !! end
20068
20069 !! test
20070 Fuzz testing: URL adjacent extension (no space, dirty; pre)
20071 !! wikitext
20072 http://example.com<pre>junk</pre>
20073 !! html/php
20074 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a><pre>junk</pre>
20075
20076 !! html/php+tidy
20077 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a></p><pre>junk</pre>
20078 !! html/parsoid
20079 <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>
20080 !! end
20081
20082 !! test
20083 Fuzz testing: image with bogus manual thumbnail
20084 !! wikitext
20085 [[Image:foobar.jpg|thumbnail= ]]
20086 !! html/php
20087 <div class="thumb tright"><div class="thumbinner" style="width:182px;">Error creating thumbnail: <div class="thumbcaption"></div></div></div>
20088
20089 !! html/parsoid
20090 <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>
20091 !! end
20092
20093 # Parsoid will emit the newline literally in wt2wt; see next test case.
20094 !! test
20095 Fuzz testing: encoded newline in generated HTML replacements (T8577)
20096 !! options
20097 parsoid=wt2html
20098 !! wikitext
20099 <pre dir="&#10;"></pre>
20100 !! html/php
20101 <pre dir="&#10;"></pre>
20102
20103 !! html/parsoid
20104 <pre dir="
20105 " typeof="mw:Extension/pre" about="#mwt2"data-mw='{"name":"pre","attrs":{"dir":"\n"},"body":{"extsrc":""}}'></pre>
20106 !! end
20107
20108 !! test
20109 Fuzz testing: encoded newline in generated HTML replacements, html2wt (T8577)
20110 !! options
20111 parsoid=html2wt
20112 !! html/parsoid
20113 <pre typeof="mw:Extension/pre" about="#mwt2" dir="
20114 " data-mw='{"name":"pre","attrs":{"dir":"\n"},"body":{"extsrc":""}}'></pre>
20115 !! wikitext
20116 <pre dir="
20117 "></pre>
20118 !! html/php
20119 <pre dir=""></pre>
20120
20121 !! end
20122
20123 !! test
20124 Templates in extension attributes are not expanded
20125 !! wikitext
20126 <pre dir="{{echo|ltr}}"></pre>
20127 !! html/php
20128 <pre dir="{{echo|ltr}}"></pre>
20129
20130 !! html/parsoid
20131 <pre dir="{{echo|ltr}}" typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{"dir":"{{echo|ltr}}"},"body":{"extsrc":""}}'></pre>
20132 !! end
20133
20134 !! test
20135 Parsing optional HTML elements (T8171)
20136 !! options
20137 !! wikitext
20138 <table>
20139 <tr>
20140 <td> Some tabular data</td>
20141 <td> More tabular data ...
20142 <td> And yet som tabular data</td>
20143 </tr>
20144 </table>
20145 !! html
20146 <table>
20147 <tr>
20148 <td> Some tabular data</td>
20149 <td> More tabular data ...
20150 </td><td> And yet som tabular data</td>
20151 </tr>
20152 </table>
20153
20154 !! end
20155
20156 !! test
20157 Correct handling of <td>, <tr> (T8171)
20158 !! options
20159 !! wikitext
20160 <table>
20161 <tr>
20162 <td> Some tabular data</td>
20163 <td> More tabular data ...</td>
20164 <td> And yet som tabular data</td>
20165 </tr>
20166 </table>
20167 !! html
20168 <table>
20169 <tr>
20170 <td> Some tabular data</td>
20171 <td> More tabular data ...</td>
20172 <td> And yet som tabular data</td>
20173 </tr>
20174 </table>
20175
20176 !! end
20177
20178
20179 !! test
20180 Parsing crashing regression (fr:JavaScript)
20181 !! wikitext
20182 </body></x>
20183 !! html
20184 <p>&lt;/body&gt;&lt;/x&gt;
20185 </p>
20186 !! end
20187
20188 !! test
20189 Inline wiki vs wiki block nesting
20190 !! wikitext
20191 '''Bold paragraph
20192
20193 New wiki paragraph
20194 !! html
20195 <p><b>Bold paragraph</b>
20196 </p><p>New wiki paragraph
20197 </p>
20198 !! end
20199
20200 # FIXME: The current php output is documented
20201 # and desired output is the parsoid target.
20202 !! test
20203 Inline HTML vs wiki block nesting
20204 !! wikitext
20205 <b>Bold paragraph
20206
20207 New wiki paragraph
20208 !! html/php
20209 <p><b>Bold paragraph
20210 </p><p>New wiki paragraph</b>
20211 </p>
20212 !! html/php+tidy
20213 <p><b>Bold paragraph
20214 </b></p><p><b>New wiki paragraph
20215 </b></p>
20216 !! html/parsoid
20217 <p><b>Bold paragraph</b>
20218 </p><p>New wiki paragraph
20219 </p>
20220 !! end
20221
20222 # Original result was this:
20223 # <p><b>bold</b><b>bold<i>bolditalics</i></b>
20224 # </p>
20225 # While that might be marginally more intuitive, maybe, the six-apostrophe
20226 # construct is clearly pathological and the result stated here (which is what
20227 # the parser actually does) is about as reasonable as anything.
20228 !!test
20229 Mixing markup for italics and bold
20230 !! options
20231 !! wikitext
20232 '''bold''''''bold''bolditalics'''''
20233 !! html
20234 <p>'<i>bold'</i><b>bold<i>bolditalics</i></b>
20235 </p>
20236 !! end
20237
20238
20239 !! article
20240 Xyzzyx
20241 !! text
20242 Article for special page transclusion test
20243 !! endarticle
20244
20245 !! test
20246 Special page transclusion
20247 !! options
20248 !! wikitext
20249 {{Special:Prefixindex/Xyzzyx}}
20250 !! html
20251 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
20252 </ul>
20253
20254 !! end
20255
20256 !! test
20257 Special page transclusion twice (T7021)
20258 !! options
20259 !! wikitext
20260 {{Special:Prefixindex/Xyzzyx}}
20261 {{Special:Prefixindex/Xyzzyx}}
20262 !! html
20263 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
20264 </ul>
20265 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
20266 </ul>
20267
20268 !! end
20269
20270 !! test
20271 Transclusion of default MediaWiki message
20272 !! wikitext
20273 {{MediaWiki:Mainpage}}
20274 !! html
20275 <p>Main Page
20276 </p>
20277 !! end
20278
20279 !! test
20280 Transclusion of nonexistent MediaWiki message
20281 !! wikitext
20282 {{MediaWiki:Mainpagexxx}}
20283 !! html
20284 <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>
20285 </p>
20286 !! end
20287
20288 !! test
20289 Transclusion of MediaWiki message with underscore
20290 !! wikitext
20291 {{MediaWiki:history_short}}
20292 !! html
20293 <p>History
20294 </p>
20295 !! end
20296
20297 !! test
20298 Transclusion of MediaWiki message with space
20299 !! wikitext
20300 {{MediaWiki:history short}}
20301 !! html
20302 <p>History
20303 </p>
20304 !! end
20305
20306 !! test
20307 Invalid header with following text
20308 !! wikitext
20309 = x = y
20310 !! html
20311 <p>= x = y
20312 </p>
20313 !! end
20314
20315
20316 !! test
20317 Section extraction test (section 0)
20318 !! options
20319 section=0
20320 !! wikitext
20321 start
20322 ==a==
20323 ===aa===
20324 ====aaa====
20325 ==b==
20326 ===ba===
20327 ===bb===
20328 ====bba====
20329 ===bc===
20330 ==c==
20331 ===ca===
20332 !! html/php
20333 start
20334 !! end
20335
20336 !! test
20337 Section extraction test (section 1)
20338 !! options
20339 section=1
20340 !! wikitext
20341 start
20342 ==a==
20343 ===aa===
20344 ====aaa====
20345 ==b==
20346 ===ba===
20347 ===bb===
20348 ====bba====
20349 ===bc===
20350 ==c==
20351 ===ca===
20352 !! html/php
20353 ==a==
20354 ===aa===
20355 ====aaa====
20356 !! end
20357
20358 !! test
20359 Section extraction test (section 2)
20360 !! options
20361 section=2
20362 !! wikitext
20363 start
20364 ==a==
20365 ===aa===
20366 ====aaa====
20367 ==b==
20368 ===ba===
20369 ===bb===
20370 ====bba====
20371 ===bc===
20372 ==c==
20373 ===ca===
20374 !! html/php
20375 ===aa===
20376 ====aaa====
20377 !! end
20378
20379 !! test
20380 Section extraction test (section 3)
20381 !! options
20382 section=3
20383 !! wikitext
20384 start
20385 ==a==
20386 ===aa===
20387 ====aaa====
20388 ==b==
20389 ===ba===
20390 ===bb===
20391 ====bba====
20392 ===bc===
20393 ==c==
20394 ===ca===
20395 !! html/php
20396 ====aaa====
20397 !! end
20398
20399 !! test
20400 Section extraction test (section 4)
20401 !! options
20402 section=4
20403 !! wikitext
20404 start
20405 ==a==
20406 ===aa===
20407 ====aaa====
20408 ==b==
20409 ===ba===
20410 ===bb===
20411 ====bba====
20412 ===bc===
20413 ==c==
20414 ===ca===
20415 !! html/php
20416 ==b==
20417 ===ba===
20418 ===bb===
20419 ====bba====
20420 ===bc===
20421 !! end
20422
20423 !! test
20424 Section extraction test (section 5)
20425 !! options
20426 section=5
20427 !! wikitext
20428 start
20429 ==a==
20430 ===aa===
20431 ====aaa====
20432 ==b==
20433 ===ba===
20434 ===bb===
20435 ====bba====
20436 ===bc===
20437 ==c==
20438 ===ca===
20439 !! html/php
20440 ===ba===
20441 !! end
20442
20443 !! test
20444 Section extraction test (section 6)
20445 !! options
20446 section=6
20447 !! wikitext
20448 start
20449 ==a==
20450 ===aa===
20451 ====aaa====
20452 ==b==
20453 ===ba===
20454 ===bb===
20455 ====bba====
20456 ===bc===
20457 ==c==
20458 ===ca===
20459 !! html/php
20460 ===bb===
20461 ====bba====
20462 !! end
20463
20464 !! test
20465 Section extraction test (section 7)
20466 !! options
20467 section=7
20468 !! wikitext
20469 start
20470 ==a==
20471 ===aa===
20472 ====aaa====
20473 ==b==
20474 ===ba===
20475 ===bb===
20476 ====bba====
20477 ===bc===
20478 ==c==
20479 ===ca===
20480 !! html/php
20481 ====bba====
20482 !! end
20483
20484 !! test
20485 Section extraction test (section 8)
20486 !! options
20487 section=8
20488 !! wikitext
20489 start
20490 ==a==
20491 ===aa===
20492 ====aaa====
20493 ==b==
20494 ===ba===
20495 ===bb===
20496 ====bba====
20497 ===bc===
20498 ==c==
20499 ===ca===
20500 !! html/php
20501 ===bc===
20502 !! end
20503
20504 !! test
20505 Section extraction test (section 9)
20506 !! options
20507 section=9
20508 !! wikitext
20509 start
20510 ==a==
20511 ===aa===
20512 ====aaa====
20513 ==b==
20514 ===ba===
20515 ===bb===
20516 ====bba====
20517 ===bc===
20518 ==c==
20519 ===ca===
20520 !! html/php
20521 ==c==
20522 ===ca===
20523 !! end
20524
20525 !! test
20526 Section extraction test (section 10)
20527 !! options
20528 section=10
20529 !! wikitext
20530 start
20531 ==a==
20532 ===aa===
20533 ====aaa====
20534 ==b==
20535 ===ba===
20536 ===bb===
20537 ====bba====
20538 ===bc===
20539 ==c==
20540 ===ca===
20541 !! html/php
20542 ===ca===
20543 !! end
20544
20545 !! test
20546 Section extraction test (nonexistent section 11)
20547 !! options
20548 section=11
20549 !! wikitext
20550 start
20551 ==a==
20552 ===aa===
20553 ====aaa====
20554 ==b==
20555 ===ba===
20556 ===bb===
20557 ====bba====
20558 ===bc===
20559 ==c==
20560 ===ca===
20561 !! html/php
20562 !! end
20563
20564 !! test
20565 Section extraction test with bogus heading (section 1)
20566 !! options
20567 section=1
20568 !! wikitext
20569 ==a==
20570 ==bogus== not a legal section
20571 ==b==
20572 !! html/php
20573 ==a==
20574 ==bogus== not a legal section
20575 !! end
20576
20577 !! test
20578 Section extraction test with bogus heading (section 2)
20579 !! options
20580 section=2
20581 !! wikitext
20582 ==a==
20583 ==bogus== not a legal section
20584 ==b==
20585 !! html/php
20586 ==b==
20587 !! end
20588
20589 !! test
20590 Section extraction test with comment after heading (section 1)
20591 !! options
20592 section=1
20593 !! wikitext
20594 ==a==
20595 ==b== <!-- -->
20596 ==c==
20597 !! html/php
20598 ==a==
20599 !! end
20600
20601 !! test
20602 Section extraction test with comment after heading (section 2)
20603 !! options
20604 section=2
20605 !! wikitext
20606 ==a==
20607 ==b== <!-- -->
20608 ==c==
20609 !! html/php
20610 ==b== <!-- -->
20611 !! end
20612
20613 !! test
20614 Section extraction test with bogus <nowiki> heading (section 1)
20615 !! options
20616 section=1
20617 !! wikitext
20618 ==a==
20619 ==bogus== <nowiki>not a legal section</nowiki>
20620 ==b==
20621 !! html/php
20622 ==a==
20623 ==bogus== <nowiki>not a legal section</nowiki>
20624 !! end
20625
20626 !! test
20627 Section extraction test with bogus <nowiki> heading (section 2)
20628 !! options
20629 section=2
20630 !! wikitext
20631 ==a==
20632 ==bogus== <nowiki>not a legal section</nowiki>
20633 ==b==
20634 !! html/php
20635 ==b==
20636 !! end
20637
20638 # Formerly testing for T4587, now resolved by the use of unmarked sections
20639 # instead of respecting commented sections
20640 !! test
20641 Section extraction prefixed by comment (section 1)
20642 !! options
20643 section=1
20644 !! wikitext
20645 <!-- -->==sec1==
20646 ==sec2==
20647 !! html/php
20648 ==sec2==
20649 !!end
20650
20651 !! test
20652 Section extraction prefixed by comment (section 2)
20653 !! options
20654 section=2
20655 !! wikitext
20656 <!-- -->==sec1==
20657 ==sec2==
20658 !! html/php
20659
20660 !!end
20661
20662 # Formerly testing for T4607, now resolved by the use of unmarked sections
20663 # instead of respecting HTML-style headings
20664 !! test
20665 Section extraction, mixed wiki and html (section 1)
20666 !! options
20667 section=1
20668 !! wikitext
20669 <h2>unmarked</h2>
20670 unmarked
20671 ==1==
20672 one
20673 ==2==
20674 two
20675 !! html/php
20676 ==1==
20677 one
20678 !! end
20679
20680 !! test
20681 Section extraction, mixed wiki and html (section 2)
20682 !! options
20683 section=2
20684 !! wikitext
20685 <h2>unmarked</h2>
20686 unmarked
20687 ==1==
20688 one
20689 ==2==
20690 two
20691 !! html/php
20692 ==2==
20693 two
20694 !! end
20695
20696
20697 # Formerly testing for T5342
20698 !! test
20699 Section extraction, heading surrounded by <noinclude>
20700 !! options
20701 section=1
20702 !! wikitext
20703 <noinclude>==unmarked==</noinclude>
20704 ==marked==
20705 !! html/php
20706 ==marked==
20707 !!end
20708
20709 # Test behavior of T21910
20710 !! test
20711 Sectiion with all-equals
20712 !! options
20713 section=2
20714 !! wikitext
20715 ===
20716 The line above must have a trailing space
20717 === <!--
20718 --> <!-- -->
20719 But just in case it doesn't...
20720 !! html/php
20721 === <!--
20722 --> <!-- -->
20723 But just in case it doesn't...
20724 !! end
20725
20726 !! test
20727 Section replacement test (section 0)
20728 !! options
20729 replace=0,"xxx"
20730 !! wikitext
20731 start
20732 ==a==
20733 ===aa===
20734 ====aaa====
20735 ==b==
20736 ===ba===
20737 ===bb===
20738 ====bba====
20739 ===bc===
20740 ==c==
20741 ===ca===
20742 !! html/php
20743 xxx
20744
20745 ==a==
20746 ===aa===
20747 ====aaa====
20748 ==b==
20749 ===ba===
20750 ===bb===
20751 ====bba====
20752 ===bc===
20753 ==c==
20754 ===ca===
20755 !! end
20756
20757 !! test
20758 Section replacement test (section 1)
20759 !! options
20760 replace=1,"xxx"
20761 !! wikitext
20762 start
20763 ==a==
20764 ===aa===
20765 ====aaa====
20766 ==b==
20767 ===ba===
20768 ===bb===
20769 ====bba====
20770 ===bc===
20771 ==c==
20772 ===ca===
20773 !! html/php
20774 start
20775 xxx
20776
20777 ==b==
20778 ===ba===
20779 ===bb===
20780 ====bba====
20781 ===bc===
20782 ==c==
20783 ===ca===
20784 !! end
20785
20786 !! test
20787 Section replacement test (section 2)
20788 !! options
20789 replace=2,"xxx"
20790 !! wikitext
20791 start
20792 ==a==
20793 ===aa===
20794 ====aaa====
20795 ==b==
20796 ===ba===
20797 ===bb===
20798 ====bba====
20799 ===bc===
20800 ==c==
20801 ===ca===
20802 !! html/php
20803 start
20804 ==a==
20805 xxx
20806
20807 ==b==
20808 ===ba===
20809 ===bb===
20810 ====bba====
20811 ===bc===
20812 ==c==
20813 ===ca===
20814 !! end
20815
20816 !! test
20817 Section replacement test (section 3)
20818 !! options
20819 replace=3,"xxx"
20820 !! wikitext
20821 start
20822 ==a==
20823 ===aa===
20824 ====aaa====
20825 ==b==
20826 ===ba===
20827 ===bb===
20828 ====bba====
20829 ===bc===
20830 ==c==
20831 ===ca===
20832 !! html/php
20833 start
20834 ==a==
20835 ===aa===
20836 xxx
20837
20838 ==b==
20839 ===ba===
20840 ===bb===
20841 ====bba====
20842 ===bc===
20843 ==c==
20844 ===ca===
20845 !! end
20846
20847 !! test
20848 Section replacement test (section 4)
20849 !! options
20850 replace=4,"xxx"
20851 !! wikitext
20852 start
20853 ==a==
20854 ===aa===
20855 ====aaa====
20856 ==b==
20857 ===ba===
20858 ===bb===
20859 ====bba====
20860 ===bc===
20861 ==c==
20862 ===ca===
20863 !! html/php
20864 start
20865 ==a==
20866 ===aa===
20867 ====aaa====
20868 xxx
20869
20870 ==c==
20871 ===ca===
20872 !! end
20873
20874 !! test
20875 Section replacement test (section 5)
20876 !! options
20877 replace=5,"xxx"
20878 !! wikitext
20879 start
20880 ==a==
20881 ===aa===
20882 ====aaa====
20883 ==b==
20884 ===ba===
20885 ===bb===
20886 ====bba====
20887 ===bc===
20888 ==c==
20889 ===ca===
20890 !! html/php
20891 start
20892 ==a==
20893 ===aa===
20894 ====aaa====
20895 ==b==
20896 xxx
20897
20898 ===bb===
20899 ====bba====
20900 ===bc===
20901 ==c==
20902 ===ca===
20903 !! end
20904
20905 !! test
20906 Section replacement test (section 6)
20907 !! options
20908 replace=6,"xxx"
20909 !! wikitext
20910 start
20911 ==a==
20912 ===aa===
20913 ====aaa====
20914 ==b==
20915 ===ba===
20916 ===bb===
20917 ====bba====
20918 ===bc===
20919 ==c==
20920 ===ca===
20921 !! html/php
20922 start
20923 ==a==
20924 ===aa===
20925 ====aaa====
20926 ==b==
20927 ===ba===
20928 xxx
20929
20930 ===bc===
20931 ==c==
20932 ===ca===
20933 !! end
20934
20935 !! test
20936 Section replacement test (section 7)
20937 !! options
20938 replace=7,"xxx"
20939 !! wikitext
20940 start
20941 ==a==
20942 ===aa===
20943 ====aaa====
20944 ==b==
20945 ===ba===
20946 ===bb===
20947 ====bba====
20948 ===bc===
20949 ==c==
20950 ===ca===
20951 !! html/php
20952 start
20953 ==a==
20954 ===aa===
20955 ====aaa====
20956 ==b==
20957 ===ba===
20958 ===bb===
20959 xxx
20960
20961 ===bc===
20962 ==c==
20963 ===ca===
20964 !! end
20965
20966 !! test
20967 Section replacement test (section 8)
20968 !! options
20969 replace=8,"xxx"
20970 !! wikitext
20971 start
20972 ==a==
20973 ===aa===
20974 ====aaa====
20975 ==b==
20976 ===ba===
20977 ===bb===
20978 ====bba====
20979 ===bc===
20980 ==c==
20981 ===ca===
20982 !! html/php
20983 start
20984 ==a==
20985 ===aa===
20986 ====aaa====
20987 ==b==
20988 ===ba===
20989 ===bb===
20990 ====bba====
20991 xxx
20992
20993 ==c==
20994 ===ca===
20995 !!end
20996
20997 !! test
20998 Section replacement test (section 9)
20999 !! options
21000 replace=9,"xxx"
21001 !! wikitext
21002 start
21003 ==a==
21004 ===aa===
21005 ====aaa====
21006 ==b==
21007 ===ba===
21008 ===bb===
21009 ====bba====
21010 ===bc===
21011 ==c==
21012 ===ca===
21013 !! html/php
21014 start
21015 ==a==
21016 ===aa===
21017 ====aaa====
21018 ==b==
21019 ===ba===
21020 ===bb===
21021 ====bba====
21022 ===bc===
21023 xxx
21024 !! end
21025
21026 !! test
21027 Section replacement test (section 10)
21028 !! options
21029 replace=10,"xxx"
21030 !! wikitext
21031 start
21032 ==a==
21033 ===aa===
21034 ====aaa====
21035 ==b==
21036 ===ba===
21037 ===bb===
21038 ====bba====
21039 ===bc===
21040 ==c==
21041 ===ca===
21042 !! html/php
21043 start
21044 ==a==
21045 ===aa===
21046 ====aaa====
21047 ==b==
21048 ===ba===
21049 ===bb===
21050 ====bba====
21051 ===bc===
21052 ==c==
21053 xxx
21054 !! end
21055
21056 !! test
21057 Section replacement test with initial whitespace (T15728)
21058 !! options
21059 replace=2,"xxx"
21060 !! wikitext
21061 Preformatted initial line
21062 ==a==
21063 ===a===
21064 !! html/php
21065 Preformatted initial line
21066 ==a==
21067 xxx
21068 !! end
21069
21070
21071 !! test
21072 Section extraction, heading followed by pre with 20 spaces (T8398)
21073 !! options
21074 section=1
21075 !! wikitext
21076 ==a==
21077 a
21078 !! html/php
21079 ==a==
21080 a
21081 !! end
21082
21083 !! test
21084 Section extraction, heading followed by pre with 19 spaces (T8398 sanity check)
21085 !! options
21086 section=1
21087 !! wikitext
21088 ==a==
21089 a
21090 !! html/php
21091 ==a==
21092 a
21093 !! end
21094
21095
21096 !! test
21097 Section extraction, <pre> around bogus header (T12309)
21098 !! options
21099 section=2
21100 !! wikitext
21101 == Section One ==
21102 <pre>
21103 =======
21104 </pre>
21105
21106 == Section Two ==
21107 stuff
21108 !! html/php
21109 == Section Two ==
21110 stuff
21111 !! end
21112
21113 !! test
21114 Section replacement, <pre> around bogus header (T12309)
21115 !! options
21116 replace=2,"xxx"
21117 !! wikitext
21118 == Section One ==
21119 <pre>
21120 =======
21121 </pre>
21122
21123 == Section Two ==
21124 stuff
21125 !! html/php
21126 == Section One ==
21127 <pre>
21128 =======
21129 </pre>
21130
21131 xxx
21132 !! end
21133
21134 !! test
21135 Handling of &#x0A; in URLs
21136 !! wikitext
21137 *irc://&#x0A;a
21138 !! html/php
21139 <ul><li><a rel="nofollow" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul>
21140 !! html/parsoid
21141 <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>
21142 !! end
21143
21144 !! test
21145 Handling of %0A in URLs
21146 !! wikitext
21147 *irc://%0Aa
21148 !! html/php
21149 <ul><li><a rel="nofollow" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul>
21150 !! html/parsoid
21151 <ul><li><a rel="mw:ExtLink" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul>
21152 !! end
21153
21154 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
21155 !! test
21156 5 quotes, code coverage +1 line
21157 !! options
21158 parsoid=wt2html
21159 !! wikitext
21160 '''''
21161 !! html/php
21162 !! html/parsoid
21163 <p><b><i></i></b></p>
21164 !! end
21165
21166 # same html as previous, but wikitext adjusted to match parsoid html2wt
21167 # note that wt2html and html2html will put the <i> before the <b>
21168 !! test
21169 5 quotes, code coverage +1 line w/ nowiki (1)
21170 !! options
21171 parsoid=wt2wt,html2wt
21172 !! wikitext
21173 '''''<nowiki/>'''''
21174 !! html/php
21175 <p><i></i>
21176 </p>
21177 !! html/parsoid
21178 <p><b><i></i></b></p>
21179 !! end
21180
21181 # same as previous, just swapping the <i> and <b>
21182 !! test
21183 5 quotes, code coverage +1 line w/ nowiki (2)
21184 !! wikitext
21185 '''''<nowiki/>'''''
21186 !! html/php
21187 <p><i></i>
21188 </p>
21189 !! html/parsoid
21190 <p><i><b></b></i></p>
21191 !! end
21192
21193 !! test
21194 Special:Search page linking.
21195 !! wikitext
21196 {{Special:search}}
21197 !! html
21198 <p><a href="/wiki/Special:Search" title="Special:Search">Special:Search</a>
21199 </p>
21200 !! end
21201
21202 !! test
21203 {{!}} is a magic word
21204 !! wikitext
21205 {{!}} is a magic word there and {{!}} is still a magic word here
21206 | is not a magic word here but {{!}} is still a magic word here
21207 !! html/php
21208 <p>| is a magic word there and | is still a magic word here
21209 | is not a magic word here but | is still a magic word here
21210 </p>
21211 !! html/parsoid
21212 <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
21213 | 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>
21214 !! end
21215
21216 !! test
21217 Say the magic word
21218 !! options
21219 title=[[Parser test]]
21220 !! wikitext
21221 *{{PAGENAME}}
21222 *{{PAGENAMEE}}
21223 *{{FULLPAGENAME}}
21224 *{{FULLPAGENAMEE}}
21225 *{{BASEPAGENAME}}
21226 *{{BASEPAGENAMEE}}
21227 *{{SUBPAGENAME}}
21228 *{{SUBPAGENAMEE}}
21229 *{{ROOTPAGENAME}}
21230 *{{ROOTPAGENAMEE}}
21231 *{{TALKPAGENAME}}
21232 *{{TALKPAGENAMEE}}
21233 *{{SUBJECTPAGENAME}}
21234 *{{SUBJECTPAGENAMEE}}
21235 *{{NAMESPACEE}}
21236 *{{NAMESPACE}}
21237 *{{NAMESPACENUMBER}}
21238 *{{TALKSPACE}}
21239 *{{TALKSPACEE}}
21240 *{{SUBJECTSPACE}}
21241 *{{SUBJECTSPACEE}}
21242 *{{Dynamic|{{NUMBEROFUSERS}}|{{NUMBEROFPAGES}}|{{CURRENTVERSION}}|{{CONTENTLANGUAGE}}|{{DIRECTIONMARK}}|{{CURRENTTIMESTAMP}}|{{NUMBEROFARTICLES}}}}
21243 !! html
21244 <ul><li>Parser test</li>
21245 <li>Parser_test</li>
21246 <li>Parser test</li>
21247 <li>Parser_test</li>
21248 <li>Parser test</li>
21249 <li>Parser_test</li>
21250 <li>Parser test</li>
21251 <li>Parser_test</li>
21252 <li>Parser test</li>
21253 <li>Parser_test</li>
21254 <li>Talk:Parser test</li>
21255 <li>Talk:Parser_test</li>
21256 <li>Parser test</li>
21257 <li>Parser_test</li>
21258 <li></li>
21259 <li></li>
21260 <li>0</li>
21261 <li>Talk</li>
21262 <li>Talk</li>
21263 <li></li>
21264 <li></li>
21265 <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>
21266 !! end
21267 ### Note: Above tests excludes the "{{NUMBEROFADMINS}}" magic word because it generates a MySQL error when included.
21268
21269 !! test
21270 Gallery with valid attributes
21271 !! wikitext
21272 <gallery type="123" summary="345">
21273 File:File:Foobar.jpg
21274 </gallery>
21275 !! html/php
21276 <ul class="gallery mw-gallery-traditional" type="123">
21277 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21278 <div class="thumb" style="height: 150px;">File:Foobar.jpg</div>
21279 <div class="gallerytext">
21280 </div>
21281 </div></li>
21282 </ul>
21283
21284 !! html/parsoid
21285 <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"}}'>
21286 <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>
21287 </ul>
21288 !! end
21289
21290 ## Parsoid thinks the "centre" here is a property, not a caption.
21291 !! test
21292 Gallery
21293 !! options
21294 parsoid={
21295 "modes": ["wt2html"],
21296 "nativeGallery": true
21297 }
21298 !! wikitext
21299 <gallery>
21300 image1.png |
21301 image2.gif|||||
21302
21303 image3|
21304 image4 |300px| centre
21305 image5.svg| http://///////
21306 [[x|xx]]]]
21307 * image6
21308 </gallery>
21309 !! html/php
21310 <ul class="gallery mw-gallery-traditional">
21311 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21312 <div class="thumb" style="height: 150px;">Image1.png</div>
21313 <div class="gallerytext">
21314 </div>
21315 </div></li>
21316 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21317 <div class="thumb" style="height: 150px;">Image2.gif</div>
21318 <div class="gallerytext">
21319 </div>
21320 </div></li>
21321 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21322 <div class="thumb" style="height: 150px;">Image3</div>
21323 <div class="gallerytext">
21324 </div>
21325 </div></li>
21326 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21327 <div class="thumb" style="height: 150px;">Image4</div>
21328 <div class="gallerytext">
21329 <pre>centre
21330 </pre>
21331 </div>
21332 </div></li>
21333 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21334 <div class="thumb" style="height: 150px;">Image5.svg</div>
21335 <div class="gallerytext">
21336 <p><a rel="nofollow" class="external free" href="http://///////">http://///////</a>
21337 </p>
21338 </div>
21339 </div></li>
21340 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21341 <div class="thumb" style="height: 150px;">* image6</div>
21342 <div class="gallerytext">
21343 </div>
21344 </div></li>
21345 </ul>
21346
21347 !! html/parsoid
21348 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21349 <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>
21350 <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>
21351 <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>
21352 <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>
21353 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline typeof="mw:Error mw:Image"><a href="./File: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>
21354 <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>
21355 </ul>
21356 !! end
21357
21358 !! test
21359 Gallery (with options, html)
21360 !! options
21361 parsoid={
21362 "modes": ["wt2html", "html2html"],
21363 "nativeGallery": true
21364 }
21365 !! wikitext
21366 <gallery widths="70px" heights="40px" perrow="2" caption="Foo [[Main Page]]">
21367 File:Nonexistent.jpg|caption
21368 File:Nonexistent.jpg
21369 image:foobar.jpg|some '''caption''' [[Main Page]]
21370 image:foobar.jpg
21371 image:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla.
21372 </gallery>
21373 !! html/php
21374 <ul class="gallery mw-gallery-traditional" style="max-width: 226px;_width: 226px;">
21375 <li class='gallerycaption'>Foo <a href="/wiki/Main_Page" title="Main Page">Main Page</a></li>
21376 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21377 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
21378 <div class="gallerytext">
21379 <p>caption
21380 </p>
21381 </div>
21382 </div></li>
21383 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21384 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
21385 <div class="gallerytext">
21386 </div>
21387 </div></li>
21388 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21389 <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>
21390 <div class="gallerytext">
21391 <p>some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
21392 </p>
21393 </div>
21394 </div></li>
21395 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21396 <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>
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="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>
21402 <div class="gallerytext">
21403 <p>blabla.
21404 </p>
21405 </div>
21406 </div></li>
21407 </ul>
21408
21409 !! html/parsoid
21410 <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":{}}'>
21411 <li class="gallerycaption">Foo <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></li>
21412 <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>
21413 <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>
21414 <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>
21415 <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>
21416 <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>
21417 </ul>
21418 !! end
21419
21420 !! test
21421 Gallery (with options, extsrc)
21422 !! options
21423 parsoid={
21424 "nativeGallery": false
21425 }
21426 !! wikitext
21427 <gallery widths="70px" heights="40px" perrow="2" caption="Foo [[Main Page]]">
21428 File:Nonexistent.jpg|caption
21429 File:Nonexistent.jpg
21430 image:foobar.jpg|some '''caption''' [[Main Page]]
21431 image:foobar.jpg
21432 image:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla.
21433 </gallery>
21434 !! html/php
21435 <ul class="gallery mw-gallery-traditional" style="max-width: 226px;_width: 226px;">
21436 <li class='gallerycaption'>Foo <a href="/wiki/Main_Page" title="Main Page">Main Page</a></li>
21437 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21438 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
21439 <div class="gallerytext">
21440 <p>caption
21441 </p>
21442 </div>
21443 </div></li>
21444 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21445 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
21446 <div class="gallerytext">
21447 </div>
21448 </div></li>
21449 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21450 <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>
21451 <div class="gallerytext">
21452 <p>some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
21453 </p>
21454 </div>
21455 </div></li>
21456 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21457 <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>
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="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>
21463 <div class="gallerytext">
21464 <p>blabla.
21465 </p>
21466 </div>
21467 </div></li>
21468 </ul>
21469
21470 !! html/parsoid
21471 <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"}}'>
21472 <li class="gallerycaption">Foo <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></li>
21473 <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>
21474 <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>
21475 <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>
21476 <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>
21477 <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>
21478 </ul>
21479 !! end
21480
21481 !! test
21482 Gallery (without px units)
21483 !! wikitext
21484 <gallery widths="70" heights="40">
21485 File:Foobar.jpg
21486 </gallery>
21487 !! html/php
21488 <ul class="gallery mw-gallery-traditional">
21489 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21490 <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>
21491 <div class="gallerytext">
21492 </div>
21493 </div></li>
21494 </ul>
21495
21496 !! html/parsoid
21497 <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"}}'>
21498 <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>
21499 </ul>
21500 !! end
21501
21502 !! test
21503 Gallery (with invalid units)
21504 !! wikitext
21505 <gallery widths="70em" heights="40em">
21506 File:Foobar.jpg
21507 </gallery>
21508 !! html/php
21509 <ul class="gallery mw-gallery-traditional">
21510 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21511 <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>
21512 <div class="gallerytext">
21513 </div>
21514 </div></li>
21515 </ul>
21516
21517 !! html/parsoid
21518 <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"}}'>
21519 <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>
21520 </ul>
21521 !! end
21522
21523 !! test
21524 Gallery with link that has fragment
21525 !! options
21526 parsoid={
21527 "modes": ["wt2html", "html2html"],
21528 "nativeGallery": true
21529 }
21530 !! wikitext
21531 <gallery>
21532 image:foobar.jpg|link=Main_Page
21533 image:foobar.jpg|link=Main_Page#section
21534 image:foobar.jpg|link=Main Page#section|caption
21535 </gallery>
21536 !! html/php
21537 <ul class="gallery mw-gallery-traditional">
21538 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21539 <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>
21540 <div class="gallerytext">
21541 </div>
21542 </div></li>
21543 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21544 <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>
21545 <div class="gallerytext">
21546 </div>
21547 </div></li>
21548 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21549 <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>
21550 <div class="gallerytext">
21551 <p>caption
21552 </p>
21553 </div>
21554 </div></li>
21555 </ul>
21556
21557 !! html/parsoid
21558 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21559 <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>
21560 <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>
21561 <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>
21562 </ul>
21563 !! end
21564
21565 !! test
21566 Gallery with template inside caption
21567 !! options
21568 parsoid={
21569 "nativeGallery": true
21570 }
21571 !! wikitext
21572 <gallery caption="{{echo|hi}}">
21573 File:Foobar.jpg|{{echo|ho}}
21574 </gallery>
21575 !! html/php
21576 <ul class="gallery mw-gallery-traditional">
21577 <li class='gallerycaption'>hi</li>
21578 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21579 <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>
21580 <div class="gallerytext">
21581 <p>ho
21582 </p>
21583 </div>
21584 </div></li>
21585 </ul>
21586
21587 !! html/parsoid
21588 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt6" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21589 <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>
21590 <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>
21591 </ul>
21592 !! end
21593
21594 !! test
21595 Gallery with wikitext inside gallery caption
21596 !! wikitext
21597 <gallery caption="# List item
21598
21599 Text '''bold''' [[link]] {{ns:-1}}
21600
21601 [[File:Foobar.jpg|thumb|File in gallery caption]]">
21602 File:Foobar.jpg|Image caption
21603 </gallery>
21604 !! html/php
21605 <ul class="gallery mw-gallery-traditional">
21606 <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>
21607 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21608 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/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>
21609 <div class="gallerytext">
21610 <p>Image caption
21611 </p>
21612 </div>
21613 </div></li>
21614 </ul>
21615
21616 !! end
21617
21618 !! test
21619 Gallery with wikitext inside caption
21620 !! options
21621 parsoid={
21622 "nativeGallery": true
21623 }
21624 !! wikitext
21625 <gallery>
21626 File:Foobar.jpg|alt=galleryalt|[[File:Foobar.jpg|alt=inneralt|20x20px|desc]]
21627 File:Foobar.jpg|alt=galleryalt|{{Test|unamedParam|alt=param}}
21628 </gallery>
21629 !! html/php
21630 <ul class="gallery mw-gallery-traditional">
21631 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21632 <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>
21633 <div class="gallerytext">
21634 <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>
21635 </p>
21636 </div>
21637 </div></li>
21638 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21639 <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>
21640 <div class="gallerytext">
21641 <p>This is a test template
21642 </p>
21643 </div>
21644 </div></li>
21645 </ul>
21646
21647 !! html/parsoid
21648 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt6" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21649 <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>
21650 <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>
21651 </ul>
21652 !! end
21653
21654 !! test
21655 Gallery (with showfilename option)
21656 !! options
21657 parsoid={
21658 "nativeGallery": true
21659 }
21660 !! wikitext
21661 <gallery showfilename="">
21662 File:Nonexistent.jpg|caption
21663 File:Nonexistent.jpg
21664 File:Foobar.jpg|some '''caption''' [[Main Page]]
21665 File:Foobar.jpg
21666 </gallery>
21667 !! html/php
21668 <ul class="gallery mw-gallery-traditional">
21669 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21670 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
21671 <div class="gallerytext">
21672 <p><a href="/wiki/File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">Nonexistent.jpg</a>
21673 caption
21674 </p>
21675 </div>
21676 </div></li>
21677 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21678 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
21679 <div class="gallerytext">
21680 <p><a href="/wiki/File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">Nonexistent.jpg</a>
21681 </p>
21682 </div>
21683 </div></li>
21684 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21685 <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>
21686 <div class="gallerytext">
21687 <p><a href="/wiki/File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">Foobar.jpg</a>
21688 some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
21689 </p>
21690 </div>
21691 </div></li>
21692 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21693 <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>
21694 <div class="gallerytext">
21695 <p><a href="/wiki/File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">Foobar.jpg</a>
21696 </p>
21697 </div>
21698 </div></li>
21699 </ul>
21700
21701 !! html/parsoid
21702 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{"showfilename":""},"body":{}}'>
21703 <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>
21704 <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>
21705 <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>
21706 <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>
21707 </ul>
21708 !! end
21709
21710 ## Should Parsoid be preserving these variations? See T151367
21711 !! test
21712 Gallery (with namespace-less filenames)
21713 !! options
21714 parsoid={
21715 "modes": ["wt2html", "html2html"],
21716 "nativeGallery": true
21717 }
21718 !! wikitext
21719 <gallery>
21720 File:Nonexistent.jpg
21721 Nonexistent.jpg
21722 image:foobar.jpg
21723 foobar.jpg
21724 </gallery>
21725 !! html/php
21726 <ul class="gallery mw-gallery-traditional">
21727 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21728 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
21729 <div class="gallerytext">
21730 </div>
21731 </div></li>
21732 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21733 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
21734 <div class="gallerytext">
21735 </div>
21736 </div></li>
21737 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21738 <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>
21739 <div class="gallerytext">
21740 </div>
21741 </div></li>
21742 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21743 <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>
21744 <div class="gallerytext">
21745 </div>
21746 </div></li>
21747 </ul>
21748
21749 !! html/parsoid
21750 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21751 <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>
21752 <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>
21753 <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>
21754 <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>
21755 </ul>
21756 !! end
21757
21758 !! test
21759 Gallery override link with wikilink (T36852)
21760 !! options
21761 parsoid={
21762 "nativeGallery": true
21763 }
21764 !! wikitext
21765 <gallery>
21766 File:Foobar.jpg|alt=galleryalt|link=Wikilink
21767 </gallery>
21768 !! html/php
21769 <ul class="gallery mw-gallery-traditional">
21770 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21771 <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>
21772 <div class="gallerytext">
21773 </div>
21774 </div></li>
21775 </ul>
21776
21777 !! html/parsoid
21778 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21779 <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>
21780 </ul>
21781 !! end
21782
21783 !! test
21784 Gallery override link with absolute external link (T36852)
21785 !! options
21786 parsoid={
21787 "nativeGallery": true
21788 }
21789 !! wikitext
21790 <gallery>
21791 File:Foobar.jpg|alt=galleryalt|link=http://www.example.org
21792 </gallery>
21793 !! html/php
21794 <ul class="gallery mw-gallery-traditional">
21795 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21796 <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>
21797 <div class="gallerytext">
21798 </div>
21799 </div></li>
21800 </ul>
21801
21802 !! html/parsoid
21803 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21804 <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>
21805 </ul>
21806 !! end
21807
21808 !! test
21809 Gallery override link with absolute external link with LanguageConverter
21810 !! options
21811 language=zh
21812 !! wikitext
21813 <gallery>
21814 File:foobar.jpg|caption|alt=galleryalt|link=http://www.example.org
21815 </gallery>
21816 !! html/php
21817 <ul class="gallery mw-gallery-traditional">
21818 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21819 <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>
21820 <div class="gallerytext">
21821 <p>caption
21822 </p>
21823 </div>
21824 </div></li>
21825 </ul>
21826
21827 !! html/parsoid
21828 <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"}}'>
21829 <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>
21830 </ul>
21831 !! end
21832
21833 !! test
21834 Gallery override link with malicious javascript (T36852)
21835 !! options
21836 parsoid={
21837 "modes": ["wt2html", "html2html"],
21838 "nativeGallery": true
21839 }
21840 !! wikitext
21841 <gallery>
21842 File:Foobar.jpg|alt=galleryalt|link=" onclick="alert('malicious javascript code!');
21843 </gallery>
21844 !! html/php
21845 <ul class="gallery mw-gallery-traditional">
21846 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21847 <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>
21848 <div class="gallerytext">
21849 </div>
21850 </div></li>
21851 </ul>
21852
21853 !! html/parsoid
21854 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21855 <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>
21856 </ul>
21857 !! end
21858
21859 # Note that parsoid uses the invalid link as a caption, PHP does not.
21860 !! test
21861 Gallery with invalid title as link (T45964)
21862 !! options
21863 parsoid={
21864 "modes": ["wt2html", "html2html"],
21865 "nativeGallery": true
21866 }
21867 !! wikitext
21868 <gallery>
21869 File:Foobar.jpg|link=<
21870 </gallery>
21871 !! html/php
21872 <ul class="gallery mw-gallery-traditional">
21873 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21874 <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>
21875 <div class="gallerytext">
21876 </div>
21877 </div></li>
21878 </ul>
21879
21880 !! html/parsoid
21881 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21882 <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>
21883 </ul>
21884 !! end
21885
21886 !! test
21887 Serialize gallery without attrs in data-mw
21888 !! options
21889 parsoid={
21890 "modes": ["html2wt"],
21891 "nativeGallery": true
21892 }
21893 !! html/parsoid
21894 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","body":{}}'>
21895 <li class="gallerycaption">123</li>
21896 <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>
21897 </ul>
21898 !! wikitext
21899 <gallery caption="123">
21900 File:Test.png
21901 </gallery>
21902 !! end
21903
21904 !! test
21905 Gallery with class and style attributes
21906 !! options
21907 parsoid={
21908 "nativeGallery": true
21909 }
21910 !! wikitext
21911 <gallery class="center" style="text-align: center;">
21912 File:Foobar.jpg
21913 </gallery>
21914 !! html/php
21915 <ul class="gallery mw-gallery-traditional center" style="text-align: center;">
21916 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21917 <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>
21918 <div class="gallerytext">
21919 </div>
21920 </div></li>
21921 </ul>
21922
21923 !! html/parsoid
21924 <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":{}}'>
21925 <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>
21926 </ul>
21927 !! end
21928
21929 !! test
21930 Gallery in slideshow mode
21931 !! options
21932 parsoid={
21933 "nativeGallery": true
21934 }
21935 !! wikitext
21936 <gallery mode="slideshow" showthumbnails="">
21937 File:Foobar.jpg
21938 </gallery>
21939 !! html/php
21940 <ul class="gallery mw-gallery-slideshow" data-showthumbnails="1">
21941 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21942 <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>
21943 <div class="gallerytext">
21944 </div>
21945 </div></li>
21946 </ul>
21947
21948 !! html/parsoid
21949 <ul class="gallery mw-gallery-slideshow" data-showthumbnails="1" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{"mode":"slideshow","showthumbnails":""},"body":{}}'>
21950 <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>
21951 </ul>
21952 !! end
21953
21954 !! test
21955 Serialize gallery image captions on a line
21956 !! options
21957 parsoid={
21958 "modes": ["html2wt"],
21959 "nativeGallery": true
21960 }
21961 !! html/parsoid
21962 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21963 <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>
21964 <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>
21965 </ul>
21966 !! wikitext
21967 <gallery>
21968 File:Foobar.jpg| hi ho
21969 File:Foobar.jpg|hi<br />ho
21970 </gallery>
21971 !! end
21972
21973 !! test
21974 HTML Hex character encoding (spells the word "JavaScript")
21975 !! options
21976 parsoid=wt2html,wt2wt,html2html
21977 !! wikitext
21978 &#x4A;&#x061;&#x0076;&#x00061;&#x000053;&#x0000063;&#114;&#x0000069;&#00000112;&#x0000000074;
21979 !! html/php
21980 <p>&#x4a;&#x61;&#x76;&#x61;&#x53;&#x63;&#114;&#x69;&#112;&#x74;
21981 </p>
21982 !! html/parsoid
21983 <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>
21984 !! end
21985
21986 !! test
21987 HTML Hex character encoding bogus encoding (T28437 regression check)
21988 !! wikitext
21989 &#xsee;&#XSEE;
21990 !! html
21991 <p>&amp;#xsee;&amp;#XSEE;
21992 </p>
21993 !! end
21994
21995 !! test
21996 HTML Hex character encoding mixed case
21997 !! options
21998 parsoid=wt2html,wt2wt,html2html
21999 !! wikitext
22000 &#xEE;&#Xee;
22001 !! html/php
22002 <p>&#xee;&#xee;
22003 </p>
22004 !! html/parsoid
22005 <p><span typeof="mw:Entity">î</span><span typeof="mw:Entity">î</span></p>
22006 !! end
22007
22008 # See: https://www.w3.org/TR/html5/syntax.html#character-references
22009 # Note that U+000C (form feed) is not a valid XML character, so
22010 # it is banned even though allowed in HTML5.
22011 !! test
22012 Illegal character references (T106578)
22013 !! wikitext
22014 ; Null: &#00;
22015 ; FF: &#xC;
22016 ; CR: &#xD;
22017 ; Control (low): &#8;
22018 ; Control (high): &#x7F; &#x9F;
22019 ; Surrogate: &#xD83D;&#xDCA9;
22020 ; This is an okay astral character: &#x1F4A9;
22021 !! html+tidy
22022 <dl><dt>Null</dt>
22023 <dd>&amp;#00;</dd>
22024 <dt>FF</dt>
22025 <dd>&amp;#xC;</dd>
22026 <dt>CR</dt>
22027 <dd>&amp;#xD;</dd>
22028 <dt>Control (low)</dt>
22029 <dd>&amp;#8;</dd>
22030 <dt>Control (high)</dt>
22031 <dd>&amp;#x7F; &amp;#x9F;</dd>
22032 <dt>Surrogate</dt>
22033 <dd>&amp;#xD83D;&amp;#xDCA9;</dd>
22034 <dt>This is an okay astral character</dt>
22035 <dd>&#x1f4a9;</dd></dl>
22036 !! end
22037
22038 !! test
22039 __FORCETOC__ override
22040 !! wikitext
22041 __NEWSECTIONLINK__
22042 __FORCETOC__
22043 !! html/php
22044 <p><br />
22045 </p>
22046 !! end
22047
22048 !! test
22049 ISBN code coverage
22050 !! wikitext
22051 ISBN 978-0-1234-56&#x20;789
22052 !! html/php
22053 <p><a href="/wiki/Special:BookSources/9780123456" class="internal mw-magiclink-isbn">ISBN 978-0-1234-56</a>&#x20;789
22054 </p>
22055 !! html/parsoid
22056 <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>
22057 !! end
22058
22059 !! test
22060 ISBN followed by 5 spaces
22061 !! wikitext
22062 ISBN
22063 !! html
22064 <p>ISBN
22065 </p>
22066 !! end
22067
22068 !! test
22069 Double ISBN
22070 !! wikitext
22071 ISBN ISBN 1234567890
22072 !! html/php
22073 <p>ISBN <a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
22074 </p>
22075 !! html/parsoid
22076 <p>ISBN <a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a></p>
22077 !! end
22078
22079 # Uppercase X and lowercase x as well
22080 !! test
22081 ISBN with an X
22082 !! wikitext
22083 ISBN 3-462-04561-X
22084 ISBN 3-462-04561-x
22085 ISBN 080442957X
22086 ISBN 080442957x
22087 ISBN 978080442957X
22088 ISBN 978080442957x
22089 !! html/php
22090 <p><a href="/wiki/Special:BookSources/346204561X" class="internal mw-magiclink-isbn">ISBN 3-462-04561-X</a>
22091 <a href="/wiki/Special:BookSources/346204561X" class="internal mw-magiclink-isbn">ISBN 3-462-04561-x</a>
22092 <a href="/wiki/Special:BookSources/080442957X" class="internal mw-magiclink-isbn">ISBN 080442957X</a>
22093 <a href="/wiki/Special:BookSources/080442957X" class="internal mw-magiclink-isbn">ISBN 080442957x</a>
22094 <a href="/wiki/Special:BookSources/978080442957X" class="internal mw-magiclink-isbn">ISBN 978080442957X</a>
22095 <a href="/wiki/Special:BookSources/978080442957X" class="internal mw-magiclink-isbn">ISBN 978080442957x</a>
22096 </p>
22097 !! html/parsoid
22098 <p><a href="./Special:BookSources/346204561X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 3-462-04561-X</a>
22099 <a href="./Special:BookSources/346204561X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 3-462-04561-x</a>
22100 <a href="./Special:BookSources/080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 080442957X</a>
22101 <a href="./Special:BookSources/080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 080442957x</a>
22102 <a href="./Special:BookSources/978080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978080442957X</a>
22103 <a href="./Special:BookSources/978080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978080442957x</a></p>
22104 !! end
22105
22106 !! test
22107 ISBN with empty prefix (parsoid test)
22108 !! wikitext
22109 ISBN 1234567890
22110 !! html/php
22111 <p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
22112 </p>
22113 !! html/parsoid
22114 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink">ISBN 1234567890</a></p>
22115 !! end
22116
22117 !! test
22118 T24905: <abbr> followed by ISBN followed by </a>
22119 !! wikitext
22120 <abbr>(fr)</abbr> ISBN 2753300917 [http://www.example.com example.com]
22121 !! html/php
22122 <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>
22123 </p>
22124 !! html/parsoid
22125 <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>
22126 !! end
22127
22128 !! test
22129 Double RFC
22130 !! wikitext
22131 RFC RFC 1234
22132 !! html/php
22133 <p>RFC <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc1234">RFC 1234</a>
22134 </p>
22135 !! html/parsoid
22136 <p>RFC <a href="https://tools.ietf.org/html/rfc1234" rel="mw:ExtLink" class="external mw-magiclink">RFC 1234</a></p>
22137 !! end
22138
22139 !! test
22140 Double RFC with a wiki link
22141 !! wikitext
22142 RFC [[RFC 1234]]
22143 !! html/php
22144 <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>
22145 </p>
22146 !! html/parsoid
22147 <p>RFC <a rel="mw:WikiLink" href="./RFC_1234" title="RFC 1234">RFC 1234</a></p>
22148 !! end
22149
22150 !! test
22151 RFC code coverage
22152 !! wikitext
22153 RFC 983&#x20;987
22154 !! html/php
22155 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc983">RFC 983</a>&#x20;987
22156 </p>
22157 !! html/parsoid
22158 <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>
22159 !! end
22160
22161 !! test
22162 Centre-aligned image
22163 !! wikitext
22164 [[Image:foobar.jpg|centre]]
22165 !! html/php
22166 <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>
22167
22168 !! html/parsoid
22169 <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>
22170 !! end
22171
22172 !! test
22173 None-aligned image
22174 !! wikitext
22175 [[Image:foobar.jpg|none]]
22176 !! html/php
22177 <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>
22178
22179 !! html/parsoid
22180 <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>
22181 !! end
22182
22183 !! test
22184 Width + Height sized image (using px) (height is ignored)
22185 !! wikitext
22186 [[Image:foobar.jpg|640x480px]]
22187 !! html/php
22188 <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>
22189 </p>
22190 !! html/parsoid
22191 <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>
22192 !! end
22193
22194 !! test
22195 Width-sized image (using px, no following whitespace)
22196 !! wikitext
22197 [[Image:foobar.jpg|640px]]
22198 !! html/php
22199 <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>
22200 </p>
22201 !! html/parsoid
22202 <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>
22203 !! end
22204
22205 !! test
22206 Width-sized image (using px, with following whitespace - test regression from r39467)
22207 !! wikitext
22208 [[Image:foobar.jpg|640px ]]
22209 !! html/php
22210 <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>
22211 </p>
22212 !! html/parsoid
22213 <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>
22214 !!end
22215
22216 !! test
22217 Width-sized image (using px, with preceding whitespace - test regression from r39467)
22218 !! wikitext
22219 [[Image:foobar.jpg| 640px]]
22220 !! html/php
22221 <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>
22222 </p>
22223 !! html/parsoid
22224 <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>
22225 !! end
22226
22227 !! test
22228 Image with page parameter
22229 !! options
22230 djvu
22231 !! wikitext
22232 [[File:LoremIpsum.djvu|page=2]]
22233 !! html/php
22234 <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>
22235 </p>
22236 !! html/parsoid
22237 <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>
22238 !! end
22239
22240 !! test
22241 Another italics / bold test
22242 !! wikitext
22243 ''' ''x'
22244 !! html
22245 <pre>'<i> </i>x'
22246 </pre>
22247 !!end
22248
22249 # FIXME: The php output seems broken. It's interleaving some open/close tags.
22250 !! test
22251 dt/dd/dl test
22252 !! wikitext
22253 :;;;::
22254 !! html/php
22255 <dl><dd><dl><dt><dl><dt><dl><dt><dl><dd><dl><dd></dt></dl></dd></dl></dd></dl></dd></dl></dd></dl></dd></dl>
22256 !! html/parsoid
22257 <dl><dd><dl><dt><dl><dt><dl><dt><dl><dd><dl><dd></dd></dl></dd></dl></dt></dl></dt></dl></dt></dl></dd></dl>
22258
22259 !!end
22260
22261 # Images with the "|" character in external URLs in comment tags; Eats half the comment, leaves unmatched "</a>" tag.
22262 !! test
22263 Images with the "|" character in the comment
22264 !! wikitext
22265 [[File:Foobar.jpg|thumb|An [http://test/?param1=|left|&param2=|x external] URL]]
22266 !! html/php
22267 <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>
22268
22269 !! html/parsoid
22270 <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>
22271 !! end
22272
22273 !! test
22274 [Before] HTML without raw HTML enabled ($wgRawHtml==false)
22275 !! wikitext
22276 <html><script>alert(1);</script></html>
22277 !! html
22278 <p>&lt;html&gt;&lt;script&gt;alert(1);&lt;/script&gt;&lt;/html&gt;
22279 </p>
22280 !! end
22281
22282 !! test
22283 HTML with raw HTML ($wgRawHtml==true)
22284 !! options
22285 wgRawHtml=1
22286 !! wikitext
22287 <html><script>alert(1);</script></html>
22288 !! html/php
22289 <p><script>alert(1);</script>
22290 </p>
22291 !! html/parsoid
22292 <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>
22293 !! end
22294
22295 !! test
22296 Parents of subpages, one level up
22297 !! options
22298 subpage title=[[Subpage test/L1/L2/L3]]
22299 !! wikitext
22300 [[../|L2]]
22301 !! html
22302 <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>
22303 </p>
22304 !! end
22305
22306
22307 !! test
22308 Parents of subpages, one level up, not named
22309 !! options
22310 subpage title=[[Subpage test/L1/L2/L3]]
22311 !! wikitext
22312 [[../]]
22313 !! html
22314 <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>
22315 </p>
22316 !! end
22317
22318
22319
22320 !! test
22321 Parents of subpages, two levels up
22322 !! options
22323 subpage title=[[Subpage test/L1/L2/L3]]
22324 !! wikitext
22325 [[../../|L1]]2
22326
22327 [[../../|L1]]l
22328 !! html
22329 <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
22330 </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>
22331 </p>
22332 !! end
22333
22334 !! test
22335 Parents of subpages, two levels up, without trailing slash or name.
22336 !! options
22337 subpage title=[[Subpage test/L1/L2/L3]]
22338 !! wikitext
22339 [[../..]]
22340 !! html
22341 <p>[[../..]]
22342 </p>
22343 !! end
22344
22345 !! test
22346 Parents of subpages, two levels up, with lots of extra trailing slashes.
22347 !! options
22348 subpage title=[[Subpage test/L1/L2/L3]]
22349 !! wikitext
22350 [[../../////]]
22351 !! html
22352 <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>
22353 </p>
22354 !! end
22355
22356 !! article
22357 Subpage test/L1/L2/L3Sibling
22358 !! text
22359 Sibling article
22360 !! endarticle
22361
22362 !! test
22363 Transclusion of a sibling page (one level up)
22364 !! options
22365 subpage title=[[Subpage test/L1/L2/L3]]
22366 !! wikitext
22367 {{../L3Sibling}}
22368 !! html
22369 <p>Sibling article
22370 </p>
22371 !! end
22372
22373 !! test
22374 Transclusion of a child page
22375 !! options
22376 subpage title=[[Subpage test/L1/L2]]
22377 !! wikitext
22378 {{/L3Sibling}}
22379 !! html
22380 <p>Sibling article
22381 </p>
22382 !! end
22383
22384 # This is wt2html only in Parsoid because we add <nowiki>
22385 # because of {{..}} and we don't expect to fix that to
22386 # eliminate the nowikis selective for {{..}} markup.
22387 !! test
22388 Non-transclusion because of too many up levels
22389 !! options
22390 subpage title=[[Subpage test/L1/L2/L3]]
22391 parsoid=wt2html
22392 !! wikitext
22393 {{../../../../More than parent}}
22394 !! html/php
22395 <p>{{../../../../More than parent}}
22396 </p>
22397 !! html/parsoid
22398 <p>{{../../../../More than parent}}</p>
22399 !! end
22400
22401 !! test
22402 Definition list code coverage
22403 !! wikitext
22404 ;title :def
22405 ;title :def
22406 ;title:def
22407 !! html/php
22408 <dl><dt>title</dt>
22409 <dd>def</dd>
22410 <dt>title</dt>
22411 <dd>def</dd>
22412 <dt>title</dt>
22413 <dd>def</dd></dl>
22414 !! html/parsoid
22415 <dl><dt>title </dt><dd>def</dd>
22416 <dt>title </dt><dd>def</dd>
22417 <dt>title</dt><dd>def</dd></dl>
22418 !! end
22419
22420 !! test
22421 Don't fall for the self-closing div
22422 !! wikitext
22423 <div>hello world</div/>
22424 !! html
22425 <div>hello world</div>
22426
22427 !! end
22428
22429 !! test
22430 MSGNW magic word
22431 !! wikitext
22432 {{MSGNW:msg}}
22433 !! html/php
22434 <p>&#91;&#91;:Template:Msg&#93;&#93;
22435 </p>
22436 !! end
22437
22438 !! test
22439 RAW magic word
22440 !! wikitext
22441 {{RAW:QUERTY}}
22442 !! html
22443 <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>
22444 </p>
22445 !! end
22446
22447 # This isn't needed for XHTML conformance, but would be handy as a fallback security measure
22448 !! test
22449 Always escape literal '>' in output, not just after '<'
22450 !! wikitext
22451 ><>
22452 !! html
22453 <p>&gt;&lt;&gt;
22454 </p>
22455 !! end
22456
22457 !! test
22458 Template caching
22459 !! wikitext
22460 {{Test}}
22461 {{Test}}
22462 !! html
22463 <p>This is a test template
22464 This is a test template
22465 </p>
22466 !! end
22467
22468
22469 !! article
22470 MediaWiki:Fake
22471 !! text
22472 ==header==
22473 !! endarticle
22474
22475 !! test
22476 Inclusion of !userCanEdit() content
22477 !! wikitext
22478 {{MediaWiki:Fake}}
22479 !! html
22480 <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>
22481
22482 !! end
22483
22484
22485 !! test
22486 Out-of-order TOC heading levels
22487 !! wikitext
22488 ==2==
22489 ======6======
22490 ===3===
22491 =1=
22492 =====5=====
22493 ==2==
22494 !! html
22495 <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>
22496 <ul>
22497 <li class="toclevel-1 tocsection-1"><a href="#2"><span class="tocnumber">1</span> <span class="toctext">2</span></a>
22498 <ul>
22499 <li class="toclevel-2 tocsection-2"><a href="#6"><span class="tocnumber">1.1</span> <span class="toctext">6</span></a></li>
22500 <li class="toclevel-2 tocsection-3"><a href="#3"><span class="tocnumber">1.2</span> <span class="toctext">3</span></a></li>
22501 </ul>
22502 </li>
22503 <li class="toclevel-1 tocsection-4"><a href="#1"><span class="tocnumber">2</span> <span class="toctext">1</span></a>
22504 <ul>
22505 <li class="toclevel-2 tocsection-5"><a href="#5"><span class="tocnumber">2.1</span> <span class="toctext">5</span></a></li>
22506 <li class="toclevel-2 tocsection-6"><a href="#2_2"><span class="tocnumber">2.2</span> <span class="toctext">2</span></a></li>
22507 </ul>
22508 </li>
22509 </ul>
22510 </div>
22511
22512 <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>
22513 <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>
22514 <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>
22515 <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>
22516 <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>
22517 <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>
22518
22519 !! end
22520
22521
22522 !! test
22523 ISBN with a dummy number
22524 !! wikitext
22525 ISBN ---
22526 !! html
22527 <p>ISBN ---
22528 </p>
22529 !! end
22530
22531
22532 !! test
22533 ISBN with space-delimited number
22534 !! wikitext
22535 ISBN 92 9017 032 8
22536 !! html/php
22537 <p><a href="/wiki/Special:BookSources/9290170328" class="internal mw-magiclink-isbn">ISBN 92 9017 032 8</a>
22538 </p>
22539 !! html/parsoid
22540 <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>
22541 !! end
22542
22543
22544 !! test
22545 ISBN with multiple spaces, no number
22546 !! wikitext
22547 ISBN foo
22548 !! html
22549 <p>ISBN foo
22550 </p>
22551 !! end
22552
22553
22554 !! test
22555 ISBN length
22556 !! wikitext
22557 ISBN 123456789
22558
22559 ISBN 1234567890
22560
22561 ISBN 12345678901
22562 !! html/php
22563 <p>ISBN 123456789
22564 </p><p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
22565 </p><p>ISBN 12345678901
22566 </p>
22567 !! html/parsoid
22568 <p>ISBN 123456789</p>
22569
22570 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a></p>
22571
22572 <p>ISBN 12345678901</p>
22573 !! end
22574
22575
22576 !! test
22577 ISBN with trailing year (T9110)
22578 !! wikitext
22579 ISBN 1-234-56789-0 - 2006
22580
22581 ISBN 1 234 56789 0 - 2006
22582 !! html/php
22583 <p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1-234-56789-0</a> - 2006
22584 </p><p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1 234 56789 0</a> - 2006
22585 </p>
22586 !! html/parsoid
22587 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1-234-56789-0</a> - 2006</p>
22588
22589 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1 234 56789 0</a> - 2006</p>
22590 !! end
22591
22592
22593 !! test
22594 anchorencode
22595 !! config
22596 wgFragmentMode=[ 'html5', 'legacy' ]
22597 !! wikitext
22598 {{anchorencode:foo bar©#%n}}
22599 !! html/php
22600 <p>foo_bar©#%n
22601 </p>
22602 !! html/parsoid
22603 <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>
22604 !! end
22605
22606 !! test
22607 anchorencode (legacy)
22608 !! config
22609 wgFragmentMode=[ 'legacy' ]
22610 !! wikitext
22611 {{anchorencode:foo bar©#%n}}
22612 !! html/php
22613 <p>foo_bar.C2.A9.23.25n
22614 </p>
22615 !! end
22616
22617 !! test
22618 anchorencode trims spaces
22619 !! config
22620 wgFragmentMode=[ 'html5', 'legacy' ]
22621 !! wikitext
22622 {{anchorencode: __pretty__please__}}
22623 !! html/php
22624 <p>pretty_please
22625 </p>
22626 !! html/parsoid
22627 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: __pretty__please__","function":"anchorencode"},"params":{},"i":0}}]}'>pretty_please</p>
22628 !! end
22629
22630 !! test
22631 anchorencode deals with links
22632 !! config
22633 wgFragmentMode=[ 'html5', 'legacy' ]
22634 !! wikitext
22635 {{anchorencode: [[hello|world]] [[hi]]}}
22636 !! html/php
22637 <p>world_hi
22638 </p>
22639 !! html/parsoid
22640 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: [[hello|world]] [[hi]]","function":"anchorencode"},"params":{},"i":0}}]}'>world_hi</p>
22641 !! end
22642
22643 !! test
22644 anchorencode deals with templates
22645 !! config
22646 wgFragmentMode=[ 'html5', 'legacy' ]
22647 !! wikitext
22648 {{anchorencode: {{Foo}} x}}
22649 !! html/php
22650 <p>FOO_x
22651 </p>
22652 !! html/parsoid
22653 <p about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: {{Foo}} x","function":"anchorencode"},"params":{},"i":0}}]}'>FOO_x</p>
22654 !! end
22655
22656 !! test
22657 anchorencode encodes like the TOC generator: (T20431)
22658 !! config
22659 wgFragmentMode=[ 'html5', 'legacy' ]
22660 !! wikitext
22661 ===_ +:.3A%3A _ &&amp;]] x===
22662 {{anchorencode: _ +:.3A%3A _ &&amp;]] x}}
22663 __NOEDITSECTION__
22664 !! html/php
22665 <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>
22666 <p>+:.3A%3A_&amp;&amp;&#93;&#93;_x
22667 </p>
22668 !! html/parsoid
22669 <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>
22670 <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>
22671 <meta property="mw:PageProp/noeditsection"/>
22672 !! end
22673
22674 !! test
22675 anchorencode encodes like the TOC generator: (T20431) (legacy)
22676 !! config
22677 wgFragmentMode=[ 'legacy' ]
22678 !! wikitext
22679 ===_ +:.3A%3A&&amp;]]===
22680 {{anchorencode: _ +:.3A%3A&&amp;]] }}
22681 __NOEDITSECTION__
22682 !! html/php
22683 <h3><span class="mw-headline" id=".2B:.3A.253A.26.26.5D.5D">_ +:.3A%3A&amp;&amp;]]</span></h3>
22684 <p>.2B:.3A.253A.26.26.5D.5D
22685 </p>
22686 !! end
22687
22688 !! test
22689 T8200: blockquotes and paragraph formatting
22690 !! wikitext
22691 <blockquote>
22692 foo
22693 </blockquote>
22694
22695 bar
22696
22697 baz
22698 !! html
22699 <blockquote>
22700 <p>foo
22701 </p>
22702 </blockquote>
22703 <p>bar
22704 </p>
22705 <pre>baz
22706 </pre>
22707 !! end
22708
22709 !! test
22710 T10293: Use of center tag ruins paragraph formatting
22711 !! wikitext
22712 <center>
22713 foo
22714 </center>
22715
22716 bar
22717
22718 baz
22719 !! html
22720 <center>
22721 <p>foo
22722 </p>
22723 </center>
22724 <p>bar
22725 </p>
22726 <pre>baz
22727 </pre>
22728 !! end
22729
22730 !!test
22731 Parsing of overlapping (improperly nested) inline html tags
22732 !! wikitext
22733 <span><s>x</span></s>
22734 !! html/php
22735 <p><span><s>x&lt;/span&gt;</s></span>
22736 </p>
22737 !! html/parsoid
22738 <p><span><s>x</s></span>
22739 </p>
22740 !!end
22741
22742 ###
22743 ### Language variants related tests
22744 ###
22745
22746 # Parsoid does not mark self-links.
22747 # Parsoid does not convert links; PHP will do any necessary redirects.
22748
22749 !! test
22750 Self-link in language variants
22751 !! options
22752 title=[[Dunav]] language=sr
22753 !! wikitext
22754 Both [[Dunav]] and [[Дунав]] are names for this river.
22755 !! html/php
22756 <p>Both <a class="mw-selflink selflink">Dunav</a> and <a class="mw-selflink selflink">Дунав</a> are names for this river.
22757 </p>
22758 !! html/parsoid
22759 <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>
22760 !! end
22761
22762 !! article
22763 Дуна
22764 !! text
22765 content
22766 !! endarticle
22767
22768 !! test
22769 Link to another existing title shouldn't be parsed as self-link even if it's a variant of this title
22770 !! options
22771 title=[[Duna]] language=sr
22772 !! wikitext
22773 [[Дуна]] is not a self-link while [[Duna]] and [[Dуна]] are still self-links.
22774 !! html/php
22775 <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.
22776 </p>
22777 !! html/parsoid
22778 <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>
22779 !! end
22780
22781 !! test
22782 Link to a section of a variant of this title shouldn't be parsed as self-link
22783 !! options
22784 title=[[Duna]] language=sr
22785 !! wikitext
22786 [[Dуна]] is a self-link while [[Dunа#Foo]] and [[Dуна#Foo]] are not self-links.
22787 !! html/php
22788 <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.
22789 </p>
22790 !! html/parsoid
22791 <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>
22792 !! end
22793
22794 !! test
22795 Link to pages in language variants
22796 !! options
22797 language=sr
22798 !! wikitext
22799 Main Page can be written as [[Маин Паге]]
22800 !! html/php
22801 <p>Main Page can be written as <a href="/wiki/Main_Page" title="Main Page">Маин Паге</a>
22802 </p>
22803 !! html/parsoid
22804 <p>Main Page can be written as <a rel="mw:WikiLink" href="./Маин_Паге" title="Маин Паге">Маин Паге</a></p>
22805 !! end
22806
22807
22808 !! test
22809 Multiple links to pages in language variants
22810 !! options
22811 language=sr
22812 !! wikitext
22813 [[Main Page]] can be written as [[Маин Паге]] same as [[Маин Паге]].
22814 !! html/php
22815 <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>.
22816 </p>
22817 !! html/parsoid
22818 <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>
22819 !! end
22820
22821
22822 !! test
22823 Simple template in language variants
22824 !! options
22825 language=sr
22826 !! wikitext
22827 {{тест}}
22828 !! html/php
22829 <p>This is a test template
22830 </p>
22831 !! end
22832
22833
22834 !! test
22835 Template with explicit namespace in language variants
22836 !! options
22837 language=sr
22838 !! wikitext
22839 {{Template:тест}}
22840 !! html/php
22841 <p>This is a test template
22842 </p>
22843 !! end
22844
22845
22846 !! test
22847 Basic test for template parameter in language variants
22848 !! options
22849 language=sr
22850 !! wikitext
22851 {{парамтест|param=foo}}
22852 !! html/php
22853 <p>This is a test template with parameter foo
22854 </p>
22855 !! end
22856
22857 !! test
22858 Simple category in language variants
22859 !! options
22860 language=sr cat
22861 !! wikitext
22862 [[Category:МедиаWики Усер'с Гуиде]]
22863 !! html/php
22864 cat=МедиаWики_Усер'с_Гуиде sort=
22865 !! html/parsoid
22866 <link rel="mw:PageProp/Category" href="./Категорија:МедиаWики_Усер'с_Гуиде" data-parsoid='{"stx":"simple","a":{"href":"./Категорија:МедиаWики_Усер&#39;с_Гуиде"},"sa":{"href":"Category:МедиаWики Усер&#39;с Гуиде"}}'/>
22867 !! end
22868
22869 !! article
22870 Category:分类
22871 !! text
22872 blah
22873 !! endarticle
22874
22875 !! article
22876 Category:分類
22877 !! text
22878 blah
22879 !! endarticle
22880
22881 ## We used to, but no longer wt2wt this test since the default serializer
22882 ## will normalize all categories to serialize on their own line.
22883 ## This wikitext usage is going to be fairly uncommon in production and
22884 ## selser will take care of preserving formatting in those scenarios.
22885 !! test
22886 Don't convert blue categorylinks to another variant (T35210)
22887 !! options
22888 cat
22889 language=zh
22890 parsoid=wt2html
22891 !! wikitext
22892 [[A]][[Category:分类]]
22893 !! html/php
22894 cat=分类 sort=
22895 !! html/parsoid
22896 <p><a rel="mw:WikiLink" href="./A" title="A">A</a></p>
22897 <link rel="mw:PageProp/Category" href="./Category:分类"/>
22898 !! end
22899
22900 !! test
22901 Stripping -{}- tags (language variants)
22902 !! options
22903 language=sr
22904 !! wikitext
22905 Latin proverb: -{Ne nuntium necare}-
22906 !! html/php
22907 <p>Latin proverb: Ne nuntium necare
22908 </p>
22909 !! html/parsoid
22910 <p>Latin proverb: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
22911 !! end
22912
22913
22914 !! test
22915 Prevent conversion with -{}- tags (language variants)
22916 !! options
22917 language=sr variant=sr-ec
22918 !! wikitext
22919 Latinski: -{Ne nuntium necare}-
22920 !! html/php
22921 <p>Латински: Ne nuntium necare
22922 </p>
22923 !! html/parsoid
22924 <p>Latinski: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
22925 !! end
22926
22927
22928 !! test
22929 Prevent conversion of text 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 links with -{}- tags (language variants)
22944 !! options
22945 language=sr variant=sr-ec
22946 !! wikitext
22947 -{[[Main Page]]}-
22948 !! html/php
22949 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
22950 </p>
22951 !! html/parsoid
22952 <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>
22953 !! end
22954
22955
22956 !! test
22957 -{}- tags within headlines (within html for parserConvert())
22958 !! config
22959 wgFragmentMode=[ 'html5', 'legacy' ]
22960 !! options
22961 language=sr variant=sr-ec
22962 !! wikitext
22963 ==-{Naslov}-==
22964
22965 Note that even an unprotected headline ID is not affected by language
22966 conversion:
22967
22968 ==Latinski==
22969 !! html/php
22970 <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>
22971 <p>Ноте тхат евен ан унпротецтед хеадлине ИД ис нот аффецтед бy лангуаге
22972 цонверсион:
22973 </p>
22974 <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>
22975
22976 !! html/parsoid
22977 <h2 id="-{Naslov}-"><span id="-.7BNaslov.7D-" typeof="mw:FallbackId"></span><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Naslov"}}'></span></h2>
22978
22979 <p>Note that even an unprotected headline ID is not affected by language
22980 conversion:</p>
22981
22982 <h2 id="Latinski">Latinski</h2>
22983 !! end
22984
22985 !! test
22986 Explicit definition of language variant alternatives
22987 !! options
22988 language=zh variant=zh-tw
22989 !! wikitext
22990 -{zh:China;zh-tw:Taiwan}-, not China
22991 !! html/php
22992 <p>Taiwan, not China
22993 </p>
22994 !! html/parsoid
22995 <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>
22996 !! end
22997
22998 !! test
22999 Explicit definition of language variant alternatives (BCP 47 codes)
23000 !! options
23001 language=zh variant=zh-tw
23002 !! wikitext
23003 -{zh:China;zh-Hant-TW:Taiwan}-, not China
23004 !! html/php
23005 <p>Taiwan, not China
23006 </p>
23007 !! html/parsoid
23008 <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>
23009 !! end
23010
23011 !! test
23012 Filter syntax for language variants
23013 !! options
23014 language=zh variant=zh-tw
23015 !! wikitext
23016 foo-{zh;zh-hans;zh-hant|blog, WEBJOURNAL, WEBLOG}-quux
23017 !! html/php
23018 <p>fooblog, WEBJOURNAL, WEBLOGquux
23019 </p>
23020 !! html/parsoid
23021 <p>foo<span typeof="mw:LanguageVariant" data-mw-variant='{"filter":{"l":["zh","zh-hans","zh-hant"],"t":"blog, WEBJOURNAL, WEBLOG"}}'></span>quux</p>
23022 !! end
23023
23024 # Note that Parsoid post-processing for language variants needs to
23025 # update the `title` attribute here, based on the mw:ExpandedAttrs property
23026 !! test
23027 Conversion around HTML tags
23028 !! options
23029 language=sr variant=sr-ec
23030 !! wikitext
23031 -{H|span=>sr-ec:script;title=>sr-ec:src}-
23032 <span title="La-{sr-el:L;sr-ec:C}-tin">ski</span>
23033 !! html/php
23034 <p>
23035 <span title="ЛаCтин">ски</span>
23036 </p>
23037 !! html/parsoid
23038 <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"}]}'/>
23039 <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>
23040 !! end
23041
23042 !! test
23043 Explicit session-wise two-way language variant mapping (A flag and - flag)
23044 !! options
23045 language=zh variant=zh-tw
23046 !! wikitext
23047 This is -{zh:China; zh-tw:Taiwan}-, but we'll forget that now.
23048
23049 Taiwan is not China.
23050
23051 But -{A|zh:China; zh-tw:Taiwan}- is China,
23052
23053 (This-{-|zh:China; zh-tw:Taiwan}- should be stripped!)
23054
23055 and -{China}- is China.
23056 !! html/php
23057 <p>This is Taiwan, but we'll forget that now.
23058 </p><p>Taiwan is not China.
23059 </p><p>But Taiwan is Taiwan,
23060 </p><p>(This should be stripped!)
23061 </p><p>and China is China.
23062 </p>
23063 !! html/parsoid
23064 <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>
23065 <p>Taiwan is not China.</p>
23066 <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>
23067 <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>
23068 <p>and <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"China"}}'></span> is China.</p>
23069 !! end
23070
23071 !! test
23072 Explicit session-wise one-way language variant mapping (A flag and - flag)
23073 !! options
23074 language=zh variant=zh-tw
23075 !! wikitext
23076 This is -{COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}-, but we'll forget that now.
23077
23078 COUNTRY is China or Taiwan.
23079
23080 But -{A|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- is COUNTRY,
23081
23082 (This-{-|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- should be stripped!)
23083
23084 and -{COUNTRY}- is COUNTRY.
23085 !! html/php
23086 <p>This is Taiwan, but we'll forget that now.
23087 </p><p>COUNTRY is China or Taiwan.
23088 </p><p>But Taiwan is Taiwan,
23089 </p><p>(This should be stripped!)
23090 </p><p>and COUNTRY is COUNTRY.
23091 </p>
23092 !! html/parsoid
23093 <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>
23094 <p>COUNTRY is China or Taiwan.</p>
23095 <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>
23096 <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>
23097 <p>and <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"COUNTRY"}}'></span> is COUNTRY.</p>
23098 !! end
23099
23100 !! test
23101 Explicit session-wise two-way language variant mapping (H flag for hide)
23102 !! options
23103 language=zh variant=zh-tw
23104 !! wikitext
23105 (This-{H|zh:China;zh-tw:Taiwan}- should be stripped!)
23106
23107 Taiwan is China.
23108 !! html/php
23109 <p>(This should be stripped!)
23110 </p><p>Taiwan is Taiwan.
23111 </p>
23112 !! html/parsoid
23113 <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>
23114 <p>Taiwan is China.</p>
23115 !! end
23116
23117 !! test
23118 Explicit session-wise one-way language variant mapping (H flag for hide)
23119 !! options
23120 language=zh variant=zh-tw
23121 !! wikitext
23122 (This-{H|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- should be stripped!)
23123
23124 COUNTRY is Taiwan or China.
23125 !! html/php
23126 <p>(This should be stripped!)
23127 </p><p>Taiwan is Taiwan or China.
23128 </p>
23129 !! html/parsoid
23130 <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>
23131 <p>COUNTRY is Taiwan or China.</p>
23132 !! end
23133
23134 ## Note that parsoid test runner does not support 'showtitle' option.
23135 !! test
23136 Adding explicit conversion rule for title (T flag)
23137 !! options
23138 language=zh variant=zh-tw showtitle
23139 !! wikitext
23140 Should be stripped-{T|zh:China;zh-tw:Taiwan}-!
23141
23142 Taiwan is China.
23143 !! html/php
23144 Taiwan
23145 <p>Should be stripped!
23146 </p><p>Taiwan is China.
23147 </p>
23148 !! html/parsoid
23149 <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>
23150 <p>Taiwan is China.</p>
23151 !! end
23152
23153 !! test
23154 Code coverage: T combined with H flag
23155 !! options
23156 language=zh variant=zh-tw showtitle
23157 !! wikitext
23158 Should be stripped-{T;H|zh:China; zh-tw:Taiwan}-!
23159
23160 Taiwan is China.
23161 !! html/php
23162 Taiwan
23163 <p>Should be stripped!
23164 </p><p>Taiwan is Taiwan.
23165 </p>
23166 !! html/parsoid
23167 <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>
23168 <p>Taiwan is China.</p>
23169 !! end
23170
23171 !! test
23172 Code coverage: T with no variants
23173 !! options
23174 language=zh variant=zh-tw showtitle
23175 !! wikitext
23176 -{H|zh:China; zh-tw:Taiwan}-
23177 Taiwan is China.-{T|Taiwan is China}-
23178 !! html/php
23179 Taiwan is China
23180 <p>
23181 Taiwan is Taiwan.
23182 </p>
23183 !! html/parsoid
23184 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>
23185 Taiwan is China.<meta typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Taiwan is China"},"title":true}'/></p>
23186 !! end
23187
23188 !! test
23189 Code coverage: rules with no variants
23190 !! options
23191 language=zh variant=zh-tw
23192 !! wikitext
23193 -{H|zh:China; zh-tw:Taiwan}-
23194 Taiwan is China.
23195 -{H|China}-
23196 Taiwan is China.
23197 !! html/php
23198 <p>
23199 Taiwan is Taiwan.
23200
23201 Taiwan is China.
23202 </p>
23203 !! html/parsoid
23204 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>
23205 Taiwan is China.
23206 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"*","t":"China"}]}'/>
23207 Taiwan is China.</p>
23208 !! end
23209
23210
23211 !! test
23212 Code coverage: D flag for conversion rule
23213 !! options
23214 language=zh variant=zh-tw
23215 !! wikitext
23216 -{D|zh-cn:XA; zh-tw:YA}-
23217 -{A;D|zh-cn:XB; zh-tw:YB}-
23218 -{D;H|zh-cn:XC; zh-tw:YC}-
23219
23220 -{D;H|FOO=>zh-tw:BAR;FOO=>zh-cn:BAT}-
23221
23222 -{D|0=>zh-tw:1}-
23223 -{A;D|2=>zh-tw:3}-
23224 -{D;H|4=>zh-tw:5}-
23225
23226 XA XB XC YA YB YC FOO BAR BAT 012345
23227 !! html/php
23228 <p>大陆:XA;台灣:YA;
23229
23230 大陆:XC;台灣:YC;
23231 </p><p>FOO⇒台灣:BAR;FOO⇒大陆:BAT;
23232 </p><p>0⇒台灣:1;
23233
23234 4⇒台灣:5;
23235 </p><p>XA YB YC YA YB YC BAR BAR BAT 013355
23236 </p>
23237 !! html/parsoid
23238 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"describe":true,"twoway":[{"l":"zh-cn","t":"XA"},{"l":"zh-tw","t":"YA"}]}'></span>
23239 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"twoway":[{"l":"zh-cn","t":"XB"},{"l":"zh-tw","t":"YB"}]}'/>
23240 <span typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"twoway":[{"l":"zh-cn","t":"XC"},{"l":"zh-tw","t":"YC"}]}'></span></p>
23241 <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>
23242 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"describe":true,"oneway":[{"f":"0","l":"zh-tw","t":"1"}]}'></span>
23243 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"oneway":[{"f":"2","l":"zh-tw","t":"3"}]}'/>
23244 <span typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"oneway":[{"f":"4","l":"zh-tw","t":"5"}]}'></span></p>
23245 <p>XA XB XC YA YB YC FOO BAR BAT 012345</p>
23246 !! end
23247
23248 !! test
23249 Code coverage: N flag for conversion rule
23250 !! options
23251 language=zh variant=zh-cn
23252 !! wikitext
23253 -{N|zh-cn}-
23254
23255 -{N|zh-tw}-
23256
23257 -{N|sr-ec}-
23258 !! html/php
23259 <p>大陆
23260 </p><p>台灣
23261 </p><p>српски (ћирилица)‎
23262 </p>
23263 !! html/parsoid
23264 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"zh-cn"}}'></span></p>
23265 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"zh-tw"}}'></span></p>
23266 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"sr-ec"}}'></span></p>
23267 !! end
23268
23269 # html2wt suppresses the bogus 'D' flag, so this is wt2html only
23270 !! test
23271 Code coverage: N flag for conversion rule (wt2html only)
23272 !! options
23273 language=zh variant=zh-cn
23274 parsoid=wt2html,html2html
23275 !! wikitext
23276 -{D;N|en}-
23277 !! html/php
23278 <p>English
23279 </p>
23280 !! html/parsoid
23281 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"en"}}' data-parsoid='{"fl":["D","N"]}'></span></p>
23282 !! end
23283
23284 !! test
23285 Testing that changing the language variant here in the tests actually works
23286 !! options
23287 language=zh variant=zh showtitle
23288 !! wikitext
23289 Should be stripped-{T|zh:China; zh-tw:Taiwan}-!
23290 !! html/php
23291 China
23292 <p>Should be stripped!
23293 </p>
23294 !! html/parsoid
23295 <p>Should be stripped<meta typeof="mw:LanguageVariant" data-mw-variant='{"title":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>!</p>
23296 !! end
23297
23298 !! test
23299 Recursive conversion of alt and title attrs shouldn't clear converter state
23300 !! options
23301 language=zh variant=zh-cn
23302 showtitle
23303 !! wikitext
23304 -{H|zh-cn:Exclamation; zh-tw:exclamation}-
23305 Should be stripped-{T|zh-cn:China; zh-tw:Taiwan}-<span title="exclamation">!</span>
23306 !! html/php
23307 China
23308 <p>
23309 Should be stripped<span title="Exclamation">!</span>
23310 </p>
23311 !! html/parsoid
23312 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh-cn","t":"Exclamation"},{"l":"zh-tw","t":"exclamation"}]}'/>
23313 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>
23314 !! end
23315
23316 !! test
23317 T26072: more test on conversion rule for title
23318 !! options
23319 language=zh variant=zh-tw showtitle
23320 !! wikitext
23321 This should be stripped-{T|zh:China; zh-tw:Taiwan}-!
23322
23323 This won't take interferes with the title rule-{H|zh:Beijing; zh-tw:Taipei}-.
23324 !! html/php
23325 Taiwan
23326 <p>This should be stripped!
23327 </p><p>This won't take interferes with the title rule.
23328 </p>
23329 !! html/parsoid
23330 <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>
23331 <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>
23332 !! end
23333
23334 !! test
23335 Partly disable title conversion if variant == main language code
23336 !! options
23337 language=zh variant=zh title=[[ZH]] showtitle
23338 !! wikitext
23339 -{T|zh-cn:CN;zh-tw:TW}-
23340 !! html/php
23341 ZH
23342 <p>
23343 </p>
23344 !! html/parsoid
23345 <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>
23346 !! end
23347
23348 !! test
23349 Partly disable title conversion if variant == main language code, more
23350 !! options
23351 language=zh variant=zh title=[[ZH]] showtitle
23352 !! wikitext
23353 -{T|TW}-
23354 !! html/php
23355 ZH
23356 <p>
23357 </p>
23358 !! html/parsoid
23359 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"TW"},"title":true}'/></p>
23360 !! end
23361
23362 !! test
23363 Raw output of variant escape tags (R flag)
23364 !! options
23365 language=zh variant=zh-tw
23366 !! wikitext
23367 Raw: -{R|zh:China;zh-tw:Taiwan}-
23368 !! html/php
23369 <p>Raw: zh:China;zh-tw:Taiwan
23370 </p>
23371 !! html/parsoid
23372 <p>Raw: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"zh:China;zh-tw:Taiwan"}}'></span></p>
23373 !! end
23374
23375 # html2wt suppresses the bogus 'D' flags, so this is wt2html only
23376 !! test
23377 Raw output of variant escape tags (R flag) (wt2html only)
23378 !! options
23379 language=zh variant=zh-tw
23380 parsoid=wt2html,html2html
23381 !! wikitext
23382 -{Variant}- -{D|syntax}- -{D;R|options}-
23383 !! html/php
23384 <p>Variant syntax options
23385 </p>
23386 !! html/parsoid
23387 <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>
23388 !! end
23389
23390 !! test
23391 Nested markup inside raw output of variant escape tags (R flag)
23392 !! options
23393 language=zh variant=zh-tw
23394 !! wikitext
23395 Nested raw: -{R|nested -{zh:China;zh-tw:Taiwan}- nested}-
23396 !! html/php
23397 <p>Nested raw: nested Taiwan nested
23398 </p>
23399 !! html/parsoid
23400 <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>
23401 !! end
23402
23403 !! test
23404 Nested markup and spaces inside raw output of variant escape tags (R flag)
23405 !! options
23406 language=zh variant=zh-tw
23407 !! wikitext
23408 X-{ outer -{ inner }- outer }-X
23409 !! html/php
23410 <p>X outer inner outer X
23411 </p>
23412 !! html/parsoid
23413 <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>
23414 !! end
23415
23416 !! test
23417 Templates inside raw output of variant escape tags (R flag)
23418 !! options
23419 language=zh variant=zh-tw
23420 !! wikitext
23421 Nested raw: -{R|nested {{echo|hi}} templates}-
23422 !! html/php
23423 <p>Nested raw: nested hi templates
23424 </p>
23425 !! html/parsoid
23426 <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>
23427 !! end
23428
23429 !! test
23430 Strings evaluating false shouldn't be ignored by Language converter (T51072)
23431 !! options
23432 language=zh variant=zh-cn
23433 !! wikitext
23434 -{zh-cn:0;zh-sg:1;zh-tw:2;zh-hk:3}-
23435 !! html/php
23436 <p>0
23437 </p>
23438 !! html/parsoid
23439 <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>
23440 !! end
23441
23442 !! test
23443 Conversion rules from [numeric-only string] to [something else] (T48634)
23444 !! options
23445 language=zh variant=zh-cn
23446 !! wikitext
23447 -{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
23448 !! html/php
23449 <p>D12345EE12345
23450 </p>
23451 !! html/parsoid
23452 <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>
23453 !! end
23454
23455 !! test
23456 Two-way converter rule entries with an empty value should be ignored (T53551)
23457 !! options
23458 language=zh variant=zh-cn
23459 !! wikitext
23460 -{H|zh-cn:foo;zh-tw:;}-foobar
23461 !! html/php
23462 <p>foobar
23463 </p>
23464 !! html/parsoid
23465 <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>
23466 !! end
23467
23468 !! test
23469 One-way converter rule entries with an empty "from" string should be ignored (T53551)
23470 !! options
23471 language=zh variant=zh-cn
23472 !! wikitext
23473 -{H|=>zh-cn:foo;}-foobar
23474 !! html/php
23475 <p>foobar
23476 </p>
23477 !! html/parsoid
23478 <p><meta typeof="mw:LanguageVariant" data-parsoid='{"tSp":[5]}' data-mw-variant='{"add":true,"oneway":[{"f":"","l":"zh-cn","t":"foo"}]}'/>foobar</p>
23479 !! end
23480
23481 !! test
23482 Empty converter rule entries shouldn't be inserted into the conversion table (T53551)
23483 !! options
23484 language=zh variant=zh-cn
23485 !! wikitext
23486 -{H|}-foobar
23487 !! html/php
23488 <p>foobar
23489 </p>
23490 !! html/parsoid
23491 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"*","t":""}]}'/>foobar</p>
23492 !! end
23493
23494 !! test
23495 Nested using of manual convert syntax
23496 !! options
23497 language=zh variant=zh-hk
23498 !! wikitext
23499 Nested: -{zh-hans:Hi -{zh-cn:China;zh-sg:Singapore;}-;zh-hant:Hello -{zh-tw:Taiwan;zh-hk:H-{ong}- K-{}-ong;}-;}-!
23500 !! html/php
23501 <p>Nested: Hello Hong Kong!
23502 </p>
23503 !! html/parsoid
23504 <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>
23505 !! end
23506
23507 !! test
23508 HTML markups with conversion syntax in attribs, nested in other conversion blocks
23509 !! options
23510 language=zh variant=zh-cn
23511 !! wikitext
23512 -{zh;zh-hans;zh-hant|<span title="-{X}-">A</span>}-
23513 !! html/php
23514 <p><span title="X">A</span>
23515 </p>
23516 !! html/parsoid
23517 <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>
23518 !! end
23519
23520 !! test
23521 HTML markups with conversion syntax in attribs, nested in other conversion blocks (not working yet in PHP parser)
23522 !! options
23523 language=zh variant=zh-cn
23524 !! wikitext
23525 -{<span title="-{X}-">A</span>}-
23526 !! html/php+disabled
23527 <p><span title="X">A</span>
23528 </p>
23529 !! html/parsoid
23530 <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>
23531 !! end
23532
23533 # Parsoid and PHP disagree on how to parse this example: Parsoid
23534 # insists that the content of a language converter element be a valid
23535 # DOM fragment or attribute string
23536 !! test
23537 Language converter markup with block content
23538 !! options
23539 language=zh variant=zh-cn
23540 !! wikitext
23541 <span>a-{b<div>c}-d
23542
23543 <span>a-{zh;zh-hans;zh-hant|b<div>c}-d
23544
23545 <span>a-{H|0=>zh-cn:x<span>y;0=>zh-tw:b<div>c}-d
23546 !! html/php+tidy
23547 <span>ab<div>cd
23548 <span>ab<div>cd
23549 <span>ad
23550 </span></div></span></div></span>
23551 !! html/parsoid
23552 <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
23553
23554 <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
23555
23556 <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>
23557 !! end
23558
23559 !! test
23560 LanguageConverter selser (1)
23561 !! options
23562 language=zh variant=zh-cn
23563 parsoid={
23564 "modes": ["wt2wt", "selser"],
23565 "changes": [
23566 ["span[typeof]", "attr", "data-mw-variant", "{\"disabled\":{\"t\":\"edited\"}}"]
23567 ]
23568 }
23569 !! wikitext
23570 -{raw}-
23571 !! wikitext/edited
23572 -{edited}-
23573 !! end
23574
23575 !! test
23576 LanguageConverter selser (2)
23577 !! options
23578 language=zh variant=zh-cn
23579 parsoid={
23580 "modes": ["wt2wt", "selser"],
23581 "changes": [
23582 ["span[class='x']", "contents", "text", "-{foo}-"],
23583 ["a", "contents", "text", "-{"],
23584 ["span[typeof]", "attr", "data-mw", "{\"parts\":[{\"template\":{\"target\":{\"wt\":\"1x\",\"href\":\"./Template:1x\"},\"params\":{\"1\":{\"wt\":\"-{\"}},\"i\":0}}]}"]
23585 ]
23586 }
23587 !! wikitext
23588 <span class="x">TEXT1</span>
23589 [http://example.com TEXT2]
23590 [[Foo|TEXT3]]
23591 {{echo|TEXT4}}
23592 !! wikitext/edited
23593 <span class="x"><nowiki>-{foo}-</nowiki></span>
23594 [http://example.com -{]
23595 [[Foo|<nowiki>-{</nowiki>]]
23596 {{1x|<nowiki>-{</nowiki>}}
23597 !! end
23598
23599 # Tests LanguageVariantText in ConstrainedText
23600 !! test
23601 LanguageConverter selser (3)
23602 !! options
23603 language=zh variant=zh-cn
23604 parsoid={
23605 "modes": ["wt2wt", "selser"],
23606 "changes": [
23607 ["td > span", "attr", "typeof", "mw:LanguageVariant"],
23608 ["td > span", "attr", "data-mw-variant", "{\"disabled\":{\"t\":\"edited\"}}"]
23609 ]
23610 }
23611 !! wikitext
23612 {|
23613 |-
23614 |<span>Foo</span>
23615 |}
23616 !! wikitext/edited
23617 {|
23618 |-
23619 |<nowiki/>-{edited}-
23620 |}
23621 !! end
23622
23623 # Tests LanguageVariantText._fromSelSer
23624 !! test
23625 LanguageConverter selser (4)
23626 !! options
23627 language=zh variant=zh-cn
23628 parsoid={
23629 "modes": ["wt2wt", "selser"],
23630 "changes": [
23631 ["td > span.x", "remove"]
23632 ]
23633 }
23634 !! wikitext
23635 {|
23636 |-
23637 |<span class="x">Foo</span>-{Bar}-
23638 ||<span class="x">Foo</span>-{Bar}-
23639 |}
23640 !! wikitext/edited
23641 {|
23642 |-
23643 |<nowiki/>-{Bar}-
23644 ||-{Bar}-
23645 |}
23646 !! end
23647
23648 # Since Parsoid is starting to emit canonical wikitext for links,
23649 # [http://example.com http://example.com] will not RT back to that
23650 # form anymore.
23651 # Parsoid does not language-convert links (it is done in a
23652 # post-processing step)
23653 !! test
23654 Proper conversion of text in external links
23655 !! options
23656 language=sr variant=sr-ec
23657 parsoid=wt2html
23658 !! wikitext
23659 http://www.google.com
23660 gopher://www.google.com
23661 [http://www.google.com http://www.google.com]
23662 [gopher://www.google.com gopher://www.google.com]
23663 [https://www.google.com irc://www.google.com]
23664 [ftp://www.google.com www.google.com/ftp://dir]
23665 [//www.google.com www.google.com]
23666 !! html/php
23667 <p><a rel="nofollow" class="external free" href="http://www.google.com">http://www.google.com</a>
23668 <a rel="nofollow" class="external free" href="gopher://www.google.com">gopher://www.google.com</a>
23669 <a rel="nofollow" class="external text" href="http://www.google.com">http://www.google.com</a>
23670 <a rel="nofollow" class="external text" href="gopher://www.google.com">gopher://www.google.com</a>
23671 <a rel="nofollow" class="external text" href="https://www.google.com">irc://www.google.com</a>
23672 <a rel="nofollow" class="external text" href="ftp://www.google.com">www.гоогле.цом/фтп://дир</a>
23673 <a rel="nofollow" class="external text" href="//www.google.com">www.гоогле.цом</a>
23674 </p>
23675 !! html/parsoid
23676 <p><a rel="mw:ExtLink" class="external free" href="http://www.google.com">http://www.google.com</a>
23677 <a rel="mw:ExtLink" class="external free" href="gopher://www.google.com">gopher://www.google.com</a>
23678 <a rel="mw:ExtLink" class="external text" href="http://www.google.com">http://www.google.com</a>
23679 <a rel="mw:ExtLink" class="external text" href="gopher://www.google.com">gopher://www.google.com</a>
23680 <a rel="mw:ExtLink" class="external text" href="https://www.google.com">irc://www.google.com</a>
23681 <a rel="mw:ExtLink" class="external text" href="ftp://www.google.com">www.google.com/ftp://dir</a>
23682 <a rel="mw:ExtLink" class="external text" href="//www.google.com">www.google.com</a></p>
23683 !! end
23684
23685 !! test
23686 Do not convert roman numbers to language variants
23687 !! options
23688 language=sr variant=sr-ec
23689 !! wikitext
23690 Fridrih IV je car.
23691 !! html/php
23692 <p>Фридрих IV је цар.
23693 </p>
23694 !! html/parsoid
23695 <p>Fridrih IV je car.</p>
23696 !! end
23697
23698 !! test
23699 Unclosed language converter markup "-{"
23700 !! options
23701 language=sr
23702 !! wikitext
23703 -{T|hello
23704 !! html
23705 <p>-{T|hello
23706 </p>
23707 !! end
23708
23709 !! test
23710 Don't convert raw rule "-{R|=&gt;}-" to "=>"
23711 !! options
23712 language=sr
23713 !! wikitext
23714 -{R|=&gt;}-
23715 !! html/php
23716 <p>=&gt;
23717 </p>
23718 !! html/parsoid
23719 <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>
23720 !!end
23721
23722 !! test
23723 Don't break link parsing if language converter markup is in the caption.
23724 !! options
23725 language=sr variant=sr-ec
23726 !! wikitext
23727 [[Main Page|-{R|main page}-]]
23728 !! html/php
23729 <p><a href="/wiki/Main_Page" title="Маин Паге">main page</a>
23730 </p>
23731 !! html/parsoid
23732 <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>
23733 !! end
23734
23735 !! test
23736 T146304: Don't break template parsing if language converter markup is in the parameter.
23737 !! options
23738 language=sr variant=sr-ec
23739 !! wikitext
23740 {{echo|-{R|foo}-}}
23741 !! html/php
23742 <p>foo
23743 </p>
23744 !! html/parsoid
23745 <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>
23746 !! end
23747
23748 !! test
23749 T146305: Don't break image parsing if language converter markup is in the caption.
23750 !! options
23751 language=sr
23752 !! wikitext
23753 [[Датотека:Foobar.jpg|thumb|-{R|caption:}-]]
23754 !! html/php
23755 <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>
23756
23757 !! html/parsoid
23758 <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>
23759 !! end
23760
23761 !! test
23762 T146305: Don't break image parsing if nested language converter markup is in the caption.
23763 !! options
23764 language=zh variant=zh-cn
23765 !! wikitext
23766 [[File:Foobar.jpg|thumb|-{|zh-cn:blog (hk: -{zh-hans|WEBJOURNAL}-, tw: -{zh-hans|WEBLOG}-)}-]]
23767 !! html/php
23768 <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>
23769
23770 !! html/parsoid
23771 <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>
23772 !! end
23773
23774 # XXX html2wt disabled because rich markup in alt is not preserved.
23775 !! test
23776 Don't break gallery if language converter markup is inside.
23777 !! options
23778 language=zh
23779 !! wikitext
23780 <gallery>
23781 File:foobar.jpg|[[File:foobar.jpg|20px|desc|alt=-{R|foo}-|-{R|bar}-]]|alt=-{R|bat}-
23782 File:foobar.jpg|{{Test|unamedParam|alt=-{R|param}-}}|alt=galleryalt
23783 </gallery>
23784 !! html/php
23785 <ul class="gallery mw-gallery-traditional">
23786 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
23787 <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>
23788 <div class="gallerytext">
23789 <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>
23790 </p>
23791 </div>
23792 </div></li>
23793 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
23794 <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>
23795 <div class="gallerytext">
23796 <p>This is a test template
23797 </p>
23798 </div>
23799 </div></li>
23800 </ul>
23801
23802 !! html/parsoid
23803 <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"}}'>
23804 <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>
23805 <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>
23806 </ul>
23807 !! end
23808
23809 !! test
23810 T153135: Don't break list handling if language converter markup is in the item.
23811 !! options
23812 language=zh variant=zh-cn
23813 !! wikitext
23814 ;-{zh-cn:AAA;zh-tw:BBB}-
23815 ;-{R|foo:bar}-
23816 !! html/php
23817 <dl><dt>AAA</dt>
23818 <dt>foo:bar</dt></dl>
23819 !! html/parsoid
23820 <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>
23821 <dt data-parsoid='{"dsr":[25,39,1,0]}'><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"foo:bar"}}'></span></dt>
23822 </dl>
23823 !! end
23824
23825 // Note that parsoid does not protect colons unless language converter
23826 // markup is properly nested, because it is a backtracking parser.
23827 !! test
23828 T153135: Unclosed markup in definition list (code coverage)
23829 !! options
23830 language=zh variant=zh-cn
23831 !! wikitext
23832 ;<b>foo:bar
23833 ;-{zh-cn:AAA
23834 !! html/php+tidy
23835 <dl><dt><b>foo:bar</b></dt><b>
23836 <dt>-{zh-cn:AAA</dt></b></dl>
23837 !! html/parsoid
23838 <dl><dt data-parsoid='{}'><b data-parsoid='{"stx":"html","autoInsertedEnd":true}'>foo:bar</b></dt><b data-parsoid='{"stx":"html","autoInsertedEnd":true,"autoInsertedStart":true}'>
23839 <dt data-parsoid='{}'>-{zh-cn</dt><dd data-parsoid='{"stx":"row"}'>AAA</dd></b></dl>
23840 !! end
23841
23842 !! test
23843 T153135: Nested language converter markup in definition list (code coverage)
23844 !! options
23845 language=zh variant=zh-cn
23846 !! wikitext
23847 ;-{|zh-cn:AAA -{zh-hans|foo:bar}- -{R|bat:baz}-}-:def
23848 !! html/php
23849 <dl><dt>AAA foo:bar bat:baz</dt>
23850 <dd>def</dd></dl>
23851 !! html/parsoid
23852 <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>
23853 <dd data-parsoid='{"stx":"row","dsr":[49,53,1,0]}'>def</dd>
23854 </dl>
23855 !! end
23856
23857 # html2wt mode disabled due to <nowiki> insertion.
23858 !! test
23859 T153140: Don't break table handling if language converter markup is in the cell.
23860 !! options
23861 language=sr variant=sr-ec
23862 parsoid=wt2html,wt2wt,html2html
23863 !! wikitext
23864 {|
23865 |-
23866 | -{R|B}-
23867 |}
23868 !! html/php
23869 <table>
23870
23871 <tr>
23872 <td>B
23873 </td></tr></table>
23874
23875 !! html/parsoid
23876 <table>
23877 <tbody>
23878 <tr>
23879 <td><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"B"}}'></span></td>
23880 </tr>
23881 </tbody>
23882 </table>
23883 !! end
23884
23885 !! test
23886 Language converter tricky html2wt cases (1)
23887 !! options
23888 language=sr
23889 parsoid=html2wt,wt2wt
23890 !! html/parsoid
23891 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"}-"}}'></span></p>
23892 !! wikitext
23893 -{<nowiki>}-</nowiki>}-
23894 !! html/php
23895 <p>&#125;-
23896 </p>
23897 !! end
23898
23899 !! test
23900 Language converter tricky html2wt cases (2)
23901 !! options
23902 language=sr
23903 parsoid=html2wt,wt2wt
23904 !! html/parsoid
23905 <p>-{foo}-</p>
23906 !! wikitext
23907 <nowiki>-{foo}-</nowiki>
23908 !! html/php
23909 <p>-&#123;foo&#125;-
23910 </p>
23911 !! end
23912
23913 !! test
23914 Language converter tricky html2wt cases (3)
23915 !! options
23916 language=sr
23917 parsoid=html2wt,wt2wt
23918 !! html/parsoid
23919 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"|"}}'></span></p>
23920 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"R|raw"}}'></span></p>
23921 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"-{foo}-"}}'></span></p>
23922 !! wikitext
23923 -{R||}-
23924
23925 -{R|R|raw}-
23926
23927 -{<nowiki>-{foo}-</nowiki>}-
23928 !! html/php
23929 <p>|
23930 </p><p>R|raw
23931 </p><p>-&#123;foo&#125;-
23932 </p>
23933 !! end
23934
23935 !! test
23936 Language converter tricky html2wt cases (4)
23937 !! options
23938 language=sr
23939 parsoid=html2wt,wt2wt
23940 !! html/parsoid
23941 <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>
23942 !! wikitext
23943 -{R|{{echo|hey}}}-
23944 !! html/php
23945 <p>hey
23946 </p>
23947 !! end
23948
23949 # Note that the <nowiki> escaping added by parsoid for source text,
23950 # destination text, and language names only works on the PHP side
23951 # for *destination text*. (HTML entity escaping wouldn't work
23952 # any better.) This is probably a bug, at least for source texts.
23953 # (For language names PHP uses a precise regexp based on the languages
23954 # it currently knows have variants, which is fragile since this set
23955 # can grow/shrink over time.)
23956 !! test
23957 Language converter tricky html2wt cases (5)
23958 !! options
23959 language=zh variant=zh-cn
23960 !! html/parsoid
23961 <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>
23962 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"A","l":"bo:g;us","t":"B"}]}'/></p>
23963 <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>
23964 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"twoway":[{"l":"bo:g;us","t":"xyz"},{"l":"zh-cn","t":"abc"}]}'></span></p>
23965 <p>a:b=>c xyz</p>
23966 !! wikitext
23967 -{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
23968
23969 -{H|A=><nowiki>bo:g;us</nowiki>:B}-
23970
23971 -{A|zh-tw:xyz; zh-cn:<nowiki>0;zh-tw:bar</nowiki>}-
23972
23973 -{<nowiki>bo:g;us</nowiki>:xyz; zh-cn:abc}-
23974
23975 a:b=>c xyz
23976 !! html/php+disabled
23977 <p>foobat;xyz=&gt;zh-cn:abc
23978 </p><p>A
23979 </p><p>0;zh-tw:bar
23980 </p><p>abc
23981 </p><p>a:b=&gt;c 0;zh-tw:bar
23982 </p>
23983 !! end
23984
23985 !! test
23986 T179579: Nowiki and lc interaction
23987 !! options
23988 parsoid=wt2html
23989 language=sr
23990 !! wikitext
23991 -{</nowiki>123}-
23992
23993 -{123<nowiki>|</nowiki>456}-
23994 !! html/parsoid
23995 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"&amp;lt;/nowiki>123"}}' data-parsoid='{"fl":[],"src":"-{&lt;/nowiki>123}-"}'></span></p>
23996
23997 <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>
23998 !! end
23999
24000 !! test
24001 T2529: Uncovered bullet
24002 !! wikitext
24003 *Foo {{bullet}}
24004 !! html
24005 <ul><li>Foo</li>
24006 <li>Bar</li></ul>
24007 !! end
24008
24009 !! test
24010 T2529: Uncovered bullet in a deeply nested list
24011 !! wikitext
24012 *******Foo {{bullet}}
24013 !! html
24014 <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>
24015 <li>Bar</li></ul>
24016 !! end
24017
24018 !! test
24019 T2529: Uncovered table already at line-start
24020 !! wikitext
24021 x
24022
24023 {{table}}
24024 y
24025 !! html
24026 <p>x
24027 </p>
24028 <table>
24029 <tr>
24030 <td>1</td>
24031 <td>2
24032 </td></tr>
24033 <tr>
24034 <td>3</td>
24035 <td>4
24036 </td></tr></table>
24037 <p>y
24038 </p>
24039 !! end
24040
24041 !! test
24042 T2529: Uncovered bullet in parser function result
24043 !! wikitext
24044 *Foo {{lc:{{bullet}} }}
24045 !! html
24046 <ul><li>Foo</li>
24047 <li>bar</li></ul>
24048 !! end
24049
24050 !! test
24051 T7678: Double-parsed template argument
24052 !! wikitext
24053 {{lc:{{{1}}}|hello}}
24054 !! html
24055 <p>{{{1}}}
24056 </p>
24057 !! end
24058
24059 !! test
24060 T7678: Double-parsed template invocation
24061 !! wikitext
24062 {{lc:{{paramtest {{!}} param = hello }} }}
24063 !! html
24064 <p>{{paramtest | param = hello }}
24065 </p>
24066 !! end
24067
24068 !! test
24069 Case insensitivity of parser functions for non-ASCII characters (T10143)
24070 !! options
24071 language=cs
24072 title=[[Main Page]]
24073 !! wikitext
24074 {{PRVNÍVELKÉ:ěščř}}
24075 {{prvnívelké:ěščř}}
24076 {{PRVNÍMALÉ:ěščř}}
24077 {{prvnímalé:ěščř}}
24078 {{MALÁ:ěščř}}
24079 {{malá:ěščř}}
24080 {{VELKÁ:ěščř}}
24081 {{velká:ěščř}}
24082 !! html
24083 <p>Ěščř
24084 Ěščř
24085 ěščř
24086 ěščř
24087 ěščř
24088 ěščř
24089 ĚŠČŘ
24090 ĚŠČŘ
24091 </p>
24092 !! end
24093
24094 !! test
24095 Morwen/13: Unclosed link followed by heading
24096 !! wikitext
24097 [[link
24098 ==heading==
24099 !! html
24100 <p>[[link
24101 </p>
24102 <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>
24103
24104 !! end
24105
24106 !! test
24107 HHP2.1: Heuristics for headings in preprocessor parenthetical structures
24108 !! wikitext
24109 {{foo|
24110 =heading=
24111 !! html
24112 <p>{{foo|
24113 </p>
24114 <h1><span class="mw-headline" id="heading">heading</span></h1>
24115
24116 !! end
24117
24118 !! test
24119 HHP2.2: Heuristics for headings in preprocessor parenthetical structures
24120 !! wikitext
24121 {{foo|
24122 ==heading==
24123 !! html
24124 <p>{{foo|
24125 </p>
24126 <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>
24127
24128 !! end
24129
24130 !! test
24131 Tildes in comments
24132 !! options
24133 pst
24134 !! wikitext
24135 <!-- ~~~~ -->
24136 !! html/php
24137 <!-- ~~~~ -->
24138 !! end
24139
24140 !! test
24141 Paragraphs inside divs (no extra line breaks)
24142 !! wikitext
24143 <div>Line one
24144
24145 Line two</div>
24146 !! html
24147 <div>Line one
24148 Line two</div>
24149
24150 !! end
24151
24152 !! test
24153 Paragraphs inside divs (extra line break on open)
24154 !! wikitext
24155 <div>
24156 Line one
24157
24158 Line two</div>
24159 !! html
24160 <div>
24161 <p>Line one
24162 </p>
24163 Line two</div>
24164
24165 !! end
24166
24167 !! test
24168 Paragraphs inside divs (extra line break on close)
24169 !! wikitext
24170 <div>Line one
24171
24172 Line two
24173 </div>
24174 !! html
24175 <div>Line one
24176 <p>Line two
24177 </p>
24178 </div>
24179
24180 !! end
24181
24182 !! test
24183 Paragraphs inside divs (extra line break on open and close)
24184 !! wikitext
24185 <div>
24186 Line one
24187
24188 Line two
24189 </div>
24190 !! html
24191 <div>
24192 <p>Line one
24193 </p><p>Line two
24194 </p>
24195 </div>
24196
24197 !! end
24198
24199 # doBlockLevels screws up this output and Remex cleans up as much as it can.
24200 !! test
24201 Nesting tags, paragraphs on lines which begin with <div>
24202 !! wikitext
24203 <div></div><strong>A
24204 B</strong>
24205 !! html/php+tidy
24206 <div></div><p><strong>A
24207 </strong></p><strong></strong><p><strong>B</strong>
24208 </p>
24209 !! html/parsoid
24210 <div data-parsoid='{"stx":"html"}'></div><p><strong data-parsoid='{"stx":"html","autoInsertedEnd":true}'>A</strong></p>
24211 <p><strong data-parsoid='{"stx":"html","autoInsertedStart":true}'>B</strong></p>
24212 !! end
24213
24214 # T8200: <blockquote> should behave like <div> with respect to line breaks
24215 !! test
24216 T8200: paragraphs inside blockquotes (no extra line breaks)
24217 !! wikitext
24218 <blockquote>Line one
24219
24220 Line two</blockquote>
24221 !! html
24222 <blockquote>Line one
24223 Line two</blockquote>
24224
24225 !! html+tidy
24226 <blockquote><p>Line one
24227 Line two</p></blockquote>
24228 !! end
24229
24230 !! test
24231 T8200: paragraphs inside blockquotes (extra line break on open)
24232 !! wikitext
24233 <blockquote>
24234 Line one
24235
24236 Line two</blockquote>
24237 !! html
24238 <blockquote>
24239 <p>Line one
24240 </p>
24241 Line two</blockquote>
24242
24243 !! html+tidy
24244 <blockquote>
24245 <p>Line one
24246 </p><p>
24247 Line two</p></blockquote>
24248 !! end
24249
24250 !! test
24251 T8200: paragraphs inside blockquotes (extra line break on close)
24252 !! wikitext
24253 <blockquote>Line one
24254
24255 Line two
24256 </blockquote>
24257 !! html
24258 <blockquote>Line one
24259 <p>Line two
24260 </p>
24261 </blockquote>
24262
24263 !! html+tidy
24264 <blockquote><p>Line one
24265 </p><p>Line two
24266 </p>
24267 </blockquote>
24268 !! end
24269
24270 !! test
24271 T8200: paragraphs inside blockquotes (extra line break on open and close)
24272 !! wikitext
24273 <blockquote>
24274 Line one
24275
24276 Line two
24277 </blockquote>
24278 !! html
24279 <blockquote>
24280 <p>Line one
24281 </p><p>Line two
24282 </p>
24283 </blockquote>
24284
24285 !! end
24286
24287 ## This is a corner case interaction between the paragraph wrapping in the
24288 ## php parser's BlockLevelPass and Remex. `doBlockLevels` has a notion of
24289 ## some tags which close paragraphs (and thus prevent wrapping on their line),
24290 ## of which "div" is one, but do p-wrapping inside them. These are referred
24291 ## to as "never suppressing". Remex, for its part, doesn't traverse into
24292 ## "div"s to p-wrap. Hence, we only get this partial wrapping.
24293 !! test
24294 Paragraphs inside blockquotes/divs (no extra line breaks)
24295 !! wikitext
24296 <blockquote><div>Line one
24297
24298 Line two</div></blockquote>
24299 !! html
24300 <blockquote><div>Line one
24301 Line two</div></blockquote>
24302
24303 !! end
24304
24305 !! test
24306 Paragraphs inside blockquotes/divs (extra line break on open)
24307 !! wikitext
24308 <blockquote><div>
24309 Line one
24310
24311 Line two</div></blockquote>
24312 !! html
24313 <blockquote><div>
24314 <p>Line one
24315 </p>
24316 Line two</div></blockquote>
24317
24318 !! end
24319
24320 !! test
24321 Paragraphs inside blockquotes/divs (extra line break on close)
24322 !! wikitext
24323 <blockquote><div>Line one
24324
24325 Line two
24326 </div></blockquote>
24327 !! html
24328 <blockquote><div>Line one
24329 <p>Line two
24330 </p>
24331 </div></blockquote>
24332
24333 !! end
24334
24335 !! test
24336 Paragraphs inside blockquotes/divs (extra line break on open and close)
24337 !! wikitext
24338 <blockquote><div>
24339 Line one
24340
24341 Line two
24342 </div></blockquote>
24343 !! html
24344 <blockquote><div>
24345 <p>Line one
24346 </p><p>Line two
24347 </p>
24348 </div></blockquote>
24349
24350 !! end
24351
24352 !! test
24353 Interwiki links trounced by replaceExternalLinks after early LinkHolderArray expansion
24354 !! options
24355 wgLinkHolderBatchSize=0
24356 !! wikitext
24357 [[meatball:1]]
24358 [[meatball:2]]
24359 [[meatball:3]]
24360 !! html
24361 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?1" class="extiw" title="meatball:1">meatball:1</a>
24362 <a href="http://www.usemod.com/cgi-bin/mb.pl?2" class="extiw" title="meatball:2">meatball:2</a>
24363 <a href="http://www.usemod.com/cgi-bin/mb.pl?3" class="extiw" title="meatball:3">meatball:3</a>
24364 </p>
24365 !! end
24366
24367 !! test
24368 Free external link invading image caption
24369 !! wikitext
24370 [[Image:Foobar.jpg|thumb|http://x|hello]]
24371 !! html/php
24372 <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>
24373
24374 !! html/parsoid
24375 <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>
24376 !! end
24377
24378 !! test
24379 T17196: localised external link numbers
24380 !! options
24381 language=fa
24382 !! wikitext
24383 [http://en.wikipedia.org/]
24384 !! html/php
24385 <p><a rel="nofollow" class="external autonumber" href="http://en.wikipedia.org/">[۱]</a>
24386 </p>
24387 !! html/parsoid
24388 <p><a rel="mw:ExtLink" class="external autonumber" href="http://en.wikipedia.org/"></a></p>
24389 !! end
24390
24391 !! test
24392 Multibyte character in padleft
24393 !! wikitext
24394 {{padleft:-Hello|7|Æ}}
24395 !! html/php
24396 <p>Æ-Hello
24397 </p>
24398 !! html/parsoid
24399 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padleft:-Hello","function":"padleft"},"params":{"1":{"wt":"7"},"2":{"wt":"Æ"}},"i":0}}]}'>Æ-Hello</p>
24400 !! end
24401
24402 !! test
24403 Multibyte character in padright
24404 !! wikitext
24405 {{padright:Hello-|7|Æ}}
24406 !! html/php
24407 <p>Hello-Æ
24408 </p>
24409 !! html/parsoid
24410 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padright:Hello-","function":"padright"},"params":{"1":{"wt":"7"},"2":{"wt":"Æ"}},"i":0}}]}'>Hello-Æ</p>
24411 !! end
24412
24413 !!test
24414 formatdate parser function
24415 !! wikitext
24416 {{#formatdate:2009-03-24}}
24417 !! html
24418 <p><span class="mw-formatted-date" title="2009-03-24">2009-03-24</span>
24419 </p>
24420 !! end
24421
24422 !!test
24423 formatdate parser function, with default format
24424 !! wikitext
24425 {{#formatdate:2009-03-24|mdy}}
24426 !! html
24427 <p><span class="mw-formatted-date" title="2009-03-24">March 24, 2009</span>
24428 </p>
24429 !! end
24430
24431 !! test
24432 Spacing of numbers in formatted dates
24433 !! wikitext
24434 {{#formatdate:January 15}}
24435 !! html
24436 <p><span class="mw-formatted-date" title="01-15">January 15</span>
24437 </p>
24438 !! end
24439
24440 !! test
24441 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
24442 !! options
24443 language=nl title=[[MediaWiki:Common.css]]
24444 !! wikitext
24445 {{#formatdate:2009-03-24|dmy}}
24446 !! html
24447 <p><span class="mw-formatted-date" title="2009-03-24">24 March 2009</span>
24448 </p>
24449 !! end
24450
24451 #
24452 #
24453 #
24454
24455 #
24456 # Edit comments
24457 #
24458
24459 !! test
24460 Edit comment with link
24461 !! options
24462 comment
24463 !! wikitext
24464 I like the [[Main Page]] a lot
24465 !! html/php
24466 I like the <a href="/wiki/Main_Page" title="Main Page">Main Page</a> a lot
24467 !!end
24468
24469 !! test
24470 Edit comment with link and link text
24471 !! options
24472 comment
24473 !! wikitext
24474 I like the [[Main Page|best pages]] a lot
24475 !! html/php
24476 I like the <a href="/wiki/Main_Page" title="Main Page">best pages</a> a lot
24477 !!end
24478
24479 !! test
24480 Edit comment with link and link text with suffix
24481 !! options
24482 comment
24483 !! wikitext
24484 I like the [[Main Page|best page]]s a lot
24485 !! html/php
24486 I like the <a href="/wiki/Main_Page" title="Main Page">best pages</a> a lot
24487 !!end
24488
24489 !! test
24490 Edit comment with section link (non-local, eg in history list)
24491 !! options
24492 comment title=[[Main Page]]
24493 !! wikitext
24494 /* External links */ removed bogus entries
24495 !! html/php
24496 <span dir="auto"><span class="autocomment"><a href="/wiki/Main_Page#External_links" title="Main Page">→‎External links</a>: </span> removed bogus entries</span>
24497 !!end
24498
24499 !! test
24500 Edit comment with section link and text before it (non-local, eg in history list)
24501 !! options
24502 comment title=[[Main Page]]
24503 !! wikitext
24504 pre-comment text /* External links */ removed bogus entries
24505 !! html/php
24506 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>
24507 !!end
24508
24509 !! test
24510 Edit comment with section link (local, eg in diff view)
24511 !! options
24512 comment local title=[[Main Page]]
24513 !! wikitext
24514 /* External links */ removed bogus entries
24515 !! html/php
24516 <span dir="auto"><span class="autocomment"><a href="#External_links">→‎External links</a>: </span> removed bogus entries</span>
24517 !!end
24518
24519 !! test
24520 Edit comment with section link that has a link in it
24521 !! options
24522 comment local title=[[Main Page]]
24523 !! wikitext
24524 /* [[A link]] */
24525 !! html/php
24526 <span dir="auto"><span class="autocomment"><a href="#A_link">→‎&#91;[A link]]</a></span></span>
24527 !! end
24528
24529 !! test
24530 Edit comment with section link that has a template in it
24531 !! options
24532 comment local title=[[Main Page]]
24533 !! wikitext
24534 /* {{foobar|param}} */
24535 !! html/php
24536 <span dir="auto"><span class="autocomment"><a href="#.7B.7Bfoobar.7Cparam.7D.7D">→‎{{foobar|param}}</a></span></span>
24537 !! end
24538
24539 !! test
24540 Edit comment with subpage link (T16080)
24541 !! options
24542 comment
24543 subpage
24544 title=[[Subpage test]]
24545 !! wikitext
24546 Poked at a [[/subpage]] here...
24547 !! html/php
24548 Poked at a <a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a> here...
24549 !!end
24550
24551 !! test
24552 Edit comment with subpage link and link text (T16080)
24553 !! options
24554 comment
24555 subpage
24556 title=[[Subpage test]]
24557 !! wikitext
24558 Poked at a [[/subpage|neat little page]] here...
24559 !! html/php
24560 Poked at a <a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">neat little page</a> here...
24561 !!end
24562
24563 !! test
24564 Edit comment with bogus subpage link in non-subpage NS (T16080)
24565 !! options
24566 comment
24567 title=[[Subpage test]]
24568 !! wikitext
24569 Poked at a [[/subpage]] here...
24570 !! html/php
24571 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...
24572 !!end
24573
24574 !! test
24575 Edit comment with bare anchor link (local, as on diff)
24576 !! options
24577 comment
24578 local
24579 title=[[Main Page]]
24580 !! wikitext
24581 [[#section]]
24582 !! html/php
24583 <a href="#section">#section</a>
24584 !! end
24585
24586 !! test
24587 Edit comment with bare anchor link (non-local, as on history)
24588 !! options
24589 comment
24590 title=[[Main Page]]
24591 !! wikitext
24592 [[#section]]
24593 !! html/php
24594 <a href="/wiki/Main_Page#section" title="Main Page">#section</a>
24595 !! end
24596
24597 !! test
24598 Anchor starting with underscore
24599 !! options
24600 title=[[Foo]]
24601 !! wikitext
24602 [[#_ref|One]]
24603 !! html/php
24604 <p><a href="#_ref">One</a>
24605 </p>
24606 !! html/parsoid
24607 <p><a rel="mw:WikiLink" href="./Foo#_ref" data-parsoid='{"stx":"piped","a":{"href":"./Foo#_ref"},"sa":{"href":"#_ref"}}'>One</a></p>
24608 !! end
24609
24610 !! test
24611 Id starting with underscore
24612 !! wikitext
24613 <div id="_ref"></div>
24614 !! html/*
24615 <div id="_ref"></div>
24616
24617 !! end
24618
24619 !! test
24620 Edit comment with link with more than one pipe (T99346)
24621 !! options
24622 comment
24623 !! wikitext
24624 [[Main Page|Many|pipes]]
24625 !! html/php
24626 <a href="/wiki/Main_Page" title="Main Page">Many|pipes</a>
24627 !! end
24628
24629 !! test
24630 Complex edit comment with link with more than one pipe (T99346)
24631 !! options
24632 comment
24633 !! wikitext
24634 Created page with "<noinclude>[[Category:Requests for permissions/Bot|{{subst:#titleparts:{{subst:PAGENAME}}|1|3}}]]</noinclude> === [[User:MineoBot|]] 8=== {{Request for permissions/links|Mineo..."
24635 !! html/php
24636 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;
24637 !! end
24638
24639 !! test
24640 Space normalisation on autocomment (T24784)
24641 !! options
24642 comment
24643 title=[[Main Page]]
24644 !! wikitext
24645 /* __hello__world__ */
24646 !! html/php
24647 <span dir="auto"><span class="autocomment"><a href="/wiki/Main_Page#hello_world" title="Main Page">→‎__hello__world__</a></span></span>
24648 !! end
24649
24650 !! test
24651 percent-encoding and + signs in comments (T28410)
24652 !! options
24653 comment
24654 !! wikitext
24655 [[ABC%33D% ++]] [[ABC%33D% ++|+%20]]
24656 !! html/php
24657 <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>
24658 !! end
24659
24660 # Parsoid doesn't support this yet: see T75581
24661 # but it *should* omit the 'src' attribute if the image is bad.
24662 # PHP side of tests was disabled in
24663 # mediawiki/core:6bd31e7d95161a6e88fa86df60871051da997c3c
24664 # because of issues in the PHP parserTests infrastructure
24665 # (but the output below is indeed what the PHP side emits)
24666 !! test
24667 Bad images - basic functionality
24668 !! wikitext
24669 [[File:Bad.jpg]]
24670 !! html/php+disabled
24671 !! html/parsoid
24672 <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>
24673 !! end
24674
24675 !! test
24676 Bad images - T18039: text after bad image disappears
24677 !! wikitext
24678 Foo bar
24679 [[File:Bad.jpg]]
24680 Bar foo
24681 !! html/php+disabled
24682 <p>Foo bar
24683 </p><p>Bar foo
24684 </p>
24685 !! html/parsoid
24686 <p>Foo bar
24687 <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>
24688 Bar foo</p>
24689 !! end
24690
24691 !! test
24692 Verify that displaytitle works (T24501) no displaytitle
24693 !! options
24694 showtitle
24695 !! config
24696 wgAllowDisplayTitle=true
24697 wgRestrictDisplayTitle=false
24698 !! wikitext
24699 this is not the the title
24700 !! html/php
24701 Parser test
24702 <p>this is not the the title
24703 </p>
24704 !! end
24705
24706 !! test
24707 Verify that displaytitle works (T24501) RestrictDisplayTitle=false
24708 !! options
24709 showtitle
24710 title=[[Screen]]
24711 !! config
24712 wgAllowDisplayTitle=true
24713 wgRestrictDisplayTitle=false
24714 !! wikitext
24715 this is not the the title
24716 {{DISPLAYTITLE:whatever}}
24717 !! html/php
24718 whatever
24719 <p>this is not the the title
24720 </p>
24721 !! end
24722
24723 !! test
24724 Verify that displaytitle works (T24501) RestrictDisplayTitle=true mismatch
24725 !! options
24726 showtitle
24727 title=[[Screen]]
24728 !! config
24729 wgAllowDisplayTitle=true
24730 wgRestrictDisplayTitle=true
24731 !! wikitext
24732 this is not the the title
24733 {{DISPLAYTITLE:whatever}}
24734 !! html/php
24735 Screen
24736 <p>this is not the the title
24737 </p>
24738 !! end
24739
24740 !! test
24741 Verify that displaytitle works (T24501) RestrictDisplayTitle=true matching
24742 !! options
24743 showtitle
24744 title=[[Screen]]
24745 !! config
24746 wgAllowDisplayTitle=true
24747 wgRestrictDisplayTitle=true
24748 !! wikitext
24749 this is not the the title
24750 {{DISPLAYTITLE:screen}}
24751 !! html/php
24752 screen
24753 <p>this is not the the title
24754 </p>
24755 !! end
24756
24757 !! test
24758 Verify that displaytitle works (T24501) AllowDisplayTitle=false
24759 !! options
24760 showtitle
24761 title=[[Screen]]
24762 !! config
24763 wgAllowDisplayTitle=false
24764 !! wikitext
24765 this is not the the title
24766 {{DISPLAYTITLE:screen}}
24767 !! html/php
24768 Screen
24769 <p>this is not the the title
24770 <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>
24771 </p>
24772 !! end
24773
24774 !! test
24775 Verify that displaytitle works (T24501) AllowDisplayTitle=false no DISPLAYTITLE
24776 !! options
24777 showtitle
24778 title=[[Screen]]
24779 !! config
24780 wgAllowDisplayTitle=false
24781 !! wikitext
24782 this is not the the title
24783 !! html/php
24784 Screen
24785 <p>this is not the the title
24786 </p>
24787 !! end
24788
24789 !! test
24790 Verify that displaytitle handles inline CSS styles (T28547) - rejected value
24791 !! options
24792 showtitle
24793 title=[[Screen]]
24794 !! config
24795 wgAllowDisplayTitle=true
24796 wgRestrictDisplayTitle=true
24797 !! wikitext
24798 this is not the the title
24799 {{DISPLAYTITLE:<span style="display: none;">s</span>creen}}
24800 !! html/php
24801 <span style="/* attempt to bypass $wgRestrictDisplayTitle */">s</span>creen
24802 <p>this is not the the title
24803 </p>
24804 !! end
24805
24806 !! test
24807 Verify that displaytitle handles inline CSS styles (T28547) - accepted value
24808 !! options
24809 showtitle
24810 title=[[Screen]]
24811 !! config
24812 wgAllowDisplayTitle=true
24813 wgRestrictDisplayTitle=true
24814 !! wikitext
24815 this is not the the title
24816 {{DISPLAYTITLE:<span style="color: red;">s</span>creen}}
24817 !! html/php
24818 <span style="color: red;">s</span>creen
24819 <p>this is not the the title
24820 </p>
24821 !! end
24822
24823 !! test
24824 Page status indicators: Empty name is invalid
24825 !! options
24826 showindicators
24827 !! wikitext
24828 <indicator name=" "></indicator>
24829 <indicator></indicator>
24830 !! html/php
24831 <p><span class="error"><strong>Error:</strong> Page status indicators' <code>name</code> attribute must not be empty.</span>
24832 <span class="error"><strong>Error:</strong> Page status indicators' <code>name</code> attribute must not be empty.</span>
24833 </p>
24834 !! end
24835
24836 !! test
24837 Page status indicators: Weird syntaxes that are okay
24838 !! options
24839 showindicators
24840 !! wikitext
24841 <indicator name="empty" />
24842 <indicator name="name"></indicator>
24843 !! html/php
24844 empty=
24845 name=
24846 <p><br />
24847 </p>
24848 !! end
24849
24850 !! test
24851 Page status indicators: Torture test
24852 !! options
24853 showindicators
24854 !! wikitext
24855 <indicator name="01">hello world</indicator>
24856 <indicator name="02">[[Main Page]]</indicator>
24857 <indicator name="03">[[File:Foobar.jpg|25px|link=]]</indicator>
24858 <indicator name="04">[[File:Foobar.jpg|25px]]</indicator>
24859 <indicator name="05">*foo
24860 *bar</indicator>
24861 <indicator name="06"><nowiki>foo</nowiki></indicator>
24862 <indicator name="07"> Preformatted</indicator>
24863 <indicator name="08"><div>Broken tag</indicator>
24864 <indicator name="09">{| class=wikitable
24865 |cell
24866 |}</indicator>
24867 <indicator name="10">Two
24868
24869 paragraphs</indicator>
24870 !! html/php
24871 01=hello world
24872 02=<a href="/wiki/Main_Page" title="Main Page">Main Page</a>
24873 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" />
24874 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>
24875 05=<ul><li>foo</li>
24876 <li>bar</li></ul>
24877 06=foo
24878 07=<pre>Preformatted
24879 </pre>
24880 08=<div>Broken tag</div>
24881
24882 09=<table class="wikitable">
24883 <tr>
24884 <td>cell
24885 </td></tr></table>
24886
24887 10=<p>Two
24888 </p><p>paragraphs
24889 </p>
24890 <p><br />
24891 </p><p><br />
24892 </p><p><br />
24893 </p><p><br />
24894 </p><p><br />
24895 </p>
24896 !! end
24897
24898 !! test
24899 preload: check <noinclude> and <includeonly>
24900 !! options
24901 preload
24902 !! wikitext
24903 Hello <noinclude>cruel</noinclude><includeonly>kind</includeonly> world.
24904 !! html/php
24905 Hello kind world.
24906 !! end
24907
24908 !! test
24909 preload: check <onlyinclude>
24910 !! options
24911 preload
24912 !! wikitext
24913 Goodbye <onlyinclude>Hello world</onlyinclude>
24914 !! html/php
24915 Hello world
24916 !! end
24917
24918 !! test
24919 preload: can pass tags through if we want to
24920 !! options
24921 preload
24922 !! wikitext
24923 <includeonly><</includeonly>includeonly>Hello world<includeonly><</includeonly>/includeonly>
24924 !! html/php
24925 <includeonly>Hello world</includeonly>
24926 !! end
24927
24928 !! test
24929 preload: check that it doesn't try to do tricks
24930 !! options
24931 preload
24932 !! wikitext
24933 * <!-- Hello --> ''{{world}}'' {{<includeonly>subst:</includeonly>How are you}}{{ {{{|safesubst:}}} #if:1|2|3}}
24934 !! html/php
24935 * <!-- Hello --> ''{{world}}'' {{subst:How are you}}{{ {{{|safesubst:}}} #if:1|2|3}}
24936 !! end
24937
24938 !! test
24939 Play a bit with r67090 and T5158
24940 !! wikitext
24941 <div style="width:50% !important">&nbsp;</div>
24942 <div style="width:50%&nbsp;!important">&nbsp;</div>
24943 <div style="width:50%&#160;!important">&nbsp;</div>
24944 <div style="border : solid;">&nbsp;</div>
24945 !! html/php
24946 <div style="width:50% !important">&#160;</div>
24947 <div style="width:50% !important">&#160;</div>
24948 <div style="width:50% !important">&#160;</div>
24949 <div style="border&#32;: solid;">&#160;</div>
24950
24951 !! html/parsoid
24952 <div style="width:50% !important" data-parsoid='{"stx":"html"}'><span typeof="mw:Entity" data-parsoid='{"srcContent":" "}'> </span></div>
24953 <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>
24954 <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>
24955 <div style="border : solid;" data-parsoid='{"stx":"html"}'><span typeof="mw:Entity" data-parsoid='{"srcContent":" "}'> </span></div>
24956
24957 !! end
24958
24959 !! test
24960 French spaces in wikitext
24961 !! wikitext
24962 foo ! bar ? bat 50 % is less than 75 %.
24963
24964 Hello : this ; is « something ‹ else › again »
24965 !! html
24966 <p>foo&#160;! bar&#160;? bat 50&#160;% is less than 75&#160;%.
24967 </p><p>Hello&#160;: this&#160;; is «&#160;something ‹&#160;else&#160;› again&#160;»
24968 </p>
24969 !! end
24970
24971 # It would be reasonable for Parsoid and PHP to differ here.
24972 # The PHP behavior is arguably a bug.
24973 !! test
24974 Corner case: french spaces in definition list
24975 !! wikitext
24976 ;foo : bar
24977 !! html+tidy
24978 <dl><dt>foo&#160;</dt>
24979 <dd>bar</dd></dl>
24980 !! end
24981
24982 !! test
24983 T5158: Test for French spaces in attributes
24984 !! wikitext
24985 <br style=" clear : both ; " />
24986 !! html/php
24987 <p><br style="clear&#32;: both&#32;;" />
24988 </p>
24989 !! end
24990
24991 !! test
24992 HTML5 data attributes
24993 !! wikitext
24994 <span data-foo="bar">Baz</span>
24995 <p data-abc-def_hij="">Quuz</p>
24996 !! html/php
24997 <p><span data-foo="bar">Baz</span>
24998 </p>
24999 <p data-abc-def_hij="">Quuz</p>
25000
25001 !! html/parsoid
25002 <p><span data-foo="bar" data-parsoid='{"stx":"html"}'>Baz</span></p>
25003 <p data-abc-def_hij="" data-parsoid='{"stx":"html"}'>Quuz</p>
25004 !! end
25005
25006 !! test
25007 Strip reserved data attributes
25008 !! wikitext
25009 <div data-mw="foo" data-parsoid="bar" data-mw-someext="baz" data-ok="fred" data-ooui="xyzzy" data-bad:ns="ns">d</div>
25010 !! html/php
25011 <div data-ok="fred">d</div>
25012
25013 !! html/parsoid
25014 <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>
25015 !! end
25016
25017 !! test
25018 percent-encoding and + signs in internal links (T28410)
25019 !! wikitext
25020 [[User:+%]] [[Page+title%]]
25021 [[%+]] [[%+|%20]] [[%+ ]] [[%+r]]
25022 [[%]] [[+]] [[File:%+abc%39|foo|[[bar]]]]
25023 [[%33%45]] [[%33%45+]]
25024 !! html/php
25025 <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>
25026 <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>
25027 <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>
25028 <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>
25029 </p>
25030 !! html/parsoid
25031 <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>
25032 <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>
25033 <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>
25034 <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>
25035 !! end
25036
25037 !! test
25038 Special characters in embedded file links (T29679)
25039 !! wikitext
25040 [[File:Contains & ampersand.jpg]]
25041 [[File:Does not exist.jpg|Title with & ampersand]]
25042 !! html/php
25043 <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>
25044 <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>
25045 </p>
25046 !! html/parsoid
25047 <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>
25048 <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>
25049 !! end
25050
25051 !! test
25052 Confirm that 'apos' named character reference doesn't make it to output (not legal in HTML 4)
25053 !! wikitext
25054 Text&apos;s been normalized?
25055 !! html
25056 <p>Text&#39;s been normalized?
25057 </p>
25058 !! end
25059
25060 !! test
25061 T21052 U+3000 IDEOGRAPHIC SPACE should terminate free external links
25062 !! wikitext
25063 http://www.example.org/ <-- U+3000 (vim: ^Vu3000)
25064 !! html
25065 <p><a rel="nofollow" class="external free" href="http://www.example.org/">http://www.example.org/</a> &lt;-- U+3000 (vim: ^Vu3000)
25066 </p>
25067 !! end
25068
25069 !! test
25070 T21052 U+3000 IDEOGRAPHIC SPACE should terminate bracketed external links
25071 !! wikitext
25072 [http://www.example.org/ ideograms]
25073 !! html
25074 <p><a rel="nofollow" class="external text" href="http://www.example.org/">ideograms</a>
25075 </p>
25076 !! end
25077
25078 !! test
25079 T21052 U+3000 IDEOGRAPHIC SPACE should terminate external images links
25080 !! wikitext
25081 http://www.example.org/pic.png <-- U+3000 (vim: ^Vu3000)
25082 !! html
25083 <p><img src="http://www.example.org/pic.png" alt="pic.png"/> &lt;-- U+3000 (vim: ^Vu3000)
25084 </p>
25085 !! end
25086
25087 !! article
25088 Mediawiki:loop1
25089 !! text
25090 {{Identical|A}}
25091 !! endarticle
25092
25093 !! article
25094 Mediawiki:loop2
25095 !! text
25096 {{Identical|B}}
25097 !! endarticle
25098
25099 !! article
25100 Template:Identical
25101 !! text
25102 {{int:loop1}}
25103 {{int:loop2}}
25104 !! endarticle
25105
25106 !! test
25107 T33098 Template which includes system messages which includes the template
25108 !! wikitext
25109 {{Identical}}
25110 !! html
25111 <p><span class="error">Template loop detected: <a href="/wiki/Template:Identical" title="Template:Identical">Template:Identical</a></span>
25112 <span class="error">Template loop detected: <a href="/wiki/Template:Identical" title="Template:Identical">Template:Identical</a></span>
25113 </p>
25114 !! end
25115
25116 !! test
25117 T33490 Turkish: ucfirst 'blah'
25118 !! options
25119 language=tr
25120 !! wikitext
25121 {{ucfirst:blah}}
25122 !! html
25123 <p>Blah
25124 </p>
25125 !! end
25126
25127 !! test
25128 T33490 Turkish: ucfirst 'ix'
25129 !! options
25130 language=tr
25131 !! wikitext
25132 {{ucfirst:ix}}
25133 !! html
25134 <p>İx
25135 </p>
25136 !! end
25137
25138 !! test
25139 T33490 Turkish: lcfirst 'BLAH'
25140 !! options
25141 language=tr
25142 !! wikitext
25143 {{lcfirst:BLAH}}
25144 !! html
25145 <p>bLAH
25146 </p>
25147 !! end
25148
25149 !! test
25150 T33490 Turkish: ucfırst (with a dotless i)
25151 !! options
25152 language=tr
25153 !! wikitext
25154 {{ucfırst:blah}}
25155 !! html
25156 <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>
25157 </p>
25158 !! end
25159
25160 !! test
25161 T33490 ucfırst (with a dotless i) with English language
25162 !! options
25163 language=en
25164 !! wikitext
25165 {{ucfırst:blah}}
25166 !! html
25167 <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>
25168 </p>
25169 !! end
25170
25171 # Note that Parsoid doesn't emit an explicit TOC.
25172 # Note also that the html2wt direction tends to emit an extra newline
25173 # between the __TOC__ magicword and the first heading unless *both*
25174 # the <meta> and the <h2> have a data-parsoid attribute set (even if
25175 # it's "{}").
25176
25177 !! test
25178 T28375: TOC with italics
25179 !! options
25180 title=[[Main Page]]
25181 !! wikitext
25182 __TOC__
25183 ==''Lost'' episodes==
25184 !! html/php
25185 <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>
25186 <ul>
25187 <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>
25188 </ul>
25189 </div>
25190
25191 <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>
25192
25193 !! html/parsoid
25194 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25195 <h2 id="Lost_episodes" data-parsoid='{}'><i>Lost</i> episodes</h2>
25196 !! end
25197
25198 !! test
25199 T28375: TOC with bold
25200 !! options
25201 title=[[Main Page]]
25202 !! wikitext
25203 __TOC__
25204 =='''should be bold''' then normal text==
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="#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>
25209 </ul>
25210 </div>
25211
25212 <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>
25213
25214 !! html/parsoid
25215 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25216 <h2 id="should_be_bold_then_normal_text" data-parsoid='{}'><b>should be bold</b> then normal text</h2>
25217 !! end
25218
25219 !! test
25220 T35845: Headings become cursive in TOC when they contain an image
25221 !! options
25222 title=[[Main Page]]
25223 !! wikitext
25224 __TOC__
25225 ==Image [[Image:foobar.jpg]]==
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="#Image"><span class="tocnumber">1</span> <span class="toctext">Image</span></a></li>
25230 </ul>
25231 </div>
25232
25233 <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>
25234
25235 !! html/parsoid
25236 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25237 <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>
25238 !! end
25239
25240 !! test
25241 T35845 (2): Headings become bold in TOC when they contain a blockquote
25242 !! options
25243 title=[[Main Page]]
25244 !! wikitext
25245 __TOC__
25246 ==<blockquote>Quote</blockquote>==
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="#Quote"><span class="tocnumber">1</span> <span class="toctext">Quote</span></a></li>
25251 </ul>
25252 </div>
25253
25254 <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>
25255
25256 !! html/php+tidy
25257 <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>
25258 <ul>
25259 <li class="toclevel-1 tocsection-1"><a href="#Quote"><span class="tocnumber">1</span> <span class="toctext">Quote</span></a></li>
25260 </ul>
25261 </div>
25262
25263 <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>
25264 !! html/parsoid
25265 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25266 <h2 id="Quote" data-parsoid='{}'><blockquote><p>Quote</p></blockquote></h2>
25267 !! end
25268
25269 !! test
25270 Unclosed tags in TOC
25271 !! config
25272 wgFragmentMode=[ 'html5', 'legacy' ]
25273 !! options
25274 title=[[Main Page]]
25275 !! wikitext
25276 __TOC__
25277 ==Proof: 2 < 3==
25278 <small>Hanc marginis exiguitas non caperet.</small>
25279 QED
25280 !! html/php
25281 <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>
25282 <ul>
25283 <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>
25284 </ul>
25285 </div>
25286
25287 <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>
25288 <p><small>Hanc marginis exiguitas non caperet.</small>
25289 QED
25290 </p>
25291 !! html/parsoid
25292 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25293 <h2 id="Proof:_2_&lt;_3" data-parsoid='{}'><span id="Proof:_2_.3C_3" typeof="mw:FallbackId"></span>Proof: 2 &lt; 3</h2>
25294 <p><small>Hanc marginis exiguitas non caperet.</small>
25295 QED</p>
25296 !! end
25297
25298 !! test
25299 Multiple tags in TOC
25300 !! wikitext
25301 __TOC__
25302 ==<i>Foo</i> <b>Bar</b>==
25303
25304 ==<i>Foo</i> <blockquote>Bar</blockquote>==
25305 !! html/php
25306 <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>
25307 <ul>
25308 <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>
25309 <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>
25310 </ul>
25311 </div>
25312
25313 <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>
25314 <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>
25315
25316 !! html/php+tidy
25317 <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>
25318 <ul>
25319 <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>
25320 <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>
25321 </ul>
25322 </div>
25323
25324 <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>
25325 <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>
25326 !! html/parsoid
25327 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25328 <h2 id="Foo_Bar" data-parsoid='{}'><i data-parsoid='{"stx":"html"}'>Foo</i> <b data-parsoid='{"stx":"html"}'>Bar</b></h2>
25329
25330 <h2 id="Foo_Bar_2" data-parsoid='{}'><i data-parsoid='{"stx":"html"}'>Foo</i> <blockquote><p>Bar</p></blockquote></h2>
25331 !! end
25332
25333 # Don't expect Parsoid to roundtrip this until the php parser comes closer to
25334 # html5 tag parsing.
25335 !! test
25336 Tags with parameters in TOC
25337 !! options
25338 parsoid=wt2html
25339 !! wikitext
25340 __TOC__
25341 ==<sup class="in-h2">Hello</sup>==
25342
25343 ==<sup class="a > b">Evilbye</sup>==
25344 !! html/php
25345 <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>
25346 <ul>
25347 <li class="toclevel-1 tocsection-1"><a href="#Hello"><span class="tocnumber">1</span> <span class="toctext"><sup>Hello</sup></span></a></li>
25348 <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>
25349 </ul>
25350 </div>
25351
25352 <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>
25353 <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>
25354
25355 !! html/parsoid
25356 <meta property="mw:PageProp/toc" />
25357 <h2 id="Hello"><sup class="in-h2" data-parsoid='{"stx":"html"}'>Hello</sup></h2>
25358
25359 <h2 id='b">Evilbye'><span id="b.22.3EEvilbye" typeof="mw:FallbackId"></span><sup class="a " data-parsoid='{"stx":"html"}'> b">Evilbye</sup></h2>
25360 !! end
25361
25362 !! test
25363 span tags with directionality in TOC
25364 !! wikitext
25365 __TOC__
25366 ==<span dir="ltr">C++</span>==
25367
25368 ==<span dir="rtl">זבנג!</span>==
25369
25370 ==<span style="font-style: italic">The attributes on these span tags must be deleted from the TOC</span>==
25371
25372 ==<span style="font-style: italic" dir="ltr">All attributes on these span tags must be deleted from the TOC</span>==
25373
25374 ==<span dir="ltr" style="font-style: italic">Attributes after dir on these span tags must be deleted from the TOC</span>==
25375 !! html/php
25376 <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>
25377 <ul>
25378 <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>
25379 <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>
25380 <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>
25381 <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>
25382 <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>
25383 </ul>
25384 </div>
25385
25386 <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>
25387 <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>
25388 <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>
25389 <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>
25390 <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>
25391
25392 !! html/parsoid
25393 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25394 <h2 id="C++" data-parsoid='{}'><span id="C.2B.2B" typeof="mw:FallbackId"></span><span dir="ltr">C++</span></h2>
25395 <h2 id="זבנג!"><span id=".D7.96.D7.91.D7.A0.D7.92.21" typeof="mw:FallbackId"></span><span dir="rtl">זבנג!</span></h2>
25396 <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>
25397 <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>
25398 <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>
25399 !! end
25400
25401 !! test
25402 T74884: bdi element in ToC
25403 !! wikitext
25404 __TOC__
25405 ==<bdi>test</bdi>==
25406 !! html/php
25407 <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>
25408 <ul>
25409 <li class="toclevel-1 tocsection-1"><a href="#test"><span class="tocnumber">1</span> <span class="toctext"><bdi>test</bdi></span></a></li>
25410 </ul>
25411 </div>
25412
25413 <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>
25414
25415 !! html/parsoid
25416 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25417 <h2 id="test" data-parsoid='{}'><bdi>test</bdi></h2>
25418 !! end
25419
25420 !! test
25421 T35715: s/strike element in ToC
25422 !! wikitext
25423 __TOC__
25424 ==<s>test</s> test <strike>test</strike>==
25425 !! html/php
25426 <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>
25427 <ul>
25428 <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>
25429 </ul>
25430 </div>
25431
25432 <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>
25433
25434 !! html/parsoid
25435 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25436 <h2 id="test_test_test" data-parsoid='{}'><s>test</s> test <strike>test</strike></h2>
25437 !! end
25438
25439 !! test
25440 T198618: style element in ToC
25441 !! options
25442 styletag=1
25443 !! wikitext
25444 __TOC__
25445 ==<style>.foo {}</style>Style<style>.bar {}</style>==
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="#Style"><span class="tocnumber">1</span> <span class="toctext">Style</span></a></li>
25450 </ul>
25451 </div>
25452
25453 <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>
25454
25455 !! html/parsoid
25456 <meta property="mw:PageProp/toc" data-parsoid="{}"/>
25457 <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>
25458 !! end
25459
25460 !! test
25461 T198618: script element in ToC
25462 !! options
25463 wgRawHtml=1
25464 !! wikitext
25465 __TOC__
25466 ==<html><script>alert(1);</script></html>Script<html><script>alert(1);</script></html>==
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="#Script"><span class="tocnumber">1</span> <span class="toctext">Script</span></a></li>
25471 </ul>
25472 </div>
25473
25474 <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>
25475
25476 !! html/parsoid
25477 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25478 <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>
25479 !! end
25480
25481 !! test
25482 Empty <p> tag in TOC, removed by Sanitizer (T92892)
25483 !! wikitext
25484 __TOC__
25485 ==x==
25486 !! html/php
25487 <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>
25488 <ul>
25489 <li class="toclevel-1 tocsection-1"><a href="#x"><span class="tocnumber">1</span> <span class="toctext">x</span></a></li>
25490 </ul>
25491 </div>
25492
25493 <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>
25494
25495 !! html/parsoid
25496 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25497 <h2 id="x" data-parsoid='{}'>x</h2>
25498 !! end
25499
25500 !! article
25501 MediaWiki:T34057
25502 !! text
25503 == {{int:headline_sample}} ==
25504 !! endarticle
25505
25506 !! test
25507 T34057: Title needed when expanding <h> nodes.
25508 !! options
25509 title=[[Main Page]]
25510 !! wikitext
25511 {{int:T34057}}
25512 !! html
25513 <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>
25514
25515 !! end
25516
25517 !! test
25518 Strip marker in urlencode
25519 !! wikitext
25520 {{urlencode:x<nowiki/>y}}
25521 {{urlencode:x<nowiki/>y|wiki}}
25522 {{urlencode:x<nowiki/>y|path}}
25523 {{urlencode:x<pre id="one">two</pre>y}}
25524 !! html/php
25525 <p>xy
25526 xy
25527 xy
25528 xy
25529 </p>
25530 !! end
25531
25532 !! test
25533 Strip marker in lc
25534 !! wikitext
25535 {{lc:x<nowiki/>y}}
25536 !! html
25537 <p>xy
25538 </p>
25539 !! end
25540
25541 !! test
25542 Strip marker in uc
25543 !! wikitext
25544 {{uc:x<nowiki/>y}}
25545 !! html
25546 <p>XY
25547 </p>
25548 !! end
25549
25550 !! test
25551 Strip marker in formatNum
25552 !! wikitext
25553 {{formatnum:1<nowiki/>2}}
25554 {{formatnum:1<nowiki/>2|R}}
25555 !! html
25556 <p>12
25557 12
25558 </p>
25559 !! end
25560
25561 !! test
25562 Check noCommafy in formatNum
25563 !! options
25564 language=be-tarask
25565 !! wikitext
25566 {{formatnum:123456.78}}
25567 {{formatnum:123456.78|NOSEP}}
25568 !! html
25569 <p>123 456,78
25570 123456.78
25571 </p>
25572 !! end
25573
25574 !! test
25575 Wrong option for formatNum (T58199)
25576 !! wikitext
25577 {{formatnum:1,234.56|Random}}
25578 {{formatnum:1,234.56|EVERYTHING}}
25579 {{formatnum:1234.56|any argument that has the string 'NOSEP'}}
25580 !! html
25581 <p>1,234.56
25582 1,234.56
25583 1,234.56
25584 </p>
25585 !! end
25586
25587 !! test
25588 Strip marker in grammar
25589 !! options
25590 language=fi
25591 !! wikitext
25592 {{grammar:elative|foo<nowiki/>bar}}
25593 !! html
25594 <p>foobarista
25595 </p>
25596 !! end
25597
25598 !! test
25599 Strip marker in padleft
25600 !! wikitext
25601 {{padleft:|2|x<nowiki/>y}}
25602 !! html
25603 <p>xy
25604 </p>
25605 !! end
25606
25607 !! test
25608 Strip marker in padright
25609 !! wikitext
25610 {{padright:|2|x<nowiki/>y}}
25611 !! html
25612 <p>xy
25613 </p>
25614 !! end
25615
25616 !! test
25617 Strip marker in anchorencode
25618 !! wikitext
25619 {{anchorencode:x<nowiki/>y}}
25620 !! html/php
25621 <p>xy
25622 </p>
25623 !! html/parsoid
25624 <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>
25625 !! end
25626
25627 !! test
25628 nowiki inside link inside heading (T20295)
25629 !! wikitext
25630 ==[[foo|x<nowiki>y</nowiki>z]]==
25631 !! html
25632 <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>
25633
25634 !! end
25635
25636 !! test
25637 new support for bdi element (T33817)
25638 !! wikitext
25639 <p dir="rtl" lang="he">ולדימיר לנין (ברוסית: <bdi lang="ru">Владимир Ленин</bdi>, 24 באפריל 1870–22 בינואר 1924) הוא מנהיג פוליטי קומוניסטי רוסי.</p>
25640 !! html
25641 <p dir="rtl" lang="he">ולדימיר לנין (ברוסית: <bdi lang="ru">Владимир Ленин</bdi>, 24 באפריל 1870–22 בינואר 1924) הוא מנהיג פוליטי קומוניסטי רוסי.</p>
25642
25643 !!end
25644
25645 !! test
25646 Ignore pipe between table row attributes
25647 !! wikitext
25648 {|
25649 |quux
25650 |- id=foo | style='color: red'
25651 |bar
25652 |}
25653 !! html
25654 <table>
25655 <tr>
25656 <td>quux
25657 </td></tr>
25658 <tr id="foo" style="color: red">
25659 <td>bar
25660 </td></tr></table>
25661
25662 !! end
25663
25664 !!test
25665 Language parser function
25666 !! wikitext
25667 {{#language:ar}}
25668 !! html
25669 <p>العربية
25670 </p>
25671 !! end
25672
25673 !!test
25674 Padleft and padright (default 0-padding)
25675 !! wikitext
25676 {{padleft:xyz|5}}
25677 {{padright:xyz|5}}
25678 !! html/php
25679 <p>00xyz
25680 xyz00
25681 </p>
25682 !! html/parsoid
25683 <p><span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padleft:xyz","function":"padleft"},"params":{"1":{"wt":"5"}},"i":0}}]}'>00xyz</span>
25684 <span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padright:xyz","function":"padright"},"params":{"1":{"wt":"5"}},"i":0}}]}'>xyz00</span></p>
25685 !! end
25686
25687 !!test
25688 Padleft and padright (partial fill)
25689 !! wikitext
25690 {{padleft:xyz|6|ab}}
25691 {{padright:xyz|6|ab}}
25692 !! html/php
25693 <p>abaxyz
25694 xyzaba
25695 </p>
25696 !! html/parsoid
25697 <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>
25698 <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>
25699 !! end
25700
25701 !!test
25702 Padleft and padright as substr
25703 !! wikitext
25704 {{padleft:|3|abcde}}
25705 {{padright:|3|abcde}}
25706 !! html/php
25707 <p>abc
25708 abc
25709 </p>
25710 !! html/parsoid
25711 <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>
25712 <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>
25713 !! end
25714
25715 !! test
25716 Padleft and padright with non-numerical length (T180403)
25717 !! wikitext
25718 {{padleft:abcdef|junk}}
25719 {{padright:abcdef|junk}}
25720 !! html/php
25721 <p>abcdef
25722 abcdef
25723 </p>
25724 !! end
25725
25726 !!test
25727 Special parser function
25728 !! wikitext
25729 {{#special:RandomPage}}
25730 {{#special:BaDtItLe}}
25731 {{#special:Foobar}}
25732 !! html
25733 <p>Special:Random
25734 Special:Badtitle
25735 Special:Foobar
25736 </p>
25737 !! end
25738
25739 !!test
25740 T36939 - Case insensitive link parsing ([HttP://])
25741 !! wikitext
25742 [HttP://MediaWiki.Org/]
25743 !! html/php
25744 <p><a rel="nofollow" class="external autonumber" href="HttP://MediaWiki.Org/">[1]</a>
25745 </p>
25746 !! html/parsoid
25747 <p><a rel="mw:ExtLink" class="external autonumber" href="HttP://MediaWiki.Org/"></a></p>
25748 !! end
25749
25750 !!test
25751 T36939 - Case insensitive link parsing ([HttP:// title])
25752 !! wikitext
25753 [HttP://MediaWiki.Org/ MediaWiki]
25754 !! html
25755 <p><a rel="nofollow" class="external text" href="HttP://MediaWiki.Org/">MediaWiki</a>
25756 </p>
25757 !! end
25758
25759 !!test
25760 T36939 - Case insensitive link parsing (HttP://)
25761 !! wikitext
25762 HttP://MediaWiki.Org/
25763 !! html/php
25764 <p><a rel="nofollow" class="external free" href="HttP://MediaWiki.Org/">HttP://MediaWiki.Org/</a>
25765 </p>
25766 !! html/parsoid
25767 <p><a rel="mw:ExtLink" class="external free" href="HttP://MediaWiki.Org/">HttP://MediaWiki.Org/</a></p>
25768 !! end
25769
25770 !!test
25771 Disable TOC
25772 !! options
25773 notoc
25774 !! wikitext
25775 Lead
25776 ==Section 1==
25777 ==Section 2==
25778 ==Section 3==
25779 ==Section 4==
25780 ==Section 5==
25781 !! html
25782 <p>Lead
25783 </p>
25784
25785 <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>
25786 <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>
25787 <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>
25788 <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>
25789 <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>
25790
25791 !! end
25792
25793
25794 ###
25795 ### Parsoid-specific tests
25796 ### Parsoid-PHP parser incompatibilities
25797 ###
25798 !!test
25799 1. SOL-sensitive wikitext tokens as template-args
25800 !! options
25801 parsoid=wt2html,wt2wt
25802 !! wikitext
25803 {{echo|*a}}
25804 {{echo|#a}}
25805 {{echo|:a}}
25806 !! html/php+tidy
25807 <ul><li>a</li></ul>
25808 <ol><li>a</li></ol>
25809 <dl><dd>a</dd></dl>
25810 !! html/parsoid
25811 <span about="#mwt1" typeof="mw:Transclusion">
25812 </span><ul about="#mwt1"><li>a</li>
25813 </ul>
25814 <span about="#mwt2" typeof="mw:Transclusion">
25815 </span><ol about="#mwt2"><li>a</li>
25816 </ol>
25817 <span about="#mwt3" typeof="mw:Transclusion">
25818 </span><dl about="#mwt3"><dd>a</dd>
25819 </dl>
25820 !!end
25821
25822 #### -----------------------------------------------------------------
25823 #### Parsoid-specific functionality tests
25824 #### -----------------------------------------------------------------
25825
25826 # T65642/T68749: Formatting elt fixup around images.
25827 # We know wt2wt will fail, but we expect selser to pass.
25828 # Due to the nature of our testing, wt2wt and selser tests will enter the
25829 # blacklist and we'll catch selser regressions based on changes to the
25830 # blacklist entries for selser tests.
25831 !! test
25832 1. Treebuilder fixup of formatting elt
25833 !! options
25834 parsoid=wt2html,wt2wt
25835 !! wikitext
25836 {|
25837 |
25838 <small>
25839 [[Image:Foobar.jpg|right|Test]]
25840 </small>
25841 |}
25842 !! html/php+tidy
25843 <table>
25844 <tbody><tr>
25845 <td>
25846 <p><small>
25847 </small></p><small>
25848 <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>
25849 </small><p><small></small>
25850 </p>
25851 </td></tr></tbody></table>
25852 !! html/parsoid
25853 <table>
25854 <tbody><tr><td>
25855 <p><small data-parsoid='{"stx":"html","autoInsertedEnd":true}'></small></p><small data-parsoid='{"stx":"html","autoInsertedEnd":true,"autoInsertedStart":true}'>
25856 <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>
25857 <p><small data-parsoid='{"stx":"html","autoInsertedStart":true}'></small></p></td></tr>
25858 </tbody></table>
25859 !! end
25860
25861 !! test
25862 2. Treebuilder fixup of formatting elt
25863 !! options
25864 parsoid=wt2html,wt2wt
25865 !! wikitext
25866 '''foo[[File:Foobar.jpg|thumb|caption]]bar'''
25867
25868 <small>[[Image:Foobar.jpg|right|300px]]</small>
25869 !! html/php+tidy
25870 <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>
25871 </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>
25872 !! html/parsoid
25873 <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>
25874
25875 <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>
25876 !! end
25877
25878 !! test
25879 3. Treebuilder fixup of formatting elt
25880 !! options
25881 parsoid=wt2html,wt2wt
25882 !! wikitext
25883 <small>'''foo[[File:Foobar.jpg|thumb|caption]]bar'''</small>
25884 !! html/php+tidy
25885 <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>
25886 </p>
25887 !! html/parsoid
25888 <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>
25889 !! end
25890
25891 !! test
25892 4. Treebuilder fixup of formatting elt: formatting tags around captionless images
25893 !! options
25894 parsoid=wt2html,wt2wt
25895 !! wikitext
25896 '''<small>[[Image:Foobar.jpg|right|300px]]</small>'''
25897 !! html/php+tidy
25898 <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>
25899 !! html/parsoid
25900 <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>
25901 !! end
25902
25903 #### ----------------------------------------------------------------
25904 #### Parsoid-only testing of Parsoid's impl of LST
25905 #### Not implemented yet, see
25906 #### https://www.mediawiki.org/wiki/Parsoid/HTML_based_LST
25907 #### ----------------------------------------------------------------
25908
25909 ## We still need to support serializing the older format while content is stored.
25910 !! test
25911 LST Sections: Backwards compatibility
25912 !! options
25913 parsoid={
25914 "suppressErrors": true,
25915 "modes": ["html2wt"]
25916 }
25917 !! wikitext
25918 <section begin="2011-05-16" />
25919 <section end="2014-04-10 (MW 1.23wmf22)" />
25920 !! html/parsoid
25921 <p><meta typeof="mw:Extension/LabeledSectionTransclusion/begin" content="2011-05-16"/>
25922 <meta typeof="mw:Extension/LabeledSectionTransclusion/end" content="2014-04-10 (MW 1.23wmf22)"/></p>
25923 !! end
25924
25925 !! test
25926 LST Sections: Newfangled approach
25927 !! wikitext
25928 <section begin="2011-05-16" />
25929 <section end="2014-04-10 (MW 1.23wmf22)" />
25930 !! html/parsoid
25931 <p><span typeof="mw:Extension/section" about="#mwt4" data-mw='{"name":"section","attrs":{"begin":"2011-05-16"}}'>
25932 </span>
25933 <span typeof="mw:Extension/section" about="#mwt6" data-mw='{"name":"section","attrs":{"end":"2014-04-10 (MW 1.23wmf22)"}}'>
25934 </span></p>
25935 !! end
25936
25937 #--------- Test stripping of empty nodes in template content ----------
25938
25939 !! test
25940 Empty LI and TR nodes should be stripped from template content
25941 !! wikitext
25942 {{EmptyLITest}}
25943 {{EmptyTRTest}}
25944 !! html/parsoid
25945 <ul about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyLITest","href":"./Template:EmptyLITest"},"params":{},"i":0}}]}'>
25946 <li>a</li>
25947 <li>b</li>
25948 </ul>
25949 <table about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyTRTest","href":"./Template:EmptyTRTest"},"params":{},"i":0}}]}'>
25950 <tbody>
25951 <tr>
25952 <td>foo</td>
25953 </tr>
25954 <tr>
25955 <td>bar</td>
25956 </tr>
25957 </tbody>
25958 </table>
25959 !! end
25960
25961 !! test
25962 Empty LI and TR nodes should not be stripped from top-level content
25963 !! wikitext
25964 *a
25965 *
25966 *b
25967
25968 {|
25969 |-
25970 |-
25971 |foo
25972 |}
25973 !! html/parsoid
25974 <ul>
25975 <li>a</li>
25976 <li class='mw-empty-elt'></li>
25977 <li>b</li>
25978 </ul>
25979 <table>
25980 <tbody>
25981 <tr class='mw-empty-elt'></tr>
25982 <tr>
25983 <td>foo</td>
25984 </tr>
25985 </tbody>
25986 </table>
25987 !! end
25988
25989 !! test
25990 Empty TR nodes should not be stripped if they have any attributes set
25991 !! wikitext
25992 {{EmptyTRWithHTMLAttrTest}}
25993 !! html/parsoid
25994 <table about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyTRWithHTMLAttrTest","href":"./Template:EmptyTRWithHTMLAttrTest"},"params":{},"i":0}}]}'>
25995 <tr align='center'></tr>
25996 <tr><td>foo</td></tr>
25997 <tr align='center'></tr>
25998 <tr><td>bar</td></tr>
25999 </table>
26000 !! end
26001
26002 #### ----------------------------------------------------------------
26003 #### The following section of tests are primarily to test
26004 #### wikitext escaping capabilities of Parsoid. Given that
26005 #### escaping can be done any number of ways, the wikitext (input)
26006 #### is always adjusted to reflect how Parsoid adds nowiki
26007 #### escape tags.
26008 ####
26009 #### We are marking several tests as parsoid-only since the
26010 #### HTML in the result section is different from what the
26011 #### PHP parser generates for it.
26012 #### ----------------------------------------------------------------
26013
26014
26015 #### --------------- Headings ---------------
26016 #### 0. Unnested
26017 #### 1. Nested inside html <h1>=foo=</h1>
26018 #### 2. Outside heading nest on a single line <h1>foo</h1>*bar
26019 #### 3. Nested inside html with wikitext split by html tags
26020 #### 4. No escape needed
26021 #### 5. Empty headings <h1></h1>
26022 #### 6. Heading chars in SOL context
26023 #### ----------------------------------------
26024 !! test
26025 Headings: 0. Unnested
26026 !! options
26027 parsoid=html2wt
26028 !! html/parsoid
26029 <p>=foo=</p>
26030
26031 <p> =foo=
26032 <!--cmt-->
26033 =foo=</p>
26034
26035 <p>=foo<i>a</i>=</p>
26036 !! wikitext
26037 <nowiki>=foo=</nowiki>
26038
26039 <nowiki> </nowiki>=foo=
26040 <!--cmt-->
26041 <nowiki>=foo=</nowiki>
26042
26043 =foo''a''<nowiki>=</nowiki>
26044 !!end
26045
26046 # New headings and existing headings are handled differently
26047 !! test
26048 Headings: 1. Nested inside html
26049 !! options
26050 parsoid=html2wt
26051 !! html/parsoid
26052 <h1>=foo=</h1>
26053 <h2>=foo=</h2>
26054 <h3>=foo=</h3>
26055
26056 <h1 data-parsoid=''>=foo=</h1>
26057 <h2 data-parsoid=''>=foo=</h2>
26058 <h3 data-parsoid=''>=foo=</h3>
26059 <h4 data-parsoid=''>=foo=</h4>
26060 <h5 data-parsoid=''>=foo=</h5>
26061 <h6 data-parsoid=''>=foo=</h6>
26062 !! wikitext
26063 = =foo= =
26064
26065 == =foo= ==
26066
26067 === =foo= ===
26068
26069 =<nowiki>=foo=</nowiki>=
26070 ==<nowiki>=foo=</nowiki>==
26071 ===<nowiki>=foo=</nowiki>===
26072 ====<nowiki>=foo=</nowiki>====
26073 =====<nowiki>=foo=</nowiki>=====
26074 ======<nowiki>=foo=</nowiki>======
26075
26076 !!end
26077
26078 !! test
26079 Headings: 2. Outside heading nest on a single line <h1>foo</h1>*bar
26080 !! options
26081 parsoid=html2wt
26082 !! html/parsoid
26083 <h1>foo</h1>*bar
26084 <h1>foo</h1>=bar
26085 <h1>foo</h1>=bar=
26086 !! wikitext
26087 = foo =
26088 <nowiki>*</nowiki>bar
26089
26090 = foo =
26091 =bar
26092
26093 = foo =
26094 <nowiki>=bar=</nowiki>
26095 !!end
26096
26097 !! test
26098 Headings: 3. Nested inside html with wikitext split by html tags
26099 !! options
26100 parsoid=html2wt
26101 !! html/parsoid
26102 <h1>=<b>bold</b>foo=</h1>
26103 !! wikitext
26104 = ='''bold'''foo= =
26105 !!end
26106
26107 !! test
26108 Headings: 4a. No escaping needed (testing just h1 and h2)
26109 !! options
26110 parsoid=html2wt
26111 !! html/parsoid
26112 <h1>=foo</h1>
26113 <h1>foo=</h1>
26114 <h1> =foo= </h1>
26115 <h1>=foo= bar</h1>
26116 <h2>=foo</h2>
26117 <h2>foo=</h2>
26118 <h1>=</h1>
26119 <h1><i>=</i>foo=</h1>
26120 !! wikitext
26121 = =foo =
26122
26123 = foo= =
26124
26125 = =foo= =
26126
26127 = =foo= bar =
26128
26129 == =foo ==
26130
26131 == foo= ==
26132
26133 = = =
26134
26135 = ''=''foo= =
26136 !!end
26137
26138 !! test
26139 Headings: 4b. No escaping needed (inside p-tags)
26140 !! options
26141 parsoid=html2wt
26142 !! html/parsoid
26143 <p>=foo= x
26144 =foo= <s></s>
26145 </p>
26146 !! wikitext
26147 =foo= x
26148 =foo= <s></s>
26149 !! html/php
26150 <p>=foo= x
26151 =foo= <s></s>
26152 </p>
26153 !!end
26154
26155 !! test
26156 Headings: 4c. Short headings (1)
26157 !! options
26158 parsoid=html2wt
26159 !! html/parsoid
26160 <p>===
26161 </p>
26162 !! wikitext
26163 <nowiki>===</nowiki>
26164 !! html/php
26165 <p>===
26166 </p>
26167 !! end
26168
26169 # in the html2wt direction we emit '= = =' or '=<nowiki>=</nowiki>='
26170 !! test
26171 Headings: 4d. Short headings (2)
26172 !! options
26173 parsoid=wt2html,html2html
26174 !! wikitext
26175 =
26176 ==
26177 ===
26178 ====
26179 =====
26180 !! html/php
26181 <p>=
26182 ==
26183 </p>
26184 <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>
26185 <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>
26186 <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>
26187
26188 !! html/parsoid
26189 <p>=
26190 ==</p>
26191 <h1 id="="><span id=".3D" typeof="mw:FallbackId"></span>=</h1>
26192 <h1 id="=="><span id=".3D.3D" typeof="mw:FallbackId"></span>==</h1>
26193 <h2 id="=_2"><span id=".3D_2" typeof="mw:FallbackId"></span>=</h2>
26194 !! end
26195
26196 !! test
26197 Headings: 5. Empty headings
26198 !! options
26199 parsoid=html2wt
26200 !! html/parsoid
26201 <h1 data-parsoid='{}'></h1>
26202
26203 <h2 data-parsoid='{}'></h2>
26204
26205 <h3 data-parsoid='{}'></h3>
26206
26207 <h4 data-parsoid='{}'></h4>
26208
26209 <h5 data-parsoid='{}'></h5>
26210
26211 <h6 data-parsoid='{}'></h6>
26212 !! wikitext
26213 =<nowiki/>=
26214
26215 ==<nowiki/>==
26216
26217 ===<nowiki/>===
26218
26219 ====<nowiki/>====
26220
26221 =====<nowiki/>=====
26222
26223 ======<nowiki/>======
26224 !!end
26225
26226 !! test
26227 Headings: 6a. Heading chars in SOL context (with trailing spaces)
26228 !! options
26229 parsoid=html2wt
26230 !! html/parsoid
26231 <p>=a=</p>
26232
26233 <p>=a=</p>
26234
26235 <p>=a=</p>
26236 !! wikitext
26237 <nowiki>=a=</nowiki>
26238
26239 <nowiki>=a=</nowiki>
26240
26241 <nowiki>=a=</nowiki>
26242 !!end
26243
26244 !! test
26245 Headings: 6b. Heading chars in SOL context (with trailing newlines)
26246 !! options
26247 parsoid=html2wt
26248 !! html/parsoid
26249 <p>=a=
26250 b</p>
26251
26252 <p>=a=
26253 b</p>
26254
26255 <p>=a=
26256 b</p>
26257 !! wikitext
26258 <nowiki>=a=</nowiki>
26259 b
26260
26261 <nowiki>=a=</nowiki>
26262 b
26263
26264 <nowiki>=a=</nowiki>
26265 b
26266 !!end
26267
26268 !! test
26269 Headings: 6c. Heading chars in SOL context (leading newline break)
26270 !! options
26271 parsoid=html2wt
26272 !! html/parsoid
26273 <p>a
26274 =b=</p>
26275 !! wikitext
26276 a
26277 <nowiki>=b=</nowiki>
26278 !!end
26279
26280 !! test
26281 Headings: 6d. Heading chars in SOL context (with interspersed comments)
26282 !! options
26283 parsoid=html2wt
26284 !! html/parsoid
26285 <!--c0--><p>=a=</p>
26286
26287 <!--c1--><p>=a=</p> <!--c2--> <!--c3-->
26288 !! wikitext
26289 <!--c0--><nowiki>=a=</nowiki>
26290
26291 <!--c1--><nowiki>=a=</nowiki> <!--c2--> <!--c3-->
26292 !!end
26293
26294 !! test
26295 Headings: 6d. Heading chars in SOL context (No escaping needed)
26296 !! options
26297 parsoid=html2wt
26298 !! html/parsoid
26299 =a=<div>b</div>
26300 !! wikitext
26301 =a=<div>b</div>
26302 !!end
26303
26304 !! test
26305 Headings: 7. Insert a newline between new content and headings
26306 !! options
26307 parsoid=html2wt
26308 !! html/parsoid
26309 <h2>NEW</h2>
26310 <p>new</p>
26311 <h2 data-parsoid='{}'>A</h2>
26312 <p data-parsoid='{}'>a</p>
26313 !! wikitext
26314 == NEW ==
26315 new
26316
26317 ==A==
26318 a
26319
26320 !! end
26321
26322 !! test
26323 Headings: Used as horizontal rule
26324 !! config
26325 wgFragmentMode=[ 'html5', 'legacy' ]
26326 !! options
26327 parsoid=wt2html
26328 !! wikitext
26329 ===============
26330 !! html/php
26331 <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>
26332
26333 !! html/parsoid
26334 <h6 id="==="><span id=".3D.3D.3D" typeof="mw:FallbackId"></span>===</h6>
26335 !! end
26336
26337 #### --------------- Lists ---------------
26338 #### 0. Outside nests (*foo, etc.)
26339 #### 1. Nested inside html <ul><li>*foo</li></ul>
26340 #### 2. Inside definition lists
26341 #### 3. Only bullets at start should be escaped
26342 #### 4. No escapes needed
26343 #### 5. No unnecessary escapes
26344 #### 6. Escape bullets in SOL position
26345 #### 7. Escape bullets in a multi-line context
26346 #### ----------------------------------------
26347
26348 !! test
26349 Lists: 0. Outside nests
26350 !! options
26351 parsoid=html2wt
26352 !! html/parsoid
26353 <p>*foo</p>
26354
26355 <p>#foo</p>
26356
26357 <p>;Foo:bar</p>
26358 !! wikitext
26359 <nowiki>*</nowiki>foo
26360
26361 <nowiki>#</nowiki>foo
26362
26363 <nowiki>;</nowiki>Foo<nowiki>:</nowiki>bar
26364 !!end
26365
26366 ## Making these next 3 tests Parsoid-only since they are html2wt tests
26367 ## to test wikitext escaping, and insignificant whitespace diffs
26368 ## cause PHP parser tests to barf
26369 !! test
26370 Lists: 1. Nested inside html (No unnecessary escapes)
26371 !! options
26372 parsoid=html2wt
26373 !! html/parsoid
26374 <ul>
26375 <li>*foo</li>
26376 <li>#foo</li>
26377 <li>:foo</li>
26378 <li>;foo</li>
26379 <li data-parsoid='{}'>*foo</li>
26380 <li data-parsoid='{}'>#foo</li>
26381 <li data-parsoid='{}'>:foo</li>
26382 <li data-parsoid='{}'>;foo</li>
26383 </ul>
26384
26385 <ol>
26386 <li>*foo</li>
26387 <li>#foo</li>
26388 <li>:foo</li>
26389 <li>;foo</li>
26390 <li data-parsoid='{}'>*foo</li>
26391 <li data-parsoid='{}'>#foo</li>
26392 <li data-parsoid='{}'>:foo</li>
26393 <li data-parsoid='{}'>;foo</li>
26394 </ol>
26395 !! wikitext
26396 * *foo
26397 * #foo
26398 * :foo
26399 * ;foo
26400 *<nowiki>*foo</nowiki>
26401 *<nowiki>#foo</nowiki>
26402 *<nowiki>:foo</nowiki>
26403 *<nowiki>;foo</nowiki>
26404
26405 # *foo
26406 # #foo
26407 # :foo
26408 # ;foo
26409 #<nowiki>*foo</nowiki>
26410 #<nowiki>#foo</nowiki>
26411 #<nowiki>:foo</nowiki>
26412 #<nowiki>;foo</nowiki>
26413 !!end
26414
26415 !! test
26416 Lists: 2. Inside definition lists
26417 !! options
26418 parsoid=html2wt
26419 !! html/parsoid
26420 <dl><dt>;foo</dt></dl>
26421 <dl><dt>:foo</dt></dl>
26422 <dl><dt>:foo</dt>
26423 <dd>bar</dd></dl>
26424 <dl><dd>:foo</dd></dl>
26425 !! wikitext
26426 ; ;foo
26427
26428 ; <nowiki>:foo</nowiki>
26429
26430 ; <nowiki>:foo</nowiki>
26431 : bar
26432
26433 : :foo
26434 !!end
26435
26436 !! test
26437 Lists: 3. Only bullets at start of text in wikitext-generated HTML should be escaped
26438 !! options
26439 parsoid=html2wt
26440 !! html/parsoid
26441 <ul>
26442 <li>*foo*bar</li>
26443 <li data-parsoid='{}'>*foo<i>it</i>*bar</li>
26444 </ul>
26445 !! wikitext
26446 * *foo*bar
26447 *<nowiki>*foo</nowiki>''it''*bar
26448 !!end
26449
26450 !! test
26451 Lists: 4. No escapes needed
26452 !! options
26453 parsoid=html2wt
26454 !! html/parsoid
26455 <ul>
26456 <li>foo*bar
26457 </li>
26458 </ul>
26459 <ul>
26460 <li><i>foo</i>*bar
26461 </li>
26462 </ul>
26463 <ul>
26464 <li><a rel="mw:WikiLink" href="Foo" title="Foo">Foo</a>: bar
26465 </li>
26466 </ul>
26467 <ul>
26468 <li><a rel="mw:WikiLink" href="Foo" title="Foo">Foo</a>*bar
26469 </li>
26470 </ul>
26471 !! wikitext
26472 *foo*bar
26473
26474 *''foo''*bar
26475
26476 *[[Foo]]: bar
26477
26478 *[[Foo]]*bar
26479 !!end
26480
26481 !! test
26482 Lists: 5. No unnecessary escapes
26483 !! options
26484 parsoid=html2wt
26485 !! html/parsoid
26486 <ul><li> bar <span>[[foo]]</span></li></ul>
26487 <ul><li> =bar <span>[[foo]]</span></li></ul>
26488 <ul><li> [[bar <span>[[foo]]</span></li></ul>
26489 <ul><li> ]]bar <span>[[foo]]</span></li></ul>
26490 <ul><li> =bar <span>foo]]</span>=</li></ul>
26491 <ul><li> <s></s>: a</li></ul>
26492 <ul><li> <i>* foo</i></li></ul>
26493
26494 !! wikitext
26495 * bar <span><nowiki>[[foo]]</nowiki></span>
26496
26497 * =bar <span><nowiki>[[foo]]</nowiki></span>
26498
26499 * [[bar <span><nowiki>[[foo]]</nowiki></span>
26500
26501 * ]]bar <span><nowiki>[[foo]]</nowiki></span>
26502
26503 * =bar <span>foo]]</span>=
26504
26505 * <s></s>: a
26506
26507 * ''* foo''
26508 !!end
26509
26510 !! test
26511 Lists: 6. Escape bullets in SOL position
26512 !! options
26513 parsoid=html2wt
26514 !! html/parsoid
26515 <p><!--cmt-->*foo</p>
26516 !! wikitext
26517 <!--cmt--><nowiki>*</nowiki>foo
26518 !!end
26519
26520 !! test
26521 Lists: 7. Escape bullets in a multi-line context
26522 !! options
26523 parsoid=html2wt
26524 !! html/parsoid
26525 <p>a
26526 *b
26527 </p>
26528 !! wikitext
26529 a
26530 <nowiki>*</nowiki>b
26531 !!end
26532
26533 !! test
26534 Lists: 8. Escape colons only if not present in tags
26535 !! options
26536 parsoid=html2wt
26537 !! html/parsoid
26538 <dl><dt>a:b<i>c:d</i></dt></dl>
26539 !! wikitext
26540 ; <nowiki>a:b</nowiki>''c:d''
26541 !! end
26542
26543 #### --------------- HRs ---------------
26544 #### 1. Single line
26545 #### -----------------------------------
26546
26547 !! test
26548 HRs: 1. Single line
26549 !! options
26550 parsoid=html2wt
26551 !! html/parsoid
26552 <hr />----
26553 <hr />=foo=
26554 <hr />*foo
26555 !! wikitext
26556 ----<nowiki>----</nowiki>
26557 ----=foo=
26558 ----*foo
26559 !! end
26560
26561 #### --------------- Tables ---------------
26562 #### 1a. Simple example
26563 #### 1b. No escaping needed (!foo)
26564 #### 1c. No escaping needed (|foo)
26565 #### 1d. No escaping needed (|}foo)
26566 ####
26567 #### 2a. Nested in td (<td>foo|bar</td>)
26568 #### 2b. Nested in td (<td>foo||bar</td>)
26569 #### 2c. Nested in td -- no escaping needed(<td>foo!!bar</td>)
26570 ####
26571 #### 3a. Nested in th (<th>foo!bar</th>)
26572 #### 3b. Nested in th (<th>foo!!bar</th>)
26573 #### 3c. Nested in th -- no escaping needed(<th>foo||bar</th>)
26574 ####
26575 #### 4a. Escape -
26576 #### 4b. Escape +
26577 #### 4c. No escaping needed
26578 #### --------------------------------------
26579
26580 !! test
26581 Tables: 1a. Simple example
26582 !! options
26583 parsoid=html2wt
26584 !! html/parsoid
26585 <p>{|
26586 |}
26587 </p>
26588 !! wikitext
26589 <nowiki>{|</nowiki>
26590 |}
26591 !! end
26592
26593 !! test
26594 Tables: 1b. No escaping needed
26595 !! options
26596 parsoid=html2wt
26597 !! html/parsoid
26598 <p>!foo
26599 </p>
26600 !! wikitext
26601 !foo
26602 !! end
26603
26604 !! test
26605 Tables: 1c. No escaping needed
26606 !! options
26607 parsoid=html2wt
26608 !! html/parsoid
26609 <p>|foo
26610 </p>
26611 !! wikitext
26612 |foo
26613 !! end
26614
26615 !! test
26616 Tables: 1d. No escaping needed
26617 !! options
26618 parsoid=html2wt
26619 !! html/parsoid
26620 <p>|}foo
26621 </p>
26622 !! wikitext
26623 |}foo
26624 !! end
26625
26626 !! test
26627 Tables: 2a. Nested in td
26628 !! options
26629 parsoid=html2wt
26630 !! html/parsoid
26631 <table><tbody><tr>
26632 <td>foo|bar</td></tr>
26633 <tr><td>x<div>a|b</div></td>
26634 </tbody></table>
26635 !! wikitext
26636 {|
26637 |<nowiki>foo|bar</nowiki>
26638 |-
26639 |x<div><nowiki>a|b</nowiki></div>
26640 |}
26641 !! html/php+tidy
26642 <table>
26643 <tbody><tr>
26644 <td>foo|bar
26645 </td></tr>
26646 <tr>
26647 <td>x<div>a|b</div>
26648 </td></tr></tbody></table>
26649 !! end
26650
26651 !! test
26652 Tables: 2b. Nested in td
26653 !! options
26654 parsoid=html2wt
26655 !! html/parsoid
26656 <table><tbody><tr>
26657 <td>foo||bar</td>
26658 <td>a<i>b||c</i></td>
26659 <td>a<i><div>b||c</div></i></td>
26660 </tr></tbody></table>
26661 !! wikitext
26662 {|
26663 |<nowiki>foo||bar</nowiki>
26664 |a''<nowiki>b||c</nowiki>''
26665 |a''<div><nowiki>b||c</nowiki></div>''
26666 |}
26667 !! html/php
26668 <table>
26669 <tr>
26670 <td>foo||bar
26671 </td>
26672 <td>a<i>b||c</i>
26673 </td>
26674 <td>a<i><div>b||c</div></i>
26675 </td></tr></table>
26676
26677 !! end
26678
26679 !! test
26680 Tables: 2c. Nested in td -- no escaping needed
26681 !! options
26682 parsoid=html2wt
26683 !! html/*
26684 <table>
26685 <tr>
26686 <td>foo!!bar
26687 </td></tr></table>
26688
26689 !! wikitext
26690 {|
26691 |foo!!bar
26692 |}
26693 !! end
26694
26695 !! test
26696 Tables: 3a. Nested in th
26697 !! options
26698 parsoid=html2wt
26699 !! html/*
26700 <table>
26701 <tr>
26702 <th>foo!bar
26703 </th></tr></table>
26704
26705 !! wikitext
26706 {|
26707 !foo!bar
26708 |}
26709 !! end
26710
26711 !! test
26712 Tables: 3b. Nested in th
26713 !! options
26714 parsoid=html2wt
26715 !! html/parsoid
26716 <table><tbody>
26717 <tr><th>foo!!bar</th>
26718 <th><i>foo|bar</i></th>
26719 <th><i>foo!!bar</i></th>
26720 <th><i><span>foo!!bar</span></i></th>
26721 </tr></tbody></table>
26722 !! wikitext
26723 {|
26724 !<nowiki>foo!!bar</nowiki>
26725 !''<nowiki>foo|bar</nowiki>''
26726 !''<nowiki>foo!!bar</nowiki>''
26727 !''<span><nowiki>foo!!bar</nowiki></span>''
26728 |}
26729 !! html/php
26730 <table>
26731 <tr>
26732 <th>foo!!bar
26733 </th>
26734 <th><i>foo|bar</i>
26735 </th>
26736 <th><i>foo!!bar</i>
26737 </th>
26738 <th><i><span>foo!!bar</span></i>
26739 </th></tr></table>
26740
26741 !! end
26742
26743 !! test
26744 Tables: 3c. Nested in th
26745 !! options
26746 parsoid=html2wt
26747 !! html/parsoid
26748 <table><tbody>
26749 <tr><th>foo||bar</th>
26750 <th><span typeof="mw:Nowiki">foo||bar</span></th>
26751 </tr></tbody></table>
26752 !! wikitext
26753 {|
26754 !<nowiki>foo||bar</nowiki>
26755 !<nowiki>foo||bar</nowiki>
26756 |}
26757 !! html/php
26758 <table>
26759 <tr>
26760 <th>foo||bar
26761 </th>
26762 <th>foo||bar
26763 </th></tr></table>
26764
26765 !! end
26766
26767 !! test
26768 Tables: 4a. Escape -
26769 !! options
26770 parsoid=html2wt
26771 !! html/*
26772 <table>
26773 <tr>
26774 <th>-bar
26775 </th></tr>
26776 <tr>
26777 <td>-bar
26778 </td></tr></table>
26779
26780 !! wikitext
26781 {|
26782 !-bar
26783 |-
26784 |<nowiki>-bar</nowiki>
26785 |}
26786 !! end
26787
26788 !! test
26789 Tables: 4b. 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: 4c. No escaping needed
26811 !! options
26812 parsoid=html2wt
26813 !! html/parsoid
26814 <table><tbody>
26815 <tr><td>foo-bar</td><td>foo+bar</td></tr>
26816 <tr><td><i>foo</i>-bar</td><td><i>foo</i>+bar</td></tr>
26817 <tr><td>foo
26818 <p>bar|baz
26819 +bar
26820 -bar</p></td></tr>
26821 <tr><td>x
26822 <div>a|b</div></td>
26823 </tbody></table>
26824 !! wikitext
26825 {|
26826 |foo-bar
26827 |foo+bar
26828 |-
26829 |''foo''-bar
26830 |''foo''+bar
26831 |-
26832 |foo
26833 bar|baz
26834 +bar
26835 -bar
26836 |-
26837 |x
26838 <div>a|b</div>
26839 |}
26840 !! html/php
26841 <table>
26842 <tr>
26843 <td>foo-bar
26844 </td>
26845 <td>foo+bar
26846 </td></tr>
26847 <tr>
26848 <td><i>foo</i>-bar
26849 </td>
26850 <td><i>foo</i>+bar
26851 </td></tr>
26852 <tr>
26853 <td>foo
26854 <p>bar|baz
26855 +bar
26856 -bar
26857 </p>
26858 </td></tr>
26859 <tr>
26860 <td>x
26861 <div>a|b</div>
26862 </td></tr></table>
26863
26864 !! end
26865
26866 !! test
26867 Tables: 4d. No escaping needed
26868 !! options
26869 parsoid=html2wt
26870 !! html/parsoid
26871 <table>
26872 <tbody><tr><td><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a>-bar</td>
26873 <td data-parsoid='{"startTagSrc":"|","attrSepSrc":"|"}'>+1</td>
26874 <td data-parsoid='{"startTagSrc":"|","attrSepSrc":"|"}'>-2</td></tr>
26875 </tbody></table>
26876 !! wikitext
26877 {|
26878 |[[Foo]]-bar
26879 ||+1
26880 ||-2
26881 |}
26882 !! html/php
26883 <table>
26884 <tr>
26885 <td><a href="/wiki/Foo" title="Foo">Foo</a>-bar
26886 </td>
26887 <td>+1
26888 </td>
26889 <td>-2
26890 </td></tr></table>
26891
26892 !! end
26893
26894 !! test
26895 Tables: 4e. Escape }
26896 !! options
26897 parsoid=html2wt
26898 !! html/parsoid
26899 <table>
26900 <tr><td>}</td></tr>
26901 <tr><td>x</td><td data-parsoid='{"stx":"row"}'>}</td></tr></table>
26902 </table>
26903 !! wikitext
26904 {|
26905 |<nowiki>}</nowiki>
26906 |-
26907 |x||}
26908 |}
26909 !! html/php
26910 <table>
26911 <tr>
26912 <td>}
26913 </td></tr>
26914 <tr>
26915 <td>x</td>
26916 <td>}
26917 </td></tr></table>
26918
26919 !! end
26920
26921 !! test
26922 Tables: 5. Empty table cells should get whitespace to avoid need for nowikis
26923 !! options
26924 parsoid=html2wt
26925 !! html/parsoid
26926 <table><tr><td></td><td align="center" data-parsoid='{"stx":"row"}'></td><td data-parsoid='{"stx":"row"}'></td></tr></table>
26927
26928 <table><tr><td></td><td align="center"></td><td></td></tr></table>
26929
26930 <table><tr><td></td><td align="center" data-parsoid='{"stx":"row", "startTagSrc":"{{!}}{{!}}"}'></td><td data-parsoid='{"stx":"row"}'></td></tr></table>
26931
26932 <table><tr><th></th><th align="center" data-parsoid='{"stx":"row"}'></th><th data-parsoid='{"stx":"row"}'></th></tr></table>
26933 !! wikitext
26934 {|
26935 | || align="center" | ||
26936 |}
26937
26938 {|
26939 |
26940 | align="center" |
26941 |
26942 |}
26943
26944 {|
26945 | {{!}}{{!}} align="center" | ||
26946 |}
26947
26948 {|
26949 ! !! align="center" | !!
26950 |}
26951 !! html/php+tidy
26952 <table>
26953 <tbody><tr>
26954 <td></td>
26955 <td align="center"></td>
26956 <td>
26957 </td></tr></tbody></table>
26958 <table>
26959 <tbody><tr>
26960 <td>
26961 </td>
26962 <td align="center">
26963 </td>
26964 <td>
26965 </td></tr></tbody></table>
26966 <table>
26967 <tbody><tr>
26968 <td></td>
26969 <td align="center"></td>
26970 <td>
26971 </td></tr></tbody></table>
26972 <table>
26973 <tbody><tr>
26974 <th></th>
26975 <th align="center"></th>
26976 <th>
26977 </th></tr></tbody></table>
26978 !! end
26979
26980 !! test
26981 T97430: Don't emit empty nowiki pairs around marker meta tags
26982 !! options
26983 parsoid=html2wt
26984 !! html/parsoid
26985 <p>*This is a long sentence here that will make the nowiki algo split up the nowikis into multiple pairs
26986 |** Make this another long long long sentence forcing the nowiki algo to split up the nowikis.</p>
26987 !! wikitext
26988 <nowiki>*</nowiki>This is a long sentence here that will make the nowiki algo split up the nowikis into multiple pairs
26989 |** Make this another long long long sentence forcing the nowiki algo to split up the nowikis.
26990 !! end
26991
26992 !! test
26993 Unclosed xmlish element in table line shouldn't eat end delimiters
26994 !! options
26995 parsoid=html2wt
26996 !! html/parsoid
26997 <table>
26998 <tbody><tr><td> &lt;foo</td>
26999 <td> bar></td></tr>
27000 </tbody></table>
27001 !! wikitext
27002 {|
27003 | <foo
27004 | bar>
27005 |}
27006 !! html/php
27007 <table>
27008 <tr>
27009 <td>&lt;foo
27010 </td>
27011 <td>bar&gt;
27012 </td></tr></table>
27013
27014 !! end
27015
27016 #### --------------- Links ----------------
27017 #### 1. Quote marks in link text
27018 #### 2. Wikilinks: Escapes needed
27019 #### 3. Wikilinks: No escapes needed
27020 #### 4. Extlinks: Escapes needed
27021 #### 5. Extlinks: No escapes needed
27022 #### --------------------------------------
27023 !! test
27024 Links 1. WikiLinks: No escapes needed
27025 !! options
27026 parsoid=html2wt
27027 !! html/parsoid
27028 <p><a rel="mw:WikiLink" href="Foo" title="Foo">Foo<i>boo</i></a>
27029 <a rel="mw:WikiLink" href="Foo" title="Foo">[Foobar]</a>
27030 <a rel="mw:WikiLink" href="Foo" title="Foo">x [Foobar] x</a></p>
27031 !! wikitext
27032 [[Foo|Foo''boo'']]
27033 [[Foo|[Foobar]]]
27034 [[Foo|x [Foobar] x]]
27035 !! html/php
27036 <p><a href="/wiki/Foo" title="Foo">Foo<i>boo</i></a>
27037 <a href="/wiki/Foo" title="Foo">[Foobar]</a>
27038 <a href="/wiki/Foo" title="Foo">x [Foobar] x</a>
27039 </p>
27040 !! end
27041
27042 !! test
27043 Links 2. WikiLinks: Escapes needed
27044 !! options
27045 parsoid=html2wt
27046 !! html/parsoid
27047 <a href="Foo" rel="mw:WikiLink">Foobar]</a>
27048 <a href="Foo" rel="mw:WikiLink">x [http://google.com g] x</a>
27049 <a href="Foo" rel="mw:WikiLink">[[Bar]]</a>
27050 <a href="Foo" rel="mw:WikiLink">x [[Bar]] x</a>
27051 <a href="Foo" rel="mw:WikiLink">|Bar</a>
27052 <a href="Foo" rel="mw:WikiLink">]]bar</a>
27053 <a href="Foo" rel="mw:WikiLink">[[bar</a>
27054 <a href="Foo" rel="mw:WikiLink">x [[ y</a>
27055 <a href="Foo" rel="mw:WikiLink">x ]] y</a>
27056 <a href="Foo" rel="mw:WikiLink">x ]] y [[ z</a>
27057 !! wikitext
27058 [[Foo|<nowiki>Foobar]</nowiki>]]
27059 [[Foo|x <nowiki>[http://google.com g]</nowiki> x]]
27060 [[Foo|<nowiki>[[Bar]]</nowiki>]]
27061 [[Foo|<nowiki>x [[Bar]] x</nowiki>]]
27062 [[Foo|<nowiki>|Bar</nowiki>]]
27063 [[Foo|<nowiki>]]bar</nowiki>]]
27064 [[Foo|<nowiki>[[bar</nowiki>]]
27065 [[Foo|<nowiki>x [[ y</nowiki>]]
27066 [[Foo|<nowiki>x ]] y</nowiki>]]
27067 [[Foo|<nowiki>x ]] y [[ z</nowiki>]]
27068 !! html/php
27069 <p><a href="/wiki/Foo" title="Foo">Foobar]</a>
27070 <a href="/wiki/Foo" title="Foo">x [http://google.com g] x</a>
27071 <a href="/wiki/Foo" title="Foo">[[Bar]]</a>
27072 <a href="/wiki/Foo" title="Foo">x [[Bar]] x</a>
27073 <a href="/wiki/Foo" title="Foo">|Bar</a>
27074 <a href="/wiki/Foo" title="Foo">]]bar</a>
27075 <a href="/wiki/Foo" title="Foo">[[bar</a>
27076 <a href="/wiki/Foo" title="Foo">x [[ y</a>
27077 <a href="/wiki/Foo" title="Foo">x ]] y</a>
27078 <a href="/wiki/Foo" title="Foo">x ]] y [[ z</a>
27079 </p>
27080 !! end
27081
27082 !! test
27083 Links 3. WikiLinks: No escapes needed
27084 !! options
27085 parsoid=html2wt
27086 !! html/parsoid
27087 <p><a rel="mw:WikiLink" href="Foo">[Foobar</a>
27088 <a rel="mw:WikiLink" href="Foo" title="Foo">foo|bar</a></p>
27089 !! wikitext
27090 [[Foo|[Foobar]]
27091 [[Foo|foo|bar]]
27092 !! html/php
27093 <p><a href="/wiki/Foo" title="Foo">[Foobar</a>
27094 <a href="/wiki/Foo" title="Foo">foo|bar</a>
27095 </p>
27096 !! end
27097
27098 !! test
27099 Links 4. ExtLinks: Escapes needed
27100 !! options
27101 parsoid=html2wt
27102 !! html/parsoid
27103 <p><a rel="mw:ExtLink" href="http://google.com">[google]</a>
27104 <a rel="mw:ExtLink" href="http://google.com">google]</a>
27105 <a rel="mw:ExtLink" href="http://google.com">goog] le</a></p>
27106 <p>[http://google.com]</p>
27107 <p>[http://google.com google]</p>
27108 <p>[<a rel="mw:ExtLink" href="http://google.com">http://google.com</a>]</p>
27109 <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>
27110 !! wikitext
27111 [http://google.com <nowiki>[google]</nowiki>]
27112 [http://google.com <nowiki>google]</nowiki>]
27113 [http://google.com <nowiki>goog] le</nowiki>]
27114
27115 <nowiki>[http://google.com]</nowiki>
27116
27117 <nowiki>[http://google.com google]</nowiki>
27118
27119 [http://google.com<nowiki>]</nowiki>
27120
27121 [{{echo|http://google.com}}<nowiki>]</nowiki>
27122 !! html/php
27123 <p><a rel="nofollow" class="external text" href="http://google.com">[google]</a>
27124 <a rel="nofollow" class="external text" href="http://google.com">google]</a>
27125 <a rel="nofollow" class="external text" href="http://google.com">goog] le</a>
27126 </p><p>[http://google.com]
27127 </p><p>[http://google.com google]
27128 </p><p>[<a rel="nofollow" class="external free" href="http://google.com">http://google.com</a>]
27129 </p><p>[<a rel="nofollow" class="external free" href="http://google.com">http://google.com</a>]
27130 </p>
27131 !! end
27132
27133 !! test
27134 Links 5. ExtLinks: No escapes needed
27135 !! options
27136 parsoid=html2wt
27137 !! html/parsoid
27138 <p><a rel="mw:ExtLink" href="http://google.com">[google</a></p>
27139 <p>[<a ref="mw:ExtLink" href="http://google.com"></a>]</p>
27140 !! wikitext
27141 [http://google.com [google]
27142
27143 [[http://google.com]]
27144 !! html/php
27145 <p><a rel="nofollow" class="external text" href="http://google.com">[google</a>
27146 </p><p>[<a rel="nofollow" class="external autonumber" href="http://google.com">[1]</a>]
27147 </p>
27148 !! end
27149
27150 !! test
27151 Links 6. Add <nowiki/>s between text-nodes and url-links when required (T66300)
27152 !! options
27153 parsoid=html2wt
27154 !! html/parsoid
27155 <p>x<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>y
27156 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>?x
27157 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>&amp;x
27158 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>'x
27159 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>,x
27160 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>.x
27161 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>;x
27162 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>:x
27163 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>;x
27164 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>!x
27165 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>=x
27166 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>(x)
27167 <a rel="mw:ExtLink" href="http://example.com(x" data-parsoid='{"stx":"url"}'>http://example.com(x</a>)
27168 </p>
27169 !! wikitext
27170 x<nowiki/>http://example.com<nowiki/>y
27171 http://example.com<nowiki/>?x
27172 http://example.com<nowiki/>&x
27173 http://example.com<nowiki/>'x
27174 http://example.com<nowiki/>,x
27175 http://example.com<nowiki/>.x
27176 http://example.com<nowiki/>;x
27177 http://example.com<nowiki/>:x
27178 http://example.com<nowiki/>;x
27179 http://example.com<nowiki/>!x
27180 http://example.com<nowiki/>=x
27181 http://example.com<nowiki/>(x)
27182 http://example.com(x<nowiki/>)
27183 !! end
27184
27185 !! test
27186 Links 7a. Don't add spurious <nowiki/>s between text-nodes and url-links (T66300)
27187 !! options
27188 parsoid=html2wt
27189 !! html/parsoid
27190 <p>x
27191 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>
27192 y
27193 "<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>"
27194 (<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>)
27195 (<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>) foo
27196 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>,
27197 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>, foo
27198 </p>
27199 !! wikitext
27200 x
27201 http://example.com
27202 y
27203 "http://example.com"
27204 (http://example.com)
27205 (http://example.com) foo
27206 http://example.com,
27207 http://example.com, foo
27208 !! html/php
27209 <p>x
27210 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
27211 y
27212 "<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>"
27213 (<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
27214 (<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>) foo
27215 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>,
27216 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>, foo
27217 </p>
27218 !! end
27219
27220 !! test
27221 Links 7b. Don't add spurious <nowiki/>s between text-nodes and url-links (T66300)
27222 !! options
27223 parsoid=html2wt
27224 !! html/parsoid
27225 <p><a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>.,;:!?\
27226 -<a rel="mw:ExtLink" href="http://example.com">http://example.com</a>:</p>
27227 !! wikitext
27228 http://example.com.,;:!?\
27229 -http://example.com:
27230 !! html/php
27231 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>.,;:!?\
27232 -<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>:
27233 </p>
27234 !! end
27235
27236 !! test
27237 Links 8. Add <nowiki/>s between text-nodes and RFC-links when required (T66300)
27238 !! options
27239 parsoid=html2wt
27240 !! html/parsoid
27241 <p><a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>4
27242 <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y
27243 X<a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y</p>
27244 !! wikitext
27245 RFC 123<nowiki/>4
27246 RFC 123<nowiki/>y
27247 X<nowiki/>RFC 123<nowiki/>y
27248 !! end
27249
27250 !! test
27251 Links 9. Don't add spurious <nowiki/>s between text-nodes and RFC-links (T66300)
27252 !! options
27253 parsoid=html2wt
27254 !! html/parsoid
27255 <p><a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>?foo
27256 <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>&amp;foo
27257 -<a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>-
27258 </p>
27259 !! wikitext
27260 RFC 123?foo
27261 RFC 123&foo
27262 -RFC 123-
27263 !! html/php
27264 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>?foo
27265 <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>&amp;foo
27266 -<a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>-
27267 </p>
27268 !! end
27269
27270 !! test
27271 Links 10. Add <nowiki/>s between text-nodes and PMID-links when required (T66300)
27272 !! options
27273 parsoid=html2wt
27274 !! html/parsoid
27275 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>4
27276 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>y
27277 X<a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>y
27278 !! wikitext
27279 PMID 123<nowiki/>4
27280 PMID 123<nowiki/>y
27281 X<nowiki/>PMID 123<nowiki/>y
27282 !! end
27283
27284 !! test
27285 Links 11. Don't add spurious <nowiki/>s between text-nodes and PMID-links (T66300)
27286 !! options
27287 parsoid=html2wt
27288 !! html/parsoid
27289 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>?foo
27290 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>&foo
27291 -<a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>-
27292 </p>
27293 !! wikitext
27294 PMID 123?foo
27295 PMID 123&foo
27296 -PMID 123-
27297 !! html/php
27298 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>?foo
27299 <a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>&amp;foo
27300 -<a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>-
27301 </p>
27302 !! end
27303
27304 !! test
27305 Links 12. Add <nowiki/>s between text-nodes and ISBN-links when required (T66300)
27306 !! options
27307 parsoid=html2wt
27308 !! html/parsoid
27309 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>1
27310 <a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>x
27311 a<a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>b
27312 </p>
27313 !! wikitext
27314 ISBN 1234567890<nowiki/>1
27315 ISBN 1234567890<nowiki/>x
27316 a<nowiki/>ISBN 1234567890<nowiki/>b
27317 !! end
27318
27319 !! test
27320 Links 13. Don't add spurious <nowiki/>s between text-nodes and ISBN-links (T66300)
27321 !! options
27322 parsoid=html2wt
27323 !! html/parsoid
27324 <p>-<a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>'s
27325 !! wikitext
27326 -ISBN 1234567890's
27327 !! html/php
27328 <p>-<a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>'s
27329 </p>
27330 !! end
27331
27332 !! test
27333 Links 14. Protect link-like plain text. (Parsoid bug T78425)
27334 !! options
27335 parsoid=html2wt
27336 !! html/*
27337 <p>this is not a link: http://example.com
27338 </p>
27339 !! wikitext
27340 this is not a link: <nowiki>http://example.com</nowiki>
27341 !! end
27342
27343 !! test
27344 Links 15. Link trails can't become link prefixes.
27345 !! options
27346 language=is
27347 parsoid=html2wt
27348 !! html/parsoid
27349 <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>
27350 !! wikitext
27351 [[Söfnuður]]-[[00]]
27352 !! html/php
27353 <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>
27354 </p>
27355 !! end
27356
27357 #### --------------- Quotes ---------------
27358 #### 1. Quotes inside <b> and <i>
27359 #### 2. Link fragments separated by <i> and <b> tags
27360 #### 3. Link fragments inside <i> and <b>
27361 #### 4. No escaping needed
27362 #### --------------------------------------
27363 !! test
27364 1a. Quotes inside <b> and <i>
27365 !! options
27366 parsoid=html2wt
27367 !! html/*
27368 <p><i>'foo'</i>
27369 <i>''foo''</i>
27370 <i>'''foo'''</i>
27371 <i>foo</i>'s
27372 <b>'foo'</b>
27373 <b>''foo''</b>
27374 <b>'''foo'''</b>
27375 <b>foo'<i>bar'</i>baz</b>
27376 <b>foo</b>'s
27377 '<i>foo</i>
27378 <i>foo</i>'
27379 <i>foo'</i>'
27380 '<i>foo</i>'
27381 '<b>foo</b>
27382 <b>foo</b>'
27383 '<b>foo</b>'
27384 <i>fools'<span> errand</span></i>
27385 <i><span>fool</span>'s errand</i>
27386 '<i>foo</i> bar '<i>baz</i>
27387 a|!*#-:;+-~[]{}b'<i>x</i>
27388 </p>
27389 !! wikitext
27390 ''<nowiki/>'foo'''
27391 ''<nowiki>''foo''</nowiki>''
27392 ''<nowiki>'''foo'''</nowiki>''
27393 ''foo''<nowiki/>'s
27394 '''<nowiki/>'foo''''
27395 '''<nowiki>''foo''</nowiki>'''
27396 '''<nowiki>'''foo'''</nowiki>'''
27397 '''foo'<nowiki/>''bar'<nowiki/>''baz'''
27398 '''foo'''<nowiki/>'s
27399 '''foo''
27400 ''foo''<nowiki/>'
27401 ''foo'''<nowiki/>'
27402 '''foo''<nowiki/>'
27403 ''''foo'''
27404 '''foo'''<nowiki/>'
27405 ''''foo'''<nowiki/>'
27406 ''fools'<span> errand</span>''
27407 ''<span>fool</span>'s errand''
27408 '<nowiki/>''foo'' bar '''baz''
27409 a|!*#-:;+-~[]{}b'''x''
27410 !! end
27411
27412 !! test
27413 1b. Quotes inside <b> and <i> with other tags on same line
27414 !! options
27415 parsoid=html2wt
27416 !! html/parsoid
27417 '<i>a</i> foo <i><a rel="mw:WikiLink" href="Bar" title="Bar">bar</a></i>
27418 <i>a'</i> foo <i><a rel="mw:WikiLink" href="Bar" title="Bar">bar</a></i>
27419 <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>
27420 <a rel="mw:WikiLink" href="Foo" title="Foo">foo</a> x'<i><a href="Bar" rel="mw:WikiLink" title="Bar">bar</a></i>
27421 '<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>
27422 '<i>foo</i> <div title="name">test</div>
27423 '<i>foo</i> and <br data-parsoid='{"stx":"html","noClose":true}'/> bar
27424 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt5" data-mw='{"name":"references","attrs":{}}'>
27425 <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>
27426 </ol>
27427 !! wikitext
27428 '''a'' foo ''[[bar]]''
27429 ''a''' foo ''[[bar]]''
27430 ''a''' foo '''{{echo|[[bar]]}}'''
27431 [[foo]] x'''[[bar]]''
27432 '''foo'' <ref>test</ref>
27433 '''foo'' <div title="name">test</div>
27434 '''foo'' and <br> bar
27435 <references />
27436 !! end
27437
27438 !! test
27439 2. Link fragments separated by <i> and <b> tags
27440 !! options
27441 parsoid=html2wt
27442 !! html/parsoid
27443 <p>[[<i>foo</i>hello]]</p>
27444 <p>[[<b>foo</b>hello]]</p>
27445 !! wikitext
27446 [[''foo''<nowiki>hello]]</nowiki>
27447
27448 [['''foo'''<nowiki>hello]]</nowiki>
27449 !! end
27450
27451 # FIXME: Escaping one or both of [[ and ]] is also acceptable --
27452 # this is one of the shortcomings of this format
27453 !! test
27454 3. Link fragments inside <i> and <b>
27455 !! options
27456 parsoid=html2wt
27457 !! html/parsoid
27458 <p><i>[[foo</i>]]</p>
27459 <p><b>[[foo</b>]]</p>
27460 !! wikitext
27461 ''[[foo''<nowiki>]]</nowiki>
27462
27463 '''[[foo'''<nowiki>]]</nowiki>
27464 !! end
27465
27466 !! test
27467 4. No escaping needed
27468 !! options
27469 parsoid=html2wt
27470 !! html/parsoid
27471 <p>'<span><i>bar</i></span>'
27472 '<span><b>bar</b></span>'
27473 'a:b'foo
27474 </p>
27475 !! wikitext
27476 '<span>''bar''</span>'
27477 '<span>'''bar'''</span>'
27478 'a:b'foo
27479 !! end
27480
27481 #### ----------- Paragraphs ---------------
27482 #### 1. No unnecessary escapes
27483 #### --------------------------------------
27484
27485 !! test
27486 1. No unnecessary escapes
27487 !! options
27488 parsoid=html2wt
27489 !! html/parsoid
27490 <p>bar <span>[[foo]]</span>
27491 </p><p>=bar <span>[[foo]]</span>
27492 </p><p>[[bar <span>[[foo]]</span>
27493 </p><p>]]bar <span>[[foo]]</span>
27494 </p><p>=bar <span>foo]]</span>=
27495 </p>
27496 !! wikitext
27497 bar <span><nowiki>[[foo]]</nowiki></span>
27498
27499 =bar <span><nowiki>[[foo]]</nowiki></span>
27500
27501 [[bar <span><nowiki>[[foo]]</nowiki></span>
27502
27503 ]]bar <span><nowiki>[[foo]]</nowiki></span>
27504
27505 =bar <span>foo]]</span><nowiki>=</nowiki>
27506 !!end
27507
27508 #### ----------------------- PRE --------------------------
27509 !! test
27510 1. Leading whitespace in SOL context should be escaped
27511 !! options
27512 parsoid=html2wt
27513 !! html/parsoid
27514 <p> a</p>
27515
27516 <p> a</p>
27517
27518 <p> a(tab)</p>
27519
27520 <p> a
27521 <!--cmt-->
27522 a</p>
27523
27524 <p>a
27525 b</p>
27526
27527 <p>a
27528 b</p>
27529
27530 <p>a
27531 b</p>
27532 !! wikitext
27533 <nowiki> </nowiki>a
27534
27535 <nowiki> </nowiki> a
27536
27537 a(tab)
27538
27539 <nowiki> </nowiki> a
27540 <!--cmt-->
27541 <nowiki> </nowiki>a
27542
27543 a
27544 <nowiki> </nowiki>b
27545
27546 a
27547 b
27548
27549 a
27550 b
27551 !! html/php
27552 <p> a
27553 </p><p> a
27554 </p><p> a(tab)
27555 </p><p> a
27556 a
27557 </p><p>a
27558 b
27559 </p><p>a
27560 b
27561 </p><p>a
27562 b
27563 </p>
27564 !! end
27565
27566 !! test
27567 2. Leading whitespace in non-indent-pre contexts should not be escaped
27568 !! options
27569 parsoid=html2wt
27570 !! html/parsoid
27571 <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>
27572 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt4" data-mw='{"name":"references","attrs":{}}'>
27573 <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>
27574 b</span></li>
27575 </ol>
27576 !! wikitext
27577 foo <ref>''a''
27578 b</ref>
27579 <references />
27580 !! end
27581
27582 !! test
27583 3. Leading whitespace in indent-pre suppressing contexts should not be escaped
27584 !! options
27585 parsoid=html2wt
27586 !! html/parsoid
27587 <blockquote>
27588 <p>
27589 a
27590 <span>b</span>
27591 c</p>
27592 </blockquote>
27593 !! wikitext
27594 <blockquote>
27595 a
27596 <span>b</span>
27597 c
27598 </blockquote>
27599 !! end
27600
27601 !! test
27602 4. Leading whitespace in indent-pre suppressing contexts should not be escaped
27603 !! options
27604 parsoid=html2wt
27605 !! html/parsoid
27606 <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>
27607 !! wikitext
27608 [[File:Foobar.jpg|thumb|caption]]
27609 !! end
27610
27611 !! test
27612 5. Nowiki escaping should account for indent-pres
27613 !! options
27614 parsoid=html2wt
27615 !! html/parsoid
27616 <pre>==foo==</pre>
27617 !! wikitext
27618 ==foo==
27619 !! end
27620
27621 !! test
27622 T95794: nowiki escaping should account for leading space at start-of-line in an indent-pre block
27623 !! options
27624 parsoid=html2wt
27625 !! html/parsoid
27626 <pre>
27627 * foo
27628 * bar
27629 </pre>
27630 !! wikitext
27631 * foo
27632 * bar
27633 !! end
27634
27635 !! test
27636 Whitespace scrubbing in SOL position should account for SOL-sensitive wikitext markup
27637 !! options
27638 parsoid = {
27639 "modes": ["html2wt"],
27640 "scrubWikitext": true
27641 }
27642 !! html/parsoid
27643 <p> foo</p>
27644 <p> %foo</p>
27645 <p> *foo</p>
27646 <p> #foo</p>
27647 <p> =foo=</p>
27648 <p><link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid="{}"> *foo</p>
27649 <p> <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid="{}">*foo</p>
27650 <p> <!--boo-->*foo</p>
27651 <p><!--boo--> *foo</p>
27652 <p><!--a--> <!--b--> <!--c--> <!--d--> <!--e--> foo</p>
27653 <p><!--a--> <!--b--> <!--c--> <!--d--> <!--e--> *foo</p>
27654 !! wikitext
27655 foo
27656
27657 %foo
27658
27659 <nowiki/>*foo
27660
27661 <nowiki/>#foo
27662
27663 <nowiki/>=foo=
27664
27665 [[Category:Foo]]
27666 <nowiki/>*foo
27667
27668 [[Category:Foo]]
27669 <nowiki>*</nowiki>foo
27670
27671 <nowiki/><!--boo-->*foo
27672
27673 <!--boo--><nowiki/>*foo
27674
27675 <!--a--><!--b--><!--c--><!--d--><!--e-->foo
27676
27677 <!--a--><nowiki/><!--b--><!--c--><!--d--><!--e-->*foo
27678 !! end
27679
27680 #### --------------- Behavior Switches --------------------
27681
27682 !! test
27683 1. Valid behavior switches should be escaped
27684 !! options
27685 parsoid=html2wt
27686 !! html/parsoid
27687 __TOC__
27688 <i>__TOC__</i>
27689 !! wikitext
27690 <nowiki>__TOC__</nowiki>
27691 ''<nowiki>__TOC__</nowiki>''
27692 !! end
27693
27694 !! test
27695 2. Invalid behavior switches should not be escaped
27696 !! options
27697 parsoid=html2wt
27698 !! html/parsoid
27699 __TOO__
27700 __|__
27701 !! wikitext
27702 __TOO__
27703 __|__
27704 !! end
27705
27706 # We use indent-pre as an indirect way to test for sol-transparent behavior.
27707 !! test
27708 Behavior switches should be SOL-transparent
27709 !! options
27710 parsoid=html2wt
27711 !! html/parsoid
27712 <meta property="mw:PageProp/toc" />
27713
27714 <!-- this one's bogus -->
27715 <pre>__TOO__</pre>
27716
27717 <pre data-parsoid='{}'><meta property="mw:PageProp/toc" data-parsoid='{"src":"__TOC__","magicSrc":"__TOC__"}'/> foo</pre>
27718
27719 <meta property="mw:PageProp/toc" data-parsoid='{"src":"__TOC__","magicSrc":"__TOC__"}'/><pre data-parsoid='{}'>bar</pre>
27720 !! wikitext
27721 __TOC__
27722
27723 <!-- this one's bogus -->
27724 __TOO__
27725
27726 __TOC__ foo
27727
27728 __TOC__
27729 bar
27730 !! end
27731
27732 #### --------------- HTML tags ---------------
27733 #### 1. a tags
27734 #### 2. other tags
27735 #### 3. multi-line html tag
27736 #### 4. extension tags
27737 #### -----------------------------------------
27738 !! test
27739 1. a tags
27740 !! options
27741 parsoid=html2wt
27742 !! html/parsoid
27743 &lt;a href=&quot;http://google.com&quot;&gt;google&lt;/a&gt;
27744 !! wikitext
27745 <a href="http://google.com">google</a>
27746 !! end
27747
27748 !! test
27749 2. other tags
27750 !! options
27751 parsoid=html2wt
27752 !! html/parsoid
27753 <ul><li> &lt;div&gt;foo&lt;/div&gt;</li>
27754 <li> &lt;div style=&quot;color:red&quot;&gt;foo&lt;/div&gt;</li>
27755 <li> &lt;td&gt;</li></ul>
27756
27757 !! wikitext
27758 * <nowiki><div>foo</div></nowiki>
27759 * <nowiki><div style="color:red">foo</div></nowiki>
27760 * <nowiki><td></nowiki>
27761 !! end
27762
27763 !! test
27764 3. multi-line html tag
27765 !! options
27766 parsoid=html2wt
27767 !! html/parsoid
27768 <p>&lt;div
27769 &gt;foo&lt;/div
27770 &gt;
27771 </p>
27772 !! wikitext
27773 <nowiki><div
27774 >foo</div
27775 ></nowiki>
27776 !! end
27777
27778 !! test
27779 4. extension tags
27780 !! options
27781 parsoid=html2wt
27782 !! html/parsoid
27783 <p>&lt;ref&gt;foo&lt;/ref&gt;
27784 </p><p>&lt;ref&gt;bar
27785 </p><p>baz&lt;/ref&gt;
27786 </p>
27787 !! wikitext
27788 <nowiki><ref>foo</ref></nowiki>
27789
27790 <nowiki><ref>bar</nowiki>
27791
27792 baz<nowiki></ref></nowiki>
27793 !! end
27794
27795 !! test
27796 Parsoid: newline inducing block nodes don't suppress <nowiki>
27797 !! options
27798 parsoid=html2wt
27799 !! html/parsoid
27800 a<h1>foo</h1>
27801 !! wikitext
27802 <nowiki> </nowiki>a
27803
27804 = foo =
27805 !! end
27806
27807 #### --------------- Others ---------------
27808 !! test
27809 Escaping nowikis
27810 !! options
27811 parsoid=html2wt
27812 !! html/parsoid
27813 <p>&lt;nowiki&gt;foo&lt;/nowiki&gt;
27814 </p>
27815 !! wikitext
27816 &lt;nowiki&gt;foo&lt;/nowiki&gt;
27817 !! end
27818
27819 ## The quote-char in the input is necessary for triggering the bug
27820 !! test
27821 (T54035) Nowiki-escaping should not get tripped by " :" in text
27822 !! options
27823 parsoid=html2wt
27824 !! html/parsoid
27825 <p>foo's bar :</p>
27826 !! wikitext
27827 foo's bar :
27828 !! end
27829
27830 #----------- End of wikitext escaping tests --------------
27831
27832 !! test
27833
27834 Tag-like HTML structures are passed through as text
27835 !! wikitext
27836 <x y>
27837
27838 <x.y>
27839
27840 <x-y>
27841
27842 1>2
27843
27844 x<y
27845
27846 a>b
27847
27848 1<d e>f
27849 !! html
27850 <p>&lt;x y&gt;
27851 </p><p>&lt;x.y&gt;
27852 </p><p>&lt;x-y&gt;
27853 </p><p>1&gt;2
27854 </p><p>x&lt;y
27855 </p><p>a&gt;b
27856 </p><p>1&lt;d e&gt;f
27857 </p>
27858 !! end
27859
27860 !! test
27861 HTML tag with necessary entities in attributes
27862 !! wikitext
27863 <span title="&amp;amp;">foo</span>
27864 !! html
27865 <p><span title="&amp;amp;">foo</span>
27866 </p>
27867 !! end
27868
27869 !! test
27870 HTML tag with 'unnecessary' entity encoding in attributes
27871 !! wikitext
27872 <span title="&amp;">foo</span>
27873 !! html
27874 <p><span title="&amp;">foo</span>
27875 </p>
27876 !! end
27877
27878 !! test
27879 HTML tag with broken attribute value quoting
27880 !! options
27881 parsoid=wt2html,html2html
27882 !! wikitext
27883 <span title="Hello world>Foo</span>
27884 !! html/php
27885 <p><span title="Hello world">Foo</span>
27886 </p>
27887 !! html/parsoid
27888 <p><span title="Hello world">Foo</span></p>
27889 !! end
27890
27891 !! test
27892 Self-closed tag with broken attribute value quoting
27893 !! options
27894 parsoid=wt2html,html2html
27895 !! wikitext
27896 <div title="Hello world />Foo
27897 !! html/php+tidy
27898 <div title="Hello world"></div><p>Foo
27899 </p>
27900 !! html/parsoid
27901 <div title="Hello world " data-parsoid='{"stx":"html","selfClose":true}'></div><p>Foo</p>
27902 !! end
27903
27904 !! test
27905 Table with broken attribute value quoting
27906 !! options
27907 parsoid=wt2html,html2html
27908 !! wikitext
27909 {|
27910 | title="Hello world|Foo
27911 |}
27912 !! html/php
27913 <table>
27914 <tr>
27915 <td title="Hello world">Foo
27916 </td></tr></table>
27917
27918 !! html/parsoid
27919 <table>
27920 <tr>
27921 <td title="Hello world">Foo
27922 </td></tr></table>
27923
27924 !! end
27925
27926 !! test
27927 Table with broken attribute value quoting on consecutive lines
27928 !! options
27929 parsoid=wt2html,html2html
27930 !! wikitext
27931 {|
27932 | title="Hello world|Foo
27933 | style="color:red|Bar
27934 |}
27935 !! html/php
27936 <table>
27937 <tr>
27938 <td title="Hello world">Foo
27939 </td>
27940 <td style="color:red">Bar
27941 </td></tr></table>
27942
27943 !! html/parsoid
27944 <table><tbody>
27945 <tr>
27946 <td title="Hello world">Foo
27947 </td><td style="color: red">Bar
27948 </td></tr></tbody></table>
27949
27950 !! end
27951
27952 !!test
27953 Accept empty td cell attribute
27954 !! wikitext
27955 {|
27956 | align="center" |foo|| |
27957 |}
27958 !! html
27959 <table>
27960 <tr>
27961 <td align="center">foo</td>
27962 <td>
27963 </td></tr></table>
27964
27965 !!end
27966
27967 !!test
27968 Non-empty attributes in th-cells
27969 !! wikitext
27970 {|
27971 !Foo!! style="color: red" |Bar
27972 |}
27973 !! html
27974 <table>
27975 <tr>
27976 <th>Foo</th>
27977 <th style="color: red">Bar
27978 </th></tr></table>
27979
27980 !!end
27981
27982 !!test
27983 Accept empty attributes in th-cells
27984 !! wikitext
27985 {|
27986 !|foo!!|bar
27987 |}
27988 !! html
27989 <table>
27990 <tr>
27991 <th>foo</th>
27992 <th>bar
27993 </th></tr></table>
27994
27995 !!end
27996
27997 !!test
27998 Empty table rows go away
27999 !! wikitext
28000 {|
28001 |Hello
28002 |there
28003 |- class="foo"
28004 |-
28005 |}
28006 !! html
28007 <table>
28008 <tr>
28009 <td>Hello
28010 </td>
28011 <td>there
28012 </td></tr>
28013
28014 </table>
28015
28016 !! end
28017
28018 ###
28019 ### Parsoid-centric tests for testing RTing of inter-element separators
28020 ### Edge cases not tested by existing parser tests and specific to
28021 ### Parsoid-specific serialization strategies.
28022 ###
28023
28024 !!test
28025 RT-ed inter-element separators should be valid separators
28026 !! wikitext
28027 {|
28028 |- [[foo]]
28029 |}
28030 !! html/php
28031 <table>
28032
28033 </table>
28034
28035 !! html/parsoid
28036 <table>
28037 <tbody><tr class='mw-empty-elt' data-parsoid='{"startTagSrc":"|-","a":{"[[foo]]":null},"sa":{"[[foo]]":""},"autoInsertedEnd":true}'></tr>
28038 </tbody></table>
28039 !!end
28040
28041 # Parsoid-only test of a DOM pass
28042 !!test
28043 Trailing newlines in a deep dom-subtree that ends a wikitext line should be migrated out
28044 !! wikitext
28045 {|
28046 |<small>foo
28047 bar
28048 |}
28049
28050 {|
28051 |<small>foo<small>
28052 |}
28053 !! html/parsoid
28054 <table>
28055 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'><small data-parsoid='{"stx":"html","autoInsertedEnd":true}'>foo
28056 <p>bar</p></small></td></tr>
28057 </tbody></table>
28058
28059 <table>
28060 <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>
28061 </tbody></table>
28062 !!end
28063
28064 # Note that the "style" attribute is really a template parameter here.
28065 # The = would have to be {{=}} if you wanted the literal.
28066 !!test
28067 Empty TD followed by TD with tpl-generated attribute
28068 !! wikitext
28069 {|
28070 |-
28071 |
28072 |{{echo|style='color:red'}}|foo
28073 |}
28074 !! html
28075 <table>
28076
28077 <tr>
28078 <td>
28079 </td>
28080 <td>foo
28081 </td></tr></table>
28082
28083 !!end
28084
28085 !!test
28086 Indented table with an empty td
28087 !! wikitext
28088 {|
28089 |-
28090 |
28091 |foo
28092 |}
28093 !! html
28094 <table>
28095
28096 <tr>
28097 <td>
28098 </td>
28099 <td>foo
28100 </td></tr></table>
28101
28102 !!end
28103
28104 !! test
28105 Indented table with blank lines in between (T85627)
28106 !! wikitext
28107 {|
28108 |foo
28109
28110
28111 |}
28112 !! html/php
28113 <table>
28114 <tr>
28115 <td>foo
28116 <p><br />
28117 </p>
28118 </td></tr></table>
28119
28120 !! html/parsoid
28121 <table>
28122 <tbody><tr><td>foo
28123 <p>
28124 <br /></p></td></tr>
28125 </tbody></table>
28126 !! end
28127
28128 !!test
28129 Indented block & table
28130 !! wikitext
28131 <div>foo</div>
28132 {|
28133 |foo
28134 |}
28135 !! html/php
28136 <div>foo</div>
28137 <table>
28138 <tr>
28139 <td>foo
28140 </td></tr></table>
28141
28142 !! html/parsoid
28143 <div data-parsoid='{"stx":"html"}'>foo</div>
28144 <table><tbody>
28145 <tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'>foo</td></tr>
28146 </tbody></table>
28147 !!end
28148
28149 !! test
28150 Indent and comment before table row
28151 !! wikitext
28152 {|
28153 <!--hi-->|-
28154 |there
28155 |}
28156 !! html/php
28157 <table>
28158
28159 <tr>
28160 <td>there
28161 </td></tr></table>
28162
28163 !! html/parsoid
28164 <table>
28165 <!--hi--><tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
28166 <td data-parsoid='{"autoInsertedEnd":true}'> there</td></tr>
28167 </tbody></table>
28168 !! end
28169
28170 # PHP parser omits empty TR
28171 !!test
28172 Empty TR followed by a template-generated TR
28173 !! wikitext
28174 {|
28175 |-
28176 {{echo|<tr><td>foo</td></tr>}}
28177 |}
28178 !! html/php+tidy
28179 <table>
28180
28181 <tbody><tr><td>foo</td></tr>
28182 </tbody></table>
28183 !! html/parsoid
28184 <table>
28185 <tbody>
28186 <tr class='mw-empty-elt'></tr>
28187 <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}}]}'>
28188 <td>foo</td></tr>
28189 </tbody></table>
28190 !!end
28191
28192 ## PHP and parsoid output differ for this; as usual PHP omits empty
28193 ## elements, and since it strips the comments the TR is empty.
28194 !!test
28195 Empty TR followed by mixed-ws-comment line should RT correctly
28196 !! wikitext
28197 {|
28198 |-
28199 <!--c-->
28200 |-
28201 <!--c--> <!--d-->
28202 |}
28203 !! html/php+tidy
28204 <table>
28205
28206
28207 </table>
28208 !! html/parsoid
28209 <table>
28210 <tbody>
28211 <tr class='mw-empty-elt'></tr>
28212 <!--c-->
28213 <tr>
28214 <!--c--> </tr><!--d-->
28215 </tbody></table>
28216
28217 !!end
28218
28219 !!test
28220 Multi-line image caption generated by templates with/without trailing newlines
28221 !! wikitext
28222 [[File:Foobar.jpg|thumb|300x300px|foo\n{{echo|A}}\n{{echo|B}}\n{{echo|C}}]]
28223 [[File:Foobar.jpg|thumb|300x300px|foo\n{{echo|A}}\n{{echo|B}}\n{{echo|C}}\n\n]]
28224 !! html/parsoid
28225 <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>
28226 <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>
28227 !!end
28228
28229 !! test
28230 New element inserted (without intervening newlines) after an old sol-transparent node should serialize correctly
28231 !! options
28232 parsoid=html2wt
28233 !! html/parsoid
28234 <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>
28235
28236 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{}'/><h1>new heading</h1>
28237 !! wikitext
28238 <includeonly>foo</includeonly>
28239 new para
28240
28241 [[Category:Foo]]
28242
28243 = new heading =
28244 !! end
28245
28246 ## PHP emits broken html for this, and since this is primarily
28247 ## a Parsoid serializer test, marking this Parsoid only
28248 !!test
28249 Improperly nested inline or quotes tags with whitespace in between
28250 !! wikitext
28251 <span> <s>x</span> </s>
28252 ''' ''x''' ''
28253 !! html/parsoid
28254 <p><span> <s>x</s></span><s> </s>
28255 <b> <i>x</i></b><i> </i>
28256 </p>
28257 !!end
28258
28259 !!test
28260 Encapsulate protected attributes from wt
28261 !! wikitext
28262 <div typeof="mw:placeholder stuff" data-mw="whoo" data-parsoid="weird" data-parsoid-other="no" about="time" rel="mw:true">foo</div>
28263
28264 {| typeof="mw:placeholder stuff" data-mw="whoo" data-parsoid="weird" data-parsoid-other="no" about="time" rel="mw:true"
28265 |ok
28266 |}
28267 !! html/parsoid
28268 <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>
28269
28270 <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">
28271 <tbody><tr><td data-parsoid='{"autoInsertedEnd":true}'>ok</td></tr>
28272 </tbody></table>
28273 !!end
28274
28275 ## Currently the p-wrapper is fragile in how it adds / removes transformations.
28276 ## Having nested or stray pre tags results in the attempt to add duplicates,
28277 ## causing an assertion fail. This test tries to prevent that situation.
28278 !! test
28279 Ensure ParagraphWrapper can deal with stray closing pre tags
28280 !! options
28281 parsoid=wt2html
28282 !! wikitext
28283 plain text</pre>
28284 !! html/parsoid
28285 <p>plain text</p>
28286 !! end
28287
28288 ## Remex doesn't account for fostered content.
28289 !! test
28290 1. Ensure fostered text content is wrapped in element nodes
28291 !! options
28292 parsoid=wt2html
28293 !! wikitext
28294 <table>hi</table><table>ho</table>
28295 !! html/php+tidy
28296 hi<table></table>ho<table></table>
28297 !! html/parsoid
28298 <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>
28299 !! end
28300
28301 ## Remex doesn't account for fostered content.
28302 !! test
28303 2. Ensure fostered text content is wrapped in element nodes (traps regressions around fostered marker on the element getting lost)
28304 !! options
28305 parsoid=wt2html,wt2wt
28306 !! wikitext
28307 <table>
28308 <tr> || ||
28309 <td> a
28310 </table>
28311 !! html/php+tidy
28312 || ||
28313 <table>
28314 <tbody><tr><td> a
28315 </td></tr></tbody></table>
28316 !! html/parsoid
28317 <p data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true}'> || ||</p>
28318 <table data-parsoid='{"stx":"html"}'>
28319 <tbody><tr data-parsoid='{"stx":"html","autoInsertedEnd":true}'><td data-parsoid='{"stx":"html","autoInsertedEnd":true}'> a
28320 </td></tr></tbody></table>
28321 !! end
28322
28323 ## Remex doesn't account for fostered content.
28324 !! test
28325 Encapsulation properly handles null DSR information from foster box
28326 !! options
28327 parsoid=wt2html,wt2wt
28328 !! wikitext
28329 {{echo|<table>foo<tr><td>bar</td></tr></table>}}
28330 !! html/parsoid
28331 <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>
28332 !! end
28333
28334 ## Remex doesn't account for fostered content.
28335 !! test
28336 1. Encapsulate foster-parented transclusion content
28337 !! options
28338 parsoid=wt2wt,wt2html
28339 !! wikitext
28340 <table>{{echo|foo<tr><td>bar</td></tr>}}</table>
28341 !! html/php+tidy
28342 foo<table><tbody><tr><td>bar</td></tr></tbody></table>
28343 !! html/parsoid
28344 <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>
28345 !! end
28346
28347 !! test
28348 2. Encapsulate foster-parented transclusion content
28349 !! options
28350 parsoid=wt2wt,wt2html
28351 !! wikitext
28352 <table><div>{{echo|foo}}</div><tr><td>bar</td></tr></table>
28353 !! html/parsoid
28354 <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>
28355 <table>
28356 <tbody>
28357 <tr>
28358 <td>bar</td>
28359 </tr>
28360 </tbody>
28361 </table>
28362 !! end
28363
28364 !! test
28365 3. Encapsulate foster-parented transclusion content
28366 !! options
28367 parsoid=wt2wt,wt2html
28368 !! wikitext
28369 <table><div><p>{{echo|foo</p></div><tr><td>}}bar</td></tr></table>
28370 !! html/parsoid
28371 <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;]}">
28372 <p>foo</p>
28373 </div>
28374 <table>
28375 <tbody>
28376 <tr>
28377 <td>bar</td>
28378 </tr>
28379 </tbody>
28380 </table>
28381 !! end
28382
28383 !! test
28384 4. Encapsulate foster-parented transclusion content
28385 !! options
28386 parsoid=wt2wt,wt2html
28387 !! wikitext
28388 <table><div><p>{{echo|foo</p></div><tr><td>}}bar</td></tr></table>
28389 !! html/parsoid
28390 <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;]}">
28391 <p>foo</p>
28392 </div>
28393 <table>
28394 <tbody>
28395 <tr>
28396 <td>bar</td>
28397 </tr>
28398 </tbody>
28399 </table>
28400 !! end
28401
28402 ## Remex doesn't account for fostered content.
28403 !! test
28404 5. Encapsulate foster-parented transclusion content
28405 !!options
28406 parsoid=wt2wt,wt2html
28407 !! wikitext
28408 <table><tr><td><div><p>{{echo|foo</p></div></td>foo}}</tr></table>
28409 !! html/php+tidy
28410 foo<table><tbody><tr><td><div><p>foo</p></div></td></tr></tbody></table>
28411 !! html/parsoid
28412 <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>
28413 !! end
28414
28415 ## Remex doesn't account for fostered content.
28416 !! test
28417 6. Encapsulate foster-parented transclusion content
28418 !! options
28419 parsoid=wt2wt,wt2html
28420 !! wikitext
28421 <table><tr><td><div><p>{{echo|foo</p></div></td>foo</tr></table>}}<p>ok</p>
28422 !! html/php+tidy
28423 foo<table><tbody><tr><td><div><p>foo</p></div></td></tr></tbody></table><p>ok</p>
28424 !! html/parsoid
28425 <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>
28426 !! end
28427
28428 !! test
28429 7. Encapsulate foster-parented transclusion content
28430 !!options
28431 parsoid=wt2wt,wt2html
28432 !! wikitext
28433 <table>{{echo|<p>foo</p>}}<td>bar</td></table>
28434 !! html/parsoid
28435 <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>
28436 <table>
28437 <tbody>
28438 <tr>
28439 <td>bar</td>
28440 </tr>
28441 </tbody>
28442 </table>
28443 !! end
28444
28445 ## Remex doesn't account for fostered content.
28446 # Note that the wt is broken on purpose: the = should be {{=}} if you
28447 # don't want it to be a template parameter key.
28448 !! test
28449 8. Encapsulate foster-parented transclusion content
28450 !! options
28451 parsoid=wt2wt,wt2html
28452 !! wikitext
28453 {{echo|a
28454 }}{|{{echo|style='color:red'}}
28455 |-
28456 |b
28457 |}
28458 !! html/php+tidy
28459 <p>a
28460 </p>
28461 <table>
28462
28463 <tbody><tr>
28464 <td>b
28465 </td></tr></tbody></table>
28466 !! html/parsoid
28467 <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">
28468 </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">
28469 <tbody><tr>
28470 <td>b
28471 </td></tr></tbody></table>
28472 !! end
28473
28474 ## Remex doesn't account for fostered content.
28475 !! test
28476 9. Encapsulate foster-parented transclusion content
28477 !!options
28478 parsoid=wt2wt,wt2html
28479 !! wikitext
28480 <table>{{echo|hi</table>hello}}
28481 !! html/php+tidy
28482 hi<table></table><p>hello
28483 </p>
28484 !! html/parsoid
28485 <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>
28486 !! end
28487
28488 !! test
28489 Table in fosterable position
28490 !!options
28491 parsoid=wt2html
28492 !! wikitext
28493 {{OpenTable}}
28494 <div>
28495 {|
28496 |}
28497 </div>
28498 |}
28499 !! html/parsoid
28500 <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">
28501 </span>
28502 <table about="#mwt1" data-parsoid='{"autoInsertedEnd":true}'></table>
28503
28504 <table>
28505 </table>
28506 !! end
28507
28508 # Parsoid only for T66747
28509 !! test
28510 Properly encapsulate empty-content transclusions in fosterable positions
28511 !! wikitext
28512 <table>
28513 {{#if:|
28514 <td>foo</td>
28515 }}
28516 </table>
28517 !! html/parsoid
28518 <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"}]]}'>
28519
28520 </table>
28521 !! end
28522
28523 ## No longer captures its original intention
28524 !! test
28525 Always encapsulate foster box when template range is expanded to table
28526 !! options
28527 disabled
28528 parsoid=wt2wt
28529 !! wikitext
28530 {|
28531 hello
28532 {{OpenTable}}
28533 |}
28534 !! html/parsoid
28535
28536 !! end
28537
28538 !! test
28539 T115289: Unclosed table
28540 !! wikitext
28541 {{echo|<table>}}<!--c-->[[Category:Two]]
28542 !! html/parsoid
28543 <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>
28544 !! end
28545
28546 !! test
28547 T115289: Don't migrate newlines out of tables with fostered content
28548 !! wikitext
28549 <table><td></td>{{echo|<tr>[[Category:One]]}}<!--c-->[[Category:Two]]
28550 !! html/parsoid
28551 <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>
28552 !! end
28553
28554 !! test
28555 T73074: More fostering fun
28556 !! wikitext
28557 <table><td></td>{{echo|<tr>}}<!--c-->[[Category:Two]]
28558 !! html/parsoid
28559 <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>
28560 !! end
28561
28562 !!test
28563 Support <object> element with .data attribute
28564 !!options
28565 parsoid=html2wt
28566 !! html/parsoid
28567 <object data="test.swf"></object>
28568 !! wikitext
28569 <object data="test.swf"></object>
28570 !!end
28571
28572 !! test
28573 Don't block XML namespace declaration
28574 !! wikitext
28575 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">MediaWiki</span>
28576 !! html/php
28577 <p><span xmlns:dct="http&#58;//purl.org/dc/terms/" property="dct:title">MediaWiki</span>
28578 </p>
28579 !! html/parsoid
28580 <p><span xmlns:dct="http://purl.org/dc/terms/" data-x-property="dct:title" data-parsoid='{"stx":"html"}'>MediaWiki</span></p>
28581 !! end
28582
28583 # -----------------------------------------------------------------
28584 # The following section of tests are primarily to spec requirements
28585 # around Parsoid's serialization (old, new, edited content)
28586 #
28587 # All these tests are marked Parsoid html2wt and html2html only
28588 # ----------------------------------------------------------------
28589
28590 !! test
28591 Ignore rel attribute in a-tags during serialization to url-links
28592 !! options
28593 parsoid=html2wt
28594 !! html/parsoid
28595 <a href='http://en.wikipedia.org/wiki/Foobar'>http://en.wikipedia.org/wiki/Foobar</a>
28596 <a href='http://en.wikipedia.org/wiki/Foobar' rel='mw:ExtLink'>http://en.wikipedia.org/wiki/Foobar</a>
28597 <a href='http://en.wikipedia.org/wiki/Foobar' rel='mw:WikiLink'>http://en.wikipedia.org/wiki/Foobar</a>
28598 !! wikitext
28599 http://en.wikipedia.org/wiki/Foobar
28600 http://en.wikipedia.org/wiki/Foobar
28601 http://en.wikipedia.org/wiki/Foobar
28602 !! end
28603
28604 # 'mi' is a localinterwiki prefix as well as a language
28605 !! test
28606 Serialize interwiki links pointing to the current wiki as plain wiki links (T67869)
28607 !! options
28608 parsoid=html2wt
28609 !! html/parsoid
28610 <p><a rel="mw:ExtLink" href="http://mi.wikipedia.org/wiki/Foo">Foo</a></p>
28611 !! wikitext
28612 [[Foo]]
28613 !! end
28614
28615 !! test
28616 Parsoid should accept interwiki shortcuts
28617 !! options
28618 parsoid=html2wt
28619 !! html/parsoid
28620 <p><a rel='mw:WikiLink' href='./fr:Foo'>Foo</a>
28621 <a rel='mw:ExtLink' href='./fr:Foo'>Foo</a>
28622 <a href='./fr:Foo'>Foo</a></p>
28623 <p><a rel='mw:WikiLink' href='fr%3AFoo'>Foo</a>
28624 <a rel='mw:ExtLink' href='fr%3AFoo'>Foo</a>
28625 <a href='fr%3AFoo'>Foo</a></p>
28626 <p><a href='FR%3AFoo'>Foo</a>
28627 <a href='./FR:Foo'>Foo</a></p>
28628 !! wikitext
28629 [[:fr:Foo|Foo]]
28630 [[:fr:Foo|Foo]]
28631 [[:fr:Foo|Foo]]
28632
28633 [[:fr:Foo|Foo]]
28634 [[:fr:Foo|Foo]]
28635 [[:fr:Foo|Foo]]
28636
28637 [[:fr:Foo|Foo]]
28638 [[:fr:Foo|Foo]]
28639 !! end
28640
28641 !! test
28642 Parsoid should not accept invalid interwiki shortcuts
28643 !! options
28644 parsoid=html2wt
28645 !! html/parsoid
28646 <p><a rel='mw:WikiLink' href='news:Foo'>Foo</a>
28647 <a rel='mw:ExtLink' href='news:Foo'>Foo</a>
28648 <a href='news:Foo'>Foo</a></p>
28649 !! wikitext
28650 [news:Foo Foo]
28651 [news:Foo Foo]
28652 [news:Foo Foo]
28653 !! end
28654
28655 # See T93839
28656 !! test
28657 New wikilinks should be serialized properly
28658 !! options
28659 parsoid=html2wt
28660 !! html/parsoid
28661 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{}'>Foo</a>
28662 <a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a>
28663 <a href="//en.wikipedia.org/wiki/Foo">//en.wikipedia.org/wiki/Foo</a>
28664 <a href="http://en.wikipedia.org/wiki/Foo">http://en.wikipedia.org/wiki/Foo</a>
28665 <a href="//en.wikipedia.org/wiki/Foo_bar">//en.wikipedia.org/wiki/Foo bar</a>
28666 !! wikitext
28667 [[Foo]]
28668 [[Foo]]
28669 [[:en:Foo|//en.wikipedia.org/wiki/Foo]]
28670 http://en.wikipedia.org/wiki/Foo
28671 [[:en:Foo_bar|//en.wikipedia.org/wiki/Foo bar]]
28672 !! end
28673
28674 !! test
28675 New wiki links (href variations)
28676 !! options
28677 parsoid=html2wt
28678 !! html/parsoid
28679 <a rel="mw:WikiLink" href="./Foo_bar">Foo_bar</a>
28680 <a rel="mw:WikiLink" href="Foo_bar">Foo_bar</a>
28681 <a rel="mw:WikiLink" href="Foo bar">Foo_bar</a>
28682 <a rel="mw:WikiLink" href="./Toxine_bact%C3%A9rienne">Toxine bactérienne</a>
28683 !! wikitext
28684 [[Foo_bar]]
28685 [[Foo_bar]]
28686 [[Foo_bar]]
28687 [[Toxine bactérienne]]
28688 !! end
28689
28690 !! test
28691 New wiki links (content string variations)
28692 !! options
28693 parsoid=html2wt
28694 !! html/parsoid
28695 <a rel="mw:WikiLink" href="./Foo_bar">Foo_bar</a>
28696 <a rel="mw:WikiLink" href="./Foo_bar">Foo bar</a>
28697 <a rel="mw:WikiLink" href="./Foo_bar">./Foo_bar</a>
28698 !! wikitext
28699 [[Foo_bar]]
28700 [[Foo bar]]
28701 [[Foo_bar|./Foo_bar]]
28702 !! end
28703
28704 !! test
28705 New category links (href variations)
28706 !! options
28707 parsoid=html2wt
28708 !! html/parsoid
28709 <link rel="mw:PageProp/Category" href="./Category:Toxine_bactérienne" />
28710 <link rel="mw:PageProp/Category" href="./Category:Toxine_bact%C3%A9rienne" />
28711 <link rel="mw:PageProp/Category" href="Category:Toxine_bact%C3%A9rienne" />
28712 !! wikitext
28713 [[Category:Toxine bactérienne]]
28714 [[Category:Toxine bactérienne]]
28715 [[Category:Toxine bactérienne]]
28716 !! end
28717
28718 !! test
28719 New sol transparent links don't need indent-pre nowiki protection
28720 !! options
28721 parsoid=html2wt
28722 language=de
28723 !! html/parsoid
28724 <link rel="mw:PageProp/redirect" href="./Main_Page">
28725 <!-- this is good --> <link rel="mw:PageProp/Category" href="./Category:Good" />
28726 <!-- this is great --> <link rel="mw:PageProp/Category" href="./Kategorie:Great" />
28727 !! wikitext
28728 #WEITERLEITUNG [[Main Page]]
28729 <!-- this is good --> [[Category:Good]]
28730 <!-- this is great --> [[Kategorie:Great]]
28731 !! end
28732
28733 !! test
28734 New interlanguage links (href variations)
28735 !! options
28736 parsoid=html2wt
28737 !! html/parsoid
28738 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine bactérienne" />
28739 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine_bactérienne" />
28740 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine_bact%C3%A9rienne" />
28741 !! wikitext
28742 [[es:Toxine bactérienne]]
28743 [[es:Toxine_bactérienne]]
28744 [[es:Toxine_bactérienne]]
28745 !! end
28746
28747 !! test
28748 Image: Modifying size of an image (1)
28749 !! options
28750 parsoid={
28751 "modes": ["wt2wt"],
28752 "changes": [
28753 ["img[height]", "attr", "height", "22"],
28754 ["img[width]", "attr", "width", "200"]
28755 ]
28756 }
28757 !! wikitext
28758 [[Image:Foobar.jpg|230x230px]]
28759 !! wikitext/edited
28760 [[Image:Foobar.jpg|200x200px]]
28761 !!end
28762
28763 !! test
28764 Image: Modifying size of an image (2)
28765 !! options
28766 parsoid={
28767 "modes": ["wt2wt"],
28768 "changes": [
28769 ["img[height]", "attr", "height", "100"],
28770 ["img[width]", "attr", "width", "500"]
28771 ]
28772 }
28773 !! wikitext
28774 [[Image:Foobar.jpg|230x230px]]
28775 !! wikitext/edited
28776 [[Image:Foobar.jpg|500x500px]]
28777 !!end
28778
28779 # Change in size is ignored so long as class='mw-default-size'
28780 !! test
28781 Image: Modifying size of an image (3)
28782 !! options
28783 parsoid={
28784 "modes": ["wt2wt"],
28785 "changes": [
28786 ["figure[class]", "removeClass", "mw-default-size"],
28787 ["figure img", "attr", "height", "19"],
28788 ["figure img", "attr", "width", "170"]
28789 ]
28790 }
28791 !! wikitext
28792 [[Image:Foobar.jpg|thumb]]
28793 !! wikitext/edited
28794 [[Image:Foobar.jpg|thumb|170x170px]]
28795 !!end
28796
28797 !! test
28798 Image: Modifying alignment of an image (T50665)
28799 !! options
28800 parsoid={
28801 "modes": ["wt2wt"],
28802 "changes": [
28803 ["figure[class]", "removeClass", "mw-halign-right"],
28804 ["figure[class]", "addClass", "mw-halign-left"]
28805 ]
28806 }
28807 !! wikitext
28808 [[Image:Foobar.jpg|thumb|caption|right]]
28809 !! wikitext/edited
28810 [[Image:Foobar.jpg|thumb|caption|left]]
28811 !! end
28812
28813 !! test
28814 Image: Modifying mw-default-size of an frameless image (T64805)
28815 !! options
28816 parsoid={
28817 "modes": ["wt2wt"],
28818 "changes": [
28819 ["figure.mw-default-size", "removeClass", "mw-default-size"]
28820 ]
28821 }
28822 !! wikitext
28823 [[Image:Foobar.jpg|frameless|right]]
28824 !! wikitext/edited
28825 [[Image:Foobar.jpg|frameless|right|220x220px]]
28826 !! end
28827
28828 !! test
28829 Image: Modifying valign of an image (T51221)
28830 !! options
28831 parsoid={
28832 "modes": ["wt2wt"],
28833 "changes": [
28834 ["*[typeof=\"mw:Image\"]", "removeClass", "mw-valign-middle"],
28835 ["*[typeof=\"mw:Image\"]", "addClass", "mw-valign-text-top"]
28836 ]
28837 }
28838 !! wikitext
28839 [[File:Foobar.jpg|20px|middle]]
28840 !! wikitext/edited
28841 [[File:Foobar.jpg|20px|text-top]]
28842 !! end
28843
28844 !! test
28845 Image: Modifying alt attribute of an image (T58400)
28846 !! options
28847 parsoid={
28848 "modes": ["wt2wt"],
28849 "changes": [
28850 ["img[alt]", "attr", "alt", "some alternate edited text"]
28851 ]
28852 }
28853 !! wikitext
28854 [[File:Foobar.jpg|thumb|some caption|alt=some alternate text]]
28855 !! wikitext/edited
28856 [[File:Foobar.jpg|thumb|some caption|alt=some alternate edited text]]
28857 !!end
28858
28859 !! test
28860 Image: Modifying caption of an image
28861 !! options
28862 parsoid={
28863 "modes": ["wt2wt"],
28864 "changes": [
28865 ["figcaption", "text", "new caption"]
28866 ]
28867 }
28868 !! wikitext
28869 [[Image:Foobar.jpg|thumb|original caption]]
28870 !! wikitext/edited
28871 [[Image:Foobar.jpg|thumb|new caption]]
28872 !!end
28873
28874 !! test
28875 Image: empty alt attribute (T50924)
28876 !! wikitext
28877 [[File:Foobar.jpg|thumb|alt=|bar]]
28878 !! html/php+tidy
28879 <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>
28880 !! html/parsoid
28881 <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>
28882 !! end
28883
28884 !! test
28885 Image: new attributes should be serialized in wiki's language for RTL languages (T53852)
28886 !! options
28887 parsoid=html2wt
28888 language=ar
28889 disabled
28890 !! html/parsoid
28891 <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>
28892 !! wikitext
28893 [[Imagen:Foobar.jpg|derecha|miniaturadeimagen]]
28894 !! end
28895
28896 !! test
28897 Image: Block level image should have \n before and after
28898 !! wikitext
28899 123
28900 [[File:Foobar.jpg|right|thumb|150x150px]]
28901 456
28902 !! html/parsoid
28903 <p>123</p>
28904 <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>
28905 <p>456</p>
28906 !! end
28907
28908 !! test
28909 Image: New block level image should have \n before and after (existing content)
28910 !! wikitext
28911 123
28912 [[File:Foobar.jpg|right|thumb|150x150px]]
28913 456
28914 !! html/parsoid
28915 <p>123</p>
28916 <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>
28917 <p>456</p>
28918 !! end
28919
28920 !! test
28921 Image: upright option (parsoid)
28922 !! wikitext
28923 [[File:Foobar.jpg|thumb|upright|caption]]
28924 [[File:Foobar.jpg|thumb|upright=0.5|caption]]
28925 [[File:Foobar.jpg|thumb|500x500px|upright=0.5|caption]]
28926 !! html/parsoid
28927 <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>
28928 <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>
28929 <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>
28930 !! end
28931
28932 !! test
28933 Image: upright option is ignored on inline and frame images (parsoid)
28934 !! wikitext
28935 [[File:Foobar.jpg|500x500px|upright=0.5|caption]]
28936 !! html/parsoid
28937 <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>
28938 !! end
28939
28940 !! test
28941 Image: in template parameter with empty parameter
28942 !! wikitext
28943 {{echo|[[File:Foobar.jpg|link=]]}}
28944 !! html/parsoid
28945 <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>
28946 !! end
28947
28948 !! test
28949 Image: from basic HTML (1)
28950 !! options
28951 parsoid=html2wt
28952 !! html/parsoid
28953 <span typeof="mw:Image">
28954 <img src="./File:Foobar.jpg" width=100 height=100 alt="Alt">
28955 </span>
28956 !! wikitext
28957 [[File:Foobar.jpg|link=|alt=Alt|100x100px]]
28958 !! end
28959
28960 !! test
28961 Image: from basic HTML (2)
28962 !! options
28963 parsoid=html2wt
28964 !! html/parsoid
28965 <img src="./File:Foobar.jpg" width=100 height=100 alt="Alt">
28966 !! wikitext
28967 [[File:Foobar.jpg|link=|alt=Alt|100x100px]]
28968 !! end
28969
28970 !! test
28971 Image: from basic HTML (3)
28972 !! options
28973 parsoid=html2wt
28974 !! html/parsoid
28975 <a href="Main"><img src="./File:Foobar.jpg" width=100 height=100 alt="Alt"></a>
28976 !! wikitext
28977 [[File:Foobar.jpg|link=Main|alt=Alt|100x100px]]
28978 !! end
28979
28980 !! test
28981 Image: from basic HTML (4)
28982 !! options
28983 parsoid=html2wt
28984 !! html/parsoid
28985 <img src="./File:Foobar.jpg">
28986 !! wikitext
28987 [[File:Foobar.jpg|link=]]
28988 !! end
28989
28990 !! test
28991 Image: Invalid title as link
28992 !! wikitext
28993 [[File:Foobar.jpg|link=<]]
28994 !! html/php
28995 <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>
28996 </p>
28997 !! html/parsoid
28998 <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>
28999 !! end
29000
29001 !! test
29002 Various link types in alt and link options
29003 !! wikitext
29004 [[File:Foobar.jpg|link=[[Main Page]]|alt=[[Main Page]]|caption]]
29005
29006 [[File:Foobar.jpg|link=[[Media:Thumb.png]]|alt=[[Media:Thumb.png]]|caption]]
29007
29008 [[File:Foobar.jpg|link=[[wikipedia:Foo]]|alt=[[wikipedia:Foo]]|caption]]
29009 !! html/php+tidy
29010 <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>
29011 </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>
29012 </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>
29013 </p>
29014 !! html/parsoid
29015 <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>
29016
29017 <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>
29018
29019 <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>
29020 !! end
29021
29022 !! test
29023 Lists: Serialize correctly even when list content is wrapped in p-tags (like VE does)
29024 !! options
29025 parsoid=html2wt
29026 !! html/parsoid
29027 <ul>
29028 <li><p>foo</p></li>
29029 </ul>
29030 !! wikitext
29031 * foo
29032 !! end
29033
29034 !! test
29035 Lists: Serialize correctly even when list tags has unneeded whitespace between tags
29036 !! options
29037 parsoid=html2wt
29038 !! html/parsoid
29039 <ul> <li>foo</li></ul>
29040 !! wikitext
29041 * foo
29042 !! end
29043
29044 !! test
29045 Don't strip leading whitespace when handling indent-pre suppressing tags
29046 !! options
29047 parsoid=html2wt
29048 !! html/parsoid
29049 <table>
29050 <tr><td> indented row</td></tr>
29051 </table>
29052 <blockquote><p>
29053 <b>This is very bold of you!</b>
29054 </p>
29055 <table><tr><td>
29056 indented cell (no pre-wrapping!)
29057 </td></tr></table>
29058 </blockquote>
29059 <p>foo</p>
29060 <div>bar</div>
29061 !! wikitext
29062 {|
29063 | indented row
29064 |}
29065 <blockquote>
29066 '''This is very bold of you!'''
29067
29068 {|
29069 |
29070 indented cell (no pre-wrapping!)
29071 |}
29072 </blockquote>
29073 foo
29074 <div>bar</div>
29075 !! end
29076
29077 !! test
29078 Nowiki-wrap leading whitespace when handling indent-pre inducing tags
29079 !! options
29080 parsoid=html2wt
29081 !! html/parsoid
29082 <p>foo</p>
29083 <span>bar</span>
29084
29085 <span>foo2
29086 </span>bar2
29087
29088 <div>foo</div>
29089 <span>bar</span>
29090
29091 <div>
29092 <span>foo</span>
29093 </div>
29094 !! wikitext
29095 foo
29096
29097 <span>bar</span>
29098
29099 <span>foo2
29100 <nowiki> </nowiki></span>bar2
29101
29102 <div>foo</div>
29103 <nowiki> </nowiki><span>bar</span>
29104
29105 <div>
29106 <nowiki> </nowiki><span>foo</span>
29107 </div>
29108 !! end
29109
29110 !! test
29111 Lists: Dont insert newlines in a serialized list item.
29112 !! options
29113 parsoid=html2wt
29114 !! html/parsoid
29115 <ul><li>a<br>b</li><li>c</li></ul>
29116 !! wikitext
29117 * a<br />b
29118 * c
29119 !! end
29120
29121 !! test
29122 1. Headings: Force sol-transparent links and behavior switches to serialize before/after
29123 !! options
29124 parsoid={
29125 "modes": ["html2wt"],
29126 "scrubWikitext": false
29127 }
29128 !! html/parsoid
29129 <h2>hello there<link href="./Category:A1" rel="mw:PageProp/Category" /></h2>
29130 <h2><link href="./Category:A2" rel="mw:PageProp/Category" />hi pal</h2>
29131
29132 <h2><!--foo--> <link href="./Category:A3" rel="mw:PageProp/Category" /> how goes it</h2>
29133 <h2>it goes well <link href="./Category:A4" rel="mw:PageProp/Category" /> <!--bar--></h2>
29134
29135 <h2 data-parsoid='{}'>howdy<link href="./Category:A5" rel="mw:PageProp/Category" /></h2>
29136
29137 <h2><meta property="mw:PageProp/toc" /> ok</h2>
29138 !! wikitext
29139 == hello there [[Category:A1]] ==
29140
29141 == [[Category:A2]] hi pal ==
29142
29143 == <!--foo--> [[Category:A3]] how goes it ==
29144
29145 == it goes well [[Category:A4]] <!--bar--> ==
29146
29147 ==howdy [[Category:A5]]==
29148
29149 == __TOC__ ok ==
29150 !! end
29151
29152 !! test
29153 2. Headings: Force sol-transparent links and behavior switches to serialize before/after
29154 !! options
29155 parsoid={
29156 "modes": ["html2wt"],
29157 "scrubWikitext": true
29158 }
29159 !! html/parsoid
29160 <h2>hello there<link href="./Category:A1" rel="mw:PageProp/Category" /></h2>
29161 <h2><link href="./Category:A2" rel="mw:PageProp/Category" />hi pal</h2>
29162
29163 <h2><!--foo--> <link href="./Category:A3" rel="mw:PageProp/Category" /> how goes it</h2>
29164 <h2>it goes well <link href="./Category:A4" rel="mw:PageProp/Category" /> <!--bar--></h2>
29165
29166 <h2><meta property="mw:PageProp/toc" /> ok</h2>
29167 !! wikitext
29168 == hello there ==
29169 [[Category:A1]]
29170 [[Category:A2]]
29171
29172 == hi pal ==
29173
29174 <!--foo-->[[Category:A3]]
29175
29176 == how goes it ==
29177
29178 == it goes well ==
29179 [[Category:A4]] <!--bar-->
29180
29181 __TOC__
29182
29183 == ok ==
29184 !! end
29185
29186 !! test
29187 Headings: Don't hoist metas that come from templates
29188 !! options
29189 parsoid={
29190 "modes": ["html2wt"],
29191 "scrubWikitext": true
29192 }
29193 !! html/parsoid
29194 <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>
29195 !! wikitext
29196 == {{echo|foo [[Category:Foo]]}} ==
29197 !! end
29198
29199 !! test
29200 Headings: Category in ref isn't hoisted
29201 !! options
29202 parsoid={
29203 "modes": ["html2wt"],
29204 "scrubWikitext": true
29205 }
29206 !! html/parsoid
29207 <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>
29208
29209 <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>
29210 !! wikitext
29211 == foo <ref>bar
29212 [[Category:Baz]] </ref> ==
29213
29214 <references />
29215 !! end
29216
29217 !! test
29218 Parsoid: Serialize positional parameters with = in them as named parameter
29219 !! options
29220 parsoid=html2wt
29221 !! html/parsoid
29222 <p about="#mwt1" typeof="mw:Transclusion"
29223 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"f=oo"}},"i":0}}]}'>foo</p>
29224
29225 <p about="#mwt1" typeof="mw:Transclusion"
29226 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"f=oo"}, "2":{"wt":"bar"}},"i":0}}]}'>foo</p>
29227
29228 <!--Orig params with data-parsoid has heuristics for handling = chars-->
29229 <!--FIXME: But maybe the heuristic needs fixing to apply to new params as well-->
29230 <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>
29231 !! wikitext
29232 {{echo|1=f=oo}}
29233
29234 {{echo|1=f=oo|2=bar}}
29235
29236 <!--Orig params with data-parsoid has heuristics for handling = chars-->
29237 <!--FIXME: But maybe the heuristic needs fixing to apply to new params as well-->
29238 {{echo|<nowiki>f=oo</nowiki>|bar}}
29239 !! end
29240
29241 !! test
29242 Parsoid: Serialize positional parameters with = in extlink as named parameter
29243 !! options
29244 parsoid=html2wt
29245 !! html/parsoid
29246 <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>
29247 !! wikitext
29248 {{echo|1=http://stuff?is=ok}}
29249 !! end
29250
29251 !! test
29252 Parsoid: Correctly serialize block-node children when they are a combination of text and p-nodes
29253 !! options
29254 parsoid=html2wt
29255 !! html/parsoid
29256 <div>a<p>b</p></div>
29257 <div>a
29258 <p>b</p></div>
29259 <div>
29260 a
29261 <p>b</p></div>
29262 !! wikitext
29263 <div>a
29264 b
29265 </div>
29266 <div>a
29267 b
29268 </div>
29269 <div>
29270 a
29271
29272 b
29273 </div>
29274 !! end
29275
29276 !! test
29277 Substrings resembling wikitext in hrefs should not get nowiki escapes
29278 !! options
29279 parsoid=html2wt
29280 !! html/parsoid
29281 <a rel="mw:WikiLink" href="./Foo''bar''baz">Foo''bar''baz</a>
29282 !! wikitext
29283 [[Foo''bar''baz]]
29284 !! end
29285
29286 !! test
29287 Enforce single-line context in the serializer
29288 !! options
29289 parsoid=html2wt
29290 !! html/parsoid
29291 <h2>testing
29292 123</h2>
29293
29294 <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">
29295 </span><span about="#mwt1">you</span> </h2>
29296
29297 <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>
29298
29299 <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
29300 there</span></li></ol>
29301
29302 <ul><li>asd
29303 sdf</li></ul>
29304
29305 <ul><li>foo
29306 bar
29307 baz</li>
29308 <li>foo <b>bar</b>
29309 baz</li></ul>
29310
29311 <dl><dt>hi
29312 ho </dt><dd data-parsoid='{"stx":"row"}'> hi
29313 ho</dd></dl>
29314
29315 <dl><dd> <table>
29316 <tbody><tr><td> ha
29317 ha
29318 ha</td></tr>
29319 </tbody></table></dd></dl>
29320 !! wikitext
29321 == testing 123 ==
29322
29323 == hi {{bogus|there
29324 you}} ==
29325
29326 == foo <ref>hello
29327 there</ref> ==
29328
29329 <references />
29330
29331 * asd sdf
29332
29333 * foo bar baz
29334 * foo '''bar''' baz
29335
29336 ; hi ho : hi ho
29337
29338 : {|
29339 | ha
29340 ha
29341 ha
29342 |}
29343 !! end
29344
29345 !! test
29346 Serialize new placeholder space without spans
29347 !! options
29348 parsoid=html2wt
29349 !! html/parsoid
29350 <p>foo<span typeof="mw:Placeholder"> </span>: bar</p>
29351
29352 <p>foo<span typeof="mw:DisplaySpace mw:Placeholder" data-parsoid='{"src":" ","isDisplayHack":true}'> </span>: bar</p>
29353
29354 <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>
29355 !! wikitext
29356 foo : bar
29357
29358 foo : bar
29359
29360 <ref>foo : bar</ref>ok
29361 !! end
29362
29363
29364 #-----------------------
29365 # Tag minimization tests
29366 #-----------------------
29367
29368 !! test
29369 1. I/B quote minimization: wikitext-only tags should be combined
29370 !! options
29371 parsoid=html2wt
29372 !! html/parsoid
29373 <p><i>A</i><i>B</i></p>
29374 <p><b>A</b><b>B</b></p>
29375 <p><i>A</i><b><i>B</i></b></p>
29376 <p><b>A</b><i><b>B</b></i></p>
29377 <p><b>A</b><i><b>B</b><b>C</b></i><b>D</b></p>
29378 <p><i><b>A</b></i><i><b>B</b></i></p>
29379 <p><i><b>A</b></i><b><i>B</i></b></p>
29380 <p><b><i>A</i></b><i><b>B</b></i></p>
29381 !! wikitext
29382 ''AB''
29383
29384 '''AB'''
29385
29386 ''A'''B'''''
29387
29388 '''A''B'''''
29389
29390 '''A''BC''D'''
29391
29392 '''''AB'''''
29393
29394 '''''AB'''''
29395
29396 '''''AB'''''
29397 !! end
29398
29399 !! test
29400 2. I/B quote minimization: wikitext and html tags should not be combined
29401 !! options
29402 parsoid=html2wt
29403 !! html/parsoid
29404 <p><i>A</i><i data-parsoid='{"stx":"html"}'>B</i></p>
29405 <p><i>A</i><b><i data-parsoid='{"stx":"html"}'>B</i></b></p>
29406 !! wikitext
29407 ''A''<i>B</i>
29408
29409 ''A''<nowiki/>'''<i>B</i>'''
29410 !! end
29411
29412 !! test
29413 3. I/B quote minimization: templated content stops minimization
29414 !! options
29415 parsoid=html2wt
29416 !! html/parsoid
29417 <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>
29418 <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>
29419 !! wikitext
29420 ''A''{{echo|''B''}}
29421
29422 ''A''{{echo|'''''B'''''}}
29423 !! end
29424
29425 !! test
29426 4. I/B quote minimization: new content should be mimimized with adjacent old content
29427 !! options
29428 parsoid=html2wt
29429 !! html/parsoid
29430 <p><i>A</i><i>B</i></p>
29431 <p><b>A</b><b>B</b></p>
29432 <p><i>A</i><b><i>B</i></b></p>
29433 !! wikitext
29434 ''AB''
29435
29436 '''AB'''
29437
29438 ''A'''B'''''
29439 !! end
29440
29441 !! test
29442 5a. Merge adjacent quote nodes if they've been edited
29443 !! options
29444 parsoid={
29445 "modes": ["wt2wt", "selser"],
29446 "changes": [
29447 ["p", "contents", "remove", ":contains('b')"]
29448 ]
29449 }
29450 !! wikitext
29451 ''a''b''c''
29452 !! wikitext/edited
29453 ''ac''
29454 !! end
29455
29456 !! test
29457 5b. Merge adjacent quote nodes if they've been edited
29458 !! options
29459 parsoid={
29460 "modes": ["wt2wt", "selser"],
29461 "changes": [
29462 ["#x", "remove"]
29463 ]
29464 }
29465 !! wikitext
29466 ''a''<span id="x">b</span>''c''
29467 !! wikitext/edited
29468 ''ac''
29469 !! end
29470
29471 !! test
29472 1. Merge adjacent link nodes as long as at least one element is new
29473 !! options
29474 parsoid={
29475 "modes": ["html2wt"],
29476 "scrubWikitext": true
29477 }
29478 !! html/parsoid
29479 <a rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
29480 <a data-parsoid="{}" rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
29481 <a data-parsoid="{}" rel="mw:WikiLink" href="./Football">Foot</a><a data-parsoid="{}" rel="mw:WikiLink" href="./Football">ball</a>
29482 !! wikitext
29483 [[Football]]
29484 [[Football]]
29485 [[Football|Foot]][[Football|ball]]
29486 !! end
29487
29488 !! test
29489 2. Merge adjacent link nodes and enable additional normalizations
29490 !! options
29491 parsoid={
29492 "modes": ["html2wt"],
29493 "scrubWikitext": true
29494 }
29495 !! html/parsoid
29496 <a rel="mw:WikiLink" href="./Football"><i>Foot</i></a><a rel="mw:WikiLink" href="./Football"><i>ball</i></a>
29497 !! wikitext
29498 ''[[Football]]''
29499 !! end
29500
29501 !! test
29502 3. Don't merge adjacent link nodes if scrubWikitext is false
29503 !! options
29504 parsoid={
29505 "modes": ["html2wt"],
29506 "scrubWikitext": false
29507 }
29508 !! html/parsoid
29509 <a rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
29510 !! wikitext
29511 [[Football|Foot]][[Football|ball]]
29512 !! end
29513
29514 !! test
29515 1. Move format tags outside of WikiLink
29516 !! options
29517 parsoid={
29518 "modes": ["html2wt"],
29519 "scrubWikitext": true
29520 }
29521 !! html/parsoid
29522 <a rel="mw:WikiLink" href="./Football"><i>Football</i></a>
29523 <a rel="mw:WikiLink" href="./Football"><i><b>Football</b></i></a>
29524 <a rel="mw:WikiLink" href="./Football"><u><i><b>Football</b></i></u></a>
29525 !! wikitext
29526 ''[[Football]]''
29527 '''''[[Football]]'''''
29528 <u>'''''[[Football]]'''''</u>
29529 !! end
29530
29531 !! test
29532 2. Move format tags outside of WikiLink with mergable A tags
29533 !! options
29534 parsoid={
29535 "modes": ["html2wt"],
29536 "scrubWikitext": true
29537 }
29538 !! html/parsoid
29539 <a rel="mw:WikiLink" href="./Football"><i><b>Foot</b></i></a><a rel="mw:WikiLink" href="./Football"><i><b>ball</b></i></a>
29540 !! wikitext
29541 '''''[[Football]]'''''
29542 !! end
29543
29544 !! test
29545 3. Move format tags outside of WikiLink while preserving formats already outside WikiLink
29546 !! options
29547 parsoid={
29548 "modes": ["html2wt"],
29549 "scrubWikitext": true
29550 }
29551 !! html/parsoid
29552 <font color="red"><a rel="mw:WikiLink" href="./Foo" title="Foo" class="mw-redirect"><u><b>Foo</b></u></a></font>
29553 !! wikitext
29554 <font color="red"><u>'''[[Foo]]'''</u></font>
29555 !! end
29556
29557 !! test
29558 4. Do not move format tags outside of WikiLink which includes attributes color, style and class
29559 !! options
29560 parsoid={
29561 "modes": ["html2wt"],
29562 "scrubWikitext": true
29563 }
29564 !! html/parsoid
29565 <a rel="mw:WikiLink" href="./Foo" title="Foo" class="mw-redirect"><font color="red">Foo</font></a>
29566 <a rel="mw:WikiLink" href="./Foo" title="Foo" class="mw-redirect"><span style="color: blue; font-size: 46px;">Foo></span></a>
29567 <a rel="mw:WikiLink" href="./Foo" title="Foo" class="mw-redirect"><span class="Bar">Foo</span></a>
29568 !! wikitext
29569 [[Foo|<font color="red">Foo</font>]]
29570 [[Foo|<span style="color: blue; font-size: 46px;">Foo></span>]]
29571 [[Foo|<span class="Bar">Foo</span>]]
29572 !! end
29573
29574 !! test
29575 5. T194083 Regression test: Manual edit test that also enables scrubWikitext to move format tags outside wikilinks
29576 !! options
29577 parsoid={
29578 "modes": ["selser"],
29579 "scrubWikitext": true,
29580 "changes": [
29581 ["a", "html", "<i>Foo</i>"]
29582 ]
29583 }
29584 !! wikitext
29585 [[Foo]]
29586 !! wikitext/edited
29587 ''[[Foo]]''
29588 !! end
29589
29590 !! test
29591 6. Regression test: Manual edit test to ensure diff markers are not lost
29592 !! options
29593 parsoid={
29594 "modes": ["selser"],
29595 "scrubWikitext": true,
29596 "changes": [
29597 ["i", "wrap", "<a href='./Foo' rel='mw:WikiLink'></a>"]
29598 ]
29599 }
29600 !! wikitext
29601 ''Foo''
29602 !! wikitext/edited
29603 ''[[Foo]]''
29604 !! end
29605
29606 !! test
29607 7. T194083 Regression test: Manual edit test to ensure nested diff markers aren't inserted
29608 !! options
29609 parsoid={
29610 "modes": ["selser"],
29611 "scrubWikitext": true,
29612 "changes": [
29613 ["div", "after", "\n<p><a href='./Foo' rel='mw:WikiLink'>Foo </a>, placeholder</p>"]
29614 ]
29615 }
29616 !! wikitext
29617 <div>placeholder</div>
29618 !! wikitext/edited
29619 <div>placeholder</div>
29620 [[Foo]] , placeholder
29621 !! end
29622
29623 #------------------------------
29624 # End of tag minimization tests
29625 #------------------------------
29626
29627 !!test
29628 T56262: New entities
29629 !! options
29630 parsoid=html2wt
29631 !! html/parsoid
29632 <span typeof="mw:Entity">&nbsp;</span>
29633 !! wikitext
29634 &nbsp;
29635 !! end
29636
29637 ## Note that there is no wikitext output for 'unknownproperty' ##
29638 ## Unknown magic words are silently dropped ##
29639
29640 !! test
29641 Magic words
29642 !! options
29643 parsoid=html2wt
29644 !! html/parsoid
29645 <meta property='mw:PageProp/toc' />
29646 <meta property='mw:PageProp/notoc' />
29647 <meta property='mw:PageProp/forcetoc' />
29648 <meta property='mw:PageProp/index' />
29649 <meta property='mw:PageProp/noindex' />
29650 <meta property='mw:PageProp/nogallery' />
29651 <meta property='mw:PageProp/noeditsection' />
29652 <meta property='mw:PageProp/notitleconvert' />
29653 <meta property='mw:PageProp/nocontentconvert' />
29654 <meta property='mw:PageProp/unknownproperty' />
29655 !! wikitext
29656 __TOC__
29657 __NOTOC__
29658 __FORCETOC__
29659 __INDEX__
29660 __NOINDEX__
29661 __NOGALLERY__
29662 __NOEDITSECTION__
29663 __NOTITLECONVERT__
29664 __NOCONTENTCONVERT__
29665 !! end
29666
29667 !! test
29668 Consecutive <pre>s should not get merged
29669 !! options
29670 parsoid=html2wt,html2html
29671 !! html/parsoid
29672 <pre>a</pre><pre>b</pre>
29673
29674 <pre>c
29675 </pre><pre>
29676 d</pre>
29677
29678 <pre>e
29679
29680 </pre><pre>
29681
29682 f</pre>
29683 !! wikitext
29684 a
29685
29686 b
29687
29688 c
29689
29690 d
29691
29692 e
29693
29694
29695
29696 f
29697 !! end
29698
29699 !! test
29700 Edited ISBN links not serializable as ISBN links should serialize as wikilinks
29701 !! options
29702 parsoid=html2wt
29703 !! html/parsoid
29704 <a href="./Special:BookSources/1234567890" rel="mw:ExtLink">ISBN 1234567895</a>
29705 !! wikitext
29706 [[Special:BookSources/1234567890|ISBN 1234567895]]
29707 !! end
29708
29709 !! test
29710 Edited RFC links not serializable as RFC links should serialize as extlinks
29711 !! options
29712 parsoid=html2wt
29713 !! html/parsoid
29714 <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink">New RFC</a>
29715 !! wikitext
29716 [https://tools.ietf.org/html/rfc123 New RFC]
29717 !! end
29718
29719 !! test
29720 Edited PMID links not serializable as PMID links should serialize as extlinks
29721 !! options
29722 parsoid=html2wt
29723 !! html/parsoid
29724 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink">New PMID</a>
29725 !! wikitext
29726 [//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract New PMID]
29727 !! end
29728
29729 !! test
29730 WTS of autolinks with trailing/surrounding context
29731 !! options
29732 parsoid=html2wt
29733 !! html/parsoid
29734 <p><a href="http://cscott.net">http://cscott.net</a><b>foo</b></p>
29735 <p><a href="http://cscott.net">http://cscott.net</a><b data-parsoid='{"stx":"html"}'>foo</b></p>
29736 <p><b><a href="http://cscott.net">http://cscott.net</a></b></p>
29737 <p><b><a href="http://cscott.net">http://cscott.net</a> </b></p>
29738 <p><b><a href="http://cscott.net">http://cscott.net</a>x</b></p>
29739 <p><a href="http://cscott.net">http://cscott.net</a>x</p>
29740 !! wikitext
29741 http://cscott.net'''foo'''
29742
29743 http://cscott.net<b>foo</b>
29744
29745 '''http://cscott.net'''
29746
29747 '''http://cscott.net '''
29748
29749 '''http://cscott.net<nowiki/>x'''
29750
29751 http://cscott.net<nowiki/>x
29752 !! end
29753
29754 !! test
29755 WTS of autolinks with nowikis (round-trip)
29756 !! wikitext
29757 x<nowiki/>http://cscott.net<nowiki/>x
29758 !! html/parsoid
29759 <p>x<a rel="mw:ExtLink" class="external free" href="http://cscott.net">http://cscott.net</a>x</p>
29760 !! end
29761
29762 # this is the "easy" test because it leaves in place all the
29763 # data-parsoid information indicating this is an autolink
29764 !! test
29765 WTS of autolinks with escapes (editing)
29766 !! options
29767 parsoid={
29768 "modes": ["wt2wt"],
29769 "changes": [
29770 [ "span", "remove" ]
29771 ]
29772 }
29773 !! wikitext
29774 x<nowiki/>http://cscott.net<nowiki/>x
29775 !! wikitext/edited
29776 x<nowiki/>http://cscott.net<nowiki/>x
29777 !! end
29778
29779 !! test
29780 WTS of edited autolink-like text (T103364)
29781 !! options
29782 parsoid={
29783 "modes": ["wt2wt"],
29784 "changes": [
29785 [ "span[typeof]", "removeAttr", "typeof" ]
29786 ]
29787 }
29788 !! wikitext
29789 Not a link: <nowiki>http://example.com</nowiki>.
29790 !! wikitext/edited
29791 Not a link: <span><nowiki>http://example.com</nowiki></span>.
29792 !! end
29793
29794 !! test
29795 WTS of newly-authored autolink-like text (T103364)
29796 !! options
29797 parsoid=html2wt
29798 !! html/parsoid
29799 <p>http://example.com is not a link.</p>
29800 !! wikitext
29801 <nowiki>http://example.com</nowiki> is not a link.
29802 !! end
29803
29804 !! test
29805 WTS of autolink-like text after an autolink (T108563)
29806 !! options
29807 parsoid=html2wt
29808 !! html/parsoid
29809 <p><a rel="mw:ExtLink" href="http://example.com">http://example.com</a> http://example.com is not a link.</p>
29810 !! wikitext
29811 http://example.com <nowiki>http://example.com</nowiki> is not a link.
29812 !! end
29813
29814 !! test
29815 Magic links inside links (not autolinked)
29816 !! wikitext
29817 [[Foo|http://example.com]]
29818 [[Foo|RFC 1234]]
29819 [[Foo|PMID 1234]]
29820 [[Foo|ISBN 123456789x]]
29821
29822 [http://foo.com http://example.com]
29823 [http://foo.com RFC 1234]
29824 [http://foo.com PMID 1234]
29825 [http://foo.com ISBN 123456789x]
29826 !! html+tidy
29827 <p><a href="/wiki/Foo" title="Foo">http://example.com</a>
29828 <a href="/wiki/Foo" title="Foo">RFC 1234</a>
29829 <a href="/wiki/Foo" title="Foo">PMID 1234</a>
29830 <a href="/wiki/Foo" title="Foo">ISBN 123456789x</a>
29831 </p><p><a rel="nofollow" class="external text" href="http://foo.com">http://example.com</a>
29832 <a rel="nofollow" class="external text" href="http://foo.com">RFC 1234</a>
29833 <a rel="nofollow" class="external text" href="http://foo.com">PMID 1234</a>
29834 <a rel="nofollow" class="external text" href="http://foo.com">ISBN 123456789x</a>
29835 </p>
29836 !! html/parsoid
29837 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">http://example.com</a>
29838 <a rel="mw:WikiLink" href="./Foo" title="Foo">RFC 1234</a>
29839 <a rel="mw:WikiLink" href="./Foo" title="Foo">PMID 1234</a>
29840 <a rel="mw:WikiLink" href="./Foo" title="Foo">ISBN 123456789x</a></p>
29841
29842 <p><a rel="mw:ExtLink" class="external text" href="http://foo.com">http://example.com</a>
29843 <a rel="mw:ExtLink" class="external text" href="http://foo.com">RFC 1234</a>
29844 <a rel="mw:ExtLink" class="external text" href="http://foo.com">PMID 1234</a>
29845 <a rel="mw:ExtLink" class="external text" href="http://foo.com">ISBN 123456789x</a></p>
29846 !! end
29847
29848 !! test
29849 Magic links inside image captions (autolinked)
29850 !! wikitext
29851 [[File:Foobar.jpg|thumb|http://example.com]]
29852 [[File:Foobar.jpg|thumb|RFC 1234]]
29853 [[File:Foobar.jpg|thumb|PMID 1234]]
29854 [[File:Foobar.jpg|thumb|ISBN 123456789x]]
29855 !! html+tidy
29856 <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>
29857 <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>
29858 <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>
29859 <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>
29860 !! html/parsoid
29861 <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>
29862 <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>
29863 <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>
29864 <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>
29865 !! end
29866
29867 !! test
29868 WTS of magic word text (T109371)
29869 !! options
29870 parsoid=html2wt
29871 !! html/parsoid
29872 <p>RFC 1234</p>
29873 <p><a href="http://foo.com" rel="mw:ExtLink">RFC 1234</a></p>
29874 <p><a href="./Foo" rel="mw:WikiLink">RFC 1234</a></p>
29875 !! wikitext
29876 <nowiki>RFC 1234</nowiki>
29877
29878 [http://foo.com RFC 1234]
29879
29880 [[Foo|RFC 1234]]
29881 !! end
29882
29883 !! test
29884 Edited Redirect link should emit a non-piped wikitext link
29885 !! options
29886 parsoid=html2wt
29887 !! html/parsoid
29888 <link rel="mw:PageProp/redirect" href="Bar" data-parsoid='{"a":{"href":"./Foo"},"sa":{"href":"Foo"}}'>
29889 !! wikitext
29890 #REDIRECT [[Bar]]
29891 !! end
29892
29893 !! test
29894 T75121: Infer extension name from typeOf if data-mw is not present
29895 !! options
29896 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
29897 !! html/parsoid
29898 <div typeOf="mw:Extension/foo"></div>
29899 !! wikitext
29900 <foo />
29901 !! end
29902
29903 # Note that the <p> wrapping isn't present in PHP parser output
29904 # The important thing for this test is that P-wrapping doesn't
29905 # interfere with the <nowiki> protection for leading - in <td>
29906 # (which isn't necessary for <th>).
29907 !! test
29908 T88318: p-wrapped dash in table.
29909 !! options
29910 parsoid=html2wt,wt2wt
29911 !! html/parsoid
29912 <table><tbody>
29913 <tr><th><p>-</p></th><th><p>- </p></th></tr>
29914 <tr><td><p>-</p></td><td><p>- </p></td></tr>
29915 <tr><td><small>-</small></td><td><br/><p>-</p></td><td><br/>-</td></tr>
29916 </tbody></table>
29917 !! wikitext
29918 {|
29919 !-
29920 !-
29921 |-
29922 |<nowiki>-</nowiki>
29923 |<nowiki>- </nowiki>
29924 |-
29925 |<small>-</small>
29926 |<br />
29927 -
29928 |<br />-
29929 |}
29930 !! html/php+tidy
29931 <table>
29932 <tbody><tr>
29933 <th>-
29934 </th>
29935 <th>-
29936 </th></tr>
29937 <tr>
29938 <td>-
29939 </td>
29940 <td>-
29941 </td></tr>
29942 <tr>
29943 <td><small>-</small>
29944 </td>
29945 <td><br />
29946 <p>-
29947 </p>
29948 </td>
29949 <td><br />-
29950 </td></tr></tbody></table>
29951 !! end
29952
29953 !! test
29954 T149209: WTS: Handle newlines in table cells properly
29955 !! options
29956 parsoid=html2wt
29957 !! html/parsoid
29958 <table>
29959 <tbody>
29960 <tr><td>a
29961 b
29962 </td><td data-parsoid='{"stx":"row"}'>c</td></tr>
29963 <tr><td><p>x</p>
29964 </td><td data-parsoid='{"stx":"row", "startTagSrc": "{{!}}{{!}}"}'>y</td></tr>
29965 </tbody></table>
29966 <table>
29967 <tbody>
29968 <tr><th>a
29969 b
29970 </th><th data-parsoid='{"stx":"row"}'>c</th></tr>
29971 <tr><th><p>x</h>
29972 </th><th data-parsoid='{"stx":"row"}'>y</th></tr>
29973 </tbody></table>
29974 !! wikitext
29975 {|
29976 |a
29977 b
29978 |c
29979 |-
29980 |x
29981 {{!}}y
29982 |}
29983 {|
29984 !a
29985 b
29986 !c
29987 |-
29988 !x
29989 !y
29990 |}
29991 !! end
29992
29993 !! test
29994 T149209: Selser: Handle newlines in table cells properly
29995 !! options
29996 parsoid={
29997 "modes": ["selser"],
29998 "changes": [
29999 [ "#h1", "html", "a\nb\n" ],
30000 [ "#h2", "html", "a\nb\n" ],
30001 [ "#c1", "html", "a\nb\n" ],
30002 [ "#c2", "html", "<p>a</p>" ],
30003 [ "#c3", "html", "<p>a</p>" ],
30004 [ "#c4", "html", "edit-me<p>a</p>" ]
30005 ]
30006 }
30007 !! wikitext
30008 {|
30009 ! id="h1" |edit-me!!1
30010 |-
30011 ! id="h2" |edit-me||2
30012 |-
30013 | id="c1" |edit-me||3
30014 |-
30015 | id="c2" |edit-me||4
30016 |-
30017 | id="c3" |edit-me||p||q||r
30018 |-
30019 | id="c4" |edit-me||p||q||r
30020 |}
30021 !! wikitext/edited
30022 {|
30023 ! id="h1" |a
30024 b
30025 !1
30026 |-
30027 ! id="h2" |a
30028 b
30029 !2
30030 |-
30031 | id="c1" |a
30032 b
30033 |3
30034 |-
30035 | id="c2" |a
30036 |4
30037 |-
30038 | id="c3" |a
30039 |p||q||r
30040 |-
30041 | id="c4" |edit-me
30042 a
30043 |p||q||r
30044 |}
30045 !! end
30046
30047 !! test
30048 HTML id attribute with Parsoid-like element ids should not be serialized to wikitext
30049 !! options
30050 parsoid=html2wt
30051 !! html/parsoid
30052 <table id='mwAb'>
30053 <td id='mwAc'>foo</td>
30054 <td id='serialize-this'>bar</td>
30055 </table>
30056 !! wikitext
30057 {|
30058 |foo
30059 | id="serialize-this" |bar
30060 |}
30061 !! end
30062
30063 !! test
30064 Parsoid-like element ids should not be serialized to wikitext unless shadowed
30065 !! options
30066 parsoid=html2wt
30067 !! html/parsoid
30068 <div id="mwAQ" data-parsoid='{"stx":"html","a":{"id":"mwAQ"},"sa":{"id":"hello"}}'>ok</div>
30069 !! wikitext
30070 <div id="hello">ok</div>
30071 !! end
30072
30073 !! test
30074 Testing serialization after deletion in references
30075 !! options
30076 parsoid={
30077 "modes": ["wt2wt"],
30078 "changes": [
30079 ["#x", "remove"]
30080 ]
30081 }
30082 !! wikitext
30083 hi <ref><div id="x">ho</div></ref>
30084
30085 <references />
30086 !! wikitext/edited
30087 hi <ref></ref>
30088
30089 <references />
30090 !! end
30091
30092 !!test
30093 Testing serialization after deletion of table cells
30094 !!options
30095 parsoid={
30096 "modes": ["wt2wt", "selser"],
30097 "changes": [
30098 ["#x", "remove"]
30099 ]
30100 }
30101 !!wikitext
30102 {|
30103 !h1 !!h2 !!h3
30104 | id="x" |c1 {{!}}{{!}}{{!}}c2 |||c3
30105 |}
30106 !! wikitext/edited
30107 {|
30108 !h1!!h2!!h3
30109 |c2|||c3
30110 |}
30111 !!end
30112
30113 !! test
30114 Testing selser after addition of new row before first row (T125419)
30115 !! options
30116 parsoid={
30117 "modes": ["wt2wt", "selser"],
30118 "changes": [
30119 [ "tr", "before", "<tr><td>X</td></tr>" ]
30120 ]
30121 }
30122 !! wikitext
30123 {|
30124 |a
30125 |}
30126 !! wikitext/edited
30127 {|
30128 |X
30129 |-
30130 |a
30131 |}
30132 !! end
30133
30134 !! test
30135 Serialize new table rows in a HTML table using HTML tags
30136 !! options
30137 parsoid={
30138 "modes": ["wt2wt", "selser"],
30139 "changes": [
30140 [ "tr", "before", "<tr><td>X</td></tr>" ]
30141 ]
30142 }
30143 !! wikitext
30144 <table><tr><td>a</td></tr></table>
30145 !! wikitext/edited
30146 <table><tr><td>X</td></tr><tr><td>a</td></tr></table>
30147 !! end
30148
30149 !! test
30150 Serialize new table cells in a HTML row using HTML tags
30151 !! options
30152 parsoid={
30153 "modes": ["wt2wt", "selser"],
30154 "changes": [
30155 [ "td", "before", "<td>X</td>" ]
30156 ]
30157 }
30158 !! wikitext
30159 <table><tr><td>a</td></tr></table>
30160 !! wikitext/edited
30161 <table><tr><td>X</td><td>a</td></tr></table>
30162 !! end
30163
30164 !! test
30165 Serialize wikitext list items as HTML list items when embedded in a HTML list
30166 !! options
30167 parsoid=html2wt
30168 !! html/parsoid
30169 <ul data-parsoid='{"stx": "html"}'>
30170 <li data-parsoid='{}'>a</li>
30171 <li>b</li>
30172 </ul>
30173 !! wikitext
30174 <ul>
30175 <li>a</li>
30176 <li>b</li>
30177 </ul>
30178 !! html/php+tidy
30179 <ul>
30180 <li>a</li>
30181 <li>b</li>
30182 </ul>
30183 !! end
30184
30185 # Nested list should be inside <li>, that is
30186 # <ul><li>foo<ul>..</ul></li></ul> instead of
30187 # <ul><li>foo</li><ul>..</ul></ul>
30188 # See https://stackoverflow.com/questions/5899337/proper-way-to-make-html-nested-list
30189 !! test
30190 Wikitext lists can be nested inside HTML lists
30191 !! options
30192 parsoid=html2wt
30193 !! html/parsoid
30194 <ul data-parsoid='{"stx": "html"}'>
30195 <li data-parsoid='{"stx": "html"}'>a
30196 <ul><li>b</li></ul>
30197 </li>
30198 </ul>
30199
30200 <ul data-parsoid='{"stx": "html"}'>
30201 <li>x
30202 <ul><li>y</li></ul>
30203 </li>
30204 </ul>
30205 !! wikitext
30206 <ul>
30207 <li>a
30208 * b
30209 </li>
30210 </ul>
30211
30212 <ul>
30213 <li>x
30214 * y
30215 </li>
30216 </ul>
30217 !! html/php+tidy
30218 <ul>
30219 <li>a
30220 <ul><li>b</li></ul>
30221 </li>
30222 </ul>
30223 <ul>
30224 <li>x
30225 <ul><li>y</li></ul>
30226 </li>
30227 </ul>
30228 !! end
30229
30230 !! test
30231 WTS change modes
30232 !! options
30233 parsoid={
30234 "modes": ["wt2wt"],
30235 "changes": [
30236 [ "#xyz", "before", "<b>before</b> stuff " ],
30237 [ "#xyz", "after", " stuff <i>after</i>" ],
30238 [ "#xyz", "html", "x <b>y</b> z" ]
30239 ]
30240 }
30241 !! wikitext
30242 <span id="xyz">hello</span>
30243 !! wikitext/edited
30244 '''before''' stuff <span id="xyz">x '''y''' z</span> stuff ''after''
30245 !! end
30246
30247 !! test
30248 Never serialize a-tag as html, regardless of what data-parsoid has to say
30249 !! options
30250 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
30251 !! html/parsoid
30252 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"html"}'>Foo</a>
30253 !! wikitext
30254 [[Foo]]
30255 !! end
30256
30257 ## SSS FIXME: This is broken output nevertheless.
30258 ## What might be a reasonable non-broken output for this?
30259 ## This is an edge case unlikely to be seen in production
30260 ## that I am not wasting more time on this right now.
30261 !! test
30262 Never serialize a-tag as html, no matter what attributes it has
30263 !! options
30264 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
30265 !! html/parsoid
30266 <a bad='true' href='http://boo.org'><img src='http://boohoo.org' /></a>
30267 !! wikitext
30268 [http://boo.org http://boohoo.org]
30269 !! end
30270
30271 # Misnested is an indication that selser can reuse the source but these have
30272 # shown to sneak through on occasion. See T101768.
30273 # The original wikitext here is: [http://test.com [[one]] two three]
30274 !! test
30275 Strip span tags added to mark misnested links
30276 !! options
30277 parsoid=html2wt
30278 !! html/parsoid
30279 <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>
30280 !! wikitext
30281 [http://test.com][[one]] two three
30282 !! end
30283
30284 !! test
30285 Catch regression when unpacking misnested links
30286 !! options
30287 parsoid=wt2html
30288 !! wikitext
30289 {{echo|hi}}[http://example.com [[ho]]]
30290 !! html/parsoid
30291 <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>
30292 !! end
30293
30294 !! test
30295 Catch regression when unpacking with trailing content
30296 !! wikitext
30297 {{echo|Foo <references/> bar}}
30298 !! html/parsoid
30299 <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>
30300 !! end
30301
30302 !! test
30303 Use data-parsoid.firstWikitextNode to compute newline constraints for template content
30304 !! options
30305 parsoid=html2wt
30306 !! html/parsoid
30307 <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|}"]}'>
30308 <tbody><tr><td>d
30309 </td></tr>
30310 </tbody></table>
30311 !! wikitext
30312 {{echo|a}}
30313 {|{{echo|c
30314 {{!}}d
30315 }}
30316 |}
30317 !! end
30318
30319 ## This test verifies the presence and computation of this attribute indirectly
30320 ## by making an edit and ensuring that the serialization is correct (which it would be
30321 ## only if firstWikitextNode is properly set).
30322 !! test
30323 data-parsoid.firstWikitextNode should be computed properly in the presence of fostered content
30324 !! options
30325 parsoid= {
30326 "modes": ["wt2wt"],
30327 "changes": [
30328 [ "div#x", "remove" ],
30329 [ "div", "before", "<div>new</div>" ]
30330 ]
30331 }
30332 !! wikitext
30333 <div id="x">foo</div>
30334 {|
30335 {{echo|<div>boo</div>
30336 {{!}}b}}
30337 |c
30338 |}
30339 !! wikitext/edited
30340
30341 <div>new</div>
30342 {|
30343 {{echo|<div>boo</div>
30344 {{!}}b}}
30345 |c
30346 |}
30347 !! end
30348
30349 # --------------------------------------------
30350 # Tests spec'ing wikitext serialization norms |
30351 # --------------------------------------------
30352
30353 !! test
30354 Serialize multi-line indent-pre starting with wikitext syntax
30355 !! options
30356 parsoid=html2wt
30357 !! html/parsoid
30358 <pre>* 1
30359 ** 2
30360 * 3</pre>
30361 !! wikitext
30362 * 1
30363 ** 2
30364 * 3
30365 !! end
30366
30367 !! test
30368 1. Categories should always be serialized on their own line
30369 !! options
30370 parsoid=html2wt
30371 !! html/parsoid
30372 foo<link rel="mw:PageProp/Category" href="./Category:Foo">bar
30373 !! wikitext
30374 foo
30375 [[Category:Foo]]
30376 bar
30377 !! end
30378
30379 !! test
30380 2. Categories that are part of templates should not introduce a line break
30381 !! wikitext
30382 foo {{echo|<span>bar</span> [[Category:baz]]}} bar
30383 !! html/parsoid
30384 <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>
30385 !! end
30386
30387 # Careful while editing these next 2 tests. There are \u200f characters
30388 # before and after the <link> tags in the HTML and following some
30389 # of the categories in wikitext
30390 # Do not remove these characters in edits.
30391 #
30392 # As part of the serialization, these bidi characters will get stripped.
30393 !! test
30394 RTL (\u200f) and LTR (\u200e) markers around category tags should be stripped
30395 !! options
30396 parsoid={
30397 "modes": ["html2wt"],
30398 "scrubWikitext": true
30399 }
30400 !! html/parsoid
30401 <p>‏<link rel="mw:PageProp/Category" href="./קטגוריה:טקסים" />‏
30402 ‏<link rel="mw:PageProp/Category" href="./קטגוריה:_שיטות_משפט" />‏</p>
30403 !! wikitext
30404 [[קטגוריה:טקסים]]
30405 [[קטגוריה: שיטות משפט]]
30406 !! end
30407
30408 !! test
30409 RTL (\u200f) and LTR (\u200e) markers should not be stripped if followed by a text node
30410 !! options
30411 parsoid={
30412 "modes": ["html2wt"],
30413 "scrubWikitext": true
30414 }
30415 !! html/parsoid
30416 <p>‏<link rel="mw:PageProp/Category" href="./קטגוריה:טקסים" />‏y</p>
30417 !! wikitext
30418 [[קטגוריה:טקסים]]
30419 ‏y
30420 !! end
30421
30422 !! test
30423 Lists: Add space after bullets
30424 !! options
30425 parsoid=html2wt
30426 !! html/parsoid
30427 <ul>
30428 <li>foo</li>
30429 <li> bar</li>
30430 <li><span> baz</span></li>
30431 </ul>
30432 !! wikitext
30433 * foo
30434 * bar
30435 * <span> baz</span>
30436 !! end
30437
30438 !! test
30439 1. Headings: Add space before/after == (T53744)
30440 !! options
30441 parsoid=html2wt
30442 !! html/parsoid
30443 <h2>foo</h2>
30444 <h2> bar</h2>
30445 <h2>baz </h2>
30446 <h2><span> baz</span></h2>
30447 !! wikitext
30448 == foo ==
30449
30450 == bar ==
30451
30452 == baz ==
30453
30454 == <span> baz</span> ==
30455 !! end
30456
30457 !! test
30458 2. Headings: Add space before/after == even after hoisted content
30459 !! options
30460 parsoid={
30461 "modes": ["html2wt"],
30462 "scrubWikitext": true
30463 }
30464 !! html/parsoid
30465 <h2> <link href="./Category:A2" rel="mw:PageProp/Category" />ok</h2>
30466 !! wikitext
30467 [[Category:A2]]
30468
30469 == ok ==
30470 !! end
30471
30472 !! test
30473 1. Headings: suppress newly created empty headings
30474 !! options
30475 parsoid={
30476 "modes": ["html2wt"],
30477 "scrubWikitext": true
30478 }
30479 !! html/parsoid
30480 <h2></h2>
30481 !! wikitext
30482 !! end
30483
30484 !! test
30485 2. Headings: don't suppress empty headings if scrubWikitext is false
30486 !! options
30487 parsoid=html2wt
30488 !! html/parsoid
30489 <h2></h2>
30490 !! wikitext
30491 ==<nowiki/>==
30492 !! end
30493
30494 !! test
30495 3. Headings: suppress empty headings on edits
30496 !! options
30497 parsoid={
30498 "modes": ["selser"],
30499 "scrubWikitext": true,
30500 "changes": [
30501 [ "#x", "remove"]
30502 ]
30503 }
30504 !! wikitext
30505 ==<span id="x">foo</span>==
30506 !! wikitext/edited
30507 !! end
30508
30509 !! test
30510 Headings: Replace <br/> with a single whitespace char (when scrubWikitext = true)
30511 !! options
30512 parsoid={
30513 "modes": ["html2wt"],
30514 "scrubWikitext": true
30515 }
30516 !! html/parsoid
30517 <h2>foo<br/>bar</h2>
30518 <h2>foo <span><br/>bar</span> baz</h2>
30519 !! wikitext
30520 == foo bar ==
30521
30522 == foo <span> bar</span> baz ==
30523 !! end
30524
30525 !! test
30526 Headings: Replace <br/> with a single whitespace char (when scrubWikitext = false)
30527 !! options
30528 parsoid={
30529 "modes": ["html2wt"],
30530 "scrubWikitext": false
30531 }
30532 !! html/parsoid
30533 <h2>foo<br/>bar</h2>
30534 !! wikitext
30535 == foo<br />bar ==
30536 !! end
30537
30538 !! test
30539 1. WT Quote Tags: suppress newly created empty style tags
30540 !! options
30541 parsoid={
30542 "modes": ["html2wt"],
30543 "scrubWikitext": true
30544 }
30545 !! html/parsoid
30546 <i></i><b></b>
30547 !! wikitext
30548 !! end
30549
30550 !! test
30551 2. WT Quote Tags: don't suppress empty style tags if scrubWikitext is false
30552 !! options
30553 parsoid=html2wt
30554 !! html/parsoid
30555 <i></i><b></b>
30556 !! wikitext
30557 ''<nowiki/>'''''<nowiki/>'''
30558 !! end
30559
30560 !! test
30561 3. WT Quote Tags: suppress empty style tags on edits
30562 !! options
30563 parsoid={
30564 "modes": ["selser"],
30565 "scrubWikitext": true,
30566 "changes": [
30567 [ "#x", "remove"]
30568 ]
30569 }
30570 !! wikitext
30571 '''<span id="x">foo</span>'''
30572 !! wikitext/edited
30573 !! end
30574
30575 !! test
30576 1. Anchors: suppress newly created empty anchors
30577 !! options
30578 parsoid={
30579 "modes": ["html2wt"],
30580 "scrubWikitext": true
30581 }
30582 !! html/parsoid
30583 <a rel="mw:WikiLink" href="./Test" title="Test"></a>
30584 !! wikitext
30585 !! end
30586
30587 !! test
30588 2. Anchors: don't suppress empty anchors if scrubWikitext is false
30589 !! options
30590 parsoid={
30591 "modes": ["html2wt"],
30592 "scrubWikitext": false
30593 }
30594 !! html/parsoid
30595 <a rel="mw:WikiLink" href="./Test" title="Test"></a>
30596 !! wikitext
30597 [[Test|<nowiki/>]]
30598 !! end
30599
30600 !! test
30601 3. Anchors: suppress empty anchors on edits
30602 !! options
30603 parsoid={
30604 "modes": ["selser"],
30605 "scrubWikitext": true,
30606 "changes": [
30607 [ "#x", "remove"]
30608 ]
30609 }
30610 !! wikitext
30611 [[Test|<span id="x">foo</span>]]
30612 !! wikitext/edited
30613 !! end
30614
30615 !! test
30616 3a. Anchors: do not suppress numbered extlinks
30617 !! options
30618 parsoid={
30619 "modes": ["wt2wt"],
30620 "scrubWikitext": true
30621 }
30622 !! wikitext
30623 [http://foo.com]
30624 !! html/parsoid
30625 <a rel="mw:ExtLink" href="http://foo.com"></a>
30626 !! end
30627
30628 !! test
30629 3b. Anchors: do not suppress numbered extlinks
30630 !! options
30631 parsoid={
30632 "modes": ["wt2wt"],
30633 "scrubWikitext": true,
30634 "changes": [
30635 [ "#x", "remove"]
30636 ]
30637 }
30638 !! wikitext
30639 [http://foo.com <span id="x">foo</span>]
30640 !! wikitext/edited
30641 [http://foo.com]
30642 !! end
30643
30644 !!test
30645 Normalizations should be restricted to edited content
30646 !!options
30647 parsoid={
30648 "modes": ["selser"],
30649 "scrubWikitext": true,
30650 "changes": [
30651 [ "h1", "before", "<i></i>"]
30652 ]
30653 }
30654 !!wikitext
30655 a
30656 = =
30657 b
30658 !!wikitext/edited
30659 a
30660 = =
30661 b
30662 !!end
30663
30664 !! test
30665 1. Multiple normalizations (html2wt)
30666 !! options
30667 parsoid={
30668 "modes": ["html2wt"],
30669 "scrubWikitext": true
30670 }
30671 !! html/parsoid
30672 <h2><i></i></h2>
30673 <p><a href='Foo' rel='mw:WikiLink'>foo<i></i>
30674 </a><b><i></i></b>x</p>
30675 !! wikitext
30676
30677 [[foo]]
30678 x
30679
30680 !! end
30681
30682 !! test
30683 2. Multiple normalizations (selser)
30684 !! options
30685 parsoid={
30686 "modes": ["selser"],
30687 "scrubWikitext": true,
30688 "changes": [
30689 [ "#x", "after", "<h1><i></i></h1>\n<p> bar<b></b></p>"]
30690 ]
30691 }
30692 !! wikitext
30693 <div id="x">foo</div>
30694 !! wikitext/edited
30695 <div id="x">foo</div>
30696 bar
30697 !! end
30698
30699 !! test
30700 1. Indent Pre Nowiki: suppress whitespace at the start of new paragraph
30701 !! options
30702 parsoid={
30703 "modes": ["html2wt"],
30704 "scrubWikitext": true
30705 }
30706 !! html/parsoid
30707 <p> hi</p>
30708 <p> hello</p>
30709 !! wikitext
30710 hi
30711
30712 hello
30713 !! end
30714
30715 !! test
30716 2. Indent Pre Nowiki: don't suppress whitespace at the start of new paragraph if scrubWikitext is false
30717 !! options
30718 parsoid=html2wt
30719 !! html/parsoid
30720 <p> hi</p>
30721 <p> hello</p>
30722 !! wikitext
30723 <nowiki> </nowiki>hi
30724
30725 <nowiki> </nowiki> hello
30726 !! end
30727
30728 !! test
30729 3. Indent Pre Nowiki: suppress whitespace after newlines in new paragraph or table cell
30730 !! options
30731 parsoid={
30732 "modes": ["html2wt"],
30733 "scrubWikitext": true
30734 }
30735 !! html/parsoid
30736 <p>Foo
30737 bar
30738 baz</p>
30739
30740 <table><tr><td>Foo
30741 bar
30742 baz bang</td></tr></table>
30743
30744 <p><!--boo--> foo
30745 bar</p>
30746
30747 <p> foo
30748 bar<span>boo</span></p>
30749 !! wikitext
30750 Foo
30751 bar
30752 baz
30753
30754 {|
30755 |Foo
30756 bar
30757 baz bang
30758 |}
30759
30760 <!--boo-->foo
30761 bar
30762
30763 foo
30764 bar<span>boo</span>
30765 !! end
30766
30767 !! test
30768 4. Indent Pre Nowiki: suppress leading whitespace in edited paragraphs
30769 !! options
30770 parsoid={
30771 "modes": ["selser"],
30772 "scrubWikitext": true,
30773 "changes": [
30774 [ "p", "html", " a\n b" ]
30775 ]
30776 }
30777 !! wikitext
30778 xyz
30779 !! wikitext/edited
30780 a
30781 b
30782 !! end
30783
30784 !! test
30785 1. New links that end in spaces
30786 !! options
30787 parsoid={
30788 "modes": ["html2wt"],
30789 "scrubWikitext": false
30790 }
30791 !! html/parsoid
30792 <p><a rel="mw:WikiLink" href="./Berlin" title="Berlin">Berlin </a>is the capital of Germany.</p>
30793 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo </a><b>bar</b></p>
30794 <p><a rel="mw:WikiLink" href="./Boston" title="Boston">Boston </a> is a city.</p>
30795 !! wikitext
30796 [[Berlin ]]<nowiki/>is the capital of Germany.
30797
30798 [[Foo ]]'''bar'''
30799
30800 [[Boston ]] is a city.
30801 !! end
30802
30803 !! test
30804 2. New links that end in spaces
30805 !! options
30806 parsoid={
30807 "modes": ["html2wt"],
30808 "scrubWikitext": true
30809 }
30810 !! html/parsoid
30811 <p><a rel="mw:WikiLink" href="./Berlin" title="Berlin">Berlin </a>is the capital of Germany.</p>
30812 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo </a><b>bar</b></p>
30813 <p><a rel="mw:WikiLink" href="./Boston" title="Boston">Boston </a> is a city.</p>
30814 !! wikitext
30815 [[Berlin]] is the capital of Germany.
30816
30817 [[Foo]] '''bar'''
30818
30819 [[Boston]] is a city.
30820 !! end
30821
30822 !! test
30823 1. Table cells with escapable prefixes
30824 !! options
30825 parsoid={
30826 "modes": ["html2wt"],
30827 "scrubWikitext": false
30828 }
30829 !! html/parsoid
30830 <table>
30831 <tr><td>a</td></tr>
30832 <tr><td>-</td></tr>
30833 <tr><td>+</td></tr>
30834 <tr><td>}</td></tr>
30835 </table>
30836 !! wikitext
30837 {|
30838 |a
30839 |-
30840 |<nowiki>-</nowiki>
30841 |-
30842 |<nowiki>+</nowiki>
30843 |-
30844 |<nowiki>}</nowiki>
30845 |}
30846 !! end
30847
30848 !! test
30849 2. Table cells with escapable prefixes
30850 !! options
30851 parsoid={
30852 "modes": ["html2wt"],
30853 "scrubWikitext": true
30854 }
30855 !! html/parsoid
30856 <table>
30857 <tr><td>a</td></tr>
30858 <tr><td>-</td></tr>
30859 <tr><td>+</td></tr>
30860 <tr><td>}</td></tr>
30861 </table>
30862 !! wikitext
30863 {|
30864 |a
30865 |-
30866 | -
30867 |-
30868 | +
30869 |-
30870 | }
30871 |}
30872 !! end
30873
30874 !! test
30875 3a. Table cells with escapable prefixes after edits
30876 !! options
30877 parsoid={
30878 "modes": ["selser"],
30879 "scrubWikitext": true,
30880 "changes": [
30881 [ "table tbody tr:first-child td:first-child", "remove"]
30882 ]
30883 }
30884 !! wikitext
30885 {|
30886 |a||-
30887 |}
30888 !! wikitext/edited
30889 {|
30890 | -
30891 |}
30892 !! end
30893
30894 !! test
30895 3b. Table cells with escapable prefixes after edits
30896 !! options
30897 parsoid={
30898 "modes": ["selser"],
30899 "scrubWikitext": true,
30900 "changes": [
30901 [ "table tbody tr:first-child td:first-child", "html", "-" ],
30902 [ "#x", "remove" ]
30903 ]
30904 }
30905 !! wikitext
30906 {|
30907 |pqr
30908 |<span id="x">foo</span>+
30909 |}
30910 !! wikitext/edited
30911 {|
30912 | -
30913 | +
30914 |}
30915 !! end
30916
30917 # FIXME: This test will fail because
30918 # normalization doesn't realize that the id attribute
30919 # will eliminate the escapable scenario
30920 !! test
30921 4a. Table cells without escapable prefixes after edits
30922 !! options
30923 parsoid={
30924 "modes": ["selser"],
30925 "scrubWikitext": true,
30926 "changes": [
30927 [ "#x", "html", "-" ]
30928 ]
30929 }
30930 !! wikitext
30931 {|
30932 | id="x" |abcd
30933 |}
30934 !! wikitext/edited
30935 {|
30936 | id="x" |-
30937 |}
30938 !! end
30939
30940 ## This tests normalizer's ability to discriminate between
30941 ## cells having identical content.
30942 !! test
30943 4b. Table cells without escapable prefixes after edits
30944 !! options
30945 parsoid={
30946 "modes": ["selser"],
30947 "scrubWikitext": true,
30948 "changes": [
30949 [ "td", "html", "-" ]
30950 ]
30951 }
30952 !! wikitext
30953 {|
30954 |a||b
30955 |}
30956 !! wikitext/edited
30957 {|
30958 | -||-
30959 |}
30960 !! end
30961
30962 ## This tests normalizer's ability to not be tripped by
30963 ## comments (and whitespace)
30964 !! test
30965 4c. Table cells without escapable prefixes after edits
30966 !! options
30967 parsoid={
30968 "modes": ["selser"],
30969 "scrubWikitext": true,
30970 "changes": [
30971 [ "table tbody tr td:first-child", "remove" ]
30972 ]
30973 }
30974 !! wikitext
30975 {|
30976 |-
30977 <!--foo--> |a||-
30978 |}
30979 !! wikitext/edited
30980 {|
30981 |-
30982 <!--foo--> | -
30983 |}
30984 !! end
30985
30986 ## This tests normalizer's ability to handle HTML cells
30987 !! test
30988 4d. Table cells without escapable prefixes after edits
30989 !! options
30990 parsoid={
30991 "modes": ["selser"],
30992 "scrubWikitext": true,
30993 "changes": [
30994 [ "td", "html", "-" ]
30995 ]
30996 }
30997 !! wikitext
30998 <table>
30999 <tr><td>a</td></tr>
31000 </table>
31001 !! wikitext/edited
31002 <table>
31003 <tr><td>-</td></tr>
31004 </table>
31005 !! end
31006
31007 ## T111151 Remove font elements without attributes
31008 !! test
31009 5a. font tags without attributes should be dropped in scrubWikitext mode
31010 !! options
31011 parsoid={
31012 "modes": ["html2wt"],
31013 "scrubWikitext": true
31014 }
31015 !! html/parsoid
31016 <font>foo</font>
31017 <font><font>bar</font></font>
31018 <font class="x">boo</font>
31019 !! wikitext
31020 foo
31021 bar
31022 <font class="x">boo</font>
31023 !! end
31024
31025 !! test
31026 5b. font tags should not be dropped without scrubWikitext being enabled
31027 !! options
31028 parsoid={
31029 "modes": ["html2wt"],
31030 "scrubWikitext": false
31031 }
31032 !! html/parsoid
31033 <font>foo</font>
31034 !! wikitext
31035 <font>foo</font>
31036 !! end
31037
31038 !! test
31039 Ignore empty <p></p> when scrubWikitext is false
31040 !! options
31041 parsoid={
31042 "modes": ["html2wt"],
31043 "scrubWikitext": false
31044 }
31045 !! html/parsoid
31046 <div>1</div>
31047 <p>a</p><p></p><p>b</p>
31048 <div>2</div>
31049 <p>a</p>
31050 <p></p>
31051 <p>b</p>
31052 <div>3</div>
31053 <p>a</p>
31054 <p></p>
31055 <p></p>
31056 <p></p>
31057 <p></p>
31058 <p>b</p>
31059 !! wikitext
31060 <div>1</div>
31061 a
31062
31063 b
31064 <div>2</div>
31065 a
31066
31067 b
31068 <div>3</div>
31069 a
31070
31071 b
31072 !! html/php+tidy
31073 <div>1</div>
31074 <p>a
31075 </p><p>b
31076 </p>
31077 <div>2</div>
31078 <p>a
31079 </p><p>b
31080 </p>
31081 <div>3</div>
31082 <p>a
31083 </p><p>b
31084 </p>
31085 !! end
31086
31087 !! test
31088 Normalize empty paragraphs to HTML form that html2wt expects
31089 !! options
31090 parsoid={
31091 "modes": ["html2wt"],
31092 "scrubWikitext": true
31093 }
31094 !! html/parsoid
31095 <div>1</div>
31096 <p>a</p><p></p><p>b</p>
31097 <div>2</div>
31098 <p>a</p>
31099 <p></p>
31100 <p>b</p>
31101 <div>3</div>
31102 <p>a</p>
31103 <p></p>
31104 <p></p>
31105 <p></p>
31106 <p></p>
31107 <p>b</p>
31108 <div>4</div>
31109 <p>a</p>
31110 <p></p>
31111 <div>foo</div>
31112 !! wikitext
31113 <div>1</div>
31114 a
31115
31116
31117 b
31118 <div>2</div>
31119 a
31120
31121
31122 b
31123 <div>3</div>
31124 a
31125
31126
31127
31128
31129
31130 b
31131 <div>4</div>
31132 a
31133
31134 <br />
31135 <div>foo</div>
31136 !! html/php+tidy
31137 <div>1</div>
31138 <p>a
31139 </p><p><br />
31140 b
31141 </p>
31142 <div>2</div>
31143 <p>a
31144 </p><p><br />
31145 b
31146 </p>
31147 <div>3</div>
31148 <p>a
31149 </p><p><br />
31150 </p><p><br />
31151 </p><p>b
31152 </p>
31153 <div>4</div>
31154 <p>a
31155 </p><p><br />
31156 </p>
31157 <div>foo</div>
31158 !! end
31159
31160 !! test
31161 Empty paragraphs (marked with mw-empty-elt) found in source should not be normalized away
31162 !! options
31163 parsoid={
31164 "modes": ["html2wt"],
31165 "scrubWikitext": true
31166 }
31167 !! html/parsoid
31168 <table>
31169 <tbody>
31170 <tr>
31171 <td><div>foo
31172 </div>
31173 <p class="mw-empty-elt"></p>
31174 </td>
31175 </tr>
31176 </tbody>
31177 <caption></caption>
31178 </table>
31179 !! wikitext
31180 {|
31181 |<div>foo
31182 </div>
31183 |+
31184 |}
31185 !! end
31186
31187 !! test
31188 Templated content should be skipped over by normalization
31189 !! options
31190 parsoid={
31191 "modes": ["html2wt"],
31192 "scrubWikitext": true
31193 }
31194 !! html/parsoid
31195 <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">
31196 </span><p about="#mwt2"></p><span about="#mwt2">
31197 </span>
31198 !! wikitext
31199 {{SomeTemplate1|boo}}{{SomeTemplate2|booboo}}
31200 !! end
31201
31202 !! test
31203 Escape nowiki DOM elements
31204 !! options
31205 parsoid=html2wt
31206 !! html/parsoid
31207 <nowiki><i>foo</i></nowiki>
31208 !! wikitext
31209 &lt;nowiki&gt;''foo''&lt;/nowiki&gt;
31210 !! end
31211
31212 # This is meant to be an interim fix while we go about figuring out
31213 # how to not introduce these trailing <nowiki/>s in the first place.
31214 !! test
31215 T115717: Strip trailing <nowiki/>s (without affecting valid uses)
31216 !! options
31217 parsoid=html2wt
31218 !! html/parsoid
31219 <p>x<meta typeof="mw:Placeholder" data-parsoid='{"src":"&lt;nowiki/>"}'/><meta typeof="mw:Placeholder" data-parsoid='{"src":"&lt;nowiki/>"}'/>
31220 y</p>
31221 <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>
31222 <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>
31223 !! wikitext
31224 x
31225 y
31226
31227 {{echo|
31228 1 = <nowiki/>}}
31229
31230 {{echo|
31231 1 = <nowiki/>
31232 }}
31233 !! end
31234
31235 !! test
31236 New list is serialized on newlines
31237 !! options
31238 parsoid=html2wt
31239 !! html/parsoid
31240 <p>The quick brown fox jumps over the lazy dog.</p><ul>
31241 <li>Yesterday</li>
31242 <li>Today</li>
31243 <li>Tomorrow</li>
31244 </ul><p>The quick onyx goblin jumps over the lazy dwarf.</p>
31245 !! wikitext
31246 The quick brown fox jumps over the lazy dog.
31247
31248 * Yesterday
31249 * Today
31250 * Tomorrow
31251
31252 The quick onyx goblin jumps over the lazy dwarf.
31253 !! end
31254
31255 !! test
31256 New lists in formatting elements serialized w/o newlines
31257 !! options
31258 parsoid=html2wt
31259 !! html/parsoid
31260 <small>
31261
31262 <ul>
31263 <li>123</li>
31264 </ul>
31265
31266 </small>
31267
31268 <small><ul><li>hi</li></ul></small>
31269 !! wikitext
31270 <small>
31271 * 123
31272 </small>
31273
31274 <small>
31275 * hi
31276 </small>
31277 !! end
31278
31279 !! test
31280 New list in table doesn't need newlines
31281 !! options
31282 parsoid=html2wt
31283 !! html/parsoid
31284 <table><tr><td><ul><li>test</li><li>123</li></td></tr></table>
31285 !! wikitext
31286 {|
31287 |
31288 * test
31289 * 123
31290 |}
31291 !! end
31292
31293 # ---------------------------------------------------
31294 # End of tests spec'ing wikitext serialization norms |
31295 # ---------------------------------------------------
31296
31297 # T104032
31298 !! test
31299 Bare inline nodes not wrapped inside p-tags should be treated as p-wrapped
31300 !! options
31301 parsoid=html2wt
31302 !! html/parsoid
31303 a<p>b</p>
31304 <b>c</b><p>d</p>
31305 <table><tr>
31306 <td>a<p>b</p></td>
31307 <td><b>c</b><p>d</p></td>
31308 </tr></table>
31309 !! wikitext
31310 a
31311
31312 b
31313
31314 '''c'''
31315
31316 d
31317 {|
31318 |a
31319 b
31320 |'''c'''
31321 d
31322 |}
31323 !! end
31324
31325 !! test
31326 Anchor without href scenarios
31327 !! options
31328 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
31329 !! html/parsoid
31330 <a class="bc"></a>
31331 <a class="no">dice</a>
31332 <a name="foo"></a>
31333 !! wikitext
31334
31335 dice
31336 <span name="foo"></span>
31337 !! end
31338
31339 !! test
31340 New transclusion added after a list should be serialized after the list
31341 !! options
31342 parsoid=html2wt
31343 !! html/parsoid
31344 <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>
31345 !! wikitext
31346 * a
31347 {{echo|foo}}
31348 !! end
31349
31350 # -----------------------------------------------------------------
31351 # End of section for Parsoid-only html2wt tests for serialization
31352 # of new content
31353 # -----------------------------------------------------------------
31354
31355 # -----------------------------------------------------------------
31356 # The following section of tests are primarily to spec behavior of
31357 # the selective serializer. All these tests have manual selser
31358 # changes. The automated selser changes for all tests handle the
31359 # wide variation of changes, but these tests here capture specs
31360 # deterministically.
31361 # ----------------------------------------------------------------
31362
31363 ## T90517
31364 !! test
31365 Selser: New comments should not be lost
31366 !! options
31367 parsoid={
31368 "modes": ["selser"],
31369 "changes": [
31370 [ "#a", "after", "<!--c1-->" ],
31371 [ "#b", "before", "<!--c2-->" ]
31372 ]
31373 }
31374 !! wikitext
31375 <span id="a">a</span>
31376
31377 <span id="b">b</span>
31378 !! wikitext/edited
31379 <span id="a">a</span><!--c1-->
31380
31381 <!--c2--><span id="b">b</span>
31382 !! end
31383
31384 ## T89383
31385 !! test
31386 Selser: Check for validity of DSR before using it
31387 !! options
31388 parsoid={
31389 "modes": ["selser"],
31390 "changes": [
31391 [ "#a", "before", "<meta property='mw:PageProp/displaytitle' content='foo'>" ]
31392 ]
31393 }
31394 !! wikitext
31395 <span id="a">a</span>
31396 !! wikitext/edited
31397 {{DISPLAYTITLE:foo}}
31398 <span id="a">a</span>
31399 !! end
31400
31401 !! test
31402 1. DOMDiff: Changes to <ref> content should be looked up using id
31403 !! options
31404 parsoid={
31405 "modes": ["selser"],
31406 "changes": [
31407 ["#X", "after", "bar"],
31408 ["#Y", "after", "baz"]
31409 ]
31410 }
31411 !! wikitext
31412 X <ref><span id="X">foo</span></ref>
31413 Y <ref name="a" />
31414 <references>
31415 <ref name="a"><span id="Y">foo</span></ref>
31416 </references>
31417 !! wikitext/edited
31418 X <ref><span id="X">foo</span>bar</ref>
31419 Y <ref name="a" />
31420 <references>
31421 <ref name="a"><span id="Y">foo</span>baz</ref>
31422 </references>
31423 !! end
31424
31425 !! test
31426 2. DOMDiff: Changes to <ref> content should be looked up using id
31427 !! options
31428 parsoid={
31429 "modes": ["selser"],
31430 "changes": [
31431 ["#Z", "after", "bar"]
31432 ]
31433 }
31434 !! wikitext
31435 A <ref>foo bar for a</ref>
31436 B <ref group="X" name="b" />
31437
31438 <references />
31439
31440 <references group="X">
31441 <ref name="b"><span id="Z">foo</span></ref>
31442 </references>
31443 !! wikitext/edited
31444 A <ref>foo bar for a</ref>
31445 B <ref group="X" name="b" />
31446
31447 <references />
31448
31449 <references group="X">
31450 <ref name="b"><span id="Z">foo</span>bar</ref>
31451 </references>
31452 !! end
31453
31454 !! test
31455 DOMDiff: Edits to content nested in elements with templated attributes should not be lost (T139388)
31456 !! options
31457 parsoid={
31458 "modes": ["selser"],
31459 "changes": [
31460 [ "div:first-child", "text", "bar" ]
31461 ]
31462 }
31463 !! wikitext
31464 <div style="{{1x|color:red;}}%">foo</div>
31465 !! wikitext/edited
31466 <div style="{{1x|color:red;}}%">bar</div>
31467 !! end
31468
31469 !! test
31470 Empty LI (T49673)
31471 !! wikitext
31472 *a
31473 *
31474 *
31475 *b
31476 !! html+tidy
31477 <ul><li>a</li>
31478 <li class="mw-empty-elt"></li>
31479 <li class="mw-empty-elt"></li>
31480 <li>b</li></ul>
31481 !! end
31482
31483 !! test
31484 Thumbnail output
31485 !! wikitext
31486 [[File:Thumb.png|thumb]]
31487 !! html/php+tidy
31488 <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>
31489 !! html/parsoid
31490 <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>
31491 !! end
31492
31493 !! test
31494 unclosed internal link XSS (T137264)
31495 !! wikitext
31496 [[#%3Cscript%3Ealert(1)%3C/script%3E|
31497 !! html/php
31498 <p>[[#&lt;script&gt;alert(1)&lt;/script&gt;|
31499 </p>
31500 !! html/parsoid
31501 <p>[[#%3Cscript%3Ealert(1)%3C/script%3E|</p>
31502 !! end
31503
31504 !! test
31505 Validating that <style> isn't eaten by tidy (T167349)
31506 !! options
31507 styletag=1
31508 !! wikitext
31509 <div class="foo">
31510 <style>.foo::before { content: "<foo>"; }</style>
31511 <style data-mw-foobar="baz">.foo::after { content: "<bar>"; }</style>
31512 </div>
31513 !! html/php+tidy
31514 <div class="foo">
31515 <style>.foo::before { content: "<foo>"; }</style>
31516 <style data-mw-foobar="baz">.foo::after { content: "<bar>"; }</style>
31517 </div>
31518 !! html/parsoid
31519 <div class="foo">
31520 <style typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{},"body":{"extsrc":".foo::before { content: \"&lt;foo>\"; }"}}'>.foo::before { content: "<foo>"; }</style>
31521 <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>
31522 </div>
31523 !! end
31524
31525 ## Right now, Parsoid doesn't de-duplicate style tags.
31526 ## So, we shouldn't see link tags that need to bypass the sanitizer.
31527 ## In a followup patch, when we de-duplicate style tags and
31528 ## introduce link tags, we'll add a hook for link tags in
31529 ## the parser test runner script.
31530 !! test
31531 Validating that <style> isn't wrapped in a paragraph (T186965)
31532 !! options
31533 styletag=1
31534 !! wikitext
31535 A style tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
31536
31537 <style>.foo::before { content: "<foo>"; }</style>
31538
31539 <style>.foo::before { content: "<foo>"; }</style> <link rel="foo" href="bar"/><style>.foo::before { content: "<foo>"; }</style>
31540
31541 But if it's on a line with other content, let it be wrapped.
31542
31543 <style>.foo::before { content: "<foo>"; }</style> bar
31544
31545 foo <style>.foo::before { content: "<foo>"; }</style>
31546
31547 foo <style>.foo::before { content: "<foo>"; }</style> bar
31548
31549 And the same if we have non-paragraph-breaking whitespace
31550
31551 foo
31552 <style>.foo::before { content: "<foo>"; }</style>
31553 bar
31554 !! html/php
31555 <p>A style tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
31556 </p>
31557 <style>.foo::before { content: "<foo>"; }</style>
31558 <style>.foo::before { content: "<foo>"; }</style> <link rel="foo" href="bar"/><style>.foo::before { content: "<foo>"; }</style>
31559 <p>But if it's on a line with other content, let it be wrapped.
31560 </p><p><style>.foo::before { content: "<foo>"; }</style> bar
31561 </p><p>foo <style>.foo::before { content: "<foo>"; }</style>
31562 </p><p>foo <style>.foo::before { content: "<foo>"; }</style> bar
31563 </p><p>And the same if we have non-paragraph-breaking whitespace
31564 </p><p>foo
31565 <style>.foo::before { content: "<foo>"; }</style>
31566 bar
31567 </p>
31568 !! html/parsoid
31569 <p>A style tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph</p>
31570
31571 <style typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{},"body":{"extsrc":".foo::before { content: \"&lt;foo>\"; }"}}'>.foo::before { content: "<foo>"; }</style>
31572
31573 <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>
31574
31575 <p>But if it's on a line with other content, let it be wrapped.</p>
31576
31577 <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>
31578
31579 <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>
31580
31581 <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>
31582
31583 <p>And the same if we have non-paragraph-breaking whitespace</p>
31584
31585 <p>foo
31586 <style typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{},"body":{"extsrc":".foo::before { content: \"&lt;foo>\"; }"}}'>.foo::before { content: "<foo>"; }</style>
31587 bar</p>
31588 !! end
31589
31590 !! test
31591 Validating that <link> isn't wrapped in a paragraph (T186965)
31592 !! options
31593 styletag=1
31594 !! wikitext
31595 A link tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
31596
31597 <link rel="foo" href="bar"/>
31598
31599 <link rel="foo" href="bar"/> <style>.foo::before { content: "<foo>"; }</style><link rel="foo" href="bar"/>
31600
31601 But if it's on a line with other content, let it be wrapped.
31602
31603 <link rel="foo" href="bar"/> bar
31604
31605 foo <link rel="foo" href="bar"/>
31606
31607 foo <link rel="foo" href="bar"/> bar
31608
31609 And the same if we have non-paragraph-breaking whitespace
31610
31611 foo
31612 <link rel="foo" href="bar"/>
31613 bar
31614 !! html/php
31615 <p>A link tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
31616 </p>
31617 <link rel="foo" href="bar"/>
31618 <link rel="foo" href="bar"/> <style>.foo::before { content: "<foo>"; }</style><link rel="foo" href="bar"/>
31619 <p>But if it's on a line with other content, let it be wrapped.
31620 </p><p><link rel="foo" href="bar"/> bar
31621 </p><p>foo <link rel="foo" href="bar"/>
31622 </p><p>foo <link rel="foo" href="bar"/> bar
31623 </p><p>And the same if we have non-paragraph-breaking whitespace
31624 </p><p>foo
31625 <link rel="foo" href="bar"/>
31626 bar
31627 </p>
31628 !! end
31629
31630 !! test
31631 Extension returning multiple nodes starting with a style tag roundtrips
31632 !! options
31633 wgRawHtml=1
31634 !! wikitext
31635 <table>
31636 {{echo|<html><style>.hi { color: red; }</style>
31637 </html>}}
31638 <tr><td class="hi">ho</td></tr>
31639 </table>
31640 !! html/parsoid
31641 <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">
31642 </span></p><table about="#mwt5" data-parsoid='{"stx":"html"}'>
31643
31644 <tbody><tr><td class="hi">ho</td></tr>
31645 </tbody></table>
31646 !! end
31647
31648 !! test
31649 Decoding of HTML entities in headings and links for IDs and link fragments (T103714)
31650 !! config
31651 wgFragmentMode=[ 'html5', 'legacy' ]
31652 !! wikitext
31653 ==A&B&amp;C&amp;amp;D&amp;amp;amp;E==
31654 [[#A&B&amp;C&amp;amp;D&amp;amp;amp;E]]
31655 !! html/php
31656 <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>
31657 <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>
31658 </p>
31659 !! html/parsoid
31660 <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>
31661 <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>
31662 !! end
31663
31664 !! test
31665 Decoding of HTML entities in headings and links for IDs and link fragments (T103714) (legacy)
31666 !! config
31667 wgFragmentMode=[ 'legacy' ]
31668 !! wikitext
31669 ==A&B&amp;C&amp;amp;D&amp;amp;amp;E==
31670 [[#A&B&amp;C&amp;amp;D&amp;amp;amp;E]]
31671 !! html/php
31672 <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>
31673 <p><a href="#A.26B.26C.26amp.3BD.26amp.3Bamp.3BE">#A&amp;B&amp;C&amp;amp;D&amp;amp;amp;E</a>
31674 </p>
31675 !! end
31676
31677 !! test
31678 Decoding of HTML entities in embedded HTML tags
31679 !! wikitext
31680 <table class="1&2&amp;3&amp;amp;4&amp;amp;amp;5"><tr><td>x</td></tr></table>
31681 !! html/php
31682 <table class="1&amp;2&amp;3&amp;amp;4&amp;amp;amp;5"><tr><td>x</td></tr></table>
31683
31684 !! html/parsoid
31685 <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>
31686 !! end
31687
31688 !! test
31689 Decoding of HTML entities in indicator names for IDs (T104196)
31690 !! options
31691 parsoid=wt2html,html2html
31692 showindicators
31693 !! wikitext
31694 <indicator name="1&2&amp;3&amp;amp;4&amp;amp;amp;5">Indicator</indicator>
31695 !! html/php
31696 1&2&3&amp;4&amp;amp;5=Indicator
31697
31698 !! html/parsoid
31699 <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>
31700 !! end
31701
31702 # this version of the test strips out the ambiguity so Parsoid rts cleanly
31703 !! test
31704 Decoding of HTML entities in indicator names for IDs (unambiguous) (T104196)
31705 !! options
31706 showindicators
31707 !! wikitext
31708 <indicator name="1&2&3&amp;amp;4&amp;amp;amp;5">Indicator</indicator>
31709 !! html/php
31710 1&2&3&amp;4&amp;amp;5=Indicator
31711
31712 !! html/parsoid
31713 <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>
31714 !! end
31715
31716 # This fragment mode is what Parsoid supports.
31717 !! test
31718 HTML5 ids: fallback to legacy
31719 !! config
31720 wgFragmentMode=[ 'html5', 'legacy' ]
31721 !! wikitext
31722 ==Foo bar==
31723
31724 ==foo Bar==
31725
31726 ==Тест==
31727
31728 ==Тест==
31729
31730 ==тест==
31731
31732 ==Hey < # " > % : '==
31733 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
31734
31735 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
31736
31737 <!-- These two links should produce identical HTML -->
31738 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
31739
31740 !! html/php
31741 <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>
31742 <ul>
31743 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
31744 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
31745 <li class="toclevel-1 tocsection-3"><a href="#Тест"><span class="tocnumber">3</span> <span class="toctext">Тест</span></a></li>
31746 <li class="toclevel-1 tocsection-4"><a href="#Тест_2"><span class="tocnumber">4</span> <span class="toctext">Тест</span></a></li>
31747 <li class="toclevel-1 tocsection-5"><a href="#тест"><span class="tocnumber">5</span> <span class="toctext">тест</span></a></li>
31748 <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>
31749 </ul>
31750 </div>
31751
31752 <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>
31753 <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>
31754 <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>
31755 <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>
31756 <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>
31757 <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>
31758 <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>
31759 </p><p>💩 <span id="💩"></span>
31760 </p><p><a href="#啤酒">#啤酒</a> <a href="#啤酒">#啤酒</a>
31761 </p>
31762 !! html/parsoid
31763 <h2 id="Foo_bar">Foo bar</h2>
31764
31765 <h2 id="foo_Bar_2">foo Bar</h2>
31766
31767 <h2 id="Тест"><span id=".D0.A2.D0.B5.D1.81.D1.82" typeof="mw:FallbackId"></span>Тест</h2>
31768
31769 <h2 id="Тест_2"><span id=".D0.A2.D0.B5.D1.81.D1.82_2" typeof="mw:FallbackId"></span>Тест</h2>
31770
31771 <h2 id="тест"><span id=".D1.82.D0.B5.D1.81.D1.82" typeof="mw:FallbackId"></span>тест</h2>
31772
31773 <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>
31774 <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>
31775
31776 <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>
31777
31778 <!-- These two links should produce identical HTML -->
31779 <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>
31780 !! end
31781
31782 # Parsoid doesn't support this mode
31783 !! test
31784 HTML5 ids: legacy with a fallback to modern
31785 !! config
31786 wgFragmentMode=[ 'legacy', 'html5' ]
31787 !! wikitext
31788 ==Foo bar==
31789
31790 ==foo Bar==
31791
31792 ==Тест==
31793
31794 ==Тест==
31795
31796 ==тест==
31797
31798 ==Hey < # " > % : '==
31799 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
31800
31801 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
31802
31803 <!-- These two links should produce identical HTML -->
31804 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
31805
31806 !! html/php
31807 <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>
31808 <ul>
31809 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
31810 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
31811 <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>
31812 <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>
31813 <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>
31814 <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>
31815 </ul>
31816 </div>
31817
31818 <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>
31819 <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>
31820 <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>
31821 <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>
31822 <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>
31823 <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>
31824 <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>
31825 </p><p>.F0.9F.92.A9 <span id=".F0.9F.92.A9"></span>
31826 </p><p><a href="#.E5.95.A4.E9.85.92">#啤酒</a> <a href="#.E5.95.A4.E9.85.92">#啤酒</a>
31827 </p>
31828 !! end
31829
31830 # Parsoid doesn't support this mode.
31831 !! test
31832 HTML5 ids: no legacy
31833 !! config
31834 wgFragmentMode=[ 'html5' ]
31835 !! wikitext
31836 ==Foo bar==
31837
31838 ==foo Bar==
31839
31840 ==Тест==
31841
31842 ==Тест==
31843
31844 ==тест==
31845
31846 ==Hey < # " > % : '==
31847 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
31848
31849 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
31850
31851 <!-- These two links should produce identical HTML -->
31852 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
31853
31854 !! html/php
31855 <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>
31856 <ul>
31857 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
31858 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
31859 <li class="toclevel-1 tocsection-3"><a href="#Тест"><span class="tocnumber">3</span> <span class="toctext">Тест</span></a></li>
31860 <li class="toclevel-1 tocsection-4"><a href="#Тест_2"><span class="tocnumber">4</span> <span class="toctext">Тест</span></a></li>
31861 <li class="toclevel-1 tocsection-5"><a href="#тест"><span class="tocnumber">5</span> <span class="toctext">тест</span></a></li>
31862 <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>
31863 </ul>
31864 </div>
31865
31866 <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>
31867 <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>
31868 <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>
31869 <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>
31870 <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>
31871 <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>
31872 <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>
31873 </p><p>💩 <span id="💩"></span>
31874 </p><p><a href="#啤酒">#啤酒</a> <a href="#啤酒">#啤酒</a>
31875 </p>
31876 !! end
31877
31878 !! test
31879 T90902: Normalize weird characters in section IDs
31880 !! config
31881 wgFragmentMode=[ 'html5', 'legacy' ]
31882 !! wikitext
31883 ==Foo&nbsp;bar==
31884 [[#Foo&nbsp;bar]]
31885
31886 !! html/php
31887 <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>
31888 <p><a href="#Foo_bar">#Foo&#160;bar</a>
31889 </p>
31890 !! html/parsoid
31891 <h2 id="Foo_bar"> Foo<span typeof="mw:Entity" data-parsoid='{"src":"&amp;nbsp;","srcContent":" "}'> </span>bar </h2>
31892 <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>
31893 !! end
31894
31895 !! test
31896 T51672: Test for brackets in attributes of elements in external link texts
31897 !! wikitext
31898 [http://example.com/ link <span title="title with [brackets]">span</span>]
31899 [http://example.com/ link <span title="title with &#91;brackets&#93;">span</span>]
31900
31901 !! html/php
31902 <p><a rel="nofollow" class="external text" href="http://example.com/">link <span title="title with &#91;brackets&#93;">span</span></a>
31903 <a rel="nofollow" class="external text" href="http://example.com/">link <span title="title with &#91;brackets&#93;">span</span></a>
31904 </p>
31905 !! html/parsoid
31906 <p><a rel="mw:ExtLink" class="external text" href="http://example.com/">link <span title="title with [brackets]">span</span></a>
31907 <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>
31908 !! end
31909
31910 !! test
31911 T72875: Test for brackets in attributes of elements in internal link texts
31912 !! wikitext
31913 [[Foo|link <span title="title with [[double brackets]]">span</span>]]
31914 [[Foo|link <span title="title with &#91;&#91;double brackets&#93;&#93;">span</span>]]
31915
31916 !! html/php
31917 <p><a href="/wiki/Foo" title="Foo">link <span title="title with &#91;&#91;double brackets&#93;&#93;">span</span></a>
31918 <a href="/wiki/Foo" title="Foo">link <span title="title with &#91;&#91;double brackets&#93;&#93;">span</span></a>
31919 </p>
31920 !! html/parsoid
31921 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">link <span title="title with [[double brackets]]">span</span></a>
31922 <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>
31923 !! end
31924
31925 !! test
31926 T199926: html arrow wt: Parsoid sometimes trips up on verticalbar chars in hrefs
31927 !! options
31928 parsoid={
31929 "modes": ["html2wt"]
31930 }
31931 !! html/parsoid
31932 <a href="https://stats.wikimedia.org/v2/#/fr.wikipedia.org/reading/page-views-by-country/normal|map|2-Year~2016060100~2018071100|~total">9</a>
31933 <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>
31934 !! wikitext
31935 [https://stats.wikimedia.org/v2/#/fr.wikipedia.org/reading/page-views-by-country/normal|map|2-Year~2016060100~2018071100|~total 9]
31936 [[stats:v2/#/fr.wikipedia.org/reading/page-views-by-country/normal%7Cmap%7C2-Year~2016060100~2018071100%7C~total|10]]
31937 !! end
31938
31939 !! test
31940 T179544: {{anchorencode:}} output should be always usable in links
31941 !! config
31942 wgFragmentMode=[ 'html5' ]
31943 !! wikitext
31944 <span id="{{anchorencode:[foo]}}"></span>[[#{{anchorencode:[foo]}}]]
31945 !! html/php
31946 <p><span id="&#91;foo&#93;"></span><a href="#[foo]">#&#91;foo&#93;</a>
31947 </p>
31948 !! html/parsoid
31949 <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>
31950 !! end
31951
31952 ## ------------------------------
31953 ## Parsoid section-wrapping tests
31954 ## ------------------------------
31955 !! test
31956 Section wrapping for well-nested sections (no leading content)
31957 !! options
31958 parsoid={
31959 "wrapSections": true
31960 }
31961 !! wikitext
31962 =1=
31963 a
31964
31965 =2=
31966 b
31967
31968 ==2.1==
31969 c
31970
31971 ==2.2==
31972 d
31973
31974 ===2.2.1===
31975 e
31976
31977 =3=
31978 f
31979 !! html/parsoid
31980 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1>
31981 <p>a</p>
31982
31983 </section><section data-mw-section-id="2"><h1 id="2">2</h1>
31984 <p>b</p>
31985
31986 <section data-mw-section-id="3"><h2 id="2.1">2.1</h2>
31987 <p>c</p>
31988
31989 </section><section data-mw-section-id="4"><h2 id="2.2">2.2</h2>
31990 <p>d</p>
31991
31992 <section data-mw-section-id="5"><h3 id="2.2.1">2.2.1</h3>
31993 <p>e</p>
31994
31995 </section></section></section><section data-mw-section-id="6"><h1 id="3">3</h1>
31996 <p>f</p>
31997
31998 </section>
31999 !! end
32000
32001 !! test
32002 Section wrapping for well-nested sections (with leading content)
32003 !! options
32004 parsoid={
32005 "wrapSections": true
32006 }
32007 !! wikitext
32008 Para 1.
32009
32010 Para 2 with a <div>nested in it</div>
32011
32012 Para 3.
32013
32014 =1=
32015 a
32016
32017 =2=
32018 b
32019
32020 ==2.1==
32021 c
32022 !! html/parsoid
32023 <section data-mw-section-id="0"><p>Para 1.</p>
32024
32025 <p>Para 2 with a </p><div>nested in it</div>
32026
32027 <p>Para 3.</p>
32028
32029 </section><section data-mw-section-id="1"><h1 id="1">1</h1>
32030 <p>a</p>
32031
32032 </section><section data-mw-section-id="2"><h1 id="2">2</h1>
32033 <p>b</p>
32034
32035 <section data-mw-section-id="3"><h2 id="2.1">2.1</h2>
32036 <p>c</p>
32037
32038 </section></section>
32039 !! end
32040
32041 !! test
32042 Section wrapping with template-generated sections (good nesting 1)
32043 !! options
32044 parsoid={
32045 "wrapSections": true
32046 }
32047 !! wikitext
32048 =1=
32049 a
32050
32051 {{echo|1=
32052 ==1.1==
32053 b
32054 }}
32055
32056 ==1.2==
32057 c
32058
32059 =2=
32060 d
32061 !! html/parsoid
32062 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1>
32063 <p>a</p>
32064
32065 <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">
32066 </span><p about="#mwt1">b</p>
32067 </section><section data-mw-section-id="3"><h2 id="1.2">1.2</h2>
32068 <p>c</p>
32069
32070 </section></section><section data-mw-section-id="4"><h1 id="2">2</h1>
32071 <p>d</p></section>
32072 !! end
32073
32074 # In this example, the template scope is mildly expanded to incorporate the
32075 # trailing newline after the transclusion since that is part of section 1.1.1
32076 !! test
32077 Section wrapping with template-generated sections (good nesting 2)
32078 !! options
32079 parsoid={
32080 "wrapSections": true,
32081 "modes": ["wt2html", "wt2wt"]
32082 }
32083 !! wikitext
32084 =1=
32085 a
32086
32087 {{echo|1=
32088 ==1.1==
32089 b
32090 ===1.1.1===
32091 d
32092 }}
32093 =2=
32094 e
32095 !! html/parsoid
32096 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1>
32097 <p>a</p>
32098
32099 <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">
32100 </span><p about="#mwt1">b</p><span about="#mwt1">
32101 </span><section data-mw-section-id="-1" about="#mwt1"><h3 about="#mwt1" id="1.1.1">1.1.1</h3><span about="#mwt1">
32102 </span><p about="#mwt1">d</p><span about="#mwt1">
32103 </span></section></section></section><section data-mw-section-id="4" data-parsoid="{}"><h1 id="2">2</h1>
32104 <p>e</p></section>
32105 !! end
32106
32107 # In this example, the template scope is mildly expanded to incorporate the
32108 # trailing newline after the transclusion since that is part of section 1.2.1
32109 !! test
32110 Section wrapping with template-generated sections (good nesting 3)
32111 !! options
32112 parsoid={
32113 "wrapSections": true,
32114 "modes": ["wt2html", "wt2wt"]
32115 }
32116 !! wikitext
32117 =1=
32118 a
32119
32120 {{echo|1=
32121 x
32122 ==1.1==
32123 b
32124 ==1.2==
32125 c
32126 ===1.2.1===
32127 d
32128 }}
32129 =2=
32130 e
32131 !! html/parsoid
32132 <section data-mw-section-id="0"></section><section data-mw-section-id="1" data-parsoid="{}"><h1 id="1"> 1 </h1>
32133 <p>a</p>
32134
32135 <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">
32136 </span><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="1.1">1.1</h2><span about="#mwt1">
32137 </span><p about="#mwt1">b</p><span about="#mwt1">
32138 </span></section><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="1.2">1.2</h2><span about="#mwt1">
32139 </span><p about="#mwt1">c</p><span about="#mwt1">
32140 </span><section data-mw-section-id="-1" about="#mwt1"><h3 about="#mwt1" id="1.2.1">1.2.1</h3><span about="#mwt1">
32141 </span><p about="#mwt1">d</p><span about="#mwt1">
32142 </span></section></section></section><section data-mw-section-id="5"><h1 id="2">2</h1>
32143 <p>e</p></section>
32144 !! end
32145
32146 # Because of section-wrapping and template-wrapping interactions,
32147 # the scope of the template is expanded so that the template markup
32148 # is valid in the presence of <section> tags.
32149 # This exercises the s1 is null scenario in the wrapSections code
32150 !! test
32151 Section wrapping with template-generated sections (bad nesting 1)
32152 !! options
32153 parsoid={
32154 "wrapSections": true
32155 }
32156 !! wikitext
32157 <div>
32158 a
32159
32160 {{echo|
32161 =1=
32162 b
32163 }}
32164
32165 c
32166 </div>
32167 !! html/parsoid
32168 <section data-mw-section-id="-1"></section><section data-mw-section-id="-2"><div data-parsoid='{"stx":"html"}'>
32169 <p>a</p>
32170
32171 <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"]}'>
32172 </span><section data-mw-section-id="-1" about="#mwt1"><h1 about="#mwt1" id="1">1</h1><span about="#mwt1">
32173 </span><p about="#mwt1">b
32174 </p><span about="#mwt1">
32175
32176 </span><p about="#mwt1">c</p><span about="#mwt1">
32177 </span></section></div></section>
32178 !! end
32179
32180 # Because of section-wrapping and template-wrapping interactions,
32181 # the scope of the template is expanded so that the template markup
32182 # is valid in the presence of <section> tags.
32183 # This exercises the s1 is ancestor of s2 scenario in the wrapSections code
32184 !! test
32185 Section wrapping with template-generated sections (bad nesting 2)
32186 !! options
32187 parsoid={
32188 "wrapSections": true
32189 }
32190 !! wikitext
32191 =1=
32192 a
32193
32194 {{echo|1=
32195 =2=
32196 b
32197 ==2.1==
32198 c
32199 }}
32200
32201 d
32202
32203 =3=
32204 e
32205 !! html/parsoid
32206 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1>
32207 <p>a</p>
32208
32209 </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">
32210 </span><p about="#mwt1">b</p><span about="#mwt1">
32211 </span><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="2.1">2.1</h2><span about="#mwt1">
32212 </span><p about="#mwt1">c</p><span about="#mwt1">
32213
32214 </span><p about="#mwt1">d</p><span about="#mwt1">
32215
32216 </span></section></section><section data-mw-section-id="4"><h1 id="3">3</h1>
32217 <p>e</p></section>
32218 !! end
32219
32220 # Because of section-wrapping and template-wrapping interactions,
32221 # additional template wrappers are added to <section> tags
32222 # so that template wrapping semantics are valid whether section
32223 # tags are retained or stripped. But, the template scope can expand
32224 # greatly when accounting for section tags.
32225 # This exercises the s1 and s2 are in different subtrees scenario
32226 !! test
32227 Section wrapping with template-generated sections (bad nesting 3)
32228 !! options
32229 parsoid={
32230 "wrapSections": true,
32231 "modes": ["wt2html", "wt2wt"]
32232 }
32233 !! wikitext
32234 =1=
32235 a
32236
32237 {{echo|1=
32238 ==1.2==
32239 b
32240 =2=
32241 c
32242 }}
32243
32244 d
32245
32246 =3=
32247 e
32248 !! html/parsoid
32249 <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>
32250 <p>a</p>
32251
32252 <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">
32253 </span><p about="#mwt1">b</p><span about="#mwt1">
32254 </span></section></section><section data-mw-section-id="-1" about="#mwt1"><h1 about="#mwt1" id="2">2</h1><span about="#mwt1">
32255 </span><p about="#mwt1">c</p>
32256
32257 <p>d</p>
32258 </section><section data-mw-section-id="4" data-parsoid="{}"><h1 id="3">3</h1>
32259 <p>e</p></section>
32260 !! end
32261
32262 !! test
32263 Section wrapping with uneditable lead section + div wrapping multiple sections
32264 !! options
32265 parsoid={
32266 "wrapSections": true
32267 }
32268 !! wikitext
32269 foo
32270
32271 <div style="border:1px solid red;">
32272 =1=
32273 a
32274
32275 ==1.1==
32276 b
32277
32278 =2=
32279 c
32280 </div>
32281
32282 =3=
32283 d
32284
32285 ==3.1==
32286 e
32287 !! html/parsoid
32288 <section data-mw-section-id="-1"><p>foo</p>
32289
32290 </section><section data-mw-section-id="-2"><div style="border:1px solid red;">
32291 <section data-mw-section-id="1"><h1 id="1">1</h1>
32292 <p>a</p>
32293
32294 <section data-mw-section-id="2"><h2 id="1.1">1.1</h2>
32295 <p>b</p>
32296
32297 </section></section><section data-mw-section-id="-1"><h1 id="2">2</h1>
32298 <p>c</p>
32299 </section></div>
32300
32301 </section><section data-mw-section-id="4"><h1 id="3">3</h1>
32302 <p>d</p>
32303
32304 <section data-mw-section-id="5"><h2 id="3.1">3.1</h2>
32305 <p>e</p>
32306 </section></section>
32307 !! end
32308
32309 !! test
32310 Section wrapping with editable lead section + div overlapping multiple sections
32311 !! options
32312 parsoid={
32313 "wrapSections": true
32314 }
32315 !! wikitext
32316 foo
32317
32318 =1=
32319 a
32320 <div style="border:1px solid red;">
32321 b
32322
32323 ==1.1==
32324 c
32325
32326 =2=
32327 d
32328 </div>
32329 e
32330
32331 =3=
32332 f
32333
32334 ==3.1==
32335 g
32336 !! html/parsoid
32337 <section data-mw-section-id="0"><p>foo</p>
32338
32339 </section><section data-mw-section-id="-1"><h1 id="1">1</h1>
32340 <p>a</p>
32341 </section><section data-mw-section-id="-2"><div style="border:1px solid red;">
32342 <p>b</p>
32343
32344 <section data-mw-section-id="2"><h2 id="1.1">1.1</h2>
32345 <p>c</p>
32346
32347 </section><section data-mw-section-id="-1"><h1 id="2">2</h1>
32348 <p>d</p>
32349 </section></div>
32350 <p>e</p>
32351
32352 </section><section data-mw-section-id="4"><h1 id="3">3</h1>
32353 <p>f</p>
32354
32355 <section data-mw-section-id="5"><h2 id="3.1">3.1</h2>
32356 <p>g</p>
32357 </section></section>
32358 !! end
32359
32360 !! test
32361 HTML header tags should not be wrapped in section tags
32362 !! options
32363 parsoid={
32364 "wrapSections": true
32365 }
32366 !! wikitext
32367 foo
32368
32369 <h1>a</h1>
32370
32371 =b=
32372
32373 <h1>c</h1>
32374
32375 =d=
32376 !! html/parsoid
32377 <section data-mw-section-id="0"><p>foo</p>
32378
32379 <h1 id="a" data-parsoid='{"stx":"html"}'>a</h1>
32380
32381 </section><section data-mw-section-id="1"><h1 id="b">b</h1>
32382
32383 <h1 id="c" data-parsoid='{"stx":"html"}'>c</h1>
32384
32385 </section><section data-mw-section-id="2"><h1 id="d">d</h1></section>
32386 !! end
32387
32388 !! test
32389 Lead section containing only whitespace and comments.
32390 !! options
32391 parsoid={
32392 "wrapSections": true
32393 }
32394 !! wikitext
32395
32396 <!-- this is a comment, presumably significant to editors -->
32397 =1=
32398 a
32399
32400 =2=
32401 b
32402 !! html/parsoid
32403 <section data-mw-section-id="0" data-parsoid="{}">
32404 <!-- this is a comment, presumably significant to editors -->
32405 </section><section data-mw-section-id="1"><h1 id="1">1</h1>
32406 <p>a</p>
32407
32408 </section><section data-mw-section-id="2"><h1 id="2">2</h1>
32409 <p>b</p></section>
32410 !! end
32411
32412 !! test
32413 Pseudo-sections emitted by templates should have id -2
32414 !! options
32415 parsoid={
32416 "wrapSections": true
32417 }
32418 !! wikitext
32419 foo
32420 {{echo|<div>
32421 ==a==
32422 ==b==
32423 </div>
32424 }}
32425 !! html/parsoid
32426 <section data-mw-section-id="-1"><p>foo</p>
32427 </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}}]}'>
32428 <section data-mw-section-id="-1"><h2 id="a">a</h2>
32429 </section><section data-mw-section-id="-1"><h2 id="b">b</h2>
32430 </section></div><span about="#mwt1">
32431 </span></section>
32432 !! end
32433
32434 ##########################################################################
32435 Tests demonstrating white-space insensitivity in input wikitext
32436 for wikitext headings, wikitext list items, and wikitext table captions,
32437 headings, and cells. HTML versions of the same should preserve whitespace.
32438 ##########################################################################
32439 !! test
32440 Trim whitespace in wikitext headings, list items, table captions, headings, and cells
32441 !! options
32442 parsoid={
32443 "modes": ["wt2html"],
32444 "preserveIEW": true
32445 }
32446 !! wikitext
32447 __NOTOC__
32448 == <!--c1--> <!--c2--> Spaces <!--c3--> <!--c4--> ==
32449 == <!--c1--> <!--c2--> Tabs <!--c3--><!--c4--> ==
32450 == <!--Headings with fallback ids--> Личная жизнь ==
32451 * <!--c1--> <!--c2--> List item <!--c3--> <!--c4-->
32452 ; <!--term to define--> term : <!--term's definition--> definition
32453 {|
32454 |+ <!--c1--> <!--c2--> Table Caption <!--c3--> <!--c4-->
32455 |-
32456 ! <!--c1--> <!--c2--> Table Heading 1 <!--c3--> <!--c4--> !! Table Heading 2 <!--c5-->
32457 |-
32458 | <!--c1--> <!--c2--> Table Cell 1 <!--c3--> <!--c4--> || Table Cell 2 <!--c5-->
32459 |-
32460 | class="foo" || <!--c1--> <!--c2--> Table Cell 3 <!--c3--> <!--c4-->
32461 |-
32462 | <!--c1--> testing [[one|two]] <!--c2--> | <!--c3--> some content
32463 |}
32464 : {|
32465 | <!--c1--> <!--c2--> Table Cell 1 <!--c3--> <!--c4--> || Table Cell 2 <!--c5-->
32466 |} foo <!--c1-->
32467 !! html/php+tidy
32468 <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>
32469 <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>
32470 <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>
32471 <ul><li>List item</li></ul>
32472 <dl><dt>term&#160;</dt>
32473 <dd>definition</dd></dl>
32474 <table>
32475 <caption>Table Caption
32476 </caption>
32477 <tbody><tr>
32478 <th>Table Heading 1</th>
32479 <th>Table Heading 2
32480 </th></tr>
32481 <tr>
32482 <td>Table Cell 1</td>
32483 <td>Table Cell 2
32484 </td></tr>
32485 <tr>
32486 <td>class="foo"</td>
32487 <td>Table Cell 3
32488 </td></tr>
32489 <tr>
32490 <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
32491 </td></tr></tbody></table>
32492 <dl><dd><table>
32493 <tbody><tr>
32494 <td>Table Cell 1</td>
32495 <td>Table Cell 2
32496 </td></tr></tbody></table> foo</dd></dl>
32497 !! html/parsoid
32498 <meta property="mw:PageProp/notoc">
32499 <h2 id="Spaces"><!--c1--><!--c2-->Spaces<!--c3--><!--c4--></h2>
32500 <h2 id="Tabs"><!--c1--><!--c2-->Tabs<!--c3--><!--c4--></h2>
32501 <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>
32502 <ul><li><!--c1--><!--c2-->List item<!--c3--><!--c4--></li></ul>
32503 <dl><dt><!--term to define-->term&nbsp;</dt><dd><!--term's definition-->definition</dd></dl>
32504 <table>
32505 <caption><!--c1--><!--c2-->Table Caption<!--c3--><!--c4--></caption>
32506 <tbody><tr>
32507 <th><!--c1--><!--c2-->Table Heading 1<!--c3--><!--c4--></th><th>Table Heading 2<!--c5--></th></tr>
32508 <tr>
32509 <td><!--c1--><!--c2-->Table Cell 1<!--c3--><!--c4--></td><td>Table Cell 2<!--c5--></td></tr>
32510 <tr>
32511 <td>class="foo"</td><td><!--c1--><!--c2-->Table Cell 3<!--c3--><!--c4--></td></tr>
32512 <tr>
32513 <td><!--c1-->testing <a rel="mw:WikiLink" href="./One" title="One">two</a> <!--c2--> | <!--c3--> some content</td></tr>
32514 </tbody></table>
32515 <dl><dd><table>
32516 <tbody><tr><td><!--c1--><!--c2-->Table Cell 1<!--c3--><!--c4--></td><td>Table Cell 2<!--c5--></td></tr>
32517 </tbody></table> foo<!--c1--></dd></dl>
32518 !! end
32519
32520 # Looks like <caption> is not accepted in HTML
32521 !! test
32522 Do not trim whitespace in HTML headings, list items, table captions, headings, and cells
32523 !! options
32524 parsoid={
32525 "modes": ["wt2html"],
32526 "preserveIEW": true
32527 }
32528 !! wikitext
32529 __NOTOC__
32530 <h2> <!--c1--> <!--c2--> Heading <!--c3--> <!--c4--> </h2>
32531 <ul><li> <!--c1--> <!--c2--> List item <!--c3--> <!--c4--> </li></ul>
32532 <table>
32533 <tr><th> <!--c1--> <!--c2--> Table Heading <!--c3--> <!--c4--> <th></tr>
32534 <tr><td> <!--c1--> <!--c2--> Table Cell <!--c3--> <!--c4--> <th></tr>
32535 </table>
32536 !! html/php+tidy
32537 <h2><span class="mw-headline" id="Heading"> Heading </span></h2>
32538 <ul><li> List item </li></ul>
32539 <table>
32540 <tbody><tr><th> Table Heading </th><th></th></tr>
32541 <tr><td> Table Cell </td><th></th></tr>
32542 </tbody></table>
32543 !! html/parsoid
32544 <meta property="mw:PageProp/notoc"/>
32545 <h2 id="Heading"> <!--c1--> <!--c2--> Heading <!--c3--> <!--c4--> </h2>
32546 <ul><li> <!--c1--> <!--c2--> List item <!--c3--> <!--c4--> </li></ul>
32547 <table>
32548 <tbody><tr><th> <!--c1--> <!--c2--> Table Heading <!--c3--> <!--c4--> </th><th></th></tr>
32549 <tr><td> <!--c1--> <!--c2--> Table Cell <!--c3--> <!--c4--> </td><th></th></tr>
32550 </tbody></table>
32551 !! end
32552
32553 !! test
32554 Do not trim whitespace in links and quotes
32555 !! options
32556 parsoid={
32557 "modes": ["wt2html"],
32558 "preserveIEW": true
32559 }
32560 !! wikitext
32561 foo '' <!--c1--> italic <!--c2--> '' and ''' <!--c3--> bold <!--c4--> '''
32562 [[Foo| some text ]]
32563 !! html/php+tidy
32564 <p>foo <i> italic </i> and <b> bold </b>
32565 <a href="/wiki/Foo" title="Foo"> some text </a>
32566 </p>
32567 !! html/parsoid
32568 <p>foo <i> <!--c1--> italic <!--c2--> </i> and <b> <!--c3--> bold <!--c4--> </b>
32569 <a rel="mw:WikiLink" href="./Foo" title="Foo"> some text </a></p>
32570 !! end
32571
32572 !! test
32573 Remove p tags surrounding a single element in a figcaption
32574 !! options
32575 parsoid=html2wt
32576 !! wikitext
32577 [[File:Foobar.jpg|right|200x200px|Caption]]
32578 !! html/parsoid
32579 <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>
32580 !! end
32581
32582 !! test
32583 Selser preserves lack of newline before list and allows newline after the list
32584 !! options
32585 parsoid={
32586 "modes": ["selser"],
32587 "scrubWikitext": true,
32588 "changes": [
32589 [ "ul", "after", "<p>footer</p>" ]
32590 ]
32591 }
32592 !! wikitext
32593 header
32594 *foo
32595 *bar
32596 !! wikitext/edited
32597 header
32598 *foo
32599 *bar
32600
32601 footer
32602 !! end
32603
32604
32605 !! test
32606 Selser does not introduce newlines between unedited paragraph preceding the list
32607 !! options
32608 parsoid={
32609 "modes": ["selser"],
32610 "changes": [
32611 [ "table tbody tr td p:last-child", "empty" ]
32612 ]
32613 }
32614 !! wikitext
32615 {|
32616 |
32617 header
32618 *foo
32619 *bar
32620 footer
32621 |}
32622 !! wikitext/edited
32623 {|
32624 |
32625 header
32626 *foo
32627 *bar
32628
32629 |}
32630 !! end
32631
32632 !! test
32633 Selser does not introduce newlines between unedited paragraph following the list
32634 !! options
32635 parsoid={
32636 "modes": ["selser"],
32637 "changes": [
32638 [ "table tbody tr td p:first-child", "empty" ]
32639 ]
32640 }
32641 !! wikitext
32642 {|
32643 |
32644 header
32645 *foo
32646 *bar
32647 footer
32648 |}
32649 !! wikitext/edited
32650 {|
32651 |
32652
32653 *foo
32654 *bar
32655 footer
32656 |}
32657 !! end
32658
32659 !! test
32660 Remove a list item but do not insert newline above list
32661 !! options
32662 parsoid={
32663 "modes": ["selser"],
32664 "changes": [
32665 [ "ul li:last-child", "remove" ]
32666 ]
32667 }
32668 !! wikitext
32669 header
32670 *foo
32671 *bar
32672 footer
32673 !! wikitext/edited
32674 header
32675 *foo
32676 footer
32677 !! end